// File: 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:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0xc8(%rsp)
movq %rdi, %rax
movq %rax, 0xd0(%rsp)
movq %rdi, 0x1b0(%rsp)
movsd %xmm0, 0x1a8(%rsp)
movq %rsi, 0x1a0(%rsp)
movsd 0x1a8(%rsp), %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, 0xdf(%rsp)
jb 0x16539
movsd 0x1cd2a(%rip), %xmm0    # 0x33250
ucomisd 0x1a8(%rsp), %xmm0
setae %al
movb %al, 0xdf(%rsp)
movb 0xdf(%rsp), %al
movb %al, 0xbf(%rsp)
leaq 0x17f(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x56a0
movq 0xc0(%rsp), %rdx
leaq 0x1d5a3(%rip), %rsi     # 0x33b0e
leaq 0x180(%rsp), %rdi
callq 0x74e0
jmp 0x1657a
movb 0xbf(%rsp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0x180(%rsp), %rsi
callq 0x7480
jmp 0x16596
leaq 0x180(%rsp), %rdi
callq 0x5788
leaq 0x17f(%rsp), %rdi
callq 0x53e0
movq 0x1a0(%rsp), %rdi
callq 0xc0c0
movl %eax, %eax
movq %rax, 0xa8(%rsp)
leaq 0x14f(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x1a340
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
leaq 0x150(%rsp), %rdi
callq 0x1a350
jmp 0x165fb
leaq 0x14f(%rsp), %rdi
callq 0x1a3d0
movl $0x0, 0x148(%rsp)
movl 0x148(%rsp), %eax
movq %rax, 0xa0(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x1a520
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
jae 0x167a1
movq 0x1a0(%rsp), %rdi
movl 0x148(%rsp), %esi
callq 0x10d30
movsd %xmm0, 0x98(%rsp)
jmp 0x16662
movsd 0x98(%rsp), %xmm0
movsd %xmm0, 0x130(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x1a750
movl %eax, 0x8c(%rsp)
movsd %xmm0, 0x90(%rsp)
jmp 0x1669b
movl 0x8c(%rsp), %eax
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x120(%rsp)
movl %eax, 0x128(%rsp)
movl 0x128(%rsp), %eax
movl %eax, 0x140(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x138(%rsp)
movl 0x148(%rsp), %eax
movl %eax, %esi
leaq 0x150(%rsp), %rdi
callq 0x1a410
movq %rax, %rdi
leaq 0x138(%rsp), %rsi
callq 0x1a790
jmp 0x16701
jmp 0x16703
movl 0x148(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x148(%rsp)
jmp 0x16613
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
jmp 0x16750
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x5788
leaq 0x17f(%rsp), %rdi
callq 0x53e0
jmp 0x16b2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
leaq 0x14f(%rsp), %rdi
callq 0x1a3d0
jmp 0x16b2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
jmp 0x16b1e
leaq 0x150(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x1a4a0
movq 0x80(%rsp), %rdi
movq %rax, 0x118(%rsp)
callq 0x1a4d0
movq %rax, 0x110(%rsp)
movq 0x118(%rsp), %rdi
movq 0x110(%rsp), %rsi
callq 0x1a7c0
jmp 0x167ea
leaq 0x150(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x1a4a0
movq 0x78(%rsp), %rdi
movq %rax, 0x108(%rsp)
callq 0x1a4d0
movq %rax, 0x100(%rsp)
movq 0x108(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0x1a800
jmp 0x1682d
movq $0x0, 0xf8(%rsp)
movb $0x0, 0xf7(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x1a520
movq %rax, 0x68(%rsp)
movb $0x0, 0xf6(%rsp)
leaq 0xf5(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x1a840
movq 0xc8(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rcx
leaq 0xf6(%rsp), %rdx
callq 0x1a850
jmp 0x1688e
leaq 0xf5(%rsp), %rdi
callq 0x1a8d0
movl $0x1, %edi
callq 0x7ba0
movq %rax, 0x60(%rsp)
jmp 0x168ac
movq 0x60(%rsp), %rdi
leaq 0x1d289(%rip), %rsi     # 0x33b41
callq 0x5360
movq %rax, 0x58(%rsp)
jmp 0x168c4
movq 0x58(%rsp), %rdi
movsd 0x1a8(%rsp), %xmm0
callq 0x5700
movq %rax, 0x50(%rsp)
jmp 0x168de
movq 0x50(%rsp), %rdi
leaq 0x1d28c(%rip), %rsi     # 0x33b76
callq 0x5360
jmp 0x168f1
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movq %rax, 0x40(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x1a520
movq 0x40(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x4f(%rsp)
jae 0x1696e
movsd 0xf8(%rsp), %xmm1
movsd 0x1a8(%rsp), %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
movb %al, 0x4f(%rsp)
jbe 0x1696e
movl 0xf0(%rsp), %eax
movl %eax, %esi
leaq 0x150(%rsp), %rdi
callq 0x1a410
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x1697b
jmp 0x16abe
movl 0xf0(%rsp), %eax
movl %eax, %esi
leaq 0x150(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x1a410
movq 0x28(%rsp), %rdi
movsd (%rax), %xmm1
movsd 0xf8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xf8(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, %esi
callq 0x1a410
movq 0xc8(%rsp), %rdi
movslq 0x8(%rax), %rsi
callq 0x1a8e0
movq %rdx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
jmp 0x169e0
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0xe0(%rsp)
movq %rax, 0xe8(%rsp)
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
movl %esi, 0x1c(%rsp)
callq 0x1a940
movl 0x1c(%rsp), %edi
callq 0x7ba0
movq %rax, 0x20(%rsp)
jmp 0x16a20
movl 0xf0(%rsp), %eax
movl %eax, %esi
leaq 0x150(%rsp), %rdi
callq 0x1a410
movq 0x20(%rsp), %rdi
movl 0x8(%rax), %esi
callq 0x5680
movq %rax, 0x10(%rsp)
jmp 0x16a4a
movq 0x10(%rsp), %rdi
leaq 0x1f74e(%rip), %rsi     # 0x361a4
callq 0x5360
jmp 0x16a5d
jmp 0x16a5f
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x168fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
leaq 0xf5(%rsp), %rdi
callq 0x1a8d0
jmp 0x16b1e
movq 0xc8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x170(%rsp)
movl %eax, 0x16c(%rsp)
callq 0x1a990
jmp 0x16b1e
movl $0x1, %edi
callq 0x7ba0
movq %rax, 0x8(%rsp)
jmp 0x16acf
movq 0x8(%rsp), %rdi
movq 0x2d4e5(%rip), %rsi     # 0x43fc0
callq 0x53c0
jmp 0x16ae2
movb $0x1, 0xf7(%rsp)
testb $0x1, 0xf7(%rsp)
jne 0x16b01
movq 0xc8(%rsp), %rdi
callq 0x1a990
leaq 0x150(%rsp), %rdi
callq 0x1a6f0
movq 0xd0(%rsp), %rax
addq $0x1b8, %rsp            # imm = 0x1B8
retq
leaq 0x150(%rsp), %rdi
callq 0x1a6f0
movq 0x170(%rsp), %rdi
callq 0x5690
nopl (%rax,%rax)