// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
cmpl $0x5, %edi
jne 0x86d8
movq %rsi, %rbx
movq 0x8(%rsi), %r14
movq 0xdecf(%rip), %r15      # 0x16388
leaq 0xdec0(%rip), %r12      # 0x16380
movq %r14, %rdi
callq 0x3170
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x34d0
movq 0x10(%rbx), %r14
movq 0xdec2(%rip), %r15      # 0x163a8
leaq 0xdeb3(%rip), %r12      # 0x163a0
movq %r14, %rdi
callq 0x3170
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x34d0
movq 0x18(%rbx), %r14
movq 0xded5(%rip), %r15      # 0x163e8
leaq 0xdec6(%rip), %r12      # 0x163e0
movq %r14, %rdi
callq 0x3170
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x34d0
movq 0x20(%rbx), %rsi
leaq -0xc8(%rbp), %r14
leaq -0x190(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3150
leaq 0x8cf0(%rip), %rsi      # 0x11249
movq %r14, %rdi
callq 0x30e0
testl %eax, %eax
jne 0x856c
movb $0x0, 0xdde4(%rip)      # 0x16350
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0xde25(%rip), %rsi      # 0x163a0
movq 0xde26(%rip), %rdx      # 0x163a8
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0xff88
leaq -0x88(%rbp), %rdi
callq 0x78f1
movl %eax, %r14d
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x85b1
callq 0x32f0
testl %r14d, %r14d
js 0x8748
leaq 0xdddf(%rip), %r14      # 0x163a0
leaq 0x8c28(%rip), %rsi      # 0x111f0
movl $0x4, %ecx
movq %r14, %rdi
movq $-0x1, %rdx
callq 0x3670
leaq 0x1(%rax), %rcx
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3360
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %rdi
callq 0xff88
leaq 0x8b46(%rip), %rsi      # 0x11157
leaq -0x48(%rbp), %r14
movl $0x1, %ecx
movq %r14, %rdi
movq $-0x1, %rdx
callq 0x3670
leaq -0xa8(%rbp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x3360
leaq 0xdd7c(%rip), %rdi      # 0x163c0
leaq -0xa8(%rbp), %r14
movq %r14, %rsi
callq 0x3400
movq (%r14), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x8667
callq 0x32f0
movl $0x1, %r15d
leaq -0xd22(%rip), %r12      # 0x7952
cmpq $0x1a, %r15
je 0x86f7
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r15, %rcx
callq 0x35f0
incq %r15
addq $0x8, %rbx
testl %eax, %eax
je 0x8674
movl %eax, %r14d
movq 0xd951(%rip), %rdi      # 0x15ff0
leaq 0x8bad(%rip), %rsi      # 0x11253
movl $0x20, %edx
callq 0x33a0
movq 0xd939(%rip), %rdi      # 0x15ff0
movl %r14d, %esi
callq 0x3570
leaq 0x8b80(%rip), %rsi      # 0x11246
movq %rax, %rdi
callq 0x3320
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x33e0
movq 0xd911(%rip), %rdi      # 0x15ff0
leaq 0x8b17(%rip), %rsi      # 0x111fd
movl $0x4b, %edx
callq 0x33a0
movl $0x1, %ebx
jmp 0x8762
xorl %ebx, %ebx
movq -0x190(%rbp,%rbx,8), %rdi
xorl %esi, %esi
callq 0x32e0
incq %rbx
cmpq $0x19, %rbx
jne 0x86f9
callq 0x7d27
movl $0x1, %ebx
testl %eax, %eax
jne 0x8726
callq 0x82f0
movl %eax, %ebx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x8734
callq 0x32f0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x874d
callq 0x32f0
jmp 0x874d
movl $0x1, %ebx
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8762
callq 0x32f0
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8799
movq %rax, %rbx
jmp 0x87aa
jmp 0x8792
jmp 0x8799
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
jne 0x87b7
jmp 0x87bc
movq %rax, %rbx
jmp 0x87bc
jmp 0x8799
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x87aa
callq 0x32f0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x87bc
callq 0x32f0
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x87d1
callq 0x32f0
movq %rbx, %rdi
callq 0x35b0
nop