// File: /workspace/github_cpp_makefile_star2_O2/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 0x72a58
movq 0x6a9a3(%rip), %rbx     # 0xdcfe8
leaq 0x3a272(%rip), %rsi     # 0xac8be
movq %rbx, %rdi
callq 0x8480
leaq 0x6c4bd(%rip), %rsi     # 0xdeb18
movq %rax, %rdi
callq 0x8430
leaq 0x3a25e(%rip), %rsi     # 0xac8c8
movq %rax, %rdi
callq 0x8480
leaq 0x6c4bf(%rip), %rsi     # 0xdeb38
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x3a23e(%rip), %rsi     # 0xac8ce
movq %rbx, %rdi
callq 0x8480
leaq 0x6c4b9(%rip), %rsi     # 0xdeb58
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq 0x6c458(%rip), %rsi     # 0xdeb18
pushq $0x8
popq %rdx
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x8890
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq 0x6c457(%rip), %rsi     # 0xdeb38
pushq $0x8
popq %rdx
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x8890
movl $0x200, %edi            # imm = 0x200
callq 0x8490
movq %rax, %r15
movq 0x6c453(%rip), %rsi     # 0xdeb58
pushq $0x10
popq %rdx
movq %rax, %rdi
callq 0x84e0
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x58(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %edx, %edx
movb %dl, (%rax)
movb %dl, (%rcx)
leaq 0x68(%rsp), %rbx
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x7277d
movq 0x68(%rsp), %rax
cmpb $0x23, 0x1(%rax)
jne 0x7277d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8430
movq %rax, %rdi
callq 0x8230
jmp 0x72737
movq 0x48(%rsp), %rax
cmpb $0x23, 0x1(%rax)
jne 0x7279a
leaq 0x48(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x72772
leaq 0x30(%rsp), %rdi
leaq 0x48(%rsp), %rsi
pushq $0x9
popq %rdx
callq 0x40349
movl $0x120, %esi            # imm = 0x120
addq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
leaq 0xa0(%rsp), %rdi
leaq 0x18(%rsp), %rcx
callq 0x613fe
leaq 0x68(%rsp), %rsi
movq %r15, %rdi
callq 0x8430
leaq 0x2763d(%rip), %rsi     # 0x99e1e
movq %rax, %rdi
callq 0x8480
leaq 0x88(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x297dc
leaq 0x88(%rsp), %rdi
pushq $0x9
popq %rdx
pushq $0x1
popq %rcx
movq %r15, %rsi
callq 0x2ea24
leaq 0x88(%rsp), %rdi
callq 0x28a08
leaq 0x68(%rsp), %rbp
leaq 0xd0(%rsp), %r14
pushq $0x3a
popq %r13
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x72962
movq 0x8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x80a0
movq %r15, %rbx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
leaq 0x48(%rsp), %rsi
pushq $0x9
popq %rdx
callq 0x40349
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x2f6c0
movq %r15, %rdi
callq 0x28a08
movq 0x30(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq 0x38(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rcx
callq 0x613fe
cmpb $0x1, 0x6c2c7(%rip)     # 0xdeb78
jne 0x72903
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rax, %r15
je 0x72903
addq %r12, %rsi
movq %r14, %rdi
movl %r13d, %edx
callq 0x40349
movq 0xd0(%rsp), %rsi
movq 0x18(%rsp), %rdi
addq %r12, %rdi
callq 0x82a0
movq %r14, %rdi
callq 0x28a08
incq %r15
addq $0x20, %r12
jmp 0x728b9
movq %rbx, %r15
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x8430
movq %rax, %rdi
leaq 0x27503(%rip), %rsi     # 0x99e1e
callq 0x8480
leaq 0xb8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x297dc
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
pushq $0x9
popq %rdx
pushq $0x1
popq %rcx
callq 0x2ea24
movq %rbx, %rdi
callq 0x28a08
leaq 0x18(%rsp), %rdi
callq 0x28a08
jmp 0x72832
leaq 0xa0(%rsp), %rdi
callq 0x28a08
leaq 0x30(%rsp), %rdi
callq 0x28a08
leaq 0x48(%rsp), %rdi
callq 0x8978
leaq 0x68(%rsp), %rdi
callq 0x8978
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x72a20
movq %rax, %rbx
jmp 0x72a32
jmp 0x729fa
movq %rax, %rbx
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdi
jmp 0x729de
movq %rax, %rbx
movl $0x208, %esi            # imm = 0x208
movq 0x8(%rsp), %rdi
jmp 0x729de
movq %rax, %rbx
movl $0x208, %esi            # imm = 0x208
movq 0x10(%rsp), %rdi
callq 0x84a0
jmp 0x72a50
jmp 0x729ff
jmp 0x729fa
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x72a16
jmp 0x729ff
jmp 0x729ff
movq %rax, %rbx
jmp 0x72a3c
movq %rax, %rbx
jmp 0x72a25
jmp 0x72a06
movq %rax, %rbx
jmp 0x72a1b
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x28a08
leaq 0x18(%rsp), %rdi
callq 0x28a08
leaq 0xa0(%rsp), %rdi
callq 0x28a08
leaq 0x30(%rsp), %rdi
callq 0x28a08
leaq 0x48(%rsp), %rdi
callq 0x8978
leaq 0x68(%rsp), %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8870