// File: /workspace/github_cpp_makefile_star2_O3/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, 0x20(%rsp)
movq %r8, %r14
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r12
movb 0x238(%rsp), %bl
movl 0x228(%rsp), %edi
movl 0x8(%rcx), %r9d
subl (%rcx), %r9d
incl %r9d
movl %r9d, 0x20(%r12)
movl 0x14(%rcx), %edx
movq %rcx, 0x10(%rsp)
subl 0x10(%rcx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x24(%r12)
movl %edi, 0x28(%r12)
movb $0x1, 0x34(%r12)
movb (%r8), %r8b
movb 0x2(%r14), %al
cmpb $0x1, %al
jne 0x1d1dd
testb %r8b, %r8b
jne 0x1d28d
addl %esi, %edi
cmpl %r9d, %edi
jl 0x1d20c
jmp 0x1d28d
testb %r8b, %r8b
jne 0x1d1fd
cmpb $0x0, 0x1(%r14)
jne 0x1d1f2
leal (%rsi,%rdi), %r8d
cmpl %r9d, %r8d
jl 0x1d20c
cmpb $0x0, 0x3(%r14)
jne 0x1d28d
movl %esi, %r8d
subl %edi, %r8d
cmpl %r9d, %r8d
jle 0x1d28d
cmpl %r9d, %esi
movl %r9d, %edi
cmovgl %esi, %edi
cmpl %edx, %r9d
cmovgl %esi, %r9d
subl %r9d, %edi
cmpl 0x230(%rsp), %edi
jge 0x1d2a1
movl %edi, 0x28(%r12)
testb %bl, %bl
je 0x1d28d
movq %r15, %rbp
movq 0x36dad(%rip), %r15     # 0x53fe8
leaq 0x2772a(%rip), %rsi     # 0x4496c
movl $0x15, %edx
movq %r15, %rdi
callq 0x7340
movl 0x28(%r12), %esi
movq %r15, %rdi
callq 0x75d0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r15, %rdi
movq %rbp, %r15
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movb 0x2(%r14), %al
testb $0x1, %al
jne 0x1d297
cmpb $0x1, (%r14)
jne 0x1d30d
movb 0x4(%r14), %bpl
xorb $0x1, %bpl
jmp 0x1d30f
testb %bl, %bl
je 0x1d2e7
movq 0x36d3c(%rip), %r14     # 0x53fe8
leaq 0x276cf(%rip), %rsi     # 0x44982
movl $0x47, %edx
movq %r14, %rdi
callq 0x7340
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x38(%r12), %rax
movl 0x8(%r13), %ecx
movl 0x4(%rax), %eax
imull %ecx, %eax
movq 0x220(%rsp), %rdx
movl %eax, 0x4(%rdx)
movl %ecx, (%rdx)
movl $0x1, %eax
jmp 0x1d95c
xorl %ebp, %ebp
movzbl %bpl, %edx
movzbl %bl, %ecx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1a78e
movq 0x38(%r12), %rax
movl 0x8(%rax), %eax
movl %eax, 0x1c(%rsp)
testb %bl, %bl
je 0x1d380
movq %r15, %rbx
movq 0x36cad(%rip), %r15     # 0x53fe8
leaq 0x27688(%rip), %rsi     # 0x449ca
movl $0xe, %edx
movq %r15, %rdi
callq 0x7340
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r15, %rdi
movq %rbx, %r15
movb 0x238(%rsp), %bl
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movl %ebp, %eax
xorb $0x1, %al
cmpl $0x0, 0x1c(%rsp)
movb %al, 0x7(%rsp)
je 0x1d3aa
movzbl %al, %ecx
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %r8
movq %r14, %r9
callq 0x1acc0
jmp 0x1d3c3
movzbl %al, %ecx
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %r8
movq %r14, %r9
callq 0x1b384
movq %r15, 0x30(%rsp)
movq %r13, 0x38(%rsp)
movl %ebp, 0x28(%rsp)
movl 0x28(%r12), %eax
movl 0x20(%r12), %ecx
movl 0x24(%r12), %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 0x1d540
movq 0x36be2(%rip), %rbx     # 0x53fe8
leaq 0x275cc(%rip), %rsi     # 0x449d9
movl $0x17, %edx
movq %rbx, %rdi
callq 0x7340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0xc(%rsp), %r13
leaq 0x8(%rsp), %r15
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1aa64
leaq 0x2758e(%rip), %rsi     # 0x449f1
movl $0x10, %edx
movq %rbx, %rdi
callq 0x7340
movslq (%r13), %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x75d0
movq %rax, %r13
leaq 0x27485(%rip), %rsi     # 0x4490d
movl $0x2, %edx
movq %rax, %rdi
callq 0x7340
movl (%r15), %r15d
movq %r13, %rdi
movl %r15d, %esi
callq 0x75d0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq (%r12), %rax
movq (%rax,%rbp,8), %rax
movslq %r15d, %rbx
movl (%rax,%rbx,4), %eax
movq 0x220(%rsp), %rcx
movl %eax, 0x4(%rcx)
leaq 0x27515(%rip), %rsi     # 0x44a02
movl $0xc, %edx
movq 0x36aef(%rip), %r13     # 0x53fe8
movq %r13, %rdi
callq 0x7340
movq 0x220(%rsp), %rax
movl 0x4(%rax), %esi
movq %r13, %rdi
callq 0x75d0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
jmp 0x1d57b
leaq 0xc(%rsp), %r15
leaq 0x8(%rsp), %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x1aa64
movq (%r12), %rax
movslq (%r15), %rbp
movq (%rax,%rbp,8), %rax
movl (%r13), %r15d
movslq %r15d, %rbx
movl (%rax,%rbx,4), %eax
movq 0x220(%rsp), %rcx
movl %eax, 0x4(%rcx)
movq 0x20(%rsp), %rax
cmpl $0x0, (%rax)
movb 0x238(%rsp), %r13b
jle 0x1d913
cmpb $0x1, 0x3(%r14)
jne 0x1d5ae
cmpl 0x24(%r12), %ebp
jge 0x1d5ae
movq 0x10(%rsp), %rcx
movl 0x10(%rcx), %eax
addl %ebp, %eax
decl %eax
movl %eax, 0x14(%rcx)
cmpb $0x1, 0x1(%r14)
jne 0x1d5ce
cmpl 0x20(%r12), %r15d
jge 0x1d5ce
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
addq %rbx, %rax
decq %rax
movq %rax, 0x8(%rcx)
cmpb $0x1, 0x2(%r14)
jne 0x1d5eb
cmpl 0x24(%r12), %ebp
jge 0x1d5eb
movq 0x10(%rsp), %rcx
movl 0x14(%rcx), %eax
subl %ebp, %eax
incl %eax
movl %eax, 0x10(%rcx)
cmpb $0x1, (%r14)
jne 0x1d60d
cmpl 0x20(%r12), %r15d
jge 0x1d60d
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rax
negq %rbx
addq %rbx, %rax
incq %rax
movq %rax, (%rcx)
testb %r13b, %r13b
movl 0x28(%rsp), %ebx
je 0x1d658
movq 0x369cb(%rip), %r15     # 0x53fe8
leaq 0x273eb(%rip), %rsi     # 0x44a0f
movl $0xc, %edx
movq %r15, %rdi
callq 0x7340
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0x60(%rsp), %rdi
callq 0x71e0
movzbl 0x7(%rsp), %eax
cmpl $0x0, 0x1c(%rsp)
je 0x1d6a8
subq $0x8, %rsp
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x68(%rsp), %r8
movq %r12, %rdi
movq 0x228(%rsp), %r15
movq %r15, %rcx
movq 0x18(%rsp), %r9
pushq 0x40(%rsp)
pushq 0x40(%rsp)
pushq %rax
callq 0x1bbda
addq $0x20, %rsp
jmp 0x1d6de
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x60(%rsp), %r9
movq %r12, %rdi
movq %r14, %rcx
movq 0x220(%rsp), %r15
movq %r15, %r8
pushq 0x38(%rsp)
pushq 0x38(%rsp)
pushq %rax
pushq 0x28(%rsp)
callq 0x1c522
addq $0x20, %rsp
testb %r13b, %r13b
je 0x1d7b7
movq 0x368fa(%rip), %rdi     # 0x53fe8
leaq 0x27327(%rip), %rsi     # 0x44a1c
movl $0x18, %edx
callq 0x7340
movl 0xc(%rsp), %esi
movq 0x368de(%rip), %rdi     # 0x53fe8
callq 0x75d0
movq %rax, %r14
leaq 0x271f4(%rip), %rsi     # 0x4490d
movl $0x2, %edx
movq %rax, %rdi
callq 0x7340
movl 0x8(%rsp), %esi
movq %r14, %rdi
callq 0x75d0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x20(%rsp), %rax
movl (%rax), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
jae 0x1d8f5
movq 0x36872(%rip), %r14     # 0x53fe8
leaq 0x272b8(%rip), %rsi     # 0x44a35
movl $0x21, %edx
movq %r14, %rdi
callq 0x7340
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq 0x36840(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
jmp 0x1d7ca
movq 0x20(%rsp), %rax
movl (%rax), %eax
addl $-0x3, %eax
cmpl $0x2, %eax
jae 0x1d8f5
leaq 0x78(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x7540
testb %bl, %bl
jne 0x1d821
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
testq %rcx, %rcx
setne %dl
addq %rax, %rcx
decq %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1d821
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x1d806
movq 0x48(%rsp), %rbx
testl %ebx, %ebx
jle 0x1d8d2
leaq 0x8(%r15), %rax
movq %rax, 0x10(%rsp)
addq $0x20, %r15
movl %ebx, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
xorl %ebp, %ebp
movl %ebp, %r12d
movq 0x40(%rsp), %rax
movslq %ebp, %rcx
leaq (%rax,%rcx), %rdx
leal 0x1(%rcx), %esi
cmpl %ebx, %esi
cmovlel %ebx, %esi
incq %rcx
cmpq %r13, %rcx
jge 0x1d876
movb (%rax,%rcx), %dil
incl %ebp
incq %rcx
cmpb (%rdx), %dil
je 0x1d861
jmp 0x1d878
movl %esi, %ebp
movq 0x220(%rsp), %r14
movq 0x10(%r14), %rsi
cmpq 0x18(%r14), %rsi
je 0x1d894
movb (%rdx), %al
movb %al, (%rsi)
incq 0x10(%r14)
jmp 0x1d89e
movq 0x10(%rsp), %rdi
callq 0x1e8b4
movl %ebp, %eax
subl %r12d, %eax
movl %eax, 0x2c(%rsp)
movq 0x28(%r14), %rsi
cmpq 0x30(%r14), %rsi
je 0x1d8bd
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%r14)
jmp 0x1d8ca
movq %r15, %rdi
leaq 0x2c(%rsp), %rdx
callq 0x1e9a6
cmpl %ebx, %ebp
jl 0x1d847
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1d8ed
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x72f0
movb 0x238(%rsp), %r13b
movq 0x3669c(%rip), %rsi     # 0x53f98
leaq 0x60(%rsp), %rdi
callq 0x7210
leaq 0xe0(%rsp), %rdi
callq 0x7100
testb %r13b, %r13b
je 0x1d95a
movq 0x366c9(%rip), %rbx     # 0x53fe8
leaq 0x27131(%rip), %rsi     # 0x44a57
movl $0xb, %edx
movq %rbx, %rdi
callq 0x7340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
xorl %eax, %eax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1d992
jmp 0x1d972
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1d995
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x72f0
jmp 0x1d995
movq %rax, %rbx
movq 0x365fc(%rip), %rsi     # 0x53f98
leaq 0x60(%rsp), %rdi
callq 0x7210
leaq 0xe0(%rsp), %rdi
callq 0x7100
movq %rbx, %rdi
callq 0x7600
nop