// File: /workspace/github_cpp_makefile_star2_O2/readmapping[P]alfalfa/src/dp.cpp
// Function: dynProg::dpBandStatic(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::dpBandStatic( const string&     ref,
        const string&     query,
        boundaries& offset,
        const dp_type&    type,
        const outputType& oType,
        dp_output&  output,
        int minbandS,
        int maxbandS,
        bool print)
{
    L1 = offset.refE-offset.refB+1;
    L2 = offset.queryE-offset.queryB+1;
    bandSize = minbandS;
    banded = true;
    assert(L1 >=0 && L2 >= 0 && bandSize >0);
    assert(!type.local);
    assert((!type.freeQueryB && !type.freeRefB) || (!type.freeQueryE && !type.freeRefE));
    //IF no free start at begin:
    //possible end of alignment should be accessible for traceback: 
    //range of allowed traceback startpositions should have a non-empty intersection
    //with the band, otherwise: give bad alignment and return
    //ELSE IF free start at begin in cols or rows: (resulting in no free ending):
    //check range of starting point (0,0) lies in range of band if rows or columns were not free
    if((type.freeQueryB && !type.freeRefB && L2 + bandSize < L1) ||
            (type.freeRefB && !type.freeQueryB && L2 - bandSize > L1) ||
            (!(type.freeQueryB || type.freeRefB) && !type.freeRefE && L2 + bandSize < L1) ||
            (!(type.freeQueryB || type.freeRefB) && !type.freeQueryE && L2 - bandSize > L1)){
        if(max(L2,L1) - min(L2,L1) < maxbandS){
            bandSize = max(L2,L1) - min(L2,L1);
            if(print) cerr << "adjusted bandSize to " << bandSize << endl;
        }
        else{
            if(print) cerr << "possible end of alignment would lay beyond the dimensions of the matrix" << endl;
            output.dpScore = scores.mismatch*query.length();
            output.editDist = query.length();
            return 1;
        }
    }
    bool backward = (type.freeQueryB || type.freeRefB) && !type.local;
    //build matrices
    updateMatrix(type, backward, print);
    bool affine = scores.openGap != 0;
    if(print)
        cerr << "fill DP matrix" << endl;
    //dp
    if(affine)
        dpFillStatic(ref, query, !backward, offset, type);
    else
        dpFillOptStatic(ref, query, !backward, offset, type);
    if(print){
        //print_matrices(ref, query, offset, false);
    }
    //traceback and output
    int        i = min(L2,L1+bandSize), j = min(L1,L2+bandSize);
    if(print)
        cerr << "find traceback position" << endl;
    //find beginPosition for traceBack and find dpScore
    findTraceBackPosStatic(&i,&j,type);
    if(print)
        cerr << "tracebackpos is " << i << ", " << j << endl;
    output.dpScore = M[i][j];
    if(print)
        cerr << "dp score is " << output.dpScore << endl;
    //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;
        if(type.freeQueryB && i < L2)
            offset.queryB = offset.queryE-i+1;
        if(type.freeRefB && j < L1)
            offset.refB = offset.refE-j+1;
        //traceBack
        if(print)
                cerr << "search trace" << endl;
        std::stringstream ss;
        if(affine)
            dpTraceBackStatic(i, j, output, ss, offset, !backward, ref, query);
        else
            dpTraceBackOptStatic(i, j, type, output, ss, offset, !backward, ref, query);
        if(print)
                cerr << "trace ended at position " << i << ", " << j << endl;
        assert(j ==0 && i==0);
        //Errorstring output
        if(oType == ERRORSTRING || oType == ALL){
            if(print)
                cerr << "write errorstring to cigar vector" << endl;
            string errorString = ss.str();
            if(!backward)
                reverse( errorString.begin(), errorString.end() );
            //create output: errorString
            int iter = 0;
            int temp;
            int errorStringLength = errorString.length();
            while(iter < errorStringLength){
                temp = iter;
                while(iter+1 < errorStringLength && errorString[iter+1]==errorString[temp])
                    iter++;
                iter++;
                output.cigarChars.push_back(errorString[temp]);
                output.cigarLengths.push_back(iter-temp);
            }
        }
    }
    //change boundaries for local and freeGap types to return changed free boundaries.
    if(print)
        cerr << "DP finished" << endl;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %r9, 0x18(%rsp)
