// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rdx, %rbx
movq %rsi, 0x8(%rsp)
movq %rdi, %rbp
movq 0x88(%rsp), %r14
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1ddd
movq %rbx, %rdi
callq 0x1cd8
movq 0x80(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x90(%rsp), %r12
movq %r14, 0x38(%rsp)
subq %r12, %r14
movq %r14, 0x18(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
cmpq %rbp, %r13
je 0x1307
movq 0x18(%rsp), %rax
xorl %edx, %edx
movq 0x10(%rsp), %r14
divq %r14
leaq 0x1(%rax), %rdi
callq 0x121f
movq %rax, %r15
imulq %r14, %r15
movq 0x20(%rsp), %r14
subq $0x1, %r14
jb 0x1302
movq %r12, %rdi
callq 0x121f
leaq (%rax,%r15), %rsi
movq %rbx, %rdi
callq 0x1423
jmp 0x12e6
incq %r13
jmp 0x12bd
xorl %r14d, %r14d
xorl %r13d, %r13d
cmpq 0x8(%rsp), %r13
je 0x1380
movq %r14, 0x40(%rsp)
movq 0x18(%rsp), %rax
xorl %edx, %edx
movq 0x10(%rsp), %r14
divq %r14
leaq 0x1(%rax), %rdi
callq 0x121f
movq %rax, %rbp
imulq %r14, %rbp
movb $0x1, %r15b
movq 0x20(%rsp), %r14
subq $0x1, %r14
jb 0x136c
movq %r12, %rdi
callq 0x121f
testb $0x1, %r15b
je 0x1367
addq %rbp, %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x14b9
movl %eax, %r15d
jmp 0x1340
xorl %r15d, %r15d
jmp 0x1340
movzbl %r15b, %eax
andl $0x1, %eax
movq 0x40(%rsp), %r14
addq %rax, %r14
incq %r13
jmp 0x130d
movq 0x38(%rsp), %xmm0
movq 0x8(%rsp), %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movdqa %xmm1, %xmm0
pand 0x1c74(%rip), %xmm0     # 0x3010
por 0x1c7c(%rip), %xmm0     # 0x3020
psrlq $0x20, %xmm1
por 0x1c7f(%rip), %xmm1     # 0x3030
subpd 0x1c87(%rip), %xmm1     # 0x3040
addpd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movq %rbx, %rdi
callq 0x1f0a
movq %r14, %xmm0
movq %rax, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa 0x1c2f(%rip), %xmm1     # 0x3010
pand %xmm0, %xmm1
por 0x1c33(%rip), %xmm1     # 0x3020
psrlq $0x20, %xmm0
por 0x1c36(%rip), %xmm0     # 0x3030
subpd 0x1c3e(%rip), %xmm0     # 0x3040
addpd %xmm1, %xmm0
divpd 0x20(%rsp), %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq