// File: 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:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq 0xc0(%rsp), %rsi
movq %rsi, 0x38(%rsp)
movl $0x0, 0xa4(%rsp)
movq %rsi, %rdi
addq $0x2c, %rdi
addq $0x28, %rsi
callq 0x14d40
movq 0x38(%rsp), %rsi
movl (%rax), %eax
movl %eax, 0xa0(%rsp)
movq %rsi, %rdi
addq $0x30, %rdi
addq $0x28, %rsi
callq 0x14d40
movl (%rax), %eax
movl %eax, 0x9c(%rsp)
movq $0x1, 0x90(%rsp)
movq 0x38(%rsp), %rcx
movq 0x90(%rsp), %rax
movslq 0x24(%rcx), %rcx
cmpq %rcx, %rax
jg 0x334f4
movq 0x90(%rsp), %rax
movslq 0xa0(%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rax
movslq 0x9c(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x88(%rsp)
jle 0x32f95
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rax
addq $0x10, %rax
movq %rax, 0x28(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rsi
subq 0x88(%rsp), %rsi
addq $0x1, %rsi
callq 0x8410
movq %rax, %rcx
movq 0x28(%rsp), %rax
movsbq (%rcx), %rcx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rax
movslq 0x14(%rax), %rsi
subq 0x90(%rsp), %rsi
addq $0x1, %rsi
callq 0x8410
movq 0x38(%rsp), %rcx
movq %rax, %rdx
movq 0x30(%rsp), %rax
movsbq (%rdx), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, 0xa4(%rsp)
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
subq $0x1, %rdx
movl (%rax,%rdx,4), %esi
addl 0xa4(%rsp), %esi
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
movl %esi, (%rax,%rdx,4)
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rdx
addl 0xc(%rdx), %eax
movq 0x38(%rcx), %rdx
addl 0x8(%rdx), %eax
movl %eax, 0x7c(%rsp)
movq 0x8(%rcx), %rax
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rcx
addl 0xc(%rcx), %eax
movl %eax, 0x78(%rsp)
leaq 0x7c(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x14d40
movq %rax, %rcx
movq 0x38(%rsp), %rax
movl (%rcx), %esi
movq 0x8(%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rsp), %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x88(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq 0x8(%rax), %rax
movq 0x90(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x88(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x14d40
movq %rax, %rcx
movq 0x38(%rsp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rsp), %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rsp), %rdx
movl (%rcx,%rdx,4), %edx
movq 0x38(%rax), %rcx
addl 0xc(%rcx), %edx
movq 0x38(%rax), %rcx
movl 0x8(%rcx), %ecx
shll %ecx
addl %ecx, %edx
movq 0x10(%rax), %rax
movq 0x90(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x88(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
movq $0x1, 0x68(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x1ec80
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movq 0x38(%rsp), %rax
movq 0x70(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movslq 0x20(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x80(%rsp), %rax
subq $0x1, %rax
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1efc0
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq (%rcx), %rax
jg 0x332a1
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rax
addq $0x10, %rax
movq %rax, 0x10(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rsi
subq 0x70(%rsp), %rsi
addq $0x1, %rsi
callq 0x8410
movq %rax, %rcx
movq 0x10(%rsp), %rax
movsbq (%rcx), %rcx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rax
movslq 0x14(%rax), %rsi
subq 0x90(%rsp), %rsi
addq $0x1, %rsi
callq 0x8410
movq 0x38(%rsp), %rcx
movq %rax, %rdx
movq 0x18(%rsp), %rax
movsbq (%rdx), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, 0xa4(%rsp)
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq (%rax,%rdx,8), %rax
movq 0x70(%rsp), %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rdx
addl 0xc(%rdx), %eax
movq 0x38(%rcx), %rdx
addl 0x8(%rdx), %eax
movl %eax, 0x54(%rsp)
movq 0x8(%rcx), %rax
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq (%rax,%rdx,8), %rax
movq 0x70(%rsp), %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rcx
addl 0xc(%rcx), %eax
movl %eax, 0x50(%rsp)
leaq 0x54(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x14d40
movq 0x38(%rsp), %rcx
movl (%rax), %esi
movq 0x8(%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x70(%rsp), %rdx
movl %esi, (%rax,%rdx,4)
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq (%rax,%rdx,8), %rax
movq 0x70(%rsp), %rdx
subq $0x1, %rdx
movl (%rax,%rdx,4), %esi
addl 0xa4(%rsp), %esi
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x70(%rsp), %rdx
movl %esi, (%rax,%rdx,4)
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x70(%rsp), %rdx
subq $0x1, %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rdx
addl 0xc(%rdx), %eax
movq 0x38(%rcx), %rdx
addl 0x8(%rdx), %eax
movl %eax, 0x4c(%rsp)
movq 0x10(%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x70(%rsp), %rdx
subq $0x1, %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rcx
addl 0xc(%rcx), %eax
movl %eax, 0x48(%rsp)
leaq 0x4c(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x14d40
movq %rax, %rcx
movq 0x38(%rsp), %rax
movl (%rcx), %esi
movq 0x10(%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x70(%rsp), %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x70(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq 0x10(%rax), %rax
movq 0x90(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x70(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x14d40
movq %rax, %rcx
movq 0x38(%rsp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x70(%rsp), %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x70(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq 0x8(%rax), %rax
movq 0x90(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x70(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x14d40
movq %rax, %rcx
movq 0x38(%rsp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movq 0x90(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x70(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x32fb8
movq 0x38(%rsp), %rcx
movq 0x80(%rsp), %rax
movslq 0x20(%rcx), %rcx
cmpq %rcx, %rax
jg 0x334d9
movq 0x38(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %rcx, 0x88(%rsp)
movq 0x38(%rax), %rax
addq $0x10, %rax
movq %rax, (%rsp)
movq 0xb8(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rsi
subq 0x88(%rsp), %rsi
addq $0x1, %rsi
callq 0x8410
movq %rax, %rcx
movq (%rsp), %rax
movsbq (%rcx), %rcx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rax
movslq 0x14(%rax), %rsi
subq 0x90(%rsp), %rsi
addq $0x1, %rsi
callq 0x8410
movq 0x38(%rsp), %rcx
movq %rax, %rdx
movq 0x8(%rsp), %rax
movsbq (%rdx), %rdx
movl (%rax,%rdx,4), %eax
movl %eax, 0xa4(%rsp)
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
subq $0x1, %rdx
movl (%rax,%rdx,4), %esi
addl 0xa4(%rsp), %esi
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
movl %esi, (%rax,%rdx,4)
movq (%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
subq $0x1, %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rdx
addl 0xc(%rdx), %eax
movq 0x38(%rcx), %rdx
addl 0x8(%rdx), %eax
movl %eax, 0x44(%rsp)
movq 0x10(%rcx), %rax
movq 0x90(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x88(%rsp), %rdx
subq $0x1, %rdx
movl (%rax,%rdx,4), %eax
movq 0x38(%rcx), %rcx
addl 0xc(%rcx), %eax
movl %eax, 0x40(%rsp)
leaq 0x44(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x14d40
movq %rax, %rcx
movq 0x38(%rsp), %rax
movl (%rcx), %esi
movq 0x10(%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rsp), %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x88(%rsp), %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq 0x10(%rax), %rax
movq 0x90(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x88(%rsp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x14d40
movq %rax, %rcx
movq 0x38(%rsp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rsp), %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rcx
movq 0x90(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq 0x88(%rsp), %rdx
movl (%rcx,%rdx,4), %edx
movq 0x38(%rax), %rcx
addl 0xc(%rcx), %edx
movq 0x38(%rax), %rcx
movl 0x8(%rcx), %ecx
shll %ecx
addl %ecx, %edx
movq 0x8(%rax), %rax
movq 0x90(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x88(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x334db
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x32d12
xorl %eax, %eax
addq $0xc8, %rsp
retq
nop