// File: /workspace/github_cpp_makefile_star2_O2/ridgelab[P]Kmer-SSR/src/FindSSRs.cpp
// Function: FindSSRs::processSequence(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 FindSSRs::processSequence(const string &header, const string &sequence)
{
	if ( (sequence.size() == 0) || (sequence.size() < this->args->getMinSequenceLength()) || (sequence.size() > this->args->getMaxSequenceLength()) )
	{
		this->progress_bar->updateProgress(sequence.size(), true);
		return;
	}
	
	vector<uint32_t> starts = {0};
	vector<uint32_t> sizes;
	uint32_t ignored_chars_count = 0;

	splitStringOnIgnoredChars(starts, sizes, sequence, ignored_chars_count);

	this->progress_bar->updateProgress(ignored_chars_count, false); // false means don't update the display

	switch (this->args->getNumThreads())
	{
		case 1:
		{
			SSRcontainer* ssrs = new SSRcontainer();
			Task* task = nullptr;

			for (uint32_t i = 0; i < starts.size(); ++i)
			{
				// create the task
				task = new Task(header, sequence.substr(starts[i], sizes[i]), starts[i], sequence.size());
				
				// fulfill the task, add the results to the SSRcontainer so we can write them to file
				ssrs->add(task->getID(), findSSRs(task, this->args, this->atomicity_checker));
				ssrs->writeToFile(this->out_file, true, true); // true means it will block if it can't write (it will always be able to write bcuz it has no competition), the second true means clear the SSRcontainer after writing
				
				// let the user know we've made some progress
				progress_bar->updateProgress(task->size(), true);
			
				// delete the ask now that we've completed it
				delete task;
			}

			delete ssrs;

			break;
		}
		default:
		{
			for (uint32_t i = 0; i < starts.size(); ++i)
			{
				// add a new task to the TaskQueue (so another thread can process it)
				this->tasks->add(new Task(header, sequence.substr(starts[i], sizes[i]), starts[i], sequence.size()));
			}
			
			break;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
movq 0x8(%rdx), %r12
testq %r12, %r12
je 0x777b
movq %rdx, %r14
movq (%rbx), %rdi
callq 0xa166
movl %eax, %eax
movq %r14, 0x8(%rsp)
movq 0x8(%r14), %r15
cmpq %rax, %r12
jb 0x777e
movq (%rbx), %rdi
callq 0xa16a
movl %eax, %eax
cmpq %rax, %r15
jbe 0x779e
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r15
jmp 0x777e
xorl %r15d, %r15d
movq 0x28(%rbx), %rdi
pushq $0x1
popq %rdx
movl %r15d, %esi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbda2
leaq 0x68(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x28(%rsp), %r15
pushq $0x1
popq %rdx
leaq 0x40(%rsp), %r12
movq %r15, %rdi
movq %r12, %rcx
callq 0x8014
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
andq $0x0, 0x10(%r12)
leaq 0x1c(%rsp), %r8
andl $0x0, (%r8)
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rcx
callq 0x7622
movq 0x28(%rbx), %rdi
movl 0x1c(%rsp), %esi
xorl %edx, %edx
callq 0xbda2
movq (%rbx), %rdi
callq 0xa18e
cmpl $0x1, %eax
jne 0x7916
pushq $0x8
popq %rdi
callq 0x32e0
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x3fe0
xorl %r12d, %r12d
pushq $0x48
popq %r15
leaq 0x68(%rsp), %rbp
movl %r12d, %r12d
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %rax
subq %r13, %rax
sarq $0x2, %rax
cmpq %r12, %rax
jbe 0x79b5
movq %r15, %r14
movq %r15, %rdi
callq 0x32e0
movq %rax, %r15
movl (%r13,%r12,4), %edx
movq 0x40(%rsp), %rax
movl (%rax,%r12,4), %ecx
movq %rbp, %rdi
movq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0x3300
movq 0x28(%rsp), %rax
movl (%rax,%r12,4), %ecx
movl 0x8(%r13), %r8d
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq %rbp, %rdx
callq 0x8750
movq %rbp, %rdi
callq 0x35d8
movq %rbp, %rdi
movq %r15, %rsi
callq 0x88de
movq (%rbx), %rsi
movq 0x30(%rbx), %rdx
movq %r15, %rdi
callq 0x7a74
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x41bc
movq %rbp, %rdi
callq 0x35d8
movq 0x20(%rbx), %rsi
movq %r13, %rdi
pushq $0x1
popq %rcx
movl %ecx, %edx
callq 0x43a2
movq 0x28(%rbx), %r13
movq %r15, %rdi
callq 0x88fe
movq %r13, %rdi
movl %eax, %esi
pushq $0x1
popq %rdx
callq 0xbda2
movq %r15, %rdi
callq 0x87c4
movq %r15, %rdi
movq %r14, %r15
movq %r14, %rsi
callq 0x32f0
incl %r12d
jmp 0x782b
xorl %r15d, %r15d
leaq 0x68(%rsp), %r14
movq %rbx, 0x60(%rsp)
movl %r15d, %r15d
movq 0x28(%rsp), %r12
movq 0x30(%rsp), %rax
subq %r12, %rax
sarq $0x2, %rax
cmpq %r15, %rax
jbe 0x79cd
movq 0x38(%rbx), %rbp
pushq $0x48
popq %rdi
callq 0x32e0
movq %rax, %r13
movl (%r12,%r15,4), %edx
movq 0x40(%rsp), %rax
movl (%rax,%r15,4), %ecx
movq %r14, %rdi
movq %r14, %rbx
movq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x3300
movq 0x28(%rsp), %rax
movl (%rax,%r15,4), %ecx
movl 0x8(%r14), %r8d
movb $0x1, %r12b
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x8750
movq %rbx, %r14
xorl %r12d, %r12d
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8c82
movq %r14, %rdi
callq 0x35d8
incl %r15d
movq 0x60(%rsp), %rbx
jmp 0x7923
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x4016
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x32f0
leaq 0x40(%rsp), %rdi
callq 0x86f0
leaq 0x28(%rsp), %rdi
callq 0x86f0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x8
popq %rsi
movq 0x10(%rsp), %rdi
jmp 0x7a4e
jmp 0x7a55
jmp 0x7a55
movq %rax, %rbx
jmp 0x7a16
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x35d8
pushq $0x48
popq %rsi
movq %r15, %rdi
jmp 0x7a4e
jmp 0x7a55
jmp 0x7a55
movq %rax, %rbx
jmp 0x7a48
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x35d8
jmp 0x7a58
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x35d8
testb %r12b, %r12b
je 0x7a58
pushq $0x48
popq %rsi
movq %r13, %rdi
callq 0x32f0
jmp 0x7a58
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x86f0
leaq 0x28(%rsp), %rdi
callq 0x86f0
movq %rbx, %rdi
callq 0x3550