// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rdi, %rbx
movl %esi, (%rdi)
movl $0x0, 0x1c(%rdi)
movq $0x0, 0x10(%rdi)
cmpl $0x2, %esi
je 0x46ff
cmpl $0x1, %esi
je 0x46eb
testl %esi, %esi
jne 0x47aa
movl $0x0, 0x28(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x47f6
movq %rcx, %r15
movl $0x2625a0, 0x18(%rbx)   # imm = 0x2625A0
movabsq $0x7fffffff0000001f, %rax # imm = 0x7FFFFFFF0000001F
movq %rax, 0x20(%rbx)
movl $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 0x3170
movq %r12, 0x8(%rbx)
movl $0xc, %r13d
movq $0x0, -0xc(%r12,%r13)
movl $0x7c, %edi
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,%r13)
movl $0x7fffffff, -0x4(%r12,%r13) # imm = 0x7FFFFFFF
addq $0x14, %r13
cmpq $0x2faf08c, %r13        # imm = 0x2FAF08C
jne 0x4744
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x49ca
movq 0xb83f(%rip), %rbx      # 0xfff0
leaq 0x78da(%rip), %rsi      # 0xc092
movl $0x2a, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x31b0
nop