// File: 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:
subq $0x58, %rsp
movb 0x78(%rsp), %al
movl 0x70(%rsp), %r10d
movl 0x68(%rsp), %r10d
movq 0x60(%rsp), %r10
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %r9, 0x28(%rsp)
andb $0x1, %al
movb %al, 0x27(%rsp)
movq 0x50(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x38(%rsp), %rcx
subq (%rcx), %rax
addq $0x1, %rax
movl %eax, 0x20(%rdi)
movq 0x38(%rsp), %rax
movl 0x14(%rax), %eax
movq 0x38(%rsp), %rcx
subl 0x10(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x24(%rdi)
movl $0x0, 0x28(%rdi)
movb $0x1, 0x34(%rdi)
movl 0x68(%rsp), %eax
movl %eax, 0x2c(%rdi)
movl 0x70(%rsp), %eax
movl %eax, 0x30(%rdi)
movq 0x30(%rsp), %rsi
movb 0x27(%rsp), %al
xorl %edx, %edx
andb $0x1, %al
movzbl %al, %ecx
callq 0x31920
movq 0x8(%rsp), %rax
movq 0x38(%rax), %rax
cmpl $0x0, 0x8(%rax)
setne %al
andb $0x1, %al
movb %al, 0x26(%rsp)
testb $0x1, 0x26(%rsp)
je 0x37e93
movq 0x8(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
movl $0x1, %ecx
callq 0x32140
jmp 0x37eb6
movq 0x8(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %r8
movq 0x30(%rsp), %r9
movl $0x1, %ecx
callq 0x33500
movq 0x8(%rsp), %rcx
movq %rcx, %rdi
addq $0x24, %rdi
movl 0x20(%rcx), %eax
addl 0x2c(%rcx), %eax
movl %eax, 0x1c(%rsp)
leaq 0x1c(%rsp), %rsi
callq 0xc080
movq 0x8(%rsp), %rcx
movl (%rax), %eax
movl %eax, 0x20(%rsp)
movq %rcx, %rdi
addq $0x20, %rdi
movl 0x24(%rcx), %eax
addl 0x30(%rcx), %eax
movl %eax, 0x14(%rsp)
leaq 0x14(%rsp), %rsi
callq 0xc080
movq 0x8(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x30(%rsp), %rcx
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x31ca0
movq 0x8(%rsp), %rax
movq (%rax), %rax
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x18(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
movq 0x60(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x28(%rsp), %rax
cmpl $0x0, (%rax)
jle 0x3801b
movq 0x30(%rsp), %rax
testb $0x1, 0x3(%rax)
je 0x37f7a
movq 0x8(%rsp), %rcx
movl 0x20(%rsp), %eax
cmpl 0x24(%rcx), %eax
jge 0x37f7a
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
addl 0x20(%rsp), %ecx
subl $0x1, %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x14(%rax)
movq 0x30(%rsp), %rax
testb $0x1, 0x1(%rax)
je 0x37fb0
movq 0x8(%rsp), %rcx
movl 0x18(%rsp), %eax
cmpl 0x20(%rcx), %eax
jge 0x37fb0
movq 0x38(%rsp), %rax
movq (%rax), %rcx
movslq 0x18(%rsp), %rax
addq %rax, %rcx
subq $0x1, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rdi
movq 0x38(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x48(%rsp), %r9
movq 0x40(%rsp), %rax
leaq 0x20(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %rax, (%rsp)
callq 0x37a20
cmpl $0x0, 0x20(%rsp)
jle 0x37ffb
movq 0x30(%rsp), %rax
testb $0x1, 0x2(%rax)
jne 0x37ffb
movl 0x20(%rsp), %ecx
movq 0x60(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
cmpl $0x0, 0x18(%rsp)
jle 0x38019
movq 0x30(%rsp), %rax
testb $0x1, (%rax)
jne 0x38019
movl 0x18(%rsp), %ecx
movq 0x60(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x3801b
movq 0x30(%rsp), %rax
testb $0x1, 0x2(%rax)
je 0x38041
cmpl $0x0, 0x20(%rsp)
jle 0x38041
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
addl 0x20(%rsp), %ecx
movq 0x38(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x30(%rsp), %rax
testb $0x1, (%rax)
je 0x3806a
cmpl $0x0, 0x18(%rsp)
jle 0x3806a
movq 0x38(%rsp), %rax
movq (%rax), %rcx
movslq 0x18(%rsp), %rax
addq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, (%rax)
xorl %eax, %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)