// File: /workspace/github_c_makefile_star2_O3/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, %ebp
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 0x479e
leaq 0xc16b(%rip), %rsi      # 0x1c948
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 0x10816
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0x10f32
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 0x14430
movq 0x60(%rsp), %r14
cmpq 0x68(%rsp), %r14
movl %ebp, 0x38(%rsp)
je 0x10979
leaq 0x90(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x32e0
addq $0x4, %r14
cmpq 0x68(%rsp), %r14
jne 0x1089d
movq 0x60(%rsp), %rax
movl $0x0, 0x20(%rsp)
cmpq %rax, %r14
je 0x10981
leaq 0xa8(%rbx), %r14
leaq 0xc0(%rbx), %r15
xorl %r13d, %r13d
leaq 0x20(%rsp), %r12
xorl %ebp, %ebp
movq 0xb0(%rbx), %rsi
cmpq 0xb8(%rbx), %rsi
je 0x10909
movl 0x20(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xb0(%rbx)
jmp 0x1091d
movq %r14, %rdi
movq %r12, %rdx
callq 0x8e4c
movq 0x60(%rsp), %rax
movl 0x20(%rsp), %ecx
leaq (%rax,%r13), %rdx
movl (%rax,%r13), %esi
addl %esi, %ecx
incl %ecx
movl %ecx, 0x20(%rsp)
movq 0xc8(%rbx), %rsi
cmpq 0xd0(%rbx), %rsi
je 0x1094e
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xc8(%rbx)
jmp 0x1095b
movq %r15, %rdi
callq 0x8e4c
movq 0x60(%rsp), %rax
incq %rbp
movq 0x68(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
addq $0x4, %r13
cmpq %rbp, %rcx
ja 0x108e6
jmp 0x10981
movl $0x0, 0x20(%rsp)
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 0x12ae4
movq 0x60(%rbx), %r14
cmpq 0x68(%rbx), %r14
je 0x109d7
leaq 0x90(%rsp), %r15
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x32e0
incq %r14
cmpq 0x68(%rbx), %r14
jne 0x109be
leaq 0x90(%rsp), %rdi
callq 0x3060
movq 0x60(%rbx), %rax
movq 0x68(%rbx), %rcx
cmpq %rax, %rcx
je 0x10a7b
leaq 0xd8(%rbx), %r14
xorpd %xmm0, %xmm0
xorl %r12d, %r12d
movq %rsp, %r15
movb (%rax,%r12), %dl
testb %dl, %dl
je 0x10a2a
cmpb $0x1, %dl
sete %sil
cmpb $0x6, %dl
setae %dl
orb %sil, %dl
jne 0x10a67
addsd 0x3d038(%rip), %xmm0    # 0x4da60
jmp 0x10a67
cvttsd2si %xmm0, %eax
movl %eax, (%rsp)
movq 0xe0(%rbx), %rsi
cmpq 0xe8(%rbx), %rsi
je 0x10a50
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe0(%rbx)
jmp 0x10a5b
movq %r14, %rdi
movq %r15, %rdx
callq 0x132d6
movq 0x60(%rbx), %rax
movq 0x68(%rbx), %rcx
xorpd %xmm0, %xmm0
incq %r12
movq %rcx, %rdx
subq %rax, %rdx
cmpq %r12, %rdx
ja 0x10a06
cvttsd2si %xmm0, %eax
jmp 0x10a7d
xorl %eax, %eax
movl %eax, (%rsp)
movq 0xe0(%rbx), %rsi
cmpq 0xe8(%rbx), %rsi
je 0x10a9f
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0xe0(%rbx)
jmp 0x10aae
leaq 0xd8(%rbx), %rdi
movq %rsp, %rdx
callq 0x132d6
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 0x479e
leaq 0xbea6(%rip), %rsi      # 0x1c97a
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 0x10b0d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0x10f86
cmpl $0x0, 0xf0(%rbx)
jle 0x10c64
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, 0x24(%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 0x24(%rsp), %rsi
callq 0x32e0
movslq 0x24(%rsp), %rsi
movl $0x0, 0x3c(%rsp)
movq %rsp, %rdi
movq %r14, %rdx
callq 0x14a68
movq (%rsp), %r13
cmpq 0x8(%rsp), %r13
je 0x10bc2
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x32e0
addq $0x4, %r13
jmp 0x10ba5
movl $0x4, %edx
movq %r12, %rdi
leaq 0x24(%rsp), %rsi
callq 0x32e0
movslq 0x24(%rsp), %rsi
movl $0x0, 0x3c(%rsp)
movq %r15, %rdi
movq %r14, %rdx
callq 0x14a68
movq 0x40(%rsp), %r13
cmpq 0x48(%rsp), %r13
je 0x10c0e
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x32e0
addq $0x4, %r13
jmp 0x10bf1
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x12b10
movq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x12b10
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x10c40
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x10c56
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
incl %ebp
cmpl 0xf0(%rbx), %ebp
jl 0x10b54
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 0x479e
movl 0x38(%rsp), %ebp
leaq 0xbcbc(%rip), %rsi      # 0x1c957
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 0x10cd7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0x10fda
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 0x10d4f
movq %r12, %rdi
movq %r15, %rsi
callq 0x5c56
jmp 0x10d0d
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 0x479e
leaq 0xbbc8(%rip), %rsi      # 0x1c94d
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 0x10dbd
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0x1102b
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 0x8700
movq 0x48(%rbx), %r14
cmpq 0x50(%rbx), %r14
je 0x10e2e
leaq 0x90(%rsp), %r15
movl $0x4, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x32e0
addq $0x4, %r14
cmpq 0x50(%rbx), %r14
jne 0x10e14
testl %ebp, %ebp
jle 0x10ed4
movl %ebp, %r12d
movq 0x78(%rbx), %rax
xorl %r13d, %r13d
leaq 0x90(%rsp), %r14
leaq (,%r13,2), %rbp
addq %r13, %rbp
movq (%rax,%rbp,8), %r15
cmpq 0x8(%rax,%rbp,8), %r15
je 0x10e78
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32e0
addq $0x4, %r15
movq 0x78(%rbx), %rax
jmp 0x10e57
incq %r13
cmpq %r12, %r13
jne 0x10e48
cmpl $0x0, 0x38(%rsp)
jle 0x10ed4
movq 0x90(%rbx), %rax
xorl %r13d, %r13d
leaq 0x90(%rsp), %r14
leaq (,%r13,2), %rbp
addq %r13, %rbp
movq (%rax,%rbp,8), %r15
cmpq 0x8(%rax,%rbp,8), %r15
je 0x10ecc
movl $0x4, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32e0
addq $0x4, %r15
movq 0x90(%rbx), %rax
jmp 0x10ea8
incq %r13
cmpq %r12, %r13
jne 0x10e99
leaq 0x90(%rsp), %rdi
callq 0x3060
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x10efc
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x10f13
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 0xd6097(%rip), %rdi     # 0xe6fd0
leaq 0x3cf17(%rip), %rsi     # 0x4de57
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd6073(%rip), %rdi     # 0xe6fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3cefe(%rip), %rsi     # 0x4de6a
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
jmp 0x1107a
movq 0xd6043(%rip), %rdi     # 0xe6fd0
leaq 0x3cec3(%rip), %rsi     # 0x4de57
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd601f(%rip), %rdi     # 0xe6fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3ceb0(%rip), %rsi     # 0x4de70
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
jmp 0x1107a
movq 0xd5fef(%rip), %rdi     # 0xe6fd0
leaq 0x3ce6f(%rip), %rsi     # 0x4de57
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd5fcb(%rip), %rdi     # 0xe6fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3ce62(%rip), %rsi     # 0x4de76
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
jmp 0x1107a
movq 0xd5f9e(%rip), %rdi     # 0xe6fd0
leaq 0x3ce1e(%rip), %rsi     # 0x4de57
movl $0x12, %edx
callq 0x3280
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0xd5f7a(%rip), %rdi     # 0xe6fd0
callq 0x3280
movq %rax, %rbx
leaq 0x3ce17(%rip), %rsi     # 0x4de7c
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3120
movl $0x1, %edi
callq 0x32a0
jmp 0x110fb
jmp 0x110b6
jmp 0x1108a
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x11109
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x11109
jmp 0x11106
jmp 0x11106
jmp 0x11106
jmp 0x110fb
jmp 0x11106
jmp 0x11106
jmp 0x110fb
jmp 0x110fb
movq %rax, %rbx
jmp 0x1116a
jmp 0x110c0
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x11177
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3230
jmp 0x11177
jmp 0x11106
jmp 0x110fb
jmp 0x110fb
jmp 0x11106
jmp 0x110fb
jmp 0x110fb
jmp 0x11123
jmp 0x11123
jmp 0x11106
jmp 0x110fb
movq %rax, %rbx
jmp 0x11153
jmp 0x11123
jmp 0x11106
jmp 0x11106
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x11153
movq 0x10(%rsp), %rsi
incq %rsi
jmp 0x1114e
jmp 0x11123
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1113d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x11153
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1116a
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
leaq 0x90(%rsp), %rdi
callq 0x3090
movq %rbx, %rdi
callq 0x33e0
nop