// File: /workspace/github_cpp_makefile_star2_O2/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, %r12
movq %rsi, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
leaq 0x44(%rdi), %r13
leaq 0x34(%rsp), %rdx
movq %rsi, %rdi
movq %r13, %rsi
callq 0x1044e
cvtss2sd %xmm0, %xmm0
movsd 0x28103(%rip), %xmm1    # 0x35588
ucomisd %xmm0, %xmm1
jae 0xd533
movq 0x78(%r14), %rax
subq 0x70(%r14), %rax
pushq $0x2c
popq %rcx
cqto
idivq %rcx
testl %eax, %eax
je 0xd6e2
movq %rbx, 0x10(%rsp)
movslq %eax, %rsi
leaq 0x40(%rsp), %rdi
callq 0x115d0
movq %r12, 0x20(%rsp)
pushq $0x1
popq %r12
pushq $0x14
popq %rbx
xorl %ebp, %ebp
leaq 0x34(%rsp), %r15
movq 0x70(%r14), %rdi
movq 0x78(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x2c
popq %rcx
idivq %rcx
movq %rax, %rcx
movslq %ecx, %rdx
cmpq %rdx, %rbp
jge 0xd555
addq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x104b7
cvtss2sd %xmm0, %xmm1
addsd 0x2809c(%rip), %xmm1    # 0x355a0
cvtsd2ss %xmm1, %xmm1
movaps %xmm0, %xmm2
cmpltss 0x24b5c(%rip), %xmm2    # 0x32070
movaps %xmm2, %xmm3
andnps %xmm0, %xmm3
andps %xmm1, %xmm2
orps %xmm3, %xmm2
movq 0x40(%rsp), %rax
movss %xmm2, (%rax,%rbp,4)
incq %rbp
addq $0x2c, %rbx
jmp 0xd4cc
movb $0x0, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11672
jmp 0xd6ff
xorl %r8d, %r8d
movq 0x40(%rsp), %rsi
movslq %r8d, %rax
cmpq %rdx, %r12
jge 0xd57f
movss (%rsi,%rax,4), %xmm0
ucomiss (%rsi,%r12,4), %xmm0
movl %r12d, %eax
ja 0xd577
movl %r8d, %eax
incq %r12
movl %eax, %r8d
jmp 0xd55d
imulq $0x2c, %rax, %r15
incl %eax
cltd
idivl %ecx
movl (%rdi,%r15), %eax
cmpq $0x4, %rax
ja 0xda36
addq %rdi, %r15
movslq %edx, %rcx
imulq $0x2c, %rcx, %rbx
addq %rdi, %rbx
leaq 0x280f6(%rip), %rcx     # 0x356a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8(%r15), %rdi
leaq 0x8(%rbx), %rsi
leaq 0x34(%rsp), %rdx
movq %r13, %rcx
callq 0x1053c
movq 0x20(%rsp), %r12
movss 0x24a8e(%rip), %xmm8    # 0x32064
movaps %xmm8, %xmm7
subss %xmm0, %xmm7
movss 0x34(%rsp), %xmm2
movss 0x38(%rsp), %xmm3
movss 0xc(%r15), %xmm1
mulss %xmm3, %xmm1
movss 0x8(%r15), %xmm4
mulss %xmm2, %xmm4
addss %xmm1, %xmm4
movss 0x3c(%rsp), %xmm6
movss 0x10(%r15), %xmm1
mulss %xmm6, %xmm1
addss %xmm4, %xmm1
movss 0xc(%rbx), %xmm4
mulss %xmm3, %xmm4
movss 0x8(%rbx), %xmm5
mulss %xmm2, %xmm5
addss %xmm4, %xmm5
movss 0x10(%rbx), %xmm4
mulss %xmm6, %xmm4
addss %xmm5, %xmm4
mulss %xmm0, %xmm4
mulss %xmm7, %xmm1
addss %xmm4, %xmm1
cvtss2sd %xmm1, %xmm4
movsd 0x27f3f(%rip), %xmm5    # 0x35590
ucomisd %xmm4, %xmm5
jae 0xd68c
movq 0x10(%rsp), %rax
mulss 0x4(%rax), %xmm3
mulss (%rax), %xmm2
addss %xmm3, %xmm2
mulss 0x8(%rax), %xmm6
addss %xmm2, %xmm6
cvtss2sd %xmm6, %xmm2
movsd 0x27f0a(%rip), %xmm3    # 0x35588
addsd %xmm4, %xmm3
ucomisd %xmm3, %xmm2
jbe 0xda49
movss %xmm7, 0x10(%rsp)
movb $0x1, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x2
popq %rsi
movq %r12, %rdi
movss %xmm0, 0x20(%rsp)
callq 0x11672
movss 0x20(%rsp), %xmm1
movl 0x4(%r15), %eax
movq (%r12), %rcx
movl %eax, (%rcx)
movq (%r12), %rax
movss 0x10(%rsp), %xmm0
movss %xmm0, 0x4(%rax)
movl 0x4(%rbx), %eax
movq (%r12), %rcx
movl %eax, 0x8(%rcx)
pushq $0xc
jmp 0xd713
movb $0x1, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11672
movl 0x50(%r14), %eax
movq (%r12), %rcx
movl %eax, (%rcx)
movss 0x24953(%rip), %xmm1    # 0x32064
pushq $0x4
popq %rax
movq (%r12), %rcx
movss %xmm1, (%rcx,%rax)
leaq 0x40(%rsp), %rdi
callq 0x12ef2
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rax
movss (%rax), %xmm2
movss 0x4(%rax), %xmm1
movss 0x24(%r15), %xmm0
movss %xmm1, 0x1c(%rsp)
mulss %xmm1, %xmm0
movss 0x20(%r15), %xmm1
movss %xmm2, 0xc(%rsp)
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x8(%rax), %xmm2
movss 0x28(%r15), %xmm0
movss %xmm2, 0x10(%rsp)
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
leaq 0x54e92c3(%rip), %rax   # 0x54f6a51
movb (%rax), %al
movq 0x20(%rsp), %r12
jbe 0xda98
movss 0x14(%r15), %xmm2
movss 0x18(%r15), %xmm1
movss 0xc(%r15), %xmm0
movss %xmm1, 0x2c(%rsp)
mulss %xmm1, %xmm0
movss 0x8(%r15), %xmm1
movss %xmm2, 0x30(%rsp)
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x1c(%r15), %xmm2
movss 0x10(%r15), %xmm0
movss %xmm2, 0x28(%rsp)
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x18(%rsp)
testb %al, %al
je 0xd814
cvtss2sd 0x18(%rsp), %xmm0
movsd 0x27dab(%rip), %xmm1    # 0x355a8
ucomisd %xmm0, %xmm1
jb 0xd814
leaq 0x27f93(%rip), %rsi     # 0x3579d
pushq $0x5
popq %rdi
xorl %eax, %eax
callq 0x9045
movss 0x1c(%rsp), %xmm1
mulss 0x2c(%rsp), %xmm1
movss 0xc(%rsp), %xmm0
mulss 0x30(%rsp), %xmm0
addss %xmm1, %xmm0
movss 0x10(%rsp), %xmm2
mulss 0x28(%rsp), %xmm2
addss %xmm0, %xmm2
cvtss2sd %xmm2, %xmm0
movsd 0x24834(%rip), %xmm1    # 0x32080
ucomisd %xmm0, %xmm1
jae 0xdc0c
movq %r12, %rax
addq $0x8, %r12
movss %xmm2, 0x10(%rsp)
ucomiss 0x18(%rsp), %xmm2
movb $0x1, (%rax)
movl $0x3f800000, 0x4(%rax)  # imm = 0x3F800000
jae 0xdd6c
pushq $0x2
popq %rsi
movq %r12, %rdi
callq 0x11672
movss 0x10(%rsp), %xmm2
divss 0x18(%rsp), %xmm2
movss 0x247cd(%rip), %xmm0    # 0x32064
minss %xmm0, %xmm2
xorpd %xmm1, %xmm1
maxss %xmm2, %xmm1
movl 0x50(%r14), %eax
movq (%r12), %rcx
movl %eax, (%rcx)
subss %xmm1, %xmm0
movq (%r12), %rax
movss %xmm0, 0x4(%rax)
movl 0x4(%r15), %eax
jmp 0xd6d7
movss 0x20(%r15), %xmm0
movss 0x24(%r15), %xmm1
movss 0xc(%r15), %xmm2
mulss %xmm1, %xmm2
movss 0x8(%r15), %xmm3
mulss %xmm0, %xmm3
addss %xmm2, %xmm3
movss 0x28(%r15), %xmm4
movss 0x10(%r15), %xmm5
mulss %xmm4, %xmm5
addss %xmm3, %xmm5
movq 0x10(%rsp), %rax
movss 0x4(%rax), %xmm2
mulss %xmm1, %xmm2
movss (%rax), %xmm3
mulss %xmm0, %xmm3
addss %xmm2, %xmm3
movss 0x8(%rax), %xmm2
mulss %xmm4, %xmm2
addss %xmm3, %xmm2
subss %xmm2, %xmm5
movss %xmm5, 0x10(%rsp)
mulss 0xc(%rbx), %xmm1
mulss 0x8(%rbx), %xmm0
mulss 0x10(%rbx), %xmm4
addss %xmm1, %xmm0
addss %xmm0, %xmm4
subss %xmm2, %xmm4
movss %xmm4, 0x1c(%rsp)
xorps %xmm0, %xmm0
subss %xmm2, %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x54e90f0(%rip), %rax   # 0x54f6a51
cmpb $0x1, (%rax)
movq 0x20(%rsp), %r12
jne 0xd996
movss 0x10(%rsp), %xmm0
ucomiss 0xc(%rsp), %xmm0
ja 0xd985
movss 0xc(%rsp), %xmm0
ucomiss 0x1c(%rsp), %xmm0
jbe 0xd996
leaq 0x27de8(%rip), %rsi     # 0x35774
pushq $0x5
popq %rdi
xorl %eax, %eax
callq 0x9045
cvtss2sd 0x10(%rsp), %xmm0
ucomisd 0x27c0c(%rip), %xmm0    # 0x355b0
jae 0xdbc1
cvtss2sd 0x1c(%rsp), %xmm0
movsd 0x246c8(%rip), %xmm1    # 0x32080
ucomisd %xmm0, %xmm1
jae 0xdbe7
movq %r12, %rax
addq $0x8, %r12
xorps %xmm0, %xmm0
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
movb $0x1, (%rax)
movl $0x3f800000, 0x4(%rax)  # imm = 0x3F800000
jbe 0xdd24
pushq $0x2
popq %rsi
movq %r12, %rdi
callq 0x11672
movss 0x10(%rsp), %xmm2
movaps %xmm2, %xmm0
subss 0xc(%rsp), %xmm0
divss %xmm0, %xmm2
movss 0x24659(%rip), %xmm0    # 0x32064
minss %xmm0, %xmm2
xorps %xmm1, %xmm1
maxss %xmm2, %xmm1
movl 0x4(%r15), %eax
movq (%r12), %rcx
movl %eax, (%rcx)
subss %xmm1, %xmm0
movq (%r12), %rax
movss %xmm0, 0x4(%rax)
movl 0x50(%r14), %eax
jmp 0xd6d7
leaq 0x27db2(%rip), %rdi     # 0x357ef
xorl %eax, %eax
callq 0x8b2f
jmp 0xd71d
addsd 0x27b47(%rip), %xmm4    # 0x35598
ucomisd %xmm4, %xmm2
jae 0xda6c
divss %xmm1, %xmm6
minss 0x24601(%rip), %xmm6    # 0x32064
xorps %xmm8, %xmm8
maxss %xmm6, %xmm8
movl (%r15), %eax
cmpl $0x4, %eax
je 0xdc50
cmpl $0x3, %eax
jne 0xdc96
subq 0x70(%r14), %r15
movq %r15, %rax
cqto
pushq $0x2c
popq %rcx
idivq %rcx
movq %rax, %rsi
jmp 0xdc81
movss 0x14(%rbx), %xmm2
movss 0x18(%rbx), %xmm1
movss 0xc(%rbx), %xmm0
movss %xmm1, 0x2c(%rsp)
mulss %xmm1, %xmm0
movss 0x8(%rbx), %xmm1
movss %xmm2, 0x30(%rsp)
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x1c(%rbx), %xmm2
movss 0x10(%rbx), %xmm0
movss %xmm2, 0x28(%rsp)
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x18(%rsp)
testb %al, %al
je 0xdb0b
cvtss2sd 0x18(%rsp), %xmm0
movsd 0x27ab4(%rip), %xmm1    # 0x355a8
ucomisd %xmm0, %xmm1
jb 0xdb0b
leaq 0x27cc5(%rip), %rsi     # 0x357c6
pushq $0x5
popq %rdi
xorl %eax, %eax
callq 0x9045
movss 0x1c(%rsp), %xmm1
mulss 0x2c(%rsp), %xmm1
movss 0xc(%rsp), %xmm0
mulss 0x30(%rsp), %xmm0
addss %xmm1, %xmm0
movss 0x10(%rsp), %xmm2
mulss 0x28(%rsp), %xmm2
addss %xmm0, %xmm2
cvtss2sd %xmm2, %xmm0
movsd 0x2453d(%rip), %xmm1    # 0x32080
ucomisd %xmm0, %xmm1
jae 0xdc2e
leaq 0x8(%r12), %r15
movss %xmm2, 0x10(%rsp)
ucomiss 0x18(%rsp), %xmm2
movb $0x1, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
jae 0xdd7c
pushq $0x2
popq %rsi
movq %r15, %rdi
callq 0x11672
movss 0x10(%rsp), %xmm2
divss 0x18(%rsp), %xmm2
movss 0x244d4(%rip), %xmm0    # 0x32064
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(%rbx), %eax
movq (%r15), %rcx
movl %eax, 0x8(%rcx)
pushq $0xc
jmp 0xdd99
movb $0x1, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11672
movl 0x4(%r15), %eax
jmp 0xd703
movb $0x1, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11672
movl 0x4(%rbx), %eax
jmp 0xd703
movb $0x1, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11672
jmp 0xd6ff
movb $0x1, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11672
jmp 0xd6ff
movq 0x70(%r14), %rdi
movq 0x78(%r14), %rcx
subq %rdi, %r15
movq %r15, %rax
cqto
pushq $0x2c
popq %r8
idivq %r8
movq %rax, %rsi
subq %rdi, %rcx
movq %rcx, %rax
cqto
idivq %r8
movq %rax, %rcx
addl %esi, %eax
decl %eax
cltd
idivl %ecx
movl %edx, %esi
movq %r14, %rdi
movq 0x10(%rsp), %rdx
movq %r12, %rcx
callq 0x10660
jmp 0xd71d
movss %xmm8, 0xc(%rsp)
movss %xmm7, 0x10(%rsp)
movb $0x0, (%r12)
movl $0x3f800000, 0x4(%r12)  # imm = 0x3F800000
addq $0x8, %r12
pushq $0x3
popq %rsi
movq %r12, %rdi
movss %xmm0, 0x20(%rsp)
callq 0x11672
movss 0x20(%rsp), %xmm1
movl 0x50(%r14), %eax
movq (%r12), %rcx
movl %eax, (%rcx)
movss 0x24386(%rip), %xmm0    # 0x32064
movss 0xc(%rsp), %xmm2
subss %xmm2, %xmm0
movq (%r12), %rax
movss %xmm0, 0x4(%rax)
movl 0x4(%r15), %eax
movq (%r12), %rcx
movl %eax, 0x8(%rcx)
movss 0x10(%rsp), %xmm0
mulss %xmm2, %xmm0
movq (%r12), %rax
movss %xmm0, 0xc(%rax)
movl 0x4(%rbx), %eax
movq (%r12), %rcx
movl %eax, 0x10(%rcx)
mulss %xmm2, %xmm1
pushq $0x14
jmp 0xd713
pushq $0x2
popq %rsi
movq %r12, %rdi
callq 0x11672
movss 0xc(%rsp), %xmm2
movaps %xmm2, %xmm0
subss 0x1c(%rsp), %xmm0
divss %xmm0, %xmm2
movss 0x2431a(%rip), %xmm0    # 0x32064
minss %xmm0, %xmm2
xorps %xmm1, %xmm1
maxss %xmm2, %xmm1
movl 0x50(%r14), %eax
movq (%r12), %rcx
movl %eax, (%rcx)
subss %xmm1, %xmm0
movq (%r12), %rax
jmp 0xd6cf
pushq $0x1
popq %rsi
movq %r12, %rdi
callq 0x11672
jmp 0xdbde
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x11672
movl 0x4(%rbx), %eax
movq (%r15), %rcx
movl %eax, (%rcx)
movss 0x242cd(%rip), %xmm1    # 0x32064
pushq $0x4
popq %rax
movq %r15, %r12
jmp 0xd714
jmp 0xdda8
jmp 0xdda8
jmp 0xdda8
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x12ef2
movq %rbx, %rdi
callq 0x45a0