// File: 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
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x2a0(%rbp)
movq %r8, -0x2b0(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq 0x11047(%rip), %rdi     # 0x14fd8
leaq 0xa0ef(%rip), %rsi      # 0xe087
callq 0x3210
movq %rax, %rdi
movq 0x11021(%rip), %rsi     # 0x14fc8
callq 0x3250
leaq -0x228(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0x32b0
movq -0x2a8(%rbp), %rdi
movq -0x2a0(%rbp), %rsi
movl $0x4, %edx
callq 0x31f0
jmp 0x3fd9
movl $0x0, -0x238(%rbp)
movl -0x238(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x4300
movl $0x10, %edi
callq 0x3220
movq %rax, -0x2b8(%rbp)
jmp 0x4005
movq -0x2b8(%rbp), %rdi
callq 0x8e70
jmp 0x4013
movq -0x2b8(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rdi
movl -0xc(%rbp), %edx
movl -0x238(%rbp), %eax
movl -0x10(%rbp), %ecx
imull %ecx, %eax
addl %eax, %edx
leaq -0x228(%rbp), %rsi
callq 0x8310
jmp 0x4047
movq -0x2b0(%rbp), %rdi
callq 0x4e00
movq %rax, -0x248(%rbp)
movq -0x2b0(%rbp), %rdi
callq 0x4e70
movq %rax, -0x250(%rbp)
leaq -0x248(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x4e30
testb $0x1, %al
jne 0x4089
jmp 0x4190
leaq 0x111f8(%rip), %rdi     # 0x15288
callq 0x6b80
jmp 0x4097
movq -0x240(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x4ea0
movq %rax, %rsi
leaq -0x270(%rbp), %rdi
callq 0x30f0
jmp 0x40c2
movq -0x2c0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x9460
jmp 0x40d7
leaq -0x270(%rbp), %rdi
callq 0x3170
leaq 0x1119e(%rip), %rdi     # 0x15288
callq 0x6bc0
movq %rax, -0x2c8(%rbp)
jmp 0x40f8
movq -0x2c8(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq 0x11153(%rip), %rdi     # 0x15260
leaq -0x278(%rbp), %rsi
callq 0x4ec0
jmp 0x411b
jmp 0x411d
leaq -0x248(%rbp), %rdi
callq 0x4ef0
jmp 0x405a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x432a
movq -0x2b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
movl $0x10, %esi
callq 0x3230
jmp 0x432a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x3170
jmp 0x432a
leaq 0x110c9(%rip), %rax     # 0x15260
movq %rax, -0x280(%rbp)
leaq 0x110bb(%rip), %rdi     # 0x15260
callq 0x4f10
movq %rax, -0x288(%rbp)
leaq 0x110a8(%rip), %rdi     # 0x15260
callq 0x4f40
movq %rax, -0x290(%rbp)
leaq -0x288(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x4f70
testb $0x1, %al
jne 0x41dd
jmp 0x4216
leaq -0x288(%rbp), %rdi
callq 0x4fb0
movq %rax, -0x298(%rbp)
movq 0x11089(%rip), %rax     # 0x15280
movq -0x298(%rbp), %rcx
addq (%rcx), %rax
movq %rax, 0x11078(%rip)     # 0x15280
leaq -0x288(%rbp), %rdi
callq 0x4fd0
jmp 0x41c4
movq 0x11063(%rip), %rax     # 0x15280
movq %rax, -0x2d8(%rbp)
leaq 0x11035(%rip), %rdi     # 0x15260
callq 0x4ff0
movq %rax, %rcx
movq -0x2d8(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rax, 0x11032(%rip)     # 0x15278
movl -0xc(%rbp), %esi
movl -0x238(%rbp), %eax
movl -0x10(%rbp), %ecx
imull %ecx, %eax
addl %eax, %esi
movq 0x10d7a(%rip), %rdi     # 0x14fd8
callq 0x3320
movq %rax, -0x2d0(%rbp)
jmp 0x426c
movq -0x2d0(%rbp), %rdi
leaq 0x9e1d(%rip), %rsi      # 0xe097
callq 0x3210
movq %rax, -0x2e0(%rbp)
jmp 0x4288
movq -0x2e0(%rbp), %rdi
movq 0x10fe2(%rip), %rsi     # 0x15278
callq 0x3140
movq %rax, -0x2e8(%rbp)
jmp 0x42a4
movq -0x2e8(%rbp), %rdi
movq 0x10d16(%rip), %rsi     # 0x14fc8
callq 0x3250
jmp 0x42b9
movq -0x240(%rbp), %rax
movq %rax, -0x2f0(%rbp)
cmpq $0x0, %rax
je 0x42ea
movq -0x2f0(%rbp), %rdi
callq 0x8e90
movq -0x2f0(%rbp), %rdi
movl $0x10, %esi
callq 0x3230
jmp 0x42ec
movl -0x238(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x238(%rbp)
jmp 0x3fe3
movq 0x10cd1(%rip), %rdi     # 0x14fd8
movq 0x10cba(%rip), %rsi     # 0x14fc8
callq 0x3250
jmp 0x4315
leaq -0x228(%rbp), %rdi
callq 0x30a0
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
leaq -0x228(%rbp), %rdi
callq 0x30a0
movq -0x230(%rbp), %rdi
callq 0x33c0
nopw %cs:(%rax,%rax)