// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
cmpb $0x0, 0xc(%rdi)
je 0x2bd09
movq %rdi, %rbx
ucomisd 0xd4cd(%rip), %xmm3     # 0x39018
jb 0x2bb71
xorpd %xmm5, %xmm5
ucomisd %xmm2, %xmm5
jb 0x2bb71
ucomisd %xmm0, %xmm5
jb 0x2bb71
ucomisd 0xd4b3(%rip), %xmm1     # 0x39018
jb 0x2bb71
ucomisd %xmm4, %xmm5
jae 0x2bd09
movsd %xmm2, 0x18(%rsp)
movsd %xmm3, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
movsd %xmm1, 0x8(%rsp)
movsd %xmm4, 0x10(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x28(%rax)
cmpl $-0x1, 0x630(%rbx)
jne 0x2bc06
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xf331(%rip), %rsi      # 0x3af00
leaq 0xf373(%rip), %rdx      # 0x3af49
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0xc868
leaq 0x1e8be(%rip), %rdi     # 0x4a4a8
movq %r14, %rsi
movl $0x1, %edx
callq 0x3721e
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x2bc06
callq 0x5410
movq %rbx, %rdi
callq 0x230f4
movl %eax, %ebp
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movapd %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0x231a4
testl %ebp, %ebp
movsd 0x20(%rsp), %xmm5
movsd 0x18(%rsp), %xmm6
je 0x2bca6
movq 0x30(%rsp), %rax
movl 0x4(%rsp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movl %ebp, %ecx
movsd 0xd3e3(%rip), %xmm2     # 0x39040
xorl %edx, %edx
movsd 0xd3b1(%rip), %xmm1     # 0x39018
xorps %xmm4, %xmm4
cvtsi2sdl (%rax,%rdx,4), %xmm4
divsd %xmm0, %xmm4
testq %rdx, %rdx
je 0x2bc88
ucomisd %xmm4, %xmm6
ja 0x2bc84
ucomisd %xmm5, %xmm4
jbe 0x2bc88
movb $0x0, 0xc(%rbx)
movapd %xmm1, %xmm3
subsd %xmm4, %xmm3
minsd %xmm4, %xmm3
minsd %xmm2, %xmm3
incq %rdx
movapd %xmm3, %xmm2
cmpq %rdx, %rcx
jne 0x2bc67
jmp 0x2bcae
movsd 0xd392(%rip), %xmm3     # 0x39040
movsd 0x28(%rsp), %xmm0
ucomisd %xmm3, %xmm0
ja 0x2bcc2
ucomisd 0x8(%rsp), %xmm3
jbe 0x2bcc6
movb $0x0, 0xc(%rbx)
movl 0x4(%rsp), %ebp
movq %rbx, %rdi
callq 0x23132
movl %ebp, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movl %eax, %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x2bcfa
movb $0x0, 0xc(%rbx)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2bd09
callq 0x5410
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
jne 0x2bd32
jmp 0x2bd37
jmp 0x2bd25
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2bd37
callq 0x5410
movq %rbx, %rdi
callq 0x57d0
nop