// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x8(%rdi), %r11
movq 0x8(%rsi), %rbx
cmpq %rbx, %r11
movq %rbx, %r14
cmovbq %r11, %r14
xorl %eax, %eax
movdqa 0x1a9e(%rip), %xmm0     # 0x4590
movdqa 0x1aa6(%rip), %xmm1     # 0x45a0
movdqa 0x1aae(%rip), %xmm2     # 0x45b0
pxor %xmm3, %xmm3
xorl %ecx, %ecx
leaq 0x3(%rcx), %rdx
cmpq %r14, %rdx
jae 0x2bcb
movq (%rdi), %rdx
movq (%rsi), %r8
movdqu (%rdx,%rcx,8), %xmm5
movdqu 0x10(%rdx,%rcx,8), %xmm6
movdqu (%r8,%rcx,8), %xmm4
por %xmm5, %xmm4
movdqu 0x10(%r8,%rcx,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, %rdx
addq %rdx, %rax
addq $0x4, %rcx
jmp 0x2b08
movabsq $0x5555555555555555, %rdx # imm = 0x5555555555555555
movabsq $0x3333333333333333, %r8 # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %r9 # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r10 # imm = 0x101010101010101
cmpq %r14, %rcx
jae 0x2c3f
movq (%rdi), %r15
movq (%rsi), %r12
movq (%r12,%rcx,8), %r12
orq (%r15,%rcx,8), %r12
movq %r12, %r15
shrq %r15
andq %rdx, %r15
subq %r15, %r12
movq %r12, %r15
andq %r8, %r15
shrq $0x2, %r12
andq %r8, %r12
addq %r15, %r12
movq %r12, %r15
shrq $0x4, %r15
addq %r12, %r15
andq %r9, %r15
imulq %r10, %r15
shrq $0x38, %r15
addq %r15, %rax
incq %rcx
jmp 0x2bf3
pxor %xmm3, %xmm3
cmpq %rbx, %r11
jae 0x2cf7
leaq 0x3(%rcx), %rdi
cmpq %rbx, %rdi
jae 0x2de0
movq (%rsi), %rdi
movdqu (%rdi,%rcx,8), %xmm4
movdqu 0x10(%rdi,%rcx,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
addq $0x4, %rcx
jmp 0x2c4c
leaq 0x3(%rcx), %rsi
cmpq %r11, %rsi
jae 0x2e25
movq (%rdi), %rsi
movdqu (%rsi,%rcx,8), %xmm4
movdqu 0x10(%rsi,%rcx,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, %rcx
jmp 0x2cf7
movq (%rsi), %rdi
movq (%rdi,%rcx,8), %rdi
movq %rdi, %r11
shrq %r11
andq %rdx, %r11
subq %r11, %rdi
movq %rdi, %r11
andq %r8, %r11
shrq $0x2, %rdi
andq %r8, %rdi
addq %r11, %rdi
movq %rdi, %r11
shrq $0x4, %r11
addq %rdi, %r11
andq %r9, %r11
imulq %r10, %r11
shrq $0x38, %r11
addq %r11, %rax
incq %rcx
cmpq %rbx, %rcx
jb 0x2da2
jmp 0x2e2a
movq (%rdi), %rsi
movq (%rsi,%rcx,8), %rsi
movq %rsi, %rbx
shrq %rbx
andq %rdx, %rbx
subq %rbx, %rsi
movq %rsi, %rbx
andq %r8, %rbx
shrq $0x2, %rsi
andq %r8, %rsi
addq %rbx, %rsi
movq %rsi, %rbx
shrq $0x4, %rbx
addq %rsi, %rbx
andq %r9, %rbx
imulq %r10, %rbx
shrq $0x38, %rbx
addq %rbx, %rax
incq %rcx
cmpq %r11, %rcx
jb 0x2de7
popq %rbx
popq %r12
popq %r14
popq %r15
retq