// File: /workspace/github_cpp_makefile_star2_O2/migueeelvargas[P]Auto-Complete/benchdict.cpp
// Function: testTrie(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 testTrie(std::string dictionary, int minSize, 
  int stepSize, unsigned int iterations, std::vector<std::string> words) {

  // Display title
  std::cout << "DictionaryTrie:" << 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) {
    // Allocate heap memory for diciontary
    DictionaryTrie* dictTrie = new DictionaryTrie();

    // Load the dictionary
    Utils::load_dict(*dictTrie, 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();
      dictTrie->find(*it);
      times.push_back(T.end_timer());
    }

    // Add up all the times
    for (auto &i : times)
      sum = sum + i;

    // Find the average time
    duration = (sum/times.size());
                 
    // Print the results
    std::cout << ((minSize)+(i*stepSize)) << "\t" << duration  << std::endl;

    // Free memory
    delete dictTrie;
  }
  std::cout << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %r8, %rbx
movl %ecx, %ebp
movl %edx, 0x4(%rsp)
movl %esi, (%rsp)
movq %rdi, %r14
movq 0x7663(%rip), %rdi      # 0x9fd8
leaq 0x3727(%rip), %rsi      # 0x60a3
callq 0x21c0
movq %rax, %rdi
callq 0x2120
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x2210
pushq $0x4
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x21a0
movl %ebp, %eax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
pushq $0x10
popq %r14
leaq 0x7848(%rip), %r13      # 0xa200
leaq 0x20(%rsp), %r12
cmpq 0x10(%rsp), %rax
je 0x2ae9
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0x21d0
movq %rax, %r15
movq %rax, %rdi
callq 0x48b4
movq 0x8(%rsp), %rax
movl %eax, %ebp
imull 0x4(%rsp), %ebp
addl (%rsp), %ebp
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
movl %ebp, %edx
callq 0x43f0
movq (%rbx), %r14
cmpq 0x8(%rbx), %r14
je 0x2a51
movq %r13, %rdi
callq 0x3508
movq %r12, %rdi
movq %r14, %rsi
callq 0x2260
movq %r15, %rdi
movq %r12, %rsi
callq 0x4ab6
movq %r12, %rdi
callq 0x2100
movq %r13, %rdi
callq 0x3516
movq %rax, 0x18(%rsp)
leaq 0x7797(%rip), %rdi      # 0xa1d8
leaq 0x18(%rsp), %rsi
callq 0x338c
addq $0x20, %r14
jmp 0x2a01
movq 0x7780(%rip), %rdx      # 0xa1d8
movq 0x7781(%rip), %rcx      # 0xa1e0
movq 0x7792(%rip), %rax      # 0xa1f8
movq %rdx, %rsi
cmpq %rcx, %rsi
je 0x2a7e
addq (%rsi), %rax
movq %rax, 0x7780(%rip)      # 0xa1f8
addq $0x8, %rsi
jmp 0x2a69
subq %rdx, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0x775f(%rip)      # 0xa1f0
movl %ebp, %esi
movq 0x753e(%rip), %rdi      # 0x9fd8
callq 0x2150
movq %rax, %rdi
leaq 0x360a(%rip), %rsi      # 0x60b3
callq 0x21c0
movq 0x773b(%rip), %rsi      # 0xa1f0
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x2120
movq %r15, %rdi
callq 0x48be
movq %r15, %rdi
pushq $0x10
popq %r14
movq %r14, %rsi
callq 0x21e0
movq 0x8(%rsp), %rax
incq %rax
jmp 0x29bd
movq 0x74e8(%rip), %rdi      # 0x9fd8
callq 0x2120
leaq 0x40(%rsp), %rdi
callq 0x2080
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b36
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r15, %rdi
callq 0x21e0
jmp 0x2b39
jmp 0x2b36
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2100
jmp 0x2b39
jmp 0x2b36
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x22e0