// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/trace.cpp
// Function: TestLineOpaque_face(int, float const*)
int TestLineOpaque_face (int facenum, const vec3_t hit)
{
	opaqueface_t *thisface = &opaquefaces[facenum];
	int x;
	if (thisface->numedges == 0)
	{
		Developer (DEVELOPER_LEVEL_WARNING, "Warning: TestLineOpaque: Empty face.\n");
		return 0;
	}
	for (x = 0; x < thisface->numedges; x++)
	{
		if (DotProduct (hit, thisface->edges[x].normal) - thisface->edges[x].dist > ON_EPSILON)
		{
			return 0;
		}
	}
#ifdef HLRAD_OPAQUE_ALPHATEST
	if (thisface->tex_alphatest)
	{
		double x, y;
		x = DotProduct (hit, thisface->tex_vecs[0]) + thisface->tex_vecs[0][3];
		y = DotProduct (hit, thisface->tex_vecs[1]) + thisface->tex_vecs[1][3];
		x = floor (x - thisface->tex_width * floor (x / thisface->tex_width));
		y = floor (y - thisface->tex_height * floor (y / thisface->tex_height));
		x = x > thisface->tex_width - 1? thisface->tex_width - 1: x < 0? 0: x;
		y = y > thisface->tex_height - 1? thisface->tex_height - 1: y < 0? 0: y;
		if (thisface->tex_canvas[(int)y * thisface->tex_width + (int)x] == 0xFF)
		{
			return 0;
		}
	}
#endif
	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq 0x66c7b10(%rip), %rbx   # 0x66f6ae8
movslq %edi, %rax
imulq $0x60, %rax, %rax
movl 0x1c(%rbx,%rax), %ecx
testl %ecx, %ecx
je 0x2f04f
addq %rax, %rbx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0x14, %rcx, %rcx
addq $0x14, %rcx
movsd 0x65a7(%rip), %xmm0     # 0x355a8
leaq 0x14(%rax), %rdx
cmpq %rdx, %rcx
je 0x2f067
movq 0x20(%rbx), %rdi
movss (%rsi), %xmm1
movss 0x4(%rsi), %xmm2
mulss 0x4(%rdi,%rax), %xmm2
mulss (%rdi,%rax), %xmm1
movss 0x8(%rsi), %xmm3
mulss 0x8(%rdi,%rax), %xmm3
addss %xmm2, %xmm1
addss %xmm1, %xmm3
subss 0xc(%rdi,%rax), %xmm3
cvtss2sd %xmm3, %xmm1
ucomisd %xmm0, %xmm1
movq %rdx, %rax
jbe 0x2f001
xorl %ebx, %ebx
jmp 0x2f1dd
leaq 0xab83(%rip), %rsi      # 0x39bd9
xorl %ebx, %ebx
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x9045
jmp 0x2f1dd
cmpb $0x1, 0x2c(%rbx)
jne 0x2f1da
movss (%rsi), %xmm0
movss 0x4(%rsi), %xmm1
movss 0x8(%rsi), %xmm2
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
movss 0x44(%rbx), %xmm3
movss 0x30(%rbx), %xmm4
movss 0x34(%rbx), %xmm5
unpcklps %xmm3, %xmm5            # xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1]
mulps %xmm1, %xmm5
movss 0x38(%rbx), %xmm1
movss 0x3c(%rbx), %xmm3
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movss 0x40(%rbx), %xmm6
unpcklps %xmm6, %xmm4            # xmm4 = xmm4[0],xmm6[0],xmm4[1],xmm6[1]
mulps %xmm0, %xmm4
addps %xmm5, %xmm4
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
movss 0x48(%rbx), %xmm0
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
mulps %xmm2, %xmm1
addps %xmm4, %xmm1
movss 0x4c(%rbx), %xmm0
unpcklps %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0],xmm3[1],xmm0[1]
addps %xmm1, %xmm3
cvtps2pd %xmm3, %xmm1
movapd %xmm1, 0x10(%rsp)
movq 0x50(%rbx), %r14
movq %r14, %xmm0
movdqa %xmm0, 0x40(%rsp)
cvtdq2pd %xmm0, %xmm0
movapd %xmm0, (%rsp)
divpd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movapd %xmm1, %xmm0
callq 0x4590
movapd %xmm0, 0x30(%rsp)
movapd 0x20(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x4590
movapd 0x30(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd (%rsp), %xmm1
movapd 0x10(%rsp), %xmm0
subpd %xmm1, %xmm0
movapd %xmm0, 0x10(%rsp)
callq 0x4590
movapd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x4590
movapd (%rsp), %xmm5
unpcklpd %xmm0, %xmm5            # xmm5 = xmm5[0],xmm0[0]
xorpd %xmm1, %xmm1
movapd %xmm5, %xmm2
cmpltpd %xmm1, %xmm2
movmskpd %xmm2, %eax
xorpd %xmm1, %xmm1
xorps %xmm4, %xmm4
testb $0x1, %al
jne 0x2f17b
movapd %xmm5, %xmm4
pcmpeqd %xmm2, %xmm2
movdqa 0x40(%rsp), %xmm3
paddd %xmm2, %xmm3
cvtdq2pd %xmm3, %xmm3
movapd %xmm3, %xmm2
cmpltpd %xmm5, %xmm2
movmskpd %xmm2, %ecx
movapd %xmm3, %xmm2
testb $0x1, %cl
jne 0x2f1a6
movaps %xmm4, %xmm2
testb $0x2, %al
jne 0x2f1ae
movapd %xmm0, %xmm1
testb $0x2, %cl
je 0x2f1bb
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
movapd %xmm3, %xmm1
cvttsd2si %xmm1, %eax
movq 0x58(%rbx), %rcx
imull %eax, %r14d
cvttsd2si %xmm2, %eax
addl %r14d, %eax
cltq
cmpb $-0x1, (%rcx,%rax)
je 0x2f048
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r14
retq