// File: /workspace/github_cpp_makefile_star2_O3/readmapping[P]alfalfa/src/mapper.cpp
// Function: leftExtension(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&, int&, long&, long, align_opt const&, int&, int, int)
inline void leftExtension(const string& S, const string& P, int & tmpQB, long & tmpRB, 
        long chrStart, const align_opt & alnOptions, int & curScore, int bandSize, int editDist){
    if(tmpQB>0 && tmpRB > chrStart){
        int zdrop = 100;
        if(alnOptions.print >= 7) cerr << "dp required before first seed" << endl;
        int qle, tle, gtle, gscore, max_off;
        uint8_t *target;
        long alignmentBoundLeft = max(tmpRB-tmpQB-(editDist),chrStart);
        int tLen = tmpRB-alignmentBoundLeft;
        target = (uint8_t *)malloc(tLen);
        for (int j = 0; j < tLen; ++j) // convert to the nt4 encoding
            target[j] = Utils::ORDVALUE[(size_t)S[tmpRB-j-1]];
        uint8_t *query;
        query = (uint8_t *)malloc(tmpQB);
        for (int j = 0; j < tmpQB; ++j)
            query[j] = Utils::ORDVALUE[(size_t)P[tmpQB-j-1]];
        if(alnOptions.print >= 7) cerr << "dp called with dimension " << (tmpQB) << "x" << (tLen) << " and band " << min(bandSize,tmpQB) << endl;
        if(alnOptions.print >= 2) cerr << "#DP " << (min(bandSize,tmpQB)*tLen) << endl;
        curScore = ksw_extend(tmpQB, query, tLen, target, 5, alnOptions.mat, 
            -1*alnOptions.openGap, -1*alnOptions.extendGap, 
            min(bandSize,tmpQB), zdrop, curScore, &qle, &tle, &gtle, &gscore, &max_off);
        if(alnOptions.print >= 7) cerr << "curScore is " << curScore << endl;
        if(alnOptions.global || gscore >= curScore + (alnOptions.mismatch-alnOptions.match)*3){
            curScore = gscore;
            tmpQB = 0;
            tmpRB = tmpRB-gtle;
            if(alnOptions.print >= 7) cerr << "global score is " << gscore << " with refbegin " << tmpRB << endl;
        }
        else{
            tmpQB = tmpQB-qle;
            tmpRB = tmpRB-tle;
            if(alnOptions.print >= 7) cerr << "local begin pos is " << tmpQB << " with refBegin " << tmpRB << endl;
        }
        free(query);
        free(target);
    }
    else if(tmpQB>0 && tmpRB == chrStart && alnOptions.global){
        if(alnOptions.print >= 7) cerr << "begin of refseq: " << tmpQB << " insert" << endl;
        curScore += alnOptions.openGap + alnOptions.extendGap*tmpQB;
    }
}

