// File: 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:
subq $0x78, %rsp
movl %edi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x66cb644(%rip), %rax   # 0x672faf8
movslq 0x70(%rsp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x644f0
movl $0x2, %edi
leaq 0xd7a5(%rip), %rsi      # 0x71c81
movb $0x0, %al
callq 0xbbf0
movl $0x0, 0x74(%rsp)
jmp 0x64892
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movq 0x60(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0x645cf
movq 0x68(%rsp), %rax
movss (%rax), %xmm1
movq 0x60(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x5c(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm2
movq 0x68(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x60(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x5c(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x68(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x60(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x5c(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x60(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x5c(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
subss 0xc(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x9236(%rip), %xmm1     # 0x6d7e0
ucomisd %xmm1, %xmm0
jbe 0x645bd
movl $0x0, 0x74(%rsp)
jmp 0x64892
jmp 0x645bf
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x644f8
movq 0x60(%rsp), %rax
testb $0x1, 0x2c(%rax)
je 0x6488a
movq 0x68(%rsp), %rax
movss (%rax), %xmm1
movq 0x60(%rsp), %rax
movss 0x30(%rax), %xmm2
movq 0x68(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x60(%rsp), %rax
mulss 0x34(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x68(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x60(%rsp), %rax
movss 0x38(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x60(%rsp), %rax
addss 0x3c(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x68(%rsp), %rax
movss (%rax), %xmm1
movq 0x60(%rsp), %rax
movss 0x40(%rax), %xmm2
movq 0x68(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0x60(%rsp), %rax
mulss 0x44(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x68(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0x60(%rsp), %rax
movss 0x48(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x60(%rsp), %rax
addss 0x4c(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x60(%rsp), %rax
cvtsi2sdl 0x50(%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x50(%rsp), %xmm0
movq 0x60(%rsp), %rax
cvtsi2sdl 0x50(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x45a0
movsd 0x28(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x30(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x45a0
movsd %xmm0, 0x50(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x60(%rsp), %rax
cvtsi2sdl 0x54(%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movsd 0x48(%rsp), %xmm0
movq 0x60(%rsp), %rax
cvtsi2sdl 0x54(%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x45a0
movsd 0x38(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x40(%rsp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x45a0
movsd %xmm0, 0x48(%rsp)
movsd 0x50(%rsp), %xmm0
movq 0x60(%rsp), %rax
movl 0x50(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x647aa
movq 0x60(%rsp), %rax
movl 0x50(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x647d8
xorps %xmm0, %xmm0
ucomisd 0x50(%rsp), %xmm0
jbe 0x647c0
xorps %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0x647cc
movsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x48(%rsp), %xmm0
movq 0x60(%rsp), %rax
movl 0x54(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x64816
movq 0x60(%rsp), %rax
movl 0x54(%rax), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x10(%rsp)
jmp 0x64844
xorps %xmm0, %xmm0
ucomisd 0x48(%rsp), %xmm0
jbe 0x6482c
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x64838
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x60(%rsp), %rax
movq 0x58(%rax), %rax
cvttsd2si 0x48(%rsp), %ecx
movq 0x60(%rsp), %rdx
imull 0x50(%rdx), %ecx
cvttsd2si 0x50(%rsp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x64888
movl $0x0, 0x74(%rsp)
jmp 0x64892
jmp 0x6488a
movl $0x1, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopl (%rax,%rax)