// File: /workspace/github_cpp_makefile_star2_O2/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_frequency_and_call_rate(double, double, double, double, double)
void entry::filter_sites_by_frequency_and_call_rate(double min_maf, double max_maf, double min_non_ref_af, double max_non_ref_af, double min_site_call_rate)
{
	// Filter sites so that all allele frequencies are between limits
	if (passed_filters == false)
		return;

	if ((min_maf <= 0.0) && (max_maf >= 1.0) && (min_site_call_rate <= 0) && (min_non_ref_af <= 0.0) && (max_non_ref_af >= 1.0))
		return;

	unsigned int N_alleles;
	unsigned int N_non_missing_chr;
	parse_basic_entry(true);
	parse_genotype_entries(true);

	if (GT_idx == -1)
		LOG.error("Require Genotypes in variant file to filter by frequency and/or call rate");

	N_alleles = get_N_alleles();

	vector<int> allele_counts;
	get_allele_counts(allele_counts, N_non_missing_chr);

	double freq, folded_freq;
	double maf=numeric_limits<double>::max();
	for (unsigned int ui=0; ui<N_alleles; ui++)
	{
		freq = allele_counts[ui] / (double)N_non_missing_chr;
		folded_freq = min(freq, 1.0 - freq);

		maf = min(maf, folded_freq);
		if ((ui > 0) && ((freq < min_non_ref_af) || (freq > max_non_ref_af)))
			passed_filters = false;
	}

	if ((maf < min_maf) || (maf > max_maf))
		passed_filters = false;

	double call_rate = N_non_missing_chr / double(get_N_chr());

	if (call_rate < min_site_call_rate)
		passed_filters = false;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x78, %rsp
movsd %xmm4, 0x10(%rsp)
cmpb $0x0, 0xc(%rdi)
je 0x23c6c
movq %rdi, %rbx
ucomisd 0x9533(%rip), %xmm3     # 0x2d018
jb 0x23b0d
xorpd %xmm4, %xmm4
ucomisd %xmm2, %xmm4
jb 0x23b0d
ucomisd %xmm0, %xmm4
jb 0x23b0d
ucomisd 0x9519(%rip), %xmm1     # 0x2d018
jb 0x23b0d
ucomisd 0x10(%rsp), %xmm4
jae 0x23c6c
movsd %xmm0, 0x28(%rsp)
movsd %xmm2, 0x30(%rsp)
movsd %xmm3, 0x38(%rsp)
movsd %xmm1, 0x20(%rsp)
movq (%rbx), %rax
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movl %ebp, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x28(%rax)
cmpl $-0x1, 0x630(%rbx)
jne 0x23b86
leaq 0xb2df(%rip), %rsi      # 0x2ee38
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x5160
leaq 0x1d961(%rip), %rdi     # 0x414d0
leaq 0x58(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x2bf18
leaq 0x58(%rsp), %rdi
callq 0x5908
movq %rbx, %rdi
callq 0x1ce64
movl %eax, %ebp
xorpd %xmm0, %xmm0
leaq 0x40(%rsp), %rsi
movapd %xmm0, (%rsi)
andq $0x0, 0x10(%rsi)
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0x1cf20
movq 0x40(%rsp), %rax
movl 0xc(%rsp), %ecx
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x18(%rsp)
movl %ebp, %ecx
movsd 0x9473(%rip), %xmm0     # 0x2d040
xorl %edx, %edx
movsd 0x9441(%rip), %xmm1     # 0x2d018
movsd 0x38(%rsp), %xmm4
movsd 0x30(%rsp), %xmm5
cmpq %rdx, %rcx
je 0x23c21
cvtsi2sdl (%rax,%rdx,4), %xmm2
divsd 0x18(%rsp), %xmm2
testq %rdx, %rdx
je 0x23c08
ucomisd %xmm2, %xmm5
ja 0x23c04
ucomisd %xmm4, %xmm2
jbe 0x23c08
movb $0x0, 0xc(%rbx)
movapd %xmm1, %xmm3
subsd %xmm2, %xmm3
minsd %xmm2, %xmm3
minsd %xmm0, %xmm3
incq %rdx
movapd %xmm3, %xmm0
jmp 0x23be3
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
ja 0x23c35
ucomisd 0x20(%rsp), %xmm0
jbe 0x23c39
movb $0x0, 0xc(%rbx)
movq %rbx, %rdi
callq 0x1cea2
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x18(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x23c62
movb $0x0, 0xc(%rbx)
leaq 0x40(%rsp), %rdi
callq 0xa18e
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5908
jmp 0x23c96
movq %rax, %rbx
jmp 0x23c96
jmp 0x23c89
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xa18e
movq %rbx, %rdi
callq 0x5800