// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/dp.cpp
// Function: dynProg::dpFillOptStatic(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&, bool, boundaries const&, dp_type const&)
int dynProg::dpFillOptStatic(const string& ref,const string& query, bool forward, 
        const boundaries& offset, const dp_type& type){
    if(!forward)
        return dpFillOptStaticBackward(ref, query, offset);
    //TODO: when changed to mallocs: use row-order traversal
    int        d = 0;
    int        local = type.local || (type.freeQueryB && type.freeRefB) ? 0 : 1;
    int bandL = max(bandLeft, bandSize);
    int bandR = max(bandRight, bandSize);
    for(long i = 1; i <= L2; i++ ){
        long idx2 = forward ? i-bandL : L1 - L2 + i - bandL;
        long colRB = forward ? i+bandR : L1 - L2 + i + bandR;
        if(idx2>0){
            d = scores.scoreMatrix[size_t(ref[offset.refB+idx2-1])][size_t(query[offset.queryB+i-1])];
            M[ i ][ idx2 ] = max(M[ i-1 ][ idx2-1 ] + d, M[ i-1 ][ idx2 ] + scores.extendGap);
            M[ i ][ idx2 ] = max(M[ i ][ idx2 ], 0 + local*M[ i ][ idx2 ]);
            idx2++;
        }
        for(long j = max( 1L, idx2); j <= min((long)L1, colRB-1); j++ ){
            d = scores.scoreMatrix[size_t(ref[offset.refB+j-1])][size_t(query[offset.queryB+i-1])];
            M[ i ][ j ] = max(M[ i-1 ][ j-1 ] + d, M[ i ][ j-1 ] + scores.extendGap);
            M[ i ][ j ] = max(M[ i ][ j ], M[ i-1 ][ j ] + scores.extendGap);
            M[ i ][ j ] = max(M[ i ][ j ], 0 + local*M[ i ][ j ]);
        }
        if(colRB <= L1){
            idx2 = colRB;
            d = scores.scoreMatrix[size_t(ref[offset.refB+idx2-1])][size_t(query[offset.queryB+i-1])];
            M[ i ][ idx2 ] = max(M[ i-1 ][ idx2-1 ] + d, M[ i ][ idx2-1 ] + scores.extendGap);
            M[ i ][ idx2 ] = max(M[ i ][ idx2 ], 0 + local*M[ i ][ idx2 ]);
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
testl %ecx, %ecx
je 0x1b7ff
xorl %eax, %eax
cmpb $0x0, 0x4(%r9)
jne 0x1b5fc
movl $0x1, %eax
cmpb $0x1, 0x2(%r9)
jne 0x1b5fc
movzbl (%r9), %eax
xorl $0x1, %eax
cmpl $0x0, 0x24(%rdi)
jle 0x1b807
movl 0x30(%rdi), %ecx
movl 0x28(%rdi), %r9d
cmpl %r9d, %ecx
cmovlel %r9d, %ecx
movl 0x2c(%rdi), %r10d
cmpl %r9d, %r10d
cmovgl %r10d, %r9d
movslq %r9d, %r9
movq %r9, 0x28(%rsp)
movslq %ecx, %rcx
movq %rcx, 0x20(%rsp)
movq 0x38(%rdi), %r10
leaq 0x10(%r10), %r11
movq (%r8), %rcx
movq (%rsi), %r9
leaq (%r9,%rcx), %rsi
leaq -0x1(%r9,%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rdx), %rcx
movq (%rdi), %rdx
movq %rdx, (%rsp)
movq %rcx, 0x8(%rsp)
decq %rcx
movq %rcx, 0x18(%rsp)
movl $0x1, %r13d
movq %r13, %rbp
subq 0x28(%rsp), %rbp
jle 0x1b6cf
movq 0x10(%rsp), %rcx
movsbq (%rcx,%rbp), %rcx
movslq 0x10(%r8), %rdx
movq 0x8(%rsp), %r9
addq %r13, %r9
movsbq -0x1(%rdx,%r9), %rdx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq %r11, %rcx
movq (%rsp), %r14
movq -0x8(%r14,%r13,8), %r9
movl -0x4(%r9,%rbp,4), %ebx
addl (%rcx,%rdx,4), %ebx
movl 0xc(%r10), %ecx
addl (%r9,%rbp,4), %ecx
cmpl %ecx, %ebx
cmovgl %ebx, %ecx
movq (%r14,%r13,8), %rdx
movl %ecx, %r9d
imull %eax, %r9d
cmpl %r9d, %ecx
cmovgl %ecx, %r9d
movl %r9d, (%rdx,%rbp,4)
incq %rbp
cmpq $0x2, %rbp
movl $0x1, %ecx
cmovlq %rcx, %rbp
movq 0x20(%rsp), %rcx
addq %r13, %rcx
movq %rcx, 0x30(%rsp)
leaq -0x1(%rcx), %r15
movslq 0x20(%rdi), %rdx
cmpq %rdx, %r15
movq %rdx, %rcx
cmovlq %r15, %rcx
cmpq %rcx, %rbp
jg 0x1b785
movq 0x18(%rsp), %rcx
addq %r13, %rcx
movq (%rsp), %rdx
movq -0x8(%rdx,%r13,8), %r9
movq (%rdx,%r13,8), %rbx
decq %rbp
movsbq (%rsi,%rbp), %rdx
movslq 0x10(%r8), %r14
movsbq (%rcx,%r14), %r14
imulq $0x1fc, %rdx, %rdx      # imm = 0x1FC
addq %r11, %rdx
movl (%r9,%rbp,4), %r12d
addl (%rdx,%r14,4), %r12d
movl 0xc(%r10), %edx
addl (%rbx,%rbp,4), %edx
cmpl %edx, %r12d
cmovgl %r12d, %edx
movl %edx, 0x4(%rbx,%rbp,4)
movl 0xc(%r10), %r14d
addl 0x4(%r9,%rbp,4), %r14d
cmpl %r14d, %edx
cmovgl %edx, %r14d
movl %r14d, %edx
imull %eax, %edx
cmpl %edx, %r14d
cmovgl %r14d, %edx
movl %edx, 0x4(%rbx,%rbp,4)
movslq 0x20(%rdi), %rdx
cmpq %rdx, %r15
movq %rdx, %r14
cmovlq %r15, %r14
incq %rbp
cmpq %r14, %rbp
jl 0x1b71c
movq 0x30(%rsp), %r14
cmpq %rdx, %r14
jg 0x1b7e9
movq 0x10(%rsp), %rcx
movsbq (%rcx,%r14), %rcx
movslq 0x10(%r8), %rdx
movq 0x8(%rsp), %r9
addq %r13, %r9
movsbq -0x1(%rdx,%r9), %rdx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq %r11, %rcx
movq (%rsp), %rbx
movq -0x8(%rbx,%r13,8), %r9
movq (%rbx,%r13,8), %rbx
movl -0x4(%r9,%r14,4), %r9d
addl (%rcx,%rdx,4), %r9d
movl 0xc(%r10), %ecx
addl -0x4(%rbx,%r14,4), %ecx
cmpl %ecx, %r9d
cmovgl %r9d, %ecx
movl %ecx, %edx
imull %eax, %edx
cmpl %edx, %ecx
cmovgl %ecx, %edx
movl %edx, (%rbx,%r14,4)
leaq 0x1(%r13), %rcx
movslq 0x24(%rdi), %rdx
cmpq %rdx, %r13
movq %rcx, %r13
jl 0x1b668
jmp 0x1b807
movq %r8, %rcx
callq 0x1b818
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq