// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %rdx, %r13
movq %rsi, 0x58(%rsp)
movq %rdi, %r14
movq 0x8(%rdx), %rbx
testq %rbx, %rbx
je 0x8062
movq (%r14), %rdi
callq 0xb7c4
movl %eax, %eax
cmpq %rax, %rbx
jb 0x8062
movq 0x8(%r13), %rbx
movq (%r14), %rdi
callq 0xb7c8
movl %eax, %eax
cmpq %rax, %rbx
jbe 0x8082
movq 0x28(%r14), %rdi
movl 0x8(%r13), %esi
movl $0x1, %edx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd770
xorl %ebx, %ebx
leaq 0x10(%rsp), %rsi
movl %ebx, (%rsi)
leaq 0x30(%rsp), %r15
leaq 0x60(%rsp), %r12
movl $0x1, %edx
movq %r15, %rdi
movq %r12, %rcx
callq 0x8b94
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movq $0x0, 0x10(%r12)
leaq 0x4c(%rsp), %r8
movl %ebx, (%r8)
leaq 0x60(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rcx
callq 0x7eca
movq 0x28(%r14), %rdi
movl 0x4c(%rsp), %esi
xorl %edx, %edx
callq 0xd770
movq (%r14), %rdi
callq 0xb7ec
cmpl $0x1, %eax
movq %r13, 0x50(%rsp)
jne 0x825b
movl $0x8, %edi
callq 0x32f0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x4398
movq 0x30(%rsp), %rbx
cmpq %rbx, 0x38(%rsp)
je 0x823c
movl $0x1, %r12d
xorl %r15d, %r15d
leaq 0x10(%rsp), %r13
movl $0x48, %edi
callq 0x32f0
movq %rax, %rbp
movl (%rbx,%r15,4), %edx
movq 0x60(%rsp), %rax
movl (%rax,%r15,4), %ecx
movq %r13, %rdi
movq 0x50(%rsp), %rbx
movq %rbx, %rsi
callq 0x3320
movq 0x30(%rsp), %rax
movl (%rax,%r15,4), %ecx
movl 0x8(%rbx), %r8d
movq %rbp, %rdi
movq 0x58(%rsp), %rsi
movq %r13, %rdx
callq 0x918c
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x818e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3300
movq %r13, %rdi
movq %rbp, %rsi
callq 0x94d4
movq (%r14), %rsi
movq 0x30(%r14), %rdx
movq %rbp, %rdi
callq 0x8436
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x45e6
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x81d4
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3300
movq 0x20(%r14), %rsi
movq 0x8(%rsp), %rdi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x48b4
movq 0x28(%r14), %r15
movq %rbp, %rdi
callq 0x951a
movq %r15, %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0xd770
movq %rbp, %rdi
callq 0x921c
movl $0x48, %esi
movq %rbp, %rdi
callq 0x3300
movl %r12d, %r15d
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %rax
subq %rbx, %rax
sarq $0x2, %rax
incl %r12d
cmpq %r15, %rax
ja 0x812b
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x43dc
movl $0x8, %esi
movq %rbx, %rdi
callq 0x3300
jmp 0x831e
movq 0x30(%rsp), %rbx
cmpq %rbx, 0x38(%rsp)
je 0x831e
movl $0x1, %r15d
xorl %r12d, %r12d
movq %r14, %r13
movq 0x38(%r14), %rbp
movl $0x48, %edi
callq 0x32f0
movq %rax, 0x8(%rsp)
movl (%rbx,%r12,4), %edx
movq 0x60(%rsp), %rax
movl (%rax,%r12,4), %ecx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq 0x50(%rsp), %rbx
movq %rbx, %rsi
callq 0x3320
movq 0x30(%rsp), %rax
movl (%rax,%r12,4), %ecx
movl 0x8(%rbx), %r8d
movb $0x1, %r12b
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq 0x58(%rsp), %rsi
movq %r14, %rdx
callq 0x918c
xorl %r12d, %r12d
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x996e
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
movq %r13, %r14
je 0x82fe
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3300
movl %r15d, %r12d
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %rax
subq %rbx, %rax
sarq $0x2, %rax
incl %r15d
cmpq %r12, %rax
ja 0x8274
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x8335
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3300
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x834c
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3300
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x8, %esi
jmp 0x83f1
jmp 0x83fd
jmp 0x83fd
movq %rax, %rbx
jmp 0x8396
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8396
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3300
movl $0x48, %esi
movq %rbp, %rdi
jmp 0x83f6
jmp 0x83fd
jmp 0x83fd
movq %rax, %rbx
movb $0x1, %r12b
jmp 0x83e7
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8400
movq 0x20(%rsp), %rsi
incq %rsi
jmp 0x83f6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x83e7
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3300
testb %r12b, %r12b
je 0x8400
movl $0x48, %esi
movq 0x8(%rsp), %rdi
callq 0x3300
jmp 0x8400
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x8417
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3300
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x842e
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3300
movq %rbx, %rdi
callq 0x3540