// File: /workspace/github_cpp_makefile_star2_O3/FreeSlave[P]vhlt/hlrad/lightmap.cpp
// Function: MLH_GetSamples_r(mdllight_t*, int, float const*, float const*)
void MLH_GetSamples_r (mdllight_t *ml, int nodenum, const float *start, const float *end)
{
	if (nodenum < 0)
		return;
	dnode_t *node = &g_dnodes[nodenum];
	dplane_t *plane;
	float front, back, frac;
	float mid[3];
	int side;
	plane = &g_dplanes[node->planenum];
	front = DotProduct (start, plane->normal) - plane->dist;
	back = DotProduct (end, plane->normal) - plane->dist;
	side = front < 0;
	if ((back < 0) == side)
	{
		MLH_GetSamples_r (ml, node->children[side], start, end);
		return;
	}
	frac = front / (front - back);
	mid[0] = start[0] + (end[0] - start[0]) * frac;
	mid[1] = start[1] + (end[1] - start[1]) * frac;
	mid[2] = start[2] + (end[2] - start[2]) * frac;
	MLH_GetSamples_r (ml, node->children[side], start, mid);
	if (ml->facecount > 0)
	{
		return;
	}
	{
		int i;
		for (i = 0; i < node->numfaces; i++)
		{
			dface_t *f = &g_dfaces[node->firstface + i];
			texinfo_t *tex = &g_texinfo[f->texinfo];
			const char *texname = GetTextureByNumber (f->texinfo);
			if (!strncmp (texname, "sky", 3))
			{
				continue;
			}
			if (f->lightofs == -1)
			{
				continue;
			}
			int s = (int)(DotProduct (mid, tex->vecs[0]) + tex->vecs[0][3]);
			int t = (int)(DotProduct (mid, tex->vecs[1]) + tex->vecs[1][3]);
			int texturemins[2], extents[2];
			MLH_CalcExtents (f, texturemins, extents);
			if (s < texturemins[0] || t < texturemins[1])
			{
				continue;
			}
			int ds = s - texturemins[0];
			int dt = t - texturemins[1];
			if (ds > extents[0] || dt > extents[1])
			{
				continue;
			}
			ds >>= 4;
			dt >>= 4;
			MLH_AddSample (ml, node->firstface + i, extents[0] / TEXTURE_STEP + 1, extents[1] / TEXTURE_STEP + 1, ds, dt, mid);
			break;
		}
	}
	if (ml->facecount > 0)
	{
		VectorCopy (mid, ml->floor);
		return;
	}
	MLH_GetSamples_r (ml, node->children[!side], mid, end);
}

