// File: /workspace/github_cpp_makefile_star2_O1/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 $0xe8, %rsp
movq %r8, 0x30(%rsp)
movq %rcx, 0x48(%rsp)
movl %edx, 0x8(%rsp)
movl %esi, %ebp
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
xorl %eax, %eax
movq %rax, 0x90(%rsp)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
testl %esi, %esi
js 0xdfd2
leaq 0x1ba3426(%rip), %rax   # 0x1bb13f4
cmpl %ebp, (%rax)
jg 0xdfe0
leaq 0x2d79b(%rip), %rdi     # 0x3b774
xorl %eax, %eax
callq 0xa01c
movslq %ebp, %rax
leaq 0x20be926(%rip), %rcx   # 0x20cc910
movq (%rcx,%rax,8), %rax
movq %rax, 0x40(%rsp)
movl $0x20, %edi
callq 0x42f0
movq %rax, %r14
movq %rax, %rdi
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
movl $0x40, %esi
movq %rdi, 0x38(%rsp)
callq 0x13ff0
leaq 0x80(%rsp), %rdi
xorl %esi, %esi
callq 0x14086
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x140b8
cmpl $0x0, 0x3b359(%rip)     # 0x493a0
movq %r15, 0x50(%rsp)
je 0xe533
movq 0x40(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
testl %ecx, %ecx
jle 0xe533
leaq 0x54ec9cc(%rip), %rbx   # 0x54faa41
xorl %edx, %edx
movl %ebp, 0xc8(%rsp)
movq %r14, 0xd8(%rsp)
movq %rdx, 0xe0(%rsp)
movslq (%rax,%rdx,4), %rax
leaq 0x20be877(%rip), %rcx   # 0x20cc910
movq (%rcx,%rax,8), %r12
movq 0x38(%r12), %rax
movq 0x40(%r12), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xe508
xorl %edx, %edx
movq %r12, 0x58(%rsp)
movq %rdx, 0xb8(%rsp)
movq (%rax,%rdx,8), %r13
movq %r13, %rdi
movq %r15, %rsi
movl %ebp, %edx
leaq 0x70(%rsp), %rcx
callq 0xed6b
testb %al, %al
je 0xe361
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
leaq 0x44(%r13), %r12
leaq 0x70(%rsp), %rdi
movq %r12, %rsi
leaq 0xcc(%rsp), %rdx
callq 0x12b85
cvtss2sd %xmm0, %xmm0
movsd 0x2d509(%rip), %xmm1    # 0x3b628
ucomisd %xmm0, %xmm1
jae 0xe38d
movq 0x90(%r13), %rax
subq 0x88(%r13), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
testl %eax, %eax
je 0xe39a
movslq %eax, %rsi
leaq 0xa0(%rsp), %rdi
callq 0x14086
movq 0x88(%r13), %rdi
movq 0x90(%r13), %rax
subq %rdi, %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %ecx # imm = 0xAAAAAAAB
testl %ecx, %ecx
jle 0xe21b
movl $0xc, %r15d
xorl %ebp, %ebp
leaq 0xcc(%rsp), %r14
movabsq $-0x5555555555555555, %rbx # imm = 0xAAAAAAAAAAAAAAAB
addq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x12c6c
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
addsd 0x2d475(%rip), %xmm1    # 0x3b630
cvtsd2ss %xmm1, %xmm1
movaps %xmm0, %xmm2
cmpltss 0x29f79(%rip), %xmm2    # 0x38144
movaps %xmm2, %xmm3
andnps %xmm0, %xmm3
andps %xmm1, %xmm2
orps %xmm3, %xmm2
movq 0xa0(%rsp), %rax
movss %xmm2, (%rax,%rbp,4)
incq %rbp
movq 0x88(%r13), %rdi
movq 0x90(%r13), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
imulq %rbx, %rcx
movslq %ecx, %rax
addq $0x18, %r15
cmpq %rax, %rbp
jl 0xe19e
movq 0xd8(%rsp), %r14
leaq 0x54ec826(%rip), %rbx   # 0x54faa41
xorl %r8d, %r8d
cmpl $0x2, %ecx
jl 0xe255
movq 0xa0(%rsp), %rax
movl %ecx, %edx
xorl %r9d, %r9d
movl $0x1, %esi
movslq %r9d, %r8
movss (%rax,%r8,4), %xmm0
ucomiss (%rax,%rsi,4), %xmm0
movl %esi, %r8d
ja 0xe24a
movl %r9d, %r8d
incq %rsi
movl %r8d, %r9d
cmpq %rsi, %rdx
jne 0xe235
movslq %r8d, %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 0xcc(%rsp), %rdx
movq %r12, %rcx
callq 0x12cf1
movss 0x29eaa(%rip), %xmm7    # 0x38138
movaps %xmm7, %xmm4
subss %xmm0, %xmm4
movss 0xcc(%rsp), %xmm2
movss 0xd0(%rsp), %xmm3
movss 0x4(%r15), %xmm1
mulss %xmm3, %xmm1
movss (%r15), %xmm5
mulss %xmm2, %xmm5
addss %xmm1, %xmm5
movss 0xd4(%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 0x2d325(%rip), %xmm5    # 0x3b638
ucomisd %xmm0, %xmm5
jae 0xe3ab
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 0x2d2de(%rip), %xmm3    # 0x3b628
ucomisd %xmm3, %xmm2
movq 0x50(%rsp), %r15
movq 0x58(%rsp), %r12
jbe 0xe3bf
xorl %ebp, %ebp
jmp 0xe3ed
cmpb $0x1, (%rbx)
jne 0xe4e0
cmpq 0x40(%rsp), %r12
jne 0xe4e0
movl $0x5, %edi
leaq 0x2d438(%rip), %rsi     # 0x3b7b9
xorl %eax, %eax
callq 0xa52e
jmp 0xe4e0
movl $0x3f800000, 0xc(%rsp)  # imm = 0x3F800000
movb $0x1, %bpl
jmp 0xe3a4
movl $0x0, 0xc(%rsp)
xorl %ebp, %ebp
movq 0x58(%rsp), %r12
jmp 0xe402
xorl %ebp, %ebp
movaps %xmm7, %xmm0
movq 0x50(%rsp), %r15
movaps %xmm7, %xmm1
movq 0x58(%rsp), %r12
jmp 0xe3f8
addsd 0x2d279(%rip), %xmm0    # 0x3b640
movb $0x1, %bpl
ucomisd %xmm0, %xmm2
jae 0xe3ed
divss %xmm4, %xmm1
movss 0x29d5c(%rip), %xmm2    # 0x38138
minss %xmm2, %xmm1
xorpd %xmm0, %xmm0
maxss %xmm1, %xmm0
movaps %xmm2, %xmm1
jmp 0xe3f8
movss 0x29d43(%rip), %xmm1    # 0x38138
movaps %xmm1, %xmm0
subss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xe41f
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
testb %bpl, %bpl
movl 0xc8(%rsp), %ebp
je 0xe4e0
movl $0x20, %edi
callq 0x42f0
movq %rax, %rdi
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
movq %rax, 0xc0(%rsp)
movl $0x4, %esi
callq 0x13ff0
movq 0xc0(%rsp), %rdx
movq %r13, %rdi
leaq 0x70(%rsp), %rsi
callq 0xf0ba
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0xe49d
movss 0xc(%rsp), %xmm0
movss %xmm0, (%rsi)
addq $0x4, 0x88(%rsp)
jmp 0xe4af
leaq 0x80(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x15b18
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xe4ce
movq 0xc0(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x18(%rsp)
jmp 0xe4e0
leaq 0x10(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
callq 0x15bf8
movq 0xb8(%rsp), %rdx
incq %rdx
movq 0x38(%r12), %rax
movq 0x40(%r12), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jl 0xe0bd
movq 0xe0(%rsp), %rdx
incq %rdx
movq 0x40(%rsp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jl 0xe086
movb $0x0, (%r14)
movl $0x0, 0x4(%r14)
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x140ea
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xe692
movabsq $0x100000000, %rbx      # imm = 0x100000000
xorl %r15d, %r15d
leaq 0x53aa468(%rip), %r12   # 0x53b89e0
movq (%rax,%r15,8), %rax
cmpb $0x1, (%rax)
jne 0xe585
movb $0x1, (%r14)
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xe672
xorl %r13d, %r13d
movss 0x4(%rax,%r13,8), %xmm0
movq 0x80(%rsp), %rcx
mulss (%rcx,%r15,4), %xmm0
movss %xmm0, 0xc(%rsp)
movq (%r12), %rcx
movslq (%rax,%r13,8), %rax
imulq $0x138, %rax, %rax      # imm = 0x138
cmpl $0x1, 0x5c(%rcx,%rax)
jne 0xe5ef
cvtss2sd %xmm0, %xmm0
mulsd 0x2d053(%rip), %xmm0    # 0x3b638
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x10(%r14), %rbp
subq 0x8(%r14), %rbp
shlq $0x1d, %rbp
leaq (%rbx,%rbp), %rsi
sarq $0x20, %rsi
movq 0x38(%rsp), %rdi
callq 0x140ea
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rax
movl (%rax,%r13,8), %eax
movq 0x8(%r14), %rcx
sarq $0x1d, %rbp
movl %eax, (%rcx,%rbp)
movss 0xc(%rsp), %xmm0
movq 0x8(%r14), %rax
movss %xmm0, 0x4(%rax,%rbp)
movss 0xc(%rsp), %xmm0
addss 0x4(%r14), %xmm0
movss %xmm0, 0x4(%r14)
incq %r13
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0xe5a8
incq %r15
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0xe578
movss 0x4(%r14), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xe716
movq %r14, %rdi
movl 0x8(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0xfa61
cmpl $0x0, 0x8(%rsp)
movq 0x30(%rsp), %rdx
jle 0xebce
leaq 0x54ec374(%rip), %rax   # 0x54faa41
cmpb $0x0, (%rax)
je 0xebce
cmpb $0x0, (%r14)
xorps %xmm0, %xmm0
jne 0xe6e7
movss 0x2ca91(%rip), %xmm0    # 0x3b178
movl 0x8(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movsd 0x2cff3(%rip), %xmm1    # 0x3b6f0
movsd %xmm1, (%rdx,%rcx)
movss %xmm0, 0x8(%rdx,%rcx)
addq $0xc, %rcx
cmpq %rcx, %rax
jne 0xe6fd
jmp 0xebce
movb $0x0, (%r14)
movl $0x0, 0x4(%r14)
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x140ea
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xe867
movabsq $0x100000000, %rbx      # imm = 0x100000000
xorl %r15d, %r15d
leaq 0x53aa285(%rip), %r12   # 0x53b89e0
movq (%rax,%r15,8), %rax
cmpb $0x1, (%rax)
jne 0xe768
movb $0x1, (%r14)
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xe847
xorl %r13d, %r13d
movss 0x4(%rax,%r13,8), %xmm0
movss %xmm0, 0xc(%rsp)
movq (%r12), %rcx
movslq (%rax,%r13,8), %rax
imulq $0x138, %rax, %rax      # imm = 0x138
cmpl $0x1, 0x5c(%rcx,%rax)
jne 0xe7c4
cvtss2sd %xmm0, %xmm0
mulsd 0x2ce7e(%rip), %xmm0    # 0x3b638
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x10(%r14), %rbp
subq 0x8(%r14), %rbp
shlq $0x1d, %rbp
leaq (%rbx,%rbp), %rsi
sarq $0x20, %rsi
movq 0x38(%rsp), %rdi
callq 0x140ea
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rax
movl (%rax,%r13,8), %eax
movq 0x8(%r14), %rcx
sarq $0x1d, %rbp
movl %eax, (%rcx,%rbp)
movss 0xc(%rsp), %xmm0
movq 0x8(%r14), %rax
movss %xmm0, 0x4(%rax,%rbp)
movss 0xc(%rsp), %xmm0
addss 0x4(%r14), %xmm0
movss %xmm0, 0x4(%r14)
incq %r13
movq 0x10(%rsp), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0xe78b
incq %r15
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0xe75b
movss 0x4(%r14), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xe8ea
movq %r14, %rdi
movl 0x8(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0xfa61
cmpl $0x0, 0x8(%rsp)
movq 0x30(%rsp), %rdx
jle 0xebce
leaq 0x54ec19f(%rip), %rax   # 0x54faa41
cmpb $0x0, (%rax)
je 0xebce
cmpb $0x0, (%r14)
xorps %xmm0, %xmm0
jne 0xe8bc
movss 0x2c8bc(%rip), %xmm0    # 0x3b178
movl 0x8(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movss 0x2c8a6(%rip), %xmm1    # 0x3b178
movlps %xmm1, (%rdx,%rcx)
movss %xmm0, 0x8(%rdx,%rcx)
addq $0xc, %rcx
cmpq %rcx, %rax
jne 0xe8d2
jmp 0xebce
movq 0x40(%rsp), %rcx
movq 0x38(%rcx), %rax
movq 0x40(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xe9fa
xorl %r15d, %r15d
leaq 0x60(%rsp), %r12
xorl %ebx, %ebx
movq 0x50(%rsp), %rbp
movq (%rax,%r15,8), %r13
movsd (%rbp), %xmm0
movsd %xmm0, 0x60(%rsp)
movss 0x8(%rbp), %xmm0
movss %xmm0, 0x68(%rsp)
leaq 0x18(%r13), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x25961
movsd 0x60(%rsp), %xmm0
movsd (%rbp), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, 0x60(%rsp)
movss 0x68(%rsp), %xmm1
subss 0x8(%rbp), %xmm1
movss %xmm1, 0x68(%rsp)
mulps %xmm0, %xmm0
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
xorps %xmm3, %xmm3
cvtss2sd %xmm0, %xmm3
addsd %xmm2, %xmm3
mulss %xmm1, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
addsd %xmm3, %xmm0
ucomisd 0x2c976(%rip), %xmm0    # 0x3b308
jb 0xe99a
sqrtsd %xmm0, %xmm0
jmp 0xe99f
callq 0x4240
cvtsd2ss %xmm0, %xmm0
testq %rbx, %rbx
je 0xe9c9
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0xb8(%rsp), %xmm2
addsd 0x2cc7d(%rip), %xmm2    # 0x3b640
ucomisd %xmm1, %xmm2
jbe 0xe9d5
movq %r13, %rbx
movss %xmm0, 0xb8(%rsp)
incq %r15
movq 0x40(%rsp), %rcx
movq 0x38(%rcx), %rax
movq 0x40(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0xe915
jmp 0xe9fc
xorl %ebx, %ebx
testq %rbx, %rbx
je 0xeb75
movq 0x50(%rsp), %rax
movsd (%rax), %xmm0
movsd 0x38(%rbx), %xmm1
subps %xmm1, %xmm0
leaq 0x70(%rsp), %rsi
movlps %xmm0, (%rsi)
movss 0x8(%rax), %xmm1
subss 0x40(%rbx), %xmm1
movss %xmm1, 0x8(%rsi)
movss 0x4c(%rbx), %xmm2
movsd 0x44(%rbx), %xmm3
movaps %xmm0, %xmm4
mulps %xmm3, %xmm4
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
movaps %xmm0, %xmm5
mulss %xmm3, %xmm5
addss %xmm4, %xmm5
movaps %xmm1, %xmm4
mulss %xmm2, %xmm4
addss %xmm5, %xmm4
movaps %xmm4, %xmm5
unpcklps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
mulps %xmm3, %xmm5
subps %xmm5, %xmm0
movlps %xmm0, (%rsi)
mulss %xmm2, %xmm4
subss %xmm4, %xmm1
movss %xmm1, 0x8(%rsi)
movq %rbx, %rdi
movq %r14, %rdx
callq 0xf0ba
movl $0x0, 0x4(%r14)
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
testl %ecx, %ecx
jle 0xeb02
xorl %ecx, %ecx
leaq 0x53a9f3e(%rip), %rdx   # 0x53b89e0
movsd 0x2cb8e(%rip), %xmm0    # 0x3b638
movq (%rdx), %rsi
movslq (%rax,%rcx,8), %rdi
imulq $0x138, %rdi, %rdi      # imm = 0x138
cmpl $0x1, 0x5c(%rsi,%rdi)
jne 0xead6
xorps %xmm1, %xmm1
cvtss2sd 0x4(%rax,%rcx,8), %xmm1
mulsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm1
movss %xmm1, 0x4(%rax,%rcx,8)
movq 0x8(%r14), %rax
movq 0x10(%r14), %rsi
movss 0x4(%rax,%rcx,8), %xmm1
addss 0x4(%r14), %xmm1
movss %xmm1, 0x4(%r14)
incq %rcx
subq %rax, %rsi
shrq $0x3, %rsi
movslq %esi, %rsi
cmpq %rsi, %rcx
jl 0xeaaa
movq %r14, %rdi
movl 0x8(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0xfa61
cmpl $0x0, 0x8(%rsp)
movq 0x30(%rsp), %rdx
jle 0xebce
leaq 0x54ebf12(%rip), %rax   # 0x54faa41
cmpb $0x0, (%rax)
je 0xebce
cmpb $0x0, (%r14)
xorps %xmm0, %xmm0
jne 0xeb49
movss 0x2c62f(%rip), %xmm0    # 0x3b178
movl 0x8(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rax
xorl %ecx, %ecx
movsd 0x2cb81(%rip), %xmm1    # 0x3b6e0
movsd %xmm1, (%rdx,%rcx)
movss %xmm0, 0x8(%rdx,%rcx)
addq $0xc, %rcx
cmpq %rcx, %rax
jne 0xeb5f
jmp 0xebce
movb $0x1, (%r14)
movl $0x0, 0x4(%r14)
movq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x140ea
movq %r14, %rdi
movl 0x8(%rsp), %esi
movq 0x48(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0xfa61
cmpl $0x0, 0x8(%rsp)
movq 0x30(%rsp), %rdi
jle 0xebce
leaq 0x54ebe8b(%rip), %rax   # 0x54faa41
cmpb $0x0, (%rax)
je 0xebce
movl 0x8(%rsp), %eax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rdx
xorl %esi, %esi
callq 0x4190
movq 0x38(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0xebe7
movq 0x18(%r14), %rsi
subq %rdi, %rsi
callq 0x4300
movl $0x20, %esi
movq %r14, %rdi
callq 0x4300
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0xec52
xorl %r14d, %r14d
movq (%rdi,%r14,8), %rbx
testq %rbx, %rbx
je 0xec37
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0xec2a
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movl $0x20, %esi
movq %rbx, %rdi
callq 0x4300
incq %r14
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r14
jl 0xec0c
testq %rdi, %rdi
je 0xec64
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xec81
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xecc0
jmp 0xecc0
movq %rdx, %r14
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xecc6
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
jmp 0xecc6
jmp 0xecc0
jmp 0xecc0
movq %rdx, %r14
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xecdd
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xecfa
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
cmpl $0x1, %r14d
jne 0xed5b
movq %rbx, %rdi
callq 0x43d0
movq 0x39289(%rip), %rax     # 0x47f98
addq $0x10, %rax
movq %rax, 0xa0(%rsp)
movq %rbx, %rdi
callq 0x4140
xorl %edi, %edi
movl $0x1, %esi
callq 0xa7c9
leaq 0xa0(%rsp), %rdi
callq 0x41c0
callq 0x4560
jmp 0xec81
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x41c0
callq 0x4560
movq %rbx, %rdi
callq 0x4590
movq %rax, %rdi
callq 0x1411b