// File: /workspace/github_c_makefile_star2_O3/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 %r9, 0x38(%rsp)
movq (%rsi), %rbx
cmpq %rbx, 0x8(%rsi)
je 0x1766d
movq %r8, %r14
movq %rcx, %rbp
movq %rdx, %r12
movq %rsi, %r15
xorl %r13d, %r13d
xorl %edx, %edx
movq %r8, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movq %rdx, 0x48(%rsp)
addq %r13, %rbx
movq 0xa8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, (%rsp)
movl $0x0, 0x10(%rsp)
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, %r8
movq 0x38(%rsp), %rbx
movq %rbx, %r9
callq 0x1767c
movq (%r15), %rsi
addq %r13, %rsi
movq 0xa8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, (%rsp)
movl $0x1, 0x10(%rsp)
movq 0x20(%rsp), %rdi
movq %r12, %rdx
movq %rbp, %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x1767c
movq (%r15), %rbx
movzwl 0x10(%rbx,%r13), %eax
movq %rax, 0x40(%rsp)
movl 0x8(%rbx,%r13), %r14d
movq %r12, %r15
movq %rbp, %r12
movl 0xc(%rbx,%r13), %ebp
movl %r14d, %esi
movl %ebp, %edx
xorl %ecx, %ecx
movq %r15, %r8
movq %r12, %r9
callq 0x18744
movapd %xmm0, 0x50(%rsp)
movq 0x40(%rsp), %rax
leal (%rax,%r14), %esi
decl %esi
movq 0x30(%rsp), %r14
movzwl 0x14(%rbx,%r13), %eax
leal -0x1(%rbp,%rax), %edx
movq %r12, %rbp
movq %r15, %r12
movq 0x28(%rsp), %r15
movl $0x1, %ecx
movq %r12, %r8
movq %rbp, %r9
callq 0x18744
movq 0x48(%rsp), %rdx
movupd 0x20(%rbx,%r13), %xmm1
movapd 0x50(%rsp), %xmm2
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
addpd %xmm1, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
addpd %xmm2, %xmm0
movupd %xmm0, 0x20(%rbx,%r13)
incq %rdx
movq 0x8(%r15), %rax
subq %rbx, %rax
sarq $0x4, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
addq $0x50, %r13
cmpq %rdx, %rax
ja 0x1752c
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq