// File: /workspace/github_cpp_makefile_star2_O1/adamnovak[P]rlcsa/suffixarray.cpp
// Function: CSA::SuffixArray::writeTo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool) const
void
SuffixArray::writeTo(const std::string& base_name, bool write_data) const
{
  if(!this->ok) { return; }

  if(write_data)
  {
    std::ofstream data_file(base_name.c_str(), std::ios_base::binary);
    if(!data_file)
    {
      std::cerr << "Error: Cannot open data file " << base_name << "!" << std::endl;
      return;
    }
    data_file.write((char*)(this->data), this->data_size);
    data_file.close();
  }

  std::string sa_name = base_name + SA_EXTENSION;
  std::ofstream sa_file(sa_name.c_str(), std::ios_base::binary);
  if(!sa_file)
  {
    std::cerr << "Error: Cannot open suffix array file " << sa_name << "!" << std::endl;
    return;
  }
  sa_file.write((char*)&(this->sequences), sizeof(uint));
  sa_file.write((char*)(this->original_sa), this->data_size * sizeof(uint));
  sa_file.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
cmpb $0x1, (%rdi)
jne 0xf4d0
movq %rsi, %r14
movq %rdi, %rbx
testb %dl, %dl
je 0xf3aa
movq (%r14), %rsi
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movl $0x4, %edx
callq 0x32a0
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0x48(%rsp,%rax), %ebp
testb $0x5, %bpl
je 0xf353
movq 0xfd01(%rip), %rdi      # 0x1eff0
leaq 0x848f(%rip), %rsi      # 0x17785
movl $0x1d, %edx
callq 0x32b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0xfce2(%rip), %rdi      # 0x1eff0
callq 0x32b0
movq %rax, %r15
leaq 0x8508(%rip), %rsi      # 0x17825
movl $0x1, %edx
movq %rax, %rdi
callq 0x32b0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
jmp 0xf36e
movq 0x8(%rbx), %rsi
movl 0x28(%rbx), %edx
leaq 0x28(%rsp), %rdi
callq 0x3310
leaq 0x28(%rsp), %rdi
callq 0x3330
movq 0xfc53(%rip), %rax      # 0x1efc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x3200
leaq 0x120(%rsp), %rdi
callq 0x30e0
testb $0x5, %bpl
jne 0xf4d0
leaq 0x1046f(%rip), %rdx     # 0x1f820
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x9f63
movq (%r15), %rsi
leaq 0x28(%rsp), %rdi
movl $0x4, %edx
callq 0x32a0
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x48(%rsp,%rax)
je 0xf451
movq 0xfc06(%rip), %rdi      # 0x1eff0
leaq 0x83b2(%rip), %rsi      # 0x177a3
movl $0x25, %edx
callq 0x32b0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0xfbe4(%rip), %rdi      # 0x1eff0
callq 0x32b0
movq %rax, %rbx
leaq 0x840a(%rip), %rsi      # 0x17825
movl $0x1, %edx
movq %rax, %rdi
callq 0x32b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3190
jmp 0xf483
leaq 0x2c(%rbx), %rsi
leaq 0x28(%rsp), %rdi
movl $0x4, %edx
callq 0x3310
movq 0x18(%rbx), %rsi
movl 0x28(%rbx), %edx
shlq $0x2, %rdx
leaq 0x28(%rsp), %rdi
callq 0x3310
leaq 0x28(%rsp), %rdi
callq 0x3330
movq 0xfb3e(%rip), %rax      # 0x1efc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x3200
leaq 0x120(%rsp), %rdi
callq 0x30e0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf4d0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3270
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xf4ff
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3350
jmp 0xf51a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3350
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf51a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3270
movq %rbx, %rdi
callq 0x3460