// File: /workspace/github_cpp_makefile_star2_O1/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 0xe693(%rip), %rsi      # 0x163e0
movq 0xe694(%rip), %rdx      # 0x163e8
addq %rsi, %rdx
leaq -0x298(%rbp), %rbx
movq %rbx, %rdi
callq 0xff88
leaq 0x948a(%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 0x7d9e
callq 0x32f0
leaq -0x428(%rbp), %rdi
callq 0x30b0
testb %al, %al
leaq -0x298(%rbp), %r14
je 0x8183
leaq -0x78(%rbp), %r12
movl $0x1, %ebx
xorl %r15d, %r15d
leaq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x68(%rbp), %rdi
leaq 0x9470(%rip), %rdx      # 0x11248
movq %rdx, %rsi
callq 0x10022
cmpl $0x16, %ebx
ja 0x7e61
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 0xfe20
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0x3400
movq -0x298(%rbp), %rdi
cmpq %r12, %rdi
je 0x7e4b
callq 0x32f0
movq %r15, %r12
movq -0x90(%rbp), %r15
movl %r13d, %ebx
leaq -0x298(%rbp), %r14
jmp 0x7e9f
movl $0x1, %r8d
cmpl $0x17, %ebx
je 0x7e7a
cmpl $0x18, %ebx
jne 0x7e83
leaq 0x96f6(%rip), %rcx      # 0x1156e
jmp 0x7e90
leaq 0x9670(%rip), %rcx      # 0x114f1
jmp 0x7e90
movl $0x2, %r8d
leaq 0x9308(%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 0xe532(%rip), %rsi      # 0x163e0
movq 0xe533(%rip), %rdx      # 0x163e8
addq %rsi, %rdx
leaq -0x48(%rbp), %r13
movq %r13, %rdi
callq 0xff88
movq %r13, %rdi
leaq 0x9289(%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 0x7f13
movq %rdx, -0x298(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x288(%rbp)
jmp 0x7f19
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 0x92ba(%rip), %rsi      # 0x111f7
callq 0x3640
movq %r12, -0x88(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7f68
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x7f70
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 0x7f9f
callq 0x32f0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x7fb1
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 0x96de(%rip), %rsi      # 0x116c5
callq 0x33c0
testq %rax, %rax
je 0x80cb
movq %rax, %rdi
callq 0x3330
leaq -0x220(%rbp), %rdi
callq 0x30b0
testb %al, %al
je 0x80d0
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 0x8118
movq -0x40(%rbp), %rdx
testq %rdx, %rdx
je 0x821f
movq -0x48(%rbp), %rsi
movb (%rsi), %al
cmpb $0x23, %al
jne 0x806b
testb $0x1, %r15b
je 0x8090
cmpb $0x23, %al
je 0x8011
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 0x80b3
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 0x8011
movb $0x1, %r13b
jmp 0x8126
movl $0x26, %edx
movq 0xdf14(%rip), %rdi      # 0x15ff0
leaq 0x90b8(%rip), %rsi      # 0x1119b
callq 0x33a0
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0xdef6(%rip), %rdi      # 0x15ff0
callq 0x33a0
movl $0x2, %edx
movq %rax, %rdi
leaq 0x9138(%rip), %rsi      # 0x11246
callq 0x33a0
xorl %r13d, %r13d
jmp 0x8126
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 0x8140
callq 0x32f0
movq -0x88(%rbp), %rdi
cmpq %r12, %rdi
je 0x8151
callq 0x32f0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x8163
callq 0x32f0
testb %r13b, %r13b
je 0x81d0
incl %ebx
cmpl $0x1a, %ebx
jne 0x7dc5
xorl %ebx, %ebx
leaq -0x498(%rbp), %rdi
callq 0x3470
jmp 0x81d5
movq 0xde66(%rip), %rdi      # 0x15ff0
leaq 0x9031(%rip), %rsi      # 0x111c2
movl $0x1f, %edx
callq 0x33a0
movq 0xe23e(%rip), %rsi      # 0x163e0
movq 0xe23f(%rip), %rdx      # 0x163e8
movq 0xde40(%rip), %rdi      # 0x15ff0
callq 0x33a0
movl $0x1, %ebx
leaq 0x9021(%rip), %rsi      # 0x111e2
movl $0x7, %edx
movq %rax, %rdi
callq 0x33a0
jmp 0x81d5
movl $0x1, %ebx
movq 0xddec(%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 0x94e5(%rip), %rdi      # 0x1170b
xorl %esi, %esi
xorl %eax, %eax
callq 0x34b0
jmp 0x8231
movq %rax, %rbx
movq -0x298(%rbp), %rdi
cmpq %r14, %rdi
je 0x82e8
callq 0x32f0
jmp 0x82e8
jmp 0x8260
jmp 0x825b
jmp 0x825b
movq %rax, %rbx
jmp 0x82a7
jmp 0x8282
movq %rax, %rbx
jmp 0x82ca
movq %rax, %rbx
jmp 0x82dc
movq %rax, %rbx
movq -0x298(%rbp), %rdi
leaq -0x288(%rbp), %rax
cmpq %rax, %rdi
je 0x8285
callq 0x32f0
jmp 0x8285
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
jne 0x82c5
jmp 0x82ca
jmp 0x8298
jmp 0x8298
movq %rax, %rbx
leaq -0x298(%rbp), %rdi
callq 0x30c0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x82b9
callq 0x32f0
movq -0x88(%rbp), %rdi
cmpq %r12, %rdi
je 0x82ca
callq 0x32f0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x82dc
callq 0x32f0
leaq -0x498(%rbp), %rdi
callq 0x34a0
movq %rbx, %rdi
callq 0x35b0