// File: /workspace/github_cpp_makefile_star2_O3/adamnovak[P]rlcsa/suffixarray.cpp
// Function: CSA::SuffixArray::SuffixArray(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
SuffixArray::SuffixArray(const std::string& base_name, bool print) :
  ok(false),
  data(0), sa(0), original_sa(0), ranks(0), data_size(0),
  sequences(0)
{
  std::ifstream 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;
  }
  this->data_size = fileSize(data_file);
  this->data = new uchar[this->data_size];
  data_file.read((char*)(this->data), data_size);
  data_file.close();

  std::string sa_name = base_name + SA_EXTENSION;
  std::ifstream 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.read((char*)&(this->sequences), sizeof(uint));
  this->sa = new uint[this->data_size];
  sa_file.read((char*)(this->sa), this->data_size * sizeof(uint));
  sa_file.close();

  this->original_sa = this->sa; this->sa += this->sequences;
  this->ok = true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x430, %rsp            # imm = 0x430
movq %rsi, %r14
movq %rdi, %rbx
movb $0x0, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movups %xmm0, 0x18(%rdi)
movq $0x0, 0x28(%rdi)
movq (%rsi), %rsi
leaq 0x228(%rsp), %r15
movq %r15, %rdi
movl $0x4, %edx
callq 0x3480
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x248(%rsp,%rax)
je 0xefc7
movq 0x11090(%rip), %rdi     # 0x1fff0
leaq 0x986b(%rip), %rsi      # 0x187d2
movl $0x1d, %edx
callq 0x32b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x11071(%rip), %rdi     # 0x1fff0
callq 0x32b0
movq %rax, %rbx
leaq 0x98e4(%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 0xf127
leaq 0x228(%rsp), %rdi
callq 0x15410
movl %eax, 0x28(%rbx)
movl %eax, %r15d
movq %r15, %rdi
callq 0x3030
leaq 0x8(%rbx), %rcx
movq %rax, (%rcx)
leaq 0x228(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x32e0
leaq 0x228(%rsp), %rdi
callq 0x3090
leaq 0x11810(%rip), %rdx     # 0x20820
movq %rsp, %rdi
movq %r14, %rsi
callq 0xa0a5
movq (%rsp), %rsi
leaq 0x20(%rsp), %rdi
movl $0x4, %edx
callq 0x3480
movq 0x20(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x40(%rsp,%rax)
je 0xf0ab
movq 0x10fab(%rip), %rdi     # 0x1fff0
leaq 0x97a4(%rip), %rsi      # 0x187f0
movl $0x25, %edx
callq 0x32b0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x10f8a(%rip), %rdi     # 0x1fff0
callq 0x32b0
movq %rax, %rbx
leaq 0x97fd(%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 0xf102
leaq 0x2c(%rbx), %rsi
leaq 0x20(%rsp), %rdi
movl $0x4, %edx
callq 0x32e0
movl 0x28(%rbx), %r14d
shlq $0x2, %r14
movq %r14, %rdi
callq 0x3030
movq %rax, 0x10(%rbx)
leaq 0x20(%rsp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x32e0
leaq 0x20(%rsp), %rdi
callq 0x3090
movq 0x10(%rbx), %rax
movq %rax, 0x18(%rbx)
movl 0x2c(%rbx), %ecx
leaq (%rax,%rcx,4), %rax
movq %rax, 0x10(%rbx)
movb $0x1, (%rbx)
leaq 0x20(%rsp), %rdi
callq 0x30a0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf127
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
leaq 0x228(%rsp), %rdi
callq 0x30a0
addq $0x430, %rsp            # imm = 0x430
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0xf155
jmp 0xf172
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x30a0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xf175
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0xf175
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x30a0
movq %rbx, %rdi
callq 0x3460