// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlrad/loadtextures.cpp
// Function: EmbedLightmapInTextures()
void EmbedLightmapInTextures ()
{
	if (!g_lightdatasize)
	{
		// hlrad hasn't run
		return;
	}
	if (!g_texdatasize)
	{
		// texdata hasn't been initialized
		return;
	}
	if (g_notextures)
	{
		// hlrad didn't load the wad files
		return;
	}

	int i, j, k;
	int miplevel;
	int count = 0;
	int count_bytes = 0;
	bool logged = false;

	for (i = 0; i < g_numfaces; i++)
	{
		dface_t *f = &g_dfaces[i];
		
		if (f->lightofs == -1) // some faces don't have lightmap
		{
			continue;
		}
		if (f->texinfo < 0 || f->texinfo >= g_numtexinfo)
		{
			continue;
		}
		
		entity_t *ent = g_face_entity[i];
		int originaltexinfonum = f->texinfo;
		texinfo_t *originaltexinfo = &g_texinfo[originaltexinfonum];
		char texname[16];
		if (!GetValidTextureName (originaltexinfo->miptex, texname))
		{
			continue;
		}
		radtexture_t *tex = &g_textures[originaltexinfo->miptex];

		if (ent == &g_entities[0]) // world
		{
			continue;
		}
		if (!strncmp (texname, "sky", 3)
			|| originaltexinfo->flags & TEX_SPECIAL) // skip special surfaces
		{
			continue;
		}
		if (!IntForKey (ent, "zhlt_embedlightmap"))
		{
			continue;
		}

		if (!logged)
		{
			Log ("\n");
			Log ("Embed Lightmap : ");
			Developer (DEVELOPER_LEVEL_MESSAGE, "\n");
			logged = true;
		}

		bool poweroftwo = DEFAULT_EMBEDLIGHTMAP_POWEROFTWO;
		vec_t denominator = DEFAULT_EMBEDLIGHTMAP_DENOMINATOR;
		vec_t gamma = DEFAULT_EMBEDLIGHTMAP_GAMMA;
		int resolution = DEFAULT_EMBEDLIGHTMAP_RESOLUTION;
		if (IntForKey (ent, "zhlt_embedlightmapresolution"))
		{
			resolution = IntForKey (ent, "zhlt_embedlightmapresolution");
			if (resolution <= 0 || resolution > TEXTURE_STEP || ((resolution - 1) & resolution) != 0)
			{
				Error ("resolution cannot be %d; valid values are 1, 2, 4 ... %d.", resolution, (int)TEXTURE_STEP);
			}
		}

		// calculate texture size and allocate memory for all miplevels

		int texturesize[2];
		float (*texture)[5]; // red, green, blue and alpha channel; the last one is number of samples
		byte (*texturemips[MIPLEVELS])[4]; // red, green, blue and alpha channel
		int s, t;
		int texmins[2];
		int texmaxs[2];
		int texsize[2]; // texturesize = (texsize + 1) * TEXTURE_STEP
		int side[2];

		GetFaceExtents (i, texmins, texmaxs);
		texsize[0] = texmaxs[0] - texmins[0];
		texsize[1] = texmaxs[1] - texmins[1];
		if (texsize[0] < 0 || texsize[1] < 0 || texsize[0] > MAX_SURFACE_EXTENT || texsize[1] > MAX_SURFACE_EXTENT)
		{
			Warning ("skipped a face with bad surface extents @ (%4.3f %4.3f %4.3f)", g_face_centroids[i][0], g_face_centroids[i][1], g_face_centroids[i][2]);
			continue;
		}

		for (k = 0; k < 2; k++)
		{
			texturesize[k] = (texsize[k] + 1) * TEXTURE_STEP;
			if (texturesize[k] < texsize[k] * TEXTURE_STEP + resolution * 4)
			{
				texturesize[k] = texsize[k] * TEXTURE_STEP + resolution * 4; // prevent edge bleeding
			}
			texturesize[k] = (texturesize[k] + resolution - 1) / resolution;
			texturesize[k] += 15 - (texturesize[k] + 15) % 16; // must be multiples of 16
			if (poweroftwo)
			{
				for (j = 0; j <= 30; j++)
				{
					if ((1 << j) >= texturesize[k])
					{
						texturesize[k] = (1 << j);
						break;
					}
				}
			}
			side[k] = (texturesize[k] * resolution - texsize[k] * TEXTURE_STEP) / 2;
		}
		texture = (float (*)[5])malloc (texturesize[0] * texturesize[1] * sizeof (float [5]));
		hlassume (texture != NULL, assume_NoMemory);
		for (miplevel = 0; miplevel < MIPLEVELS; miplevel++)
		{
			texturemips[miplevel] = (byte (*)[4])malloc ((texturesize[0] >> miplevel) * (texturesize[1] >> miplevel) * sizeof (byte [4]));
			hlassume (texturemips[miplevel] != NULL, assume_NoMemory);
		}

		// calculate the texture

		for (t = 0; t < texturesize[1]; t++)
		{
			for (s = 0; s < texturesize[0]; s++)
			{
				float (*dest)[5] = &texture[t * texturesize[0] + s];
				VectorFill (*dest, 0);
				(*dest)[3] = 0;
				(*dest)[4] = 0;
			}
		}
		for (t = -side[1]; t < texsize[1] * TEXTURE_STEP + side[1]; t++)
		{
			for (s = -side[0]; s < texsize[0] * TEXTURE_STEP + side[0]; s++)
			{
				double s_vec, t_vec;
				double src_s, src_t;
				int src_is, src_it;
				byte src_index;
				byte src_color[3];
				double dest_s, dest_t;
				int dest_is, dest_it;
				float (*dest)[5];
				double light_s, light_t;
				vec3_t light;

				s_vec = s + texmins[0] * TEXTURE_STEP + 0.5;
				t_vec = t + texmins[1] * TEXTURE_STEP + 0.5;

				if (resolution == 1)
				{
					dest_s = s_vec;
					dest_t = t_vec;
				}
				else // the final blurred texture is shifted by a half pixel so that lightmap samples align with the center of pixels
				{
					dest_s = s_vec / resolution + 0.5;
					dest_t = t_vec / resolution + 0.5;
				}
				dest_s = dest_s - texturesize[0] * floor (dest_s / texturesize[0]);
				dest_t = dest_t - texturesize[1] * floor (dest_t / texturesize[1]);
				dest_is = (int)floor (dest_s); // dest_is = dest_s % texturesize[0]
				dest_it = (int)floor (dest_t); // dest_it = dest_t % texturesize[1]
				dest_is = qmax (0, qmin (dest_is, texturesize[0] - 1));
				dest_it = qmax (0, qmin (dest_it, texturesize[1] - 1));
				dest = &texture[dest_it * texturesize[0] + dest_is];

				src_s = s_vec;
				src_t = t_vec;
				src_s = src_s - tex->width * floor (src_s / tex->width);
				src_t = src_t - tex->height * floor (src_t / tex->height);
				src_is = (int)floor (src_s); // src_is = src_s % tex->width
				src_it = (int)floor (src_t); // src_it = src_t % tex->height
				src_is = qmax (0, qmin (src_is, tex->width - 1));
				src_it = qmax (0, qmin (src_it, tex->height - 1));
				src_index = tex->canvas[src_it * tex->width + src_is];
				VectorCopy (tex->palette[src_index], src_color);

				// get light from the center of the destination pixel
				light_s = (s_vec + resolution * (dest_is + 0.5 - dest_s)) / TEXTURE_STEP - texmins[0];
				light_t = (t_vec + resolution * (dest_it + 0.5 - dest_t)) / TEXTURE_STEP - texmins[1];
				GetLight (f, texsize, light_s, light_t, light);

				(*dest)[4] += 1;
				if (!(texname[0] == '{' && src_index == 255))
				{
					for (k = 0; k < 3; k++)
					{
						float v = src_color[k] * pow (light[k] / denominator, gamma);
						(*dest)[k] += 255 * qmax (0, qmin (v, 255));
					}
					(*dest)[3] += 255;
				}
			}
		}
		for (t = 0; t < texturesize[1]; t++)
		{
			for (s = 0; s < texturesize[0]; s++)
			{
				float (*src)[5] = &texture[t * texturesize[0] + s];
				byte (*dest)[4] = &texturemips[0][t * texturesize[0] + s];

				if ((*src)[4] == 0) // no samples (outside face range?)
				{
					VectorFill (*dest, 0);
					(*dest)[3] = 255;
				}
				else
				{
					if ((*src)[3] / (*src)[4] <= 0.4 * 255) // transparent
					{
						VectorFill (*dest, 0);
						(*dest)[3] = 0;
					}
					else // normal
					{
						for (j = 0; j < 3; j++)
						{
							int val = (int)floor ((*src)[j] / (*src)[3] + 0.5);
							(*dest)[j] = qmax (0, qmin (val, 255));
						}
						(*dest)[3] = 255;
					}
				}
			}
		}

		for (miplevel = 1; miplevel < MIPLEVELS; miplevel++)
		{
			for (t = 0; t < (texturesize[1] >> miplevel); t++)
			{
				for (s = 0; s < (texturesize[0] >> miplevel); s++)
				{
					byte (*src[4])[4];
					byte (*dest)[4];
					double average[4];

					dest = &texturemips[miplevel][t * (texturesize[0] >> miplevel) + s];
					src[0] = &texturemips[miplevel - 1][(2 * t) * (texturesize[0] >> (miplevel - 1)) + (2 * s)];
					src[1] = &texturemips[miplevel - 1][(2 * t) * (texturesize[0] >> (miplevel - 1)) + (2 * s + 1)];
					src[2] = &texturemips[miplevel - 1][(2 * t + 1) * (texturesize[0] >> (miplevel - 1)) + (2 * s)];
					src[3] = &texturemips[miplevel - 1][(2 * t + 1) * (texturesize[0] >> (miplevel - 1)) + (2 * s + 1)];

					VectorClear (average);
					average[3] = 0;
					for (k = 0; k < 4; k++)
					{
						for (j = 0; j < 3; j++)
						{
							average[j] += (*src[k])[3] * (*src[k])[j];
						}
						average[3] += (*src[k])[3];
					}

					if (average[3] / 4 <= 0.4 * 255)
					{
						VectorClear (*dest);
						(*dest)[3] = 0;
					}
					else
					{
						for (j = 0; j < 3; j++)
						{
							int val = (int)floor (average[j] / average[3] + 0.5);
							(*dest)[j] = qmax (0, qmin (val, 255));
						}
						(*dest)[3] = 255;
					}
				}
			}
		}

		// create its palette

		byte palette[256][3];
		cq_searchnode_t *palettetree = CQ_AllocSearchTree (256);
		int paletteoffset;
		int palettenumcolors;

		{
			int palettemaxcolors;
			int numsamplepoints;
			unsigned char (*samplepoints)[3];

			if (texname[0] == '{')
			{
				paletteoffset = 0;
				palettemaxcolors = 255;
				VectorCopy (tex->palette[255], palette[255]); // the transparency color
			}
			/*else if (texname[0] == '!')
			{
				paletteoffset = 16; // because the 4th entry and the 5th entry are reserved for fog color and fog density
				for (j = 0; j < 16; j++)
				{
					VectorCopy (tex->palette[j], palette[j]);
				}
				palettemaxcolors = 256 - 16;
			}*/
			else
			{
				paletteoffset = 0;
				palettemaxcolors = 256;
			}

			samplepoints = (unsigned char (*)[3])malloc (texturesize[0] * texturesize[1] * sizeof (unsigned char [3]));
			hlassume (samplepoints != NULL, assume_NoMemory);
			numsamplepoints = 0;
			for (t = 0; t < texturesize[1]; t++)
			{
				for (s = 0; s < texturesize[0]; s++)
				{
					byte (*src)[4] = &texturemips[0][t * texturesize[0] + s];
					if ((*src)[3] > 0)
					{
						VectorCopy (*src, samplepoints[numsamplepoints]);
						numsamplepoints++;
					}
				}
			}

			CQ_CreatePalette (numsamplepoints, samplepoints, palettemaxcolors, &palette[paletteoffset], palettenumcolors, palettetree);
			for (j = palettenumcolors; j < palettemaxcolors; j++)
			{
				VectorClear (palette[paletteoffset + j]);
			}

			free (samplepoints);
		}

		// emit a texinfo

		hlassume (g_numtexinfo < MAX_MAP_TEXINFO, assume_MAX_MAP_TEXINFO);
		f->texinfo = g_numtexinfo;
		texinfo_t *info = &g_texinfo[g_numtexinfo];
		g_numtexinfo++;

		*info = g_texinfo[originaltexinfonum];
		if (resolution != 1)
		{
			// apply a scale and a shift over the original vectors
			for (k = 0; k < 2; k++)
			{
				VectorScale (info->vecs[k], 1.0 / resolution, info->vecs[k]);
				info->vecs[k][3] = info->vecs[k][3] / resolution + 0.5;
			}
		}
		info->miptex = NewTextures_GetCurrentMiptexIndex ();

		// emit a texture

		int miptexsize;
		
		miptexsize = (int)sizeof (miptex_t);
		for (miplevel = 0; miplevel < MIPLEVELS; miplevel++)
		{
			miptexsize += (texturesize[0] >> miplevel) * (texturesize[1] >> miplevel);
		}
		miptexsize += 2 + 256 * 3 + 2;
		miptex_t *miptex = (miptex_t *)malloc (miptexsize);
		hlassume (miptex != NULL, assume_NoMemory);

		memset (miptex, 0, sizeof (miptex_t));
		miptex->width = texturesize[0];
		miptex->height = texturesize[1];
		byte *p = (byte *)miptex + sizeof (miptex_t);
		for (miplevel = 0; miplevel < MIPLEVELS; miplevel++)
		{
			miptex->offsets[miplevel] = p - (byte *)miptex;
			for (int t = 0; t < (texturesize[1] >> miplevel); t++)
			{
				for (int s = 0; s < (texturesize[0] >> miplevel); s++)
				{
					byte (*src)[4] = &texturemips[miplevel][t * (texturesize[0] >> miplevel) + s];
					if ((*src)[3] > 0)
					{
						if (palettenumcolors)
						{
							unsigned char point[3];
							VectorCopy (*src, point);
							*p = paletteoffset + CQ_MapPoint (point, &palette[paletteoffset], palettenumcolors, palettetree);
						}
						else // this should never happen
						{
							*p = paletteoffset + 0;
						}
					}
					else
					{
						*p = 255;
					}
					p++;
				}
			}
		}
		*(short *)p = 256;
		p += 2;
		memcpy (p, palette, 256 * 3);
		p += 256 * 3;
		*(short *)p = 0;
		p += 2;
		if (p != (byte *)miptex + miptexsize)
		{
			Error ("EmbedLightmapInTextures: internal error");
		}

		if (texname[0] == '{')
		{
			strcpy (miptex->name, "{_rad");
		}
		/*else if (texname[0] == '!')
		{
			strcpy (miptex->name, "!_rad");
		}*/
		else
		{
			strcpy (miptex->name, "__rad");
		}
		if (originaltexinfonum < 0 || originaltexinfonum > 99999)
		{
			Error ("EmbedLightmapInTextures: internal error: texinfo out of range");
		}
		miptex->name[5] = '0' + (originaltexinfonum / 10000) % 10; // store the original texinfo
		miptex->name[6] = '0' + (originaltexinfonum / 1000) % 10;
		miptex->name[7] = '0' + (originaltexinfonum / 100) % 10;
		miptex->name[8] = '0' + (originaltexinfonum / 10) % 10;
		miptex->name[9] = '0' + (originaltexinfonum) % 10;
		char table[62];
		for (int k = 0; k < 62; k++)
		{
			table[k] = k >= 36? 'a' + (k - 36): k >= 10? 'A' + (k - 10): '0' + k; // same order as the ASCII table
		}
		miptex->name[10] = '\0';
		miptex->name[11] = '\0';
		miptex->name[12] = '\0';
		miptex->name[13] = '\0';
		miptex->name[14] = '\0';
		miptex->name[15] = '\0';
		unsigned int hash = Hash (miptexsize, miptex);
		miptex->name[10] = table[(hash / 62 / 62) % 52 + 10];
		miptex->name[11] = table[(hash / 62) % 62];
		miptex->name[12] = table[(hash) % 62];
		miptex->name[13] = table[(count / 62) % 62];
		miptex->name[14] = table[(count) % 62];
		miptex->name[15] = '\0';
		NewTextures_PushTexture (miptexsize, miptex);
		count++;
		count_bytes += miptexsize;
		Developer (DEVELOPER_LEVEL_MESSAGE, "Created texture '%s' for face (texture %s) at (%4.3f %4.3f %4.3f)\n", miptex->name, texname, g_face_centroids[i][0], g_face_centroids[i][1], g_face_centroids[i][2]);

		free (miptex);

		CQ_FreeSearchTree (palettetree);
		
		free (texture);
		for (miplevel = 0; miplevel < MIPLEVELS; miplevel++)
		{
			free (texturemips[miplevel]);
		}
	}
	NewTextures_Write (); // update texdata now

	if (logged)
	{
		Log ("added %d texinfos and textures (%d bytes)\n", count, count_bytes);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x548, %rsp            # imm = 0x548
leaq 0x82dcec(%rip), %rax    # 0x84d494
cmpl $0x0, (%rax)
je 0x211d2
leaq 0x82dcec(%rip), %r8     # 0x84d4a4
cmpl $0x0, (%r8)
je 0x211d2
leaq 0x54d7272(%rip), %rax   # 0x54f6a3b
cmpb $0x0, (%rax)
jne 0x211d2
leaq 0x1b8dc2b(%rip), %r9    # 0x1bad404
leaq 0x1b8dc30(%rip), %r10   # 0x1bad410
leaq 0x118dc15(%rip), %r11   # 0x11ad3fc
leaq 0x118dc12(%rip), %rbx   # 0x11ad400
xorl %edi, %edi
movq $0x0, 0xd8(%rsp)
movl $0x0, 0x8c(%rsp)
movl $0x0, 0x58(%rsp)
movslq (%r9), %rax
cmpq %rax, %rdi
jge 0x211aa
imulq $0x14, %rdi, %rax
cmpl $-0x1, 0x10(%r10,%rax)
je 0x1f924
addq %r10, %rax
movswl 0xa(%rax), %ebp
testl %ebp, %ebp
js 0x1f924
cmpl %ebp, (%r11)
jle 0x1f924
movq %rax, 0x150(%rsp)
movl (%r8), %eax
testl %eax, %eax
movq %rdi, 0x10(%rsp)
je 0x1f865
leaq 0x82dc4a(%rip), %rcx    # 0x84d4a8
movq (%rcx), %rcx
movl (%rcx), %ecx
jmp 0x1f867
xorl %ecx, %ecx
movl %ebp, %edx
imulq $0x28, %rdx, %rdx
movq %rdx, %r12
movl 0x20(%rbx,%rdx), %edx
testl %edx, %edx
setns %sil
cmpl %edx, %ecx
setg %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x1f91f
leaq 0x82dc14(%rip), %rsi    # 0x84d4a8
movq (%rsi), %r14
movslq 0x4(%r14,%rdx,4), %rdx
testq %rdx, %rdx
movq 0x10(%rsp), %rdi
js 0x1f924
leaq 0x4(%r14), %rsi
subl %edx, %eax
addq %rdx, %r14
movl %ecx, %ecx
leaq (%rsi,%rcx,4), %rcx
cmpq %rcx, %r14
setb %cl
cmpl $0x28, %eax
setl %al
orb %cl, %al
jne 0x1f924
movl %ebp, 0x11c(%rsp)
leaq 0x52d511d(%rip), %rax   # 0x52f49f0
movq (%rax,%rdi,8), %rbx
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
pushq $0x10
popq %rdx
callq 0x7721
movq %r15, %rdi
movq %r14, %rsi
callq 0x4460
testl %eax, %eax
je 0x1f92c
leaq 0x82dba1(%rip), %r8     # 0x84d4a4
leaq 0x1b8dafa(%rip), %r9    # 0x1bad404
leaq 0x1b8daff(%rip), %r10   # 0x1bad410
leaq 0x118dae4(%rip), %r11   # 0x11ad3fc
leaq 0x118dae1(%rip), %rbx   # 0x11ad400
movq 0x10(%rsp), %rdi
incq %rdi
jmp 0x1f80f
movq %r15, %rdi
callq 0x4150
cmpq $0x5, %rax
jb 0x1f955
leaq 0xc1(%rsp), %rdi
leaq 0x170b2(%rip), %rsi     # 0x369fb
pushq $0x4
popq %rdx
callq 0x43f0
testl %eax, %eax
je 0x1f8fc
cmpq 0x24674(%rip), %rbx     # 0x43fd0
je 0x1f8fc
addq 0x2460b(%rip), %r12     # 0x43f70
movslq 0x20(%r12), %rax
imulq $0x330, %rax, %rax      # imm = 0x330
addq 0x524f040(%rip), %rax   # 0x526e9b8
movq %rax, 0xe8(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x17c4b(%rip), %rsi     # 0x375da
pushq $0x3
popq %rdx
callq 0x4300
testl %eax, %eax
je 0x1f8fc
testb $0x1, 0x24(%r12)
jne 0x1f8fc
movq %r12, 0x1d8(%rsp)
movq %rbx, %rdi
leaq 0x16f55(%rip), %rsi     # 0x36912
callq 0x6a5d
testl %eax, %eax
je 0x1f8fc
testb $0x1, 0xd8(%rsp)
jne 0x1fa0a
leaq 0x141fd(%rip), %r14     # 0x33bd8
movq %r14, %rdi
xorl %eax, %eax
callq 0x8790
leaq 0x16f39(%rip), %rdi     # 0x36925
xorl %eax, %eax
callq 0x8790
pushq $0x3
popq %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x9045
movb $0x1, %al
movq %rax, 0xd8(%rsp)
movq %rbx, %rdi
leaq 0x16f23(%rip), %rsi     # 0x36937
callq 0x6a5d
pushq $0x1
popq %rcx
movq %rcx, 0x20(%rsp)
testl %eax, %eax
je 0x1fa67
movq %rbx, %rdi
leaq 0x16f08(%rip), %rsi     # 0x36937
callq 0x6a5d
movl %eax, %esi
leal -0x11(%rsi), %eax
cmpl $-0x10, %eax
movq %rsi, 0x20(%rsp)
jb 0x1fa56
movq 0x20(%rsp), %rax
addl $0x1f, %eax
testl %eax, 0x20(%rsp)
movq 0x20(%rsp), %rsi
je 0x1fa67
leaq 0x16ef7(%rip), %rdi     # 0x36954
pushq $0x10
popq %rdx
xorl %eax, %eax
callq 0x8b2f
movq 0x10(%rsp), %rbx
movl %ebx, %edi
leaq 0x160(%rsp), %rsi
leaq 0x1f8(%rsp), %rdx
callq 0x568d
movq 0x1f8(%rsp), %xmm1
movq 0x160(%rsp), %xmm0
psubd %xmm0, %xmm1
movq %xmm1, 0x158(%rsp)
pshufd $0x50, %xmm1, %xmm0     # xmm0 = xmm1[0,0,1,1]
pxor 0x157e1(%rip), %xmm0    # 0x35290
pcmpgtd 0x16a59(%rip), %xmm0    # 0x36510
movmskpd %xmm0, %eax
testl %eax, %eax
je 0x1faee
imulq $0xc, %rbx, %rax
leaq 0x4c20e56(%rip), %rcx   # 0x4c40920
cvtss2sd (%rcx,%rax), %xmm0
cvtss2sd 0x4(%rcx,%rax), %xmm1
cvtss2sd 0x8(%rcx,%rax), %xmm2
leaq 0x16eac(%rip), %rdi     # 0x3698e
movb $0x3, %al
callq 0x8ea5
jmp 0x21182
movq 0x20(%rsp), %rax
leal (,%rax,4), %esi
leal -0x1(%rax), %edi
xorl %r8d, %r8d
pushq $0x10
popq %r10
pushq $0x2
popq %r11
cmpq $0x2, %r8
je 0x1fb77
movl 0x158(%rsp,%r8,4), %r9d
shll $0x4, %r9d
leal 0x10(%r9), %ecx
leal (%r9,%rsi), %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
addl %edi, %eax
cltd
idivl 0x20(%rsp)
movl %eax, %ecx
leal 0xf(%rcx), %eax
cltd
idivl %r10d
negl %edx
addl %ecx, %edx
addl $0xf, %edx
movl %edx, 0x78(%rsp,%r8,4)
xorl %ecx, %ecx
cmpl $0x1f, %ecx
je 0x1fb5c
pushq $0x1
popq %rax
shll %cl, %eax
incl %ecx
cmpl %edx, %eax
jl 0x1fb45
movl %eax, 0x78(%rsp,%r8,4)
jmp 0x1fb5e
movl %edx, %eax
imull 0x20(%rsp), %eax
subl %r9d, %eax
cltd
idivl %r11d
movl %eax, 0x168(%rsp,%r8,4)
incq %r8
jmp 0x1fb08
movdqa %xmm1, (%rsp)
movq 0x78(%rsp), %rcx
movq %rcx, %xmm0
movdqa %xmm0, 0x120(%rsp)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
movl %eax, 0x5c(%rsp)
movq %rcx, 0xa0(%rsp)
imull %ecx, %eax
movslq %eax, %rcx
movq %rcx, 0x1d0(%rsp)
imulq $0x14, %rcx, %rdi
callq 0x4420
movq %rax, %r15
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0x1fc16
movq 0xa0(%rsp), %rax
movl %ebx, %ecx
sarl %cl, %eax
movl 0x5c(%rsp), %edx
sarl %cl, %edx
imull %eax, %edx
movslq %edx, %rdi
shlq $0x2, %rdi
callq 0x4420
movq %rax, 0x200(%rsp,%rbx,8)
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
incq %rbx
jmp 0x1fbd1
movq 0xa0(%rsp), %rcx
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
movslq %ecx, %rsi
movl 0x5c(%rsp), %edx
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
movq %rcx, 0xe0(%rsp)
movq %rsi, 0x140(%rsp)
imulq $0x14, %rsi, %rcx
movq %rcx, 0x148(%rsp)
movq %rax, 0xa8(%rsp)
imulq $0x14, %rax, %rax
movq %r15, %rcx
xorl %edx, %edx
movdqa (%rsp), %xmm1
cmpq 0xe0(%rsp), %rdx
je 0x1fc9d
xorl %esi, %esi
cmpq %rsi, %rax
je 0x1fc90
pxor %xmm0, %xmm0
movdqu %xmm0, (%rcx,%rsi)
andl $0x0, 0x10(%rcx,%rsi)
addq $0x14, %rsi
jmp 0x1fc77
incq %rdx
addq 0x148(%rsp), %rcx
jmp 0x1fc6b
movl 0x168(%rsp), %eax
movl 0x16c(%rsp), %ecx
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
movd %xmm0, %edx
shll $0x4, %edx
addl %ecx, %edx
movl %ecx, %esi
negl %esi
movd %xmm1, %edi
shll $0x4, %edi
addl %eax, %edi
movl %eax, %r8d
negl %r8d
xorl %eax, %eax
movq 0x20(%rsp), %rcx
cmpl $0x1, %ecx
cvtsi2sd %ecx, %xmm0
sete %al
movdqa 0x120(%rsp), %xmm1
cvtdq2pd %xmm1, %xmm2
movapd %xmm2, 0x1c0(%rsp)
xorpd 0x16825(%rip), %xmm2    # 0x36520
movapd %xmm2, 0x170(%rsp)
cmpl %edi, %r8d
movl %r8d, 0x114(%rsp)
cmovgl %r8d, %edi
movl %edi, 0xf0(%rsp)
paddd 0x1683e(%rip), %xmm1    # 0x36560
movdqa %xmm1, 0x120(%rsp)
cmpl %edx, %esi
cmovgl %esi, %edx
movl %edx, 0x118(%rsp)
movq 0xe8(%rsp), %rcx
leaq 0x20(%rcx), %rcx
movq %rcx, 0x1e0(%rsp)
movapd %xmm0, 0x220(%rsp)
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, 0x90(%rsp)
movd %eax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
pshufd $0xa0, %xmm0, %xmm0     # xmm0 = xmm0[0,0,2,2]
pslld $0x1f, %xmm0
psrad $0x1f, %xmm0
movdqa %xmm0, 0x230(%rsp)
movq %r15, 0x100(%rsp)
movl 0x114(%rsp), %ecx
cmpl 0x118(%rsp), %esi
movl %esi, 0xf8(%rsp)
je 0x20317
cmpl 0xf0(%rsp), %ecx
je 0x20310
movq 0xe8(%rsp), %rax
movl 0x10(%rax), %r14d
movl 0x14(%rax), %ebx
cvtsi2sd %r14d, %xmm0
movsd %xmm0, 0x40(%rsp)
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x70(%rsp)
leal -0x1(%r14), %ebp
decl %ebx
movq 0x160(%rsp), %xmm0
movdqa %xmm0, 0x130(%rsp)
pslld $0x4, %xmm0
movd %esi, %xmm1
movl %ecx, 0x28(%rsp)
movd %ecx, %xmm2
punpckldq %xmm1, %xmm2    # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
paddd %xmm0, %xmm2
cvtdq2pd %xmm2, %xmm2
movq 0x18(%rax), %r15
movapd 0x16719(%rip), %xmm1    # 0x36530
addpd %xmm1, %xmm2
movapd %xmm2, 0x30(%rsp)
movapd %xmm2, %xmm0
divpd 0x90(%rsp), %xmm0
addpd %xmm1, %xmm0
movapd %xmm2, %xmm1
movapd 0x230(%rsp), %xmm2
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
movapd %xmm2, 0x60(%rsp)
movapd %xmm2, %xmm0
divpd 0x1c0(%rsp), %xmm0
movapd %xmm0, 0xb0(%rsp)
callq 0x4590
movapd %xmm0, (%rsp)
movapd 0xb0(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x4590
movapd (%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd 0x170(%rsp), %xmm1
addpd 0x60(%rsp), %xmm1
movapd %xmm1, (%rsp)
movapd %xmm1, %xmm0
callq 0x4590
movapd %xmm0, 0x60(%rsp)
movapd (%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x4590
movapd 0x60(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvttpd2dq %xmm1, %xmm0
movapd %xmm0, %xmm1
movdqa 0x120(%rsp), %xmm2
pcmpgtd %xmm2, %xmm1
pand %xmm1, %xmm2
pandn %xmm0, %xmm1
por %xmm2, %xmm1
movdqa %xmm1, %xmm2
pxor %xmm0, %xmm0
pcmpgtd %xmm0, %xmm2
pand %xmm1, %xmm2
movdqa %xmm2, 0x60(%rsp)
movapd 0x30(%rsp), %xmm0
divsd 0x40(%rsp), %xmm0
callq 0x4590
mulsd 0x40(%rsp), %xmm0
movapd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm2, 0xb0(%rsp)
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
movapd %xmm0, 0x40(%rsp)
divsd 0x70(%rsp), %xmm0
callq 0x4590
mulsd 0x70(%rsp), %xmm0
movapd 0x40(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
movapd 0xb0(%rsp), %xmm0
callq 0x4590
cvttsd2si %xmm0, %r12d
movapd 0x40(%rsp), %xmm0
callq 0x4590
cvttsd2si %xmm0, %eax
cmpl %r12d, %ebp
cmovll %ebp, %r12d
testl %r12d, %r12d
movl $0x0, %ecx
cmovlel %ecx, %r12d
cmpl %eax, %ebx
cmovgel %eax, %ebx
testl %ebx, %ebx
cmovlel %ecx, %ebx
imull %r14d, %ebx
addl %r12d, %ebx
movslq %ebx, %rax
movzbl (%r15,%rax), %eax
movq %rax, 0x40(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x1e0(%rsp), %rdx
movb (%rdx,%rax), %cl
movb %cl, 0x1d(%rsp)
movb 0x1(%rdx,%rax), %cl
movb %cl, 0x1e(%rsp)
movb 0x2(%rdx,%rax), %al
movb %al, 0x1f(%rsp)
cvtdq2pd 0x60(%rsp), %xmm0
addpd 0x16551(%rip), %xmm0    # 0x36530
subpd (%rsp), %xmm0
mulpd 0x90(%rsp), %xmm0
addpd 0x30(%rsp), %xmm0
mulpd 0x16545(%rip), %xmm0    # 0x36540
cvtdq2pd 0x130(%rsp), %xmm1
subpd %xmm1, %xmm0
movapd %xmm0, (%rsp)
callq 0x4590
movapd %xmm0, 0x30(%rsp)
movapd (%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x4590
movapd (%rsp), %xmm3
movapd 0x30(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm1
subpd %xmm1, %xmm3
minpd 0x16507(%rip), %xmm3    # 0x36550
movapd %xmm3, %xmm1
cmpltpd 0x1560a(%rip), %xmm1    # 0x35660
movmskpd %xmm1, %eax
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
testb $0x1, %al
jne 0x2006a
movapd %xmm3, %xmm1
movapd %xmm1, (%rsp)
testb $0x2, %al
jne 0x2007b
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
movapd %xmm3, %xmm2
movapd %xmm2, 0x30(%rsp)
movdqa 0x60(%rsp), %xmm2
pshufd $0x55, %xmm2, %xmm1     # xmm1 = xmm2[1,1,1,1]
movd %xmm1, %eax
imull 0xa0(%rsp), %eax
movd %xmm2, %ecx
addl %eax, %ecx
movslq %ecx, %rax
imulq $0x14, %rax, %r12
movd %xmm0, %r14d
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ebx
movq 0x150(%rsp), %r13
movq %r13, %rdi
leaq 0x158(%rsp), %rbp
movq %rbp, %rsi
movl %r14d, %edx
movl %ebx, %ecx
leaq 0x240(%rsp), %r8
callq 0x211e4
leal 0x1(%r14), %r15d
movq %r13, %rdi
movq %rbp, %rsi
movl %r15d, %edx
movl %ebx, %ecx
leaq 0x180(%rsp), %r8
callq 0x211e4
incl %ebx
movq %r13, %rdi
movq %rbp, %rsi
movl %r14d, %edx
movl %ebx, %ecx
leaq 0x108(%rsp), %r8
callq 0x211e4
movq %r13, %rdi
movq %rbp, %rsi
movl %r15d, %edx
movl %ebx, %ecx
leaq 0x80(%rsp), %r8
callq 0x211e4
movsd 0x14f97(%rip), %xmm5    # 0x350c8
movapd %xmm5, %xmm1
movapd 0x30(%rsp), %xmm7
subsd %xmm7, %xmm1
cvtps2pd 0x240(%rsp), %xmm4
cvtss2sd 0x248(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
cvtss2sd 0x110(%rsp), %xmm2
mulsd %xmm7, %xmm2
addsd %xmm0, %xmm2
cvtsd2ss %xmm2, %xmm2
cvtss2sd 0x188(%rsp), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
cvtss2sd 0x88(%rsp), %xmm3
mulsd %xmm7, %xmm3
addsd %xmm0, %xmm3
cvtsd2ss %xmm3, %xmm0
movapd %xmm5, %xmm3
movapd (%rsp), %xmm6
subsd %xmm6, %xmm3
cvtss2sd %xmm2, %xmm2
mulsd %xmm3, %xmm2
cvtsd2ss %xmm2, %xmm2
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm1, %xmm4
cvtpd2ps %xmm4, %xmm4
cvtps2pd %xmm4, %xmm4
cvtps2pd 0x108(%rsp), %xmm5
unpcklpd %xmm7, %xmm7            # xmm7 = xmm7[0,0]
mulpd %xmm7, %xmm5
addpd %xmm4, %xmm5
cvtpd2ps %xmm5, %xmm4
cvtps2pd 0x180(%rsp), %xmm5
mulpd %xmm1, %xmm5
cvtpd2ps %xmm5, %xmm1
cvtps2pd %xmm1, %xmm1
cvtps2pd 0x80(%rsp), %xmm5
mulpd %xmm7, %xmm5
addpd %xmm1, %xmm5
cvtpd2ps %xmm5, %xmm1
cvtps2pd %xmm4, %xmm4
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm4, %xmm3
cvtpd2ps %xmm3, %xmm3
cvtps2pd %xmm3, %xmm3
cvtps2pd %xmm1, %xmm1
movapd %xmm6, %xmm4
unpcklpd %xmm6, %xmm4            # xmm4 = xmm4[0],xmm6[0]
mulpd %xmm1, %xmm4
addpd %xmm3, %xmm4
cvtpd2ps %xmm4, %xmm1
movlpd %xmm1, 0x1e8(%rsp)
cvtss2sd %xmm2, %xmm1
cvtss2sd %xmm0, %xmm0
mulsd %xmm6, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x1f0(%rsp)
movq 0x100(%rsp), %r15
movss 0x10(%r15,%r12), %xmm0
addss 0x11dfc(%rip), %xmm0    # 0x32064
movss %xmm0, 0x10(%r15,%r12)
cmpq $0xff, 0x40(%rsp)
jne 0x20284
cmpb $0x7b, 0xc0(%rsp)
je 0x202fe
addq %r15, %r12
xorl %ebx, %ebx
cmpq $0x3, %rbx
je 0x202e8
movzbl 0x1d(%rsp,%rbx), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, (%rsp)
movss 0x1e8(%rsp,%rbx,4), %xmm0
divss 0x162c2(%rip), %xmm0    # 0x36570
movss 0x162be(%rip), %xmm1    # 0x36574
callq 0x4520
mulss (%rsp), %xmm0
movss 0x15708(%rip), %xmm2    # 0x359d0
minss %xmm2, %xmm0
xorps %xmm1, %xmm1
maxss %xmm0, %xmm1
mulss %xmm2, %xmm1
addss (%r12,%rbx,4), %xmm1
movss %xmm1, (%r12,%rbx,4)
incq %rbx
jmp 0x20289
movss 0xc(%r12), %xmm0
addss 0x156d9(%rip), %xmm0    # 0x359d0
movss %xmm0, 0xc(%r12)
movl 0x28(%rsp), %ecx
incl %ecx
movl 0xf8(%rsp), %esi
jmp 0x1fda5
incl %esi
jmp 0x1fd8a
movq 0x200(%rsp), %rcx
movq 0x140(%rsp), %rax
leaq (,%rax,4), %rax
movq %rax, 0x170(%rsp)
movq %r15, %r13
movq %rcx, 0x28(%rsp)
movq %rcx, %rbp
xorl %r12d, %r12d
cmpq 0xe0(%rsp), %r12
je 0x20463
movq %r12, 0x60(%rsp)
imulq 0x140(%rsp), %r12
movq %r13, 0x30(%rsp)
movq %rbp, 0x40(%rsp)
xorl %ebx, %ebx
cmpq 0xa8(%rsp), %rbx
je 0x2043c
leaq (%rbx,%r12), %r14
imulq $0x14, %r14, %rax
movss 0x10(%r15,%rax), %xmm0
ucomiss 0x11cdf(%rip), %xmm0    # 0x32070
jne 0x203a7
jp 0x203a7
movq 0x28(%rsp), %rax
movl $0xff000000, (%rax,%r14,4) # imm = 0xFF000000
jmp 0x2042c
addq %r15, %rax
movss 0xc(%rax), %xmm1
movss %xmm1, (%rsp)
divss %xmm0, %xmm1
movss 0x161b8(%rip), %xmm0    # 0x36578
ucomiss %xmm1, %xmm0
jae 0x2040d
xorl %r15d, %r15d
cmpq $0x3, %r15
je 0x20419
movss (%r13,%r15,4), %xmm0
divss (%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd 0x14e7a(%rip), %xmm0    # 0x35260
callq 0x4590
cvttsd2si %xmm0, %eax
movl $0xff, %ecx
cmpl %ecx, %eax
jl 0x203fd
movl $0xff, %eax
testl %eax, %eax
jg 0x20403
xorl %eax, %eax
movb %al, (%rbp,%r15)
incq %r15
jmp 0x203c8
movq 0x28(%rsp), %rax
andl $0x0, (%rax,%r14,4)
jmp 0x2042c
movq 0x28(%rsp), %rax
movb $-0x1, 0x3(%rax,%r14,4)
movq 0x100(%rsp), %r15
incq %rbx
addq $0x4, %rbp
addq $0x14, %r13
jmp 0x2036d
movq 0x60(%rsp), %r12
incq %r12
movq 0x40(%rsp), %rbp
addq 0x170(%rsp), %rbp
movq 0x30(%rsp), %r13
addq 0x148(%rsp), %r13
jmp 0x20345
pushq $0x1
popq %r8
movq 0x28(%rsp), %r15
cmpq $0x4, %r8
je 0x206e5
movl 0x5c(%rsp), %eax
movl %eax, %esi
movl %r8d, %ecx
sarl %cl, %esi
movq 0xa0(%rsp), %rdx
movl %edx, %eax
sarl %cl, %eax
leal -0x1(%r8), %ecx
sarl %cl, %edx
testl %eax, %eax
movl $0x0, %r9d
cmovgl %eax, %r9d
movslq %eax, %rcx
testl %esi, %esi
movl $0x0, %eax
cmovlel %eax, %esi
movq %rsi, 0xf8(%rsp)
movslq %edx, %rax
movq %rax, 0x120(%rsp)
movq %rcx, 0xf0(%rsp)
leaq (,%rcx,4), %rax
movq %rax, 0x1c0(%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
movq %r9, 0x90(%rsp)
cmpq 0xf8(%rsp), %rdx
je 0x206dd
movq %rdx, %r10
imulq 0xf0(%rsp), %r10
leaq (%rdx,%rdx), %r11
movq 0x120(%rsp), %rax
imulq %rax, %r11
movq %rdx, 0xb0(%rsp)
leaq 0x1(,%rdx,2), %rbx
imulq %rax, %rbx
movq %rcx, 0x130(%rsp)
movq %rcx, %r15
xorl %r13d, %r13d
movq %r10, 0x40(%rsp)
movq %r11, 0x60(%rsp)
movq %rbx, 0x70(%rsp)
cmpq %r9, %r13
je 0x206b8
movq 0x200(%rsp,%r8,8), %rbp
leaq (%r10,%r13), %r14
leaq (,%r13,8), %rax
addq 0x1f8(%rsp,%r8,8), %rax
leaq (%rax,%r11,4), %rcx
movq %rcx, 0x240(%rsp)
leaq (%rax,%r11,4), %rcx
addq $0x4, %rcx
movq %rcx, 0x248(%rsp)
leaq (%rax,%rbx,4), %rcx
movq %rcx, 0x250(%rsp)
leaq 0x4(%rax,%rbx,4), %rax
movq %rax, 0x258(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x180(%rsp)
movdqa %xmm0, 0x190(%rsp)
xorpd %xmm2, %xmm2
xorl %eax, %eax
cmpq $0x4, %rax
je 0x2060b
movq 0x240(%rsp,%rax,8), %rdx
movzbl 0x3(%rdx), %ecx
xorl %esi, %esi
cmpq $0x3, %rsi
je 0x205f0
movzbl (%rdx,%rsi), %edi
imull %ecx, %edi
cvtsi2sd %edi, %xmm0
addsd 0x180(%rsp,%rsi,8), %xmm0
movsd %xmm0, 0x180(%rsp,%rsi,8)
incq %rsi
jmp 0x205c8
cvtsi2sd %ecx, %xmm2
addsd 0x198(%rsp), %xmm2
movsd %xmm2, 0x198(%rsp)
incq %rax
jmp 0x205b4
movapd %xmm2, %xmm0
mulsd 0x15ed1(%rip), %xmm0    # 0x364e8
movsd 0x15ed1(%rip), %xmm1    # 0x364f0
ucomisd %xmm0, %xmm1
jae 0x20680
movq %r14, 0x30(%rsp)
movq %r8, %rbx
leaq (%r15,%rbp), %r14
xorl %r12d, %r12d
movsd %xmm2, (%rsp)
cmpq $0x3, %r12
je 0x20688
movsd 0x180(%rsp,%r12,8), %xmm0
divsd %xmm2, %xmm0
addsd 0x14c0b(%rip), %xmm0    # 0x35260
callq 0x4590
movsd (%rsp), %xmm2
cvttsd2si %xmm0, %eax
movl $0xff, %ecx
cmpl %ecx, %eax
cmovgel %ecx, %eax
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movb %al, (%r14,%r12)
incq %r12
jmp 0x20639
andl $0x0, (%rbp,%r14,4)
jmp 0x206ac
movq 0x30(%rsp), %rax
movb $-0x1, 0x3(%rbp,%rax,4)
movq %rbx, %r8
movq 0x90(%rsp), %r9
movq 0x40(%rsp), %r10
movq 0x60(%rsp), %r11
movq 0x70(%rsp), %rbx
incq %r13
addq $0x4, %r15
jmp 0x2053e
movq 0xb0(%rsp), %rdx
incq %rdx
movq 0x130(%rsp), %rcx
addq 0x1c0(%rsp), %rcx
movq 0x28(%rsp), %r15
jmp 0x204e3
incq %r8
jmp 0x2046c
movl $0x4fd8, %edi           # imm = 0x4FD8
callq 0x4420
xorl %edi, %edi
movq %rax, (%rsp)
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
movl $0x100, %eax            # imm = 0x100
movq %rax, 0x90(%rsp)
cmpb $0x7b, 0xc0(%rsp)
jne 0x20757
movq 0xe8(%rsp), %rcx
movb 0x31d(%rcx), %al
movb %al, 0x53d(%rsp)
movb 0x31e(%rcx), %al
movb %al, 0x53e(%rsp)
movb 0x31f(%rcx), %al
movb %al, 0x53f(%rsp)
movl $0xff, %eax
movq %rax, 0x90(%rsp)
movq 0x1d0(%rsp), %rax
leaq (%rax,%rax,2), %rdi
callq 0x4420
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
addq $0x3, %r15
xorl %eax, %eax
xorl %ebx, %ebx
cmpq 0xe0(%rsp), %rax
je 0x207d9
xorl %ecx, %ecx
cmpq %rcx, 0xa8(%rsp)
je 0x207cc
cmpb $0x0, (%r15,%rcx,4)
je 0x207c7
movb -0x3(%r15,%rcx,4), %dl
movslq %ebx, %rbx
leaq (%rbx,%rbx,2), %rsi
movb %dl, (%r14,%rsi)
movb -0x2(%r15,%rcx,4), %dl
movb %dl, 0x1(%r14,%rsi)
movb -0x1(%r15,%rcx,4), %dl
movb %dl, 0x2(%r14,%rsi)
incl %ebx
incq %rcx
jmp 0x20790
incq %rax
addq 0x170(%rsp), %r15
jmp 0x20784
testl %ebx, %ebx
jle 0x20bfa
movl %ebx, %eax
movq %r14, %r15
leaq (%rax,%rax,2), %r14
movq %r14, %rdi
callq 0x4420
movq %rax, %r12
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0x92cb
movq %r12, %rdi
movq %r15, 0x130(%rsp)
movq %r15, %rsi
movq %r14, %rdx
callq 0x4240
movq 0x90(%rsp), %rax
leal -0x1(,%rax,2), %r13d
imulq $0x70, %r13, %rdi
callq 0x4420
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
movl %ebp, %esi
callq 0x92cb
movb $0x1, (%r14)
andq $0x0, 0x8(%r14)
movl %ebx, 0x20(%r14)
movq %r12, 0xb0(%rsp)
movq %r12, 0x28(%r14)
movq %r14, %r12
movq %r14, %rdi
callq 0x212f0
movl %ebp, %ebx
movq %r12, 0xa8(%rsp)
movq %r13, 0x28(%rsp)
testl %ebp, %ebp
movl $0x0, %eax
cmovgl %ebp, %eax
cmpl 0x90(%rsp), %ebx
je 0x20aab
xorl %ecx, %ecx
movq %r12, %rdx
subq $0x1, %rax
jb 0x208d9
cmpb $0x1, (%rdx)
jne 0x208d3
cmpb $0x1, 0x48(%rdx)
jne 0x208d3
movsd 0x68(%rdx), %xmm0
testb $0x1, %cl
je 0x208c8
movsd 0x40(%rsp), %xmm1
addsd 0x14d4e(%rip), %xmm1    # 0x35610
ucomisd %xmm1, %xmm0
jbe 0x208d3
movb $0x1, %cl
movsd %xmm0, 0x40(%rsp)
movq %rdx, %r14
addq $0x70, %rdx
jmp 0x20899
testb $0x1, %cl
je 0x20aab
movl %ebx, 0x70(%rsp)
movq %r14, 0x30(%rsp)
movb $0x0, (%r14)
movslq %ebp, %rbx
imulq $0x70, %rbx, %r14
addq %r12, %r14
xorl %r12d, %r12d
leaq 0x1616b(%rip), %r15     # 0x36a6e
cmpq $0x2, %r12
je 0x20941
leaq (%rbx,%r12), %rax
cmpq %r13, %rax
jl 0x2091c
movq %r15, %rdi
xorl %eax, %eax
callq 0x8b2f
movq 0x30(%rsp), %rax
movq %r14, 0x10(%rax,%r12,8)
movb $0x1, (%r14)
movq %rax, 0x8(%r14)
andl $0x0, 0x20(%r14)
andq $0x0, 0x28(%r14)
incq %r12
addq $0x70, %r14
jmp 0x20903
movq %rbp, 0x60(%rsp)
movq 0x30(%rsp), %rax
movslq 0x50(%rax), %rbx
movl 0x54(%rax), %ebp
movq 0x28(%rax), %r15
movslq 0x20(%rax), %rax
leaq (%rax,%rax,2), %rax
leaq (%r15,%rax), %r14
addq $-0x3, %r14
addq $-0x3, %r15
movq %r15, %r13
movzbl 0x3(%r15,%rbx), %eax
addq $0x3, %r15
addq $0x3, %r13
cmpl %eax, %ebp
jg 0x2096d
addq $0x3, %r14
movzbl -0x3(%r14,%rbx), %eax
addq $-0x3, %r14
cmpl %eax, %ebp
jle 0x20983
cmpq %r14, %r15
jae 0x209c1
movq %r15, %rdi
leaq 0x180(%rsp), %r13
movq %r13, %rsi
callq 0x21711
movq %r14, %rdi
movq %r15, %rsi
callq 0x21711
movq %r13, %rdi
movq %r14, %rsi
callq 0x21711
jmp 0x20966
leaq -0x3(%r15), %rax
cmpq %rax, %r14
je 0x209d8
leaq 0x1609d(%rip), %rdi     # 0x36a6e
xorl %eax, %eax
callq 0x8b2f
movq %r13, %rax
movq 0x30(%rsp), %r14
subq 0x28(%r14), %rax
cqto
pushq $0x3
popq %rsi
idivq %rsi
movq 0x10(%r14), %rcx
movl %eax, 0x20(%rcx)
movq 0x10(%r14), %rax
movq 0x28(%r14), %rcx
movq %rcx, 0x28(%rax)
movslq 0x20(%r14), %rax
leaq (%rax,%rax,2), %rax
addq %rcx, %rax
subq %r13, %rax
cqto
idivq %rsi
movq 0x18(%r14), %rcx
movl %eax, 0x20(%rcx)
movq 0x18(%r14), %rax
movq %r15, 0x28(%rax)
movq 0x10(%r14), %rax
movl 0x20(%rax), %eax
testl %eax, %eax
movq 0x60(%rsp), %rbp
movl 0x70(%rsp), %ebx
jle 0x20a47
cvtsi2sd %eax, %xmm0
movsd 0x58(%r14), %xmm1
ucomisd %xmm0, %xmm1
jne 0x20a47
jnp 0x20a55
leaq 0x16020(%rip), %rdi     # 0x36a6e
xorl %eax, %eax
callq 0x8b2f
movq 0x18(%r14), %rax
movl 0x20(%rax), %eax
testl %eax, %eax
movq 0x28(%rsp), %r13
jle 0x20a77
cvtsi2sd %eax, %xmm0
movsd 0x60(%r14), %xmm1
ucomisd %xmm0, %xmm1
jne 0x20a77
jnp 0x20a85
leaq 0x15ff0(%rip), %rdi     # 0x36a6e
xorl %eax, %eax
callq 0x8b2f
movl %ebp, %ebp
addq %r12, %rbp
movq 0x10(%r14), %rdi
callq 0x212f0
movq 0x18(%r14), %rdi
callq 0x212f0
incl %ebx
movq 0xa8(%rsp), %r12
jmp 0x2087d
movq (%rsp), %rax
leaq 0x18(%rax), %rcx
testl %ebp, %ebp
movl $0x0, %eax
cmovgl %ebp, %eax
imulq $0x70, %rax, %rsi
xorl %edi, %edi
cmpq %rdi, %rsi
je 0x20b1d
movb (%r12,%rdi), %al
movb %al, -0x18(%rcx)
testb %al, %al
jne 0x20b13
movq 0x50(%r12,%rdi), %rax
movq %rax, (%rcx)
movq 0x10(%r12,%rdi), %rax
subq %r12, %rax
cqto
pushq $0x70
popq %r8
idivq %r8
imulq $0x28, %rax, %rax
movq (%rsp), %r9
addq %r9, %rax
movq %rax, -0x10(%rcx)
movq 0x18(%r12,%rdi), %rax
subq %r12, %rax
cqto
idivq %r8
imulq $0x28, %rax, %rax
addq %r9, %rax
movq %rax, -0x8(%rcx)
addq $0x28, %rcx
addq $0x70, %rdi
jmp 0x20ac3
leaq 0x240(%rsp), %rbx
xorl %esi, %esi
movq %r12, %r14
cmpb $0x0, (%r14)
jne 0x20b36
movq 0x10(%r14), %r14
jmp 0x20b2a
movq %r14, %rax
subq %r12, %rax
cqto
pushq $0x70
popq %rcx
idivq %rcx
imulq $0x28, %rax, %rax
movq (%rsp), %rcx
movl %esi, 0x20(%rcx,%rax)
pushq $0x6
popq %r15
cmpq $0x9, %r15
je 0x20b9d
movq %rsi, %r13
movsd (%r14,%r15,8), %xmm0
addsd 0x146f5(%rip), %xmm0    # 0x35260
addsd 0x1150d(%rip), %xmm0    # 0x32080
callq 0x4590
cvttsd2si %xmm0, %eax
movl $0xff, %ecx
cmpl %ecx, %eax
jl 0x20b8a
movl $0xff, %eax
testl %eax, %eax
jg 0x20b90
xorl %eax, %eax
movb %al, -0x6(%rbx,%r15)
incq %r15
movq %r13, %rsi
jmp 0x20b54
incq %rsi
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x20bbf
cmpq 0x10(%rax), %r14
movq %rax, %r14
jne 0x20ba0
movq 0x18(%rax), %r14
addq $0x3, %rbx
jmp 0x20b2a
movq %rsi, %rbx
leal -0x1(,%rsi,2), %eax
cmpl %ebp, %eax
je 0x20bdb
leaq 0x15e9a(%rip), %rdi     # 0x36a6e
xorl %eax, %eax
callq 0x8b2f
movq 0xb0(%rsp), %rdi
callq 0x4380
movq %r12, %rdi
callq 0x4380
movq 0x130(%rsp), %r14
jmp 0x20bfc
xorl %ebx, %ebx
movq %rbx, %r13
movslq %ebx, %rax
movl 0x90(%rsp), %ecx
leaq (%rax,%rax,2), %rdx
leaq 0x242(%rsp), %rsi
addq %rsi, %rdx
cmpq %rcx, %rax
jge 0x20c2e
movb $0x0, (%rdx)
andw $0x0, -0x2(%rdx)
incq %rax
addq $0x3, %rdx
jmp 0x20c18
movq %r14, %rdi
callq 0x4380
xorl %edi, %edi
leaq 0x118c7bd(%rip), %rbx   # 0x11ad3fc
cmpl $0x7fff, (%rbx)         # imm = 0x7FFF
setl %dil
pushq $0x26
popq %rsi
callq 0x92cb
movslq (%rbx), %rcx
imulq $0x28, %rcx, %rax
leal 0x1(%rcx), %edx
movq 0x150(%rsp), %rsi
movw %cx, 0xa(%rsi)
movl %edx, (%rbx)
movq 0x1d8(%rsp), %rdx
movq 0x20(%rdx), %rcx
leaq 0x118c784(%rip), %rsi   # 0x11ad400
movq %rcx, 0x20(%rsi,%rax)
movupd (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rsi,%rax)
movupd %xmm0, (%rsi,%rax)
movq 0x20(%rsp), %rcx
cmpl $0x1, %ecx
leaq 0xc0(%rsp), %rbx
jne 0x20f3d
addq %rsi, %rax
leaq 0x82c7f5(%rip), %rcx    # 0x84d4a8
movq (%rcx), %rcx
movl 0x524dd18(%rip), %edx   # 0x526e9d4
addl (%rcx), %edx
movl %edx, 0x20(%rax)
movl 0x78(%rsp), %ebp
movl 0x7c(%rsp), %r15d
xorl %ecx, %ecx
pushq $0x28
popq %rsi
cmpl $0x4, %ecx
je 0x20ce6
movl %ebp, %eax
sarl %cl, %eax
movl %r15d, %edx
sarl %cl, %edx
imull %eax, %edx
addl %edx, %esi
incl %ecx
jmp 0x20ccf
addl $0x304, %esi            # imm = 0x304
movl %esi, 0x40(%rsp)
movslq %esi, %rdi
movq %rdi, 0x60(%rsp)
callq 0x4420
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x92cb
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%r14)
movupd %xmm0, (%r14)
andq $0x0, 0x20(%r14)
movl %ebp, 0x10(%r14)
movl %r15d, 0x14(%r14)
movq %r14, 0x30(%rsp)
addq $0x28, %r14
xorl %r12d, %r12d
movq %r13, %rsi
cmpq $0x4, %r12
je 0x20ebc
movl %r14d, %eax
movq 0x30(%rsp), %rcx
subl %ecx, %eax
movl %eax, 0x18(%rcx,%r12,4)
xorl %ebx, %ebx
movl %r15d, %eax
movl %r12d, %ecx
sarl %cl, %eax
cmpl %eax, %ebx
jge 0x20eac
xorl %r15d, %r15d
movl %ebp, %edx
movl %r12d, %ecx
sarl %cl, %edx
cmpl %edx, %r15d
jge 0x20ea0
movq 0x200(%rsp,%r12,8), %rax
imull %ebx, %edx
addl %r15d, %edx
movslq %edx, %rcx
cmpb $0x0, 0x3(%rax,%rcx,4)
je 0x20e87
testl %esi, %esi
je 0x20e8d
movb (%rax,%rcx,4), %dl
movb %dl, 0x80(%rsp)
movb 0x1(%rax,%rcx,4), %dl
movb %dl, 0x81(%rsp)
movb 0x2(%rax,%rcx,4), %al
movb %al, 0x82(%rsp)
testl %esi, %esi
jg 0x20dd0
leaq 0x15ce9(%rip), %rdi     # 0x36ab2
xorl %eax, %eax
callq 0x8b2f
movq (%rsp), %rax
cmpb $0x0, (%rax)
jne 0x20df4
movslq 0x18(%rax), %rcx
movzbl 0x80(%rsp,%rcx), %ecx
xorl %edx, %edx
cmpl %ecx, 0x1c(%rax)
setle %dl
movq 0x8(%rax,%rdx,8), %rax
jmp 0x20dd4
movslq 0x20(%rax), %rax
movl %eax, 0x108(%rsp)
leaq (%rax,%rax,2), %rax
addq %rsp, %rax
addq $0x240, %rax            # imm = 0x240
xorl %ecx, %ecx
xorl %edx, %edx
cmpq $0x3, %rcx
je 0x20e2e
movzbl (%rax,%rcx), %esi
movzbl 0x80(%rsp,%rcx), %edi
subl %edi, %esi
imull %esi, %esi
addl %esi, %edx
incq %rcx
jmp 0x20e10
movl %edx, 0x180(%rsp)
cvtsi2sd %edx, %xmm0
sqrtsd %xmm0, %xmm0
addsd 0x147cb(%rip), %xmm0    # 0x35610
callq 0x4090
cvttsd2si %xmm0, %r9d
leaq 0x180(%rsp), %rdi
leaq 0x108(%rsp), %rsi
movq (%rsp), %rdx
leaq 0x240(%rsp), %rcx
leaq 0x80(%rsp), %r8
callq 0x2162d
movb 0x108(%rsp), %al
movb %al, (%r14)
movq %r13, %rsi
jmp 0x20e91
movb $-0x1, (%r14)
jmp 0x20e91
movb $0x0, (%r14)
incq %r14
incl %r15d
movl 0x78(%rsp), %ebp
jmp 0x20d6a
incl %ebx
movl 0x7c(%rsp), %r15d
jmp 0x20d57
incq %r12
leaq 0xc0(%rsp), %rbx
jmp 0x20d3c
movw $0x100, (%r14)          # imm = 0x100
leaq 0x2(%r14), %rdi
movl $0x300, %edx            # imm = 0x300
leaq 0x240(%rsp), %rsi
callq 0x4240
andw $0x0, 0x302(%r14)
addq $0x304, %r14            # imm = 0x304
movq 0x30(%rsp), %r12
movq %r12, %rax
addq 0x60(%rsp), %rax
cmpq %rax, %r14
je 0x20f08
leaq 0x15acb(%rip), %rdi     # 0x369cc
xorl %eax, %eax
callq 0x8b2f
cmpb $0x7b, 0xc0(%rsp)
movl 0x11c(%rsp), %edi
movq 0x100(%rsp), %r14
movl 0x40(%rsp), %r15d
jne 0x20fb1
movb $0x64, 0x4(%r12)
movl $0x61725f7b, (%r12)     # imm = 0x61725F7B
jmp 0x20fbf
movsd 0x14183(%rip), %xmm0    # 0x350c8
divsd 0x220(%rsp), %xmm0
cvtsi2ss %ecx, %xmm1
movapd %xmm0, %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
leaq (%rsi,%rax), %rcx
addq $0xc, %rcx
xorl %edx, %edx
cmpq $0x20, %rdx
je 0x20ca9
cvtps2pd -0xc(%rcx,%rdx), %xmm3
mulpd %xmm2, %xmm3
cvtpd2ps %xmm3, %xmm3
movlpd %xmm3, -0xc(%rcx,%rdx)
cvtss2sd -0x4(%rcx,%rdx), %xmm3
mulsd %xmm0, %xmm3
cvtsd2ss %xmm3, %xmm3
movss %xmm3, -0x4(%rcx,%rdx)
movss (%rcx,%rdx), %xmm3
divss %xmm1, %xmm3
addss 0x14a42(%rip), %xmm3    # 0x359e8
movss %xmm3, (%rcx,%rdx)
addq $0x10, %rdx
jmp 0x20f64
movb $0x64, 0x4(%r12)
movl $0x61725f5f, (%r12)     # imm = 0x61725F5F
movl %edi, %eax
xorl %edx, %edx
movw $0x2710, %cx            # imm = 0x2710
divw %cx
orb $0x30, %al
movb %al, 0x5(%r12)
movl %edi, %eax
xorl %edx, %edx
movw $0x3e8, %cx             # imm = 0x3E8
divw %cx
movzbl %al, %eax
movb $0xa, %cl
divb %cl
movzbl %ah, %eax
orb $0x30, %al
movb %al, 0x6(%r12)
movl %edi, %eax
xorl %edx, %edx
movw $0x64, %cx
divw %cx
xorl %edx, %edx
movw $0xa, %si
divw %si
orb $0x30, %dl
movb %dl, 0x7(%r12)
movl %edi, %eax
xorl %edx, %edx
divw %si
movl %edx, %ecx
xorl %edx, %edx
divw %si
orb $0x30, %dl
movb %dl, 0x8(%r12)
orb $0x30, %cl
movb %cl, 0x9(%r12)
xorl %eax, %eax
cmpq $0x3e, %rax
je 0x21054
cmpq $0x24, %rax
jb 0x2103a
leal 0x3d(%rax), %ecx
jmp 0x21048
cmpq $0xa, %rax
jb 0x21045
leal 0x37(%rax), %ecx
jmp 0x21048
leal 0x30(%rax), %ecx
movb %cl, 0x180(%rsp,%rax)
incq %rax
jmp 0x21029
xorl %eax, %eax
testl %r15d, %r15d
movl $0x0, %edx
cmovgl %r15d, %edx
andw $0x0, 0xe(%r12)
andl $0x0, 0xa(%r12)
xorl %ecx, %ecx
cmpq %rax, %rdx
je 0x21085
imull $0x1f, %ecx, %esi
movzbl (%r12,%rax), %ecx
addl %esi, %ecx
incq %rax
jmp 0x21071
movl %ecx, %eax
xorl %edx, %edx
movl $0xf04, %esi            # imm = 0xF04
divl %esi
xorl %edx, %edx
pushq $0x34
popq %rsi
divl %esi
leaq 0x180(%rsp), %rax
movb 0xa(%rdx,%rax), %al
movb %al, 0xa(%r12)
movl %ecx, %eax
xorl %edx, %edx
pushq $0x3e
popq %rsi
divl %esi
movl %edx, %ecx
xorl %edx, %edx
divl %esi
movb 0x180(%rsp,%rdx), %al
movb %al, 0xb(%r12)
movb 0x180(%rsp,%rcx), %al
movb %al, 0xc(%r12)
movl 0x58(%rsp), %ebp
movl %ebp, %eax
cltd
idivl %esi
movl %edx, %ecx
cltd
idivl %esi
movslq %edx, %rax
movb 0x180(%rsp,%rax), %al
movb %al, 0xd(%r12)
movslq %ecx, %rax
movb 0x180(%rsp,%rax), %al
movb %al, 0xe(%r12)
movb $0x0, 0xf(%r12)
movl %r15d, %edi
movq %r12, %rsi
callq 0x1f579
incl %ebp
movl %ebp, 0x58(%rsp)
imulq $0xc, 0x10(%rsp), %rax
leaq 0x4c1f801(%rip), %rcx   # 0x4c40920
cvtss2sd (%rcx,%rax), %xmm0
cvtss2sd 0x4(%rcx,%rax), %xmm1
cvtss2sd 0x8(%rcx,%rax), %xmm2
pushq $0x3
popq %rdi
leaq 0x158c6(%rip), %rsi     # 0x36a00
movq %r12, %rdx
movq %rbx, %rcx
movb $0x3, %al
callq 0x9045
movq %r12, %rdi
callq 0x4380
movq (%rsp), %rdi
callq 0x4380
movq %r14, %rdi
callq 0x4380
xorl %ebx, %ebx
cmpq $0x4, %rbx
je 0x2117a
movq 0x200(%rsp,%rbx,8), %rdi
callq 0x4380
incq %rbx
jmp 0x21162
addl %r15d, 0x8c(%rsp)
leaq 0x118c277(%rip), %rbx   # 0x11ad400
leaq 0x82c314(%rip), %r8     # 0x84d4a4
leaq 0x1b8c26d(%rip), %r9    # 0x1bad404
leaq 0x1b8c272(%rip), %r10   # 0x1bad410
leaq 0x118c257(%rip), %r11   # 0x11ad3fc
jmp 0x1f91f
callq 0x1f60f
testb $0x1, 0xd8(%rsp)
je 0x211d2
leaq 0x15883(%rip), %rdi     # 0x36a43
movl 0x58(%rsp), %esi
movl 0x8c(%rsp), %edx
xorl %eax, %eax
callq 0x8790
addq $0x548, %rsp            # imm = 0x548
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq