// File: /workspace/github_cpp_makefile_star2_O3/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 0x667a
movslq 0x4e8(%rbx), %rax
testq %rax, %rax
jle 0x401d
notl %r14d
imull %eax, %r14d
addl 0x4dc(%rbx), %r14d
xorl %ecx, %ecx
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
cmpq %rcx, %rax
jne 0x3ffd
movq 0x9fb4(%rip), %rdi      # 0xdfd8
leaq 0x608e(%rip), %rsi      # 0xa0b9
movl $0x2b, %edx
callq 0x32a0
movl 0x4e8(%rbx), %esi
movq 0x9f96(%rip), %rdi      # 0xdfd8
callq 0x33d0
movq %rax, %r14
leaq 0x6094(%rip), %rsi      # 0xa0e5
movl $0x15, %edx
movq %rax, %rdi
callq 0x32a0
movl 0x4e0(%rbx), %esi
movq %r14, %rdi
callq 0x33d0
movq %rax, %r14
leaq 0x6085(%rip), %rsi      # 0xa0fb
movl $0xf, %edx
movq %rax, %rdi
callq 0x32a0
movq %r14, %rdi
callq 0x3170
movslq 0x4e8(%rbx), %rsi
leaq 0x58(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rcx
callq 0x6920
cmpl $0x0, 0x4e8(%rbx)
jle 0x4124
xorl %r14d, %r14d
xorl %ebp, %ebp
cmpl $0x0, 0x4e0(%rbx)
jle 0x4113
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x28(%rsp), %rax
movq (%rax,%r14,8), %rsi
movq 0x38(%rbx), %rax
movq (%rax,%r15), %rax
movq (%rax), %rdx
movq %rbx, %rdi
callq 0x37fc
movsd 0x90(%rbx), %xmm1
ucomisd %xmm0, %xmm1
ja 0x4108
incq %r12
movslq 0x4e0(%rbx), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x40c9
jmp 0x4113
incl %ebp
movq 0x40(%rsp), %rax
incl (%rax,%r14,4)
incq %r14
movslq 0x4e8(%rbx), %rax
cmpq %rax, %r14
jl 0x40ba
jmp 0x4126
xorl %ebp, %ebp
movq 0x9eab(%rip), %rdi      # 0xdfd8
movl %ebp, %esi
callq 0x33d0
movq %rax, %r14
leaq 0x5fcd(%rip), %rsi      # 0xa10b
movl $0x2, %edx
movq %rax, %rdi
callq 0x32a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
addl %ebp, 0x4f0(%rbx)
movl 0x4e8(%rbx), %eax
addl %eax, 0x4f4(%rbx)
cmpl $0x0, 0x4ec(%rbx)
je 0x41ef
leaq 0x2d8(%rbx), %rdi
movl %ebp, %esi
callq 0x33d0
movq %rax, %r14
leaq 0x5f67(%rip), %rsi      # 0xa10c
movl $0x1, %edx
movq %rax, %rdi
callq 0x32a0
movl 0x4e0(%rbx), %esi
movq %r14, %rdi
callq 0x33d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
jmp 0x43ae
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x70(%rbx), %rsi
movq 0x78(%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x799e
leaq 0x8(%rsp), %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x4247
leaq 0x5ede(%rip), %rcx      # 0xa10e
leaq 0x8(%rsp), %rdi
movl $0xb, %r8d
movq %rax, %rsi
xorl %edx, %edx
callq 0x3280
jmp 0x4258
leaq 0x5ec0(%rip), %rsi      # 0xa10e
leaq 0x8(%rsp), %rdi
callq 0x3410
movq 0x9d79(%rip), %rdi      # 0xdfd8
leaq 0x5eb4(%rip), %rsi      # 0xa11a
movl $0x1e, %edx
callq 0x32a0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x9d57(%rip), %rdi      # 0xdfd8
callq 0x32a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
leaq 0x58(%rsp), %rdi
movl $0xf, %esi
callq 0x6a9c
movq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdi
movl $0x10, %edx
callq 0x3050
cmpl $0x0, 0x4e8(%rbx)
jle 0x435b
xorl %ebp, %ebp
leaq 0x58(%rsp), %r14
leaq 0x5e22(%rip), %r15      # 0xa10c
movq 0x28(%rsp), %rax
movq (%rax,%rbp,8), %rax
movl (%rax), %esi
incl %esi
movq %r14, %rdi
callq 0x33d0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x32a0
movq 0x40(%rsp), %rax
movl (%rax,%rbp,4), %esi
movq %r12, %rdi
callq 0x33d0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
incq %rbp
movslq 0x4e8(%rbx), %rax
cmpq %rax, %rbp
jl 0x42ea
leaq 0x58(%rsp), %rdi
callq 0x3320
leaq 0x9994(%rip), %rax      # 0xdd00
leaq 0x150(%rsp), %rbx
movq %rax, -0xf8(%rbx)
leaq 0x99a6(%rip), %rax      # 0xdd28
movq %rax, (%rbx)
leaq 0x60(%rsp), %rdi
callq 0x31f0
movq %rbx, %rdi
callq 0x30d0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x43ae
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3250
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x43c5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3250
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x43dc
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3250
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x43f6
jmp 0x4428
jmp 0x4402
jmp 0x43fb
movq %rax, %rbx
jmp 0x440f
movq %rax, %rbx
jmp 0x4442
jmp 0x4428
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x6b38
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x442b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3250
jmp 0x442b
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x4442
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3250
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x4459
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3250
movq %rbx, %rdi
callq 0x33e0
nop