// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x128(%rbp), %rdi
movslq -0x34(%rbp), %rax
movq %rax, -0x130(%rbp)
addq $0x30, %rdi
callq 0x21430
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq %rcx, %rax
jae 0x2aa98
movq -0x128(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x140(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x2b0a0
movq %rax, %rdi
callq 0x2b0c0
movq -0x140(%rbp), %rdi
movl %eax, -0x38(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x2b0a0
movq %rax, %rdi
callq 0x2b0d0
movq -0x140(%rbp), %rdi
movl %eax, -0x3c(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x2b0a0
movq %rax, %rdi
callq 0x2b0f0
movq -0x140(%rbp), %rdi
movl %eax, -0x40(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x2b0a0
movq %rax, %rdi
callq 0x2b110
movq -0x140(%rbp), %rdi
movl %eax, -0x44(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x2b0a0
movq %rax, %rdi
callq 0x2b130
movq -0x140(%rbp), %rdi
movl %eax, -0x48(%rbp)
movslq -0x34(%rbp), %rsi
callq 0x2b0a0
movq %rax, %rdi
callq 0x2b150
movsd %xmm0, -0x50(%rbp)
leaq -0x68(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x4720
movq -0x138(%rbp), %rdi
movl $0x2710, %esi           # imm = 0x2710
callq 0xbae0
jmp 0x2a665
leaq -0x90(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0xbef0
movq -0x148(%rbp), %rdi
movl $0x2710, %esi           # imm = 0x2710
callq 0x2b170
jmp 0x2a68b
movl -0x38(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jg 0x2a76e
movq -0x18(%rbp), %rdi
movslq -0x94(%rbp), %rsi
callq 0xbac0
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0xbc00
jmp 0x2a6c1
movq -0x28(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x94(%rbp), %rsi
callq 0xbac0
movq -0x128(%rbp), %rdi
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
movl (%rax), %ecx
movl -0x48(%rbp), %r8d
callq 0x2aac0
movsd %xmm0, -0x150(%rbp)
jmp 0x2a711
movsd -0x150(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2b270
jmp 0x2a736
jmp 0x2a738
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x2a694
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2aa8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2aa81
movl -0x40(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x44(%rbp), %eax
jg 0x2aa5e
movq -0x20(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
callq 0xbac0
movq -0x128(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xa8(%rbp)
movl $0x0, -0xac(%rbp)
movl $0x0, -0xb0(%rbp)
movq 0x20(%rbp), %rsi
movq 0x28(%rbp), %rdx
movl -0xa8(%rbp), %r9d
movl -0x48(%rbp), %ecx
movq %rsp, %rax
movl %ecx, (%rax)
leaq -0xb0(%rbp), %rcx
leaq -0xac(%rbp), %r8
callq 0x2ab50
jmp 0x2a7e5
movq 0x10(%rbp), %rdi
movslq -0xb0(%rbp), %rsi
callq 0x29950
movq %rax, -0x170(%rbp)
movq 0x18(%rbp), %rdi
movslq -0xb0(%rbp), %rsi
callq 0x29950
movq -0x128(%rbp), %rdi
movq -0x170(%rbp), %rsi
movq %rax, %rdx
movl -0xac(%rbp), %ecx
movl -0x48(%rbp), %r8d
callq 0x2aac0
movsd %xmm0, -0x168(%rbp)
jmp 0x2a836
movsd -0x168(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jg 0x2aa48
movl -0xbc(%rbp), %eax
subl -0x38(%rbp), %eax
movslq %eax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x150c0
movsd (%rax), %xmm0
addsd -0xb8(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
xorps %xmm0, %xmm0
ucomisd -0xc8(%rbp), %xmm0
jbe 0x2aa32
movl -0xbc(%rbp), %eax
movl -0x38(%rbp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
leaq -0x68(%rbp), %rdi
callq 0xbac0
movl (%rax), %eax
movl %eax, -0x17c(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0x178(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x174(%rbp)
movl -0xbc(%rbp), %eax
movl -0x38(%rbp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x150c0
movl -0x17c(%rbp), %esi
movl -0x178(%rbp), %edx
movl -0x174(%rbp), %ecx
movsd (%rax), %xmm0
movsd -0xb8(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd -0x50(%rbp), %xmm1
leaq -0x118(%rbp), %rdi
callq 0x2b2a0
jmp 0x2a923
movl -0xb0(%rbp), %esi
leaq -0x118(%rbp), %rdi
callq 0x2b360
jmp 0x2a937
movl -0xac(%rbp), %esi
leaq -0x118(%rbp), %rdi
callq 0x29970
jmp 0x2a94b
movq -0x10(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x2b380
jmp 0x2a95d
jmp 0x2aa16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2aa24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2aa24
movq -0x70(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x3370
movq %rax, %rsi
leaq -0x120(%rbp), %rdi
callq 0x2b3f0
movq -0x190(%rbp), %rdi
callq 0x3100
movq 0x2162f(%rip), %rdi     # 0x4bff0
leaq 0xe338(%rip), %rsi      # 0x38d00
callq 0x3270
movq %rax, -0x188(%rbp)
jmp 0x2a9d6
movq -0x188(%rbp), %rdi
movq 0x215c4(%rip), %rsi     # 0x4bfa8
callq 0x32b0
jmp 0x2a9eb
movl $0x1, %edi
callq 0x3330
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x31a0
callq 0x3480
jmp 0x2aa14
jmp 0x2aa24
leaq -0x118(%rbp), %rdi
callq 0x23d60
jmp 0x2aa32
leaq -0x118(%rbp), %rdi
callq 0x23d60
jmp 0x2aa81
jmp 0x2aa34
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x2a84f
jmp 0x2aa4a
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x2a777
leaq -0x90(%rbp), %rdi
callq 0xc690
leaq -0x68(%rbp), %rdi
callq 0x49d0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2a565
leaq -0x90(%rbp), %rdi
callq 0xc690
leaq -0x68(%rbp), %rdi
callq 0x49d0
jmp 0x2aaa1
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x34d0
movq %rax, %rdi
callq 0x5150
nopw %cs:(%rax,%rax)