// File: /workspace/github_cpp_makefile_star2_O2/readmapping[P]alfalfa/src/dp.cpp
// Function: dynProg::dpBandScore(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, boundaries&, dp_type const&, outputType const&, dp_output&, int, int, bool)
int dynProg::dpBandScore( const string& ref, 
        const string&     query,
        boundaries& offset,
        const dp_type&    type,
        const outputType& oType,
        dp_output&  output, 
        int bandL, 
        int bandR, 
        bool print){
    L1 = offset.refE-offset.refB+1;
    L2 = offset.queryE-offset.queryB+1;
    bandSize = 0;
    banded = true;
    bandLeft = bandL;
    bandRight = bandR;
    assert(L1 >=0 && L2 >= 0 && bandLeft >0 && bandRight > 0);
    //build matrices
    updateMatrix(type, false, print);
    bool affine = scores.openGap != 0;
    //dp
    if(affine)
        dpFillStatic( ref, query, true, offset, type);
    else
        dpFillOptStatic( ref, query, true, offset, type);
    //traceback and output
    int        i = min(L2,L1+bandLeft), j = min(L1,L2+bandRight);
    //find beginPosition for traceBack and find dpScore
    findTraceBackPosStatic(&i,&j,type);
    output.dpScore = M[i][j];
    
    //Next is for output only
    if(oType>DPSCORE){
        //Alter boundaries to return the new positions when free gaps were introduced.
        if(type.freeQueryE && i < L2)
            offset.queryE = offset.queryB+i-1;
        if(type.freeRefE && j < L1)
            offset.refE = offset.refB+j-1;
        //traceBack
        dpTraceBackScore( i, j, offset, output, ref, query);
        //Edit Dist ouput
        if( i > 0 && !type.freeQueryB)
            output.editDist += i;
        if(j > 0 && !type.freeRefB)
            output.editDist += j;
    }
    //change boundaries for local and freeGap types to return changed free boundaries.
    if(type.freeQueryB && i > 0)
        offset.queryB = offset.queryB+i;
    if(type.freeRefB && j > 0)
        offset.refB = offset.refB+j;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x30(%rsp)
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
movb 0x88(%rsp), %al
movl 0x80(%rsp), %ecx
movl 0x8(%rbx), %edx
subl (%rbx), %edx
incl %edx
movl %edx, 0x20(%rdi)
movl 0x14(%rbx), %edx
subl 0x10(%rbx), %edx
incl %edx
movl %edx, 0x24(%rdi)
andl $0x0, 0x28(%rdi)
movl 0x78(%rsp), %edx
movb $0x1, 0x34(%rdi)
movl %edx, 0x2c(%rdi)
movl %ecx, 0x30(%rdi)
movzbl %al, %ecx
movq %r8, %rsi
xorl %edx, %edx
callq 0x15822
movq 0x38(%r13), %rax
cmpl $0x0, 0x8(%rax)
movq %rbx, 0x18(%rsp)
movq %r15, 0x28(%rsp)
movq %r12, 0x20(%rsp)
pushq $0x1
popq %rcx
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %r8
movq %r14, %r9
je 0x185ce
callq 0x15be6
jmp 0x185d3
callq 0x162b8
movq %r14, %rbx
movl 0x20(%r13), %ebp
movl 0x24(%r13), %r14d
movl 0x2c(%r13), %eax
addl %ebp, %eax
cmpl %r14d, %eax
cmovgel %r14d, %eax
leaq 0x14(%rsp), %r15
movl %eax, (%r15)
movl 0x30(%r13), %eax
addl %r14d, %eax
cmpl %ebp, %eax
cmovgel %ebp, %eax
leaq 0x10(%rsp), %r12
movl %eax, (%r12)
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x15a46
movq (%r13), %rcx
movslq (%r15), %rax
movq (%rcx,%rax,8), %rsi
movl (%r12), %ecx
movslq %ecx, %rdx
movl (%rsi,%rdx,4), %esi
movq 0x70(%rsp), %r12
movl %esi, 0x4(%r12)
movq 0x30(%rsp), %rsi
cmpl $0x0, (%rsi)
jle 0x186ce
cmpl %r14d, %eax
setl %sil
andb 0x3(%rbx), %sil
cmpb $0x1, %sil
movq 0x18(%rsp), %r14
jne 0x18668
movl 0x10(%r14), %esi
addl %esi, %eax
decl %eax
movl %eax, 0x14(%r14)
cmpl %ebp, %ecx
setl %al
andb 0x1(%rbx), %al
cmpb $0x1, %al
jne 0x18681
movq (%r14), %rax
addq %rdx, %rax
decq %rax
movq %rax, 0x8(%r14)
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
leaq 0x14(%rsp), %r15
leaq 0x10(%rsp), %rdx
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rcx
movq %r12, %r8
movq 0x28(%rsp), %r9
callq 0x183fc
movl (%r15), %eax
testl %eax, %eax
jle 0x186bb
cmpb $0x0, 0x2(%rbx)
jne 0x186bb
addl %eax, (%r12)
movl 0x10(%rsp), %ecx
testl %ecx, %ecx
jle 0x186d3
cmpb $0x0, (%rbx)
jne 0x186d3
addl %ecx, (%r12)
jmp 0x186d3
movq 0x18(%rsp), %r14
testl %eax, %eax
jle 0x186e1
cmpb $0x0, 0x2(%rbx)
je 0x186e1
addl %eax, 0x10(%r14)
testl %ecx, %ecx
jle 0x186ef
cmpb $0x0, (%rbx)
je 0x186ef
movl %ecx, %eax
addq %rax, (%r14)
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq