// File: FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: GetLightInt(dface_t*, int const*, int, int, float (&) [3])
static void GetLightInt (dface_t *face, const int texsize[2], int ix, int iy, vec3_t &light)
{
	ix = qmax (0, qmin (ix, texsize[0]));
	iy = qmax (0, qmin (iy, texsize[1]));
	VectorClear (light);
	if (face->lightofs < 0)
	{
		return;
	}
	for (int k = 0; k < MAXLIGHTMAPS && face->styles[k] != 255; k++)
	{
		byte *samples = &g_dlightdata[face->lightofs + k * (texsize[0] + 1) * (texsize[1] + 1) * 3];
		if (face->styles[k] == 0)
		{
			VectorAdd (light, &samples[(iy * (texsize[0] + 1) + ix) * 3], light);
		}
	}
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movl %edx, -0x14(%rsp)
movl %ecx, -0x18(%rsp)
movq %r8, -0x20(%rsp)
movl -0x14(%rsp), %eax
movq -0x10(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x4920e
movl -0x14(%rsp), %eax
movl %eax, -0x34(%rsp)
jmp 0x49219
movq -0x10(%rsp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rsp)
movl -0x34(%rsp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jle 0x4922b
xorl %eax, %eax
movl %eax, -0x38(%rsp)
jmp 0x49255
movl -0x14(%rsp), %eax
movq -0x10(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x49242
movl -0x14(%rsp), %eax
movl %eax, -0x3c(%rsp)
jmp 0x4924d
movq -0x10(%rsp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rsp)
movl -0x3c(%rsp), %eax
movl %eax, -0x38(%rsp)
movl -0x38(%rsp), %eax
movl %eax, -0x14(%rsp)
movl -0x18(%rsp), %eax
movq -0x10(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x49275
movl -0x18(%rsp), %eax
movl %eax, -0x40(%rsp)
jmp 0x49281
movq -0x10(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x40(%rsp)
movl -0x40(%rsp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jle 0x49293
xorl %eax, %eax
movl %eax, -0x44(%rsp)
jmp 0x492bf
movl -0x18(%rsp), %eax
movq -0x10(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x492ab
movl -0x18(%rsp), %eax
movl %eax, -0x48(%rsp)
jmp 0x492b7
movq -0x10(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x48(%rsp)
movl -0x48(%rsp), %eax
movl %eax, -0x44(%rsp)
movl -0x44(%rsp), %eax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rax)
movq -0x20(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movq -0x20(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movq -0x8(%rsp), %rax
cmpl $0x0, 0x10(%rax)
jge 0x492fd
jmp 0x49465
movl $0x0, -0x24(%rsp)
xorl %eax, %eax
cmpl $0x4, -0x24(%rsp)
movb %al, -0x49(%rsp)
jge 0x4932d
movq -0x8(%rsp), %rax
movslq -0x24(%rsp), %rcx
movzbl 0xc(%rax,%rcx), %eax
cmpl $0xff, %eax
setne %al
movb %al, -0x49(%rsp)
movb -0x49(%rsp), %al
testb $0x1, %al
jne 0x4933a
jmp 0x49465
leaq 0x83d157(%rip), %rax    # 0x886498
movq (%rax), %rax
movq -0x8(%rsp), %rcx
movl 0x10(%rcx), %ecx
movl -0x24(%rsp), %edx
movq -0x10(%rsp), %rsi
movl (%rsi), %esi
addl $0x1, %esi
imull %esi, %edx
movq -0x10(%rsp), %rsi
movl 0x4(%rsi), %esi
addl $0x1, %esi
imull %esi, %edx
imull $0x3, %edx, %edx
addl %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rsp)
movq -0x8(%rsp), %rax
movslq -0x24(%rsp), %rcx
movzbl 0xc(%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x49453
movq -0x20(%rsp), %rax
movss (%rax), %xmm0
movq -0x30(%rsp), %rax
movl -0x18(%rsp), %ecx
movq -0x10(%rsp), %rdx
movl (%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x14(%rsp), %ecx
imull $0x3, %ecx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
cvtsi2ss %eax, %xmm1
addss %xmm1, %xmm0
movq -0x20(%rsp), %rax
movss %xmm0, (%rax)
movq -0x20(%rsp), %rax
movss 0x4(%rax), %xmm0
movq -0x30(%rsp), %rax
movl -0x18(%rsp), %ecx
movq -0x10(%rsp), %rdx
movl (%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x14(%rsp), %ecx
imull $0x3, %ecx, %ecx
movslq %ecx, %rcx
movzbl 0x1(%rax,%rcx), %eax
cvtsi2ss %eax, %xmm1
addss %xmm1, %xmm0
movq -0x20(%rsp), %rax
movss %xmm0, 0x4(%rax)
movq -0x20(%rsp), %rax
movss 0x8(%rax), %xmm0
movq -0x30(%rsp), %rax
movl -0x18(%rsp), %ecx
movq -0x10(%rsp), %rdx
movl (%rdx), %edx
addl $0x1, %edx
imull %edx, %ecx
addl -0x14(%rsp), %ecx
imull $0x3, %ecx, %ecx
movslq %ecx, %rcx
movzbl 0x2(%rax,%rcx), %eax
cvtsi2ss %eax, %xmm1
addss %xmm1, %xmm0
movq -0x20(%rsp), %rax
movss %xmm0, 0x8(%rax)
jmp 0x49455
movl -0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rsp)
jmp 0x49305
retq
nopw %cs:(%rax,%rax)