// File: /workspace/github_cpp_makefile_star2_O1/ridgelab[P]Kmer-SSR/src/FindSSRs.cpp
// Function: seekSinglePeriodSizeSSRatIndex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int, unsigned int, unsigned int)
static
SSR* seekSinglePeriodSizeSSRatIndex(const string &sequence, uint32_t index, uint32_t global_pos, uint32_t period)
{
	//assert((period * 2) <= sequence.size());
	
	string base = sequence.substr(index, period);
	string next = base;
	uint32_t repeats = 0;
	uint32_t pos = index;

	while ( (base == next) && (pos < (sequence.size() - period + 1)) )
	{
		++repeats;
		pos += period;
		next = sequence.substr(pos,  period);
	}

	//// check up to one period before
	//for (uint32_t i = index; (i >= 0) && (i > (index - period)); --i)
	//{
	//	if (sequence[i] == sequence[i + period])
	//	{

	//	}

	//	if (i == 0)
	//	{
	//		break;
	//	}
	//}
	//// check up to one period after

	return new SSR(base, repeats, index + global_pos);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r12
movl %esi, %edx
movl %ecx, 0x14(%rsp)
movl %ecx, %r13d
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
callq 0x3320
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x3ada
movl %ebp, 0x10(%rsp)
movq 0x40(%rsp), %rbp
xorl %r14d, %r14d
cmpq 0x20(%rsp), %rbp
movl %r15d, 0xc(%rsp)
jne 0x8a75
xorl %r14d, %r14d
leaq 0x78(%rsp), %rbx
testq %rbp, %rbp
je 0x8a0a
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %rdi
movq %rbp, %rdx
callq 0x3310
testl %eax, %eax
jne 0x8a75
movl %r15d, %eax
movq 0x8(%r12), %rcx
subq %r13, %rcx
incq %rcx
cmpq %rax, %rcx
jbe 0x8a75
addl 0x14(%rsp), %r15d
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x3320
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x33a0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x8a62
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3300
movq 0x40(%rsp), %rbp
incl %r14d
cmpq 0x20(%rsp), %rbp
je 0x89ef
movl $0x28, %edi
callq 0x32f0
movq %rax, %r15
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x38(%rsp), %rsi
addq %rsi, %rbp
leaq 0x58(%rsp), %rdi
movq %rbp, %rdx
callq 0x3ada
movl 0x10(%rsp), %ecx
addl 0xc(%rsp), %ecx
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
movl %r14d, %edx
callq 0x411a
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x8ad0
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3300
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x8aec
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3300
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8b07
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3300
movq %r15, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x8b3b
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3300
jmp 0x8b3b
movq %rax, %rbx
movl $0x28, %esi
movq %r15, %rdi
callq 0x3300
jmp 0x8b54
jmp 0x8b51
movq %rax, %rbx
jmp 0x8b70
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x8b70
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3300
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8b8b
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3300
movq %rbx, %rdi
callq 0x3540
nop