inline bool has_zero_byte(unsigned int x)
{
    return ((x - 0x01010101) & ~x & 0x80808080) != 0;
}

static const char table[16] = {
    4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };

inline int get_nth_zero(unsigned x)
{
    unsigned int y;

    y = (x & 0x7F7F7F7F) + 0x7F7F7F7F;
    y = ~(y | x | 0x7F7F7F7F);
    return table[y * 0x00204081 >> 28];
}

#define METHOD 1
#if METHOD == 1
size_t strlen_ex(char* s)
{
    auto word = (unsigned int*)s;
    while (!has_zero_byte(*word))
        ++word;

    return ((char*) word) - s + get_nth_zero(*word);
}
#elif METHOD == 2
size_t strlen_ex(char* s)
{
    auto word = (unsigned int*) s;
    while (!has_zero_byte(*word++));
    auto byte = (char*) word;

    if (!byte[-4]) return byte - s - 4;
    if (!byte[-3]) return byte - s - 3;
    if (!byte[-2]) return byte - s - 2;
    return byte - s - 1;
}
#endif