// File: IHorvalds[P]RomAna/./processing/InflexEngineUtil.cpp
// Function: InflexEngine::saveExternal(char const*)
void InflexEngine::saveExternal(const char* filename) {
// Save class members to external binary file
  std::ofstream out;
  out.open(filename, std::ios::out | std::ios::binary);
  
  // "+ 1" because "bufferLastPtr" points on the last used pointer
  uint32_t writeSize = bufferLastPtr + 1;
  out.write((char*) &writeSize,  sizeof(uint32_t));
  out.write((char*) &sigma,      sizeof(uint32_t));
  out.write((char*) &fullBits,  sizeof(uint32_t));
  
  for (unsigned i = 0; i < writeSize; i++) {
    unsigned countOfSons = bitOp::countOfBits(staticTrieAccess(i)->configuration);
    
    // Computes configuration (the sons with non-zero values).
    if (staticTrieAccess(i)->configuration == fullBits) {
      staticTrieAccess(i)->configuration = 0;
      for (unsigned j = 0; j < sigma; j++)
        if (staticTrieAccess(i)->sons[j])
          staticTrieAccess(i)->configuration |= (1u << j);
    }
    out.write((char*) &staticTrieAccess(i)->code,          sizeof(uint32_t));
    out.write((char*) &staticTrieAccess(i)->configuration, sizeof(uint32_t));
    out.write((char*) &staticTrieAccess(i)->parent,        sizeof(uint32_t));

    // Writes only the sons with non-zero values.
    for (unsigned j = 0; j < countOfSons; j++)
      if (staticTrieAccess(i)->sons[j])
        out.write((char*) &staticTrieAccess(i)->sons[j], sizeof(uint32_t));
  }
  out.close();
}

// Assembly:
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, 0x2a0(%rsp)
movq %rsi, 0x298(%rsp)
movq 0x2a0(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x45e0
movq 0x298(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x10, %edi
movl $0x4, %esi
callq 0xb010
movl %eax, 0x74(%rsp)
jmp 0x77d3
movl 0x74(%rsp), %edx
movq 0x68(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x4070
jmp 0x77eb
movq 0x60(%rsp), %rax
movl 0x28(%rax), %eax
incl %eax
movl %eax, 0x88(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movl $0x4, %edx
callq 0x4490
jmp 0x7818
movq 0x60(%rsp), %rsi
addq $0x20, %rsi
leaq 0x98(%rsp), %rdi
movl $0x4, %edx
callq 0x4490
jmp 0x7835
movq 0x60(%rsp), %rsi
addq $0x24, %rsi
leaq 0x98(%rsp), %rdi
movl $0x4, %edx
callq 0x4490
jmp 0x7852
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
cmpl 0x88(%rsp), %eax
jae 0x7af2
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x58(%rsp)
jmp 0x7889
movq 0x58(%rsp), %rax
movl 0x8(%rax), %edi
callq 0x5bc0
movl %eax, 0x54(%rsp)
jmp 0x789c
movq 0x60(%rsp), %rdi
movl 0x54(%rsp), %eax
movl %eax, 0x80(%rsp)
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x48(%rsp)
jmp 0x78bf
movq 0x60(%rsp), %rcx
movq 0x48(%rsp), %rax
movl 0x8(%rax), %eax
cmpl 0x24(%rcx), %eax
jne 0x79b0
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x40(%rsp)
jmp 0x78ed
movq 0x40(%rsp), %rax
movl $0x0, 0x8(%rax)
movl $0x0, 0x7c(%rsp)
movq 0x60(%rsp), %rcx
movl 0x7c(%rsp), %eax
cmpl 0x20(%rcx), %eax
jae 0x79ae
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x38(%rsp)
jmp 0x792b
movq 0x38(%rsp), %rax
movq 0xc(%rax), %rax
movl 0x7c(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x799c
movq 0x60(%rsp), %rdi
movb 0x7c(%rsp), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0x2c(%rsp)
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x30(%rsp)
jmp 0x7965
movq 0x30(%rsp), %rax
movl 0x2c(%rsp), %ecx
orl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
jmp 0x799c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x4520
jmp 0x7b16
jmp 0x799e
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x7901
jmp 0x79b0
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x20(%rsp)
jmp 0x79c8
movq 0x20(%rsp), %rsi
leaq 0x98(%rsp), %rdi
movl $0x4, %edx
callq 0x4490
jmp 0x79e1
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x18(%rsp)
jmp 0x79f9
movq 0x18(%rsp), %rsi
addq $0x8, %rsi
leaq 0x98(%rsp), %rdi
movl $0x4, %edx
callq 0x4490
jmp 0x7a16
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x10(%rsp)
jmp 0x7a2e
movq 0x10(%rsp), %rsi
addq $0x4, %rsi
leaq 0x98(%rsp), %rdi
movl $0x4, %edx
callq 0x4490
jmp 0x7a4b
movl $0x0, 0x78(%rsp)
movl 0x78(%rsp), %eax
cmpl 0x80(%rsp), %eax
jae 0x7ada
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, 0x8(%rsp)
jmp 0x7a78
movq 0x8(%rsp), %rax
movq 0xc(%rax), %rax
movl 0x78(%rsp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x7ac8
movq 0x60(%rsp), %rdi
movl 0x84(%rsp), %esi
callq 0x4bd0
movq %rax, (%rsp)
jmp 0x7aa2
movq (%rsp), %rax
movq 0xc(%rax), %rax
movl 0x78(%rsp), %ecx
leaq (%rax,%rcx,4), %rsi
leaq 0x98(%rsp), %rdi
movl $0x4, %edx
callq 0x4490
jmp 0x7ac6
jmp 0x7ac8
jmp 0x7aca
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x7a53
jmp 0x7adc
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x785d
leaq 0x98(%rsp), %rdi
callq 0x44f0
jmp 0x7b01
leaq 0x98(%rsp), %rdi
callq 0x4520
addq $0x2a8, %rsp            # imm = 0x2A8
retq
movq 0x90(%rsp), %rdi
callq 0x4620
nopw %cs:(%rax,%rax)