// File: /workspace/github_cpp_makefile_star2_O3/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 $0xf8, %rsp
callq 0x99f93
movq 0x6861b(%rip), %rbx     # 0x101fe8
leaq 0x4320a(%rip), %rsi     # 0xdcbde
movl $0x9, %edx
movq %rbx, %rdi
callq 0x84e0
movq 0x6a108(%rip), %rsi     # 0x103af0
movq 0x6a109(%rip), %rdx     # 0x103af8
movq %rbx, %rdi
callq 0x84e0
movq %rax, %r14
leaq 0x431e7(%rip), %rsi     # 0xdcbe8
movl $0x5, %edx
movq %rax, %rdi
callq 0x84e0
movq 0x6a0fb(%rip), %rsi     # 0x103b10
movq 0x6a0fc(%rip), %rdx     # 0x103b18
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 0x43199(%rip), %rsi     # 0xdcbee
movl $0x12, %edx
movq %rbx, %rdi
callq 0x84e0
movq 0x6a0c7(%rip), %rsi     # 0x103b30
movq 0x6a0c8(%rip), %rdx     # 0x103b38
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 0x6a03a(%rip), %rsi     # 0x103af0
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %r14
movq 0x6a039(%rip), %rsi     # 0x103b10
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
movq %r14, 0x28(%rsp)
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq 0x6a036(%rip), %rsi     # 0x103b30
movq %rax, (%rsp)
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0x40(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x8(%rsp), %r12
movq 0x28(%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 0x99bb7
movq 0x8(%rsp), %rsi
cmpb $0x23, 0x1(%rsi)
jne 0x99bb7
movq 0x10(%rsp), %rdx
movq (%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 0x99b37
movq 0x30(%rsp), %rax
cmpb $0x23, 0x1(%rax)
jne 0x99be9
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x99bac
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0x9, %edx
callq 0x4d650
movl $0x120, %esi            # imm = 0x120
addq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0xc8(%rsp), %rdi
leaq 0x70(%rsp), %rcx
callq 0x7f67a
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq (%rsp), %rdi
callq 0x84e0
leaq 0x33d92(%rip), %rsi     # 0xcd9ca
movl $0x1, %edx
movq %rax, %rdi
callq 0x84e0
leaq 0xb0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x2fc8e
leaq 0xb0(%rsp), %rdi
movq (%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x36ba0
leaq 0xb0(%rsp), %rdi
callq 0x2e784
leaq 0x30(%rsp), %r12
leaq 0x90(%rsp), %rbp
leaq 0x70(%rsp), %r13
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x99e4e
movq 0x28(%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x8870
movq %rbx, %r14
movq %rbp, %rdi
movq %r12, %rsi
movl $0x9, %edx
callq 0x4d650
movq 0x60(%rsp), %rax
movaps 0x90(%rsp), %xmm0
movq 0xa0(%rsp), %rcx
movq %rcx, 0x60(%rsp)
movaps 0x50(%rsp), %xmm1
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x70(%rsp)
movq %rax, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq %r13, %rdi
callq 0x2e784
movq %rbp, %rdi
callq 0x2e784
movq 0x50(%rsp), %rsi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rsi
movq 0x58(%rsp), %rdx
movq %r13, %rbx
movq %r13, %rdi
movq %rbp, %rcx
callq 0x7f67a
cmpb $0x1, 0x69dcb(%rip)     # 0x103b50
jne 0x99de3
movq 0x70(%rsp), %rsi
cmpq %rsi, 0x78(%rsp)
je 0x99de3
xorl %r15d, %r15d
xorl %r13d, %r13d
addq %r15, %rsi
movq %rbp, %rdi
movl $0x3a, %edx
callq 0x4d650
movq 0x90(%rsp), %rsi
movq 0x70(%rsp), %rdi
addq %r15, %rdi
callq 0x8270
movq %rbp, %rdi
callq 0x2e784
incq %r13
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
addq $0x20, %r15
cmpq %rax, %r13
jne 0x99d99
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq (%rsp), %rdi
callq 0x84e0
movq %rbx, %r13
leaq 0xe0(%rsp), %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x33bba(%rip), %rsi     # 0xcd9ca
callq 0x84e0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2fc8e
movq %rbx, %rdi
movq (%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x36ba0
movq %rbx, %rdi
movq %r14, %rbx
callq 0x2e784
movq %r13, %rdi
callq 0x2e784
jmp 0x99c94
leaq 0xc8(%rsp), %rdi
callq 0x2e784
leaq 0x50(%rsp), %rdi
callq 0x2e784
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x99e81
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x99e9d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x8480
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
leaq 0xb0(%rsp), %rdi
jmp 0x99f37
movq %rax, %r12
jmp 0x99f53
jmp 0x99f13
movq %rax, %r12
movl $0x200, %esi            # imm = 0x200
movq (%rsp), %rdi
jmp 0x99f86
movq %rax, %r12
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
jmp 0x99f86
movq %rax, %r12
movl $0x208, %esi            # imm = 0x208
movq %rbx, %rdi
jmp 0x99f86
movq %rax, %r12
jmp 0x99f46
movq %rax, %r12
leaq 0xe0(%rsp), %rdi
jmp 0x99f28
jmp 0x99f18
jmp 0x99f18
jmp 0x99f13
jmp 0x99f2f
movq %rax, %r12
jmp 0x99f5d
movq %rax, %r12
jmp 0x99f3c
movq %rax, %r12
leaq 0x90(%rsp), %rdi
callq 0x2e784
jmp 0x99f32
movq %rax, %r12
leaq 0x70(%rsp), %rdi
callq 0x2e784
leaq 0x18(%rsp), %r15
leaq 0x40(%rsp), %rbp
leaq 0xc8(%rsp), %rdi
callq 0x2e784
leaq 0x50(%rsp), %rdi
callq 0x2e784
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x99f74
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x99f8b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r12, %rdi
callq 0x8840