// File: 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
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 0x10c57(%rip), %rdi     # 0x14fd8
leaq 0x9d11(%rip), %rsi      # 0xe099
callq 0x3210
movq %rax, %rdi
movq 0x10c31(%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 0x43c9
movl $0x0, -0x238(%rbp)
movl -0x238(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x46f0
movl $0x30, %edi
callq 0x3220
movq %rax, -0x2b8(%rbp)
jmp 0x43f5
movq -0x2b8(%rbp), %rdi
callq 0xade0
jmp 0x4403
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 0x70c0
jmp 0x4437
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 0x4479
jmp 0x4580
leaq 0x10e08(%rip), %rdi     # 0x15288
callq 0x6b80
jmp 0x4487
movq -0x240(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x4ea0
movq %rax, %rsi
leaq -0x270(%rbp), %rdi
callq 0x30f0
jmp 0x44b2
movq -0x2c0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0xaea0
jmp 0x44c7
leaq -0x270(%rbp), %rdi
callq 0x3170
leaq 0x10dae(%rip), %rdi     # 0x15288
callq 0x6bc0
movq %rax, -0x2c8(%rbp)
jmp 0x44e8
movq -0x2c8(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq 0x10d63(%rip), %rdi     # 0x15260
leaq -0x278(%rbp), %rsi
callq 0x4ec0
jmp 0x450b
jmp 0x450d
leaq -0x248(%rbp), %rdi
callq 0x4ef0
jmp 0x444a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x471a
movq -0x2b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
movl $0x30, %esi
callq 0x3230
jmp 0x471a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x3170
jmp 0x471a
leaq 0x10cd9(%rip), %rax     # 0x15260
movq %rax, -0x280(%rbp)
leaq 0x10ccb(%rip), %rdi     # 0x15260
callq 0x4f10
movq %rax, -0x288(%rbp)
leaq 0x10cb8(%rip), %rdi     # 0x15260
callq 0x4f40
movq %rax, -0x290(%rbp)
leaq -0x288(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x4f70
testb $0x1, %al
jne 0x45cd
jmp 0x4606
leaq -0x288(%rbp), %rdi
callq 0x4fb0
movq %rax, -0x298(%rbp)
movq 0x10c99(%rip), %rax     # 0x15280
movq -0x298(%rbp), %rcx
addq (%rcx), %rax
movq %rax, 0x10c88(%rip)     # 0x15280
leaq -0x288(%rbp), %rdi
callq 0x4fd0
jmp 0x45b4
movq 0x10c73(%rip), %rax     # 0x15280
movq %rax, -0x2d8(%rbp)
leaq 0x10c45(%rip), %rdi     # 0x15260
callq 0x4ff0
movq %rax, %rcx
movq -0x2d8(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rax, 0x10c42(%rip)     # 0x15278
movl -0xc(%rbp), %esi
movl -0x238(%rbp), %eax
movl -0x10(%rbp), %ecx
imull %ecx, %eax
addl %eax, %esi
movq 0x1098a(%rip), %rdi     # 0x14fd8
callq 0x3320
movq %rax, -0x2d0(%rbp)
jmp 0x465c
movq -0x2d0(%rbp), %rdi
leaq 0x9a2d(%rip), %rsi      # 0xe097
callq 0x3210
movq %rax, -0x2e0(%rbp)
jmp 0x4678
movq -0x2e0(%rbp), %rdi
movq 0x10bf2(%rip), %rsi     # 0x15278
callq 0x3140
movq %rax, -0x2e8(%rbp)
jmp 0x4694
movq -0x2e8(%rbp), %rdi
movq 0x10926(%rip), %rsi     # 0x14fc8
callq 0x3250
jmp 0x46a9
movq -0x240(%rbp), %rax
movq %rax, -0x2f0(%rbp)
cmpq $0x0, %rax
je 0x46da
movq -0x2f0(%rbp), %rdi
callq 0xaf00
movq -0x2f0(%rbp), %rdi
movl $0x30, %esi
callq 0x3230
jmp 0x46dc
movl -0x238(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x238(%rbp)
jmp 0x43d3
movq 0x108e1(%rip), %rdi     # 0x14fd8
movq 0x108ca(%rip), %rsi     # 0x14fc8
callq 0x3250
jmp 0x4705
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)