// File: FreeSlave[P]vhlt/hlrad/trace.cpp
// Function: CreateOpaqueNodes()
void CreateOpaqueNodes ()
{
	int i, j;
	opaquemodels = (opaquemodel_t *)calloc (g_nummodels, sizeof (opaquemodel_t));
	opaquenodes = (opaquenode_t *)calloc (g_numnodes, sizeof (opaquenode_t));
	opaquefaces = (opaqueface_t *)calloc (g_numfaces, sizeof (opaqueface_t));
	for (i = 0; i < g_numfaces; i++)
	{
		opaqueface_t *of = &opaquefaces[i];
		dface_t *df = &g_dfaces[i];
		of->winding = new Winding (*df);
		if (of->winding->m_NumPoints < 3)
		{
			delete of->winding;
			of->winding = NULL;
		}
		of->plane = g_dplanes[df->planenum];
		if (df->side)
		{
			VectorInverse (of->plane.normal);
			of->plane.dist = -of->plane.dist;
		}
#ifdef HLRAD_OPAQUE_ALPHATEST
		of->texinfo = df->texinfo;
		texinfo_t *info = &g_texinfo[of->texinfo];
		for (j = 0; j < 2; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				of->tex_vecs[j][k] = info->vecs[j][k];
			}
		}
		radtexture_t *tex = &g_textures[info->miptex];
		of->tex_alphatest = tex->name[0] == '{';
		of->tex_width = tex->width;
		of->tex_height = tex->height;
		of->tex_canvas = tex->canvas;
#endif
	}
	for (i = 0; i < g_numnodes; i++)
	{
		opaquenode_t *on = &opaquenodes[i];
		dnode_t *dn = &g_dnodes[i];
		on->type = g_dplanes[dn->planenum].type;
		VectorCopy (g_dplanes[dn->planenum].normal, on->normal);
		on->dist = g_dplanes[dn->planenum].dist;
		on->children[0] = dn->children[0];
		on->children[1] = dn->children[1];
		on->firstface = dn->firstface;
		on->numfaces = dn->numfaces;
		on->numfaces = MergeOpaqueFaces (on->firstface, on->numfaces);
	}
	for (i = 0; i < g_numfaces; i++)
	{
		BuildFaceEdges (&opaquefaces[i]);
	}
	for (i = 0; i < g_nummodels; i++)
	{
		opaquemodel_t *om = &opaquemodels[i];
		dmodel_t *dm = &g_dmodels[i];
		om->headnode = dm->headnode[0];
		for (j = 0; j < 3; j++)
		{
			om->mins[j] = dm->mins[j] - 1;
			om->maxs[j] = dm->maxs[j] + 1;
		}
	}
}

