// File: FreeSlave[P]vhlt/hlvis/flow.cpp
// Function: MaxDistVis(int)
void	MaxDistVis(int unused)
{
	int i, j, k, m;
	int a, b, c, d;
	leaf_t	*l;
	leaf_t	*tl;
	plane_t	*boundary = NULL;
	vec3_t delta;

	float new_dist;

	unsigned offset_l;
	unsigned bit_l;

	unsigned offset_tl;
	unsigned bit_tl;
	
	while(1)
	{
		i = GetThreadWork();
		if (i == -1)
			break;

		l = &g_leafs[i];

		for(j = i + 1, tl = g_leafs + j; j < g_portalleafs; j++, tl++)
		{
#ifdef HLVIS_MAXDIST_NEW

			offset_l = i >> 3;
			bit_l = (1 << (i & 7));

			offset_tl = j >> 3;
			bit_tl = (1 << (j & 7));

			{
				bool visible = false;
				for (k = 0; k < l->numportals; k++)
				{
					if (l->portals[k]->visbits[offset_tl] & bit_tl)
					{
						visible = true;
					}
				}
				for (m = 0; m < tl->numportals; m++)
				{	
					if (tl->portals[m]->visbits[offset_l] & bit_l)
					{
						visible = true;
					}
				}
				if (!visible)
				{
					goto NoWork;
				}
			}
			
			// rough check
			{
				vec3_t v;
				vec_t dist;
				const winding_t *w;
				const leaf_t *leaf[2] = {l, tl};
				vec3_t center[2];
				vec_t radius[2];
				int count[2];
				for (int side = 0; side < 2; side++)
				{
					count[side] = 0;
					VectorClear (center[side]);
					for (a = 0; a < leaf[side]->numportals; a++)
					{
						w = leaf[side]->portals[a]->winding;
						for (b = 0; b < w->numpoints; b++)
						{
							VectorAdd (w->points[b], center[side], center[side]);
							count[side]++;
						}
					}
				}
				if (!count[0] && !count[1])
				{
					goto Work;
				}
				for (int side = 0; side < 2; side++)
				{
					VectorScale (center[side], 1.0 / (vec_t)count[side], center[side]);
					radius[side] = 0;
					for (a = 0; a < leaf[side]->numportals; a++)
					{
						w = leaf[side]->portals[a]->winding;
						for (b = 0; b < w->numpoints; b++)
						{
							VectorSubtract (w->points[b], center[side], v);
							dist = DotProduct (v, v);
							radius[side] = qmax (radius[side], dist);
						}
					}
					radius[side] = sqrt (radius[side]);
				}
				VectorSubtract (center[0], center[1], v);
				dist = VectorLength (v);
				if (qmax (dist - radius[0] - radius[1], 0) >= g_maxdistance - ON_EPSILON)
				{
					goto Work;
				}
				if (dist + radius[0] + radius[1] < g_maxdistance - ON_EPSILON)
				{
					goto NoWork;
				}
			}

			// exact check
			{
				vec_t mindist = 9999999999;
				vec_t dist;
				for (k = 0; k < l->numportals; k++)
				{
					for (m = 0; m < tl->numportals; m++)
					{
						const winding_t *w[2];
						w[0] = l->portals[k]->winding;
						w[1] = tl->portals[m]->winding;
						dist = WindingDist (w);
						mindist = qmin (dist, mindist);
					}
				}
				if (mindist >= g_maxdistance - ON_EPSILON)
				{
					goto Work;
				}
				else
				{
					goto NoWork;
				}
			}
#else
			if(j == i)		// Ideally, should never be true
			{
				continue;
			}

			// If they already can't see each other, no use checking
			if(DisjointLeafVis(i, j))
			{
				continue;
			}

			new_dist = GetShortestDistance(l, tl);

			if(new_dist <= g_maxdistance)
				continue;

			// Try out our NEW, IMPROVED ALGORITHM!!!!
			
			// Get a portal on Leaf 1 that completely seperates the two leafs
			/*split = GetSplitPortal(l, tl);

			if(!split)
				continue;

			// We have a split, so create the bounds
			GetPortalBounds(split, &boundary);

			// Now get the dot product for all points on the other leaf
			max_dist = 999999999.999;

			/// Do the first check if mode is >= 2
			if(g_mdmode >= 2)
			{
				for(k = 0; k < tl->numportals; k++)
				{
					for(m = 0; m < tl->portals[k]->winding->numpoints; m++)
					{
						for(n = 0; n < split->winding->numpoints; n++) // numpoints of split portals = number of boundaries
						{
							dist = DotProduct(tl->portals[k]->winding->points[m], boundary[n].normal) - boundary[n].dist;
	
							if(dist < -ON_EPSILON)
							{
								// Outside boundaries
								//max_dot = MaxDotProduct(tl->portals[k]->winding->points[m], boundary, split->winding->numpoints);

								//max_dist = qmin(max_dist, max_dot);

								// Break so we don't do inside boundary check
								break;
							}
						}
						if(n < split->winding->numpoints)
							continue;

						// We found a point that's inside all the boundries!
						new_dist = DotProduct(tl->portals[k]->winding->points[m], split->plane.normal) - split->plane.dist;

						max_dist = qmin(max_dist, new_dist);
					}
				}
			}

			// This is now a special check.  If Leaf 2 has a split plane, we generate a polygon by clipping the plane
			// with the borders.  We then get the minimum dot products.  If more than one split plane, use intersection.
			// Only do this is g_mdmode is 3
			if(g_mdmode >= 3)	// For future mode expansion
			{
				new_dist = CalcSplitsAndDotProducts(&split->plane, tl, l, boundary, split->winding->numpoints);

				max_dist = qmin(max_dist, new_dist);
			}*/

			// Third and final check.  If the whole of leaf2 is outside of leaf1 boundaries, this one will catch it
			// Basic "every point to every point" type of deal :)
			// This is done by default all the time
			for(a = 0; a < l->numportals; a++)
			{
				for(b = 0; b < tl->numportals; b++)
				{
					for(c = 0; c < l->portals[a]->winding->numpoints; c++)
					{
						for(d = 0; d < tl->portals[b]->winding->numpoints; d++)
						{
							VectorSubtract(l->portals[a]->winding->points[c], tl->portals[b]->winding->points[d], delta);

							if(VectorLength(delta) <= g_maxdistance)
								goto NoWork;
						}
					}
				}
			}
#endif

#ifdef HLVIS_MAXDIST_NEW
Work:
			ThreadLock ();
			for (k = 0; k < l->numportals; k++)
			{
				l->portals[k]->visbits[offset_tl] &= ~bit_tl;
			}
			for (m = 0; m < tl->numportals; m++)
			{
				tl->portals[m]->visbits[offset_l] &= ~bit_l;
			}
			ThreadUnlock ();
#else
			offset_l = i >> 3;
			bit_l = (1 << (i & 7));

			offset_tl = j >> 3;
			bit_tl = (1 << (j & 7));

			for(k = 0; k < l->numportals; k++)
			{
				for(m = 0; m < tl->numportals; m++)
				{
					if(l->portals[k]->status != stat_none)
						l->portals[k]->visbits[offset_tl] &= ~bit_tl;
					else
						l->portals[k]->mightsee[offset_tl] &= ~bit_tl;
					
					if(tl->portals[m]->status != stat_none)
						tl->portals[m]->visbits[offset_l] &= ~bit_l;
					else
						tl->portals[m]->mightsee[offset_l] &= ~bit_l;
				}
			}
#endif
			
NoWork:
			continue;	// Hack to keep label from causing compile error
		}
	}

	// Release potential memory
	if(boundary)
		delete [] boundary;
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movl %edi, 0x104(%rsp)
movq $0x0, 0xc8(%rsp)
callq 0xbcc0
movl %eax, 0x100(%rsp)
cmpl $-0x1, 0x100(%rsp)
jne 0x13855
jmp 0x142f0
leaq 0x2091f24(%rip), %rax   # 0x20a5780
movq (%rax), %rax
movslq 0x100(%rsp), %rcx
imulq $0x810, %rcx, %rcx      # imm = 0x810
addq %rcx, %rax
movq %rax, 0xd8(%rsp)
movl 0x100(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xfc(%rsp)
leaq 0x2091eef(%rip), %rax   # 0x20a5780
movq (%rax), %rax
movslq 0xfc(%rsp), %rcx
imulq $0x810, %rcx, %rcx      # imm = 0x810
addq %rcx, %rax
movq %rax, 0xd0(%rsp)
movl 0xfc(%rsp), %eax
leaq 0x2091eb8(%rip), %rcx   # 0x20a5774
cmpl (%rcx), %eax
jae 0x142eb
movl 0x100(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0xb4(%rsp)
movl 0x100(%rsp), %ecx
andl $0x7, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0xb0(%rsp)
movl 0xfc(%rsp), %eax
sarl $0x3, %eax
movl %eax, 0xac(%rsp)
movl 0xfc(%rsp), %ecx
andl $0x7, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0xa8(%rsp)
movb $0x0, 0xa7(%rsp)
movl $0x0, 0xf8(%rsp)
movl 0xf8(%rsp), %eax
movq 0xd8(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x13989
movq 0xd8(%rsp), %rax
movslq 0xf8(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movl 0xac(%rsp), %ecx
movzbl (%rax,%rcx), %eax
andl 0xa8(%rsp), %eax
cmpl $0x0, %eax
je 0x13974
movb $0x1, 0xa7(%rsp)
jmp 0x13976
movl 0xf8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf8(%rsp)
jmp 0x13929
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movq 0xd0(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x139f4
movq 0xd0(%rsp), %rax
movslq 0xf4(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movl 0xb4(%rsp), %ecx
movzbl (%rax,%rcx), %eax
andl 0xb0(%rsp), %eax
cmpl $0x0, %eax
je 0x139df
movb $0x1, 0xa7(%rsp)
jmp 0x139e1
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x13994
testb $0x1, 0xa7(%rsp)
jne 0x13a03
jmp 0x142bd
movq 0xd8(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x78(%rsp)
movl $0x0, 0x3c(%rsp)
cmpl $0x2, 0x3c(%rsp)
jge 0x13c22
movslq 0x3c(%rsp), %rax
movl $0x0, 0x40(%rsp,%rax,4)
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rax)
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax)
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movss %xmm0, (%rax)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movslq 0x3c(%rsp), %rcx
movq 0x70(%rsp,%rcx,8), %rcx
cmpl (%rcx), %eax
jae 0x13c10
movslq 0x3c(%rsp), %rax
movq 0x70(%rsp,%rax,8), %rax
movslq 0xf0(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movq %rax, 0x88(%rsp)
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
movq 0x88(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x13bf8
movq 0x88(%rsp), %rax
addq $0x8, %rax
movslq 0xec(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss (%rax), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movslq 0xec(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x4(%rax), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movslq 0xec(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x8(%rax), %xmm0
movslq 0x3c(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movslq 0x3c(%rsp), %rax
movl 0x40(%rsp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rsp,%rax,4)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x13ad9
jmp 0x13bfa
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x13a92
jmp 0x13c12
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x13a25
cmpl $0x0, 0x40(%rsp)
jne 0x13c35
cmpl $0x0, 0x44(%rsp)
jne 0x13c35
jmp 0x141eb
movl $0x0, 0x38(%rsp)
cmpl $0x2, 0x38(%rsp)
jge 0x13f62
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movslq 0x38(%rsp), %rax
cvtsi2ssl 0x40(%rsp,%rax,4), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x84f8(%rip), %xmm1     # 0x1c170
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movslq 0x38(%rsp), %rax
cvtsi2ssl 0x40(%rsp,%rax,4), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x84a6(%rip), %xmm1     # 0x1c170
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movslq 0x38(%rsp), %rax
cvtsi2ssl 0x40(%rsp,%rax,4), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x8453(%rip), %xmm1     # 0x1c170
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movslq 0x38(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x48(%rsp,%rax,4)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movslq 0x38(%rsp), %rcx
movq 0x70(%rsp,%rcx,8), %rcx
cmpl (%rcx), %eax
jae 0x13f37
movslq 0x38(%rsp), %rax
movq 0x70(%rsp,%rax,8), %rax
movslq 0xf0(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movq %rax, 0x88(%rsp)
movl $0x0, 0xec(%rsp)
movl 0xec(%rsp), %eax
movq 0x88(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x13f1f
movq 0x88(%rsp), %rax
addq $0x8, %rax
movslq 0xec(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
subss (%rax), %xmm0
movss %xmm0, 0x98(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movslq 0xec(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
subss 0x4(%rax), %xmm0
movss %xmm0, 0x9c(%rsp)
movq 0x88(%rsp), %rax
addq $0x8, %rax
movslq 0xec(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movslq 0x38(%rsp), %rcx
leaq 0x50(%rsp), %rax
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
subss 0x8(%rax), %xmm0
movss %xmm0, 0xa0(%rsp)
movss 0x98(%rsp), %xmm1
movss 0x98(%rsp), %xmm2
movss 0x9c(%rsp), %xmm0
mulss 0x9c(%rsp), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0xa0(%rsp), %xmm0
movss 0xa0(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x94(%rsp)
movslq 0x38(%rsp), %rax
movss 0x48(%rsp,%rax,4), %xmm0
ucomiss 0x94(%rsp), %xmm0
jbe 0x13ee9
movslq 0x38(%rsp), %rax
movss 0x48(%rsp,%rax,4), %xmm0
movss %xmm0, 0x1c(%rsp)
jmp 0x13ef8
movss 0x94(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x1c(%rsp), %xmm0
movslq 0x38(%rsp), %rax
movss %xmm0, 0x48(%rsp,%rax,4)
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x13d9f
jmp 0x13f21
movl 0xf0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf0(%rsp)
jmp 0x13d58
movslq 0x38(%rsp), %rax
movss 0x48(%rsp,%rax,4), %xmm0
callq 0x7c40
movslq 0x38(%rsp), %rax
movss %xmm0, 0x48(%rsp,%rax,4)
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x13c3d
movss 0x50(%rsp), %xmm0
subss 0x5c(%rsp), %xmm0
movss %xmm0, 0x98(%rsp)
movss 0x54(%rsp), %xmm0
subss 0x60(%rsp), %xmm0
movss %xmm0, 0x9c(%rsp)
movss 0x58(%rsp), %xmm0
subss 0x64(%rsp), %xmm0
movss %xmm0, 0xa0(%rsp)
movss 0x98(%rsp), %xmm0
mulss 0x98(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x9c(%rsp), %xmm1
mulss 0x9c(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movss 0xa0(%rsp), %xmm1
mulss 0xa0(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
callq 0x31a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x94(%rsp)
movss 0x94(%rsp), %xmm0
subss 0x48(%rsp), %xmm0
subss 0x4c(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x14037
movss 0x94(%rsp), %xmm0
subss 0x48(%rsp), %xmm0
subss 0x4c(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0x14042
xorps %xmm0, %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0x14042
movss 0x18(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2091761(%rip), %rax   # 0x20a57b4
movl (%rax), %eax
cvtsi2sd %rax, %xmm1
movsd 0x85ce(%rip), %xmm2     # 0x1c630
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x14071
jmp 0x141eb
movss 0x94(%rsp), %xmm0
movss 0x48(%rsp), %xmm2
movss 0x4c(%rsp), %xmm1
addss %xmm2, %xmm0
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
leaq 0x209171b(%rip), %rax   # 0x20a57b4
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x8588(%rip), %xmm2     # 0x1c630
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x140b7
jmp 0x142bd
movss 0x859d(%rip), %xmm0     # 0x1c65c
movss %xmm0, 0x34(%rsp)
movl $0x0, 0xf8(%rsp)
movl 0xf8(%rsp), %eax
movq 0xd8(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x141ba
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movq 0xd0(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x141a2
movq 0xd8(%rsp), %rax
movslq 0xf8(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0xd0(%rsp), %rax
movslq 0xf4(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x18(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x11cf0
movss %xmm0, 0x30(%rsp)
movss 0x30(%rsp), %xmm1
movss 0x34(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x14174
movss 0x30(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
jmp 0x14180
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x34(%rsp)
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x140f2
jmp 0x141a4
movl 0xf8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf8(%rsp)
jmp 0x140d0
movss 0x34(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x20915e9(%rip), %rax   # 0x20a57b4
movl (%rax), %eax
cvtsi2sd %rax, %xmm1
movsd 0x8456(%rip), %xmm2     # 0x1c630
subsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x141e6
jmp 0x141eb
jmp 0x142bd
callq 0xc020
movl $0x0, 0xf8(%rsp)
movl 0xf8(%rsp), %eax
movq 0xd8(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x14254
movl 0xa8(%rsp), %esi
xorl $-0x1, %esi
movq 0xd8(%rsp), %rax
movslq 0xf8(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movl 0xac(%rsp), %ecx
movzbl (%rax,%rcx), %edx
andl %esi, %edx
movb %dl, (%rax,%rcx)
movl 0xf8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf8(%rsp)
jmp 0x141fb
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
movq 0xd0(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x142b8
movl 0xb0(%rsp), %esi
xorl $-0x1, %esi
movq 0xd0(%rsp), %rax
movslq 0xf4(%rsp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movl 0xb4(%rsp), %ecx
movzbl (%rax,%rcx), %edx
andl %esi, %edx
movb %dl, (%rax,%rcx)
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0x1425f
callq 0xc040
jmp 0x142bf
movl 0xfc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xfc(%rsp)
movq 0xd0(%rsp), %rax
addq $0x810, %rax            # imm = 0x810
movq %rax, 0xd0(%rsp)
jmp 0x138ae
jmp 0x1383a
cmpq $0x0, 0xc8(%rsp)
je 0x1431a
movq 0xc8(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x14318
movq 0x8(%rsp), %rdi
callq 0x3300
jmp 0x1431a
addq $0x108, %rsp            # imm = 0x108
retq
nopw %cs:(%rax,%rax)