// File: FreeSlave[P]vhlt/hlcsg/textures.cpp
// Function: WriteMiptex()
void            WriteMiptex()
{
    int             len, texsize, totaltexsize = 0;
    byte*           data;
    dmiptexlump_t*  l;
    double          start, end;

    g_texdatasize = 0;

    start = I_FloatTime();
    {
        if (!TEX_InitFromWad())
            return;

        AddAnimatingTextures();
    }
    end = I_FloatTime();
    Verbose("TEX_InitFromWad & AddAnimatingTextures elapsed time = %ldms\n", (long)(end - start));

    start = I_FloatTime();
    {
        int             i;

        for (i = 0; i < nummiptex; i++)
        {
            lumpinfo_t*     found;

            found = FindTexture(miptex + i);
            if (found)
            {
                miptex[i] = *found;
#ifdef HLCSG_AUTOWAD_NEW
				texwadpathes[found->iTexFile]->usedtextures++;
#endif
            }
            else
            {
                miptex[i].iTexFile = miptex[i].filepos = miptex[i].disksize = 0;
            }
        }
    }
    end = I_FloatTime();
    Verbose("FindTextures elapsed time = %ldms\n", (long)(end - start));

#ifdef HLCSG_AUTOWAD_NEW
	// Now we have filled lumpinfo for each miptex and the number of used textures for each wad.
	{
		char szTmpWad[MAX_VAL];
		int i;

		szTmpWad[0] = 0;
		for (i = 0; i < nTexFiles; i++)
		{
			wadpath_t *currentwad = texwadpathes[i];
			if (!currentwad->usedbymap && (currentwad->usedtextures > 0 || !g_bWadAutoDetect))
			{
				Log ("Including Wadfile: %s\n", currentwad->path);
				double percused = (double)currentwad->usedtextures / (double)nummiptex * 100;
				Log (" - Contains %i used texture%s, %2.2f percent of map (%d textures in wad)\n",
					 currentwad->usedtextures, currentwad->usedtextures == 1? "": "s", percused, currentwad->totaltextures);
			}
		}
		for (i = 0; i < nTexFiles; i++)
		{
			wadpath_t *currentwad = texwadpathes[i];
			if (currentwad->usedbymap && (currentwad->usedtextures > 0 || !g_bWadAutoDetect))
			{
				Log ("Using Wadfile: %s\n", currentwad->path);
				double percused = (double)currentwad->usedtextures / (double)nummiptex * 100;
				Log (" - Contains %i used texture%s, %2.2f percent of map (%d textures in wad)\n",
					 currentwad->usedtextures, currentwad->usedtextures == 1? "": "s", percused, currentwad->totaltextures);
	#ifdef HLCSG_STRIPWADPATH
				char tmp[_MAX_PATH];
				ExtractFile (currentwad->path, tmp);
				safe_strncat (szTmpWad, tmp, MAX_VAL);
	#else
				safe_strncat (szTmpWad, currentwad->path, MAX_VAL);
	#endif
				safe_strncat (szTmpWad, ";", MAX_VAL);
			}
		}
		
	#ifdef HLCSG_CHART_FIX
		Log("\n");
		if (*szTmpWad)
		{
			Log ("Wad files required to run the map: \"%s\"\n", szTmpWad);
		}
		else
		{
			Log ("Wad files required to run the map: (None)\n");
		}
	#endif
		SetKeyValue(&g_entities[0], "wad", szTmpWad);
	}

#endif
    start = I_FloatTime();
    {
        int             i;
        texinfo_t*      tx = g_texinfo;

        // Sort them FIRST by wadfile and THEN by name for most efficient loading in the engine.
        qsort((void*)miptex, (size_t) nummiptex, sizeof(miptex[0]), lump_sorter_by_wad_and_name);

        // Sleazy Hack 104 Pt 2 - After sorting the miptex array, reset the texinfos to point to the right miptexs
        for (i = 0; i < g_numtexinfo; i++, tx++)
        {
#ifdef HLCSG_TEXMAP64_FIX
            char*          miptex_name = texmap_retrieve(tx->miptex);
#else
            char*          miptex_name = texmap64_retrieve(tx->miptex);
#endif

            tx->miptex = FindMiptex(miptex_name);

#ifndef HLCSG_TEXMAP64_FIX
            // Free up the originally strdup()'ed miptex_name
            free(miptex_name);
#endif
        }
#ifdef HLCSG_TEXMAP64_FIX
		texmap_clear ();
#endif
    }
    end = I_FloatTime();
    Verbose("qsort(miptex) elapsed time = %ldms\n", (long)(end - start));

    start = I_FloatTime();
    {
        int             i;

        // Now setup to get the miptex data (or just the headers if using -wadtextures) from the wadfile
        l = (dmiptexlump_t*)g_dtexdata;
        data = (byte*) & l->dataofs[nummiptex];
        l->nummiptex = nummiptex;
#ifdef ZHLT_NOWADDIR
		char writewad_name[_MAX_PATH];
		FILE *writewad_file;
		int writewad_maxlumpinfos;
		typedef struct
		{
			int             filepos;
			int             disksize;
			int             size;
			char            type;
			char            compression;
			char            pad1, pad2;
			char            name[MAXWADNAME];
		} dlumpinfo_t;
		dlumpinfo_t *writewad_lumpinfos;
		wadinfo_t writewad_header;
		safe_snprintf (writewad_name, _MAX_PATH, "%s.wa_", g_Mapname);
		writewad_file = SafeOpenWrite (writewad_name);
		writewad_maxlumpinfos = nummiptex;
		writewad_lumpinfos = (dlumpinfo_t *)malloc (writewad_maxlumpinfos * sizeof (dlumpinfo_t));
		hlassume (writewad_lumpinfos != NULL, assume_NoMemory);
		writewad_header.identification[0] = 'W';
		writewad_header.identification[1] = 'A';
		writewad_header.identification[2] = 'D';
		writewad_header.identification[3] = '3';
		writewad_header.numlumps = 0;
		if (fseek (writewad_file, sizeof (wadinfo_t), SEEK_SET))
			Error ("File write failure");
#endif
        for (i = 0; i < nummiptex; i++)
        {
            l->dataofs[i] = data - (byte*) l;
#ifdef ZHLT_NOWADDIR
			byte *writewad_data;
			int writewad_datasize;
			len = LoadLump (miptex + i, data, &texsize
#ifdef HLCSG_FILEREADFAILURE_FIX
							, &g_dtexdata[g_max_map_miptex] - data
#endif
							, writewad_data, writewad_datasize);
			if (writewad_data)
			{
				dlumpinfo_t *writewad_lumpinfo = &writewad_lumpinfos[writewad_header.numlumps];
				writewad_lumpinfo->filepos = ftell (writewad_file);
				writewad_lumpinfo->disksize = writewad_datasize;
				writewad_lumpinfo->size = miptex[i].size;
				writewad_lumpinfo->type = miptex[i].type;
				writewad_lumpinfo->compression = miptex[i].compression;
				writewad_lumpinfo->pad1 = miptex[i].pad1;
				writewad_lumpinfo->pad2 = miptex[i].pad2;
				memcpy (writewad_lumpinfo->name, miptex[i].name, MAXWADNAME);
				writewad_header.numlumps++;
				SafeWrite (writewad_file, writewad_data, writewad_datasize);
				free (writewad_data);
			}
#else
            len = LoadLump(miptex + i, data, &texsize
#ifdef HLCSG_FILEREADFAILURE_FIX
							, &g_dtexdata[g_max_map_miptex] - data
#endif
							);
#endif

            if (!len)
            {
                l->dataofs[i] = -1;                        // didn't find the texture
            }
            else
            {
                totaltexsize += texsize;

                hlassume(totaltexsize < g_max_map_miptex, assume_MAX_MAP_MIPTEX);
            }
            data += len;
        }
        g_texdatasize = data - g_dtexdata;
#ifdef ZHLT_NOWADDIR
		writewad_header.infotableofs = ftell (writewad_file);
		SafeWrite (writewad_file, writewad_lumpinfos, writewad_header.numlumps * sizeof (dlumpinfo_t));
		if (fseek (writewad_file, 0, SEEK_SET))
			Error ("File write failure");
		SafeWrite (writewad_file, &writewad_header, sizeof (wadinfo_t));
		if (fclose (writewad_file))
			Error ("File write failure");
#endif
    }
    end = I_FloatTime();
    Log("Texture usage is at %1.2f mb (of %1.2f mb MAX)\n", (float)totaltexsize / (1024 * 1024),
        (float)g_max_map_miptex / (1024 * 1024));
    Verbose("LoadLump() elapsed time = %ldms\n", (long)(end - start));
}

