// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/dp.cpp
// Function: dynProg::dpFillStaticBackward(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 const&)
int dynProg::dpFillStaticBackward(const string& ref,const string& query,
        const boundaries& offset){
    int        d = 0;
    int bandL = max(bandLeft, bandSize);
    int bandR = max(bandRight, bandSize);
    for(long i = 1; i <= L2; i++ ){
        //always backward: traverse from right to left!
        long idx2 = i-bandL;
        long colRB = i+bandR;
        if(idx2>0){//left value undefined
            d = scores.scoreMatrix[size_t (ref[offset.refE-idx2+1])][size_t (query[offset.queryE-i+1])];
            M[ i ][ idx2 ] = M[ i-1 ][ idx2-1 ] + d;
            UP[i][idx2] = max(M[ i-1 ][ idx2 ] + scores.extendGap + scores.openGap, UP[i-1][idx2]+scores.extendGap);
            M[ i ][ idx2 ] = max(M[ i ][ idx2 ] , UP[i][idx2]);
            //fill in generic value for gapLeft, such that it is defined, but not chosen in next step
            LEFT[i][idx2] = M[ i ][ idx2 ] + scores.extendGap + 2*scores.openGap;
            idx2++;
        }
        for(long j = max( 1L, idx2); j <= min((long)L1, colRB-1); j++ ){
            //here insert substitution matrix!
            d = scores.scoreMatrix[size_t(ref[offset.refE-j+1])][size_t(query[offset.queryE-i+1])];
            UP[i][j] = max(M[ i-1 ][ j ] + scores.extendGap + scores.openGap, UP[i-1][j]+scores.extendGap);
            M[i][j] = M[ i-1 ][ j-1 ] + d;
            LEFT[i][j] = max(M[ i ][ j-1 ] + scores.extendGap + scores.openGap, LEFT[i][j-1]+scores.extendGap);
            M[i][j] = max(M[i][j], LEFT[i][j]);
            M[i][j] = max(M[i][j], UP[i][j]);
        }
        if(colRB <= L1){
            idx2 = colRB;
            d = scores.scoreMatrix[size_t(ref[offset.refE-idx2+1])][size_t(query[offset.queryE-i+1])];
            M[ i ][ idx2 ] = M[ i-1 ][ idx2-1 ] + d;
            LEFT[i][idx2] = max(M[ i ][ idx2-1 ] + scores.extendGap + scores.openGap, LEFT[i][idx2-1]+scores.extendGap);
            M[ i ][ idx2 ] = max(M[ i ][ idx2 ], LEFT[i][idx2]);
            //fill in generic value for gapUp, such that it is defined, but not chosen in next step
            UP[i][idx2] = M[ i ][ idx2 ] + scores.extendGap + 2*scores.openGap;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, -0x60(%rsp)
movq %rdi, -0x58(%rsp)
cmpl $0x0, 0x24(%rdi)
jle 0x1b5bd
movq -0x58(%rsp), %r10
movl 0x30(%r10), %eax
movl 0x28(%r10), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
movl 0x2c(%r10), %r8d
cmpl %ecx, %r8d
cmovgl %r8d, %ecx
movslq %ecx, %rcx
movq %rcx, -0x10(%rsp)
cltq
movq %rax, -0x18(%rsp)
movq 0x38(%r10), %r9
leaq 0x10(%r9), %rax
movq %rax, -0x38(%rsp)
movq -0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq (%rsi), %rcx
movq (%rdx), %rdi
movq (%r10), %rdx
movq %rdx, -0x40(%rsp)
movq 0x8(%r10), %rdx
movq %rdx, -0x48(%rsp)
movq 0x10(%r10), %rdx
movq %rdx, -0x50(%rsp)
movq %rax, -0x28(%rsp)
movq %rcx, -0x30(%rsp)
addq %rcx, %rax
incq %rax
movq %rax, -0x20(%rsp)
movl $0x1, %r13d
movq %r13, %rbp
subq -0x10(%rsp), %rbp
jle 0x1b3e7
movq -0x28(%rsp), %rax
subq %rbp, %rax
movq -0x30(%rsp), %rcx
movsbq 0x1(%rcx,%rax), %rax
movq -0x60(%rsp), %rcx
movslq 0x14(%rcx), %rsi
subq %r13, %rsi
movsbq 0x1(%rdi,%rsi), %rsi
imulq $0x1fc, %rax, %rax      # imm = 0x1FC
addq -0x38(%rsp), %rax
movq -0x40(%rsp), %rcx
movq -0x8(%rcx,%r13,8), %r8
movl -0x4(%r8,%rbp,4), %r10d
addl (%rax,%rsi,4), %r10d
movq (%rcx,%r13,8), %rax
movl %r10d, (%rax,%rbp,4)
movl 0xc(%r9), %esi
movl (%r8,%rbp,4), %r8d
addl %esi, %r8d
movq -0x48(%rsp), %rcx
movq -0x8(%rcx,%r13,8), %r10
addl (%r10,%rbp,4), %esi
addl 0x8(%r9), %r8d
cmpl %esi, %r8d
cmovgl %r8d, %esi
movq (%rcx,%r13,8), %r8
movl %esi, (%r8,%rbp,4)
movl (%rax,%rbp,4), %r8d
cmpl %esi, %r8d
cmovgl %r8d, %esi
movl %esi, (%rax,%rbp,4)
addl 0xc(%r9), %esi
movl 0x8(%r9), %eax
leal (%rsi,%rax,2), %eax
movq -0x50(%rsp), %rcx
movq (%rcx,%r13,8), %rsi
movl %eax, (%rsi,%rbp,4)
incq %rbp
cmpq $0x2, %rbp
movl $0x1, %eax
cmovlq %rax, %rbp
movq -0x18(%rsp), %rax
addq %r13, %rax
movq %rax, -0x8(%rsp)
decq %rax
movq -0x58(%rsp), %rcx
movslq 0x20(%rcx), %r12
cmpq %r12, %rax
movq %r12, %rsi
cmovlq %rax, %rsi
cmpq %rsi, %rbp
jg 0x1b500
movq -0x40(%rsp), %rcx
movq -0x8(%rcx,%r13,8), %r8
movq (%rcx,%r13,8), %rsi
movq -0x48(%rsp), %rcx
movq -0x8(%rcx,%r13,8), %r11
movq (%rcx,%r13,8), %r15
movq -0x50(%rsp), %rcx
movq (%rcx,%r13,8), %r14
movq -0x20(%rsp), %rbx
subq %rbp, %rbx
decq %rbp
movsbq (%rbx), %r10
movq -0x60(%rsp), %rcx
movslq 0x14(%rcx), %r12
subq %r13, %r12
imulq $0x1fc, %r10, %r10      # imm = 0x1FC
addq -0x38(%rsp), %r10
movl 0xc(%r9), %ecx
movl 0x4(%r8,%rbp,4), %edx
addl %ecx, %edx
addl 0x8(%r9), %edx
addl 0x4(%r11,%rbp,4), %ecx
cmpl %ecx, %edx
cmovgl %edx, %ecx
movsbq 0x1(%rdi,%r12), %rdx
movl (%r10,%rdx,4), %edx
movl %ecx, 0x4(%r15,%rbp,4)
addl (%r8,%rbp,4), %edx
movl %edx, 0x4(%rsi,%rbp,4)
movl 0xc(%r9), %r12d
movl (%rsi,%rbp,4), %ecx
addl %r12d, %ecx
addl 0x8(%r9), %ecx
addl (%r14,%rbp,4), %r12d
cmpl %r12d, %ecx
cmovgl %ecx, %r12d
movl %r12d, 0x4(%r14,%rbp,4)
movl 0x4(%rsi,%rbp,4), %r10d
cmpl %r12d, %r10d
jg 0x1b4c7
movl %r12d, %r10d
movl %r10d, 0x4(%rsi,%rbp,4)
movl 0x4(%r15,%rbp,4), %r12d
cmpl %r12d, %r10d
jg 0x1b4d9
movl %r12d, %r10d
movl %r10d, 0x4(%rsi,%rbp,4)
movq -0x58(%rsp), %rcx
movslq 0x20(%rcx), %r12
cmpq %r12, %rax
movq %r12, %rcx
cmovlq %rax, %rcx
incq %rbp
decq %rbx
cmpq %rcx, %rbp
jl 0x1b450
movq -0x8(%rsp), %r8
cmpq %r12, %r8
jg 0x1b5a4
movq -0x28(%rsp), %rax
subq %r8, %rax
movq -0x30(%rsp), %rcx
movsbq 0x1(%rcx,%rax), %rax
movq -0x60(%rsp), %rcx
movslq 0x14(%rcx), %rcx
subq %r13, %rcx
movsbq 0x1(%rdi,%rcx), %rcx
imulq $0x1fc, %rax, %rax      # imm = 0x1FC
addq -0x38(%rsp), %rax
movq -0x40(%rsp), %rsi
movq -0x8(%rsi,%r13,8), %rdx
movq (%rsi,%r13,8), %rsi
movl -0x4(%rdx,%r8,4), %edx
addl (%rax,%rcx,4), %edx
movl %edx, (%rsi,%r8,4)
movl 0xc(%r9), %eax
movl -0x4(%rsi,%r8,4), %ecx
addl %eax, %ecx
addl 0x8(%r9), %ecx
movq -0x50(%rsp), %rdx
movq (%rdx,%r13,8), %rdx
addl -0x4(%rdx,%r8,4), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl %eax, (%rdx,%r8,4)
movl (%rsi,%r8,4), %ecx
cmpl %eax, %ecx
cmovgl %ecx, %eax
movl %eax, (%rsi,%r8,4)
addl 0xc(%r9), %eax
movl 0x8(%r9), %ecx
leal (%rax,%rcx,2), %eax
movq -0x48(%rsp), %rcx
movq (%rcx,%r13,8), %rcx
movl %eax, (%rcx,%r8,4)
leaq 0x1(%r13), %rax
movq -0x58(%rsp), %rcx
movslq 0x24(%rcx), %rcx
cmpq %rcx, %r13
movq %rax, %r13
jl 0x1b339
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq