// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/bitops.c
// Function: redisPopcount
size_t redisPopcount(void *s, long count) {
    size_t bits = 0;
    unsigned char *p = s;
    uint32_t *p4;
    static const unsigned char bitsinbyte[256] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8};

    /* Count initial bytes not aligned to 32 bit. */
    while((unsigned long)p & 3 && count) {
        bits += bitsinbyte[*p++];
        count--;
    }

    /* Count bits 28 bytes at a time */
    p4 = (uint32_t*)p;
    while(count>=28) {
        uint32_t aux1, aux2, aux3, aux4, aux5, aux6, aux7;

        aux1 = *p4++;
        aux2 = *p4++;
        aux3 = *p4++;
        aux4 = *p4++;
        aux5 = *p4++;
        aux6 = *p4++;
        aux7 = *p4++;
        count -= 28;

        aux1 = aux1 - ((aux1 >> 1) & 0x55555555);
        aux1 = (aux1 & 0x33333333) + ((aux1 >> 2) & 0x33333333);
        aux2 = aux2 - ((aux2 >> 1) & 0x55555555);
        aux2 = (aux2 & 0x33333333) + ((aux2 >> 2) & 0x33333333);
        aux3 = aux3 - ((aux3 >> 1) & 0x55555555);
        aux3 = (aux3 & 0x33333333) + ((aux3 >> 2) & 0x33333333);
        aux4 = aux4 - ((aux4 >> 1) & 0x55555555);
        aux4 = (aux4 & 0x33333333) + ((aux4 >> 2) & 0x33333333);
        aux5 = aux5 - ((aux5 >> 1) & 0x55555555);
        aux5 = (aux5 & 0x33333333) + ((aux5 >> 2) & 0x33333333);
        aux6 = aux6 - ((aux6 >> 1) & 0x55555555);
        aux6 = (aux6 & 0x33333333) + ((aux6 >> 2) & 0x33333333);
        aux7 = aux7 - ((aux7 >> 1) & 0x55555555);
        aux7 = (aux7 & 0x33333333) + ((aux7 >> 2) & 0x33333333);
        bits += ((((aux1 + (aux1 >> 4)) & 0x0F0F0F0F) +
                    ((aux2 + (aux2 >> 4)) & 0x0F0F0F0F) +
                    ((aux3 + (aux3 >> 4)) & 0x0F0F0F0F) +
                    ((aux4 + (aux4 >> 4)) & 0x0F0F0F0F) +
                    ((aux5 + (aux5 >> 4)) & 0x0F0F0F0F) +
                    ((aux6 + (aux6 >> 4)) & 0x0F0F0F0F) +
                    ((aux7 + (aux7 >> 4)) & 0x0F0F0F0F))* 0x01010101) >> 24;
    }
    /* Count the remaining bytes. */
    p = (unsigned char*)p4;
    while(count--) bits += bitsinbyte[*p++];
    return bits;
}

// Assembly:
testb $0x3, %dil
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
leaq 0x585aa(%rip), %rcx     # 0xcbe30
jne 0x738b8
leaq 0x1(%rdi), %rdx
xorl %eax, %eax
movq %rsi, %r8
movq %rax, %rsi
movzbl (%rdi), %eax
incq %rdi
movzbl (%rax,%rcx), %eax
addq %rsi, %rax
leaq -0x1(%r8), %rsi
testb $0x3, %dl
je 0x738ba
incq %rdx
cmpq $0x1, %r8
movq %rsi, %r8
jne 0x73891
jmp 0x738ba
xorl %eax, %eax
cmpq $0x1c, %rsi
jl 0x73a04
movl $0x33333333, %r9d       # imm = 0x33333333
movdqa 0x5849e(%rip), %xmm0    # 0xcbd70
movdqa 0x584a6(%rip), %xmm1    # 0xcbd80
movdqa 0x584ae(%rip), %xmm2    # 0xcbd90
movdqa 0x584b6(%rip), %xmm3    # 0xcbda0
movdqa 0x584be(%rip), %xmm4    # 0xcbdb0
movdqa 0x584c6(%rip), %xmm5    # 0xcbdc0
movl 0x10(%rdi), %r10d
leaq 0x1c(%rdi), %rdx
leaq -0x1c(%rsi), %r8
movl %r10d, %r11d
shrl %r11d
andl $0x55555555, %r11d      # imm = 0x55555555
subl %r11d, %r10d
movl %r10d, %r11d
andl %r9d, %r11d
shrl $0x2, %r10d
andl %r9d, %r10d
addl %r11d, %r10d
movdqu (%rdi), %xmm7
movdqa %xmm7, %xmm6
psrld $0x1, %xmm6
pand %xmm0, %xmm6
psubd %xmm6, %xmm7
movdqa %xmm7, %xmm6
pand %xmm1, %xmm6
psrld $0x2, %xmm7
pand %xmm1, %xmm7
paddd %xmm6, %xmm7
movdqa %xmm7, %xmm6
psrld $0x4, %xmm6
paddd %xmm7, %xmm6
pand %xmm2, %xmm6
movl %r10d, %r11d
shrl $0x4, %r11d
addl %r10d, %r11d
andl $0xf0f0f0f, %r11d       # imm = 0xF0F0F0F
movq 0x14(%rdi), %xmm7
movdqa %xmm7, %xmm8
psrld $0x1, %xmm8
pand %xmm3, %xmm8
psubd %xmm8, %xmm7
movdqa %xmm7, %xmm8
pand %xmm4, %xmm8
psrld $0x2, %xmm7
pand %xmm4, %xmm7
paddd %xmm8, %xmm7
movdqa %xmm7, %xmm8
psrld $0x4, %xmm8
paddd %xmm7, %xmm8
pand %xmm5, %xmm8
pshufd $0xee, %xmm6, %xmm7     # xmm7 = xmm6[2,3,2,3]
paddd %xmm6, %xmm7
pshufd $0x55, %xmm7, %xmm6     # xmm6 = xmm7[1,1,1,1]
paddd %xmm7, %xmm6
movd %xmm6, %edi
pshufd $0x55, %xmm8, %xmm6     # xmm6 = xmm8[1,1,1,1]
paddd %xmm8, %xmm6
movd %xmm6, %r10d
addl %r11d, %r10d
addl %edi, %r10d
imull $0x1010101, %r10d, %edi # imm = 0x1010101
shrl $0x18, %edi
addq %rdi, %rax
movq %rdx, %rdi
cmpq $0x37, %rsi
movq %r8, %rsi
ja 0x738fa
jmp 0x73a0a
movq %rdi, %rdx
movq %rsi, %r8
testq %r8, %r8
je 0x73a24
xorl %esi, %esi
movzbl (%rdx,%rsi), %edi
movzbl (%rdi,%rcx), %edi
addq %rdi, %rax
incq %rsi
cmpq %rsi, %r8
jne 0x73a11
retq