// File: /workspace/github_cpp_makefile_star2_O2/sorazy[P]canny/canny.cpp
// Function: recursiveDT(double**, double**, HashMap*, HashMap*, int, int, int)
void recursiveDT(double **mag, double **final, HashMap *h, HashMap *peaks, int a, int b, int flag)
{
	// If the pixel value is < lo, out-of-bounds, or at a point we've visited before,
	// then exit the funciton.
	if (mag[a][b] < lo || a < 0 || b < 0 || a >= height || b >= width)
		return;
	if (h->contains(a, b))
		return;

	// Insert the current pixel so we know we've been here before.
	h->insert(a, b);

	// If flag = 0, that means that this is the first pixel of the "series" that
	// we're looking at. We're going to look for a pixel in "final" that's set to
	// ON. If we found one, assert the flag and break out of the loops.
	if (!flag)
	{
		for (int p = -1; p <= 1; p++)
		{
			for (int q = -1; q <= 1; q++)
			{
				if (final[a+p][b+q] == 255)
				{
					final[a][b] = 255;
					flag = 1;
					break;
				}
			}

			if (flag)
				break;
		}
	}
	
	// If flag is asserted, that means we found a pixel that's in final, all what
	// we have to do now is just search for pixels that are in the mid range.
	// Also, make sure that it's in the peaks to begin with.
	if (flag)
	{
		for (int p = -1; p <= 1; p++)
		{
			for (int q = -1; q <= 1; q++)
			{
				if (mag[a+p][b+q] >= lo && peaks->contains(a+p, b+q))
				{
					recursiveDT(mag, final, h, peaks, a+p, b+q, 1);
					final[a][b] = 255;
				}
			}
		}
	}

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
movq %rsi, -0x40(%rbp)
movl %r9d, %eax
orl %r8d, %eax
js 0x3512
movl %r9d, %r14d
movl %r8d, %r13d
movq %rdi, %r12
movslq %r8d, %rax
movq %rax, -0x38(%rbp)
movq (%rdi,%rax,8), %rax
leaq 0x2caf(%rip), %rcx      # 0x6184
cvtsi2sdl (%rcx), %xmm0
movslq %r9d, %rcx
movq %rcx, -0x30(%rbp)
ucomisd (%rax,%rcx,8), %xmm0
ja 0x3512
leaq 0x2c86(%rip), %rax      # 0x6174
cmpl %r13d, (%rax)
jle 0x3512
leaq 0x2c7e(%rip), %rax      # 0x6178
cmpl %r14d, (%rax)
jle 0x3512
movq -0x48(%rbp), %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x38b0
testl %eax, %eax
je 0x3521
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x10(%rbp), %ebx
movq -0x48(%rbp), %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x390a
testl %ebx, %ebx
leaq 0x2c48(%rip), %rbx      # 0x6184
jne 0x35b0
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
pushq $-0x1
popq %rcx
movq -0x30(%rbp), %rdx
leaq (,%rdx,8), %rdx
movsd 0xaaf(%rip), %xmm0      # 0x4010
movq %rcx, %rsi
cmpq $0x2, %rsi
je 0x3512
movq (%rax,%rsi,8), %rdi
addq %rdx, %rdi
movq %rcx, %r8
cmpq $0x2, %r8
je 0x358d
movsd (%rdi,%r8,8), %xmm1
incq %r8
ucomisd %xmm0, %xmm1
jne 0x3574
jp 0x3574
jmp 0x3592
incq %rsi
jmp 0x3564
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x30(%rbp), %rcx
movabsq $0x406fe00000000000, %rdx # imm = 0x406FE00000000000
movq %rdx, (%rax,%rcx,8)
pushq $-0x1
popq %rcx
movl %r14d, %eax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
leaq (,%rax,8), %rax
movq %rax, -0x68(%rbp)
cmpq $0x2, %rcx
je 0x3512
movq -0x38(%rbp), %rax
movq %rcx, -0x58(%rbp)
leaq (%rcx,%rax), %r13
pushq $-0x1
popq %r15
cmpq $0x2, %r15
je 0x3674
movq (%r12,%r13,8), %rax
addq -0x68(%rbp), %rax
movsd (%rax,%r15,8), %xmm0
cvtsi2sdl (%rbx), %xmm1
ucomisd %xmm1, %xmm0
jb 0x366c
movq -0x60(%rbp), %rax
leaq (%rax,%r15), %r14
movq -0x50(%rbp), %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x38b0
testl %eax, %eax
je 0x366c
movl $0x1, (%rsp)
movq %r12, %rdi
movq %r12, %rbx
movq -0x40(%rbp), %r12
movq %r12, %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl %r13d, %r8d
movl %r14d, %r9d
callq 0x3495
movq -0x38(%rbp), %rax
movq (%r12,%rax,8), %rax
movq %rbx, %r12
leaq 0x2b2a(%rip), %rbx      # 0x6184
movq -0x30(%rbp), %rcx
movabsq $0x406fe00000000000, %rdx # imm = 0x406FE00000000000
movq %rdx, (%rax,%rcx,8)
incq %r15
jmp 0x35e4
movq -0x58(%rbp), %rcx
incq %rcx
jmp 0x35ca