// File: FreeSlave[P]vhlt/hlrad/lerp.cpp
// Function: FindNeighbors(facetriangulation_t*)
static void FindNeighbors (facetriangulation_t *facetrian)
{
	int i;
	int j;
	int e;
	const edgeshare_t *es;
	int side;
	const facelist_t *fl;
	int facenum;
	int facenum2;
	const dface_t *f;
	const dface_t *f2;
	const dplane_t *dp;
	const dplane_t *dp2;

	facenum = facetrian->facenum;
	f = &g_dfaces[facenum];
	dp = getPlaneFromFace (f);

	facetrian->neighbors.resize (0);

	facetrian->neighbors.push_back (facenum);

	for (i = 0; i < f->numedges; i++)
	{
		e = g_dsurfedges[f->firstedge + i];
		es = &g_edgeshare[abs (e)];
		if (!es->smooth)
		{
			continue;
		}
		f2 = es->faces[e > 0? 1: 0];
		facenum2 = f2 - g_dfaces;
		dp2 = getPlaneFromFace (f2);
		if (DotProduct (dp->normal, dp2->normal) < -NORMAL_EPSILON)
		{
			continue;
		}
		for (j = 0; j < (int)facetrian->neighbors.size (); j++)
		{
			if (facetrian->neighbors[j] == facenum2)
			{
				break;
			}
		}
		if (j == (int)facetrian->neighbors.size ())
		{
			facetrian->neighbors.push_back (facenum2);
		}
	}

	for (i = 0; i < f->numedges; i++)
	{
		e = g_dsurfedges[f->firstedge + i];
		es = &g_edgeshare[abs (e)];
		if (!es->smooth)
		{
			continue;
		}
		for (side = 0; side < 2; side++)
		{
			for (fl = es->vertex_facelist[side]; fl; fl = fl->next)
			{
				f2 = fl->face;
				facenum2 = f2 - g_dfaces;
				dp2 = getPlaneFromFace (f2);
				if (DotProduct (dp->normal, dp2->normal) < -NORMAL_EPSILON)
				{
					continue;
				}
				for (j = 0; j < (int)facetrian->neighbors.size (); j++)
				{
					if (facetrian->neighbors[j] == facenum2)
					{
						break;
					}
				}
				if (j == (int)facetrian->neighbors.size ())
				{
					facetrian->neighbors.push_back (facenum2);
				}
			}
		}
	}
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq 0x60(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x34(%rsp)
movslq 0x34(%rsp), %rcx
leaq 0x1bcf410(%rip), %rax   # 0x1be6410
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0x5cfa0
movq %rax, 0x18(%rsp)
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1fb10
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
leaq 0x34(%rsp), %rsi
callq 0x1fbb0
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movq 0x28(%rsp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x171f8
movq 0x28(%rsp), %rax
movl 0x4(%rax), %eax
addl 0x5c(%rsp), %eax
movslq %eax, %rcx
leaq 0x1e693bd(%rip), %rax   # 0x1e80430
movl (%rax,%rcx,4), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x216a8a1(%rip), %rax   # 0x2181930
imulq $0xb0, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
testb $0x1, 0x39(%rax)
jne 0x170ae
jmp 0x171e8
movq 0x48(%rsp), %rax
movl 0x54(%rsp), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovgl %edx, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
leaq 0x1bcf334(%rip), %rcx   # 0x1be6410
subq %rcx, %rax
movl $0x14, %ecx
cqto
idivq %rcx
movl %eax, 0x30(%rsp)
movq 0x20(%rsp), %rdi
callq 0x5cfa0
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movss (%rax), %xmm1
movq 0x10(%rsp), %rax
movss (%rax), %xmm2
movq 0x18(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x10(%rsp), %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x18(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x10(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x5669e(%rip), %xmm0    # 0x6d7f0
ucomisd %xmm1, %xmm0
jbe 0x1715d
jmp 0x171e8
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
callq 0x1eee0
movq %rax, %rcx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jge 0x171b2
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
movslq 0x58(%rsp), %rsi
callq 0x1fc20
movl (%rax), %eax
cmpl 0x30(%rsp), %eax
jne 0x171a3
jmp 0x171b2
jmp 0x171a5
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x17165
movl 0x58(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
callq 0x1eee0
movq %rax, %rcx
movl 0x8(%rsp), %eax
cmpl %ecx, %eax
jne 0x171e6
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
leaq 0x30(%rsp), %rsi
callq 0x1fbb0
jmp 0x171e8
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x17048
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movq 0x28(%rsp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x173f3
movq 0x28(%rsp), %rax
movl 0x4(%rax), %eax
addl 0x5c(%rsp), %eax
movslq %eax, %rcx
leaq 0x1e69205(%rip), %rax   # 0x1e80430
movl (%rax,%rcx,4), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x216a6e9(%rip), %rax   # 0x2181930
imulq $0xb0, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
testb $0x1, 0x39(%rax)
jne 0x17266
jmp 0x173e3
movl $0x0, 0x44(%rsp)
cmpl $0x2, 0x44(%rsp)
jge 0x173e1
movq 0x48(%rsp), %rax
movslq 0x44(%rsp), %rcx
movq 0x40(%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x173cf
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
leaq 0x1bcf15e(%rip), %rcx   # 0x1be6410
subq %rcx, %rax
movl $0x14, %ecx
cqto
idivq %rcx
movl %eax, 0x30(%rsp)
movq 0x20(%rsp), %rdi
callq 0x5cfa0
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movss (%rax), %xmm1
movq 0x10(%rsp), %rax
movss (%rax), %xmm2
movq 0x18(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x10(%rsp), %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x18(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x10(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x564c8(%rip), %xmm0    # 0x6d7f0
ucomisd %xmm1, %xmm0
jbe 0x17333
jmp 0x173bc
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
callq 0x1eee0
movq %rax, %rcx
movl 0x4(%rsp), %eax
cmpl %ecx, %eax
jge 0x17388
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
movslq 0x58(%rsp), %rsi
callq 0x1fc20
movl (%rax), %eax
cmpl 0x30(%rsp), %eax
jne 0x17379
jmp 0x17388
jmp 0x1737b
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x1733b
movl 0x58(%rsp), %eax
movl %eax, (%rsp)
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
callq 0x1eee0
movq %rax, %rcx
movl (%rsp), %eax
cmpl %ecx, %eax
jne 0x173ba
movq 0x60(%rsp), %rdi
addq $0x8, %rdi
leaq 0x30(%rsp), %rsi
callq 0x1fbb0
jmp 0x173bc
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x1728d
jmp 0x173d1
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x1726e
jmp 0x173e3
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x17200
addq $0x68, %rsp
retq
nopl (%rax,%rax)