// File: ridgelab[P]Kmer-SSR/src/FindSSRs.cpp
// Function: FindSSRs::splitStringOnIgnoredChars(std::vector<unsigned int, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned int&)
void FindSSRs::splitStringOnIgnoredChars(vector<uint32_t> &starts, vector<uint32_t> &sizes, const string &sequence, uint32_t &actually_ignored_chars)
{
	for (uint32_t i = 0; i < sequence.size(); ++i)
	{
		//if (!this->args->alphabet->count(sequence[i])) // if it's a "bad" character
		if (!this->args->inAlphabet(sequence[i])) // if it's a "bad" character
		{
			sizes.push_back(i - starts[starts.size() - 1]);
			++actually_ignored_chars;
		
			if (sizes[sizes.size() - 1] == 0)
			{
				starts.pop_back();
				sizes.pop_back();
			}

			starts.push_back(i + 1);
		}
	}

	sizes.push_back(sequence.size() - starts[starts.size() - 1]);

	if (sizes[sizes.size() - 1] == 0)
	{
		starts.pop_back();
		sizes.pop_back();
	}

	// Sanity check
	if (starts.size() != sizes.size())
	{
		cerr << "\n\tERROR! starts and sizes are not the same size!\n" << endl;
		exit(1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rdi
callq 0x4260
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x11f5b
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, %esi
callq 0x4430
movq -0x50(%rbp), %rdi
movsbl (%rax), %esi
callq 0x19e40
testb $0x1, %al
jne 0x11f4b
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0x134d0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x134b0
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl -0x5c(%rbp), %eax
subl (%rcx), %eax
movl %eax, -0x30(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x13480
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x134d0
movq -0x58(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x134b0
cmpl $0x0, (%rax)
jne 0x11f35
movq -0x10(%rbp), %rdi
callq 0x134f0
movq -0x18(%rbp), %rdi
callq 0x134f0
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
leaq -0x34(%rbp), %rsi
callq 0x13480
jmp 0x11f4d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x11e5e
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rdi
callq 0x4260
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
callq 0x134d0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x134b0
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movq -0x80(%rbp), %rax
movl (%rcx), %ecx
subq %rcx, %rax
movl %eax, -0x38(%rbp)
leaq -0x38(%rbp), %rsi
callq 0x13480
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x134d0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x134b0
cmpl $0x0, (%rax)
jne 0x11ff1
movq -0x10(%rbp), %rdi
callq 0x134f0
movq -0x18(%rbp), %rdi
callq 0x134f0
movq -0x10(%rbp), %rdi
callq 0x134d0
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
callq 0x134d0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
je 0x12045
movq 0x1ffd0(%rip), %rdi     # 0x31ff0
leaq 0xf1a1(%rip), %rsi      # 0x211c8
callq 0x4390
movq %rax, %rdi
movq 0x1ff5a(%rip), %rsi     # 0x31f90
callq 0x43e0
movl $0x1, %edi
callq 0x4490
addq $0xa0, %rsp
popq %rbp
retq
nop