// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %rbp
testq %rbp, %rbp
je 0x32f2d
movq %rdi, %rbx
movslq 0x8(%rbp), %rdi
movl %edi, 0x1c(%rbx)
movl $0x14, %esi
callq 0x41e0
movq %rax, 0x20(%rbx)
movl 0x8(%rbp), %ecx
testl %ecx, %ecx
je 0x32f2d
movl $0x8, %r15d
movl $0x1, %r12d
leaq 0xbec0(%rip), %r14      # 0x3ec6b
xorl %r13d, %r13d
movq 0x10(%rbp), %rax
movl %ecx, %ecx
cmpq %rcx, %r12
movl $0x0, %ecx
cmovneq %r12, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rbx), %rbp
movss (%rax,%rcx,4), %xmm3
subss -0x8(%rax,%r15), %xmm3
movss 0x4(%rax,%rcx,4), %xmm0
subss -0x4(%rax,%r15), %xmm0
movss 0x8(%rax,%rcx,4), %xmm4
subss (%rax,%r15), %xmm4
movss 0x10(%rbx), %xmm2
mulss %xmm0, %xmm2
movss 0xc(%rbx), %xmm1
mulss %xmm4, %xmm1
subss %xmm2, %xmm1
movss %xmm1, (%rbp,%r13)
mulss 0x8(%rbx), %xmm4
movss 0x10(%rbx), %xmm2
mulss %xmm3, %xmm2
subss %xmm4, %xmm2
movss %xmm2, 0x4(%rbp,%r13)
mulss 0xc(%rbx), %xmm3
mulss 0x8(%rbx), %xmm0
subss %xmm3, %xmm0
movaps %xmm2, %xmm3
mulss %xmm2, %xmm3
movaps %xmm1, %xmm4
mulss %xmm1, %xmm4
addss %xmm3, %xmm4
movaps %xmm0, %xmm3
mulss %xmm0, %xmm3
addss %xmm4, %xmm3
cvtss2sd %xmm3, %xmm3
sqrtsd %xmm3, %xmm3
movsd 0x42ba(%rip), %xmm4     # 0x37118
ucomisd %xmm3, %xmm4
jbe 0x32e78
movl $0x0, 0x8(%rbp,%r13)
movq $0x0, (%rbp,%r13)
jmp 0x32eb6
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
cvtps2pd %xmm1, %xmm1
cvtss2sd %xmm0, %xmm0
divsd %xmm3, %xmm0
cvtsd2ss %xmm0, %xmm0
xorps %xmm2, %xmm2
cvtsd2ss %xmm3, %xmm2
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
divpd %xmm3, %xmm1
cvtpd2ps %xmm1, %xmm1
movss %xmm0, 0x8(%rbp,%r13)
movlpd %xmm1, (%rbp,%r13)
ucomiss 0x41fe(%rip), %xmm2     # 0x370b0
jne 0x32f07
jp 0x32f07
movl $0x2, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0xa446
movl $0x0, 0x8(%rbp,%r13)
movq $0x0, (%rbp,%r13)
movss 0x74a1(%rip), %xmm0     # 0x3a380
movss %xmm0, 0xc(%rbp,%r13)
movq (%rbx), %rbp
movl 0x8(%rbp), %ecx
addq $0x14, %r13
addq $0xc, %r15
leaq 0x1(%r12), %rax
cmpq %rcx, %r12
movq %rax, %r12
jb 0x32dae
jmp 0x32f2d
movapd %xmm1, %xmm2
shufps $0x55, %xmm1, %xmm2     # xmm2 = xmm2[1,1],xmm1[1,1]
mulss -0x4(%rax,%r15), %xmm2
mulss -0x8(%rax,%r15), %xmm1
addss %xmm2, %xmm1
mulss (%rax,%r15), %xmm0
addss %xmm1, %xmm0
jmp 0x32edf
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq