// File: /workspace/github_cpp_makefile_star2_O3/hanhwi[P]SimPoint/analysiscode/Simpoint.cpp
// Function: Simpoint::saveSimpointWeights(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<bool, std::allocator<bool>> const&, Dataset const&)
void Simpoint::saveSimpointWeights(const string &filename, 
        const vector<bool> &largestClusters, const Dataset &centers) {
    ofstream output(filename.c_str());
    Utilities::check(output.is_open(), "Simpoint::saveSimpointWeights(): could not open file " +
                            filename);
    double sumWeights = 0.0;
    for (unsigned int r = 0; r < centers.numRows(); r++) {
        if (largestClusters[r]) {
            sumWeights += centers.getWeight(r);
        }
    }

    for (unsigned int r = 0; r < centers.numRows(); r++) {
        if (largestClusters[r]) {
            output << (centers.getWeight(r) / sumWeights) << " " << r << endl;
        }
    }
    output.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rsi
leaq 0x28(%rsp), %rdi
movl $0x10, %edx
callq 0x4310
leaq 0x98(%rsp), %rdi
callq 0x40b0
movl %eax, %ebp
leaq 0x10018(%rip), %rsi     # 0x1cc26
leaq 0x8(%rsp), %rdi
movq %r15, %rdx
callq 0x5ea5
testb %bpl, %bpl
je 0xcd9c
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xcc3f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
testl %edx, %edx
je 0xcc94
movq (%r14), %rsi
movq 0x18(%rbx), %rdi
movl %edx, %r8d
xorpd %xmm1, %xmm1
xorl %r9d, %r9d
movl %r9d, %r10d
shrl $0x6, %r10d
movq (%rsi,%r10,8), %r10
btq %r9, %r10
jae 0xcc8a
addsd (%rdi,%r9,8), %xmm1
incq %r9
cmpq %r9, %r8
jne 0xcc73
jmp 0xcc98
xorpd %xmm1, %xmm1
testl %edx, %edx
je 0xcd4e
xorl %r15d, %r15d
leaq 0x28(%rsp), %r12
leaq 0x12555(%rip), %r13     # 0x1f204
movsd %xmm1, (%rsp)
movq (%r14), %rdx
movq %r15, %rsi
shrq $0x6, %rsi
movq (%rdx,%rsi,8), %rdx
btq %r15, %rdx
jae 0xcd32
movq 0x18(%rbx), %rax
movsd (%rax,%r15,8), %xmm0
divsd %xmm1, %xmm0
movq %r12, %rdi
callq 0x4510
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x4330
movq %rbp, %rdi
movq %r15, %rsi
callq 0x41c0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x4290
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x41d0
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movsd (%rsp), %xmm1
incq %r15
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %edx # imm = 0xAAAAAAAB
cmpq %rdx, %r15
jb 0xccb4
leaq 0x28(%rsp), %rdi
callq 0x4440
movq 0x1a269(%rip), %rax     # 0x26fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x4240
leaq 0x120(%rsp), %rdi
callq 0x4120
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a58d(%rip), %rax     # 0x27330
movl (%rax), %ecx
shrl $0x1f, %ecx
movq 0x8(%rax,%rcx,8), %rbx
leaq 0xf3c4(%rip), %rsi      # 0x1c178
movl $0x8, %edx
movq %rbx, %rdi
callq 0x4330
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x4160
movl $0x1, %edi
callq 0x4370
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xce0c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0xce0c
jmp 0xce09
jmp 0xce09
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x4480
movq %rbx, %rdi
callq 0x4580