// File: /workspace/github_cpp_makefile_star2_O3/auton1[P]viterbi/entry_filters.cpp
// Function: entry::filter_sites_by_overlap_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_overlap_positions(const string &positions_overlap_file, const string &exclude_positions_overlap_file)
{
	// Filter sites by overlapping with a user defined file containing a list of positions
	if (passed_filters == false)
		return;

	if ((positions_overlap_file == "") && (exclude_positions_overlap_file == ""))
		return;

	int idx;
	if (keep_positions.empty() && positions_overlap_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_overlap_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + positions_overlap_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_overlap_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_overlap_file.c_str(), "rb");
		if (gz_in == NULL)
			LOG.error("Could not open Positions file: " + exclude_positions_overlap_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;

				for (unsigned int ui=POS; ui<(POS+REF.size()); ui++)
					if (keep_positions[idx].find(ui) != keep_positions[idx].end())
					{
						found = true;
						break;
					}

				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;

			for (unsigned int ui=POS; ui<(POS+REF.size()); ui++)
				if (exclude_positions[idx].find(ui) != 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 0x2999b
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10718(%rip), %rsi     # 0x39ed7
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
jne 0x297e2
leaq 0x10705(%rip), %rsi     # 0x39ed7
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x2999b
movq 0x20b3f(%rip), %rax     # 0x4a328
cmpq 0x20b40(%rip), %rax     # 0x4a330
je 0x299ad
movq 0x20b43(%rip), %rax     # 0x4a340
cmpq 0x20b44(%rip), %rax     # 0x4a348
je 0x29bd0
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x10(%rax)
movq 0x20b08(%rip), %rax     # 0x4a328
cmpq 0x20b09(%rip), %rax     # 0x4a330
je 0x298c9
leaq 0x3e0(%rbx), %r14
leaq 0x20b1d(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x18140
leaq 0x20b16(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
je 0x298c5
leaq 0x20b02(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x177e8
movl 0x400(%rbx), %ecx
movslq %ecx, %rdx
addq 0x430(%rbx), %rdx
cmpq %rcx, %rdx
jbe 0x298c5
movslq (%rax), %rax
movq 0x20aab(%rip), %rsi     # 0x4a328
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rsi, %rax
addq $0x8, %rax
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x298be
movq %rsi, %r8
movq %rax, %rdi
xorl %r9d, %r9d
cmpl %ecx, 0x20(%r8)
setl %r9b
cmovgeq %r8, %rdi
movq 0x10(%r8,%r9,8), %r8
testq %r8, %r8
jne 0x2989b
cmpq %rax, %rdi
je 0x298be
cmpl 0x20(%rdi), %ecx
jge 0x298c9
incl %ecx
cmpq %rcx, %rdx
ja 0x29890
movb $0x0, 0xc(%rbx)
movq 0x20a70(%rip), %rax     # 0x4a340
cmpq 0x20a71(%rip), %rax     # 0x4a348
je 0x2999b
leaq 0x3e0(%rbx), %r14
leaq 0x20a6d(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x18140
leaq 0x20a66(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
je 0x2999b
leaq 0x20a4e(%rip), %rdi     # 0x4a358
movq %r14, %rsi
callq 0x177e8
movl 0x400(%rbx), %ecx
movslq %ecx, %rdx
addq 0x430(%rbx), %rdx
cmpq %rcx, %rdx
jbe 0x2999b
movslq (%rax), %rax
movq 0x20a0f(%rip), %rsi     # 0x4a340
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %rsi, %rax
addq $0x8, %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
movq %rax, %r9
testq %rdi, %rdi
je 0x29980
movq %rdi, %r9
movq %rax, %r8
xorl %r10d, %r10d
cmpl %ecx, 0x20(%r9)
setl %r10b
cmovgeq %r9, %r8
movq 0x10(%r9,%r10,8), %r9
testq %r9, %r9
jne 0x29954
movq %rax, %r9
cmpq %rax, %r8
je 0x29980
cmpl 0x20(%r8), %ecx
cmovlq %rax, %r8
movq %r8, %r9
cmpq %rax, %r9
setne %r8b
orb %r8b, %sil
incl %ecx
cmpq %rcx, %rdx
ja 0x29946
testb $0x1, %sil
je 0x2999b
movb $0x0, 0xc(%rbx)
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10523(%rip), %rsi     # 0x39ed7
movq %r15, %rdi
callq 0x50e0
testl %eax, %eax
je 0x297f6
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0x209a1(%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 0xeb0b(%rip), %rsi      # 0x38522
callq 0x5650
movq %rax, %rbp
testq %rax, %rax
jne 0x29a64
leaq 0x1043a(%rip), %rsi     # 0x39e65
leaq 0x70(%rsp), %rdi
movq %r15, %rdx
callq 0xb777
leaq 0x1fa69(%rip), %rdi     # 0x494a8
leaq 0x70(%rsp), %rsi
movl $0x1, %edx
callq 0x36ec8
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29a64
callq 0x5410
movq %r12, 0x48(%rsp)
leaq 0x10467(%rip), %r12     # 0x39ed7
leaq 0x8(%rsp), %r15
movq %rbp, %rdi
callq 0x5110
testl %eax, %eax
jne 0x29de2
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 0x29a9a
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x29a75
movl $0x4, %ecx
movq %r15, %rdi
leaq 0xec7f(%rip), %rsi      # 0x3875d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x29ea6
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 0x207fb(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x18140
leaq 0x207f2(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
jne 0x29b9e
leaq 0x207de(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movq 0x48(%rsp), %rsi
movl %esi, (%rax)
incl %esi
leaq 0x20794(%rip), %rdi     # 0x4a328
movq %rsi, 0x48(%rsp)
callq 0x2c2f6
leaq 0x207b3(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x20767(%rip), %rdi     # 0x4a328
leaq 0x4(%rsp), %rsi
callq 0x2cb28
jmp 0x29a75
leaq 0x10300(%rip), %rsi     # 0x39ed7
movq %r14, %rdi
callq 0x50e0
testl %eax, %eax
je 0x2980a
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 0xe8ef(%rip), %rsi      # 0x38522
callq 0x5650
movq %rax, %r13
testq %rax, %rax
jne 0x29c7d
leaq 0x1021e(%rip), %rsi     # 0x39e65
leaq 0x50(%rsp), %rdi
movq %r14, %rdx
callq 0xb777
leaq 0x1f84d(%rip), %rdi     # 0x494a8
leaq 0x50(%rsp), %rsi
movl $0x1, %edx
callq 0x36ec8
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29c7d
callq 0x5410
xorl %r14d, %r14d
leaq 0x10250(%rip), %rbp     # 0x39ed7
leaq 0x8(%rsp), %r15
movq %r13, %rdi
callq 0x5110
testl %eax, %eax
jne 0x29e44
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 0x29cb1
movq 0x8(%rsp), %rax
cmpb $0x23, (%rax)
je 0x29c8c
movl $0x4, %ecx
movq %r15, %rdi
leaq 0xea68(%rip), %rsi      # 0x3875d
movq $-0x1, %rdx
callq 0x56f0
incq %rax
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0x29ebe
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 0x205e4(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x18140
leaq 0x205db(%rip), %rcx     # 0x4a360
cmpq %rcx, %rax
jne 0x29db0
leaq 0x205c7(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movl %r14d, (%rax)
incl %r14d
leaq 0x20598(%rip), %rdi     # 0x4a340
movq %r14, %rsi
callq 0x2c2f6
leaq 0x205a1(%rip), %rdi     # 0x4a358
leaq 0x28(%rsp), %rsi
callq 0x177e8
movslq (%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x4, %rdi
addq 0x2056d(%rip), %rdi     # 0x4a340
leaq 0x4(%rsp), %rsi
callq 0x2cb28
jmp 0x29c8c
movq %rbp, %rdi
callq 0x5740
movq %r13, %rdi
callq 0x55b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x29e06
callq 0x5410
movq 0x1f173(%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 0x297f6
callq 0x5410
jmp 0x297f6
movq %r13, %rdi
callq 0x5740
movq %r12, %rdi
callq 0x55b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x29e68
callq 0x5410
movq 0x1f111(%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 0x2980a
callq 0x5410
jmp 0x2980a
leaq 0xe711(%rip), %rdi      # 0x385be
leaq 0xe741(%rip), %rsi      # 0x385f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
leaq 0xe6f9(%rip), %rdi      # 0x385be
leaq 0xe729(%rip), %rsi      # 0x385f5
movq %rax, %rdx
xorl %eax, %eax
callq 0x5660
movq %rax, %rbx
leaq 0x60(%rsp), %rax
jmp 0x29eeb
movq %rax, %rbx
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29f1f
callq 0x5410
jmp 0x29f1f
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f09
jmp 0x29f1c
movq %rax, %rbx
jmp 0x29f54
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
jmp 0x29f1c
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x29f33
callq 0x5410
movq 0x1f046(%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 0x29f68
callq 0x5410
movq %rbx, %rdi
callq 0x57d0