// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/seed_search.cpp
// Function: SeedSearch::CalcInteractionEnergy(std::vector<Hit, std::allocator<Hit>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, std::vector<float, std::allocator<float>>&, std::vector<float, std::allocator<float>>&, std::vector<std::vector<float, std::allocator<float>>, std::allocator<std::vector<float, std::allocator<float>>>>&, std::vector<std::vector<float, std::allocator<float>>, std::allocator<std::vector<float, std::allocator<float>>>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&)
void SeedSearch::CalcInteractionEnergy(vector<Hit> &hit_result, vector<int> &query_suffix_array, vector<int> &db_suffix_array, vector<float> &query_accessibility, vector<float> &query_conditional_accessibility, vector<vector<float> > &db_accessibility,vector<vector<float> > &db_conditional_accessibility, vector<int> &db_seq_length, vector<int> &db_seq_start_position){
  for(int i = 0;i < _hit_candidate_result.size(); i++){
    int sp_q_sa = _hit_candidate_result[i].GetSpQSa();
    int ep_q_sa = _hit_candidate_result[i].GetEpQSa();
    int sp_db_sa = _hit_candidate_result[i].GetSpDbSa();
    int ep_db_sa = _hit_candidate_result[i].GetEpDbSa();
    int length = _hit_candidate_result[i].GetLength();
    double temp_score = _hit_candidate_result[i].GetEnergy();

    vector<int> q_sp_vector; q_sp_vector.reserve(10000);
    vector<double> qa_vector; qa_vector.reserve(10000);
    for(int j = sp_q_sa; j <=ep_q_sa ; j++){
      q_sp_vector.push_back(query_suffix_array[j]);
      qa_vector.push_back(CalcAccessibility(query_accessibility, query_conditional_accessibility, query_suffix_array[j], length));
    }

    for(int k = sp_db_sa; k <=ep_db_sa ; k++){
      int db_sp = db_suffix_array[k];
      int dbseq_start = 0; int dbseq_id = 0;
      GetSeqIdAndStart(db_seq_length, db_seq_start_position, &dbseq_id, &dbseq_start, db_sp, length);
      double dba = CalcAccessibility(db_accessibility[dbseq_id], db_conditional_accessibility[dbseq_id], dbseq_start, length);
      
      for(int j = sp_q_sa; j <= ep_q_sa; j++){
	double interaction_energy = qa_vector[j-sp_q_sa] + dba + temp_score;
	
	if(interaction_energy < 0){
	  Hit temp_hit( q_sp_vector[j-sp_q_sa], db_sp, length, qa_vector[j-sp_q_sa] + dba, temp_score);
	  temp_hit.SetDbSeqId(dbseq_id);
	  temp_hit.SetDbSeqIdStart(dbseq_start);
	  try{
	    hit_result.push_back(temp_hit);
	  }catch(bad_alloc){
	    cerr << "The memory capacity is too small to run RIblast for this dataset" << endl;  
	    exit(1);
	  }
	}
      }
    } 
  }
  return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rcx, 0xa8(%rsp)
movq %rsi, 0xb0(%rsp)
movq 0x30(%rdi), %rax
movq %rdi, 0x68(%rsp)
cmpq %rax, 0x38(%rdi)
je 0x14c83
movq %r9, %r12
movq %r8, %r13
movq %rdx, %rbp
xorl %ebx, %ebx
movq %r9, 0x98(%rsp)
movq %r8, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq %rbx, %rcx
shlq $0x5, %rcx
movslq (%rax,%rcx), %rdx
movq %rdx, 0x28(%rsp)
movl 0x4(%rax,%rcx), %edx
movq %rdx, 0x20(%rsp)
movl 0xc(%rax,%rcx), %edx
movl %edx, 0x14(%rsp)
movslq 0x8(%rax,%rcx), %rdx
movq %rdx, 0x70(%rsp)
movslq 0x10(%rax,%rcx), %r14
movsd 0x18(%rax,%rcx), %xmm0
movsd %xmm0, 0x80(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movl $0x2710, %esi           # imm = 0x2710
leaq 0x50(%rsp), %rdi
callq 0x7740
movq %rbx, 0xa0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x2710, %esi           # imm = 0x2710
leaq 0x30(%rsp), %rdi
callq 0x14f96
movq 0x20(%rsp), %rax
cmpl %eax, 0x28(%rsp)
jg 0x14a7f
movq 0x20(%rsp), %rax
leal 0x1(%rax), %ebx
movq 0x28(%rsp), %r15
leaq (,%r15,4), %rdx
addq (%rbp), %rdx
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x149f5
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x149ff
leaq 0x50(%rsp), %rdi
callq 0x7da6
movq (%rbp), %rax
movslq (%rax,%r15,4), %rax
movq (%r13), %rcx
xorps %xmm0, %xmm0
cvtss2sd (%rcx,%rax,4), %xmm0
movq 0x68(%rsp), %rcx
movslq 0x24(%rcx), %rcx
cmpl %r14d, %ecx
jge 0x14a3d
shlq $0x2, %rax
addq (%r12), %rax
xorps %xmm1, %xmm1
cvtss2sd (%rax,%rcx,4), %xmm1
addsd %xmm1, %xmm0
incq %rcx
cmpq %rcx, %r14
jne 0x14a29
movsd %xmm0, 0xc8(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x14a61
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x14a73
leaq 0x30(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
callq 0x15198
incq %r15
cmpl %r15d, %ebx
jne 0x149ce
movq 0x70(%rsp), %rcx
cmpl 0x14(%rsp), %ecx
jg 0x14c15
incl 0x14(%rsp)
movq 0x20(%rsp), %rbp
subl 0x28(%rsp), %ebp
incl %ebp
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rcx, 0x70(%rsp)
movl (%rax,%rcx,4), %r9d
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
movl %eax, 0x18(%rsp)
movl %r14d, (%rsp)
movq 0x160(%rsp), %rsi
movq 0x168(%rsp), %rdx
leaq 0x18(%rsp), %rcx
leaq 0x1c(%rsp), %r8
movl %r9d, 0x7c(%rsp)
callq 0x14da8
movl 0x18(%rsp), %r13d
movslq %r13d, %rax
movq 0x150(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rdx
movl 0x1c(%rsp), %ebx
movslq %ebx, %rax
movq (%rcx,%rdx,8), %rcx
xorps %xmm2, %xmm2
cvtss2sd (%rcx,%rax,4), %xmm2
movq 0x68(%rsp), %rcx
movslq 0x24(%rcx), %rcx
cmpl %r14d, %ecx
jge 0x14b42
movq 0x158(%rsp), %rsi
movq (%rsi), %rsi
shlq $0x2, %rax
addq (%rsi,%rdx,8), %rax
xorps %xmm0, %xmm0
cvtss2sd (%rax,%rcx,4), %xmm0
addsd %xmm0, %xmm2
incq %rcx
cmpq %rcx, %r14
jne 0x14b2e
movq 0x20(%rsp), %rax
cmpl %eax, 0x28(%rsp)
jg 0x14c03
xorl %r12d, %r12d
movsd %xmm2, 0xb8(%rsp)
movq 0x30(%rsp), %rax
movsd (%rax,%r12,8), %xmm0
addsd %xmm2, %xmm0
addsd 0x80(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x14bf7
movq 0x50(%rsp), %rcx
movl (%rcx,%r12,4), %esi
movsd (%rax,%r12,8), %xmm0
addsd %xmm2, %xmm0
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
movl 0x7c(%rsp), %edx
movl %r14d, %ecx
movsd 0x80(%rsp), %xmm1
callq 0x1502c
movl %r13d, 0xc8(%rsp)
movl %ebx, 0xcc(%rsp)
movq 0xb0(%rsp), %rdi
movq %r15, %rsi
callq 0x150a4
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x14bee
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movsd 0xb8(%rsp), %xmm2
incq %r12
cmpl %r12d, %ebp
jne 0x14b5d
movq 0x70(%rsp), %rcx
incq %rcx
cmpl %ecx, 0x14(%rsp)
jne 0x14a9d
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x14c2c
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
movq 0x98(%rsp), %r12
movq 0x90(%rsp), %r13
movq 0x88(%rsp), %rbp
movq 0xa0(%rsp), %rbx
je 0x14c63
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
incq %rbx
movq 0x68(%rsp), %rcx
movq 0x30(%rcx), %rax
movq 0x38(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rbx, %rcx
ja 0x14927
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x14d4d
jmp 0x14ca3
jmp 0x14ca3
jmp 0x14ca3
movq %rax, %rbx
jmp 0x14d36
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x14d19
movq %rbx, %rdi
callq 0x32d0
movq 0xd1306(%rip), %rax     # 0xe5fc8
addq $0x10, %rax
movq %rax, 0xc0(%rsp)
movq %rbx, %rdi
callq 0x30f0
movq 0xd1313(%rip), %rdi     # 0xe5ff0
leaq 0x99ca8(%rip), %rsi     # 0xae98c
movl $0x40, %edx
callq 0x3280
movq 0xd12fb(%rip), %rdi     # 0xe5ff0
callq 0x3120
movl $0x1, %edi
callq 0x32a0
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3150
callq 0x33b0
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x14d36
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x14d4d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x14d64
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33e0
movq %rax, %rdi
callq 0x46e7