// File: 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
movq %rsp, %rbp
subq $0x3c0, %rsp            # imm = 0x3C0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq 0x1f86f(%rip), %rdi     # 0x24fd0
leaq 0x12a1e(%rip), %rsi     # 0x18186
callq 0x32c0
movq %rax, %rdi
movq -0x2f0(%rbp), %rax
movl 0x4e0(%rax), %esi
callq 0x3490
movq %rax, %rdi
leaq 0x12a07(%rip), %rsi     # 0x18193
callq 0x32c0
movq %rax, %rdi
movq 0x1f83d(%rip), %rsi     # 0x24fd8
callq 0x3310
leaq -0x208(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
movl $0xf, %esi
callq 0x8e50
movq -0x2f0(%rbp), %rdi
addq $0x70, %rdi
callq 0x3120
movq -0x2e8(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0x3050
jmp 0x57de
movl $0x1, -0x218(%rbp)
leaq 0x129b1(%rip), %rsi     # 0x181a0
leaq -0x208(%rbp), %rdi
callq 0x32c0
movq %rax, -0x2f8(%rbp)
jmp 0x5804
movq -0x2f8(%rbp), %rdi
movq -0x2f0(%rbp), %rax
movl 0x4e4(%rax), %esi
callq 0x3490
movq %rax, -0x300(%rbp)
jmp 0x5826
movq -0x300(%rbp), %rdi
leaq 0x12979(%rip), %rsi     # 0x181ad
callq 0x32c0
movq %rax, -0x308(%rbp)
jmp 0x5842
movq -0x2f0(%rbp), %rdi
addq $0x38, %rdi
callq 0x96c0
movq -0x308(%rbp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, -0x310(%rbp)
jmp 0x586a
movq -0x310(%rbp), %rdi
leaq 0x12947(%rip), %rsi     # 0x181bf
callq 0x32c0
movq %rax, -0x318(%rbp)
jmp 0x5886
movq -0x318(%rbp), %rdi
movq 0x1f72c(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x589b
leaq 0x12928(%rip), %rsi     # 0x181ca
leaq -0x208(%rbp), %rdi
callq 0x32c0
movq %rax, -0x320(%rbp)
jmp 0x58b7
movq -0x320(%rbp), %rdi
movq 0x1f6fb(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x58cc
movq -0x2f0(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x220(%rbp)
movq -0x220(%rbp), %rdi
callq 0x96f0
movq %rax, -0x228(%rbp)
movq -0x220(%rbp), %rdi
callq 0x9720
movq %rax, -0x230(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x9750
testb $0x1, %al
jne 0x5920
jmp 0x5a4f
leaq -0x228(%rbp), %rdi
callq 0x9790
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rdi
callq 0x97b0
movq %rax, -0x248(%rbp)
movq -0x240(%rbp), %rdi
callq 0x97e0
movq %rax, -0x250(%rbp)
leaq -0x248(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x9810
testb $0x1, %al
jne 0x5983
jmp 0x5a2f
leaq -0x248(%rbp), %rdi
callq 0x9850
movq %rax, -0x258(%rbp)
movl -0x218(%rbp), %esi
leaq -0x208(%rbp), %rdi
callq 0x3490
movq %rax, -0x328(%rbp)
jmp 0x59b1
movq -0x328(%rbp), %rdi
leaq 0x126d1(%rip), %rsi     # 0x18090
callq 0x32c0
movq %rax, -0x330(%rbp)
jmp 0x59cd
movq -0x330(%rbp), %rdi
movq -0x258(%rbp), %rax
movq (%rax), %rax
movl (%rax), %esi
incl %esi
callq 0x3490
movq %rax, -0x338(%rbp)
jmp 0x59f0
movq -0x338(%rbp), %rdi
movq 0x1f5c2(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x5a05
jmp 0x5a07
leaq -0x248(%rbp), %rdi
callq 0x9870
jmp 0x5967
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x5ed0
movl -0x218(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x218(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x9890
jmp 0x5904
leaq -0x208(%rbp), %rdi
callq 0x3410
jmp 0x5a5d
movq -0x2f0(%rbp), %rsi
addq $0x70, %rsi
leaq -0x278(%rbp), %rdi
callq 0x3130
jmp 0x5a76
leaq -0x278(%rbp), %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x3510
movq %rax, -0x280(%rbp)
cmpq $-0x1, -0x280(%rbp)
jne 0x5ad9
leaq 0x1273a(%rip), %rsi     # 0x181e0
leaq -0x278(%rbp), %rdi
callq 0x32a0
jmp 0x5ab4
jmp 0x5af7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x31a0
jmp 0x5ed0
movq -0x280(%rbp), %rsi
leaq 0x126f9(%rip), %rdx     # 0x181e0
leaq -0x278(%rbp), %rdi
callq 0x30b0
jmp 0x5af5
jmp 0x5af7
leaq -0x278(%rbp), %rdi
callq 0x3120
movq %rax, %rsi
leaq -0x208(%rbp), %rdi
movl $0x10, %edx
callq 0x3050
jmp 0x5b19
movl $0x1, -0x218(%rbp)
leaq 0x12676(%rip), %rsi     # 0x181a0
leaq -0x208(%rbp), %rdi
callq 0x32c0
movq %rax, -0x340(%rbp)
jmp 0x5b3f
movq -0x340(%rbp), %rdi
movq -0x2f0(%rbp), %rax
movl 0x4e4(%rax), %esi
callq 0x3490
movq %rax, -0x348(%rbp)
jmp 0x5b61
movq -0x348(%rbp), %rdi
leaq 0x1263e(%rip), %rsi     # 0x181ad
callq 0x32c0
movq %rax, -0x350(%rbp)
jmp 0x5b7d
movq -0x2f0(%rbp), %rdi
addq $0x38, %rdi
callq 0x96c0
movq -0x350(%rbp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, -0x358(%rbp)
jmp 0x5ba5
movq -0x358(%rbp), %rdi
leaq 0x1260c(%rip), %rsi     # 0x181bf
callq 0x32c0
movq %rax, -0x360(%rbp)
jmp 0x5bc1
movq -0x360(%rbp), %rdi
movq 0x1f3f1(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x5bd6
leaq 0x1260e(%rip), %rsi     # 0x181eb
leaq -0x208(%rbp), %rdi
callq 0x32c0
movq %rax, -0x368(%rbp)
jmp 0x5bf2
movq -0x368(%rbp), %rdi
movq 0x1f3c0(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x5c07
movq -0x2f0(%rbp), %rdi
addq $0x38, %rdi
callq 0x98b0
movq %rax, -0x370(%rbp)
jmp 0x5c20
movq -0x370(%rbp), %rax
movq %rax, -0x288(%rbp)
movq -0x2f0(%rbp), %rdi
addq $0x38, %rdi
callq 0x98e0
movq %rax, -0x378(%rbp)
jmp 0x5c47
movq -0x378(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0x288(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x9750
testb $0x1, %al
jne 0x5c71
jmp 0x5e70
movl -0x218(%rbp), %eax
incl %eax
movl %eax, -0x294(%rbp)
movq -0x288(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x2a8(%rbp), %rdi
movl $0x1, %esi
callq 0x9910
movq %rax, -0x380(%rbp)
jmp 0x5ca7
movq -0x380(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2f0(%rbp), %rdi
addq $0x38, %rdi
callq 0x98e0
movq %rax, -0x388(%rbp)
jmp 0x5cce
movq -0x388(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x2a0(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x9750
testb $0x1, %al
jne 0x5cf8
jmp 0x5e47
leaq -0x288(%rbp), %rdi
callq 0x9940
movq %rax, %rdi
callq 0x97b0
movq %rax, -0x2c0(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x9850
movq (%rax), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x9940
movq %rax, %rdi
callq 0x97b0
movq %rax, -0x2d0(%rbp)
leaq -0x2d0(%rbp), %rdi
callq 0x9850
movq (%rax), %rax
movq %rax, -0x2c8(%rbp)
movl -0x218(%rbp), %esi
leaq -0x208(%rbp), %rdi
callq 0x3490
movq %rax, -0x390(%rbp)
jmp 0x5d75
movq -0x390(%rbp), %rdi
leaq 0x1230d(%rip), %rsi     # 0x18090
callq 0x32c0
movq %rax, -0x398(%rbp)
jmp 0x5d91
movq -0x398(%rbp), %rdi
movl -0x294(%rbp), %esi
callq 0x3490
movq %rax, -0x3a0(%rbp)
jmp 0x5dac
movq -0x3a0(%rbp), %rdi
leaq 0x122d6(%rip), %rsi     # 0x18090
callq 0x32c0
movq %rax, -0x3a8(%rbp)
jmp 0x5dc8
movq -0x2f0(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
movq -0x2c8(%rbp), %rdx
callq 0x37c0
movsd %xmm0, -0x3b0(%rbp)
jmp 0x5dec
movsd -0x3b0(%rbp), %xmm0
movq -0x3a8(%rbp), %rdi
callq 0x34f0
movq %rax, -0x3b8(%rbp)
jmp 0x5e09
movq -0x3b8(%rbp), %rdi
movq 0x1f1a9(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x5e1e
movl -0x294(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x294(%rbp)
leaq -0x2a0(%rbp), %rdi
xorl %esi, %esi
callq 0x9960
movq %rax, -0x2d8(%rbp)
jmp 0x5cb5
movl -0x218(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x218(%rbp)
leaq -0x288(%rbp), %rdi
xorl %esi, %esi
callq 0x9960
movq %rax, -0x2e0(%rbp)
jmp 0x5c2e
leaq -0x208(%rbp), %rdi
callq 0x3410
jmp 0x5e7e
movq 0x1f14b(%rip), %rdi     # 0x24fd0
leaq 0x122f4(%rip), %rsi     # 0x18180
callq 0x32c0
movq %rax, -0x3c0(%rbp)
jmp 0x5e9a
movq -0x3c0(%rbp), %rdi
movq 0x1f118(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x5eaf
leaq -0x278(%rbp), %rdi
callq 0x31a0
leaq -0x208(%rbp), %rdi
callq 0x8f10
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbp
retq
leaq -0x208(%rbp), %rdi
callq 0x8f10
movq -0x210(%rbp), %rdi
callq 0x34a0
nopl (%rax,%rax)