// File: /workspace/github_cpp_makefile_star2_O1/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
leaq (%rax,%rax,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rax, %rdi
addq 0x66c62a5(%rip), %rdi   # 0x66faae8
leaq 0x1c(%rsp), %r8
movsd (%rdx), %xmm0
movsd (%rsi), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, -0x4(%r8)
movss 0x8(%rdx), %xmm0
movss 0x8(%rsi), %xmm2
subss %xmm2, %xmm0
leaq 0x20(%rsp), %rdx
movss %xmm0, (%rdx)
leaq 0xc(%rsp), %rsi
movsd (%rcx), %xmm3
subps %xmm1, %xmm3
movlps %xmm3, -0x4(%rsi)
movss 0x8(%rcx), %xmm1
subss %xmm2, %xmm1
leaq 0x10(%rsp), %rcx
movss %xmm1, (%rcx)
movss -0x8(%rdx), %xmm6
movss -0x4(%rdx), %xmm5
movss -0x8(%rcx), %xmm7
movss -0x4(%rcx), %xmm4
xorl %eax, %eax
movsd 0x6d91(%rip), %xmm2     # 0x3b640
movsd 0x6d91(%rip), %xmm3     # 0x3b648
xorl %r9d, %r9d
movss 0x18(%rsp,%r9,4), %xmm9
movss 0xc(%rdi,%r9,4), %xmm10
subss %xmm10, %xmm9
movss 0x8(%rsp,%r9,4), %xmm8
subss %xmm10, %xmm8
xorps %xmm11, %xmm11
cvtss2sd %xmm9, %xmm11
ucomisd %xmm2, %xmm11
xorps %xmm10, %xmm10
cvtss2sd %xmm8, %xmm10
jb 0x348fd
ucomisd %xmm2, %xmm10
jae 0x34a92
ucomisd %xmm3, %xmm11
ja 0x3490f
ucomisd %xmm3, %xmm10
jbe 0x3499a
movaps %xmm9, %xmm10
subss %xmm8, %xmm10
ucomiss %xmm8, %xmm9
divss %xmm10, %xmm9
movaps %xmm7, %xmm11
subss %xmm6, %xmm11
mulss %xmm9, %xmm11
addss %xmm6, %xmm11
movaps %xmm4, %xmm8
subss %xmm5, %xmm8
mulss %xmm9, %xmm8
addss %xmm5, %xmm8
movaps %xmm1, %xmm10
subss %xmm0, %xmm10
mulss %xmm9, %xmm10
addss %xmm0, %xmm10
jbe 0x34977
movss %xmm11, 0x18(%rsp)
movq %r8, %r10
movq %rdx, %r11
movaps %xmm10, %xmm0
movaps %xmm8, %xmm5
movaps %xmm11, %xmm6
jmp 0x34990
movss %xmm11, 0x8(%rsp)
movq %rsi, %r10
movq %rcx, %r11
movaps %xmm10, %xmm1
movaps %xmm8, %xmm4
movaps %xmm11, %xmm7
movss %xmm8, (%r10)
movss %xmm10, (%r11)
movss (%rdi,%r9,4), %xmm8
movaps %xmm8, %xmm9
subss 0x18(%rsp,%r9,4), %xmm9
subss 0x8(%rsp,%r9,4), %xmm8
xorps %xmm11, %xmm11
cvtss2sd %xmm9, %xmm11
ucomisd %xmm2, %xmm11
xorps %xmm10, %xmm10
cvtss2sd %xmm8, %xmm10
jb 0x349d6
ucomisd %xmm2, %xmm10
jae 0x34a92
ucomisd %xmm3, %xmm11
ja 0x349e8
ucomisd %xmm3, %xmm10
jbe 0x34a73
movaps %xmm9, %xmm10
subss %xmm8, %xmm10
ucomiss %xmm8, %xmm9
divss %xmm10, %xmm9
movaps %xmm7, %xmm11
subss %xmm6, %xmm11
mulss %xmm9, %xmm11
addss %xmm6, %xmm11
movaps %xmm4, %xmm8
subss %xmm5, %xmm8
mulss %xmm9, %xmm8
addss %xmm5, %xmm8
movaps %xmm1, %xmm10
subss %xmm0, %xmm10
mulss %xmm9, %xmm10
addss %xmm0, %xmm10
jbe 0x34a50
movss %xmm11, 0x18(%rsp)
movq %r8, %r10
movq %rdx, %r11
movaps %xmm10, %xmm0
movaps %xmm8, %xmm5
movaps %xmm11, %xmm6
jmp 0x34a69
movss %xmm11, 0x8(%rsp)
movq %rsi, %r10
movq %rcx, %r11
movaps %xmm10, %xmm1
movaps %xmm8, %xmm4
movaps %xmm11, %xmm7
movss %xmm8, (%r10)
movss %xmm10, (%r11)
incq %r9
cmpq $0x3, %r9
jne 0x348ba
movl 0x18(%rdi), %edi
leaq 0x18(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x345b6
addq $0x28, %rsp
retq