// File: 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:
subq $0x168, %rsp            # imm = 0x168
movl 0x170(%rsp), %eax
movq %rdi, 0x160(%rsp)
movq %rsi, 0x158(%rsp)
movq %rdx, 0x150(%rsp)
movq %rcx, 0x148(%rsp)
movq %r8, 0x140(%rsp)
movss %xmm0, 0x13c(%rsp)
movss %xmm1, 0x138(%rsp)
movq %r9, 0x130(%rsp)
movq 0x140(%rsp), %rax
movl 0x135c(%rax), %eax
movl %eax, 0x128(%rsp)
movq 0x140(%rsp), %rax
movq 0x1360(%rax), %rax
movq %rax, 0x120(%rsp)
movq 0x120(%rsp), %rdi
callq 0x5cfa0
movq %rax, 0x118(%rsp)
movl 0x128(%rsp), %edi
movss 0x13c(%rsp), %xmm0
movss 0x138(%rsp), %xmm1
movq 0x130(%rsp), %rsi
movl $0x64, %edx
callq 0x426e0
movq %rax, 0x110(%rsp)
movb $0x0, 0x107(%rsp)
movq 0x110(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x108(%rsp)
cmpq $0x0, 0x108(%rsp)
je 0x3511b
movq 0x108(%rsp), %rax
movl 0x18(%rax), %edi
movq 0x108(%rsp), %rax
movq 0x160(%rax), %rsi
movq 0x108(%rsp), %rdx
addq $0x168, %rdx            # imm = 0x168
movq 0x108(%rsp), %rax
movss 0x90(%rax), %xmm0
movq 0x108(%rsp), %rax
movss 0x94(%rax), %xmm1
leaq 0xd0(%rsp), %rcx
leaq 0xcc(%rsp), %r8
leaq 0xc8(%rsp), %r9
leaq 0xc4(%rsp), %r10
leaq 0xc3(%rsp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x60350
testb $0x1, %al
jne 0x34f47
jmp 0x35103
testb $0x1, 0x107(%rsp)
jne 0x34f5e
movb $0x1, 0xc2(%rsp)
jmp 0x3505f
movb 0xc3(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movb 0xdf(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x34f92
movb 0xc3(%rsp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0xc2(%rsp)
jmp 0x3505d
movss 0xc4(%rsp), %xmm0
subss 0xe0(%rsp), %xmm0
callq 0x11ce0
cvtss2sd %xmm0, %xmm0
movsd 0x38833(%rip), %xmm1    # 0x6d7e8
ucomisd %xmm1, %xmm0
jbe 0x34fde
movss 0xc4(%rsp), %xmm1
movss 0xe0(%rsp), %xmm0
ucomiss %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, 0xc2(%rsp)
jmp 0x3505b
movq 0x108(%rsp), %rax
movb 0x20(%rax), %al
andb $0x1, %al
movzbl %al, %eax
movq 0xf8(%rsp), %rcx
movb 0x20(%rcx), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x35037
movq 0x108(%rsp), %rcx
xorl %eax, %eax
testb $0x1, 0x20(%rcx)
movb %al, 0x2b(%rsp)
je 0x35028
movq 0xf8(%rsp), %rax
movb 0x20(%rax), %al
xorb $-0x1, %al
movb %al, 0x2b(%rsp)
movb 0x2b(%rsp), %al
andb $0x1, %al
movb %al, 0xc2(%rsp)
jmp 0x35059
movq 0x108(%rsp), %rax
movl 0x18(%rax), %eax
movq 0xf8(%rsp), %rcx
cmpl 0x18(%rcx), %eax
setl %al
andb $0x1, %al
movb %al, 0xc2(%rsp)
jmp 0x3505b
jmp 0x3505d
jmp 0x3505f
testb $0x1, 0xc2(%rsp)
je 0x35101
movb $0x1, 0x107(%rsp)
movq 0x108(%rsp), %rax
movq %rax, 0xf8(%rsp)
movss 0xd0(%rsp), %xmm0
movss %xmm0, 0xec(%rsp)
movss 0xd4(%rsp), %xmm0
movss %xmm0, 0xf0(%rsp)
movss 0xd8(%rsp), %xmm0
movss %xmm0, 0xf4(%rsp)
movss 0xcc(%rsp), %xmm0
movss %xmm0, 0xe8(%rsp)
movss 0xc8(%rsp), %xmm0
movss %xmm0, 0xe4(%rsp)
movss 0xc4(%rsp), %xmm0
movss %xmm0, 0xe0(%rsp)
movb 0xc3(%rsp), %al
andb $0x1, %al
movb %al, 0xdf(%rsp)
jmp 0x35103
movq 0x108(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x108(%rsp)
jmp 0x34eb0
testb $0x1, 0x107(%rsp)
je 0x354bd
movq 0xf8(%rsp), %rax
movl 0x18(%rax), %edi
leaq 0x90(%rsp), %rsi
callq 0x5dfe0
leaq 0x90(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x5e120
testb $0x1, %al
jne 0x35328
movq 0xf8(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, 0x50(%rsp)
callq 0xd220
movl 0x50(%rsp), %esi
leaq 0x39296(%rip), %rdi     # 0x6e410
xorl %eax, %eax
callq 0xb0d0
movl $0x20, %edi
callq 0x4320
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x20(%rsp)
movl 0x50(%rsp), %eax
leaq (%rax,%rax,4), %rcx
leaq 0x1bb126b(%rip), %rax   # 0x1be6410
leaq (%rax,%rcx,4), %rsi
movss 0x389df(%rip), %xmm0    # 0x6db90
callq 0xf130
jmp 0x351b8
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0x38(%rsp)
movl 0x38(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x352f2
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x38(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movl 0x50(%rsp), %eax
movl %eax, %ecx
leaq 0x543880e(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss (%rax), %xmm0
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x38(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, (%rax)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x38(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movl 0x50(%rsp), %eax
movl %eax, %ecx
leaq 0x54387c3(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x4(%rax), %xmm0
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x38(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x4(%rax)
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x38(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movl 0x50(%rsp), %eax
movl %eax, %ecx
leaq 0x5438776(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x8(%rax), %xmm0
movq 0x48(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x38(%rsp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x8(%rax)
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x351ca
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
movl $0x20, %esi
callq 0x4330
jmp 0x355ed
movq 0x48(%rsp), %rdi
callq 0xd7f0
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x35317
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
callq 0xd240
xorl %edi, %edi
movl $0x1e, %esi
callq 0xbf00
movss 0xe8(%rsp), %xmm0
movss %xmm0, 0x54(%rsp)
movss 0xe4(%rsp), %xmm0
movss %xmm0, 0x58(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x5c(%rsp)
leaq 0x54(%rsp), %rsi
leaq 0x60(%rsp), %rdi
leaq 0x2c(%rsp), %rdx
callq 0x5d920
movss 0x2c(%rsp), %xmm0
movq 0x160(%rsp), %rax
movss %xmm0, (%rax)
movss 0x30(%rsp), %xmm0
movq 0x160(%rsp), %rax
movss %xmm0, 0x4(%rax)
movss 0x34(%rsp), %xmm0
movq 0x160(%rsp), %rax
movss %xmm0, 0x8(%rax)
movq 0x160(%rsp), %rax
movss (%rax), %xmm0
movq 0xf8(%rsp), %rax
movslq 0x18(%rax), %rcx
leaq 0x5438656(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss (%rax), %xmm0
movq 0x160(%rsp), %rax
movss %xmm0, (%rax)
movq 0x160(%rsp), %rax
movss 0x4(%rax), %xmm0
movq 0xf8(%rsp), %rax
movslq 0x18(%rax), %rcx
leaq 0x543861f(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x4(%rax), %xmm0
movq 0x160(%rsp), %rax
movss %xmm0, 0x4(%rax)
movq 0x160(%rsp), %rax
movss 0x8(%rax), %xmm0
movq 0xf8(%rsp), %rax
movslq 0x18(%rax), %rcx
leaq 0x54385e6(%rip), %rax   # 0x546da10
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
addss 0x8(%rax), %xmm0
movq 0x160(%rsp), %rax
movss %xmm0, 0x8(%rax)
movss 0xec(%rsp), %xmm0
movq 0x158(%rsp), %rax
movss %xmm0, (%rax)
movss 0xf0(%rsp), %xmm0
movq 0x158(%rsp), %rax
movss %xmm0, 0x4(%rax)
movss 0xf4(%rsp), %xmm0
movq 0x158(%rsp), %rax
movss %xmm0, 0x8(%rax)
movq 0xf8(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x150(%rsp), %rax
movl %ecx, (%rax)
movb 0xdf(%rsp), %cl
movq 0x148(%rsp), %rax
andb $0x1, %cl
movb %cl, (%rax)
movl $0x3, 0x12c(%rsp)
jmp 0x355d1
movq 0x140(%rsp), %rdi
movq 0x160(%rsp), %rsi
movss 0x13c(%rsp), %xmm0
movss 0x138(%rsp), %xmm1
callq 0x42e50
movq 0x160(%rsp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movq 0x118(%rsp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x37fe4(%rip), %xmm2    # 0x6d4f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x158(%rsp), %rax
movss %xmm0, (%rax)
movq 0x160(%rsp), %rax
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movq 0x118(%rsp), %rax
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x37fa2(%rip), %xmm2    # 0x6d4f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x158(%rsp), %rax
movss %xmm0, 0x4(%rax)
movq 0x160(%rsp), %rax
movss 0x8(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movq 0x118(%rsp), %rax
movss 0x8(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x37f5f(%rip), %xmm2    # 0x6d4f0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x158(%rsp), %rax
movss %xmm0, 0x8(%rax)
movl 0x128(%rsp), %ecx
movq 0x150(%rsp), %rax
movl %ecx, (%rax)
movq 0x148(%rsp), %rax
movb $0x1, (%rax)
movl $0x0, 0x12c(%rsp)
movq 0x110(%rsp), %rdi
callq 0x42f80
movl 0x12c(%rsp), %eax
addq $0x168, %rsp            # imm = 0x168
retq
movq 0x40(%rsp), %rdi
callq 0x45c0
nopw (%rax,%rax)