// File: /workspace/github_cpp_makefile_star2_O3/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_mask(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool, int)
void entry::filter_sites_by_mask(const string &mask_file, bool invert_mask, int min_kept_mask_value)
{
	// Filter sites on the basis of a fasta-like mask file.
	if (passed_filters == false || mask_file == "")
		return;

	if (!mask.is_open())
	{
		mask.open(mask_file.c_str());
		mask_chr = "";
		mask_line = "";

		if (!mask.is_open())
			LOG.error("Could not open mask file: " + mask_file);
	}

	string line;
	string next_chr="";
	unsigned int next_pos = 0;

	parse_basic_entry();
	next_chr = CHROM;

	if (mask_chr != next_chr)
	{
		mask_chr = "";
		mask_line = "";
		while (!mask.eof())
		{
			getline(mask, line);
			line.erase( line.find_last_not_of(" \t") + 1);

			if (line[0] == '>')
			// Header
				mask_chr = line.substr(1, line.find_first_of(" \t")-1);
			else
			{
				mask_line = line;
				if (mask_chr == next_chr)
					break;
			}
		}
	}

	if (next_chr == mask_chr)
		next_pos = (unsigned)POS;
	else
	{
		passed_filters = false;
		return;
	}

	if (next_pos <= mask_line.size())
	{
		char mask_base = mask_line[next_pos-1]-48;
		bool keep = (mask_base <= min_kept_mask_value);

		if (invert_mask == true)
			keep = !keep;

		if (keep == false)
			passed_filters = false;
	}
	else
		passed_filters = false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
cmpb $0x0, 0xc(%rdi)
je 0x2b580
movl %ecx, %r12d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xec8a(%rip), %rsi      # 0x39ed7
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x2b580
leaq 0x1f1b4(%rip), %rdi     # 0x4a418
callq 0x50b0
testb %al, %al
jne 0x2b310
movq (%r14), %rsi
leaq 0x1f125(%rip), %rdi     # 0x4a3a0
movl $0x8, %edx
callq 0x5240
movq 0x1f324(%rip), %rdx     # 0x4a5b0
leaq 0x1f315(%rip), %rdi     # 0x4a5a8
leaq 0xec3d(%rip), %r15      # 0x39ed7
xorl %esi, %esi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x5690
movq 0x1f322(%rip), %rdx     # 0x4a5d0
leaq 0x1f313(%rip), %rdi     # 0x4a5c8
xorl %esi, %esi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x5690
leaq 0x1f14f(%rip), %rdi     # 0x4a418
callq 0x50b0
testb %al, %al
jne 0x2b310
leaq 0xebe1(%rip), %rsi      # 0x39eba
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xb777
leaq 0x1e1b8(%rip), %rdi     # 0x494a8
movq %r15, %rsi
movl $0x1, %edx
callq 0x36ec8
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2b310
callq 0x5410
movl %r12d, (%rsp)
movl %ebp, 0x4(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xeb9b(%rip), %rdx      # 0x39ed7
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0xc85e
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
leaq 0x3e0(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x51f0
movq 0x1f240(%rip), %r14     # 0x4a5b0
cmpq 0x10(%rsp), %r14
jne 0x2b39c
testq %r14, %r14
je 0x2b528
movq 0x8(%rsp), %rsi
movq 0x1f21c(%rip), %rdi     # 0x4a5a8
movq %r14, %rdx
callq 0x5470
testl %eax, %eax
je 0x2b500
leaq 0x1f205(%rip), %rdi     # 0x4a5a8
leaq 0xeb2d(%rip), %rcx      # 0x39ed7
xorl %esi, %esi
movq %r14, %rdx
xorl %r8d, %r8d
callq 0x5690
movq 0x1f212(%rip), %rdx     # 0x4a5d0
leaq 0x1f203(%rip), %rdi     # 0x4a5c8
leaq 0xeb0b(%rip), %rcx      # 0x39ed7
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x5690
leaq 0x1efc3(%rip), %r15     # 0x4a3a0
movq 0x1efbc(%rip), %rax     # 0x4a3a0
movq -0x18(%rax), %rdi
testb $0x2, 0x20(%rdi,%r15)
jne 0x2b500
addq %r15, %rdi
leaq 0x28(%rsp), %r12
leaq 0xead2(%rip), %r13      # 0x39ed5
leaq 0x48(%rsp), %rbp
leaq 0x1f1b9(%rip), %r14     # 0x4a5c8
movl $0xa, %esi
callq 0x5440
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x5830
movl $0x2, %ecx
movq %r12, %rdi
movq %r13, %rsi
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x30(%rsp), %rcx
cmpq %rax, %rcx
jb 0x2b592
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x28(%rsp), %rax
cmpb $0x3e, (%rax)
jne 0x2b4b2
movl $0x2, %ecx
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x5670
leaq -0x1(%rax), %rcx
movl $0x1, %edx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5480
leaq 0x1f114(%rip), %rdi     # 0x4a5a8
movq %rbp, %rsi
callq 0x5550
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2b4e5
callq 0x5410
jmp 0x2b4e5
movq %r14, %rdi
movq %r12, %rsi
callq 0x51f0
movq 0x1f0ec(%rip), %rdx     # 0x4a5b0
cmpq 0x10(%rsp), %rdx
jne 0x2b4e5
testq %rdx, %rdx
je 0x2b528
movq 0x8(%rsp), %rsi
movq 0x1f0cc(%rip), %rdi     # 0x4a5a8
callq 0x5470
testl %eax, %eax
je 0x2b500
movq 0x1eeb4(%rip), %rax     # 0x4a3a0
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
testb $0x2, 0x20(%rax,%r15)
je 0x2b40f
movq 0x1f0a9(%rip), %rdx     # 0x4a5b0
cmpq %rdx, 0x10(%rsp)
jne 0x2b554
testq %rdx, %rdx
je 0x2b528
movq 0x1f08e(%rip), %rsi     # 0x4a5a8
movq 0x8(%rsp), %rdi
callq 0x5470
testl %eax, %eax
jne 0x2b554
movl 0x400(%rbx), %eax
cmpq %rax, 0x1f09b(%rip)     # 0x4a5d0
jb 0x2b554
decl %eax
movq 0x1f088(%rip), %rcx     # 0x4a5c8
movb (%rcx,%rax), %al
addb $-0x30, %al
movsbl %al, %eax
cmpl (%rsp), %eax
setle %al
xorb 0x4(%rsp), %al
jne 0x2b558
movb $0x0, 0xc(%rbx)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2b56c
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2b580
callq 0x5410
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd025(%rip), %rdi      # 0x385be
leaq 0xd055(%rip), %rsi      # 0x385f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
movq %rax, %rbx
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x2b5e2
movq %rax, %rbx
jmp 0x2b5d8
jmp 0x2b5c1
jmp 0x2b5c1
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2b5d8
callq 0x5410
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2b5ec
callq 0x5410
movq %rbx, %rdi
callq 0x57d0