// File: /workspace/github_c_makefile_star2_O1/fukunagatsu[P]RIblast/gapped_extension.cpp
// Function: GappedExtension::Run(std::vector<Hit, std::allocator<Hit>>&, std::vector<unsigned char, std::allocator<unsigned char>>&, std::vector<unsigned char, std::allocator<unsigned char>>&, 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>>&)
void GappedExtension::Run(vector<Hit> &candidate, vector<unsigned char> &query_seq, vector<unsigned char> &db_seq, 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){

  for(int x = 0; x < candidate.size(); x++){
    extension(candidate[x], query_seq, db_seq, query_accessibility, query_conditional_accessibility, db_accessibility, db_conditional_accessibility, 0);
    extension(candidate[x], query_seq, db_seq, query_accessibility, query_conditional_accessibility, db_accessibility, db_conditional_accessibility, 1);
    
    double energy = candidate[x].GetEnergy();
    double h_energy = candidate[x].GetHybridizationEnergy();
    int qlength = candidate[x].GetQLength();
    int dbseq_length = db_seq_length[candidate[x].GetDbSeqId()];

    energy += CalcDangleEnergy(candidate[x].GetQSp(), candidate[x].GetDbSp(), 0 ,query_seq, db_seq, dbseq_length);

    energy += CalcDangleEnergy(candidate[x].GetQSp()+candidate[x].GetQLength()-1, candidate[x].GetDbSp()+candidate[x].GetDbLength()-1, 1 ,query_seq, db_seq, dbseq_length);
    h_energy += CalcDangleEnergy(candidate[x].GetQSp(), candidate[x].GetDbSp(), 0 ,query_seq, db_seq, dbseq_length);
    h_energy += CalcDangleEnergy(candidate[x].GetQSp()+candidate[x].GetQLength()-1, candidate[x].GetDbSp()+candidate[x].GetDbLength()-1, 1 ,query_seq, db_seq, dbseq_length);
    
    candidate[x].SetEnergy(energy);
    candidate[x].SetHybridizationEnergy(h_energy);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r12
movq (%rsi), %rsi
cmpq %rsi, 0x8(%r12)
je 0x15842
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r13
movq %rdx, %r15
xorl %ebp, %ebp
xorl %r8d, %r8d
movq %r14, 0x40(%rsp)
movq %r9, 0x38(%rsp)
movq %r12, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
movq %r8, 0x60(%rsp)
addq %rbp, %rsi
movq 0xa8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, (%rsp)
movl $0x0, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movq %r15, %rdx
movq %r13, %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x15852
movq (%r12), %rsi
addq %rbp, %rsi
movq 0xa8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, (%rsp)
movl $0x1, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movq %r15, %rdx
movq %r13, %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x15852
movq 0x30(%rsp), %rax
movq (%rax), %r12
movsd 0x28(%r12,%rbp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%r12,%rbp), %xmm0
movsd %xmm0, 0x58(%rsp)
movzwl 0x10(%r12,%rbp), %eax
movq %rax, 0x48(%rsp)
movl 0x8(%r12,%rbp), %ebx
movl 0xc(%r12,%rbp), %r14d
movl %ebx, %esi
movl %r14d, %edx
xorl %ecx, %ecx
movq %r15, %r8
movq %r13, %r9
callq 0x1697c
movapd %xmm0, %xmm1
movsd %xmm0, 0x50(%rsp)
movsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x48(%rsp), %rax
leal -0x1(%rax,%rbx), %esi
movq 0x38(%rsp), %rbx
movzwl 0x14(%r12,%rbp), %eax
leal -0x1(%r14,%rax), %edx
movq 0x40(%rsp), %r14
movl $0x1, %ecx
movq %r15, %r8
movq %r13, %r9
callq 0x1697c
movq 0x60(%rsp), %r8
movsd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x58(%rsp), %xmm2
addsd 0x50(%rsp), %xmm2
addsd %xmm0, %xmm2
movsd %xmm1, 0x28(%r12,%rbp)
movsd %xmm2, 0x20(%r12,%rbp)
movq 0x30(%rsp), %r12
incq %r8
movq (%r12), %rsi
movq 0x8(%r12), %rax
subq %rsi, %rax
sarq $0x4, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
addq $0x50, %rbp
cmpq %r8, %rax
ja 0x156d4
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop