// File: FreeSlave[P]vhlt/hlrad/lerp.cpp
// Function: BuildWalls(facetriangulation_t*)
static void BuildWalls (facetriangulation_t *facetrian)
{
	int i;
	int j;
	int facenum;
	int facenum2;
	const dface_t *f;
	const dface_t *f2;
	const dplane_t *dp;
	const dplane_t *dp2;
	int e;
	const edgeshare_t *es;
	vec_t dot;

	facenum = facetrian->facenum;
	f = &g_dfaces[facenum];
	dp = getPlaneFromFace (f);

	facetrian->walls.resize (0);

	for (i = 0; i < (int)facetrian->neighbors.size (); i++)
	{
		facenum2 = facetrian->neighbors[i];
		f2 = &g_dfaces[facenum2];
		dp2 = getPlaneFromFace (f2);
		if (DotProduct (dp->normal, dp2->normal) <= 0.1)
		{
			continue;
		}
		for (j = 0; j < f2->numedges; j++)
		{
			e = g_dsurfedges[f2->firstedge + j];
			es = &g_edgeshare[abs (e)];
			if (!es->smooth)
			{
				facetriangulation_t::Wall wall;

				VectorAdd (g_dvertexes[g_dedges[abs(e)].v[0]].point, g_face_offset[facenum], wall.points[0]);
				VectorAdd (g_dvertexes[g_dedges[abs(e)].v[1]].point, g_face_offset[facenum], wall.points[1]);
				VectorSubtract (wall.points[1], wall.points[0], wall.direction);
				dot = DotProduct (wall.direction, dp->normal);
				VectorMA (wall.direction, -dot, dp->normal, wall.direction);
				if (VectorNormalize (wall.direction))
				{
					CrossProduct (wall.direction, dp->normal, wall.normal);
					VectorNormalize (wall.normal);
					facetrian->walls.push_back (wall);
				}
			}
		}
	}
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq 0x80(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x74(%rsp)
movslq 0x74(%rsp), %rcx
leaq 0x1bcefe7(%rip), %rax   # 0x1be6410
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rdi
callq 0x5cfa0
movq %rax, 0x58(%rsp)
movq 0x80(%rsp), %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20a10
movl $0x0, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x80(%rsp), %rdi
addq $0x8, %rdi
callq 0x1eee0
movq %rax, %rcx
movl 0x8(%rsp), %eax
cmpl %ecx, %eax
jge 0x17984
movq 0x80(%rsp), %rdi
addq $0x8, %rdi
movslq 0x7c(%rsp), %rsi
callq 0x1fc20
movl (%rax), %eax
movl %eax, 0x70(%rsp)
movslq 0x70(%rsp), %rcx
leaq 0x1bcef5f(%rip), %rax   # 0x1be6410
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
callq 0x5cfa0
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rax
movss (%rax), %xmm1
movq 0x50(%rsp), %rax
movss (%rax), %xmm2
movq 0x58(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x50(%rsp), %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x58(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x50(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x562d6(%rip), %xmm0    # 0x6d7f8
ucomisd %xmm1, %xmm0
jb 0x1752d
jmp 0x17974
movl $0x0, 0x78(%rsp)
movl 0x78(%rsp), %eax
movq 0x60(%rsp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x17972
movq 0x60(%rsp), %rax
movl 0x4(%rax), %eax
addl 0x78(%rsp), %eax
movslq %eax, %rcx
leaq 0x1e68ed0(%rip), %rax   # 0x1e80430
movl (%rax,%rcx,4), %eax
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x216a3b4(%rip), %rax   # 0x2181930
imulq $0xb0, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
testb $0x1, 0x39(%rax)
jne 0x17960
movl 0x4c(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x1d4ee61(%rip), %rax   # 0x1d66410
movzwl (%rax,%rcx,4), %eax
movl %eax, %ecx
leaq 0x104ee54(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movslq 0x74(%rsp), %rcx
leaq 0x545643d(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss (%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x1d4ee17(%rip), %rax   # 0x1d66410
movzwl (%rax,%rcx,4), %eax
movl %eax, %ecx
leaq 0x104ee0a(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movslq 0x74(%rsp), %rcx
leaq 0x54563f2(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x4(%rax), %xmm0
movss %xmm0, 0x10(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x1d4edcb(%rip), %rax   # 0x1d66410
movzwl (%rax,%rcx,4), %eax
movl %eax, %ecx
leaq 0x104edbe(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movslq 0x74(%rsp), %rcx
leaq 0x54563a6(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x8(%rax), %xmm0
movss %xmm0, 0x14(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x1d4ed7f(%rip), %rax   # 0x1d66410
movzwl 0x2(%rax,%rcx,4), %eax
movl %eax, %ecx
leaq 0x104ed71(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movslq 0x74(%rsp), %rcx
leaq 0x545635a(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss (%rax), %xmm0
movss %xmm0, 0x18(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x1d4ed34(%rip), %rax   # 0x1d66410
movzwl 0x2(%rax,%rcx,4), %eax
movl %eax, %ecx
leaq 0x104ed26(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movslq 0x74(%rsp), %rcx
leaq 0x545630e(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x4(%rax), %xmm0
movss %xmm0, 0x1c(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movslq %eax, %rcx
leaq 0x1d4ece7(%rip), %rax   # 0x1d66410
movzwl 0x2(%rax,%rcx,4), %eax
movl %eax, %ecx
leaq 0x104ecd9(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movslq 0x74(%rsp), %rcx
leaq 0x54562c1(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x8(%rax), %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x18(%rsp), %xmm0
subss 0xc(%rsp), %xmm0
movss %xmm0, 0x24(%rsp)
movss 0x1c(%rsp), %xmm0
subss 0x10(%rsp), %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x20(%rsp), %xmm0
subss 0x14(%rsp), %xmm0
movss %xmm0, 0x2c(%rsp)
movss 0x24(%rsp), %xmm1
movq 0x58(%rsp), %rax
movss (%rax), %xmm2
movss 0x28(%rsp), %xmm0
movq 0x58(%rsp), %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x2c(%rsp), %xmm0
movq 0x58(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x3c(%rsp)
movss 0x24(%rsp), %xmm1
movss 0x3c(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0x58(%rsp), %rax
movss (%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
movss 0x28(%rsp), %xmm1
movss 0x3c(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0x58(%rsp), %rax
movss 0x4(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x2c(%rsp), %xmm1
movss 0x3c(%rsp), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0x58(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x2c(%rsp)
leaq 0xc(%rsp), %rdi
addq $0x18, %rdi
callq 0x11980
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1788b
jp 0x1788b
jmp 0x1795e
movss 0x28(%rsp), %xmm0
movq 0x58(%rsp), %rax
movss 0x8(%rax), %xmm2
movss 0x2c(%rsp), %xmm1
movq 0x58(%rsp), %rax
mulss 0x4(%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x30(%rsp)
movss 0x2c(%rsp), %xmm0
movq 0x58(%rsp), %rax
movss (%rax), %xmm2
movss 0x24(%rsp), %xmm1
movq 0x58(%rsp), %rax
mulss 0x8(%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x34(%rsp)
movss 0x24(%rsp), %xmm0
movq 0x58(%rsp), %rax
movss 0x4(%rax), %xmm2
movss 0x28(%rsp), %xmm1
movq 0x58(%rsp), %rax
mulss (%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x38(%rsp)
leaq 0xc(%rsp), %rdi
addq $0x24, %rdi
callq 0x11980
movq 0x80(%rsp), %rdi
addq $0x20, %rdi
leaq 0xc(%rsp), %rsi
callq 0x20ab0
jmp 0x17960
jmp 0x17962
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x17535
jmp 0x17974
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x17461
addq $0x88, %rsp
retq
nopl (%rax)