// File: /workspace/github_cpp_makefile_star2_O2/mapequation[P]partition-validation/./partition-validation.h
// Function: Partitions::printClusters()
void Partitions::printClusters() {
    cout << "--> Writing " << nClusters << " clusters..." << flush;

    my_ofstream ofs;
    ofs.open(outFileName.c_str());

    int i = 1;
    ofs << "# Clustered " << nTrainingPartitions << " partitions into " << clusters.size() << " clusters." << endl;
    ofs << "ClusterId PartitionId" << endl;
    for (auto &cluster: clusters) {
        for (auto &partition: cluster) {
            ofs << i << " " << partition->partitionId + 1 << endl;
        }
        i++;
    }

    ofs.close();

    string distanceOutFileName = outFileName;
    size_t periodPos = distanceOutFileName.find_last_of('.');

    if (periodPos == string::npos) {
        distanceOutFileName += "_distances";
    } else {
        distanceOutFileName.insert(periodPos, "_distances");
    }

    ofs.open(distanceOutFileName.c_str());
    i = 1;

    ofs << "# Clustered " << nTrainingPartitions << " partitions into " << clusters.size() << " clusters." << endl;
    ofs << "ClusterId1 ClusterId2 Distance" << endl;

    for (auto cluster1 = begin(clusters); cluster1 != end(clusters); cluster1++) {
        auto j = i + 1;
        for (auto cluster2 = next(cluster1); cluster2 != end(clusters); cluster2++) {
            auto partition1 = *cluster1->begin();
            auto partition2 = *cluster2->begin();
            ofs << i << " " << j << " " << wpJaccardDist(partition1, partition2) << endl;
            j++;
        }
        i++;
    }

    ofs.close();
    cout << "done!" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rdi, %r14
movq 0x9a5d(%rip), %rdi      # 0xdfd8
leaq 0x4c10(%rip), %rsi      # 0x9192
callq 0x3240
movl 0x4e0(%r14), %esi
movq %rax, %rdi
callq 0x33d0
leaq 0x4c02(%rip), %rsi      # 0x919f
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3190
leaq 0x48(%rsp), %rbx
pushq $0xf
popq %rsi
movq %rbx, %rdi
callq 0x585e
movq %r14, 0x8(%rsp)
movq 0x70(%r14), %rsi
pushq $0x10
popq %rdx
movq %rbx, %rdi
callq 0x3040
leaq 0x4bd4(%rip), %rsi      # 0x91ac
leaq 0x48(%rsp), %rdi
callq 0x3240
movq 0x8(%rsp), %rcx
movl 0x4e4(%rcx), %esi
movq %rax, %rdi
callq 0x33d0
leaq 0x4bbd(%rip), %rsi      # 0x91b9
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
movq 0x8(%rsp), %rcx
movq 0x40(%rcx), %rax
subq 0x38(%rcx), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x3180
leaq 0x4ba0(%rip), %rsi      # 0x91cb
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
leaq 0x4b94(%rip), %rsi      # 0x91d6
leaq 0x48(%rsp), %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
movq 0x8(%rsp), %rax
leaq 0x70(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x38(%rax), %r13
movq 0x40(%rax), %rax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rbp
leaq 0x48(%rsp), %r15
leaq 0x4a1e(%rip), %r12      # 0x909c
cmpq 0x10(%rsp), %r13
je 0x46cc
movq (%r13), %r14
movq 0x8(%r13), %rbx
cmpq %rbx, %r14
je 0x46c4
movq %r15, %rdi
movl %ebp, %esi
callq 0x33d0
movq %rax, %rdi
movq %r12, %rsi
callq 0x3240
movq (%r14), %rcx
movl (%rcx), %esi
incl %esi
movq %rax, %rdi
callq 0x33d0
movq %rax, %rdi
callq 0x3130
addq $0x8, %r14
jmp 0x468d
incl %ebp
addq $0x18, %r13
jmp 0x467e
leaq 0x48(%rsp), %rdi
callq 0x3330
leaq 0x28(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x3320
leaq 0x28(%rsp), %rdi
pushq $0x2e
popq %rsi
pushq $-0x1
popq %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x4711
leaq 0x4aea(%rip), %rdx      # 0x91ec
leaq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x3080
jmp 0x4722
leaq 0x4ad4(%rip), %rsi      # 0x91ec
leaq 0x28(%rsp), %rdi
callq 0x3400
movq 0x28(%rsp), %rsi
leaq 0x48(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3040
leaq 0x4a71(%rip), %rsi      # 0x91ac
leaq 0x48(%rsp), %rdi
callq 0x3240
movq 0x8(%rsp), %rcx
movl 0x4e4(%rcx), %esi
movq %rax, %rdi
callq 0x33d0
leaq 0x4a5a(%rip), %rsi      # 0x91b9
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
movq 0x8(%rsp), %rcx
movq 0x40(%rcx), %rax
subq 0x38(%rcx), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %rsi
callq 0x3180
leaq 0x4a3d(%rip), %rsi      # 0x91cb
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
leaq 0x4a52(%rip), %rsi      # 0x91f7
leaq 0x48(%rsp), %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
movq 0x8(%rsp), %rax
movq 0x38(%rax), %r15
movq 0x40(%rax), %rax
pushq $0x1
popq %rcx
movq %rcx, 0x10(%rsp)
cmpq %rax, %r15
je 0x4875
movq 0x10(%rsp), %rcx
leal 0x1(%rcx), %ebp
leaq 0x18(%r15), %r12
movq %r12, 0x20(%rsp)
movl %ebp, 0x18(%rsp)
cmpq %rax, %r12
je 0x4867
movq (%r15), %rax
movq (%rax), %r13
movq (%r12), %rax
movq (%rax), %r14
leaq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x33d0
movq %rax, %rdi
leaq 0x4887(%rip), %rsi      # 0x909c
callq 0x3240
movq %rax, %rdi
movl %ebp, %esi
callq 0x33d0
movq %rax, %rdi
leaq 0x486e(%rip), %rsi      # 0x909c
callq 0x3240
movq %rax, %rbx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x363e
movq %rbx, %rdi
callq 0x3380
movq %rax, %rdi
callq 0x3130
incl %ebp
addq $0x18, %r12
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rax
jmp 0x47ea
movq 0x20(%rsp), %r15
movl 0x18(%rsp), %ecx
jmp 0x47c7
leaq 0x48(%rsp), %rdi
callq 0x3330
movq 0x9752(%rip), %rdi      # 0xdfd8
leaq 0x48ff(%rip), %rsi      # 0x918c
callq 0x3240
movq %rax, %rdi
callq 0x3130
leaq 0x28(%rsp), %rdi
callq 0x3110
leaq 0x48(%rsp), %rdi
callq 0x58c0
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x48c8
jmp 0x48c8
jmp 0x48c8
jmp 0x48cd
movq %rax, %rbx
jmp 0x48da
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3110
leaq 0x48(%rsp), %rdi
callq 0x58c0
movq %rbx, %rdi
callq 0x33e0