// File: bhhbazinga[P]LockFreeHashTable/test.cc
// Function: main
int main(int argc, char const* argv[]) {
  (void)argc;
  (void)argv;

  srand(std::time(0));

  std::cout << "Benchmark with " << kMaxThreads << " threads:"
            << "\n";

  int elements[] = {kElements1, kElements2, kElements3};
  int timespan1[] = {0, 0, 0, 0};
  int timespan2[] = {0, 0, 0, 0};
  int timespan3[] = {0, 0, 0, 0};

  elements2timespan[kElements1] = timespan1;
  elements2timespan[kElements2] = timespan2;
  elements2timespan[kElements3] = timespan3;

  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 3; ++j) {
      maxElements = elements[j];
      TestConcurrentInsert();
      TestConcurrentFind();
      TestConcurrentDelete();
      TestConcurrentInsertAndFindAndDequeue();
      std::cout << "\n";
    }
  }

  for (int i = 0; i < 3; ++i) {
    maxElements = elements[i];
    float avg = static_cast<float>(elements2timespan[maxElements][0]) / 10.0f;
    std::cout << maxElements
              << " elements insert concurrently, average timespan=" << avg
              << "ms"
              << "\n";
    avg = static_cast<float>(elements2timespan[maxElements][1]) / 10.0f;
    std::cout << maxElements
              << " elements find concurrently, average timespan=" << avg << "ms"
              << "\n";
    avg = static_cast<float>(elements2timespan[maxElements][2]) / 10.0f;
    std::cout << maxElements
              << " elements delete concurrently, average timespan=" << avg
              << "ms"
              << "\n";
    avg = static_cast<float>(elements2timespan[maxElements][3]) / 10.0f;
    std::cout << maxElements
              << " elements insert & find & delete concurrently, average timespan="
              << avg << "ms"
              << "\n";
    std::cout << "\n";
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x2110
movl %eax, %edi
callq 0x2120
movq 0x164e8(%rip), %rdi     # 0x19fd8
leaq 0xd82f(%rip), %rsi      # 0x11326
callq 0x2130
movq %rax, %rdi
movl 0x16e5b(%rip), %esi     # 0x1a960
callq 0x2200
movq %rax, %rdi
leaq 0xd822(%rip), %rsi      # 0x11336
callq 0x2130
movq %rax, %rdi
leaq 0xd72f(%rip), %rsi      # 0x11252
callq 0x2130
movq 0xd511(%rip), %rax      # 0x11040
movq %rax, -0x1c(%rbp)
movl 0xd50f(%rip), %eax      # 0x11048
movl %eax, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x20b0
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x20b0
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x20b0
leaq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq 0x17215(%rip), %rdi     # 0x1ad90
leaq 0xd4ca(%rip), %rsi      # 0x1104c
callq 0x5440
movq -0x78(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq 0x171f3(%rip), %rdi     # 0x1ad90
leaq 0xd4ac(%rip), %rsi      # 0x11050
callq 0x5440
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq 0x171d1(%rip), %rdi     # 0x1ad90
leaq 0xd48e(%rip), %rsi      # 0x11054
callq 0x5440
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
movl $0x0, -0x54(%rbp)
cmpl $0xa, -0x54(%rbp)
jge 0x3c39
movl $0x0, -0x58(%rbp)
cmpl $0x3, -0x58(%rbp)
jge 0x3c2c
movslq -0x58(%rbp), %rax
movl -0x1c(%rbp,%rax,4), %eax
movl %eax, 0x16d6a(%rip)     # 0x1a964
callq 0x2fe0
callq 0x3270
callq 0x3490
callq 0x3740
movq 0x163c3(%rip), %rdi     # 0x19fd8
leaq 0xd636(%rip), %rsi      # 0x11252
callq 0x2130
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3be6
jmp 0x3c2e
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3bd9
movl $0x0, -0x5c(%rbp)
cmpl $0x3, -0x5c(%rbp)
jge 0x3e58
movslq -0x5c(%rbp), %rax
movl -0x1c(%rbp,%rax,4), %eax
movl %eax, 0x16d0c(%rip)     # 0x1a964
leaq 0x17131(%rip), %rdi     # 0x1ad90
leaq 0x16cfe(%rip), %rsi     # 0x1a964
callq 0x5440
movq (%rax), %rax
cvtsi2ssl (%rax), %xmm0
movss 0xd416(%rip), %xmm1     # 0x11090
divss %xmm1, %xmm0
movss %xmm0, -0x60(%rbp)
movl 0x16cdb(%rip), %esi     # 0x1a964
movq 0x16348(%rip), %rdi     # 0x19fd8
callq 0x2200
movq %rax, %rdi
leaq 0xd6a1(%rip), %rsi      # 0x11340
callq 0x2130
movq %rax, %rdi
movss -0x60(%rbp), %xmm0
callq 0x20d0
movq %rax, %rdi
leaq 0xd594(%rip), %rsi      # 0x1124f
callq 0x2130
movq %rax, %rdi
leaq 0xd588(%rip), %rsi      # 0x11252
callq 0x2130
leaq 0x170ba(%rip), %rdi     # 0x1ad90
leaq 0x16c87(%rip), %rsi     # 0x1a964
callq 0x5440
movq (%rax), %rax
cvtsi2ssl 0x4(%rax), %xmm0
movss 0xd39e(%rip), %xmm1     # 0x11090
divss %xmm1, %xmm0
movss %xmm0, -0x60(%rbp)
movl 0x16c63(%rip), %esi     # 0x1a964
movq 0x162d0(%rip), %rdi     # 0x19fd8
callq 0x2200
movq %rax, %rdi
leaq 0xd65a(%rip), %rsi      # 0x11371
callq 0x2130
movq %rax, %rdi
movss -0x60(%rbp), %xmm0
callq 0x20d0
movq %rax, %rdi
leaq 0xd51c(%rip), %rsi      # 0x1124f
callq 0x2130
movq %rax, %rdi
leaq 0xd510(%rip), %rsi      # 0x11252
callq 0x2130
leaq 0x17042(%rip), %rdi     # 0x1ad90
leaq 0x16c0f(%rip), %rsi     # 0x1a964
callq 0x5440
movq (%rax), %rax
cvtsi2ssl 0x8(%rax), %xmm0
movss 0xd326(%rip), %xmm1     # 0x11090
divss %xmm1, %xmm0
movss %xmm0, -0x60(%rbp)
movl 0x16beb(%rip), %esi     # 0x1a964
movq 0x16258(%rip), %rdi     # 0x19fd8
callq 0x2200
movq %rax, %rdi
leaq 0xd611(%rip), %rsi      # 0x113a0
callq 0x2130
movq %rax, %rdi
movss -0x60(%rbp), %xmm0
callq 0x20d0
movq %rax, %rdi
leaq 0xd4a4(%rip), %rsi      # 0x1124f
callq 0x2130
movq %rax, %rdi
leaq 0xd498(%rip), %rsi      # 0x11252
callq 0x2130
leaq 0x16fca(%rip), %rdi     # 0x1ad90
leaq 0x16b97(%rip), %rsi     # 0x1a964
callq 0x5440
movq (%rax), %rax
cvtsi2ssl 0xc(%rax), %xmm0
movss 0xd2ae(%rip), %xmm1     # 0x11090
divss %xmm1, %xmm0
movss %xmm0, -0x60(%rbp)
movl 0x16b73(%rip), %esi     # 0x1a964
movq 0x161e0(%rip), %rdi     # 0x19fd8
callq 0x2200
movq %rax, %rdi
leaq 0xd5ca(%rip), %rsi      # 0x113d1
callq 0x2130
movq %rax, %rdi
movss -0x60(%rbp), %xmm0
callq 0x20d0
movq %rax, %rdi
leaq 0xd42c(%rip), %rsi      # 0x1124f
callq 0x2130
movq %rax, %rdi
leaq 0xd420(%rip), %rsi      # 0x11252
callq 0x2130
movq 0x1619a(%rip), %rdi     # 0x19fd8
leaq 0xd40d(%rip), %rsi      # 0x11252
callq 0x2130
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3c40
xorl %eax, %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)