// File: /workspace/github_cpp_makefile_star2_O1/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 0x65fa
movslq 0x4e8(%rbx), %rax
testq %rax, %rax
jle 0x3fe9
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 0x3fc9
movq 0x9fe8(%rip), %rdi      # 0xdfd8
leaq 0x6062(%rip), %rsi      # 0xa059
movl $0x2b, %edx
callq 0x32a0
movl 0x4e8(%rbx), %esi
movq 0x9fca(%rip), %rdi      # 0xdfd8
callq 0x33d0
movq %rax, %r14
leaq 0x6068(%rip), %rsi      # 0xa085
movl $0x15, %edx
movq %rax, %rdi
callq 0x32a0
movl 0x4e0(%rbx), %esi
movq %r14, %rdi
callq 0x33d0
movq %rax, %r14
leaq 0x6059(%rip), %rsi      # 0xa09b
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 0x689e
cmpl $0x0, 0x4e8(%rbx)
jle 0x40f0
xorl %r14d, %r14d
xorl %ebp, %ebp
cmpl $0x0, 0x4e0(%rbx)
jle 0x40df
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 0x40d4
incq %r12
movslq 0x4e0(%rbx), %rax
addq $0x18, %r15
cmpq %rax, %r12
jl 0x4095
jmp 0x40df
incl %ebp
movq 0x40(%rsp), %rax
incl (%rax,%r14,4)
incq %r14
movslq 0x4e8(%rbx), %rax
cmpq %rax, %r14
jl 0x4086
jmp 0x40f2
xorl %ebp, %ebp
movq 0x9edf(%rip), %rdi      # 0xdfd8
movl %ebp, %esi
callq 0x33d0
movq %rax, %r14
leaq 0x5fa1(%rip), %rsi      # 0xa0ab
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 0x41bb
leaq 0x2d8(%rbx), %rdi
movl %ebp, %esi
callq 0x33d0
movq %rax, %r14
leaq 0x5f3b(%rip), %rsi      # 0xa0ac
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 0x437a
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x70(%rbx), %rsi
movq 0x78(%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x78a0
leaq 0x8(%rsp), %rdi
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x3420
cmpq $-0x1, %rax
je 0x4213
leaq 0x5eb2(%rip), %rcx      # 0xa0ae
leaq 0x8(%rsp), %rdi
movl $0xb, %r8d
movq %rax, %rsi
xorl %edx, %edx
callq 0x3280
jmp 0x4224
leaq 0x5e94(%rip), %rsi      # 0xa0ae
leaq 0x8(%rsp), %rdi
callq 0x3410
movq 0x9dad(%rip), %rdi      # 0xdfd8
leaq 0x5e88(%rip), %rsi      # 0xa0ba
movl $0x1e, %edx
callq 0x32a0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x9d8b(%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 0x691c
movq 0x8(%rsp), %rsi
leaq 0x58(%rsp), %rdi
movl $0x10, %edx
callq 0x3050
cmpl $0x0, 0x4e8(%rbx)
jle 0x4327
xorl %ebp, %ebp
leaq 0x58(%rsp), %r14
leaq 0x5df6(%rip), %r15      # 0xa0ac
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 0x42b6
leaq 0x58(%rsp), %rdi
callq 0x3320
leaq 0x99c8(%rip), %rax      # 0xdd00
leaq 0x150(%rsp), %rbx
movq %rax, -0xf8(%rbx)
leaq 0x99da(%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 0x437a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3250
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x4391
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3250
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x43a8
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 0x43c2
jmp 0x43f4
jmp 0x43ce
jmp 0x43c7
movq %rax, %rbx
jmp 0x43db
movq %rax, %rbx
jmp 0x440e
jmp 0x43f4
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x69b8
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x43f7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3250
jmp 0x43f7
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x440e
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3250
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x4425
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3250
movq %rbx, %rdi
callq 0x33e0
nop