// File: /workspace/github_cpp_makefile_star2_O3/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 0xf69e
movq %rsi, %r14
movq %rdi, %rbx
testb %dl, %dl
je 0xf578
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 0xf521
movq 0x10b33(%rip), %rdi     # 0x1fff0
leaq 0x930e(%rip), %rsi      # 0x187d2
movl $0x1d, %edx
callq 0x32b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10b14(%rip), %rdi     # 0x1fff0
callq 0x32b0
movq %rax, %r15
leaq 0x9387(%rip), %rsi      # 0x18872
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 0xf53c
movq 0x8(%rbx), %rsi
movl 0x28(%rbx), %edx
leaq 0x28(%rsp), %rdi
callq 0x3310
leaq 0x28(%rsp), %rdi
callq 0x3330
movq 0x10a85(%rip), %rax     # 0x1ffc8
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 0xf69e
leaq 0x112a1(%rip), %rdx     # 0x20820
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xa0a5
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 0xf61f
movq 0x10a38(%rip), %rdi     # 0x1fff0
leaq 0x9231(%rip), %rsi      # 0x187f0
movl $0x25, %edx
callq 0x32b0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x10a16(%rip), %rdi     # 0x1fff0
callq 0x32b0
movq %rax, %rbx
leaq 0x9289(%rip), %rsi      # 0x18872
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 0xf651
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 0x10970(%rip), %rax     # 0x1ffc8
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 0xf69e
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 0xf6cd
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3350
jmp 0xf6e8
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3350
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf6e8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3270
movq %rbx, %rdi
callq 0x3460