// File: FreeSlave[P]vhlt/hlrad/qrad.cpp
// Function: CollectLight()
static void     CollectLight()
{
#ifdef ZHLT_TEXLIGHT
    unsigned        j; //LRC
#endif
    unsigned        i;
    patch_t*        patch;

    for (i = 0, patch = g_patches; i < g_num_patches; i++, patch++)
    {
#ifdef HLRAD_AUTOCORING
		vec3_t newtotallight[MAXLIGHTMAPS];
#ifdef ZHLT_XASH
		vec3_t newtotallight_direction[MAXLIGHTMAPS];
#endif
		for (j = 0; j < MAXLIGHTMAPS && newstyles[i][j] != 255; j++)
		{
			VectorClear (newtotallight[j]);
#ifdef ZHLT_XASH
			VectorClear (newtotallight_direction[j]);
#endif
			int k;
			for (k = 0; k < MAXLIGHTMAPS && patch->totalstyle[k] != 255; k++)
			{
				if (patch->totalstyle[k] == newstyles[i][j])
				{
					VectorCopy (patch->totallight[k], newtotallight[j]);
#ifdef ZHLT_XASH
					VectorCopy (patch->totallight_direction[k], newtotallight_direction[k]);
#endif
					break;
				}
			}
		}
		for (j = 0; j < MAXLIGHTMAPS; j++)
		{
			if (newstyles[i][j] != 255)
			{
				patch->totalstyle[j] = newstyles[i][j];
				VectorCopy (newtotallight[j], patch->totallight[j]);
				VectorCopy (addlight[i][j], emitlight[i][j]);
#ifdef ZHLT_XASH
				VectorCopy (newtotallight_direction[j], patch->totallight_direction[j]);
				VectorCopy (addlight_direction[i][j], emitlight_direction[i][j]);
#endif
			}
			else
			{
				patch->totalstyle[j] = 255;
			}
		}
#else
#ifdef ZHLT_TEXLIGHT
         //LRC
		for (j = 0; j < MAXLIGHTMAPS && patch->totalstyle[j] != 255; j++)
		{
		    VectorAdd(patch->totallight[j], addlight[i][j], patch->totallight[j]);
	#ifdef HLRAD_TRANSFERDATA_COMPRESS
	        VectorCopy(addlight[i][j], emitlight[i][j]);
	#else
	        VectorScale(addlight[i][j], TRANSFER_SCALE, emitlight[i][j]);
	#endif
			VectorClear(addlight[i][j]);
		}
#else
        VectorAdd(patch->totallight, addlight[i], patch->totallight);
	#ifdef HLRAD_TRANSFERDATA_COMPRESS
        VectorCopy(addlight[i], emitlight[i]);
	#else
        VectorScale(addlight[i], TRANSFER_SCALE, emitlight[i]);
	#endif
        VectorClear(addlight[i]);
#endif
#endif
    }
}

// Assembly:
movl $0x0, -0x8(%rsp)
movq 0x5392901(%rip), %rax   # 0x53eda00
movq %rax, -0x10(%rsp)
movl -0x8(%rsp), %eax
cmpl 0x54128fa(%rip), %eax   # 0x546da08
jae 0x5b4e0
movl $0x0, -0x4(%rsp)
xorl %eax, %eax
cmpl $0x4, -0x4(%rsp)
movb %al, -0x4d(%rsp)
jae 0x5b14f
movq 0x5514a98(%rip), %rax   # 0x556fbc8
movl -0x8(%rsp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
setne %al
movb %al, -0x4d(%rsp)
movb -0x4d(%rsp), %al
testb $0x1, %al
jne 0x5b15c
jmp 0x5b2da
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rax)
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl $0x0, -0x4c(%rsp)
xorl %eax, %eax
cmpl $0x4, -0x4c(%rsp)
movb %al, -0x4e(%rsp)
jge 0x5b1dc
movq -0x10(%rsp), %rax
movslq -0x4c(%rsp), %rcx
movzbl 0x88(%rax,%rcx), %eax
cmpl $0xff, %eax
setne %al
movb %al, -0x4e(%rsp)
movb -0x4e(%rsp), %al
testb $0x1, %al
jne 0x5b1e9
jmp 0x5b2c8
movq -0x10(%rsp), %rax
movslq -0x4c(%rsp), %rcx
movzbl 0x88(%rax,%rcx), %eax
movq 0x55149c6(%rip), %rcx   # 0x556fbc8
movl -0x8(%rsp), %edx
shlq $0x2, %rdx
addq %rdx, %rcx
movl -0x4(%rsp), %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x5b2b6
movq -0x10(%rsp), %rax
addq $0x90, %rax
movslq -0x4c(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
movq -0x10(%rsp), %rax
addq $0x90, %rax
movslq -0x4c(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movq -0x10(%rsp), %rax
addq $0x90, %rax
movslq -0x4c(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x5b2c8
jmp 0x5b2b8
movl -0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rsp)
jmp 0x5b1b1
jmp 0x5b2ca
movl -0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rsp)
jmp 0x5b11c
movl $0x0, -0x4(%rsp)
cmpl $0x4, -0x4(%rsp)
jae 0x5b4be
movq 0x55148d4(%rip), %rax   # 0x556fbc8
movl -0x8(%rsp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
je 0x5b49b
movq 0x55148af(%rip), %rax   # 0x556fbc8
movl -0x8(%rsp), %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
movb (%rax,%rcx), %dl
movq -0x10(%rsp), %rax
movl -0x4(%rsp), %ecx
movb %dl, 0x88(%rax,%rcx)
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movq -0x10(%rsp), %rax
addq $0x90, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movq -0x10(%rsp), %rax
addq $0x90, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movl -0x4(%rsp), %eax
movl %eax, %ecx
leaq -0x48(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movq -0x10(%rsp), %rax
addq $0x90, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movq 0x55147ea(%rip), %rax   # 0x556fbc0
movl -0x8(%rsp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movq 0x55147c1(%rip), %rax   # 0x556fbb8
movl -0x8(%rsp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
movq 0x55147a8(%rip), %rax   # 0x556fbc0
movl -0x8(%rsp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movq 0x551477e(%rip), %rax   # 0x556fbb8
movl -0x8(%rsp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movq 0x5514764(%rip), %rax   # 0x556fbc0
movl -0x8(%rsp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movq 0x551473a(%rip), %rax   # 0x556fbb8
movl -0x8(%rsp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x4(%rsp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
jmp 0x5b4ac
movq -0x10(%rsp), %rax
movl -0x4(%rsp), %ecx
movb $-0x1, 0x88(%rax,%rcx)
jmp 0x5b4ae
movl -0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rsp)
jmp 0x5b2e2
jmp 0x5b4c0
movl -0x8(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rsp)
movq -0x10(%rsp), %rax
addq $0x138, %rax            # imm = 0x138
movq %rax, -0x10(%rsp)
jmp 0x5b104
retq
nopw %cs:(%rax,%rax)