// File: bhhbazinga[P]LockFreeHashTable/test.cc
// Function: TestConcurrentInsertAndFindAndDequeue()
void TestConcurrentInsertAndFindAndDequeue() {
  int old_size = ht.size();

  int divide = kMaxThreads / 3;
  std::vector<std::thread> threads;
  for (int i = 0; i < divide; ++i) {
    threads.push_back(std::thread(onInsert, divide));
    threads.push_back(std::thread(onFind, divide));
    threads.push_back(std::thread(onDelete, divide));
  }

  cnt = 0;
  start = true;
  auto t1_ = std::chrono::steady_clock::now();
  for (int i = 0; i < threads.size(); ++i) {
    threads[i].join();
  }
  auto t2_ = std::chrono::steady_clock::now();

  assert(cnt + old_size == static_cast<int>(ht.size()));
  int ms =
      std::chrono::duration_cast<std::chrono::milliseconds>(t2_ - t1_).count();
  elements2timespan[maxElements][3] += ms;
  std::cout << maxElements
            << " elements insert & find & delete concurrently, timespan=" << ms
            << "ms"
            << "\n";

  cnt = 0;
  start = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
leaq 0x17216(%rip), %rdi     # 0x1a968
callq 0x5110
movl %eax, -0x4(%rbp)
movl 0x17200(%rip), %eax     # 0x1a960
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, -0x8(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x5190
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x387e
leaq -0x94e(%rip), %rsi      # 0x2e40
leaq -0x30(%rbp), %rdi
leaq -0x8(%rbp), %rdx
callq 0x5560
jmp 0x379d
leaq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x51b0
jmp 0x37ac
leaq -0x30(%rbp), %rdi
callq 0x52a0
leaq -0x8ec(%rip), %rsi      # 0x2ed0
leaq -0x48(%rbp), %rdi
leaq -0x8(%rbp), %rdx
callq 0x5560
jmp 0x37cb
leaq -0x20(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x51b0
jmp 0x37da
leaq -0x48(%rbp), %rdi
callq 0x52a0
leaq -0x89a(%rip), %rsi      # 0x2f50
leaq -0x50(%rbp), %rdi
leaq -0x8(%rbp), %rdx
callq 0x5560
jmp 0x37f9
leaq -0x20(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x51b0
jmp 0x3808
leaq -0x50(%rbp), %rdi
callq 0x52a0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x377b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3aa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x52a0
jmp 0x3aa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x52a0
jmp 0x3aa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x52a0
jmp 0x3aa0
leaq 0x17503(%rip), %rdi     # 0x1ad88
xorl %esi, %esi
callq 0x54d0
leaq 0x174f9(%rip), %rdi     # 0x1ad8c
movl $0x1, %esi
callq 0x52d0
callq 0x2180
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movslq -0x5c(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x5620
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x38f4
movslq -0x5c(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5300
movq %rax, %rdi
callq 0x21f0
jmp 0x38e7
jmp 0x38e9
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x38ad
callq 0x2180
movq %rax, -0x68(%rbp)
leaq 0x17484(%rip), %rdi     # 0x1ad88
callq 0x5320
movl -0x4(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x94(%rbp)
leaq 0x1704d(%rip), %rdi     # 0x1a968
callq 0x5110
movq %rax, -0x90(%rbp)
jmp 0x3929
movl -0x94(%rbp), %eax
movq -0x90(%rbp), %rcx
cmpl %ecx, %eax
jne 0x393c
jmp 0x395b
leaq 0xd891(%rip), %rdi      # 0x111d4
leaq 0xd8b8(%rip), %rsi      # 0x11202
movl $0x99, %edx
leaq 0xd96a(%rip), %rcx      # 0x112c0
callq 0x20c0
leaq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x53d0
movq %rax, -0xa0(%rbp)
jmp 0x3971
movq -0xa0(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x53a0
movq %rax, -0xa8(%rbp)
jmp 0x398e
movq -0xa8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5420
movq %rax, -0xb0(%rbp)
jmp 0x39ab
movq -0xb0(%rbp), %rax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0xbc(%rbp)
leaq 0x173cb(%rip), %rdi     # 0x1ad90
leaq 0x16f98(%rip), %rsi     # 0x1a964
callq 0x5440
movq %rax, -0xb8(%rbp)
jmp 0x39da
movl -0xbc(%rbp), %edx
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl 0xc(%rax), %ecx
addl %edx, %ecx
movl %ecx, 0xc(%rax)
movl 0x16f6c(%rip), %esi     # 0x1a964
movq 0x165d9(%rip), %rdi     # 0x19fd8
callq 0x2200
movq %rax, -0xc8(%rbp)
jmp 0x3a0d
movq -0xc8(%rbp), %rdi
leaq 0xd8d2(%rip), %rsi      # 0x112ed
callq 0x2130
movq %rax, -0xd0(%rbp)
jmp 0x3a29
movq -0xd0(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x2200
movq %rax, -0xd8(%rbp)
jmp 0x3a41
movq -0xd8(%rbp), %rdi
leaq 0xd800(%rip), %rsi      # 0x1124f
callq 0x2130
movq %rax, -0xe0(%rbp)
jmp 0x3a5d
movq -0xe0(%rbp), %rdi
leaq 0xd7e7(%rip), %rsi      # 0x11252
callq 0x2130
jmp 0x3a72
leaq 0x1730f(%rip), %rdi     # 0x1ad88
xorl %esi, %esi
callq 0x54d0
leaq 0x17305(%rip), %rdi     # 0x1ad8c
xorl %esi, %esi
callq 0x52d0
leaq -0x20(%rbp), %rdi
callq 0x5470
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x5470
movq -0x38(%rbp), %rdi
callq 0x2230
nopw %cs:(%rax,%rax)