// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
testl %ecx, %ecx
je 0x162ee
movq %r8, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
cmpb $0x0, 0x4(%r9)
jne 0x1630e
cmpb $0x1, 0x2(%r9)
jne 0x16307
movzbl (%r9), %eax
xorl $0x1, %eax
jmp 0x1630a
movq %r8, %rcx
callq 0x16540
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
movl 0x2c(%rdi), %ecx
movl 0x28(%rdi), %eax
cmpl %eax, %ecx
cmovlel %eax, %ecx
movl 0x30(%rdi), %r8d
cmpl %eax, %r8d
cmovgl %r8d, %eax
movslq %ecx, %rcx
movq %rcx, 0x48(%rsp)
cltq
movq %rax, 0x40(%rsp)
movq 0x38(%rdi), %rax
movq %rax, 0x38(%rsp)
addq $0x10, %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq (%rsi), %rax
leaq -0x1(%rax,%rcx), %rax
movq %rax, 0x28(%rsp)
movq (%rdx), %rax
movq %rax, 0x20(%rsp)
movq (%rdi), %rax
movq %rax, 0x18(%rsp)
pushq $0x1
popq %r13
movq %rdx, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movslq 0x24(%rdi), %rcx
cmpq %rcx, %r13
jg 0x162f6
movq %r13, %rbp
subq 0x48(%rsp), %rbp
jle 0x163ff
movq 0x28(%rsp), %rax
movsbq (%rax,%rbp), %rcx
movq 0x10(%rsp), %r14
movslq 0x10(%r14), %rax
movq 0x20(%rsp), %r8
addq %r13, %r8
movsbq -0x1(%rax,%r8), %rax
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq 0x30(%rsp), %rcx
movq 0x18(%rsp), %r10
movq -0x8(%r10,%r13,8), %r8
movl -0x4(%r8,%rbp,4), %r9d
addl (%rcx,%rax,4), %r9d
movq 0x38(%rsp), %rax
movl 0xc(%rax), %ecx
addl (%r8,%rbp,4), %ecx
cmpl %ecx, %r9d
cmovgl %r9d, %ecx
movq (%r10,%r13,8), %rax
movl %ecx, %r9d
imull 0xc(%rsp), %r9d
cmpl %r9d, %ecx
cmovgl %ecx, %r9d
movl %r9d, (%rax,%rbp,4)
incq %rbp
jmp 0x16404
movq 0x10(%rsp), %r14
movq 0x40(%rsp), %rax
leaq (%rax,%r13), %rcx
cmpq $0x2, %rbp
pushq $0x1
popq %rax
cmovlq %rax, %rbp
movq %rcx, 0x60(%rsp)
decq %rcx
movq (%rdi), %rax
movq 0x38(%rdi), %r8
leaq 0x10(%r8), %r9
movq (%r14), %r10
movq (%rsi), %r11
leaq -0x1(%r11,%r10), %r11
movq (%rdx), %r10
leaq (%r10,%r13), %rbx
decq %rbx
movq %r14, %rdx
movl 0xc(%rsp), %esi
movslq 0x20(%rdi), %r14
cmpq %r14, %rcx
movq %r14, %r10
cmovlq %rcx, %r10
cmpq %r10, %rbp
jg 0x164be
movsbq (%r11,%rbp), %r10
movslq 0x10(%rdx), %r14
movsbq (%rbx,%r14), %r14
imulq $0x1fc, %r10, %r10      # imm = 0x1FC
addq %r9, %r10
movq -0x8(%rax,%r13,8), %r15
movl -0x4(%r15,%rbp,4), %r12d
addl (%r10,%r14,4), %r12d
movq (%rax,%r13,8), %r10
movl 0xc(%r8), %r14d
addl -0x4(%r10,%rbp,4), %r14d
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movl %r14d, (%r10,%rbp,4)
movl 0xc(%r8), %r12d
addl (%r15,%rbp,4), %r12d
cmpl %r12d, %r14d
cmovgl %r14d, %r12d
movl %r12d, %r14d
imull %esi, %r14d
cmpl %r14d, %r12d
cmovgl %r12d, %r14d
movl %r14d, (%r10,%rbp,4)
incq %rbp
jmp 0x16447
movq 0x60(%rsp), %r8
cmpq %r14, %r8
jg 0x1652e
movq 0x28(%rsp), %rax
movsbq (%rax,%r8), %rcx
movq 0x10(%rsp), %rax
movslq 0x10(%rax), %rdx
movq 0x20(%rsp), %rax
leaq (%rax,%r13), %rsi
movsbq -0x1(%rdx,%rsi), %rdx
imulq $0x1fc, %rcx, %rcx      # imm = 0x1FC
addq 0x30(%rsp), %rcx
movq 0x18(%rsp), %rax
movq -0x8(%rax,%r13,8), %rsi
movq (%rax,%r13,8), %r9
movl -0x4(%rsi,%r8,4), %esi
addl (%rcx,%rdx,4), %esi
movq 0x38(%rsp), %rax
movl 0xc(%rax), %ecx
addl -0x4(%r9,%r8,4), %ecx
cmpl %ecx, %esi
cmovgl %esi, %ecx
movl %ecx, %edx
imull 0xc(%rsp), %edx
cmpl %edx, %ecx
cmovgl %ecx, %edx
movl %edx, (%r9,%r8,4)
incq %r13
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %rsi
jmp 0x16378