// File: FreeSlave[P]vhlt/hlrad/lightmap.cpp
// Function: ChopFrag(samplefrag_s*)
void ChopFrag (samplefrag_t *frag)
	// fill winding, windingplane, mywinding, mywindingplane, numedges, edges
{
	// get the shape of the fragment by clipping the face using the boundaries
	dface_t *f;
	Winding *facewinding;
	matrix_t worldtotex;
	const vec3_t v_up = {0, 0, 1};

	f = &g_dfaces[frag->facenum];
	facewinding = new Winding (*f);

	TranslateWorldToTex (frag->facenum, worldtotex);
	frag->mywinding = new Winding (facewinding->m_NumPoints);
	for (int x = 0; x < facewinding->m_NumPoints; x++)
	{
		ApplyMatrix (worldtotex, facewinding->m_Points[x], frag->mywinding->m_Points[x]);
		frag->mywinding->m_Points[x][2] = 0.0;
	}
	frag->mywinding->RemoveColinearPoints ();
	VectorCopy (v_up, frag->mywindingplane.normal); // this is the same as applying the worldtotex matrix to the faceplane
	if (CalcMatrixSign (worldtotex) < 0.0)
	{
		frag->mywindingplane.normal[2] *= -1;
	}
	frag->mywindingplane.dist = 0.0;

	for (int x = 0; x < 4 && frag->mywinding->m_NumPoints > 0; x++)
	{
		frag->mywinding->Clip (frag->myrect.planes[x], false);
	}

	frag->winding = new Winding (frag->mywinding->m_NumPoints);
	for (int x = 0; x < frag->mywinding->m_NumPoints; x++)
	{
		ApplyMatrix (frag->mycoordtocoord, frag->mywinding->m_Points[x], frag->winding->m_Points[x]);
	}
	frag->winding->RemoveColinearPoints ();
	VectorCopy (frag->mywindingplane.normal, frag->windingplane.normal);
	if (CalcMatrixSign (frag->mycoordtocoord) < 0.0)
	{
		frag->windingplane.normal[2] *= -1;
	}
	frag->windingplane.dist = 0.0;

	delete facewinding;

	// find the edges where the fragment can grow in the future
	frag->numedges = 0;
	frag->edges = (samplefragedge_t *)malloc (f->numedges * sizeof (samplefragedge_t));
	hlassume (frag->edges != NULL, assume_NoMemory);
	for (int i = 0; i < f->numedges; i++)
	{
		samplefragedge_t *e;
		edgeshare_t *es;
		dedge_t *de;
		dvertex_t *dv1;
		dvertex_t *dv2;
		vec_t frac1, frac2;
		vec_t edgelen;
		vec_t dot, dot1, dot2;
		vec3_t tmp, v, normal;
		const matrix_t *m;
		const matrix_t *m_inverse;
		
		e = &frag->edges[frag->numedges];

		// some basic info
		e->edgenum = abs (g_dsurfedges[f->firstedge + i]);
		e->edgeside = (g_dsurfedges[f->firstedge + i] < 0? 1: 0);
		es = &g_edgeshare[e->edgenum];
		if (!es->smooth)
		{
			continue;
		}
		if (es->faces[e->edgeside] - g_dfaces != frag->facenum)
		{
			Error ("internal error 1 in GrowSingleSampleFrag");
		}
		m = &es->textotex[e->edgeside];
		m_inverse = &es->textotex[1-e->edgeside];
		e->nextfacenum = es->faces[1-e->edgeside] - g_dfaces;
		if (e->nextfacenum == frag->facenum)
		{
			continue; // an invalid edge (usually very short)
		}
		e->tried = false; // because the frag hasn't been linked into the list yet

		// translate the edge points from world to the texture plane of the original frag
		//   so the distances are able to be compared among edges from different frags
		de = &g_dedges[e->edgenum];
		dv1 = &g_dvertexes[de->v[e->edgeside]];
		dv2 = &g_dvertexes[de->v[1-e->edgeside]];
		ApplyMatrix (worldtotex, dv1->point, tmp);
		ApplyMatrix (frag->mycoordtocoord, tmp, e->point1);
		e->point1[2] = 0.0;
		ApplyMatrix (worldtotex, dv2->point, tmp);
		ApplyMatrix (frag->mycoordtocoord, tmp, e->point2);
		e->point2[2] = 0.0;
		VectorSubtract (e->point2, e->point1, e->direction);
		edgelen = VectorNormalize (e->direction);
		if (edgelen <= ON_EPSILON)
		{
			continue;
		}

		// clip the edge
		frac1 = 0;
		frac2 = 1;
		for (int x = 0; x < 4; x++)
		{
			vec_t dot1;
			vec_t dot2;

			dot1 = DotProduct (e->point1, frag->rect.planes[x].normal) - frag->rect.planes[x].dist;
			dot2 = DotProduct (e->point2, frag->rect.planes[x].normal) - frag->rect.planes[x].dist;
			if (dot1 <= ON_EPSILON && dot2 <= ON_EPSILON)
			{
				frac1 = 1;
				frac2 = 0;
			}
			else if (dot1 < 0)
			{
				frac1 = qmax (frac1, dot1 / (dot1 - dot2));
			}
			else if (dot2 < 0)
			{
				frac2 = qmin (frac2, dot1 / (dot1 - dot2));
			}
		}
		if (edgelen * (frac2 - frac1) <= ON_EPSILON)
		{
			continue;
		}
		VectorMA (e->point1, edgelen * frac2, e->direction, e->point2);
		VectorMA (e->point1, edgelen * frac1, e->direction, e->point1);

		// calculate the distance, etc., which are used to determine its priority
		e->noseam = frag->noseam;
		dot = DotProduct (frag->origin, e->direction);
		dot1 = DotProduct (e->point1, e->direction);
		dot2 = DotProduct (e->point2, e->direction);
		dot = qmax (dot1, qmin (dot, dot2));
		VectorMA (e->point1, dot - dot1, e->direction, v);
		VectorSubtract (v, frag->origin, v);
		e->distance = VectorLength (v);
		CrossProduct (e->direction, frag->windingplane.normal, normal);
		VectorNormalize (normal); // points inward
		e->distancereduction = DotProduct (v, normal);
		e->flippedangle = frag->flippedangle + acos (qmin (es->cos_normals_angle, 1.0));

		// calculate the matrix
		e->ratio = (*m_inverse).v[2][2];
		if (e->ratio <= NORMAL_EPSILON || (1 / e->ratio) <= NORMAL_EPSILON)
		{
			Developer (DEVELOPER_LEVEL_SPAM, "TranslateTexToTex failed on face %d and %d @(%f,%f,%f)", frag->facenum, e->nextfacenum, dv1->point[0], dv1->point[1], dv1->point[2]);
			continue;
		}

		if (fabs (e->ratio - 1) < 0.005)
		{
			e->prevtonext = *m;
			e->nexttoprev = *m_inverse;
		}
		else
		{
			e->noseam = false;
			e->prevtonext = *m;
			e->nexttoprev = *m_inverse;
		}

		frag->numedges++;
	}
}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
movl $0x3f800000, 0x108(%rsp) # imm = 0x3F800000
movq $0x0, 0x100(%rsp)
movq 0x150(%rsp), %rax
movslq 0x18(%rax), %rax
leaq (%rax,%rax,4), %rcx
leaq 0x1bb92b3(%rip), %rax   # 0x1be6410
leaq (%rax,%rcx,4), %rax
movq %rax, 0x148(%rsp)
movl $0x20, %edi
callq 0x4320
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq 0x148(%rsp), %rsi
movss 0x40a02(%rip), %xmm0    # 0x6db90
callq 0xf130
jmp 0x2d195
movq 0x50(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x150(%rsp), %rax
movl 0x18(%rax), %edi
leaq 0x110(%rsp), %rsi
callq 0x5dfe0
movl $0x20, %edi
callq 0x4320
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x48(%rsp)
movq 0x140(%rsp), %rax
movl 0x8(%rax), %esi
callq 0xe980
jmp 0x2d1e1
movq 0x48(%rsp), %rcx
movq 0x150(%rsp), %rax
movq %rcx, 0x160(%rax)
movl $0x0, 0xf0(%rsp)
movl 0xf0(%rsp), %eax
movq 0x140(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x2d2f2
movq 0x140(%rsp), %rax
movq 0x10(%rax), %rsi
movslq 0xf0(%rsp), %rax
imulq $0xc, %rax, %rax
addq %rax, %rsi
movq 0x150(%rsp), %rax
movq 0x160(%rax), %rax
movq 0x10(%rax), %rdx
movslq 0xf0(%rsp), %rax
imulq $0xc, %rax, %rax
addq %rax, %rdx
leaq 0x110(%rsp), %rdi
callq 0x5d920
movq 0x150(%rsp), %rax
movq 0x160(%rax), %rax
movq 0x10(%rax), %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 0x2d200
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
movl $0x20, %esi
callq 0x4330
jmp 0x2e5fe
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
movl $0x20, %esi
callq 0x4330
jmp 0x2e5fe
movq 0x150(%rsp), %rax
movq 0x160(%rax), %rdi
movss 0x40887(%rip), %xmm0    # 0x6db90
callq 0xf2b0
movss 0x100(%rsp), %xmm0
movq 0x150(%rsp), %rax
movss %xmm0, 0x168(%rax)
movss 0x104(%rsp), %xmm0
movq 0x150(%rsp), %rax
movss %xmm0, 0x16c(%rax)
movss 0x108(%rsp), %xmm0
movq 0x150(%rsp), %rax
movss %xmm0, 0x170(%rax)
leaq 0x110(%rsp), %rdi
callq 0x5ded0
cvtss2sd %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2d393
movq 0x150(%rsp), %rax
movss 0x40191(%rip), %xmm0    # 0x6d514
mulss 0x170(%rax), %xmm0
movss %xmm0, 0x170(%rax)
movq 0x150(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x174(%rax)
movl $0x0, 0xec(%rsp)
xorl %eax, %eax
cmpl $0x4, 0xec(%rsp)
movb %al, 0x47(%rsp)
jge 0x2d3db
movq 0x150(%rsp), %rax
movq 0x160(%rax), %rax
cmpl $0x0, 0x8(%rax)
seta %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
testb $0x1, %al
jne 0x2d3e5
jmp 0x2d437
movq 0x150(%rsp), %rax
movq 0x160(%rax), %rdi
movq 0x150(%rsp), %rsi
addq $0xec, %rsi
movslq 0xec(%rsp), %rax
imulq $0x14, %rax, %rax
addq %rax, %rsi
xorl %edx, %edx
movss 0x40774(%rip), %xmm0    # 0x6db90
callq 0x10450
movl 0xec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x2d3b1
movl $0x20, %edi
callq 0x4320
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x38(%rsp)
movq 0x150(%rsp), %rax
movq 0x160(%rax), %rax
movl 0x8(%rax), %esi
callq 0xe980
jmp 0x2d465
movq 0x38(%rsp), %rcx
movq 0x150(%rsp), %rax
movq %rcx, 0x140(%rax)
movl $0x0, 0xe8(%rsp)
movl 0xe8(%rsp), %eax
movq 0x150(%rsp), %rcx
movq 0x160(%rcx), %rcx
cmpl 0x8(%rcx), %eax
jae 0x2d536
movq 0x150(%rsp), %rdi
addq $0x54, %rdi
movq 0x150(%rsp), %rax
movq 0x160(%rax), %rax
movq 0x10(%rax), %rsi
movslq 0xe8(%rsp), %rax
imulq $0xc, %rax, %rax
addq %rax, %rsi
movq 0x150(%rsp), %rax
movq 0x140(%rax), %rax
movq 0x10(%rax), %rdx
movslq 0xe8(%rsp), %rax
imulq $0xc, %rax, %rax
addq %rax, %rdx
callq 0x5d920
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
jmp 0x2d484
movq 0x38(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf8(%rsp)
movl %eax, 0xf4(%rsp)
movl $0x20, %esi
callq 0x4330
jmp 0x2e5fe
movq 0x150(%rsp), %rax
movq 0x140(%rax), %rdi
movss 0x40643(%rip), %xmm0    # 0x6db90
callq 0xf2b0
movq 0x150(%rsp), %rax
movss 0x168(%rax), %xmm0
movq 0x150(%rsp), %rax
movss %xmm0, 0x148(%rax)
movq 0x150(%rsp), %rax
movss 0x16c(%rax), %xmm0
movq 0x150(%rsp), %rax
movss %xmm0, 0x14c(%rax)
movq 0x150(%rsp), %rax
movss 0x170(%rax), %xmm0
movq 0x150(%rsp), %rax
movss %xmm0, 0x150(%rax)
movq 0x150(%rsp), %rdi
addq $0x54, %rdi
callq 0x5ded0
cvtss2sd %xmm0, %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2d5f0
movq 0x150(%rsp), %rax
movss 0x3ff34(%rip), %xmm0    # 0x6d514
mulss 0x150(%rax), %xmm0
movss %xmm0, 0x150(%rax)
movq 0x150(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x154(%rax)
movq 0x140(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x2d621
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x150(%rsp), %rax
movl $0x0, 0x17c(%rax)
movq 0x148(%rsp), %rax
movswq 0x8(%rax), %rax
imulq $0xa8, %rax, %rdi
callq 0x4430
movq %rax, %rcx
movq 0x150(%rsp), %rax
movq %rcx, 0x180(%rax)
movq 0x150(%rsp), %rax
cmpq $0x0, 0x180(%rax)
setne %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x1, %esi
callq 0xbf00
movl $0x0, 0xe4(%rsp)
movl 0xe4(%rsp), %eax
movq 0x148(%rsp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x2e5f6
movq 0x150(%rsp), %rax
movq 0x180(%rax), %rax
movq 0x150(%rsp), %rcx
movslq 0x17c(%rcx), %rcx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xd8(%rsp)
movq 0x148(%rsp), %rax
movl 0x4(%rax), %eax
addl 0xe4(%rsp), %eax
movslq %eax, %rcx
leaq 0x1e52d3d(%rip), %rax   # 0x1e80430
movl (%rax,%rcx,4), %ecx
movl %ecx, %eax
negl %eax
cmovnsl %eax, %ecx
movq 0xd8(%rsp), %rax
movl %ecx, (%rax)
movq 0x148(%rsp), %rax
movl 0x4(%rax), %eax
addl 0xe4(%rsp), %eax
movslq %eax, %rcx
leaq 0x1e52d0d(%rip), %rax   # 0x1e80430
movl (%rax,%rcx,4), %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovll %eax, %ecx
movq 0xd8(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0xd8(%rsp), %rax
movslq (%rax), %rcx
leaq 0x21541e0(%rip), %rax   # 0x2181930
imulq $0xb0, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
testb $0x1, 0x39(%rax)
jne 0x2d775
jmp 0x2e5e0
movq 0xd0(%rsp), %rax
movq 0xd8(%rsp), %rcx
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rax
leaq 0x1bb8c7c(%rip), %rcx   # 0x1be6410
subq %rcx, %rax
movl $0x14, %ecx
cqto
idivq %rcx
movq 0x150(%rsp), %rcx
movslq 0x18(%rcx), %rcx
cmpq %rcx, %rax
je 0x2d7c0
leaq 0x4076a(%rip), %rdi     # 0x6df23
movb $0x0, %al
callq 0xb580
movq 0xd0(%rsp), %rax
addq $0x50, %rax
movq 0xd8(%rsp), %rcx
movslq 0x4(%rcx), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x70(%rsp)
movq 0xd0(%rsp), %rax
addq $0x50, %rax
movq 0xd8(%rsp), %rdx
movl $0x1, %ecx
subl 0x4(%rdx), %ecx
movslq %ecx, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x68(%rsp)
movq 0xd0(%rsp), %rax
movq 0xd8(%rsp), %rdx
movl $0x1, %ecx
subl 0x4(%rdx), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
leaq 0x1bb8bdb(%rip), %rcx   # 0x1be6410
subq %rcx, %rax
movl $0x14, %ecx
cqto
idivq %rcx
movl %eax, %ecx
movq 0xd8(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0xd8(%rsp), %rax
movl 0x8(%rax), %eax
movq 0x150(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x2d86c
jmp 0x2e5e0
movq 0xd8(%rsp), %rax
movb $0x0, 0xc(%rax)
movq 0xd8(%rsp), %rax
movslq (%rax), %rcx
leaq 0x1d38b86(%rip), %rax   # 0x1d66410
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movq 0xd8(%rsp), %rcx
movslq 0x4(%rcx), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %ecx
leaq 0x1038b56(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xc0(%rsp)
movq 0xc8(%rsp), %rax
movq 0xd8(%rsp), %rdx
movl $0x1, %ecx
subl 0x4(%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %ecx
leaq 0x1038b1f(%rip), %rax   # 0x1066410
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0xb8(%rsp)
movq 0xc0(%rsp), %rsi
leaq 0x110(%rsp), %rdi
leaq 0x94(%rsp), %rdx
callq 0x5d920
movq 0x150(%rsp), %rdi
addq $0x54, %rdi
leaq 0x94(%rsp), %rsi
movq 0xd8(%rsp), %rdx
addq $0x10, %rdx
callq 0x5d920
movq 0xd8(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x18(%rax)
movq 0xb8(%rsp), %rsi
leaq 0x110(%rsp), %rdi
leaq 0x94(%rsp), %rdx
callq 0x5d920
movq 0x150(%rsp), %rdi
addq $0x54, %rdi
leaq 0x94(%rsp), %rsi
movq 0xd8(%rsp), %rdx
addq $0x1c, %rdx
callq 0x5d920
movq 0xd8(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x24(%rax)
movq 0xd8(%rsp), %rax
movss 0x1c(%rax), %xmm0
movq 0xd8(%rsp), %rax
subss 0x10(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x28(%rax)
movq 0xd8(%rsp), %rax
movss 0x20(%rax), %xmm0
movq 0xd8(%rsp), %rax
subss 0x14(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x2c(%rax)
movq 0xd8(%rsp), %rax
movss 0x24(%rax), %xmm0
movq 0xd8(%rsp), %rax
subss 0x18(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x30(%rax)
movq 0xd8(%rsp), %rdi
addq $0x28, %rdi
callq 0x11980
movss %xmm0, 0xac(%rsp)
movss 0xac(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3fd98(%rip), %xmm0    # 0x6d7e0
ucomisd %xmm1, %xmm0
jb 0x2da53
jmp 0x2e5e0
xorps %xmm0, %xmm0
movss %xmm0, 0xb4(%rsp)
movss 0x3c5e5(%rip), %xmm0    # 0x6a04c
movss %xmm0, 0xb0(%rsp)
movl $0x0, 0x64(%rsp)
cmpl $0x4, 0x64(%rsp)
jge 0x2dd31
movq 0xd8(%rsp), %rax
movss 0x10(%rax), %xmm1
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm2
movq 0xd8(%rsp), %rax
movss 0x14(%rax), %xmm0
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0xd8(%rsp), %rax
movss 0x18(%rax), %xmm0
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x60(%rsp)
movq 0xd8(%rsp), %rax
movss 0x1c(%rax), %xmm1
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm2
movq 0xd8(%rsp), %rax
movss 0x20(%rax), %xmm0
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
mulss 0x4(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0xd8(%rsp), %rax
movss 0x24(%rax), %xmm0
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0x150(%rsp), %rax
addq $0x9c, %rax
movslq 0x64(%rsp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
subss 0xc(%rax), %xmm0
movss %xmm0, 0x5c(%rsp)
movss 0x60(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3fbdb(%rip), %xmm0    # 0x6d7e0
ucomisd %xmm1, %xmm0
jb 0x2dc45
movss 0x5c(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3fbc3(%rip), %xmm0    # 0x6d7e0
ucomisd %xmm1, %xmm0
jb 0x2dc45
movss 0x3c421(%rip), %xmm0    # 0x6a04c
movss %xmm0, 0xb4(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0xb0(%rsp)
jmp 0x2dd1f
xorps %xmm0, %xmm0
ucomiss 0x60(%rsp), %xmm0
jbe 0x2dcb1
movss 0xb4(%rsp), %xmm0
movss 0x60(%rsp), %xmm1
movss 0x60(%rsp), %xmm2
subss 0x5c(%rsp), %xmm2
divss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2dc84
movss 0xb4(%rsp), %xmm0
movss %xmm0, 0x2c(%rsp)
jmp 0x2dca0
movss 0x60(%rsp), %xmm0
movss 0x60(%rsp), %xmm1
subss 0x5c(%rsp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x2c(%rsp)
movss 0x2c(%rsp), %xmm0
movss %xmm0, 0xb4(%rsp)
jmp 0x2dd1d
xorps %xmm0, %xmm0
ucomiss 0x5c(%rsp), %xmm0
jbe 0x2dd1b
movss 0xb0(%rsp), %xmm1
movss 0x60(%rsp), %xmm0
movss 0x60(%rsp), %xmm2
subss 0x5c(%rsp), %xmm2
divss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2dcf0
movss 0xb0(%rsp), %xmm0
movss %xmm0, 0x28(%rsp)
jmp 0x2dd0c
movss 0x60(%rsp), %xmm0
movss 0x60(%rsp), %xmm1
subss 0x5c(%rsp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x28(%rsp)
movss 0x28(%rsp), %xmm0
movss %xmm0, 0xb0(%rsp)
jmp 0x2dd1d
jmp 0x2dd1f
jmp 0x2dd21
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x2da78
movss 0xac(%rsp), %xmm0
movss 0xb0(%rsp), %xmm1
subss 0xb4(%rsp), %xmm1
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3fa84(%rip), %xmm0    # 0x6d7e0
ucomisd %xmm1, %xmm0
jb 0x2dd67
jmp 0x2e5e0
movq 0xd8(%rsp), %rax
movss 0x10(%rax), %xmm1
movss 0xac(%rsp), %xmm0
mulss 0xb0(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x1c(%rax)
movq 0xd8(%rsp), %rax
movss 0x14(%rax), %xmm1
movss 0xac(%rsp), %xmm0
mulss 0xb0(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x2c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x20(%rax)
movq 0xd8(%rsp), %rax
movss 0x18(%rax), %xmm1
movss 0xac(%rsp), %xmm0
mulss 0xb0(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x24(%rax)
movq 0xd8(%rsp), %rax
movss 0x10(%rax), %xmm1
movss 0xac(%rsp), %xmm0
mulss 0xb4(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x10(%rax)
movq 0xd8(%rsp), %rax
movss 0x14(%rax), %xmm1
movss 0xac(%rsp), %xmm0
mulss 0xb4(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x2c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x14(%rax)
movq 0xd8(%rsp), %rax
movss 0x18(%rax), %xmm1
movss 0xac(%rsp), %xmm0
mulss 0xb4(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x18(%rax)
movq 0x150(%rsp), %rax
movb 0x20(%rax), %cl
movq 0xd8(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x34(%rax)
movq 0x150(%rsp), %rax
movss 0x84(%rax), %xmm1
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm2
movq 0x150(%rsp), %rax
movss 0x88(%rax), %xmm0
movq 0xd8(%rsp), %rax
mulss 0x2c(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0x150(%rsp), %rax
movss 0x8c(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xa8(%rsp)
movq 0xd8(%rsp), %rax
movss 0x10(%rax), %xmm1
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm2
movq 0xd8(%rsp), %rax
movss 0x14(%rax), %xmm0
movq 0xd8(%rsp), %rax
mulss 0x2c(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0xd8(%rsp), %rax
movss 0x18(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xa4(%rsp)
movq 0xd8(%rsp), %rax
movss 0x1c(%rax), %xmm1
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm2
movq 0xd8(%rsp), %rax
movss 0x20(%rax), %xmm0
movq 0xd8(%rsp), %rax
mulss 0x2c(%rax), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movq 0xd8(%rsp), %rax
movss 0x24(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0xa0(%rsp)
movss 0xa4(%rsp), %xmm0
movss %xmm0, 0x24(%rsp)
movss 0xa8(%rsp), %xmm1
movss 0xa0(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2e07b
movss 0xa8(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
jmp 0x2e08a
movss 0xa0(%rsp), %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x24(%rsp), %xmm0
movss 0x20(%rsp), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x2e0ac
movss 0xa4(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
jmp 0x2e0ef
movss 0xa8(%rsp), %xmm1
movss 0xa0(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2e0d4
movss 0xa8(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
jmp 0x2e0e3
movss 0xa0(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
movss 0x18(%rsp), %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x1c(%rsp), %xmm0
movss %xmm0, 0xa8(%rsp)
movq 0xd8(%rsp), %rax
movss 0x10(%rax), %xmm1
movss 0xa8(%rsp), %xmm0
subss 0xa4(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x88(%rsp)
movq 0xd8(%rsp), %rax
movss 0x14(%rax), %xmm1
movss 0xa8(%rsp), %xmm0
subss 0xa4(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x2c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x8c(%rsp)
movq 0xd8(%rsp), %rax
movss 0x18(%rax), %xmm1
movss 0xa8(%rsp), %xmm0
subss 0xa4(%rsp), %xmm0
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x90(%rsp)
movss 0x88(%rsp), %xmm0
movq 0x150(%rsp), %rax
subss 0x84(%rax), %xmm0
movss %xmm0, 0x88(%rsp)
movss 0x8c(%rsp), %xmm0
movq 0x150(%rsp), %rax
subss 0x88(%rax), %xmm0
movss %xmm0, 0x8c(%rsp)
movss 0x90(%rsp), %xmm0
movq 0x150(%rsp), %rax
subss 0x8c(%rax), %xmm0
movss %xmm0, 0x90(%rsp)
movss 0x88(%rsp), %xmm0
mulss 0x88(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x8c(%rsp), %xmm1
mulss 0x8c(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
movss 0x90(%rsp), %xmm1
mulss 0x90(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
addsd %xmm1, %xmm0
callq 0x4270
cvtsd2ss %xmm0, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x38(%rax)
movq 0xd8(%rsp), %rax
movss 0x2c(%rax), %xmm0
movq 0x150(%rsp), %rax
movss 0x150(%rax), %xmm2
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm1
movq 0x150(%rsp), %rax
mulss 0x14c(%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x7c(%rsp)
movq 0xd8(%rsp), %rax
movss 0x30(%rax), %xmm0
movq 0x150(%rsp), %rax
movss 0x148(%rax), %xmm2
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm1
movq 0x150(%rsp), %rax
mulss 0x150(%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x80(%rsp)
movq 0xd8(%rsp), %rax
movss 0x28(%rax), %xmm0
movq 0x150(%rsp), %rax
movss 0x14c(%rax), %xmm2
movq 0xd8(%rsp), %rax
movss 0x2c(%rax), %xmm1
movq 0x150(%rsp), %rax
mulss 0x148(%rax), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x84(%rsp)
leaq 0x7c(%rsp), %rdi
callq 0x11980
movss 0x88(%rsp), %xmm1
movss 0x7c(%rsp), %xmm2
movss 0x8c(%rsp), %xmm0
mulss 0x80(%rsp), %xmm0
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0x90(%rsp), %xmm0
movss 0x84(%rsp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x3c(%rax)
movq 0x150(%rsp), %rax
movss 0x1c(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xd0(%rsp), %rax
movss 0x34(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3edde(%rip), %xmm0    # 0x6d1e8
ucomisd %xmm1, %xmm0
jbe 0x2e429
movq 0xd0(%rsp), %rax
movss 0x34(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x2e439
movsd 0x3edb7(%rip), %xmm0    # 0x6d1e8
movsd %xmm0, 0x8(%rsp)
jmp 0x2e439
movsd 0x8(%rsp), %xmm0
callq 0x42f0
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x40(%rax)
movq 0x68(%rsp), %rax
movss 0x20(%rax), %xmm0
movq 0xd8(%rsp), %rax
movss %xmm0, 0x44(%rax)
movq 0xd8(%rsp), %rax
movss 0x44(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3bbd6(%rip), %xmm0    # 0x6a068
ucomisd %xmm1, %xmm0
jae 0x2e4bf
movq 0xd8(%rsp), %rax
movss 0x3bba4(%rip), %xmm0    # 0x6a04c
divss 0x44(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x3bbaf(%rip), %xmm0    # 0x6a068
ucomisd %xmm1, %xmm0
jb 0x2e51f
movq 0x150(%rsp), %rax
movl 0x18(%rax), %edx
movq 0xd8(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0xc0(%rsp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq 0xc0(%rsp), %rax
movss 0x4(%rax), %xmm1
cvtss2sd %xmm1, %xmm1
movq 0xc0(%rsp), %rax
movss 0x8(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movl $0x5, %edi
leaq 0x3f90c(%rip), %rsi     # 0x6de1f
movb $0x3, %al
callq 0xbbf0
jmp 0x2e5e0
movq 0xd8(%rsp), %rax
movss 0x44(%rax), %xmm0
movss 0x3bb18(%rip), %xmm1    # 0x6a04c
subss %xmm1, %xmm0
callq 0x11ce0
cvtss2sd %xmm0, %xmm1
movsd 0x3f69f(%rip), %xmm0    # 0x6dbe8
ucomisd %xmm1, %xmm0
jbe 0x2e587
movq 0x70(%rsp), %rsi
movq 0xd8(%rsp), %rdi
addq $0x48, %rdi
movl $0x30, %edx
callq 0x4280
movq 0x68(%rsp), %rsi
movq 0xd8(%rsp), %rdi
addq $0x78, %rdi
movl $0x30, %edx
callq 0x4280
jmp 0x2e5c9
movq 0xd8(%rsp), %rax
movb $0x0, 0x34(%rax)
movq 0x70(%rsp), %rsi
movq 0xd8(%rsp), %rdi
addq $0x48, %rdi
movl $0x30, %edx
callq 0x4280
movq 0x68(%rsp), %rsi
movq 0xd8(%rsp), %rdi
addq $0x78, %rdi
movl $0x30, %edx
callq 0x4280
movq 0x150(%rsp), %rax
movl 0x17c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x17c(%rax)
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0x2d68c
addq $0x158, %rsp            # imm = 0x158
retq
movq 0xf8(%rsp), %rdi
callq 0x45c0
nopl (%rax,%rax)