// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/hlbsp/writebsp.cpp
// Function: FinishBSPFile()
void            FinishBSPFile()
{
    Verbose("--- FinishBSPFile ---\n");

#ifdef ZHLT_MAX_MAP_LEAFS
	if (g_dmodels[0].visleafs > MAX_MAP_LEAFS_ENGINE)
	{
		Warning ("Number of world leaves(%d) exceeded MAX_MAP_LEAFS(%d)\nIf you encounter problems when running your map, consider this the most likely cause.\n", g_dmodels[0].visleafs, MAX_MAP_LEAFS_ENGINE);
	}
#endif
#ifdef ZHLT_WARNWORLDFACES
	if (g_dmodels[0].numfaces > MAX_MAP_WORLDFACES)
	{
		Warning ("Number of world faces(%d) exceeded %d. Some faces will disappear in game.\nTo reduce world faces, change some world brushes (including func_details) to func_walls.\n", g_dmodels[0].numfaces, MAX_MAP_WORLDFACES);
	}
#endif
#ifdef HLBSP_MERGECLIPNODE
	Developer (DEVELOPER_LEVEL_MESSAGE, "count_mergedclipnodes = %d\n", count_mergedclipnodes);
	if (!g_noclipnodemerge)
	{
#ifdef ZHLT_XASH2
		int total = 0;
		for (int hull = 1; hull < MAX_MAP_HULLS; hull++)
		{
			total += g_numclipnodes[hull - 1];
		}
		Log ("Reduced %d clipnodes to %d\n", total + count_mergedclipnodes, total);
#else
		Log ("Reduced %d clipnodes to %d\n", g_numclipnodes + count_mergedclipnodes, g_numclipnodes);
#endif
	}
#endif
	if(!g_noopt)
	{
#ifdef HLCSG_HLBSP_REDUCETEXTURE
		{
			Log ("Reduced %d texinfos to %d\n", g_numtexinfo, g_nummappedtexinfo);
			for (int i = 0; i < g_nummappedtexinfo; i++)
			{
				g_texinfo[i] = g_mappedtexinfo[i];
			}
			g_numtexinfo = g_nummappedtexinfo;
		}
		{
			dmiptexlump_t *l = (dmiptexlump_t *)g_dtexdata;
			int &g_nummiptex = l->nummiptex;
			bool *Used = (bool *)calloc (g_nummiptex, sizeof(bool));
			int Num = 0, Size = 0;
			int *Map = (int *)malloc (g_nummiptex * sizeof(int));
			int i;
			hlassume (Used != NULL && Map != NULL, assume_NoMemory);
			int *lumpsizes = (int *)malloc (g_nummiptex * sizeof (int));
			const int newdatasizemax = g_texdatasize - ((byte *)&l->dataofs[g_nummiptex] - (byte *)l);
			byte *newdata = (byte *)malloc (newdatasizemax);
			int newdatasize = 0;
			hlassume (lumpsizes != NULL && newdata != NULL, assume_NoMemory);
			int total = 0;
			for (i = 0; i < g_nummiptex; i++)
			{
				if (l->dataofs[i] == -1)
				{
					lumpsizes[i] = -1;
					continue;
				}
				lumpsizes[i] = g_texdatasize - l->dataofs[i];
				for (int j = 0; j < g_nummiptex; j++)
				{
					int lumpsize = l->dataofs[j] - l->dataofs[i];
					if (l->dataofs[j] == -1 || lumpsize < 0 || lumpsize == 0 && j <= i)
						continue;
					if (lumpsize < lumpsizes[i])
						lumpsizes[i] = lumpsize;
				}
				total += lumpsizes[i];
			}
			if (total != newdatasizemax)
			{
				Warning ("Bad texdata structure.\n");
				goto skipReduceTexdata;
			}
			for (i = 0; i < g_numtexinfo; i++)
			{
				texinfo_t *t = &g_texinfo[i];
				if (t->miptex < 0 || t->miptex >= g_nummiptex)
				{
					Warning ("Bad miptex number %d.\n", t->miptex);
					goto skipReduceTexdata;
				}
				Used[t->miptex] = true;
			}
			for (i = 0; i < g_nummiptex; i++)
			{
				const int MAXWADNAME = 16;
				char name[MAXWADNAME];
				int j, k;
				if (l->dataofs[i] < 0)
					continue;
				if (Used[i] == true)
				{
					miptex_t *m = (miptex_t *)((byte *)l + l->dataofs[i]);
					if (m->name[0] != '+' && m->name[0] != '-')
						continue;
					safe_strncpy (name, m->name, MAXWADNAME);
					if (name[1] == '\0')
						continue;
					for (j = 0; j < 20; j++)
					{
						if (j < 10)
							name[1] = '0' + j;
						else
							name[1] = 'A' + j - 10;
						for (k = 0; k < g_nummiptex; k++)
						{
							if (l->dataofs[k] < 0)
								continue;
							miptex_t *m2 = (miptex_t *)((byte *)l + l->dataofs[k]);
							if (!strcasecmp (name, m2->name))
								Used[k] = true;
						}
					}
				}
			}
			for (i = 0; i < g_nummiptex; i++)
			{
				if (Used[i])
				{
					Map[i] = Num;
					Num++;
				}
				else
				{
					Map[i] = -1;
				}
			}
			for (i = 0; i < g_numtexinfo; i++)
			{
				texinfo_t *t = &g_texinfo[i];
				t->miptex = Map[t->miptex];
			}
			Size += (byte *)&l->dataofs[Num] - (byte *)l;
			for (i = 0; i < g_nummiptex; i++)
			{
				if (Used[i])
				{
					if (lumpsizes[i] == -1)
					{
						l->dataofs[Map[i]] = -1;
					}
					else
					{
						memcpy ((byte *)newdata + newdatasize, (byte *)l + l->dataofs[i], lumpsizes[i]);
						l->dataofs[Map[i]] = Size;
						newdatasize += lumpsizes[i];
						Size += lumpsizes[i];
					}
				}
			}
			memcpy (&l->dataofs[Num], newdata, newdatasize);
			Log ("Reduced %d texdatas to %d (%d bytes to %d)\n", g_nummiptex, Num, g_texdatasize, Size);
			g_nummiptex = Num;
			g_texdatasize = Size;
			skipReduceTexdata:;
			free (lumpsizes);
			free (newdata);
			free (Used);
			free (Map);
		}
		Log ("Reduced %d planes to %d\n", g_numplanes, gNumMappedPlanes);
#endif
		for(int counter = 0; counter < gNumMappedPlanes; counter++)
		{
			g_dplanes[counter] = gMappedPlanes[counter];
		}
		g_numplanes = gNumMappedPlanes;
	}
#ifdef HLCSG_HLBSP_REDUCETEXTURE
	else
	{
		hlassume (g_numtexinfo < MAX_MAP_TEXINFO, assume_MAX_MAP_TEXINFO);
		hlassume (g_numplanes < MAX_MAP_PLANES, assume_MAX_MAP_PLANES);
	}
#endif
#ifdef HLBSP_BRINKHACK
	if (!g_nobrink)
	{
		Log ("FixBrinks:\n");
#ifdef ZHLT_XASH2
		dclipnode_t *clipnodes[MAX_MAP_HULLS - 1];
		int numclipnodes[MAX_MAP_HULLS - 1];
		for (int hull = 1; hull < MAX_MAP_HULLS; hull++)
		{
			clipnodes[hull - 1] = (dclipnode_t *)malloc (MAX_MAP_CLIPNODES * sizeof (dclipnode_t));
			hlassume (clipnodes[hull - 1] != NULL, assume_NoMemory);
		}
#else
		dclipnode_t *clipnodes; //[MAX_MAP_CLIPNODES]
		int numclipnodes;
		clipnodes = (dclipnode_t *)malloc (MAX_MAP_CLIPNODES * sizeof (dclipnode_t));
		hlassume (clipnodes != NULL, assume_NoMemory);
#endif
		void *(*brinkinfo)[NUM_HULLS]; //[MAX_MAP_MODELS]
		int (*headnode)[NUM_HULLS]; //[MAX_MAP_MODELS]
		brinkinfo = (void *(*)[NUM_HULLS])malloc (MAX_MAP_MODELS * sizeof (void *[NUM_HULLS]));
		hlassume (brinkinfo != NULL, assume_NoMemory);
		headnode = (int (*)[NUM_HULLS])malloc (MAX_MAP_MODELS * sizeof (int [NUM_HULLS]));
		hlassume (headnode != NULL, assume_NoMemory);

		int i, j, level;
		for (i = 0; i < g_nummodels; i++)
		{
			dmodel_t *m = &g_dmodels[i];
			Developer (DEVELOPER_LEVEL_MESSAGE, " model %d\n", i);
			for (j = 1; j < NUM_HULLS; j++)
			{
#ifdef ZHLT_XASH2
				brinkinfo[i][j] = CreateBrinkinfo (g_dclipnodes[j - 1], m->headnode[j]);
#else
				brinkinfo[i][j] = CreateBrinkinfo (g_dclipnodes, m->headnode[j]);
#endif
			}
		}
		for (level = BrinkAny; level > BrinkNone; level--)
		{
#ifdef ZHLT_XASH2
			for (int hull = 1; hull < MAX_MAP_HULLS; hull++)
			{
				numclipnodes[hull - 1] = 0;
			}
#else
			numclipnodes = 0;
#endif
#ifdef HLBSP_MERGECLIPNODE
			count_mergedclipnodes = 0;
#endif
			for (i = 0; i < g_nummodels; i++)
			{
				for (j = 1; j < NUM_HULLS; j++)
				{
#ifdef ZHLT_XASH2
					if (!FixBrinks (brinkinfo[i][j], (bbrinklevel_e) level, headnode[i][j], clipnodes[j - 1], MAX_MAP_CLIPNODES, numclipnodes[j - 1], numclipnodes[j - 1]))
#else
					if (!FixBrinks (brinkinfo[i][j], (bbrinklevel_e) level, headnode[i][j], clipnodes, MAX_MAP_CLIPNODES, numclipnodes, numclipnodes))
#endif
					{
						break;
					}
				}
				if (j < NUM_HULLS)
				{
					break;
				}
			}
			if (i == g_nummodels)
			{
				break;
			}
		}
		for (i = 0; i < g_nummodels; i++)
		{
			for (j = 1; j < NUM_HULLS; j++)
			{
				DeleteBrinkinfo (brinkinfo[i][j]);
			}
		}
		if (level == BrinkNone)
		{
			Warning ("No brinks have been fixed because clipnode data is almost full.");
		}
		else
		{
			if (level != BrinkAny)
			{
				Warning ("Not all brinks have been fixed because clipnode data is almost full.");
			}
#ifdef HLBSP_MERGECLIPNODE
			Developer (DEVELOPER_LEVEL_MESSAGE, "count_mergedclipnodes = %d\n", count_mergedclipnodes);
#endif
#ifdef ZHLT_XASH2
			int g_numclipnodes_total = 0;
			int numclipnodes_total = 0;
			for (int hull = 1; hull < MAX_MAP_HULLS; hull++)
			{
				g_numclipnodes_total += g_numclipnodes[hull - 1];
				numclipnodes_total += numclipnodes[hull - 1];
			}
			Log ("Increased %d clipnodes to %d.\n", g_numclipnodes_total, numclipnodes_total);
			for (int hull = 1; hull < MAX_MAP_HULLS; hull++)
			{
				g_numclipnodes[hull - 1] = numclipnodes[hull - 1];
				memcpy (g_dclipnodes[hull - 1], clipnodes[hull - 1], numclipnodes[hull - 1] * sizeof (dclipnode_t));
			}
#else
			Log ("Increased %d clipnodes to %d.\n", g_numclipnodes, numclipnodes);
			g_numclipnodes = numclipnodes;
			memcpy (g_dclipnodes, clipnodes, numclipnodes * sizeof (dclipnode_t));
#endif
			for (i = 0; i < g_nummodels; i++)
			{
				dmodel_t *m = &g_dmodels[i];
				for (j = 1; j < NUM_HULLS; j++)
				{
					m->headnode[j] = headnode[i][j];
				}
			}
		}
		free (brinkinfo);
		free (headnode);
#ifdef ZHLT_XASH2
		for (int hull = 1; hull < MAX_MAP_HULLS; hull++)
		{
			free (clipnodes[hull - 1]);
		}
#else
		free (clipnodes);
#endif
	}
#endif
	
#ifdef ZHLT_HIDDENSOUNDTEXTURE
	for (int i = 0; i < g_numtexinfo; i++)
	{
		g_texinfo[i].flags &= ~TEX_SHOULDHIDE;
	}
#endif
#ifdef ZHLT_64BIT_FIX
#ifdef PLATFORM_CAN_CALC_EXTENT
	WriteExtentFile (g_extentfilename);
#else
	Warning ("The " PLATFORM_VERSIONSTRING " version of hlbsp couldn't create extent file. The lack of extent file may cause hlrad error.");
#endif
#endif
	if (g_chart)
    {
        PrintBSPFileSizes();
    }

#ifdef HLCSG_HLBSP_DOUBLEPLANE
#undef dplane_t // this allow us to temporarily access the raw data directly without the layer of indirection
#undef g_dplanes
	for (int i = 0; i < g_numplanes; i++)
	{
		plane_t *mp = &g_mapplanes[i];
		dplane_t *dp = &g_dplanes[i];
		VectorCopy (mp->normal, dp->normal);
		dp->dist = mp->dist;
		dp->type = mp->type;
	}
#define dplane_t plane_t
#define g_dplanes g_mapplanes
#endif
    WriteBSPFile(g_bspfilename);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq 0x705d(%rip), %rdi      # 0x20ccd
xorl %eax, %eax
callq 0x8f76
leaq 0x107c2(%rip), %r12     # 0x2a440
movl 0x34(%r12), %esi
cmpl $0x2001, %esi           # imm = 0x2001
jl 0x19c9e
leaq 0x7052(%rip), %rdi      # 0x20ce4
movl $0x2000, %edx           # imm = 0x2000
xorl %eax, %eax
callq 0x8e95
movl 0x3c(%r12), %esi
cmpl $0x8001, %esi           # imm = 0x8001
jl 0x19cbe
leaq 0x70bf(%rip), %rdi      # 0x20d71
movl $0x8000, %edx           # imm = 0x8000
xorl %eax, %eax
callq 0x8e95
movl 0x4a34ebc(%rip), %edx   # 0x4a4eb80
leaq 0x714a(%rip), %rsi      # 0x20e15
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x9035
leaq 0x20b8d35(%rip), %rax   # 0x20d2a11
cmpb $0x0, (%rax)
jne 0x19d00
leaq 0x1cb86d8(%rip), %rax   # 0x1cd23c0
movl (%rax), %edx
movl 0x4a34e90(%rip), %esi   # 0x4a4eb80
addl %edx, %esi
leaq 0x7138(%rip), %rdi      # 0x20e31
xorl %eax, %eax
callq 0x8780
leaq 0x20b8d09(%rip), %rax   # 0x20d2a10
leaq 0x11786ae(%rip), %r14   # 0x11923bc
movl (%r14), %esi
cmpb $0x0, (%rax)
je 0x19d4a
xorl %edi, %edi
cmpl $0x7fff, %esi           # imm = 0x7FFF
setl %dil
pushq $0x26
popq %rsi
callq 0x92bb
leaq 0xaf8683(%rip), %rax    # 0xb123b4
xorl %edi, %edi
cmpl $0x8000, (%rax)         # imm = 0x8000
setl %dil
pushq $0x23
popq %rsi
callq 0x92bb
jmp 0x1a1fd
movl 0x4a34e38(%rip), %edx   # 0x4a4eb88
leaq 0x70f6(%rip), %rdi      # 0x20e4d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x8780
movl 0x4a34e22(%rip), %eax   # 0x4a4eb88
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
imulq $0x28, %rcx, %rcx
leaq 0x4a34e15(%rip), %rdx   # 0x4a4eb90
leaq 0x117863e(%rip), %rdi   # 0x11923c0
cmpq %rbx, %rcx
je 0x19dad
movq 0x20(%rbx,%rdx), %rsi
movq %rsi, 0x20(%rdi,%rbx)
movupd (%rbx,%rdx), %xmm0
movupd 0x10(%rbx,%rdx), %xmm1
movupd %xmm1, 0x10(%rdi,%rbx)
movupd %xmm0, (%rdi,%rbx)
addq $0x28, %rbx
jmp 0x19d82
movl %eax, (%r14)
leaq 0x8186b1(%rip), %rax    # 0x832468
movq (%rax), %rbp
movslq (%rbp), %r15
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0x41e0
movq %rax, %rbx
shlq $0x2, %r15
movq %r15, %rdi
callq 0x4410
movq %rbx, 0x18(%rsp)
testq %rbx, %rbx
setne %dl
movq %rax, 0x20(%rsp)
testq %rax, %rax
setne %cl
andb %dl, %cl
movzbl %cl, %edi
pushq $0x1
popq %rsi
callq 0x92bb
movslq (%rbp), %rbx
movq %rbx, %rdi
shlq $0x2, %rdi
callq 0x4410
movq %rax, %r14
leaq 0x81864f(%rip), %r12    # 0x832464
leaq 0x4(%rbp), %r15
leal (%r15,%rbx,4), %eax
movl %ebp, %r13d
subl %eax, %r13d
addl (%r12), %r13d
movslq %r13d, %rdi
callq 0x4410
movq %r14, 0x28(%rsp)
testq %r14, %r14
setne %dl
movq %rax, 0x48(%rsp)
testq %rax, %rax
setne %cl
andb %dl, %cl
movzbl %cl, %edi
pushq $0x1
popq %rsi
callq 0x92bb
movl (%rbp), %eax
movl (%r12), %ecx
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %esi
cmovgl %eax, %esi
xorl %edi, %edi
cmpq %rsi, %rdx
je 0x19ed5
movl (%r15,%rdx,4), %r8d
cmpl $-0x1, %r8d
je 0x19ec6
movl %ecx, %r9d
subl %r8d, %r9d
movq 0x28(%rsp), %r10
movl %r9d, (%r10,%rdx,4)
xorl %r10d, %r10d
cmpq %r10, %rax
je 0x19ec1
movl (%r15,%r10,4), %r11d
cmpl $-0x1, %r11d
je 0x19ebc
subl %r8d, %r11d
js 0x19ebc
sete %bl
cmpq %rdx, %r10
setbe %r14b
testb %bl, %r14b
jne 0x19ebc
cmpl %r9d, %r11d
jge 0x19ebc
movq 0x28(%rsp), %r9
movl %r11d, (%r9,%rdx,4)
movl %r11d, %r9d
incq %r10
jmp 0x19e88
addl %r9d, %edi
jmp 0x19ed0
movq 0x28(%rsp), %r8
orl $-0x1, (%r8,%rdx,4)
incq %rdx
jmp 0x19e67
cmpl %r13d, %edi
jne 0x19f26
leaq 0x11784db(%rip), %rcx   # 0x11923bc
movl (%rcx), %edx
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
imulq $0x28, %rdx, %rdx
leaq 0x1054b(%rip), %r12     # 0x2a440
leaq 0x11784c4(%rip), %r8    # 0x11923c0
movq 0x18(%rsp), %rdi
cmpq %rcx, %rdx
je 0x19f39
movslq 0x20(%r8,%rcx), %rsi
testq %rsi, %rsi
js 0x1a146
cmpl %eax, %esi
jge 0x1a146
movb $0x1, (%rdi,%rsi)
addq $0x28, %rcx
jmp 0x19f01
leaq 0x6f3b(%rip), %rdi      # 0x20e68
xorl %eax, %eax
callq 0x8e95
jmp 0x1a13d
leaq 0x30(%rsp), %r13
xorl %edx, %edx
movslq %eax, %rcx
cmpq %rcx, %rdx
jge 0x1a00d
movq %rdx, 0x10(%rsp)
movslq (%r15,%rdx,4), %rsi
testq %rsi, %rsi
js 0x19ffd
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpb $0x1, (%rax,%rcx)
jne 0x19ffd
movzbl (%rbp,%rsi), %eax
cmpl $0x2d, %eax
je 0x19f81
cmpl $0x2b, %eax
jne 0x19ffd
addq %rbp, %rsi
movq %r13, %rdi
pushq $0x10
popq %rdx
callq 0x7711
cmpb $0x0, 0x31(%rsp)
je 0x19ffd
xorl %r12d, %r12d
cmpl $0x14, %r12d
je 0x19ffd
leal 0x37(%r12), %eax
movl %r12d, %ecx
orb $0x30, %cl
cmpl $0xa, %r12d
movzbl %cl, %ecx
movzbl %al, %eax
cmovbl %ecx, %eax
movb %al, 0x31(%rsp)
movl (%rbp), %r14d
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x19ff8
movslq (%r15,%rbx,4), %rsi
testq %rsi, %rsi
js 0x19ff3
addq %rbp, %rsi
movq %r13, %rdi
callq 0x4330
testl %eax, %eax
jne 0x19ff3
movq 0x18(%rsp), %rax
movb $0x1, (%rax,%rbx)
incq %rbx
jmp 0x19fcd
incl %r12d
jmp 0x19f99
movq 0x10(%rsp), %rdx
incq %rdx
movl (%rbp), %eax
jmp 0x19f40
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
pushq $-0x1
popq %rdx
xorl %r14d, %r14d
movq 0x20(%rsp), %r8
leaq 0x1178396(%rip), %r9    # 0x11923bc
leaq 0x1178393(%rip), %r10   # 0x11923c0
cmpq %rcx, %rax
je 0x1a04f
movq 0x18(%rsp), %rsi
movzbl (%rsi,%rcx), %esi
testl %esi, %esi
movl %edx, %edi
cmovnel %r14d, %edi
addl %esi, %r14d
movl %edi, (%r8,%rcx,4)
incq %rcx
jmp 0x1a02d
movl (%r9), %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovlel %eax, %ecx
imulq $0x28, %rcx, %rcx
cmpq %rax, %rcx
je 0x1a076
movslq 0x20(%r10,%rax), %rdx
movl (%r8,%rdx,4), %edx
movl %edx, 0x20(%r10,%rax)
addq $0x28, %rax
jmp 0x1a05d
movl %r14d, %eax
leaq (%r15,%rax,4), %rax
movq %rax, 0x50(%rsp)
subl %ebp, %eax
movl %eax, 0x10(%rsp)
xorl %r13d, %r13d
xorl %eax, %eax
movslq (%rbp), %rcx
movslq %eax, %r12
cmpq %rcx, %r13
jge 0x1a0ff
movq 0x18(%rsp), %rcx
cmpb $0x1, (%rcx,%r13)
jne 0x1a0fa
movq 0x28(%rsp), %rcx
movslq (%rcx,%r13,4), %rbx
cmpq $-0x1, %rbx
je 0x1a0ec
movq 0x48(%rsp), %rax
leaq (%rax,%r12), %rdi
movslq 0x4(%rbp,%r13,4), %rsi
addq %rbp, %rsi
movq %rbx, %rdx
callq 0x4260
movq 0x20(%rsp), %rax
movslq (%rax,%r13,4), %rax
movl 0x10(%rsp), %ecx
movl %ecx, 0x4(%rbp,%rax,4)
addl %ebx, %r12d
addl %ebx, %ecx
movl %ecx, 0x10(%rsp)
movl %r12d, %eax
jmp 0x1a0fa
movq 0x20(%rsp), %rcx
movslq (%rcx,%r13,4), %rcx
orl $-0x1, (%r15,%rcx,4)
incq %r13
jmp 0x1a08d
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %r12, %rdx
callq 0x4260
movl (%rbp), %esi
leaq 0x818349(%rip), %rbx    # 0x832464
movl 0x10(%rsp), %r15d
movl (%rbx), %ecx
leaq 0x6d6e(%rip), %rdi      # 0x20e97
movl %r14d, %edx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x8780
movl %r14d, (%rbp)
movl %r15d, (%rbx)
leaq 0x102fc(%rip), %r12     # 0x2a440
jmp 0x1a154
leaq 0x6d33(%rip), %rdi      # 0x20e80
xorl %eax, %eax
callq 0x8e95
movq 0x28(%rsp), %rdi
callq 0x4390
movq 0x48(%rsp), %rdi
callq 0x4390
movq 0x18(%rsp), %rdi
callq 0x4390
movq 0x20(%rsp), %rdi
callq 0x4390
leaq 0xaf8231(%rip), %rbx    # 0xb123b4
movl (%rbx), %esi
movl 0x4a349f9(%rip), %edx   # 0x4a4eb84
leaq 0x6d31(%rip), %rdi      # 0x20ec3
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x8780
movl 0x4a349e2(%rip), %eax   # 0x4a4eb84
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
shlq $0x6, %rcx
leaq 0x4b749b9(%rip), %rdx   # 0x4b8eb70
leaq 0x20b8862(%rip), %rsi   # 0x20d2a20
cmpq %r14, %rcx
je 0x1a1fb
movapd (%r14,%rdx), %xmm0
movapd 0x10(%r14,%rdx), %xmm1
movaps 0x20(%r14,%rdx), %xmm2
movaps 0x30(%r14,%rdx), %xmm3
movaps %xmm3, 0x30(%rsi,%r14)
movaps %xmm2, 0x20(%rsi,%r14)
movapd %xmm1, 0x10(%rsi,%r14)
movapd %xmm0, (%rsi,%r14)
addq $0x40, %r14
jmp 0x1a1be
movl %eax, (%rbx)
leaq 0x20b8811(%rip), %rax   # 0x20d2a15
cmpb $0x0, (%rax)
jne 0x1a401
leaq 0x6cc8(%rip), %rdi      # 0x20edc
xorl %eax, %eax
callq 0x8780
movl $0x3fff8, %edi          # imm = 0x3FFF8
callq 0x4410
movq %rax, %rbx
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0x92bb
movl $0x4000, %edi           # imm = 0x4000
callq 0x4410
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
movl %ebp, %esi
callq 0x92bb
movl $0x2000, %edi           # imm = 0x2000
callq 0x4410
xorl %edi, %edi
movq %rax, 0x20(%rsp)
testq %rax, %rax
setne %dil
movl %ebp, %esi
callq 0x92bb
addq $0x28, %r12
movq %r14, 0x10(%rsp)
movq %r14, %rbp
addq $0x8, %rbp
leaq 0x1cb8142(%rip), %r13   # 0x1cd23d0
xorl %r15d, %r15d
leaq 0x10198(%rip), %rax     # 0x2a430
movslq (%rax), %rax
cmpq %rax, %r15
jge 0x1a2e0
pushq $0x3
popq %rdi
leaq 0x6c3e(%rip), %rsi      # 0x20ee8
movl %r15d, %edx
xorl %eax, %eax
callq 0x9035
xorl %r14d, %r14d
cmpq $0x3, %r14
je 0x1a2d3
movl (%r12,%r14,4), %esi
movq %r13, %rdi
callq 0xf4d8
movq %rax, (%rbp,%r14,8)
incq %r14
jmp 0x1a2b7
incq %r15
addq $0x20, %rbp
addq $0x40, %r12
jmp 0x1a291
pushq $0x5
popq %rcx
leaq 0x30(%rsp), %r13
movl %ecx, %ebp
subl $0x1, %ecx
jb 0x1a386
movl %ecx, 0x28(%rsp)
andl $0x0, 0x30(%rsp)
andl $0x0, 0x4a3487d(%rip)   # 0x4a4eb80
movq 0x10(%rsp), %r14
movq 0x20(%rsp), %r15
xorl %edx, %edx
movslq %eax, %rcx
cmpq %rcx, %rdx
jge 0x1a37a
movq %rdx, 0x18(%rsp)
pushq $0x4
popq %r12
cmpq $0x10, %r12
je 0x1a351
movq (%r14,%r12,2), %rdi
leaq (%r15,%r12), %rdx
movl 0x30(%rsp), %r9d
movq %r13, (%rsp)
movl %ebp, %esi
movq %rbx, %rcx
movl $0x7fff, %r8d           # imm = 0x7FFF
callq 0xf8b0
addq $0x4, %r12
testb %al, %al
jne 0x1a320
jmp 0x1a36c
movq 0x18(%rsp), %rdx
incq %rdx
leaq 0x100d0(%rip), %rax     # 0x2a430
movl (%rax), %eax
addq $0x10, %r15
addq $0x20, %r14
jmp 0x1a30f
leaq 0x100bd(%rip), %rax     # 0x2a430
movl (%rax), %eax
movq 0x18(%rsp), %rdx
cmpl %edx, %eax
movl 0x28(%rsp), %ecx
jne 0x1a2e8
xorl %r14d, %r14d
movq 0x10(%rsp), %r15
leaq 0x100ab(%rip), %r13     # 0x2a440
cltq
cmpq %rax, %r14
jge 0x1a3c6
pushq $0x1
popq %r12
cmpq $0x4, %r12
je 0x1a3b4
movq (%r15,%r12,8), %rdi
callq 0xf952
incq %r12
jmp 0x1a3a0
incq %r14
leaq 0x10072(%rip), %rax     # 0x2a430
movl (%rax), %eax
addq $0x20, %r15
jmp 0x1a395
cmpl $0x5, %ebp
je 0x1a4a0
testl %ebp, %ebp
jne 0x1a492
leaq 0x6b15(%rip), %rdi      # 0x20ef3
xorl %eax, %eax
callq 0x8e95
movq 0x10(%rsp), %rdi
callq 0x4390
movq 0x20(%rsp), %rdi
callq 0x4390
movq %rbx, %rdi
callq 0x4390
leaq 0x20b7608(%rip), %rdi   # 0x20d1a10
callq 0x582c
leaq 0x20b8603(%rip), %rax   # 0x20d2a17
cmpb $0x1, (%rax)
jne 0x1a41e
callq 0x5e69
leaq 0xaf7f8f(%rip), %rax    # 0xb123b4
movl (%rax), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
shlq $0x6, %rax
leaq 0xaf7f87(%rip), %rdx    # 0xb123c0
addq $0x10, %rdx
leaq 0x20b85dc(%rip), %rsi   # 0x20d2a20
cmpq %rcx, %rax
je 0x1a477
movsd 0x10(%rsi,%rcx), %xmm0
movhpd 0x30(%rsi,%rcx), %xmm0  # xmm0 = xmm0[0],mem[0]
cvtpd2ps (%rsi,%rcx), %xmm1
cvtpd2ps %xmm0, %xmm0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movupd %xmm1, -0x10(%rdx)
movl 0x38(%rsi,%rcx), %edi
movl %edi, (%rdx)
addq $0x40, %rcx
addq $0x14, %rdx
jmp 0x1a444
leaq 0x20b3592(%rip), %rdi   # 0x20cda10
callq 0x52f1
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6a9a(%rip), %rdi      # 0x20f33
xorl %eax, %eax
callq 0x8e95
movl 0x4a346da(%rip), %edx   # 0x4a4eb80
leaq 0x6968(%rip), %rsi      # 0x20e15
xorl %r15d, %r15d
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x9035
leaq 0x1cb7eff(%rip), %r14   # 0x1cd23c0
movl (%r14), %esi
movl 0x30(%rsp), %edx
leaq 0x6aa9(%rip), %rdi      # 0x20f78
xorl %eax, %eax
callq 0x8780
movslq 0x30(%rsp), %rdx
movl %edx, (%r14)
shlq $0x3, %rdx
leaq 0x1cb7ee7(%rip), %rdi   # 0x1cd23d0
movq %rbx, %rsi
callq 0x4260
leaq 0xff38(%rip), %rax      # 0x2a430
movl (%rax), %eax
testl %eax, %eax
cmovlel %r15d, %eax
addq $0x28, %r13
movq 0x20(%rsp), %rcx
addq $0x4, %rcx
cmpq %rax, %r15
je 0x1a3e5
xorl %edx, %edx
cmpq $0x3, %rdx
je 0x1a52b
movl (%rcx,%rdx,4), %esi
movl %esi, (%r13,%rdx,4)
incq %rdx
jmp 0x1a518
incq %r15
addq $0x10, %rcx
addq $0x40, %r13
jmp 0x1a50d