// File: /workspace/github_cpp_makefile_star2_O1/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 0x9caa
movq %rbx, %rdi
callq 0xbae4
movq %rbx, %rdi
callq 0xb598
movq %rbx, %rdi
callq 0xbf92
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %esi # imm = 0xAAAAAAAB
leaq 0xb0(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0xc8(%rsp), %rdi
leaq 0x50(%rsp), %rcx
callq 0xf6d6
movq (%rbx), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %esi # imm = 0xAAAAAAAB
leaq 0xb0(%rsp), %rdi
callq 0x643c
movl 0xc0(%rbx), %eax
movl %eax, 0x8(%rsp)
movl $0x1, 0xc(%rsp)
leaq 0x18f3b(%rip), %r12     # 0x27330
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
cmpb $0x1, 0x88(%rbx)
jne 0xe499
leaq 0xea95(%rip), %rsi      # 0x1ceaa
movl $0x29, %edx
movq %r14, %rdi
callq 0x4330
movl 0x8(%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
cmpq %rax, 0x98(%rbx)
je 0xe46f
movq %rax, 0x98(%rbx)
leaq 0x90(%rbx), %r14
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0xe504
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe511
leaq 0xea34(%rip), %rsi      # 0x1ced4
movl $0x27, %edx
movq %r14, %rdi
callq 0x4330
cmpb $0x1, 0x89(%rbx)
jne 0xe5bf
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xaf6e
movq %rax, %r14
movq 0x8(%rax), %rax
subq (%r14), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
movl %eax, 0x50(%rsp)
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0xe584
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe595
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
callq 0x10e9c
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0xe534
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe541
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x10e9c
movl 0xc(%rsp), %ecx
addl 0x8(%rsp), %ecx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
movl %eax, 0x50(%rsp)
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0xe575
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xe5bf
leaq 0x50(%rsp), %rdx
movq %r14, %rdi
callq 0x10fbc
jmp 0xe5bf
leaq 0x90(%rbx), %rdi
leaq 0x50(%rsp), %rdx
callq 0x10fbc
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xe5aa
movq 0x28(%r14), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x7bf4
movl $0x30, %esi
movq %r14, %rdi
callq 0x42d0
movslq 0xc4(%rbx), %rsi
leaq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0xf8dc
movslq 0xc4(%rbx), %rsi
leaq 0x28(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0xf8dc
movslq 0xc4(%rbx), %rsi
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x6aee
movq 0x98(%rbx), %rax
cmpq 0x90(%rbx), %rax
je 0xf030
leaq 0x90(%rbx), %rax
movq %rax, 0x98(%rsp)
leaq 0x10(%rbx), %rax
movq %rax, 0xf0(%rsp)
leaq 0x28(%rbx), %rax
movq %rax, 0xe8(%rsp)
leaq 0x40(%rbx), %rax
movq %rax, 0xe0(%rsp)
leaq 0xe8c9(%rip), %rbp      # 0x1cf18
leaq 0x10(%rsp), %r13
xorl %eax, %eax
movq $0x0, 0x90(%rsp)
movq $0x0, 0x88(%rsp)
xorl %ecx, %ecx
movq %rbx, 0xa8(%rsp)
movq %rax, 0xa0(%rsp)
movq %rcx, 0x68(%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 0xe850(%rip), %rsi      # 0x1cf1a
callq 0x4330
movl $0xb, %edx
movq %r15, %rdi
leaq 0xe81e(%rip), %rsi      # 0x1cefc
callq 0x4330
movq 0x68(%rsp), %rax
leal 0x1(%rax), %esi
movq %r15, %rdi
movq %rsi, 0xf8(%rsp)
callq 0x41c0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x10e25(%rip), %rsi     # 0x1f52f
callq 0x4330
cmpb $0x1, 0x88(%rbx)
jne 0xe76f
cvtsi2sdl 0xc0(%rbx), %xmm0
callq 0x4220
movsd %xmm0, 0x48(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0x8, %edx
movq %r14, %rdi
leaq 0xe7c2(%rip), %rsi      # 0x1cf08
callq 0x4330
movsd 0x48(%rsp), %xmm0
divsd 0xdc77(%rip), %xmm0     # 0x1c3d0
addsd 0xdc77(%rip), %xmm0     # 0x1c3d8
cvttsd2si %xmm0, %esi
movq %r14, %rdi
callq 0x4560
jmp 0xe792
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 0xe764(%rip), %rsi      # 0x1cf11
callq 0x4330
movq 0x98(%rsp), %rax
movq (%rax), %rax
movq 0xa0(%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 0xe711(%rip), %rsi      # 0x1cf1a
callq 0x4330
cmpl $0x0, 0xc4(%rbx)
jle 0xed40
xorl %r15d, %r15d
movq $0x0, 0x40(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0x41, %edx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4330
movl $0x1d, %edx
movq %r14, %rdi
leaq 0xe708(%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 0x10cb2(%rip), %rsi     # 0x1f52f
callq 0x4330
movl 0xc4(%rbx), %esi
movq %r14, %rdi
callq 0x4560
movq %rax, %r14
movl $0x18, %edx
movq %rax, %rdi
leaq 0xe6d6(%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
movq %rbp, %rsi
callq 0x4330
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
movl %r15d, %edx
callq 0xaf6e
movq 0x50(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
movl $0x30, %edi
callq 0x42c0
movq %rax, %r14
movq 0x50(%rsp), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x6efc
movq 0x28(%rsp), %rax
movq %r14, (%rax,%r15,8)
cmpb $0x0, 0x78(%rbx)
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
jne 0xe93d
movl 0x7c(%rbx), %edx
movq 0x8(%rbx), %rdi
movq 0x28(%rsp), %rax
movq (%rax,%r15,8), %rsi
callq 0x8a50
movq (%rbx), %rdi
movq 0x28(%rsp), %rax
movq (%rax,%r15,8), %rsi
callq 0x92b8
movq 0x70(%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 0xe60b(%rip), %rsi      # 0x1cf91
callq 0x4330
movq 0x70(%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 0x70(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
movq 0x40(%rsp), %rcx
movslq %ecx, %rcx
ucomisd (%rax,%rcx,8), %xmm0
cmoval %r15d, %ecx
movq %rcx, 0x40(%rsp)
movq (%rbx), %rdi
movq 0x28(%rsp), %rax
movq (%rax,%r15,8), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
callq 0x8ef4
movq 0x28(%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 0x643c
movq (%rbx), %rdi
movq 0x28(%rsp), %rax
movq (%rax,%r15,8), %rdx
leaq 0xc8(%rsp), %rsi
movq %r13, %rcx
callq 0x9084
movsd %xmm0, 0x48(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0xe, %edx
movq %r14, %rdi
leaq 0xe536(%rip), %rsi      # 0x1cf9f
callq 0x4330
movq %r14, %rdi
movsd 0x48(%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 0xe4f9(%rip), %rsi      # 0x1cfae
callq 0x4330
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
leaq 0x10739(%rip), %r13     # 0x1f204
je 0xeb17
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 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0xead5
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 0x28(%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 0xe446(%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 0x48(%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 0xe3e1(%rip), %rsi      # 0x1cfd3
callq 0x4330
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
movq 0xa8(%rsp), %rbx
leaq 0x18720(%rip), %r12     # 0x27330
leaq 0x105ed(%rip), %r13     # 0x1f204
je 0xecb8
movl $0x1, %r14d
xorl %ecx, %ecx
movq 0x28(%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 0xd626(%rip), %xmm1     # 0x1c288
movq 0x8(%r12,%rdx,8), %rdi
jbe 0xec81
movsd (%rax,%rcx,8), %xmm0
addsd 0xd76a(%rip), %xmm1     # 0x1c3e0
divsd %xmm1, %xmm0
callq 0x4510
jmp 0xec88
xorl %esi, %esi
callq 0x4560
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x4330
movl %r14d, %ecx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
incl %r14d
cmpq %rcx, %rdx
ja 0xec25
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 0xa8(%rsp), %rbx
incl 0xa8(%rbx)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xed10
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movslq 0xc4(%rbx), %rax
movq 0x100(%rsp), %rcx
movq %rcx, %r15
cmpq %rax, %rcx
leaq 0x18604(%rip), %r12     # 0x27330
leaq 0xe1e5(%rip), %rbp      # 0x1cf18
leaq 0x10(%rsp), %r13
jl 0xe827
jmp 0xed49
movq $0x0, 0x40(%rsp)
movl (%r12), %eax
shrl $0x1f, %eax
movq 0x8(%r12,%rax,8), %r14
movl $0x2a, %edx
movq %r14, %rdi
leaq 0xe285(%rip), %rsi      # 0x1cfe9
callq 0x4330
movq 0x40(%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 0x50(%rsp), %rdx
addq %r15, %rdx
movq 0x18(%rbx), %rsi
cmpq 0x20(%rbx), %rsi
je 0xedca
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rbx)
jmp 0xedd7
movq 0xf0(%rsp), %rdi
callq 0x110b4
movq 0x28(%rsp), %rdx
addq %r15, %rdx
movq 0x30(%rbx), %rsi
cmpq 0x38(%rbx), %rsi
je 0xedf6
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x30(%rbx)
jmp 0xee03
movq 0xe8(%rsp), %rdi
callq 0x110b4
addq 0x70(%rsp), %r15
movq 0x48(%rbx), %rsi
cmpq 0x50(%rbx), %rsi
je 0xee25
movsd (%r15), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x48(%rbx)
jmp 0xee35
movq 0xe0(%rsp), %rdi
movq %r15, %rdx
callq 0x111d4
cmpl $0x0, 0xc4(%rbx)
jle 0xeee4
movl %r13d, %r15d
xorl %r13d, %r13d
cmpq %r13, %r15
je 0xeebd
movq 0x50(%rsp), %rax
movq (%rax,%r13,8), %r14
testq %r14, %r14
je 0xee85
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xee70
movq 0x28(%r14), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x7bf4
movl $0x30, %esi
movq %r14, %rdi
callq 0x42d0
movq 0x28(%rsp), %rax
movq (%rax,%r13,8), %r14
testq %r14, %r14
je 0xeebd
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0xeea8
movq 0x28(%r14), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x7bf4
movl $0x30, %esi
movq %r14, %rdi
callq 0x42d0
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
movq %rcx, (%rax,%r13,8)
movq 0x28(%rsp), %rax
movq %rcx, (%rax,%r13,8)
incq %r13
movslq 0xc4(%rbx), %rax
cmpq %rax, %r13
jl 0xee48
cmpb $0x0, 0x88(%rbx)
je 0xefa5
movq 0x40(%rbx), %rax
movq 0xa0(%rsp), %rsi
movsd (%rax,%rsi,8), %xmm0
movq 0x88(%rsp), %rcx
movslq %ecx, %rcx
ucomisd (%rax,%rcx,8), %xmm0
movq 0x68(%rsp), %rdi
cmoval %edi, %ecx
movq 0x90(%rsp), %rdx
movslq %edx, %rdx
movsd (%rax,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %edi, %edx
cmpl $0x2, %edi
leaq 0x10(%rsp), %r13
movq %rdx, 0x90(%rsp)
movq %rcx, 0x88(%rsp)
jb 0xefaa
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movslq %edx, %rdx
movsd (%rax,%rdx,8), %xmm1
subsd %xmm1, %xmm0
mulsd 0xd8(%rbx), %xmm0
movq 0x90(%rbx), %rax
movl (%rax,%rsi,4), %eax
movl $0xffffffff, 0x10(%rsp) # imm = 0xFFFFFFFF
cmpl %edx, %ecx
jle 0xefd4
addsd %xmm1, %xmm0
movq 0x48(%rbx), %rcx
ucomisd -0x8(%rcx), %xmm0
jbe 0xefd4
movl 0x8(%rsp), %ecx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
movl %edx, 0x10(%rsp)
movl %eax, 0xc(%rsp)
jmp 0xefeb
leaq 0x10(%rsp), %r13
movq 0xf8(%rsp), %rcx
movl %ecx, %edx
movq 0x98(%rbx), %rax
subq 0x90(%rbx), %rax
sarq $0x2, %rax
cmpq %rdx, %rax
movq %rdx, %rax
ja 0xe678
jmp 0xf030
movl 0xc(%rsp), %ecx
addl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
movl %edx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
subl 0xc(%rsp), %eax
cmpl $0x2, %eax
jl 0xefaa
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0xf01b
movl 0x10(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0xefaa
movq 0x98(%rsp), %rdi
movq %r13, %rdx
callq 0x10e9c
jmp 0xefaa
movq %rbx, %rdi
callq 0xcdf6
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xf052
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xf069
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xf080
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0xf09d
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0xf0ba
movq 0xd8(%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 0xf0ea
jmp 0xf0ea
jmp 0xf0ea
jmp 0xf10d
jmp 0xf10d
movq %rax, %rbx
jmp 0xf148
movq %rax, %rbx
jmp 0xf15f
jmp 0xf0ea
movq %rax, %rbx
jmp 0xf193
movq %rax, %rbx
jmp 0xf176
jmp 0xf10d
jmp 0xf10d
jmp 0xf10d
jmp 0xf10d
movq %rax, %rbx
movl $0x30, %esi
movq %r14, %rdi
jmp 0xf129
jmp 0xf10d
jmp 0xf114
jmp 0xf114
movq %rax, %rbx
jmp 0xf12e
jmp 0xf114
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf12e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xf148
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0xf15f
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xf176
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0xf193
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0xf1b0
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x4580