// File: /workspace/github_cpp_makefile_star2_O2/migueeelvargas[P]Auto-Complete/test.cpp
// Function: modeTrie(DictionaryTrie*, 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>>>>&, 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 modeTrie (DictionaryTrie* dictionaryTrie, 
              std::vector<std::string>& words,
              std::vector<std::string>& wordsNotIn) {
    /* Test - insert() */
  std::cout << "Inserting strings..." << std::endl;
  for( auto i = words.begin(); i != words.end(); ++i) {
    // auto freq = (unsigned int)rand()%100;
    auto freq = 10;
    if (dictionaryTrie->insert(*i, freq))
      std::cout << "Inserted " << "\"" << *i << ", " << freq << "\"" << std::endl;

    else {
      std::cout << "\"" << *i << "\"" << " is already in dictionary." << std::endl;
      pass = false;
    }
  }
  if (pass)
    std::cout << "PASSED." << std::endl << std::endl;
  else 
    std::cout << "FAILED." << std::endl << std::endl;

  /* Testing Re-Insert - Should return all false */
  pass = true;
  std::cout << "Re-Inserting strings..." << std::endl;
  for( auto i = words.begin(); i != words.end(); ++i) {
    if (dictionaryTrie->insert(*i, 10)) {
      std::cout << "Inserted " << "\"" << *i << "\"" << std::endl;
      pass = false;
    }

    else 
      std::cout << "\"" << *i << "\"" << " is already in dictionary." << std::endl;
  }
  if (pass)
    std::cout << "PASSED." << std::endl << std::endl;
  else 
    std::cout << "FAILED." << std::endl << std::endl;

  /* Testing - find() */
  pass = true;
  std::cout << "Finding strings..." << std::endl;
  for( auto i = words.begin(); i != words.end(); ++i) {
    if (dictionaryTrie->find(*i))
      std::cout << "Found " << "\"" << *i << "\"" << std::endl;

    else {
      std::cout << "\"" << *i << "\"" << " is not in the dictionary." << std::endl;
      pass = false;
    }
  }
  for( auto i = wordsNotIn.begin(); i != wordsNotIn.end(); ++i) {
    if (dictionaryTrie->find(*i)) {
      std::cout << "Found " << "\"" << *i << "\"" << std::endl;
      pass = false;
    }

    else {
      std::cout << "\"" << *i << "\"" << " is not in the dictionary." << std::endl;
    }
  }
  if (pass)
    std::cout << "PASSED." << std::endl << std::endl;
  else 
    std::cout << "FAILED." << std::endl << std::endl << std::endl;

  /* Print # of vertices */
  std::cout << "# of vertices: " << dictionaryTrie->num_vertices << std::endl << std::endl;

  /* Testing predictCompletions */
  std::cout << "Testing predictCompletions..." << std::endl;
  auto prefix = "b";
  auto num = 4;

  auto completions = dictionaryTrie->predictCompletions(prefix, num);

  if(completions.empty())
    std::cout << std::endl << "The prefix does not have any words in the dictionary." << std::endl;

  else {
    std::cout << "finding the top " << num << " completions for: " << prefix << std::endl;

    for(auto it = completions.begin(); it != completions.end(); ++it) {
      std::cout << *it << std::endl;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movq 0x52f0(%rip), %rdi      # 0x7fd8
leaq 0x23eb(%rip), %rsi      # 0x50da
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq (%r15), %r13
leaq 0xa8(%rsp), %rbp
leaq 0x234d(%rip), %r12      # 0x505b
cmpq 0x8(%r15), %r13
je 0x2dde
movq %rbp, %rdi
movq %r13, %rsi
callq 0x21d0
movq %rbx, %rdi
movq %rbp, %rsi
pushq $0xa
popq %rdx
callq 0x3fa0
movl %eax, %r14d
movq %rbp, %rdi
callq 0x20b0
movq 0x5295(%rip), %rdi      # 0x7fd8
testb %r14b, %r14b
je 0x2d99
leaq 0x2302(%rip), %rsi      # 0x5051
callq 0x2160
movq %rax, %rdi
movq %r12, %rsi
callq 0x2160
movq %rax, %rdi
movq %r13, %rsi
callq 0x2150
movq %rax, %rdi
leaq 0x2360(%rip), %rsi      # 0x50d4
callq 0x2160
movq %rax, %rdi
pushq $0xa
popq %rsi
callq 0x2220
movq %rax, %rdi
movq %r12, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
jmp 0x2dd5
movq %r12, %rsi
callq 0x2160
movq %rax, %rdi
movq %r13, %rsi
callq 0x2150
movq %rax, %rdi
movq %r12, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x229c(%rip), %rsi      # 0x505d
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movb $0x0, 0x5363(%rip)      # 0x8138
addq $0x20, %r13
jmp 0x2d0e
leaq 0x2293(%rip), %rax      # 0x5078
cmpb $0x0, 0x534c(%rip)      # 0x8138
leaq 0x228d(%rip), %rsi      # 0x5080
cmovneq %rax, %rsi
movq 0x51da(%rip), %r14      # 0x7fd8
movq %r14, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x20c0
movb $0x1, 0x531b(%rip)      # 0x8138
leaq 0x22b3(%rip), %rsi      # 0x50d7
movq %r14, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq (%r15), %r14
leaq 0x88(%rsp), %rbp
leaq 0x2215(%rip), %r13      # 0x505b
cmpq 0x8(%r15), %r14
je 0x2efc
movq %rbp, %rdi
movq %r14, %rsi
callq 0x21d0
movq %rbx, %rdi
movq %rbp, %rsi
pushq $0xa
popq %rdx
callq 0x3fa0
movl %eax, %r12d
movq %rbp, %rdi
callq 0x20b0
movq 0x515d(%rip), %rdi      # 0x7fd8
testb %r12b, %r12b
je 0x2ebe
leaq 0x21ca(%rip), %rsi      # 0x5051
callq 0x2160
movq %rax, %rdi
movq %r13, %rsi
callq 0x2160
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
movq %r13, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movb $0x0, 0x527c(%rip)      # 0x8138
jmp 0x2ef3
movq %r13, %rsi
callq 0x2160
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
movq %r13, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x2177(%rip), %rsi      # 0x505d
callq 0x2160
movq %rax, %rdi
callq 0x20c0
addq $0x20, %r14
jmp 0x2e46
cmpb $0x0, 0x5235(%rip)      # 0x8138
leaq 0x2176(%rip), %rsi      # 0x5080
leaq 0x2167(%rip), %rax      # 0x5078
cmovneq %rax, %rsi
movq 0x50bc(%rip), %r14      # 0x7fd8
movq %r14, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x20c0
movb $0x1, 0x51fd(%rip)      # 0x8138
leaq 0x214c(%rip), %rsi      # 0x508e
movq %r14, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq (%r15), %r14
leaq 0x68(%rsp), %r12
leaq 0x20fa(%rip), %rbp      # 0x505b
cmpq 0x8(%r15), %r14
je 0x3014
movq %r12, %rdi
movq %r14, %rsi
callq 0x21d0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x414a
movl %eax, %r13d
movq %r12, %rdi
callq 0x20b0
movq 0x5045(%rip), %rdi      # 0x7fd8
testb %r13b, %r13b
je 0x2fcf
leaq 0x2102(%rip), %rsi      # 0x50a1
callq 0x2160
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
jmp 0x300b
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x20b8(%rip), %rsi      # 0x50af
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movb $0x0, 0x512d(%rip)      # 0x8138
addq $0x20, %r14
jmp 0x2f61
movq 0x8(%rsp), %rax
movq (%rax), %r14
leaq 0x48(%rsp), %r15
movq 0x4fb0(%rip), %r12      # 0x7fd8
leaq 0x202c(%rip), %rbp      # 0x505b
movq 0x8(%rsp), %rax
cmpq 0x8(%rax), %r14
je 0x30e3
movq %r15, %rdi
movq %r14, %rsi
callq 0x21d0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x414a
movl %eax, %r13d
movq %r15, %rdi
callq 0x20b0
movq %r12, %rdi
testb %r13b, %r13b
je 0x30a5
leaq 0x2033(%rip), %rsi      # 0x50a1
callq 0x2160
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movb $0x0, 0x5095(%rip)      # 0x8138
jmp 0x30da
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x1fe2(%rip), %rsi      # 0x50af
callq 0x2160
movq %rax, %rdi
callq 0x20c0
addq $0x20, %r14
jmp 0x302f
cmpb $0x0, 0x504e(%rip)      # 0x8138
je 0x3101
movq 0x4ee5(%rip), %rdi      # 0x7fd8
leaq 0x1f7e(%rip), %rsi      # 0x5078
callq 0x2160
jmp 0x311c
movq 0x4ed0(%rip), %rdi      # 0x7fd8
leaq 0x1f71(%rip), %rsi      # 0x5080
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x20c0
movq 0x4ea5(%rip), %r14      # 0x7fd8
leaq 0x1fb5(%rip), %rsi      # 0x50ef
movq %r14, %rdi
callq 0x2160
movl (%rbx), %esi
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20c0
movq %rax, %rdi
callq 0x20c0
leaq 0x1f9c(%rip), %rsi      # 0x50ff
movq %r14, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq 0x1e95(%rip), %rsi      # 0x500f
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x32bc
leaq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rdx
pushq $0x4
popq %rcx
movq %rbx, %rsi
callq 0x4216
leaq 0x28(%rsp), %rdi
callq 0x20b0
movq 0x10(%rsp), %rax
cmpq 0x18(%rsp), %rax
je 0x3224
movq 0x4e1d(%rip), %rdi      # 0x7fd8
leaq 0x1f91(%rip), %rsi      # 0x5153
callq 0x2160
pushq $0x4
popq %rsi
movq %rax, %rdi
callq 0x2220
leaq 0x1f8b(%rip), %rsi      # 0x5164
movq %rax, %rdi
callq 0x2160
leaq 0x1e27(%rip), %rsi      # 0x500f
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
movq 0x10(%rsp), %rbx
movq 0x4dd4(%rip), %r14      # 0x7fd8
cmpq 0x18(%rsp), %rbx
je 0x3247
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20c0
addq $0x20, %rbx
jmp 0x3204
movq 0x4dad(%rip), %rdi      # 0x7fd8
callq 0x20c0
leaq 0x1ee6(%rip), %rsi      # 0x511d
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq 0x10(%rsp), %rdi
callq 0x32f8
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x32a0
movq %rax, %rbx
jmp 0x32b4
jmp 0x32a7
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x32a0
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x32a0
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x32a0
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x20b0
jmp 0x32b4
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x32f8
movq %rbx, %rdi
callq 0x2230