// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6b8, %rsp            # imm = 0x6B8
movq %rdx, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x4b0(%rsp), %rdi
pushq $0x8
popq %rbp
movl %ebp, %edx
callq 0x34a0
leaq 0x2a8(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x34a0
leaq 0x4b0(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x3470
leaq 0x2a8(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x3470
movl 0x14(%rsp), %eax
cmpl 0x4(%rsp), %eax
jne 0x4a1b
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x4b0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x4d6e
leaq 0x2a8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x4d6e
leaq 0xc8(%rsp), %rbx
leaq 0xa8(%rsp), %r15
leaq 0x18(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x188(%rsp), %rbp
subl $0x1, 0x4(%rsp)
jb 0x499c
leaq 0x4b0(%rsp), %rdi
movq %rbx, %rsi
callq 0x4d6e
leaq 0x2a8(%rsp), %rdi
movq %r15, %rsi
callq 0x4d6e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4dc6
movq %r13, %rdi
movq %r15, %rsi
callq 0x4dc6
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
subq %rsi, %rax
movq 0x38(%rsp), %rcx
subq 0x30(%rsp), %rcx
cmpq %rcx, %rax
jne 0x49fc
movq %rbp, %rdi
callq 0x3350
leaq 0x88(%rsp), %rdi
movq %rbp, %rsi
callq 0x4ea6
movq %rbp, %rdi
callq 0x3120
movq 0x30(%rsp), %rsi
leaq 0x288(%rsp), %rbx
movq %rbx, %rdi
callq 0x3350
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq 0x4ea6
leaq 0x268(%rsp), %r12
leaq 0x248(%rsp), %r13
movq %rbx, %rdi
callq 0x3120
movq %r12, %rdi
leaq 0x88(%rsp), %rsi
callq 0x3350
movq %r12, %rdi
xorl %esi, %esi
callq 0x3df2
movl %eax, %r15d
movq %r12, %rdi
callq 0x3120
testb %r15b, %r15b
leaq 0x68(%rsp), %rsi
leaq 0x88(%rsp), %rax
cmovneq %rax, %rsi
movq %r13, %rdi
callq 0x3350
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x4c78
movq %r13, %rdi
callq 0x3120
movq 0x20(%rsp), %rax
subq 0x18(%rsp), %rax
shrq $0x5, %rax
movl %eax, %ebp
pushq $0x20
popq %r13
pushq $0x1
popq %r12
cmpq %rbp, %r12
jae 0x4956
movq 0x18(%rsp), %rsi
addq %r13, %rsi
leaq 0x228(%rsp), %rbx
movq %rbx, %rdi
callq 0x3350
leaq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x4ea6
movq %rbx, %rdi
callq 0x3120
movq 0x30(%rsp), %rsi
addq %r13, %rsi
leaq 0x208(%rsp), %rbx
movq %rbx, %rdi
callq 0x3350
leaq 0xe8(%rsp), %rdi
movq %rbx, %rsi
callq 0x4ea6
movq %rbx, %rdi
callq 0x3120
testb %r15b, %r15b
je 0x486e
leaq 0x108(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x3350
leaq 0x1a8(%rsp), %r14
movq %r14, %rdi
leaq 0x48(%rsp), %rsi
callq 0x3350
movq 0x8(%rsp), %rdi
leaq 0x108(%rsp), %rbx
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4cce
jmp 0x4923
leaq 0x168(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x3350
leaq 0x168(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x3df2
movl %eax, %ebx
movq %r14, %rdi
callq 0x3120
testb %bl, %bl
je 0x48e1
leaq 0x148(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3350
leaq 0x1e8(%rsp), %r14
movq %r14, %rdi
leaq 0x48(%rsp), %rsi
callq 0x3350
movq 0x8(%rsp), %rdi
leaq 0x148(%rsp), %rbx
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4cce
jmp 0x4923
leaq 0x128(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3350
leaq 0x1c8(%rsp), %r14
movq %r14, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x3350
movq 0x8(%rsp), %rdi
leaq 0x128(%rsp), %rbx
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4cce
movq %r14, %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3120
leaq 0xe8(%rsp), %rdi
callq 0x3120
leaq 0x48(%rsp), %rdi
callq 0x3120
incq %r12
addq $0x20, %r13
jmp 0x47bc
leaq 0x68(%rsp), %rdi
callq 0x3120
leaq 0x88(%rsp), %rdi
callq 0x3120
leaq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x65b0
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x65b0
leaq 0xc8(%rsp), %rbx
leaq 0xa8(%rsp), %r15
jmp 0x468b
leaq 0x4b0(%rsp), %rdi
callq 0x3080
leaq 0x2a8(%rsp), %rdi
callq 0x3080
leaq 0xa8(%rsp), %rdi
callq 0x3120
leaq 0xc8(%rsp), %rdi
callq 0x3120
leaq 0x2a8(%rsp), %rdi
callq 0x30b0
leaq 0x4b0(%rsp), %rdi
callq 0x30b0
addq $0x6b8, %rsp            # imm = 0x6B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x571a(%rip), %rdi      # 0xa11d
leaq 0x5659(%rip), %rsi      # 0xa063
leaq 0x56cb(%rip), %rcx      # 0xa0dc
movl $0x96, %edx
callq 0x3180
leaq 0x568e(%rip), %rdi      # 0xa0b0
leaq 0x563a(%rip), %rsi      # 0xa063
leaq 0x56ac(%rip), %rcx      # 0xa0dc
pushq $0x71
popq %rdx
callq 0x3180
movq %rax, %rbx
jmp 0x4bb0
movq %rax, %rbx
jmp 0x4ba3
jmp 0x4aa9
movq %rax, %rbx
jmp 0x4b75
movq %rax, %rbx
leaq 0x248(%rsp), %rdi
jmp 0x4b59
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
jmp 0x4b70
movq %rax, %rbx
jmp 0x4b68
movq %rax, %rbx
leaq 0x288(%rsp), %rdi
jmp 0x4b63
jmp 0x4aa9
movq %rax, %rbx
leaq 0x268(%rsp), %rdi
jmp 0x4b59
movq %rax, %rbx
jmp 0x4b7f
jmp 0x4b2d
movq %rax, %rbx
jmp 0x4b89
movq %rax, %rbx
leaq 0x1e8(%rsp), %rdi
callq 0x3120
jmp 0x4ac6
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
jmp 0x4b19
movq %rax, %rbx
jmp 0x4ae5
movq %rax, %rbx
leaq 0x1c8(%rsp), %rdi
callq 0x3120
leaq 0x128(%rsp), %rdi
jmp 0x4b19
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x3120
jmp 0x4b11
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
jmp 0x4b19
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x3120
jmp 0x4b47
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
jmp 0x4b59
movq %rax, %rbx
jmp 0x4b5e
movq %rax, %rbx
jmp 0x4b54
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
jmp 0x4b4f
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x3120
leaq 0x48(%rsp), %rdi
callq 0x3120
leaq 0x68(%rsp), %rdi
callq 0x3120
leaq 0x88(%rsp), %rdi
callq 0x3120
leaq 0x30(%rsp), %rdi
callq 0x65b0
leaq 0x18(%rsp), %rdi
callq 0x65b0
leaq 0xa8(%rsp), %rdi
callq 0x3120
leaq 0xc8(%rsp), %rdi
callq 0x3120
leaq 0x2a8(%rsp), %rdi
callq 0x30b0
leaq 0x4b0(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x3480
nop