// File: /workspace/github_cpp_makefile_star2_O2/mapequation[P]partition-validation/./partition-validation.h
// Function: Partitions::validatePartitions(int)
void Partitions::validatePartitions(int fold) {
    int nValidated = 0;

    auto validationPartitionPtrs = vector<Partition *>(nValidationPartitions);
    for (int i = 0; i < nValidationPartitions; i++) {
        validationPartitionPtrs[i] = &partitions[nPartitions - (fold + 1) * nValidationPartitions + i];
    }

    cout << "--> Number of validation partitions out of " << nValidationPartitions
         << " that fits in one of " << nClusters << " clusters is..." << flush;

    vector<int> validatedPartitions(nValidationPartitions, 0);

#pragma omp parallel for
    for (auto i = 0; i < nValidationPartitions; i++) {
        for (auto j = 0; j < nClusters; j++) {
            if (wpJaccardDist(validationPartitionPtrs[i], clusters[j][0]) < distThreshold) {
#pragma omp atomic
                nValidated++;
                validatedPartitions[i] += 1;
                break;
            }
        }
    }

    cout << nValidated << ". " << endl;
    nTotValidated += nValidated;
    nTotTested += nValidationPartitions;

    if (validationSamples == 0) {
        auto validationOutFileName = outFileName;
        auto periodPos = validationOutFileName.find_last_of('.');
        if (periodPos == string::npos) {
            validationOutFileName += "_validation";
        } else {
            validationOutFileName.insert(periodPos, "_validation");
        }

        cout << "Writing validation results to " << validationOutFileName << endl;

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

        for (int i = 0; i < nValidationPartitions; i++) {
            ofs << validationPartitionPtrs[i]->partitionId + 1 << " " << validatedPartitions[i] << endl;
        }

        ofs.close();
    } else {
        validationOfs << nValidated << " " << nClusters << endl;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %esi, %r14d
movq %rdi, %rbx
movslq 0x4e8(%rdi), %rsi
leaq 0x28(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x560c
movl 0x4e8(%rbx), %eax
notl %r14d
imull %eax, %r14d
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
addl 0x4dc(%rbx), %r14d
cmpq %rcx, %rax
je 0x3ce4
leal (%r14,%rcx), %edx
movslq %edx, %rdx
imulq $0x58, %rdx, %rdx
addq 0x50(%rbx), %rdx
movq 0x28(%rsp), %rsi
movq %rdx, (%rsi,%rcx,8)
incq %rcx
jmp 0x3cc2
movq 0xa2ed(%rip), %rdi      # 0xdfd8
leaq 0x5357(%rip), %rsi      # 0x9049
callq 0x3240
movl 0x4e8(%rbx), %esi
movq %rax, %rdi
callq 0x33d0
leaq 0x5369(%rip), %rsi      # 0x9075
movq %rax, %rdi
callq 0x3240
movl 0x4e0(%rbx), %esi
movq %rax, %rdi
callq 0x33d0
leaq 0x5362(%rip), %rsi      # 0x908b
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3190
movslq 0x4e8(%rbx), %rsi
leaq 0x58(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rcx
callq 0x5808
xorl %r14d, %r14d
pushq $-0x1
popq %r15
xorl %ebp, %ebp
movslq 0x4e8(%rbx), %rax
cmpq %rax, %r14
jge 0x3dbf
movq %r15, %r12
xorl %r13d, %r13d
movslq 0x4e0(%rbx), %rax
incq %r12
cmpq %rax, %r12
jge 0x3dba
movq 0x28(%rsp), %rax
movq (%rax,%r14,8), %rsi
movq 0x38(%rbx), %rax
movq (%rax,%r13), %rax
movq (%rax), %rdx
movq %rbx, %rdi
callq 0x363e
addq $0x18, %r13
movsd 0x90(%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x3d72
incl %ebp
movq 0x40(%rsp), %rax
incl (%rax,%r14,4)
incq %r14
jmp 0x3d60
movq 0xa212(%rip), %rdi      # 0xdfd8
movl %ebp, %esi
callq 0x33d0
leaq 0x52c7(%rip), %rsi      # 0x909b
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
addl %ebp, 0x4f0(%rbx)
movl 0x4e8(%rbx), %eax
addl %eax, 0x4f4(%rbx)
cmpl $0x0, 0x4ec(%rbx)
je 0x3e37
leaq 0x2d8(%rbx), %rdi
movl %ebp, %esi
callq 0x33d0
leaq 0x5288(%rip), %rsi      # 0x909c
movq %rax, %rdi
callq 0x3240
movl 0x4e0(%rbx), %esi
movq %rax, %rdi
callq 0x33d0
movq %rax, %rdi
callq 0x3130
jmp 0x3f40
leaq 0x70(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x3320
leaq 0x8(%rsp), %rdi
pushq $0x2e
popq %rsi
pushq $-0x1
popq %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x3e71
leaq 0x523c(%rip), %rdx      # 0x909e
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x3080
jmp 0x3e82
leaq 0x5226(%rip), %rsi      # 0x909e
leaq 0x8(%rsp), %rdi
callq 0x3400
movq 0xa14f(%rip), %rdi      # 0xdfd8
leaq 0x521a(%rip), %rsi      # 0x90aa
callq 0x3240
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x3220
movq %rax, %rdi
callq 0x3130
leaq 0x58(%rsp), %rdi
pushq $0xf
popq %rsi
callq 0x585e
movq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x3040
xorl %r12d, %r12d
leaq 0x58(%rsp), %r14
leaq 0x51c4(%rip), %r15      # 0x909c
movslq 0x4e8(%rbx), %rax
cmpq %rax, %r12
jge 0x3f22
movq 0x28(%rsp), %rax
movq (%rax,%r12,8), %rax
movl (%rax), %esi
incl %esi
movq %r14, %rdi
callq 0x33d0
movq %rax, %rdi
movq %r15, %rsi
callq 0x3240
movq 0x40(%rsp), %rcx
movl (%rcx,%r12,4), %esi
movq %rax, %rdi
callq 0x33d0
movq %rax, %rdi
callq 0x3130
incq %r12
jmp 0x3ed8
leaq 0x58(%rsp), %rdi
callq 0x3330
leaq 0x58(%rsp), %rdi
callq 0x58c0
leaq 0x8(%rsp), %rdi
callq 0x3110
leaq 0x40(%rsp), %rdi
callq 0x7de4
leaq 0x28(%rsp), %rdi
callq 0x7938
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3f6e
jmp 0x3f93
jmp 0x3f7a
jmp 0x3f75
movq %rax, %rbx
jmp 0x3f87
jmp 0x3f93
movq %rax, %rbx
jmp 0x3fa0
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x58c0
leaq 0x8(%rsp), %rdi
callq 0x3110
jmp 0x3f96
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x7de4
leaq 0x28(%rsp), %rdi
callq 0x7938
movq %rbx, %rdi
callq 0x33e0