// File: /workspace/github_cpp_makefile_star2_O2/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)
andq $0x0, 0x28(%rdi)
movq (%rsi), %rsi
leaq 0x228(%rsp), %r15
pushq $0x4
popq %rdx
movq %r15, %rdi
callq 0x3430
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x248(%rsp,%rax)
je 0xcef2
movq 0x10131(%rip), %rdi     # 0x1cff0
leaq 0x68c4(%rip), %rsi      # 0x1378a
callq 0x3200
movq %rax, %rdi
movq %r14, %rsi
callq 0x31f0
leaq 0x694d(%rip), %rsi      # 0x1382a
movq %rax, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3100
jmp 0xd005
leaq 0x228(%rsp), %rdi
callq 0x10d10
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 0x3290
leaq 0x228(%rsp), %rdi
callq 0x3090
leaq 0x108c5(%rip), %rdx     # 0x1d800
movq %rsp, %rdi
movq %r14, %rsi
callq 0x8410
movq (%rsp), %rsi
leaq 0x20(%rsp), %rdi
pushq $0x4
popq %rdx
callq 0x3430
movq 0x20(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x40(%rsp,%rax)
je 0xcf9e
movq 0x10082(%rip), %rdi     # 0x1cff0
leaq 0x6833(%rip), %rsi      # 0x137a8
callq 0x3200
movq %rsp, %rsi
movq %rax, %rdi
callq 0x31f0
leaq 0x689e(%rip), %rsi      # 0x1382a
movq %rax, %rdi
callq 0x3200
movq %rax, %rdi
callq 0x3100
jmp 0xcff3
leaq 0x2c(%rbx), %rsi
leaq 0x20(%rsp), %rdi
pushq $0x4
popq %rdx
callq 0x3290
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 0x3290
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
movq %rsp, %rdi
callq 0x3478
leaq 0x228(%rsp), %rdi
callq 0x30a0
addq $0x430, %rsp            # imm = 0x430
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0xd033
jmp 0xd03d
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x30a0
movq %rsp, %rdi
callq 0x3478
jmp 0xd040
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x30a0
movq %rbx, %rdi
callq 0x3410
nop