// File: /workspace/github_cpp_makefile_star2_O3/migueeelvargas[P]Auto-Complete/benchdict.cpp
// Function: testBST(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, unsigned int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>)
void testBST(std::string dictionary, int minSize, 
  int stepSize, unsigned int iterations, std::vector<std::string> words) {

  // Display title
  std::cout << "DictionaryBST:" << std::endl;

  // Open a stream to read input file
  std::ifstream ifs;
  ifs.open(dictionary, std::ios::binary);

  // Find average times
  for (unsigned i = 0; i < iterations; ++i) {

    DictionaryBST* dictBST = new DictionaryBST();
    //loading dictionary
    Utils::load_dict(*dictBST, ifs, (minSize+(i*stepSize)));
    
    /* timing 10 finds that are not in the dictionary */
    for (auto it = words.begin(); it != words.end(); ++it) {
      T.begin_timer();
      dictBST->find(*it);
      times.push_back(T.end_timer());
    }

    for (auto &i : times) {
      sum = sum + i;
    }
    duration = (sum/times.size());
                 
    // Print the results
    std::cout << ((minSize)+(i*stepSize)) << "\t" << duration  << std::endl;

    delete dictBST;
  }
  std::cout << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %r8, 0x10(%rsp)
movl %ecx, %ebx
movl %edx, 0xc(%rsp)
movl %esi, 0x8(%rsp)
movq %rdi, %r15
movq 0x81fe(%rip), %r14      # 0xafd8
leaq 0x52d4(%rip), %rsi      # 0x80b5
movl $0xe, %edx
movq %r14, %rdi
callq 0x2210
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0x50(%rsp), %r12
movq %r12, %rdi
callq 0x2200
movq %r12, %rdi
movq %r15, %rsi
movl $0x4, %edx
callq 0x2190
testl %ebx, %ebx
je 0x2ff2
leaq 0x40(%rsp), %rbp
movl %ebx, %eax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
leaq 0x83b0(%rip), %r12      # 0xb200
leaq 0x30(%rsp), %r13
movl $0x30, %edi
callq 0x21c0
movq %rax, %r15
movq %rax, %rdi
callq 0x6908
movl %r14d, %ebx
imull 0xc(%rsp), %ebx
addl 0x8(%rsp), %ebx
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
movl %ebx, %edx
callq 0x3fd6
movq %r14, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %r14
cmpq 0x8(%rax), %r14
je 0x2f29
movq %r12, %rdi
callq 0x3a38
movq %rbp, 0x30(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x349c
movq %r15, %rdi
movq %r13, %rsi
callq 0x69c6
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2edd
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %r12, %rdi
callq 0x3a46
movq %rax, 0x28(%rsp)
movq 0x82ef(%rip), %rsi      # 0xb1e0
cmpq 0x82f0(%rip), %rsi      # 0xb1e8
je 0x2f0a
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x82d8(%rip)      # 0xb1e0
jmp 0x2f1b
leaq 0x82c7(%rip), %rdi      # 0xb1d8
leaq 0x28(%rsp), %rdx
callq 0x38fc
addq $0x20, %r14
movq 0x10(%rsp), %rax
jmp 0x2e92
movq 0x82a8(%rip), %rdx      # 0xb1d8
movq 0x82a9(%rip), %rcx      # 0xb1e0
movq 0x82ba(%rip), %rax      # 0xb1f8
movq %rdx, %rsi
cmpq %rcx, %rdx
je 0x2f59
addq (%rsi), %rax
movq %rax, 0x82a8(%rip)      # 0xb1f8
addq $0x8, %rsi
cmpq %rcx, %rsi
jne 0x2f46
subq %rdx, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0x8284(%rip)      # 0xb1f0
movl %ebx, %esi
movq 0x8063(%rip), %rdi      # 0xafd8
callq 0x2130
movq 0x20(%rsp), %r14
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5122(%rip), %rsi      # 0x80b3
callq 0x2210
movq 0x8253(%rip), %rsi      # 0xb1f0
movq %rbx, %rdi
callq 0x20e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %r15, %rdi
callq 0x69dc
movl $0x30, %esi
movq %r15, %rdi
callq 0x21d0
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x2e55
movq 0x7fdf(%rip), %rdi      # 0xafd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x7fc4(%rip), %rdi      # 0xafd8
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0x50(%rsp), %rdi
callq 0x2080
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x306c
movq %rax, %rbx
movl $0x30, %esi
movq %r15, %rdi
jmp 0x3063
jmp 0x306c
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x306f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x306f
jmp 0x306c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x22e0