// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
leaq 0x6adc(%rip), %rdi      # 0x22d6d
xorl %eax, %eax
callq 0xa2ef
leaq 0xf191(%rip), %rbx      # 0x2b430
movl 0x34(%rbx), %esi
cmpl $0x2001, %esi           # imm = 0x2001
jl 0x1c2bd
leaq 0x6ad3(%rip), %rdi      # 0x22d84
movl $0x2000, %edx           # imm = 0x2000
xorl %eax, %eax
callq 0xa20e
movl 0x3c(%rbx), %esi
cmpl $0x8001, %esi           # imm = 0x8001
jl 0x1c2db
leaq 0x6b42(%rip), %rdi      # 0x22e11
movl $0x8000, %edx           # imm = 0x8000
xorl %eax, %eax
callq 0xa20e
movl 0x4a3388f(%rip), %edx   # 0x4a4fb70
leaq 0x6bcd(%rip), %rsi      # 0x22eb5
movl $0x3, %edi
xorl %eax, %eax
callq 0xa3ae
leaq 0x20b7706(%rip), %rax   # 0x20d3a01
cmpb $0x0, (%rax)
jne 0x1c31f
leaq 0x1cb70a9(%rip), %rax   # 0x1cd33b0
movl (%rax), %edx
movl 0x4a33861(%rip), %esi   # 0x4a4fb70
addl %edx, %esi
leaq 0x6bb9(%rip), %rdi      # 0x22ed1
xorl %eax, %eax
callq 0x9bae
leaq 0x20b76da(%rip), %rax   # 0x20d3a00
leaq 0x117707f(%rip), %r14   # 0x11933ac
movl (%r14), %esi
cmpb $0x0, (%rax)
je 0x1c36d
xorl %edi, %edi
cmpl $0x7fff, %esi           # imm = 0x7FFF
setl %dil
movl $0x26, %esi
callq 0xa655
leaq 0xaf7052(%rip), %rax    # 0xb133a4
xorl %edi, %edi
cmpl $0x8000, (%rax)         # imm = 0x8000
setl %dil
movl $0x23, %esi
callq 0xa655
jmp 0x1c7fe
movl 0x4a33805(%rip), %edx   # 0x4a4fb78
leaq 0x6b73(%rip), %rdi      # 0x22eed
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x9bae
movslq 0x4a337ee(%rip), %rbx   # 0x4a4fb78
testq %rbx, %rbx
jle 0x1c3ad
movq %rbx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdx
leaq 0x117700f(%rip), %rdi   # 0x11933b0
leaq 0x4a337d8(%rip), %rsi   # 0x4a4fb80
callq 0x4260
movl %ebx, (%r14)
leaq 0x8170a1(%rip), %rax    # 0x833458
movq (%rax), %r14
movslq (%r14), %r15
movl $0x1, %esi
movq %r15, %rdi
callq 0x41e0
movq %rax, %rbx
shlq $0x2, %r15
movq %r15, %rdi
callq 0x4400
movq %rax, %r15
movq %rbx, 0x8(%rsp)
testq %rbx, %rbx
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
movzbl %cl, %edi
movl $0x1, %esi
callq 0xa655
movslq (%r14), %rbx
movq %rbx, %rdi
shlq $0x2, %rdi
callq 0x4400
leaq 0x817042(%rip), %rdx    # 0x833454
leaq 0x4(%r14), %r13
leal (%r13,%rbx,4), %ecx
movq %rax, %rbx
movl %r14d, %r12d
subl %ecx, %r12d
addl (%rdx), %r12d
movslq %r12d, %rdi
callq 0x4400
testq %rbx, %rbx
setne %dl
movq %rax, 0x20(%rsp)
testq %rax, %rax
setne %cl
andb %dl, %cl
movzbl %cl, %edi
movl $0x1, %esi
callq 0xa655
movslq (%r14), %rax
testq %rax, %rax
jle 0x1c4c8
leaq 0x816ff6(%rip), %rcx    # 0x833454
movl (%rcx), %ecx
xorl %edx, %edx
xorl %ebp, %ebp
movl (%r13,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x1c4b9
movl %ecx, %edi
subl %esi, %edi
movl %edi, (%rbx,%rdx,4)
xorl %r8d, %r8d
movl (%r13,%r8,4), %r9d
cmpl $-0x1, %r9d
je 0x1c4ad
subl %esi, %r9d
js 0x1c4ad
setne %r10b
cmpq %rdx, %r8
seta %r11b
orb %r10b, %r11b
cmpl %edi, %r9d
setl %r10b
andb %r11b, %r10b
cmpb $0x1, %r10b
jne 0x1c4ad
movl %r9d, (%rbx,%rdx,4)
movl %r9d, %edi
incq %r8
cmpq %r8, %rax
jne 0x1c478
addl %edi, %ebp
jmp 0x1c4c0
movl $0xffffffff, (%rbx,%rdx,4) # imm = 0xFFFFFFFF
incq %rdx
cmpq %rax, %rdx
jne 0x1c464
movq %rbx, 0x28(%rsp)
cmpl %r12d, %ebp
jne 0x1c51c
leaq 0x1176ed3(%rip), %rcx   # 0x11933ac
movslq (%rcx), %rcx
testq %rcx, %rcx
movq 0x8(%rsp), %rbx
jle 0x1c534
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rcx
xorl %edx, %edx
leaq 0x1176eb9(%rip), %rdi   # 0x11933b0
movslq 0x20(%rdi,%rdx), %rsi
testq %rsi, %rsi
js 0x1c63b
cmpl %eax, %esi
jge 0x1c63b
movb $0x1, (%rbx,%rsi)
addq $0x28, %rdx
cmpq %rdx, %rcx
jne 0x1c4f7
jmp 0x1c53c
leaq 0x69e5(%rip), %rdi      # 0x22f08
xorl %eax, %eax
callq 0xa20e
movq 0x8(%rsp), %rbx
jmp 0x1c649
testl %eax, %eax
jle 0x1c749
movq %r15, 0x18(%rsp)
xorl %ecx, %ecx
leaq 0x30(%rsp), %r12
movq %rcx, 0x10(%rsp)
movslq (%r13,%rcx,4), %rsi
testq %rsi, %rsi
js 0x1c5f0
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpb $0x1, (%rax,%rcx)
jne 0x1c5f0
movzbl (%r14,%rsi), %eax
cmpl $0x2d, %eax
je 0x1c57e
cmpl $0x2b, %eax
jne 0x1c5f0
addq %r14, %rsi
movl $0x10, %edx
movq %r12, %rdi
callq 0x8821
cmpb $0x0, 0x31(%rsp)
je 0x1c5f0
xorl %r15d, %r15d
leal 0x37(%r15), %eax
movl %r15d, %ecx
orb $0x30, %cl
cmpl $0xa, %r15d
movzbl %cl, %ecx
movzbl %al, %eax
cmovbl %ecx, %eax
movb %al, 0x31(%rsp)
movslq (%r14), %rbx
testq %rbx, %rbx
jle 0x1c5e7
xorl %ebp, %ebp
movslq (%r13,%rbp,4), %rsi
testq %rsi, %rsi
js 0x1c5df
addq %r14, %rsi
movq %r12, %rdi
callq 0x4320
testl %eax, %eax
jne 0x1c5df
movq 0x8(%rsp), %rax
movb $0x1, (%rax,%rbp)
incq %rbp
cmpq %rbp, %rbx
jne 0x1c5bd
incl %r15d
cmpl $0x14, %r15d
jne 0x1c598
movq 0x10(%rsp), %rcx
incq %rcx
movslq (%r14), %rax
cmpq %rax, %rcx
jl 0x1c548
testl %eax, %eax
leaq 0x1176d9f(%rip), %rdi   # 0x11933ac
jle 0x1c653
xorl %ecx, %ecx
xorl %ebp, %ebp
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r15
movzbl (%rbx,%rcx), %edx
testl %edx, %edx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmovnel %ebp, %esi
addl %edx, %ebp
movl %esi, (%r15,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1c61d
jmp 0x1c65f
leaq 0x68de(%rip), %rdi      # 0x22f20
xorl %eax, %eax
callq 0xa20e
movq 0x20(%rsp), %r12
jmp 0x1c796
xorl %ebp, %ebp
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r15
movslq (%rdi), %rcx
testq %rcx, %rcx
jle 0x1c691
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rax
xorl %ecx, %ecx
leaq 0x1176d38(%rip), %rdx   # 0x11933b0
movslq 0x20(%rdx,%rcx), %rsi
movl (%r15,%rsi,4), %esi
movl %esi, 0x20(%rdx,%rcx)
addq $0x28, %rcx
cmpq %rcx, %rax
jne 0x1c678
movl (%r14), %eax
movslq %ebp, %rcx
leaq (,%rcx,4), %rsi
addq %r13, %rsi
movl %esi, %ecx
subl %r14d, %ecx
movl %ecx, 0x10(%rsp)
xorl %edx, %edx
testl %eax, %eax
jle 0x1c744
xorl %r15d, %r15d
movq %rsi, 0x40(%rsp)
cmpb $0x1, (%rbx,%r15)
jne 0x1c72c
movq 0x28(%rsp), %rax
movslq (%rax,%r15,4), %r12
cmpq $-0x1, %r12
je 0x1c71a
movslq %edx, %rdx
movq 0x20(%rsp), %rax
leaq (%rax,%rdx), %rdi
movslq 0x4(%r14,%r15,4), %rsi
addq %r14, %rsi
movq %rdx, %rbx
movq %r12, %rdx
callq 0x4260
movq 0x40(%rsp), %rsi
movq %rbx, %rdx
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %rax
movslq (%rax,%r15,4), %rax
movl 0x10(%rsp), %ecx
movl %ecx, 0x4(%r14,%rax,4)
addl %r12d, %edx
addl %r12d, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x1c72c
movq 0x18(%rsp), %rax
movslq (%rax,%r15,4), %rax
movl $0xffffffff, (%r13,%rax,4) # imm = 0xFFFFFFFF
incq %r15
movslq (%r14), %rax
cmpq %rax, %r15
jl 0x1c6ba
movslq %edx, %rdx
movq %rsi, %r13
movq 0x18(%rsp), %r15
jmp 0x1c755
movq %rsi, %r13
jmp 0x1c755
movl $0x4, 0x10(%rsp)
xorl %ebp, %ebp
xorl %edx, %edx
movq %r13, %rdi
movq 0x20(%rsp), %r12
movq %r12, %rsi
callq 0x4260
movl (%r14), %esi
leaq 0x816ce5(%rip), %rax    # 0x833454
movl (%rax), %ecx
leaq 0x67bf(%rip), %rdi      # 0x22f37
movl %ebp, %edx
movl 0x10(%rsp), %r13d
movl %r13d, %r8d
xorl %eax, %eax
callq 0x9bae
movl %ebp, (%r14)
leaq 0x816cc1(%rip), %rax    # 0x833454
movl %r13d, (%rax)
movq 0x28(%rsp), %rdi
callq 0x4380
movq %r12, %rdi
callq 0x4380
movq %rbx, %rdi
callq 0x4380
movq %r15, %rdi
callq 0x4380
leaq 0xaf6be5(%rip), %rbx    # 0xb133a4
movl (%rbx), %esi
movl 0x4a333ad(%rip), %edx   # 0x4a4fb74
leaq 0x6795(%rip), %rdi      # 0x22f63
xorl %eax, %eax
callq 0x9bae
movslq 0x4a33398(%rip), %r14   # 0x4a4fb74
testq %r14, %r14
jle 0x1c7fb
movq %r14, %rdx
shlq $0x6, %rdx
leaq 0x20b7221(%rip), %rdi   # 0x20d3a10
leaq 0x4b7336a(%rip), %rsi   # 0x4b8fb60
callq 0x4260
movl %r14d, (%rbx)
leaq 0x20b7200(%rip), %rax   # 0x20d3a05
cmpb $0x0, (%rax)
jne 0x1cacf
leaq 0x6767(%rip), %rdi      # 0x22f7c
xorl %eax, %eax
callq 0x9bae
movl $0x3fff8, %edi          # imm = 0x3FFF8
callq 0x4400
xorl %edi, %edi
movq %rax, 0x8(%rsp)
testq %rax, %rax
setne %dil
movl $0x1, %esi
callq 0xa655
movl $0x4000, %edi           # imm = 0x4000
callq 0x4400
movq %rax, %rbx
xorl %edi, %edi
testq %rax, %rax
setne %dil
movl $0x1, %esi
callq 0xa655
movl $0x2000, %edi           # imm = 0x2000
callq 0x4400
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
setne %dil
movl $0x1, %esi
callq 0xa655
leaq 0xeb9b(%rip), %rax      # 0x2b420
movl (%rax), %eax
testl %eax, %eax
movq %rbx, 0x20(%rsp)
movq %r14, 0x18(%rsp)
jle 0x1c904
leaq 0xeb94(%rip), %rax      # 0x2b430
leaq 0x28(%rax), %r14
leaq 0x8(%rbx), %r15
leaq 0x66dd(%rip), %r12      # 0x22f88
leaq 0x1cb6b0e(%rip), %r13   # 0x1cd33c0
xorl %ebp, %ebp
movl $0x3, %edi
movq %r12, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0xa3ae
xorl %ebx, %ebx
movl (%r14,%rbx,4), %esi
movq %r13, %rdi
callq 0x1129d
movq %rax, (%r15,%rbx,8)
incq %rbx
cmpq $0x3, %rbx
jne 0x1c8c7
incq %rbp
leaq 0xeb36(%rip), %rax      # 0x2b420
movslq (%rax), %rax
addq $0x20, %r15
addq $0x40, %r14
cmpq %rax, %rbp
jl 0x1c8b4
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r14
leaq 0x4(%r14), %rcx
movq %rcx, 0x10(%rsp)
addq $0x8, %rbx
movq %rbx, 0x28(%rsp)
movl $0x5, %r12d
leaq 0x30(%rsp), %r13
xorl %ecx, %ecx
movl %ecx, 0x30(%rsp)
movl %ecx, 0x4a33243(%rip)   # 0x4a4fb70
movl $0x0, %r15d
testl %eax, %eax
jle 0x1c99e
movq 0x28(%rsp), %rbp
movq 0x10(%rsp), %r14
xorl %r15d, %r15d
xorl %ebx, %ebx
movq (%rbp,%rbx,2), %rdi
leaq (%r14,%rbx), %rdx
movl 0x30(%rsp), %r9d
movq %r13, (%rsp)
movl %r12d, %esi
movq 0x8(%rsp), %rcx
movl $0x7fff, %r8d           # imm = 0x7FFF
callq 0x11696
testb %al, %al
je 0x1c995
addq $0x4, %rbx
cmpq $0xc, %rbx
jne 0x1c946
incq %r15
leaq 0xea9d(%rip), %rax      # 0x2b420
movslq (%rax), %rax
addq $0x10, %r14
addq $0x20, %rbp
cmpq %rax, %r15
jl 0x1c944
jmp 0x1c99e
leaq 0xea84(%rip), %rax      # 0x2b420
movl (%rax), %eax
cmpl %eax, %r15d
je 0x1c9b8
leal -0x1(%r12), %ecx
cmpl $0x1, %r12d
movl %ecx, %r12d
ja 0x1c921
xorl %r12d, %r12d
testl %eax, %eax
leaq 0xea6f(%rip), %r13      # 0x2b430
jle 0x1c9f8
xorl %r14d, %r14d
movq 0x20(%rsp), %r15
movl $0x1, %ebx
movq (%r15,%rbx,8), %rdi
callq 0x1173b
incq %rbx
cmpq $0x4, %rbx
jne 0x1c9d0
incq %r14
leaq 0xea34(%rip), %rax      # 0x2b420
movslq (%rax), %rax
addq $0x20, %r15
cmpq %rax, %r14
jl 0x1c9cb
cmpl $0x5, %r12d
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
je 0x1ca2e
testl %r12d, %r12d
jne 0x1ca20
leaq 0x657f(%rip), %rdi      # 0x22f93
xorl %eax, %eax
callq 0xa20e
jmp 0x1cab5
leaq 0x65ac(%rip), %rdi      # 0x22fd3
xorl %eax, %eax
callq 0xa20e
movl 0x4a3313c(%rip), %edx   # 0x4a4fb70
leaq 0x647a(%rip), %rsi      # 0x22eb5
movl $0x3, %edi
xorl %eax, %eax
callq 0xa3ae
leaq 0x1cb6962(%rip), %rbx   # 0x1cd33b0
movl (%rbx), %esi
movl 0x30(%rsp), %edx
leaq 0x65bd(%rip), %rdi      # 0x23018
xorl %eax, %eax
callq 0x9bae
movslq 0x30(%rsp), %rdx
movl %edx, (%rbx)
shlq $0x3, %rdx
leaq 0x1cb694c(%rip), %rdi   # 0x1cd33c0
movq 0x8(%rsp), %rsi
callq 0x4260
leaq 0xe99b(%rip), %rax      # 0x2b420
movslq (%rax), %rax
testq %rax, %rax
jle 0x1cab5
movq %r15, %rcx
addq $0x4, %rcx
shlq $0x4, %rax
xorl %edx, %edx
movl 0x8(%rcx,%rdx), %esi
movl %esi, 0x30(%r13,%rdx,4)
movq (%rcx,%rdx), %rsi
movq %rsi, 0x28(%r13,%rdx,4)
addq $0x10, %rdx
cmpq %rdx, %rax
jne 0x1ca9a
movq %r14, %rdi
callq 0x4380
movq %r15, %rdi
callq 0x4380
movq 0x8(%rsp), %rdi
callq 0x4380
leaq 0x20b5f2a(%rip), %rdi   # 0x20d2a00
callq 0x5dab
leaq 0x20b6f25(%rip), %rax   # 0x20d3a07
cmpb $0x1, (%rax)
jne 0x1caec
callq 0x6511
leaq 0xaf68b1(%rip), %rax    # 0xb133a4
movslq (%rax), %rax
testq %rax, %rax
jle 0x1cb44
leaq 0xaf68ae(%rip), %rcx    # 0xb133b0
addq $0x10, %rcx
shlq $0x6, %rax
xorl %edx, %edx
leaq 0x20b6efd(%rip), %rsi   # 0x20d3a10
movsd 0x10(%rsi,%rdx), %xmm0
cvtpd2ps (%rsi,%rdx), %xmm1
movhpd 0x30(%rsi,%rdx), %xmm0  # xmm0 = xmm0[0],mem[0]
cvtpd2ps %xmm0, %xmm0
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movupd %xmm1, -0x10(%rcx)
movl 0x38(%rsi,%rdx), %edi
movl %edi, (%rcx)
addq $0x14, %rcx
addq $0x40, %rdx
cmpq %rdx, %rax
jne 0x1cb13
leaq 0x20b1eb5(%rip), %rdi   # 0x20cea00
callq 0x57c8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq