// File: /workspace/github_cpp_makefile_star2_O3/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_positions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void entry::filter_sites_by_positions(const string &positions_file, const string &exclude_positions_file)
{
	// Filter sites by a user defined file containing a list of positions
	if (passed_filters == false)
		return;

	if ((positions_file == "") && (exclude_positions_file == ""))
		return;

	int idx;
	if (keep_positions.empty() && positions_file != "")
	{
		string chr;
		int pos1;
		unsigned int N_chr=chr_to_idx.size();
		stringstream ss;
		string line;
		unsigned int gzMAX_LINE_LEN = 1024*1024;
		char *gz_readbuffer = new char[gzMAX_LINE_LEN];

		gzFile gz_in = gzopen(positions_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + positions_file);

		while (!gzeof(gz_in))
		{
			line = "";
			bool again = true;
			while (again == true)
			{
				gzgets(gz_in, gz_readbuffer, gzMAX_LINE_LEN);
				line.append(gz_readbuffer);
				if (strlen(gz_readbuffer) != gzMAX_LINE_LEN-1)
					again = false;
			}
			if (line[0] == '#')
				continue;
			line.erase( line.find_last_not_of(" \t\n\r") + 1);	// Trim whitespace at end of line (required in gzipped case!)

			ss.clear();
			ss.str(line);
			ss >> chr >> pos1;

			if (chr_to_idx.find(chr) == chr_to_idx.end())
			{
				N_chr++;
				chr_to_idx[chr] = (N_chr-1);
				keep_positions.resize(N_chr);
			}

			idx = chr_to_idx[chr];
			keep_positions[idx].insert(pos1);
		}
		gzclose(gz_in);
		delete [] gz_readbuffer;
	}
	if (exclude_positions.empty() && exclude_positions_file != "")
	{
		string chr;
		int pos1;
		unsigned int N_chr=0;
		stringstream ss;
		string line;
		unsigned int gzMAX_LINE_LEN = 1024*1024;
		char *gz_readbuffer = new char[gzMAX_LINE_LEN];

		gzFile gz_in = gzopen(exclude_positions_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + exclude_positions_file);

		while (!gzeof(gz_in))
		{
			line = "";
			bool again = true;
			while (again == true)
			{
				gzgets(gz_in, gz_readbuffer, gzMAX_LINE_LEN);
				line.append(gz_readbuffer);
				if (strlen(gz_readbuffer) != gzMAX_LINE_LEN-1)
					again = false;
			}
			if (line[0] == '#')
				continue;
			line.erase( line.find_last_not_of(" \t\n\r") + 1);	// Trim whitespace at end of line (required in gzipped case!)

			ss.clear();
			ss.str(line);
			ss >> chr >> pos1;

			if (chr_to_idx.find(chr) == chr_to_idx.end())
			{
				N_chr++;
				chr_to_idx[chr] = (N_chr-1);
				exclude_positions.resize(N_chr);
			}

			idx = chr_to_idx[chr];
			exclude_positions[idx].insert(pos1);
		}
		gzclose(gz_in);
		delete [] gz_readbuffer;
	}

	parse_basic_entry();

	if (!keep_positions.empty())
	{	// Check to see if position is in keep list
			if (chr_to_idx.find(CHROM) == chr_to_idx.end())
				passed_filters = false;
			else
			{
				idx = chr_to_idx[CHROM];
				bool found=false;

				if (keep_positions[idx].find(POS) != keep_positions[idx].end())
					found = true;

				if (found == false)
					passed_filters = false;
			}
	}
	if (!exclude_positions.empty())
	{	// Check to see if position is in exclude list
		if (chr_to_idx.find(CHROM) != chr_to_idx.end())
		{
			idx = chr_to_idx[CHROM];
			bool found=false;

			if (exclude_positions[idx].find(POS) != exclude_positions[idx].end())
				found = true;

				if (found == true)
					passed_filters = false;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
cmpb $0x0, 0xc(%rdi)
je 0x291bf
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10ea0(%rip), %rsi     # 0x39ed7
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
jne 0x2905a
leaq 0x10e8d(%rip), %rsi     # 0x39ed7
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x291bf
movq 0x212c7(%rip), %rax     # 0x4a328
cmpq 0x212c8(%rip), %rax     # 0x4a330
je 0x291d1
movq 0x212cb(%rip), %rax     # 0x4a340
cmpq 0x212cc(%rip), %rax     # 0x4a348
je 0x293f4
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq 0x21290(%rip), %rax     # 0x4a328
cmpq 0x21291(%rip), %rax     # 0x4a330
je 0x29128
leaq 0x3e0(%rbx), %r14
leaq 0x212a5(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x18140
leaq 0x2129e(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
je 0x29124
leaq 0x2128a(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x177e8
movslq (%rax), %rax
movq 0x21248(%rip), %rcx     # 0x4a328
leaq (%rax,%rax,2), %rdx
shlq $0x4, %rdx
movq 0x10(%rcx,%rdx), %rax
testq %rax, %rax
je 0x29124
leaq (%rcx,%rdx), %rsi
addq $0x8, %rsi
movl 0x400(%rbx), %ecx
movq %rsi, %rdx
xorl %edi, %edi
cmpl %ecx, 0x20(%rax)
setl %dil
cmovgeq %rax, %rdx
movq 0x10(%rax,%rdi,8), %rax
testq %rax, %rax
jne 0x29103
cmpq %rsi, %rdx
je 0x29124
cmpl 0x20(%rdx), %ecx
jge 0x29128
movb $0x0, 0xc(%rbx)
movq 0x21211(%rip), %rax     # 0x4a340
cmpq 0x21212(%rip), %rax     # 0x4a348
je 0x291bf
leaq 0x3e0(%rbx), %r14
leaq 0x2120e(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x18140
leaq 0x21207(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
je 0x291bf
leaq 0x211f3(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x177e8
movslq (%rax), %rax
movq 0x211c9(%rip), %rcx     # 0x4a340
leaq (%rax,%rax,2), %rdx
shlq $0x4, %rdx
movq 0x10(%rcx,%rdx), %rax
testq %rax, %rax
je 0x291bf
leaq (%rcx,%rdx), %rsi
addq $0x8, %rsi
movl 0x400(%rbx), %ecx
movq %rsi, %rdx
xorl %edi, %edi
cmpl %ecx, 0x20(%rax)
setl %dil
cmovgeq %rax, %rdx
movq 0x10(%rax,%rdi,8), %rax
testq %rax, %rax
jne 0x2919a
cmpq %rsi, %rdx
je 0x291bf
cmpl 0x20(%rdx), %ecx
jl 0x291bf
movb $0x0, 0xc(%rbx)
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10cff(%rip), %rsi     # 0x39ed7
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
je 0x2906e
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0x2117d(%rip), %r12d    # 0x4a380
leaq 0x90(%rsp), %rdi
callq 0x52e0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x100000, %edi         # imm = 0x100000
callq 0x5030
movq %rax, %r13
movq (%r15), %rdi
leaq 0xf2e7(%rip), %rsi      # 0x38522
callq 0x5650
movq %rax, %rbp
testq %rax, %rax
jne 0x29288
leaq 0x10c16(%rip), %rsi     # 0x39e65
leaq 0x70(%rsp), %rdi
movq %r15, %rdx
callq 0xb777
leaq 0x20245(%rip), %rdi     # 0x494a8
leaq 0x70(%rsp), %rsi
movl $0x1, %edx
callq 0x36ec8
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29288
callq 0x5410
movq %r12, 0x48(%rsp)
leaq 0x10c43(%rip), %r12     # 0x39ed7
leaq 0x8(%rsp), %r15
movq %rbp, %rdi
callq 0x5110
testl %eax, %eax
jne 0x29606
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x5690
movq %rbp, %rdi
movq %r13, %rsi
movl $0x100000, %edx         # imm = 0x100000
callq 0x5770
movq %r15, %rdi
movq %r13, %rsi
callq 0x5870
movq %r13, %rdi
callq 0x5180
cmpq $0xfffff, %rax          # imm = 0xFFFFF
je 0x292be
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x29299
movl $0x4, %ecx
movq %r15, %rdi
leaq 0xf45b(%rip), %rsi      # 0x3875d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x296ca
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x90(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x5750
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x5640
leaq 0x90(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5590
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x5230
leaq 0x20fd7(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x18140
leaq 0x20fce(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
jne 0x293c2
leaq 0x20fba(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movq 0x48(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x20f70(%rip), %rdi     # 0x4a328
movq %rsi, 0x48(%rsp)
callq 0x2c2f6
leaq 0x20f8f(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x20f43(%rip), %rdi     # 0x4a328
leaq 0x4(%rsp), %rsi
callq 0x2cb28
jmp 0x29299
leaq 0x10adc(%rip), %rsi     # 0x39ed7
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x29082
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x90(%rsp), %rdi
callq 0x52e0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x100000, %edi         # imm = 0x100000
callq 0x5030
movq %rax, %r12
movq (%r14), %rdi
leaq 0xf0cb(%rip), %rsi      # 0x38522
callq 0x5650
movq %rax, %r13
testq %rax, %rax
jne 0x294a1
leaq 0x109fa(%rip), %rsi     # 0x39e65
leaq 0x50(%rsp), %rdi
movq %r14, %rdx
callq 0xb777
leaq 0x20029(%rip), %rdi     # 0x494a8
leaq 0x50(%rsp), %rsi
movl $0x1, %edx
callq 0x36ec8
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x294a1
callq 0x5410
xorl %r14d, %r14d
leaq 0x10a2c(%rip), %rbp     # 0x39ed7
leaq 0x8(%rsp), %r15
movq %r13, %rdi
callq 0x5110
testl %eax, %eax
jne 0x29668
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x5690
movq %r13, %rdi
movq %r12, %rsi
movl $0x100000, %edx         # imm = 0x100000
callq 0x5770
movq %r15, %rdi
movq %r12, %rsi
callq 0x5870
movq %r12, %rdi
callq 0x5180
cmpq $0xfffff, %rax          # imm = 0xFFFFF
je 0x294d5
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x294b0
movl $0x4, %ecx
movq %r15, %rdi
leaq 0xf244(%rip), %rsi      # 0x3875d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x296e2
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x90(%rsp), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x5750
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
callq 0x5640
leaq 0x90(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5590
movq %rax, %rdi
leaq 0x4(%rsp), %rsi
callq 0x5230
leaq 0x20dc0(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x18140
leaq 0x20db7(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
jne 0x295d4
leaq 0x20da3(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movl %r14d, (%rax)
incl %r14d
leaq 0x20d74(%rip), %rdi     # 0x4a340
movq %r14, %rsi
callq 0x2c2f6
leaq 0x20d7d(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x20d49(%rip), %rdi     # 0x4a340
leaq 0x4(%rsp), %rsi
callq 0x2cb28
jmp 0x294b0
movq %rbp, %rdi
callq 0x5740
movq %r13, %rdi
callq 0x55b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2962a
callq 0x5410
movq 0x1f94f(%rip), %rsi     # 0x48f80
leaq 0x90(%rsp), %rdi
callq 0x5330
leaq 0x110(%rsp), %rdi
callq 0x5100
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2906e
callq 0x5410
jmp 0x2906e
movq %r13, %rdi
callq 0x5740
movq %r12, %rdi
callq 0x55b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2968c
callq 0x5410
movq 0x1f8ed(%rip), %rsi     # 0x48f80
leaq 0x90(%rsp), %rdi
callq 0x5330
leaq 0x110(%rsp), %rdi
callq 0x5100
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x29082
callq 0x5410
jmp 0x29082
leaq 0xeeed(%rip), %rdi      # 0x385be
leaq 0xef1d(%rip), %rsi      # 0x385f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
leaq 0xeed5(%rip), %rdi      # 0x385be
leaq 0xef05(%rip), %rsi      # 0x385f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
movq %rax, %rbx
leaq 0x60(%rsp), %rax
jmp 0x2970f
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29743
callq 0x5410
jmp 0x29743
jmp 0x29740
jmp 0x29740
jmp 0x29740
jmp 0x29740
jmp 0x29740
jmp 0x2972d
jmp 0x29740
movq %rax, %rbx
jmp 0x29778
jmp 0x29740
jmp 0x29740
jmp 0x29740
jmp 0x29740
jmp 0x29740
jmp 0x29740
jmp 0x29740
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x29757
callq 0x5410
movq 0x1f822(%rip), %rsi     # 0x48f80
leaq 0x90(%rsp), %rdi
callq 0x5330
leaq 0x110(%rsp), %rdi
callq 0x5100
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2978c
callq 0x5410
movq %rbx, %rdi
callq 0x57d0