// File: /workspace/github_cpp_makefile_star2_O1/hanhwi[P]SimPoint/analysiscode/Simpoint.cpp
// Function: Simpoint::loadInitialCenters(int, int) const
Dataset *Simpoint::loadInitialCenters(int runNumber, int seedNumber) const {
    Dataset *centers = NULL;
    // user has provided initial labels?
    if (options.loadInitialLabelsName != "") {
        centers = loadInitialCentersFromLabels(options.loadInitialLabelsName,
                                               *wholeDataset);
    // user has provided initial centers?
    } else if (options.loadInitialCentersName != "") {
        Utilities::check(isRegularFile(options.loadInitialCentersName),
                "loadInitialCenters() not regular file: " +
                options.loadInitialCentersName);
        centers = new Dataset;
        ifstream input(options.loadInitialCentersName.c_str());
        Utilities::check(input.is_open(), "Simpoint::loadInitialCenters(): could not open file " +
                                options.loadInitialCentersName);
        centers->read(input);
        input.close();
        Logger::log() << "  Loaded initial k-means centers from file '"
             << options.loadInitialCentersName << "' (k = " 
             << centers->numRows() << ")\n";
        Utilities::check(centers->numCols() == wholeDataset->numCols(),
            "loadInitialCenters(): initial centers dimension != "
            "projected data dimension");

        // user has not provided initial labels or centers; create the initial centers
    } else {
        centers = new Dataset(options.kValues[runNumber],
                                     wholeDataset->numCols());
        if (options.kMeansInitType == "samp") {
            KMeans::initializeRandomly(options.randSeedKMeansInit + seedNumber,
                    *wholeDataset, centers);
            Logger::log() << "  Initialized k-means centers using random sampling: " 
                << options.kValues[runNumber] << " centers\n";
        } else if (options.kMeansInitType == "ff") {
            KMeans::initializeFurthestFirst(options.randSeedKMeansInit + seedNumber,
                    *wholeDataset, centers);
            Logger::log() << "  Initialized k-means centers using furthest-first: " 
                << options.kValues[runNumber] << " centers\n";
        } else {
            Utilities::check(false, 
                    "loadInitialCenters(): unknown k-means initialization type");
        }
    }

    // Set the (VLI) weights for the centers properly. If vectors should not be
    // VLI-weighted, the appropriate weights should (will) be applied outside
    // this scope, after this function completes.
    for (unsigned int i = 0; i < centers->numRows(); i++) {
        centers->setWeight(i, 0.0);
    }
    vector<int> labels(wholeDataset->numRows());
    KMeans::findLabelsAndDists(*wholeDataset, *centers, &labels);
    for (unsigned int i = 0; i < wholeDataset->numRows(); i++) {
        centers->setWeight(labels[i],
                wholeDataset->getWeight(i) + centers->getWeight(labels[i]));
    }

    // make sure the center weights add to 1.0
    double totalWeight = 0.0;
    for (unsigned int i = 0; i < centers->numRows(); i++) {
        totalWeight += centers->getWeight(i);
    }
    for (unsigned int i = 0; i < centers->numRows(); i++) {
        centers->setWeight(i, centers->getWeight(i) / totalWeight);
    }

    return centers;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movl %edx, %ebp
movl %esi, %r12d
movq %rdi, %r14
leaq 0x280(%rdi), %rbx
leaq 0x112a5(%rip), %rsi     # 0x1c23a
movq %rbx, %rdi
callq 0x40e0
testl %eax, %eax
je 0xafb4
movq (%r14), %rsi
movq %rbx, %rdi
callq 0xab04
movq %rax, %rbx
jmp 0xb2a2
leaq 0x260(%r14), %r15
leaq 0x11278(%rip), %rsi     # 0x1c23a
movq %r15, %rdi
callq 0x40e0
testl %eax, %eax
je 0xb1aa
movq (%r15), %rdi
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x4280
movl %eax, %ebp
movl $0xf000, %r12d          # imm = 0xF000
andl 0x18(%rbx), %r12d
leaq 0x11789(%rip), %rsi     # 0x1c77e
leaq 0x20(%rsp), %rdi
movq %r15, %rdx
callq 0x5ed9
testl %ebp, %ebp
jne 0xb3c7
cmpl $0x8000, %r12d          # imm = 0x8000
jne 0xb3c7
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb032
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42d0
movl $0x30, %edi
callq 0x42c0
movq %rax, %rbx
movq %rax, %rdi
callq 0x6d94
movq (%r15), %rsi
leaq 0x20(%rsp), %rdi
movl $0x8, %edx
callq 0x45a0
leaq 0x98(%rsp), %rdi
callq 0x40b0
movl %eax, %ebp
leaq 0x11737(%rip), %rsi     # 0x1c7a6
movq %rsp, %rdi
movq %r15, %rdx
callq 0x5ed9
testb %bpl, %bpl
je 0xb408
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb09e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x7220
leaq 0x20(%rsp), %rdi
callq 0x40a0
leaq 0x1c274(%rip), %rcx     # 0x27330
movl (%rcx), %eax
shrl $0x1f, %eax
movq 0x8(%rcx,%rax,8), %r15
leaq 0x1170e(%rip), %rsi     # 0x1c7db
movl $0x2c, %edx
movq %r15, %rdi
callq 0x4330
movq 0x260(%r14), %rsi
movq 0x268(%r14), %rdx
movq %r15, %rdi
callq 0x4330
movq %rax, %r15
leaq 0x1170e(%rip), %rsi     # 0x1c808
movl $0x7, %edx
movq %rax, %rdi
callq 0x4330
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %esi # imm = 0xAAAAAAAB
movq %r15, %rdi
callq 0x41c0
leaq 0x118ba(%rip), %rsi     # 0x1c9e1
movl $0x2, %edx
movq %rax, %rdi
callq 0x4330
movq (%rbx), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r15
movq (%r14), %rax
movq (%rax), %rax
movq (%rax), %r12
movq 0x8(%rax), %r13
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x116b3(%rip), %rsi     # 0x1c810
leaq 0x116f7(%rip), %rdx     # 0x1c85b
callq 0x6086
subq %r12, %r13
shrq $0x3, %r13
subq %rbp, %r15
shrq $0x3, %r15
cmpl %r13d, %r15d
jne 0xb448
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb19b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0x20(%rsp), %rdi
callq 0x40c0
jmp 0xb2a2
movl $0x30, %edi
callq 0x42c0
movq %rax, %rbx
movslq %r12d, %r12
movq (%r14), %rax
movq 0x90(%r14), %rcx
movl (%rcx,%r12,4), %esi
movq (%rax), %rax
movq 0x8(%rax), %rdx
subq (%rax), %rdx
shrq $0x3, %rdx
movq %rbx, %rdi
callq 0x6e50
leaq 0xe0(%r14), %r15
leaq 0x11670(%rip), %rsi     # 0x1c85c
movq %r15, %rdi
callq 0x40e0
testl %eax, %eax
je 0xb242
leaq 0x1324f(%rip), %rsi     # 0x1e44e
movq %r15, %rdi
callq 0x40e0
testl %eax, %eax
jne 0xb490
addl 0xa8(%r14), %ebp
movq (%r14), %rsi
movl %ebp, %edi
movq %rbx, %rdx
callq 0x8866
leaq 0x1c106(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %r15
leaq 0x11666(%rip), %rsi     # 0x1c8a1
movl $0x34, %edx
jmp 0xb273
addl 0xa8(%r14), %ebp
movq (%r14), %rsi
movl %ebp, %edi
movq %rbx, %rdx
callq 0x8798
leaq 0x1c0d3(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %r15
leaq 0x115f3(%rip), %rsi     # 0x1c861
movl $0x35, %edx
movq %r15, %rdi
callq 0x4330
movq 0x90(%r14), %rax
movl (%rax,%r12,4), %esi
movq %r15, %rdi
callq 0x4560
leaq 0x11602(%rip), %rsi     # 0x1c897
movl $0x9, %edx
movq %rax, %rdi
callq 0x4330
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r15, %rax
testl %eax, %eax
je 0xb2d0
movq 0x18(%rbx), %rdi
movl %eax, %edx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x4190
movq (%r14), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %esi # imm = 0xAAAAAAAB
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x950a
movq (%r14), %rdi
leaq 0x20(%rsp), %rdx
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x8ef4
movq (%r14), %rcx
movq 0x8(%rcx), %rsi
subq (%rcx), %rsi
sarq $0x3, %rsi
imulq %r15, %rsi
testl %esi, %esi
je 0xb347
movq 0x20(%rsp), %rax
movq 0x18(%rcx), %rcx
movq 0x18(%rbx), %rdx
movl %esi, %esi
xorl %edi, %edi
movl (%rax,%rdi,4), %r8d
movsd (%rcx,%rdi,8), %xmm0
addsd (%rdx,%r8,8), %xmm0
movsd %xmm0, (%rdx,%r8,8)
incq %rdi
cmpq %rdi, %rsi
jne 0xb32a
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x3, %rax
imulq %r15, %rax
testl %eax, %eax
je 0xb375
movq 0x18(%rbx), %rcx
movl %eax, %edx
xorpd %xmm0, %xmm0
xorl %esi, %esi
addsd (%rcx,%rsi,8), %xmm0
incq %rsi
cmpq %rsi, %rdx
jne 0xb366
jmp 0xb379
xorpd %xmm0, %xmm0
testl %eax, %eax
je 0xb39b
movq 0x18(%rbx), %rcx
movl %eax, %eax
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xb385
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xb3b2
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %rbx, %rax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1bf62(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rbx
leaq 0x10d99(%rip), %rsi     # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
jmp 0xb486
leaq 0x1bf21(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rbx
leaq 0x10d58(%rip), %rsi     # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
jmp 0xb486
leaq 0x1bee1(%rip), %rcx     # 0x27330
movl (%rcx), %eax
shrl $0x1f, %eax
movq 0x8(%rcx,%rax,8), %rbx
leaq 0x10d18(%rip), %rsi     # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
movl $0x1, %edi
callq 0x4370
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x11436(%rip), %rsi     # 0x1c8d6
leaq 0x11468(%rip), %rdx     # 0x1c90f
leaq 0x20(%rsp), %rdi
callq 0x6086
leaq 0x1be78(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rbx
leaq 0x10caf(%rip), %rsi     # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
jmp 0xb486
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
jne 0xb547
jmp 0xb590
jmp 0xb57e
jmp 0xb555
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
jmp 0xb522
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb586
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0xb586
movq %rax, %r14
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb590
movq 0x30(%rsp), %rsi
incq %rsi
jmp 0xb577
jmp 0xb583
jmp 0xb583
movq %rax, %r14
movl $0x30, %esi
movq %rbx, %rdi
jmp 0xb577
movq %rax, %r14
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xb590
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
jmp 0xb590
movq %rax, %r14
jmp 0xb590
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x40c0
movq %r14, %rdi
callq 0x4580