// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/evo_findDiscordantPairs.cpp
// Function: DiscordPairsMain(int, char**)
int DiscordPairsMain(int argc, char** argv) {
    parseDiscordPairsOptions(argc, argv);
    string line; // for reading the input files
    
    std::istream* hetsFile = createReader(opt::hetsFile.c_str());
    std::ifstream* pairtoolsFile = new std::ifstream(opt::pairtoolsFile.c_str());
    std::ifstream* samFile = new std::ifstream(opt::samFile.c_str());
    
    std::ofstream* phaseSwitchFile = new std::ofstream("switches" + opt::runName + ".txt");
    std::ofstream* goodReadPairsFile = new std::ofstream("goodReadPairs" + opt::runName + ".txt");
    
    std::map<int,PhaseInfo*> positionToPhase;
    std::map<string,std::vector<int>> infoPairNameToPos;
    std::map<string,std::vector<string>> infoPairNameToStrands;
    
    std::map<string,std::vector<RecombRead*>> samNameToReads;
    int numHetPairs = 0;
    std::unordered_map<string, ReadLinkSNPpair*> SNPpairs;
    
    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++;
            } 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);
                positionToPhase[snpPos] = thisPhase;
            }
        }
    } 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);
            positionToPhase[snpPos] = thisPhase;
        }
        numHetPairs = nChoosek((int)positionToPhase.size(),2);
    }
    
    
    
    // Now parse the pairtools file to record the exact readpairs
    while (getline(*pairtoolsFile,line)) {
        // std::cerr << line << std::endl;
        std::vector<string> pairVec = split(line, '\t'); assert(pairVec.size() == 8);
        
        string pairName = pairVec[0];
        int pair1pos = atoi(pairVec[2].c_str());
        int pair2pos = atoi(pairVec[4].c_str());
        std::vector<int> bothPos; bothPos.push_back(pair1pos); bothPos.push_back(pair2pos);
        infoPairNameToPos[pairName] = bothPos;
        
        string pair1strand = pairVec[5];
        string pair2strand = pairVec[6];
        std::vector<string> bothStrands; bothStrands.push_back(pair1strand); bothStrands.push_back(pair1strand);
        infoPairNameToStrands[pairName] = bothStrands;
    }
    
    
    // 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
    while (getline(*samFile,line)) {
        // std::cerr << line << std::endl;
        std::vector<string> samRecVec = split(line, '\t'); //assert(pairVec.size() == 8);
        int flag = atoi(samRecVec[1].c_str());
        if (flag > 2000) continue;
        
        RecombRead* thisRead = new RecombRead(samRecVec);
        
        int CIGARlengthTotal = vector_sum(thisRead->GIGARnumsNoSI);
        //std::cout << "thisRead->CIGAR: " << thisRead->CIGAR << std::endl;
        // print_vector(thisRead->GIGARnums, std::cout);
        //std::cout << "CIGARlengthTotal: " << CIGARlengthTotal << std::endl;
        
        
        int adjusted5pReadPos;
        if (thisRead->readStrand == "-") {
            adjusted5pReadPos = thisRead->readPos + CIGARlengthTotal - 1;
        } else {
            adjusted5pReadPos = thisRead->readPos;
        }
        thisRead->adjustedReadPos = adjusted5pReadPos;
        
        string readSeq; string readQual;
        if(infoPairNameToPos.count(thisRead->readName) != 1) {
            std::cerr << "Not in info pair file: " << thisRead->readName << std::endl;
        } else {
            if (thisRead->MQ > opt::minMQ) {
                std::vector<int> pairPosVec = infoPairNameToPos.at(thisRead->readName);
                if (adjusted5pReadPos == pairPosVec[0] || adjusted5pReadPos == pairPosVec[1]) {
                    samNameToReads[thisRead->readName].push_back(thisRead);
                   // std::cout << "Good" << std::endl;
                } else {
                   /* std::cout << "Bad" << "\t" << adjusted5pReadPos << "\t" << pairPosVec[0] << "\t" << pairPosVec[1] << std::endl;
                    std::cout << "CIGAR: " << thisRead->CIGAR << std::endl;
                    print_vector(thisRead->GIGARnums, std::cout);
                    std::cout << "CIGARlengthTotal: " << CIGARlengthTotal << std::endl;
                    std::cout << "readStrand: " << thisRead->readStrand << std::endl; */
                }
            }
        }
    }
    
    int goodPairs = 0;
    std::vector<RecombReadPair*> goodReadPairs; goodReadPairs.reserve(samNameToReads.size());
    for (std::map<string,std::vector<RecombRead*>>::iterator it = samNameToReads.begin(); it != samNameToReads.end(); it++) {
        if (it->second.size() == 2) {
            goodPairs++;
            RecombReadPair* thisReadPair = new RecombReadPair(it->second[0], it->second[1]);
            goodReadPairs.push_back(thisReadPair);
        } else {
            // std::cout << "it->second.size(): " << it->second.size() << std::endl;
        }
    }
    std::sort(goodReadPairs.begin(), goodReadPairs.end());
    
    
    
    int numConcordant = 0; int numDiscordant = 0;
    int numMatch = 0; int numMismatch = 0;
    std::vector<double> matchBaseScores; std::vector<double> mismatchBaseScores;
    std::vector<double> concordantBaseScores; std::vector<double> discordantBaseScores;
    std::vector<PhaseSwitch*> phaseSwitches;
    
    int numFullLenghtReadPairs = 0;
    int totalUsedLength = 0;
    std::vector<int> numHets;
    int num0het = 0; int num1het = 0; int num2plusHets = 0;
    
    for (int r = 0; r < goodReadPairs.size(); r++) {
        
        goodReadPairs[r]->findAndCombinePairHets(positionToPhase);
        goodReadPairs[r]->filterHetsByQuality(opt::minBQ);
        
        if (goodReadPairs[r]->hetSites.size() == 0) {
            num0het++;
           /* std::cout << "goodReadPairs[r]->hetSites.size(): " << goodReadPairs[r]->hetSites.size() << std::endl;
            std::cout << "goodReadPairs[r]->read1->readPos: " << goodReadPairs[r]->read1->readPos << std::endl;
            std::cout << "goodReadPairs[r]->read1->readStrand: " << goodReadPairs[r]->read1->readStrand << std::endl;
            std::cout << "goodReadPairs[r]->read1->usedLength: " << goodReadPairs[r]->read1->usedLength << std::endl;
            std::cout << "goodReadPairs[r]->read1->adjustedReadPos: " << goodReadPairs[r]->read1->adjustedReadPos << std::endl;
            std::cout << "goodReadPairs[r]->read1->CIGAR: " << goodReadPairs[r]->read1->CIGAR << std::endl;
            std::cout << "goodReadPairs[r]->read2->readPos: " << goodReadPairs[r]->read2->readPos << std::endl;
            std::cout << "goodReadPairs[r]->read2->readStrand: " << goodReadPairs[r]->read2->readStrand << std::endl;
            std::cout << "goodReadPairs[r]->read2->usedLength: " << goodReadPairs[r]->read2->usedLength << std::endl;
            std::cout << "goodReadPairs[r]->read2->adjustedReadPos: " << goodReadPairs[r]->read2->adjustedReadPos << std::endl;
            std::cout << "goodReadPairs[r]->read2->CIGAR: " << goodReadPairs[r]->read2->CIGAR << std::endl;
            std::cout <<  std::endl;
            //std::cout << "goodReadPairs[r]->read2->readStrand: " << goodReadPairs[r]->read1-> << std::endl; */
        } else if (goodReadPairs[r]->hetSites.size() == 1) {
            num1het++;
        } else {
            num2plusHets++;
            if(goodReadPairs[r]->read1->hetSites.size() >= 1 && goodReadPairs[r]->read2->hetSites.size() >= 1) {
                *goodReadPairsFile << goodReadPairs[r]->read1->readPos << "\t" << goodReadPairs[r]->read2->readPos << std::endl;
            }
        }
        
        /* Just debug
         if (goodReadPairs[r]->read1->CIGAR == "151M" && goodReadPairs[r]->read2->CIGAR == "151M") {
            numFullLenghtReadPairs++;
        } */
        
        totalUsedLength = totalUsedLength + goodReadPairs[r]->read1->usedLength;
        totalUsedLength = totalUsedLength + goodReadPairs[r]->read2->usedLength;
        
    }
    
    std::cout << "goodReadPairs.size(): " << goodReadPairs.size() << std::endl;
    std::cout << "num0het: " << num0het << std::endl;
    std::cout << "num1het: " << num1het << std::endl;
    std::cout << "num2plusHets: " << num2plusHets << std::endl;
    
    if (opt::hapcutFormat) {
        
        for (int r = 0; r < goodReadPairs.size(); r++) {
           for (int i = 0; i < goodReadPairs[r]->hetSites.size(); i++) {
                HetInfo* thisHet = goodReadPairs[r]->hetSites[i];
                if (thisHet->readPhaseBaseMismatch) {
                    /*  std::cout << "Bases don't match" << std::endl;
                      std::cout << "sequence: " << thisRead->readSeq << std::endl;
                      std::cout << "readBase: " << thisRead->readSeq[i-1] << "[" << readBase << "]" << thisRead->readSeq[i+1] << std::endl;
                      std::cout << "readQual[i]: " << thisRead->readQual[i] << "; score: " << int(thisRead->readQual[i])-33 << std::endl;
                      std::cout << "readPos: " << thisRead->readPos << std::endl;
                      std::cout << "i: " << i << std::endl;
                      std::cout << "readPos + i: " << thisRead->readPos + i << std::endl;
                      std::cout << "phasedSNPbases[0]: " << phasedSNPbases[0] << std::endl;
                      std::cout << "phasedSNPbases[1]: " << phasedSNPbases[1] << std::endl; */
                    numMismatch++;
                    mismatchBaseScores.push_back(thisHet->thisBaseQuality);
                } else {
                    // std::cout << "Fine: " << std::endl;
                     matchBaseScores.push_back(thisHet->thisBaseQuality);
                     numMatch++;
                }
            }
            
            // 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))
            
            
            
            if (goodReadPairs[r]->hetSites.size() > 1) {
                int phaseOfPrevious; int posOfPrevious; bool allConcordant = true;
                if (goodReadPairs[r]->hetSites[0]->thisBase == goodReadPairs[r]->hetSites[0]->thisHetPhase0) phaseOfPrevious = 0;
                if (goodReadPairs[r]->hetSites[0]->thisBase == goodReadPairs[r]->hetSites[0]->thisHetPhase1) phaseOfPrevious = 1;
                for (int i = 1; i < goodReadPairs[r]->hetSites.size(); i++) {
                    int phaseThis;
                    if (goodReadPairs[r]->hetSites[i]->thisBase == goodReadPairs[r]->hetSites[i]->thisHetPhase0) phaseThis = 0;
                    if (goodReadPairs[r]->hetSites[i]->thisBase == goodReadPairs[r]->hetSites[i]->thisHetPhase1) phaseThis = 1;
                    
                    if (phaseThis != phaseOfPrevious) {
                        allConcordant = false;
                        PhaseSwitch* thisSwitch = new PhaseSwitch(goodReadPairs[r]->hetSites[i-1]->pos, goodReadPairs[r]->hetSites[i]->pos, goodReadPairs[r]->hetSites[i-1]->thisPhaseQuality, goodReadPairs[r]->hetSites[i]->thisPhaseQuality);
                        phaseSwitches.push_back(thisSwitch);
                    }
                    posOfPrevious = goodReadPairs[r]->hetSites[i]->pos;
                    phaseOfPrevious = phaseThis;
                }
                if (allConcordant == false) numDiscordant++;
                else numConcordant++;
            }
        }
        std::cout << "numConcordant: " << numConcordant << std::endl;
        std::cout << "numDiscordant: " << numDiscordant << 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;
        }
        
    } else {
        for (int r = 0; r < goodReadPairs.size(); r++) {
            if (goodReadPairs[r]->hetSites.size() > 1) {
                for (int i = 0; i < goodReadPairs[r]->hetSites.size() - 1; i++) {
                    for (int j = 1; j < goodReadPairs[r]->hetSites.size(); j++) {
                        char readBase1 = goodReadPairs[r]->hetSites[i]->thisBase;
                        char readBase2 = goodReadPairs[r]->hetSites[j]->thisBase;
                        int pos1 = goodReadPairs[r]->hetSites[i]->pos;
                        int pos2 = goodReadPairs[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 << "numFullLenghtReadPairs: " << numFullLenghtReadPairs << std::endl;
        std::cout << "totalUsedLength: " << totalUsedLength << std::endl;
        std::cout << "totalUsedLength/(goodReadPairs.size()*300): " << (double)totalUsedLength/(double)(goodReadPairs.size()*300) << std::endl;
    }
    
    return 0;
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
callq 0x8ca68
leaq 0x1b0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x53f2b(%rip), %rsi     # 0xdf318
leaq 0x118(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x21904
leaq 0x118(%rsp), %rdi
pushq $0x8
popq %rsi
callq 0x42587
movq %rax, 0x28(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x8978
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq %rax, %r15
movq 0x53f20(%rip), %rsi     # 0xdf358
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x8890
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq %rax, %rbx
movq 0x53ee1(%rip), %rsi     # 0xdf338
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x8890
movl $0x200, %edi            # imm = 0x200
callq 0x8490
movq %rax, 0xb8(%rsp)
leaq 0x2674f(%rip), %rsi     # 0xb1bca
leaq 0x53ef6(%rip), %rdx     # 0xdf378
leaq 0x170(%rsp), %rdi
callq 0x5b784
leaq 0x2198f(%rip), %rdx     # 0xace25
leaq 0x118(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x28a29
leaq 0x118(%rsp), %rsi
pushq $0x10
popq %rdx
movq 0xb8(%rsp), %rdi
callq 0x8900
leaq 0x118(%rsp), %rdi
callq 0x8978
leaq 0x170(%rsp), %rdi
callq 0x8978
movl $0x200, %edi            # imm = 0x200
callq 0x8490
movq %rax, 0xb0(%rsp)
leaq 0x266dd(%rip), %rsi     # 0xb1bd3
leaq 0x53e7b(%rip), %rdx     # 0xdf378
leaq 0x170(%rsp), %rdi
callq 0x5b784
leaq 0x21914(%rip), %rdx     # 0xace25
leaq 0x118(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x28a29
leaq 0x118(%rsp), %rsi
pushq $0x10
popq %rdx
movq 0xb0(%rsp), %rdi
callq 0x8900
movq %r15, 0x60(%rsp)
movq %rbx, 0x58(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x8978
leaq 0x170(%rsp), %rdi
callq 0x8978
leaq 0x178(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x280(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x2c8(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x250(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x148(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movupd %xmm0, -0x8(%rax)
cmpb $0x0, 0x53d92(%rip)     # 0xdf398
je 0x8b808
movl $0x0, 0x6c(%rsp)
leaq 0x30(%rsp), %r13
leaq 0x2f0(%rsp), %rbx
leaq 0x70(%rsp), %rbp
movq 0x28(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x8b922
movq 0x1a0(%rsp), %rax
movzbl (%rax), %ecx
cmpl $0x42, %ecx
je 0x8b661
cmpl $0x2a, %ecx
jne 0x8b66b
jmp 0x8b626
cmpb $0x4c, 0x1(%rax)
je 0x8b7ff
movq %r13, %r14
movq %r13, %rdi
leaq 0x1a0(%rsp), %rsi
pushq $0x9
popq %rdx
callq 0x40349
movq 0x30(%rsp), %r12
movq 0x80(%r12), %rdi
callq 0x86f0
movl %eax, 0xe0(%rsp)
movq 0x20(%r12), %rdi
callq 0x86f0
movl %eax, %r13d
movq 0x40(%r12), %rdi
callq 0x86f0
cmpq $0x1, 0xa8(%r12)
jne 0x8c721
cmpq $0x1, 0xc8(%r12)
jne 0x8c72a
movl %eax, %r15d
movq 0xa0(%r12), %rax
movb (%rax), %al
movb %al, 0x90(%rsp)
movq 0xc0(%r12), %rax
movb (%rax), %al
movb %al, 0x10(%rsp)
movq 0x140(%r12), %rsi
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x21904
movq %rbx, %rdi
callq 0x402aa
movsd %xmm0, 0x50(%rsp)
movq %rbx, %rdi
callq 0x8978
movq 0x30(%rsp), %rax
movq 0x160(%rax), %rdi
callq 0x86f0
movl %eax, %r12d
andq $0x0, 0x80(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movl %r15d, %eax
xorl $0x1, %eax
orl %r13d, %eax
je 0x8b76d
xorl $0x1, %r13d
orl %r15d, %r13d
je 0x8b787
movq %rbp, %rdi
callq 0x55604
movq %r14, %r13
movq %r14, %rdi
callq 0x28a08
jmp 0x8b626
movq %rbp, %rdi
leaq 0x90(%rsp), %rsi
callq 0x5504a
leaq 0x10(%rsp), %rsi
movq %r14, %r13
jmp 0x8b79f
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x5504a
leaq 0x90(%rsp), %rsi
movq %r14, %r13
movq %rbp, %rdi
callq 0x5504a
pushq $0x30
popq %rdi
callq 0x8490
movq %rax, %r15
movl 0xe0(%rsp), %esi
movq %rax, %rdi
movsd 0x50(%rsp), %xmm0
movl %r12d, %edx
movq %rbp, %rcx
movl 0x6c(%rsp), %r8d
callq 0x8cc7a
leaq 0x170(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x8ccc8
movq %r15, (%rax)
movq %rbp, %rdi
callq 0x55604
movq %r13, %rdi
callq 0x28a08
jmp 0x8b626
incl 0x6c(%rsp)
jmp 0x8b626
leaq 0x1a0(%rsp), %rbx
leaq 0x30(%rsp), %r14
leaq 0x70(%rsp), %r15
leaq 0x170(%rsp), %r12
leaq 0xe0(%rsp), %rbp
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x8b913
movq %r14, %rdi
movq %rbx, %rsi
pushq $0x9
popq %rdx
callq 0x40349
movq 0x30(%rsp), %r13
movq 0x20(%r13), %rdi
callq 0x86f0
movl %eax, 0xe0(%rsp)
cmpq $0x1, 0x48(%r13)
jne 0x8c6ff
cmpq $0x1, 0x68(%r13)
jne 0x8c708
movq 0x40(%r13), %rax
movb (%rax), %al
movb %al, 0x90(%rsp)
movq 0x60(%r13), %rax
movb (%rax), %al
movb %al, 0x10(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x5504a
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
callq 0x5504a
pushq $0x30
popq %rdi
callq 0x8490
movq %rax, %r13
movl 0xe0(%rsp), %esi
xorpd %xmm0, %xmm0
movq %rax, %rdi
xorl %edx, %edx
movq %r15, %rcx
pushq $0x1
popq %r8
callq 0x8cc7a
movq %r12, %rdi
movq %rbp, %rsi
callq 0x8ccc8
movq %r13, (%rax)
movq %r15, %rdi
callq 0x55604
movq %r14, %rdi
callq 0x28a08
jmp 0x8b82a
movl 0x198(%rsp), %edi
pushq $0x2
popq %rsi
callq 0x797ea
leaq 0x1a0(%rsp), %r12
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r13
leaq 0x70(%rsp), %rbp
leaq 0x100(%rsp), %r14
movq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x8bacb
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
pushq $0x9
popq %rdx
callq 0x40349
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rax
subq %rsi, %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x8c6e0
movq %r15, %rdi
callq 0x8600
movq 0x90(%rsp), %rbx
movq 0x40(%rbx), %rdi
callq 0x86f0
movl %eax, 0x150(%rsp)
movq 0x80(%rbx), %rdi
callq 0x86f0
movl %eax, 0x1c0(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %r13, %rdi
leaq 0x150(%rsp), %rsi
callq 0x3aca4
movq %r13, %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x3aca4
leaq 0x278(%rsp), %rdi
movq %r15, %rsi
callq 0x3aaec
movq %rax, %rdi
movq %r13, %rsi
callq 0x2ab5a
movq 0x90(%rsp), %rsi
movl $0xa0, %eax
addq %rax, %rsi
movq %rbp, %rdi
callq 0x8600
movq 0x90(%rsp), %rsi
movl $0xc0, %eax
addq %rax, %rsi
leaq 0xe0(%rsp), %rdi
callq 0x8600
xorpd %xmm0, %xmm0
movapd %xmm0, 0x100(%rsp)
andq $0x0, 0x110(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2b0a4
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2b0a4
leaq 0x2c0(%rsp), %rdi
movq %r15, %rsi
callq 0x3abd8
movq %rax, %rdi
movq %r14, %rsi
callq 0x2a25e
movq %r14, %rdi
callq 0x28a08
leaq 0xe0(%rsp), %rdi
callq 0x8978
movq %rbp, %rdi
callq 0x8978
movq %r13, %rdi
callq 0x2aef2
movq %r15, %rdi
callq 0x8978
leaq 0x90(%rsp), %rdi
callq 0x28a08
jmp 0x8b941
leaq 0x1a0(%rsp), %rbx
leaq 0xe0(%rsp), %r12
leaq 0x2a8(%rsp), %r13
leaq 0x310(%rsp), %r14
xorl %ebp, %ebp
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x8bcdc
movq %r12, %rdi
movq %rbx, %rsi
pushq $0x9
popq %rdx
callq 0x40349
movq 0xe0(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x86f0
cmpl $0x7d0, %eax            # imm = 0x7D0
jg 0x8bccf
movl $0x150, %edi            # imm = 0x150
callq 0x8490
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0x297dc
movq %r15, %rdi
movq %r13, %rsi
callq 0x8cd16
movq %r13, %rdi
callq 0x28a08
movq %r15, 0x10(%rsp)
addq $0xe8, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2c6d4
movq %r14, %rdi
callq 0x2c6ac
movsd %xmm0, 0x28(%rsp)
movq %r14, %rdi
callq 0x2aef2
movq 0x10(%rsp), %rdi
addq $0x8, %rdi
leaq 0xceb2(%rip), %rsi      # 0x98a50
callq 0x2193f
testb %al, %al
je 0x8bbbe
cvttsd2si 0x28(%rsp), %eax
movq 0x10(%rsp), %rsi
movl 0x48(%rsi), %ecx
leal (%rax,%rcx), %r15d
decl %r15d
jmp 0x8bbc7
movq 0x10(%rsp), %rsi
movl 0x48(%rsi), %r15d
movl %r15d, 0x4c(%rsi)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
movb %bpl, 0x40(%rsp)
movb %bpl, 0x80(%rsp)
addq $0x28, %rsi
leaq 0x278(%rsp), %rdi
callq 0x8cf56
cmpq $0x1, %rax
jne 0x8bc8f
movq 0x10(%rsp), %rsi
movl 0x90(%rsi), %eax
cmpl 0x51a05(%rip), %eax     # 0xdd628
jle 0x8bcbb
addq $0x28, %rsi
leaq 0x278(%rsp), %rdi
callq 0x8cf70
leaq 0x90(%rsp), %rdi
movq %rax, %rsi
callq 0x2c6d4
movq 0x90(%rsp), %rax
cmpl (%rax), %r15d
je 0x8bc5d
cmpl 0x4(%rax), %r15d
jne 0x8bc80
movq 0x10(%rsp), %rsi
addq $0x28, %rsi
leaq 0x248(%rsp), %rdi
callq 0x8cfb6
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8d01c
leaq 0x90(%rsp), %rdi
callq 0x2aef2
jmp 0x8bcbb
movq 0x51352(%rip), %rdi     # 0xdcfe8
leaq 0x2600b(%rip), %rsi     # 0xb1ca8
callq 0x8480
movq 0x10(%rsp), %rsi
addq $0x28, %rsi
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x70(%rsp), %rdi
callq 0x8978
leaq 0x30(%rsp), %rdi
callq 0x8978
movq %r12, %rdi
callq 0x28a08
jmp 0x8baed
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq 0x270(%rsp), %rsi
callq 0x8d03a
movq 0x260(%rsp), %r15
pushq $0x30
popq %rbx
leaq 0x10(%rsp), %r14
leaq 0x30(%rsp), %r12
leaq 0x250(%rsp), %rax
cmpq %rax, %r15
je 0x8bd7e
movq 0x48(%r15), %rax
subq 0x40(%r15), %rax
cmpq $0x10, %rax
jne 0x8bd71
movq %rbx, %rdi
callq 0x8490
movq 0x40(%r15), %rcx
movq (%rcx), %rdx
movq 0x8(%rcx), %rcx
andq $0x0, 0x28(%rax)
cmpq %rcx, %rdx
movq %rcx, %rsi
cmovbq %rdx, %rsi
cmovbq %rcx, %rdx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rax)
movq %rsi, (%rax)
movq %rdx, 0x8(%rax)
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x8d0d0
movq %r15, %rdi
callq 0x8340
movq %rax, %r15
jmp 0x8bd10
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x8ddb1
xorpd %xmm0, %xmm0
movapd %xmm0, 0x100(%rsp)
andq $0x0, 0x110(%rsp)
movapd %xmm0, 0x150(%rsp)
andq $0x0, 0x160(%rsp)
movapd %xmm0, 0x1c0(%rsp)
andq $0x0, 0x1d0(%rsp)
movapd %xmm0, 0x200(%rsp)
andq $0x0, 0x210(%rsp)
movapd %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movapd %xmm0, 0x1e0(%rsp)
andq $0x0, 0x1f0(%rsp)
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
leaq 0x170(%rsp), %r14
leaq 0xe00a(%rip), %r12      # 0x99e1e
movl $0x0, 0x50(%rsp)
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x8bf11
movq (%rax,%r13,8), %rdi
movq %r14, %rsi
callq 0x8f514
movq 0x10(%rsp), %rax
movq (%rax,%r13,8), %rdi
movl 0x517d9(%rip), %esi     # 0xdd62c
callq 0x8f5a4
movq 0x10(%rsp), %rax
movq (%rax,%r13,8), %rcx
movq 0x20(%rcx), %rdx
subq 0x18(%rcx), %rdx
sarq $0x3, %rdx
cmpq $0x1, %rdx
je 0x8be7c
testq %rdx, %rdx
jne 0x8be80
incl %ebp
jmp 0x8beee
incl %ebx
jmp 0x8beee
incl %r15d
movq (%rcx), %rdx
movq 0x110(%rdx), %rsi
cmpq 0x108(%rdx), %rsi
je 0x8beee
movq 0x8(%rcx), %rsi
movq 0x110(%rsi), %rdi
cmpq 0x108(%rsi), %rdi
je 0x8beee
movl 0x48(%rdx), %esi
movq 0xb0(%rsp), %rdi
callq 0x8840
movq %rax, %rdi
movq %r12, %rsi
callq 0x8480
movq 0x10(%rsp), %rcx
movq (%rcx,%r13,8), %rcx
movq 0x8(%rcx), %rcx
movl 0x48(%rcx), %esi
movq %rax, %rdi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x10(%rsp), %rax
movq (%rax,%r13,8), %rcx
movq (%rcx), %rdx
movl 0x50(%rsp), %esi
addl 0x100(%rdx), %esi
movq 0x8(%rcx), %rcx
addl 0x100(%rcx), %esi
movl %esi, 0x50(%rsp)
incq %r13
jmp 0x8be23
movq 0x510a0(%rip), %rdi     # 0xdcfb8
leaq 0x25da1(%rip), %rsi     # 0xb1cc0
callq 0x8480
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x8320
movq %rax, %rdi
callq 0x8230
movq 0x5106f(%rip), %rdi     # 0xdcfb8
leaq 0x25d87(%rip), %rsi     # 0xb1cd7
callq 0x8480
movq %rax, %rdi
movl %ebp, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x5104a(%rip), %rdi     # 0xdcfb8
leaq 0x25d6c(%rip), %rsi     # 0xb1ce1
callq 0x8480
movq %rax, %rdi
movl %ebx, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x51025(%rip), %rdi     # 0xdcfb8
leaq 0x25d51(%rip), %rsi     # 0xb1ceb
callq 0x8480
movq %rax, %rdi
movl %r15d, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x10(%rsp), %rbx
cmpb $0x0, 0x533da(%rip)     # 0xdf398
je 0x8c159
xorl %r15d, %r15d
movl $0x0, 0x60(%rsp)
movl $0x0, 0x58(%rsp)
xorl %r14d, %r14d
movl $0x0, 0x28(%rsp)
movq 0x18(%rsp), %rax
subq %rbx, %rax
sarq $0x3, %rax
cmpq %r15, %rax
jbe 0x8c32e
xorl %ebp, %ebp
movq (%rbx,%r15,8), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
jbe 0x8c068
movq (%rax,%rbp,8), %rax
cmpb $0x1, 0x24(%rax)
jne 0x8c03e
cvtsi2sdl 0xc(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2af10
incl 0x28(%rsp)
jmp 0x8c05e
cvtsi2sdl 0xc(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2af10
incl %r14d
incq %rbp
movq 0x10(%rsp), %rbx
jmp 0x8bff9
cmpq $0x1, %rcx
jbe 0x8c151
movq (%rax), %rax
movb 0x8(%rax), %cl
cmpb 0x10(%rax), %cl
movl $0x0, %edx
cmovel %edx, %r12d
cmpb 0x11(%rax), %cl
pushq $0x1
popq %rax
cmovel %eax, %r12d
movb $0x1, %al
pushq $0x1
popq %rbp
movq (%rbx,%r15,8), %rdx
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rbp, %rdx
jbe 0x8c13f
movq (%rcx,%rbp,8), %rcx
movb 0x8(%rcx), %sil
xorl %edx, %edx
cmpb 0x10(%rcx), %sil
je 0x8c0c2
movl %r13d, %edx
pushq $0x1
popq %r13
cmpb 0x11(%rcx), %sil
je 0x8c0cf
movl %edx, %r13d
cmpl %r12d, %r13d
je 0x8c134
pushq $0x20
popq %rdi
callq 0x8490
movq (%rbx,%r15,8), %rcx
movq 0x18(%rcx), %rcx
movq -0x8(%rcx,%rbp,8), %rdx
movq (%rcx,%rbp,8), %rcx
movl (%rdx), %esi
movl (%rcx), %edi
movsd 0x18(%rdx), %xmm0
movsd 0x18(%rcx), %xmm1
movl %esi, (%rax)
movl %edi, 0x4(%rax)
movsd %xmm0, 0x8(%rax)
movsd %xmm1, 0x10(%rax)
subl %esi, %edi
movl %edi, %ecx
negl %ecx
cmovsl %edi, %ecx
movl %ecx, 0x18(%rax)
movq %rax, 0x30(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8d0ee
movq 0x10(%rsp), %rbx
xorl %eax, %eax
incq %rbp
movl %r13d, %r12d
jmp 0x8c093
andb $0x1, %al
movzbl %al, %eax
addl %eax, 0x60(%rsp)
xorb $0x1, %al
movzbl %al, %eax
addl %eax, 0x58(%rsp)
incq %r15
jmp 0x8bfe2
xorl %esi, %esi
leaq 0xe0(%rsp), %r12
movq 0x18(%rsp), %rax
subq %rbx, %rax
sarq $0x3, %rax
cmpq %rsi, %rax
jbe 0x8c54c
movq (%rbx,%rsi,8), %rax
movq 0x20(%rax), %rcx
subq 0x18(%rax), %rcx
cmpq $0x9, %rcx
jb 0x8c326
movq (%rbx,%rsi,8), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
xorl %edi, %edi
movq %rsi, 0x58(%rsp)
subq %rax, %rcx
sarq $0x3, %rcx
decq %rcx
cmpq %rdi, %rcx
jbe 0x8c326
pushq $0x1
popq %r15
movq %rdi, 0x60(%rsp)
movq (%rbx,%rsi,8), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x8c31e
movq (%rax,%rdi,8), %rcx
movb 0x8(%rcx), %dl
movb %dl, 0xf(%rsp)
movq %r15, 0x28(%rsp)
movq (%rax,%r15,8), %rax
movb 0x8(%rax), %dl
movb %dl, 0xe(%rsp)
movl (%rcx), %r14d
movl (%rax), %ebp
movq %r12, %rbx
movq %r12, %rdi
movl %r14d, %esi
callq 0x28ad3
leaq 0x70(%rsp), %rdi
movq %rbx, %r12
movq %rbx, %rsi
leaq 0x175a0(%rip), %rdx     # 0xa37bc
callq 0x28a29
leaq 0x90(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x28ad3
leaq 0x30(%rsp), %r13
movq %r13, %rdi
leaq 0x70(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x28a48
movq %r15, %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8978
movq %r12, %rdi
callq 0x8978
leaq 0x118(%rsp), %rdi
movq %r13, %rsi
callq 0x8e350
testq %rax, %rax
je 0x8c2c0
leaq 0x118(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8e434
movq (%rax), %rdi
addq $0x8, %rdi
leaq 0xf(%rsp), %rsi
callq 0x5504a
leaq 0x118(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8e434
movq (%rax), %rdi
addq $0x8, %rdi
leaq 0xe(%rsp), %rsi
callq 0x5504a
jmp 0x8c2f8
pushq $0x38
popq %rdi
callq 0x8490
movq %rax, %rbx
movsbl 0xf(%rsp), %ecx
movsbl 0xe(%rsp), %r8d
movq %rax, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x8d10c
leaq 0x118(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x8e434
movq %rbx, (%rax)
leaq 0x30(%rsp), %rdi
callq 0x8978
movq 0x28(%rsp), %r15
incq %r15
movq 0x10(%rsp), %rbx
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdi
jmp 0x8c1bd
incq %rdi
jmp 0x8c1a1
incq %rsi
jmp 0x8c163
movq 0x50c83(%rip), %rdi     # 0xdcfb8
leaq 0x259be(%rip), %rsi     # 0xb1cfa
callq 0x8480
movq %rax, %rdi
movl 0x60(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x50c5c(%rip), %rdi     # 0xdcfb8
leaq 0x259a7(%rip), %rsi     # 0xb1d0a
callq 0x8480
movq %rax, %rdi
movl 0x58(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x50c35(%rip), %rdi     # 0xdcfb8
leaq 0x25990(%rip), %rsi     # 0xb1d1a
callq 0x8480
movq %rax, %rdi
movl %r14d, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x50c0f(%rip), %rdi     # 0xdcfb8
leaq 0x25975(%rip), %rsi     # 0xb1d25
callq 0x8480
movq %rax, %rdi
movl 0x28(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x50be8(%rip), %rdi     # 0xdcfb8
leaq 0x2595c(%rip), %rsi     # 0xb1d33
callq 0x8480
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x2f816
leaq 0x230(%rsp), %rdi
callq 0x2f7e9
movq %rbx, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x230(%rsp), %rdi
callq 0x2b43c
movq 0x50b93(%rip), %rdi     # 0xdcfb8
leaq 0x25921(%rip), %rsi     # 0xb1d4d
callq 0x8480
movq %rax, %rbx
leaq 0x218(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x2f816
leaq 0x218(%rsp), %rdi
callq 0x2f7e9
movq %rbx, %rdi
callq 0x8750
movq %rax, %rdi
callq 0x8230
leaq 0x218(%rsp), %rdi
callq 0x2b43c
xorl %r14d, %r14d
leaq 0xd9a1(%rip), %rbx      # 0x99e1e
movq 0xc0(%rsp), %rax
movq 0xc8(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %r14
je 0x8c626
movq (%rax,%r14,8), %rax
movl (%rax), %esi
movq 0xb8(%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 0x8c47d
movq 0x50a65(%rip), %rdi     # 0xdcfb8
leaq 0x2580a(%rip), %rsi     # 0xb1d64
callq 0x8480
movq 0x130(%rsp), %rsi
movq %rax, %rdi
callq 0x8320
movq %rax, %rdi
callq 0x8230
movq 0x50a3a(%rip), %rdi     # 0xdcfb8
leaq 0x257f1(%rip), %rsi     # 0xb1d76
callq 0x8480
movq %rax, %rdi
xorl %esi, %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x50a15(%rip), %rdi     # 0xdcfb8
leaq 0x257e5(%rip), %rsi     # 0xb1d8f
callq 0x8480
movq %rax, %rdi
movl 0x50(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x509ee(%rip), %rdi     # 0xdcfb8
leaq 0x257d0(%rip), %rsi     # 0xb1da1
callq 0x8480
cvtsi2sdl 0x50(%rsp), %xmm0
movq 0x18(%rsp), %rcx
subq 0x10(%rsp), %rcx
sarq $0x3, %rcx
imulq $0x12c, %rcx, %rcx      # imm = 0x12C
movq %rcx, %xmm1
punpckldq 0x5c42(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x5c4a(%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 0x1e0(%rsp), %rdi
callq 0x2aef2
leaq 0xc0(%rsp), %rdi
callq 0x8e1d8
leaq 0x200(%rsp), %rdi
callq 0x2b43c
leaq 0x1c0(%rsp), %rdi
callq 0x2b43c
leaq 0x150(%rsp), %rdi
callq 0x2b43c
leaq 0x100(%rsp), %rdi
callq 0x2b43c
leaq 0x10(%rsp), %rdi
callq 0x8dc3a
leaq 0x118(%rsp), %rdi
callq 0x8d2a2
leaq 0x248(%rsp), %rdi
callq 0x8d360
leaq 0x2c0(%rsp), %rdi
callq 0x32f44
leaq 0x278(%rsp), %rdi
callq 0x3c43a
leaq 0x170(%rsp), %rdi
callq 0x8d40e
leaq 0x1a0(%rsp), %rdi
callq 0x8978
xorl %eax, %eax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x252c1(%rip), %rdi     # 0xb19a8
leaq 0x25515(%rip), %rsi     # 0xb1c03
leaq 0x2552a(%rip), %rcx     # 0xb1c1f
movl $0x8f, %edx
callq 0x82f0
leaq 0x2555e(%rip), %rdi     # 0xb1c64
jmp 0x8c70f
leaq 0x25577(%rip), %rdi     # 0xb1c86
leaq 0x254ed(%rip), %rsi     # 0xb1c03
leaq 0x25502(%rip), %rcx     # 0xb1c1f
pushq $0x7d
jmp 0x8c741
leaq 0x254b9(%rip), %rdi     # 0xb1be1
jmp 0x8c731
leaq 0x25511(%rip), %rdi     # 0xb1c42
leaq 0x254cb(%rip), %rsi     # 0xb1c03
leaq 0x254e0(%rip), %rcx     # 0xb1c1f
pushq $0x68
popq %rdx
callq 0x82f0
movq %rax, %r14
pushq $0x30
popq %rsi
movq %r15, %rdi
jmp 0x8c89d
movq %rax, %r14
leaq 0x218(%rsp), %rdi
jmp 0x8c76d
movq %rax, %r14
leaq 0x230(%rsp), %rdi
callq 0x2b43c
jmp 0x8c9ba
movq %rax, %r14
leaq 0x118(%rsp), %rdi
callq 0x8978
jmp 0x8c78c
movq %rax, %r14
leaq 0x170(%rsp), %rdi
callq 0x8978
jmp 0x8c79e
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0xb0(%rsp), %rdi
jmp 0x8c801
jmp 0x8c822
movq %rax, %r14
leaq 0x118(%rsp), %rdi
callq 0x8978
jmp 0x8c7c4
movq %rax, %r14
leaq 0x170(%rsp), %rdi
callq 0x8978
jmp 0x8c7d6
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0xb8(%rsp), %rdi
jmp 0x8c801
jmp 0x8c822
movq %rax, %r14
movl $0x208, %esi            # imm = 0x208
movq %rbx, %rdi
jmp 0x8c801
jmp 0x8c822
movq %rax, %r14
movl $0x208, %esi            # imm = 0x208
movq %r15, %rdi
callq 0x84a0
jmp 0x8ca53
jmp 0x8c822
movq %rax, %r14
leaq 0x118(%rsp), %rdi
callq 0x8978
jmp 0x8ca53
movq %rax, %r14
jmp 0x8ca53
jmp 0x8c8cc
jmp 0x8c8cc
jmp 0x8c8af
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0x2aef2
jmp 0x8c8ed
jmp 0x8c8ea
movq %rax, %r14
leaq 0x2f0(%rsp), %rdi
callq 0x8978
jmp 0x8c8d9
movq %rax, %r14
jmp 0x8c8d9
jmp 0x8c8e2
jmp 0x8c88f
movq %rax, %r14
leaq 0x2a8(%rsp), %rdi
callq 0x28a08
jmp 0x8c880
movq %rax, %r14
movl $0x150, %esi            # imm = 0x150
movq %r15, %rdi
callq 0x84a0
jmp 0x8c901
movq %rax, %r14
jmp 0x8c901
movq %rax, %r14
pushq $0x30
popq %rsi
movq %r13, %rdi
callq 0x84a0
jmp 0x8c8cf
jmp 0x8c8e2
jmp 0x8c8e2
jmp 0x8c8e2
jmp 0x8c991
movq %rax, %r14
jmp 0x8ca08
jmp 0x8c8e2
movq %rax, %r14
jmp 0x8c92d
jmp 0x8c939
movq %rax, %r14
jmp 0x8c950
jmp 0x8c8e2
jmp 0x8c8cc
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x55604
leaq 0x30(%rsp), %rdi
jmp 0x8c958
jmp 0x8c8e2
movq %rax, %r14
jmp 0x8ca12
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x8978
leaq 0x30(%rsp), %rdi
callq 0x8978
leaq 0xe0(%rsp), %rdi
jmp 0x8c958
jmp 0x8c991
movq %rax, %r14
leaq 0x100(%rsp), %rdi
callq 0x28a08
leaq 0xe0(%rsp), %rdi
callq 0x8978
leaq 0x70(%rsp), %rdi
callq 0x8978
jmp 0x8c93c
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x2aef2
leaq 0x30(%rsp), %rdi
callq 0x8978
leaq 0x90(%rsp), %rdi
callq 0x28a08
jmp 0x8ca12
jmp 0x8c991
jmp 0x8c991
jmp 0x8c991
jmp 0x8c991
movq %rax, %r14
pushq $0x38
popq %rsi
movq %rbx, %rdi
callq 0x84a0
jmp 0x8c9b0
movq %rax, %r14
jmp 0x8c9a3
movq %rax, %r14
leaq 0x90(%rsp), %rdi
callq 0x8978
jmp 0x8c999
movq %rax, %r14
jmp 0x8c9ba
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x8978
leaq 0xe0(%rsp), %rdi
jmp 0x8c9b5
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x8978
leaq 0x1e0(%rsp), %rdi
callq 0x2aef2
leaq 0xc0(%rsp), %rdi
callq 0x8e1d8
leaq 0x200(%rsp), %rdi
callq 0x2b43c
leaq 0x1c0(%rsp), %rdi
callq 0x2b43c
leaq 0x150(%rsp), %rdi
callq 0x2b43c
leaq 0x100(%rsp), %rdi
callq 0x2b43c
leaq 0x10(%rsp), %rdi
callq 0x8dc3a
leaq 0x118(%rsp), %rdi
callq 0x8d2a2
leaq 0x248(%rsp), %rdi
callq 0x8d360
leaq 0x2c0(%rsp), %rdi
callq 0x32f44
leaq 0x278(%rsp), %rdi
callq 0x3c43a
leaq 0x170(%rsp), %rdi
callq 0x8d40e
leaq 0x1a0(%rsp), %rdi
callq 0x8978
movq %r14, %rdi
callq 0x8870