// Assembly:
subq $0x30d8, %rsp           # imm = 0x30D8
movl $0x0, 0x30cc(%rsp)
leaq 0x817ceb(%rip), %rax    # 0x83f514
movl $0x0, (%rax)
callq 0x93c0
movsd %xmm0, 0x30b0(%rsp)
callq 0x268a0
testb $0x1, %al
jne 0x2784b
jmp 0x28216
callq 0x275b0
callq 0x93c0
movsd %xmm0, 0x30a8(%rsp)
movsd 0x30a8(%rsp), %xmm0
subsd 0x30b0(%rsp), %xmm0
cvttsd2si %xmm0, %rsi
leaq 0x869d(%rip), %rdi      # 0x2ff19
movb $0x0, %al
callq 0xc000
callq 0x93c0
movsd %xmm0, 0x30b0(%rsp)
movl $0x0, 0x30a4(%rsp)
movl 0x30a4(%rsp), %eax
cmpl 0x61b4753(%rip), %eax   # 0x61dbffc
jge 0x2799b
movslq 0x30a4(%rsp), %rax
leaq 0x61b4742(%rip), %rdi   # 0x61dc000
imulq $0x24, %rax, %rax
addq %rax, %rdi
callq 0x27060
movq %rax, 0x3098(%rsp)
cmpq $0x0, 0x3098(%rsp)
je 0x2792d
movq 0x3098(%rsp), %rsi
movslq 0x30a4(%rsp), %rax
leaq 0x61b470c(%rip), %rdi   # 0x61dc000
imulq $0x24, %rax, %rax
addq %rax, %rdi
movl $0x24, %edx
callq 0x4310
movq 0x3098(%rsp), %rax
movslq 0x20(%rax), %rcx
leaq 0x61b3ec8(%rip), %rax   # 0x61db7e0
movq (%rax,%rcx,8), %rax
movl 0x1004(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1004(%rax)
jmp 0x27983
movslq 0x30a4(%rsp), %rcx
leaq 0x61b46c4(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movslq 0x30a4(%rsp), %rcx
leaq 0x61b46a7(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
movslq 0x30a4(%rsp), %rcx
leaq 0x61b468b(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x20(%rax)
jmp 0x27985
movl 0x30a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30a4(%rsp)
jmp 0x2789c
callq 0x93c0
movsd %xmm0, 0x30a8(%rsp)
movsd 0x30a8(%rsp), %xmm0
subsd 0x30b0(%rsp), %xmm0
cvttsd2si %xmm0, %rsi
leaq 0x858f(%rip), %rdi      # 0x2ff56
movb $0x0, %al
callq 0xc000
movb $0x0, 0x2090(%rsp)
movl $0x0, 0x208c(%rsp)
movl 0x208c(%rsp), %eax
cmpl 0x61b41f2(%rip), %eax   # 0x61dbbe0
jge 0x27afa
movslq 0x208c(%rsp), %rcx
leaq 0x61b3ddd(%rip), %rax   # 0x61db7e0
movq (%rax,%rcx,8), %rax
movq %rax, 0x2080(%rsp)
movq 0x2080(%rsp), %rax
testb $0x1, 0x1000(%rax)
jne 0x27ae2
movq 0x2080(%rsp), %rax
cmpl $0x0, 0x1004(%rax)
jg 0x27a45
leaq 0x61b3cb5(%rip), %rax   # 0x61db6f1
testb $0x1, (%rax)
jne 0x27ae2
movq 0x2080(%rsp), %rsi
leaq 0x8525(%rip), %rdi      # 0x2ff79
movb $0x0, %al
callq 0xb5d0
movq 0x2080(%rsp), %rax
cvtsi2sdl 0x1004(%rax), %xmm0
cvtsi2sdl 0x61b4589(%rip), %xmm1 # 0x61dbffc
divsd %xmm1, %xmm0
movsd 0x25e1(%rip), %xmm1     # 0x2a060
mulsd %xmm1, %xmm0
movsd %xmm0, 0x2078(%rsp)
movq 0x2080(%rsp), %rax
movl 0x1004(%rax), %esi
movq 0x2080(%rsp), %rax
movl 0x1004(%rax), %ecx
leaq 0x2657(%rip), %rdx      # 0x2a106
leaq 0x4283(%rip), %rax      # 0x2bd39
cmpl $0x1, %ecx
cmoveq %rax, %rdx
movsd 0x2078(%rsp), %xmm0
movq 0x2080(%rsp), %rax
movl 0x1008(%rax), %ecx
leaq 0x84b5(%rip), %rdi      # 0x2ff90
movb $0x1, %al
callq 0xb5d0
jmp 0x27ae4
movl 0x208c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x208c(%rsp)
jmp 0x279e1
movl $0x0, 0x208c(%rsp)
movl 0x208c(%rsp), %eax
cmpl 0x61b40ce(%rip), %eax   # 0x61dbbe0
jge 0x27c66
movslq 0x208c(%rsp), %rcx
leaq 0x61b3cb9(%rip), %rax   # 0x61db7e0
movq (%rax,%rcx,8), %rax
movq %rax, 0x2070(%rsp)
movq 0x2070(%rsp), %rax
testb $0x1, 0x1000(%rax)
je 0x27c4e
movq 0x2070(%rsp), %rax
cmpl $0x0, 0x1004(%rax)
jg 0x27b69
leaq 0x61b3b91(%rip), %rax   # 0x61db6f1
testb $0x1, (%rax)
jne 0x27c4e
movq 0x2070(%rsp), %rsi
leaq 0x8462(%rip), %rdi      # 0x2ffda
movb $0x0, %al
callq 0xb5d0
movq 0x2070(%rsp), %rax
cvtsi2sdl 0x1004(%rax), %xmm0
cvtsi2sdl 0x61b4465(%rip), %xmm1 # 0x61dbffc
divsd %xmm1, %xmm0
movsd 0x24bd(%rip), %xmm1     # 0x2a060
mulsd %xmm1, %xmm0
movsd %xmm0, 0x2068(%rsp)
movq 0x2070(%rsp), %rax
movl 0x1004(%rax), %esi
movq 0x2070(%rsp), %rax
movl 0x1004(%rax), %ecx
leaq 0x2533(%rip), %rdx      # 0x2a106
leaq 0x415f(%rip), %rax      # 0x2bd39
cmpl $0x1, %ecx
cmoveq %rax, %rdx
movsd 0x2068(%rsp), %xmm0
movq 0x2070(%rsp), %rax
movl 0x1008(%rax), %ecx
leaq 0x8391(%rip), %rdi      # 0x2ff90
movb $0x1, %al
callq 0xb5d0
movq 0x2070(%rsp), %rdi
leaq 0x1060(%rsp), %rsi
callq 0x9730
leaq 0x2090(%rsp), %rdi
leaq 0x1060(%rsp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x9b30
leaq 0x2090(%rsp), %rdi
leaq 0x83a9(%rip), %rsi      # 0x2ffed
movl $0x1000, %edx           # imm = 0x1000
callq 0x9b30
jmp 0x27c50
movl 0x208c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x208c(%rsp)
jmp 0x27b05
leaq 0x40cb(%rip), %rdi      # 0x2bd38
movb $0x0, %al
callq 0xb5d0
cmpb $0x0, 0x2090(%rsp)
je 0x27c96
leaq 0x2090(%rsp), %rsi
leaq 0x26f3(%rip), %rdi      # 0x2a380
movb $0x0, %al
callq 0xb5d0
jmp 0x27ca4
leaq 0x2665(%rip), %rdi      # 0x2a302
movb $0x0, %al
callq 0xb5d0
leaq 0x2090(%rsp), %rdx
leaq 0x20057fd(%rip), %rdi   # 0x202d4b0
leaq 0x6d6f(%rip), %rsi      # 0x2ea29
callq 0x8070
callq 0x93c0
movsd %xmm0, 0x30b0(%rsp)
leaq 0x117779c(%rip), %rax   # 0x119f470
movq %rax, 0x1050(%rsp)
movslq 0x61b4319(%rip), %rsi   # 0x61dbffc
leaq 0x61b4316(%rip), %rdi   # 0x61dc000
movl $0x24, %edx
leaq 0x52a(%rip), %rcx       # 0x28220
callq 0x4710
movl $0x0, 0x105c(%rsp)
movl 0x105c(%rsp), %eax
leaq 0x1177758(%rip), %rcx   # 0x119f46c
cmpl (%rcx), %eax
jge 0x27d71
movq 0x1050(%rsp), %rax
movl 0x20(%rax), %edi
callq 0x28290
movq %rax, 0x1048(%rsp)
movq 0x1048(%rsp), %rdi
callq 0x27710
movl %eax, %ecx
movq 0x1050(%rsp), %rax
movl %ecx, 0x20(%rax)
movl 0x105c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x105c(%rsp)
movq 0x1050(%rsp), %rax
addq $0x28, %rax
movq %rax, 0x1050(%rsp)
jmp 0x27d06
callq 0x282e0
callq 0x93c0
movsd %xmm0, 0x30a8(%rsp)
movsd 0x30a8(%rsp), %xmm0
subsd 0x30b0(%rsp), %xmm0
cvttsd2si %xmm0, %rsi
leaq 0x824d(%rip), %rdi      # 0x2ffef
movb $0x0, %al
callq 0xc000
callq 0x93c0
movsd %xmm0, 0x30b0(%rsp)
leaq 0x81775a(%rip), %rax    # 0x83f518
movq (%rax), %rax
movq %rax, 0x30b8(%rsp)
movq 0x30b8(%rsp), %rax
addq $0x4, %rax
movslq 0x61b4220(%rip), %rcx   # 0x61dbffc
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x30c0(%rsp)
movl 0x61b420b(%rip), %ecx   # 0x61dbffc
movq 0x30b8(%rsp), %rax
movl %ecx, (%rax)
leaq 0x40(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
leaq 0x3d0c(%rip), %rdx      # 0x2bb18
leaq 0xe5cd(%rip), %rcx      # 0x363e0
movb $0x0, %al
callq 0x99e0
leaq 0x40(%rsp), %rdi
callq 0xb020
movq %rax, 0x38(%rsp)
movl 0x61b41cd(%rip), %eax   # 0x61dbffc
movl %eax, 0x34(%rsp)
movslq 0x34(%rsp), %rdi
shlq $0x5, %rdi
callq 0x4500
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
setne %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x1, %esi
callq 0xc400
movb $0x57, 0x1c(%rsp)
movb $0x41, 0x1d(%rsp)
movb $0x44, 0x1e(%rsp)
movb $0x33, 0x1f(%rsp)
movl $0x0, 0x20(%rsp)
movq 0x38(%rsp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x4440
cmpl $0x0, %eax
je 0x27e9f
leaq 0x3a93(%rip), %rdi      # 0x2b92b
movb $0x0, %al
callq 0xba80
movl $0x0, 0x1044(%rsp)
movl 0x1044(%rsp), %eax
cmpl 0x61b4145(%rip), %eax   # 0x61dbffc
jge 0x28105
movq 0x30c0(%rsp), %rax
movq 0x30b8(%rsp), %rcx
subq %rcx, %rax
movl %eax, %edx
movq 0x30b8(%rsp), %rax
movslq 0x1044(%rsp), %rcx
movl %edx, 0x4(%rax,%rcx,4)
movslq 0x1044(%rsp), %rax
leaq 0x61b410b(%rip), %rdi   # 0x61dc000
imulq $0x24, %rax, %rax
addq %rax, %rdi
movq 0x30c0(%rsp), %rsi
leaq 0x81760d(%rip), %rax    # 0x83f518
movq (%rax), %rax
leaq 0xe4ab(%rip), %rcx      # 0x363c0
movslq (%rcx), %rcx
addq %rcx, %rax
movq 0x30c0(%rsp), %rcx
subq %rcx, %rax
movl %eax, %ecx
leaq 0x30d0(%rsp), %rdx
leaq 0x10(%rsp), %r8
leaq 0xc(%rsp), %r9
callq 0x27320
movl %eax, 0x30d4(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0x28076
movq 0x28(%rsp), %rax
movslq 0x20(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, (%rsp)
movq 0x38(%rsp), %rdi
callq 0x4030
movl %eax, %ecx
movq (%rsp), %rax
movl %ecx, (%rax)
movl 0xc(%rsp), %ecx
movq (%rsp), %rax
movl %ecx, 0x4(%rax)
movslq 0x1044(%rsp), %rcx
leaq 0x61b406d(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq (%rsp), %rax
movl %ecx, 0x8(%rax)
movslq 0x1044(%rsp), %rcx
leaq 0x61b404d(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movb 0xc(%rax), %cl
movq (%rsp), %rax
movb %cl, 0xc(%rax)
movslq 0x1044(%rsp), %rcx
leaq 0x61b402d(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movb 0xd(%rax), %cl
movq (%rsp), %rax
movb %cl, 0xd(%rax)
movslq 0x1044(%rsp), %rcx
leaq 0x61b400d(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movb 0xe(%rax), %cl
movq (%rsp), %rax
movb %cl, 0xe(%rax)
movslq 0x1044(%rsp), %rcx
leaq 0x61b3fed(%rip), %rax   # 0x61dc000
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movb 0xf(%rax), %cl
movq (%rsp), %rax
movb %cl, 0xf(%rax)
movq (%rsp), %rax
movslq 0x1044(%rsp), %rdx
leaq 0x61b3fc9(%rip), %rcx   # 0x61dc000
imulq $0x24, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
callq 0xb130
movq 0x10(%rsp), %rdi
callq 0x4470
cmpl $0x0, 0x30d4(%rsp)
jne 0x2809a
movq 0x30b8(%rsp), %rax
movslq 0x1044(%rsp), %rcx
movl $0xffffffff, 0x4(%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x280d2
movl 0x30d0(%rsp), %eax
addl 0x30cc(%rsp), %eax
movl %eax, 0x30cc(%rsp)
movl 0x30cc(%rsp), %eax
leaq 0xe303(%rip), %rcx      # 0x363c0
cmpl (%rcx), %eax
setl %al
movzbl %al, %edi
andl $0x1, %edi
movl $0x25, %esi
callq 0xc400
movl 0x30d4(%rsp), %ecx
movq 0x30c0(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x30c0(%rsp)
movl 0x1044(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1044(%rsp)
jmp 0x27eaa
movq 0x30c0(%rsp), %rax
leaq 0x817404(%rip), %rcx    # 0x83f518
movq (%rcx), %rcx
subq %rcx, %rax
movl %eax, %ecx
leaq 0x8173f1(%rip), %rax    # 0x83f514
movl %ecx, (%rax)
movq 0x38(%rsp), %rdi
callq 0x4030
movl %eax, 0x24(%rsp)
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
movslq 0x20(%rsp), %rax
shlq $0x5, %rax
movl %eax, %edx
callq 0xb130
movq 0x38(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x4440
cmpl $0x0, %eax
je 0x28170
leaq 0x37c2(%rip), %rdi      # 0x2b92b
movb $0x0, %al
callq 0xba80
movq 0x38(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
movl $0xc, %edx
callq 0xb130
movq 0x38(%rsp), %rdi
callq 0x43a0
cmpl $0x0, %eax
je 0x281a1
leaq 0x3791(%rip), %rdi      # 0x2b92b
movb $0x0, %al
callq 0xba80
callq 0x93c0
movsd %xmm0, 0x30a8(%rsp)
cvtsi2ssl 0x30cc(%rsp), %xmm0
movss 0x7b98(%rip), %xmm1     # 0x2fd58
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0xe1f1(%rip), %rax      # 0x363c0
cvtsi2ssl (%rax), %xmm1
movss 0x7b7d(%rip), %xmm2     # 0x2fd58
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
leaq 0x7e29(%rip), %rdi      # 0x30013
movb $0x2, %al
callq 0xb5d0
movsd 0x30a8(%rsp), %xmm0
subsd 0x30b0(%rsp), %xmm0
cvttsd2si %xmm0, %rsi
leaq 0x7e34(%rip), %rdi      # 0x30043
movb $0x0, %al
callq 0xc000
addq $0x30d8, %rsp           # imm = 0x30D8
retq
nop