// File: ruankotovich[P]TextCorrection-Trie/src/main.cpp
// Function: main
int main()
{
  trie::Trie_t personTrie;

  std::string name = "Duan";
  std::string name2 = "Daniel";
  std::string name3 = "Soto";
  std::string name4 = "Roab";
  std::string name5 = "Bananation";
  std::string name6 = "SotoBanaNAO";
  std::string name7 = "Danyel";
  std::string name8 = "ovo";
  std::string name9 = "uva";

  personTrie.putIndividualWord(name, name);
  personTrie.putIndividualWord(name2, name2);
  personTrie.putIndividualWord(name3, name3);
  personTrie.putIndividualWord(name4, name4);
  personTrie.putIndividualWord(name5, name5);
  personTrie.putIndividualWord(name6, name6);
  personTrie.putIndividualWord(name7, name7);
  personTrie.putIndividualWord(name8, name8);
  personTrie.putIndividualWord(name9, name9);

  personTrie.buildActiveNodeSet(false);

  std::string search;
  std::cout << "\n >> ";
  while (std::getline(std::cin, search)) {
    std::cout << " --- Searching \"" << search << "\".\n";
    auto mSearch = personTrie.searchKeyword(search);
    if (mSearch.first) {
      for (auto element : mSearch.second) {
        std::cout << " - "<<  element << std::endl;
      }
    } else {
      std::cout << " --- Couldn't find an exact match for this word, searching with errors.\n";
      auto a = personTrie.searchSimilarKeyword(search);
      if (a.empty()) {
        std::cout << " --- Couldn't find any result on this query\n";
        std::cout << "\n >> ";
        continue;
      }

      while (!a.empty()) {
        // std::cout << " -- " << a.top().content->name << " - " << a.top().content->age << '\n';
        std::cout << " - " << a.top().content << std::endl;
        a.pop();
      }
    }
    std::cout << "\n >> ";
  }
}

