// File: /workspace/github_cpp_makefile_star2_O2/readmapping[P]alfalfa/src/mapper.cpp
// Function: extendAlignmentChain(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&, std::vector<match_t, std::allocator<match_t>> const&, int, int, int, align_opt const&, long, long, read_t&, bool)
int extendAlignmentChain(const string& S, const string& P, 
        const vector<match_t>& matches, int editDist, int minScore, int minCoverage, 
        const align_opt & alnOptions, long chrStart, long chrEnd, read_t & read, bool fw){
    int maxAlnScore = min(-1, minScore-10);
    if(alnOptions.print >= 5){
        cerr << "min Score is " << minScore << endl;
        cerr << "seeds are: " << endl;
        for(size_t i = 0; i < matches.size(); i++)
            cerr << matches[i].query << "," << matches[i].ref << "," << matches[i].len << endl;
    }
    list<size_t> chain;
    //seeds in order of 
    vector<long> seedOrder;
    seedOrder.reserve(matches.size());
    vector<bool> used;
    used.assign(matches.size(),false);
    for(size_t i = 0; i < matches.size(); i++)
        seedOrder.push_back((long)matches[i].len<<32 | i);
    sort(seedOrder.begin(), seedOrder.end());
    //for all seeds:
    vector<boundaries> alnBounds;
    vector<int> alnScores;
    vector<long> alnBegins;
    for(int i = seedOrder.size()-1; i >=0; i--){
        size_t anchorPos = (uint32_t)seedOrder[i];
        match_t anchor = matches[anchorPos];
        if(alnOptions.print >= 5) cerr << "anchor " << anchor.query << "," << anchor.ref << "," << anchor.len << endl;
        //check if current anchor is not already in alignment
        bool extend = !used[anchorPos];
        size_t j = 0;
        while(j < alnBounds.size() && extend){
            bool notContained = anchor.query < alnBounds[j].queryB || anchor.query+anchor.len >= alnBounds[j].queryE || anchor.ref < alnBounds[j].refB || anchor.ref+anchor.len >= alnBounds[j].refE;
            if(!notContained){
                int qDist = anchor.query - alnBounds[j].queryB;
                int refDist = anchor.ref - alnBounds[j].refB;
                int max_gapL = min(alnOptions.fixedBandSize, (int)((min(qDist,refDist)*alnOptions.match + alnOptions.openGap)/alnOptions.extendGap + 1.));
                extend = max(qDist,refDist) >= max_gapL;
                if(extend){
                    qDist = alnBounds[j].queryE - (anchor.query+anchor.len);
                    refDist = alnBounds[j].refE - (anchor.ref+anchor.len);
                    max_gapL = min(alnOptions.fixedBandSize, (int)((min(qDist,refDist)*alnOptions.match + alnOptions.openGap)/alnOptions.extendGap + 1.));
                    extend = max(qDist,refDist) >= max_gapL;
                }
            }
            j++;
        }
        if(extend){
            //CREATE CHAIN AROUND THIS ANCHOR
            int curScore = 0;
            int minEdit = nextChain(matches, chain, anchorPos, alnOptions.errorPercent, used, P.length(), curScore);
            int chainScore = curScore;//for debug purpose
            if(alnOptions.print >= 2){
                cerr << "#CHAIN " << chain.size() << endl;
                cerr << "#CHAINSCORE " << curScore << endl;
                cerr << "#CHAINSKEW " << minEdit << endl;
                cerr << "#CHAINMINSCORE " << minCoverage << endl;
                if(alnOptions.print >= 5)
                        cerr << "extend chain of size " << chain.size() << " elements and minEdit,curScore =  " << minEdit << "," << curScore << endl;
            }
            //ITERATE THROUGH CHAIN
            if(minEdit <= editDist && (chain.size() > 1 || anchor.len >= minCoverage )){
                std::list<size_t>::const_iterator iterator = chain.begin(), itEnd = chain.end();
                int bandSize = min(alnOptions.fixedBandSize, (int)(editDist-minEdit+1));
                anchor = matches[*iterator];
                iterator++;
                int tmpQB = anchor.query;
                int tmpQE = anchor.query+anchor.len-1;
                long tmpRB = anchor.ref;
                long tmpRE = anchor.ref + anchor.len-1L;
                if(alnOptions.print >= 7) cerr << "first seed (q/r/l): " << tmpQB << "," << tmpRB << "," << anchor.len << endl;
                //INSIDE CHAIN
                while(iterator != itEnd){
                    match_t seed = matches[*iterator];
                    if(alnOptions.print >= 6) cerr << "current seed (q/r/l): " << seed.query << "," << seed.ref << "," << seed.len << endl;
                    long qDist = seed.query - tmpQE;
                    long refDist = seed.ref - tmpRE;
                    if (qDist < 0 || refDist < 0) {
                        if (qDist >= refDist)
                            qDist -= refDist; //qDist insertions
                        else
                            refDist -= qDist;
                    }
                    if (qDist <= 0) {//minRefDist deletions
                        //1+|qDist| matches lost of next mem
                        curScore += alnOptions.openGap + alnOptions.extendGap*refDist;
                        if(alnOptions.print >= 7) cerr << "added deletion of size " << refDist << endl;
                    } else if (refDist <= 0) {
                        curScore += alnOptions.openGap + alnOptions.extendGap*qDist;
                        if(alnOptions.print >= 7) cerr << "added insertion of size " << qDist << endl;
                    } else if (qDist == 1) {
                        curScore += alnOptions.openGap + alnOptions.extendGap*(refDist-1);
                        if(alnOptions.print >= 7) cerr << "added deletion of size " << refDist-1 << endl;
                    } else if (refDist == 1) {
                        curScore += alnOptions.openGap + alnOptions.extendGap*(qDist-1);
                        if(alnOptions.print >= 7) cerr << "added insertion of size " << qDist-1 << endl;
                    } else if (refDist == 2 && qDist==2) {
                        curScore += alnOptions.mismatch;
                        if(alnOptions.print >= 7) cerr << "added mutation" << endl;
                    } else {//both distances are positive and not equal to (1,1), otherwise seeds would not be maximal!
                        uint8_t *target;
                        int tLen = seed.ref - tmpRE - 1;
                        target = (uint8_t *)malloc(tLen);
                        for (int j = 0; j < tLen; ++j) // convert to the nt4 encoding
                            target[j] = Utils::ORDVALUE[(size_t)S[tmpRE+1+j]];
                        uint8_t *query;
                        int qLen = seed.query - tmpQE - 1;
                        query = (uint8_t *)malloc(qLen);
                        for (int j = 0; j < qLen; ++j)
                            query[j] = Utils::ORDVALUE[(size_t)P[tmpQE+1+j]];
                        int innerBand = min(alnOptions.fixedBandSize, (int)(editDist-minEdit+abs(qLen-tLen)+3));
                        innerBand = max(innerBand,abs(qLen-tLen)+(int)(abs(qLen-tLen)*alnOptions.errorPercent));
                        if(alnOptions.print >= 2) cerr << "#DP " << (tLen*innerBand) << endl;
                        if(alnOptions.print >= 7) cerr << "dp called with dimension " << (seed.query-tmpQE+1) << "x" << (seed.ref-tmpRE+1) << " and band " << innerBand << endl;
                        curScore += ksw_nw(qLen, query, tLen, target, 5, alnOptions.mat, 
                                -1*alnOptions.openGap, -1*alnOptions.extendGap, innerBand);
                        free(query);
                        free(target);
                    }
                    if(alnOptions.print >= 6) cerr << "curScore is " << curScore << endl;
                    //update bounds
                    tmpRE = seed.ref + seed.len - 1L;
                    tmpQE = seed.query + seed.len - 1;            
                    ++iterator;
                }
                //lef-right extensions
                if(tmpQB <= (int)(P.length()-1)-tmpQE){
                    leftExtension(S, P, tmpQB, tmpRB, chrStart, alnOptions, curScore, bandSize, editDist-minEdit+1);
                    rightExtension(S, P, tmpQE, tmpRE, chrEnd, alnOptions, curScore, bandSize, editDist);
                }
                else{
                    rightExtension(S, P, tmpQE, tmpRE, chrEnd, alnOptions, curScore, bandSize, editDist);
                    leftExtension(S, P, tmpQB, tmpRB, chrStart, alnOptions, curScore, bandSize, editDist-minEdit+1);
                }
                if(alnOptions.print >= 5) cerr << "current alignments startpos would be " << tmpRB << endl;
                maxAlnScore = max(maxAlnScore, curScore);
                if(curScore >= minScore){
                    if(alnOptions.print >= 2) cerr << "#SUCCES " << curScore << endl;
                    bool equal = false;
                    for(size_t i = 0; i < alnScores.size(); i++){
                        if(alnScores[i]>= curScore && abs(alnBegins[i]-tmpRB) < editDist)
                            equal = true;
                    }
                    if(!equal){
                        alignment_t * alignmentFound = new alignment_t();
                        alignmentFound->refB = tmpRB;
                        alignmentFound->refE = tmpRE;
                        alignmentFound->qB = tmpQB;
                        alignmentFound->qE = tmpQE;
                        alignmentFound->alignmentScore = curScore;
                        if(!fw){
                            alignmentFound->flag.set(4,true);
                        }
                        alignmentFound->refLength = (tmpRE-tmpRB+1);
                        for(std::list<size_t>::const_iterator iterator = chain.begin(); iterator != chain.end(); iterator++){
                            match_t seed = matches[*iterator];
                            alignmentFound->chain.push_back(seed);
                        }
                        read.alignments.push_back(alignmentFound);
                        alnScores.push_back(curScore);
                        alnBegins.push_back(tmpRB);
                    }
                }
                else if(alnOptions.print >= 2)
                    cerr << "#FAIL " << curScore << endl;
                if(alnOptions.print >= 5) cerr << "final score is " << curScore << endl;
                alnBounds.push_back(boundaries(tmpRB, tmpRE, tmpQB, tmpQE));
#ifndef NDEBUG
                if(alnOptions.debugFile != NULL){
                    //print alignment
                    fprintf(alnOptions.debugFile,"@CHA %lu %d %d\n", chain.size(), chainScore, anchor.len);
                    for( list<size_t>::const_iterator iterator = chain.begin(); iterator != chain.end(); iterator++){
                        fprintf(alnOptions.debugFile,"%d %ld %d\n", matches[*iterator].query, matches[*iterator].ref, matches[*iterator].len);
                    }
                    if(curScore >= (int) (P.length()*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*editDist)){
                        alignment_t * alignmentFound = new alignment_t();
                        alignmentFound->refB = tmpRB;
                        alignmentFound->refE = tmpRE;
                        alignmentFound->qB = tmpQB;
                        alignmentFound->qE = tmpQE;
                        alignmentFound->alignmentScore = curScore;
                        for(std::list<size_t>::const_iterator iterator = chain.begin(); iterator != chain.end(); iterator++){
                            match_t seed = matches[*iterator];
                            alignmentFound->chain.push_back(seed);
                        }
                        uint8_t *query;
                        query = (uint8_t *)malloc(P.length());
                        for (size_t i = 0; i < P.length(); ++i) // convert to the nt4 encoding
                            query[i] = Utils::ORDVALUE[(size_t)P[i]];
                        alignmentFound->constructCIGAR(S, query, P.length(), alnOptions.fixedBandSize, alnOptions.mat, 
                                alnOptions.match, alnOptions.openGap, alnOptions.extendGap, 0);
                        free(query);
                        fprintf(alnOptions.debugFile,"@SUC %d %ld %s %d\n", alignmentFound->editDist, tmpRB, alignmentFound->NMtag.c_str(), curScore);
                        delete alignmentFound;
                    }
                    else{//print fail reason
                        fprintf(alnOptions.debugFile,"@ERR %ld %d\n", tmpRB, curScore);
                    }
                    //print best possible alignment
                    long refB = matches[chain.front()].ref - matches[chain.front()].query - 3*editDist;
                    long refE = refB+P.length() + 6*editDist;
                    dp_output output = dpInRegion(S, P, refB, refE, 0, P.length());
                    string cigarstring = createCigar(output.cigarChars, output.cigarLengths);
                    fprintf(alnOptions.debugFile,"@BEST %d %ld %s %d\n", output.editDist, refB, cigarstring.c_str(), output.dpScore);
                }
#endif
            }
        }
    }
    int scoreReturned = -1;
    if(maxAlnScore >= minScore)
        scoreReturned = maxAlnScore;
    return scoreReturned;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movl %r9d, 0x6c(%rsp)
movq %rcx, 0x70(%rsp)
movq %rdx, %r14
movq %rsi, 0x10(%rsp)
movq %rdi, 0x58(%rsp)
movq 0x1b0(%rsp), %rcx
cmpl $0x9, %r8d
pushq $0x9
popq %rax
cmovll %r8d, %eax
movl %eax, 0x8(%rsp)
cmpl $0x4, 0x78(%rcx)
movl %r8d, 0x3c(%rsp)
jle 0x1b821
movl %r8d, %ebp
movq 0x2e87c(%rip), %rbx     # 0x49fe8
leaq 0x1b79c(%rip), %rsi     # 0x36f0f
movq %rbx, %rdi
callq 0x72b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
leaq 0x1b789(%rip), %rsi     # 0x36f1d
movq %rbx, %rdi
callq 0x72b0
movq %rax, %rdi
callq 0x7160
movq %r14, %r13
xorl %r15d, %r15d
leaq 0x1b69f(%rip), %r14     # 0x36e50
xorl %r12d, %r12d
movl 0x8(%rsp), %ebp
movq (%r13), %rax
movq 0x8(%r13), %rsi
subq %rax, %rsi
sarq $0x4, %rsi
cmpq %rsi, %r12
jae 0x1b833
movl 0x8(%rax,%r15), %esi
movq %rbx, %rdi
callq 0x75c0
movq %rax, %rdi
movq %r14, %rsi
callq 0x72b0
movq (%r13), %rcx
movq (%rcx,%r15), %rsi
movq %rax, %rdi
callq 0x72a0
movq %rax, %rdi
movq %r14, %rsi
callq 0x72b0
movq (%r13), %rcx
movl 0xc(%rcx,%r15), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
incq %r12
addq $0x10, %r15
jmp 0x1b7b8
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x4, %rsi
movq %r14, %r13
movl 0x8(%rsp), %ebp
movq %r13, 0x18(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
andq $0x0, 0x10(%rax)
xorpd %xmm0, %xmm0
leaq 0xb0(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
callq 0x22178
leaq 0x150(%rsp), %rdi
andq $0x0, (%rdi)
andl $0x0, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
andl $0x0, 0x18(%rdi)
andq $0x0, 0x20(%rdi)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x4, %rsi
xorl %edx, %edx
callq 0x2613a
movq 0x1c8(%rsp), %rax
movq %rax, 0xc8(%rsp)
addl $-0xa, %ebp
pushq $0xc
popq %r15
xorl %r12d, %r12d
leaq 0xb0(%rsp), %rbx
leaq 0xd0(%rsp), %r14
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
cmpq %rcx, %r12
jae 0x1b904
movl (%rax,%r15), %eax
shlq $0x20, %rax
orq %r12, %rax
movq %rax, 0xd0(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x127d0
incq %r12
addq $0x10, %r15
jmp 0x1b8c5
movl %ebp, 0x8(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x26784
xorpd %xmm0, %xmm0
leaq 0xd0(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x100(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movapd %xmm0, (%rax)
movapd %xmm0, (%rcx)
leaq 0x130(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq 0xb8(%rsp), %rax
subq 0xb0(%rsp), %rax
shrq $0x3, %rax
movq 0x1b0(%rsp), %rcx
addq $0x10, %rcx
movq %rcx, 0x120(%rsp)
movslq 0x70(%rsp), %rcx
movq %rcx, 0x128(%rsp)
addq $0xb0, 0xc8(%rsp)
movl %eax, %eax
movl 0x3c(%rsp), %ebp
movq 0x18(%rsp), %r15
decq %rax
testl %eax, %eax
js 0x1c665
movq %rax, 0x80(%rsp)
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq 0xb0(%rsp), %rcx
movl (%rcx,%rax,8), %r14d
movq (%r15), %rax
movq %r14, %rcx
shlq $0x4, %rcx
movq (%rax,%rcx), %rdx
movq %rdx, 0x50(%rsp)
movl 0x8(%rax,%rcx), %r12d
movslq 0xc(%rax,%rcx), %r13
movl %r13d, %ebp
movq 0x1b0(%rsp), %r15
cmpl $0x5, 0x78(%r15)
jl 0x1ba4e
movq 0x2e5ee(%rip), %rdi     # 0x49fe8
leaq 0x1b528(%rip), %rsi     # 0x36f29
callq 0x72b0
movq %rax, %rdi
movl %r12d, %esi
callq 0x75c0
movq %rax, %rdi
leaq 0x1b435(%rip), %rsi     # 0x36e50
callq 0x72b0
movq %rax, %rdi
movq 0x50(%rsp), %rsi
callq 0x72a0
movq %rax, %rdi
leaq 0x1b419(%rip), %rsi     # 0x36e50
callq 0x72b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
leaq 0x150(%rsp), %rdi
movq %r14, 0x40(%rsp)
movq %r14, %rsi
callq 0x22132
testq %rdx, (%rax)
sete %r14b
movq 0xd0(%rsp), %rsi
movq 0xd8(%rsp), %rax
subq %rsi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %rcx
leal (%r12,%rbp), %edi
movq %r13, 0x78(%rsp)
movq 0x50(%rsp), %r9
leaq (%r9,%r13), %rbx
movl (%r15), %r10d
movl 0x8(%r15), %r11d
movl 0xc(%r15), %edx
movl 0x90(%r15), %r8d
addq %r9, %rbp
movq %rbp, 0x30(%rsp)
addq $0x14, %rsi
xorl %r15d, %r15d
movq %rbx, 0x88(%rsp)
movl %r10d, 0x48(%rsp)
movl %edx, 0x60(%rsp)
cmpq %rcx, %r15
jae 0x1bb8b
testb $0x1, %r14b
je 0x1bb8b
movl %edx, %ebp
movb $0x1, %r14b
movl %r12d, %edx
subl -0x4(%rsi), %edx
jl 0x1bb7d
movl (%rsi), %r9d
subl %edi, %r9d
jle 0x1bb7d
movq -0x14(%rsi), %rax
cmpq %rax, 0x50(%rsp)
jl 0x1bb7d
movq -0xc(%rsi), %r13
cmpq %r13, %rbx
jge 0x1bb7d
movq 0x50(%rsp), %rbx
movl %ebx, %r14d
subl %eax, %r14d
cmpl %r14d, %edx
movl %r14d, %eax
cmovll %edx, %eax
cmovgl %edx, %r14d
imull %r10d, %eax
addl %r11d, %eax
cltd
idivl %ebp
incl %eax
cmpl %eax, %r8d
cmovll %r8d, %eax
cmpl %eax, %r14d
jge 0x1bb45
xorl %r14d, %r14d
jmp 0x1bb75
subl 0x30(%rsp), %r13d
cmpl %r13d, %r9d
movl %r13d, %eax
cmovll %r9d, %eax
cmovgl %r9d, %r13d
imull 0x48(%rsp), %eax
addl %r11d, %eax
cltd
idivl 0x60(%rsp)
incl %eax
cmpl %eax, %r8d
cmovll %r8d, %eax
cmpl %eax, %r13d
setge %r14b
movq 0x88(%rsp), %rbx
incq %r15
addq $0x18, %rsi
movl %ebp, %edx
jmp 0x1bacc
testb $0x1, %r14b
movl 0x3c(%rsp), %ebp
movq 0x18(%rsp), %r15
movq 0x80(%rsp), %rax
je 0x1b9a0
andl $0x0, (%rsp)
movq 0x1b0(%rsp), %r14
movsd 0x30(%r14), %xmm0
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r8
movq %r15, %rdi
leaq 0x98(%rsp), %rsi
movq 0x40(%rsp), %rdx
leaq 0x150(%rsp), %rcx
movq %rsp, %r9
callq 0x1b3cf
movl %eax, %ebx
cmpl $0x2, 0x78(%r14)
jl 0x1bcf7
movq 0x2e3f3(%rip), %rdi     # 0x49fe8
leaq 0x1b335(%rip), %rsi     # 0x36f31
callq 0x72b0
movq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x71d0
movq %rax, %rdi
callq 0x7160
movq 0x2e3c8(%rip), %rdi     # 0x49fe8
leaq 0x1b312(%rip), %rsi     # 0x36f39
callq 0x72b0
movl (%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x2e3a2(%rip), %rdi     # 0x49fe8
leaq 0x1b2f9(%rip), %rsi     # 0x36f46
callq 0x72b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x2e37d(%rip), %rdi     # 0x49fe8
leaq 0x1b2e0(%rip), %rsi     # 0x36f52
callq 0x72b0
movq %rax, %rdi
movl 0x6c(%rsp), %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x1b0(%rsp), %rax
cmpl $0x5, 0x78(%rax)
jl 0x1bcf7
movq 0x2e348(%rip), %rdi     # 0x49fe8
leaq 0x1b2bb(%rip), %rsi     # 0x36f62
callq 0x72b0
movq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x71d0
movq %rax, %rdi
leaq 0x1b2b2(%rip), %rsi     # 0x36f78
callq 0x72b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x75c0
movq %rax, %rdi
leaq 0x1b171(%rip), %rsi     # 0x36e50
callq 0x72b0
movl (%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x70(%rsp), %rax
subl %ebx, %eax
jl 0x1bd16
cmpq $0x1, 0xa8(%rsp)
ja 0x1bd23
movq 0x78(%rsp), %rcx
cmpl 0x6c(%rsp), %ecx
jge 0x1bd23
movq 0x80(%rsp), %rax
jmp 0x1b9a0
movq %rax, 0x60(%rsp)
leal 0x1(%rax), %ecx
movq 0x1b0(%rsp), %rdi
movl 0x90(%rdi), %eax
cmpl %eax, %ecx
movq %rcx, 0x78(%rsp)
cmovll %ecx, %eax
movq %rax, 0x40(%rsp)
movq 0x98(%rsp), %rax
movq (%rax), %r14
movq 0x10(%rax), %rax
movq (%r15), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rdx
movl 0x8(%rcx,%rax), %esi
movslq 0xc(%rcx,%rax), %rbx
movl %esi, 0xc(%rsp)
leal -0x1(%rsi,%rbx), %eax
movl %eax, 0x4(%rsp)
movq %rdx, 0x20(%rsp)
leaq (%rdx,%rbx), %rax
decq %rax
movq %rax, 0x28(%rsp)
cmpl $0x7, 0x78(%rdi)
jl 0x1bdea
movq 0x2e253(%rip), %rdi     # 0x49fe8
leaq 0x1b1ff(%rip), %rsi     # 0x36f9b
callq 0x72b0
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
leaq 0x1b099(%rip), %rsi     # 0x36e50
callq 0x72b0
movq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x72a0
movq %rax, %rdi
leaq 0x1b07d(%rip), %rsi     # 0x36e50
callq 0x72b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x60(%rsp), %rax
addl $0x3, %eax
movq %rax, 0x60(%rsp)
movq 0x10(%rsp), %rbp
leaq 0x98(%rsp), %rax
cmpq %rax, %r14
je 0x1c2a5
movq %r14, 0x50(%rsp)
movq 0x10(%r14), %rax
movq (%r15), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %r13
movslq 0x8(%rcx,%rax), %r12
movslq 0xc(%rcx,%rax), %rbx
movq 0x1b0(%rsp), %rax
cmpl $0x6, 0x78(%rax)
jl 0x1be92
movq 0x2e1a8(%rip), %rdi     # 0x49fe8
leaq 0x1b169(%rip), %rsi     # 0x36fb0
callq 0x72b0
movq %rax, %rdi
movl %r12d, %esi
callq 0x75c0
movq %rax, %rdi
leaq 0x1afef(%rip), %rsi     # 0x36e50
callq 0x72b0
movq %rax, %rdi
movq %r13, %rsi
callq 0x72a0
movq %rax, %rdi
leaq 0x1afd5(%rip), %rsi     # 0x36e50
callq 0x72b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq %rbx, 0x88(%rsp)
movslq 0x4(%rsp), %r15
movq %r12, %r14
subq %r15, %r14
movq 0x28(%rsp), %rbp
movq %r13, %rbx
subq %rbp, %rbx
testl %r14d, %r14d
js 0x1beba
testq %rbx, %rbx
jns 0x1beca
movq %rbx, %rax
subq %r14, %rax
jle 0x1bec7
movq %rax, %rbx
jmp 0x1beca
subq %rbx, %r14
testq %r14, %r14
jle 0x1bf27
testq %rbx, %rbx
jle 0x1bf69
cmpq $0x1, %r14
jne 0x1bfa5
decq %rbx
movq 0x1b0(%rsp), %rcx
movl 0xc(%rcx), %eax
imull %ebx, %eax
addl 0x8(%rcx), %eax
addl %eax, (%rsp)
movl 0x78(%rcx), %eax
cmpl $0x7, %eax
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbp
jl 0x1c00d
movq 0x2e0d2(%rip), %rdi     # 0x49fe8
leaq 0x1b0aa(%rip), %rsi     # 0x36fc7
callq 0x72b0
jmp 0x1bfef
movq 0x1b0(%rsp), %rcx
movl 0xc(%rcx), %eax
imull %ebx, %eax
addl 0x8(%rcx), %eax
addl %eax, (%rsp)
movl 0x78(%rcx), %eax
cmpl $0x7, %eax
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbp
jl 0x1c00d
movq 0x2e090(%rip), %rdi     # 0x49fe8
leaq 0x1b068(%rip), %rsi     # 0x36fc7
callq 0x72b0
jmp 0x1bfef
movq 0x1b0(%rsp), %rcx
movl 0xc(%rcx), %eax
imull %r14d, %eax
addl 0x8(%rcx), %eax
addl %eax, (%rsp)
movl 0x78(%rcx), %eax
cmpl $0x7, %eax
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbp
jl 0x1c00d
movq 0x2e051(%rip), %rdi     # 0x49fe8
leaq 0x1b041(%rip), %rsi     # 0x36fdf
callq 0x72b0
jmp 0x1bfec
cmpq $0x1, %rbx
jne 0x1c062
decq %r14
movq 0x1b0(%rsp), %rcx
movl 0xc(%rcx), %eax
imull %r14d, %eax
addl 0x8(%rcx), %eax
addl %eax, (%rsp)
movl 0x78(%rcx), %eax
cmpl $0x7, %eax
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbp
jl 0x1c00d
movq 0x2e008(%rip), %rdi     # 0x49fe8
leaq 0x1aff8(%rip), %rsi     # 0x36fdf
callq 0x72b0
movq %r14, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x72a0
movq %rax, %rdi
callq 0x7160
movq 0x1b0(%rsp), %rax
movl 0x78(%rax), %eax
cmpl $0x6, %eax
jl 0x1c038
movq 0x2dfcf(%rip), %rdi     # 0x49fe8
leaq 0x1afec(%rip), %rsi     # 0x3700c
callq 0x72b0
movl (%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x88(%rsp), %rcx
leaq (%rcx,%r13), %rax
decq %rax
movq %rax, 0x28(%rsp)
leal -0x1(%r12,%rcx), %eax
movl %eax, 0x4(%rsp)
movq 0x50(%rsp), %r14
movq (%r14), %r14
jmp 0x1bdfc
cmpq $0x2, %r14
jne 0x1c0aa
cmpq $0x2, %rbx
jne 0x1c0aa
movq 0x1b0(%rsp), %rcx
movl 0x4(%rcx), %eax
addl %eax, (%rsp)
movl 0x78(%rcx), %eax
cmpl $0x7, %eax
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rbp
jl 0x1c00d
movq 0x2df4f(%rip), %rdi     # 0x49fe8
leaq 0x1af58(%rip), %rsi     # 0x36ff8
callq 0x72b0
jmp 0x1bffa
movq %rbp, %r14
notq %r14
addq %r13, %r14
movslq %r14d, %rdi
movq %rdi, 0x30(%rsp)
callq 0x7430
movq %rax, %rbx
movq 0x58(%rsp), %rax
movq (%rax), %rax
addq %rbp, %rax
incq %rax
cmpl $0x0, 0x30(%rsp)
movl $0x0, %ecx
movq %r14, 0x30(%rsp)
cmovgl %r14d, %ecx
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x1c104
movsbq (%rax,%rdx), %rsi
leaq 0x1aaf9(%rip), %rdi     # 0x36bf0
movb (%rsi,%rdi), %sil
movb %sil, (%rbx,%rdx)
incq %rdx
jmp 0x1c0e6
movl %r15d, %ebp
notl %ebp
addl %r12d, %ebp
movslq %ebp, %rdi
movq %rdi, 0x48(%rsp)
callq 0x7430
movq %rax, %r14
movq 0x10(%rsp), %rax
movq (%rax), %rcx
cmpl $0x0, 0x48(%rsp)
movl $0x0, %eax
movl %ebp, 0x48(%rsp)
cmovgl %ebp, %eax
addq %r15, %rcx
incq %rcx
xorl %edx, %edx
movq 0x18(%rsp), %r15
cmpq %rdx, %rax
je 0x1c160
movsbq (%rcx,%rdx), %rsi
leaq 0x1aa9d(%rip), %rdi     # 0x36bf0
movb (%rsi,%rdi), %sil
movb %sil, (%r14,%rdx)
incq %rdx
jmp 0x1c142
movl 0x48(%rsp), %eax
subl 0x30(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movq 0x60(%rsp), %rax
addl %ecx, %eax
movq 0x1b0(%rsp), %rsi
movl 0x90(%rsi), %edx
cmpl %edx, %eax
cmovll %eax, %edx
cvtsi2sd %ecx, %xmm0
mulsd 0x30(%rsi), %xmm0
cvttsd2si %xmm0, %ebp
addl %ecx, %ebp
cmpl %ebp, %edx
cmovgl %edx, %ebp
cmpl $0x1, 0x78(%rsi)
jle 0x1c248
movq 0x2de3a(%rip), %rdi     # 0x49fe8
leaq 0x1ae52(%rip), %rsi     # 0x37007
callq 0x72b0
movl %ebp, %esi
imull 0x30(%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x1b0(%rsp), %rax
cmpl $0x7, 0x78(%rax)
jl 0x1c248
movq 0x2de02(%rip), %rdi     # 0x49fe8
leaq 0x1ab2b(%rip), %rsi     # 0x36d18
callq 0x72b0
movl 0x4(%rsp), %ecx
movl %r12d, %esi
subl %ecx, %esi
incl %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
leaq 0x16cac(%rip), %rsi     # 0x32ebb
callq 0x72b0
movq %r13, %rsi
subq 0x28(%rsp), %rsi
incq %rsi
movq %rax, %rdi
callq 0x72a0
movq %rax, %rdi
leaq 0x1ab01(%rip), %rsi     # 0x36d32
callq 0x72b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
xorl %eax, %eax
movq 0x1b0(%rsp), %rcx
subl 0x8(%rcx), %eax
xorl %r10d, %r10d
subl 0xc(%rcx), %r10d
subq $0x8, %rsp
movl 0x50(%rsp), %edi
movq %r14, %rsi
movq 0x38(%rsp), %rdx
movq %rbx, %rcx
pushq $0x5
popq %r8
movq 0x128(%rsp), %r9
pushq %rbp
pushq %r10
pushq %rax
callq 0x316fb
addq $0x20, %rsp
addl %eax, (%rsp)
movq %r14, %rdi
callq 0x7360
movq %rbx, %rdi
callq 0x7360
movq 0x10(%rsp), %rbp
jmp 0x1c002
movl 0x4(%rsp), %eax
notl %eax
addl 0x8(%rbp), %eax
cmpl %eax, 0xc(%rsp)
movq %rbp, %rsi
movl 0x3c(%rsp), %ebp
jle 0x1c339
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
leaq 0xc(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq 0x1c8(%rsp), %r8
movq 0x1b8(%rsp), %r9
pushq 0x78(%rsp)
pushq 0x50(%rsp)
leaq 0x18(%rsp), %rax
pushq %rax
callq 0x225e1
addq $0x20, %rsp
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x14(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movq 0x1c0(%rsp), %r8
movq 0x1b8(%rsp), %r9
pushq 0x80(%rsp)
pushq 0x50(%rsp)
leaq 0x18(%rsp), %rax
pushq %rax
callq 0x2220e
addq $0x20, %rsp
jmp 0x1c3b5
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
leaq 0x14(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movq 0x1c0(%rsp), %r8
movq 0x1b8(%rsp), %r9
pushq 0x80(%rsp)
pushq 0x50(%rsp)
leaq 0x18(%rsp), %rax
pushq %rax
callq 0x2220e
addq $0x20, %rsp
subq $0x8, %rsp
movq 0x60(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq 0x1c8(%rsp), %r8
movq 0x1b8(%rsp), %r9
pushq 0x78(%rsp)
pushq 0x50(%rsp)
leaq 0x18(%rsp), %rax
pushq %rax
callq 0x225e1
addq $0x20, %rsp
movq 0x1b0(%rsp), %rax
cmpl $0x5, 0x78(%rax)
jl 0x1c3eb
movq 0x2dc1e(%rip), %rdi     # 0x49fe8
leaq 0x1ac48(%rip), %rsi     # 0x37019
callq 0x72b0
movq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x72a0
movq %rax, %rdi
callq 0x7160
movl (%rsp), %eax
movl 0x8(%rsp), %ecx
cmpl %eax, %ecx
cmovlel %eax, %ecx
movl %ecx, 0x8(%rsp)
movq 0x1b0(%rsp), %rcx
movl 0x78(%rcx), %ecx
cmpl %ebp, %eax
jge 0x1c43e
cmpl $0x2, %ecx
jl 0x1c613
movq 0x2dbce(%rip), %rdi     # 0x49fe8
leaq 0x1ac27(%rip), %rsi     # 0x37048
callq 0x72b0
movl (%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
jmp 0x1c5df
cmpl $0x2, %ecx
jl 0x1c46c
movq 0x2db9e(%rip), %rdi     # 0x49fe8
leaq 0x1abee(%rip), %rsi     # 0x3703f
callq 0x72b0
movl (%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movl (%rsp), %eax
movq 0x100(%rsp), %rcx
movq 0x108(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
movq 0x130(%rsp), %rsi
movq 0x20(%rsp), %r8
xorl %edi, %edi
xorl %r9d, %r9d
cmpq %r9, %rdx
je 0x1c4c5
cmpl %eax, (%rcx,%r9,4)
jl 0x1c4c0
movq (%rsi,%r9,8), %r10
subq %r8, %r10
movq %r10, %r11
negq %r11
cmovsq %r10, %r11
cmpq 0x128(%rsp), %r11
setl %r10b
orb %r10b, %dil
incq %r9
jmp 0x1c495
testb $0x1, %dil
jne 0x1c5df
movl $0x100, %edi            # imm = 0x100
callq 0x72d0
movq %rax, %r14
movq %rax, %rdi
callq 0x229e0
movq %r14, 0x90(%rsp)
movq 0x20(%rsp), %rcx
movq %rcx, (%r14)
movq 0x28(%rsp), %rax
movq %rax, 0x8(%r14)
movl 0xc(%rsp), %edx
movl %edx, 0x10(%r14)
movl 0x4(%rsp), %edx
movl %edx, 0x14(%r14)
movl (%rsp), %edx
movl %edx, 0x70(%r14)
cmpb $0x0, 0x1d0(%rsp)
jne 0x1c542
addq $0x40, %r14
movq %r14, %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
callq 0xa1f6
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq 0x90(%rsp), %r14
subl %ecx, %eax
incl %eax
movl %eax, 0x98(%r14)
leaq 0x98(%rsp), %rbx
movq (%rbx), %rbx
leaq 0x98(%rsp), %rax
cmpq %rax, %rbx
je 0x1c5a8
movq 0x10(%rbx), %rax
movq (%r15), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rdx
movq %rdx, 0xe8(%rsp)
movq 0x8(%rcx,%rax), %rax
movq %rax, 0xf0(%rsp)
movq 0x90(%rsp), %rdi
movl $0xe8, %eax
addq %rax, %rdi
leaq 0xe8(%rsp), %rsi
callq 0x2205e
jmp 0x1c555
movq 0xc8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x22ac6
leaq 0x100(%rsp), %rdi
movq %rsp, %rsi
callq 0x22ae4
leaq 0x130(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x12b24
movq 0x1b0(%rsp), %rax
cmpl $0x5, 0x78(%rax)
jl 0x1c613
movq 0x2d9f4(%rip), %rdi     # 0x49fe8
leaq 0x1aa54(%rip), %rsi     # 0x3704f
callq 0x72b0
movl (%rsp), %esi
movq %rax, %rdi
callq 0x75c0
movq %rax, %rdi
callq 0x7160
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movl 0xc(%rsp), %edx
movl 0x4(%rsp), %esi
movq %rax, 0xe8(%rsp)
movq %rcx, 0xf0(%rsp)
movl %edx, 0xf8(%rsp)
movl %esi, 0xfc(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x26db0
movq 0x80(%rsp), %rax
jmp 0x1b9a0
movl 0x8(%rsp), %eax
cmpl %ebp, %eax
pushq $-0x1
popq %rbx
cmovgel %eax, %ebx
leaq 0x130(%rsp), %rdi
callq 0xa3d4
leaq 0x100(%rsp), %rdi
callq 0xa268
leaq 0xd0(%rsp), %rdi
callq 0x26baa
leaq 0x150(%rsp), %rdi
callq 0x22b02
leaq 0xb0(%rsp), %rdi
callq 0xa3d4
leaq 0x98(%rsp), %rdi
callq 0x2477e
movl %ebx, %eax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
callq 0x72e0
jmp 0x1c70a
jmp 0x1c707
jmp 0x1c707
jmp 0x1c707
jmp 0x1c702
jmp 0x1c702
movq %rax, %rbx
jmp 0x1c73e
jmp 0x1c707
jmp 0x1c707
jmp 0x1c707
jmp 0x1c707
jmp 0x1c707
jmp 0x1c707
jmp 0x1c707
movq %rax, %rbx
jmp 0x1c731
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0xa3d4
leaq 0x100(%rsp), %rdi
callq 0xa268
leaq 0xd0(%rsp), %rdi
callq 0x26baa
leaq 0x150(%rsp), %rdi
callq 0x22b02
leaq 0xb0(%rsp), %rdi
callq 0xa3d4
leaq 0x98(%rsp), %rdi
callq 0x2477e
movq %rbx, %rdi
callq 0x75e0