// File: 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:
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, 0x2b0(%rsp)
movq %rsi, 0x2a8(%rsp)
movq %rdx, 0x2a0(%rsp)
movq 0x2b0(%rsp), %rdi
callq 0x5190
movq %rax, %rsi
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movl $0x10, %edx
callq 0x53f0
movq 0x50(%rsp), %rdi
callq 0x5290
movb %al, 0x5f(%rsp)
jmp 0x16ff6
movq 0x2b0(%rsp), %rdx
leaq 0x1cbc1(%rip), %rsi     # 0x33bc6
leaq 0x70(%rsp), %rdi
callq 0x7880
jmp 0x17011
movb 0x5f(%rsp), %al
movzbl %al, %edi
andl $0x1, %edi
leaq 0x70(%rsp), %rsi
callq 0x7480
jmp 0x17027
leaq 0x70(%rsp), %rdi
callq 0x5788
xorps %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
movl %eax, 0x48(%rsp)
movq 0x2a0(%rsp), %rdi
callq 0xc0c0
movl %eax, 0x4c(%rsp)
jmp 0x1705d
movl 0x48(%rsp), %eax
movl 0x4c(%rsp), %ecx
cmpl %ecx, %eax
jae 0x1710b
movq 0x2a8(%rsp), %rdi
movl 0x64(%rsp), %eax
movl %eax, %esi
callq 0x1aa20
movb %al, 0x47(%rsp)
jmp 0x17086
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x17090
jmp 0x170f9
movq 0x2a0(%rsp), %rdi
movl 0x64(%rsp), %esi
callq 0x10d30
movsd %xmm0, 0x38(%rsp)
jmp 0x170a9
movsd 0x38(%rsp), %xmm0
addsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
jmp 0x170f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
jmp 0x17216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x5788
jmp 0x17216
jmp 0x170fb
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x17042
movl $0x0, 0x60(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0x2a0(%rsp), %rdi
callq 0xc0c0
movl %eax, 0x34(%rsp)
jmp 0x1712e
movl 0x30(%rsp), %eax
movl 0x34(%rsp), %ecx
cmpl %ecx, %eax
jae 0x171f2
movq 0x2a8(%rsp), %rdi
movl 0x60(%rsp), %eax
movl %eax, %esi
callq 0x1aa20
movb %al, 0x2f(%rsp)
jmp 0x17157
movb 0x2f(%rsp), %al
testb $0x1, %al
jne 0x17161
jmp 0x171e0
movq 0x2a0(%rsp), %rdi
movl 0x60(%rsp), %esi
callq 0x10d30
movsd %xmm0, 0x20(%rsp)
jmp 0x1717a
movsd 0x20(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0xa0(%rsp), %rdi
callq 0x5700
movq %rax, 0x18(%rsp)
jmp 0x1719e
movq 0x18(%rsp), %rdi
leaq 0x1effa(%rip), %rsi     # 0x361a4
callq 0x5360
movq %rax, 0x10(%rsp)
jmp 0x171b6
movq 0x10(%rsp), %rdi
movl 0x60(%rsp), %esi
callq 0x5520
movq %rax, 0x8(%rsp)
jmp 0x171cb
movq 0x8(%rsp), %rdi
movq 0x2cde9(%rip), %rsi     # 0x43fc0
callq 0x53c0
jmp 0x171de
jmp 0x171e0
jmp 0x171e2
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x17113
leaq 0xa0(%rsp), %rdi
callq 0x5560
jmp 0x17201
leaq 0xa0(%rsp), %rdi
callq 0x55a0
addq $0x2b8, %rsp            # imm = 0x2B8
retq
leaq 0xa0(%rsp), %rdi
callq 0x55a0
movq 0x98(%rsp), %rdi
callq 0x5690