// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]evo/process_vcf_merge.cpp
// Function: mergeMain(int, char**)
int mergeMain(int argc, char** argv) {
    parseMergeOptions(argc, argv);
    
    std::cerr << "Merging: " << opt::VCF1File << " and " << opt::VCF2File << std::endl;
    std::cerr << "writing output to:" << opt::out << std::endl;
    
    // Open connection to read from the vcf files
    std::ifstream* pVCF1 = new std::ifstream(opt::VCF1File.c_str());
    std::ifstream* pVCF2 = new std::ifstream(opt::VCF2File.c_str());
    std::ofstream* pOut = new std::ofstream(opt::out.c_str());
    
    
    string line1; string line2;
    while (getline(*pVCF1, line1)) {
        if (line1[1] != '#') break;
        *pOut << line1 << std::endl;
    }
    while (getline(*pVCF2, line2)) {
        if (line2[1] != '#') break;
    }
    
    // Print the sample names
    std::vector<std::string> fields2 = split(line2, '\t');
    std::vector<std::string> genotypes(fields2.begin()+9,fields2.end());
    *pOut << line1 << "\t"; print_vector(genotypes, *pOut);
    
    // Print the variant details
    while (getline(*pVCF1, line1)) {
        getline(*pVCF2, line2);
        fields2 = split(line2, '\t');
        std::vector<std::string> genotypes(fields2.begin()+9,fields2.end());
        if (opt::bGTonly) {
            for (std::vector<std::string>::size_type i = 0; i != genotypes.size(); i++) {
                std::vector<std::string> gtFields = split(genotypes[i], ':');
                genotypes[i] = gtFields[0];
            }
        }
        *pOut << line1 << "\t"; print_vector(genotypes, *pOut);
    }
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
callq 0x9aa4b
movq 0x70b77(%rip), %rbx     # 0x10afe8
leaq 0x4a176(%rip), %rsi     # 0xe45ee
movl $0x9, %edx
movq %rbx, %rdi
callq 0x84e0
movq 0x72654(%rip), %rsi     # 0x10cae0
movq 0x72655(%rip), %rdx     # 0x10cae8
movq %rbx, %rdi
callq 0x84e0
movq %rax, %r14
leaq 0x4a153(%rip), %rsi     # 0xe45f8
movl $0x5, %edx
movq %rax, %rdi
callq 0x84e0
movq 0x72647(%rip), %rsi     # 0x10cb00
movq 0x72648(%rip), %rdx     # 0x10cb08
movq %r14, %rdi
callq 0x84e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x4a105(%rip), %rsi     # 0xe45fe
movl $0x12, %edx
movq %rbx, %rdi
callq 0x84e0
movq 0x72613(%rip), %rsi     # 0x10cb20
movq 0x72614(%rip), %rdx     # 0x10cb28
movq %rbx, %rdi
callq 0x84e0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %rbx, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %rbx
movq 0x72586(%rip), %rsi     # 0x10cae0
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %r14
movq 0x72585(%rip), %rsi     # 0x10cb00
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
movq %r14, 0x48(%rsp)
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq 0x72582(%rip), %rsi     # 0x10cb20
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0x60(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x10(%rsp), %r12
movq 0x48(%rsp), %r14
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x9a65d
movq 0x10(%rsp), %rsi
cmpb $0x23, 0x1(%rsi)
jne 0x9a65d
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x84e0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r13, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
jmp 0x9a5dc
movq 0x50(%rsp), %rax
cmpb $0x23, 0x1(%rax)
jne 0x9a68f
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x9a652
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movl $0x9, %edx
callq 0x50624
movl $0x120, %esi            # imm = 0x120
addq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
leaq 0xb8(%rsp), %rdi
leaq 0x30(%rsp), %rcx
callq 0x7fa48
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x84e0
leaq 0x3759f(%rip), %rsi     # 0xd1c7e
movl $0x1, %edx
movq %rax, %rdi
callq 0x84e0
leaq 0xa0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x3273a
leaq 0xa0(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x39979
leaq 0xa0(%rsp), %rdi
callq 0x3123c
leaq 0x50(%rsp), %r12
leaq 0x88(%rsp), %rbp
leaq 0x30(%rsp), %r13
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x9a905
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x8870
movq %rbx, %r14
movq %rbp, %rdi
movq %r12, %rsi
movl $0x9, %edx
callq 0x50624
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movups 0x70(%rsp), %xmm0
movq 0x80(%rsp), %rax
movups 0x88(%rsp), %xmm1
movups %xmm1, 0x70(%rsp)
movq 0x98(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movaps 0x30(%rsp), %xmm1
movaps %xmm0, 0x30(%rsp)
movq %rax, 0x40(%rsp)
movups %xmm1, 0x88(%rsp)
movq $0x0, 0x98(%rsp)
movq %r13, %rdi
callq 0x3123c
movq %rbp, %rdi
callq 0x3123c
movq 0x70(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq 0x78(%rsp), %rdx
movq %r13, %rbx
movq %r13, %rdi
movq %rbp, %rcx
callq 0x7fa48
cmpb $0x1, 0x72306(%rip)     # 0x10cb40
jne 0x9a898
movq 0x30(%rsp), %rsi
cmpq %rsi, 0x38(%rsp)
je 0x9a898
xorl %r15d, %r15d
xorl %r13d, %r13d
addq %r15, %rsi
movq %rbp, %rdi
movl $0x3a, %edx
callq 0x50624
movq 0x88(%rsp), %rsi
movq 0x30(%rsp), %rdi
addq %r15, %rdi
callq 0x8270
movq %rbp, %rdi
callq 0x3123c
incq %r13
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
addq $0x20, %r15
cmpq %rax, %r13
jne 0x9a84e
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x84e0
movq %rbx, %r13
leaq 0xd0(%rsp), %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x373b8(%rip), %rsi     # 0xd1c7e
callq 0x84e0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3273a
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x39979
movq %rbx, %rdi
movq %r14, %rbx
callq 0x3123c
movq %r13, %rdi
callq 0x3123c
jmp 0x9a73c
leaq 0xb8(%rsp), %rdi
callq 0x3123c
leaq 0x70(%rsp), %rdi
callq 0x3123c
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x9a938
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x9a954
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x8480
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
leaq 0xa0(%rsp), %rdi
jmp 0x9a9ef
movq %rax, %r12
jmp 0x9aa0b
jmp 0x9a9cb
movq %rax, %r12
movl $0x200, %esi            # imm = 0x200
movq 0x8(%rsp), %rdi
jmp 0x9aa3e
movq %rax, %r12
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
jmp 0x9aa3e
movq %rax, %r12
movl $0x208, %esi            # imm = 0x208
movq %rbx, %rdi
jmp 0x9aa3e
movq %rax, %r12
jmp 0x9a9fe
movq %rax, %r12
leaq 0xd0(%rsp), %rdi
jmp 0x9a9e0
jmp 0x9a9d0
jmp 0x9a9d0
jmp 0x9a9cb
jmp 0x9a9e7
movq %rax, %r12
jmp 0x9aa15
movq %rax, %r12
jmp 0x9a9f4
movq %rax, %r12
leaq 0x88(%rsp), %rdi
callq 0x3123c
jmp 0x9a9ea
movq %rax, %r12
leaq 0x30(%rsp), %rdi
callq 0x3123c
leaq 0x20(%rsp), %r15
leaq 0x60(%rsp), %rbp
leaq 0xb8(%rsp), %rdi
callq 0x3123c
leaq 0x70(%rsp), %rdi
callq 0x3123c
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9aa2c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x9aa43
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r12, %rdi
callq 0x8840