movq %r8, %r14
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
movb 0x238(%rsp), %bl
movl 0x228(%rsp), %edi
movl 0x8(%rcx), %ecx
subl (%r12), %ecx
incl %ecx
movl %ecx, 0x20(%r13)
movl 0x14(%r12), %edx
subl 0x10(%r12), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x24(%r13)
movl %edi, 0x28(%r13)
movb $0x1, 0x34(%r13)
movb (%r8), %r8b
movb 0x2(%r14), %al
cmpb $0x1, %al
jne 0x17b4a
testb %r8b, %r8b
jne 0x17bbb
addl %esi, %edi
cmpl %ecx, %edi
jl 0x17b71
jmp 0x17bbb
testb %r8b, %r8b
jne 0x17b66
cmpb $0x0, 0x1(%r14)
jne 0x17b5f
leal (%rsi,%rdi), %r8d
cmpl %ecx, %r8d
jl 0x17b71
cmpb $0x0, 0x3(%r14)
jne 0x17bbb
movl %esi, %r8d
subl %edi, %r8d
cmpl %ecx, %r8d
jle 0x17bbb
cmpl %ecx, %esi
movl %ecx, %edi
cmovgl %esi, %edi
cmpl %edx, %ecx
cmovgl %esi, %ecx
subl %ecx, %edi
cmpl 0x230(%rsp), %edi
jge 0x17bcf
movl %edi, 0x28(%r13)
testb %bl, %bl
je 0x17bbb
movq 0x32451(%rip), %rdi     # 0x49fe8
leaq 0x1edce(%rip), %rsi     # 0x3696c
callq 0x72b0
movl 0x28(%r13), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movb 0x2(%r14), %al
testb $0x1, %al
jne 0x17bc5
cmpb $0x1, (%r14)
jne 0x17c11
movb 0x4(%r14), %bpl
xorb $0x1, %bpl
jmp 0x17c13
testb %bl, %bl
je 0x17bee
movq 0x3240e(%rip), %rdi     # 0x49fe8
leaq 0x1eda1(%rip), %rsi     # 0x36982
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movq 0x38(%r13), %rax
movl 0x8(%r15), %ecx
movl 0x4(%rax), %eax
imull %ecx, %eax
movq 0x220(%rsp), %rdx
movl %eax, 0x4(%rdx)
movl %ecx, (%rdx)
pushq $0x1
popq %rax
jmp 0x18035
xorl %ebp, %ebp
movzbl %bpl, %edx
movzbl %bl, %ecx
movq %r13, %rdi
movq %r14, %rsi
callq 0x15822
movq 0x38(%r13), %rax
movl 0x8(%rax), %edx
testb %bl, %bl
je 0x17c56
movq 0x323b1(%rip), %rdi     # 0x49fe8
leaq 0x1ed8c(%rip), %rsi     # 0x369ca
movl %edx, %ebx
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movl %ebx, %edx
movb 0x238(%rsp), %bl
movl %ebp, %eax
xorb $0x1, %al
movzbl %al, %ecx
movl %edx, 0x24(%rsp)
testl %edx, %edx
movq %rcx, 0x30(%rsp)
je 0x17c82
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r12, %r8
movq %r14, %r9
callq 0x15be6
jmp 0x17c98
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r12, %r8
movq %r14, %r9
callq 0x162b8
movl %ebp, 0x28(%rsp)
movq %r15, 0x38(%rsp)
movl 0x28(%r13), %eax
movl 0x20(%r13), %ecx
movl 0x24(%r13), %edx
leal (%rax,%rcx), %esi
cmpl %edx, %esi
cmovgel %edx, %esi
movl %esi, 0xc(%rsp)
addl %eax, %edx
cmpl %ecx, %edx
cmovgel %ecx, %edx
movl %edx, 0x8(%rsp)
testb %bl, %bl
je 0x17d44
movq 0x32319(%rip), %r15     # 0x49fe8
leaq 0x1ed03(%rip), %rsi     # 0x369d9
movq %r15, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
leaq 0xc(%rsp), %rbp
leaq 0x8(%rsp), %rbx
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x15a46
leaq 0x1ece9(%rip), %rsi     # 0x369f1
movq %r15, %rdi
callq 0x72b0
movl (%rbp), %r15d
movq %rax, %rdi
movl %r15d, %esi
callq 0x75c0
leaq 0x1ebe7(%rip), %rsi     # 0x3690d
movq %rax, %rdi
callq 0x72b0
movl (%rbx), %ebp
movq %rax, %rdi
movl %ebp, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
jmp 0x17d65
leaq 0xc(%rsp), %r15
leaq 0x8(%rsp), %rbp
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x15a46
movl (%r15), %r15d
movl (%rbp), %ebp
movq (%r13), %rax
movslq %r15d, %rcx
movq (%rax,%rcx,8), %rax
movslq %ebp, %rbx
movl (%rax,%rbx,4), %eax
movq 0x220(%rsp), %rcx
movl %eax, 0x4(%rcx)
cmpb $0x0, 0x238(%rsp)
je 0x17db9
movq 0x32256(%rip), %rdi     # 0x49fe8
leaq 0x1ec69(%rip), %rsi     # 0x36a02
callq 0x72b0
movq 0x220(%rsp), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x18(%rsp), %rax
cmpl $0x0, (%rax)
jle 0x1800e
cmpb $0x1, 0x3(%r14)
jne 0x17de3
cmpl 0x24(%r13), %r15d
jge 0x17de3
movl 0x10(%r12), %eax
addl %r15d, %eax
decl %eax
movl %eax, 0x14(%r12)
cmpb $0x1, 0x1(%r14)
jne 0x17dff
cmpl 0x20(%r13), %ebp
jge 0x17dff
movq (%r12), %rax
addq %rbx, %rax
decq %rax
movq %rax, 0x8(%r12)
cmpb $0x1, 0x2(%r14)
jne 0x17e1b
cmpl 0x24(%r13), %r15d
jge 0x17e1b
movl 0x14(%r12), %eax
subl %r15d, %eax
incl %eax
movl %eax, 0x10(%r12)
cmpb $0x1, (%r14)
jne 0x17e39
cmpl 0x20(%r13), %ebp
jge 0x17e39
movq 0x8(%r12), %rax
negq %rbx
addq %rbx, %rax
incq %rax
movq %rax, (%r12)
movb 0x238(%rsp), %bl
testb %bl, %bl
movq 0x38(%rsp), %r15
je 0x17e64
movq 0x32198(%rip), %rdi     # 0x49fe8
leaq 0x1ebb8(%rip), %rsi     # 0x36a0f
callq 0x72b0
movq %rax, %rdi
callq 0x7160
leaq 0x60(%rsp), %rdi
callq 0x71e0
cmpl $0x0, 0x24(%rsp)
movl 0x28(%rsp), %ebp
je 0x17eaf
subq $0x8, %rsp
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x68(%rsp), %r8
movq %r13, %rdi
movq 0x228(%rsp), %rcx
movq %r12, %r9
pushq %r15
pushq 0x20(%rsp)
pushq 0x48(%rsp)
callq 0x16ace
addq $0x20, %rsp
jmp 0x17ee1
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x60(%rsp), %r9
movq %r13, %rdi
movq %r14, %rcx
movq 0x220(%rsp), %r8
pushq %r15
pushq 0x18(%rsp)
pushq 0x40(%rsp)
pushq %r12
callq 0x1726a
addq $0x20, %rsp
testb %bl, %bl
je 0x17f57
movq 0x320fc(%rip), %rdi     # 0x49fe8
leaq 0x1eb29(%rip), %rsi     # 0x36a1c
callq 0x72b0
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x75c0
leaq 0x1ea02(%rip), %rsi     # 0x3690d
movq %rax, %rdi
callq 0x72b0
movl 0x8(%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x18(%rsp), %rax
movl (%rax), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
jae 0x18004
movq 0x320a7(%rip), %rdi     # 0x49fe8
leaq 0x1eaed(%rip), %rsi     # 0x36a35
callq 0x72b0
movq %rax, %rdi
callq 0x7160
jmp 0x17f6a
movq 0x18(%rsp), %rax
movl (%rax), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
jae 0x18004
leaq 0x78(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x7540
testb %bpl, %bpl
jne 0x17f90
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
addq %rdi, %rsi
callq 0xa101
movq 0x48(%rsp), %rbx
movq 0x220(%rsp), %r15
leaq 0x8(%r15), %r14
addq $0x20, %r15
movslq %ebx, %r12
xorl %ebp, %ebp
cmpl %ebx, %ebp
jge 0x17ffa
movq 0x40(%rsp), %rax
movslq %ebp, %rcx
leaq (%rax,%rcx), %rsi
incq %rcx
movl %ebp, %r13d
cmpq %r12, %rcx
jge 0x17fd4
movb (%rax,%rcx), %dl
incl %r13d
incq %rcx
cmpb (%rsi), %dl
je 0x17fc0
jmp 0x17fd7
movl %ebx, %r13d
movq %r14, %rdi
callq 0x18cba
movl %r13d, %eax
subl %ebp, %eax
movl %eax, 0x2c(%rsp)
movq %r15, %rdi
leaq 0x2c(%rsp), %rsi
callq 0x18e08
movl %r13d, %ebp
jmp 0x17faa
leaq 0x40(%rsp), %rdi
callq 0x76a8
leaq 0x60(%rsp), %rdi
callq 0x7210
cmpb $0x0, 0x238(%rsp)
je 0x18033
movq 0x31fc9(%rip), %rdi     # 0x49fe8
leaq 0x1ea31(%rip), %rsi     # 0x36a57
callq 0x72b0
movq %rax, %rdi
callq 0x7160
xorl %eax, %eax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x18052
jmp 0x1804b
movq %rax, %rbx
jmp 0x1805f
jmp 0x18052
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x76a8
leaq 0x60(%rsp), %rdi
callq 0x7210
movq %rbx, %rdi
callq 0x75e0
nop