// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38(%rsp)
movq %r8, %r14
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, 0x10(%rsp)
movq %rdi, %r12
movb 0x238(%rsp), %r15b
movl 0x228(%rsp), %esi
movl 0x8(%rcx), %eax
subl (%rcx), %eax
incl %eax
movl %eax, 0x20(%rdi)
movl 0x14(%rcx), %ecx
subl 0x10(%r13), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x24(%rdi)
movl %esi, 0x28(%rdi)
movb $0x1, 0x34(%rdi)
movb 0x2(%r8), %dil
cmpb $0x1, %dil
jne 0x1d4dd
cmpb $0x0, (%r14)
jne 0x1d4dd
leal (%rdx,%rsi), %r8d
cmpl %eax, %r8d
jl 0x1d501
movb (%r14), %r9b
movl %edx, %r8d
subl %esi, %r8d
testb %dil, %dil
jne 0x1d5f8
testb %r9b, %r9b
je 0x1d5f8
cmpl %eax, %r8d
jle 0x1d5f8
cmpl %eax, %edx
movl 0x20(%r12), %esi
movl 0x24(%r12), %edi
movl %edi, %edx
cmovll %esi, %edx
cmpl %ecx, %eax
cmovgl %edi, %esi
subl %esi, %edx
cmpl 0x230(%rsp), %edx
jge 0x1d58c
movl %edx, 0x28(%r12)
testb %r15b, %r15b
je 0x1d606
movq 0x36ab1(%rip), %r15     # 0x53fe8
leaq 0x2742e(%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
movb 0x238(%rsp), %r15b
callq 0x7040
movq %rax, %rdi
callq 0x71d0
jmp 0x1d606
testb %r15b, %r15b
je 0x1d5d3
movq 0x36a50(%rip), %r14     # 0x53fe8
leaq 0x273e3(%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(%rbx), %ecx
movl 0x4(%rax), %eax
imull %ecx, %eax
movq 0x220(%rsp), %rdx
movl %eax, 0x4(%rdx)
movl %ecx, (%rdx)
movl $0x1, %eax
jmp 0x1dc43
orb %r9b, %dil
je 0x1d621
testb %dil, %dil
je 0x1dc55
cmpb $0x0, 0x2(%r14)
movq %rbx, 0x18(%rsp)
jne 0x1d618
cmpb $0x1, (%r14)
jne 0x1d634
movb 0x4(%r14), %bl
xorb $0x1, %bl
jmp 0x1d636
cmpb $0x0, 0x1(%r14)
jne 0x1d5fd
addl %edx, %esi
cmpl %eax, %esi
jl 0x1d501
jmp 0x1d5fd
xorl %ebx, %ebx
movzbl %bl, %edx
movzbl %r15b, %ecx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1aa00
movq 0x38(%r12), %rax
movl 0x8(%rax), %ebp
testb %r15b, %r15b
je 0x1d69f
movq 0x3698c(%rip), %r15     # 0x53fe8
leaq 0x27367(%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
movb 0x238(%rsp), %r15b
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movl %ebx, %eax
xorb $0x1, %al
movzbl %al, %ecx
movl %ebp, 0x28(%rsp)
testl %ebp, %ebp
movq %rcx, 0x30(%rsp)
je 0x1d6cd
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %r8
movq %r14, %r9
callq 0x1af00
jmp 0x1d6e5
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %r8
movq %r14, %r9
callq 0x1b5ca
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 %r15b, %r15b
movl %ebx, 0x24(%rsp)
je 0x1d7e9
movq 0x368c9(%rip), %r15     # 0x53fe8
leaq 0x272b3(%rip), %rsi     # 0x449d9
movl $0x17, %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 0xc(%rsp), %rbp
leaq 0x8(%rsp), %rbx
movq %r12, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1acd2
leaq 0x27275(%rip), %rsi     # 0x449f1
movl $0x10, %edx
movq %r15, %rdi
callq 0x7340
movl (%rbp), %esi
movq %r15, %rdi
callq 0x75d0
movq %rax, %r15
leaq 0x2716f(%rip), %rsi     # 0x4490d
movl $0x2, %edx
movq %rax, %rdi
callq 0x7340
movl (%rbx), %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
movb 0x238(%rsp), %r15b
callq 0x7040
movq %rax, %rdi
callq 0x71d0
jmp 0x1d7fe
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movq %r14, %rcx
callq 0x1acd2
movq (%r12), %rax
movslq 0xc(%rsp), %rbx
movq (%rax,%rbx,8), %rax
movslq 0x8(%rsp), %rbp
movl (%rax,%rbp,4), %eax
movq 0x220(%rsp), %rcx
movl %eax, 0x4(%rcx)
testb %r15b, %r15b
je 0x1d883
movq 0x367be(%rip), %r15     # 0x53fe8
leaq 0x271d1(%rip), %rsi     # 0x44a02
movl $0xc, %edx
movq %r15, %rdi
callq 0x7340
movq 0x220(%rsp), %rax
movl 0x4(%rax), %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
movb 0x238(%rsp), %r15b
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x38(%rsp), %rax
cmpl $0x0, (%rax)
jle 0x1dbfa
cmpb $0x1, 0x3(%r14)
jne 0x1d8ab
cmpl 0x24(%r12), %ebx
jge 0x1d8ab
movl 0x10(%r13), %eax
addl %ebx, %eax
decl %eax
movl %eax, 0x14(%r13)
cmpb $0x1, 0x1(%r14)
jne 0x1d8c7
cmpl 0x20(%r12), %ebp
jge 0x1d8c7
movq (%r13), %rax
addq %rbp, %rax
decq %rax
movq %rax, 0x8(%r13)
cmpb $0x1, 0x2(%r14)
jne 0x1d8e1
cmpl 0x24(%r12), %ebx
jge 0x1d8e1
movl 0x14(%r13), %eax
subl %ebx, %eax
incl %eax
movl %eax, 0x10(%r13)
cmpb $0x1, (%r14)
jne 0x1d8ff
cmpl 0x20(%r12), %ebp
jge 0x1d8ff
movq 0x8(%r13), %rax
negq %rbp
addq %rbp, %rax
incq %rax
movq %rax, (%r13)
testb %r15b, %r15b
je 0x1d94e
movq 0x366dd(%rip), %r15     # 0x53fe8
leaq 0x270fd(%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
movb 0x238(%rsp), %r15b
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0x60(%rsp), %rdi
callq 0x71e0
cmpl $0x0, 0x28(%rsp)
movq 0x18(%rsp), %rax
je 0x1d99c
subq $0x8, %rsp
leaq 0x14(%rsp), %rsi
leaq 0x10(%rsp), %rdx
leaq 0x68(%rsp), %r8
movq %r12, %rdi
movq 0x228(%rsp), %rbx
movq %rbx, %rcx
movq %r13, %r9
pushq %rax
pushq 0x20(%rsp)
pushq 0x48(%rsp)
callq 0x1be3e
addq $0x20, %rsp
jmp 0x1d9d0
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x60(%rsp), %r9
movq %r12, %rdi
movq %r14, %rcx
movq 0x220(%rsp), %rbx
movq %rbx, %r8
pushq %rax
pushq 0x18(%rsp)
pushq 0x40(%rsp)
pushq %r13
callq 0x1c7f4
addq $0x20, %rsp
testb %r15b, %r15b
je 0x1da4a
movq 0x3660c(%rip), %rdi     # 0x53fe8
leaq 0x27039(%rip), %rsi     # 0x44a1c
movl $0x18, %edx
callq 0x7340
movl 0xc(%rsp), %esi
movq 0x365f0(%rip), %rdi     # 0x53fe8
callq 0x75d0
movq %rax, %r14
leaq 0x26f06(%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 0x38(%rsp), %rax
movl (%rax), %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x1dbdc
testb %r15b, %r15b
je 0x1daa8
movq 0x3657f(%rip), %r14     # 0x53fe8
leaq 0x26fc5(%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 0x3654d(%rip), %rdi     # 0x53fe8
callq 0x7040
movq %rax, %rdi
callq 0x71d0
leaq 0x78(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x7540
cmpb $0x0, 0x24(%rsp)
jne 0x1db02
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 0x1db02
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 0x1dae7
movq 0x48(%rsp), %r13
testl %r13d, %r13d
jle 0x1dbb9
leaq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x20(%rbx), %r15
movl %r13d, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %ebx, %ebx
movl %ebx, %r12d
movq 0x40(%rsp), %rax
movslq %ebx, %rdx
leal 0x1(%rdx), %ecx
cmpl %r13d, %ecx
cmovlel %r13d, %ecx
leaq 0x1(%rdx), %rsi
cmpq %rbp, %rsi
jge 0x1db57
movb (%rax,%rsi), %dil
incl %ebx
incq %rsi
cmpb (%rax,%rdx), %dil
je 0x1db41
jmp 0x1db59
movl %ecx, %ebx
addq 0x40(%rsp), %rdx
movq 0x220(%rsp), %r14
movq 0x10(%r14), %rsi
cmpq 0x18(%r14), %rsi
je 0x1db7a
movb (%rdx), %al
movb %al, (%rsi)
incq 0x10(%r14)
jmp 0x1db84
movq 0x10(%rsp), %rdi
callq 0x1ebb8
movl %ebx, %eax
subl %r12d, %eax
movl %eax, 0x2c(%rsp)
movq 0x28(%r14), %rsi
cmpq 0x30(%r14), %rsi
je 0x1dba3
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x28(%r14)
jmp 0x1dbb0
movq %r15, %rdi
leaq 0x2c(%rsp), %rdx
callq 0x1ecaa
cmpl %r13d, %ebx
jl 0x1db28
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1dbd4
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x72f0
movb 0x238(%rsp), %r15b
movq 0x363b5(%rip), %rsi     # 0x53f98
leaq 0x60(%rsp), %rdi
callq 0x7210
leaq 0xe0(%rsp), %rdi
callq 0x7100
testb %r15b, %r15b
je 0x1dc41
movq 0x363e2(%rip), %rbx     # 0x53fe8
leaq 0x26e4a(%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
cmpb $0x0, 0x3(%r14)
jne 0x1d606
cmpl %eax, %r8d
jg 0x1d501
jmp 0x1d606
jmp 0x1dc92
jmp 0x1dc72
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1dc95
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x72f0
jmp 0x1dc95
movq %rax, %rbx
movq 0x362fc(%rip), %rsi     # 0x53f98
leaq 0x60(%rsp), %rdi
callq 0x7210
leaq 0xe0(%rsp), %rdi
callq 0x7100
movq %rbx, %rdi
callq 0x7600
nop