// File: bhhbazinga[P]LockFreeHashTable/test.cc
// Function: TestConcurrentInsert()
void TestConcurrentInsert() {
  int old_size = ht.size();
  std::vector<std::thread> threads;
  for (int i = 0; i < kMaxThreads; ++i) {
    threads.push_back(std::thread(onInsert, kMaxThreads));
  }

  start = true;
  auto t1_ = std::chrono::steady_clock::now();
  for (int i = 0; i < kMaxThreads; ++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][0] += ms;
  std::cout << maxElements << " elements insert concurrently, timespan=" << ms
            << "ms"
            << "\n";
  start = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
leaq 0x17976(%rip), %rdi     # 0x1a968
callq 0x5110
movl %eax, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x5190
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x1794d(%rip), %eax     # 0x1a960
jge 0x307c
leaq -0x1dc(%rip), %rsi      # 0x2e40
leaq 0x1793d(%rip), %rdx     # 0x1a960
leaq -0x30(%rbp), %rdi
callq 0x51e0
jmp 0x302e
leaq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x51b0
jmp 0x303d
leaq -0x30(%rbp), %rdi
callq 0x52a0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x300a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x325c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x52a0
jmp 0x325c
leaq 0x17d09(%rip), %rdi     # 0x1ad8c
movl $0x1, %esi
callq 0x52d0
callq 0x2180
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl 0x178ba(%rip), %eax     # 0x1a960
jge 0x30cc
movslq -0x4c(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x5300
movq %rax, %rdi
callq 0x21f0
jmp 0x30bf
jmp 0x30c1
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x309d
callq 0x2180
movq %rax, -0x58(%rbp)
leaq 0x17cac(%rip), %rdi     # 0x1ad88
callq 0x5320
movl -0x4(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x7c(%rbp)
leaq 0x17878(%rip), %rdi     # 0x1a968
callq 0x5110
movq %rax, -0x78(%rbp)
jmp 0x30fb
movl -0x7c(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl %ecx, %eax
jne 0x3108
jmp 0x3127
leaq 0xe0c5(%rip), %rdi      # 0x111d4
leaq 0xe0ec(%rip), %rsi      # 0x11202
movl $0x4a, %edx
leaq 0xe0e8(%rip), %rcx      # 0x1120a
callq 0x20c0
leaq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x53d0
movq %rax, -0x88(%rbp)
jmp 0x313d
movq -0x88(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x53a0
movq %rax, -0x90(%rbp)
jmp 0x315a
movq -0x90(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5420
movq %rax, -0x98(%rbp)
jmp 0x3177
movq -0x98(%rbp), %rax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0xa4(%rbp)
leaq 0x17bff(%rip), %rdi     # 0x1ad90
leaq 0x177cc(%rip), %rsi     # 0x1a964
callq 0x5440
movq %rax, -0xa0(%rbp)
jmp 0x31a6
movl -0xa4(%rbp), %edx
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movl (%rax), %ecx
addl %edx, %ecx
movl %ecx, (%rax)
movl 0x177a2(%rip), %esi     # 0x1a964
movq 0x16e0f(%rip), %rdi     # 0x19fd8
callq 0x2200
movq %rax, -0xb0(%rbp)
jmp 0x31d7
movq -0xb0(%rbp), %rdi
leaq 0xe041(%rip), %rsi      # 0x11226
callq 0x2130
movq %rax, -0xb8(%rbp)
jmp 0x31f3
movq -0xb8(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x2200
movq %rax, -0xc0(%rbp)
jmp 0x320b
movq -0xc0(%rbp), %rdi
leaq 0xe036(%rip), %rsi      # 0x1124f
callq 0x2130
movq %rax, -0xc8(%rbp)
jmp 0x3227
movq -0xc8(%rbp), %rdi
leaq 0xe01d(%rip), %rsi      # 0x11252
callq 0x2130
jmp 0x323c
leaq 0x17b49(%rip), %rdi     # 0x1ad8c
xorl %esi, %esi
callq 0x52d0
leaq -0x20(%rbp), %rdi
callq 0x5470
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0x5470
movq -0x38(%rbp), %rdi
callq 0x2230
nop