#include #include #include #define HIGHS(x) ((x) - ((x)*0-1) / 255 * 128) #define LOWS(x) (((x)*0-1) / 255) #define has_zero(x) ((x) - LOWS(x) & ~(x) & HIGHS(x)) #undef strcmp int strcmp(const char *l, const char *r) { const size_t *wl; const size_t *wr; if ((uintptr_t)l % sizeof(size_t) != (uintptr_t)r % sizeof(size_t)) goto bytewise; for (; (uintptr_t)l % sizeof(size_t); l++, r++) { if (*l != *r || !*l || !*r) { return *(unsigned char *)l - *(unsigned char *)r; } } for (wl = (const size_t *)l, wr = (const size_t *)r ; has_zero(*wl) || has_zero(*wr) && *wl == *wr ; wl++, wr++); l = (const char *)wl; r = (const char *)wr; bytewise: for(; *l == *r && *l && *r; l++, r++); return *(unsigned char *)l - *(unsigned char *)r; }