// File: /workspace/github_cpp_makefile_star2_O2/lemire[P]fastscancount/benchmark/counters.cpp
// Function: demo_random(unsigned long, unsigned long, unsigned long, unsigned long)
void demo_random(size_t N, size_t length, size_t array_count, size_t threshold) {
  std::vector<std::vector<uint32_t>> data(array_count);

  std::vector<const std::vector<uint32_t>*> data_ptrs;
  std::vector<uint32_t> answer;
  answer.reserve(N);

  size_t sum = 0;
  for (size_t c = 0; c < array_count; c++) {
    std::vector<uint32_t> &v = data[c];
    for (size_t i = 0; i < length; i++) {
      v.push_back(rand() % N);
    }
    std::sort(v.begin(), v.end());
    v.resize(std::distance(v.begin(), unique(v.begin(), v.end())));
    sum += v.size();
    data_ptrs.push_back(&data[c]);
  }


  std::vector<std::vector<uint32_t>> range_boundaries;
  calc_alldata_boundaries(data, range_boundaries, range_size_avx512);
  std::vector<const std::vector<uint32_t>*> range_ptrs;
  for (size_t c = 0; c < array_count; c++) {
    range_ptrs.push_back(&range_boundaries[c]);
  }

  std::vector<int> evts = {
#ifdef __linux__
                           PERF_COUNT_HW_CPU_CYCLES,
                           PERF_COUNT_HW_INSTRUCTIONS,
                           PERF_COUNT_HW_BRANCH_MISSES,
                           PERF_COUNT_HW_CACHE_REFERENCES,
                           PERF_COUNT_HW_CACHE_MISSES
#endif
                          }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rcx, 0x30(%rsp)
movq %rdx, %rbx
movq %rsi, (%rsp)
movq %rdi, %r12
leaq 0x118(%rsp), %rdi
leaq 0x1e0(%rsp), %rdx
movq %rbx, %rsi
callq 0x4ca0
xorpd %xmm0, %xmm0
movapd %xmm0, 0xa0(%rsp)
andq $0x0, 0xb0(%rsp)
leaq 0x10(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %r12, %rsi
callq 0x49f6
xorl %eax, %eax
leaq 0x1e0(%rsp), %rbp
xorl %r13d, %r13d
cmpq %rbx, %rax
je 0x380c
movq %r13, 0x50(%rsp)
movq %rax, 0x38(%rsp)
imulq $0x18, %rax, %r15
movq 0x118(%rsp), %r14
addq %r15, %r14
movq (%rsp), %r13
subq $0x1, %r13
jb 0x379c
callq 0x2070
cltq
xorl %edx, %edx
divq %r12
movl %edx, 0x1e0(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x6a32
jmp 0x3776
movq (%r14), %rdi
movq 0x8(%r14), %rsi
callq 0x6b28
movq (%r14), %r13
movq 0x8(%r14), %rsi
movq %r13, %rdi
callq 0x6f28
subq %r13, %rax
sarq $0x2, %rax
movq %r14, %rdi
movq %rax, %rsi
callq 0x4916
movq (%r14), %r13
movq 0x8(%r14), %r14
addq 0x118(%rsp), %r15
movq %r15, 0x1e0(%rsp)
leaq 0xa0(%rsp), %rdi
movq %rbp, %rsi
callq 0x6392
subq %r13, %r14
sarq $0x2, %r14
movq 0x50(%rsp), %r13
addq %r14, %r13
movq 0x38(%rsp), %rax
incq %rax
jmp 0x3750
xorpd %xmm0, %xmm0
leaq 0x170(%rsp), %rsi
movapd %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
leaq 0x118(%rsp), %rdi
movl $0x9c40, %edx           # imm = 0x9C40
callq 0x28bf
leaq 0x1c0(%rsp), %r14
andq $0x0, 0x10(%r14)
xorpd %xmm0, %xmm0
movapd %xmm0, (%r14)
xorl %r12d, %r12d
leaq 0x1e0(%rsp), %r15
subq $0x1, %rbx
jb 0x387e
movq 0x170(%rsp), %rax
addq %r12, %rax
movq %rax, 0x1e0(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x6392
addq $0x18, %r12
jmp 0x3854
movupd 0x4bea(%rip), %xmm0     # 0x8470
leaq 0x1e0(%rsp), %rsi
movapd %xmm0, (%rsi)
movl $0x3, 0x10(%rsi)
leaq 0x1a8(%rsp), %rdi
pushq $0x5
popq %rdx
leaq 0x150(%rsp), %rcx
callq 0x4a8c
leaq 0x190(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x4ac2
leaq 0x1e0(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x4b10
leaq 0x190(%rsp), %rdi
callq 0x6288
leaq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x26f4
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x96b3(%rip), %rdi      # 0xcfc8
leaq 0x47f9(%rip), %rsi      # 0x8115
callq 0x21e0
movq 0x38(%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
movq %rsi, 0x80(%rsp)
callq 0x2150
leaq 0x476f(%rip), %rsi      # 0x80b0
movq %rax, %rdi
callq 0x21e0
movq %r13, %xmm0
punpckldq 0x46ba(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
imulq $0xa, %r13, %rax
movq %rax, 0x108(%rsp)
subpd 0x46b6(%rip), %xmm0     # 0x8020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0xd0(%rsp)
xorpd %xmm0, %xmm0
movss %xmm0, 0x50(%rsp)
pushq $0xa
popq %r12
leaq 0x130(%rsp), %r15
leaq 0x150(%rsp), %r13
leaq 0x1e0(%rsp), %rbp
movq 0x961c(%rip), %rbx      # 0xcfc8
movq %r12, %r14
subq $0x1, %r14
jb 0x3bf9
movq %r15, %rdi
leaq 0x46f4(%rip), %rsi      # 0x80b7
leaq 0x88(%rsp), %rdx
callq 0x4c2c
movq %r13, %rdi
callq 0x6692
movq %rbp, %rdi
callq 0x66b0
leaq 0xa0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x26f4
movq %rbp, %rdi
callq 0x66ce
movq %r13, %rdi
callq 0x6718
testq %rax, %rax
js 0x3a13
cvtsi2ss %rax, %xmm0
jmp 0x3a28
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movss %xmm0, (%rsp)
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x3a95
movq 0x95a3(%rip), %rdi      # 0xcfe8
leaq 0x4882(%rip), %rsi      # 0x82ce
callq 0x21e0
movq %rax, %rdi
movq 0x80(%rsp), %rsi
callq 0x2150
movq %rax, %rdi
leaq 0x4872(%rip), %rsi      # 0x82dd
callq 0x21e0
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
leaq 0x4625(%rip), %rsi      # 0x80b5
callq 0x21e0
cmpq $0x1, %r12
jne 0x3bd8
movq %rbp, %rdi
xorl %esi, %esi
callq 0x6730
movq %rax, %xmm0
punpckldq 0x455a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4562(%rip), %xmm0     # 0x8020
movapd %xmm0, 0x70(%rsp)
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0x6730
movq %rax, %xmm0
punpckldq 0x4534(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x453c(%rip), %xmm0     # 0x8020
movapd %xmm0, 0x40(%rsp)
movq %rbp, %rdi
pushq $0x5
popq %rsi
callq 0x6730
movq %rax, %xmm0
punpckldq 0x450e(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4516(%rip), %xmm0     # 0x8020
movapd %xmm0, 0x60(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2110
movapd 0x70(%rsp), %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x70(%rsp)
movapd %xmm1, %xmm0
divsd 0xd0(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x478d(%rip), %rsi      # 0x82e7
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movapd 0x40(%rsp), %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x70(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x4767(%rip), %rsi      # 0x82f8
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movapd 0x60(%rsp), %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0xd0(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x4743(%rip), %rsi      # 0x830e
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movss 0x50(%rsp), %xmm0
addss (%rsp), %xmm0
movss %xmm0, 0x50(%rsp)
movq %r15, %rdi
callq 0x2100
movq %r14, %r12
jmp 0x39af
movq 0x30(%rsp), %rax
movl %eax, %ecx
movq %rcx, 0x110(%rsp)
xorpd %xmm0, %xmm0
movss %xmm0, (%rsp)
pushq $0xa
popq %r13
leaq 0x130(%rsp), %r12
leaq 0xa0(%rsp), %r14
leaq 0x10(%rsp), %r15
movzbl %al, %eax
movl %eax, 0x30(%rsp)
leaq 0x150(%rsp), %rbp
leaq 0x1e0(%rsp), %rbx
movq %r13, %rax
subq $0x1, %rax
movq %rax, 0x70(%rsp)
jb 0x3fa7
movq %r12, %rdi
leaq 0x443f(%rip), %rsi      # 0x809c
leaq 0xf(%rsp), %rdx
callq 0x4c2c
movq %r14, %rdi
movq %r15, %rsi
movq 0x110(%rsp), %rdx
callq 0x26f4
movq 0x10(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x650e
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x6b28
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x3cc7
movq %rax, 0x18(%rsp)
movq %r14, %rdi
movq %r15, %rsi
movl 0x30(%rsp), %edx
callq 0x24ec
movq %r13, 0x40(%rsp)
movq %rbx, %r13
movq 0x10(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq %r15, %rsi
movq 0x18(%rsp), %rbx
leaq 0xb8(%rsp), %rdi
callq 0x650e
movq 0xb8(%rsp), %rdi
movq 0xc0(%rsp), %rsi
callq 0x6b28
leaq 0x88(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x655b
testb %al, %al
jne 0x40c9
leaq 0xb8(%rsp), %rdi
callq 0x620e
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
callq 0x620e
movq %r12, %rdi
callq 0x2100
movq %r12, %rdi
leaq 0x4369(%rip), %rsi      # 0x80ca
movq %rbx, %rdx
callq 0x4c2c
movq %rbp, %rdi
callq 0x6692
movq %r13, %rbx
movq %r13, %rdi
callq 0x66b0
movq 0x9245(%rip), %r13      # 0xcfc8
movq %r14, %rdi
movq %r15, %rsi
movl 0x30(%rsp), %edx
callq 0x24ec
movq %rbx, %rdi
callq 0x66ce
movq %rbp, %rdi
callq 0x6718
testq %rax, %rax
js 0x3dae
cvtsi2ss %rax, %xmm0
jmp 0x3dc3
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
movss %xmm0, 0x60(%rsp)
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0x3e31
movq 0x9207(%rip), %rdi      # 0xcfe8
leaq 0x44e6(%rip), %rsi      # 0x82ce
callq 0x21e0
movq %rax, %rdi
movq 0x80(%rsp), %rsi
callq 0x2150
movq %rax, %rdi
leaq 0x44d6(%rip), %rsi      # 0x82dd
callq 0x21e0
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
leaq 0x4289(%rip), %rsi      # 0x80b5
callq 0x21e0
cmpq $0x1, 0x40(%rsp)
jne 0x3f82
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6730
movq %rax, %xmm0
punpckldq 0x41bc(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x41c4(%rip), %xmm0     # 0x8020
movapd %xmm0, 0x40(%rsp)
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x6730
movq %rax, %xmm0
punpckldq 0x4196(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x419e(%rip), %xmm0     # 0x8020
movapd %xmm0, 0xf0(%rsp)
movq %rbx, %rdi
pushq $0x5
popq %rsi
callq 0x6730
movq %rax, %xmm0
punpckldq 0x416d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4175(%rip), %xmm0     # 0x8020
movapd %xmm0, 0xe0(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2110
movapd 0x40(%rsp), %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
movapd %xmm1, %xmm0
divsd 0xd0(%rsp), %xmm0
movq %r13, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x43e9(%rip), %rsi      # 0x82e7
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movapd 0xf0(%rsp), %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x40(%rsp), %xmm0
movq %r13, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x43c0(%rip), %rsi      # 0x82f8
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movapd 0xe0(%rsp), %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0xd0(%rsp), %xmm0
movq %r13, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x4399(%rip), %rsi      # 0x830e
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movss (%rsp), %xmm0
addss 0x60(%rsp), %xmm0
movss %xmm0, (%rsp)
movq %r12, %rdi
callq 0x2100
movq 0x70(%rsp), %rax
movq %rax, %r13
jmp 0x3c44
movq 0x901a(%rip), %rdi      # 0xcfc8
leaq 0x4139(%rip), %rsi      # 0x80ee
callq 0x21e0
movq %rax, %rdi
callq 0x2110
movq 0x8fff(%rip), %rdi      # 0xcfc8
leaq 0x4139(%rip), %rsi      # 0x8109
callq 0x21e0
movsd 0x108(%rsp), %xmm0
unpcklps 0x402b(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4033(%rip), %xmm0     # 0x8020
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
cvtss2sd 0x50(%rsp), %xmm1
divsd 0x4039(%rip), %xmm1     # 0x8040
movapd %xmm2, 0x50(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x2110
movq 0x8f9c(%rip), %rdi      # 0xcfc8
leaq 0x40d2(%rip), %rsi      # 0x8105
callq 0x21e0
cvtss2sd (%rsp), %xmm1
divsd 0x3ffb(%rip), %xmm1     # 0x8040
movapd 0x50(%rsp), %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x2110
leaq 0x1e0(%rsp), %rdi
callq 0x4c8a
leaq 0x1a8(%rsp), %rdi
callq 0x6288
leaq 0x1c0(%rsp), %rdi
callq 0x635e
leaq 0x170(%rsp), %rdi
callq 0x4c68
leaq 0x10(%rsp), %rdi
callq 0x620e
leaq 0xa0(%rsp), %rdi
callq 0x635e
leaq 0x118(%rsp), %rdi
callq 0x4c68
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8ef8(%rip), %rdi      # 0xcfc8
leaq 0x41d9(%rip), %rsi      # 0x82b0
callq 0x21e0
movq 0x60(%rsp), %rsi
subq 0xf0(%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
movq %rsi, %r15
callq 0x2150
leaq 0x41b6(%rip), %rsi      # 0x82b5
movq %rax, %rdi
callq 0x21e0
movq %rbx, %rsi
subq 0xe0(%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
movq %rsi, %rbx
callq 0x2150
movq %rax, %rdi
callq 0x2110
cmpq %r15, %rbx
cmovbq %rbx, %r15
xorl %ebx, %ebx
movq 0x8e8f(%rip), %r14      # 0xcfc8
leaq 0x4173(%rip), %r12      # 0x82b3
leaq 0x4174(%rip), %r13      # 0x82bb
leaq 0x4172(%rip), %rbp      # 0x82c0
cmpq %rbx, %r15
je 0x41ca
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2150
movq %rax, %rdi
movq %r12, %rsi
callq 0x21e0
movq 0x88(%rsp), %rcx
movl (%rcx,%rbx,4), %esi
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
movq %r13, %rsi
callq 0x21e0
movq 0xb8(%rsp), %rcx
movl (%rcx,%rbx,4), %esi
movq %rax, %rdi
callq 0x2150
movq 0x88(%rsp), %rax
movl (%rax,%rbx,4), %eax
movq 0xb8(%rsp), %rcx
cmpl (%rcx,%rbx,4), %eax
je 0x41bd
movq %r14, %rdi
movq %rbp, %rsi
callq 0x21e0
movq %r14, %rdi
callq 0x2110
incq %rbx
jmp 0x414e
pushq $0x10
popq %rdi
callq 0x2120
movq %rax, %r14
leaq 0x40ec(%rip), %rsi      # 0x82c8
leaq 0x150(%rsp), %rdi
leaq 0x130(%rsp), %rdx
callq 0x4d54
movb $0x1, %bpl
leaq 0x150(%rsp), %rsi
movq %r14, %rdi
callq 0x2320
xorl %ebp, %ebp
movq 0x8de3(%rip), %rsi      # 0xcff0
movq 0x8da4(%rip), %rdx      # 0xcfb8
movq %r14, %rdi
callq 0x2350
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x2100
testb %bpl, %bpl
jne 0x4236
jmp 0x4282
movq %rax, %rbx
movq %r14, %rdi
callq 0x2180
jmp 0x4282
jmp 0x427f
jmp 0x4273
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x6288
jmp 0x42c6
movq %rax, %rbx
jmp 0x42c6
jmp 0x427a
movq %rax, %rbx
jmp 0x42e0
jmp 0x42ef
jmp 0x4273
jmp 0x4273
jmp 0x427f
jmp 0x4291
jmp 0x4273
jmp 0x4273
movq %rax, %rbx
jmp 0x42b9
jmp 0x42ef
movq %rax, %rbx
jmp 0x42d3
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x620e
jmp 0x4294
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x620e
jmp 0x42ac
jmp 0x42a9
jmp 0x42ef
jmp 0x42a9
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x2100
leaq 0x1e0(%rsp), %rdi
callq 0x4c8a
leaq 0x1a8(%rsp), %rdi
callq 0x6288
leaq 0x1c0(%rsp), %rdi
callq 0x635e
leaq 0x170(%rsp), %rdi
callq 0x4c68
jmp 0x42f2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x620e
leaq 0xa0(%rsp), %rdi
callq 0x635e
leaq 0x118(%rsp), %rdi
callq 0x4c68
movq %rbx, %rdi
callq 0x2360