// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/evo_findDiscordantPairsFromSAM.cpp
// Function: DiscordPairsFromSAMMain(int, char**)
int DiscordPairsFromSAMMain(int argc, char** argv) {
    parseDiscordPairsFromSAMOptions(argc, argv);
    string line; // for reading the input files
    
    std::istream* hetsFile = createReader(opt::hetsFile.c_str());
    std::ifstream* samFile = new std::ifstream(opt::samFile.c_str());
    
    std::ofstream* phaseSwitchFile = new std::ofstream("switches" + opt::runName + ".txt");
    std::ofstream* recombFile = new std::ofstream("recombMap" + opt::runName + ".txt");
    
    std::map<int,PhaseInfo*> posToPhase;
    std::map<string,std::vector<int>> infoPairNameToPos;
    std::map<string,std::vector<string>> infoPairNameToStrands;
    std::vector<int> phaseBlockSNPnums;
    
    std::map<string,std::vector<RecombRead*>> samNameToReads;
    int numHetPairs = 0;
    std::unordered_map<string, ReadLinkSNPpair*> SNPpairs;
    
    
    std::cout << "1) Processing hets..." << std::endl;
    if (opt::hapcutFormat) {
        int blockNum = 0;
        // Parse the Hapcut blocks file
        while (getline(*hetsFile, line)) {
            if (line[0] == '*') {
            
            } else if (line[0] == 'B' && line[1] == 'L') { // New block - should in the future separate the hets by blocks
                blockNum++; phaseBlockSNPnums.push_back(0);
            } else {
                std::vector<string> phasedSNPdetails = split(line, '\t');
                int snpPos = atoi(phasedSNPdetails[4].c_str());
                int H1phase = atoi(phasedSNPdetails[1].c_str());
                int H2phase = atoi(phasedSNPdetails[2].c_str());
                //std::cout << "line: " << line << std::endl;
                // std::cout << "phasedSNPdetails[5]: " << phasedSNPdetails[5] << std::endl;
                assert(phasedSNPdetails[5].length() == 1); assert(phasedSNPdetails[6].length() == 1);
                char refBase = phasedSNPdetails[5][0];
                char altBase = phasedSNPdetails[6][0];
                double phaseQual = stringToDouble(phasedSNPdetails[10].c_str());
                int snpCoverage = atoi(phasedSNPdetails[11].c_str());
                std::vector<char> phasedVars;
                if (H1phase == 0 && H2phase == 1) {
                    phasedVars.push_back(refBase); phasedVars.push_back(altBase);
                } else if (H1phase == 1 && H2phase == 0) {
                    phasedVars.push_back(altBase); phasedVars.push_back(refBase);
                } else{
                    continue;
                }
                PhaseInfo* thisPhase = new PhaseInfo(snpPos,phaseQual,snpCoverage, phasedVars,blockNum);
                posToPhase[snpPos] = thisPhase;
                phaseBlockSNPnums[blockNum-1]++;
            }
        }
        //maxBlockIndex = (int)std::distance(phaseBlockSNPnums.begin(),std::max_element(phaseBlockSNPnums.begin(), phaseBlockSNPnums.end()));
    } else {
        while (getline(*hetsFile, line)) {
            std::vector<string> phasedSNPdetails = split(line, '\t');
            int snpPos = atoi(phasedSNPdetails[1].c_str());
            assert(phasedSNPdetails[2].length() == 1); assert(phasedSNPdetails[3].length() == 1);
            char refBase = phasedSNPdetails[2][0];
            char altBase = phasedSNPdetails[3][0];
            
            std::vector<char> phasedVars;
            phasedVars.push_back(refBase); phasedVars.push_back(altBase);
            double phaseQual = 0; int snpCoverage = 0;
            PhaseInfo* thisPhase = new PhaseInfo(snpPos,phaseQual,snpCoverage, phasedVars, 1);
            posToPhase[snpPos] = thisPhase;
        }
        numHetPairs = nChoosek((int)posToPhase.size(),2);
    }
    
    
    
    std::cout << std::endl;
    std::cout << "2) Loading read-pairs... " << std::endl;
    // Now parse the samtools file to find reads that match records from the pairstools file
    // and therefore  can be informative about the phasing and recombination
    int readN = 0;
    std::vector<RecombRead*> informativeReads;
    while (getline(*samFile,line)) {
        // std::cerr << line << std::endl;
        readN++;
        std::vector<string> samRecVec = split(line, '\t'); //assert(pairVec.size() == 8);
        RecombRead* thisRead = new RecombRead(samRecVec);
        informativeReads.push_back(thisRead);
    }
    
    std::cout << std::endl;
    std::cout << "3) Linking read-pairs and hets... " << std::endl;
    int num0het = 0; int num1het = 0; int num2plusHets = 0;
    int totalUsedLength = 0;
    std::vector<RecombReadPair*> informativeReadPairs;
    for (int r = 0; r < informativeReads.size(); r=r+2) {
        RecombReadPair* thisReadPair = new RecombReadPair(informativeReads[r], informativeReads[r+1]);
        thisReadPair->findAndCombinePairHets(posToPhase);
        thisReadPair->filterHetsByQuality(opt::minBQ);
        
        if (thisReadPair->hetSites.size() == 0) {
            num0het++;
        } else if (thisReadPair->hetSites.size() == 1) {
            num1het++;
        } else {
            num2plusHets++;
        }
        
        if (thisReadPair->hetSites.size() > 1) {
            for (std::map<int, std::vector<int>>::iterator it = thisReadPair->read1->BlockIDsToHetPos.begin();
                 it != thisReadPair->read1->BlockIDsToHetPos.end(); it++) {
                if (thisReadPair->read2->BlockIDsToHetPos.count(it->first) == 1) {
                    informativeReadPairs.push_back(thisReadPair);
                    totalUsedLength += thisReadPair->read1->usedLength;
                    totalUsedLength += thisReadPair->read2->usedLength;
                }
            }
        }
    }
    
    std::cout << "Initial Read Pairs.size(): " << informativeReads.size()/2.0 << std::endl;
    std::cout << "num0het: " << num0het << std::endl;
    std::cout << "num1het: " << num1het << std::endl;
    std::cout << "num2plusHets: " << num2plusHets << std::endl;
    std::cout << "informativeReadPairs.size(): " << informativeReadPairs.size() << std::endl;
    std::cout << std::endl;
    
    std::cout << "4) Categorising concordant-discordant read-pairs... " << std::endl;
    int numConcordant = 0; int numDiscordant = 0;
    int numMatch = 0; int numMismatch = 0; long long int totalEffectiveLength = 0;
    std::vector<double> matchBaseScores; std::vector<double> mismatchBaseScores;
    std::vector<double> concordantBaseScores; std::vector<double> discordantBaseScores;
    std::vector<PhaseSwitch*> phaseSwitches;
    std::vector<std::vector<int>> phaseConcordanceCoords;
        
    
    std::vector<int> coveredHetPos;
    if (opt::hapcutFormat) {
        int readPairsProcessed = 0;
        for (int r = 0; r < informativeReadPairs.size(); r++) {
            readPairsProcessed++;
            
           for (int i = 0; i < informativeReadPairs[r]->hetSites.size(); i++) {
                HetInfo* thisHet = informativeReadPairs[r]->hetSites[i];
                if (thisHet->readPhaseBaseMismatch) {
                    numMismatch++;
                    mismatchBaseScores.push_back(thisHet->thisBaseQuality);
                } else {
                    // std::cout << "Fine: " << std::endl;
                     matchBaseScores.push_back(thisHet->thisBaseQuality);
                     numMatch++;
                }
               coveredHetPos.push_back(thisHet->pos);
            }
            
            // Now consider all HiC pairs i that map to the chromosome and cover a het at each end - lets call the physical locations of the hets x_i, y_i ( x < y) and let Z_i = 1 if they are in phase, 0 if out of phase (recombined)
            
            // Prod_i ((1-Z_i)(G(y_i)-G(x_i)) + Z_i*(1 -(G(y_i)-G(x_i))
            
            // std::vector<PhaseSwitch*> thisPairSwitches;
            std::vector<int> switchPairI; std::vector<int> switchPairJ;
            std::vector<int> concordPairI; std::vector<int> concordPairJ;
            for (int i = 0; i < informativeReadPairs[r]->hetSites.size() - 1; i++) {
                for (int j = 1; j < informativeReadPairs[r]->hetSites.size(); j++) {
                    if (informativeReadPairs[r]->hetSites[i]->phaseBlock == informativeReadPairs[r]->hetSites[j]->phaseBlock) {
                        int phaseI = informativeReadPairs[r]->hetSites[i]->thisHetPhase01;
                        int phaseJ = informativeReadPairs[r]->hetSites[j]->thisHetPhase01;
                        int iPos = informativeReadPairs[r]->hetSites[i]->pos;
                        int jPos = informativeReadPairs[r]->hetSites[j]->pos;
                        if (phaseI != phaseJ && abs(jPos - iPos) > opt::minDist) {
                            switchPairI.push_back(i); switchPairJ.push_back(j);
                            //int iPos = informativeReadPairs[r]->hetSites[i]->pos;
                            //int jPos = informativeReadPairs[r]->hetSites[j]->pos;
                            //int iQual = informativeReadPairs[r]->hetSites[i]->thisPhaseQuality;
                            //int jQual = informativeReadPairs[r]->hetSites[j]->thisPhaseQuality;
                            // PhaseSwitch* thisSwitch = new PhaseSwitch(iPos, jPos, iQual, jQual);
                            // thisPairSwitches.push_back(thisSwitch);
                        } else {
                            concordPairI.push_back(i); concordPairJ.push_back(j);
                        }
                    }
                }
            }
            
            // TO DO:
            // Select the 'right' switch pair if there are multiple options:
            // The shortest one? Needs more thought....
            if (switchPairI.size() > 0) {
                numDiscordant++;
                int iPos = informativeReadPairs[r]->hetSites[switchPairI[0]]->pos;
                int jPos = informativeReadPairs[r]->hetSites[switchPairJ[0]]->pos;
                int iQual = informativeReadPairs[r]->hetSites[switchPairI[0]]->thisPhaseQuality;
                int jQual = informativeReadPairs[r]->hetSites[switchPairJ[0]]->thisPhaseQuality;
                if (jPos - iPos < 0) {
                    int tmp = iPos; iPos = jPos; jPos = tmp;
                    tmp = iQual; iQual = jQual; jQual = tmp;
                }
                PhaseSwitch* thisSwitch = new PhaseSwitch(iPos, jPos, iQual, jQual);
                phaseSwitches.push_back(thisSwitch);
                switchPairI.empty(); switchPairJ.empty();
                totalEffectiveLength = totalEffectiveLength + (jPos - iPos);
                
            } else {
                numConcordant++;
                std::vector<int> thisConcordantCoords;
                int maxD = 0; int maxDindex = 0;
                for (int i = 0; i != concordPairI.size(); i++) {
                    int iPos = informativeReadPairs[r]->hetSites[concordPairI[i]]->pos;
                    int jPos = informativeReadPairs[r]->hetSites[concordPairJ[i]]->pos;
                    if (abs(jPos - iPos) > maxD) {
                        maxDindex = i;
                    }
                }
                int iPosDindex = informativeReadPairs[r]->hetSites[concordPairI[maxDindex]]->pos;
                int jPosDindex = informativeReadPairs[r]->hetSites[concordPairJ[maxDindex]]->pos;
                if (jPosDindex - iPosDindex < 0) {
                    int tmp = iPosDindex; iPosDindex = jPosDindex; jPosDindex = tmp;
                }
                
                int concordantPairDist = jPosDindex - iPosDindex;
                totalEffectiveLength = totalEffectiveLength + concordantPairDist;
                thisConcordantCoords.push_back(iPosDindex);
                thisConcordantCoords.push_back(jPosDindex);
                thisConcordantCoords.push_back(concordantPairDist);
                phaseConcordanceCoords.push_back(thisConcordantCoords);
            }
          /*  if (readPairsProcessed % 10000 == 0) {
                std::cout << "readPairsProcessed: " << readPairsProcessed << std::endl;
               // std::cout << "informativeReadPairs[r]->hetSites.size(): " << informativeReadPairs[r]->hetSites.size() << std::endl;
                std::cout << "phaseSwitches.size(): " << phaseSwitches.size() << std::endl;
                std::cout << "Effective coverage (bp): " << totalEffectiveLength << std::endl;
                std::cout << std::endl;
            } */
        }
        
        std::cout << "Effective coverage (bp): " << totalEffectiveLength << std::endl;
        std::cout << "numConcordant: " << numConcordant << std::endl;
        std::cout << "numDiscordant: " << numDiscordant << std::endl;
        std::cout << "phaseConcordanceCoords.size(): " << phaseConcordanceCoords.size() << std::endl;
        
        std::cout << "numMatch: " << numMatch << std::endl;
        std::cout << "numMismatch: " << numMismatch << std::endl;
        std::cout << "Mean mismatchBaseScores: " << vector_average(mismatchBaseScores) << std::endl;
        std::cout << "Mean matchBaseScores: " << vector_average(matchBaseScores) << std::endl;
        
        for (int i = 0; i != phaseSwitches.size(); i++) {
            *phaseSwitchFile << phaseSwitches[i]->posLeft << "\t" << phaseSwitches[i]->posRight << "\t" << phaseSwitches[i]->dist << "\t" << phaseSwitches[i]->phaseQualLeft << "\t" << phaseSwitches[i]->phaseQualRight << std::endl;
        }
        
        
        
        std::cout << std::endl;
        std::cout << "5) Making a genetic map... " << std::endl;
        std::sort(coveredHetPos.begin(), coveredHetPos.end());
        std::vector<int>::iterator it = std::unique(coveredHetPos.begin(), coveredHetPos.end());
        coveredHetPos.resize(distance(coveredHetPos.begin(),it));
        std::cout << "coveredHetPos.size() " << coveredHetPos.size() << std::endl;
        
        double meanRecombinationRate = (double)numDiscordant/(double)totalEffectiveLength;
        std::cout << "meanRecombinationRate " << meanRecombinationRate << std::endl;
        std::vector<double> recombFractions(coveredHetPos.size()+1, meanRecombinationRate);
        
        int numProcessedHets = 0;
        for (int i = 0; i != coveredHetPos.size() - 1; i++) {
            int left = coveredHetPos[i];
            int right = coveredHetPos[i + 1];
            //int distSNPs = (right - left) + 1;
            
            int coveringReadPairs = 0;
            
            double totalRecombFractionPerBP = 0;
            for (int j = 0; j != phaseSwitches.size(); j++) {
                if(phaseSwitches[j]->posLeft <= left && phaseSwitches[j]->posRight >= right){
                    coveringReadPairs++;
                    double recombFractionPerBP = (double)1.0/(double)phaseSwitches[j]->dist;
                    totalRecombFractionPerBP += recombFractionPerBP;
                }
            }
          //  std::cout << "totalRecombFraction: " << totalRecombFraction << std::endl;
            
            double totalConcordantFraction = 0;
            for (int j = 0; j != phaseConcordanceCoords.size(); j++) {
                if(phaseConcordanceCoords[j][0] <= left && phaseConcordanceCoords[j][1] >= right){
                    coveringReadPairs++;
                    //double concordPairFraction = (double)distSNPs/(double)(phaseConcordanceCoords[j][2]);
                    totalConcordantFraction++;
                }
            }
           // std::cout << "totalConcordantFraction: " << totalConcordantFraction << std::endl;
            
            if (coveringReadPairs > 10) {
                recombFractions[i+1] = totalRecombFractionPerBP/totalConcordantFraction;
            }
            
            numProcessedHets++;
            if (numProcessedHets % 10000 == 0) {
                std::cout << "numProcessedHets: " << numProcessedHets << " ("<< (double)numProcessedHets/coveredHetPos.size() << "%)"<< std::endl;
                std::cout << "pos: " << left << "bp"<< std::endl;
                
            }
            
        }
        
        *recombFile << "0\t" << coveredHetPos[0] << "\t" << recombFractions[0] << std::endl;
        for (int i = 1; i != coveredHetPos.size(); i++) {
            *recombFile << coveredHetPos[i-1] << "\t" << coveredHetPos[i] << "\t" << recombFractions[i] << std::endl;
        }
        //int chrSize = 0;
        //*recombFile << coveredHetPos.back() << "\t" <<  << "\t" << recombFractions[i] << std::endl;
        //print_vector(coveredHetPos, std::cout);
        
        
    } else {
        for (int r = 0; r < informativeReadPairs.size(); r++) {
            if (informativeReadPairs[r]->hetSites.size() > 1) {
                for (int i = 0; i < informativeReadPairs[r]->hetSites.size() - 1; i++) {
                    for (int j = 1; j < informativeReadPairs[r]->hetSites.size(); j++) {
                        char readBase1 = informativeReadPairs[r]->hetSites[i]->thisBase;
                        char readBase2 = informativeReadPairs[r]->hetSites[j]->thisBase;
                        int pos1 = informativeReadPairs[r]->hetSites[i]->pos;
                        int pos2 = informativeReadPairs[r]->hetSites[j]->pos;
                        string pairIndex = numToString(pos1)+"_"+numToString(pos2);
                        if (!SNPpairs.count(pairIndex)) {
                            SNPpairs[pairIndex] = new ReadLinkSNPpair(pos1,pos2,readBase1,readBase2);
                        } else {
                            SNPpairs[pairIndex]->base1.push_back(readBase1);
                            SNPpairs[pairIndex]->base1.push_back(readBase2);
                        }
                    }
                }
            }
        }
        std::cout << "SNPpairs.size(): " << SNPpairs.size() << std::endl;
        std::cout << "totalUsedLength: " << totalUsedLength << std::endl;
        std::cout << "totalUsedLength/(goodReadPairs.size()*300): " << (double)totalUsedLength/(double)(informativeReadPairs.size()*300) << std::endl;
    }
    
    return 0;
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
callq 0x91802
leaq 0x260(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x4f67f(%rip), %rsi     # 0xdf3f8
leaq 0x188(%rsp), %rdi
leaq 0x1c0(%rsp), %rdx
callq 0x21904
leaq 0x188(%rsp), %rdi
pushq $0x8
popq %rsi
callq 0x42587
movq %rax, 0x18(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x8978
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq 0x4f657(%rip), %rsi     # 0xdf418
pushq $0x8
popq %rdx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x8890
movl $0x200, %edi            # imm = 0x200
callq 0x8490
movq %rax, 0x100(%rsp)
leaq 0x21de0(%rip), %rsi     # 0xb1bca
leaq 0x4f647(%rip), %rdx     # 0xdf438
leaq 0x1c0(%rsp), %rdi
callq 0x5b784
leaq 0x1d020(%rip), %rdx     # 0xace25
leaq 0x188(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x28a29
leaq 0x188(%rsp), %rsi
pushq $0x10
popq %rdx
movq 0x100(%rsp), %rdi
callq 0x8900
leaq 0x188(%rsp), %rdi
callq 0x8978
leaq 0x1c0(%rsp), %rdi
callq 0x8978
movl $0x200, %edi            # imm = 0x200
callq 0x8490
movq %rax, 0xa8(%rsp)
leaq 0x2261f(%rip), %rsi     # 0xb2484
leaq 0x4f5cc(%rip), %rdx     # 0xdf438
leaq 0x1c0(%rsp), %rdi
callq 0x5b784
leaq 0x1cfa5(%rip), %rdx     # 0xace25
leaq 0x188(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x28a29
leaq 0x188(%rsp), %rsi
pushq $0x10
popq %rdx
movq 0xa8(%rsp), %rdi
callq 0x8900
leaq 0x188(%rsp), %rdi
callq 0x8978
leaq 0x1c0(%rsp), %rdi
callq 0x8978
leaq 0x1c8(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x380(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x350(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
andq $0x0, 0x240(%rsp)
leaq 0x320(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x230(%rsp)
leaq 0x1b8(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movupd %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movupd %xmm0, -0x8(%rax)
movq 0x4d03b(%rip), %rdi     # 0xdcfb8
leaq 0x2250a(%rip), %rsi     # 0xb248e
callq 0x8480
movq %rax, %rdi
callq 0x8230
cmpb $0x0, 0x4f4c0(%rip)     # 0xdf458
je 0x901c7
xorl %eax, %eax
leaq 0x20(%rsp), %rbp
leaq 0x2f8(%rsp), %r14
leaq 0x70(%rsp), %r13
movl %eax, %eax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x902e7
movq 0x250(%rsp), %rax
movzbl (%rax), %ecx
cmpl $0x42, %ecx
je 0x8fff4
cmpl $0x2a, %ecx
jne 0x8fffe
jmp 0x8ffb9
cmpb $0x4c, 0x1(%rax)
je 0x901a6
movq %rbp, %r15
movq %rbp, %rdi
leaq 0x250(%rsp), %rsi
pushq $0x9
popq %rdx
callq 0x40349
movq 0x20(%rsp), %rbx
movq 0x80(%rbx), %rdi
callq 0x86f0
movl %eax, 0x110(%rsp)
movq 0x20(%rbx), %rdi
callq 0x86f0
movl %eax, %r12d
movq 0x40(%rbx), %rdi
callq 0x86f0
cmpq $0x1, 0xa8(%rbx)
jne 0x914a4
cmpq $0x1, 0xc8(%rbx)
jne 0x914ad
movl %eax, %ebp
movq 0xa0(%rbx), %rax
movb (%rax), %al
movb %al, 0x150(%rsp)
movq 0xc0(%rbx), %rax
movb (%rax), %al
movb %al, 0xe0(%rsp)
movq 0x140(%rbx), %rsi
movq %r14, %rdi
movq %r13, %rdx
callq 0x21904
movq %r14, %rdi
callq 0x402aa
movsd %xmm0, 0xb0(%rsp)
movq %r14, %rdi
callq 0x8978
movq 0x20(%rsp), %rax
movq 0x160(%rax), %rdi
callq 0x86f0
movl %eax, %ebx
andq $0x0, 0x80(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movl %ebp, %eax
xorl $0x1, %eax
orl %r12d, %eax
je 0x900fb
xorl $0x1, %r12d
orl %ebp, %r12d
je 0x90118
movq %r13, %rdi
callq 0x55604
movq %r15, %rbp
movq %r15, %rdi
callq 0x28a08
jmp 0x8ffb9
movq %r13, %rdi
leaq 0x150(%rsp), %rsi
callq 0x5504a
leaq 0xe0(%rsp), %rsi
movq %r15, %rbp
jmp 0x90133
movq %r13, %rdi
leaq 0xe0(%rsp), %rsi
callq 0x5504a
leaq 0x150(%rsp), %rsi
movq %r15, %rbp
movq %r13, %rdi
callq 0x5504a
pushq $0x30
popq %rdi
callq 0x8490
movq %rax, %r12
movl 0x110(%rsp), %esi
movq %rax, %rdi
movsd 0xb0(%rsp), %xmm0
movl %ebx, %edx
movq %r13, %rcx
movq 0x8(%rsp), %r8
callq 0x8cc7a
leaq 0x1c0(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x8ccc8
movq %r12, (%rax)
movq 0x230(%rsp), %rax
movq 0x8(%rsp), %rcx
incl -0x4(%rax,%rcx,4)
movq %r13, %rdi
callq 0x55604
movq %rbp, %rdi
callq 0x28a08
jmp 0x8ffb9
andl $0x0, 0x20(%rsp)
leaq 0x230(%rsp), %rdi
movq %rbp, %rsi
callq 0x2c80c
movq 0x8(%rsp), %rax
incl %eax
jmp 0x8ffb2
leaq 0x250(%rsp), %r14
leaq 0x20(%rsp), %r15
leaq 0x70(%rsp), %r13
leaq 0x1c0(%rsp), %r12
leaq 0x110(%rsp), %rbx
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x902d8
movq %r15, %rdi
movq %r14, %rsi
pushq $0x9
popq %rdx
callq 0x40349
movq 0x20(%rsp), %rbp
movq 0x20(%rbp), %rdi
callq 0x86f0
movl %eax, 0x110(%rsp)
cmpq $0x1, 0x48(%rbp)
jne 0x9147c
cmpq $0x1, 0x68(%rbp)
jne 0x91485
movq 0x40(%rbp), %rax
movb (%rax), %al
movb %al, 0x150(%rsp)
movq 0x60(%rbp), %rax
movb (%rax), %al
movb %al, 0xe0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
movq %r13, %rdi
leaq 0x150(%rsp), %rsi
callq 0x5504a
movq %r13, %rdi
leaq 0xe0(%rsp), %rsi
callq 0x5504a
pushq $0x30
popq %rdi
callq 0x8490
movq %rax, %rbp
movl 0x110(%rsp), %esi
xorpd %xmm0, %xmm0
movq %rax, %rdi
xorl %edx, %edx
movq %r13, %rcx
pushq $0x1
popq %r8
callq 0x8cc7a
movq %r12, %rdi
movq %rbx, %rsi
callq 0x8ccc8
movq %rbp, (%rax)
movq %r13, %rdi
callq 0x55604
movq %r15, %rdi
callq 0x28a08
jmp 0x901e9
movl 0x1e8(%rsp), %edi
pushq $0x2
popq %rsi
callq 0x797ea
movq 0x4ccca(%rip), %rdi     # 0xdcfb8
callq 0x8230
movq 0x4ccbe(%rip), %rdi     # 0xdcfb8
leaq 0x221f0(%rip), %rsi     # 0xb24f1
callq 0x8480
movq %rax, %rdi
callq 0x8230
xorpd %xmm0, %xmm0
leaq 0xe0(%rsp), %rbx
movapd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x250(%rsp), %r14
leaq 0x20(%rsp), %r12
pushq $0x9
popq %r15
leaq 0x2e0(%rsp), %r13
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x903ac
movq %r12, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x40349
movl $0x150, %edi            # imm = 0x150
callq 0x8490
movq %rax, %rbp
movq %r13, %rdi
movq %r12, %rsi
callq 0x297dc
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8cd16
movq %r13, %rdi
callq 0x28a08
movq %rbp, 0x70(%rsp)
movq %rbx, %rdi
leaq 0x70(%rsp), %rsi
callq 0x8d01c
movq %r12, %rdi
callq 0x28a08
jmp 0x9033c
movq 0x4cc05(%rip), %rdi     # 0xdcfb8
callq 0x8230
movq 0x4cbf9(%rip), %rdi     # 0xdcfb8
leaq 0x22145(%rip), %rsi     # 0xb250b
callq 0x8480
movq %rax, %rdi
callq 0x8230
xorpd %xmm0, %xmm0
leaq 0x90(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorl %r15d, %r15d
movl $0x120, %r14d           # imm = 0x120
leaq 0x20(%rsp), %r13
movl $0x0, 0x8(%rsp)
xorl %r12d, %r12d
movl $0x0, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movq 0xe0(%rsp), %rbx
movq 0xe8(%rsp), %rax
subq %rbx, %rax
sarq $0x3, %rax
cmpq %r15, %rax
jbe 0x90557
pushq $0x30
popq %rdi
callq 0x8490
movq (%rbx,%r15,8), %rcx
movq 0x8(%rbx,%r15,8), %rdx
andq $0x0, 0x28(%rax)
cmpq %rdx, %rcx
movq %rdx, %rsi
cmovbq %rcx, %rsi
cmovbq %rdx, %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rax)
movq %rsi, (%rax)
movq %rcx, 0x8(%rax)
movq %rax, 0x20(%rsp)
movq %rax, %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x8f514
movq 0x20(%rsp), %rdi
movl 0x4d1af(%rip), %esi     # 0xdd634
callq 0x8f5a4
movq 0x20(%rsp), %rbp
movq 0x20(%rbp), %rax
subq 0x18(%rbp), %rax
sarq $0x3, %rax
cmpq $0x1, %rax
je 0x904af
testq %rax, %rax
jne 0x904b8
incl 0x18(%rsp)
jmp 0x9054e
incl 0x10(%rsp)
jmp 0x9054e
incl %r12d
cmpq $0x2, %rax
jb 0x9054e
movl %r12d, 0xb0(%rsp)
movq (%rbp), %r12
movq 0x138(%r12), %rbx
addq $0x128, %r12            # imm = 0x128
cmpq %r12, %rbx
je 0x90546
movq 0x8(%rbp), %rdi
addq %r14, %rdi
leaq 0x20(%rbx), %rsi
callq 0x8f80c
cmpq $0x1, %rax
jne 0x90530
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x8d0d0
movq 0x20(%rsp), %rbp
movq (%rbp), %r12
movq 0x8(%rbp), %rax
movl 0x8(%rsp), %ecx
addl 0x100(%r12), %ecx
addl 0x100(%rax), %ecx
movl %ecx, 0x8(%rsp)
jmp 0x90539
movq 0x20(%rsp), %rbp
movq (%rbp), %r12
movq %rbx, %rdi
callq 0x8340
movq %rax, %rbx
jmp 0x904d9
movl 0xb0(%rsp), %r12d
addq $0x2, %r15
jmp 0x90411
movq 0x4ca5a(%rip), %rdi     # 0xdcfb8
leaq 0x21fc9(%rip), %rsi     # 0xb252e
callq 0x8480
movq 0xe8(%rsp), %rcx
subq 0xe0(%rsp), %rcx
sarq $0x3, %rcx
movq %rcx, %xmm1
punpckldq 0x1cb5(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1cbd(%rip), %xmm1     # 0x92250
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x7059(%rip), %xmm0     # 0x97600
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
movq 0x4c9fa(%rip), %rdi     # 0xdcfb8
leaq 0x21712(%rip), %rsi     # 0xb1cd7
callq 0x8480
movq %rax, %rdi
movl 0x18(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4c9d3(%rip), %rdi     # 0xdcfb8
leaq 0x216f5(%rip), %rsi     # 0xb1ce1
callq 0x8480
movq %rax, %rdi
movl 0x10(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4c9ac(%rip), %rdi     # 0xdcfb8
leaq 0x216d8(%rip), %rsi     # 0xb1ceb
callq 0x8480
movq %rax, %rdi
movl %r12d, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4c986(%rip), %rdi     # 0xdcfb8
leaq 0x21f11(%rip), %rsi     # 0xb254a
callq 0x8480
movq 0x98(%rsp), %rsi
subq 0x90(%rsp), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x8320
movq %rax, %rdi
callq 0x8230
movq 0x4c94f(%rip), %rdi     # 0xdcfb8
callq 0x8230
movq 0x4c943(%rip), %rdi     # 0xdcfb8
leaq 0x21eec(%rip), %rsi     # 0xb2568
callq 0x8480
movq %rax, %rdi
callq 0x8230
andq $0x0, 0x220(%rsp)
xorpd %xmm0, %xmm0
andq $0x0, 0x200(%rsp)
movapd %xmm0, 0x210(%rsp)
andq $0x0, 0x2a0(%rsp)
movapd %xmm0, 0x1f0(%rsp)
andq $0x0, 0x280(%rsp)
movapd %xmm0, 0x290(%rsp)
andq $0x0, 0xd0(%rsp)
movapd %xmm0, 0x270(%rsp)
andq $0x0, 0x180(%rsp)
movapd %xmm0, 0xc0(%rsp)
andq $0x0, 0x50(%rsp)
movapd %xmm0, 0x170(%rsp)
movapd %xmm0, 0x40(%rsp)
cmpb $0x0, 0x4ed4c(%rip)     # 0xdf458
je 0x90ae7
xorl %r14d, %r14d
leaq 0x110(%rsp), %r12
leaq 0x130(%rsp), %r13
leaq 0x4(%rsp), %rbx
movq $0x0, 0x8(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x90ce2
xorl %ebp, %ebp
movq (%rax,%r14,8), %rdx
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rbp, %rdx
jbe 0x907fb
movq (%rcx,%rbp,8), %r15
cmpb $0x1, 0x24(%r15)
jne 0x907bc
cvtsi2sdl 0xc(%r15), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x1f0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2af10
incl 0x18(%rsp)
jmp 0x907de
cvtsi2sdl 0xc(%r15), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x210(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2af10
incl 0x10(%rsp)
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x3aca4
incq %rbp
movq 0x90(%rsp), %rax
jmp 0x90775
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movapd %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
movapd %xmm0, 0x110(%rsp)
andq $0x0, 0x120(%rsp)
movapd %xmm0, 0x150(%rsp)
andq $0x0, 0x160(%rsp)
movq (%rax,%r14,8), %rdx
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdx
xorl %esi, %esi
movl %esi, 0x130(%rsp)
movslq %esi, %rsi
movq %rdx, %rdi
subq %rcx, %rdi
sarq $0x3, %rdi
decq %rdi
cmpq %rsi, %rdi
jbe 0x90918
pushq $0x1
popq %rsi
movl %esi, 0x4(%rsp)
movslq %esi, %rsi
movq %rdx, %rdi
subq %rcx, %rdi
sarq $0x3, %rdi
cmpq %rsi, %rdi
jbe 0x9090a
movslq 0x130(%rsp), %rax
movq (%rcx,%rax,8), %rax
movl 0x4(%rax), %edx
movq (%rcx,%rsi,8), %rcx
cmpl 0x4(%rcx), %edx
jne 0x908eb
movl 0x20(%rax), %edx
cmpl 0x20(%rcx), %edx
je 0x908d0
movl (%rcx), %ecx
subl (%rax), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl 0x4cd7e(%rip), %eax     # 0xdd638
jle 0x908d0
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x3aca4
leaq 0x70(%rsp), %rdi
jmp 0x908e3
movq %r12, %rdi
movq %r13, %rsi
callq 0x3aca4
leaq 0x150(%rsp), %rdi
movq %rbx, %rsi
callq 0x3aca4
movl 0x4(%rsp), %esi
incl %esi
movq 0x90(%rsp), %rax
movq (%rax,%r14,8), %rdx
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdx
jmp 0x9086f
movl 0x130(%rsp), %esi
incl %esi
jmp 0x9084c
movq 0x20(%rsp), %rdx
cmpq %rdx, 0x28(%rsp)
je 0x909b7
movslq (%rdx), %rax
movq (%rcx,%rax,8), %rax
movl (%rax), %edx
movq 0x70(%rsp), %rsi
movslq (%rsi), %rsi
movq (%rcx,%rsi,8), %rcx
movl (%rcx), %r15d
movsd 0x18(%rcx), %xmm0
movhpd 0x18(%rax), %xmm0       # xmm0 = xmm0[0],mem[0]
cvttpd2dq %xmm0, %xmm0
movl %edx, %ebp
cmpl %edx, %r15d
cmovll %r15d, %ebp
cmovll %edx, %r15d
jl 0x90962
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movdqa %xmm0, 0xb0(%rsp)
pushq $0x20
popq %rdi
callq 0x8490
cvtdq2pd 0xb0(%rsp), %xmm0
movl %ebp, (%rax)
movl %r15d, 0x4(%rax)
movdqu %xmm0, 0x8(%rax)
subl %ebp, %r15d
movl %r15d, %ecx
negl %ecx
cmovsl %r15d, %ecx
movl %ecx, 0x18(%rax)
movq %rax, 0x130(%rsp)
leaq 0xc0(%rsp), %rdi
movq %r13, %rsi
callq 0x8d0ee
incl 0x68(%rsp)
jmp 0x90aae
andq $0x0, 0x140(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x130(%rsp)
movq 0x110(%rsp), %rcx
movq 0x118(%rsp), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
xorl %edi, %edi
movq 0x150(%rsp), %rdx
xorl %r8d, %r8d
cmpq %rdi, %rsi
je 0x90a1e
movq (%rax,%r14,8), %r9
movslq (%rcx,%rdi,4), %r10
movq 0x18(%r9), %r9
movq (%r9,%r10,8), %r10
movslq (%rdx,%rdi,4), %r11
movq (%r9,%r11,8), %r9
movl (%r9), %r9d
cmpl (%r10), %r9d
je 0x90a19
movl %edi, %r8d
incq %rdi
jmp 0x909f1
movq (%rax,%r14,8), %rax
movslq %r8d, %rsi
movslq (%rcx,%rsi,4), %rcx
movq 0x18(%rax), %rax
movq (%rax,%rcx,8), %rcx
movl (%rcx), %r15d
movl %r15d, 0x4(%rsp)
movslq (%rdx,%rsi,4), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movl %eax, 0x6c(%rsp)
cmpl %r15d, %eax
jge 0x90a59
movl %eax, 0x4(%rsp)
movl %r15d, 0x6c(%rsp)
movl %eax, %ecx
jmp 0x90a5f
movl %r15d, %ecx
movl %eax, %r15d
subl %ecx, %r15d
movl %r15d, 0x10c(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3aca4
movq %r13, %rdi
leaq 0x6c(%rsp), %rsi
callq 0x3aca4
movq %r13, %rdi
leaq 0x10c(%rsp), %rsi
callq 0x3aca4
leaq 0x170(%rsp), %rdi
movq %r13, %rsi
callq 0x3b5c4
incl 0x64(%rsp)
movq %r13, %rdi
callq 0x2aef2
movslq %r15d, %rax
addq %rax, 0x8(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x2aef2
movq %r12, %rdi
callq 0x2aef2
leaq 0x70(%rsp), %rdi
callq 0x2aef2
leaq 0x20(%rsp), %rdi
callq 0x2aef2
incq %r14
jmp 0x90753
movq 0x90(%rsp), %rax
xorl %edi, %edi
leaq 0x110(%rsp), %rbx
leaq 0x70(%rsp), %r12
movq 0x98(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rdi, %rcx
jbe 0x912e0
movq (%rax,%rdi,8), %rcx
movq 0x20(%rcx), %rdx
subq 0x18(%rcx), %rdx
cmpq $0x9, %rdx
jb 0x90cda
movq (%rax,%rdi,8), %rdx
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdx
xorl %r8d, %r8d
movq %rdi, 0xb0(%rsp)
subq %rcx, %rdx
sarq $0x3, %rdx
decq %rdx
cmpq %r8, %rdx
jbe 0x90cda
pushq $0x1
popq %r15
movq %r8, 0x10(%rsp)
movq (%rax,%rdi,8), %rdx
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
cmpq %r15, %rsi
jbe 0x90cd2
movq (%rcx,%r8,8), %rax
movb 0x8(%rax), %dl
movb %dl, 0x130(%rsp)
movq %r15, 0x18(%rsp)
movq (%rcx,%r15,8), %rcx
movb 0x8(%rcx), %dl
movb %dl, 0x4(%rsp)
movl (%rax), %r14d
movl (%rcx), %ebp
movq %rbx, %rdi
movl %r14d, %esi
callq 0x28ad3
movq %r12, %rdi
movq %rbx, %r13
movq %rbx, %rsi
leaq 0x12c00(%rip), %rdx     # 0xa37bc
callq 0x28a29
leaq 0x150(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x28ad3
leaq 0x20(%rsp), %r12
movq %r12, %rdi
leaq 0x70(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x28a48
movq %r15, %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8978
movq %r13, %rdi
callq 0x8978
leaq 0x188(%rsp), %rdi
movq %r12, %rsi
callq 0x8e350
testq %rax, %rax
je 0x90c63
leaq 0x188(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8e434
movq (%rax), %rdi
addq $0x8, %rdi
leaq 0x130(%rsp), %rsi
callq 0x5504a
leaq 0x188(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8e434
movq (%rax), %rdi
addq $0x8, %rdi
leaq 0x4(%rsp), %rsi
callq 0x5504a
jmp 0x90c9e
pushq $0x38
popq %rdi
callq 0x8490
movq %rax, %rbx
movsbl 0x130(%rsp), %ecx
movsbl 0x4(%rsp), %r8d
movq %rax, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x8d10c
leaq 0x188(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x8e434
movq %rbx, (%rax)
leaq 0x20(%rsp), %rdi
callq 0x8978
movq 0x18(%rsp), %r15
incq %r15
movq 0x90(%rsp), %rax
movq 0xb0(%rsp), %rdi
movq %r13, %rbx
leaq 0x70(%rsp), %r12
movq 0x10(%rsp), %r8
jmp 0x90b5f
incq %r8
jmp 0x90b43
incq %rdi
jmp 0x90afe
movq 0x4c2cf(%rip), %rdi     # 0xdcfb8
leaq 0x218ad(%rip), %rsi     # 0xb259d
callq 0x8480
movq 0x8(%rsp), %r15
movl 0x68(%rsp), %ebp
movq %rax, %rdi
movq %r15, %rsi
callq 0x81b0
movq %rax, %rdi
callq 0x8230
movq 0x4c2a0(%rip), %rdi     # 0xdcfb8
leaq 0x20fdb(%rip), %rsi     # 0xb1cfa
callq 0x8480
movq %rax, %rdi
movl 0x64(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4c279(%rip), %rdi     # 0xdcfb8
leaq 0x20fc4(%rip), %rsi     # 0xb1d0a
callq 0x8480
movq %rax, %rdi
movl %ebp, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4c254(%rip), %rdi     # 0xdcfb8
leaq 0x2184c(%rip), %rsi     # 0xb25b7
callq 0x8480
movq %rax, %rdi
movq 0x178(%rsp), %rax
subq 0x170(%rsp), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x8320
movq %rax, %rdi
callq 0x8230
movq 0x4c216(%rip), %rdi     # 0xdcfb8
leaq 0x20f71(%rip), %rsi     # 0xb1d1a
callq 0x8480
movq %rax, %rdi
movl 0x10(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4c1ef(%rip), %rdi     # 0xdcfb8
leaq 0x20f55(%rip), %rsi     # 0xb1d25
callq 0x8480
movq %rax, %rdi
movl 0x18(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4c1c8(%rip), %rdi     # 0xdcfb8
leaq 0x20f3c(%rip), %rsi     # 0xb1d33
callq 0x8480
movq %rax, %rbx
leaq 0x2c8(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0x2f816
leaq 0x2c8(%rsp), %rdi
callq 0x2f7e9
movq %rbx, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x2c8(%rsp), %rdi
callq 0x2b43c
movq 0x4c173(%rip), %rdi     # 0xdcfb8
leaq 0x20f01(%rip), %rsi     # 0xb1d4d
callq 0x8480
movq %rax, %rbx
leaq 0x2b0(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x2f816
leaq 0x2b0(%rsp), %rdi
callq 0x2f7e9
movq %rbx, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x2b0(%rsp), %rdi
callq 0x2b43c
xorl %r14d, %r14d
leaq 0x8f81(%rip), %rbx      # 0x99e1e
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r14
je 0x90f6c
movq (%rax,%r14,8), %rax
movl (%rax), %esi
movq 0x100(%rsp), %rdi
callq 0x8840
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8480
movq 0xc0(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8480
movq 0xc0(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
movl 0x18(%rcx), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8480
movq 0xc0(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
movsd 0x8(%rcx), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8480
movq 0xc0(%rsp), %rcx
movq (%rcx,%r14,8), %rcx
movsd 0x10(%rcx), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
incq %r14
jmp 0x90e9d
movq 0x4c045(%rip), %rdi     # 0xdcfb8
callq 0x8230
movq 0x4c039(%rip), %rdi     # 0xdcfb8
leaq 0x21651(%rip), %rsi     # 0xb25d7
callq 0x8480
movq %rax, %rdi
callq 0x8230
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x45b51
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x45f51
leaq 0x40(%rsp), %rdi
subq (%rdi), %rax
sarq $0x2, %rax
movq %rax, %rsi
callq 0x43aec
movq 0x4bfec(%rip), %rdi     # 0xdcfb8
leaq 0x21620(%rip), %rsi     # 0xb25f3
callq 0x8480
movq 0x48(%rsp), %rsi
subq 0x40(%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x8320
movq %rax, %rdi
callq 0x8230
cvtsi2sd %ebp, %xmm0
cvtsi2sd %r15, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x4bfa8(%rip), %rdi     # 0xdcfb8
leaq 0x215f2(%rip), %rsi     # 0xb2609
callq 0x8480
movsd 0x70(%rsp), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
movq 0x48(%rsp), %rsi
subq 0x40(%rsp), %rsi
sarq $0x2, %rsi
incq %rsi
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rdx
leaq 0x110(%rsp), %rcx
callq 0x4381e
xorl %ecx, %ecx
movl $0x2710, %r12d          # imm = 0x2710
movq 0x4bf4f(%rip), %rbx     # 0xdcfb8
leaq 0xcf08(%rip), %r13      # 0x9df78
leaq 0x150a5(%rip), %rbp     # 0xa611c
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
decq %rdx
cmpq %rcx, %rdx
je 0x9120c
movl (%rax,%rcx,4), %r15d
movl 0x4(%rax,%rcx,4), %esi
leaq 0x1(%rcx), %r14
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
xorpd %xmm0, %xmm0
xorl %r8d, %r8d
xorl %edi, %edi
cmpq %r8, %rdx
je 0x910f1
movq (%rax,%r8,8), %r9
cmpl %r15d, (%r9)
jg 0x910ec
cmpl %esi, 0x4(%r9)
jl 0x910ec
cvtsi2sdl 0x18(%r9), %xmm1
incl %edi
movsd 0x650c(%rip), %xmm2     # 0x975f0
divsd %xmm1, %xmm2
addsd %xmm2, %xmm0
incq %r8
jmp 0x910c0
movq 0x170(%rsp), %r8
movq 0x178(%rsp), %rax
subq %r8, %rax
cqto
pushq $0x18
popq %r9
idivq %r9
xorpd %xmm1, %xmm1
subq $0x1, %rax
jb 0x91134
movq (%r8), %rdx
cmpl %r15d, (%rdx)
jg 0x9112e
cmpl %esi, 0x4(%rdx)
jl 0x9112e
incl %edi
addsd 0x64c2(%rip), %xmm1     # 0x975f0
addq $0x18, %r8
jmp 0x91111
cmpl $0xa, %edi
jle 0x91148
divsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
movsd %xmm0, 0x8(%rax,%rcx,8)
movl %r14d, %eax
xorl %edx, %edx
divl %r12d
movq %r14, %rcx
testl %edx, %edx
jne 0x91077
movq %rbx, %rdi
leaq 0x214bb(%rip), %rsi     # 0xb2620
callq 0x8480
movq %rax, %rdi
movl %r14d, %esi
callq 0x8840
movq %rax, %rdi
leaq 0x106c4(%rip), %rsi     # 0xa1843
callq 0x8480
cvtsi2sd %r14d, %xmm0
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
sarq $0x2, %rcx
movq %rcx, %xmm1
punpckldq 0x109c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x10a4(%rip), %xmm1     # 0x92250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
leaq 0x1684e(%rip), %rsi     # 0xa7a1c
callq 0x8480
movq %rax, %rdi
callq 0x8230
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8480
movq %rax, %rdi
movl %r15d, %esi
callq 0x8840
movq %rax, %rdi
movq %rbp, %rsi
callq 0x8480
movq %rax, %rdi
callq 0x8230
movq %r14, %rcx
jmp 0x91077
leaq 0x1bc51(%rip), %rsi     # 0xace64
movq 0xa8(%rsp), %rdi
callq 0x8480
movq 0x40(%rsp), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x8840
leaq 0x8be8(%rip), %rsi      # 0x99e1e
movq %rax, %rdi
callq 0x8480
movq 0x20(%rsp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
pushq $0x1
popq %r14
leaq 0x8bbc(%rip), %rbx      # 0x99e1e
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rcx, %r14
je 0x912d1
movl -0x4(%rax,%r14,4), %esi
movq 0xa8(%rsp), %rdi
callq 0x8840
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8480
movq 0x40(%rsp), %rcx
movl (%rcx,%r14,4), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
movq %rbx, %rsi
callq 0x8480
movq 0x20(%rsp), %rcx
movsd (%rcx,%r14,8), %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
incq %r14
jmp 0x91262
leaq 0x20(%rsp), %rdi
callq 0x2b43c
jmp 0x9139b
movq 0x4bcd1(%rip), %rdi     # 0xdcfb8
leaq 0x20a76(%rip), %rsi     # 0xb1d64
callq 0x8480
movl 0x8(%rsp), %ebx
movq 0x1a0(%rsp), %rsi
movq %rax, %rdi
callq 0x8320
movq %rax, %rdi
callq 0x8230
movq 0x4bca2(%rip), %rdi     # 0xdcfb8
leaq 0x20a72(%rip), %rsi     # 0xb1d8f
callq 0x8480
movq %rax, %rdi
movl %ebx, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x4bc7d(%rip), %rdi     # 0xdcfb8
leaq 0x20a5f(%rip), %rsi     # 0xb1da1
callq 0x8480
cvtsi2sd %ebx, %xmm0
movq 0x98(%rsp), %rcx
subq 0x90(%rsp), %rcx
sarq $0x3, %rcx
imulq $0x12c, %rcx, %rcx      # imm = 0x12C
movq %rcx, %xmm1
punpckldq 0xecd(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xed5(%rip), %xmm1      # 0x92250
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq %rax, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x40(%rsp), %rdi
callq 0x2aef2
leaq 0x170(%rsp), %rdi
callq 0x3b73c
leaq 0xc0(%rsp), %rdi
callq 0x8e1d8
leaq 0x270(%rsp), %rdi
callq 0x2b43c
leaq 0x290(%rsp), %rdi
callq 0x2b43c
leaq 0x1f0(%rsp), %rdi
callq 0x2b43c
leaq 0x210(%rsp), %rdi
callq 0x2b43c
leaq 0x90(%rsp), %rdi
callq 0x8dc3a
leaq 0xe0(%rsp), %rdi
callq 0x8d3da
leaq 0x188(%rsp), %rdi
callq 0x8d2a2
leaq 0x318(%rsp), %rdi
callq 0x8d360
leaq 0x230(%rsp), %rdi
callq 0x2aef2
leaq 0x348(%rsp), %rdi
callq 0x32f44
leaq 0x378(%rsp), %rdi
callq 0x3c43a
leaq 0x1c0(%rsp), %rdi
callq 0x8d40e
leaq 0x250(%rsp), %rdi
callq 0x8978
xorl %eax, %eax
addq $0x3a8, %rsp            # imm = 0x3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x207e1(%rip), %rdi     # 0xb1c64
jmp 0x9148c
leaq 0x207fa(%rip), %rdi     # 0xb1c86
leaq 0x21011(%rip), %rsi     # 0xb24a4
leaq 0x2102d(%rip), %rcx     # 0xb24c7
movl $0x84, %edx
callq 0x82f0
leaq 0x20736(%rip), %rdi     # 0xb1be1
jmp 0x914b4
leaq 0x2078e(%rip), %rdi     # 0xb1c42
leaq 0x20fe9(%rip), %rsi     # 0xb24a4
leaq 0x21005(%rip), %rcx     # 0xb24c7
pushq $0x6d
popq %rdx
callq 0x82f0
jmp 0x915ff
jmp 0x916d1
movq %rax, %r14
pushq $0x30
popq %rsi
movq %r12, %rdi
jmp 0x915f4
movq %rax, %r14
leaq 0x2b0(%rsp), %rdi
jmp 0x9168e
movq %rax, %r14
leaq 0x2c8(%rsp), %rdi
jmp 0x9168e
movq %rax, %r14
leaq 0x188(%rsp), %rdi
callq 0x8978
jmp 0x91517
movq %rax, %r14
leaq 0x1c0(%rsp), %rdi
callq 0x8978
jmp 0x91529
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0xa8(%rsp), %rdi
jmp 0x9157f
jmp 0x915a0
movq %rax, %r14
leaq 0x188(%rsp), %rdi
callq 0x8978
jmp 0x9154f
movq %rax, %r14
leaq 0x1c0(%rsp), %rdi
callq 0x8978
jmp 0x91561
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0x100(%rsp), %rdi
jmp 0x9157f
jmp 0x915a0
movq %rax, %r14
movl $0x208, %esi            # imm = 0x208
movq 0x10(%rsp), %rdi
callq 0x84a0
jmp 0x917ed
jmp 0x915a0
movq %rax, %r14
leaq 0x188(%rsp), %rdi
callq 0x8978
jmp 0x917ed
movq %rax, %r14
jmp 0x917ed
jmp 0x916d1
jmp 0x9164e
jmp 0x9164e
jmp 0x91686
jmp 0x916d1
jmp 0x9166a
jmp 0x916d1
jmp 0x915ff
jmp 0x916d1
movq %rax, %r14
leaq 0x2f8(%rsp), %rdi
callq 0x8978
jmp 0x9165b
movq %rax, %r14
jmp 0x9165b
jmp 0x915ff
movq %rax, %r14
pushq $0x30
popq %rsi
movq %rbp, %rdi
callq 0x84a0
jmp 0x91651
jmp 0x915ff
jmp 0x915ff
movq %rax, %r14
jmp 0x9179f
jmp 0x916a0
jmp 0x916ed
movq %rax, %r14
leaq 0x130(%rsp), %rdi
callq 0x2aef2
jmp 0x916f0
movq %rax, %r14
leaq 0x2e0(%rsp), %rdi
callq 0x28a08
jmp 0x9163b
movq %rax, %r14
movl $0x150, %esi            # imm = 0x150
movq %rbp, %rdi
callq 0x84a0
jmp 0x91677
jmp 0x9166a
jmp 0x9164e
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x55604
leaq 0x20(%rsp), %rdi
callq 0x28a08
jmp 0x9179f
movq %rax, %r14
jmp 0x91792
jmp 0x91686
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x28a08
jmp 0x91792
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x2b43c
jmp 0x9172d
jmp 0x916a0
jmp 0x916d1
jmp 0x916d1
jmp 0x916d1
movq %rax, %r14
jmp 0x91785
jmp 0x916d1
movq %rax, %r14
pushq $0x38
popq %rsi
movq %rbx, %rdi
callq 0x84a0
jmp 0x91723
movq %rax, %r14
jmp 0x916e3
movq %rax, %r14
leaq 0x150(%rsp), %rdi
callq 0x8978
jmp 0x916d9
movq %rax, %r14
jmp 0x9172d
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x8978
leaq 0x110(%rsp), %rdi
jmp 0x91728
movq %rax, %r14
leaq 0x150(%rsp), %rdi
callq 0x2aef2
leaq 0x110(%rsp), %rdi
callq 0x2aef2
leaq 0x70(%rsp), %rdi
callq 0x2aef2
leaq 0x20(%rsp), %rdi
callq 0x2aef2
jmp 0x9172d
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x8978
leaq 0x40(%rsp), %rdi
callq 0x2aef2
leaq 0x170(%rsp), %rdi
callq 0x3b73c
leaq 0xc0(%rsp), %rdi
callq 0x8e1d8
leaq 0x270(%rsp), %rdi
callq 0x2b43c
leaq 0x290(%rsp), %rdi
callq 0x2b43c
leaq 0x1f0(%rsp), %rdi
callq 0x2b43c
leaq 0x210(%rsp), %rdi
callq 0x2b43c
leaq 0x90(%rsp), %rdi
callq 0x8dc3a
leaq 0xe0(%rsp), %rdi
callq 0x8d3da
leaq 0x188(%rsp), %rdi
callq 0x8d2a2
leaq 0x318(%rsp), %rdi
callq 0x8d360
leaq 0x230(%rsp), %rdi
callq 0x2aef2
leaq 0x348(%rsp), %rdi
callq 0x32f44
leaq 0x378(%rsp), %rdi
callq 0x3c43a
leaq 0x1c0(%rsp), %rdi
callq 0x8d40e
leaq 0x250(%rsp), %rdi
callq 0x8978
movq %r14, %rdi
callq 0x8870