// File: /workspace/github_cpp_makefile_star2_O1/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 0x81f7(%rip), %r14      # 0xafd8
leaq 0x52cd(%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 0x3000
leaq 0x40(%rsp), %rbp
movl %ebx, %eax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
leaq 0x83a9(%rip), %r12      # 0xb200
leaq 0x30(%rsp), %r13
movl $0x30, %edi
callq 0x21c0
movq %rax, %r15
movq %rax, %rdi
callq 0x68e0
movl %r14d, %ebx
imull 0xc(%rsp), %ebx
addl 0x8(%rsp), %ebx
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
movl %ebx, %edx
callq 0x3fd2
movq %r14, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %r14
cmpq 0x8(%rax), %r14
je 0x2f30
movq %r12, %rdi
callq 0x3a3c
movq %rbp, 0x30(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x34b0
movq %r15, %rdi
movq %r13, %rsi
callq 0x699e
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2ee4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %r12, %rdi
callq 0x3a4a
movq %rax, 0x28(%rsp)
movq 0x82e8(%rip), %rsi      # 0xb1e0
cmpq 0x82e9(%rip), %rsi      # 0xb1e8
je 0x2f11
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x82d1(%rip)      # 0xb1e0
jmp 0x2f22
leaq 0x82c0(%rip), %rdi      # 0xb1d8
leaq 0x28(%rsp), %rdx
callq 0x38fe
addq $0x20, %r14
movq 0x10(%rsp), %rax
jmp 0x2e99
movq 0x82a1(%rip), %rdx      # 0xb1d8
movq 0x82a2(%rip), %rcx      # 0xb1e0
cmpq %rcx, %rdx
je 0x2f60
movq 0x82ae(%rip), %rax      # 0xb1f8
movq %rdx, %rsi
addq (%rsi), %rax
movq %rax, 0x82a1(%rip)      # 0xb1f8
addq $0x8, %rsi
cmpq %rcx, %rsi
jne 0x2f4d
movq 0x8291(%rip), %rax      # 0xb1f8
subq %rdx, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0x8276(%rip)      # 0xb1f0
movl %ebx, %esi
movq 0x8055(%rip), %rdi      # 0xafd8
callq 0x2130
movq 0x20(%rsp), %r14
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5114(%rip), %rsi      # 0x80b3
callq 0x2210
movq 0x8245(%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 0x69b4
movl $0x30, %esi
movq %r15, %rdi
callq 0x21d0
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x2e5c
movq 0x7fd1(%rip), %rdi      # 0xafd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x7fb6(%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 0x307a
movq %rax, %rbx
movl $0x30, %esi
movq %r15, %rdi
jmp 0x3071
jmp 0x307a
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x307d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x307d
jmp 0x307a
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x22e0