5 void *memcpy(void *restrict dest, const void *restrict src, size_t n)
7 unsigned char *d = dest;
8 const unsigned char *s = src;
12 #if __BYTE_ORDER == __LITTLE_ENDIAN
20 typedef uint32_t __attribute__((__may_alias__)) u32;
23 for (; (uintptr_t)s % 4 && n; n--) *d++ = *s++;
25 if ((uintptr_t)d % 4 == 0) {
26 for (; n>=16; s+=16, d+=16, n-=16) {
27 *(u32 *)(d+0) = *(u32 *)(s+0);
28 *(u32 *)(d+4) = *(u32 *)(s+4);
29 *(u32 *)(d+8) = *(u32 *)(s+8);
30 *(u32 *)(d+12) = *(u32 *)(s+12);
33 *(u32 *)(d+0) = *(u32 *)(s+0);
34 *(u32 *)(d+4) = *(u32 *)(s+4);
38 *(u32 *)(d+0) = *(u32 *)(s+0);
42 *d++ = *s++; *d++ = *s++;
50 if (n >= 32) switch ((uintptr_t)d % 4) {
57 for (; n>=17; s+=16, d+=16, n-=16) {
59 *(u32 *)(d+0) = (w LS 24) | (x RS 8);
61 *(u32 *)(d+4) = (x LS 24) | (w RS 8);
63 *(u32 *)(d+8) = (w LS 24) | (x RS 8);
65 *(u32 *)(d+12) = (x LS 24) | (w RS 8);
73 for (; n>=18; s+=16, d+=16, n-=16) {
75 *(u32 *)(d+0) = (w LS 16) | (x RS 16);
77 *(u32 *)(d+4) = (x LS 16) | (w RS 16);
79 *(u32 *)(d+8) = (w LS 16) | (x RS 16);
81 *(u32 *)(d+12) = (x LS 16) | (w RS 16);
88 for (; n>=19; s+=16, d+=16, n-=16) {
90 *(u32 *)(d+0) = (w LS 8) | (x RS 24);
92 *(u32 *)(d+4) = (x LS 8) | (w RS 24);
94 *(u32 *)(d+8) = (w LS 8) | (x RS 24);
96 *(u32 *)(d+12) = (x LS 8) | (w RS 24);
101 *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
102 *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
103 *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
104 *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
107 *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
108 *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
111 *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
114 *d++ = *s++; *d++ = *s++;
122 for (; n; n--) *d++ = *s++;