// Assembly:
subq $0x3b8, %rsp            # imm = 0x3B8
movl $0x0, 0x3b4(%rsp)
leaq 0x2b8(%rsp), %rdi
callq 0x2e30
leaq 0x297(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x2310
movq 0x98(%rsp), %rdx
leaq 0x13b55(%rip), %rsi     # 0x16008
leaq 0x298(%rsp), %rdi
callq 0x2250
jmp 0x24c2
leaq 0x297(%rsp), %rdi
callq 0x2200
leaq 0x25f(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x2310
movq 0x90(%rsp), %rdx
leaq 0x13b1a(%rip), %rsi     # 0x1600d
leaq 0x260(%rsp), %rdi
callq 0x2250
jmp 0x2502
leaq 0x25f(%rsp), %rdi
callq 0x2200
leaq 0x237(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x2310
movq 0x88(%rsp), %rdx
leaq 0x13ae1(%rip), %rsi     # 0x16014
leaq 0x238(%rsp), %rdi
callq 0x2250
jmp 0x2542
leaq 0x237(%rsp), %rdi
callq 0x2200
leaq 0x20f(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x2310
movq 0x80(%rsp), %rdx
leaq 0x13aa6(%rip), %rsi     # 0x16019
leaq 0x210(%rsp), %rdi
callq 0x2250
jmp 0x2582
leaq 0x20f(%rsp), %rdi
callq 0x2200
leaq 0x1e7(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x2310
movq 0x78(%rsp), %rdx
leaq 0x13a71(%rip), %rsi     # 0x1601e
leaq 0x1e8(%rsp), %rdi
callq 0x2250
jmp 0x25bc
leaq 0x1e7(%rsp), %rdi
callq 0x2200
leaq 0x1bf(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x2310
movq 0x70(%rsp), %rdx
leaq 0x13a42(%rip), %rsi     # 0x16029
leaq 0x1c0(%rsp), %rdi
callq 0x2250
jmp 0x25f6
leaq 0x1bf(%rsp), %rdi
callq 0x2200
leaq 0x197(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x2310
movq 0x68(%rsp), %rdx
leaq 0x13a14(%rip), %rsi     # 0x16035
leaq 0x198(%rsp), %rdi
callq 0x2250
jmp 0x2630
leaq 0x197(%rsp), %rdi
callq 0x2200
leaq 0x16f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x2310
movq 0x60(%rsp), %rdx
leaq 0x139e1(%rip), %rsi     # 0x1603c
leaq 0x170(%rsp), %rdi
callq 0x2250
jmp 0x266a
leaq 0x16f(%rsp), %rdi
callq 0x2200
leaq 0x147(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x2310
movq 0x58(%rsp), %rdx
leaq 0x139ab(%rip), %rsi     # 0x16040
leaq 0x148(%rsp), %rdi
callq 0x2250
jmp 0x26a4
leaq 0x147(%rsp), %rdi
callq 0x2200
leaq 0x2b8(%rsp), %rdi
leaq 0x298(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x26cb
leaq 0x2b8(%rsp), %rdi
leaq 0x260(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x26e5
leaq 0x2b8(%rsp), %rdi
leaq 0x238(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x26ff
leaq 0x2b8(%rsp), %rdi
leaq 0x210(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x2719
leaq 0x2b8(%rsp), %rdi
leaq 0x1e8(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x2733
leaq 0x2b8(%rsp), %rdi
leaq 0x1c0(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x274d
leaq 0x2b8(%rsp), %rdi
leaq 0x198(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x2767
leaq 0x2b8(%rsp), %rdi
leaq 0x170(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x2781
leaq 0x2b8(%rsp), %rdi
leaq 0x148(%rsp), %rdx
movq %rdx, %rsi
callq 0x3210
jmp 0x279b
leaq 0x2b8(%rsp), %rdi
xorl %esi, %esi
callq 0x33d0
jmp 0x27ac
leaq 0x120(%rsp), %rdi
callq 0x2260
movq 0x1e808(%rip), %rdi     # 0x20fc8
leaq 0x1387d(%rip), %rsi     # 0x16044
callq 0x21a0
jmp 0x27ce
jmp 0x27d0
movq 0x1e809(%rip), %rdi     # 0x20fe0
leaq 0x120(%rsp), %rsi
callq 0x2050
movq %rax, 0x50(%rsp)
jmp 0x27eb
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2230
movb %al, 0x4f(%rsp)
jmp 0x2805
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x2812
jmp 0x2ceb
movq 0x1e7af(%rip), %rdi     # 0x20fc8
leaq 0x1382a(%rip), %rsi     # 0x1604a
callq 0x21a0
movq %rax, 0x40(%rsp)
jmp 0x282c
movq 0x40(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x2180
movq %rax, 0x38(%rsp)
jmp 0x2845
movq 0x38(%rsp), %rdi
leaq 0x1380a(%rip), %rsi     # 0x1605b
callq 0x21a0
jmp 0x2858
leaq 0x100(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x39a0
jmp 0x2877
testb $0x1, 0x100(%rsp)
je 0x2b31
leaq 0x100(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x3b50
movq %rax, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x3b80
movq %rax, 0xe8(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3bb0
testb $0x1, %al
jne 0x28e1
jmp 0x2b2c
leaq 0xf0(%rsp), %rdi
callq 0x3bf0
movq %rax, %rsi
leaq 0xc8(%rsp), %rdi
callq 0x20b0
jmp 0x2900
movq 0x1e6c1(%rip), %rdi     # 0x20fc8
leaq 0x13751(%rip), %rsi     # 0x1605f
callq 0x21a0
movq %rax, 0x30(%rsp)
jmp 0x291a
movq 0x30(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x2180
movq %rax, 0x28(%rsp)
jmp 0x2933
movq 0x28(%rsp), %rdi
movq 0x1e679(%rip), %rsi     # 0x20fb8
callq 0x21f0
jmp 0x2946
leaq 0xc8(%rsp), %rdi
callq 0x2100
leaq 0xf0(%rsp), %rdi
callq 0x3c00
jmp 0x28c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x297(%rsp), %rdi
callq 0x2200
jmp 0x2e0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x25f(%rsp), %rdi
callq 0x2200
jmp 0x2dfe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x237(%rsp), %rdi
callq 0x2200
jmp 0x2df1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x20f(%rsp), %rdi
callq 0x2200
jmp 0x2de4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x1e7(%rsp), %rdi
callq 0x2200
jmp 0x2dd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x1bf(%rsp), %rdi
callq 0x2200
jmp 0x2dca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x197(%rsp), %rdi
callq 0x2200
jmp 0x2dbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x16f(%rsp), %rdi
callq 0x2200
jmp 0x2db0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x147(%rsp), %rdi
callq 0x2200
jmp 0x2da3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x2d96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x2d89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x2cd9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x2100
jmp 0x2cd9
jmp 0x2c95
movq 0x1e490(%rip), %rdi     # 0x20fc8
leaq 0x13524(%rip), %rsi     # 0x16063
callq 0x21a0
jmp 0x2b46
leaq 0xa8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x3c20
jmp 0x2b65
leaq 0xa8(%rsp), %rdi
callq 0x3f70
movb %al, 0x27(%rsp)
jmp 0x2b78
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x2b82
jmp 0x2be2
movq 0x1e43f(%rip), %rdi     # 0x20fc8
leaq 0x1351c(%rip), %rsi     # 0x160ac
callq 0x21a0
jmp 0x2b97
movq 0x1e42a(%rip), %rdi     # 0x20fc8
leaq 0x1349f(%rip), %rsi     # 0x16044
callq 0x21a0
jmp 0x2bac
movl $0x2, 0xa4(%rsp)
jmp 0x2c79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x3ff0
jmp 0x2cd9
jmp 0x2be4
leaq 0xa8(%rsp), %rdi
callq 0x3f70
movb %al, 0x26(%rsp)
jmp 0x2bf7
movb 0x26(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2c03
jmp 0x2c6e
movq 0x1e3be(%rip), %rdi     # 0x20fc8
leaq 0x1344e(%rip), %rsi     # 0x1605f
callq 0x21a0
movq %rax, 0x18(%rsp)
jmp 0x2c1d
leaq 0xa8(%rsp), %rdi
callq 0x3f90
movq %rax, 0x10(%rsp)
jmp 0x2c31
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x2180
movq %rax, 0x8(%rsp)
jmp 0x2c47
movq 0x8(%rsp), %rdi
movq 0x1e365(%rip), %rsi     # 0x20fb8
callq 0x21f0
jmp 0x2c5a
leaq 0xa8(%rsp), %rdi
callq 0x3fa0
jmp 0x2c69
jmp 0x2be4
movl $0x0, 0xa4(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x3ff0
movl 0xa4(%rsp), %eax
testl %eax, %eax
jne 0x2cb5
jmp 0x2c93
jmp 0x2c95
movq 0x1e32c(%rip), %rdi     # 0x20fc8
leaq 0x133a1(%rip), %rsi     # 0x16044
callq 0x21a0
jmp 0x2caa
movl $0x0, 0xa4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x4000
movl 0xa4(%rsp), %eax
testl %eax, %eax
je 0x2cd4
jmp 0x2ccf
jmp 0x27d0
jmp 0x27d0
leaq 0x100(%rsp), %rdi
callq 0x4000
jmp 0x2d89
leaq 0x120(%rsp), %rdi
callq 0x2100
leaq 0x148(%rsp), %rdi
callq 0x2100
leaq 0x170(%rsp), %rdi
callq 0x2100
leaq 0x198(%rsp), %rdi
callq 0x2100
leaq 0x1c0(%rsp), %rdi
callq 0x2100
leaq 0x1e8(%rsp), %rdi
callq 0x2100
leaq 0x210(%rsp), %rdi
callq 0x2100
leaq 0x238(%rsp), %rdi
callq 0x2100
leaq 0x260(%rsp), %rdi
callq 0x2100
leaq 0x298(%rsp), %rdi
callq 0x2100
leaq 0x2b8(%rsp), %rdi
callq 0x4020
movl 0x3b4(%rsp), %eax
addq $0x3b8, %rsp            # imm = 0x3B8
retq
leaq 0x120(%rsp), %rdi
callq 0x2100
leaq 0x148(%rsp), %rdi
callq 0x2100
leaq 0x170(%rsp), %rdi
callq 0x2100
leaq 0x198(%rsp), %rdi
callq 0x2100
leaq 0x1c0(%rsp), %rdi
callq 0x2100
leaq 0x1e8(%rsp), %rdi
callq 0x2100
leaq 0x210(%rsp), %rdi
callq 0x2100
leaq 0x238(%rsp), %rdi
callq 0x2100
leaq 0x260(%rsp), %rdi
callq 0x2100
leaq 0x298(%rsp), %rdi
callq 0x2100
leaq 0x2b8(%rsp), %rdi
callq 0x4020
movq 0x288(%rsp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)
nop