// File: FreeSlave[P]vhlt/hlrad/lightmap.cpp
// Function: MLH_CopyLight(float const*, float const*)
int MLH_CopyLight (const vec3_t from, const vec3_t to)
{
	int i, j, k, count = 0;
	mdllight_t mlfrom, mlto;
	VectorCopy (from, mlfrom.origin);
	VectorCopy (to, mlto.origin);
	MLH_mdllightCreate (&mlfrom);
	MLH_mdllightCreate (&mlto);
	if (mlfrom.facecount == 0 || mlfrom.face[0].samplecount == 0)
		return -1;
	for (i = 0; i < mlto.facecount; ++i)
		for (j = 0; j < mlto.face[i].samplecount; ++j, ++count)
			for (k = 0; k < ALLSTYLES; ++k)
				if (mlto.face[i].style[k].exist && mlfrom.face[0].style[k].exist)
				{
					VectorCopy (mlfrom.face[0].sample[0].style[k],mlto.face[i].sample[j].style[k]);
					Developer (DEVELOPER_LEVEL_SPAM, "Mdl Light Hack: face (%d) sample (%d) style (%d) position (%f,%f,%f)\n",
						mlto.face[i].num, mlto.face[i].sample[j].num, k, 
						mlto.face[i].sample[j].pos[0], mlto.face[i].sample[j].pos[1], mlto.face[i].sample[j].pos[2]);
				}
	Developer (DEVELOPER_LEVEL_MESSAGE, "Mdl Light Hack: %d sample light copied from (%f,%f,%f) to (%f,%f,%f)\n", 
		count, mlfrom.floor[0], mlfrom.floor[1], mlfrom.floor[2], mlto.floor[0], mlto.floor[1], mlto.floor[2]);
	return count;
}

