// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlrad/lerp.cpp
// Function: CalcInterpolation(localtriangulation_t const*, float const*, interpolation_t*)
static void CalcInterpolation (const localtriangulation_t *lt, const vec3_t spot, interpolation_t *interp)
	// The interpolation function is defined over the entire plane, so CalcInterpolation never fails.
{
	vec3_t direction;
	const localtriangulation_t::Wedge *w;
	const localtriangulation_t::Wedge *wnext;

	int i;
	int j;
	vec_t angle;
	std::vector< vec_t > angles;

	if (GetDirection (spot, lt->normal, direction) <= 2 * ON_EPSILON)
	{
		// spot happens to be at the center
		interp->isbiased = false;
		interp->totalweight = 1.0;
		interp->points.resize (1);
		interp->points[0].patchnum = lt->patchnum;
		interp->points[0].weight = 1.0;
		return;
	}

	if ((int)lt->sortedwedges.size () == 0) // this local triangulation only has center patch
	{
		interp->isbiased = true;
		interp->totalweight = 1.0;
		interp->points.resize (1);
		interp->points[0].patchnum = lt->patchnum;
		interp->points[0].weight = 1.0;
		return;
	}
	
	// Find the wedge with minimum non-negative angle (counterclockwise) pass the spot
	angles.resize ((int)lt->sortedwedges.size ());
	for (i = 0; i < (int)lt->sortedwedges.size (); i++)
	{
		angle = GetAngle (lt->sortedwedges[i].leftdirection, direction, lt->normal);
		angles[i] = GetAngleDiff (angle, 0);
	}
	j = 0;
	for (i = 1; i < (int)lt->sortedwedges.size (); i++)
	{
		if (angles[i] < angles[j])
		{
			j = i;
		}
	}
	w = &lt->sortedwedges[j];
	wnext = &lt->sortedwedges[(j + 1) % (int)lt->sortedwedges.size ()];

	// Different wedge types have different interpolation methods
	switch (w->shape)
	{
#ifdef HLRAD_BILINEARINTERPOLATION
	case localtriangulation_t::Wedge::eSquareLeft:
	case localtriangulation_t::Wedge::eSquareRight:
#endif
	case localtriangulation_t::Wedge::eTriangular:
		// w->wedgenormal is undefined
		{
			vec_t frac;
			vec_t len;
			vec_t dist;
			bool istoofar;
			vec_t ratio;

			frac = GetFrac (w->leftspot, wnext->leftspot, direction, lt->normal);
			
			len = (1 - frac) * DotProduct (w->leftspot, direction) + frac * DotProduct (wnext->leftspot, direction);
			dist = DotProduct (spot, direction);
			if (len <= ON_EPSILON / 4 || dist > len + 2 * ON_EPSILON)
			{
				istoofar = true;
				ratio = 1.0;
			}
			else if (dist >= len - ON_EPSILON)
			{
				istoofar = false;
				ratio = 1.0;
			}
			else
			{
				istoofar = false;
				ratio = dist / len;
				ratio = qmax (0, qmin (ratio, 1));
			}

			if (istoofar)
			{
				interp->isbiased = true;
				interp->totalweight = 1.0;
				interp->points.resize (2);
				interp->points[0].patchnum = w->leftpatchnum;
				interp->points[0].weight = 1 - frac;
				interp->points[1].patchnum = wnext->leftpatchnum;
				interp->points[1].weight = frac;
			}
#ifdef HLRAD_BILINEARINTERPOLATION
			else if (w->shape == localtriangulation_t::Wedge::eSquareLeft)
			{
				i = w - &lt->sortedwedges[0];
				CalcInterpolation_Square (lt, i, spot, interp);
			}
			else if (w->shape == localtriangulation_t::Wedge::eSquareRight)
			{
				i = w - &lt->sortedwedges[0];
				i = (i - 1 + (int)lt->sortedwedges.size ()) % (int)lt->sortedwedges.size ();
				CalcInterpolation_Square (lt, i, spot, interp);
			}
#endif
			else
			{
				interp->isbiased = false;
				interp->totalweight = 1.0;
				interp->points.resize (3);
				interp->points[0].patchnum = lt->patchnum;
				interp->points[0].weight = 1 - ratio;
				interp->points[1].patchnum = w->leftpatchnum;
				interp->points[1].weight = ratio * (1 - frac);
				interp->points[2].patchnum = wnext->leftpatchnum;
				interp->points[2].weight = ratio * frac;
			}
		}
		break;
	case localtriangulation_t::Wedge::eConvex:
		// w->wedgenormal is the unit vector pointing from w->leftspot to wnext->leftspot
		{
			vec_t dot;
			vec_t dot1;
			vec_t dot2;
			vec_t frac;

			dot1 = DotProduct (w->leftspot, w->wedgenormal) - DotProduct (spot, w->wedgenormal);
			dot2 = DotProduct (wnext->leftspot, w->wedgenormal) - DotProduct (spot, w->wedgenormal);
			dot = 0 - DotProduct (spot, w->wedgenormal);
			// for eConvex type: dot1 < dot < dot2

			if (g_drawlerp && (dot1 > dot || dot > dot2))
			{
				Developer (DEVELOPER_LEVEL_SPAM, "Debug: triangulation: internal error 3.\n");
			}
			if (dot1 >= -NORMAL_EPSILON) // 0 <= dot1 < dot < dot2
			{
				interp->isbiased = true;
				interp->totalweight = 1.0;
				interp->points.resize (1);
				interp->points[0].patchnum = w->leftpatchnum;
				interp->points[0].weight = 1.0;
			}
			else if (dot2 <= NORMAL_EPSILON) // dot1 < dot < dot2 <= 0
			{
				interp->isbiased = true;
				interp->totalweight = 1.0;
				interp->points.resize (1);
				interp->points[0].patchnum = wnext->leftpatchnum;
				interp->points[0].weight = 1.0;
			}
			else if (dot > 0) // dot1 < 0 < dot < dot2
			{
				frac = dot1 / (dot1 - dot);
				frac = qmax (0, qmin (frac, 1));

				interp->isbiased = true;
				interp->totalweight = 1.0;
				interp->points.resize (2);
				interp->points[0].patchnum = w->leftpatchnum;
				interp->points[0].weight = 1 - frac;
				interp->points[1].patchnum = lt->patchnum;
				interp->points[1].weight = frac;
			}
			else // dot1 < dot <= 0 < dot2
			{
				frac = dot / (dot - dot2);
				frac = qmax (0, qmin (frac, 1));
			
				interp->isbiased = true;
				interp->totalweight = 1.0;
				interp->points.resize (2);
				interp->points[0].patchnum = lt->patchnum;
				interp->points[0].weight = 1 - frac;
				interp->points[1].patchnum = wnext->leftpatchnum;
				interp->points[1].weight = frac;
			}
		}
		break;
	case localtriangulation_t::Wedge::eConcave:
		{
			vec_t len;
			vec_t dist;
			vec_t ratio;

			if (DotProduct (spot, w->wedgenormal) < 0) // the spot is closer to the left edge than the right edge
			{
				len = DotProduct (w->leftspot, w->leftdirection);
				dist = DotProduct (spot, w->leftdirection);
				if (g_drawlerp && len <= ON_EPSILON)
				{
					Developer (DEVELOPER_LEVEL_SPAM, "Debug: triangulation: internal error 4.\n");
				}
				if (dist <= NORMAL_EPSILON)
				{
					interp->isbiased = true;
					interp->totalweight = 1.0;
					interp->points.resize (1);
					interp->points[0].patchnum = lt->patchnum;
					interp->points[0].weight = 1.0;
				}
				else if (dist >= len)
				{
					interp->isbiased = true;
					interp->totalweight = 1.0;
					interp->points.resize (1);
					interp->points[0].patchnum = w->leftpatchnum;
					interp->points[0].weight = 1.0;
				}
				else
				{
					ratio = dist / len;
					ratio = qmax (0, qmin (ratio, 1));

					interp->isbiased = true;
					interp->totalweight = 1.0;
					interp->points.resize (2);
					interp->points[0].patchnum = lt->patchnum;
					interp->points[0].weight = 1 - ratio;
					interp->points[1].patchnum = w->leftpatchnum;
					interp->points[1].weight = ratio;
				}
			}
			else // the spot is closer to the right edge than the left edge
			{
				len = DotProduct (wnext->leftspot, wnext->leftdirection);
				dist = DotProduct (spot, wnext->leftdirection);
				if (g_drawlerp && len <= ON_EPSILON)
				{
					Developer (DEVELOPER_LEVEL_SPAM, "Debug: triangulation: internal error 5.\n");
				}
				if (dist <= NORMAL_EPSILON)
				{
					interp->isbiased = true;
					interp->totalweight = 1.0;
					interp->points.resize (1);
					interp->points[0].patchnum = lt->patchnum;
					interp->points[0].weight = 1.0;
				}
				else if (dist >= len)
				{
					interp->isbiased = true;
					interp->totalweight = 1.0;
					interp->points.resize (1);
					interp->points[0].patchnum = wnext->leftpatchnum;
					interp->points[0].weight = 1.0;
				}
				else
				{
					ratio = dist / len;
					ratio = qmax (0, qmin (ratio, 1));

					interp->isbiased = true;
					interp->totalweight = 1.0;
					interp->points.resize (2);
					interp->points[0].patchnum = lt->patchnum;
					interp->points[0].weight = 1 - ratio;
					interp->points[1].patchnum = wnext->leftpatchnum;
					interp->points[1].weight = ratio;
				}
			}
		}
		break;
	default:
		Error ("CalcInterpolation: internal error: invalid wedge type.");
		break;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
leaq 0x44(%rdi), %r12
leaq 0x34(%rsp), %rdx
movq %rsi, %rdi
movq %r12, %rsi
callq 0x12b85
cvtss2sd %xmm0, %xmm0
movsd 0x2c526(%rip), %xmm1    # 0x3b628
ucomisd %xmm0, %xmm1
jae 0xf3a3
movq 0x78(%r14), %rax
subq 0x70(%r14), %rax
sarq $0x2, %rax
movabsq $0x2e8ba2e8ba2e8ba3, %rbp # imm = 0x2E8BA2E8BA2E8BA3
imulq %rbp, %rax
testl %eax, %eax
je 0xf3c0
movslq %eax, %rsi
leaq 0x40(%rsp), %rdi
callq 0x14086
movq 0x70(%r14), %rdi
movq 0x78(%r14), %rax
subq %rdi, %rax
shrq $0x2, %rax
imull $0xba2e8ba3, %eax, %ecx # imm = 0xBA2E8BA3
testl %ecx, %ecx
jle 0xf1de
movq %r15, 0x20(%rsp)
movq %rbx, 0x10(%rsp)
movl $0x14, %r15d
xorl %ebx, %ebx
leaq 0x34(%rsp), %r13
addq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x12c6c
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
addsd 0x2c4a4(%rip), %xmm1    # 0x3b630
cvtsd2ss %xmm1, %xmm1
movaps %xmm0, %xmm2
cmpltss 0x28fa8(%rip), %xmm2    # 0x38144
movaps %xmm2, %xmm3
andnps %xmm0, %xmm3
andps %xmm1, %xmm2
orps %xmm3, %xmm2
movq 0x40(%rsp), %rax
movss %xmm2, (%rax,%rbx,4)
incq %rbx
movq 0x70(%r14), %rdi
movq 0x78(%r14), %rcx
subq %rdi, %rcx
sarq $0x2, %rcx
imulq %rbp, %rcx
movslq %ecx, %rax
addq $0x2c, %r15
cmpq %rax, %rbx
jl 0xf16f
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r15
xorl %r8d, %r8d
cmpl $0x2, %ecx
jl 0xf215
movq 0x40(%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 0xf20a
movl %r9d, %r8d
incq %rsi
movl %r8d, %r9d
cmpq %rsi, %rdx
jne 0xf1f5
movslq %r8d, %rax
imulq $0x2c, %rax, %r13
incl %eax
cltd
idivl %ecx
movl (%rdi,%r13), %eax
cmpq $0x4, %rax
ja 0xf745
addq %rdi, %r13
movslq %edx, %rcx
imulq $0x2c, %rcx, %rbp
addq %rdi, %rbp
leaq 0x2c51d(%rip), %rcx     # 0x3b760
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8(%r13), %rdi
leaq 0x8(%rbp), %rsi
leaq 0x34(%rsp), %rdx
movq %r12, %rcx
callq 0x12cf1
movss 0x28ece(%rip), %xmm8    # 0x38138
movaps %xmm8, %xmm7
subss %xmm0, %xmm7
movss 0x34(%rsp), %xmm2
movss 0x38(%rsp), %xmm3
movss 0xc(%r13), %xmm1
mulss %xmm3, %xmm1
movss 0x8(%r13), %xmm4
mulss %xmm2, %xmm4
addss %xmm1, %xmm4
movss 0x3c(%rsp), %xmm6
movss 0x10(%r13), %xmm1
mulss %xmm6, %xmm1
addss %xmm4, %xmm1
movss 0xc(%rbp), %xmm4
mulss %xmm3, %xmm4
movss 0x8(%rbp), %xmm5
mulss %xmm2, %xmm5
addss %xmm4, %xmm5
movss 0x10(%rbp), %xmm4
mulss %xmm6, %xmm4
addss %xmm5, %xmm4
mulss %xmm0, %xmm4
mulss %xmm7, %xmm1
addss %xmm4, %xmm1
xorps %xmm4, %xmm4
cvtss2sd %xmm1, %xmm4
movb $0x1, %al
movsd 0x2c34e(%rip), %xmm5    # 0x3b638
ucomisd %xmm4, %xmm5
jae 0xf347
mulss 0x4(%r15), %xmm3
mulss (%r15), %xmm2
addss %xmm3, %xmm2
mulss 0x8(%r15), %xmm6
addss %xmm2, %xmm6
xorps %xmm2, %xmm2
cvtss2sd %xmm6, %xmm2
movsd 0x2c310(%rip), %xmm3    # 0x3b628
addsd %xmm4, %xmm3
ucomisd %xmm3, %xmm2
ja 0xf347
addsd 0x2c316(%rip), %xmm4    # 0x3b640
ucomisd %xmm4, %xmm2
jae 0xf345
divss %xmm1, %xmm6
minss 0x28dfc(%rip), %xmm6    # 0x38138
xorps %xmm8, %xmm8
maxss %xmm6, %xmm8
xorl %eax, %eax
testb %al, %al
je 0xf41f
movss %xmm7, 0x20(%rsp)
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x2, %esi
movq %rbx, %rdi
movss %xmm0, 0x10(%rsp)
callq 0x140ea
movss 0x10(%rsp), %xmm1
movl 0x4(%r13), %eax
movq (%rbx), %rcx
movl %eax, (%rcx)
movq (%rbx), %rax
movss 0x20(%rsp), %xmm0
movss %xmm0, 0x4(%rax)
movl 0x4(%rbp), %eax
movq (%rbx), %rcx
movl %eax, 0x8(%rcx)
movl $0xc, %eax
jmp 0xf3f1
movb $0x0, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x1, %esi
movq %rbx, %rdi
callq 0x140ea
jmp 0xf3db
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x1, %esi
movq %rbx, %rdi
callq 0x140ea
movl 0x50(%r14), %eax
movq (%rbx), %rcx
movl %eax, (%rcx)
movss 0x28d4c(%rip), %xmm1    # 0x38138
movl $0x4, %eax
movq (%rbx), %rcx
movss %xmm1, (%rcx,%rax)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xf410
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%r13), %eax
cmpl $0x4, %eax
je 0xf876
cmpl $0x3, %eax
jne 0xf8b6
subq 0x70(%r14), %r13
shrq $0x2, %r13
imull $0xba2e8ba3, %r13d, %esi # imm = 0xBA2E8BA3
jmp 0xf8a3
movss (%r15), %xmm2
movss 0x4(%r15), %xmm1
movss 0x24(%r13), %xmm0
movss %xmm1, 0xc(%rsp)
mulss %xmm1, %xmm0
movss 0x20(%r13), %xmm1
movss %xmm2, 0x20(%rsp)
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x8(%r15), %xmm2
movss 0x28(%r13), %xmm0
movss %xmm2, 0x10(%rsp)
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
leaq 0x54eb5a2(%rip), %rax   # 0x54faa41
movb (%rax), %al
jbe 0xf758
movss 0x14(%r13), %xmm2
movss 0x18(%r13), %xmm1
movss 0xc(%r13), %xmm0
movss %xmm1, 0x2c(%rsp)
mulss %xmm1, %xmm0
movss 0x8(%r13), %xmm1
movss %xmm2, 0x30(%rsp)
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x1c(%r13), %xmm2
movss 0x10(%r13), %xmm0
movss %xmm2, 0x28(%rsp)
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x1c(%rsp)
testb %al, %al
je 0xf525
xorps %xmm0, %xmm0
cvtss2sd 0x1c(%rsp), %xmm0
movsd 0x2c13c(%rip), %xmm1    # 0x3b648
ucomisd %xmm0, %xmm1
jb 0xf525
leaq 0x2c344(%rip), %rsi     # 0x3b85d
movl $0x5, %edi
xorl %eax, %eax
callq 0xa52e
movss 0xc(%rsp), %xmm1
mulss 0x2c(%rsp), %xmm1
movss 0x20(%rsp), %xmm0
mulss 0x30(%rsp), %xmm0
addss %xmm1, %xmm0
movss 0x10(%rsp), %xmm2
mulss 0x28(%rsp), %xmm2
addss %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
movsd 0x28bb0(%rip), %xmm1    # 0x38110
ucomisd %xmm0, %xmm1
jae 0xf963
leaq 0x8(%rbx), %r15
movss %xmm2, 0x10(%rsp)
ucomiss 0x1c(%rsp), %xmm2
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
jae 0xf9fc
movl $0x2, %esi
movq %r15, %rdi
callq 0x140ea
movss 0x10(%rsp), %xmm2
divss 0x1c(%rsp), %xmm2
movss 0x28b8e(%rip), %xmm0    # 0x38138
minss %xmm0, %xmm2
xorpd %xmm1, %xmm1
maxss %xmm2, %xmm1
movl 0x50(%r14), %eax
movq (%r15), %rcx
movl %eax, (%rcx)
subss %xmm1, %xmm0
movq (%r15), %rax
movss %xmm0, 0x4(%rax)
movl 0x4(%r13), %eax
jmp 0xf9ef
movss 0x20(%r13), %xmm0
movss 0x24(%r13), %xmm1
movss 0xc(%r13), %xmm2
mulss %xmm1, %xmm2
movss 0x8(%r13), %xmm3
mulss %xmm0, %xmm3
addss %xmm2, %xmm3
movss 0x28(%r13), %xmm4
movss 0x10(%r13), %xmm5
mulss %xmm4, %xmm5
addss %xmm3, %xmm5
movss 0x4(%r15), %xmm2
mulss %xmm1, %xmm2
movss (%r15), %xmm3
mulss %xmm0, %xmm3
addss %xmm2, %xmm3
movss 0x8(%r15), %xmm2
mulss %xmm4, %xmm2
addss %xmm3, %xmm2
subss %xmm2, %xmm5
movss %xmm5, 0x10(%rsp)
mulss 0xc(%rbp), %xmm1
mulss 0x8(%rbp), %xmm0
mulss 0x10(%rbp), %xmm4
addss %xmm1, %xmm0
addss %xmm0, %xmm4
subss %xmm2, %xmm4
movss %xmm4, 0xc(%rsp)
xorps %xmm0, %xmm0
subss %xmm2, %xmm0
movss %xmm0, 0x20(%rsp)
leaq 0x54eb3d1(%rip), %rax   # 0x54faa41
cmpb $0x1, (%rax)
jne 0xf6a2
movss 0x10(%rsp), %xmm0
ucomiss 0x20(%rsp), %xmm0
ja 0xf68f
movss 0x20(%rsp), %xmm0
ucomiss 0xc(%rsp), %xmm0
jbe 0xf6a2
leaq 0x2c19e(%rip), %rsi     # 0x3b834
movl $0x5, %edi
xorl %eax, %eax
callq 0xa52e
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
ucomisd 0x2bf9d(%rip), %xmm0    # 0x3b650
jae 0xf852
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
movsd 0x28a46(%rip), %xmm1    # 0x38110
ucomisd %xmm0, %xmm1
jae 0xf940
leaq 0x8(%rbx), %r15
xorps %xmm0, %xmm0
movss 0x20(%rsp), %xmm1
ucomiss %xmm0, %xmm1
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
jbe 0xf9a3
movl $0x2, %esi
movq %r15, %rdi
callq 0x140ea
movss 0x10(%rsp), %xmm2
movaps %xmm2, %xmm0
subss 0x20(%rsp), %xmm0
divss %xmm0, %xmm2
movss 0x28a1c(%rip), %xmm0    # 0x38138
minss %xmm0, %xmm2
xorps %xmm1, %xmm1
maxss %xmm2, %xmm1
movl 0x4(%r13), %eax
movq (%r15), %rcx
movl %eax, (%rcx)
subss %xmm1, %xmm0
movq (%r15), %rax
movss %xmm0, 0x4(%rax)
movl 0x50(%r14), %eax
jmp 0xf9ef
leaq 0x2c163(%rip), %rdi     # 0x3b8af
xorl %eax, %eax
callq 0xa01c
jmp 0xf3f9
movss 0x14(%rbp), %xmm2
movss 0x18(%rbp), %xmm1
movss 0xc(%rbp), %xmm0
movss %xmm1, 0x2c(%rsp)
mulss %xmm1, %xmm0
movss 0x8(%rbp), %xmm1
movss %xmm2, 0x30(%rsp)
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x1c(%rbp), %xmm2
movss 0x10(%rbp), %xmm0
movss %xmm2, 0x28(%rsp)
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x1c(%rsp)
testb %al, %al
je 0xf7d0
xorps %xmm0, %xmm0
cvtss2sd 0x1c(%rsp), %xmm0
movsd 0x2be91(%rip), %xmm1    # 0x3b648
ucomisd %xmm0, %xmm1
jb 0xf7d0
leaq 0x2c0c2(%rip), %rsi     # 0x3b886
movl $0x5, %edi
xorl %eax, %eax
callq 0xa52e
movss 0xc(%rsp), %xmm1
mulss 0x2c(%rsp), %xmm1
movss 0x20(%rsp), %xmm0
mulss 0x30(%rsp), %xmm0
addss %xmm1, %xmm0
movss 0x10(%rsp), %xmm2
mulss 0x28(%rsp), %xmm2
addss %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
movsd 0x28905(%rip), %xmm1    # 0x38110
ucomisd %xmm0, %xmm1
jae 0xf983
leaq 0x8(%rbx), %r15
movss %xmm2, 0x10(%rsp)
ucomiss 0x1c(%rsp), %xmm2
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
jae 0xfa0f
movl $0x2, %esi
movq %r15, %rdi
callq 0x140ea
movss 0x10(%rsp), %xmm2
divss 0x1c(%rsp), %xmm2
jmp 0xf9c3
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x1, %esi
movq %rbx, %rdi
callq 0x140ea
movl 0x4(%r13), %eax
jmp 0xf3df
movq 0x70(%r14), %rax
movq 0x78(%r14), %rcx
subq %rax, %r13
shrq $0x2, %r13
imull $0xba2e8ba3, %r13d, %edx # imm = 0xBA2E8BA3
subq %rax, %rcx
shrq $0x2, %rcx
imull $0xba2e8ba3, %ecx, %ecx # imm = 0xBA2E8BA3
leal (%rdx,%rcx), %eax
decl %eax
cltd
idivl %ecx
movl %edx, %esi
movq %r14, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x12e1f
jmp 0xf3f9
movss %xmm8, 0xc(%rsp)
movss %xmm7, 0x20(%rsp)
movb $0x0, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x3, %esi
movq %rbx, %rdi
movss %xmm0, 0x10(%rsp)
callq 0x140ea
movss 0x10(%rsp), %xmm1
movl 0x50(%r14), %eax
movq (%rbx), %rcx
movl %eax, (%rcx)
movss 0x2883d(%rip), %xmm0    # 0x38138
movss 0xc(%rsp), %xmm2
subss %xmm2, %xmm0
movq (%rbx), %rax
movss %xmm0, 0x4(%rax)
movl 0x4(%r13), %eax
movq (%rbx), %rcx
movl %eax, 0x8(%rcx)
movss 0x20(%rsp), %xmm0
mulss %xmm2, %xmm0
movq (%rbx), %rax
movss %xmm0, 0xc(%rax)
movl 0x4(%rbp), %eax
movq (%rbx), %rcx
movl %eax, 0x10(%rcx)
mulss %xmm2, %xmm1
movl $0x14, %eax
jmp 0xf3f1
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x1, %esi
movq %rbx, %rdi
callq 0x140ea
movl 0x4(%rbp), %eax
jmp 0xf3df
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x1, %esi
movq %rbx, %rdi
callq 0x140ea
jmp 0xf3db
movb $0x1, (%rbx)
movl $0x3f800000, 0x4(%rbx)  # imm = 0x3F800000
addq $0x8, %rbx
movl $0x1, %esi
movq %rbx, %rdi
callq 0x140ea
jmp 0xf3db
movl $0x2, %esi
movq %r15, %rdi
callq 0x140ea
movss 0x20(%rsp), %xmm2
movaps %xmm2, %xmm0
subss 0xc(%rsp), %xmm0
divss %xmm0, %xmm2
movss 0x2876d(%rip), %xmm0    # 0x38138
minss %xmm0, %xmm2
xorpd %xmm1, %xmm1
maxss %xmm2, %xmm1
movl 0x50(%r14), %eax
movq (%r15), %rcx
movl %eax, (%rcx)
subss %xmm1, %xmm0
movq (%r15), %rax
movss %xmm0, 0x4(%rax)
movl 0x4(%rbp), %eax
movq (%r15), %rcx
movl %eax, 0x8(%rcx)
movl $0xc, %eax
jmp 0xfa31
movl $0x1, %esi
movq %r15, %rdi
callq 0x140ea
movl 0x4(%r13), %eax
jmp 0xfa1f
movl $0x1, %esi
movq %r15, %rdi
callq 0x140ea
movl 0x4(%rbp), %eax
movq (%r15), %rcx
movl %eax, (%rcx)
movss 0x2870c(%rip), %xmm1    # 0x38138
movl $0x4, %eax
movq %r15, %rbx
jmp 0xf3f1
jmp 0xfa3f
jmp 0xfa3f
jmp 0xfa3f
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xfa59
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x4590