// File: /workspace/github_c_makefile_star2_O1/FastFilter[P]BlockBloomSimulator/src/windowedblockmodel.h
// Function: simulateWindow
sim_stats_t simulateWindow(size_t HowManyKeys, windowed_model_t model, size_t howmanytests,
                bitset_t *b) {
  bitset_resize(b, model.TotalBits, true);
  bitset_clear(b);
  for (size_t i = 0; i < HowManyKeys; i++) {
    size_t blockindex = random_integer(NumberOfBlocks(&model));
    for (size_t j = 0; j < model.BitsPerKeyPerBlock; j++) {
      size_t bi = random_integer(model.BlockSizeInBits);
      bitset_set(b, blockindex * model.WindowSizeInBits + bi);
    }
  }
  size_t matches = 0;
  for (size_t i = 0; i < howmanytests; i++) {
    size_t blockindex = random_integer(NumberOfBlocks(&model));
    bool is_matched = true;
    for (size_t j = 0; j < model.BitsPerKeyPerBlock; j++) {
      size_t bi = random_integer(model.BlockSizeInBits);
      is_matched =
          is_matched && bitset_get(b, blockindex * model.WindowSizeInBits + bi);
    }
    if (is_matched)
      matches++;
  }
  sim_stats_t answer;
  answer.collision_rate = matches * 1.0 / howmanytests;
  answer.density = bitset_count(b) * 1.0 / model.TotalBits;
  return answer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movq %rsi, 0x30(%rsp)
movq %rdi, %r14
leaq 0xa0(%rsp), %rax
movq 0x8(%rax), %rsi
movq %rdx, %rdi
movq %rsi, 0x28(%rsp)
movl $0x1, %edx
callq 0x1f8a
movq %rbx, %rdi
callq 0x1e71
movq %r14, 0x60(%rsp)
testq %r14, %r14
je 0x13dd
leaq 0xa0(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rcx), %r12
movq 0x28(%rsp), %rax
subq %r12, %rax
movq 0x18(%rcx), %rcx
xorl %esi, %esi
xorl %edx, %edx
movq %rcx, 0x50(%rsp)
divq %rcx
incq %rax
movq %rax, 0x58(%rsp)
movq %r12, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq 0x58(%rsp), %rdi
callq 0x1210
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x13ca
movq 0x10(%rsp), %rax
imulq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rbp
movq %r12, %rdi
callq 0x1210
movq %rax, %r13
addq 0x10(%rsp), %r13
movq %r13, %r14
shrq $0x6, %r14
cmpq 0x8(%rbx), %r14
jb 0x13af
leaq 0x1(%r14), %r15
cmpq %r14, 0x10(%rbx)
ja 0x138b
leaq (%r15,%r15), %rax
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
movq %r15, %rsi
shlq $0x4, %rsi
callq 0x10c0
movq %rax, %r12
testq %rax, %rax
je 0x1379
movq %r12, (%rbx)
jmp 0x1381
movq (%rbx), %rdi
callq 0x1030
testq %r12, %r12
movq 0x40(%rsp), %r12
je 0x13c1
movq 0x8(%rbx), %rax
leaq (,%rax,8), %rdi
addq (%rbx), %rdi
movq %r15, %rdx
subq %rax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x1080
movq %r15, 0x8(%rbx)
movl $0x1, %eax
movl %r13d, %ecx
shlq %cl, %rax
movq (%rbx), %rcx
orq %rax, (%rcx,%r14,8)
decq %rbp
jne 0x132e
movq 0x38(%rsp), %rsi
incq %rsi
cmpq 0x60(%rsp), %rsi
jne 0x12f9
cmpq $0x0, 0x30(%rsp)
je 0x14c2
leaq 0xa0(%rsp), %rcx
movq (%rcx), %r13
movq 0x10(%rcx), %r12
movq 0x28(%rsp), %rax
subq %r12, %rax
movq 0x18(%rcx), %rcx
xorl %ebp, %ebp
xorl %edx, %edx
movq %rcx, 0x8(%rsp)
divq %rcx
incq %rax
movq %rax, 0x40(%rsp)
xorl %r15d, %r15d
movq %r13, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0x1210
testq %r13, %r13
je 0x1487
movq %rax, %r14
movq %r15, 0x10(%rsp)
imulq 0x8(%rsp), %r14
movb $0x1, %r15b
movq %r12, %rdi
callq 0x1210
testb $0x1, %r15b
je 0x146f
addq %r14, %rax
movq %rax, %rcx
shrq $0x6, %rcx
cmpq 0x8(%rbx), %rcx
jae 0x146f
movq (%rbx), %rdx
movq (%rdx,%rcx,8), %rcx
btq %rax, %rcx
setb %r15b
jmp 0x1472
xorl %r15d, %r15d
decq %r13
jne 0x1440
movzbl %r15b, %eax
movq 0x38(%rsp), %r13
movq 0x10(%rsp), %r15
jmp 0x148c
movl $0x1, %eax
addq %rax, %r15
incq %rbp
cmpq 0x30(%rsp), %rbp
jne 0x1420
movq %r15, %xmm0
punpckldq 0x1b6a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1b72(%rip), %xmm0     # 0x3020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
jmp 0x14cc
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq 0x28(%rsp), %xmm0
movq 0x30(%rsp), %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movdqa 0x1b4c(%rip), %xmm0     # 0x3030
pand %xmm1, %xmm0
por 0x1b50(%rip), %xmm0     # 0x3040
psrlq $0x20, %xmm1
por 0x1b53(%rip), %xmm1     # 0x3050
subpd 0x1b5b(%rip), %xmm1     # 0x3060
addpd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
movq %rbx, %rdi
callq 0x20e6
movq %rax, %xmm0
punpckldq 0x1aec(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1af4(%rip), %xmm0     # 0x3020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addpd %xmm0, %xmm1
movapd 0x10(%rsp), %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
divpd 0x40(%rsp), %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq