// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
callq 0x9cf2
movq %rbx, %rdi
callq 0xbb1a
movq %rbx, %rdi
callq 0xb5e0
movq %rbx, %rdi
callq 0xbfcc
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %esi # imm = 0xAAAAAAAB
leaq 0xa8(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0xc0(%rsp), %rdi
leaq 0x48(%rsp), %rcx
callq 0xf660
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %esi # imm = 0xAAAAAAAB
leaq 0xa8(%rsp), %rdi
callq 0x641c
movl 0xc0(%rbx), %eax
movl %eax, (%rsp)
movl $0x1, 0x4(%rsp)
leaq 0x18fd6(%rip), %r12     # 0x27330
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
cmpb $0x1, 0x88(%rbx)
jne 0xe406
leaq 0xeb30(%rip), %rsi      # 0x1ceaa
movl $0x29, %edx
movq %r14, %rdi
callq 0x4330
movl (%rsp), %esi
movq %r14, %rdi
callq 0x4560
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movq 0x90(%rbx), %rax
movq 0x98(%rbx), %rsi
cmpq %rax, %rsi
je 0xe3d9
movq %rax, 0x98(%rbx)
movq %rax, %rsi
leaq 0x90(%rbx), %r14
movq 0xa0(%rbx), %rax
cmpq %rax, %rsi
je 0xe471
movl 0x4(%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe48c
leaq 0xeac7(%rip), %rsi      # 0x1ced4
movl $0x27, %edx
movq %r14, %rdi
callq 0x4330
cmpb $0x1, 0x89(%rbx)
jne 0xe52e
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xafb6
movq %rax, %r14
movq 0x8(%rax), %rax
subq (%r14), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl %eax, 0x48(%rsp)
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0xe4f3
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe504
leaq 0x4(%rsp), %rdx
movq %r14, %rdi
callq 0x10e6e
movq 0x98(%rbx), %rsi
movq 0xa0(%rbx), %rax
cmpq %rax, %rsi
je 0xe4a3
movl (%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe4bf
movq %rsp, %rdx
movq %r14, %rdi
callq 0x10e6e
movl (%rsp), %ecx
movq 0x98(%rbx), %rsi
movq 0xa0(%rbx), %rax
addl 0x4(%rsp), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
movl %edx, 0x48(%rsp)
cmpq %rax, %rsi
je 0xe4e4
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe52e
leaq 0x48(%rsp), %rdx
movq %r14, %rdi
callq 0x10f8e
jmp 0xe52e
leaq 0x90(%rbx), %rdi
leaq 0x48(%rsp), %rdx
callq 0x10f8e
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xe519
movq 0x28(%r14), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x7be2
movl $0x30, %esi
movq %r14, %rdi
callq 0x42d0
movslq 0xc4(%rbx), %rsi
leaq 0x48(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xf86e
movslq 0xc4(%rbx), %rsi
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0xf86e
movslq 0xc4(%rbx), %rsi
leaq 0x80(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x6ad6
movq 0x98(%rbx), %rax
cmpq 0x90(%rbx), %rax
je 0xef92
leaq 0x90(%rbx), %rbp
leaq 0x10(%rbx), %rax
movq %rax, 0xe8(%rsp)
leaq 0x28(%rbx), %rax
movq %rax, 0xe0(%rsp)
leaq 0x40(%rbx), %rax
movq %rax, 0xd8(%rsp)
leaq 0x8(%rsp), %r13
xorl %eax, %eax
movq $0x0, 0x68(%rsp)
movq $0x0, 0x60(%rsp)
xorl %ecx, %ecx
movq %rbx, 0xa0(%rsp)
movq %rbp, 0xf8(%rsp)
movq %rcx, 0x70(%rsp)
movq %rax, 0x98(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movq %rax, %r15
movl $0x3f, %edx
movq %rax, %rdi
leaq 0xe8e8(%rip), %rsi      # 0x1cf1a
callq 0x4330
movl $0xb, %edx
movq %r15, %rdi
leaq 0xe8b6(%rip), %rsi      # 0x1cefc
callq 0x4330
movq 0x70(%rsp), %rax
incl %eax
movl %eax, 0x7c(%rsp)
movl %eax, %esi
movq %r15, %rdi
movq %rsi, 0xf0(%rsp)
callq 0x41c0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x10eb8(%rip), %rsi     # 0x1f52f
callq 0x4330
cmpb $0x1, 0x88(%rbx)
jne 0xe6dc
cvtsi2sdl 0xc0(%rbx), %xmm0
callq 0x4220
movsd %xmm0, 0x40(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0x8, %edx
movq %r14, %rdi
leaq 0xe855(%rip), %rsi      # 0x1cf08
callq 0x4330
movsd 0x40(%rsp), %xmm0
divsd 0xdd12(%rip), %xmm0     # 0x1c3d8
addsd 0xdd12(%rip), %xmm0     # 0x1c3e0
cvttsd2si %xmm0, %esi
movq %r14, %rdi
callq 0x4560
jmp 0xe6ff
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %rdi
movq 0x98(%rbx), %rsi
subq 0x90(%rbx), %rsi
sarq $0x2, %rsi
callq 0x41c0
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0x6, %edx
movq %r14, %rdi
leaq 0xe7f7(%rip), %rsi      # 0x1cf11
callq 0x4330
movq (%rbp), %rax
movq 0x98(%rsp), %rcx
movl (%rax,%rcx,4), %esi
movq %r14, %rdi
callq 0x4560
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movl $0x3f, %edx
movq %rax, %rdi
leaq 0xe7ab(%rip), %rsi      # 0x1cf1a
callq 0x4330
cmpl $0x0, 0xc4(%rbx)
jle 0xecb8
xorl %r15d, %r15d
movq $0x0, 0x38(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0x41, %edx
movq %r14, %rdi
leaq 0xe770(%rip), %rsi      # 0x1cf18
callq 0x4330
movl $0x1d, %edx
movq %r14, %rdi
leaq 0xe79e(%rip), %rsi      # 0x1cf5a
callq 0x4330
leaq 0x1(%r15), %rsi
movq %r14, %rdi
movq %rsi, 0x100(%rsp)
callq 0x4560
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0x10d48(%rip), %rsi     # 0x1f52f
callq 0x4330
movl 0xc4(%rbx), %esi
movq %r14, %rdi
callq 0x4560
movq %rax, %r14
movl $0x18, %edx
movq %rax, %rdi
leaq 0xe76c(%rip), %rsi      # 0x1cf78
callq 0x4330
movl 0xa8(%rbx), %esi
movq %r14, %rdi
callq 0x4560
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movl $0x41, %edx
movq %rax, %rdi
leaq 0xe6c0(%rip), %rsi      # 0x1cf18
callq 0x4330
movq %rbx, %rdi
movq 0x70(%rsp), %rsi
movl %r15d, %edx
callq 0xafb6
movq 0x48(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
movl $0x30, %edi
callq 0x42c0
movq %rax, %r14
movq 0x48(%rsp), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x6ee8
movq 0x20(%rsp), %rax
movq %r14, (%rax,%r15,8)
cmpb $0x0, 0x78(%rbx)
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
jne 0xe8ab
movl 0x7c(%rbx), %edx
movq 0x8(%rbx), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rsi
callq 0x8a84
movq (%rbx), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rsi
callq 0x92d2
movq 0x80(%rsp), %rax
movsd %xmm0, (%rax,%r15,8)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0xd, %edx
movq %r14, %rdi
leaq 0xe69a(%rip), %rsi      # 0x1cf91
callq 0x4330
movq 0x80(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq %r14, %rdi
callq 0x4510
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movq 0x80(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x38(%rsp), %rcx
movslq %ecx, %rcx
ucomisd (%rax,%rcx,8), %xmm0
cmoval %r15d, %ecx
movq %rcx, 0x38(%rsp)
movq (%rbx), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rsi
leaq 0xc0(%rsp), %rdx
leaq 0xa8(%rsp), %rcx
callq 0x8f00
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %esi # imm = 0xAAAAAAAB
movq %r13, %rdi
callq 0x641c
movq (%rbx), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rdx
leaq 0xc0(%rsp), %rsi
movq %r13, %rcx
callq 0x9090
movsd %xmm0, 0x40(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0xe, %edx
movq %r14, %rdi
leaq 0xe5bf(%rip), %rsi      # 0x1cf9f
callq 0x4330
movq %r14, %rdi
movsd 0x40(%rsp), %xmm0
callq 0x4510
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movl $0x17, %edx
movq %rax, %rdi
leaq 0xe582(%rip), %rsi      # 0x1cfae
callq 0x4330
movq 0x8(%rsp), %rax
cmpq %rax, 0x10(%rsp)
leaq 0x107c2(%rip), %r13     # 0x1f204
je 0xea8e
movl $0x1, %r14d
xorl %ecx, %ecx
movl (%r12), %edx
shrl $0x1f, %edx
movq 0x8(%r12,%rdx,8), %rdi
movsd (%rax,%rcx,8), %xmm0
callq 0x4510
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x4330
movl %r14d, %ecx
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0xea4c
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movq (%rbx), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r13
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rax
movq %r12, %rcx
movq (%rax), %r12
movq 0x8(%rax), %rbx
movl (%rcx), %eax
shrl $0x1f, %eax
movq 0x8(%rcx,%rax,8), %r14
movl $0xc, %edx
movq %r14, %rdi
leaq 0xe4cf(%rip), %rsi      # 0x1cfc6
callq 0x4330
subq %r12, %rbx
shrq $0x3, %rbx
imull $0x55555555, %ebx, %eax # imm = 0x55555555
subq %rbp, %r13
shrq $0x3, %r13
imull $0xaaaaaaab, %r13d, %ecx # imm = 0xAAAAAAAB
addl %eax, %ecx
cvtsi2sd %rcx, %xmm1
movsd 0x40(%rsp), %xmm0
divsd %xmm1, %xmm0
movq %r14, %rdi
callq 0x4510
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movl $0x15, %edx
movq %rax, %rdi
leaq 0xe46a(%rip), %rsi      # 0x1cfd3
callq 0x4330
movq 0x8(%rsp), %rax
cmpq %rax, 0x10(%rsp)
movq 0xa0(%rsp), %rbx
leaq 0x187a9(%rip), %r12     # 0x27330
leaq 0x10676(%rip), %r13     # 0x1f204
je 0xec2f
movl $0x1, %r14d
xorl %ecx, %ecx
movq 0x20(%rsp), %rdx
movq (%rdx,%r15,8), %rdx
movq (%rbx), %rsi
movq 0x8(%rsi), %rdi
subq (%rsi), %rdi
shrq $0x3, %rdi
imull $0xaaaaaaab, %edi, %esi # imm = 0xAAAAAAAB
xorps %xmm1, %xmm1
cvtsi2sd %rsi, %xmm1
movq 0x18(%rdx), %rdx
mulsd (%rdx,%rcx,8), %xmm1
movl (%r12), %edx
shrl $0x1f, %edx
ucomisd 0xd6af(%rip), %xmm1     # 0x1c288
movq 0x8(%r12,%rdx,8), %rdi
jbe 0xebf8
movsd (%rax,%rcx,8), %xmm0
addsd 0xd7fb(%rip), %xmm1     # 0x1c3e8
divsd %xmm1, %xmm0
callq 0x4510
jmp 0xebff
xorl %esi, %esi
callq 0x4560
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x4330
movl %r14d, %ecx
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0xeb9c
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movq 0xa0(%rsp), %rbx
incl 0xa8(%rbx)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xec87
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movslq 0xc4(%rbx), %rax
movq 0x100(%rsp), %rcx
movq %rcx, %r15
cmpq %rax, %rcx
leaq 0x1868d(%rip), %r12     # 0x27330
movq 0xf8(%rsp), %rbp
leaq 0x8(%rsp), %r13
jl 0xe78d
jmp 0xecc1
movq $0x0, 0x38(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0x2a, %edx
movq %r14, %rdi
leaq 0xe30d(%rip), %rsi      # 0x1cfe9
callq 0x4330
movq 0x38(%rsp), %r13
leal 0x1(%r13), %esi
movq %r14, %rdi
callq 0x4560
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movslq %r13d, %r15
shlq $0x3, %r15
movq 0x48(%rsp), %rdx
addq %r15, %rdx
movq 0x18(%rbx), %rsi
cmpq 0x20(%rbx), %rsi
je 0xed42
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rbx)
jmp 0xed4f
movq 0xe8(%rsp), %rdi
callq 0x11086
movq 0x20(%rsp), %rdx
addq %r15, %rdx
movq 0x30(%rbx), %rsi
cmpq 0x38(%rbx), %rsi
je 0xed6e
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x30(%rbx)
jmp 0xed7b
movq 0xe0(%rsp), %rdi
callq 0x11086
addq 0x80(%rsp), %r15
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0xeda0
movsd (%r15), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x48(%rbx)
jmp 0xedb0
movq 0xd8(%rsp), %rdi
movq %r15, %rdx
callq 0x111a6
movl 0xc4(%rbx), %eax
testl %eax, %eax
jle 0xee62
movl %r13d, %r15d
xorl %r13d, %r13d
cmpq %r13, %r15
je 0xee3f
movq 0x48(%rsp), %rax
movq (%rax,%r13,8), %r14
testq %r14, %r14
je 0xedf4
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xedec
movq 0x28(%r14), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x7be2
movl $0x30, %esi
movq %r14, %rdi
callq 0x42d0
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %r14
testq %r14, %r14
je 0xee2c
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xee24
movq 0x28(%r14), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x7be2
movl $0x30, %esi
movq %r14, %rdi
callq 0x42d0
movl 0xc4(%rbx), %eax
movq 0x48(%rsp), %rcx
xorl %edx, %edx
movq %rdx, (%rcx,%r13,8)
movq 0x20(%rsp), %rcx
movq %rdx, (%rcx,%r13,8)
incq %r13
movslq %eax, %rcx
cmpq %rcx, %r13
jl 0xedc4
movq 0x90(%rbx), %rax
cmpb $0x0, 0x88(%rbx)
je 0xef1a
movq 0x40(%rbx), %rdx
movq 0x98(%rsp), %rcx
movsd (%rdx,%rcx,8), %xmm0
movq 0x60(%rsp), %rdi
movslq %edi, %rdi
ucomisd (%rdx,%rdi,8), %xmm0
movq 0x70(%rsp), %r8
cmoval %r8d, %edi
movq 0x68(%rsp), %rsi
movslq %esi, %rsi
movsd (%rdx,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %r8d, %esi
cmpl $0x2, %r8d
leaq 0x8(%rsp), %r13
movq %rsi, 0x68(%rsp)
movq %rdi, 0x60(%rsp)
jb 0xef1f
movl (%rax,%rcx,4), %ecx
cmpl %esi, %edi
jle 0xef44
movslq 0x60(%rsp), %rsi
movsd (%rdx,%rsi,8), %xmm0
movslq 0x68(%rsp), %rsi
movsd (%rdx,%rsi,8), %xmm1
subsd %xmm1, %xmm0
mulsd 0xd8(%rbx), %xmm0
addsd %xmm1, %xmm0
movq 0x48(%rbx), %rdx
ucomisd -0x8(%rdx), %xmm0
jbe 0xef44
movl (%rsp), %edi
leal (%rdi,%rcx), %esi
movl %esi, %edx
shrl $0x1f, %edx
addl %esi, %edx
sarl %edx
movl %edx, 0x8(%rsp)
movl %ecx, 0x4(%rsp)
movl %ecx, %esi
movl %edi, %ecx
jmp 0xef5b
leaq 0x8(%rsp), %r13
movq 0x98(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq 0xf0(%rsp), %rax
cmpq %rax, %rcx
movl 0x7c(%rsp), %ecx
ja 0xe5e0
jmp 0xef92
movl 0x4(%rsp), %esi
leal (%rsi,%rcx), %edi
movl %edi, %edx
shrl $0x1f, %edx
addl %edi, %edx
sarl %edx
movl %edx, 0x8(%rsp)
movl %ecx, (%rsp)
subl %esi, %ecx
cmpl $0x2, %ecx
jl 0xef1f
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0xef81
movl %edx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xef1f
movq %rbp, %rdi
movq %r13, %rdx
callq 0x10e6e
movq (%rbp), %rax
jmp 0xef1f
movq %rbx, %rdi
callq 0xce1e
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xefb7
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xefce
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xefe5
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0xf002
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xf01f
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf052
jmp 0xf052
jmp 0xf052
jmp 0xf075
jmp 0xf075
movq %rax, %rbx
jmp 0xf0b3
movq %rax, %rbx
jmp 0xf0ca
jmp 0xf052
movq %rax, %rbx
jmp 0xf0fe
movq %rax, %rbx
jmp 0xf0e1
jmp 0xf075
jmp 0xf075
jmp 0xf075
jmp 0xf075
movq %rax, %rbx
movl $0x30, %esi
movq %r14, %rdi
jmp 0xf091
jmp 0xf075
jmp 0xf07c
jmp 0xf07c
movq %rax, %rbx
jmp 0xf096
jmp 0xf07c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xf096
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xf0b3
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xf0ca
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xf0e1
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0xf0fe
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0xf11b
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x4580
nop