// Assembly:
testl %esi, %esi
js 0x207a0
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %rbx
movq %rdi, %r14
movl %esi, %eax
leaq (%rax,%rax,2), %rax
leaq 0x10cfec2(%rip), %rcx   # 0x10f0400
leaq (%rcx,%rax,8), %r13
movslq (%r13), %rax
leaq (%rax,%rax,4), %rax
leaq 0xb0fe9f(%rip), %rcx    # 0xb303f0
movss (%rcx,%rax,4), %xmm5
movss 0x4(%rcx,%rax,4), %xmm4
movss 0x8(%rdx), %xmm0
movss 0x8(%rcx,%rax,4), %xmm3
movss 0xc(%rcx,%rax,4), %xmm6
movsd (%rdx), %xmm1
movaps %xmm1, %xmm2
shufps $0x55, %xmm1, %xmm2     # xmm2 = xmm2[1,1],xmm1[1,1]
mulss %xmm4, %xmm2
movaps %xmm1, %xmm7
mulss %xmm5, %xmm7
addss %xmm2, %xmm7
movaps %xmm0, %xmm8
mulss %xmm3, %xmm8
addss %xmm7, %xmm8
subss %xmm6, %xmm8
movsd (%rbx), %xmm2
movaps %xmm2, %xmm7
shufps $0x55, %xmm2, %xmm7     # xmm7 = xmm7[1,1],xmm2[1,1]
mulss %xmm4, %xmm7
mulss %xmm2, %xmm5
addss %xmm7, %xmm5
movss 0x8(%rbx), %xmm4
mulss %xmm4, %xmm3
addss %xmm5, %xmm3
subss %xmm6, %xmm3
xorps %xmm5, %xmm5
ucomiss %xmm8, %xmm5
seta %al
ucomiss %xmm3, %xmm5
setbe %cl
cmpb %cl, %al
je 0x205f5
xorl %eax, %eax
ucomiss %xmm8, %xmm5
seta %al
movswl 0x4(%r13,%rax,2), %esi
movq %r14, %rdi
movq %rbx, %rcx
callq 0x20515
jmp 0x20792
xorl %eax, %eax
ucomiss %xmm8, %xmm5
seta %al
movaps %xmm8, %xmm5
subss %xmm3, %xmm5
movaps %xmm8, %xmm3
divss %xmm5, %xmm3
subps %xmm1, %xmm2
subss %xmm0, %xmm4
mulss %xmm3, %xmm4
unpcklps %xmm3, %xmm3            # xmm3 = xmm3[0,0,1,1]
mulps %xmm2, %xmm3
addps %xmm1, %xmm3
leaq 0x8(%rsp), %rcx
movlps %xmm3, (%rcx)
addss %xmm0, %xmm4
movss %xmm4, 0x8(%rcx)
movswl 0x4(%r13,%rax,2), %esi
movq %r14, %rdi
movss %xmm8, 0x18(%rsp)
callq 0x20515
cmpl $0x0, 0xa518(%r14)
jg 0x20792
movq %r14, 0x20(%rsp)
cmpw $0x0, 0x16(%r13)
je 0x2076e
xorl %r12d, %r12d
leaq 0x1b8fd8f(%rip), %rbp   # 0x1bb0400
movzwl 0x14(%r13), %eax
addq %r12, %rax
leaq (%rax,%rax,4), %r14
movswl 0xa(%rbp,%r14,4), %r15d
movl %r15d, %edi
callq 0x637e
cmpb $0x73, (%rax)
jne 0x206a0
cmpb $0x6b, 0x1(%rax)
jne 0x206a0
cmpb $0x79, 0x2(%rax)
je 0x2075d
leaq (,%r14,4), %rdi
addq %rbp, %rdi
cmpl $-0x1, 0x10(%rdi)
je 0x2075d
movslq %r15d, %rax
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq 0x268a9(%rip), %rax     # 0x46f70
movss 0x8(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
movss 0x4(%rax), %xmm2
mulss %xmm1, %xmm2
movss (%rax), %xmm3
mulss %xmm0, %xmm3
addss %xmm2, %xmm3
movss 0x10(%rsp), %xmm4
movss 0x8(%rax), %xmm2
mulss %xmm4, %xmm2
addss %xmm3, %xmm2
addss 0xc(%rax), %xmm2
cvttss2si %xmm2, %r15d
mulss 0x14(%rax), %xmm1
mulss 0x10(%rax), %xmm0
mulss 0x18(%rax), %xmm4
addss %xmm1, %xmm0
addss %xmm0, %xmm4
addss 0x1c(%rax), %xmm4
movss %xmm4, 0x1c(%rsp)
leaq 0x30(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x204a2
subl 0x30(%rsp), %r15d
jl 0x2075d
cvttss2si 0x1c(%rsp), %r9d
subl 0x34(%rsp), %r9d
jl 0x2075d
movl 0x28(%rsp), %ecx
cmpl %ecx, %r15d
jg 0x2075d
movl 0x2c(%rsp), %eax
cmpl %eax, %r9d
jle 0x207be
movzwl 0x16(%r13), %eax
incq %r12
cmpl %eax, %r12d
jb 0x20671
movq 0x20(%rsp), %rdi
cmpl $0x0, 0xa518(%rdi)
jle 0x207a1
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0xc(%rdi)
movss 0x10(%rsp), %xmm0
movss %xmm0, 0x14(%rdi)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
xorl %eax, %eax
ucomiss 0x18(%rsp), %xmm0
setbe %al
movswl 0x4(%r13,%rax,2), %esi
leaq 0x8(%rsp), %rdx
jmp 0x205e8
sarl $0x4, %r15d
sarl $0x4, %r9d
movzwl 0x14(%r13), %edx
addl %edx, %r12d
leal 0xf(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x4, %edx
incl %edx
leal 0xf(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x4, %ecx
incl %ecx
leaq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq 0x20(%rsp), %rdi
movl %r12d, %esi
movl %r15d, %r8d
callq 0x20380
jmp 0x2076e