// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testb $0x3, %dil
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
leaq 0x57a24(%rip), %r9      # 0xced30
jne 0x7733f
leaq 0x1(%rdi), %rdx
xorl %eax, %eax
movq %rsi, %r8
movq %rax, %rsi
movzbl (%rdi), %eax
incq %rdi
movzbl (%rax,%r9), %eax
addq %rsi, %rax
leaq -0x1(%r8), %rsi
testb $0x3, %dl
je 0x77341
incq %rdx
cmpq $0x1, %r8
movq %rsi, %r8
jne 0x77317
jmp 0x77341
xorl %eax, %eax
cmpq $0x1c, %rsi
jl 0x774c0
movl $0x55555555, %edx       # imm = 0x55555555
movl $0x33333333, %r8d       # imm = 0x33333333
movl $0xf0f0f0f, %r9d        # imm = 0xF0F0F0F
movq %rsi, %r10
movl (%rdi), %ecx
movl 0x4(%rdi), %r12d
movl 0x8(%rdi), %r15d
movl 0xc(%rdi), %r14d
movl 0x10(%rdi), %ebp
movl 0x14(%rdi), %ebx
movl 0x18(%rdi), %r11d
addq $0x1c, %rdi
addq $-0x1c, %rsi
movl %ecx, %r13d
shrl %r13d
andl %edx, %r13d
subl %r13d, %ecx
movl %ecx, %r13d
andl %r8d, %r13d
shrl $0x2, %ecx
andl %r8d, %ecx
addl %r13d, %ecx
movl %r12d, %r13d
shrl %r13d
andl %edx, %r13d
subl %r13d, %r12d
movl %r12d, %r13d
andl %r8d, %r13d
shrl $0x2, %r12d
andl %r8d, %r12d
addl %r13d, %r12d
movl %r15d, %r13d
shrl %r13d
andl %edx, %r13d
subl %r13d, %r15d
movl %r15d, %r13d
andl %r8d, %r13d
shrl $0x2, %r15d
andl %r8d, %r15d
addl %r13d, %r15d
movl %r14d, %r13d
shrl %r13d
andl %edx, %r13d
subl %r13d, %r14d
movl %r14d, %r13d
andl %r8d, %r13d
shrl $0x2, %r14d
andl %r8d, %r14d
addl %r13d, %r14d
movl %ebp, %r13d
shrl %r13d
andl %edx, %r13d
subl %r13d, %ebp
movl %ebp, %r13d
andl %r8d, %r13d
shrl $0x2, %ebp
andl %r8d, %ebp
addl %r13d, %ebp
movl %ebx, %r13d
shrl %r13d
andl %edx, %r13d
subl %r13d, %ebx
movl %ebx, %r13d
andl %r8d, %r13d
shrl $0x2, %ebx
andl %r8d, %ebx
addl %r13d, %ebx
movl %r11d, %r13d
shrl %r13d
andl %edx, %r13d
subl %r13d, %r11d
movl %r11d, %r13d
andl %r8d, %r13d
shrl $0x2, %r11d
andl %r8d, %r11d
addl %r13d, %r11d
movl %ecx, %r13d
shrl $0x4, %r13d
addl %ecx, %r13d
andl %r9d, %r13d
movl %r12d, %ecx
shrl $0x4, %ecx
addl %r12d, %ecx
andl %r9d, %ecx
addl %r13d, %ecx
movl %r15d, %r12d
shrl $0x4, %r12d
addl %r15d, %r12d
andl %r9d, %r12d
movl %r14d, %r15d
shrl $0x4, %r15d
addl %r14d, %r15d
andl %r9d, %r15d
addl %r12d, %r15d
addl %ecx, %r15d
movl %ebp, %ecx
shrl $0x4, %ecx
addl %ebp, %ecx
andl %r9d, %ecx
movl %ebx, %ebp
shrl $0x4, %ebp
addl %ebx, %ebp
andl %r9d, %ebp
addl %ecx, %ebp
movl %r11d, %ecx
shrl $0x4, %ecx
addl %r11d, %ecx
andl %r9d, %ecx
addl %ebp, %ecx
addl %r15d, %ecx
imull $0x1010101, %ecx, %ecx  # imm = 0x1010101
shrl $0x18, %ecx
addq %rcx, %rax
cmpq $0x37, %r10
jg 0x7735c
leaq 0x57870(%rip), %r9      # 0xced30
testq %rsi, %rsi
je 0x774db
xorl %edx, %edx
movzbl (%rdi,%rdx), %ecx
movzbl (%rcx,%r9), %ecx
addq %rcx, %rax
incq %rdx
cmpq %rdx, %rsi
jne 0x774c7
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq