// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/bitset.c
// Function: bitset_union_count
size_t bitset_union_count(const bitset_t *restrict b1, const bitset_t * restrict b2) {
  size_t answer = 0;
  size_t minlength = b1->arraysize < b2->arraysize ? b1->arraysize : b2->arraysize;
  size_t k = 0;
  for( ; k + 3 < minlength; k += 4) {
    answer += __builtin_popcountll ( b1->array[k] | b2->array[k]);
    answer += __builtin_popcountll ( b1->array[k+1] | b2->array[k+1]);
    answer += __builtin_popcountll ( b1->array[k+2] | b2->array[k+2]);
    answer += __builtin_popcountll ( b1->array[k+3] | b2->array[k+3]);
  }
  for( ; k < minlength; ++k) {
    answer += __builtin_popcountll ( b1->array[k] | b2->array[k]);
  }
  if(b2->arraysize > b1->arraysize) {
    //k = b1->arraysize;
    for(; k + 3 < b2->arraysize; k+=4) {
      answer += __builtin_popcountll (b2->array[k]);
      answer += __builtin_popcountll (b2->array[k+1]);
      answer += __builtin_popcountll (b2->array[k+2]);
      answer += __builtin_popcountll (b2->array[k+3]);
    }
    for(; k < b2->arraysize; ++k) {
      answer += __builtin_popcountll (b2->array[k]);
    }
  } else {
    //k = b2->arraysize;
    for(; k  + 3 < b1->arraysize; k+=4) {
      answer += __builtin_popcountll (b1->array[k]);
      answer += __builtin_popcountll (b1->array[k+1]);
      answer += __builtin_popcountll (b1->array[k+2]);
      answer += __builtin_popcountll (b1->array[k+3]);
    }
    for(; k < b1->arraysize; ++k) {
      answer += __builtin_popcountll (b1->array[k]);
    }
  }
  return answer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x8(%rdi), %rcx
movq 0x8(%rsi), %rdx
cmpq %rdx, %rcx
movq %rdx, %r9
cmovbq %rcx, %r9
cmpq $0x4, %r9
jb 0x2fc0
movq (%rdi), %r10
movq (%rsi), %r11
xorl %ebx, %ebx
movdqa 0x16a5(%rip), %xmm0     # 0x4590
movdqa 0x16ad(%rip), %xmm1     # 0x45a0
movdqa 0x16b5(%rip), %xmm2     # 0x45b0
pxor %xmm3, %xmm3
xorl %eax, %eax
movdqu (%r10,%rbx,8), %xmm5
movdqu 0x10(%r10,%rbx,8), %xmm6
movdqu (%r11,%rbx,8), %xmm4
por %xmm5, %xmm4
movdqu 0x10(%r11,%rbx,8), %xmm5
por %xmm6, %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, %r8
addq %r8, %rax
leaq 0x4(%rbx), %r8
addq $0x7, %rbx
cmpq %r9, %rbx
movq %r8, %rbx
jb 0x2f01
jmp 0x2fc5
xorl %eax, %eax
xorl %r8d, %r8d
cmpq %r9, %r8
jae 0x303f
movq (%rdi), %r10
movq (%rsi), %r11
movabsq $0x5555555555555555, %rbx # imm = 0x5555555555555555
movabsq $0x3333333333333333, %r14 # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %r15 # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r12 # imm = 0x101010101010101
movq (%r11,%r8,8), %r13
orq (%r10,%r8,8), %r13
movq %r13, %rbp
shrq %rbp
andq %rbx, %rbp
subq %rbp, %r13
movq %r13, %rbp
andq %r14, %rbp
shrq $0x2, %r13
andq %r14, %r13
addq %rbp, %r13
movq %r13, %rbp
shrq $0x4, %rbp
addq %r13, %rbp
andq %r15, %rbp
imulq %r12, %rbp
shrq $0x38, %rbp
addq %rbp, %rax
incq %r8
cmpq %r8, %r9
jne 0x2ff8
movq %r9, %r8
leaq 0x3(%r8), %r9
cmpq %rdx, %rcx
jae 0x3121
cmpq %rdx, %r9
jae 0x31f3
movq (%rsi), %rcx
movdqa 0x1530(%rip), %xmm0     # 0x4590
movdqa 0x1538(%rip), %xmm1     # 0x45a0
movdqa 0x1540(%rip), %xmm2     # 0x45b0
pxor %xmm3, %xmm3
movdqu (%rcx,%r8,8), %xmm4
movdqu 0x10(%rcx,%r8,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, %rdi
addq %rdi, %rax
leaq 0x4(%r8), %rdi
addq $0x7, %r8
cmpq %rdx, %r8
movq %rdi, %r8
jb 0x3074
jmp 0x31f6
cmpq %rcx, %r9
jae 0x326c
movq (%rdi), %rdx
movdqa 0x145b(%rip), %xmm0     # 0x4590
movdqa 0x1463(%rip), %xmm1     # 0x45a0
movdqa 0x146b(%rip), %xmm2     # 0x45b0
pxor %xmm3, %xmm3
movdqu (%rdx,%r8,8), %xmm4
movdqu 0x10(%rdx,%r8,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
leaq 0x4(%r8), %rsi
addq $0x7, %r8
cmpq %rcx, %r8
movq %rsi, %r8
jb 0x3149
jmp 0x326f
movq %r8, %rdi
cmpq %rdx, %rdi
jae 0x32df
movq (%rsi), %rcx
movabsq $0x5555555555555555, %rsi # imm = 0x5555555555555555
movabsq $0x3333333333333333, %r8 # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %r9 # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r10 # imm = 0x101010101010101
movq (%rcx,%rdi,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 %rdi
cmpq %rdi, %rdx
jne 0x322a
jmp 0x32df
movq %r8, %rsi
cmpq %rcx, %rsi
jae 0x32df
movq (%rdi), %rdx
movabsq $0x5555555555555555, %rdi # imm = 0x5555555555555555
movabsq $0x3333333333333333, %r8 # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %r9 # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r10 # imm = 0x101010101010101
movq (%rdx,%rsi,8), %r11
movq %r11, %rbx
shrq %rbx
andq %rdi, %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 %rsi
cmpq %rsi, %rcx
jne 0x329f
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq