<commit_before>/**
 * @file   string.c
 * @author <NAME> \<<EMAIL>\>
 *
 * @date Created on Thursday, October 11th 2018, 8:57:33 am
 *
 * @date Last modified by:   <NAME>
 * @date Last modified time: 2018-10-27T19:50:19-04:00
 */

#include "string.h"

EXPORT_SYMBOL(memcmp);
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(memset);
EXPORT_SYMBOL(memmove);
EXPORT_SYMBOL(strcat);
EXPORT_SYMBOL(strcpy);
EXPORT_SYMBOL(strdup);
EXPORT_SYMBOL(strcmp);
EXPORT_SYMBOL(strlen);
EXPORT_SYMBOL(strncmp);

int memcmp(const void* buf1, const void* buf2, size_t len)
{
    const unsigned char* p1 = buf1, * p2 = buf2;
    while (len--)
        if (*p1 != *p2)
            return *p1 - *p2;
        else
            p1++, p2++;
    return 0;
}

void* memcpy(void* dest, const void* src, size_t len)
{
    #if ARCH_TYPE == ARCH_x86_32
        asm volatile ("rep movsb"
                      :
                      : "D" (dest), "S" (src), "c" (len)
                      : "memory");
        return dest;
    #else
        char* d = dest;
        const char* s = src;
        while (len--)
            *d++ = *s++;
        return dest;
    #endif
}

void* memset(void* dest, int c, size_t len)
{
    /*#if ARCH_TYPE == ARCH_x86_32
        asm volatile ("rep stosb"
                      :
                      : "a" (c), "D" (dest), "c" (len)
                      : "memory");
        return src;
    #else*/
        unsigned char* ptr = dest;
        while (len-- > 0)
            *ptr++ = c;
        return dest;
    //#endif
}

void* memmove(void* dest, void* src, size_t len)
{
    char* d = dest;
    char* s = src;
    if (d < s)
        while (len--)
            *d++ = *s++;
    else
    {
        char* lasts = s + (len - 1);
        char* lastd = d + (len - 1);
        while (len--)
            *lastd-- = *lasts--;
    }
    return dest;<commit_msg>Reverted memset.<commit_after>/**
 * @file   string.c
 * @author <NAME> \<<EMAIL>\>
 *
 * @date Created on Thursday, October 11th 2018, 8:57:33 am
 *
 * @date Last modified by:   <NAME>
 * @date Last modified time: 2018-10-27T19:50:19-04:00
 */

#include "string.h"

EXPORT_SYMBOL(memcmp);
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(memset);
EXPORT_SYMBOL(memmove);
EXPORT_SYMBOL(strcat);
EXPORT_SYMBOL(strcpy);
EXPORT_SYMBOL(strdup);
EXPORT_SYMBOL(strcmp);
EXPORT_SYMBOL(strlen);
EXPORT_SYMBOL(strncmp);

int memcmp(const void* buf1, const void* buf2, size_t len)
{
    const unsigned char* p1 = buf1, * p2 = buf2;
    while (len--)
        if (*p1 != *p2)
            return *p1 - *p2;
        else
            p1++, p2++;
    return 0;
}

void* memcpy(void* dest, const void* src, size_t len)
{
    #if ARCH_TYPE == ARCH_x86_32
        asm volatile ("rep movsb"
                      :
                      : "D" (dest), "S" (src), "c" (len)
                      : "memory");
        return dest;
    #else
        char* d = dest;
        const char* s = src;
        while (len--)
            *d++ = *s++;
        return dest;
    #endif
}

void* memset(void* dest, int c, size_t len)
{
    #if ARCH_TYPE == ARCH_x86_32
        asm volatile ("rep stosb"
                      :
                      : "a" (c), "D" (dest), "c" (len)
                      : "memory");
        return dest;
    #else
        unsigned char* ptr = dest;
        while (len-- > 0)
            *ptr++ = c;
        return dest;
    #endif
}

void* memmove(void* dest, void* src, size_t len)
{
    char* d = dest;
    char* s = src;
    if (d < s)
        while (len--)
            *d++ = *s++;
    else
    {
        char* lasts = s + (len - 1);
        char* lastd = d + (len - 1);
        while (len--)
            *lastd-- = *lasts--;
    }
    return dest;
{'fraction_non_alphanumeric': 0.15424374319912948, 'fraction_numerical': 0.02883569096844396, 'mean_word_length': 1.7216876387860844, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4693411', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1298, 'n_words': 356}