// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movslq %edi, %rax
imulq $0x1c, %rax, %rdi
addq 0x66c7673(%rip), %rdi   # 0x66f6af8
leaq 0x1c(%rsp), %r8
movss 0x8(%rdx), %xmm6
movss 0x8(%rsi), %xmm0
subss %xmm0, %xmm6
leaq 0x20(%rsp), %r9
movss %xmm6, (%r9)
movsd (%rdx), %xmm7
movsd (%rsi), %xmm1
subps %xmm1, %xmm7
movlps %xmm7, -0x8(%r9)
movsd (%rcx), %xmm2
subps %xmm1, %xmm2
leaq 0xc(%rsp), %rdx
movlps %xmm2, -0x4(%rdx)
movss 0x8(%rcx), %xmm3
subss %xmm0, %xmm3
leaq 0x10(%rsp), %rcx
movss %xmm3, (%rcx)
xorl %esi, %esi
movsd 0x60ba(%rip), %xmm0     # 0x35598
movsd 0x60c2(%rip), %xmm1     # 0x355a8
cmpq $0x3, %rsi
je 0x2f668
movss 0x18(%rsp,%rsi,4), %xmm8
movss 0xc(%rdi,%rsi,4), %xmm5
movaps %xmm8, %xmm10
subss %xmm5, %xmm10
movss 0x8(%rsp,%rsi,4), %xmm9
movaps %xmm9, %xmm4
subss %xmm5, %xmm4
cvtss2sd %xmm10, %xmm11
xorl %eax, %eax
ucomisd %xmm0, %xmm11
cvtss2sd %xmm4, %xmm5
jb 0x2f531
ucomisd %xmm0, %xmm5
jae 0x2f67a
ucomisd %xmm1, %xmm11
ja 0x2f543
ucomisd %xmm1, %xmm5
ja 0x2f543
movaps %xmm6, %xmm5
jmp 0x2f5aa
movaps %xmm10, %xmm5
ucomiss %xmm4, %xmm10
subss %xmm4, %xmm5
divss %xmm5, %xmm10
movaps %xmm2, %xmm5
subps %xmm7, %xmm5
movaps %xmm10, %xmm4
shufps $0x0, %xmm10, %xmm4     # xmm4 = xmm4[0,0],xmm10[0,0]
mulps %xmm5, %xmm4
addps %xmm7, %xmm4
movaps %xmm3, %xmm5
subss %xmm6, %xmm5
mulss %xmm10, %xmm5
addss %xmm6, %xmm5
jbe 0x2f58f
movlps %xmm4, 0x18(%rsp)
movss %xmm5, 0x20(%rsp)
movss 0x18(%rsp,%rsi,4), %xmm8
jmp 0x2f5ad
movlps %xmm4, 0x8(%rsp)
movss %xmm5, 0x10(%rsp)
movss 0x8(%rsp,%rsi,4), %xmm9
movaps %xmm5, %xmm3
movaps %xmm6, %xmm5
movaps %xmm4, %xmm2
movaps %xmm7, %xmm4
movss (%rdi,%rsi,4), %xmm6
movaps %xmm6, %xmm7
subss %xmm8, %xmm7
subss %xmm9, %xmm6
cvtss2sd %xmm7, %xmm9
ucomisd %xmm0, %xmm9
cvtss2sd %xmm6, %xmm8
jb 0x2f5db
ucomisd %xmm0, %xmm8
jae 0x2f67a
ucomisd %xmm1, %xmm9
ja 0x2f5e9
ucomisd %xmm1, %xmm8
jbe 0x2f65a
movaps %xmm7, %xmm8
ucomiss %xmm6, %xmm7
subss %xmm6, %xmm8
divss %xmm8, %xmm7
movaps %xmm2, %xmm8
subps %xmm4, %xmm8
movaps %xmm7, %xmm6
shufps $0x0, %xmm7, %xmm6      # xmm6 = xmm6[0,0],xmm7[0,0]
mulps %xmm8, %xmm6
addps %xmm4, %xmm6
movaps %xmm3, %xmm8
subss %xmm5, %xmm8
mulss %xmm7, %xmm8
addss %xmm5, %xmm8
jbe 0x2f63a
movss %xmm6, 0x18(%rsp)
movq %r8, %rax
movq %r9, %r10
movaps %xmm8, %xmm5
movaps %xmm6, %xmm4
jmp 0x2f64d
movss %xmm6, 0x8(%rsp)
movq %rdx, %rax
movq %rcx, %r10
movaps %xmm8, %xmm3
movaps %xmm6, %xmm2
shufps $0x55, %xmm6, %xmm6     # xmm6 = xmm6[1,1,1,1]
movss %xmm6, (%rax)
movss %xmm8, (%r10)
incq %rsi
movaps %xmm5, %xmm6
movaps %xmm4, %xmm7
jmp 0x2f4e6
movl 0x18(%rdi), %edi
leaq 0x18(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2f1e7
addq $0x28, %rsp
retq