// File: /workspace/github_cpp_makefile_star2_O2/readmapping[P]alfalfa/src/dp.cpp
// Function: dynProg::findTraceBackPosStatic(int*, int*, dp_type const&)
int dynProg::findTraceBackPosStatic(int* const i, int* const j,const dp_type& type){
    //find beginPosition for traceBack and find dpScore
    int maximum = M[*i][*j];
    int bandCorrection = 0;
    int bandL = max(bandLeft, bandSize);
    int bandR = max(bandRight, bandSize);
    if((type.freeQueryE && type.freeRefE) || (type.freeQueryB && type.freeRefB) || type.local){//local
        if(!banded){
            for(int idx = L2; idx >= 0; idx--){
                for(int idx2 = L1; idx2 >= 0; idx2--){
                    if(M[idx][idx2] > maximum){
                        maximum = M[idx][idx2];
                        *i = idx;
                        *j = idx2;
                    }
                }
            }
        }
        else{
            for(int idx = L2; idx >= 0; idx--){
                for(int idx2 = min(bandCorrection+idx+bandR,L1); idx2 >= max(0,bandCorrection+idx-bandL); idx2--){
                    if(M[idx][idx2] > maximum){
                        maximum = M[idx][idx2];
                        *i = idx;
                        *j = idx2;
                    }
                }
            }
        }
    }
    else if(type.freeQueryE || type.freeQueryB){//banded update
        for(int idx = min(L2, bandCorrection + L1 + bandR); 
                idx >= min(L2, max(0, bandCorrection + L1 - bandL)); 
                idx--){
            if(M[idx][*j] > maximum){
                maximum = M[idx][*j];
                *i = idx;
            }
        }
    }
    else if(type.freeRefE || type.freeRefB){
        for(int idx = min(L1, bandCorrection + L2 + bandR); 
                idx >= min(L1, max(0, bandCorrection + L2 - bandL)); 
                idx--){
            if(M[*i][idx] > maximum){
                maximum = M[*i][idx];
                *j = idx;
            }
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq (%rdi), %rax
movslq (%rsi), %r8
movq (%rax,%r8,8), %r8
movslq (%rdx), %r9
movl (%r8,%r9,4), %r8d
movl 0x2c(%rdi), %r9d
movl 0x28(%rdi), %r10d
cmpl %r10d, %r9d
cmovlel %r10d, %r9d
movl 0x30(%rdi), %r11d
cmpl %r10d, %r11d
cmovgl %r11d, %r10d
movb 0x3(%rcx), %r11b
cmpb $0x1, %r11b
jne 0x15a89
cmpb $0x0, 0x1(%rcx)
jne 0x15aa0
movb 0x2(%rcx), %bl
cmpb $0x1, %bl
jne 0x15a96
cmpb $0x0, (%rcx)
jne 0x15aa0
cmpb $0x1, 0x4(%rcx)
jne 0x15b26
movl 0x24(%rdi), %ecx
cmpb $0x0, 0x34(%rdi)
je 0x15af1
xorl %r11d, %r11d
testl %ecx, %ecx
js 0x15bdb
leal (%rcx,%r10), %ebx
movl 0x20(%rdi), %ebp
cmpl %ebx, %ebp
cmovll %ebp, %ebx
movl %ecx, %ebp
subl %r9d, %ebp
testl %ebp, %ebp
cmovlel %r11d, %ebp
movl %ecx, %r14d
cmpl %ebp, %ebx
jl 0x15aed
movq (%rax,%r14,8), %r15
movl %ebx, %r12d
movl (%r15,%r12,4), %r15d
cmpl %r8d, %r15d
jle 0x15ae9
movl %ecx, (%rsi)
movl %ebx, (%rdx)
movl %r15d, %r8d
decl %ebx
jmp 0x15ace
decl %ecx
jmp 0x15aac
testl %ecx, %ecx
js 0x15bdb
movl 0x20(%rdi), %r9d
movl %ecx, %r10d
testl %r9d, %r9d
js 0x15b22
movq (%rax,%r10,8), %r11
movl %r9d, %ebx
movl (%r11,%rbx,4), %r11d
cmpl %r8d, %r11d
jle 0x15b1d
movl %ecx, (%rsi)
movl %r9d, (%rdx)
movl %r11d, %r8d
decl %r9d
jmp 0x15b00
decl %ecx
jmp 0x15af1
orb %bl, %r11b
cmpb $0x1, %r11b
jne 0x15b80
movl 0x20(%rdi), %ecx
movl 0x24(%rdi), %r11d
addl %ecx, %r10d
cmpl %r10d, %r11d
cmovll %r11d, %r10d
movslq %r10d, %r10
xorl %ebx, %ebx
movl %ecx, %ebp
subl %r9d, %ebp
testl %ebp, %ebp
cmovlel %ebx, %ebp
cmpl %r11d, %ebp
cmovgel %r11d, %ebp
movslq %ebp, %r14
cmpq %r14, %r10
jl 0x15bdb
movq (%rax,%r10,8), %r14
movslq (%rdx), %r15
movl (%r14,%r15,4), %ebp
cmpl %r8d, %ebp
jle 0x15b7b
movl %r10d, (%rsi)
movl 0x20(%rdi), %ecx
movl 0x24(%rdi), %r11d
movl %ebp, %r8d
decq %r10
jmp 0x15b45
cmpb $0x0, 0x1(%rcx)
jne 0x15b8b
cmpb $0x1, (%rcx)
jne 0x15bdb
movl 0x20(%rdi), %ecx
movl 0x24(%rdi), %r11d
addl %r11d, %r10d
cmpl %r10d, %ecx
cmovll %ecx, %r10d
movslq %r10d, %r10
xorl %ebx, %ebx
movl %r11d, %ebp
subl %r9d, %ebp
testl %ebp, %ebp
cmovlel %ebx, %ebp
cmpl %ecx, %ebp
cmovgel %ecx, %ebp
movslq %ebp, %r14
cmpq %r14, %r10
jl 0x15bdb
movslq (%rsi), %r14
movq (%rax,%r14,8), %r14
movl (%r14,%r10,4), %ebp
cmpl %r8d, %ebp
jle 0x15bd6
movl %r10d, (%rdx)
movl 0x20(%rdi), %ecx
movl 0x24(%rdi), %r11d
movl %ebp, %r8d
decq %r10
jmp 0x15ba1
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq