// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rax
movq %rcx, %r14
movl 0x2c(%rdi), %eax
movl 0x28(%rdi), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
movl 0x30(%rdi), %r8d
cmpl %ecx, %r8d
cmovgl %r8d, %ecx
cltq
movq %rax, -0x28(%rsp)
movslq %ecx, %rax
movq %rax, -0x30(%rsp)
movq 0x38(%rdi), %rax
movq %rax, -0x40(%rsp)
leaq 0x10(%rax), %rax
movq %rax, -0x48(%rsp)
movq 0x8(%r14), %rax
movq %rax, -0x50(%rsp)
movq %rsi, -0x20(%rsp)
movq (%rsi), %rax
movq %rax, -0x58(%rsp)
movq %rdx, -0x18(%rsp)
movq (%rdx), %rax
movq %rax, -0x60(%rsp)
movq (%rdi), %rax
movq %rax, -0x68(%rsp)
movq 0x8(%rdi), %rax
movq %rax, -0x70(%rsp)
movq %rdi, -0x80(%rsp)
movq 0x10(%rdi), %rax
movq %rax, -0x78(%rsp)
movabsq $0x1, %rax
movq %r14, -0x38(%rsp)
movq -0x80(%rsp), %rcx
movslq 0x24(%rcx), %rcx
cmpq %rcx, %rax
jg 0x162a7
movq %rax, %rbp
subq -0x28(%rsp), %rbp
jle 0x160c9
movq -0x50(%rsp), %rcx
subq %rbp, %rcx
movq -0x58(%rsp), %rdx
movsbq 0x1(%rdx,%rcx), %rcx
movslq 0x14(%r14), %rdx
subq %rax, %rdx
movq -0x60(%rsp), %rsi
movsbq 0x1(%rsi,%rdx), %rdx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq -0x48(%rsp), %rcx
movq -0x68(%rsp), %rdi
movq -0x8(%rdi,%rax,8), %rsi
movl -0x4(%rsi,%rbp,4), %r8d
addl (%rcx,%rdx,4), %r8d
movq (%rdi,%rax,8), %rcx
movl %r8d, (%rcx,%rbp,4)
movq -0x40(%rsp), %rdi
movl 0xc(%rdi), %edx
movl (%rsi,%rbp,4), %esi
addl %edx, %esi
movq -0x70(%rsp), %r9
movq -0x8(%r9,%rax,8), %r8
addl (%r8,%rbp,4), %edx
addl 0x8(%rdi), %esi
cmpl %edx, %esi
cmovgl %esi, %edx
movq (%r9,%rax,8), %rsi
movl %edx, (%rsi,%rbp,4)
movl (%rcx,%rbp,4), %esi
cmpl %edx, %esi
cmovgl %esi, %edx
movl %edx, (%rcx,%rbp,4)
addl 0xc(%rdi), %edx
movl 0x8(%rdi), %ecx
leal (%rdx,%rcx,2), %ecx
movq -0x78(%rsp), %rdx
movq (%rdx,%rax,8), %rdx
movl %ecx, (%rdx,%rbp,4)
leaq -0x1(%rax), %rsi
incq %rbp
jmp 0x160cd
leaq -0x1(%rax), %rsi
cmpq $0x2, %rbp
movabsq $0x1, %rcx
cmovlq %rcx, %rbp
movq -0x30(%rsp), %rcx
leaq (%rax,%rcx), %rcx
movq %rcx, -0x10(%rsp)
leaq -0x1(%rcx), %r8
movq -0x80(%rsp), %rdi
movq 0x38(%rdi), %r10
leaq 0x10(%r10), %rcx
movq %rcx, (%rsp)
movq 0x8(%r14), %rdx
movq -0x20(%rsp), %rcx
movq (%rcx), %r9
movq -0x18(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, -0x8(%rsp)
movq (%rdi), %r11
movq 0x8(%rdi), %r13
subq %rbp, %rdx
leaq (%r9,%rdx), %r12
incq %r12
movq 0x10(%rdi), %r15
movq -0x80(%rsp), %rcx
movslq 0x20(%rcx), %rdx
cmpq %rdx, %r8
movq %rdx, %r9
cmovlq %r8, %r9
cmpq %r9, %rbp
jg 0x161f1
movq (%r11,%rsi,8), %rdx
movl 0xc(%r10), %r9d
movl (%rdx,%rbp,4), %ebx
addl %r9d, %ebx
movq (%r13,%rsi,8), %rcx
addl (%rcx,%rbp,4), %r9d
movsbq (%r12), %rcx
movslq 0x14(%r14), %rdi
subq %rax, %rdi
movq -0x8(%rsp), %r14
movsbq 0x1(%r14,%rdi), %rdi
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq (%rsp), %rcx
addl 0x8(%r10), %ebx
movl (%rcx,%rdi,4), %ecx
cmpl %r9d, %ebx
cmovgl %ebx, %r9d
movq (%r13,%rax,8), %rdi
movl %r9d, (%rdi,%rbp,4)
addl -0x4(%rdx,%rbp,4), %ecx
movq (%r11,%rax,8), %r9
movl %ecx, (%r9,%rbp,4)
movl 0xc(%r10), %edx
movl -0x4(%r9,%rbp,4), %ecx
addl %edx, %ecx
addl 0x8(%r10), %ecx
movq (%r15,%rax,8), %rbx
addl -0x4(%rbx,%rbp,4), %edx
cmpl %edx, %ecx
cmovgl %ecx, %edx
movl %edx, (%rbx,%rbp,4)
movl (%r9,%rbp,4), %ecx
cmpl %edx, %ecx
cmovgl %ecx, %edx
movl %edx, (%r9,%rbp,4)
movl (%rdi,%rbp,4), %ebx
cmpl %ebx, %edx
jg 0x161dd
movl %ebx, %edx
movl %edx, (%r9,%rbp,4)
incq %rbp
decq %r12
movq -0x38(%rsp), %r14
jmp 0x16130
movq -0x10(%rsp), %r9
cmpq %rdx, %r9
jg 0x1629f
movq -0x50(%rsp), %rcx
subq %r9, %rcx
movq -0x58(%rsp), %rdx
movsbq 0x1(%rdx,%rcx), %rcx
movslq 0x14(%r14), %rdx
subq %rax, %rdx
movq -0x60(%rsp), %rsi
movsbq 0x1(%rsi,%rdx), %rdx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq -0x48(%rsp), %rcx
movq -0x68(%rsp), %rdi
movq -0x8(%rdi,%rax,8), %rsi
movq (%rdi,%rax,8), %rdi
movl -0x4(%rsi,%r9,4), %esi
addl (%rcx,%rdx,4), %esi
movl %esi, (%rdi,%r9,4)
movq -0x40(%rsp), %r8
movl 0xc(%r8), %ecx
movl -0x4(%rdi,%r9,4), %edx
addl %ecx, %edx
addl 0x8(%r8), %edx
movq -0x78(%rsp), %rsi
movq (%rsi,%rax,8), %rsi
addl -0x4(%rsi,%r9,4), %ecx
cmpl %ecx, %edx
cmovgl %edx, %ecx
movl %ecx, (%rsi,%r9,4)
movl (%rdi,%r9,4), %edx
cmpl %ecx, %edx
cmovgl %edx, %ecx
movl %ecx, (%rdi,%r9,4)
movq -0x38(%rsp), %r14
addl 0xc(%r8), %ecx
movl 0x8(%r8), %edx
leal (%rcx,%rdx,2), %ecx
movq -0x70(%rsp), %rdx
movq (%rdx,%rax,8), %rdx
movl %ecx, (%rdx,%r9,4)
incq %rax
jmp 0x1600a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq