// File: IHorvalds[P]RomAna/./processing/InflexEngineUtil.cpp
// Function: InflexEngine::consumeInflexions(char const*, char const*)
void InflexEngine::consumeInflexions(const char* filename, const char* latinFilename) {
  std::ifstream infile(filename);
  std::ifstream latinInfile(latinFilename);
   
  // Read both variants
  unsigned latinTotalCountOfRoots, totalCountOfRoots;
  infile >> totalCountOfRoots;
  latinInfile >> latinTotalCountOfRoots;
  
  // Compare for equality of count of words
  assert(latinTotalCountOfRoots == totalCountOfRoots);
  
  // Function to extract the inflexions from each line
  auto extractInflexionsFromLine = [&](std::string& line) -> std::vector<std::string> {
    const std::string delimiter = ",";
    std::vector<std::string> inflexions;
    size_t pos = 0;
    while ((pos = line.find(delimiter)) != std::string::npos) {
      inflexions.push_back(line.substr(0, pos));
      line.erase(0, pos + delimiter.length());
    }
    // If the root-word is alone in the list
    if (inflexions.empty())
      inflexions.push_back(line);
    return inflexions;
  };
   
  // Personal getline
  auto __getline = [&](std::ifstream& file, std::string& result) {
    result.clear();
    char c;
    while ((file.get(c)) && (c != '\n'))
      result += c;
  };
  
  // Jump over the newline character
  std::string line, latinLine;
  __getline(infile, line);
  __getline(latinInfile, latinLine);
  
  // Read both files
  while (totalCountOfRoots--) {
    __getline(infile, line);
    __getline(latinInfile, latinLine);
    
    // Extract the inflexions from each line
    std::vector<std::string> inflexions = extractInflexionsFromLine(line), latinInflexions = extractInflexionsFromLine(latinLine);
    assert(inflexions.size() == latinInflexions.size());
    
    std::string root = specialChars::cleanUpWord(inflexions.front()), latinRoot = specialChars::cleanUpWord(latinInflexions.front());
    
    // Check if the root is indeed a romanian one
    bool isInLanguage = romanian::isRomanian(root);
    addRoot(isInLanguage ? root : latinRoot);
    
    // Iterate over the inflexions
    for (unsigned index = 1, limit = inflexions.size(); index < limit; ++index) {
      std::string inflexion = specialChars::cleanUpWord(inflexions[index]), latinInflexion = specialChars::cleanUpWord(latinInflexions[index]);
      
      // Does the root-word have characters outside the language?
      if (!isInLanguage) {
        // It could be the case that some of the inflexions do have all their characters in the language
        if (romanian::isRomanian(inflexion)) {
          addDerivated(latinRoot, inflexion);
        } else {
          addDerivated(latinRoot, latinInflexion);
        }
      } else {
        // This means, the root-word contains only characters from the language. Thus we are sure that the inflexion also does.
        addDerivated(root, inflexion);
      }
    }
  }
  infile.close();
  latinInfile.close();
}

// Assembly:
subq $0x718, %rsp            # imm = 0x718
movq %rdi, 0x710(%rsp)
movq %rsi, 0x708(%rsp)
movq %rdx, 0x700(%rsp)
movq 0x710(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x708(%rsp), %rsi
leaq 0x4f8(%rsp), %rdi
movl $0x8, %edx
movl %edx, 0x34(%rsp)
callq 0x4650
movl 0x34(%rsp), %edx
movq 0x700(%rsp), %rsi
leaq 0x2f0(%rsp), %rdi
callq 0x4650
jmp 0x6715
leaq 0x4f8(%rsp), %rdi
leaq 0x2dc(%rsp), %rsi
callq 0x4080
jmp 0x672c
leaq 0x2f0(%rsp), %rdi
leaq 0x2e0(%rsp), %rsi
callq 0x4080
jmp 0x6743
movl 0x2e0(%rsp), %eax
cmpl 0x2dc(%rsp), %eax
jne 0x6755
jmp 0x67a6
leaq 0xe99d(%rip), %rdi      # 0x150f9
leaq 0xe90c(%rip), %rsi      # 0x1506f
movl $0x71, %edx
leaq 0xe9b6(%rip), %rcx      # 0x15125
callq 0x4230
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x7012
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x7005
leaq 0x2b8(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x44e0
leaq 0x298(%rsp), %rdi
callq 0x44e0
movq 0x20(%rsp), %rdx
leaq 0x2da(%rsp), %rdi
leaq 0x4f8(%rsp), %rsi
callq 0x7320
jmp 0x67e1
leaq 0x2da(%rsp), %rdi
leaq 0x2f0(%rsp), %rsi
leaq 0x298(%rsp), %rdx
callq 0x7320
jmp 0x6800
jmp 0x6802
movl 0x2dc(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x2dc(%rsp)
cmpl $0x0, %eax
je 0x6f91
leaq 0x2da(%rsp), %rdi
leaq 0x4f8(%rsp), %rsi
leaq 0x2b8(%rsp), %rdx
callq 0x7320
jmp 0x683d
leaq 0x2da(%rsp), %rdi
leaq 0x2f0(%rsp), %rsi
leaq 0x298(%rsp), %rdx
callq 0x7320
jmp 0x685c
leaq 0x280(%rsp), %rdi
leaq 0x2db(%rsp), %rsi
leaq 0x2b8(%rsp), %rdx
callq 0x73a0
jmp 0x687b
leaq 0x268(%rsp), %rdi
leaq 0x2db(%rsp), %rsi
leaq 0x298(%rsp), %rdx
callq 0x73a0
jmp 0x689a
leaq 0x280(%rsp), %rdi
callq 0xaf40
movq %rax, 0x18(%rsp)
leaq 0x268(%rsp), %rdi
callq 0xaf40
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jne 0x68c8
jmp 0x6919
leaq 0xe897(%rip), %rdi      # 0x15166
leaq 0xe799(%rip), %rsi      # 0x1506f
movl $0x96, %edx
leaq 0xe843(%rip), %rcx      # 0x15125
callq 0x4230
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6feb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6f82
leaq 0x280(%rsp), %rdi
callq 0xaf60
movq %rax, %rsi
leaq 0x228(%rsp), %rdi
callq 0x4170
jmp 0x6938
leaq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0x7570
jmp 0x694f
leaq 0x228(%rsp), %rdi
callq 0x4200
leaq 0x268(%rsp), %rdi
callq 0xaf60
movq %rax, %rsi
leaq 0x1e8(%rsp), %rdi
callq 0x4170
jmp 0x697b
leaq 0x208(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x7570
jmp 0x6992
leaq 0x1e8(%rsp), %rdi
callq 0x4200
leaq 0x1c0(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x4170
jmp 0x69b6
leaq 0x1c0(%rsp), %rdi
xorl %esi, %esi
callq 0x5810
movb %al, 0x17(%rsp)
jmp 0x69cb
leaq 0x1c0(%rsp), %rdi
callq 0x4200
movb 0x17(%rsp), %al
andb $0x1, %al
movb %al, 0x1e7(%rsp)
testb $0x1, 0x1e7(%rsp)
je 0x69fe
leaq 0x248(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x6a0d
leaq 0x208(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x6a0d
movq 0x8(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x4170
jmp 0x6a21
movq 0x28(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x7180
jmp 0x6a35
leaq 0x1a0(%rsp), %rdi
callq 0x4200
movl $0x1, 0x19c(%rsp)
leaq 0x280(%rsp), %rdi
callq 0xaf40
movl %eax, 0x198(%rsp)
movl 0x19c(%rsp), %eax
cmpl 0x198(%rsp), %eax
jae 0x6f22
movl 0x19c(%rsp), %eax
movl %eax, %esi
leaq 0x280(%rsp), %rdi
callq 0xaf90
movq %rax, %rsi
leaq 0x158(%rsp), %rdi
callq 0x4170
jmp 0x6a9d
leaq 0x178(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x7570
jmp 0x6ab4
leaq 0x158(%rsp), %rdi
callq 0x4200
movl 0x19c(%rsp), %eax
movl %eax, %esi
leaq 0x268(%rsp), %rdi
callq 0xaf90
movq %rax, %rsi
leaq 0x118(%rsp), %rdi
callq 0x4170
jmp 0x6ae9
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x7570
jmp 0x6b00
leaq 0x118(%rsp), %rdi
callq 0x4200
testb $0x1, 0x1e7(%rsp)
jne 0x6e42
leaq 0xf8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x4170
jmp 0x6b32
leaq 0xf8(%rsp), %rdi
xorl %esi, %esi
callq 0x5810
movb %al, 0x7(%rsp)
jmp 0x6b47
leaq 0xf8(%rsp), %rdi
callq 0x4200
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x6b61
jmp 0x6d9a
leaq 0xd8(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x4170
jmp 0x6b78
leaq 0xb8(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x4170
jmp 0x6b8f
movq 0x28(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x7200
jmp 0x6bab
leaq 0xb8(%rsp), %rdi
callq 0x4200
leaq 0xd8(%rsp), %rdi
callq 0x4200
jmp 0x6e3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6f75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x228(%rsp), %rdi
callq 0x4200
jmp 0x6f75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6f68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0x4200
jmp 0x6f68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x4200
jmp 0x6f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x4200
jmp 0x6f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x4200
jmp 0x6f5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6f13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x4200
jmp 0x6f13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6f06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4200
jmp 0x6f06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6d88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x4200
leaq 0xd8(%rsp), %rdi
callq 0x4200
jmp 0x6f06
leaq 0x98(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x4170
jmp 0x6db1
leaq 0x78(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x4170
jmp 0x6dc5
movq 0x28(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x7200
jmp 0x6dde
leaq 0x78(%rsp), %rdi
callq 0x4200
leaq 0x98(%rsp), %rdi
callq 0x4200
jmp 0x6e3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6e2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x4200
leaq 0x98(%rsp), %rdi
callq 0x4200
jmp 0x6f06
jmp 0x6ed6
leaq 0x58(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x4170
jmp 0x6e56
leaq 0x38(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x4170
jmp 0x6e6a
movq 0x28(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x7200
jmp 0x6e80
leaq 0x38(%rsp), %rdi
callq 0x4200
leaq 0x58(%rsp), %rdi
callq 0x4200
jmp 0x6ed6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
jmp 0x6eca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2e8(%rsp)
movl %eax, 0x2e4(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x4200
leaq 0x58(%rsp), %rdi
callq 0x4200
jmp 0x6f06
leaq 0x138(%rsp), %rdi
callq 0x4200
leaq 0x178(%rsp), %rdi
callq 0x4200
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x6a61
leaq 0x138(%rsp), %rdi
callq 0x4200
leaq 0x178(%rsp), %rdi
callq 0x4200
jmp 0x6f5b
leaq 0x208(%rsp), %rdi
callq 0x4200
leaq 0x248(%rsp), %rdi
callq 0x4200
leaq 0x268(%rsp), %rdi
callq 0xafb0
leaq 0x280(%rsp), %rdi
callq 0xafb0
jmp 0x6802
leaq 0x208(%rsp), %rdi
callq 0x4200
leaq 0x248(%rsp), %rdi
callq 0x4200
leaq 0x268(%rsp), %rdi
callq 0xafb0
leaq 0x280(%rsp), %rdi
callq 0xafb0
jmp 0x6feb
leaq 0x4f8(%rsp), %rdi
callq 0x40c0
jmp 0x6fa0
leaq 0x2f0(%rsp), %rdi
callq 0x40c0
jmp 0x6faf
leaq 0x298(%rsp), %rdi
callq 0x4200
leaq 0x2b8(%rsp), %rdi
callq 0x4200
leaq 0x2f0(%rsp), %rdi
callq 0x4100
leaq 0x4f8(%rsp), %rdi
callq 0x4100
addq $0x718, %rsp            # imm = 0x718
retq
leaq 0x298(%rsp), %rdi
callq 0x4200
leaq 0x2b8(%rsp), %rdi
callq 0x4200
leaq 0x2f0(%rsp), %rdi
callq 0x4100
leaq 0x4f8(%rsp), %rdi
callq 0x4100
movq 0x2e8(%rsp), %rdi
callq 0x4620
nopl (%rax)