// File: auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_mean_depth(double, double)
void entry::filter_sites_by_mean_depth(double min_mean_depth, double max_mean_depth)
{
	// Filter sites by mean depth
	if (passed_filters == false)
		return;

	if ((min_mean_depth <= 0) && (max_mean_depth == numeric_limits<double>::max()))
		return;

	int depth;

	unsigned int N_indv_included = 0;
	double depth_sum = 0.0;
	for (unsigned int ui=0; ui<N_indv; ui++)
	{
		if (include_indv[ui] == false)
			continue;

		if (include_genotype[ui] == true)
		{
			parse_genotype_entry(ui, false, false, true);

			if (entry_header.has_genotypes == false)
				LOG.error("Require Genotypes in VCF file in order to filter sites by mean depth");

			depth = get_indv_DEPTH(ui);
			if (depth >= 0)
			{
				depth_sum += depth;
			}
			N_indv_included++;
		}
	}
	double mean_depth = depth_sum / N_indv_included;

	if ((mean_depth < min_mean_depth) || (mean_depth > max_mean_depth))
		passed_filters = false;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movsd %xmm0, 0x98(%rsp)
movsd %xmm1, 0x90(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
movb 0xc(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5d1b0
jmp 0x5d3f5
xorps %xmm0, %xmm0
ucomisd 0x98(%rsp), %xmm0
jb 0x5d1e8
movsd 0x90(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0xf250
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jne 0x5d1e8
jp 0x5d1e8
jmp 0x5d3f5
movl $0x0, 0x88(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
movq 0x10(%rsp), %rcx
movl 0x7c(%rsp), %eax
cmpl 0x8(%rcx), %eax
jae 0x5d3a7
movq 0x10(%rsp), %rdi
addq $0x1f0, %rdi            # imm = 0x1F0
movl 0x7c(%rsp), %eax
movl %eax, %esi
callq 0x102b0
movq %rax, 0x68(%rsp)
movq %rdx, 0x70(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x10310
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5d253
jmp 0x5d397
movq 0x10(%rsp), %rdi
addq $0x218, %rdi            # imm = 0x218
movl 0x7c(%rsp), %eax
movl %eax, %esi
callq 0x102b0
movq %rax, 0x58(%rsp)
movq %rdx, 0x60(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x10310
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x5d395
movq 0x10(%rsp), %rdi
movl 0x7c(%rsp), %esi
movq (%rdi), %rax
xorl %r9d, %r9d
movl $0x1, %r8d
movl %r9d, %edx
movl %r9d, %ecx
callq *0x20(%rax)
movq 0x10(%rsp), %rax
movb 0x15(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5d34a
leaq 0x37(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x69f0
movq (%rsp), %rdx
leaq 0x18999(%rip), %rsi     # 0x75c72
leaq 0x38(%rsp), %rdi
callq 0x67c0
jmp 0x5d2e5
leaq 0x36314(%rip), %rdi     # 0x93600
leaq 0x38(%rsp), %rsi
movl $0x1, %edx
callq 0x712f0
jmp 0x5d2fd
leaq 0x38(%rsp), %rdi
callq 0x6b50
leaq 0x37(%rsp), %rdi
callq 0x65f0
jmp 0x5d34a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x28(%rsp)
movl %eax, 0x24(%rsp)
jmp 0x5d33b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x28(%rsp)
movl %eax, 0x24(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x6b50
leaq 0x37(%rsp), %rdi
callq 0x65f0
jmp 0x5d3fd
movq 0x10(%rsp), %rdi
movl 0x7c(%rsp), %esi
callq 0x4be10
movl %eax, 0x8c(%rsp)
cmpl $0x0, 0x8c(%rsp)
jl 0x5d384
cvtsi2sdl 0x8c(%rsp), %xmm0
addsd 0x80(%rsp), %xmm0
movsd %xmm0, 0x80(%rsp)
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x5d397
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x5d207
movsd 0x80(%rsp), %xmm0
movl 0x88(%rsp), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rsp), %xmm1
movsd 0x98(%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x5d3ec
movsd 0x18(%rsp), %xmm0
ucomisd 0x90(%rsp), %xmm0
jbe 0x5d3f5
movq 0x10(%rsp), %rax
movb $0x0, 0xc(%rax)
addq $0xa8, %rsp
retq
movq 0x28(%rsp), %rdi
callq 0x69e0
nopw (%rax,%rax)