// File: readmapping[P]alfalfa/src/mapper.cpp
// Function: processLisIntervalsSimultaneous(sparseSA const&, read_t&, read_t&, align_opt const&, paired_opt const&, std::vector<lis_t, std::allocator<lis_t>> const&, std::vector<lis_t, std::allocator<lis_t>> const&, std::vector<LIScouple_t, std::allocator<LIScouple_t>> const&, int, double, int, int)
inline void processLisIntervalsSimultaneous(const sparseSA& sa, read_t & mate1, read_t & mate2, 
        const align_opt & alnOptions, const paired_opt & pairedOpt, const vector<lis_t> & lisIntervals1, 
        const vector<lis_t> & lisIntervals2, const vector<LIScouple_t> & pairedOrder, 
        int maxAlnCount, double minCoveragePercent, int minScore1, int minScore2){
    int minCoverage1 = mate1.sequence.length()*minCoveragePercent;
    int minCoverage2 = mate2.sequence.length()*minCoveragePercent;
    int editDist1 = (int)(alnOptions.errorPercent*mate1.sequence.length())+1;
    int editDist2 = (int)(alnOptions.errorPercent*mate2.sequence.length())+1;
    //for every interval, try to align
    size_t lisIndex = 0;
    //trial parameter for performance reasons
    int trial = 0;
    //////////////////////
    //MAIN ALIGNMENT LOOP
    //////////////////////
    //tree containing information for uniqueness option
    int maxAlnScore = 0;
    int alnCount = 0;
    while(alnCount < maxAlnCount && lisIndex < pairedOrder.size()){
        const lis_t & cluster1 = lisIntervals1[pairedOrder[lisIndex].firstPosition];
        const lis_t & cluster2 = lisIntervals2[pairedOrder[lisIndex].secondPosition];
        bool extensionCriterium = (trial < alnOptions.maxTrial);        
        if(alnOptions.print >=2 ){
            cerr << "#LISI " << lisIndex << endl;
            cerr << "#TRIAL " << trial << endl;
            cerr << "#EXTEND " << extensionCriterium << endl;
            cerr << "#LISMEMS " << (cluster1.matches.size()+cluster2.matches.size()) << endl;
            cerr << "#LISSCORE " << pairedOrder[lisIndex].score << endl;
        }
        if(extensionCriterium){
            const vector<match_t> & matchVector1 = cluster1.matches;
            const vector<match_t> & matchVector2 = cluster2.matches;
            long chrStart1, chrEnd1, chrStart2, chrEnd2;
            sa.getChromBounds(matchVector1[0].ref, chrStart1, chrEnd1);
            sa.getChromBounds(matchVector2[0].ref, chrStart2, chrEnd2);
            int returnedAlnScore, returnedAlnScore1, returnedAlnScore2;
            size_t baseAln1 = mate1.alignments.size();
            size_t baseAln2 = mate2.alignments.size();
            //extend cluster1
            if(alnOptions.print >=5) cerr << "try cluster " << pairedOrder[lisIndex].firstPosition << " with " << matchVector1.size() << " seeds on " << (cluster1.fw ? "forward" : "reverse complemented") << " strand." << endl;
            returnedAlnScore1 = extendAlignmentChain(sa.S, cluster1.fw ? mate1.sequence : mate1.rcSequence, matchVector1, editDist1, minScore1, minCoverage1, alnOptions, chrStart1, chrEnd1, mate1, cluster1.fw);
            //extend cluster2
            if(alnOptions.print >=5) cerr << "try cluster " << pairedOrder[lisIndex].secondPosition << " with " << matchVector2.size() << " seeds on " << (cluster2.fw ? "forward" : "reverse complemented") << " strand." << endl;
            returnedAlnScore2 = extendAlignmentChain(sa.S, cluster2.fw ? mate2.sequence : mate2.rcSequence, matchVector2, editDist2, minScore2, minCoverage2, alnOptions, chrStart2, chrEnd2, mate2, cluster2.fw);
            //rescue cluster1 or 2
            if(baseAln1 == mate1.alignments.size() && baseAln2 < mate2.alignments.size() && alnOptions.rescue){
                if(alnOptions.print >= 2) cerr << "#RESCUE" << endl;
                minScore1 = max(0,(int)(mate1.sequence.length()*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*0.2*mate1.sequence.length()));
                returnedAlnScore1 = extendAlignmentChain(sa.S, cluster1.fw ? mate1.sequence : mate1.rcSequence, matchVector1, editDist1, minScore1, minCoverage1, alnOptions, chrStart1, chrEnd1, mate1, cluster1.fw);
            }
            else if(baseAln1 < mate1.alignments.size() && baseAln2 == mate2.alignments.size() && alnOptions.rescue){
                if(alnOptions.print >= 2) cerr << "#RESCUE" << endl;
                minScore2 = max(0,(int)(mate2.sequence.length()*alnOptions.match + (alnOptions.mismatch-alnOptions.match)*0.2*mate2.sequence.length()));
                returnedAlnScore2 = extendAlignmentChain(sa.S, cluster2.fw ? mate2.sequence : mate2.rcSequence, matchVector2, editDist2, minScore2, minCoverage2, alnOptions, chrStart2, chrEnd2, mate2, cluster2.fw);
            }
            //pair if possible
            if(baseAln1 < mate1.alignments.size() && baseAln2 < mate2.alignments.size()){
                size_t mate1MaxSize = mate1.alignments.size();
                size_t mate2MaxSize = mate2.alignments.size();
                for(size_t i = baseAln1; i < mate1MaxSize; i++){
                    for(size_t j = baseAln2; j < mate2MaxSize; j++){
                        alignment_t * aln1 = mate1.alignments[i];
                        aln1->setLocalPos(sa);
                        alignment_t * aln2 = mate2.alignments[j];
                        aln2->setLocalPos(sa);
                        if(isConcordant(aln1, aln2, pairedOpt, alnOptions.print)){
                            if(alnOptions.print >= 4) cerr << "found concordancy between aln " << i << " of mate 1 and aln " << j << " of mate 2" << endl;
                            setPaired(sa, mate1, mate2,i,j, true);
                            alnCount++;
                        }
                    }
                }
            }
            //deal with new alignments
            trial++;
            returnedAlnScore = returnedAlnScore1 + returnedAlnScore2;
            if(returnedAlnScore >= 0 && (!alnOptions.maxTrialBest || maxAlnScore < returnedAlnScore))
                trial = 0;
            maxAlnScore = max(maxAlnScore, returnedAlnScore);
        }
        lisIndex++;
    }  
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movl 0x2e0(%rsp), %eax
movl 0x2d8(%rsp), %eax
movl 0x2d0(%rsp), %eax
movq 0x2c8(%rsp), %rax
movq 0x2c0(%rsp), %rax
movq %rdi, 0x2a0(%rsp)
movq %rsi, 0x298(%rsp)
movq %rdx, 0x290(%rsp)
movq %rcx, 0x288(%rsp)
movq %r8, 0x280(%rsp)
movq %r9, 0x278(%rsp)
movsd %xmm0, 0x270(%rsp)
movq 0x298(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movq %rax, %xmm0
movaps 0x2f01b(%rip), %xmm1    # 0x7db70
movaps %xmm1, 0x170(%rsp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2f017(%rip), %xmm1    # 0x7db80
movaps %xmm1, 0x180(%rsp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x270(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x26c(%rsp)
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movaps 0x170(%rsp), %xmm2
movaps 0x180(%rsp), %xmm1
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x270(%rsp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x268(%rsp)
movq 0x288(%rsp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, 0x168(%rsp)
movq 0x298(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movsd 0x168(%rsp), %xmm0
movaps 0x170(%rsp), %xmm3
movaps 0x180(%rsp), %xmm2
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x264(%rsp)
movq 0x288(%rsp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, 0x198(%rsp)
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movaps 0x170(%rsp), %xmm3
movaps 0x180(%rsp), %xmm2
movsd 0x198(%rsp), %xmm0
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
addl $0x1, %eax
movl %eax, 0x260(%rsp)
movq $0x0, 0x258(%rsp)
movl $0x0, 0x254(%rsp)
movl $0x0, 0x250(%rsp)
movl $0x0, 0x24c(%rsp)
movl 0x24c(%rsp), %ecx
xorl %eax, %eax
cmpl 0x2d0(%rsp), %ecx
movb %al, 0x167(%rsp)
jge 0x4ed37
movq 0x258(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x4e9b0
movq %rax, %rcx
movq 0x158(%rsp), %rax
cmpq %rcx, %rax
setb %al
movb %al, 0x167(%rsp)
movb 0x167(%rsp), %al
testb $0x1, %al
jne 0x4ed47
jmp 0x4fb85
movq 0x278(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x2c8(%rsp), %rdi
movq 0x258(%rsp), %rsi
callq 0x52e40
movq 0x148(%rsp), %rdi
movslq (%rax), %rsi
callq 0x4e190
movq %rax, 0x240(%rsp)
movq 0x2c0(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x2c8(%rsp), %rdi
movq 0x258(%rsp), %rsi
callq 0x52e40
movq 0x150(%rsp), %rdi
movslq 0x4(%rax), %rsi
callq 0x4e190
movq %rax, 0x238(%rsp)
movl 0x254(%rsp), %eax
movq 0x288(%rsp), %rcx
cmpl 0x54(%rcx), %eax
setl %al
andb $0x1, %al
movb %al, 0x237(%rsp)
movq 0x288(%rsp), %rax
cmpl $0x2, 0x78(%rax)
jl 0x4ef46
movq 0x481f7(%rip), %rdi     # 0x96ff0
leaq 0x2f0ff(%rip), %rsi     # 0x7deff
callq 0x8360
movq %rax, %rdi
movq 0x258(%rsp), %rsi
callq 0x8100
movq %rax, %rdi
movq 0x48191(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x481c5(%rip), %rdi     # 0x96ff0
leaq 0x2f0dd(%rip), %rsi     # 0x7df0f
callq 0x8360
movq %rax, %rdi
movl 0x254(%rsp), %esi
callq 0x8710
movq %rax, %rdi
movq 0x48160(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x48194(%rip), %rdi     # 0x96ff0
leaq 0x2f0b4(%rip), %rsi     # 0x7df17
callq 0x8360
movq %rax, %rdi
movb 0x237(%rsp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x8760
movq %rax, %rdi
movq 0x4812a(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x4815e(%rip), %rdi     # 0x96ff0
leaq 0x2f087(%rip), %rsi     # 0x7df20
callq 0x8360
movq %rax, 0x138(%rsp)
movq 0x240(%rsp), %rdi
addq $0x20, %rdi
callq 0x23440
movq %rax, 0x130(%rsp)
movq 0x238(%rsp), %rdi
addq $0x20, %rdi
callq 0x23440
movq 0x130(%rsp), %rsi
movq 0x138(%rsp), %rdi
addq %rax, %rsi
callq 0x8100
movq %rax, %rdi
movq 0x480be(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x480f2(%rip), %rdi     # 0x96ff0
leaq 0x2f025(%rip), %rsi     # 0x7df2a
callq 0x8360
movq %rax, 0x140(%rsp)
movq 0x2c8(%rsp), %rdi
movq 0x258(%rsp), %rsi
callq 0x52e40
movq 0x140(%rsp), %rdi
movl 0x8(%rax), %esi
callq 0x8710
movq %rax, %rdi
movq 0x4806f(%rip), %rsi     # 0x96fb0
callq 0x83b0
testb $0x1, 0x237(%rsp)
je 0x4fb6c
movq 0x240(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x228(%rsp)
movq 0x238(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x220(%rsp)
movq 0x2a0(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x228(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c8f0
movq 0x120(%rsp), %rdi
movq (%rax), %rsi
leaq 0x218(%rsp), %rdx
leaq 0x210(%rsp), %rcx
callq 0x4e1b0
movq 0x2a0(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x220(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c8f0
movq 0x128(%rsp), %rdi
movq (%rax), %rsi
leaq 0x208(%rsp), %rdx
leaq 0x200(%rsp), %rcx
callq 0x4e1b0
movq 0x298(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, 0x1e8(%rsp)
movq 0x290(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, 0x1e0(%rsp)
movq 0x288(%rsp), %rax
cmpl $0x5, 0x78(%rax)
jl 0x4f110
movq 0x47fa1(%rip), %rdi     # 0x96ff0
leaq 0x2eedf(%rip), %rsi     # 0x7df35
callq 0x8360
movq %rax, 0x110(%rsp)
movq 0x2c8(%rsp), %rdi
movq 0x258(%rsp), %rsi
callq 0x52e40
movq 0x110(%rsp), %rdi
movl (%rax), %esi
callq 0x8710
movq %rax, %rdi
leaq 0x2eceb(%rip), %rsi     # 0x7dd7c
callq 0x8360
movq %rax, 0x118(%rsp)
movq 0x228(%rsp), %rdi
callq 0x23440
movq 0x118(%rsp), %rdi
movq %rax, %rsi
callq 0x8100
movq %rax, %rdi
leaq 0x2ee7d(%rip), %rsi     # 0x7df42
callq 0x8360
movq %rax, %rdi
movq 0x240(%rsp), %rax
movb 0x4(%rax), %cl
leaq 0x2ee6e(%rip), %rsi     # 0x7df4d
leaq 0x2bdbf(%rip), %rax     # 0x7aea5
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x8360
movq %rax, %rdi
leaq 0x2bde9(%rip), %rsi     # 0x7aee5
callq 0x8360
movq %rax, %rdi
movq 0x47ea5(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x2a0(%rsp), %rax
addq $0x50, %rax
movq %rax, 0x108(%rsp)
movq 0x240(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x4f148
movq 0x298(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x100(%rsp)
jmp 0x4f15c
movq 0x298(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x100(%rsp)
movq 0x108(%rsp), %rdi
movq 0x100(%rsp), %rsi
movq 0x228(%rsp), %rdx
movl 0x264(%rsp), %ecx
movl 0x2d8(%rsp), %r8d
movl 0x26c(%rsp), %r9d
movq 0x288(%rsp), %r14
movq 0x218(%rsp), %rbx
movq 0x210(%rsp), %r11
movq 0x298(%rsp), %r10
movq 0x240(%rsp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
callq 0x3f5b0
movl %eax, 0x1f8(%rsp)
movq 0x288(%rsp), %rax
cmpl $0x5, 0x78(%rax)
jl 0x4f2b9
movq 0x47df9(%rip), %rdi     # 0x96ff0
leaq 0x2ed37(%rip), %rsi     # 0x7df35
callq 0x8360
movq %rax, 0xf0(%rsp)
movq 0x2c8(%rsp), %rdi
movq 0x258(%rsp), %rsi
callq 0x52e40
movq 0xf0(%rsp), %rdi
movl 0x4(%rax), %esi
callq 0x8710
movq %rax, %rdi
leaq 0x2eb42(%rip), %rsi     # 0x7dd7c
callq 0x8360
movq %rax, 0xf8(%rsp)
movq 0x220(%rsp), %rdi
callq 0x23440
movq 0xf8(%rsp), %rdi
movq %rax, %rsi
callq 0x8100
movq %rax, %rdi
leaq 0x2ecd4(%rip), %rsi     # 0x7df42
callq 0x8360
movq %rax, %rdi
movq 0x238(%rsp), %rax
movb 0x4(%rax), %cl
leaq 0x2ecc5(%rip), %rsi     # 0x7df4d
leaq 0x2bc16(%rip), %rax     # 0x7aea5
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x8360
movq %rax, %rdi
leaq 0x2bc40(%rip), %rsi     # 0x7aee5
callq 0x8360
movq %rax, %rdi
movq 0x47cfc(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x2a0(%rsp), %rax
addq $0x50, %rax
movq %rax, 0xe8(%rsp)
movq 0x238(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x4f2f1
movq 0x290(%rsp), %rax
addq $0x20, %rax
movq %rax, 0xe0(%rsp)
jmp 0x4f305
movq 0x290(%rsp), %rax
addq $0x60, %rax
movq %rax, 0xe0(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movq 0x220(%rsp), %rdx
movl 0x260(%rsp), %ecx
movl 0x2e0(%rsp), %r8d
movl 0x268(%rsp), %r9d
movq 0x288(%rsp), %r14
movq 0x208(%rsp), %rbx
movq 0x200(%rsp), %r11
movq 0x290(%rsp), %r10
movq 0x238(%rsp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
callq 0x3f5b0
movl %eax, 0x1f4(%rsp)
movq 0x1e8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x298(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, %rcx
movq 0xd8(%rsp), %rax
cmpq %rcx, %rax
jne 0x4f616
movq 0x1e0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x290(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, %rcx
movq 0xd0(%rsp), %rax
cmpq %rcx, %rax
jae 0x4f616
movq 0x288(%rsp), %rax
testb $0x1, 0x71(%rax)
je 0x4f616
movq 0x288(%rsp), %rax
cmpl $0x2, 0x78(%rax)
jl 0x4f439
movq 0x47bd2(%rip), %rdi     # 0x96ff0
leaq 0x2ec71(%rip), %rsi     # 0x7e096
callq 0x8360
movq %rax, %rdi
movq 0x47b7c(%rip), %rsi     # 0x96fb0
callq 0x83b0
movl $0x0, 0x1dc(%rsp)
movq 0x298(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movq %rax, %rdx
movq 0x288(%rsp), %rax
movslq (%rax), %rsi
movl %esi, %ecx
imulq %rsi, %rdx
movq %rdx, %xmm0
movaps 0x2e6fb(%rip), %xmm1    # 0x7db70
movaps %xmm1, 0x90(%rsp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2e6f7(%rip), %xmm1    # 0x7db80
movaps %xmm1, 0xa0(%rsp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0xc0(%rsp)
movl 0x4(%rax), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0x2e69e(%rip), %xmm1    # 0x7db58
mulsd %xmm1, %xmm0
movsd %xmm0, 0xb8(%rsp)
movq 0x298(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movaps 0x90(%rsp), %xmm4
movaps 0xa0(%rsp), %xmm3
movsd 0xb8(%rsp), %xmm0
movsd 0xc0(%rsp), %xmm1
movq %rax, %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x1d8(%rsp)
leaq 0x1dc(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x14d40
movl (%rax), %eax
movl %eax, 0x2d8(%rsp)
movq 0x2a0(%rsp), %rax
addq $0x50, %rax
movq %rax, 0xc8(%rsp)
movq 0x240(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x4f57b
movq 0x298(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x88(%rsp)
jmp 0x4f58f
movq 0x298(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x88(%rsp)
movq 0xc8(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x228(%rsp), %rdx
movl 0x264(%rsp), %ecx
movl 0x2d8(%rsp), %r8d
movl 0x26c(%rsp), %r9d
movq 0x288(%rsp), %r14
movq 0x218(%rsp), %rbx
movq 0x210(%rsp), %r11
movq 0x298(%rsp), %r10
movq 0x240(%rsp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
callq 0x3f5b0
movl %eax, 0x1f8(%rsp)
jmp 0x4f875
movq 0x1e8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x298(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, %rcx
movq 0x80(%rsp), %rax
cmpq %rcx, %rax
jae 0x4f873
movq 0x1e0(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x290(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
jne 0x4f873
movq 0x288(%rsp), %rax
testb $0x1, 0x71(%rax)
je 0x4f873
movq 0x288(%rsp), %rax
cmpl $0x2, 0x78(%rax)
jl 0x4f6c2
movq 0x47949(%rip), %rdi     # 0x96ff0
leaq 0x2e9e8(%rip), %rsi     # 0x7e096
callq 0x8360
movq %rax, %rdi
movq 0x478f3(%rip), %rsi     # 0x96fb0
callq 0x83b0
movl $0x0, 0x1d4(%rsp)
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movq %rax, %rdx
movq 0x288(%rsp), %rax
movslq (%rax), %rsi
movl %esi, %ecx
imulq %rsi, %rdx
movq %rdx, %xmm0
movaps 0x2e472(%rip), %xmm1    # 0x7db70
movaps %xmm1, 0x40(%rsp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2e471(%rip), %xmm1    # 0x7db80
movaps %xmm1, 0x50(%rsp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x68(%rsp)
movl 0x4(%rax), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0x2e41e(%rip), %xmm1    # 0x7db58
mulsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x290(%rsp), %rdi
addq $0x20, %rdi
callq 0x8630
movaps 0x40(%rsp), %xmm4
movaps 0x50(%rsp), %xmm3
movsd 0x60(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movq %rax, %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x1d0(%rsp)
leaq 0x1d4(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x14d40
movl (%rax), %eax
movl %eax, 0x2e0(%rsp)
movq 0x2a0(%rsp), %rax
addq $0x50, %rax
movq %rax, 0x70(%rsp)
movq 0x238(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x4f7e6
movq 0x290(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x38(%rsp)
jmp 0x4f7f7
movq 0x290(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x38(%rsp)
movq 0x70(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x220(%rsp), %rdx
movl 0x260(%rsp), %ecx
movl 0x2e0(%rsp), %r8d
movl 0x268(%rsp), %r9d
movq 0x288(%rsp), %r14
movq 0x208(%rsp), %rbx
movq 0x200(%rsp), %r11
movq 0x290(%rsp), %r10
movq 0x238(%rsp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movzbl %al, %eax
movl %eax, 0x20(%rsp)
callq 0x3f5b0
movl %eax, 0x1f4(%rsp)
jmp 0x4f875
movq 0x1e8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x298(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x4faf5
movq 0x1e0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x290(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x4faf5
movq 0x298(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, 0x1c8(%rsp)
movq 0x290(%rsp), %rdi
addq $0xb0, %rdi
callq 0xdac0
movq %rax, 0x1c0(%rsp)
movq 0x1e8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rax
cmpq 0x1c8(%rsp), %rax
jae 0x4faf3
movq 0x1e0(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x1b0(%rsp), %rax
cmpq 0x1c0(%rsp), %rax
jae 0x4fad8
movq 0x298(%rsp), %rdi
addq $0xb0, %rdi
movq 0x1b8(%rsp), %rsi
callq 0xdae0
movq (%rax), %rax
movq %rax, 0x1a8(%rsp)
movq 0x1a8(%rsp), %rdi
movq 0x2a0(%rsp), %rsi
callq 0x4c2d0
movq 0x290(%rsp), %rdi
addq $0xb0, %rdi
movq 0x1b0(%rsp), %rsi
callq 0xdae0
movq (%rax), %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rdi
movq 0x2a0(%rsp), %rsi
callq 0x4c2d0
movq 0x1a8(%rsp), %rdi
movq 0x1a0(%rsp), %rsi
movq 0x280(%rsp), %rdx
movq 0x288(%rsp), %rax
movl 0x78(%rax), %ecx
callq 0x43290
testb $0x1, %al
jne 0x4fa06
jmp 0x4fabd
movq 0x288(%rsp), %rax
cmpl $0x4, 0x78(%rax)
jl 0x4fa74
movq 0x475d5(%rip), %rdi     # 0x96ff0
leaq 0x2e877(%rip), %rsi     # 0x7e299
callq 0x8360
movq %rax, %rdi
movq 0x1b8(%rsp), %rsi
callq 0x8100
movq %rax, %rdi
leaq 0x2e877(%rip), %rsi     # 0x7e2b8
callq 0x8360
movq %rax, %rdi
movq 0x1b0(%rsp), %rsi
callq 0x8100
movq %rax, %rdi
leaq 0x2e86c(%rip), %rsi     # 0x7e2cc
callq 0x8360
movq %rax, %rdi
movq 0x47541(%rip), %rsi     # 0x96fb0
callq 0x83b0
movq 0x2a0(%rsp), %rdi
movq 0x298(%rsp), %rsi
movq 0x290(%rsp), %rdx
movq 0x1b8(%rsp), %rax
movl %eax, %ecx
movq 0x1b0(%rsp), %rax
movl %eax, %r8d
movl $0x1, %r9d
callq 0x43b50
movl 0x24c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24c(%rsp)
jmp 0x4fabf
movq 0x1b0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1b0(%rsp)
jmp 0x4f947
jmp 0x4fada
movq 0x1b8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1b8(%rsp)
jmp 0x4f921
jmp 0x4faf5
movl 0x254(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x254(%rsp)
movl 0x1f8(%rsp), %eax
addl 0x1f4(%rsp), %eax
movl %eax, 0x1fc(%rsp)
cmpl $0x0, 0x1fc(%rsp)
jl 0x4fb4e
movq 0x288(%rsp), %rax
testb $0x1, 0x5c(%rax)
je 0x4fb43
movl 0x250(%rsp), %eax
cmpl 0x1fc(%rsp), %eax
jge 0x4fb4e
movl $0x0, 0x254(%rsp)
leaq 0x250(%rsp), %rdi
leaq 0x1fc(%rsp), %rsi
callq 0x14d40
movl (%rax), %eax
movl %eax, 0x250(%rsp)
movq 0x258(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x258(%rsp)
jmp 0x4ece9
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r14
retq