// File: /workspace/github_cpp_makefile_star2_O1/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:
movq (%rdi), %rax
testq %rax, %rax
je 0x33f96
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq 0x8(%rax), %rdi
movl %edi, 0x1c(%rbx)
movl $0x14, %esi
callq 0x41e0
movq %rax, 0x20(%rbx)
movq (%rbx), %rax
movl 0x8(%rax), %ecx
testl %ecx, %ecx
je 0x33f88
movl $0x8, %r15d
movl $0x1, %r12d
xorl %r13d, %r13d
movq 0x10(%rax), %r14
movl %ecx, %eax
cmpq %rax, %r12
movl $0x0, %eax
cmovneq %r12, %rax
leaq (%rax,%rax,2), %rax
movq 0x20(%rbx), %rbp
movss (%r14,%rax,4), %xmm1
subss -0x8(%r14,%r15), %xmm1
movss 0x4(%r14,%rax,4), %xmm0
subss -0x4(%r14,%r15), %xmm0
movss 0x8(%r14,%rax,4), %xmm2
subss (%r14,%r15), %xmm2
movss 0x10(%rbx), %xmm3
mulss %xmm0, %xmm3
movss 0xc(%rbx), %xmm4
mulss %xmm2, %xmm4
subss %xmm3, %xmm4
movss %xmm4, (%rbp,%r13)
mulss 0x8(%rbx), %xmm2
movss 0x10(%rbx), %xmm3
mulss %xmm1, %xmm3
subss %xmm2, %xmm3
movss %xmm3, 0x4(%rbp,%r13)
mulss 0xc(%rbx), %xmm1
mulss 0x8(%rbx), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x8(%rbp,%r13)
mulss %xmm3, %xmm3
mulss %xmm4, %xmm4
addss %xmm3, %xmm4
mulss %xmm0, %xmm0
addss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd 0x747c(%rip), %xmm0     # 0x3b308
jb 0x33e94
sqrtsd %xmm0, %xmm0
jmp 0x33e99
callq 0x4240
movsd 0x426f(%rip), %xmm1     # 0x38110
ucomisd %xmm0, %xmm1
jbe 0x33ebb
movl $0x0, 0x8(%rbp,%r13)
movq $0x0, (%rbp,%r13)
jmp 0x33f00
cvtps2pd (%rbp,%r13), %xmm1
movapd %xmm0, %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
divpd %xmm2, %xmm1
cvtpd2ps %xmm1, %xmm1
movlpd %xmm1, (%rbp,%r13)
xorps %xmm1, %xmm1
cvtss2sd 0x8(%rbp,%r13), %xmm1
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x8(%rbp,%r13)
cvtsd2ss %xmm0, %xmm0
ucomiss 0x4248(%rip), %xmm0     # 0x38144
jne 0x33f55
jp 0x33f55
movl $0x2, %edi
leaq 0xbddf(%rip), %rsi      # 0x3fceb
xorl %eax, %eax
callq 0xa52e
movl $0x0, 0x8(%rbp,%r13)
movq $0x0, (%rbp,%r13)
movss 0x7443(%rip), %xmm0     # 0x3b370
movss %xmm0, 0xc(%rbp,%r13)
movq (%rbx), %rax
movl 0x8(%rax), %ecx
addq $0x14, %r13
addq $0xc, %r15
leaq 0x1(%r12), %rdx
cmpq %rcx, %r12
movq %rdx, %r12
jb 0x33ddf
jmp 0x33f88
movss 0x4(%rbp,%r13), %xmm0
mulss -0x4(%r14,%r15), %xmm0
movss (%rbp,%r13), %xmm1
mulss -0x8(%r14,%r15), %xmm1
addss %xmm0, %xmm1
movss 0x8(%rbp,%r13), %xmm0
mulss (%r14,%r15), %xmm0
addss %xmm1, %xmm0
jmp 0x33f2d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq