// File: ridgelab[P]Kmer-SSR/src/FindSSRs.cpp
// Function: findSSRsNormally(Task*, Arguments*, AtomicityChecker*)
static
vector<SSR*>* findSSRsNormally(Task* task, Arguments* args, AtomicityChecker* atomicity_checker)
{
	vector<bool>* filter = new vector<bool>(task->size(), false);

	vector<SSR*>* ssrs = new vector<SSR*>();

	string seq = task->getSequence();
	set<uint32_t, bool(*)(uint32_t,uint32_t)>* periods = args->getPeriods();
	SSR* ssr = nullptr;
	
	//for (uint32_t i = 0; i < periods.size(); ++i)
	for (set<uint32_t, bool(*)(uint32_t,uint32_t)>::iterator itr = periods->begin(); itr != periods->end(); ++itr)
	{
		if ( (*itr * 2) <= seq.size() )
		{
			for (uint32_t index = 0; index < task->size(); ++index)
			{
				//ssr = seekSinglePeriodSizeSSRatIndex(seq, index, task->getGlobalPosition(), periods[i]);
				ssr = seekSinglePeriodSizeSSRatIndex(seq, index, task->getGlobalPosition(), *itr);

				if (isGoodSSR(ssr, task->getGlobalPosition(), *filter, args, atomicity_checker))
				{
					//for (uint32_t j = (ssr->getStartPosition() - task->getGlobalPosition()); j < (ssr->getExclusiveEndPosition() - task->getGlobalPosition()); ++j) // TODO
					//{
					//	filter->at(j) = true;
					//}

					//index += (ssr->getLength() - periods[i] - 1);
					index += (ssr->getLength() - *itr);
					//index += (ssr->getLength() - *itr - 1);

					if (keepSSR(ssr, args))
					{
						ssrs->push_back(ssr);
						for (uint32_t j = (ssr->getStartPosition() - task->getGlobalPosition()); j < (ssr->getExclusiveEndPosition() - task->getGlobalPosition()); ++j)
						{
							filter->at(j) = true;
						}
					}
					else
					{
						delete ssr;
					}
				}
				else
				{
					delete ssr;
				}
			}
		}
	}

	filter->clear();
	delete filter;

	return ssrs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x28, %edi
callq 0x43a0
movq %rax, -0xa0(%rbp)
movb $0x1, -0x2f(%rbp)
movq -0x8(%rbp), %rdi
callq 0x163d0
movl %eax, -0x94(%rbp)
jmp 0x1296d
movl -0x94(%rbp), %eax
movl %eax, %eax
movq %rax, -0xb0(%rbp)
movb $0x0, -0x2d(%rbp)
leaq -0x2e(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x13d00
movq -0xa0(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rcx
leaq -0x2d(%rbp), %rdx
callq 0x13d20
jmp 0x129b0
movb $0x0, -0x2f(%rbp)
leaq -0x2e(%rbp), %rdi
callq 0x13da0
movq -0xa0(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x18, %edi
callq 0x43a0
movq %rax, %rdi
movq %rdi, -0xc0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x137b0
movq -0xc0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x163a0
movq -0x10(%rbp), %rdi
callq 0x19ec0
movq %rax, -0xb8(%rbp)
jmp 0x12a19
movq -0xb8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x137d0
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rdi
callq 0x13830
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x13800
testb $0x1, %al
jne 0x12a5c
jmp 0x12d75
leaq -0x70(%rbp), %rdi
callq 0x13890
movl (%rax), %eax
shll %eax
movl %eax, %eax
movq %rax, -0xc8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4260
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq %rcx, %rax
ja 0x12d65
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0xd0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x163d0
movl %eax, -0xcc(%rbp)
jmp 0x12aaf
movl -0xd0(%rbp), %eax
movl -0xcc(%rbp), %ecx
cmpl %ecx, %eax
jae 0x12d63
movl -0x7c(%rbp), %eax
movl %eax, -0xd8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x163f0
movl %eax, -0xd4(%rbp)
jmp 0x12add
leaq -0x70(%rbp), %rdi
callq 0x13890
movl -0xd8(%rbp), %esi
movl -0xd4(%rbp), %edx
movl (%rax), %ecx
leaq -0x58(%rbp), %rdi
callq 0x12de0
movq %rax, -0xe0(%rbp)
jmp 0x12b06
movq -0xe0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x163f0
movl %eax, -0xe4(%rbp)
jmp 0x12b2d
movl -0xe4(%rbp), %esi
movq -0xf0(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
callq 0x12ff0
movb %al, -0xf1(%rbp)
jmp 0x12b53
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0x12b62
jmp 0x12d23
movq -0x68(%rbp), %rdi
callq 0x5820
movl %eax, -0xf8(%rbp)
jmp 0x12b73
leaq -0x70(%rbp), %rdi
callq 0x13890
movl -0xf8(%rbp), %ecx
movl (%rax), %eax
subl %eax, %ecx
movl -0x7c(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x7c(%rbp)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x13230
movb %al, -0xf9(%rbp)
jmp 0x12ba3
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x12bb2
jmp 0x12cf1
movq -0x38(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x69e0
jmp 0x12bc1
movq -0x68(%rbp), %rdi
callq 0x5800
movl %eax, -0x100(%rbp)
jmp 0x12bd2
movq -0x8(%rbp), %rdi
callq 0x163f0
movl %eax, -0x104(%rbp)
jmp 0x12be3
movl -0x104(%rbp), %ecx
movl -0x100(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x10c(%rbp)
movq -0x68(%rbp), %rdi
callq 0x5850
movl %eax, -0x108(%rbp)
jmp 0x12c0e
movq -0x8(%rbp), %rdi
callq 0x163f0
movl %eax, -0x110(%rbp)
jmp 0x12c1f
movl -0x10c(%rbp), %eax
movl -0x110(%rbp), %edx
movl -0x108(%rbp), %ecx
subl %edx, %ecx
cmpl %ecx, %eax
jae 0x12cef
movq -0x20(%rbp), %rdi
movl -0x80(%rbp), %eax
movl %eax, %esi
callq 0x13dc0
movq %rdx, -0x120(%rbp)
movq %rax, -0x118(%rbp)
jmp 0x12c59
movq -0x120(%rbp), %rax
movq -0x118(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movq %rax, -0x88(%rbp)
leaq -0x90(%rbp), %rdi
movl $0x1, %esi
callq 0x13e10
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x12bf4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x12cb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2e(%rbp), %rdi
callq 0x13da0
testb $0x1, -0x2f(%rbp)
jne 0x12cbf
jmp 0x12cd0
movq -0xa0(%rbp), %rdi
movl $0x28, %esi
callq 0x43b0
jmp 0x12dd0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4788
jmp 0x12dd0
jmp 0x12d21
movq -0x68(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
je 0x12d1f
movq -0x128(%rbp), %rdi
callq 0x5770
movq -0x128(%rbp), %rdi
movl $0x28, %esi
callq 0x43b0
jmp 0x12d21
jmp 0x12d53
movq -0x68(%rbp), %rax
movq %rax, -0x130(%rbp)
cmpq $0x0, %rax
je 0x12d51
movq -0x130(%rbp), %rdi
callq 0x5770
movq -0x130(%rbp), %rdi
movl $0x28, %esi
callq 0x43b0
jmp 0x12d53
jmp 0x12d55
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x12a95
jmp 0x12d65
jmp 0x12d67
leaq -0x70(%rbp), %rdi
callq 0x138c0
jmp 0x12a39
movq -0x20(%rbp), %rdi
callq 0x13e60
movq -0x20(%rbp), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, %rax
je 0x12dac
movq -0x138(%rbp), %rdi
callq 0x13eb0
movq -0x138(%rbp), %rdi
movl $0x28, %esi
callq 0x43b0
movq -0x38(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4788
movq -0x140(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x46e0
nopl (%rax)