// Assembly:
movl (%rdx), %eax
testl %eax, %eax
jle 0x2bf56
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r14
movq %r8, %rbx
movq %rdx, %r15
movq 0x80(%rsp), %r12
movq (%rcx), %rbp
cmpq %r8, %rbp
jle 0x2be0e
movq %rdi, %r13
movq %rsi, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
movq %r15, 0x8(%rsp)
movl 0x90(%rsp), %r12d
cmpl $0x7, 0x78(%r14)
jl 0x2bb16
movq 0x2851c(%rip), %r15     # 0x53fe8
leaq 0x19c6e(%rip), %rsi     # 0x45741
movl $0x1d, %edx
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
movq 0x30(%rsp), %rax
movq (%rax), %rbp
movq 0x8(%rsp), %rax
movl (%rax), %eax
movslq %eax, %r15
movslq %r12d, %rax
addq %r15, %rax
movq %rbp, %rcx
subq %rax, %rcx
cmpq %rbx, %rcx
cmovleq %rbx, %rcx
movq %rbp, %r12
subq %rcx, %r12
movslq %r12d, %rbx
movq %rbx, %rdi
callq 0x7430
movq %rax, 0x18(%rsp)
testl %ebx, %ebx
jle 0x2bb80
movq (%r13), %rcx
movl %r12d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rbp, %rcx
decq %rcx
negq %rax
xorl %edx, %edx
leaq 0x1909c(%rip), %rsi     # 0x44c00
movq 0x18(%rsp), %rdi
movsbq (%rcx,%rdx), %r8
movb (%r8,%rsi), %r8b
movb %r8b, (%rdi)
incq %rdi
decq %rdx
cmpq %rdx, %rax
jne 0x2bb69
movq %r15, %rdi
callq 0x7430
movq %rax, %r13
testl %r15d, %r15d
jle 0x2bbbf
movq 0x38(%rsp), %rax
movq (%rax), %rax
addq %r15, %rax
decq %rax
xorl %ecx, %ecx
leaq 0x19059(%rip), %rdx     # 0x44c00
movsbq (%rax), %rsi
movb (%rsi,%rdx), %sil
movb %sil, (%r13,%rcx)
incq %rcx
decq %rax
cmpq %rcx, %r15
jne 0x2bba7
movl 0x88(%rsp), %r15d
movl 0x78(%r14), %eax
cmpl $0x6, %eax
jle 0x2bc78
movq 0x2840d(%rip), %rbx     # 0x53fe8
leaq 0x19176(%rip), %rsi     # 0x44d58
movl $0x19, %edx
movq %rbx, %rdi
callq 0x7340
movq 0x8(%rsp), %rbp
movl (%rbp), %esi
movq %rbx, %rdi
callq 0x75d0
movq %rax, %rbx
leaq 0x15232(%rip), %rsi     # 0x40e3b
movl $0x1, %edx
movq %rax, %rdi
callq 0x7340
movq %rbx, %rdi
movl %r12d, %esi
callq 0x75d0
movq %rax, %rbx
leaq 0x19147(%rip), %rsi     # 0x44d72
movl $0xa, %edx
movq %rax, %rdi
callq 0x7340
movl (%rbp), %esi
cmpl %r15d, %esi
cmovgel %r15d, %esi
movq %rbx, %rdi
callq 0x75d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movl 0x78(%r14), %eax
cmpl $0x2, %eax
jl 0x2bcdc
movq 0x28364(%rip), %rbx     # 0x53fe8
leaq 0x193bc(%rip), %rsi     # 0x45047
movl $0x4, %edx
movq %rbx, %rdi
callq 0x7340
movq 0x8(%rsp), %rax
movl (%rax), %esi
cmpl %r15d, %esi
cmovgel %r15d, %esi
imull %r12d, %esi
movq %rbx, %rdi
callq 0x75d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq 0x8(%rsp), %rax
movl (%rax), %edi
leaq 0x10(%r14), %r9
xorl %r10d, %r10d
xorl %eax, %eax
subl 0x8(%r14), %eax
subl 0xc(%r14), %r10d
cmpl %r15d, %edi
cmovll %edi, %r15d
movq 0x80(%rsp), %rbp
movl (%rbp), %r11d
leaq 0x44(%rsp), %rbx
movq %r12, %rdx
leaq 0x14(%rsp), %r12
movq %r13, %rsi
movq 0x18(%rsp), %rcx
movl $0x5, %r8d
pushq %rbx
pushq %r12
leaq 0x34(%rsp), %rbx
pushq %rbx
leaq 0x40(%rsp), %rbx
pushq %rbx
leaq 0x4c(%rsp), %rbx
pushq %rbx
pushq %r11
pushq $0x64
pushq %r15
pushq %r10
pushq %rax
callq 0x7b59
addq $0x50, %rsp
movl %eax, (%rbp)
cmpl $0x7, 0x78(%r14)
jl 0x2bda3
movq 0x2828e(%rip), %rbx     # 0x53fe8
leaq 0x192eb(%rip), %rsi     # 0x4504c
movl $0xc, %edx
movq %rbx, %rdi
callq 0x7340
movl (%rbp), %esi
movq %rbx, %rdi
callq 0x75d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movl 0x14(%rsp), %eax
cmpb $0x0, 0x2a(%r14)
movq 0x30(%rsp), %r15
jne 0x2be9f
movl 0x4(%r14), %ecx
subl (%r14), %ecx
leal (%rcx,%rcx,2), %ecx
addl (%rbp), %ecx
cmpl %ecx, %eax
jge 0x2be9f
movl 0x2c(%rsp), %eax
movq 0x8(%rsp), %rbx
subl %eax, (%rbx)
movslq 0x28(%rsp), %rax
subq %rax, (%r15)
cmpl $0x7, 0x78(%r14)
jl 0x2bf36
movq 0x281f7(%rip), %rdi     # 0x53fe8
leaq 0x19988(%rip), %rsi     # 0x45780
movl $0x13, %edx
callq 0x7340
leaq 0x1998b(%rip), %r14     # 0x45794
jmp 0x2bee0
jne 0x2bf48
cmpb $0x1, 0x2a(%r14)
jne 0x2bf48
cmpl $0x7, 0x78(%r14)
jl 0x2be8d
movq 0x281bb(%rip), %rbx     # 0x53fe8
leaq 0x19970(%rip), %rsi     # 0x457a4
movl $0x11, %edx
movq %rbx, %rdi
callq 0x7340
movl (%r15), %esi
movq %rbx, %rdi
callq 0x75d0
movq %rax, %rbx
leaq 0x19960(%rip), %rsi     # 0x457b6
movl $0x7, %edx
movq %rax, %rdi
callq 0x7340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movl (%r15), %eax
imull 0xc(%r14), %eax
addl 0x8(%r14), %eax
addl %eax, (%r12)
jmp 0x2bf48
movl %eax, (%rbp)
movq 0x8(%rsp), %rax
movl $0x0, (%rax)
movslq 0x24(%rsp), %rax
subq %rax, (%r15)
cmpl $0x7, 0x78(%r14)
jl 0x2bf36
movq 0x28125(%rip), %rdi     # 0x53fe8
leaq 0x19895(%rip), %rsi     # 0x4575f
movl $0x10, %edx
callq 0x7340
leaq 0x19895(%rip), %r14     # 0x45770
leaq 0x14(%rsp), %rbx
movl (%rbx), %esi
movq 0x280ff(%rip), %rdi     # 0x53fe8
callq 0x75d0
movq %rax, %rbx
movl $0xf, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x7340
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x72a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq %r13, %rdi
callq 0x7380
movq 0x18(%rsp), %rdi
callq 0x7380
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq