// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/rna_interaction_search.cpp
// Function: RnaInteractionSearch::LoadDatabase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void RnaInteractionSearch::LoadDatabase(string db_file_name, int hash_size){
  //load seq file
  ifstream ifs((db_file_name+".seq").c_str(), ios::in | ios::binary);
  if (!ifs){
    cout << "Error: can't open " << db_file_name << ".seq." <<endl;
    exit(1);
  }
  int temp_i = 0;
  ifs.read(reinterpret_cast<char*>(&temp_i), sizeof(int));
  _number_of_db_seq = temp_i;
  vector<int> temp_iv;
  vector<int>::iterator i_it;
  temp_iv.assign(temp_i, 0.0);
  for(i_it=temp_iv.begin();i_it!=temp_iv.end();i_it++){
    ifs.read(reinterpret_cast<char*>(&*i_it),sizeof(int));
  }
  int temp = 0;
  for(int i = 0; i <temp_iv.size(); i++){
    _db_seq_start_position.push_back(temp);
    temp += temp_iv[i]+1;
    _db_seq_length.push_back(temp_iv[i]);
  }
  
  int count = 0;
  vector<unsigned char>::iterator c_it;
  ifs.read(reinterpret_cast<char*>(&count), sizeof(int));
  
  _db_seq.resize(count);
  for(c_it=_db_seq.begin();c_it!=_db_seq.end();c_it++){
    ifs.read(reinterpret_cast<char*>(&*c_it),sizeof(unsigned char));
  }
  ifs.close();
  double length_count = 0;
  for(int i= 0; i<_db_seq.size();i++){
    if(_db_seq[i] == 0){
      _db_seq_length_without_repeat.push_back(length_count);
      length_count = 0;
    }else if(_db_seq[i]>=2 && _db_seq[i]<=5){
      length_count++;
    }
  }
  _db_seq_length_without_repeat.push_back(length_count);
  //load acc file
  ifs.open((db_file_name+".acc").c_str(), ios::in | ios::binary);
  if (!ifs){
    cout << "Error: can't open " << db_file_name << ".acc." <<endl;
    exit(1);
  }
  for(int i = 0; i < _number_of_db_seq; i++){
    int a_count = 0;
    vector<float>::iterator it;
    vector <float> temp;
    vector <float> c_temp;
    ifs.read(reinterpret_cast<char*>(&a_count), sizeof(int));
    temp.assign(a_count, 0.0);
    for(it=temp.begin();it!=temp.end();it++){
      ifs.read(reinterpret_cast<char*>(&*it),sizeof(float));
    }
    ifs.read(reinterpret_cast<char*>(&a_count), sizeof(int));
    c_temp.assign(a_count, 0.0);
    for(it=c_temp.begin();it!=c_temp.end();it++){
      ifs.read(reinterpret_cast<char*>(&*it),sizeof(float));
    }
    _db_accessibility.push_back(temp);
    _db_conditional_accessibility.push_back(c_temp);
  }
  ifs.close();

  //load nam file
  ifs.open((db_file_name+".nam").c_str(), ios::in);
  if (!ifs){
    cout << "Error: can't open " << db_file_name << ".nam." <<endl;
    exit(1);
  }
  string str;
  while(getline(ifs, str)){
    _db_seq_name.push_back(str);
  }
  ifs.close();

  //load ind file
  ifs.open((db_file_name+".ind").c_str(), ios::in | ios::binary);
  if (!ifs){
    cout << "Error: can't open " << db_file_name << ".ind." <<endl;
    exit(1);
  }
  count = 0;
  vector<int>::iterator it;
  ifs.read(reinterpret_cast<char*>(&count), sizeof(int));
  
  _db_suffix_array.resize(count);
  for(it=_db_suffix_array.begin();it!=_db_suffix_array.end();it++){
    ifs.read(reinterpret_cast<char*>(&*it),sizeof(int));
  }
  for(int i = 0; i < hash_size; i++){
    for(it=_start_hash[i].begin();it!=_start_hash[i].end();it++){
      ifs.read(reinterpret_cast<char*>(&*it),sizeof(int));
    }
  }
  
  for(int i = 0; i < hash_size; i++){
    for(it=_end_hash[i].begin();it!=_end_hash[i].end();it++){
      ifs.read(reinterpret_cast<char*>(&*it),sizeof(int));
    }
  }
  ifs.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movl %edx, 0x38(%rsp)
