// File: /workspace/github_cpp_makefile_star2_O1/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 0xedf7
movq 0x10260(%rip), %rdi     # 0x1eff0
leaq 0x89ee(%rip), %rsi      # 0x17785
movl $0x1d, %edx
callq 0x32b0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10241(%rip), %rdi     # 0x1eff0
callq 0x32b0
movq %rax, %rbx
leaq 0x8a67(%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 0xef58
leaq 0x228(%rsp), %rdi
callq 0x14e80
movq %rax, %r15
movl %r15d, 0x28(%rbx)
movl %r15d, %edi
callq 0x3030
leaq 0x8(%rbx), %rcx
movq %rax, (%rcx)
movl %r15d, %edx
leaq 0x228(%rsp), %rdi
movq %rax, %rsi
callq 0x32e0
leaq 0x228(%rsp), %rdi
callq 0x3090
leaq 0x109df(%rip), %rdx     # 0x1f820
movq %rsp, %rdi
movq %r14, %rsi
callq 0x9f63
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 0xeedc
movq 0x1017a(%rip), %rdi     # 0x1eff0
leaq 0x8926(%rip), %rsi      # 0x177a3
movl $0x25, %edx
callq 0x32b0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x10159(%rip), %rdi     # 0x1eff0
callq 0x32b0
movq %rax, %rbx
leaq 0x897f(%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 0xef33
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 0xef58
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 0xef86
jmp 0xefa3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x30a0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xefa6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0xefa6
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
callq 0x30a0
movq %rbx, %rdi
callq 0x3460
nop