// File: ridgelab[P]Kmer-SSR/src/FindSSRs.cpp
// Function: isGoodSSR(SSR*, unsigned int, std::vector<bool, std::allocator<bool>> const&, Arguments*, AtomicityChecker*)
static
bool isGoodSSR(SSR* ssr, uint32_t global_pos, const vector<bool> &filter, Arguments* args, AtomicityChecker* atomicity_checker)
{
	// check enumerated SSRs
	//if (args->ssrs->size() && !args->ssrs->count(ssr->getBaseSSR()))
	if (args->areEnumeratedSSRs() && !args->baseSSRinEnumeratedSSRs(ssr->getBaseSSR()))
	{
		return false; // the user enumerated SSRs and this one wasn't one of them
	}

	// check the number of repeats
	if (ssr->getRepeats() < 2)
	{
		return false; // this ssr doesn't repeat, making it not an ssr
	}

	// check atomicity
	if (!args->allowNonAtomic() && !atomicity_checker->isAtomic(ssr->getBaseSSR()))
	{
		return false; // this SSR was not atomic (e.g., ATAT instead of AT)
	}

	//// check overlap of first/last periods 
	//bool good = true;
	//for (uint32_t i = (ssr->getStartPosition() - global_pos); i < (ssr->getStartPosition() - global_pos + ssr->getPeriod()); ++i)
	//{
	//	if (filter[i])
	//	{
	//		good = false;
	//		break;
	//	}
	//}
	//
	//if (!good)
	//{
	//	for (uint32_t i = (ssr->getExclusiveEndPosition() - 1 - global_pos - ssr->getPeriod()); i < (ssr->getExclusiveEndPosition() - global_pos); ++i)
	//	{
	//		if (filter[i])
	//		{
	//			return false;
	//		}
	//	}
	//}

	//return true;

	// check overlap of entire SSR
	for (uint32_t i = ssr->getStartPosition() - global_pos; i < ssr->getExclusiveEndPosition() - global_pos; ++i)
	{
		if (!filter[i])
		{
			return true;
		}
	}

	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x19f90
movb %al, %cl
movb $0x0, -0x51(%rbp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x91(%rbp)
jne 0x1302c
jmp 0x13078
movq -0x28(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x5790
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movb $0x1, -0x51(%rbp)
callq 0x19f50
movb %al, -0x92(%rbp)
jmp 0x1306a
movb -0x92(%rbp), %al
xorb $-0x1, %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
movb %al, -0xa9(%rbp)
testb $0x1, -0x51(%rbp)
jne 0x1308c
jmp 0x13095
leaq -0x50(%rbp), %rdi
callq 0x4788
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x130a1
jmp 0x130cc
movb $0x0, -0x1(%rbp)
jmp 0x13219
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
testb $0x1, -0x51(%rbp)
jne 0x130be
jmp 0x130c7
leaq -0x50(%rbp), %rdi
callq 0x4788
jmp 0x13227
movq -0x10(%rbp), %rdi
callq 0x57e0
cmpl $0x2, %eax
jae 0x130e3
movb $0x0, -0x1(%rbp)
jmp 0x13219
movq -0x28(%rbp), %rdi
callq 0x19c10
movb %al, %cl
movb $0x0, -0x89(%rbp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xaa(%rbp)
jne 0x13154
movq -0x30(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x5790
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movb $0x1, -0x89(%rbp)
callq 0xab40
movb %al, -0xab(%rbp)
jmp 0x13146
movb -0xab(%rbp), %al
xorb $-0x1, %al
movb %al, -0xaa(%rbp)
movb -0xaa(%rbp), %al
movb %al, -0xc1(%rbp)
testb $0x1, -0x89(%rbp)
jne 0x1316b
jmp 0x13177
leaq -0x88(%rbp), %rdi
callq 0x4788
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x13183
jmp 0x131b1
movb $0x0, -0x1(%rbp)
jmp 0x13219
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
testb $0x1, -0x89(%rbp)
jne 0x131a3
jmp 0x131af
leaq -0x88(%rbp), %rdi
callq 0x4788
jmp 0x13227
movq -0x10(%rbp), %rdi
callq 0x5800
subl -0x14(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5850
movl %eax, %ecx
movl -0xc8(%rbp), %eax
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jae 0x13215
movq -0x20(%rbp), %rdi
movl -0x90(%rbp), %eax
movl %eax, %esi
callq 0x145d0
testb $0x1, %al
jne 0x13202
movb $0x1, -0x1(%rbp)
jmp 0x13219
jmp 0x13204
movl -0x90(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x90(%rbp)
jmp 0x131c3
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x46e0