// File: IHorvalds[P]RomAna/./processing/InflexEngineCore.cpp
// Function: InflexEngine::updateMihailsJmenuri(int, unsigned int, int)
void InflexEngine::updateMihailsJmenuri(int32_t ptr, uint32_t pos, int32_t goesTo) {
// Enlarge the vector of sons - the edge of "pos" points now to "goesTo" 
// The idea is to fully alloc the vector of sons
  // Get the number of sons
  size_t countOfSons = bitOp::countOfBits(staticTrieAccess(ptr)->configuration);
  
  // Create temporary copy of the sons
  uint32_t* temp = new uint32_t[countOfSons]();
  for (unsigned index = 0; index < countOfSons; index++)
    temp[index] = staticTrieAccess(ptr)->sons[index];
  delete[] staticTrieAccess(ptr)->sons;
  
  // Alloc a new vector of sons
  staticTrieAccess(ptr)->sons = new uint32_t[sigma]();
  
  // Re-establish the sons. 
  for (unsigned index = 0; index < sigma; index++) {
    if (bitOp::getBit(staticTrieAccess(ptr)->configuration, index))
      staticTrieAccess(ptr)->sons[index] = temp[bitOp::orderOfBit(staticTrieAccess(ptr)->configuration, index)];
    else
      staticTrieAccess(ptr)->sons[index] = 0;
  }
  
  // Update the configuration
  staticTrieAccess(ptr)->configuration = fullBits;
  
  // Let the edge "pos" point to "goesTo"
  staticTrieAccess(ptr)->sons[pos] = goesTo;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movl %esi, 0x6c(%rsp)
movl %edx, 0x68(%rsp)
movl %ecx, 0x64(%rsp)
movq 0x70(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movl 0x6c(%rsp), %esi
callq 0x4bd0
movl 0x8(%rax), %edi
callq 0x5bc0
movl %eax, %eax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, 0x38(%rsp)
callq 0x4030
movq 0x38(%rsp), %rdx
movq %rax, %rdi
movq %rdi, 0x40(%rsp)
xorl %esi, %esi
callq 0x41b0
movq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpq 0x58(%rsp), %rax
jae 0x5a35
movq 0x30(%rsp), %rdi
movl 0x6c(%rsp), %esi
callq 0x4bd0
movq 0xc(%rax), %rax
movl 0x4c(%rsp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x50(%rsp), %rax
movl 0x4c(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x59f8
movq 0x30(%rsp), %rdi
movl 0x6c(%rsp), %esi
callq 0x4bd0
movq 0xc(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x5a5c
movq 0x28(%rsp), %rdi
callq 0x4460
movq 0x30(%rsp), %rax
movl 0x20(%rax), %eax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, 0x18(%rsp)
callq 0x4030
movq 0x18(%rsp), %rdx
movq %rax, %rdi
movq %rdi, 0x20(%rsp)
xorl %esi, %esi
callq 0x41b0
movq 0x30(%rsp), %rdi
movl 0x6c(%rsp), %esi
callq 0x4bd0
movq 0x20(%rsp), %rcx
movq %rcx, 0xc(%rax)
movl $0x0, 0x48(%rsp)
movq 0x30(%rsp), %rcx
movl 0x48(%rsp), %eax
cmpl 0x20(%rcx), %eax
jae 0x5b71
movq 0x30(%rsp), %rdi
movl 0x6c(%rsp), %esi
callq 0x4bd0
movl 0x8(%rax), %edi
movl 0x48(%rsp), %esi
callq 0x5c00
testb $0x1, %al
jne 0x5aef
jmp 0x5b42
movq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x6c(%rsp), %esi
callq 0x4bd0
movl 0x8(%rax), %edi
movl 0x48(%rsp), %esi
callq 0x5c20
movq 0x30(%rsp), %rdi
movl %eax, %ecx
movq 0x8(%rsp), %rax
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x14(%rsp)
movl 0x6c(%rsp), %esi
callq 0x4bd0
movl 0x14(%rsp), %edx
movq 0xc(%rax), %rax
movl 0x48(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x5b5f
movq 0x30(%rsp), %rdi
movl 0x6c(%rsp), %esi
callq 0x4bd0
movq 0xc(%rax), %rax
movl 0x48(%rsp), %ecx
movl $0x0, (%rax,%rcx,4)
jmp 0x5b61
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x5abd
movq 0x30(%rsp), %rdi
movl 0x24(%rdi), %eax
movl %eax, (%rsp)
movl 0x6c(%rsp), %esi
callq 0x4bd0
movl (%rsp), %ecx
movq 0x30(%rsp), %rdi
movl %ecx, 0x8(%rax)
movl 0x64(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x6c(%rsp), %esi
callq 0x4bd0
movl 0x4(%rsp), %edx
movq 0xc(%rax), %rax
movl 0x68(%rsp), %ecx
movl %edx, (%rax,%rcx,4)
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)