// File: FreeSlave[P]vhlt/hlrad/trace.cpp
// Function: BuildFaceEdges(opaqueface_t*)
void BuildFaceEdges (opaqueface_t *f)
{
	if (!f->winding)
		return;
	f->numedges = f->winding->m_NumPoints;
	f->edges = (dplane_t *)calloc (f->numedges, sizeof (dplane_t));
	const vec_t *p1, *p2;
	const vec_t *n = f->plane.normal;
	vec3_t e;
	dplane_t *pl;
	int x;
	for (x = 0; x < f->winding->m_NumPoints; x++)
	{
		p1 = f->winding->m_Points[x];
		p2 = f->winding->m_Points[(x+1)%f->winding->m_NumPoints];
		pl = &f->edges[x];
		VectorSubtract (p2, p1, e);
		CrossProduct (n, e, pl->normal);
		if (VectorNormalize (pl->normal) == 0.0)
		{
			Developer (DEVELOPER_LEVEL_WARNING, "Warning: BuildFaceEdges: Empty edge.\n");
			VectorClear (pl->normal);
			pl->dist = -1;
			continue;
		}
		pl->dist = DotProduct (pl->normal, p1);
	}
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x63b99
jmp 0x63e33
movq 0x40(%rsp), %rax
movq (%rax), %rax
movl 0x8(%rax), %ecx
movq 0x40(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x40(%rsp), %rax
movslq 0x1c(%rax), %rdi
movl $0x14, %esi
callq 0x4220
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x40(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x28(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
jae 0x63e33
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movslq 0xc(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, (%rsp)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
xorl %edx, %edx
divl 0x8(%rcx)
movq (%rsp), %rax
movl %edx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0xc(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movss (%rax), %xmm0
movq 0x38(%rsp), %rax
subss (%rax), %xmm0
movss %xmm0, 0x1c(%rsp)
movq 0x30(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x38(%rsp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, 0x20(%rsp)
movq 0x30(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x38(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x28(%rsp), %rax
movss 0x4(%rax), %xmm0
movss 0x24(%rsp), %xmm2
movq 0x28(%rsp), %rax
movss 0x8(%rax), %xmm1
mulss 0x20(%rsp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x10(%rsp), %rax
movss %xmm0, (%rax)
movq 0x28(%rsp), %rax
movss 0x8(%rax), %xmm0
movss 0x1c(%rsp), %xmm2
movq 0x28(%rsp), %rax
movss (%rax), %xmm1
mulss 0x24(%rsp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x10(%rsp), %rax
movss %xmm0, 0x4(%rax)
movq 0x28(%rsp), %rax
movss (%rax), %xmm0
movss 0x20(%rsp), %xmm2
movq 0x28(%rsp), %rax
movss 0x4(%rax), %xmm1
mulss 0x1c(%rsp), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x10(%rsp), %rax
movss %xmm0, 0x8(%rax)
movq 0x10(%rsp), %rdi
callq 0x11980
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x63dcf
jp 0x63dcf
movl $0x2, %edi
leaq 0xdecd(%rip), %rsi      # 0x71c5b
movb $0x0, %al
callq 0xbbf0
movq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rax)
movq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movq 0x10(%rsp), %rax
movss 0x974c(%rip), %xmm0     # 0x6d514
movss %xmm0, 0xc(%rax)
jmp 0x63e23
movq 0x10(%rsp), %rax
movss (%rax), %xmm1
movq 0x38(%rsp), %rax
movss (%rax), %xmm2
movq 0x10(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x38(%rsp), %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x10(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x38(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x10(%rsp), %rax
movss %xmm0, 0xc(%rax)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x63be1
addq $0x48, %rsp
retq
nopl (%rax,%rax)