// File: /workspace/github_cpp_makefile_star2_O3/mshabbirhasan[P]ups-indel/src/ups_indel.cpp
// Function: merge_outputs()
int merge_outputs() {
    bool hasHeaderPrinted = false;
    ofstream fout(output_file_name + ".uvcf");
    if (fout.is_open()) {
        for (int chrNum = 1; chrNum <= 25; chrNum++) {
            string chr = "";
            if (chrNum >= 1 && chrNum <= 22) {
                chr = to_string(chrNum);
            } else if (chrNum == 23) {
                chr = "X";
            } else if (chrNum == 24) {
                chr = "Y";
            } else if (chrNum == 25) {
                chr = "MT";
            }

            string chromosome_wise_uvcf_file_name =
                output_file_name + "." + chr + ".uvcf";
            string line;

            ifstream uvcfFile(chromosome_wise_uvcf_file_name);
            if (fileExists(chromosome_wise_uvcf_file_name)) {
                if(uvcfFile.is_open()){
                    while (getline(uvcfFile, line)) {
                        if (line.at(0) == '#' && !hasHeaderPrinted) {
                            fout << line << endl;
                        } else if (line.at(0) != '#') {
                            fout << line << endl;
                        }
                    }
                    uvcfFile.close();
                } else {
                    std::cerr << "ERROR: Could not read from UVCF file: " << chromosome_wise_uvcf_file_name << ".\n";
                    return 1;
                }

                hasHeaderPrinted = true;
            }
        }

        fout.close();
    } else {
        std::cerr << "ERROR: Could not write output: " << output_file_name << ".uvcf.\n";
        return 1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
leaq -0x288(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0xe77d(%rip), %rsi      # 0x163e0
movq 0xe77e(%rip), %rdx      # 0x163e8
addq %rsi, %rdx
leaq -0x298(%rbp), %rbx
movq %rbx, %rdi
callq 0xf868
leaq 0x9574(%rip), %rsi      # 0x111f7
movq %rbx, %rdi
callq 0x3640
leaq -0x498(%rbp), %rdi
leaq -0x298(%rbp), %rsi
movl $0x10, %edx
callq 0x3650
movq -0x298(%rbp), %rdi
cmpq %r14, %rdi
je 0x7cb4
callq 0x32f0
leaq -0x428(%rbp), %rdi
callq 0x30b0
testb %al, %al
leaq -0x298(%rbp), %r14
je 0x8094
leaq -0x78(%rbp), %r12
movl $0x1, %ebx
xorl %r15d, %r15d
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
leaq 0x955a(%rip), %rdx      # 0x11248
movq %rdx, %rsi
callq 0xf906
cmpl $0x16, %ebx
ja 0x7d77
movq %r15, -0x90(%rbp)
movq %r12, %r15
cmpl $0xa, %ebx
movl $0x2, %r13d
sbbl $0x0, %r13d
leaq -0x288(%rbp), %r12
movq %r12, -0x298(%rbp)
movq %r14, %rdi
movq %r13, %rsi
movl $0x2d, %edx
callq 0x33b0
movq -0x298(%rbp), %rdi
movl %r13d, %esi
movl %ebx, %r13d
movl %ebx, %edx
callq 0xf702
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0x3400
movq -0x298(%rbp), %rdi
cmpq %r12, %rdi
je 0x7d61
callq 0x32f0
movq %r15, %r12
movq -0x90(%rbp), %r15
movl %r13d, %ebx
leaq -0x298(%rbp), %r14
jmp 0x7db5
movl $0x1, %r8d
cmpl $0x18, %ebx
je 0x7d90
cmpl $0x17, %ebx
jne 0x7d99
leaq 0x9763(%rip), %rcx      # 0x114f1
jmp 0x7da6
leaq 0x97d7(%rip), %rcx      # 0x1156e
jmp 0x7da6
movl $0x2, %r8d
leaq 0x93f2(%rip), %rcx      # 0x11198
movq -0x60(%rbp), %rdx
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
callq 0x34d0
leaq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0xe61c(%rip), %rsi      # 0x163e0
movq 0xe61d(%rip), %rdx      # 0x163e8
addq %rsi, %rdx
leaq -0x48(%rbp), %r13
movq %r13, %rdi
callq 0xf868
movq %r13, %rdi
leaq 0x9373(%rip), %rsi      # 0x11157
callq 0x3640
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r13, %rdi
callq 0x30f0
leaq -0x288(%rbp), %rsi
movq %rsi, -0x298(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7e29
movq %rdx, -0x298(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x288(%rbp)
jmp 0x7e2f
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x290(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rdi
leaq 0x93a4(%rip), %rsi      # 0x111f7
callq 0x3640
movq %r12, -0x88(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7e7e
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x7e86
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x80(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x298(%rbp), %rdi
leaq -0x288(%rbp), %rax
cmpq %rax, %rdi
je 0x7eb5
callq 0x32f0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x7ec7
callq 0x32f0
leaq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movb $0x0, -0x38(%rbp)
movq %r14, %rdi
leaq -0x88(%rbp), %rsi
movl $0x8, %edx
callq 0x3520
movq -0x88(%rbp), %rdi
leaq 0x978e(%rip), %rsi      # 0x1168b
callq 0x33c0
testq %rax, %rax
je 0x7fdc
movq %rax, %rdi
callq 0x3330
leaq -0x220(%rbp), %rdi
callq 0x30b0
testb %al, %al
je 0x7fe1
movq -0x298(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3310
movsbl %al, %edx
movq %r14, %rdi
leaq -0x48(%rbp), %rsi
callq 0x3610
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x8029
movq -0x40(%rbp), %rdx
testq %rdx, %rdx
je 0x8130
movq -0x48(%rbp), %rsi
cmpb $0x23, (%rsi)
jne 0x7fa1
testb $0x1, %r15b
jne 0x7f27
leaq -0x498(%rbp), %rdi
callq 0x33a0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3310
jmp 0x7fc4
leaq -0x498(%rbp), %rdi
callq 0x33a0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3310
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3220
jmp 0x7f27
movb $0x1, %r13b
jmp 0x8037
movl $0x26, %edx
movq 0xe003(%rip), %rdi      # 0x15ff0
leaq 0x91a7(%rip), %rsi      # 0x1119b
callq 0x33a0
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0xdfe5(%rip), %rdi      # 0x15ff0
callq 0x33a0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x9227(%rip), %rsi      # 0x11246
callq 0x33a0
xorl %r13d, %r13d
jmp 0x8037
movb $0x1, %r15b
movq %r14, %rdi
callq 0x30a0
movb $0x1, %r13b
movq %r14, %rdi
callq 0x30c0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x8051
callq 0x32f0
movq -0x88(%rbp), %rdi
cmpq %r12, %rdi
je 0x8062
callq 0x32f0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x8074
callq 0x32f0
testb %r13b, %r13b
je 0x80e1
incl %ebx
cmpl $0x1a, %ebx
jne 0x7cdb
xorl %ebx, %ebx
leaq -0x498(%rbp), %rdi
callq 0x3470
jmp 0x80e6
movq 0xdf55(%rip), %rdi      # 0x15ff0
leaq 0x9120(%rip), %rsi      # 0x111c2
movl $0x1f, %edx
callq 0x33a0
movq 0xe32d(%rip), %rsi      # 0x163e0
movq 0xe32e(%rip), %rdx      # 0x163e8
movq 0xdf2f(%rip), %rdi      # 0x15ff0
callq 0x33a0
movl $0x1, %ebx
leaq 0x9110(%rip), %rsi      # 0x111e2
movl $0x7, %edx
movq %rax, %rdi
callq 0x33a0
jmp 0x80e6
movl $0x1, %ebx
movq 0xdedb(%rip), %rax      # 0x15fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x490(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x498(%rbp,%rcx)
callq 0x32a0
leaq -0x3a0(%rbp), %rdi
callq 0x3120
movl %ebx, %eax
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x959a(%rip), %rdi      # 0x116d1
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x34b0
jmp 0x8144
movq %rax, %rbx
movq -0x298(%rbp), %rdi
cmpq %r14, %rdi
je 0x81fb
callq 0x32f0
jmp 0x81fb
jmp 0x81a2
jmp 0x819d
jmp 0x819d
movq %rax, %rbx
movq -0x298(%rbp), %rdi
leaq -0x288(%rbp), %rax
cmpq %rax, %rdi
je 0x818e
callq 0x32f0
jmp 0x818e
jmp 0x818b
movq %rax, %rbx
jmp 0x81ba
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
jne 0x81d8
jmp 0x81dd
movq %rax, %rbx
jmp 0x81dd
movq %rax, %rbx
jmp 0x81ef
jmp 0x81ab
jmp 0x81ab
movq %rax, %rbx
leaq -0x298(%rbp), %rdi
callq 0x30c0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x81cc
callq 0x32f0
movq -0x88(%rbp), %rdi
cmpq %r12, %rdi
je 0x81dd
callq 0x32f0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x81ef
callq 0x32f0
leaq -0x498(%rbp), %rdi
callq 0x34a0
movq %rbx, %rdi
callq 0x35b0