// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x3460
movq %r15, %rdi
movq %r14, %rsi
movl $0x14, %edx
callq 0x3060
movl 0x28(%rbx), %eax
incl %eax
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x18(%rsp), %rdi
movl $0x4, %edx
callq 0x3360
leaq 0x20(%rbx), %r14
leaq 0x18(%rsp), %rdi
movl $0x4, %edx
movq %r14, %rsi
callq 0x3360
leaq 0x24(%rbx), %rsi
leaq 0x18(%rsp), %rdi
movl $0x4, %edx
movq %rsi, 0x10(%rsp)
callq 0x3360
cmpl $0x0, 0xc(%rsp)
je 0x5efc
xorl %r12d, %r12d
leaq 0x18(%rsp), %r13
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movl 0x8(%rax), %r15d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movl 0x8(%rax), %eax
movq 0x10(%rsp), %rcx
cmpl (%rcx), %eax
jne 0x5e07
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movl $0x0, 0x8(%rax)
cmpl $0x0, (%r14)
je 0x5e07
xorl %ebp, %ebp
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movq 0xc(%rax), %rax
cmpl $0x0, (%rax,%rbp,4)
je 0x5dfc
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movl $0x1, %edx
movl %ebp, %ecx
shll %cl, %edx
orl %edx, 0x8(%rax)
incq %rbp
movl (%r14), %eax
cmpq %rax, %rbp
jb 0x5dd0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movl $0x4, %edx
movq %r13, %rdi
movq %rax, %rsi
callq 0x3360
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
addq $0x8, %rax
movl $0x4, %edx
movq %r13, %rdi
movq %rax, %rsi
callq 0x3360
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
addq $0x4, %rax
movl $0x4, %edx
movq %r13, %rdi
movq %rax, %rsi
callq 0x3360
testl %r15d, %r15d
je 0x5eee
movl %r15d, %eax
shrl %eax
andl $0x55555555, %eax       # imm = 0x55555555
subl %eax, %r15d
movl %r15d, %eax
movl $0x33333333, %ecx       # imm = 0x33333333
andl %ecx, %eax
shrl $0x2, %r15d
andl %ecx, %r15d
addl %eax, %r15d
movl %r15d, %eax
shrl $0x4, %eax
addl %r15d, %eax
andl $0xf0f0f0f, %eax        # imm = 0xF0F0F0F
imull $0x1010101, %eax, %r15d # imm = 0x1010101
shrl $0x18, %r15d
cmpl $0x1, %r15d
adcl $0x0, %r15d
shll $0x2, %r15d
xorl %ebp, %ebp
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movq 0xc(%rax), %rax
cmpl $0x0, (%rax,%rbp)
je 0x5ee5
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
movq 0xc(%rax), %rsi
addq %rbp, %rsi
movl $0x4, %edx
movq %r13, %rdi
callq 0x3360
addq $0x4, %rbp
cmpq %rbp, %r15
jne 0x5eb1
incl %r12d
cmpl 0xc(%rsp), %r12d
jb 0x5d90
leaq 0x18(%rsp), %rdi
callq 0x3390
movq 0xa0bb(%rip), %rax      # 0xffc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x20(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x18(%rsp,%rcx)
callq 0x3210
leaq 0x110(%rsp), %rdi
callq 0x3100
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5f52
jmp 0x5f52
jmp 0x5f52
jmp 0x5f52
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x33c0
movq %rbx, %rdi
callq 0x34b0
nop