<commit_before>#include <stdlib.h>
#include <ctype.h>
#include <string.h>

void *memccpy(void *dest, const void *src, int c, size_t num) {
	char* d = (char*)dest;
	char* s = (char*)src;
	while ((*d = *s) != (char)c && num > 0) {
		d++;
		s++;
		num--;
	}

	return num == 0 ? NULL : (void*)(++d);
}

void *memchr(const void *ptr, int c, size_t n) {
	char* s = (char*)ptr;
	while (*s != (char)c && n > 0) {
		s++;
		n--;
	}

	return n == 0 ? NULL : (void*)s;
}

// Syscall is broken. It's sys_memcmp if you prefer.
int memcmp(const void* s1, const void* s2, unsigned int n) {
	const unsigned char *p1 = s1, *p2 = s2;
	while(n--)
		if( *p1 != *p2 )
			return *p1 - *p2;
		else
			p1++,p2++;
	return 0;
}

// GCC builtin
/*
void* memcpy(void* destination, const void* source, size_t num) {
	char* d = (char*)destination;
	char* s = (char*)source;
	while (num-- > 0) {
		*d = *s;
		d++;
		s++;
	}

	return destination;
}
*/

// TODO extremely inefficient and generally bad.
void* memmove(void* destination, const void* source, size_t num) {
	void* d = malloc(num);
	memcpy(d, source, num);
	memcpy(destination, d, num);
	free(d);
	return destination;
}

char *strcat(char *dest, const char *src) {
	char* ret = dest;
	dest += strlen(dest);
	strcpy(dest, src);
	return ret;
}

char *strchr(const char *s, int c) {
	while (*s != (char)c) {
		if (*s == 0)
			return NULL;
		s++;
	}
	return (char *)s;
}

int strcmp(const char *s1, const char *s2) {
	while (*s1 != 0 && *s2 != 0) {
		if (*s1 != *s2)
			break;
		s1++;
		s2++;<commit_msg>Bring back memset.<commit_after>#include <stdlib.h>
#include <ctype.h>
#include <string.h>

void *memccpy(void *dest, const void *src, int c, size_t num) {
	char* d = (char*)dest;
	char* s = (char*)src;
	while ((*d = *s) != (char)c && num > 0) {
		d++;
		s++;
		num--;
	}

	return num == 0 ? NULL : (void*)(++d);
}

void *memchr(const void *ptr, int c, size_t n) {
	char* s = (char*)ptr;
	while (*s != (char)c && n > 0) {
		s++;
		n--;
	}

	return n == 0 ? NULL : (void*)s;
}

// Syscall is broken. It's sys_memcmp if you prefer.
int memcmp(const void* s1, const void* s2, unsigned int n) {
	const unsigned char *p1 = s1, *p2 = s2;
	while(n--)
		if( *p1 != *p2 )
			return *p1 - *p2;
		else
			p1++,p2++;
	return 0;
}

// GCC builtin
/*
void* memcpy(void* destination, const void* source, size_t num) {
	char* d = (char*)destination;
	char* s = (char*)source;
	while (num-- > 0) {
		*d = *s;
		d++;
		s++;
	}

	return destination;
}
*/

// TODO extremely inefficient and generally bad.
void* memmove(void* destination, const void* source, size_t num) {
	void* d = malloc(num);
	memcpy(d, source, num);
	memcpy(destination, d, num);
	free(d);
	return destination;
}

void *memset(void *dest, int c, unsigned int n) {
    char* d = (char*)dest;
    while (n-- > 0) { *d++ = (char)c; }

    return dest;
}

char *strcat(char *dest, const char *src) {
	char* ret = dest;
	dest += strlen(dest);
	strcpy(dest, src);
	return ret;
}

char *strchr(const char *s, int c) {
	while (*s != (char)c) {
		if (*s == 0)
			return NULL;
		s++;
	}
	return (char *)s;
}

int strcmp(const char *s1, const char *s2) {
	while (*s1 != 0 && *s2 != 0) {
		if (*s1 != *s2)
			break;
		s1++;
		s2++;
{'fraction_non_alphanumeric': 0.2031884964051266, 'fraction_numerical': 0.018443263519849953, 'mean_word_length': 3.129032258064516, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7078090', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1348, 'n_words': 413}