// File: 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:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
movq 0x90(%rsp), %rsi
movq %rsi, 0x20(%rsp)
movq (%rsi), %rax
movq 0x88(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x80(%rsp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x74(%rsp)
movl $0x0, 0x70(%rsp)
movq %rsi, %rdi
addq $0x2c, %rdi
addq $0x28, %rsi
callq 0x14d40
movq 0x20(%rsp), %rsi
movl (%rax), %eax
movl %eax, 0x6c(%rsp)
movq %rsi, %rdi
addq $0x30, %rdi
addq $0x28, %rsi
callq 0x14d40
movl (%rax), %eax
movl %eax, 0x68(%rsp)
movq 0x78(%rsp), %rax
testb $0x1, 0x3(%rax)
je 0x31d44
movq 0x78(%rsp), %rax
testb $0x1, 0x1(%rax)
jne 0x31d68
movq 0x78(%rsp), %rax
testb $0x1, 0x2(%rax)
je 0x31d59
movq 0x78(%rsp), %rax
testb $0x1, (%rax)
jne 0x31d68
movq 0x78(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x31f1c
movq 0x20(%rsp), %rax
testb $0x1, 0x34(%rax)
jne 0x31e1f
movq 0x20(%rsp), %rax
movl 0x24(%rax), %eax
movl %eax, 0x64(%rsp)
cmpl $0x0, 0x64(%rsp)
jl 0x31e1a
movq 0x20(%rsp), %rax
movl 0x20(%rax), %eax
movl %eax, 0x60(%rsp)
cmpl $0x0, 0x60(%rsp)
jl 0x31e08
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq 0x64(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x60(%rsp), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x74(%rsp), %eax
jle 0x31df9
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq 0x64(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x60(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x74(%rsp)
movl 0x64(%rsp), %ecx
movq 0x88(%rsp), %rax
movl %ecx, (%rax)
movl 0x60(%rsp), %ecx
movq 0x80(%rsp), %rax
movl %ecx, (%rax)
jmp 0x31dfb
movl 0x60(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x31d9a
jmp 0x31e0a
movl 0x64(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x31d83
jmp 0x31f17
movq 0x20(%rsp), %rax
movl 0x24(%rax), %eax
movl %eax, 0x5c(%rsp)
cmpl $0x0, 0x5c(%rsp)
jl 0x31f15
movq 0x20(%rsp), %rsi
movl 0x70(%rsp), %eax
addl 0x5c(%rsp), %eax
addl 0x68(%rsp), %eax
movl %eax, 0x54(%rsp)
addq $0x20, %rsi
leaq 0x54(%rsp), %rdi
callq 0xc080
movl (%rax), %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl $0x0, 0x50(%rsp)
movl 0x70(%rsp), %eax
addl 0x5c(%rsp), %eax
subl 0x6c(%rsp), %eax
movl %eax, 0x4c(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x4c(%rsp), %rsi
callq 0x14d40
movq %rax, %rcx
movl 0x1c(%rsp), %eax
cmpl (%rcx), %eax
jl 0x31f03
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x58(%rsp), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x74(%rsp), %eax
jle 0x31ef1
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq 0x5c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x58(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x74(%rsp)
movl 0x5c(%rsp), %ecx
movq 0x88(%rsp), %rax
movl %ecx, (%rax)
movl 0x58(%rsp), %ecx
movq 0x80(%rsp), %rax
movl %ecx, (%rax)
jmp 0x31ef3
movl 0x58(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x31e5f
jmp 0x31f05
movl 0x5c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x31e2b
jmp 0x31f17
jmp 0x3212c
movq 0x78(%rsp), %rax
testb $0x1, 0x3(%rax)
jne 0x31f36
movq 0x78(%rsp), %rax
testb $0x1, 0x2(%rax)
je 0x32025
movq 0x20(%rsp), %rcx
movq %rcx, %rdi
addq $0x24, %rdi
movl 0x70(%rsp), %eax
addl 0x20(%rcx), %eax
addl 0x68(%rsp), %eax
movl %eax, 0x44(%rsp)
leaq 0x44(%rsp), %rsi
callq 0xc080
movl (%rax), %eax
movl %eax, 0x48(%rsp)
movq 0x20(%rsp), %rcx
movl 0x48(%rsp), %eax
movl %eax, 0x18(%rsp)
movq %rcx, %rax
addq $0x24, %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0x40(%rsp)
movl 0x70(%rsp), %eax
addl 0x20(%rcx), %eax
subl 0x6c(%rsp), %eax
movl %eax, 0x3c(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
callq 0x14d40
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0xc080
movq %rax, %rcx
movl 0x18(%rsp), %eax
cmpl (%rcx), %eax
jl 0x32020
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq 0x48(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x80(%rsp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x74(%rsp), %eax
jle 0x3200e
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq 0x48(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x80(%rsp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x74(%rsp)
movl 0x48(%rsp), %ecx
movq 0x88(%rsp), %rax
movl %ecx, (%rax)
jmp 0x32010
movl 0x48(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x31f61
jmp 0x3212a
movq 0x78(%rsp), %rax
testb $0x1, 0x1(%rax)
jne 0x3203e
movq 0x78(%rsp), %rax
testb $0x1, (%rax)
je 0x32128
movq 0x20(%rsp), %rcx
movq %rcx, %rdi
addq $0x20, %rdi
movl 0x70(%rsp), %eax
addl 0x24(%rcx), %eax
addl 0x68(%rsp), %eax
movl %eax, 0x34(%rsp)
leaq 0x34(%rsp), %rsi
callq 0xc080
movl (%rax), %eax
movl %eax, 0x38(%rsp)
movq 0x20(%rsp), %rcx
movl 0x38(%rsp), %eax
movl %eax, 0xc(%rsp)
movq %rcx, %rax
addq $0x20, %rax
movq %rax, (%rsp)
movl $0x0, 0x30(%rsp)
movl 0x70(%rsp), %eax
addl 0x24(%rcx), %eax
subl 0x6c(%rsp), %eax
movl %eax, 0x2c(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
callq 0x14d40
movq (%rsp), %rdi
movq %rax, %rsi
callq 0xc080
movq %rax, %rcx
movl 0xc(%rsp), %eax
cmpl (%rcx), %eax
jl 0x32126
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x88(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x38(%rsp), %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x74(%rsp), %eax
jle 0x32114
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x88(%rsp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x38(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x74(%rsp)
movl 0x38(%rsp), %ecx
movq 0x80(%rsp), %rax
movl %ecx, (%rax)
jmp 0x32116
movl 0x38(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x32069
jmp 0x32128
jmp 0x3212a
jmp 0x3212c
xorl %eax, %eax
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)