// File: /workspace/github_cpp_makefile_star2_O3/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 0x2ba06
leaq 0x77b2a(%rip), %rsi     # 0xd1a88
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 0x2ba06
leaq 0x77b0c(%rip), %rsi     # 0xd1a99
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 0x2ba06
leaq 0x77af2(%rip), %rsi     # 0xd1aad
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 0x2ba06
leaq 0x77adf(%rip), %rsi     # 0xd1ac8
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 0x77885(%rip), %rsi     # 0xd1909
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 0x80502(%rip), %rsi     # 0xda5b0
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 0x779f7(%rip), %rsi     # 0xd1ae0
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 0x779e5(%rip), %rsi     # 0xd1b1c
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 0x7778e(%rip), %rsi     # 0xd1909
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 0x8040b(%rip), %rsi     # 0xda5b0
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 0x77957(%rip), %rsi     # 0xd1b37
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 0x77946(%rip), %rsi     # 0xd1b74
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 0x77697(%rip), %rsi     # 0xd1909
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 0x80314(%rip), %rsi     # 0xda5b0
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 0x778e5(%rip), %rsi     # 0xd1bbc
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 0x77924(%rip), %rsi     # 0xd1c3f
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 0x775aa(%rip), %rsi     # 0xd1909
movl $0xd, %edx
movq (%rsp), %rdi
callq 0x84e0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq (%rsp), %rdi
callq 0x84e0
movq %rax, %rbx
leaq 0x80229(%rip), %rsi     # 0xda5b0
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 0x77775(%rip), %rsi     # 0xd1b37
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 0x7788a(%rip), %rsi     # 0xd1c98
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 0x2fc8e
leaq 0x100(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x36ba0
leaq 0x100(%rsp), %rdi
callq 0x2e784
leaq 0xe8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x2fc8e
leaq 0xe8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x36ba0
leaq 0xe8(%rsp), %rdi
callq 0x2e784
leaq 0xd0(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x2fc8e
leaq 0xd0(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x36ba0
leaq 0xd0(%rsp), %rdi
callq 0x2e784
leaq 0xb8(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x2fc8e
movq %rbp, 0x28(%rsp)
leaq 0xb8(%rsp), %rdi
movq (%rsp), %rsi
movl $0x9, %edx
movl $0x1, %ecx
callq 0x36ba0
leaq 0xb8(%rsp), %rdi
callq 0x2e784
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %edx # imm = 0xAAAAAAAB
testl %edx, %edx
jle 0x5a6a6
xorl %r15d, %r15d
movq 0xa7a87(%rip), %r12     # 0x101fe8
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rdx
testl %edx, %edx
jle 0x5a697
leaq (%r15,%r15,2), %rbp
xorl %ebx, %ebx
movq (%rax,%rbp,8), %rax
movsd (%rax,%rbx,8), %xmm0
movsd 0x75da8(%rip), %xmm1    # 0xd0340
callq 0x85c0
ucomisd 0x7178b(%rip), %xmm0    # 0xcbd30
jne 0x5a66f
jp 0x5a66f
movq (%r14), %rax
movq (%rax,%rbp,8), %rax
movsd (%rax,%rbx,8), %xmm0
movsd 0x7214b(%rip), %xmm1    # 0xcc710
callq 0x85c0
ucomisd 0x7175e(%rip), %xmm0    # 0xcbd30
jne 0x5a5da
jnp 0x5a66f
movl $0x7, %edx
movq %r12, %rdi
leaq 0x776c7(%rip), %rsi     # 0xd1cb0
callq 0x84e0
movq %r12, %rdi
movl %r15d, %esi
callq 0x8810
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x86da4(%rip), %rsi     # 0xe13af
callq 0x84e0
movq %r13, %rdi
movl %ebx, %esi
callq 0x8810
movq %rax, %r13
movl $0x16, %edx
movq %rax, %rdi
leaq 0x7768c(%rip), %rsi     # 0xd1cb8
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
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %edx # imm = 0xAAAAAAAB
movslq %edx, %rdx
cmpq %rdx, %rbx
jl 0x5a587
jmp 0x5a69a
movslq %edx, %rdx
incq %r15
cmpq %rdx, %r15
jl 0x5a561
movq 0xb0(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0xa0(%rsp), %r12
leaq 0x80(%rsp), %r13
callq 0x5b035
movq 0x28(%rsp), %rbx
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
movq -0x18(%rax), %rax
movq $0xa, 0x8(%rsi,%rax)
movq %r14, %rdi
callq 0x5b035
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x5b035
movq 0x150(%rsp), %rdi
movq (%rsp), %rsi
callq 0x5b126
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5a724
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x5a740
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x5a75a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x5a777
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 0x2e784
jmp 0x5a82d
movq %rax, %r14
leaq 0xd0(%rsp), %rdi
jmp 0x5a7c3
movq %rax, %r14
leaq 0xe8(%rsp), %rdi
jmp 0x5a7c3
movq %rax, %r14
leaq 0x100(%rsp), %rdi
callq 0x2e784
jmp 0x5a83d
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq (%rsp), %rdi
jmp 0x5a805
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0x8(%rsp), %rdi
jmp 0x5a805
jmp 0x5a825
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq 0x10(%rsp), %rdi
jmp 0x5a805
jmp 0x5a825
movq %rax, %r14
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
callq 0x8480
jmp 0x5a83d
jmp 0x5a825
jmp 0x5a825
jmp 0x5a812
movq %rax, %r14
jmp 0x5a859
jmp 0x5a819
movq %rax, %r14
jmp 0x5a875
jmp 0x5a820
movq %rax, %r14
jmp 0x5a88f
movq %rax, %r14
jmp 0x5a83d
movq %rax, %r14
leaq 0xa0(%rsp), %r12
leaq 0x80(%rsp), %r13
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5a859
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x5a875
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x5a88f
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x5a8ac
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r14, %rdi
callq 0x8840