// File: /workspace/github_cpp_makefile_star2_O2/IHorvalds[P]RomAna/./processing/InflexEngineUtil.cpp
// Function: InflexEngine::InflexEngine(InflexEngine::Mode, char const*, char const*)
InflexEngine::InflexEngine(Mode generationMode, const char* filename, const char* latinFilename) : generationMode(generationMode) {
  // Initialize the auxiliar InflexEngine
  auxTrieSize = 0, auxTrie = nullptr;
  
  switch (generationMode) {
    // Simple initialization
    case Read : {
      // Necessary when deallocating
      bufferLastPtr = 0;
      break;
    }
    // Load from external binary file
    case Load : {
      loadExternal(filename);
      break;
    }
    // Build up the InflexEngine from the file with inflections
    case Build : {
      // Compute properties of the namespace
      size = SIZE;
      sigma = romanian::ROMANIAN_SIGMA;
      assert(sigma <= MAX_ACCEPTED_SIGMA);
      
      // Pay attention to the right shift when sigma == MAX_ACCEPTED_SIGMA
      fullBits = (sigma == MAX_ACCEPTED_SIGMA) ? 0xffffffff : ((1u << sigma) - 1);
      
      // Alloc staticTrie
      bufferLastPtr = 0;
      staticTrie = new InflexEngineNode[size];
      for (unsigned index = 0; index < size; index++) {
        staticTrie[index].code = 0;
        staticTrie[index].parent = 0;
        staticTrie[index].sons = new uint32_t[sigma]();
        staticTrie[index].configuration = fullBits;
      }
      
      // And consume the inflexions
      consumeInflexions(filename, latinFilename);
      break;
    }
    default : {
      std::cerr << "Mode of InflexEngine does not (yet) exist." << std::endl;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %rbx
movl %esi, (%rdi)
andl $0x0, 0x1c(%rdi)
andq $0x0, 0x10(%rdi)
cmpl $0x2, %esi
je 0x431c
cmpl $0x1, %esi
je 0x4303
testl %esi, %esi
jne 0x43c7
andl $0x0, 0x28(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x43f0
movq %rcx, %r15
movl $0x2625a0, 0x18(%rbx)   # imm = 0x2625A0
movabsq $0x7fffffff0000001f, %rax # imm = 0x7FFFFFFF0000001F
movq %rax, 0x20(%rbx)
andl $0x0, 0x28(%rbx)
movl $0x2faf080, %edi        # imm = 0x2FAF080
callq 0x3030
movq %rax, %r12
movl $0x2faf080, %edx        # imm = 0x2FAF080
movq %rax, %rdi
xorl %esi, %esi
callq 0x3160
movq %r12, 0x8(%rbx)
pushq $0xc
popq %rbp
pushq $0x7c
popq %r13
cmpq $0x2faf08c, %rbp        # imm = 0x2FAF08C
je 0x43ab
andq $0x0, -0xc(%r12,%rbp)
movq %r13, %rdi
callq 0x3030
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x60(%rax)
movups %xmm0, 0x6c(%rax)
movq %rax, (%r12,%rbp)
movl $0x7fffffff, -0x4(%r12,%rbp) # imm = 0x7FFFFFFF
addq $0x14, %rbp
jmp 0x435f
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x45b0
movq 0xac22(%rip), %rdi      # 0xeff0
leaq 0x5cb0(%rip), %rsi      # 0xa085
callq 0x3250
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3130