// File: /workspace/github_cpp_makefile_star2_O3/FreeSlave[P]vhlt/hlrad/lerp.cpp
// Function: InterpolateSampleLight(float const*, int, int, int const*, float (*) [3])
void InterpolateSampleLight (const vec3_t position, int surface, int numstyles, const int *styles, vec3_t *outs
#ifdef ZHLT_XASH
							, vec3_t *outs_direction
#endif
							)
{
	try
	{
	
	const facetriangulation_t *ft;
	interpolation_t *maininterp;
	std::vector< vec_t > localweights;
	std::vector< interpolation_t * > localinterps;

	int i;
	int j;
	int n;
	const facetriangulation_t *ft2;
	const localtriangulation_t *lt;
	vec3_t spot;
	vec_t weight;
	interpolation_t *interp;
	const localtriangulation_t *best;
	vec3_t v;
	vec_t dist;
	vec_t bestdist;
	vec_t dot;

	if (surface < 0 || surface >= g_numfaces)
	{
		Error ("InterpolateSampleLight: internal error: surface number out of range.");
	}
	ft = g_facetriangulations[surface];
	maininterp = new interpolation_t;
	maininterp->points.reserve (64);

	// Calculate local interpolations and their weights
	localweights.resize (0);
	localinterps.resize (0);
	if (g_lerp_enabled)
	{
		for (i = 0; i < (int)ft->neighbors.size (); i++) // for this face and each of its neighbors
		{
			ft2 = g_facetriangulations[ft->neighbors[i]];
			for (j = 0; j < (int)ft2->localtriangulations.size (); j++) // for each patch on that face
			{
				lt = ft2->localtriangulations[j];
				if (!CalcAdaptedSpot (lt, position, surface, spot))
				{
					if (g_drawlerp && ft2 == ft)
					{
						Developer (DEVELOPER_LEVEL_SPAM, "Debug: triangulation: internal error 6.\n");
					}
					continue;
				}
				if (!CalcWeight (lt, spot, &weight))
				{
					continue;
				}
				interp = new interpolation_t;
#ifdef HLRAD_BILINEARINTERPOLATION
				interp->points.reserve (4);
#else
				interp->points.reserve (3);
#endif
				CalcInterpolation (lt, spot, interp);

				localweights.push_back (weight);
				localinterps.push_back (interp);
			}
		}
	}
	
	// Combine into one interpolation
	maininterp->isbiased = false;
	maininterp->totalweight = 0;
	maininterp->points.resize (0);
	for (i = 0; i < (int)localinterps.size (); i++)
	{
		if (localinterps[i]->isbiased)
		{
			maininterp->isbiased = true;
		}
		for (j = 0; j < (int)localinterps[i]->points.size (); j++)
		{
			weight = localinterps[i]->points[j].weight * localweights[i];
			if (g_patches[localinterps[i]->points[j].patchnum].flags == ePatchFlagOutside)
			{
				weight *= 0.01;
			}
			n = (int)maininterp->points.size ();
			maininterp->points.resize (n + 1);
			maininterp->points[n].patchnum = localinterps[i]->points[j].patchnum;
			maininterp->points[n].weight = weight;
			maininterp->totalweight += weight;
		}
	}
	if (maininterp->totalweight > 0)
	{
		ApplyInterpolation (maininterp, numstyles, styles, outs
#ifdef ZHLT_XASH
							, outs_direction
#endif
							);
		if (g_drawlerp)
		{
			for (j = 0; j < numstyles; j++)
			{
				// white or yellow
				outs[j][0] = 100;
				outs[j][1] = 100;
				outs[j][2] = (maininterp->isbiased? 0: 100);
			}
		}
	}
	else
	{
		// try again, don't multiply localweights[i] (which equals to 0)
		maininterp->isbiased = false;
		maininterp->totalweight = 0;
		maininterp->points.resize (0);
		for (i = 0; i < (int)localinterps.size (); i++)
		{
			if (localinterps[i]->isbiased)
			{
				maininterp->isbiased = true;
			}
			for (j = 0; j < (int)localinterps[i]->points.size (); j++)
			{
				weight = localinterps[i]->points[j].weight;
				if (g_patches[localinterps[i]->points[j].patchnum].flags == ePatchFlagOutside)
				{
					weight *= 0.01;
				}
				n = (int)maininterp->points.size ();
				maininterp->points.resize (n + 1);
				maininterp->points[n].patchnum = localinterps[i]->points[j].patchnum;
				maininterp->points[n].weight = weight;
				maininterp->totalweight += weight;
			}
		}
		if (maininterp->totalweight > 0)
		{
			ApplyInterpolation (maininterp, numstyles, styles, outs
#ifdef ZHLT_XASH
								, outs_direction
#endif
								);
			if (g_drawlerp)
			{
				for (j = 0; j < numstyles; j++)
				{
					// red
					outs[j][0] = 100;
					outs[j][1] = 0;
					outs[j][2] = (maininterp->isbiased? 0: 100);
				}
			}
		}
		else
		{
			// worst case, simply use the nearest patch

			best = NULL;
			for (i = 0; i < (int)ft->localtriangulations.size (); i++)
			{
				lt = ft->localtriangulations[i];
				VectorCopy (position, v);
				snap_to_winding (lt->winding, lt->plane, v);
				VectorSubtract (v, position, v);
				dist = VectorLength (v);
				if (best == NULL || dist < bestdist - ON_EPSILON)
				{
					best = lt;
					bestdist = dist;
				}
			}

			if (best)
			{
				lt = best;
				VectorSubtract (position, lt->center, spot);
				dot = DotProduct (spot, lt->normal);
				VectorMA (spot, -dot, lt->normal, spot);
				CalcInterpolation (lt, spot, maininterp);

				maininterp->totalweight = 0;
				for (j = 0; j < (int)maininterp->points.size (); j++)
				{
					if (g_patches[maininterp->points[j].patchnum].flags == ePatchFlagOutside)
					{
						maininterp->points[j].weight *= 0.01;
					}
					maininterp->totalweight += maininterp->points[j].weight;
				}
				ApplyInterpolation (maininterp, numstyles, styles, outs
#ifdef ZHLT_XASH
									, outs_direction
#endif
									);
				if (g_drawlerp)
				{
					for (j = 0; j < numstyles; j++)
					{
						// green
						outs[j][0] = 0;
						outs[j][1] = 100;
						outs[j][2] = (maininterp->isbiased? 0: 100);
					}
				}
			}
			else
			{
				maininterp->isbiased = true;
				maininterp->totalweight = 0;
				maininterp->points.resize (0);
				ApplyInterpolation (maininterp, numstyles, styles, outs
#ifdef ZHLT_XASH
									, outs_direction
#endif
									);
				if (g_drawlerp)
				{
					for (j = 0; j < numstyles; j++)
					{
						// black
						outs[j][0] = 0;
						outs[j][1] = 0;
						outs[j][2] = 0;
					}
				}
			}
		}
	}
	delete maininterp;

	for (i = 0; i < (int)localinterps.size (); i++)
	{
		delete localinterps[i];
	}

	}
	catch (std::bad_alloc)
	{
		hlassume (false, assume_NoMemory);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, 0x48(%rsp)
movl %edx, 0xc(%rsp)
movl %esi, %r12d
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
xorl %eax, %eax
movq %rax, 0x90(%rsp)
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
testl %esi, %esi
js 0xdb24
leaq 0x1ba28d5(%rip), %rax   # 0x1bb03f4
cmpl %r12d, (%rax)
jg 0xdb32
leaq 0x2cbf9(%rip), %rdi     # 0x3a724
xorl %eax, %eax
callq 0x9f34
movslq %r12d, %rax
leaq 0x20bddd4(%rip), %rcx   # 0x20cb910
movq (%rcx,%rax,8), %r15
movl $0x20, %edi
callq 0x42e0
movq %rax, %rbp
movq %rax, %rdi
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
movl $0x40, %esi
movq %rdi, 0x40(%rsp)
callq 0x1388e
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x1392a
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x1395c
cmpl $0x0, 0x3a80c(%rip)     # 0x483a0
movq %r14, 0x50(%rsp)
movq %r15, 0x58(%rsp)
je 0xe08a
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x2, %rdx
testl %edx, %edx
jle 0xe08a
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
xorl %edi, %edi
movq %rbp, 0xe0(%rsp)
movl %r12d, 0x14(%rsp)
movslq (%rax,%rdi,4), %rdx
leaq 0x20bdd2e(%rip), %rsi   # 0x20cb910
movq (%rsi,%rdx,8), %rsi
movq 0x38(%rsi), %rdx
movq %rsi, 0xe8(%rsp)
movq 0x40(%rsi), %rsi
subq %rdx, %rsi
shrq $0x3, %rsi
testl %esi, %esi
jle 0xe071
movq %rdi, 0xf0(%rsp)
xorl %ecx, %ecx
movq %rcx, 0xc0(%rsp)
movq (%rdx,%rcx,8), %r13
movq %r13, %rdi
movq %r14, %rsi
movl %r12d, %edx
leaq 0x70(%rsp), %rcx
callq 0xe891
testb %al, %al
je 0xdda4
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
leaq 0x44(%r13), %r12
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
leaq 0xd4(%rsp), %rdx
callq 0x12521
cvtss2sd %xmm0, %xmm0
movsd 0x2c966(%rip), %xmm1    # 0x3a5d8
ucomisd %xmm0, %xmm1
jae 0xddda
movq 0x90(%r13), %rax
subq 0x88(%r13), %rax
sarq $0x3, %rax
imulq %rbx, %rax
testl %eax, %eax
je 0xddec
movslq %eax, %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1392a
movq 0x88(%r13), %rdi
movq 0x90(%r13), %rax
subq %rdi, %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
xorl %r9d, %r9d
testl %ecx, %ecx
jle 0xde0c
movl $0xc, %r15d
xorl %r14d, %r14d
movq %r12, %rbp
movq %rbx, %r12
leaq 0xd4(%rsp), %rbx
addq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x125f4
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
addsd 0x2c8dc(%rip), %xmm1    # 0x3a5e0
cvtsd2ss %xmm1, %xmm1
movaps %xmm0, %xmm2
cmpltss 0x2939c(%rip), %xmm2    # 0x370b0
movaps %xmm2, %xmm3
andnps %xmm0, %xmm3
andps %xmm1, %xmm2
orps %xmm3, %xmm2
movq 0xa0(%rsp), %rax
movss %xmm2, (%rax,%r14,4)
incq %r14
movq 0x88(%r13), %rdi
movq 0x90(%r13), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
imulq %r12, %rcx
movslq %ecx, %rax
addq $0x18, %r15
cmpq %rax, %r14
jl 0xdce7
cmpl $0x2, %ecx
jl 0xddfe
movq 0xa0(%rsp), %rax
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movl $0x1, %esi
movq 0x50(%rsp), %r14
movq %r12, %rbx
movq %rbp, %r12
movslq %r8d, %r9
movss (%rax,%r9,4), %xmm0
ucomiss (%rax,%rsi,4), %xmm0
movl %esi, %r9d
ja 0xdd97
movl %r8d, %r9d
incq %rsi
movl %r9d, %r8d
cmpq %rsi, %rdx
jne 0xdd82
jmp 0xde0c
leaq 0x54ebc96(%rip), %rax   # 0x54f9a41
cmpb $0x1, (%rax)
jne 0xe034
cmpq %r15, 0xe8(%rsp)
jne 0xe034
movl $0x5, %edi
leaq 0x2c99b(%rip), %rsi     # 0x3a769
xorl %eax, %eax
callq 0xa446
jmp 0xe034
movl $0x3f800000, 0x10(%rsp) # imm = 0x3F800000
movl 0x14(%rsp), %r12d
jmp 0xdf83
movl $0x0, 0x10(%rsp)
movl 0x14(%rsp), %r12d
jmp 0xe034
movq 0x50(%rsp), %r14
movq %r12, %rbx
movq %rbp, %r12
xorl %r9d, %r9d
movslq %r9d, %rax
leaq (%rax,%rax,2), %rdx
leaq (%rdi,%rdx,8), %r15
incl %eax
cltd
idivl %ecx
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdi,%rax,8), %rbp
movq %r15, %rdi
movq %rbp, %rsi
leaq 0xd4(%rsp), %rdx
movq %r12, %rcx
callq 0x12679
movss 0x2925f(%rip), %xmm7    # 0x370a4
movaps %xmm7, %xmm4
subss %xmm0, %xmm4
movss 0xd4(%rsp), %xmm2
movss 0xd8(%rsp), %xmm3
movss 0x4(%r15), %xmm1
mulss %xmm3, %xmm1
movss (%r15), %xmm5
mulss %xmm2, %xmm5
addss %xmm1, %xmm5
movss 0xdc(%rsp), %xmm1
movss 0x8(%r15), %xmm6
mulss %xmm1, %xmm6
addss %xmm5, %xmm6
mulss %xmm4, %xmm6
movss 0x4(%rbp), %xmm4
mulss %xmm3, %xmm4
movss (%rbp), %xmm5
mulss %xmm2, %xmm5
addss %xmm4, %xmm5
movss 0x8(%rbp), %xmm4
mulss %xmm1, %xmm4
addss %xmm5, %xmm4
mulss %xmm0, %xmm4
addss %xmm6, %xmm4
xorps %xmm0, %xmm0
cvtss2sd %xmm4, %xmm0
movsd 0x2c71e(%rip), %xmm5    # 0x3a5e8
ucomisd %xmm0, %xmm5
jae 0xdf11
mulss 0x74(%rsp), %xmm3
mulss 0x70(%rsp), %xmm2
addss %xmm3, %xmm2
mulss 0x78(%rsp), %xmm1
addss %xmm2, %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm1, %xmm2
movapd %xmm0, %xmm3
addsd 0x2c6db(%rip), %xmm3    # 0x3a5d8
ucomisd %xmm3, %xmm2
movq 0x58(%rsp), %r15
movl 0x14(%rsp), %r12d
jbe 0xdf22
xorl %ebp, %ebp
jmp 0xdf45
xorl %ebp, %ebp
movaps %xmm7, %xmm0
movq 0x58(%rsp), %r15
movl 0x14(%rsp), %r12d
jmp 0xdf48
addsd 0x2c6c6(%rip), %xmm0    # 0x3a5f0
movb $0x1, %bpl
ucomisd %xmm0, %xmm2
jae 0xdf45
divss %xmm4, %xmm1
minss %xmm7, %xmm1
xorpd %xmm0, %xmm0
maxss %xmm1, %xmm0
jmp 0xdf48
movaps %xmm7, %xmm0
movaps %xmm7, %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0x10(%rsp)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xdf72
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
testb %bpl, %bpl
movq 0xe0(%rsp), %rbp
je 0xe034
movl $0x20, %edi
callq 0x42e0
movq %rax, %rdi
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
movq %rax, 0xc8(%rsp)
movl $0x4, %esi
callq 0x1388e
movq 0xc8(%rsp), %rdx
movq %r13, %rdi
leaq 0x70(%rsp), %rsi
callq 0xeb13
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0xdff1
movss 0x10(%rsp), %xmm0
movss %xmm0, (%rsi)
addq $0x4, 0x88(%rsp)
jmp 0xe003
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x153de
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0xe022
movq 0xc8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x28(%rsp)
jmp 0xe034
leaq 0x20(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
callq 0x154be
movq 0xc0(%rsp), %rcx
incq %rcx
movq 0xe8(%rsp), %rax
movq 0x38(%rax), %rdx
movq 0x40(%rax), %rax
subq %rdx, %rax
shrq $0x3, %rax
cltq
cmpq %rax, %rcx
jl 0xdc0f
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
movq 0xf0(%rsp), %rdi
incq %rdi
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x2, %rdx
movslq %edx, %rdx
cmpq %rdx, %rdi
jl 0xdbd7
movb $0x0, (%rbp)
movl $0x0, 0x4(%rbp)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x1398e
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
testl %edx, %edx
jle 0xe1e3
movabsq $0x100000000, %rbx      # imm = 0x100000000
xorl %r15d, %r15d
leaq 0x53a990f(%rip), %r12   # 0x53b79e0
movq (%rax,%r15,8), %rsi
cmpb $0x1, (%rsi)
jne 0xe0e2
movb $0x1, (%rbp)
movq (%rax,%r15,8), %rsi
movq 0x8(%rsi), %rdx
movq 0x10(%rsi), %rsi
subq %rdx, %rsi
shrq $0x3, %rsi
testl %esi, %esi
jle 0xe1ca
xorl %r13d, %r13d
movss 0x4(%rdx,%r13,8), %xmm0
movq 0x80(%rsp), %rax
mulss (%rax,%r15,4), %xmm0
movss %xmm0, 0x10(%rsp)
movq (%r12), %rax
movslq (%rdx,%r13,8), %rcx
imulq $0x138, %rcx, %rcx      # imm = 0x138
cmpl $0x1, 0x5c(%rax,%rcx)
jne 0xe143
cvtss2sd %xmm0, %xmm0
mulsd 0x2c4af(%rip), %xmm0    # 0x3a5e8
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x10(%rbp), %r14
subq 0x8(%rbp), %r14
shlq $0x1d, %r14
leaq (%r14,%rbx), %rsi
sarq $0x20, %rsi
movq 0x40(%rsp), %rdi
callq 0x1398e
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rax
movl (%rax,%r13,8), %eax
movq 0x8(%rbp), %rcx
sarq $0x1d, %r14
movl %eax, (%rcx,%r14)
movss 0x10(%rsp), %xmm0
movq 0x8(%rbp), %rax
movss %xmm0, 0x4(%rax,%r14)
addss 0x4(%rbp), %xmm0
movss %xmm0, 0x4(%rbp)
incq %r13
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %rcx
subq %rdx, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0xe0fc
movq 0x28(%rsp), %rcx
movq 0x50(%rsp), %r14
incq %r15
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
movslq %edx, %rdx
cmpq %rdx, %r15
jl 0xe0d1
movss 0x4(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xe266
movq %rbp, %rdi
movl 0xc(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xf4d2
cmpl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rdx
jle 0xe6f4
leaq 0x54eb824(%rip), %rax   # 0x54f9a41
cmpb $0x0, (%rax)
je 0xe6f4
cmpb $0x0, (%rbp)
xorps %xmm0, %xmm0
jne 0xe237
movss 0x2bf41(%rip), %xmm0    # 0x3a178
movl 0xc(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movsd 0x2c453(%rip), %xmm1    # 0x3a6a0
movsd %xmm1, (%rdx,%rcx)
movss %xmm0, 0x8(%rdx,%rcx)
addq $0xc, %rcx
cmpq %rcx, %rax
jne 0xe24d
jmp 0xe6f4
movb $0x0, (%rbp)
movl $0x0, 0x4(%rbp)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x1398e
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
testl %edx, %edx
jle 0xe3b1
movabsq $0x100000000, %rbx      # imm = 0x100000000
xorl %r15d, %r15d
leaq 0x53a9733(%rip), %r12   # 0x53b79e0
movq (%rax,%r15,8), %rsi
cmpb $0x1, (%rsi)
jne 0xe2be
movb $0x1, (%rbp)
movq (%rax,%r15,8), %rsi
movq 0x8(%rsi), %rdx
movq 0x10(%rsi), %rsi
subq %rdx, %rsi
shrq $0x3, %rsi
testl %esi, %esi
jle 0xe398
xorl %r13d, %r13d
movss 0x4(%rdx,%r13,8), %xmm0
movss %xmm0, 0x10(%rsp)
movq (%r12), %rax
movslq (%rdx,%r13,8), %rcx
imulq $0x138, %rcx, %rcx      # imm = 0x138
cmpl $0x1, 0x5c(%rax,%rcx)
jne 0xe311
cvtss2sd %xmm0, %xmm0
mulsd 0x2c2e1(%rip), %xmm0    # 0x3a5e8
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x10(%rbp), %r14
subq 0x8(%rbp), %r14
shlq $0x1d, %r14
leaq (%r14,%rbx), %rsi
sarq $0x20, %rsi
movq 0x40(%rsp), %rdi
callq 0x1398e
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rax
movl (%rax,%r13,8), %eax
movq 0x8(%rbp), %rcx
sarq $0x1d, %r14
movl %eax, (%rcx,%r14)
movss 0x10(%rsp), %xmm0
movq 0x8(%rbp), %rax
movss %xmm0, 0x4(%rax,%r14)
addss 0x4(%rbp), %xmm0
movss %xmm0, 0x4(%rbp)
incq %r13
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %rcx
subq %rdx, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0xe2d8
movq 0x28(%rsp), %rcx
movq 0x50(%rsp), %r14
incq %r15
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
movslq %edx, %rdx
cmpq %rdx, %r15
jl 0xe2ad
movss 0x4(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xe433
movq %rbp, %rdi
movl 0xc(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xf4d2
cmpl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rdx
jle 0xe6f4
leaq 0x54eb656(%rip), %rax   # 0x54f9a41
cmpb $0x0, (%rax)
je 0xe6f4
cmpb $0x0, (%rbp)
xorps %xmm0, %xmm0
jne 0xe405
movss 0x2bd73(%rip), %xmm0    # 0x3a178
movl 0xc(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movss 0x2bd5d(%rip), %xmm1    # 0x3a178
movlps %xmm1, (%rdx,%rcx)
movss %xmm0, 0x8(%rdx,%rcx)
addq $0xc, %rcx
cmpq %rcx, %rax
jne 0xe41b
jmp 0xe6f4
movq 0x58(%rsp), %rcx
movq 0x38(%rcx), %rax
movq 0x40(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xe69c
movsd (%r14), %xmm0
movss 0x8(%r14), %xmm1
xorl %r15d, %r15d
leaq 0x60(%rsp), %r12
xorl %ebx, %ebx
movq (%rax,%r15,8), %r13
movlps %xmm0, 0x60(%rsp)
movss %xmm1, 0x68(%rsp)
leaq 0x18(%r13), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x24be8
movsd 0x60(%rsp), %xmm2
movsd (%r14), %xmm0
subps %xmm0, %xmm2
movlps %xmm2, 0x60(%rsp)
movss 0x68(%rsp), %xmm3
movss 0x8(%r14), %xmm1
subss %xmm1, %xmm3
movss %xmm3, 0x68(%rsp)
mulps %xmm2, %xmm2
xorps %xmm4, %xmm4
cvtss2sd %xmm2, %xmm4
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
cvtss2sd %xmm2, %xmm2
addsd %xmm4, %xmm2
mulss %xmm3, %xmm3
cvtss2sd %xmm3, %xmm3
addsd %xmm2, %xmm3
xorps %xmm2, %xmm2
sqrtsd %xmm3, %xmm2
cvtsd2ss %xmm2, %xmm2
testq %rbx, %rbx
je 0xe4fe
xorps %xmm3, %xmm3
cvtss2sd %xmm2, %xmm3
xorps %xmm4, %xmm4
cvtss2sd 0xc0(%rsp), %xmm4
addsd 0x2c0f8(%rip), %xmm4    # 0x3a5f0
ucomisd %xmm3, %xmm4
jbe 0xe50a
movq %r13, %rbx
movss %xmm2, 0xc0(%rsp)
incq %r15
movq 0x58(%rsp), %rcx
movq 0x38(%rcx), %rax
movq 0x40(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0xe464
movss 0x8(%r14), %xmm0
subss 0x40(%rbx), %xmm0
movss 0x4c(%rbx), %xmm1
movsd (%r14), %xmm2
movsd 0x38(%rbx), %xmm3
subps %xmm3, %xmm2
movsd 0x44(%rbx), %xmm3
movaps %xmm2, %xmm4
mulps %xmm3, %xmm4
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
movaps %xmm2, %xmm5
mulss %xmm3, %xmm5
addss %xmm4, %xmm5
movaps %xmm0, %xmm4
mulss %xmm1, %xmm4
addss %xmm5, %xmm4
movaps %xmm4, %xmm5
unpcklps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
mulps %xmm3, %xmm5
subps %xmm5, %xmm2
leaq 0x70(%rsp), %rsi
movlps %xmm2, (%rsi)
mulss %xmm1, %xmm4
subss %xmm4, %xmm0
movss %xmm0, 0x8(%rsi)
movq %rbx, %rdi
movq %rbp, %rdx
callq 0xeb13
movl $0x0, 0x4(%rbp)
movq 0x8(%rbp), %rax
movq 0x10(%rbp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rdx
testl %edx, %edx
jle 0xe629
leaq 0x53a9421(%rip), %rdx   # 0x53b79e0
movq (%rdx), %rdi
xorps %xmm1, %xmm1
xorl %esi, %esi
movsd 0x2c019(%rip), %xmm0    # 0x3a5e8
movslq (%rax,%rsi,8), %r8
imulq $0x138, %r8, %r8        # imm = 0x138
cmpl $0x1, 0x5c(%rdi,%r8)
jne 0xe609
xorps %xmm1, %xmm1
cvtss2sd 0x4(%rax,%rsi,8), %xmm1
mulsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x4(%rax,%rsi,8)
movq (%rdx), %rdi
movq 0x8(%rbp), %rax
movss 0x4(%rbp), %xmm1
movq 0x10(%rbp), %rcx
addss 0x4(%rax,%rsi,8), %xmm1
movss %xmm1, 0x4(%rbp)
incq %rsi
movq %rcx, %r8
subq %rax, %r8
shrq $0x3, %r8
movslq %r8d, %r8
cmpq %r8, %rsi
jl 0xe5cf
movq %rbp, %rdi
movl 0xc(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xf4d2
cmpl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rdx
jle 0xe6f4
leaq 0x54eb3eb(%rip), %rax   # 0x54f9a41
cmpb $0x0, (%rax)
je 0xe6f4
cmpb $0x0, (%rbp)
xorps %xmm0, %xmm0
jne 0xe670
movss 0x2bb08(%rip), %xmm0    # 0x3a178
movl 0xc(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movsd 0x2c00a(%rip), %xmm1    # 0x3a690
movsd %xmm1, (%rdx,%rcx)
movss %xmm0, 0x8(%rdx,%rcx)
addq $0xc, %rcx
cmpq %rcx, %rax
jne 0xe686
jmp 0xe6f4
movb $0x1, (%rbp)
movl $0x0, 0x4(%rbp)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x1398e
movq %rbp, %rdi
movl 0xc(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xf4d2
cmpl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rdi
jle 0xe6f4
leaq 0x54eb365(%rip), %rax   # 0x54f9a41
cmpb $0x0, (%rax)
je 0xe6f4
movl 0xc(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rdx
xorl %esi, %esi
callq 0x4190
movq 0x40(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0xe70d
movq 0x18(%rbp), %rsi
subq %rdi, %rsi
callq 0x42f0
movl $0x20, %esi
movq %rbp, %rdi
callq 0x42f0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
subq %rdi, %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0xe778
xorl %r14d, %r14d
movq (%rdi,%r14,8), %rbx
testq %rbx, %rbx
je 0xe750
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0xe750
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
callq 0x42f0
movl $0x20, %esi
movq %rbx, %rdi
callq 0x42f0
incq %r14
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
subq %rdi, %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r14
jl 0xe732
testq %rdi, %rdi
je 0xe78a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xe7a7
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe7e6
jmp 0xe7e6
movq %rdx, %r14
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xe7ec
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
jmp 0xe7ec
jmp 0xe7e6
jmp 0xe7e6
movq %rdx, %r14
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xe803
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xe820
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
cmpl $0x1, %r14d
jne 0xe881
movq %rbx, %rdi
callq 0x43c0
movq 0x38763(%rip), %rax     # 0x46f98
addq $0x10, %rax
movq %rax, 0xa0(%rsp)
movq %rbx, %rdi
callq 0x4140
xorl %edi, %edi
movl $0x1, %esi
callq 0xa6ed
leaq 0xa0(%rsp), %rdi
callq 0x41c0
callq 0x4550
jmp 0xe7a7
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x41c0
callq 0x4550
movq %rbx, %rdi
callq 0x4580
movq %rax, %rdi
callq 0x139bf