// File: /workspace/github_cpp_makefile_star2_O2/mshabbirhasan[P]ups-indel/src/ups_indel.cpp
// Function: main
int main(int argc, char const* *argv) {
    if (argc != 5) {
        std::cerr << "USAGE: ups_indel REFERENCE_FILE.fa VCF_FILE.vcf OUTPUT_FILE_NAME -hd=true.\n";
        return 1;
    }

    reference_file_name = argv[1];
    input_file_name = argv[2];
    output_file_name = argv[3];
    string horizontal_decomposition_flag = argv[4];

    if(horizontal_decomposition_flag == "-hd=false"){
        isHorizontalDecompositionEnabled = false;
    }

    int splitFlag = splitInput(input_file_name);
    if (splitFlag < 0) {
      return 1;
    }

    pthread_t threads[25]; // 24 chromosomes and MT

    string input_file_base_name_with_extension =
        input_file_name.substr(0, input_file_name.find_last_of(".vcf") + 1);
    string input_file_name_str(input_file_base_name_with_extension);

    input_file_base_name =
        input_file_name_str.substr(0, input_file_name_str.find_last_of("."));

    for (int k = 0; k < 25; k++) {
        int thread_creation_flag = pthread_create( & threads[k], NULL, executeUPSIndel, (void * )(intptr_t)(k + 1));

        if (thread_creation_flag) {
            std::cerr << "ERROR: Unable to create thread, " << thread_creation_flag << ".\n";
            exit(-1);
        }
    }

    for (int l = 0; l < 25; l++) {
        pthread_join(threads[l], NULL);
    }

    if (merge_outputs()) {
        return 1;
    }

    if (cleanup()) {
      return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x170, %rsp            # imm = 0x170
cmpl $0x5, %edi
jne 0x666d
movq %rsi, %rbx
movq 0x8(%rsi), %rsi
leaq 0xde71(%rip), %rdi      # 0x14370
callq 0x3610
movq 0x10(%rbx), %rsi
leaq 0xde81(%rip), %rdi      # 0x14390
callq 0x3610
movq 0x18(%rbx), %rsi
leaq 0xdeb1(%rip), %rdi      # 0x143d0
callq 0x3610
movq 0x20(%rbx), %rsi
leaq -0xa0(%rbp), %r14
leaq -0x190(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3150
leaq 0x6ce5(%rip), %rsi      # 0xd22d
movq %r14, %rdi
callq 0x681b
testb %al, %al
je 0x655b
movb $0x0, 0xdde5(%rip)      # 0x14340
leaq 0xde2e(%rip), %rsi      # 0x14390
leaq -0x80(%rbp), %rdi
callq 0x3440
leaq -0x80(%rbp), %rdi
callq 0x5e83
movl %eax, %r14d
leaq -0x80(%rbp), %rdi
callq 0x3668
testl %r14d, %r14d
js 0x66af
leaq 0xde00(%rip), %r14      # 0x14390
leaq 0x6c3d(%rip), %rsi      # 0xd1d4
pushq $-0x1
popq %rdx
movq %r14, %rdi
callq 0x32f0
leaq 0x1(%rax), %rcx
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3340
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3440
leaq 0x6b73(%rip), %rsi      # 0xd13b
leaq -0x40(%rbp), %r14
pushq $-0x1
popq %rdx
movq %r14, %rdi
callq 0x32f0
leaq -0xc0(%rbp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x3340
leaq 0xddbe(%rip), %rdi      # 0x143b0
leaq -0xc0(%rbp), %r14
movq %r14, %rsi
callq 0x33e0
movq %r14, %rdi
callq 0x3668
pushq $0x1
popq %r14
leaq -0x742(%rip), %r15      # 0x5ed2
cmpq $0x1a, %r14
je 0x6685
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %r14, %rcx
callq 0x35c0
incq %r14
addq $0x8, %rbx
testl %eax, %eax
je 0x6614
movl %eax, %r12d
movq 0xd9b1(%rip), %rdi      # 0x13ff0
leaq 0x6bf1(%rip), %rsi      # 0xd237
callq 0x3310
movq %rax, %rdi
movl %r12d, %esi
callq 0x3550
leaq 0x6bcd(%rip), %rsi      # 0xd22a
movq %rax, %rdi
callq 0x3310
pushq $-0x1
popq %rdi
callq 0x33c0
movq 0xd97c(%rip), %rdi      # 0x13ff0
leaq 0x6b66(%rip), %rsi      # 0xd1e1
callq 0x3310
pushq $0x1
popq %rbx
jmp 0x66d9
xorl %ebx, %ebx
cmpq $0x19, %rbx
je 0x66a1
movq -0x190(%rbp,%rbx,8), %rdi
xorl %esi, %esi
callq 0x32d0
incq %rbx
jmp 0x6687
callq 0x60cb
testl %eax, %eax
je 0x66b4
pushq $0x1
popq %rbx
jmp 0x66bb
pushq $0x1
popq %rbx
jmp 0x66cd
callq 0x63f2
movl %eax, %ebx
leaq -0x40(%rbp), %rdi
callq 0x3668
leaq -0x60(%rbp), %rdi
callq 0x3668
leaq -0xa0(%rbp), %rdi
callq 0x3668
movl %ebx, %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6706
movq %rax, %rbx
jmp 0x6712
jmp 0x66ff
jmp 0x6706
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
jmp 0x6716
movq %rax, %rbx
jmp 0x671b
jmp 0x6706
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x3668
leaq -0x60(%rbp), %rdi
callq 0x3668
leaq -0xa0(%rbp), %rdi
callq 0x3668
movq %rbx, %rdi
callq 0x3590
nop