// File: 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
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
movq %rdi, %rax
movq %rax, -0x90(%rbp)
callq 0xc2b0
movq -0x78(%rbp), %rdi
addq $0x38, %rdi
movq %rdi, -0x88(%rbp)
callq 0xc2d0
movq -0x78(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x80(%rbp)
callq 0xc2f0
movq -0x78(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, 0x68(%rdi)
movl $0x1, 0x6c(%rdi)
addq $0x70, %rdi
movq %rdi, -0x70(%rbp)
movq -0x18(%rbp), %rsi
callq 0x3130
jmp 0x9bad
movq -0x90(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
movsd %xmm0, 0x90(%rdi)
addq $0x98, %rdi
movq %rdi, -0xa0(%rbp)
callq 0xc310
movq -0x90(%rbp), %rdi
addq $0xb0, %rdi
movq %rdi, -0x98(%rbp)
callq 0x3360
jmp 0x9bf0
movq -0x90(%rbp), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
movq %rdi, -0xb0(%rbp)
callq 0x3400
movq -0x90(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movq %rdi, -0xa8(%rbp)
movl $0xf, %esi
callq 0x8e50
jmp 0x9c2b
movq -0x90(%rbp), %rax
movl $0x0, 0x4d8(%rax)
movl $0x0, 0x4dc(%rax)
movl $0x0, 0x4e0(%rax)
movl -0x24(%rbp), %ecx
movl %ecx, 0x4e4(%rax)
movl -0x28(%rbp), %ecx
movl %ecx, 0x4e8(%rax)
movl 0x10(%rbp), %ecx
movl %ecx, 0x4ec(%rax)
movl $0x0, 0x4f0(%rax)
movl $0x0, 0x4f4(%rax)
movl $0x1, -0x40(%rbp)
movl $0x1, -0x44(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0xc330
movq %rax, -0xb8(%rbp)
jmp 0x9ca3
movq -0x90(%rbp), %rax
movq -0xb8(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x6c(%rax)
movl $0x0, -0x48(%rbp)
movq -0x90(%rbp), %rcx
movl -0x48(%rbp), %eax
cmpl 0x6c(%rcx), %eax
jge 0x9d4a
movq -0x90(%rbp), %rdi
addq $0x98, %rdi
movl 0x18(%rbp), %eax
incl %eax
movl %eax, -0x4c(%rbp)
leaq -0x4c(%rbp), %rsi
callq 0xc370
jmp 0x9ced
jmp 0x9cef
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x9cbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa009
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x9ff4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x9fdc
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x8f10
jmp 0x9fdc
movq -0x90(%rbp), %rax
addq $0xb0, %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3120
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
movl $0x8, %edx
callq 0x31c0
jmp 0x9d7d
movq -0x90(%rbp), %rax
movq 0xb0(%rax), %rcx
movq -0x18(%rcx), %rcx
leaq 0xb0(%rax,%rcx), %rdi
callq 0x3150
movb %al, -0xc1(%rbp)
jmp 0x9da4
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x9db0
jmp 0x9e20
movq 0x1b219(%rip), %rdi     # 0x24fd0
leaq 0xec4b(%rip), %rsi      # 0x18a09
callq 0x32c0
movq %rax, -0xd0(%rbp)
jmp 0x9dcc
movq -0xd0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3280
movq %rax, -0xd8(%rbp)
jmp 0x9de5
movq -0xd8(%rbp), %rdi
leaq 0xec27(%rip), %rsi      # 0x18a1a
callq 0x32c0
movq %rax, -0xe0(%rbp)
jmp 0x9e01
movq -0xe0(%rbp), %rdi
movq 0x1b1b1(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x9e16
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3370
movq -0x90(%rbp), %rdi
callq 0x4c90
jmp 0x9e2e
cmpl $0x0, -0x2c(%rbp)
jle 0x9e8a
movq -0x90(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0xe8(%rbp)
callq 0x8a90
movq -0xe8(%rbp), %rdi
movq %rax, -0x58(%rbp)
callq 0x8ac0
movq -0x90(%rbp), %rdi
movq %rax, -0x60(%rbp)
addq $0x98, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8af0
movq %rax, %rdx
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x8820
jmp 0x9e88
jmp 0x9e8a
cmpl $0x0, 0x10(%rbp)
jle 0x9fbe
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x2b8, %rdi            # imm = 0x2B8
callq 0x3040
jmp 0x9ead
movq -0x90(%rbp), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
movl $0x2e, %esi
movq $-0x1, %rdx
callq 0x3510
movq %rax, -0x68(%rbp)
cmpq $-0x1, -0x68(%rbp)
jne 0x9ef5
movq -0x90(%rbp), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
leaq 0xe1a6(%rip), %rsi      # 0x18092
callq 0x32a0
jmp 0x9ef3
jmp 0x9f17
movq -0x90(%rbp), %rdi
addq $0x2b8, %rdi            # imm = 0x2B8
movq -0x68(%rbp), %rsi
leaq 0xe184(%rip), %rdx      # 0x18092
callq 0x30b0
jmp 0x9f15
jmp 0x9f17
movq -0x90(%rbp), %rdi
movq %rdi, %rax
addq $0x2d8, %rax            # imm = 0x2D8
movq %rax, -0xf0(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
callq 0x3120
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
movl $0x10, %edx
callq 0x3050
jmp 0x9f50
movq -0x90(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
leaq 0xeac2(%rip), %rsi      # 0x18a27
callq 0x32c0
movq %rax, -0xf8(%rbp)
jmp 0x9f73
movq -0xf8(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x3490
movq %rax, -0x100(%rbp)
jmp 0x9f8b
movq -0x100(%rbp), %rdi
leaq 0xeaac(%rip), %rsi      # 0x18a45
callq 0x32c0
movq %rax, -0x108(%rbp)
jmp 0x9fa7
movq -0x108(%rbp), %rdi
movq 0x1b00b(%rip), %rsi     # 0x24fc0
callq 0x3310
jmp 0x9fbc
jmp 0x9fbe
movq -0x90(%rbp), %rdi
addq $0xb0, %rdi
callq 0x3090
jmp 0x9fd3
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xb0(%rbp), %rdi
callq 0x31a0
movq -0x98(%rbp), %rdi
callq 0x30c0
movq -0xa0(%rbp), %rdi
callq 0xc3f0
movq -0x70(%rbp), %rdi
callq 0x31a0
movq -0x80(%rbp), %rdi
callq 0x9070
movq -0x88(%rbp), %rdi
callq 0xc450
movq -0x78(%rbp), %rdi
callq 0xc4b0
movq -0x38(%rbp), %rdi
callq 0x34a0