// File: FreeSlave[P]vhlt/hlrad/lerp.cpp
// Function: ApplyInterpolation(interpolation_t const*, int, int const*, float (*) [3])
static void ApplyInterpolation (const interpolation_t *interp, int numstyles, const int *styles, vec3_t *outs
#ifdef ZHLT_XASH
								, vec3_t *outs_direction
#endif
								)
{
	int i;
	int j;

	for (j = 0; j < numstyles; j++)
	{
		VectorClear (outs[j]);
#ifdef ZHLT_XASH
		VectorClear (outs_direction[j]);
#endif
	}
	if (interp->totalweight <= 0)
	{
		return;
	}
	for (i = 0; i < (int)interp->points.size (); i++)
	{
		for (j = 0; j < numstyles; j++)
		{
#ifdef ZHLT_XASH
			const vec3_t *b_direction;
#endif
			const vec3_t *b = GetTotalLight (&g_patches[interp->points[i].patchnum], styles[j]
#ifdef ZHLT_XASH
											, b_direction
#endif
											);
			VectorMA (outs[j], interp->points[i].weight / interp->totalweight, *b, outs[j]);
#ifdef ZHLT_XASH
			VectorMA (outs_direction[j], interp->points[i].weight / interp->totalweight, *b_direction, outs_direction[j]);
#endif
		}
	}
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movl %esi, 0x3c(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x16c20
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rax)
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x16bbf
movq 0x40(%rsp), %rax
xorps %xmm0, %xmm0
ucomiss 0x4(%rax), %xmm0
jb 0x16c33
jmp 0x16e22
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
callq 0x1f120
movq %rax, %rcx
movl 0x14(%rsp), %eax
cmpl %ecx, %eax
jge 0x16e22
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x16e10
leaq 0x53d6d83(%rip), %rax   # 0x53eda00
movq (%rax), %rax
movq %rax, (%rsp)
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
movslq 0x24(%rsp), %rsi
callq 0x1f700
movq (%rsp), %rdi
movslq (%rax), %rax
imulq $0x138, %rax, %rax      # imm = 0x138
addq %rax, %rdi
movq 0x30(%rsp), %rax
movslq 0x20(%rsp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x42640
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movss %xmm0, 0x8(%rsp)
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
movslq 0x24(%rsp), %rsi
callq 0x1f700
movss 0x8(%rsp), %xmm1
movss 0x4(%rax), %xmm0
movq 0x40(%rsp), %rax
divss 0x4(%rax), %xmm0
movq 0x18(%rsp), %rax
movss (%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
movslq 0x24(%rsp), %rsi
callq 0x1f700
movss 0xc(%rsp), %xmm1
movss 0x4(%rax), %xmm0
movq 0x40(%rsp), %rax
divss 0x4(%rax), %xmm0
movq 0x18(%rsp), %rax
movss 0x4(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
movslq 0x24(%rsp), %rsi
callq 0x1f700
movss 0x10(%rsp), %xmm1
movss 0x4(%rax), %xmm0
movq 0x40(%rsp), %rax
divss 0x4(%rax), %xmm0
movq 0x18(%rsp), %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x16c68
jmp 0x16e12
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x16c3b
addq $0x48, %rsp
retq
nopw (%rax,%rax)