// File: /workspace/github_cpp_makefile_star2_O1/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 $0x258, %rsp            # imm = 0x258
movq %r8, 0x10(%rsp)
movl %ecx, %ebx
movl %edx, 0xc(%rsp)
movl %esi, 0x8(%rsp)
movq %rdi, %r15
movq 0x84cf(%rip), %r14      # 0xafd8
leaq 0x5593(%rip), %rsi      # 0x80a3
movl $0xf, %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 0x2d28
leaq 0x40(%rsp), %rbp
movl %ebx, %eax
movq %rax, 0x18(%rsp)
xorl %r14d, %r14d
leaq 0x8681(%rip), %r12      # 0xb200
leaq 0x30(%rsp), %r13
movl $0x10, %edi
callq 0x21c0
movq %rax, %r15
movq %rax, %rdi
callq 0x5dc0
movl %r14d, %ebx
imull 0xc(%rsp), %ebx
addl 0x8(%rsp), %ebx
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
movl %ebx, %edx
callq 0x55e8
movq %r14, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %r14
cmpq 0x8(%rax), %r14
je 0x2c58
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 0x6016
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2c0c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %r12, %rdi
callq 0x3a4a
movq %rax, 0x28(%rsp)
movq 0x85c0(%rip), %rsi      # 0xb1e0
cmpq 0x85c1(%rip), %rsi      # 0xb1e8
je 0x2c39
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x85a9(%rip)      # 0xb1e0
jmp 0x2c4a
leaq 0x8598(%rip), %rdi      # 0xb1d8
leaq 0x28(%rsp), %rdx
callq 0x38fe
addq $0x20, %r14
movq 0x10(%rsp), %rax
jmp 0x2bc1
movq 0x8579(%rip), %rdx      # 0xb1d8
movq 0x857a(%rip), %rcx      # 0xb1e0
cmpq %rcx, %rdx
je 0x2c88
movq 0x8586(%rip), %rax      # 0xb1f8
movq %rdx, %rsi
addq (%rsi), %rax
movq %rax, 0x8579(%rip)      # 0xb1f8
addq $0x8, %rsi
cmpq %rcx, %rsi
jne 0x2c75
movq 0x8569(%rip), %rax      # 0xb1f8
subq %rdx, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0x854e(%rip)      # 0xb1f0
movl %ebx, %esi
movq 0x832d(%rip), %rdi      # 0xafd8
callq 0x2130
movq 0x20(%rsp), %r14
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x53ec(%rip), %rsi      # 0x80b3
callq 0x2210
movq 0x851d(%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 0x5dd0
movl $0x10, %esi
movq %r15, %rdi
callq 0x21d0
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x2b84
movq 0x82a9(%rip), %rdi      # 0xafd8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x828e(%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 0x2da2
movq %rax, %rbx
movl $0x10, %esi
movq %r15, %rdi
jmp 0x2d99
jmp 0x2da2
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2da5
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21d0
jmp 0x2da5
jmp 0x2da2
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x22e0