// File: 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:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
movl %esi, 0x14c(%rsp)
movl %edx, 0x148(%rsp)
movq %rcx, 0x140(%rsp)
movq %r8, 0x138(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x1ec50
leaq 0xf8(%rsp), %rdi
callq 0x1ec60
cmpl $0x0, 0x14c(%rsp)
jl 0x13357
movl 0x14c(%rsp), %eax
leaq 0x1bd30b5(%rip), %rcx   # 0x1be6404
cmpl (%rcx), %eax
jl 0x13408
leaq 0x5a522(%rip), %rdi     # 0x6d880
xorl %eax, %eax
callq 0xb580
jmp 0x13367
jmp 0x13408
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x1f1a0
leaq 0x110(%rsp), %rdi
callq 0x1f200
movl 0x94(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x14544
movq 0x98(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x43f0
movq %rax, %rsi
leaq 0x88(%rsp), %rdi
callq 0x1f260
movq 0x80(%rsp), %rdi
callq 0x4140
xorl %edi, %edi
movl $0x1, %esi
callq 0xbf00
jmp 0x133ee
leaq 0x88(%rsp), %rdi
callq 0x4200
callq 0x4580
addq $0x158, %rsp            # imm = 0x158
retq
movslq 0x14c(%rsp), %rcx
leaq 0x20ee519(%rip), %rax   # 0x2101930
movq (%rax,%rcx,8), %rax
movq %rax, 0x130(%rsp)
movl $0x20, %edi
callq 0x4320
movq %rax, 0x78(%rsp)
jmp 0x13434
movq 0x78(%rsp), %rdi
callq 0x1ec70
movq 0x78(%rsp), %rax
movq %rax, 0x128(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movl $0x40, %esi
callq 0x1ec90
jmp 0x13463
xorl %eax, %eax
movl %eax, %esi
leaq 0x110(%rsp), %rdi
callq 0x1eda0
jmp 0x13476
xorl %eax, %eax
movl %eax, %esi
leaq 0xf8(%rsp), %rdi
callq 0x1ee40
jmp 0x13489
cmpl $0x0, 0x6af20(%rip)     # 0x7e3b0
je 0x136b4
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, 0x74(%rsp)
movq 0x130(%rsp), %rdi
addq $0x8, %rdi
callq 0x1eee0
movq %rax, %rcx
movl 0x74(%rsp), %eax
cmpl %ecx, %eax
jge 0x136b2
movq 0x130(%rsp), %rdi
addq $0x8, %rdi
movslq 0xf4(%rsp), %rsi
callq 0x1ef00
movslq (%rax), %rcx
leaq 0x20ee441(%rip), %rax   # 0x2101930
movq (%rax,%rcx,8), %rax
movq %rax, 0xe0(%rsp)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x70(%rsp)
movq 0xe0(%rsp), %rdi
addq $0x38, %rdi
callq 0x1ef20
movq %rax, %rcx
movl 0x70(%rsp), %eax
cmpl %ecx, %eax
jge 0x1369a
movq 0xe0(%rsp), %rdi
addq $0x38, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1ef40
movq (%rax), %rax
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rdi
movq 0x150(%rsp), %rsi
movl 0x14c(%rsp), %edx
leaq 0xcc(%rsp), %rcx
callq 0x14560
movb %al, 0x6f(%rsp)
jmp 0x1357f
movb 0x6f(%rsp), %al
testb $0x1, %al
jne 0x135c3
jmp 0x13589
leaq 0x551c4d1(%rip), %rax   # 0x552fa61
testb $0x1, (%rax)
je 0x135be
movq 0xe0(%rsp), %rax
cmpq 0x130(%rsp), %rax
jne 0x135be
leaq 0x5a317(%rip), %rsi     # 0x6d8c5
xorl %eax, %eax
movl $0x5, %edi
callq 0xbbf0
jmp 0x135bc
jmp 0x135be
jmp 0x13684
movq 0xd8(%rsp), %rdi
leaq 0xcc(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
callq 0x14ad0
movb %al, 0x6e(%rsp)
jmp 0x135e6
movb 0x6e(%rsp), %al
testb $0x1, %al
jne 0x135f5
jmp 0x135f0
jmp 0x13684
movl $0x20, %edi
callq 0x4320
movq %rax, 0x60(%rsp)
jmp 0x13606
movq 0x60(%rsp), %rdi
callq 0x1ec70
movq 0x60(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rdi
addq $0x8, %rdi
movl $0x4, %esi
callq 0x1ec90
jmp 0x13635
movq 0xd8(%rsp), %rdi
movq 0xc0(%rsp), %rdx
leaq 0xcc(%rsp), %rsi
callq 0x150a0
jmp 0x13654
leaq 0x110(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x1ef60
jmp 0x1366b
leaq 0xf8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x1efd0
jmp 0x13682
jmp 0x13684
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x13506
jmp 0x1369c
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x134a1
jmp 0x136b4
movq 0x128(%rsp), %rax
movb $0x0, (%rax)
movq 0x128(%rsp), %rax
movl $0x0, 0x4(%rax)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f040
jmp 0x136e5
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, 0x5c(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x1f0e0
movq %rax, %rcx
movl 0x5c(%rsp), %eax
cmpl %ecx, %eax
jge 0x1395b
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rax
testb $0x1, (%rax)
je 0x1373f
movq 0x128(%rsp), %rax
movb $0x1, (%rax)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x58(%rsp)
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
callq 0x1f120
movq %rax, %rcx
movl 0x58(%rsp), %eax
cmpl %ecx, %eax
jge 0x13943
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movss 0x4(%rax), %xmm0
movss %xmm0, 0x4c(%rsp)
movslq 0xf4(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0x1f160
movss 0x4c(%rsp), %xmm0
mulss (%rax), %xmm0
movss %xmm0, 0xc8(%rsp)
leaq 0x53da218(%rip), %rax   # 0x53eda00
movq (%rax), %rax
movq %rax, 0x50(%rsp)
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movq %rax, %rcx
movq 0x50(%rsp), %rax
movslq (%rcx), %rcx
imulq $0x138, %rcx, %rcx      # imm = 0x138
addq %rcx, %rax
cmpl $0x1, 0x5c(%rax)
jne 0x1385a
movss 0xc8(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x59f8f(%rip), %xmm1    # 0x6d7d8
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc8(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
callq 0x1f120
movl %eax, 0xec(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movl 0xec(%rsp), %eax
incl %eax
movslq %eax, %rsi
callq 0x1f040
jmp 0x13891
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movl (%rax), %eax
movl %eax, 0x44(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movslq 0xec(%rsp), %rsi
callq 0x1f140
movl 0x44(%rsp), %ecx
movl %ecx, (%rax)
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0x48(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movslq 0xec(%rsp), %rsi
callq 0x1f140
movss 0x48(%rsp), %xmm0
movss %xmm0, 0x4(%rax)
movss 0xc8(%rsp), %xmm0
movq 0x128(%rsp), %rax
addss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x1374a
jmp 0x13945
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x136f0
movq 0x128(%rsp), %rax
movss 0x4(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x13a64
movq 0x128(%rsp), %rdi
movl 0x148(%rsp), %esi
movq 0x140(%rsp), %rdx
movq 0x138(%rsp), %rcx
callq 0x16ba0
jmp 0x1399a
leaq 0x551c0c0(%rip), %rax   # 0x552fa61
testb $0x1, (%rax)
je 0x13a5f
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
cmpl 0x148(%rsp), %eax
jge 0x13a5d
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x59810(%rip), %xmm0    # 0x6d1f8
movss %xmm0, (%rax)
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x597ed(%rip), %xmm0    # 0x6d1f8
movss %xmm0, 0x4(%rax)
movq 0x128(%rsp), %rax
movb (%rax), %dl
movl $0x64, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
cvtsi2ss %eax, %xmm0
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x139b5
jmp 0x13a5f
jmp 0x14453
movq 0x128(%rsp), %rax
movb $0x0, (%rax)
movq 0x128(%rsp), %rax
movl $0x0, 0x4(%rax)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f040
jmp 0x13a95
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, 0x40(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x1f0e0
movq %rax, %rcx
movl 0x40(%rsp), %eax
cmpl %ecx, %eax
jge 0x13ce6
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rax
testb $0x1, (%rax)
je 0x13aef
movq 0x128(%rsp), %rax
movb $0x1, (%rax)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x3c(%rsp)
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
callq 0x1f120
movq %rax, %rcx
movl 0x3c(%rsp), %eax
cmpl %ecx, %eax
jge 0x13cce
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movss 0x4(%rax), %xmm0
movss %xmm0, 0xc8(%rsp)
leaq 0x53d9e8d(%rip), %rax   # 0x53eda00
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movq %rax, %rcx
movq 0x30(%rsp), %rax
movslq (%rcx), %rcx
imulq $0x138, %rcx, %rcx      # imm = 0x138
addq %rcx, %rax
cmpl $0x1, 0x5c(%rax)
jne 0x13be5
movss 0xc8(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x59c04(%rip), %xmm1    # 0x6d7d8
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc8(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
callq 0x1f120
movl %eax, 0xec(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movl 0xec(%rsp), %eax
incl %eax
movslq %eax, %rsi
callq 0x1f040
jmp 0x13c1c
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movl (%rax), %eax
movl %eax, 0x28(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movslq 0xec(%rsp), %rsi
callq 0x1f140
movl 0x28(%rsp), %ecx
movl %ecx, (%rax)
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0x2c(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movslq 0xec(%rsp), %rsi
callq 0x1f140
movss 0x2c(%rsp), %xmm0
movss %xmm0, 0x4(%rax)
movss 0xc8(%rsp), %xmm0
movq 0x128(%rsp), %rax
addss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x13afa
jmp 0x13cd0
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x13aa0
movq 0x128(%rsp), %rax
movss 0x4(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x13dea
movq 0x128(%rsp), %rdi
movl 0x148(%rsp), %esi
movq 0x140(%rsp), %rdx
movq 0x138(%rsp), %rcx
callq 0x16ba0
jmp 0x13d25
leaq 0x551bd35(%rip), %rax   # 0x552fa61
testb $0x1, (%rax)
je 0x13de5
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
cmpl 0x148(%rsp), %eax
jge 0x13de3
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x59485(%rip), %xmm0    # 0x6d1f8
movss %xmm0, (%rax)
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movq 0x128(%rsp), %rax
movb (%rax), %dl
movl $0x64, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
cvtsi2ss %eax, %xmm0
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x13d40
jmp 0x13de5
jmp 0x14451
movq $0x0, 0xb8(%rsp)
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, 0x24(%rsp)
movq 0x130(%rsp), %rdi
addq $0x38, %rdi
callq 0x1ef20
movq %rax, %rcx
movl 0x24(%rsp), %eax
cmpl %ecx, %eax
jge 0x13fd8
movq 0x130(%rsp), %rdi
addq $0x38, %rdi
movslq 0xf4(%rsp), %rsi
callq 0x1ef40
movq (%rax), %rax
movq %rax, 0xd8(%rsp)
movq 0x150(%rsp), %rax
movss (%rax), %xmm0
movss %xmm0, 0xac(%rsp)
movq 0x150(%rsp), %rax
movss 0x4(%rax), %xmm0
movss %xmm0, 0xb0(%rsp)
movq 0x150(%rsp), %rax
movss 0x8(%rax), %xmm0
movss %xmm0, 0xb4(%rsp)
movq 0xd8(%rsp), %rsi
movq %rsi, %rdi
addq $0x18, %rdi
leaq 0xac(%rsp), %rdx
callq 0x4a4a0
jmp 0x13eaf
movss 0xac(%rsp), %xmm0
movq 0x150(%rsp), %rax
subss (%rax), %xmm0
movss %xmm0, 0xac(%rsp)
movss 0xb0(%rsp), %xmm0
movq 0x150(%rsp), %rax
subss 0x4(%rax), %xmm0
movss %xmm0, 0xb0(%rsp)
movss 0xb4(%rsp), %xmm0
movq 0x150(%rsp), %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0xb4(%rsp)
movss 0xac(%rsp), %xmm0
mulss 0xac(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0xb0(%rsp), %xmm1
mulss 0xb0(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movss 0xb4(%rsp), %xmm1
mulss 0xb4(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
callq 0x4270
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xa8(%rsp)
cmpq $0x0, 0xb8(%rsp)
je 0x13f9e
movss 0xa8(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movss 0xa4(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x5984c(%rip), %xmm2    # 0x6d7e0
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x13fc0
movq 0xd8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movss 0xa8(%rsp), %xmm0
movss %xmm0, 0xa4(%rsp)
jmp 0x13fc2
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x13e01
cmpq $0x0, 0xb8(%rsp)
je 0x1435a
movq 0xb8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x150(%rsp), %rax
movss (%rax), %xmm0
movq 0xd8(%rsp), %rax
movss 0x38(%rax), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xcc(%rsp)
movq 0x150(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss 0x3c(%rax), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xd0(%rsp)
movq 0x150(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss 0x40(%rax), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xd4(%rsp)
movq 0xd8(%rsp), %rax
movss 0xcc(%rsp), %xmm1
movss 0xd0(%rsp), %xmm0
movss 0x44(%rax), %xmm2
movss 0x48(%rax), %xmm3
mulss %xmm3, %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0xd4(%rsp), %xmm0
movss 0x4c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xa0(%rsp)
movss 0xcc(%rsp), %xmm0
movss 0xa0(%rsp), %xmm1
movq 0xd8(%rsp), %rax
movss 0x44(%rax), %xmm2
mulss %xmm2, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xcc(%rsp)
movss 0xd0(%rsp), %xmm0
movss 0xa0(%rsp), %xmm1
movq 0xd8(%rsp), %rax
movss 0x48(%rax), %xmm2
mulss %xmm2, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xd0(%rsp)
movss 0xd4(%rsp), %xmm0
movss 0xa0(%rsp), %xmm1
movq 0xd8(%rsp), %rax
movss 0x4c(%rax), %xmm2
mulss %xmm2, %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xd4(%rsp)
movq 0xd8(%rsp), %rdi
movq 0x128(%rsp), %rdx
leaq 0xcc(%rsp), %rsi
callq 0x150a0
jmp 0x14169
movq 0x128(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movl %eax, 0x20(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
callq 0x1f120
movq %rax, %rcx
movl 0x20(%rsp), %eax
cmpl %ecx, %eax
jge 0x1426f
leaq 0x53d984a(%rip), %rax   # 0x53eda00
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movq %rax, %rcx
movq 0x18(%rsp), %rax
movslq (%rcx), %rcx
imulq $0x138, %rcx, %rcx      # imm = 0x138
addq %rcx, %rax
cmpl $0x1, 0x5c(%rax)
jne 0x14229
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x595bc(%rip), %xmm1    # 0x6d7d8
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
movslq 0xf0(%rsp), %rsi
callq 0x1f140
movss 0x4(%rax), %xmm0
movq 0x128(%rsp), %rax
addss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x14184
movq 0x128(%rsp), %rdi
movl 0x148(%rsp), %esi
movq 0x140(%rsp), %rdx
movq 0x138(%rsp), %rcx
callq 0x16ba0
jmp 0x14295
leaq 0x551b7c5(%rip), %rax   # 0x552fa61
testb $0x1, (%rax)
je 0x14355
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
cmpl 0x148(%rsp), %eax
jge 0x14353
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x58ef7(%rip), %xmm0    # 0x6d1f8
movss %xmm0, 0x4(%rax)
movq 0x128(%rsp), %rax
movb (%rax), %dl
movl $0x64, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
cvtsi2ss %eax, %xmm0
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x142b0
jmp 0x14355
jmp 0x1444f
movq 0x128(%rsp), %rax
movb $0x1, (%rax)
movq 0x128(%rsp), %rax
movl $0x0, 0x4(%rax)
movq 0x128(%rsp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1f040
jmp 0x1438b
movq 0x128(%rsp), %rdi
movl 0x148(%rsp), %esi
movq 0x140(%rsp), %rdx
movq 0x138(%rsp), %rcx
callq 0x16ba0
jmp 0x143b1
leaq 0x551b6a9(%rip), %rax   # 0x552fa61
testb $0x1, (%rax)
je 0x1444d
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
cmpl 0x148(%rsp), %eax
jge 0x1444b
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movq 0x138(%rsp), %rax
movslq 0xf0(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rax)
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x143cc
jmp 0x1444d
jmp 0x1444f
jmp 0x14451
jmp 0x14453
movq 0x128(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x1447f
movq 0x10(%rsp), %rdi
callq 0x1f180
movq 0x10(%rsp), %rdi
movl $0x20, %esi
callq 0x4330
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movl %eax, 0xc(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x1f0e0
movq %rax, %rcx
movl 0xc(%rsp), %eax
cmpl %ecx, %eax
jge 0x144fb
movslq 0xf4(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x1f100
movq (%rax), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x144e6
movq (%rsp), %rdi
callq 0x1f180
movq (%rsp), %rdi
movl $0x20, %esi
callq 0x4330
jmp 0x144e8
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x1448a
leaq 0xf8(%rsp), %rdi
callq 0x1f1a0
leaq 0x110(%rsp), %rdi
callq 0x1f200
jmp 0x13400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x4200
callq 0x4580
jmp 0x14542
jmp 0x14544
movq 0x98(%rsp), %rdi
callq 0x45c0
movq %rax, %rdi
callq 0x1f2a0
nopl (%rax)