// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]evo/process_vcf_print_routines.cpp
// Function: print_pairwise_diff_stats(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, int, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>> const&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>> const&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>> const&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>> const&)
void print_pairwise_diff_stats(const string& fileRoot, const std::vector<std::string>& header, const int totalVariantNumber, const std::vector<std::vector<double> >& diffMatrix, const std::vector<std::vector<double> >& diffMatrixMe, const std::vector<std::vector<double> >& diffMatrixHetsVsHomDiff, const std::vector<std::vector<int> >& pairwiseMissingness) {
    std::ios_base::openmode mode_out = std::ios_base::out;
    string diffFileName = fileRoot + ".diff_matrix.txt";
    string diffMeFileName = fileRoot + ".diff_me_matrix.txt";
    string hetHomFileName = fileRoot + ".hets_over_homs_matrix.txt";
    string pairwiseMisFileName = fileRoot + ".parwiseMissingness.txt";
    std::ofstream* pDiffOutFile = new std::ofstream(diffFileName.c_str(), mode_out);
    std::ofstream* pDiffMeOutFile = new std::ofstream(diffMeFileName.c_str(), mode_out);
    std::ofstream* pHetHomOutFile = new std::ofstream(hetHomFileName.c_str(), mode_out);
    std::ofstream* pPairMisOutFile = new std::ofstream(pairwiseMisFileName.c_str(), mode_out);
    *pDiffOutFile << "# Input file:" << fileRoot << ".vcf" << std::endl;
    *pDiffOutFile << "# Total number of segragating variant sites in this sample:" << totalVariantNumber << std::endl;
    *pDiffOutFile << "# Richard's scoring scheme" << std::endl;
    *pDiffMeOutFile << "# Input file:" << fileRoot << ".vcf" << std::endl;
    *pDiffMeOutFile << "# Total number of segragating variant sites in this sample: " << totalVariantNumber << std::endl;
    *pDiffMeOutFile << "# Homozygous difference = 1, one homozygous, another heterozygous = 0.5" << std::endl;
    *pHetHomOutFile << "# Input file:" << fileRoot << ".vcf" << std::endl;
    *pHetHomOutFile << "# number of sites both individuals hets/number of sites individuals have a homozygous difference; i.e. num(1/0::1/0)/num(1/1::0/0)" << std::endl;
    *pHetHomOutFile << "# For a free mixing population, we expect this number ~2; for fully separated species ~0" << std::endl;
    *pPairMisOutFile << "# Input file:" << fileRoot << ".vcf" << std::endl;
    *pPairMisOutFile << "# Total number of segragating variant sites in this sample: " << totalVariantNumber << std::endl;
    *pPairMisOutFile << "# Pairwise missingness:" << std::endl;
    
    
    // print headers
    print_vector(header,*pDiffOutFile);
    print_vector(header,*pDiffMeOutFile);
    print_vector(header,*pHetHomOutFile);
    print_vector(header,*pPairMisOutFile);
    
    for (int i = 0; i < (int)diffMatrixMe.size(); i++) {
        for (int j = 0; j < (int)diffMatrixMe.size(); j++) {
            if (fmod(diffMatrixMe[i][j],0.2) == 0 && fmod(diffMatrixMe[i][j],1.0) != 0)  {
                std::cerr << "[i][j] " << i << " " << j << " diffMatrixMe[i][j] = " << diffMatrixMe[i][j] << std::endl;
            }
        }
    }
    
    // print statistics
    print_matrix<const std::vector<std::vector<double> >&>(diffMatrix, *pDiffOutFile);
    pDiffMeOutFile->precision(10); print_matrix<const std::vector<std::vector<double> >&>(diffMatrixMe, *pDiffMeOutFile);
    print_matrix<const std::vector<std::vector<double> >&>(diffMatrixHetsVsHomDiff, *pHetHomOutFile);
    print_matrix<const std::vector<std::vector<int> >&>(pairwiseMissingness, *pPairMisOutFile);
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r9, %rbp
movq %r8, %r14
movq %rcx, 0xb0(%rsp)
movl %edx, 0x24(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %r15
leaq 0xa0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x2e45c
leaq 0x7e151(%rip), %rsi     # 0xd7f4a
movq %rbx, %rdi
callq 0x88c0
leaq 0x80(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x2e45c
leaq 0x7e133(%rip), %rsi     # 0xd7f5b
leaq 0x70(%rsp), %rdi
callq 0x88c0
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x2e45c
leaq 0x7e119(%rip), %rsi     # 0xd7f6f
leaq 0x50(%rsp), %rdi
callq 0x88c0
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0x2e45c
leaq 0x7e106(%rip), %rsi     # 0xd7f8a
leaq 0x30(%rsp), %rdi
callq 0x88c0
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq %rax, %rbx
movq 0x90(%rsp), %rsi
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq 0x70(%rsp), %rsi
movq %rax, 0x10(%rsp)
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq %rbx, 0x18(%rsp)
movq 0x50(%rsp), %rsi
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movl $0x10, %edx
callq 0x84c0
movl $0x200, %edi            # imm = 0x200
callq 0x8470
movq %rax, (%rsp)
movq 0x30(%rsp), %rsi
movq (%rsp), %rdi
movl $0x10, %edx
callq 0x84c0
leaq 0x7deac(%rip), %rsi     # 0xd7dcb
movl $0xd, %edx
movq 0x18(%rsp), %rdi
callq 0x84e0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x18(%rsp), %rdi
callq 0x84e0
movq %rax, %rbx
leaq 0x88087(%rip), %rsi     # 0xe1fd0
movl $0x4, %edx
movq %rax, %rdi
callq 0x84e0
movq (%rbx), %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
leaq 0x7e01e(%rip), %rsi     # 0xd7fa2
movl $0x3b, %edx
movq 0x18(%rsp), %rdi
callq 0x84e0
movq 0x18(%rsp), %rdi
movl 0x24(%rsp), %esi
callq 0x8810
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
leaq 0x7e00c(%rip), %rsi     # 0xd7fde
movl $0x1a, %edx
movq 0x18(%rsp), %rdi
callq 0x84e0
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq 0x18(%rsp), %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x7ddb5(%rip), %rsi     # 0xd7dcb
movl $0xd, %edx
movq 0x10(%rsp), %rdi
callq 0x84e0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%rsp), %rdi
callq 0x84e0
movq %rax, %rbx
leaq 0x87f90(%rip), %rsi     # 0xe1fd0
movl $0x4, %edx
movq %rax, %rdi
callq 0x84e0
movq (%rbx), %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
leaq 0x7df7e(%rip), %rsi     # 0xd7ff9
movl $0x3c, %edx
movq 0x10(%rsp), %rdi
callq 0x84e0
movq 0x10(%rsp), %rdi
movl 0x24(%rsp), %esi
callq 0x8810
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
leaq 0x7df6d(%rip), %rsi     # 0xd8036
movl $0x47, %edx
movq 0x10(%rsp), %rdi
callq 0x84e0
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq 0x10(%rsp), %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x7dcbe(%rip), %rsi     # 0xd7dcb
movl $0xd, %edx
movq 0x8(%rsp), %rdi
callq 0x84e0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x8(%rsp), %rdi
callq 0x84e0
movq %rax, %rbx
leaq 0x87e99(%rip), %rsi     # 0xe1fd0
movl $0x4, %edx
movq %rax, %rdi
callq 0x84e0
movq (%rbx), %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
leaq 0x7df0c(%rip), %rsi     # 0xd807e
movl $0x82, %edx
movq 0x8(%rsp), %rdi
callq 0x84e0
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq 0x8(%rsp), %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x7df4b(%rip), %rsi     # 0xd8101
movl $0x58, %edx
movq 0x8(%rsp), %rdi
callq 0x84e0
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq 0x8(%rsp), %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x7dbd1(%rip), %rsi     # 0xd7dcb
movl $0xd, %edx
movq (%rsp), %rdi
callq 0x84e0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq (%rsp), %rdi
callq 0x84e0
movq %rax, %rbx
leaq 0x87dae(%rip), %rsi     # 0xe1fd0
movl $0x4, %edx
movq %rax, %rdi
callq 0x84e0
movq (%rbx), %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
leaq 0x7dd9c(%rip), %rsi     # 0xd7ff9
movl $0x3c, %edx
movq (%rsp), %rdi
callq 0x84e0
movq (%rsp), %rdi
movl 0x24(%rsp), %esi
callq 0x8810
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
leaq 0x7deb1(%rip), %rsi     # 0xd815a
movl $0x17, %edx
movq (%rsp), %rdi
callq 0x84e0
movq (%rsp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq (%rsp), %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x100(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3273a
leaq 0x100(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x39979
leaq 0x100(%rsp), %rdi
callq 0x3123c
leaq 0xe8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3273a
leaq 0xe8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x39979
leaq 0xe8(%rsp), %rdi
callq 0x3123c
leaq 0xd0(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3273a
leaq 0xd0(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x39979
leaq 0xd0(%rsp), %rdi
callq 0x3123c
leaq 0xb8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3273a
movq %rbp, 0x28(%rsp)
leaq 0xb8(%rsp), %rdi
movq (%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x39979
leaq 0xb8(%rsp), %rdi
callq 0x3123c
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
testl %eax, %eax
jle 0x5a542
xorl %r15d, %r15d
movq 0xb0bf2(%rip), %r12     # 0x10afe8
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
testl %ecx, %ecx
jle 0x5a523
leaq (%r15,%r15,2), %rbp
xorl %ebx, %ebx
movq (%rax,%rbp,8), %rax
movsd (%rax,%rbx,8), %xmm0
movsd 0x6fcbf(%rip), %xmm1    # 0xca0e8
callq 0x85c0
ucomisd 0x73bf2(%rip), %xmm0    # 0xce028
jne 0x5a500
jp 0x5a500
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movsd (%rax,%rbx,8), %xmm0
movsd 0x74fea(%rip), %xmm1    # 0xcf440
callq 0x85c0
ucomisd 0x73bc5(%rip), %xmm0    # 0xce028
jne 0x5a46b
jnp 0x5a500
movl $0x7, %edx
movq %r12, %rdi
leaq 0x7dcf8(%rip), %rsi     # 0xd8172
callq 0x84e0
movq %r12, %rdi
movl %r15d, %esi
callq 0x8810
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x8fe9b(%rip), %rsi     # 0xea337
callq 0x84e0
movq %r13, %rdi
movl %ebx, %esi
callq 0x8810
movq %rax, %r13
movl $0x16, %edx
movq %rax, %rdi
leaq 0x7dcbd(%rip), %rsi     # 0xd817a
callq 0x84e0
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r13, %rdi
callq 0x8730
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
incq %rbx
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
imull $0xaaaaaaab, %ecx, %ecx # imm = 0xAAAAAAAB
movslq %ecx, %rcx
cmpq %rcx, %rbx
jl 0x5a418
incq %r15
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
cltq
cmpq %rax, %r15
jl 0x5a3f6
movq 0xb0(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xa0(%rsp), %r12
leaq 0x80(%rsp), %r13
callq 0x5aeca
movq 0x28(%rsp), %rbx
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
movq -0x18(%rax), %rax
movq $0xa, 0x8(%rsi,%rax)
movq %r14, %rdi
callq 0x5aeca
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x5aeca
movq 0x150(%rsp), %rdi
movq (%rsp), %rsi
callq 0x5afb4
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5a5c0
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x5a5dc
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x5a5f6
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x5a613
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x8480
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
callq 0x3123c
jmp 0x5a6c9
movq %rax, %r14
leaq 0xd0(%rsp), %rdi
jmp 0x5a65f
movq %rax, %r14
leaq 0xe8(%rsp), %rdi
jmp 0x5a65f
movq %rax, %r14
leaq 0x100(%rsp), %rdi
callq 0x3123c
jmp 0x5a6d9
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq (%rsp), %rdi
jmp 0x5a6a1
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0x8(%rsp), %rdi
jmp 0x5a6a1
jmp 0x5a6c1
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0x10(%rsp), %rdi
jmp 0x5a6a1
jmp 0x5a6c1
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
callq 0x8480
jmp 0x5a6d9
jmp 0x5a6c1
jmp 0x5a6c1
jmp 0x5a6ae
movq %rax, %r14
jmp 0x5a6f5
jmp 0x5a6b5
movq %rax, %r14
jmp 0x5a711
jmp 0x5a6bc
movq %rax, %r14
jmp 0x5a72b
movq %rax, %r14
jmp 0x5a6d9
movq %rax, %r14
leaq 0xa0(%rsp), %r12
leaq 0x80(%rsp), %r13
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5a6f5
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x5a711
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x5a72b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x5a748
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r14, %rdi
callq 0x8840