// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movq %r9, 0x48(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, 0x20(%rsp)
movq %rdx, 0x38(%rsp)
movq %rdi, 0x28(%rsp)
movq %rsi, 0x30(%rsp)
movq (%rsi), %rbx
xorl %r15d, %r15d
xorl %esi, %esi
movq 0x38(%rsp), %r13
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rax
subq %rbx, %rax
cqto
pushq $0x50
popq %rcx
idivq %rcx
cmpq %rsi, %rax
jbe 0x11879
addq %r15, %rbx
andl $0x0, 0x10(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, (%rsp)
movq 0x28(%rsp), %r12
movq %r12, %rdi
movq %rsi, 0x58(%rsp)
movq %rbx, %rsi
movq %r13, %rdx
movq 0x20(%rsp), %rcx
movq 0x40(%rsp), %r14
movq %r14, %r8
movq 0x48(%rsp), %rbx
movq %rbx, %r9
callq 0x11888
movq 0x30(%rsp), %rbp
movq (%rbp), %rsi
addq %r15, %rsi
movq 0xb8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, (%rsp)
movl $0x1, 0x10(%rsp)
movq %r12, %rdi
movq %r13, %rdx
movq 0x20(%rsp), %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x11888
movq (%rbp), %rbx
movzwl 0x10(%rbx,%r15), %eax
movq %rax, 0x50(%rsp)
movl 0x8(%rbx,%r15), %r14d
movl 0xc(%rbx,%r15), %ebp
movq %r12, %rdi
movl %r14d, %esi
movl %ebp, %edx
xorl %ecx, %ecx
movq %r13, %r8
movq 0x20(%rsp), %r12
movq %r12, %r9
callq 0x1269c
movapd %xmm0, 0x60(%rsp)
movq 0x50(%rsp), %rax
leal (%rax,%r14), %esi
decl %esi
movzwl 0x14(%rbx,%r15), %eax
leal -0x1(%rbp,%rax), %edx
movq 0x28(%rsp), %rdi
pushq $0x1
popq %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x1269c
movq 0x58(%rsp), %rsi
movupd 0x20(%rbx,%r15), %xmm1
movapd 0x60(%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,%r15)
incq %rsi
addq $0x50, %r15
jmp 0x11735
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq