// File: ridgelab[P]Kmer-SSR/src/AtomicityChecker.cpp
// Function: AtomicityChecker::calculateFactors(unsigned int)
unordered_set<uint32_t>* AtomicityChecker::calculateFactors(uint32_t x)
{
	if (this->factors->count(x))
	{
		return this->factors->at(x);
	}

	if (x == 1)
	{
		this->safeInsert(1, new unordered_set<uint32_t>( {1} ) );
		return this->factors->at(x);
	}
	
	unordered_set<uint32_t>* xfactors = new unordered_set<uint32_t>( {1, x} );

	for (uint32_t i = 2; i <= (x / 2); ++i)
	{
		if ( (x % i) == 0) // english: if i is a factor of x
		{
			xfactors->insert(i); // add i to xfactors

			if (!this->factors->count(i)) // if i is not in this->factors
			{
				this->safeInsert(i, this->calculateFactors(i)); // add it
			}
		}
	}

	this->safeInsert(x, xfactors);
	return this->factors->at(x);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq (%rax), %rdi
leaq -0x14(%rbp), %rsi
callq 0xb910
cmpq $0x0, %rax
je 0xac48
movq -0x80(%rbp), %rax
movq (%rax), %rdi
leaq -0x14(%rbp), %rsi
callq 0xb9b0
movq (%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0xaeae
cmpl $0x1, -0x14(%rbp)
jne 0xad37
movl $0x38, %edi
callq 0x43a0
movq %rax, -0x88(%rbp)
movq %rax, -0x98(%rbp)
movb $0x1, -0x3d(%rbp)
movl $0x1, -0x2c(%rbp)
leaq -0x2c(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x1, -0x20(%rbp)
leaq -0x2f(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0xb3a0
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq %rsp, %rax
movq %rcx, (%rax)
xorl %eax, %eax
movl %eax, %ecx
leaq -0x2d(%rbp), %r8
leaq -0x2e(%rbp), %r9
callq 0xb3c0
jmp 0xacc4
movq -0x98(%rbp), %rdx
movq -0x80(%rbp), %rdi
movb $0x0, -0x3d(%rbp)
movl $0x1, %esi
callq 0xb2e0
jmp 0xacdf
leaq -0x2f(%rbp), %rdi
callq 0xb540
movq -0x80(%rbp), %rax
movq (%rax), %rdi
leaq -0x14(%rbp), %rsi
callq 0xb9b0
movq (%rax), %rax
movq %rax, -0x8(%rbp)
jmp 0xaeae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2f(%rbp), %rdi
callq 0xb540
testb $0x1, -0x3d(%rbp)
jne 0xad21
jmp 0xad32
movq -0x98(%rbp), %rdi
movl $0x38, %esi
callq 0x43b0
jmp 0xaebb
movl $0x38, %edi
callq 0x43a0
movq %rax, -0xa0(%rbp)
movq %rax, -0xb0(%rbp)
movb $0x1, -0x64(%rbp)
movl $0x1, -0x60(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x58(%rbp)
movq $0x2, -0x50(%rbp)
leaq -0x63(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0xb3a0
movq -0xa8(%rbp), %rcx
movq -0xa0(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rsp, %rax
movq %rcx, (%rax)
xorl %eax, %eax
movl %eax, %ecx
leaq -0x61(%rbp), %r8
leaq -0x62(%rbp), %r9
callq 0xb3c0
jmp 0xadaf
movb $0x0, -0x64(%rbp)
leaq -0x63(%rbp), %rdi
callq 0xb540
movq -0xb0(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x2, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl -0x14(%rbp), %ecx
shrl %ecx
cmpl %ecx, %eax
ja 0xae87
movl -0x14(%rbp), %eax
xorl %edx, %edx
divl -0x68(%rbp)
cmpl $0x0, %edx
jne 0xae77
movq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xb9e0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x78(%rbp)
movb %dl, -0x70(%rbp)
movq (%rax), %rdi
leaq -0x68(%rbp), %rsi
callq 0xb910
cmpq $0x0, %rax
jne 0xae75
movq -0x80(%rbp), %rdi
movl -0x68(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0x68(%rbp), %esi
callq 0xac00
movq -0x80(%rbp), %rdi
movl -0xb4(%rbp), %esi
movq %rax, %rdx
callq 0xb2e0
jmp 0xae75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x63(%rbp), %rdi
callq 0xb540
testb $0x1, -0x64(%rbp)
jne 0xae62
jmp 0xae73
movq -0xb0(%rbp), %rdi
movl $0x38, %esi
callq 0x43b0
jmp 0xaebb
jmp 0xae77
jmp 0xae79
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xadce
movq -0x80(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x48(%rbp), %rdx
callq 0xb2e0
movq -0x80(%rbp), %rax
movq (%rax), %rdi
leaq -0x14(%rbp), %rsi
callq 0xb9b0
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x46e0
nopw %cs:(%rax,%rax)