// Assembly:
subq $0x14a68, %rsp          # imm = 0x14A68
movq %rdi, 0x14a58(%rsp)
movq %rsi, 0x14a50(%rsp)
movl $0x0, 0x14a40(%rsp)
movq 0x14a58(%rsp), %rax
movss (%rax), %xmm0
movss %xmm0, 0xa520(%rsp)
movq 0x14a58(%rsp), %rax
movss 0x4(%rax), %xmm0
movss %xmm0, 0xa524(%rsp)
movq 0x14a58(%rsp), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, 0xa528(%rsp)
movq 0x14a50(%rsp), %rax
movss (%rax), %xmm0
movss %xmm0, (%rsp)
movq 0x14a50(%rsp), %rax
movss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rsp)
movq 0x14a50(%rsp), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rsp)
leaq 0xa520(%rsp), %rdi
callq 0x406c0
movq %rsp, %rdi
callq 0x406c0
cmpl $0x0, 0x14a38(%rsp)
je 0x40873
cmpl $0x0, 0xaf80(%rsp)
jne 0x40883
movl $0xffffffff, 0x14a64(%rsp) # imm = 0xFFFFFFFF
jmp 0x40c0b
movl $0x0, 0x14a4c(%rsp)
movl 0x14a4c(%rsp), %eax
cmpl 0xa518(%rsp), %eax
jge 0x40b9e
movl $0x0, 0x14a48(%rsp)
movl 0x14a48(%rsp), %eax
movq %rsp, %rcx
addq $0x18, %rcx
movslq 0x14a4c(%rsp), %rdx
imulq $0xa50, %rdx, %rdx      # imm = 0xA50
addq %rdx, %rcx
cmpl 0xa48(%rcx), %eax
jge 0x40b86
movl $0x0, 0x14a44(%rsp)
cmpl $0x40, 0x14a44(%rsp)
jge 0x40b5d
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rcx
imulq $0xa50, %rcx, %rcx      # imm = 0xA50
addq %rcx, %rax
movslq 0x14a44(%rsp), %rcx
testb $0x1, 0x4(%rax,%rcx,8)
je 0x40b45
movslq 0x14a44(%rsp), %rax
testb $0x1, 0xa53c(%rsp,%rax,8)
je 0x40b45
movslq 0x14a44(%rsp), %rax
movq 0xa750(%rsp,%rax,8), %rax
movb (%rax), %cl
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rdx
imulq $0xa50, %rdx, %rdx      # imm = 0xA50
addq %rdx, %rax
addq $0x208, %rax            # imm = 0x208
movslq 0x14a48(%rsp), %rdx
imulq $0x210, %rdx, %rdx      # imm = 0x210
addq %rdx, %rax
movslq 0x14a44(%rsp), %rdx
movq 0x10(%rax,%rdx,8), %rax
movb %cl, (%rax)
movslq 0x14a44(%rsp), %rax
movq 0xa750(%rsp,%rax,8), %rax
movb 0x1(%rax), %cl
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rdx
imulq $0xa50, %rdx, %rdx      # imm = 0xA50
addq %rdx, %rax
addq $0x208, %rax            # imm = 0x208
movslq 0x14a48(%rsp), %rdx
imulq $0x210, %rdx, %rdx      # imm = 0x210
addq %rdx, %rax
movslq 0x14a44(%rsp), %rdx
movq 0x10(%rax,%rdx,8), %rax
movb %cl, 0x1(%rax)
movslq 0x14a44(%rsp), %rax
movq 0xa750(%rsp,%rax,8), %rax
movb 0x2(%rax), %cl
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rdx
imulq $0xa50, %rdx, %rdx      # imm = 0xA50
addq %rdx, %rax
addq $0x208, %rax            # imm = 0x208
movslq 0x14a48(%rsp), %rdx
imulq $0x210, %rdx, %rdx      # imm = 0x210
addq %rdx, %rax
movslq 0x14a44(%rsp), %rdx
movq 0x10(%rax,%rdx,8), %rax
movb %cl, 0x2(%rax)
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rcx
imulq $0xa50, %rcx, %rcx      # imm = 0xA50
addq %rcx, %rax
movl (%rax), %edx
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rcx
imulq $0xa50, %rcx, %rcx      # imm = 0xA50
addq %rcx, %rax
addq $0x208, %rax            # imm = 0x208
movslq 0x14a48(%rsp), %rcx
imulq $0x210, %rcx, %rcx      # imm = 0x210
addq %rcx, %rax
movl (%rax), %ecx
movl 0x14a44(%rsp), %r8d
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rsi
imulq $0xa50, %rsi, %rsi      # imm = 0xA50
addq %rsi, %rax
addq $0x208, %rax            # imm = 0x208
movslq 0x14a48(%rsp), %rsi
imulq $0x210, %rsi, %rsi      # imm = 0x210
addq %rsi, %rax
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rsi
imulq $0xa50, %rsi, %rsi      # imm = 0xA50
addq %rsi, %rax
addq $0x208, %rax            # imm = 0x208
movslq 0x14a48(%rsp), %rsi
imulq $0x210, %rsi, %rsi      # imm = 0x210
addq %rsi, %rax
movss 0x8(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq %rsp, %rax
addq $0x18, %rax
movslq 0x14a4c(%rsp), %rsi
imulq $0xa50, %rsi, %rsi      # imm = 0xA50
addq %rsi, %rax
addq $0x208, %rax            # imm = 0x208
movslq 0x14a48(%rsp), %rsi
imulq $0x210, %rsi, %rsi      # imm = 0x210
addq %rsi, %rax
movss 0xc(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movl $0x5, %edi
leaq 0x2d76c(%rip), %rsi     # 0x6e2aa
movb $0x3, %al
callq 0xbbf0
jmp 0x40b47
movl 0x14a44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14a44(%rsp)
jmp 0x408e4
jmp 0x40b5f
movl 0x14a48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14a48(%rsp)
movl 0x14a40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14a40(%rsp)
jmp 0x408ad
jmp 0x40b88
movl 0x14a4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14a4c(%rsp)
jmp 0x4088e
movl 0x14a40(%rsp), %edx
movss 0xa52c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0xa530(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0xa534(%rsp), %xmm2
cvtss2sd %xmm2, %xmm2
movss 0xc(%rsp), %xmm3
cvtss2sd %xmm3, %xmm3
movss 0x10(%rsp), %xmm4
cvtss2sd %xmm4, %xmm4
movss 0x14(%rsp), %xmm5
cvtss2sd %xmm5, %xmm5
movl $0x3, %edi
leaq 0x2d6fa(%rip), %rsi     # 0x6e2f0
movb $0x6, %al
callq 0xbbf0
movl 0x14a40(%rsp), %eax
movl %eax, 0x14a64(%rsp)
movl 0x14a64(%rsp), %eax
addq $0x14a68, %rsp          # imm = 0x14A68
retq
nopw (%rax,%rax)