// File: /workspace/github_cpp_makefile_star2_O2/hanhwi[P]SimPoint/analysiscode/Simpoint.cpp
// Function: Simpoint::getLargestClusters(double, Dataset const&)
vector<bool> Simpoint::getLargestClusters(double coveragePct, const Dataset &finalCenters) {
    Utilities::check(coveragePct >= 0 && coveragePct <= 1,
            "getLargestClusters(): coveragePct is out of bounds");

    // sort the clusters by size
    // the pair represents percentage (double) and cluster (int)
    vector<pair<double, int> > sortedClusters(finalCenters.numRows());
    for (unsigned int i = 0; i < sortedClusters.size(); i++) {
        sortedClusters[i] = make_pair(finalCenters.getWeight(i), i);
    }
    sort(sortedClusters.begin(), sortedClusters.end());
    reverse(sortedClusters.begin(), sortedClusters.end());

    // now that they're sorted, select the largest that fulfill the
    // desired percentage and mark them as largestClusters
    double percentExecution = 0.0;
    vector<bool> largestClusters(sortedClusters.size(), false); // order of orig. clusters
    Logger::log(1) << "    Largest non-empty clusters with total weight >= "
        << coveragePct << " (listed largest to smallest): ";
    for (unsigned int i = 0; (i < sortedClusters.size()) &&
            (percentExecution < coveragePct) &&
            (sortedClusters[i].first > 0.0); i++) {
        percentExecution += sortedClusters[i].first;
        largestClusters[sortedClusters[i].second] = true;
        Logger::log(1) << sortedClusters[i].second << " ";
    }
    Logger::log(1) << endl;

    return largestClusters;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %r14
movapd %xmm0, 0x30(%rsp)
movq %rdi, %rbx
leaq 0xb718(%rip), %rsi      # 0x15b1e
leaq 0x10(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x53a6
movsd 0xae33(%rip), %xmm0     # 0x15250
movapd 0x30(%rsp), %xmm2
movapd %xmm2, %xmm1
cmplepd %xmm0, %xmm1
xorpd %xmm0, %xmm0
cmplepd %xmm2, %xmm0
andpd %xmm1, %xmm0
movd %xmm0, %edi
andl $0x1, %edi
leaq 0x10(%rsp), %rsi
callq 0x5364
leaq 0x10(%rsp), %rdi
callq 0x45e8
movq 0x8(%r14), %rax
subq (%r14), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movl %eax, %esi
leaq 0x10(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0xc242
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %rsi, %rax
subq %rdi, %rax
sarq $0x4, %rax
movq 0x18(%r14), %rcx
xorl %edx, %edx
movl %edx, %r8d
cmpq %r8, %rax
jbe 0xa4af
movsd (%rcx,%r8,8), %xmm0
shlq $0x4, %r8
movsd %xmm0, (%rdi,%r8)
movl %edx, 0x8(%rdi,%r8)
incl %edx
jmp 0xa48e
callq 0xd543
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0xdb3a
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x4, %rsi
leaq 0x6(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x7(%rsp), %rcx
movq %rbx, %rdi
callq 0xc294
leaq 0x16e2b(%rip), %r15     # 0x21318
xorl %eax, %eax
cmpl $0x0, (%r15)
setle %al
movq 0x8(%r15,%rax,8), %rdi
leaq 0xb64f(%rip), %rsi      # 0x15b51
callq 0x4290
movq %rax, %rdi
movapd 0x30(%rsp), %xmm0
callq 0x44d0
leaq 0xb66a(%rip), %rsi      # 0x15b86
movq %rax, %rdi
callq 0x4290
xorl %r12d, %r12d
leaq 0xdc86(%rip), %r14      # 0x181b4
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movl %r12d, %r12d
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
cmpq %r12, %rcx
jbe 0xa5d0
movapd 0x30(%rsp), %xmm0
ucomisd 0x8(%rsp), %xmm0
jbe 0xa5d0
movq %r12, %r13
shlq $0x4, %r13
movsd (%rax,%r13), %xmm0
ucomisd 0xad94(%rip), %xmm0     # 0x15308
jbe 0xa5d0
movsd %xmm0, 0x48(%rsp)
addq %r13, %rax
movslq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0xc2f8
orq %rdx, (%rax)
xorl %eax, %eax
cmpl $0x0, (%r15)
setle %al
movq 0x8(%r15,%rax,8), %rdi
movq 0x10(%rsp), %rax
movl 0x8(%rax,%r13), %esi
callq 0x4510
movq %rax, %rdi
movq %r14, %rsi
callq 0x4290
movsd 0x8(%rsp), %xmm0
addsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
incl %r12d
jmp 0xa538
xorl %eax, %eax
cmpl $0x0, (%r15)
setle %al
movq 0x8(%r15,%rax,8), %rdi
callq 0x4180
leaq 0x10(%rsp), %rdi
callq 0xcc9e
movq %rbx, %rax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0xa600
movq %rax, %r14
jmp 0xa62a
jmp 0xa616
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x45e8
jmp 0xa634
movq %rax, %r14
jmp 0xa634
jmp 0xa61f
jmp 0xa61f
movq %rax, %r14
movq %rbx, %rdi
callq 0xc316
leaq 0x10(%rsp), %rdi
callq 0xcc9e
movq %r14, %rdi
callq 0x4530