// File: FreeSlave[P]vhlt/hlrad/trace.cpp
// Function: TestLineOpaque(int, float const*, float const*, float const*)
int TestLineOpaque (int modelnum, const vec3_t modelorigin, const vec3_t start, const vec3_t stop)
{
	opaquemodel_t *thismodel = &opaquemodels[modelnum];
	vec_t front, back, frac;
	vec3_t p1, p2;
	VectorSubtract (start, modelorigin, p1);
	VectorSubtract (stop, modelorigin, p2);
	int axial;
	for (axial = 0; axial < 3; axial++)
	{
		front = p1[axial] - thismodel->maxs[axial];
		back = p2[axial] - thismodel->maxs[axial];
		if (front >= -ON_EPSILON && back >= -ON_EPSILON)
		{
			return 0;
		}
		if (front > ON_EPSILON || back > ON_EPSILON)
		{
			frac = front / (front - back);
			if (front > back)
			{
				p1[0] = p1[0] + (p2[0] - p1[0]) * frac;
				p1[1] = p1[1] + (p2[1] - p1[1]) * frac;
				p1[2] = p1[2] + (p2[2] - p1[2]) * frac;
			}
			else
			{
				p2[0] = p1[0] + (p2[0] - p1[0]) * frac;
				p2[1] = p1[1] + (p2[1] - p1[1]) * frac;
				p2[2] = p1[2] + (p2[2] - p1[2]) * frac;
			}
		}
		front = thismodel->mins[axial] - p1[axial];
		back = thismodel->mins[axial] - p2[axial];
		if (front >= -ON_EPSILON && back >= -ON_EPSILON)
		{
			return 0;
		}
		if (front > ON_EPSILON || back > ON_EPSILON)
		{
			frac = front / (front - back);
			if (front > back)
			{
				p1[0] = p1[0] + (p2[0] - p1[0]) * frac;
				p1[1] = p1[1] + (p2[1] - p1[1]) * frac;
				p1[2] = p1[2] + (p2[2] - p1[2]) * frac;
			}
			else
			{
				p2[0] = p1[0] + (p2[0] - p1[0]) * frac;
				p2[1] = p1[1] + (p2[1] - p1[1]) * frac;
				p2[2] = p1[2] + (p2[2] - p1[2]) * frac;
			}
		}
	}
	return TestLineOpaque_r (thismodel->headnode, p1, p2);
}

// Assembly:
subq $0x58, %rsp
movl %edi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq 0x66cad8a(%rip), %rax   # 0x672fb08
movslq 0x50(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rax
movss (%rax), %xmm0
movq 0x48(%rsp), %rax
subss (%rax), %xmm0
movss %xmm0, 0x18(%rsp)
movq 0x40(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x48(%rsp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, 0x1c(%rsp)
movq 0x40(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x48(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x20(%rsp)
movq 0x38(%rsp), %rax
movss (%rax), %xmm0
movq 0x48(%rsp), %rax
subss (%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x38(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x48(%rsp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x48(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0x14(%rsp)
movl $0x0, 0x8(%rsp)
cmpl $0x3, 0x8(%rsp)
jge 0x651d2
movslq 0x8(%rsp), %rax
movss 0x18(%rsp,%rax,4), %xmm0
movq 0x30(%rsp), %rax
movslq 0x8(%rsp), %rcx
subss 0xc(%rax,%rcx,4), %xmm0
movss %xmm0, 0x2c(%rsp)
movslq 0x8(%rsp), %rax
movss 0xc(%rsp,%rax,4), %xmm0
movq 0x30(%rsp), %rax
movslq 0x8(%rsp), %rcx
subss 0xc(%rax,%rcx,4), %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x2c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x89a2(%rip), %xmm1     # 0x6d830
ucomisd %xmm1, %xmm0
jb 0x64eb9
movss 0x28(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x898a(%rip), %xmm1     # 0x6d830
ucomisd %xmm1, %xmm0
jb 0x64eb9
movl $0x0, 0x54(%rsp)
jmp 0x651ed
movss 0x2c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8915(%rip), %xmm1     # 0x6d7e0
ucomisd %xmm1, %xmm0
ja 0x64eed
movss 0x28(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x88fd(%rip), %xmm1     # 0x6d7e0
ucomisd %xmm1, %xmm0
jbe 0x64ffe
movss 0x2c(%rsp), %xmm0
movss 0x2c(%rsp), %xmm1
subss 0x28(%rsp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
movss 0x2c(%rsp), %xmm0
ucomiss 0x28(%rsp), %xmm0
jbe 0x64f8a
movss 0x18(%rsp), %xmm1
movss 0xc(%rsp), %xmm0
subss 0x18(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x18(%rsp)
movss 0x1c(%rsp), %xmm1
movss 0x10(%rsp), %xmm0
subss 0x1c(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x20(%rsp), %xmm1
movss 0x14(%rsp), %xmm0
subss 0x20(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x20(%rsp)
jmp 0x64ffc
movss 0x18(%rsp), %xmm1
movss 0xc(%rsp), %xmm0
subss 0x18(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
movss 0x1c(%rsp), %xmm1
movss 0x10(%rsp), %xmm0
subss 0x1c(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x10(%rsp)
movss 0x20(%rsp), %xmm1
movss 0x14(%rsp), %xmm0
subss 0x20(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x14(%rsp)
jmp 0x64ffe
movq 0x30(%rsp), %rax
movslq 0x8(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movslq 0x8(%rsp), %rax
subss 0x18(%rsp,%rax,4), %xmm0
movss %xmm0, 0x2c(%rsp)
movq 0x30(%rsp), %rax
movslq 0x8(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movslq 0x8(%rsp), %rax
subss 0xc(%rsp,%rax,4), %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x2c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x87e0(%rip), %xmm1     # 0x6d830
ucomisd %xmm1, %xmm0
jb 0x6507b
movss 0x28(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x87c8(%rip), %xmm1     # 0x6d830
ucomisd %xmm1, %xmm0
jb 0x6507b
movl $0x0, 0x54(%rsp)
jmp 0x651ed
movss 0x2c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x8753(%rip), %xmm1     # 0x6d7e0
ucomisd %xmm1, %xmm0
ja 0x650af
movss 0x28(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x873b(%rip), %xmm1     # 0x6d7e0
ucomisd %xmm1, %xmm0
jbe 0x651c0
movss 0x2c(%rsp), %xmm0
movss 0x2c(%rsp), %xmm1
subss 0x28(%rsp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x24(%rsp)
movss 0x2c(%rsp), %xmm0
ucomiss 0x28(%rsp), %xmm0
jbe 0x6514c
movss 0x18(%rsp), %xmm1
movss 0xc(%rsp), %xmm0
subss 0x18(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x18(%rsp)
movss 0x1c(%rsp), %xmm1
movss 0x10(%rsp), %xmm0
subss 0x1c(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x20(%rsp), %xmm1
movss 0x14(%rsp), %xmm0
subss 0x20(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x20(%rsp)
jmp 0x651be
movss 0x18(%rsp), %xmm1
movss 0xc(%rsp), %xmm0
subss 0x18(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
movss 0x1c(%rsp), %xmm1
movss 0x10(%rsp), %xmm0
subss 0x1c(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x10(%rsp)
movss 0x20(%rsp), %xmm1
movss 0x14(%rsp), %xmm0
subss 0x20(%rsp), %xmm0
movss 0x24(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x14(%rsp)
jmp 0x651c0
jmp 0x651c2
movl 0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8(%rsp)
jmp 0x64e2f
movq 0x30(%rsp), %rax
movl 0x18(%rax), %edi
leaq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x648a0
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)