// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/dp.cpp
// Function: dynProg::updateMatrix(dp_type const&, bool, bool)
int dynProg::updateMatrix(const dp_type& type, bool backward, bool print){
    //TODO: change this to mallocs and initialize once per thread + realloc if nec.
    assert(L1 >=0 && L2 >= 0);
    int newDimL2 = DP_L2;
    while(L2 >= newDimL2){
        newDimL2 = 2*newDimL2;
    }
    int newDimL1 = DP_L1;
    while(L1 >= newDimL1){
        newDimL1 = 2*newDimL1;
    }
    if(newDimL2 > DP_L2 || newDimL1 > DP_L1){
        if(print) cerr << "resize DP matrix from " << DP_L2 << "x" << DP_L1 << " to " << newDimL2 << "x" << newDimL1 << endl;
        resizeDPMatrix(newDimL2, newDimL1, scores.openGap != 0);
        if(print) cerr << "resize succesful" << endl;
    }
    M[0][0] = 0;
    for(int i = 1; i <= L2; i++)
        M[i][0] = (type.freeQueryB && !backward) ? 0 : scores.openGap + i*scores.extendGap;
    for(int i = 1; i <= L1; i++)
        M[0][i] = (type.freeRefB && !backward) ? 0 : scores.openGap + i*scores.extendGap;
    if(scores.openGap != 0){//affine gap penalties
        UP[0][0] = LEFT[0][0] = 0;
        for(int i = 1; i <= L1; i++){
            UP[0][i] = M[0][i] + scores.openGap;
            LEFT[0][i] = M[0][i] + scores.openGap;
        }
        for(int i = 1; i <= L2; i++){
            UP[i][0] = M[i][0] + scores.openGap;
            LEFT[i][0] = M[i][0] + scores.openGap;
        }
    }
    return 0;//return is not really used, maybe for future use
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x18(%rdi), %eax
movl 0x24(%rdi), %edx
movl %eax, %esi
movl %esi, %r15d
leal (%r15,%r15), %esi
cmpl %r15d, %edx
jge 0x1a7a9
movl 0x1c(%rbx), %edx
movl 0x20(%rbx), %esi
movl %edx, %edi
movl %edi, %r12d
leal (%r12,%r12), %edi
cmpl %r12d, %esi
jge 0x1a7bd
cmpl %eax, %r15d
setg %al
cmpl %edx, %r12d
setg %dl
orb %al, %dl
cmpb $0x1, %dl
jne 0x1a938
testb %cl, %cl
je 0x1a90d
movq 0x397f9(%rip), %r13     # 0x53fe8
leaq 0x2a0aa(%rip), %rsi     # 0x448a0
movl $0x16, %edx
movq %r13, %rdi
callq 0x7340
movl 0x18(%rbx), %esi
movq %r13, %rdi
callq 0x75d0
movq %rax, %r13
leaq 0x26623(%rip), %rsi     # 0x40e3b
movl $0x1, %edx
movq %rax, %rdi
callq 0x7340
movl 0x1c(%rbx), %esi
movq %r13, %rdi
callq 0x75d0
movq %rax, %r13
leaq 0x2a143(%rip), %rsi     # 0x4497d
movl $0x4, %edx
movq %rax, %rdi
callq 0x7340
movq %r13, %rdi
movl %r15d, %esi
callq 0x75d0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x265d7(%rip), %rsi     # 0x40e3b
callq 0x7340
movq %r13, %rdi
movl %r12d, %esi
callq 0x75d0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x38(%rbx), %rax
xorl %r13d, %r13d
cmpl $0x0, 0x8(%rax)
setne %r13b
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1a6ba
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
movl %r13d, %ecx
callq 0x1a5b6
leaq 0x29fe7(%rip), %rsi     # 0x448b7
movl $0x10, %edx
movq 0x3970c(%rip), %r15     # 0x53fe8
movq %r15, %rdi
callq 0x7340
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
jmp 0x1a938
movq 0x38(%rbx), %rax
xorl %r13d, %r13d
cmpl $0x0, 0x8(%rax)
setne %r13b
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1a6ba
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
movl %r13d, %ecx
callq 0x1a5b6
movq (%rbx), %rax
movq (%rax), %rcx
movl $0x0, (%rcx)
cmpl $0x0, 0x24(%rbx)
jle 0x1a987
movb 0x2(%r14), %dl
xorb $0x1, %dl
orb %bpl, %dl
movq 0x38(%rbx), %rsi
movl $0x1, %edi
xorl %r8d, %r8d
testb %dl, %dl
je 0x1a970
movl 0xc(%rsi), %r8d
imull %edi, %r8d
addl 0x8(%rsi), %r8d
movq (%rax,%rdi,8), %r9
movl %r8d, (%r9)
leaq 0x1(%rdi), %r8
movslq 0x24(%rbx), %r9
cmpq %r9, %rdi
movq %r8, %rdi
jl 0x1a95d
cmpl $0x0, 0x20(%rbx)
jle 0x1a9ca
movb (%r14), %sil
xorb $0x1, %sil
orb %bpl, %sil
movq 0x38(%rbx), %rdx
movl $0x1, %edi
xorl %r8d, %r8d
testb %sil, %sil
je 0x1a9b4
movl 0xc(%rdx), %r8d
imull %edi, %r8d
addl 0x8(%rdx), %r8d
movl %r8d, (%rcx,%rdi,4)
leaq 0x1(%rdi), %r8
movslq 0x20(%rbx), %r9
cmpq %r9, %rdi
movq %r8, %rdi
jl 0x1a9a0
jmp 0x1a9ce
movq 0x38(%rbx), %rdx
cmpl $0x0, 0x8(%rdx)
je 0x1aa53
movq 0x10(%rbx), %rsi
movq (%rsi), %r8
xorl %r10d, %r10d
movl %r10d, (%r8)
movq 0x8(%rbx), %rdi
movq (%rdi), %r9
movl %r10d, (%r9)
cmpl %r10d, 0x20(%rbx)
jle 0x1aa1c
xorl %r10d, %r10d
movl 0x8(%rdx), %r11d
addl 0x4(%rcx,%r10,4), %r11d
movl %r11d, 0x4(%r9,%r10,4)
movl 0x8(%rdx), %r11d
addl 0x4(%rcx,%r10,4), %r11d
movl %r11d, 0x4(%r8,%r10,4)
movslq 0x20(%rbx), %r11
incq %r10
cmpq %r11, %r10
jl 0x1a9f4
cmpl $0x0, 0x24(%rbx)
jle 0x1aa53
xorl %ecx, %ecx
movq 0x8(%rax,%rcx,8), %r8
movl 0x8(%rdx), %r9d
addl (%r8), %r9d
movq 0x8(%rdi,%rcx,8), %r10
movl %r9d, (%r10)
movl 0x8(%rdx), %r9d
addl (%r8), %r9d
movq 0x8(%rsi,%rcx,8), %r8
movl %r9d, (%r8)
movslq 0x24(%rbx), %r8
incq %rcx
cmpq %r8, %rcx
jl 0x1aa24
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq