// File: /workspace/github_cpp_makefile_star2_O2/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, 0x18(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, 0x10(%rsp)
movl %esi, %r13d
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
testl %esi, %esi
js 0xc67d
leaq 0x1ba0d8c(%rip), %rax   # 0x1bad404
cmpl %r13d, (%rax)
jg 0xc68b
leaq 0x29030(%rip), %rdi     # 0x356b4
xorl %eax, %eax
callq 0x8b2f
movslq %r13d, %rax
leaq 0x20bc28b(%rip), %rcx   # 0x20c8920
movq (%rcx,%rax,8), %r12
pushq $0x20
popq %rdi
callq 0x42e0
movq %rax, %r14
movq %rax, %rdi
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
andq $0x0, 0x18(%rax)
pushq $0x40
popq %rsi
movq %rdi, 0x28(%rsp)
callq 0x1153a
leaq 0xc0(%rsp), %rdi
xorl %esi, %esi
callq 0x115d0
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x11602
cmpl $0x0, 0x38cca(%rip)     # 0x453b0
movq %r15, 0x58(%rsp)
movq %r12, 0x60(%rsp)
je 0xcaec
xorl %edx, %edx
movl %r13d, 0x24(%rsp)
movq 0x8(%r12), %rax
movq 0x10(%r12), %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rdx
jge 0xcaec
movq %rdx, 0xe0(%rsp)
movslq (%rax,%rdx,4), %rax
leaq 0x20bc1f3(%rip), %rcx   # 0x20c8920
movq (%rcx,%rax,8), %rax
movq %rax, 0x68(%rsp)
xorl %ebx, %ebx
movq 0x68(%rsp), %rcx
movq 0x38(%rcx), %rax
movq 0x40(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jge 0xcadc
movq (%rax,%rbx,8), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movl %r13d, %edx
leaq 0x80(%rsp), %rcx
callq 0xd1ce
testb %al, %al
je 0xc86f
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
leaq 0x44(%rbp), %r13
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
leaq 0xac(%rsp), %rdx
callq 0x1044e
cvtss2sd %xmm0, %xmm0
movsd 0x28dd2(%rip), %xmm1    # 0x35588
ucomisd %xmm0, %xmm1
jae 0xc8a0
movq 0x90(%rbp), %rax
subq 0x88(%rbp), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
testl %eax, %eax
je 0xca74
movslq %eax, %rsi
leaq 0x90(%rsp), %rdi
callq 0x115d0
pushq $0xc
popq %r15
xorl %r12d, %r12d
movq 0x88(%rbp), %rdi
movq 0x90(%rbp), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq %rax, %rcx
movslq %ecx, %rdx
cmpq %rdx, %r12
jge 0xc926
addq %r15, %rdi
leaq 0xac(%rsp), %rsi
movq %r13, %rdx
callq 0x104b7
cvtss2sd %xmm0, %xmm1
addsd 0x28d64(%rip), %xmm1    # 0x355a0
cvtsd2ss %xmm1, %xmm1
movaps %xmm0, %xmm2
cmpltss 0x25824(%rip), %xmm2    # 0x32070
movaps %xmm2, %xmm3
andnps %xmm0, %xmm3
andps %xmm1, %xmm2
orps %xmm3, %xmm2
movq 0x90(%rsp), %rax
movss %xmm2, (%rax,%r12,4)
incq %r12
addq $0x18, %r15
jmp 0xc7f5
leaq 0x54ea1db(%rip), %rax   # 0x54f6a51
cmpb $0x1, (%rax)
jne 0xca8b
cmpq %r12, 0x68(%rsp)
jne 0xca8b
pushq $0x5
popq %rdi
leaq 0x28e65(%rip), %rsi     # 0x356f9
xorl %eax, %eax
callq 0x9045
jmp 0xca8b
movl $0x3f800000, 0xc(%rsp)  # imm = 0x3F800000
leaq 0x90(%rsp), %rdi
callq 0x12ef2
movl 0x24(%rsp), %r13d
pushq $0x20
popq %rdi
callq 0x42e0
movq %rax, %rdi
addq $0x8, %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
andq $0x0, 0x18(%rax)
movq %rax, 0xb8(%rsp)
pushq $0x4
popq %rsi
callq 0x1153a
movq 0xb8(%rsp), %rdx
movq %rbp, %rdi
leaq 0x80(%rsp), %rsi
callq 0xd440
leaq 0xc0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x11634
leaq 0x30(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x11654
jmp 0xca8b
xorl %r9d, %r9d
movq 0x90(%rsp), %rsi
pushq $0x1
popq %r8
movslq %r9d, %rax
cmpq %rdx, %r8
jge 0xc957
movss (%rsi,%rax,4), %xmm0
ucomiss (%rsi,%r8,4), %xmm0
movl %r8d, %eax
ja 0xc94f
movl %r9d, %eax
incq %r8
movl %eax, %r9d
jmp 0xc935
imulq $0x18, %rax, %r15
addq %rdi, %r15
incl %eax
cltd
idivl %ecx
movslq %edx, %rax
imulq $0x18, %rax, %r12
addq %rdi, %r12
movq %r15, %rdi
movq %r12, %rsi
leaq 0xac(%rsp), %rdx
movq %r13, %rcx
callq 0x1053c
movss 0x256d9(%rip), %xmm7    # 0x32064
movaps %xmm7, %xmm4
subss %xmm0, %xmm4
movss 0xac(%rsp), %xmm2
movss 0xb0(%rsp), %xmm3
movss 0x4(%r15), %xmm1
mulss %xmm3, %xmm1
movss (%r15), %xmm5
mulss %xmm2, %xmm5
addss %xmm1, %xmm5
movss 0xb4(%rsp), %xmm1
movss 0x8(%r15), %xmm6
mulss %xmm1, %xmm6
addss %xmm5, %xmm6
mulss %xmm4, %xmm6
movss 0x4(%r12), %xmm4
mulss %xmm3, %xmm4
movss (%r12), %xmm5
mulss %xmm2, %xmm5
addss %xmm4, %xmm5
movss 0x8(%r12), %xmm4
mulss %xmm1, %xmm4
addss %xmm5, %xmm4
mulss %xmm0, %xmm4
addss %xmm6, %xmm4
cvtss2sd %xmm4, %xmm0
movsd 0x28b7e(%rip), %xmm5    # 0x35590
ucomisd %xmm0, %xmm5
movl 0x24(%rsp), %r13d
jae 0xca56
mulss 0x84(%rsp), %xmm3
mulss 0x80(%rsp), %xmm2
addss %xmm3, %xmm2
mulss 0x88(%rsp), %xmm1
addss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm2
movapd %xmm0, %xmm3
addsd 0x28b38(%rip), %xmm3    # 0x35588
ucomisd %xmm3, %xmm2
jbe 0xca93
andl $0x0, 0xc(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x12ef2
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %r12
jmp 0xca8b
andl $0x0, 0xc(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x12ef2
movl 0x24(%rsp), %r13d
incq %rbx
jmp 0xc738
addsd 0x28afd(%rip), %xmm0    # 0x35598
ucomisd %xmm0, %xmm2
movaps %xmm7, %xmm0
jae 0xcab3
divss %xmm4, %xmm1
minss %xmm7, %xmm1
xorps %xmm0, %xmm0
maxss %xmm1, %xmm0
movaps %xmm7, %xmm1
subss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x12ef2
movq 0x58(%rsp), %r15
movq 0x60(%rsp), %r12
jmp 0xc8ba
movq 0xe0(%rsp), %rdx
incq %rdx
jmp 0xc6fd
movb $0x0, (%r14)
andl $0x0, 0x4(%r14)
movq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x11672
movabsq $0x100000000, %rbx      # imm = 0x100000000
movq 0x30(%rsp), %rax
xorl %r12d, %r12d
leaq 0x53a7ed6(%rip), %r15   # 0x53b49f0
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r12
jge 0xcc12
movq (%rax,%r12,8), %rcx
cmpb $0x1, (%rcx)
jne 0xcb3f
movb $0x1, (%r14)
xorl %r13d, %r13d
movq (%rax,%r12,8), %rdx
movq 0x8(%rdx), %rcx
movq 0x10(%rdx), %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0xcc0a
movss 0x4(%rcx,%r13,8), %xmm0
movq 0xc0(%rsp), %rax
mulss (%rax,%r12,4), %xmm0
movss %xmm0, 0xc(%rsp)
movq (%r15), %rax
movslq (%rcx,%r13,8), %rcx
imulq $0x138, %rcx, %rcx      # imm = 0x138
cmpl $0x1, 0x5c(%rax,%rcx)
jne 0xcba7
cvtss2sd %xmm0, %xmm0
mulsd 0x289f3(%rip), %xmm0    # 0x35590
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 0x28(%rsp), %rdi
callq 0x11672
movq 0x30(%rsp), %rax
movq (%rax,%r12,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)
addss 0x4(%r14), %xmm0
movss %xmm0, 0x4(%r14)
incq %r13
movq 0x30(%rsp), %rax
jmp 0xcb42
incq %r12
jmp 0xcb1a
movss 0x4(%r14), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xcc92
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xddbd
leaq 0x54e9e13(%rip), %rax   # 0x54f6a51
cmpb $0x1, (%rax)
movq 0x18(%rsp), %rdx
jne 0xd0a6
xorl %eax, %eax
movq 0x10(%rsp), %rcx
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0xc, %rcx, %rcx
movsd 0x289ec(%rip), %xmm0    # 0x35650
movss 0x2846c(%rip), %xmm1    # 0x350d8
cmpq %rax, %rcx
je 0xd0a6
movsd %xmm0, (%rdx,%rax)
cmpb $0x0, (%r14)
xorps %xmm2, %xmm2
jne 0xcc86
movaps %xmm1, %xmm2
movss %xmm2, 0x8(%rdx,%rax)
addq $0xc, %rax
jmp 0xcc6c
movb $0x0, (%r14)
andl $0x0, 0x4(%r14)
movq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x11672
movq 0x30(%rsp), %rax
xorl %r12d, %r12d
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r12
jge 0xcd99
movq (%rax,%r12,8), %rcx
cmpb $0x1, (%rcx)
jne 0xccd4
movb $0x1, (%r14)
xorl %r13d, %r13d
movq (%rax,%r12,8), %rdx
movq 0x8(%rdx), %rcx
movq 0x10(%rdx), %rdx
subq %rcx, %rdx
shrq $0x3, %rdx
movslq %edx, %rdx
cmpq %rdx, %r13
jge 0xcd91
movss 0x4(%rcx,%r13,8), %xmm0
movss %xmm0, 0xc(%rsp)
movq (%r15), %rax
movslq (%rcx,%r13,8), %rcx
imulq $0x138, %rcx, %rcx      # imm = 0x138
cmpl $0x1, 0x5c(%rax,%rcx)
jne 0xcd2e
cvtss2sd %xmm0, %xmm0
mulsd 0x2886c(%rip), %xmm0    # 0x35590
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 0x28(%rsp), %rdi
callq 0x11672
movq 0x30(%rsp), %rax
movq (%rax,%r12,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)
addss 0x4(%r14), %xmm0
movss %xmm0, 0x4(%r14)
incq %r13
movq 0x30(%rsp), %rax
jmp 0xccd7
incq %r12
jmp 0xccaf
movss 0x4(%r14), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0xce18
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xddbd
leaq 0x54e9c8c(%rip), %rax   # 0x54f6a51
cmpb $0x1, (%rax)
movq 0x18(%rsp), %rdx
jne 0xd0a6
xorl %eax, %eax
movq 0x10(%rsp), %rcx
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0xc, %rcx, %rcx
movss 0x282ed(%rip), %xmm0    # 0x350d8
movss 0x282e5(%rip), %xmm1    # 0x350d8
cmpq %rax, %rcx
je 0xd0a6
movlps %xmm0, (%rdx,%rax)
cmpb $0x0, (%r14)
xorps %xmm2, %xmm2
jne 0xce0c
movaps %xmm1, %xmm2
movss %xmm2, 0x8(%rdx,%rax)
addq $0xc, %rax
jmp 0xcdf3
xorl %ebp, %ebp
xorl %ebx, %ebx
movq 0x60(%rsp), %rcx
movq 0x58(%rsp), %r12
movq 0x38(%rcx), %rax
movq 0x40(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbp
jge 0xcef0
movq (%rax,%rbp,8), %r13
movsd (%r12), %xmm0
movsd %xmm0, 0x70(%rsp)
movss 0x8(%r12), %xmm0
movss %xmm0, 0x78(%rsp)
leaq 0x18(%r13), %rdi
movq %r13, %rsi
leaq 0x70(%rsp), %rdx
callq 0x21a7f
movsd 0x70(%rsp), %xmm0
movsd (%r12), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, 0x70(%rsp)
movss 0x78(%rsp), %xmm1
subss 0x8(%r12), %xmm1
movss %xmm1, 0x78(%rsp)
mulps %xmm0, %xmm0
cvtss2sd %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm0
addsd %xmm2, %xmm0
mulss %xmm1, %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm0, %xmm1
sqrtsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
testq %rbx, %rbx
je 0xceda
cvtss2sd %xmm0, %xmm1
cvtss2sd 0x68(%rsp), %xmm2
addsd 0x286c4(%rip), %xmm2    # 0x35598
ucomisd %xmm1, %xmm2
jbe 0xcee3
movq %r13, %rbx
movss %xmm0, 0x68(%rsp)
incq %rbp
movq 0x60(%rsp), %rcx
jmp 0xce26
testq %rbx, %rbx
je 0xd044
movq 0x58(%rsp), %rax
movss 0x8(%rax), %xmm0
subss 0x40(%rbx), %xmm0
movss 0x4c(%rbx), %xmm1
movsd (%rax), %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 0x80(%rsp), %rsi
movlps %xmm2, (%rsi)
mulss %xmm1, %xmm4
subss %xmm4, %xmm0
movss %xmm0, 0x8(%rsi)
movq %rbx, %rdi
movq %r14, %rdx
callq 0xd440
andl $0x0, 0x4(%r14)
movq 0x8(%r14), %rax
xorps %xmm0, %xmm0
xorl %ecx, %ecx
movq 0x10(%r14), %rdx
subq %rax, %rdx
shrq $0x3, %rdx
movslq %edx, %rdx
cmpq %rdx, %rcx
jge 0xcfd6
movq (%r15), %rdx
movslq (%rax,%rcx,8), %rsi
imulq $0x138, %rsi, %rsi      # imm = 0x138
cmpl $0x1, 0x5c(%rdx,%rsi)
jne 0xcfc5
cvtss2sd 0x4(%rax,%rcx,8), %xmm0
mulsd 0x285df(%rip), %xmm0    # 0x35590
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rax,%rcx,8)
movq 0x8(%r14), %rax
movss 0x4(%r14), %xmm0
addss 0x4(%rax,%rcx,8), %xmm0
movss %xmm0, 0x4(%r14)
incq %rcx
jmp 0xcf7b
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xddbd
leaq 0x54e9a5d(%rip), %rax   # 0x54f6a51
cmpb $0x1, (%rax)
movq 0x18(%rsp), %rdx
jne 0xd0a6
xorl %eax, %eax
movq 0x10(%rsp), %rcx
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0xc, %rcx, %rcx
movsd 0x28626(%rip), %xmm0    # 0x35640
movss 0x280b6(%rip), %xmm1    # 0x350d8
cmpq %rax, %rcx
je 0xd0a6
movsd %xmm0, (%rdx,%rax)
cmpb $0x0, (%r14)
xorps %xmm2, %xmm2
jne 0xd038
movaps %xmm1, %xmm2
movss %xmm2, 0x8(%rdx,%rax)
addq $0xc, %rax
jmp 0xd022
movb $0x1, (%r14)
andl $0x0, 0x4(%r14)
movq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x11672
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0xddbd
leaq 0x54e99da(%rip), %rax   # 0x54f6a51
cmpb $0x1, (%rax)
movq 0x18(%rsp), %rdx
jne 0xd0a6
xorl %eax, %eax
movq 0x10(%rsp), %rcx
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0xc, %rcx, %rcx
cmpq %rax, %rcx
je 0xd0a6
andq $0x0, (%rdx,%rax)
andl $0x0, 0x8(%rdx,%rax)
addq $0xc, %rax
jmp 0xd091
movq 0x28(%rsp), %rdi
callq 0x1172a
pushq $0x20
popq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x42f0
xorl %r15d, %r15d
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jge 0xd0fc
movq (%rax,%r15,8), %r14
testq %r14, %r14
je 0xd0ec
leaq 0x8(%r14), %rdi
callq 0x1172a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x42f0
incq %r15
jmp 0xd0c1
leaq 0x30(%rsp), %rdi
callq 0x1329c
leaq 0xc0(%rsp), %rdi
callq 0x12ef2
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xd142
jmp 0xd142
movq %rdx, %r14
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x12ef2
jmp 0xd148
jmp 0xd142
jmp 0xd142
movq %rdx, %r14
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x1329c
leaq 0xc0(%rsp), %rdi
callq 0x12ef2
cmpl $0x1, %r14d
jne 0xd1be
movq %rbx, %rdi
callq 0x43d0
movq 0x36e1c(%rip), %rax     # 0x43f90
addq $0x10, %rax
movq %rax, 0x90(%rsp)
movq %rbx, %rdi
callq 0x4140
pushq $0x1
popq %rsi
xorl %edi, %edi
callq 0x92cb
leaq 0x90(%rsp), %rdi
callq 0x41d0
callq 0x4570
jmp 0xd113
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x41d0
callq 0x4570
movq %rbx, %rdi
callq 0x45a0
movq %rax, %rdi
callq 0x116a3