// File: hanhwi[P]SimPoint/analysiscode/Simpoint.cpp
// Function: Simpoint::doClustering()
void Simpoint::doClustering() {
    loadData();
    applyWeights();
    sampleDataset();
    savePreClusteringData();

    // create vectors to save all the data that will be produced
    vector<int> labels(wholeDataset->numRows(), 0);
    Datapoint distsToCenters(wholeDataset->numRows());

    // binary search variables
    int search_k_max = options.max_k, search_k_min = 1,
        min_bic_ndx = 0, max_bic_ndx = 0;
    if (options.useBinarySearch) {
        Logger::log() << "  Searching for best clustering for k <= " 
            << search_k_max << endl;
        options.kValues.clear();
        options.kValues.push_back(search_k_min);
        options.kValues.push_back(search_k_max);
        options.kValues.push_back((search_k_max + search_k_min) / 2);
    } else {
        Logger::log() << "  Clustering for user-defined k-values\n"; 

        if (options.learnKFromFile) {
            // find out the k value from the clusters the user provided
            Dataset *tempCtrs = loadInitialCenters(0, 0);
            options.kValues.push_back(tempCtrs->numRows());
            delete tempCtrs;
        }
    }

    vector<Dataset *> initSeedInitialCenters(options.numInitSeeds),
                      initSeedFinalCenters(options.numInitSeeds);
    vector<double> initSeedBicScores(options.numInitSeeds);

    for (unsigned int runNumber = 0; runNumber < options.kValues.size(); runNumber++) {
        Logger::log() << endl
            << "--------------------------------------------------------------\n"
            << "Run number " << (runNumber+1) << " of ";
        if (options.useBinarySearch) {
            int maxRuns = (int)(log((double)options.max_k) / log(2.0) + 3);
            Logger::log() << "at most " << maxRuns;
        } else {
            Logger::log() << options.kValues.size();
        }
        Logger::log() << ", k = " << options.kValues[runNumber] << endl
            << "--------------------------------------------------------------\n";

        int bestInitSeedRun = 0;
        for (int initSeedRun = 0; initSeedRun < options.numInitSeeds; initSeedRun++) {
            Logger::log() 
                << "  --------------------------------------------------------------\n"
                << "  Initialization seed trial #" << (initSeedRun+1) << " of "
                << options.numInitSeeds << "; initialization seed = " 
                << options.randSeedKMeansInit << endl
                << "  --------------------------------------------------------------\n";

            initSeedInitialCenters[initSeedRun] = loadInitialCenters(runNumber, initSeedRun);
            initSeedFinalCenters[initSeedRun] =
                new Dataset(*initSeedInitialCenters[initSeedRun]);

            int iteration_limit = options.numKMeansIterations;
            if (options.useNoIterationLimit) { iteration_limit = INT_MAX; }
            KMeans::runKMeans(*sampledDataset, initSeedFinalCenters[initSeedRun], 
                    iteration_limit);

            // calculate and save the BIC score
            initSeedBicScores[initSeedRun] = KMeans::bicScore(*wholeDataset,
                    *initSeedFinalCenters[initSeedRun]);
            Logger::log() << "  BIC score: " << initSeedBicScores[initSeedRun] << endl;

            if (initSeedBicScores[initSeedRun] > initSeedBicScores[bestInitSeedRun]) {
                bestInitSeedRun = initSeedRun;
            }

            // report the distortions and variances
            KMeans::findLabelsAndDists(*wholeDataset,
                    *initSeedFinalCenters[initSeedRun], 
                    &labels, &distsToCenters);
            Datapoint clusterDistortions(initSeedFinalCenters[initSeedRun]->numRows());
            double dist = KMeans::distortion(*wholeDataset, labels,
                    *initSeedFinalCenters[initSeedRun], &clusterDistortions);
            Logger::log() << "  Distortion: " << dist << endl
                          << "  Distortions/cluster: ";
            for (unsigned int i = 0; i < clusterDistortions.size(); i++) {
                Logger::log() << clusterDistortions[i] << " ";
            }
            Logger::log() << endl;

            double degreesOfFreedom = wholeDataset->numRows() -
                                initSeedFinalCenters[initSeedRun]->numRows();
            Logger::log() << "  Variance: " << (dist/degreesOfFreedom) << endl 
                << "  Variances/cluster: ";
            for (unsigned int i = 0; i < clusterDistortions.size(); i++) {
                double weight = initSeedFinalCenters[initSeedRun]->getWeight(i)
                                * wholeDataset->numRows();
                if (weight > 1.0) {
                    Logger::log() << (clusterDistortions[i] / (weight - 1.0)) << " ";
                } else {
                    Logger::log() << 0 << " ";
                }
            }
            Logger::log() << endl;
            options.randSeedKMeansInit++;
        }

        Logger::log() << "  The best initialization seed trial was #" 
            << (bestInitSeedRun+1) << endl;

        initialCenters.push_back(initSeedInitialCenters[bestInitSeedRun]);
        finalCenters.push_back(initSeedFinalCenters[bestInitSeedRun]);
        bicScores.push_back(initSeedBicScores[bestInitSeedRun]);

        // free up the memory and reset the pointers for the next go-round
        for (int initSeedRun = 0; initSeedRun < options.numInitSeeds; initSeedRun++) {
            if (initSeedRun != bestInitSeedRun) {
                delete initSeedInitialCenters[initSeedRun];
                delete initSeedFinalCenters[initSeedRun];
            }
            initSeedInitialCenters[initSeedRun] = NULL;
            initSeedFinalCenters[initSeedRun] = NULL;
        }

        if (options.useBinarySearch) {
            if (bicScores[runNumber] > bicScores[max_bic_ndx]) max_bic_ndx = runNumber;
            if (bicScores[runNumber] < bicScores[min_bic_ndx]) min_bic_ndx = runNumber;

            double bic_range = (bicScores[max_bic_ndx] - bicScores[min_bic_ndx]);
            double bic_threshold = bicScores[min_bic_ndx] +
                bic_range * options.bicThreshold;
            int last_k = options.kValues[runNumber];

            if (runNumber >= 2) { // determine where we should search next
                int next_k = -1;
                bool searchUpper = (max_bic_ndx > min_bic_ndx) ?
                    (bicScores.back() < bic_threshold) : false;

                if (searchUpper) { // search in upper window
                    next_k = (last_k + search_k_max) / 2;
                    search_k_min = last_k;
                } else { // search in the lower window
                    next_k = (last_k + search_k_min) / 2;
                    search_k_max = last_k;
                }

                // the ending condition for binary search
                if ((search_k_max - search_k_min) > 1) {
                    options.kValues.push_back(next_k);
                }
            }
        }
    }

    savePostClusteringData();
}

// Assembly:
subq $0x418, %rsp            # imm = 0x418
movq %rdi, 0x410(%rsp)
movq 0x410(%rsp), %rdi
movq %rdi, 0x2b0(%rsp)
callq 0x127b0
movq 0x2b0(%rsp), %rdi
callq 0x15870
movq 0x2b0(%rsp), %rdi
callq 0x14e00
movq 0x2b0(%rsp), %rdi
callq 0x15dd0
movq 0x2b0(%rsp), %rax
movq (%rax), %rdi
callq 0xc0c0
movl %eax, %eax
movq %rax, 0x2b8(%rsp)
movl $0x0, 0x3f4(%rsp)
leaq 0x3f3(%rsp), %rdi
movq %rdi, 0x2c0(%rsp)
callq 0x10e30
movq 0x2b8(%rsp), %rsi
movq 0x2c0(%rsp), %rcx
leaq 0x3f8(%rsp), %rdi
leaq 0x3f4(%rsp), %rdx
callq 0x1a9a0
jmp 0x188bc
leaq 0x3f3(%rsp), %rdi
callq 0x10ec0
movq 0x2b0(%rsp), %rax
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0x2ac(%rsp)
jmp 0x188e2
movl 0x2ac(%rsp), %esi
leaq 0x3c8(%rsp), %rdi
callq 0x8d60
jmp 0x188f8
movq 0x2b0(%rsp), %rax
movl 0xc0(%rax), %ecx
movl %ecx, 0x3c4(%rsp)
movl $0x1, 0x3c0(%rsp)
movl $0x0, 0x3bc(%rsp)
movl $0x0, 0x3b8(%rsp)
testb $0x1, 0x88(%rax)
je 0x18a8a
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x2a0(%rsp)
jmp 0x1894c
movq 0x2a0(%rsp), %rdi
leaq 0x1b4ef(%rip), %rsi     # 0x33e4a
callq 0x5360
movq %rax, 0x298(%rsp)
jmp 0x1896a
movq 0x298(%rsp), %rdi
movl 0x3c4(%rsp), %esi
callq 0x5680
movq %rax, 0x290(%rsp)
jmp 0x18988
movq 0x290(%rsp), %rdi
movq 0x2b629(%rip), %rsi     # 0x43fc0
callq 0x53c0
jmp 0x1899e
movq 0x2b0(%rsp), %rdi
addq $0x90, %rdi
movq %rdi, 0x288(%rsp)
callq 0x1ad40
movq 0x288(%rsp), %rdi
leaq 0x3c0(%rsp), %rsi
callq 0x1ad60
jmp 0x189d1
movq 0x2b0(%rsp), %rdi
addq $0x90, %rdi
leaq 0x3c4(%rsp), %rsi
callq 0x1ad60
jmp 0x189ef
movq 0x2b0(%rsp), %rdi
addq $0x90, %rdi
movl 0x3c4(%rsp), %eax
movl 0x3c0(%rsp), %ecx
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
sarl %eax
movl %eax, 0x3b4(%rsp)
leaq 0x3b4(%rsp), %rsi
callq 0x1add0
jmp 0x18a2d
jmp 0x18b7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
leaq 0x3f3(%rsp), %rdi
callq 0x10ec0
jmp 0x19d7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
jmp 0x19d6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
jmp 0x19d62
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x280(%rsp)
jmp 0x18a9b
movq 0x280(%rsp), %rdi
leaq 0x1b3ca(%rip), %rsi     # 0x33e74
callq 0x5360
jmp 0x18ab1
movq 0x2b0(%rsp), %rax
testb $0x1, 0x89(%rax)
je 0x18b79
movq 0x2b0(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x14390
movq %rax, 0x278(%rsp)
jmp 0x18ae1
movq 0x2b0(%rsp), %rax
movq 0x278(%rsp), %rcx
movq %rcx, 0x3a8(%rsp)
addq $0x90, %rax
movq %rax, 0x268(%rsp)
movq 0x3a8(%rsp), %rdi
callq 0xc0c0
movl %eax, 0x274(%rsp)
jmp 0x18b1d
movq 0x268(%rsp), %rdi
movl 0x274(%rsp), %eax
movl %eax, 0x3a4(%rsp)
leaq 0x3a4(%rsp), %rsi
callq 0x1add0
jmp 0x18b42
movq 0x3a8(%rsp), %rax
movq %rax, 0x260(%rsp)
cmpq $0x0, %rax
je 0x18b77
movq 0x260(%rsp), %rdi
callq 0x10da0
movq 0x260(%rsp), %rdi
movl $0x30, %esi
callq 0x5390
jmp 0x18b79
jmp 0x18b7b
movq 0x2b0(%rsp), %rax
movslq 0xc4(%rax), %rax
movq %rax, 0x250(%rsp)
leaq 0x387(%rsp), %rdi
movq %rdi, 0x258(%rsp)
callq 0x1ae00
movq 0x250(%rsp), %rsi
movq 0x258(%rsp), %rdx
leaq 0x388(%rsp), %rdi
callq 0x1ae10
jmp 0x18bc6
leaq 0x387(%rsp), %rdi
callq 0x1ae90
movq 0x2b0(%rsp), %rax
movslq 0xc4(%rax), %rax
movq %rax, 0x240(%rsp)
leaq 0x367(%rsp), %rdi
movq %rdi, 0x248(%rsp)
callq 0x1ae00
movq 0x240(%rsp), %rsi
movq 0x248(%rsp), %rdx
leaq 0x368(%rsp), %rdi
callq 0x1ae10
jmp 0x18c1e
leaq 0x367(%rsp), %rdi
callq 0x1ae90
movq 0x2b0(%rsp), %rax
movslq 0xc4(%rax), %rax
movq %rax, 0x230(%rsp)
leaq 0x347(%rsp), %rdi
movq %rdi, 0x238(%rsp)
callq 0x99c0
movq 0x230(%rsp), %rsi
movq 0x238(%rsp), %rdx
leaq 0x348(%rsp), %rdi
callq 0x99d0
jmp 0x18c76
leaq 0x347(%rsp), %rdi
callq 0x9a50
movl $0x0, 0x340(%rsp)
movq 0x2b0(%rsp), %rdi
movl 0x340(%rsp), %eax
movq %rax, 0x228(%rsp)
addq $0x58, %rdi
addq $0x38, %rdi
callq 0x10df0
movq %rax, %rcx
movq 0x228(%rsp), %rax
cmpq %rcx, %rax
jae 0x19ce3
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x220(%rsp)
jmp 0x18cd7
movq 0x220(%rsp), %rdi
movq 0x2b2da(%rip), %rsi     # 0x43fc0
callq 0x53c0
movq %rax, 0x218(%rsp)
jmp 0x18cf5
movq 0x218(%rsp), %rdi
leaq 0x1b1b6(%rip), %rsi     # 0x33eba
callq 0x5360
movq %rax, 0x210(%rsp)
jmp 0x18d13
movq 0x210(%rsp), %rdi
leaq 0x1b17a(%rip), %rsi     # 0x33e9c
callq 0x5360
movq %rax, 0x208(%rsp)
jmp 0x18d31
movq 0x208(%rsp), %rdi
movl 0x340(%rsp), %esi
incl %esi
callq 0x5520
movq %rax, 0x200(%rsp)
jmp 0x18d51
movq 0x200(%rsp), %rdi
leaq 0x1d76f(%rip), %rsi     # 0x364cf
callq 0x5360
jmp 0x18d67
movq 0x2b0(%rsp), %rax
testb $0x1, 0x88(%rax)
je 0x18ea3
movq 0x2b0(%rsp), %rax
cvtsi2sdl 0xc0(%rax), %xmm0
callq 0x52d0
movsd %xmm0, 0x1f0(%rsp)
movsd 0x1a566(%rip), %xmm0    # 0x33308
callq 0x52d0
movaps %xmm0, %xmm1
movsd 0x1f0(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd 0x1a5e1(%rip), %xmm1    # 0x333a0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x33c(%rsp)
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x1f8(%rsp)
jmp 0x18ddf
movq 0x1f8(%rsp), %rdi
leaq 0x1b0ba(%rip), %rsi     # 0x33ea8
callq 0x5360
movq %rax, 0x1e8(%rsp)
jmp 0x18dfd
movq 0x1e8(%rsp), %rdi
movl 0x33c(%rsp), %esi
callq 0x5680
jmp 0x18e13
jmp 0x18edc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
leaq 0x387(%rsp), %rdi
callq 0x1ae90
jmp 0x19d62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
leaq 0x367(%rsp), %rdi
callq 0x1ae90
jmp 0x19d55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
leaq 0x347(%rsp), %rdi
callq 0x9a50
jmp 0x19d48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
jmp 0x19d3b
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x1e0(%rsp)
jmp 0x18eb4
movq 0x2b0(%rsp), %rdi
addq $0x90, %rdi
callq 0x10df0
movq 0x1e0(%rsp), %rdi
movq %rax, %rsi
callq 0x50e0
jmp 0x18eda
jmp 0x18edc
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x1d8(%rsp)
jmp 0x18eed
movq 0x1d8(%rsp), %rdi
leaq 0x1afb5(%rip), %rsi     # 0x33eb1
callq 0x5360
movq %rax, 0x1d0(%rsp)
jmp 0x18f0b
movq 0x2b0(%rsp), %rdi
addq $0x90, %rdi
movl 0x340(%rsp), %eax
movl %eax, %esi
callq 0x10dd0
movq 0x1d0(%rsp), %rdi
movl (%rax), %esi
callq 0x5680
movq %rax, 0x1c8(%rsp)
jmp 0x18f41
movq 0x1c8(%rsp), %rdi
movq 0x2b070(%rip), %rsi     # 0x43fc0
callq 0x53c0
movq %rax, 0x1c0(%rsp)
jmp 0x18f5f
movq 0x1c0(%rsp), %rdi
leaq 0x1af4c(%rip), %rsi     # 0x33eba
callq 0x5360
jmp 0x18f75
movl $0x0, 0x338(%rsp)
movl $0x0, 0x334(%rsp)
movq 0x2b0(%rsp), %rcx
movl 0x334(%rsp), %eax
cmpl 0xc4(%rcx), %eax
jge 0x1985d
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x1b8(%rsp)
jmp 0x18fb7
movq 0x1b8(%rsp), %rdi
leaq 0x1aef2(%rip), %rsi     # 0x33eb8
callq 0x5360
movq %rax, 0x1b0(%rsp)
jmp 0x18fd5
movq 0x1b0(%rsp), %rdi
leaq 0x1af16(%rip), %rsi     # 0x33efa
callq 0x5360
movq %rax, 0x1a8(%rsp)
jmp 0x18ff3
movq 0x1a8(%rsp), %rdi
movl 0x334(%rsp), %esi
incl %esi
callq 0x5680
movq %rax, 0x1a0(%rsp)
jmp 0x19013
movq 0x1a0(%rsp), %rdi
leaq 0x1d4ad(%rip), %rsi     # 0x364cf
callq 0x5360
movq %rax, 0x198(%rsp)
jmp 0x19031
movq 0x198(%rsp), %rdi
movq 0x2b0(%rsp), %rax
movl 0xc4(%rax), %esi
callq 0x5680
movq %rax, 0x190(%rsp)
jmp 0x19056
movq 0x190(%rsp), %rdi
leaq 0x1aeb3(%rip), %rsi     # 0x33f18
callq 0x5360
movq %rax, 0x188(%rsp)
jmp 0x19074
movq 0x188(%rsp), %rdi
movq 0x2b0(%rsp), %rax
movl 0xa8(%rax), %esi
callq 0x5680
movq %rax, 0x180(%rsp)
jmp 0x19099
movq 0x180(%rsp), %rdi
movq 0x2af18(%rip), %rsi     # 0x43fc0
callq 0x53c0
movq %rax, 0x178(%rsp)
jmp 0x190b7
movq 0x178(%rsp), %rdi
leaq 0x1adf2(%rip), %rsi     # 0x33eb8
callq 0x5360
jmp 0x190cd
movq 0x2b0(%rsp), %rdi
movl 0x340(%rsp), %esi
movl 0x334(%rsp), %edx
callq 0x14390
movq %rax, 0x170(%rsp)
jmp 0x190f2
movslq 0x334(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x1aa70
movq 0x170(%rsp), %rcx
movq %rcx, (%rax)
movl $0x30, %edi
callq 0x5380
movq %rax, 0x168(%rsp)
jmp 0x19126
movslq 0x334(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x1aa70
movq 0x168(%rsp), %rdi
movq (%rax), %rsi
callq 0xb050
jmp 0x1914d
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq 0x168(%rsp), %rdx
movq %rax, %rcx
movq 0x2b0(%rsp), %rax
movq %rdx, (%rcx)
movl 0x7c(%rax), %ecx
movl %ecx, 0x330(%rsp)
testb $0x1, 0x78(%rax)
je 0x191c0
movl $0x7fffffff, 0x330(%rsp) # imm = 0x7FFFFFFF
jmp 0x191c0
movq 0x168(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
movl $0x30, %esi
callq 0x5390
jmp 0x19d3b
movq 0x2b0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x160(%rsp)
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq 0x160(%rsp), %rdi
movq (%rax), %rsi
movl 0x330(%rsp), %edx
callq 0xf650
jmp 0x19202
movq 0x2b0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x150(%rsp)
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq 0x150(%rsp), %rdi
movq (%rax), %rsi
callq 0x107c0
movsd %xmm0, 0x158(%rsp)
jmp 0x19245
movslq 0x334(%rsp), %rsi
leaq 0x348(%rsp), %rdi
callq 0x9ba0
movsd 0x158(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x148(%rsp)
jmp 0x19278
movq 0x148(%rsp), %rdi
leaq 0x1acaa(%rip), %rsi     # 0x33f31
callq 0x5360
movq %rax, 0x140(%rsp)
jmp 0x19296
movslq 0x334(%rsp), %rsi
leaq 0x348(%rsp), %rdi
callq 0x9ba0
movq 0x140(%rsp), %rdi
movsd (%rax), %xmm0
callq 0x5700
movq %rax, 0x138(%rsp)
jmp 0x192c6
movq 0x138(%rsp), %rdi
movq 0x2aceb(%rip), %rsi     # 0x43fc0
callq 0x53c0
jmp 0x192dc
movslq 0x334(%rsp), %rsi
leaq 0x348(%rsp), %rdi
callq 0x9ba0
movsd (%rax), %xmm0
movsd %xmm0, 0x130(%rsp)
movslq 0x338(%rsp), %rsi
leaq 0x348(%rsp), %rdi
callq 0x9ba0
movsd 0x130(%rsp), %xmm0
ucomisd (%rax), %xmm0
jbe 0x19330
movl 0x334(%rsp), %eax
movl %eax, 0x338(%rsp)
movq 0x2b0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x128(%rsp)
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq 0x128(%rsp), %rdi
movq (%rax), %rsi
leaq 0x3f8(%rsp), %rdx
leaq 0x3c8(%rsp), %rcx
callq 0x101e0
jmp 0x1937a
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0x124(%rsp)
jmp 0x193a0
movl 0x124(%rsp), %esi
leaq 0x318(%rsp), %rdi
callq 0x8d60
jmp 0x193b6
movq 0x2b0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x110(%rsp)
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq 0x110(%rsp), %rdi
movq (%rax), %rdx
leaq 0x3f8(%rsp), %rsi
leaq 0x318(%rsp), %rcx
callq 0x10430
movsd %xmm0, 0x118(%rsp)
jmp 0x19409
movsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x310(%rsp)
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x108(%rsp)
jmp 0x1942c
movq 0x108(%rsp), %rdi
leaq 0x1ab04(%rip), %rsi     # 0x33f3f
callq 0x5360
movq %rax, 0x100(%rsp)
jmp 0x1944a
movq 0x100(%rsp), %rdi
movsd 0x310(%rsp), %xmm0
callq 0x5700
movq %rax, 0xf8(%rsp)
jmp 0x1946a
movq 0xf8(%rsp), %rdi
movq 0x2ab47(%rip), %rsi     # 0x43fc0
callq 0x53c0
movq %rax, 0xf0(%rsp)
jmp 0x19488
movq 0xf0(%rsp), %rdi
leaq 0x1aab7(%rip), %rsi     # 0x33f4e
callq 0x5360
jmp 0x1949e
movl $0x0, 0x30c(%rsp)
movl 0x30c(%rsp), %eax
movq %rax, 0xe8(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x9b60
movq %rax, %rcx
movq 0xe8(%rsp), %rax
cmpq %rcx, %rax
jae 0x1956f
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0xe0(%rsp)
jmp 0x194ea
movl 0x30c(%rsp), %eax
movl %eax, %esi
leaq 0x318(%rsp), %rdi
callq 0x9ba0
movq 0xe0(%rsp), %rdi
movsd (%rax), %xmm0
callq 0x5700
movq %rax, 0xd8(%rsp)
jmp 0x1951b
movq 0xd8(%rsp), %rdi
leaq 0x1cc7a(%rip), %rsi     # 0x361a4
callq 0x5360
jmp 0x19531
jmp 0x19533
movl 0x30c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30c(%rsp)
jmp 0x194a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3e8(%rsp)
movl %eax, 0x3e4(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x9bc0
jmp 0x19d3b
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0xd0(%rsp)
jmp 0x19580
movq 0xd0(%rsp), %rdi
movq 0x2aa31(%rip), %rsi     # 0x43fc0
callq 0x53c0
jmp 0x19596
movq 0x2b0(%rsp), %rax
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0xcc(%rsp)
jmp 0x195af
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0xc8(%rsp)
jmp 0x195d5
movl 0xc8(%rsp), %ecx
movl 0xcc(%rsp), %eax
subl %ecx, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x300(%rsp)
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0xc0(%rsp)
jmp 0x19604
movq 0xc0(%rsp), %rdi
leaq 0x1a953(%rip), %rsi     # 0x33f66
callq 0x5360
movq %rax, 0xb8(%rsp)
jmp 0x19622
movq 0xb8(%rsp), %rdi
movsd 0x310(%rsp), %xmm0
movsd 0x300(%rsp), %xmm1
divsd %xmm1, %xmm0
callq 0x5700
movq %rax, 0xb0(%rsp)
jmp 0x1964f
movq 0xb0(%rsp), %rdi
movq 0x2a962(%rip), %rsi     # 0x43fc0
callq 0x53c0
movq %rax, 0xa8(%rsp)
jmp 0x1966d
movq 0xa8(%rsp), %rdi
leaq 0x1a8f7(%rip), %rsi     # 0x33f73
callq 0x5360
jmp 0x19683
movl $0x0, 0x2fc(%rsp)
movl 0x2fc(%rsp), %eax
movq %rax, 0xa0(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x9b60
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
jae 0x19802
movslq 0x334(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq (%rax), %rdi
movl 0x2fc(%rsp), %esi
callq 0x10d30
movsd %xmm0, 0x98(%rsp)
jmp 0x196ed
movq 0x2b0(%rsp), %rax
movq (%rax), %rdi
callq 0xc0c0
movl %eax, 0x94(%rsp)
jmp 0x19706
movsd 0x98(%rsp), %xmm0
movl 0x94(%rsp), %eax
movl %eax, %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x2f0(%rsp)
movsd 0x2f0(%rsp), %xmm0
movsd 0x19b15(%rip), %xmm1    # 0x33250
ucomisd %xmm1, %xmm0
jbe 0x197b4
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x88(%rsp)
jmp 0x19752
movl 0x2fc(%rsp), %eax
movl %eax, %esi
leaq 0x318(%rsp), %rdi
callq 0x9ba0
movq 0x88(%rsp), %rdi
movsd (%rax), %xmm0
movsd 0x2f0(%rsp), %xmm1
movsd 0x19c23(%rip), %xmm2    # 0x333a8
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x5700
movq %rax, 0x80(%rsp)
jmp 0x1979c
movq 0x80(%rsp), %rdi
leaq 0x1c9f9(%rip), %rsi     # 0x361a4
callq 0x5360
jmp 0x197b2
jmp 0x197ea
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x78(%rsp)
jmp 0x197c2
movq 0x78(%rsp), %rdi
xorl %esi, %esi
callq 0x5680
movq %rax, 0x70(%rsp)
jmp 0x197d5
movq 0x70(%rsp), %rdi
leaq 0x1c9c3(%rip), %rsi     # 0x361a4
callq 0x5360
jmp 0x197e8
jmp 0x197ea
jmp 0x197ec
movl 0x2fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2fc(%rsp)
jmp 0x1968e
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x68(%rsp)
jmp 0x19810
movq 0x68(%rsp), %rdi
movq 0x2a7a4(%rip), %rsi     # 0x43fc0
callq 0x53c0
jmp 0x19823
movq 0x2b0(%rsp), %rax
movl 0xa8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xa8(%rax)
leaq 0x318(%rsp), %rdi
callq 0x9bc0
movl 0x334(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x334(%rsp)
jmp 0x18f8b
xorl %edi, %edi
callq 0x7ba0
movq %rax, 0x60(%rsp)
jmp 0x1986b
movq 0x60(%rsp), %rdi
leaq 0x1a712(%rip), %rsi     # 0x33f89
callq 0x5360
movq %rax, 0x58(%rsp)
jmp 0x19883
movq 0x58(%rsp), %rdi
movl 0x338(%rsp), %esi
incl %esi
callq 0x5680
movq %rax, 0x50(%rsp)
jmp 0x1989d
movq 0x50(%rsp), %rdi
movq 0x2a717(%rip), %rsi     # 0x43fc0
callq 0x53c0
jmp 0x198b0
movq 0x2b0(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x48(%rsp)
movslq 0x338(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x1aa70
movq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x1aea0
jmp 0x198e5
movq 0x2b0(%rsp), %rax
addq $0x28, %rax
movq %rax, 0x40(%rsp)
movslq 0x338(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x1aea0
jmp 0x1991a
movq 0x2b0(%rsp), %rax
addq $0x40, %rax
movq %rax, 0x38(%rsp)
movslq 0x338(%rsp), %rsi
leaq 0x348(%rsp), %rdi
callq 0x9ba0
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x1af10
jmp 0x1994f
movl $0x0, 0x2ec(%rsp)
movq 0x2b0(%rsp), %rcx
movl 0x2ec(%rsp), %eax
cmpl 0xc4(%rcx), %eax
jge 0x19a4d
movl 0x2ec(%rsp), %eax
cmpl 0x338(%rsp), %eax
je 0x199ff
movslq 0x2ec(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x1aa70
movq (%rax), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x199c1
movq 0x30(%rsp), %rdi
callq 0x10da0
movq 0x30(%rsp), %rdi
movl $0x30, %esi
callq 0x5390
movslq 0x2ec(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq (%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x199fd
movq 0x28(%rsp), %rdi
callq 0x10da0
movq 0x28(%rsp), %rdi
movl $0x30, %esi
callq 0x5390
jmp 0x199ff
movslq 0x2ec(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x1aa70
movq $0x0, (%rax)
movslq 0x2ec(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x1aa70
movq $0x0, (%rax)
movl 0x2ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2ec(%rsp)
jmp 0x1995a
movq 0x2b0(%rsp), %rax
testb $0x1, 0x88(%rax)
je 0x19ccb
movq 0x2b0(%rsp), %rdi
addq $0x40, %rdi
movl 0x340(%rsp), %eax
movl %eax, %esi
callq 0x9ba0
movq 0x2b0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x40, %rdi
movslq 0x3b8(%rsp), %rsi
callq 0x9ba0
movsd 0x20(%rsp), %xmm0
ucomisd (%rax), %xmm0
jbe 0x19ab9
movl 0x340(%rsp), %eax
movl %eax, 0x3b8(%rsp)
movq 0x2b0(%rsp), %rdi
addq $0x40, %rdi
movl 0x340(%rsp), %eax
movl %eax, %esi
callq 0x9ba0
movq 0x2b0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
addq $0x40, %rdi
movslq 0x3bc(%rsp), %rsi
callq 0x9ba0
movsd 0x18(%rsp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x19b14
movl 0x340(%rsp), %eax
movl %eax, 0x3bc(%rsp)
movq 0x2b0(%rsp), %rdi
addq $0x40, %rdi
movslq 0x3b8(%rsp), %rsi
callq 0x9ba0
movq 0x2b0(%rsp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0x40, %rdi
movslq 0x3bc(%rsp), %rsi
callq 0x9ba0
movsd 0x10(%rsp), %xmm0
movq 0x2b0(%rsp), %rdi
subsd (%rax), %xmm0
movsd %xmm0, 0x2e0(%rsp)
addq $0x40, %rdi
movslq 0x3bc(%rsp), %rsi
callq 0x9ba0
movq 0x2b0(%rsp), %rdi
movsd (%rax), %xmm1
movsd 0x2e0(%rsp), %xmm0
movsd 0xd8(%rdi), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x2d8(%rsp)
addq $0x58, %rdi
addq $0x38, %rdi
movl 0x340(%rsp), %eax
movl %eax, %esi
callq 0x10dd0
movl (%rax), %eax
movl %eax, 0x2d4(%rsp)
cmpl $0x2, 0x340(%rsp)
jb 0x19cc9
movl $0xffffffff, 0x2d0(%rsp) # imm = 0xFFFFFFFF
movl 0x3b8(%rsp), %eax
cmpl 0x3bc(%rsp), %eax
jle 0x19c1d
movq 0x2b0(%rsp), %rdi
addq $0x40, %rdi
callq 0x1af80
movsd (%rax), %xmm1
movsd 0x2d8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0xf(%rsp)
jmp 0x19c25
xorl %eax, %eax
movb %al, 0xf(%rsp)
jmp 0x19c25
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x2cf(%rsp)
testb $0x1, 0x2cf(%rsp)
je 0x19c69
movl 0x2d4(%rsp), %eax
addl 0x3c4(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0x2d0(%rsp)
movl 0x2d4(%rsp), %eax
movl %eax, 0x3c0(%rsp)
jmp 0x19c94
movl 0x2d4(%rsp), %eax
addl 0x3c0(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0x2d0(%rsp)
movl 0x2d4(%rsp), %eax
movl %eax, 0x3c4(%rsp)
movl 0x3c4(%rsp), %eax
subl 0x3c0(%rsp), %eax
cmpl $0x1, %eax
jle 0x19cc7
movq 0x2b0(%rsp), %rdi
addq $0x90, %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x1ad60
jmp 0x19cc5
jmp 0x19cc7
jmp 0x19cc9
jmp 0x19ccb
jmp 0x19ccd
movl 0x340(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x340(%rsp)
jmp 0x18c8e
movq 0x2b0(%rsp), %rdi
callq 0x17230
jmp 0x19cf2
leaq 0x348(%rsp), %rdi
callq 0x9960
leaq 0x368(%rsp), %rdi
callq 0x1afc0
leaq 0x388(%rsp), %rdi
callq 0x1afc0
leaq 0x3c8(%rsp), %rdi
callq 0x9bc0
leaq 0x3f8(%rsp), %rdi
callq 0x10ed0
addq $0x418, %rsp            # imm = 0x418
retq
leaq 0x348(%rsp), %rdi
callq 0x9960
leaq 0x368(%rsp), %rdi
callq 0x1afc0
leaq 0x388(%rsp), %rdi
callq 0x1afc0
leaq 0x3c8(%rsp), %rdi
callq 0x9bc0
leaq 0x3f8(%rsp), %rdi
callq 0x10ed0
movq 0x3e8(%rsp), %rdi
callq 0x5690
nopl (%rax)