// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/process_vcf_stats_functions.cpp
// Function: diffs_between_individuals_with_multialleleics(std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>&, FilterResult&)
void diffs_between_individuals_with_multialleleics(std::vector<std::vector<double> >& diffs_me, std::vector<std::vector<int> >& pairwise_missingness, std::vector<std::vector<double> >& diffs_me_bootstrap, std::vector<std::vector<int> >& pairwise_missingness_bootstrap, FilterResult& result) {
    for (std::vector<std::vector<int> >::size_type i = 0; i < diffs_me.size(); i++) {
        const int ind_i = result.counts.haplotypesWithVariant[2*i];
        const int ind_i2 = result.counts.haplotypesWithVariant[2*i+1];
        const bool ind_i_missing = result.counts.missingGenotypesPerIndividual[i];
        for (int j = 0; j <= i; j++) {
            double diff_measure_Me;
            if (ind_i_missing) {
                diff_measure_Me = 0;
                pairwise_missingness[i][j]++;
                pairwise_missingness_bootstrap[i][j]++;
            } else {
                const bool ind_j_missing = result.counts.missingGenotypesPerIndividual[j];
                if (ind_j_missing) {
                    diff_measure_Me = 0;
                    pairwise_missingness[i][j]++;
                    pairwise_missingness_bootstrap[i][j]++;
                } else {
                    const int ind_j = result.counts.haplotypesWithVariant[2*j];
                    const int ind_j2 = result.counts.haplotypesWithVariant[2*j+1];
                    if (j < i) {
                        double totalD = 0; const double numComparisons = 4;
                        if (ind_i != ind_j) totalD++;
                        if (ind_i != ind_j2) totalD++;
                        if (ind_i2 != ind_j) totalD++;
                        if (ind_i2 != ind_j2) totalD++;
                        diff_measure_Me = totalD/numComparisons;
                        if (diff_measure_Me != 0 && diff_measure_Me != 0.5 && diff_measure_Me != 0.75 && diff_measure_Me != 1) {
                            std::cerr << "diff_measure_Me: " << diff_measure_Me << std::endl;
                            std::cerr << "ind_i: " << ind_i << std::endl;
                            std::cerr << "ind_i2: " << ind_i2 << std::endl;
                            std::cerr << "ind_j: " << ind_j << std::endl;
                            std::cerr << "ind_j2: " << ind_j2 << std::endl;
                        }
                        diffs_me[i][j] = diffs_me[i][j] + diff_measure_Me;
                        diffs_me_bootstrap[i][j] = diffs_me_bootstrap[i][j] + diff_measure_Me;
                    } else if (j == i) { // Fill in the diagonal, the number of hets
                        if (ind_i != ind_i2) {
                            diffs_me[i][j]++;
                            diffs_me_bootstrap[i][j]++;
                        }
                    }
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rdx, 0x28(%rsp)
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
movq %r8, 0x18(%rsp)
leaq 0xd8(%r8), %rax
movq %rax, 0x30(%rsp)
pushq $0x1
popq %rbp
xorl %ebx, %ebx
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %rax, %rbx
jae 0x4c571
movq 0x18(%rsp), %rax
movq 0xc0(%rax), %rax
movl (%rax,%rbx,8), %ecx
movl %ecx, 0x4(%rsp)
movl 0x4(%rax,%rbx,8), %eax
movl %eax, (%rsp)
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x439c0
movq %rdx, %r15
andq (%rax), %r15
xorl %r13d, %r13d
cmpq %r13, %rbp
je 0x4c566
testq %r15, %r15
jne 0x4c34f
movq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x439c0
testq %rdx, (%rax)
je 0x4c36f
movq (%r12), %rax
imulq $0x18, %rbx, %rcx
movq (%rax,%rcx), %rax
incl (%rax,%r13,4)
movq (%r14), %rax
movq (%rax,%rcx), %rax
incl (%rax,%r13,4)
incq %r13
jmp 0x4c32f
cmpq %r13, %rbx
movsd 0x4b276(%rip), %xmm1    # 0x975f0
jbe 0x4c518
movq 0x18(%rsp), %rax
movq 0xc0(%rax), %rax
movl (%rax,%r13,8), %edx
xorpd %xmm2, %xmm2
cmpl %edx, 0x4(%rsp)
je 0x4c39e
movapd %xmm1, %xmm2
movl 0x4(%rax,%r13,8), %ecx
cmpl %ecx, 0x4(%rsp)
je 0x4c3ad
addsd %xmm1, %xmm2
cmpl %edx, (%rsp)
je 0x4c3b6
addsd %xmm1, %xmm2
cmpl %ecx, (%rsp)
je 0x4c3bf
addsd %xmm1, %xmm2
mulsd 0x54fc9(%rip), %xmm2    # 0xa1390
ucomisd %xmm1, %xmm2
jne 0x4c3d3
jnp 0x4c4db
ucomisd 0x54fbd(%rip), %xmm2    # 0xa1398
jne 0x4c3e3
jnp 0x4c4db
ucomisd 0x49dad(%rip), %xmm2    # 0x96198
jne 0x4c3f3
jnp 0x4c4db
ucomisd 0x4b205(%rip), %xmm2    # 0x97600
jne 0x4c403
jnp 0x4c4db
movq 0x90bde(%rip), %rdi     # 0xdcfe8
movl %ecx, 0x14(%rsp)
movl %edx, 0x10(%rsp)
leaq 0x55072(%rip), %rsi     # 0xa148b
movsd %xmm2, 0x20(%rsp)
callq 0x8480
movq %rax, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x8750
movq %rax, %rdi
callq 0x8230
movq 0x90ba7(%rip), %rdi     # 0xdcfe8
leaq 0x55055(%rip), %rsi     # 0xa149d
callq 0x8480
movq %rax, %rdi
movl 0x4(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x90b80(%rip), %rdi     # 0xdcfe8
leaq 0x55036(%rip), %rsi     # 0xa14a5
callq 0x8480
movq %rax, %rdi
movl (%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x90b5a(%rip), %rdi     # 0xdcfe8
leaq 0x55019(%rip), %rsi     # 0xa14ae
callq 0x8480
movq %rax, %rdi
movl 0x10(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movq 0x90b33(%rip), %rdi     # 0xdcfe8
leaq 0x54ffa(%rip), %rsi     # 0xa14b6
callq 0x8480
movq %rax, %rdi
movl 0x14(%rsp), %esi
callq 0x8840
movq %rax, %rdi
callq 0x8230
movsd 0x20(%rsp), %xmm2
movq 0x8(%rsp), %rax
movq (%rax), %rax
imulq $0x18, %rbx, %rcx
movq (%rax,%rcx), %rax
movsd (%rax,%r13,8), %xmm0
addsd %xmm2, %xmm0
movsd %xmm0, (%rax,%r13,8)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rcx), %rax
addsd (%rax,%r13,8), %xmm2
movsd %xmm2, (%rax,%r13,8)
jmp 0x4c36a
movl (%rsp), %eax
cmpl %eax, 0x4(%rsp)
je 0x4c36a
movq 0x8(%rsp), %rax
movq (%rax), %rax
imulq $0x18, %rbx, %rcx
movq (%rax,%rcx), %rax
movsd (%rax,%r13,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%r13,8)
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rcx), %rax
movsd (%rax,%r13,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%r13,8)
jmp 0x4c36a
incq %rbx
incq %rbp
jmp 0x4c2e2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq