// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movsd %xmm0, 0x30(%rsp)
movq %rdi, %rbx
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x10607(%rip), %rsi     # 0x1cb6e
leaq 0x10632(%rip), %rdx     # 0x1cba0
leaq 0x10(%rsp), %rdi
callq 0x6058
xorpd %xmm0, %xmm0
movsd 0x30(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0xc84b
movsd 0xfcf4(%rip), %xmm0     # 0x1c288
ucomisd %xmm1, %xmm0
jb 0xc84b
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xc5b5
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x8(%r15), %rax
subq (%r15), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %esi # imm = 0xAAAAAAAB
leaq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0xf576
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %r14
movq %r14, %rax
subq %r12, %rax
je 0xc63d
sarq $0x4, %rax
movq 0x18(%r15), %rcx
leaq 0x8(%r12), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm0
movsd %xmm0, -0x8(%rdx)
movl %esi, (%rdx)
incq %rsi
movl %esi, %edi
addq $0x10, %rdx
cmpq %rdi, %rax
ja 0xc5f6
cmpq %r12, %r14
je 0xc63d
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x107a2
movq %r12, %rdi
movq %r14, %rsi
callq 0x10855
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rax
cmpq %r14, %rax
setne %dl
leaq -0x10(%r14), %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xc688
movq %rax, %rdx
movsd (%rdx), %xmm0
movsd (%rcx), %xmm1
movsd %xmm1, (%rdx)
movsd %xmm0, (%rcx)
movl 0x8(%rdx), %esi
movl 0x8(%rcx), %edi
movl %edi, 0x8(%rdx)
movl %esi, 0x8(%rcx)
addq $0x10, %rdx
addq $-0x10, %rcx
cmpq %rcx, %rdx
jb 0xc65f
subq %rax, %r14
sarq $0x4, %r14
leaq 0xe(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0xf(%rsp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf5f8
leaq 0x1ac82(%rip), %r15     # 0x27330
xorl %eax, %eax
cmpl $0x0, (%r15)
setle %al
movq 0x8(%r15,%rax,8), %r14
leaq 0x104de(%rip), %rsi     # 0x1cba1
movl $0x34, %edx
movq %r14, %rdi
callq 0x4330
movq %r14, %rdi
movsd 0x30(%rsp), %xmm0
callq 0x4510
leaq 0x104f1(%rip), %rsi     # 0x1cbd6
movl $0x1f, %edx
movq %rax, %rdi
callq 0x4330
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0xc7ed
xorpd %xmm1, %xmm1
movsd 0x30(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xc7ed
movl $0x1, %ebp
movabsq $-0x8000000000000000, %r12 # imm = 0x8000000000000000
xorl %ecx, %ecx
leaq 0x3f(%r12), %r13
leaq 0x12ad1(%rip), %r14     # 0x1f204
shlq $0x4, %rcx
movsd (%rax,%rcx), %xmm0
ucomisd 0xfbfc(%rip), %xmm0     # 0x1c340
jbe 0xc7ed
movsd %xmm0, 0x38(%rsp)
movsd %xmm1, 0x40(%rsp)
addq %rcx, %rax
movslq 0x8(%rax), %rcx
leal 0x3f(%rcx), %eax
testq %rcx, %rcx
cmovnsl %ecx, %eax
sarl $0x6, %eax
cltq
shlq $0x3, %rax
addq (%rbx), %rax
movq %rcx, %rdx
andq %r13, %rdx
xorl %esi, %esi
cmpq %r12, %rdx
setbe %sil
movl $0x1, %edx
shlq %cl, %rdx
orq %rdx, -0x8(%rax,%rsi,8)
xorl %eax, %eax
cmpl $0x0, (%r15)
setle %al
movq 0x8(%r15,%rax,8), %rdi
movl %ecx, %esi
callq 0x4560
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x4330
movl %ebp, %ecx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
cmpq %rcx, %rdx
movsd 0x40(%rsp), %xmm1
movsd 0x38(%rsp), %xmm0
jbe 0xc7ed
addsd %xmm0, %xmm1
incl %ebp
movsd 0x30(%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0xc733
xorl %eax, %eax
cmpl $0x0, (%r15)
setle %al
movq 0x8(%r15,%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 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc839
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1aade(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rbx
leaq 0xf915(%rip), %rsi      # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
movl $0x1, %edi
callq 0x4370
jmp 0xc8ad
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0xc8dd
movq 0x20(%rsp), %rsi
incq %rsi
jmp 0xc8d8
movq %rax, %r14
jmp 0xc8c6
jmp 0xc8b4
movq %rax, %r14
jmp 0xc8dd
jmp 0xc8bb
movq %rax, %r14
movq %rbx, %rdi
callq 0x10db0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc8dd
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42d0
movq %r14, %rdi
callq 0x4580
movq %rax, %rdi
callq 0x5fb7
nop