movq %rsi, %rcx
movq %rdi, %rbx
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rsi), %rsi
movq %rcx, 0x28(%rsp)
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
movq %rsp, %r14
movq %r14, %rdi
callq 0x46f2
leaq 0xc75d(%rip), %rsi      # 0x1b860
movq %r14, %rdi
callq 0x3420
movq (%rsp), %rsi
leaq 0x90(%rsp), %rdi
movl $0xc, %edx
callq 0x3400
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf13c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0xf832
leaq 0x84(%rsp), %rsi
movl $0x0, (%rsi)
leaq 0x90(%rsp), %rdi
movl $0x4, %edx
callq 0x32e0
movslq 0x84(%rsp), %rsi
movl %esi, 0xf0(%rbx)
xorpd %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movapd %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rsp, %rdx
movl $0x0, (%rdx)
callq 0x12d02
movq 0x60(%rsp), %r14
cmpq 0x68(%rsp), %r14
je 0xf1d6
leaq 0x90(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x32e0
addq $0x4, %r14
cmpq 0x68(%rsp), %r14
jne 0xf1bb
movl $0x0, 0x24(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0xf293
leaq 0xa8(%rbx), %r14
leaq 0xc0(%rbx), %r15
xorl %r13d, %r13d
leaq 0x24(%rsp), %r12
xorl %ebp, %ebp
movq 0xb0(%rbx), %rsi
cmpq 0xb8(%rbx), %rsi
je 0xf229
movl 0x24(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb0(%rbx)
jmp 0xf234
movq %r14, %rdi
movq %r12, %rdx
callq 0x7da6
movq 0x60(%rsp), %rdx
movl (%rdx,%r13), %eax
addq %r13, %rdx
movl 0x24(%rsp), %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x24(%rsp)
movq 0xc8(%rbx), %rsi
cmpq 0xd0(%rbx), %rsi
je 0xf26d
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xc8(%rbx)
jmp 0xf275
movq %r15, %rdi
callq 0x7da6
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
incq %rbp
sarq $0x2, %rax
addq $0x4, %r13
cmpq %rbp, %rax
ja 0xf206
leaq 0x34(%rsp), %rsi
movl $0x0, (%rsi)
leaq 0x90(%rsp), %rdi
movl $0x4, %edx
callq 0x32e0
leaq 0x60(%rbx), %rdi
movslq 0x34(%rsp), %rsi
callq 0x1138a
movq 0x60(%rbx), %r14
cmpq 0x68(%rbx), %r14
je 0xf2e9
leaq 0x90(%rsp), %r15
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x32e0
incq %r14
cmpq 0x68(%rbx), %r14
jne 0xf2d0
leaq 0x90(%rsp), %rdi
callq 0x3060
movq 0x60(%rbx), %rax
cmpq %rax, 0x68(%rbx)
je 0xf37f
leaq 0xd8(%rbx), %r14
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
movq %rsp, %r15
movb (%rax,%r12), %al
testb %al, %al
je 0xf331
cmpb $0x1, %al
sete %cl
cmpb $0x6, %al
setae %al
orb %cl, %al
jne 0xf366
addsd 0x3d651(%rip), %xmm0    # 0x4c980
jmp 0xf366
cvttsd2si %xmm0, %eax
movl %eax, (%rsp)
movq 0xe0(%rbx), %rsi
cmpq 0xe8(%rbx), %rsi
je 0xf357
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe0(%rbx)
jmp 0xf362
movq %r14, %rdi
movq %r15, %rdx
callq 0x11b9a
xorpd %xmm0, %xmm0
incq %r12
movq 0x60(%rbx), %rax
movq 0x68(%rbx), %rcx
subq %rax, %rcx
cmpq %r12, %rcx
ja 0xf311
cvttsd2si %xmm0, %eax
jmp 0xf381
xorl %eax, %eax
movl %eax, (%rsp)
movq 0xe0(%rbx), %rsi
cmpq 0xe8(%rbx), %rsi
je 0xf3a3
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe0(%rbx)
jmp 0xf3b2
leaq 0xd8(%rbx), %rdi
movq %rsp, %rdx
callq 0x11b9a
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x46f2
leaq 0xc4ba(%rip), %rsi      # 0x1b892
movq %rsp, %rdi
callq 0x3420
movq (%rsp), %rsi
leaq 0x90(%rsp), %rdi
movl $0xc, %edx
callq 0x3160
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf411
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0xf886
cmpl $0x0, 0xf0(%rbx)
jle 0xf568
leaq 0x18(%rbx), %rax
movq %rax, 0x88(%rsp)
leaq 0x90(%rsp), %r12
leaq 0x3c(%rsp), %r14
leaq 0x40(%rsp), %r15
xorl %ebp, %ebp
movl $0x0, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movq %rax, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
movl $0x4, %edx
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x32e0
movslq 0x20(%rsp), %rsi
movl $0x0, 0x3c(%rsp)
movq %rsp, %rdi
movq %r14, %rdx
callq 0x12f82
movq (%rsp), %r13
cmpq 0x8(%rsp), %r13
je 0xf4c6
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x32e0
addq $0x4, %r13
jmp 0xf4a9
movl $0x4, %edx
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x32e0
movslq 0x20(%rsp), %rsi
movl $0x0, 0x3c(%rsp)
movq %r15, %rdi
movq %r14, %rdx
callq 0x12f82
movq 0x40(%rsp), %r13
cmpq 0x48(%rsp), %r13
je 0xf512
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x32e0
addq $0x4, %r13
jmp 0xf4f5
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x113b6
movq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x113b6
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xf544
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xf55a
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
incl %ebp
cmpl 0xf0(%rbx), %ebp
jl 0xf458
leaq 0x90(%rsp), %rdi
callq 0x3060
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x46f2
leaq 0xc2d4(%rip), %rsi      # 0x1b86f
movq %rsp, %rdi
callq 0x3420
movq (%rsp), %rsi
leaq 0x90(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x3160
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf5d7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0xf8da
movq %rsp, %r15
leaq 0x10(%rsp), %rax
movq %rax, (%r15)
movq $0x0, 0x8(%r15)
movb $0x0, 0x10(%r15)
leaq 0x30(%rbx), %r12
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3200
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3410
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xf64f
movq %r12, %rdi
movq %r15, %rsi
callq 0x57d8
jmp 0xf60d
leaq 0x90(%rsp), %rdi
callq 0x3060
leaq 0x50(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x46f2
leaq 0xc1e0(%rip), %rsi      # 0x1b865
leaq 0x40(%rsp), %rdi
callq 0x3420
movq 0x40(%rsp), %rsi
leaq 0x90(%rsp), %rdi
movl $0xc, %edx
callq 0x3160
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0xf6bd
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0xf92b
leaq 0x34(%rsp), %rsi
movl $0x0, (%rsi)
leaq 0x90(%rsp), %rdi
movl $0x4, %edx
callq 0x32e0
leaq 0x48(%rbx), %rdi
movslq 0x34(%rsp), %rsi
callq 0x770e
movq 0x48(%rbx), %r14
cmpq 0x50(%rbx), %r14
je 0xf72e
leaq 0x90(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x32e0
addq $0x4, %r14
cmpq 0x50(%rbx), %r14
jne 0xf714
movl 0x38(%rsp), %eax
movl %eax, %r12d
testl %eax, %eax
jle 0xf780
xorl %r13d, %r13d
leaq 0x90(%rsp), %r14
movq 0x78(%rbx), %rax
leaq (,%r13,2), %rbp
addq %r13, %rbp
movq (%rax,%rbp,8), %r15
cmpq 0x8(%rax,%rbp,8), %r15
je 0xf778
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32e0
addq $0x4, %r15
movq 0x78(%rbx), %rax
jmp 0xf757
incq %r13
cmpq %r12, %r13
jne 0xf744
cmpl $0x0, 0x38(%rsp)
jle 0xf7d4
xorl %r13d, %r13d
leaq 0x90(%rsp), %r14
movq 0x90(%rbx), %rax
leaq (,%r13,2), %rbp
addq %r13, %rbp
movq (%rax,%rbp,8), %r15
cmpq 0x8(%rax,%rbp,8), %r15
je 0xf7cc
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32e0
addq $0x4, %r15
movq 0x90(%rbx), %rax
jmp 0xf7a8
incq %r13
cmpq %r12, %r13
jne 0xf792
leaq 0x90(%rsp), %rdi
callq 0x3060
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xf7fc
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xf813
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
leaq 0x90(%rsp), %rdi
callq 0x3090
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd6797(%rip), %rdi     # 0xe5fd0
leaq 0x3d447(%rip), %rsi     # 0x4cc87
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd6773(%rip), %rdi     # 0xe5fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3d42e(%rip), %rsi     # 0x4cc9a
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
jmp 0xf97a
movq 0xd6743(%rip), %rdi     # 0xe5fd0
leaq 0x3d3f3(%rip), %rsi     # 0x4cc87
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd671f(%rip), %rdi     # 0xe5fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3d3e0(%rip), %rsi     # 0x4cca0
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
jmp 0xf97a
movq 0xd66ef(%rip), %rdi     # 0xe5fd0
leaq 0x3d39f(%rip), %rsi     # 0x4cc87
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd66cb(%rip), %rdi     # 0xe5fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3d392(%rip), %rsi     # 0x4cca6
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
jmp 0xf97a
movq 0xd669e(%rip), %rdi     # 0xe5fd0
leaq 0x3d34e(%rip), %rsi     # 0x4cc87
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd667a(%rip), %rdi     # 0xe5fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3d347(%rip), %rsi     # 0x4ccac
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
movl $0x1, %edi
callq 0x32a0
jmp 0xf9fb
jmp 0xf9b6
jmp 0xf98a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0xfa09
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0xfa09
jmp 0xfa06
jmp 0xfa06
jmp 0xfa06
jmp 0xf9fb
jmp 0xfa06
jmp 0xfa06
jmp 0xf9fb
jmp 0xf9fb
movq %rax, %rbx
jmp 0xfa6a
jmp 0xf9c0
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xfa77
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0xfa77
jmp 0xfa06
jmp 0xf9fb
jmp 0xf9fb
jmp 0xfa06
jmp 0xf9fb
jmp 0xf9fb
jmp 0xfa23
jmp 0xfa23
jmp 0xfa06
jmp 0xf9fb
movq %rax, %rbx
jmp 0xfa53
jmp 0xfa23
jmp 0xfa06
jmp 0xfa06
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xfa53
movq 0x10(%rsp), %rsi
incq %rsi
jmp 0xfa4e
jmp 0xfa23
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xfa3d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xfa53
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xfa6a
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
leaq 0x90(%rsp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x33e0
nop