#include <string.h>

#undef memset
void *memset(void *s, int c, size_t count)
{
	unsigned int reg;
    int edi;
	__asm__ __volatile__(
		"	mov	%%ecx, %1\n"
		"	shr	$3, %%rcx\n"
		"	movzx	%%al, %%eax\n" /* 3 bytes */
	    "   movabs	$0x0101010101010101,%%r8 \n"
	    "   imul	%%r8, %%rax\n"
		/* fill full words */
		"	rep; stosq\n"
		/* fill 0-3 bytes */
		"   and	$7, %1\n"
		"	mov	%1, %%ecx\n"
		"   rep; stosb\n"
		: "=&D" (edi), "=&r" (reg)
		: "0" (s), "a" (c), "c" (count)
		: "memory"
	);
	return s;
}

