// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/lightmap.cpp
// Function: SetSampleFromST(float*, float*, int*, bool*, lightinfo_t const*, float, float, float const (*) [2], eModelLightmodes)
static light_flag_t SetSampleFromST(vec_t* const point,
#ifdef HLRAD_GROWSAMPLE
									vec_t* const position, // a valid world position for light tracing
									int* const surface, // the face used for phong normal and patch interpolation
#endif
#ifdef HLRAD_AVOIDWALLBLEED
									bool *nudged,
#endif
									const lightinfo_t* const l, const vec_t original_s, const vec_t original_t,
#ifdef HLRAD_GROWSAMPLE
#ifdef HLRAD_BLUR_MINIMALSQUARE
									const vec_t square[2][2], // {smin, tmin}, {smax, tmax}
#else
									const vec_t reach, // the size of the square that grows
#endif
#endif
									eModelLightmodes lightmode)
{
#ifdef HLRAD_GROWSAMPLE
	light_flag_t LuxelFlag;
	int facenum;
	dface_t *face;
	const dplane_t*	faceplane;
	samplefraginfo_t *fraginfo;
	samplefrag_t *f;

	facenum = l->surfnum;
	face = l->face;
	faceplane = getPlaneFromFace (face);
	
	fraginfo = CreateSampleFrag (facenum, original_s, original_t, 
#ifdef HLRAD_BLUR_MINIMALSQUARE
		square,
#else
		reach, 
#endif
		100);
	
	bool found;
	samplefrag_t *bestfrag;
	vec3_t bestpos;
	vec_t bests, bestt;
	vec_t best_dist;
#ifdef HLRAD_AVOIDWALLBLEED
	bool best_nudged;
#endif

	found = false;
	for (f = fraginfo->head; f; f = f->next)
	{
		vec3_t pos;
		vec_t s, t;
		vec_t dist;

#ifdef HLRAD_AVOIDWALLBLEED
		bool nudged_one;
#endif
		if (!FindNearestPosition (f->facenum, f->mywinding, f->mywindingplane, f->myorigin[0], f->myorigin[1], pos, &s, &t, &dist
#ifdef HLRAD_AVOIDWALLBLEED
									, &nudged_one
#endif
									))
		{
			continue;
		}

		bool better;

		if (!found)
		{
			better = true;
		}
#ifdef HLRAD_AVOIDWALLBLEED
		else if (nudged_one != best_nudged)
		{
			better = !nudged_one;
		}
#endif
		else if (fabs (dist - best_dist) > 2 * ON_EPSILON)
		{
			better = (dist < best_dist);
		}
		else if (f->noseam != bestfrag->noseam)
		{
			better = (f->noseam && !bestfrag->noseam);
		}
		else
		{
			better = (f->facenum < bestfrag->facenum);
		}

		if (better)
		{
			found = true;
			bestfrag = f;
			VectorCopy (pos, bestpos);
			bests = s;
			bestt = t;
			best_dist = dist;
#ifdef HLRAD_AVOIDWALLBLEED
			best_nudged = nudged_one;
#endif
		}
	}
	
	if (found)
	{
		matrix_t worldtotex, textoworld;
		vec3_t tex;

		TranslateWorldToTex (bestfrag->facenum, worldtotex);
		if (!InvertMatrix (worldtotex, textoworld))
		{
			const unsigned facenum = bestfrag->facenum;
			ThreadLock ();
			Log ("Malformed face (%d) normal @ \n", facenum);
			Winding* w = new Winding (g_dfaces[facenum]);
			for (int x = 0; x < w->m_NumPoints; x++)
			{
				VectorAdd (w->m_Points[x], g_face_offset[facenum], w->m_Points[x]);
			}
			w->Print ();
			delete w;
			ThreadUnlock ();
			hlassume (false, assume_MalformedTextureFace);
		}
		
		// point
		tex[0] = bests;
		tex[1] = bestt;
		tex[2] = 0.0;
		{vec3_t v; ApplyMatrix (textoworld, tex, v); VectorCopy (v, point);}
		VectorAdd (point, g_face_offset[bestfrag->facenum], point);
		// position
		VectorCopy (bestpos, position);
		// surface
		*surface = bestfrag->facenum;
#ifdef HLRAD_AVOIDWALLBLEED
		// whether nudged to fit
		*nudged = best_nudged;
#endif
		// returned value
		LuxelFlag = LightNormal;
	}
	else
	{
		SetSurfFromST (l, point, original_s, original_t);
		VectorMA (point, DEFAULT_HUNT_OFFSET, faceplane->normal, position);
		*surface = facenum;
#ifdef HLRAD_AVOIDWALLBLEED
		*nudged = true;
#endif
		LuxelFlag = LightOutside;
	}

	DeleteSampleFrag (fraginfo);
	
	return LuxelFlag;

#else
	light_flag_t	LuxelFlag = LightOutside;
	int				huntsize = 3;
	vec_t			huntscale = 0.2;
	vec_t			width = DEFAULT_EDGE_WIDTH;

	int				facenum = l->surfnum;
	const vec_t*	face_delta = g_face_offset[facenum];

	const dface_t*	f = &g_dfaces[facenum];
	const dplane_t*	p = getPlaneFromFace (f);
	Winding			*wd = new Winding (*f);
	{
		int				j;
		for (j = 0; j < wd->m_NumPoints; j++)
		{
			VectorAdd (wd->m_Points[j], face_delta, wd->m_Points[j]);
		}
	}

	const vec_t*	face_centroid = g_face_centroids[facenum];
	vec_t			mids, midt;
	SetSTFromSurf (l, face_centroid, mids, midt);

	vec3_t			surf_original;
	dleaf_t*		leaf_original;
	SetSurfFromST (l, surf_original, original_s, original_t);
	leaf_original = HuntForWorld (surf_original, face_delta, p, 1, 0.0, DEFAULT_HUNT_OFFSET);

	int				facenum_tosnap = PointInFace (l, surf_original);
	const dface_t*	f_tosnap = &g_dfaces[facenum_tosnap];
	const dplane_t*	p_tosnap = getPlaneFromFace (f_tosnap);
#ifdef HLRAD_SMOOTH_TEXNORMAL
	vec3_t			snapdir;
	if (!GetIntertexnormal (facenum, facenum_tosnap, snapdir))
	{
		facenum_tosnap = facenum;
		f_tosnap = f;
		p_tosnap = p;
	}
#endif

	vec3_t			surf_direct;
	dleaf_t*		leaf_direct;
	VectorCopy (surf_original, surf_direct);
	{
		vec_t dist;
		vec_t scale;
#ifdef HLRAD_SMOOTH_TEXNORMAL
		scale = DotProduct (snapdir, p_tosnap->normal);
#else
		scale = DotProduct (l->texnormal, p_tosnap->normal);
#endif
		dist = DotProduct (surf_direct, p_tosnap->normal) - DotProduct (face_delta, p_tosnap->normal) - p_tosnap->dist - DEFAULT_HUNT_OFFSET;
#ifdef HLRAD_SMOOTH_TEXNORMAL
		VectorMA (surf_direct, - dist / scale, snapdir, surf_direct);
#else
		VectorMA (surf_direct, - dist / scale, l->texnormal, surf_direct);
#endif
	}
	leaf_direct = HuntForWorld (surf_direct, face_delta, p_tosnap, huntsize, huntscale, DEFAULT_HUNT_OFFSET);

	if (LuxelFlag == LightOutside)
	{
		if (leaf_direct && point_in_winding_noedge (*wd, *p, surf_direct, width))
		{
			LuxelFlag = LightNormal;
			VectorCopy (surf_direct, point);
		}
	}

	if (LuxelFlag == LightOutside)
	{
		bool	blocked_direct;
		bool	blocked_inwinding;
		bool	blocked_inwinding_noedge;
		vec3_t	surf_inwinding;
		vec3_t	surf_inwinding_noedge;
		dleaf_t*leaf_inwinding;
		dleaf_t*leaf_inwinding_noedge;
#ifdef HLRAD_HULLU
		vec3_t transparency = { 1.0, 1.0, 1.0 };
#endif
#ifdef HLRAD_OPAQUE_STYLE
		int opaquestyle;
#endif
		{
			blocked_direct = (leaf_direct == NULL);
			if (!point_in_winding (*wd, *p, surf_original))
			{
				VectorCopy (surf_original, surf_inwinding);
				snap_to_winding (*wd, *p, surf_inwinding);
				leaf_inwinding = HuntForWorld (surf_inwinding, face_delta, p, huntsize, huntscale, DEFAULT_HUNT_OFFSET);
				if ( blocked_direct
					|| !leaf_inwinding
					|| TestLine (surf_direct, surf_inwinding) != CONTENTS_EMPTY
					|| TestSegmentAgainstOpaqueList (surf_direct, surf_inwinding
	#ifdef HLRAD_HULLU
						, transparency
	#endif
	#ifdef HLRAD_OPAQUE_STYLE
						, opaquestyle
	#endif
						) == true
	#ifdef HLRAD_OPAQUE_STYLE
					|| opaquestyle != -1
	#endif
	#ifdef HLRAD_TRANSLUCENT
					|| l->translucent_b
	#endif
					)
				{
					blocked_direct = true;
				}
			}
			else
			{
				VectorCopy (surf_original, surf_inwinding);
				leaf_inwinding = leaf_original;
			}
			blocked_inwinding = (leaf_inwinding == NULL);
			if (!point_in_winding_noedge (*wd, *p, surf_inwinding, width))
			{
				VectorCopy (surf_inwinding, surf_inwinding_noedge);
				snap_to_winding_noedge (*wd, *p, surf_inwinding_noedge, width, 4 * width);
				leaf_inwinding_noedge = HuntForWorld (surf_inwinding_noedge, face_delta, p, huntsize, huntscale, DEFAULT_HUNT_OFFSET);
				if ( blocked_inwinding
					|| !leaf_inwinding_noedge
					|| TestLine (surf_inwinding, surf_inwinding_noedge) != CONTENTS_EMPTY
					|| TestSegmentAgainstOpaqueList (surf_inwinding, surf_inwinding_noedge
	#ifdef HLRAD_HULLU
						, transparency
	#endif
	#ifdef HLRAD_OPAQUE_STYLE
						, opaquestyle
	#endif
						) == true
	#ifdef HLRAD_OPAQUE_STYLE
					|| opaquestyle != -1
	#endif
					)
				{
					blocked_inwinding = true;
				}
			}
			else
			{
				VectorCopy (surf_inwinding, surf_inwinding_noedge);
				leaf_inwinding_noedge = leaf_inwinding;
			}
			blocked_inwinding_noedge = (leaf_inwinding_noedge == NULL);
			if (blocked_inwinding_noedge == true)
			{
				blocked_inwinding = true;
			}
			if (blocked_inwinding == true)
			{
				blocked_direct = true;
			}
		}
		if (!blocked_direct)
		{
			LuxelFlag = LightNormal;
			VectorCopy (surf_direct, point);
		}
		else if (!blocked_inwinding)
		{
			LuxelFlag = LightPulledInside;
			VectorCopy (surf_inwinding, point);
		}
		else if (!blocked_inwinding_noedge)
		{
			LuxelFlag = LightPulledInside;
			VectorCopy (surf_inwinding_noedge, point);
		}
	}

	if (LuxelFlag == LightOutside)
	{
		// this part is very slow
		const int numnudges = 13;
		vec_t nudgelist[numnudges][2] = {{0,0},{0.6,0},{0,0.6},{-0.6,0},{0,-0.6},{1.1,1.1},{1.1,-1.1},{-1.1,1.1},{-1.1,-1.1},{1.6,0},{0,1.6},{-1.6,0},{0,-1.6}};
		vec_t nudgescale_s, nudgescale_t;
		nudgescale_s = original_s <= mids? TEXTURE_STEP: -TEXTURE_STEP;
		nudgescale_t = original_t <= midt? TEXTURE_STEP: -TEXTURE_STEP;
		int i;
		for (i = 0; i < numnudges; i++)
		{
			vec_t s1 = original_s + nudgelist[i][0] * nudgescale_s;
			vec_t t1 = original_t + nudgelist[i][1] * nudgescale_t;
			vec3_t surf;
			SetSurfFromST(l, surf, s1, t1);
			if (point_in_winding (*wd, *p, surf) && HuntForWorld (surf, face_delta, p, 2, 0.5, DEFAULT_HUNT_OFFSET) && point_in_winding (*wd, *p, surf))
			{
				LuxelFlag = LightSimpleNudge;
				VectorCopy (surf, point);
				break;
			}
		}
	}

	if (LuxelFlag == LightOutside)
	{
		VectorCopy (surf_original, point);
	}

	delete wd;
	return LuxelFlag;
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r9, %r13
movss %xmm1, 0x34(%rsp)
movss %xmm0, 0x30(%rsp)
movq %rcx, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdi, 0x50(%rsp)
movl 0x135c(%r8), %r15d
movq %r8, 0x80(%rsp)
movq 0x1360(%r8), %rdi
callq 0x2b6a1
movq %rax, 0x88(%rsp)
pushq $0x10
popq %rdi
callq 0x4420
movq %rax, %rbx
movq %rax, %r12
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0x92cb
movabsq $0x100000064, %rax      # imm = 0x100000064
movq %rax, (%rbx)
movl $0x188, %edi            # imm = 0x188
callq 0x4420
movq %rax, %r14
movq %rbx, 0x20(%rsp)
movq %rax, 0x8(%rbx)
xorl %edi, %edi
testq %rax, %rax
setne %dil
movl %ebp, %esi
callq 0x92cb
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
andq $0x0, 0x10(%r14)
movl %r15d, 0x44(%rsp)
movl %r15d, 0x18(%r14)
andl $0x0, 0x1c(%r14)
movb $0x1, 0x20(%r14)
leaq 0x24(%r14), %rsi
leaq 0x1b706(%rip), %rbx     # 0x33d30
movss 0x19a32(%rip), %xmm0    # 0x32064
movq %rbx, %rdi
callq 0x2bda9
leaq 0x54(%r14), %rsi
movq %rbx, %rdi
movss 0x19a1b(%rip), %xmm0    # 0x32064
callq 0x2bda9
movss 0x30(%rsp), %xmm1
movss %xmm1, 0x84(%r14)
movss 0x34(%rsp), %xmm0
movss %xmm0, 0x88(%r14)
andl $0x0, 0x8c(%r14)
movss %xmm1, 0x90(%r14)
movss %xmm0, 0x94(%r14)
movsd 0x1d3f2(%rip), %xmm0    # 0x35a80
movups %xmm0, 0x98(%r14)
movss (%r13), %xmm0
movss %xmm0, 0xa8(%r14)
movsd 0x1d4e3(%rip), %xmm0    # 0x35b90
movsd %xmm0, 0xb0(%r14)
movl $0x80000000, %eax       # imm = 0x80000000
movl %eax, 0xb8(%r14)
movss 0x8(%r13), %xmm0
movaps 0x1cbc1(%rip), %xmm1    # 0x35290
xorps %xmm1, %xmm0
movss %xmm0, 0xbc(%r14)
movsd 0x1d39d(%rip), %xmm0    # 0x35a80
movsd %xmm0, 0xc4(%r14)
andl $0x0, 0xcc(%r14)
leaq 0x9c(%r14), %rsi
movss 0x4(%r13), %xmm0
movss %xmm0, 0xd0(%r14)
movsd 0x1d48e(%rip), %xmm0    # 0x35ba0
movsd %xmm0, 0xd8(%r14)
movl %eax, 0xe0(%r14)
movss 0xc(%r13), %xmm0
xorps %xmm1, %xmm0
movss %xmm0, 0xe4(%r14)
leaq 0xec(%r14), %rdi
pushq $0x14
popq %rcx
rep  movsl (%rsi), %es:(%rdi)
movq %r14, %rdi
callq 0x14fec
movq 0x140(%r14), %rdi
movq 0x160(%r14), %rax
xorl %ecx, %ecx
cmpl %ecx, 0x8(%rdi)
je 0x1879f
cmpl $0x0, 0x8(%rax)
je 0x187a4
movq 0x180(%r14), %rcx
movq %rcx, %rax
movslq 0x17c(%r14), %rdx
imulq $0xa8, %rdx, %rdx
addq %rcx, %rdx
cmpq %rdx, %rax
jae 0x187e1
movl 0x8(%rax), %edx
cmpl 0x18(%r14), %edx
jne 0x18797
movb $0x1, 0xc(%rax)
movq 0x180(%r14), %rcx
addq $0xa8, %rax
jmp 0x1876d
testq %rax, %rax
je 0x187b9
movq (%rax), %rcx
movq %rax, %rdi
callq *0x8(%rcx)
movq 0x140(%r14), %rdi
testq %rdi, %rdi
je 0x187bf
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x180(%r14), %rdi
callq 0x4380
movq %r14, %rdi
callq 0x4380
andq $0x0, 0x8(%r12)
andl $0x0, 0x4(%r12)
xorl %ebp, %ebp
addq $0x8, 0x20(%rsp)
pushq $0x64
popq %rax
movsd 0x1cde6(%rip), %xmm4    # 0x355d8
movaps 0x1caa7(%rip), %xmm3    # 0x352a0
movsd 0x1cda7(%rip), %xmm5    # 0x355a8
movq %r12, 0x8(%rsp)
cmpl %eax, %ebp
jge 0x18dfa
xorl %eax, %eax
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x188f7
movq 0x180(%rcx), %rdx
movslq 0x17c(%rcx), %rsi
imulq $0xa8, %rsi, %rsi
addq %rdx, %rsi
cmpq %rsi, %rdx
jae 0x18815
cmpb $0x0, 0xc(%rdx)
jne 0x188bb
testb $0x1, %al
je 0x188b3
cvtss2sd 0x40(%rdx), %xmm0
ucomisd %xmm0, %xmm4
seta %dil
cvtss2sd 0x40(%r13), %xmm1
ucomisd %xmm1, %xmm4
seta %r8b
cmpb %r8b, %dil
je 0x18876
ucomisd %xmm0, %xmm4
jbe 0x188bb
ucomisd %xmm1, %xmm4
jbe 0x188b3
jmp 0x188bb
movb 0x34(%rdx), %r8b
movb 0x34(%r13), %dil
cmpb %dil, %r8b
jne 0x188a9
movss 0x38(%rdx), %xmm0
movss 0x38(%r13), %xmm1
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
andps %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
ucomisd %xmm5, %xmm2
jbe 0x188c7
ucomiss %xmm0, %xmm1
ja 0x188b3
jmp 0x188bb
testb %r8b, %r8b
je 0x188bb
testb %dil, %dil
jne 0x188bb
movb $0x1, %al
movq %rcx, %r15
movq %rdx, %r13
addq $0xa8, %rdx
jmp 0x18839
movss 0x3c(%rdx), %xmm0
movss 0x3c(%r13), %xmm1
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
andps %xmm3, %xmm2
cvtss2sd %xmm2, %xmm2
ucomisd %xmm5, %xmm2
jbe 0x188ed
ucomiss %xmm1, %xmm0
ja 0x188b3
jmp 0x188bb
movl (%rdx), %edi
cmpl (%r13), %edi
jl 0x188b3
jmp 0x188bb
testb $0x1, %al
je 0x18dfa
movl $0x188, %edi            # imm = 0x188
callq 0x4420
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
andq $0x0, (%r14)
movq %r15, 0x8(%r14)
movq %r13, 0x10(%r14)
movl 0x8(%r13), %eax
movl %eax, 0x18(%r14)
movss 0x40(%r13), %xmm0
movss %xmm0, 0x1c(%r14)
movb 0x34(%r13), %al
movb %al, 0x20(%r14)
leaq 0x48(%r13), %rdi
leaq 0x24(%r15), %rsi
leaq 0x24(%r14), %rbx
movq %rbx, %rdx
callq 0x2bceb
leaq 0x54(%r15), %rdi
leaq 0x78(%r13), %rsi
leaq 0x54(%r14), %rbp
movq %rbp, %rdx
callq 0x2bceb
movss 0x84(%r15), %xmm0
leaq 0x84(%r14), %rsi
movss %xmm0, 0x84(%r14)
movss 0x88(%r15), %xmm0
movss %xmm0, 0x88(%r14)
movss 0x8c(%r15), %xmm0
movss %xmm0, 0x8c(%r14)
leaq 0x90(%r14), %rdx
movq %rbx, %rdi
callq 0x2bb9d
movl $0x9c, %eax
leaq (%r15,%rax), %rsi
leaq (%r14,%rax), %rdi
pushq $0x14
popq %rcx
rep  movsl (%rsi), %es:(%rdi)
leaq 0xf8(%r14), %r12
pushq $0x4
popq %rbx
subq $0x1, %rbx
jb 0x18a97
leaq -0x5c(%r12), %rsi
movss -0x50(%r12), %xmm0
leaq -0xc(%r12), %rdx
movq %rbp, %rdi
movq %r12, %rcx
callq 0x2bc3d
movsd -0xc(%r12), %xmm2
movaps %xmm2, %xmm0
mulps %xmm2, %xmm0
cvtps2pd %xmm0, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movss -0x4(%r12), %xmm1
movaps %xmm1, %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm3, %xmm0
sqrtsd %xmm0, %xmm0
ucomisd 0x1cbdf(%rip), %xmm0    # 0x35618
jne 0x18a41
jnp 0x18c04
cvtps2pd %xmm2, %xmm2
movsd 0x1c67c(%rip), %xmm3    # 0x350c8
divsd %xmm0, %xmm3
movapd %xmm3, %xmm4
unpcklpd %xmm3, %xmm4            # xmm4 = xmm4[0],xmm3[0]
mulpd %xmm2, %xmm4
cvtpd2ps %xmm4, %xmm2
cvtss2sd %xmm1, %xmm1
mulsd %xmm3, %xmm1
movlpd %xmm2, -0xc(%r12)
cvtsd2ss %xmm1, %xmm1
movss %xmm1, -0x4(%r12)
cvtss2sd (%r12), %xmm1
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, (%r12)
addq $0x14, %r12
jmp 0x189d5
movq %r14, %rdi
callq 0x14fec
movq 0x140(%r14), %rdi
movq 0x160(%r14), %rax
movl 0x8(%rdi), %ecx
testq %rcx, %rcx
je 0x18ccb
cmpl $0x0, 0x8(%rax)
movq 0x8(%rsp), %rbx
je 0x18cd5
imulq $0x14, %rcx, %rdi
callq 0x4420
movq %rax, %rbx
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
movq $0x0, 0x28(%rsp)
xorl %ebp, %ebp
xorl %eax, %eax
movq %rbx, 0x18(%rsp)
movl %eax, 0x14(%rsp)
movl %eax, %eax
imulq $0x14, %rax, %r12
addq %rbx, %r12
movl %ebp, %eax
movq 0x140(%r14), %rdx
movl 0x8(%rdx), %ecx
cmpl %ecx, %eax
jae 0x18c23
movq 0x10(%rdx), %rdx
leal 0x1(%rax), %ebp
cmpl %ecx, %ebp
movl %ebp, %ecx
movl $0x0, %esi
cmovel %esi, %ecx
imulq $0xc, %rcx, %rcx
movss (%rdx,%rcx), %xmm0
cltq
imulq $0xc, %rax, %rbx
subss (%rdx,%rbx), %xmm0
movss 0x148(%r14), %xmm1
movsd 0x4(%rdx,%rcx), %xmm2
movsd 0x4(%rdx,%rbx), %xmm3
subps %xmm3, %xmm2
movsd 0x14c(%r14), %xmm3
movaps %xmm0, %xmm4
shufps $0xd4, %xmm2, %xmm4     # xmm4 = xmm4[0,1],xmm2[1,3]
shufps $0x52, %xmm2, %xmm4     # xmm4 = xmm4[2,0],xmm2[1,1]
mulps %xmm3, %xmm4
movaps %xmm1, %xmm5
shufps $0xd4, %xmm3, %xmm5     # xmm5 = xmm5[0,1],xmm3[1,3]
shufps $0x52, %xmm3, %xmm5     # xmm5 = xmm5[2,0],xmm3[1,1]
mulps %xmm2, %xmm5
subps %xmm4, %xmm5
movlps %xmm5, (%r12)
mulss %xmm1, %xmm2
mulss %xmm3, %xmm0
subss %xmm2, %xmm0
movss %xmm0, 0x8(%r12)
movq %r12, %rdi
callq 0xc021
ucomiss 0x194ca(%rip), %xmm0    # 0x32070
movl %ebp, %eax
jne 0x18bb0
jnp 0x18b06
movq 0x140(%r14), %rax
movq 0x10(%rax), %rax
movss (%rax,%rbx), %xmm0
movss 0x4(%rax,%rbx), %xmm1
mulss 0x4(%r12), %xmm1
mulss (%r12), %xmm0
addss %xmm1, %xmm0
movss 0x8(%rax,%rbx), %xmm1
mulss 0x8(%r12), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0xc(%r12)
movl 0x14(%rsp), %eax
incl %eax
incq 0x28(%rsp)
movq 0x18(%rsp), %rbx
jmp 0x18af7
movl 0x18(%r14), %edx
pushq $0x6
popq %rdi
leaq 0x1d799(%rip), %rsi     # 0x363ab
xorl %eax, %eax
callq 0x9045
movq 0x8(%rsp), %rbx
jmp 0x18cfc
xorl %ebp, %ebp
movq 0x20(%rsp), %rbx
movq %r14, 0x38(%rsp)
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x18ca2
testb $0x1, %bpl
jne 0x18ca2
pushq $0x20
popq %rdi
callq 0x42e0
movq %rax, %r12
movq 0x140(%rbx), %rsi
movq %rax, %rdi
callq 0xaab8
movq 0x28(%rsp), %r14
movq 0x18(%rsp), %rbp
movl 0x8(%r12), %eax
subq $0x1, %r14
jb 0x18c8b
testl %eax, %eax
je 0x18c8b
movq %r12, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movss 0x1cd48(%rip), %xmm0    # 0x359c8
callq 0xb632
addq $0x14, %rbp
jmp 0x18c61
testl %eax, %eax
setne %bpl
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq 0x38(%rsp), %r14
jmp 0x18c2f
movq 0x18(%rsp), %rdi
callq 0x4380
testb $0x1, %bpl
je 0x18d2a
movq 0x160(%r14), %rdi
testq %rdi, %rdi
movq 0x8(%rsp), %rbx
je 0x18cde
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x18cde
testq %rax, %rax
movq 0x8(%rsp), %rbx
je 0x18cea
movq (%rax), %rcx
movq %rax, %rdi
callq *0x8(%rcx)
movq 0x140(%r14), %rdi
testq %rdi, %rdi
je 0x18cf0
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x180(%r14), %rdi
callq 0x4380
movq %r14, %rdi
callq 0x4380
movb $0x1, 0xc(%r13)
movl 0x4(%rbx), %ebp
movaps 0x1c58d(%rip), %xmm3    # 0x352a0
movsd 0x1c8bd(%rip), %xmm4    # 0x355d8
movsd 0x1c885(%rip), %xmm5    # 0x355a8
movl (%rbx), %eax
jmp 0x18806
movb $0x1, 0xc(%r13)
movq 0x8(%rsp), %rbx
movl 0x4(%rbx), %ebp
testq %r14, %r14
movaps 0x1c55f(%rip), %xmm3    # 0x352a0
movsd 0x1c88f(%rip), %xmm4    # 0x355d8
movsd 0x1c857(%rip), %xmm5    # 0x355a8
je 0x18d23
movq 0x8(%rbx), %rax
movq %rax, (%r14)
movq %r14, 0x8(%rbx)
incl %ebp
movl %ebp, 0x4(%rbx)
movq %r14, %rax
testq %rax, %rax
je 0x18dac
movq 0x180(%r14), %rdx
movq %rdx, %rcx
movslq 0x17c(%r14), %rsi
imulq $0xa8, %rsi, %rsi
addq %rdx, %rsi
cmpq %rsi, %rcx
jae 0x18da7
movl 0x8(%rcx), %esi
cmpl 0x18(%rax), %esi
jne 0x18d9e
movb $0x1, 0xc(%rcx)
movq 0x180(%r14), %rdx
addq $0xa8, %rcx
jmp 0x18d75
movq (%rax), %rax
jmp 0x18d66
movq %r14, %rax
testq %rax, %rax
je 0x18d23
movq 0x180(%rax), %rdx
movq %rdx, %rcx
movslq 0x17c(%rax), %rsi
imulq $0xa8, %rsi, %rsi
addq %rdx, %rsi
cmpq %rsi, %rcx
jae 0x18df5
movl 0x8(%rcx), %esi
cmpl 0x18(%r14), %esi
jne 0x18dec
movb $0x1, 0xc(%rcx)
movq 0x180(%rax), %rdx
addq $0xa8, %rcx
jmp 0x18dc2
movq (%rax), %rax
jmp 0x18daf
leaq 0x70(%rsp), %r15
leaq 0xb8(%rsp), %r14
leaq 0xe8(%rsp), %r13
leaq 0x94(%rsp), %rbp
xorl %ebx, %ebx
movq 0x20(%rsp), %r12
movq (%r12), %r12
testq %r12, %r12
je 0x18f5d
movss %xmm3, 0x18(%rsp)
movl 0x18(%r12), %edi
movq 0x160(%r12), %rsi
leaq 0x168(%r12), %rdx
movss 0x90(%r12), %xmm0
movss 0x94(%r12), %xmm1
movq %r14, %rcx
movq %r13, %r8
movq %rbp, %r9
leaq 0x7(%rsp), %rax
pushq %rax
pushq %r15
callq 0x2cd2f
popq %rcx
popq %rdx
testb %al, %al
je 0x18ebd
movb 0x7(%rsp), %al
testb $0x1, %bl
movaps 0x1c41c(%rip), %xmm2    # 0x352a0
movss 0x18(%rsp), %xmm3
je 0x18ed6
movb 0x28(%rsp), %cl
andb $0x1, %cl
cmpb %cl, %al
jne 0x18ec8
movss 0x70(%rsp), %xmm0
movaps %xmm0, %xmm1
subss %xmm3, %xmm1
andps %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd 0x1c6d5(%rip), %xmm1    # 0x35588
jbe 0x18f2a
ucomiss %xmm0, %xmm3
seta %cl
jmp 0x18ecd
movss 0x18(%rsp), %xmm3
jmp 0x18e1e
movl %eax, %ecx
xorb $0x1, %cl
testb $0x1, %cl
je 0x18e1e
movsd 0xb8(%rsp), %xmm0
movaps %xmm0, 0xa0(%rsp)
movss 0xc0(%rsp), %xmm0
movss %xmm0, 0x14(%rsp)
movss 0xe8(%rsp), %xmm0
movss %xmm0, 0x4c(%rsp)
movss 0x94(%rsp), %xmm0
movss %xmm0, 0x48(%rsp)
movb $0x1, %bl
movss 0x70(%rsp), %xmm3
movb %al, 0x28(%rsp)
movq %r12, 0x38(%rsp)
jmp 0x18e1e
movb 0x20(%r12), %dl
movq 0x38(%rsp), %rsi
movb 0x20(%rsi), %cl
cmpb %cl, %dl
jne 0x18f48
movl 0x18(%r12), %ecx
cmpl 0x18(%rsi), %ecx
setl %cl
jmp 0x18ecd
xorb $0x1, %cl
movzbl %cl, %ecx
testb %dl, %dl
movl $0x0, %edx
cmovel %edx, %ecx
jmp 0x18ecd
testb $0x1, %bl
je 0x1903e
movq 0x38(%rsp), %r12
movl 0x18(%r12), %edi
leaq 0xb8(%rsp), %rbx
movq %rbx, %rsi
callq 0x2be6e
leaq 0xe8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2bf09
testb %al, %al
movq 0x8(%rsp), %r15
jne 0x19169
movl 0x18(%r12), %ebx
callq 0x9e0c
leaq 0x1d3de(%rip), %rdi     # 0x3638c
movl %ebx, %esi
xorl %eax, %eax
callq 0x8790
pushq $0x20
popq %rdi
callq 0x42e0
movq %rax, %r14
imulq $0x14, %rbx, %rsi
addq 0x2b01b(%rip), %rsi     # 0x43fe8
movss 0x1c9ef(%rip), %xmm0    # 0x359c4
movq %rax, %rdi
callq 0xadb6
imulq $0xc, %rbx, %rax
addq 0x2af90(%rip), %rax     # 0x43f78
xorl %ecx, %ecx
xorl %edx, %edx
movl 0x8(%r14), %esi
cmpq %rsi, %rdx
jae 0x19149
movq 0x10(%r14), %rsi
movss (%rsi,%rcx), %xmm0
addss (%rax), %xmm0
movss %xmm0, (%rsi,%rcx)
movq 0x10(%r14), %rsi
movss 0x4(%rsi,%rcx), %xmm0
addss 0x4(%rax), %xmm0
movss %xmm0, 0x4(%rsi,%rcx)
movq 0x10(%r14), %rsi
movss 0x8(%rsi,%rcx), %xmm0
addss 0x8(%rax), %xmm0
movss %xmm0, 0x8(%rsi,%rcx)
incq %rdx
addq $0xc, %rcx
jmp 0x18fec
movq 0x80(%rsp), %rsi
movslq 0x135c(%rsi), %rax
xorl %ecx, %ecx
movq 0x8(%rsp), %r15
movq 0x50(%rsp), %rdx
cmpq $0x3, %rcx
je 0x19094
movss 0xf18(%rsi,%rcx,4), %xmm0
mulss 0x30(%rsp), %xmm0
addss 0xef4(%rsi,%rcx,4), %xmm0
movss 0xf24(%rsi,%rcx,4), %xmm1
mulss 0x34(%rsp), %xmm1
addss %xmm0, %xmm1
movss %xmm1, (%rdx,%rcx,4)
incq %rcx
jmp 0x19059
imulq $0xc, %rax, %rax
leaq 0x541b961(%rip), %rcx   # 0x5434a00
movss (%rdx), %xmm0
movss 0x4(%rdx), %xmm1
addss (%rcx,%rax), %xmm0
movss %xmm0, (%rdx)
addss 0x4(%rcx,%rax), %xmm1
movss %xmm1, 0x4(%rdx)
movss 0x8(%rdx), %xmm1
addss 0x8(%rcx,%rax), %xmm1
movss %xmm1, 0x8(%rdx)
cvtss2sd %xmm0, %xmm0
movq 0x88(%rsp), %rcx
cvtss2sd (%rcx), %xmm1
movsd 0x1c17c(%rip), %xmm2    # 0x35260
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movq 0x58(%rsp), %rax
movss %xmm0, (%rax)
cvtss2sd 0x4(%rdx), %xmm0
cvtss2sd 0x4(%rcx), %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x4(%rax)
cvtss2sd 0x8(%rdx), %xmm0
cvtss2sd 0x8(%rcx), %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x8(%rax)
movq 0x60(%rsp), %rax
movl 0x44(%rsp), %ecx
movl %ecx, (%rax)
movq 0x68(%rsp), %rax
movb $0x1, (%rax)
xorl %ebp, %ebp
jmp 0x19237
movq %r14, %rdi
callq 0xa160
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
callq 0x9e1d
pushq $0x1e
popq %rsi
xorl %edi, %edi
callq 0x92cb
leaq 0x94(%rsp), %rsi
movss 0x4c(%rsp), %xmm0
movss %xmm0, (%rsi)
movss 0x48(%rsp), %xmm0
movss %xmm0, 0x4(%rsi)
andl $0x0, 0x8(%rsi)
leaq 0xe8(%rsp), %rdi
leaq 0x70(%rsp), %rbx
movq %rbx, %rdx
callq 0x2bb9d
movsd (%rbx), %xmm0
movq 0x50(%rsp), %rdx
movsd %xmm0, (%rdx)
movss 0x8(%rbx), %xmm1
movss %xmm1, 0x8(%rdx)
movslq 0x18(%r12), %rax
imulq $0xc, %rax, %rax
leaq 0x541b83a(%rip), %rcx   # 0x5434a00
movss (%rcx,%rax), %xmm2
addss %xmm0, %xmm2
movss %xmm2, (%rdx)
movslq 0x18(%r12), %rax
imulq $0xc, %rax, %rax
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
addss 0x4(%rcx,%rax), %xmm0
movss %xmm0, 0x4(%rdx)
movslq 0x18(%r12), %rax
imulq $0xc, %rax, %rax
addss 0x8(%rcx,%rax), %xmm1
movss %xmm1, 0x8(%rdx)
movq 0x58(%rsp), %rax
movaps 0xa0(%rsp), %xmm0
movlps %xmm0, (%rax)
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x8(%rax)
movl 0x18(%r12), %eax
movq 0x60(%rsp), %rcx
movl %eax, (%rcx)
movb 0x28(%rsp), %cl
andb $0x1, %cl
movq 0x68(%rsp), %rax
movb %cl, (%rax)
pushq $0x3
popq %rbp
movq 0x20(%rsp), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x19284
movq (%r14), %rbx
movq 0x160(%r14), %rdi
testq %rdi, %rdi
je 0x19259
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x140(%r14), %rdi
testq %rdi, %rdi
je 0x1926b
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x180(%r14), %rdi
callq 0x4380
movq %r14, %rdi
callq 0x4380
movq %rbx, %r14
jmp 0x1923f
movq %r15, %rdi
callq 0x4380
movl %ebp, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r14, %rdi
jmp 0x192b4
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r12, %rdi
callq 0x42f0
movq %rbx, %rdi
callq 0x45a0