// Assembly:
subq $0x78, %rsp
leaq 0x1a625(%rip), %rax     # 0x7e470
movslq (%rax), %rdi
movl $0x1c, %esi
callq 0x4220
movq %rax, 0x66cbca9(%rip)   # 0x672fb08
leaq 0x10c25a2(%rip), %rax   # 0x1126408
movslq (%rax), %rdi
movl $0x24, %esi
callq 0x4220
movq %rax, 0x66cbc86(%rip)   # 0x672fb00
leaq 0x1b82583(%rip), %rax   # 0x1be6404
movslq (%rax), %rdi
movl $0x60, %esi
callq 0x4220
movq %rax, 0x66cbc63(%rip)   # 0x672faf8
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
leaq 0x1b8255c(%rip), %rcx   # 0x1be6404
cmpl (%rcx), %eax
jge 0x64159
movq 0x66cbc41(%rip), %rax   # 0x672faf8
movslq 0x74(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, 0x68(%rsp)
movslq 0x74(%rsp), %rax
leaq (%rax,%rax,4), %rcx
leaq 0x1b82534(%rip), %rax   # 0x1be6410
leaq (%rax,%rcx,4), %rax
movq %rax, 0x60(%rsp)
movl $0x20, %edi
callq 0x4320
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x10(%rsp)
movq 0x60(%rsp), %rsi
movss 0x9c89(%rip), %xmm0     # 0x6db90
callq 0xf130
jmp 0x63f0e
movq 0x10(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, (%rax)
movq 0x68(%rsp), %rax
movq (%rax), %rax
cmpl $0x3, 0x8(%rax)
jae 0x63f77
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x63f47
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x68(%rsp), %rax
movq $0x0, (%rax)
jmp 0x63f77
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
movl $0x20, %esi
callq 0x4330
jmp 0x643e6
movq 0x60(%rsp), %rax
movzwl (%rax), %eax
leaq 0xb0247a(%rip), %rcx    # 0xb66400
imulq $0x14, %rax, %rax
addq %rax, %rcx
movq 0x68(%rsp), %rax
movq (%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0x10(%rcx), %ecx
movl %ecx, 0x18(%rax)
movq 0x60(%rsp), %rax
cmpw $0x0, 0x2(%rax)
je 0x6403b
movq 0x68(%rsp), %rax
movss 0x8(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0x68(%rsp), %rax
movss %xmm0, 0x8(%rax)
movq 0x68(%rsp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0x68(%rsp), %rax
movss %xmm0, 0xc(%rax)
movq 0x68(%rsp), %rax
movss 0x10(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0x68(%rsp), %rax
movss %xmm0, 0x10(%rax)
movq 0x68(%rsp), %rax
movss 0x14(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movq 0x68(%rsp), %rax
movss %xmm0, 0x14(%rax)
movq 0x60(%rsp), %rax
movswl 0xa(%rax), %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x68(%rsp), %rax
movslq 0x28(%rax), %rcx
leaq 0x11823a4(%rip), %rax   # 0x11e6400
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movl $0x0, 0x70(%rsp)
cmpl $0x2, 0x70(%rsp)
jge 0x640dc
movl $0x0, 0x44(%rsp)
cmpl $0x4, 0x44(%rsp)
jge 0x640cd
movq 0x48(%rsp), %rax
movslq 0x70(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0x68(%rsp), %rax
addq $0x30, %rax
movslq 0x70(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movslq 0x44(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x6407f
jmp 0x640cf
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x64070
leaq 0x52438e5(%rip), %rax   # 0x52a79c8
movq (%rax), %rax
movq 0x48(%rsp), %rcx
movslq 0x20(%rcx), %rcx
imulq $0x330, %rcx, %rcx      # imm = 0x330
addq %rcx, %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
sete %cl
movq 0x68(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x2c(%rax)
movq 0x38(%rsp), %rax
movl 0x10(%rax), %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x50(%rax)
movq 0x38(%rsp), %rax
movl 0x14(%rax), %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x54(%rax)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x58(%rax)
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x63e9d
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
leaq 0x10c229c(%rip), %rcx   # 0x1126408
cmpl (%rcx), %eax
jge 0x642ca
movq 0x66cb985(%rip), %rax   # 0x672fb00
movslq 0x74(%rsp), %rcx
imulq $0x24, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x30(%rsp)
movslq 0x74(%rsp), %rcx
leaq 0x10c2278(%rip), %rax   # 0x1126410
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movslq (%rax), %rcx
leaq 0xb0224d(%rip), %rax    # 0xb66400
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
movq 0x28(%rsp), %rax
movslq (%rax), %rcx
leaq 0xb0222d(%rip), %rax    # 0xb66400
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss (%rax), %xmm0
movq 0x30(%rsp), %rax
movss %xmm0, 0x4(%rax)
movq 0x28(%rsp), %rax
movslq (%rax), %rcx
leaq 0xb02209(%rip), %rax    # 0xb66400
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x4(%rax), %xmm0
movq 0x30(%rsp), %rax
movss %xmm0, 0x8(%rax)
movq 0x28(%rsp), %rax
movslq (%rax), %rcx
leaq 0xb021e4(%rip), %rax    # 0xb66400
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0x8(%rax), %xmm0
movq 0x30(%rsp), %rax
movss %xmm0, 0xc(%rax)
movq 0x28(%rsp), %rax
movslq (%rax), %rcx
leaq 0xb021bf(%rip), %rax    # 0xb66400
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movss 0xc(%rax), %xmm0
movq 0x30(%rsp), %rax
movss %xmm0, 0x10(%rax)
movq 0x28(%rsp), %rax
movswl 0x4(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x14(%rax)
movq 0x28(%rsp), %rax
movswl 0x6(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x18(%rax)
movq 0x28(%rsp), %rax
movzwl 0x14(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq 0x28(%rsp), %rax
movzwl 0x16(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x20(%rax)
movq 0x30(%rsp), %rax
movl 0x1c(%rax), %edi
movq 0x30(%rsp), %rax
movl 0x20(%rax), %esi
callq 0x639d0
movl %eax, %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x20(%rax)
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x64161
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
leaq 0x1b82127(%rip), %rcx   # 0x1be6404
cmpl (%rcx), %eax
jge 0x64306
movq 0x66cb810(%rip), %rdi   # 0x672faf8
movslq 0x74(%rsp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rdi
callq 0x63b80
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x642d2
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
leaq 0x1a157(%rip), %rcx     # 0x7e470
cmpl (%rcx), %eax
jge 0x643e1
movq 0x66cb7e0(%rip), %rax   # 0x672fb08
movslq 0x74(%rsp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movslq 0x74(%rsp), %rcx
leaq 0x1a13b(%rip), %rax     # 0x7e480
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movl 0x24(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, 0x18(%rax)
movl $0x0, 0x70(%rsp)
cmpl $0x3, 0x70(%rsp)
jge 0x643cf
movq 0x18(%rsp), %rax
movslq 0x70(%rsp), %rcx
movss (%rax,%rcx,4), %xmm0
movss 0x5cc5(%rip), %xmm1     # 0x6a04c
subss %xmm1, %xmm0
movq 0x20(%rsp), %rax
movslq 0x70(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq 0x18(%rsp), %rax
movslq 0x70(%rsp), %rcx
movss 0x5ca0(%rip), %xmm0     # 0x6a04c
addss 0xc(%rax,%rcx,4), %xmm0
movq 0x20(%rsp), %rax
movslq 0x70(%rsp), %rcx
movss %xmm0, 0xc(%rax,%rcx,4)
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x64369
jmp 0x643d1
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x6430e
addq $0x78, %rsp
retq
movq 0x58(%rsp), %rdi
callq 0x45c0