// File: /workspace/github_cpp_makefile_star2_O3/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 0x85f7
movq %rsi, %rbx
movq 0x8(%rsi), %r14
movq 0xdfb0(%rip), %r15      # 0x16388
leaq 0xdfa1(%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 0xdfa3(%rip), %r15      # 0x163a8
leaq 0xdf94(%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 0xdfb6(%rip), %r15      # 0x163e8
leaq 0xdfa7(%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 0x8dd1(%rip), %rsi      # 0x11249
movq %r14, %rdi
callq 0x30e0
testl %eax, %eax
jne 0x848b
movb $0x0, 0xdec5(%rip)      # 0x16350
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0xdf06(%rip), %rsi      # 0x163a0
movq 0xdf07(%rip), %rdx      # 0x163a8
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0xf868
leaq -0x88(%rbp), %rdi
callq 0x7807
movl %eax, %r14d
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x84d0
callq 0x32f0
testl %r14d, %r14d
js 0x8667
leaq 0xdec0(%rip), %r14      # 0x163a0
leaq 0x8d09(%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 0xf868
leaq 0x8c27(%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 0xde5d(%rip), %rdi      # 0x163c0
leaq -0xa8(%rbp), %r14
movq %r14, %rsi
callq 0x3400
movq (%r14), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x8586
callq 0x32f0
movl $0x1, %r15d
leaq -0xd2b(%rip), %r12      # 0x7868
cmpq $0x1a, %r15
je 0x8616
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r15, %rcx
callq 0x35f0
incq %r15
addq $0x8, %rbx
testl %eax, %eax
je 0x8593
movl %eax, %r14d
movq 0xda32(%rip), %rdi      # 0x15ff0
leaq 0x8c8e(%rip), %rsi      # 0x11253
movl $0x20, %edx
callq 0x33a0
movq 0xda1a(%rip), %rdi      # 0x15ff0
movl %r14d, %esi
callq 0x3570
leaq 0x8c61(%rip), %rsi      # 0x11246
movq %rax, %rdi
callq 0x3320
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x33e0
movq 0xd9f2(%rip), %rdi      # 0x15ff0
leaq 0x8bf8(%rip), %rsi      # 0x111fd
movl $0x4b, %edx
callq 0x33a0
movl $0x1, %ebx
jmp 0x8681
xorl %ebx, %ebx
movq -0x190(%rbp,%rbx,8), %rdi
xorl %esi, %esi
callq 0x32e0
incq %rbx
cmpq $0x19, %rbx
jne 0x8618
callq 0x7c3d
movl $0x1, %ebx
testl %eax, %eax
jne 0x8645
callq 0x8203
movl %eax, %ebx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x8653
callq 0x32f0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x866c
callq 0x32f0
jmp 0x866c
movl $0x1, %ebx
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8681
callq 0x32f0
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x86b8
movq %rax, %rbx
jmp 0x86c9
jmp 0x86b1
jmp 0x86b8
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
jne 0x86d6
jmp 0x86db
movq %rax, %rbx
jmp 0x86db
jmp 0x86b8
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x86c9
callq 0x32f0
leaq -0x58(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x86db
callq 0x32f0
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x86f0
callq 0x32f0
movq %rbx, %rdi
callq 0x35b0