// File: /workspace/github_c_makefile_star2_O2/FastFilter[P]BlockBloomSimulator/src/bitset.c
// Function: bitset_count
size_t bitset_count(const bitset_t *bitset) {
    size_t card = 0;
    size_t k = 0;
    // assumes that long long is 8 bytes
    for(; k + 7 < bitset->arraysize; k+=8) {
        card += __builtin_popcountll(bitset->array[k]);
        card += __builtin_popcountll(bitset->array[k+1]);
        card += __builtin_popcountll(bitset->array[k+2]);
        card += __builtin_popcountll(bitset->array[k+3]);
        card += __builtin_popcountll(bitset->array[k+4]);
        card += __builtin_popcountll(bitset->array[k+5]);
        card += __builtin_popcountll(bitset->array[k+6]);
        card += __builtin_popcountll(bitset->array[k+7]);
    }
    for(; k + 3 < bitset->arraysize; k+=4) {
        card += __builtin_popcountll(bitset->array[k]);
        card += __builtin_popcountll(bitset->array[k+1]);
        card += __builtin_popcountll(bitset->array[k+2]);
        card += __builtin_popcountll(bitset->array[k+3]);
    }
    for(; k < bitset->arraysize; k++) {
        card += __builtin_popcountll(bitset->array[k]);
    }
    return card;
}

// Assembly:
pushq %rbx
movq 0x8(%rdi), %rcx
xorl %eax, %eax
movdqa 0x1e0f(%rip), %xmm0     # 0x4590
movdqa 0x1e17(%rip), %xmm1     # 0x45a0
movdqa 0x1e1f(%rip), %xmm2     # 0x45b0
pxor %xmm3, %xmm3
xorl %edx, %edx
leaq 0x7(%rdx), %rsi
cmpq %rcx, %rsi
jae 0x28d0
movq (%rdi), %rsi
movdqu (%rsi,%rdx,8), %xmm7
movdqu 0x10(%rsi,%rdx,8), %xmm4
movdqu 0x20(%rsi,%rdx,8), %xmm6
movdqu 0x30(%rsi,%rdx,8), %xmm5
movdqa %xmm6, %xmm8
psrlw $0x1, %xmm8
pand %xmm0, %xmm8
psubb %xmm8, %xmm6
movdqa %xmm6, %xmm8
pand %xmm1, %xmm8
psrlw $0x2, %xmm6
pand %xmm1, %xmm6
paddb %xmm8, %xmm6
movdqa %xmm6, %xmm8
psrlw $0x4, %xmm8
paddb %xmm6, %xmm8
pand %xmm2, %xmm8
movdqa %xmm7, %xmm6
psrlw $0x1, %xmm6
pand %xmm0, %xmm6
psubb %xmm6, %xmm7
movdqa %xmm7, %xmm6
pand %xmm1, %xmm6
psrlw $0x2, %xmm7
pand %xmm1, %xmm7
paddb %xmm6, %xmm7
movdqa %xmm7, %xmm6
psrlw $0x4, %xmm6
paddb %xmm7, %xmm6
pand %xmm2, %xmm6
paddb %xmm8, %xmm6
movdqa %xmm5, %xmm7
psrlw $0x1, %xmm7
pand %xmm0, %xmm7
psubb %xmm7, %xmm5
movdqa %xmm5, %xmm7
pand %xmm1, %xmm7
psrlw $0x2, %xmm5
pand %xmm1, %xmm5
paddb %xmm7, %xmm5
movdqa %xmm5, %xmm7
psrlw $0x4, %xmm7
paddb %xmm5, %xmm7
pand %xmm2, %xmm7
movdqa %xmm4, %xmm5
psrlw $0x1, %xmm5
pand %xmm0, %xmm5
psubb %xmm5, %xmm4
movdqa %xmm4, %xmm5
pand %xmm1, %xmm5
psrlw $0x2, %xmm4
pand %xmm1, %xmm4
paddb %xmm5, %xmm4
movdqa %xmm4, %xmm5
psrlw $0x4, %xmm5
paddb %xmm4, %xmm5
pand %xmm2, %xmm5
paddb %xmm7, %xmm5
paddb %xmm6, %xmm5
psadbw %xmm3, %xmm5
pshufd $0xee, %xmm5, %xmm4     # xmm4 = xmm5[2,3,2,3]
paddq %xmm5, %xmm4
movq %xmm4, %rsi
addq %rsi, %rax
addq $0x8, %rdx
jmp 0x2797
pxor %xmm3, %xmm3
leaq 0x3(%rdx), %rsi
cmpq %rcx, %rsi
jae 0x297f
movq (%rdi), %rsi
movdqu (%rsi,%rdx,8), %xmm4
movdqu 0x10(%rsi,%rdx,8), %xmm5
movdqa %xmm5, %xmm6
psrlw $0x1, %xmm6
pand %xmm0, %xmm6
psubb %xmm6, %xmm5
movdqa %xmm5, %xmm6
pand %xmm1, %xmm6
psrlw $0x2, %xmm5
pand %xmm1, %xmm5
paddb %xmm6, %xmm5
movdqa %xmm5, %xmm6
psrlw $0x4, %xmm6
paddb %xmm5, %xmm6
pand %xmm2, %xmm6
movdqa %xmm4, %xmm5
psrlw $0x1, %xmm5
pand %xmm0, %xmm5
psubb %xmm5, %xmm4
movdqa %xmm4, %xmm5
pand %xmm1, %xmm5
psrlw $0x2, %xmm4
pand %xmm1, %xmm4
paddb %xmm5, %xmm4
movdqa %xmm4, %xmm5
psrlw $0x4, %xmm5
paddb %xmm4, %xmm5
pand %xmm2, %xmm5
paddb %xmm6, %xmm5
psadbw %xmm3, %xmm5
pshufd $0xee, %xmm5, %xmm4     # xmm4 = xmm5[2,3,2,3]
paddq %xmm5, %xmm4
movq %xmm4, %rsi
addq %rsi, %rax
addq $0x4, %rdx
jmp 0x28d4
movabsq $0x5555555555555555, %rsi # imm = 0x5555555555555555
movabsq $0x3333333333333333, %r8 # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %r9 # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r10 # imm = 0x101010101010101
cmpq %rcx, %rdx
jae 0x29ec
movq (%rdi), %r11
movq (%r11,%rdx,8), %r11
movq %r11, %rbx
shrq %rbx
andq %rsi, %rbx
subq %rbx, %r11
movq %r11, %rbx
andq %r8, %rbx
shrq $0x2, %r11
andq %r8, %r11
addq %rbx, %r11
movq %r11, %rbx
shrq $0x4, %rbx
addq %r11, %rbx
andq %r9, %rbx
imulq %r10, %rbx
shrq $0x38, %rbx
addq %rbx, %rax
incq %rdx
jmp 0x29a7
popq %rbx
retq