// File: /workspace/github_cpp_makefile_star2_O2/mapequation[P]partition-validation/./partition-validation.h
// Function: Partitions::Partitions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, double, int, int, int, int, int)
Partitions(const string &inFileName,
               const string &outFileName,
               double distThreshold,
               int nTrainingPartitions,
               int nValidationPartitions,
               int crossValidateK,
               int validationSamples,
               int seed)
            : crossValidateK(crossValidateK),
              outFileName(outFileName),
              distThreshold(distThreshold),
              nTrainingPartitions(nTrainingPartitions),
              nValidationPartitions(nValidationPartitions),
              validationSamples(validationSamples) {

        nThreads = max(1, omp_get_max_threads());

        for (int i = 0; i < nThreads; i++) {
            mtRands.emplace_back(seed + 1);
        }

        ifs.open(inFileName.c_str());

        if (!ifs) {
            cout << "Failed to open \"" << inFileName << "\" exiting..." << endl;
            exit(-1);
        }

        readPartitionsFile();

        if (crossValidateK > 0) {
            // Randomize ordered partitions
            shuffle(begin(partitions), end(partitions), mtRands[0]);
        }

        if (validationSamples > 0) {
            validationSampleOutFileName = outFileName;
            auto periodPos = validationSampleOutFileName.find_last_of('.');

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

            validationOfs.open(validationSampleOutFileName.c_str());
            validationOfs << "# number_of_validated_out_of_" << nValidationPartitions
                          << " number_of_partition_clusters" << endl;
        }

        ifs.close();
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %r13d
movl %r8d, 0xc(%rsp)
movl %ecx, %ebp
movsd %xmm0, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
leaq 0x30(%rdi), %rax
movq %rax, (%rdi)
movq $0x1, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movl $0x3f800000, 0x20(%rdi) # imm = 0x3F800000
movups %xmm0, 0x28(%rdi)
movups %xmm0, 0x38(%rdi)
movups %xmm0, 0x48(%rdi)
movups %xmm0, 0x58(%rdi)
movl %r9d, 0x68(%rdi)
movl $0x1, 0x6c(%rdi)
leaq 0x70(%rdi), %r14
movq %r14, %rdi
movq %rdx, 0x40(%rsp)
movq %rdx, %rsi
callq 0x3320
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x90(%rbx)
leaq 0x98(%rbx), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x98(%rbx)
andq $0x0, 0xa8(%rbx)
leaq 0xb0(%rbx), %r12
movq %r12, %rdi
movq %r14, 0x38(%rsp)
callq 0x3290
movq %r12, 0x10(%rsp)
leaq 0x2c8(%rbx), %rax
movq %rax, 0x2b8(%rbx)
andq $0x0, 0x2c0(%rbx)
leaq 0x2b8(%rbx), %rax
movq %rax, 0x30(%rsp)
movb $0x0, 0x2c8(%rbx)
leaq 0x2d8(%rbx), %rdi
pushq $0xf
popq %rsi
movq %rdi, 0x28(%rsp)
callq 0x585e
andq $0x0, 0x4d8(%rbx)
movl 0x88(%rsp), %r14d
andl $0x0, 0x4e0(%rbx)
movl 0x80(%rsp), %ecx
movl %ebp, 0x4e4(%rbx)
movl 0xc(%rsp), %eax
movl %eax, 0x4e8(%rbx)
movl %ecx, 0x4ec(%rbx)
andq $0x0, 0x4f0(%rbx)
movl $0x1, 0x6c(%rbx)
incl %r14d
xorl %r12d, %r12d
pushq $0x1
popq %rax
leaq 0x1c(%rsp), %rbp
cmpl %eax, %r12d
jge 0x5d63
movl %r14d, 0x1c(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x6390
incl %r12d
movl 0x6c(%rbx), %eax
jmp 0x5d46
movq 0x20(%rsp), %rax
movq (%rax), %rsi
pushq $0x8
popq %rdx
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %rbp
callq 0x3170
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x20(%r14,%rax)
jne 0x5e63
movq %rbx, %rdi
callq 0x3fb2
testl %r13d, %r13d
jle 0x5db9
movq 0x50(%rbx), %rdi
movq 0x58(%rbx), %rsi
movq 0x98(%rbx), %rdx
callq 0x565d
cmpl $0x0, 0x80(%rsp)
jle 0x5e4c
movq %r12, %rdi
movq 0x40(%rsp), %rsi
callq 0x3150
pushq $0x2e
popq %rsi
pushq $-0x1
popq %rdx
movq %r12, %rdi
callq 0x3420
cmpq $-0x1, %rax
je 0x5dfc
leaq 0x32af(%rip), %rdx      # 0x909e
movq %r12, %rdi
movq %rax, %rsi
callq 0x3080
jmp 0x5e0b
leaq 0x329b(%rip), %rsi      # 0x909e
movq %r12, %rdi
callq 0x3400
movq (%r12), %rsi
pushq $0x10
popq %rdx
movq %rbp, %rdi
callq 0x3040
leaq 0x3c12(%rip), %rsi      # 0x9a33
movq %rbp, %rdi
callq 0x3240
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x33d0
leaq 0x3c15(%rip), %rsi      # 0x9a51
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
movq %r14, %rdi
callq 0x3070
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x816e(%rip), %rdi      # 0xdfd8
leaq 0x3ba4(%rip), %rsi      # 0x9a15
callq 0x3240
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x3220
leaq 0x3b9c(%rip), %rsi      # 0x9a26
movq %rax, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x3130
pushq $-0x1
popq %rdi
callq 0x32a0
movq %rax, %r14
jmp 0x5ec2
movq %rax, %r14
jmp 0x5ed6
movq %rax, %r14
jmp 0x5ee8
jmp 0x5eb5
jmp 0x5eb5
movq %rax, %r14
movq 0x28(%rsp), %rdi
callq 0x58c0
movq 0x30(%rsp), %rdi
callq 0x3110
movq 0x10(%rsp), %rdi
callq 0x3090
movq %r15, %rdi
callq 0x661a
movq 0x38(%rsp), %rdi
callq 0x3110
leaq 0x50(%rbx), %rdi
leaq 0x38(%rbx), %r15
callq 0x5932
movq %r15, %rdi
callq 0x63d2
movq %rbx, %rdi
callq 0x66a4
movq %r14, %rdi
callq 0x33e0
nop