// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r14
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, %r13
movl (%rdx), %eax
testl %eax, %eax
jle 0x2bf25
cmpq %rbp, (%r12)
jle 0x2bf25
movq %rdi, %r15
movq %rsi, 0x30(%rsp)
movl 0x90(%rsp), %ebx
cmpl $0x7, 0x78(%r14)
movq %r13, 0x8(%rsp)
jl 0x2bc2e
movq 0x283fb(%rip), %r13     # 0x53fe8
leaq 0x19b4d(%rip), %rsi     # 0x45741
movl $0x1d, %edx
movq %r13, %rdi
callq 0x7340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x72b0
movsbl %al, %esi
movq %r13, %rdi
movq 0x8(%rsp), %r13
callq 0x7040
movq %rax, %rdi
callq 0x71d0
movq %r12, 0x38(%rsp)
movq (%r12), %r12
movslq (%r13), %r13
movslq %ebx, %rax
addq %r13, %rax
movq %r12, %rcx
subq %rax, %rcx
cmpq %rbp, %rcx
cmovleq %rbp, %rcx
movq %r12, %rbp
subq %rcx, %rbp
movslq %ebp, %rbx
movq %rbx, %rdi
callq 0x7430
movq %rax, 0x28(%rsp)
testl %ebx, %ebx
jle 0x2bca0
movq (%r15), %rcx
movl %ebp, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %r12, %rcx
decq %rcx
negq %rax
xorl %edx, %edx
leaq 0x18f7c(%rip), %rsi     # 0x44c00
movq 0x28(%rsp), %rdi
movsbq (%rcx,%rdx), %r8
movb (%r8,%rsi), %r8b
movb %r8b, (%rdi)
incq %rdi
decq %rdx
cmpq %rdx, %rax
jne 0x2bc89
movq %r13, %rdi
callq 0x7430
movq %rax, 0x10(%rsp)
testl %r13d, %r13d
jle 0x2bcdb
movq 0x30(%rsp), %rax
movq (%rax), %rax
leaq 0x18f3f(%rip), %rcx     # 0x44c00
movq 0x10(%rsp), %rdx
movsbq -0x1(%rax,%r13), %rsi
movb (%rsi,%rcx), %sil
movb %sil, (%rdx)
incq %rdx
decq %r13
jne 0x2bcc6
movl 0x88(%rsp), %r15d
cmpl $0x6, 0x78(%r14)
movq 0x8(%rsp), %r12
jle 0x2bd8f
movq 0x282ee(%rip), %rbx     # 0x53fe8
leaq 0x19057(%rip), %rsi     # 0x44d58
movl $0x19, %edx
movq %rbx, %rdi
callq 0x7340
movl (%r12), %esi
movq %rbx, %rdi
callq 0x75d0
movq %rax, %rbx
leaq 0x15117(%rip), %rsi     # 0x40e3b
movl $0x1, %edx
movq %rax, %rdi
callq 0x7340
movq %rbx, %rdi
movl %ebp, %esi
callq 0x75d0
movq %rax, %rbx
leaq 0x1902d(%rip), %rsi     # 0x44d72
movl $0xa, %edx
movq %rax, %rdi
callq 0x7340
movl (%r12), %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
cmpl $0x2, 0x78(%r14)
jl 0x2bdf1
movq 0x2824b(%rip), %rbx     # 0x53fe8
leaq 0x192a3(%rip), %rsi     # 0x45047
movl $0x4, %edx
movq %rbx, %rdi
callq 0x7340
movl (%r12), %esi
cmpl %r15d, %esi
cmovgel %r15d, %esi
imull %ebp, %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 (%r12), %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), %r12
movl (%r12), %r11d
leaq 0x44(%rsp), %rbx
leaq 0x4(%rsp), %r13
movq 0x10(%rsp), %rsi
movl %ebp, %edx
movq 0x28(%rsp), %rbp
movq %rbp, %rcx
movl $0x5, %r8d
pushq %rbx
pushq %r13
leaq 0x2c(%rsp), %rbx
pushq %rbx
leaq 0x38(%rsp), %rbx
pushq %rbx
leaq 0x44(%rsp), %rbx
pushq %rbx
pushq %r11
pushq $0x64
pushq %r15
pushq %r10
pushq %rax
callq 0x7bbf
addq $0x50, %rsp
movl %eax, (%r12)
cmpl $0x7, 0x78(%r14)
jl 0x2bebb
movq 0x28177(%rip), %rbx     # 0x53fe8
leaq 0x191d4(%rip), %rsi     # 0x4504c
movl $0xc, %edx
movq %rbx, %rdi
callq 0x7340
movl (%r12), %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
cmpb $0x0, 0x2a(%r14)
movq 0x38(%rsp), %r15
jne 0x2bfca
movl 0x4(%r14), %eax
subl (%r14), %eax
leal (%rax,%rax,2), %eax
addl (%r12), %eax
cmpl %eax, 0x4(%rsp)
jge 0x2bfca
movl 0x24(%rsp), %eax
movq 0x8(%rsp), %rbx
subl %eax, (%rbx)
movslq 0x20(%rsp), %rax
subq %rax, (%r15)
cmpl $0x7, 0x78(%r14)
jl 0x2c066
movq 0x280e0(%rip), %rdi     # 0x53fe8
leaq 0x19871(%rip), %rsi     # 0x45780
movl $0x13, %edx
callq 0x7340
leaq 0x19874(%rip), %r14     # 0x45794
jmp 0x2c010
testl %eax, %eax
jle 0x2c078
cmpq %rbp, (%r12)
jne 0x2c078
cmpb $0x1, 0x2a(%r14)
jne 0x2c078
cmpl $0x7, 0x78(%r14)
jl 0x2bfae
movq 0x28098(%rip), %rbx     # 0x53fe8
leaq 0x1984d(%rip), %rsi     # 0x457a4
movl $0x11, %edx
movq %rbx, %rdi
callq 0x7340
movl (%r13), %esi
movq %rbx, %rdi
callq 0x75d0
movq %rax, %rbx
leaq 0x1983c(%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 (%r13), %eax
imull 0xc(%r14), %eax
addl 0x8(%r14), %eax
movq 0x80(%rsp), %rcx
addl %eax, (%rcx)
jmp 0x2c078
movl 0x4(%rsp), %eax
movl %eax, (%r12)
movq 0x8(%rsp), %rax
movl $0x0, (%rax)
movslq 0x1c(%rsp), %rax
subq %rax, (%r15)
cmpl $0x7, 0x78(%r14)
jl 0x2c066
movq 0x27ff5(%rip), %rdi     # 0x53fe8
leaq 0x19765(%rip), %rsi     # 0x4575f
movl $0x10, %edx
callq 0x7340
leaq 0x19765(%rip), %r14     # 0x45770
leaq 0x4(%rsp), %rbx
movl (%rbx), %esi
movq 0x27fcf(%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 0x10(%rsp), %rdi
callq 0x7380
movq %rbp, %rdi
callq 0x7380
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq