LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/outside.cpp
// Function: FreeDetailNode_r(node_s*)
static void FreeDetailNode_r (node_t *n)
{
	int i;
	if (n->planenum == -1)
	{
		if (!(n->isportalleaf && n->contents == CONTENTS_SOLID))
		{
			free (n->markfaces);
			n->markfaces = NULL;
		}
		return;
	}
	for (i = 0; i < 2; i++)
	{
		FreeDetailNode_r (n->children[i]);
		free (n->children[i]);
		n->children[i] = NULL;
	}
	face_t *f, *next;
	for (f = n->faces; f; f = next)
	{
		next = f->next;
		FreeFace (f);
	}
	n->faces = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $-0x1, 0x80(%rdi)
je 0x13cf7
xorl %r14d, %r14d
movq 0x88(%rbx,%r14,8), %rdi
callq 0x13c90
movq 0x88(%rbx,%r14,8), %rdi
callq 0x4380
movq $0x0, 0x88(%rbx,%r14,8)
incq %r14
cmpq $0x1, %r14
je 0x13ca3
movq 0x98(%rbx), %rdi
addq $0x98, %rbx
testq %rdi, %rdi
je 0x13d19
movq (%rdi), %r14
callq 0x150c0
movq %r14, %rdi
testq %r14, %r14
jne 0x13ce5
jmp 0x13d19
cmpb $0x1, 0x49(%rbx)
jne 0x13d06
cmpl $-0x2, 0xa0(%rbx)
je 0x13d20
movq 0xa8(%rbx), %rdi
addq $0xa8, %rbx
callq 0x4380
movq $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/portals.cpp
// Function: AddPortalToNodes(portal_s*, node_s*, node_s*)
void            AddPortalToNodes(portal_t* p, node_t* front, node_t* back)
{
    if (p->nodes[0] || p->nodes[1])
    {
        Error("AddPortalToNode: allready included");
    }

    p->nodes[0] = front;
    p->next[0] = front->portals;
    front->portals = p;

    p->nodes[1] = back;
    p->next[1] = back->portals;
    back->portals = p;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpq $0x0, 0x48(%rdi)
jne 0x13d44
cmpq $0x0, 0x50(%r14)
je 0x13d52
leaq 0xe5c5(%rip), %rdi      # 0x22310
xorl %eax, %eax
callq 0x9f84
movq %r15, 0x48(%r14)
movq 0xb0(%r15), %rax
movq %rax, 0x58(%r14)
movq %r14, 0xb0(%r15)
movq %rbx, 0x50(%r14)
movq 0xb0(%rbx), %rax
movq %rax, 0x60(%r14)
movq %r14, 0xb0(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/portals.cpp
// Function: RemovePortalFromNode(portal_s*, node_s*)
void            RemovePortalFromNode(portal_t* portal, node_t* l)
{
    portal_t**      pp;
    portal_t*       t;

    // remove reference to the current portal
    pp = &l->portals;
    while (1)
    {
        t = *pp;
        if (!t)
        {
            Error("RemovePortalFromNode: portal not in leaf");
        }

        if (t == portal)
        {
            break;
        }

        if (t->nodes[0] == l)
        {
            pp = &t->next[0];
        }
        else if (t->nodes[1] == l)
        {
            pp = &t->next[1];
        }
        else
        {
            Error("RemovePortalFromNode: portal not bounding leaf");
        }
    }

    if (portal->nodes[0] == l)
    {
        *pp = portal->next[0];
        portal->nodes[0] = NULL;
    }
    else if (portal->nodes[1] == l)
    {
        *pp = portal->next[1];
        portal->nodes[1] = NULL;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xb0(%rsi), %r13
leaq 0xe590(%rip), %r15      # 0x22333
leaq 0xe5b2(%rip), %r12      # 0x2235c
movq (%r13), %rbp
testq %rbp, %rbp
jne 0x13dbd
movq %r15, %rdi
xorl %eax, %eax
callq 0x9f84
cmpq %rbx, %rbp
je 0x13dec
cmpq %r14, 0x48(%rbp)
je 0x13dda
cmpq %r14, 0x50(%rbp)
je 0x13de3
movq %r12, %rdi
xorl %eax, %eax
callq 0x9f84
jmp 0x13daa
addq $0x58, %rbp
movq %rbp, %r13
jmp 0x13daa
addq $0x60, %rbp
movq %rbp, %r13
jmp 0x13daa
cmpq %r14, 0x48(%rbx)
je 0x13e03
cmpq %r14, 0x50(%rbx)
jne 0x13e1b
leaq 0x50(%rbx), %rax
movl $0x60, %ecx
jmp 0x13e0c
leaq 0x48(%rbx), %rax
movl $0x58, %ecx
movq (%rbx,%rcx), %rcx
movq %rcx, (%r13)
movq $0x0, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/portals.cpp
// Function: WritePortalfile(node_s*)
void            WritePortalfile(node_t* headnode)
{
    // set the visleafnum field in every leaf and count the total number of portals
    num_visleafs = 0;
    num_visportals = 0;
    NumberLeafs_r(headnode);

    // write the file
    pf = fopen(g_portfilename, "w");
    if (!pf)
    {
        Error("Error writing portal file %s", g_portfilename);
    }
#ifdef HLBSP_VIEWPORTAL
	if (g_viewportal)
	{
		char filename[_MAX_PATH];
		safe_snprintf(filename, _MAX_PATH, "%s_portal.pts", g_Mapname);
		pf_view = fopen (filename, "w");
		if (!pf_view)
		{
			Error ("Couldn't open %s", filename);
		}
		Log ("Writing '%s' ...\n", filename);
	}
#endif

    fprintf(pf, "%i\n", num_visleafs);
    fprintf(pf, "%i\n", num_visportals);

#ifdef ZHLT_DETAILBRUSH
	WriteLeafCount_r (headnode);
#endif
    WritePortalFile_r(headnode);
    fclose(pf);
#ifdef HLBSP_VIEWPORTAL
	if (g_viewportal)
	{
		fclose (pf_view);
	}
#endif
    Log("BSP generation successful, writing portal file '%s'\n", g_portfilename);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movq %rdi, %rbx
xorl %eax, %eax
movl %eax, 0x20bb992(%rip)   # 0x20cf9e8
movl %eax, 0x20bb990(%rip)   # 0x20cf9ec
callq 0x14184
leaq 0x20be9a8(%rip), %rdi   # 0x20d2a10
leaq 0xf11b(%rip), %rsi      # 0x2318a
callq 0x4370
movq %rax, 0x20bb975(%rip)   # 0x20cf9f0
testq %rax, %rax
jne 0x14095
leaq 0xe304(%rip), %rdi      # 0x2238b
leaq 0x20be982(%rip), %rsi   # 0x20d2a10
xorl %eax, %eax
callq 0x9f84
leaq 0x20c097f(%rip), %r15   # 0x20d4a1b
cmpb $0x1, (%r15)
jne 0x140ff
leaq 0xe2ff(%rip), %rdx      # 0x223a8
leaq 0x17270(%rip), %rcx     # 0x2b320
movq %rsp, %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
xorl %eax, %eax
callq 0x8863
leaq 0xf0c1(%rip), %rsi      # 0x2318a
movq %r14, %rdi
callq 0x4370
movq %rax, 0x20bb920(%rip)   # 0x20cf9f8
testq %rax, %rax
jne 0x140ee
leaq 0xe2d2(%rip), %rdi      # 0x223b6
movq %rsp, %rsi
xorl %eax, %eax
callq 0x9f84
leaq 0xe2d2(%rip), %rdi      # 0x223c7
movq %rsp, %rsi
xorl %eax, %eax
callq 0x9c96
movq 0x20bb8ea(%rip), %rdi   # 0x20cf9f0
movl 0x20bb8dc(%rip), %edx   # 0x20cf9e8
leaq 0xcfaa(%rip), %r14      # 0x210bd
movq %r14, %rsi
xorl %eax, %eax
callq 0x4440
movq 0x20bb8cc(%rip), %rdi   # 0x20cf9f0
movl 0x20bb8c2(%rip), %edx   # 0x20cf9ec
movq %r14, %rsi
xorl %eax, %eax
callq 0x4440
movq %rbx, %rdi
callq 0x14221
movq %rbx, %rdi
callq 0x1426b
movq 0x20bb8a5(%rip), %rdi   # 0x20cf9f0
callq 0x42e0
cmpb $0x1, (%r15)
jne 0x14162
movq 0x20bb89b(%rip), %rdi   # 0x20cf9f8
callq 0x42e0
leaq 0xe270(%rip), %rdi      # 0x223d9
leaq 0x20be8a0(%rip), %rsi   # 0x20d2a10
xorl %eax, %eax
callq 0x9c96
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/portals.cpp
// Function: WriteLeafCount_r(node_s*)
static void WriteLeafCount_r (node_t *node)
{
	if (!node->isportalleaf)
	{
		WriteLeafCount_r (node->children[0]);
		WriteLeafCount_r (node->children[1]);
	}
	else
	{
		if (node->contents == CONTENTS_SOLID)
		{
			return;
		}
		int count = CountChildLeafs_r (node);
		fprintf (pf, "%i\n", count);
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpb $0x0, 0x49(%rbx)
jne 0x14240
movq 0x88(%rbx), %rdi
callq 0x14221
movq 0x90(%rbx), %rbx
jmp 0x14225
cmpl $-0x2, 0xa0(%rbx)
jne 0x1424b
popq %rbx
retq
movq %rbx, %rdi
callq 0x146da
movq 0x20bb796(%rip), %rdi   # 0x20cf9f0
leaq 0xce5c(%rip), %rsi      # 0x210bd
movl %eax, %edx
xorl %eax, %eax
popq %rbx
jmp 0x4440
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/portals.cpp
// Function: FreePortals(node_s*)
void            FreePortals(node_t* node)
{
    portal_t*       p;
    portal_t*       nextp;

#ifdef ZHLT_DETAILBRUSH
	if (!node->isportalleaf)
#else
    if (node->planenum != -1)
#endif
    {
        FreePortals(node->children[0]);
        FreePortals(node->children[1]);
        return;
    }

    for (p = node->portals; p; p = nextp)
    {
        if (p->nodes[0] == node)
        {
            nextp = p->next[0];
        }
        else
        {
            nextp = p->next[1];
        }
        RemovePortalFromNode(p, p->nodes[0]);
        RemovePortalFromNode(p, p->nodes[1]);
        delete p->winding;
        FreePortal(p);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpb $0x0, 0x49(%rbx)
jne 0x14684
movq 0x88(%rbx), %rdi
callq 0x14661
movq 0x90(%rbx), %rbx
jmp 0x14669
movq 0xb0(%rbx), %r14
testq %r14, %r14
je 0x146d4
movq 0x48(%r14), %rsi
xorl %eax, %eax
cmpq %rbx, %rsi
setne %al
movq 0x58(%r14,%rax,8), %r15
movq %r14, %rdi
callq 0x13d84
movq 0x50(%r14), %rsi
movq %r14, %rdi
callq 0x13d84
movq 0x68(%r14), %rdi
testq %rdi, %rdi
je 0x146c4
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, %rdi
callq 0x15120
movq %r15, %r14
testq %r15, %r15
jne 0x14690
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/portals.cpp
// Function: CountChildLeafs_r(node_s*)
static int CountChildLeafs_r (node_t *node)
{
	if (node->planenum == -1)
	{ // dleaf
		if (node->iscontentsdetail)
		{ // solid
			return 0;
		}
		else
		{
			return 1;
		}
	}
	else
	{ // node
		int count = 0;
		count += CountChildLeafs_r (node->children[0]);
		count += CountChildLeafs_r (node->children[1]);
		return count;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
xorl %ebx, %ebx
cmpl $-0x1, 0x80(%r14)
je 0x14704
movq 0x88(%r14), %rdi
callq 0x146da
movq 0x90(%r14), %r14
addl %eax, %ebx
jmp 0x146e3
movzbl 0x4a(%r14), %eax
xorl $0x1, %eax
addl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: NewFaceFromFace(face_s const*)
face_t*         NewFaceFromFace(const face_t* const in)
{
    face_t*         newf;

    newf = AllocFace();

    newf->planenum = in->planenum;
    newf->texturenum = in->texturenum;
    newf->original = in->original;
    newf->contents = in->contents;
#ifdef HLBSP_NewFaceFromFace_FIX
	newf->facestyle = in->facestyle;
#endif
#ifdef ZHLT_DETAILBRUSH
	newf->detaillevel = in->detaillevel;
#endif

    return newf;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x4b8, %edi            # imm = 0x4B8
callq 0x4400
movq %rax, %r14
movl $0x4b8, %edx            # imm = 0x4B8
movq %rax, %rdi
xorl %esi, %esi
callq 0x4180
movl $0xffffffff, 0x8(%r14)  # imm = 0xFFFFFFFF
movq 0x20(%rbx), %rax
movq %rax, 0x20(%r14)
movl 0x30(%rbx), %eax
movl %eax, 0x30(%r14)
movups 0x8(%rbx), %xmm0
movups %xmm0, 0x8(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: AllocFace()
face_t*         AllocFace()
{
    face_t*         f;

    f = (face_t*)malloc(sizeof(face_t));
    memset(f, 0, sizeof(face_t));

    f->planenum = -1;

    return f;
}

// Assembly:
pushq %rbx
movl $0x4b8, %edi            # imm = 0x4B8
callq 0x4400
movq %rax, %rbx
movl $0x4b8, %edx            # imm = 0x4B8
movq %rax, %rdi
xorl %esi, %esi
callq 0x4180
movl $0xffffffff, 0x8(%rbx)  # imm = 0xFFFFFFFF
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: NewSideFromSide(side_s const*)
side_t *NewSideFromSide (const side_t *s)
{
	side_t *news;
	news = AllocSide ();
	news->plane = s->plane;
	news->w = new Winding (*s->w);
	return news;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r15
movl $0x50, %edi
callq 0x4400
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movups 0x8(%r15), %xmm0
movups 0x18(%r15), %xmm1
movups 0x28(%r15), %xmm2
movups 0x38(%r15), %xmm3
movups %xmm3, 0x38(%rax)
movups %xmm2, 0x28(%rax)
movups %xmm1, 0x18(%rax)
movups %xmm0, 0x8(%rax)
movl $0x20, %edi
callq 0x42f0
movq %rax, %r14
movq 0x48(%r15), %rsi
movq %rax, %rdi
callq 0xc326
movq %r14, 0x48(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movl $0x20, %esi
movq %r14, %rdi
callq 0x4300
movq %rbx, %rdi
callq 0x4540
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: FreeBrush(brush_s*)
void FreeBrush (brush_t *b)
{
	if (b->sides)
	{
		side_t *s, *next;
		for (s = b->sides; s; s = next)
		{
			next = s->next;
			FreeSide (s);
		}
	}
	free (b);
	return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %r14
testq %r14, %r14
je 0x15237
movq (%r14), %r15
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x15227
movq (%rdi), %rax
callq *0x8(%rax)
movq %r14, %rdi
callq 0x4380
movq %r15, %r14
testq %r15, %r15
jne 0x15215
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4380
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: NewBrushFromBrush(brush_s const*)
brush_t *NewBrushFromBrush (const brush_t *b)
{
	brush_t *newb;
	newb = AllocBrush ();
	side_t *s, **pnews;
	for (s = b->sides, pnews = &newb->sides; s; s = s->next, pnews = &(*pnews)->next)
	{
		*pnews = NewSideFromSide (s);
	}
	return newb;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
movl $0x10, %edi
callq 0x4400
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq 0x8(%r14), %r14
testq %r14, %r14
je 0x15285
movq %rbx, %r15
addq $0x8, %r15
movq %r14, %rdi
callq 0x15164
movq %rax, (%r15)
movq (%r14), %r14
movq %rax, %r15
testq %r14, %r14
jne 0x1526f
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: ClipBrush(brush_s**, plane_t const*, double)
void ClipBrush (brush_t **b, const dplane_t *split, vec_t epsilon)
{
	side_t *s, **pnext;
	Winding *w;
	for (pnext = &(*b)->sides, s = *pnext; s; s = *pnext)
	{
		if (s->w->Clip (*split, false, epsilon))
		{
			pnext = &s->next;
		}
		else
		{
			*pnext = s->next;
			FreeSide (s);
		}
	}
	if (!(*b)->sides)
	{ // empty brush
		FreeBrush (*b);
		*b = NULL;
		return;
	}
	w = new Winding (*split);
	for (s = (*b)->sides; s; s = s->next)
	{
		if (!w->Clip (s->plane, false, epsilon))
		{
			break;
		}
	}
	if (w->m_NumPoints == 0)
	{
		delete w;
	}
	else
	{
		s = AllocSide ();
		s->plane = *split;
		s->w = w;
		s->next = (*b)->sides;
		(*b)->sides = s;
	}
	return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r12
movq 0x8(%r12), %r15
testq %r15, %r15
je 0x152f5
addq $0x8, %r12
movq 0x48(%r15), %rdi
movq %r14, %rsi
xorl %edx, %edx
movsd (%rsp), %xmm0
callq 0xd070
testb %al, %al
je 0x152ce
movq %r15, %r12
jmp 0x152ec
movq (%r15), %rax
movq %rax, (%r12)
movq 0x48(%r15), %rdi
testq %rdi, %rdi
je 0x152e4
movq (%rdi), %rax
callq *0x8(%rax)
movq %r15, %rdi
callq 0x4380
movq (%r12), %r15
testq %r15, %r15
jne 0x152b2
movq (%rbx), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x153a1
movl $0x20, %edi
callq 0x42f0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0xc8e2
movq (%rbx), %r12
addq $0x8, %r12
movq (%r12), %r12
testq %r12, %r12
je 0x15343
leaq 0x8(%r12), %rsi
movq %r15, %rdi
xorl %edx, %edx
movsd (%rsp), %xmm0
callq 0xd070
testb %al, %al
jne 0x15322
cmpl $0x0, 0x8(%r15)
je 0x153b9
movl $0x50, %edi
callq 0x4400
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movups %xmm3, 0x38(%rax)
movups %xmm2, 0x28(%rax)
movups %xmm1, 0x18(%rax)
movups %xmm0, 0x8(%rax)
movq %r15, 0x48(%rax)
movq (%rbx), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, (%rax)
movq %rax, 0x8(%rcx)
jmp 0x153ad
callq 0x15204
movq $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%r15), %rax
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *0x8(%rax)
movq %rax, %rbx
movl $0x20, %esi
movq %r15, %rdi
callq 0x4300
movq %rbx, %rdi
callq 0x4540
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: BrushFromBox(double const*, double const*)
brush_t *BrushFromBox (const vec3_t mins, const vec3_t maxs)
{
	brush_t *b = AllocBrush ();
	dplane_t planes[6];
	for (int k = 0; k < 3; k++)
	{
		VectorFill (planes[k].normal, 0.0);
		planes[k].normal[k] = 1.0;
		planes[k].dist = mins[k];
		VectorFill (planes[k+3].normal, 0.0);
		planes[k+3].normal[k] = -1.0;
		planes[k+3].dist = -maxs[k];
	}
	b->sides = AllocSide ();
	b->sides->plane = planes[0];
	b->sides->w = new Winding (planes[0]);
	for (int k = 1; k < 6; k++)
	{
		ClipBrush (&b, &planes[k], NORMAL_EPSILON);
		if (b == NULL)
		{
			break;
		}
	}
	return b;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rsi, %r14
movq %rdi, %r15
movl $0x10, %edi
callq 0x4400
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, 0x8(%rsp)
leaq 0x10(%rsp), %rax
xorl %ecx, %ecx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movabsq $-0x4010000000000000, %rsi # imm = 0xBFF0000000000000
movaps 0xbcf8(%rip), %xmm1     # 0x212d0
movq %rax, %rdi
xorl %r8d, %r8d
movaps %xmm0, (%rdi)
movq %rcx, 0x10(%rdi)
movq %rdx, (%rax)
movsd (%r15,%r8,8), %xmm2
movsd %xmm2, 0x30(%rdi)
movaps %xmm0, 0xc0(%rdi)
movq %rcx, 0xd0(%rdi)
movq %rsi, 0xc0(%rax)
movsd (%r14,%r8,8), %xmm2
xorps %xmm1, %xmm2
movlps %xmm2, 0xf0(%rdi)
incq %r8
addq $0x40, %rdi
addq $0x48, %rax
cmpq $0x3, %r8
jne 0x155de
movl $0x50, %edi
callq 0x4400
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movq %rax, 0x8(%rbx)
leaq 0x10(%rsp), %r15
movaps (%r15), %xmm0
movaps 0x10(%r15), %xmm1
movaps 0x20(%r15), %xmm2
movaps 0x30(%r15), %xmm3
movups %xmm3, 0x38(%rax)
movups %xmm2, 0x28(%rax)
movups %xmm1, 0x18(%rax)
movups %xmm0, 0x8(%rax)
movl $0x20, %edi
callq 0x42f0
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0xc8e2
movq 0x8(%rbx), %rax
movq %r14, 0x48(%rax)
movl $0x40, %r14d
leaq 0x8(%rsp), %rbx
leaq (%rsp,%r14), %rsi
addq $0x10, %rsi
movq %rbx, %rdi
movsd 0x8a5d(%rip), %xmm0     # 0x1e110
callq 0x1528e
cmpq $0x0, 0x8(%rsp)
je 0x156d0
leaq 0x40(%r14), %rax
cmpq $0x140, %r14            # imm = 0x140
movq %rax, %r14
jne 0x156a0
movq 0x8(%rsp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movl $0x20, %esi
movq %r14, %rdi
callq 0x4300
movq %rbx, %rdi
callq 0x4540
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/qbsp.cpp
// Function: CalcBrushBounds(brush_s const*, double (&) [3], double (&) [3])
void CalcBrushBounds (const brush_t *b, vec3_t &mins, vec3_t &maxs)
{
	VectorFill (mins, BOGUS_RANGE);
	VectorFill (maxs, -BOGUS_RANGE);
	for (side_t *s = b->sides; s; s = s->next)
	{
		vec3_t windingmins, windingmaxs;
		s->w->getBounds (windingmins, windingmaxs);
		VectorCompareMinimum (mins, windingmins, mins);
		VectorCompareMaximum (maxs, windingmaxs, maxs);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movaps 0xcd62(%rip), %xmm0     # 0x22470
movups %xmm0, (%rsi)
movabsq $0x4101940000000000, %rax # imm = 0x4101940000000000
movq %rax, 0x10(%rsi)
movapd 0xcd59(%rip), %xmm0     # 0x22480
movupd %xmm0, (%rdx)
movabsq $-0x3efe6c0000000000, %rax # imm = 0xC101940000000000
movq %rax, 0x10(%rdx)
movq 0x8(%rdi), %r13
testq %r13, %r13
je 0x157a7
movq %rdx, %rbx
movq %rsi, %r14
leaq 0x20(%rsp), %r15
movq %rsp, %r12
movq 0x48(%r13), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xbb30
movupd (%r14), %xmm0
minpd 0x20(%rsp), %xmm0
movupd %xmm0, (%r14)
movsd 0x10(%r14), %xmm0
minsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x10(%r14)
movupd (%rbx), %xmm0
maxpd (%rsp), %xmm0
movupd %xmm0, (%rbx)
movsd 0x10(%rbx), %xmm0
maxsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rbx)
movq (%r13), %r13
testq %r13, %r13
jne 0x15750
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: BuildSurfaceTree(surface_s*, double)
surfacetree_t *BuildSurfaceTree (surface_t *surfaces, vec_t epsilon)
{
	surfacetree_t *tree;
	tree = (surfacetree_t *)malloc (sizeof (surfacetree_t));
	tree->epsilon = epsilon;
	tree->result.middle = new std::vector< face_t * >;
	tree->headnode = (surfacetreenode_t *)malloc (sizeof (surfacetreenode_t));
	tree->headnode->leaffaces = new std::vector< face_t * >;
	{
		surface_t *p2;
		face_t *f;
		for (p2 = surfaces; p2; p2 = p2->next)
		{
			if (p2->onnode)
			{
				continue;
			}
			for (f = p2->faces; f; f = f->next)
			{
				tree->headnode->leaffaces->push_back (f);
			}
		}
	}
	tree->dontbuild = tree->headnode->leaffaces->size () < 20;
	BuildSurfaceTree_r (tree, tree->headnode);
	if (tree->dontbuild)
	{
		*tree->result.middle = *tree->headnode->leaffaces;
		tree->result.backsize = 0;
		tree->result.frontsize = 0;
	}
	return tree;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movsd %xmm0, 0x10(%rsp)
movq %rdi, %r14
movl $0x28, %edi
callq 0x4400
movq %rax, %rbx
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movl $0x18, %edi
callq 0x42f0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
xorl %r12d, %r12d
movq %r12, 0x10(%rax)
movq %rax, 0x20(%rbx)
movl $0x68, %edi
callq 0x4400
movq %rax, %r15
movq %rax, 0x10(%rbx)
movl $0x18, %edi
callq 0x42f0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r12, 0x10(%rax)
movq %rax, 0x60(%r15)
testq %r14, %r14
je 0x1823d
leaq 0x8(%rsp), %r15
cmpq $0x0, 0x40(%r14)
je 0x18201
movq (%r14), %r14
testq %r14, %r14
jne 0x181f0
jmp 0x1823d
movq 0x48(%r14), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x181f7
movq 0x10(%rbx), %rcx
movq 0x60(%rcx), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x1822b
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x18233
movq %r15, %rdx
callq 0x1a170
movq 0x8(%rsp), %rax
movq (%rax), %rax
jmp 0x18205
movq 0x10(%rbx), %rsi
movq 0x60(%rsi), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
cmpq $0xa0, %rcx
setb (%rbx)
movq %rbx, %rdi
callq 0x17c48
cmpb $0x1, (%rbx)
jne 0x1827c
movq 0x10(%rbx), %rax
movq 0x20(%rbx), %rdi
movq 0x60(%rax), %rsi
callq 0x1a09a
movq $0x0, 0x18(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: TestSurfaceTree_r(surfacetree_t*, surfacetreenode_s const*, plane_t const*)
void TestSurfaceTree_r (surfacetree_t *tree, const surfacetreenode_t *node, const dplane_t *split)
{
	if (node->size == 0)
	{
		return;
	}
	vec_t low, high;
	low = high = -split->dist;
	for (int k = 0; k < 3; k++)
	{
		if (split->normal[k] >= 0)
		{
			high += split->normal[k] * node->maxs[k];
			low += split->normal[k] * node->mins[k];
		}
		else
		{
			high += split->normal[k] * node->mins[k];
			low += split->normal[k] * node->maxs[k];
		}
	}
	if (low > tree->epsilon)
	{
		tree->result.frontsize += node->size;
#ifdef HLCSG_HLBSP_SOLIDHINT
		tree->result.frontsize -= node->size_discardable;
#endif
		return;
	}
	if (high < -tree->epsilon)
	{
		tree->result.backsize += node->size;
#ifdef HLCSG_HLBSP_SOLIDHINT
		tree->result.backsize -= node->size_discardable;
#endif
		return;
	}
	if (node->isleaf)
	{
		for (std::vector< face_t * >::iterator i = node->leaffaces->begin (); i != node->leaffaces->end (); ++i)
		{
			tree->result.middle->push_back (*i);
		}
	}
	else
	{
		for (std::vector< face_t * >::iterator i = node->nodefaces->begin (); i != node->nodefaces->end (); ++i)
		{
			tree->result.middle->push_back (*i);
		}
		TestSurfaceTree_r (tree, node->children[0], split);
		TestSurfaceTree_r (tree, node->children[1], split);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movapd 0x902c(%rip), %xmm4     # 0x212d0
xorpd %xmm5, %xmm5
movl (%r14), %eax
testl %eax, %eax
je 0x1838b
movsd 0x30(%r15), %xmm0
xorpd %xmm4, %xmm0
movq %r14, %rcx
xorl %edx, %edx
movapd %xmm0, %xmm1
movsd (%r15,%rdx,8), %xmm2
leaq 0x20(%rcx), %rsi
addq $0x8, %rcx
ucomisd %xmm5, %xmm2
movq %rsi, %rdi
cmovbq %rcx, %rdi
movsd (%rdi), %xmm3
mulsd %xmm2, %xmm3
cmovaeq %rcx, %rsi
mulsd (%rsi), %xmm2
addsd %xmm3, %xmm0
addsd %xmm2, %xmm1
incq %rdx
cmpq $0x3, %rdx
jne 0x182c6
movsd 0x8(%rbx), %xmm2
ucomisd %xmm2, %xmm1
ja 0x1836f
xorpd %xmm4, %xmm2
ucomisd %xmm0, %xmm2
ja 0x1837e
cmpb $0x1, 0x38(%r14)
je 0x18397
movq 0x50(%r14), %rax
movq (%rax), %r12
cmpq 0x8(%rax), %r12
je 0x18357
movq 0x20(%rbx), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x18345
movq (%r12), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x1834d
movq %r12, %rdx
callq 0x1a170
addq $0x8, %r12
movq 0x50(%r14), %rax
jmp 0x18323
movq 0x40(%r14), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x1828b
movq 0x48(%r14), %r14
jmp 0x1829c
addl 0x18(%rbx), %eax
movl %eax, 0x18(%rbx)
subl 0x4(%r14), %eax
movl %eax, 0x18(%rbx)
jmp 0x1838b
addl 0x1c(%rbx), %eax
movl %eax, 0x1c(%rbx)
subl 0x4(%r14), %eax
movl %eax, 0x1c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x60(%r14), %rax
movq (%rax), %r15
cmpq 0x8(%rax), %r15
je 0x1838b
movq 0x20(%rbx), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x183bf
movq (%r15), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x183c7
movq %r15, %rdx
callq 0x1a170
addq $0x8, %r15
movq 0x60(%r14), %rax
jmp 0x1839e
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: TestSurfaceTree(surfacetree_t*, plane_t const*)
void TestSurfaceTree (surfacetree_t *tree, const dplane_t *split)
{
	if (tree->dontbuild)
	{
		return;
	}
	tree->result.middle->clear ();
	tree->result.backsize = 0;
	tree->result.frontsize = 0;
	TestSurfaceTree_r (tree, tree->headnode, split);
}

// Assembly:
cmpb $0x0, (%rdi)
je 0x183d7
retq
movq %rsi, %rdx
movq 0x20(%rdi), %rax
movq (%rax), %rcx
cmpq %rcx, 0x8(%rax)
je 0x183eb
movq %rcx, 0x8(%rax)
movq $0x0, 0x18(%rdi)
movq 0x10(%rdi), %rsi
jmp 0x1828b
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: DeleteSurfaceTree_r(surfacetreenode_s*)
void DeleteSurfaceTree_r (surfacetreenode_t *node)
{
	if (node->isleaf)
	{
		delete node->leaffaces;
	}
	else
	{
		DeleteSurfaceTree_r (node->children[0]);
		free (node->children[0]);
		DeleteSurfaceTree_r (node->children[1]);
		free (node->children[1]);
		delete node->nodefaces;
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpb $0x1, 0x38(%rdi)
jne 0x1840c
movq 0x60(%rbx), %rbx
jmp 0x18434
movq 0x40(%rbx), %rdi
callq 0x183fc
movq 0x40(%rbx), %rdi
callq 0x4380
movq 0x48(%rbx), %rdi
callq 0x183fc
movq 0x48(%rbx), %rdi
callq 0x4380
movq 0x50(%rbx), %rbx
testq %rbx, %rbx
je 0x1845b
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x1844d
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movl $0x18, %esi
movq %rbx, %rdi
popq %rbx
jmp 0x4300
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: DeleteSurfaceTree(surfacetree_t*)
void DeleteSurfaceTree (surfacetree_t *tree)
{
	DeleteSurfaceTree_r (tree->headnode);
	free (tree->headnode);
	delete tree->result.middle;
	free (tree);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0x183fc
movq 0x10(%rbx), %rdi
callq 0x4380
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x184a0
movq (%r14), %rdi
testq %rdi, %rdi
je 0x18493
movq 0x10(%r14), %rsi
subq %rdi, %rsi
callq 0x4300
movl $0x18, %esi
movq %r14, %rdi
callq 0x4300
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4380
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: FixDetaillevelForDiscardable(node_s*, int)
void FixDetaillevelForDiscardable (node_t *node, int detaillevel)
{
	// when we move on to the next detaillevel, some discardable faces of previous detail level remain not on node (because they are discardable). remove them now
	surface_t *s, **psnext;
	face_t *f, **pfnext;
	for (psnext = &node->surfaces; s = *psnext, s != NULL; )
	{
		if (s->onnode)
		{
			psnext = &s->next;
			continue;
		}
		hlassume (s->faces, assume_ValidPointer);
		for (pfnext = &s->faces; f = *pfnext, f != NULL; )
		{
			if (detaillevel == -1 || f->detaillevel < detaillevel)
			{
				*pfnext = f->next;
				FreeFace (f);
			}
			else
			{
				pfnext = &f->next;
			}
		}
		if (!s->faces)
		{
			*psnext = s->next;
			FreeSurface (s);
		}
		else
		{
			psnext = &s->next;
			CalcSurfaceInfo (s);
			hlassume (!(detaillevel == -1 || s->detaillevel < detaillevel), assume_first);
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rdi), %r14
testq %r14, %r14
je 0x185a3
movl %esi, %ebx
movq %rdi, %r15
cmpq $0x0, 0x40(%r14)
jne 0x18594
leaq 0x48(%r14), %r12
xorl %edi, %edi
cmpq $0x0, 0x48(%r14)
setne %dil
movl $0x2, %esi
callq 0xa731
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x18558
movq %r12, %r13
cmpl $-0x1, %ebx
je 0x1853e
cmpl %ebx, 0x14(%rdi)
jge 0x1854c
movq (%rdi), %rax
movq %rax, (%r13)
callq 0x150c0
jmp 0x1854f
movq %rdi, %r13
movq (%r13), %rdi
testq %rdi, %rdi
jne 0x18534
cmpq $0x0, (%r12)
je 0x18575
movq %r14, %rdi
callq 0x185ad
cmpl $-0x1, %ebx
je 0x18588
cmpl %ebx, 0x50(%r14)
setge %al
jmp 0x1858a
movq (%r14), %rax
movq %rax, (%r15)
movq %r14, %rdi
callq 0x150f0
movq %r15, %r14
jmp 0x18594
xorl %eax, %eax
movzbl %al, %edi
xorl %esi, %esi
callq 0xa731
movq %r14, %r15
movq (%r14), %r14
testq %r14, %r14
jne 0x18504
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: CalcSurfaceInfo(surface_s*)
static void     CalcSurfaceInfo(surface_t* surf)
{
    int             i;
    int             j;
    face_t*         f;

    hlassume(surf->faces != NULL, assume_ValidPointer);    // "CalcSurfaceInfo() surface without a face"

    //
    // calculate a bounding box
    //
    for (i = 0; i < 3; i++)
    {
        surf->mins[i] = 99999;
        surf->maxs[i] = -99999;
    }

#ifdef ZHLT_DETAILBRUSH
	surf->detaillevel = -1;
#endif
    for (f = surf->faces; f; f = f->next)
    {
        if (f->contents >= 0)
        {
            Error("Bad contents");
        }
        for (i = 0; i < f->numpoints; i++)
        {
            for (j = 0; j < 3; j++)
            {
                if (f->pts[i][j] < surf->mins[j])
                {
                    surf->mins[j] = f->pts[i][j];
                }
                if (f->pts[i][j] > surf->maxs[j])
                {
                    surf->maxs[j] = f->pts[i][j];
                }
            }
        }
#ifdef ZHLT_DETAILBRUSH
		if (surf->detaillevel == -1 || f->detaillevel < surf->detaillevel)
		{
			surf->detaillevel = f->detaillevel;
		}
#endif
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %edi, %edi
cmpq $0x0, 0x48(%rbx)
setne %dil
movl $0x2, %esi
callq 0xa731
movq $-0x3, %rax
movabsq $0x40f869f000000000, %rcx # imm = 0x40F869F000000000
movabsq $-0x3f07961000000000, %rdx # imm = 0xC0F869F000000000
movq %rcx, 0x28(%rbx,%rax,8)
movq %rdx, 0x40(%rbx,%rax,8)
incq %rax
jne 0x185e5
movl $0xffffffff, 0x50(%rbx) # imm = 0xFFFFFFFF
movq 0x48(%rbx), %r15
testq %r15, %r15
je 0x1868f
leaq 0xb307(%rip), %r14      # 0x23916
cmpl $0x0, 0x10(%r15)
js 0x18620
movq %r14, %rdi
xorl %eax, %eax
callq 0x9f84
cmpl $0x0, 0x2c(%r15)
jle 0x18672
leaq 0x38(%r15), %rax
xorl %ecx, %ecx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm0
movsd 0x10(%rbx,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x18646
movsd %xmm0, 0x10(%rbx,%rdx,8)
movsd (%rax,%rdx,8), %xmm0
ucomisd 0x28(%rbx,%rdx,8), %xmm0
jbe 0x18659
movsd %xmm0, 0x28(%rbx,%rdx,8)
incq %rdx
cmpq $0x3, %rdx
jne 0x1862f
incq %rcx
movslq 0x2c(%r15), %rdx
addq $0x18, %rax
cmpq %rdx, %rcx
jl 0x1862d
movl 0x50(%rbx), %eax
cmpl $-0x1, %eax
je 0x18680
cmpl %eax, 0x14(%r15)
jge 0x18687
movl 0x14(%r15), %eax
movl %eax, 0x50(%rbx)
movq (%r15), %r15
testq %r15, %r15
jne 0x1860f
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/solidbsp.cpp
// Function: MakeLeaf(node_s*)
static void MakeLeaf (node_t *leafnode)
{
	int				nummarkfaces;
	face_t			*markfaces[MAX_LEAF_FACES + 1];
	surface_t		*surf;
	face_t			*f;	

    leafnode->planenum = -1;

	leafnode->iscontentsdetail = leafnode->detailbrushes != NULL;
	FreeLeafBrushes (leafnode);
	leafnode->detailbrushes = NULL;
#ifdef HLBSP_DETAILBRUSH_CULL
	if (leafnode->boundsbrush)
	{
		FreeBrush (leafnode->boundsbrush);
	}
	leafnode->boundsbrush = NULL;
#endif

	if (!(leafnode->isportalleaf && leafnode->contents == CONTENTS_SOLID))
	{
		nummarkfaces = 0;
		for (surf = leafnode->surfaces; surf; surf = surf->next)
		{
			if (!surf->onnode)
			{
				continue;
			}
#ifdef HLCSG_HLBSP_SOLIDHINT
			if (!surf->onnode)
			{
				continue;
			}
#endif
			for (f = surf->faces; f; f = f->next)
			{
				if (f->original == NULL)
				{ // because it is not on node or its content is solid
					continue;
				}
#ifdef HLCSG_HLBSP_SOLIDHINT
				if (f->original == NULL)
				{
					continue;
				}
#endif
				hlassume(nummarkfaces < MAX_LEAF_FACES, assume_MAX_LEAF_FACES);

				markfaces[nummarkfaces++] = f->original;
			}
		}
		markfaces[nummarkfaces] = NULL;                    // end marker
		nummarkfaces++;

		leafnode->markfaces = (face_t**)malloc(nummarkfaces * sizeof(*leafnode->markfaces));
		memcpy(leafnode->markfaces, markfaces, nummarkfaces * sizeof(*leafnode->markfaces));
	}

	FreeLeafSurfs(leafnode);
	leafnode->surfaces = NULL;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20010, %rsp          # imm = 0x20010
movq %rdi, %rbx
movl $0xffffffff, 0x80(%rdi) # imm = 0xFFFFFFFF
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
setne 0x4a(%rbx)
je 0x19dc8
movq (%rdi), %r14
callq 0x15204
movq %r14, %rdi
testq %r14, %r14
jne 0x19db8
movq $0x0, 0x8(%rbx)
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x19dde
callq 0x15204
movq $0x0, 0x10(%rbx)
cmpb $0x1, 0x49(%rbx)
jne 0x19df5
cmpl $-0x2, 0xa0(%rbx)
je 0x19e73
movq (%rbx), %r14
xorl %ebp, %ebp
testq %r14, %r14
je 0x19e43
cmpq $0x0, 0x40(%r14)
je 0x19e3e
movq 0x48(%r14), %r15
testq %r15, %r15
je 0x19e3e
cmpq $0x0, 0x20(%r15)
je 0x19e39
xorl %edi, %edi
cmpl $0x4000, %ebp           # imm = 0x4000
setl %dil
movl $0x12, %esi
callq 0xa731
movq 0x20(%r15), %rax
movslq %ebp, %rcx
incl %ebp
movq %rax, (%rsp,%rcx,8)
movq (%r15), %r15
jmp 0x19e0a
movq (%r14), %r14
jmp 0x19dfa
movslq %ebp, %rax
movq $0x0, (%rsp,%rax,8)
leaq 0x8(,%rax,8), %r14
movq %r14, %rdi
callq 0x4400
movq %rax, 0xa8(%rbx)
movq %rsp, %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x4260
movq (%rbx), %r14
testq %r14, %r14
je 0x19ea7
movq (%r14), %r15
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x19e97
movq (%rdi), %r12
callq 0x150c0
movq %r12, %rdi
testq %r12, %r12
jne 0x19e87
movq %r14, %rdi
callq 0x150f0
movq %r15, %r14
testq %r15, %r15
jne 0x19e7b
movq $0x0, (%rbx)
addq $0x20010, %rsp          # imm = 0x20010
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/surfaces.cpp
// Function: GetEdge(double const*, double const*, face_s*)
int             GetEdge(const vec3_t p1, const vec3_t p2, face_t* f)
{
    int             v1;
    int             v2;
    dedge_t*        edge;
    int             i;

    hlassert(f->contents);

    v1 = GetVertex(p1, f->planenum);
    v2 = GetVertex(p2, f->planenum);
    for (i = firstmodeledge; i < g_numedges; i++)
    {
        edge = &g_dedges[i];
        if (v1 == edge->v[1] && v2 == edge->v[0] && !edgefaces[i][1] && edgefaces[i][0]->contents == f->contents
#ifdef HLBSP_EDGESHARE_SAMESIDE
			&& edgefaces[i][0]->planenum != (f->planenum ^ 1)
			&& edgefaces[i][0]->contents == f->contents
#endif
			)
        {
            edgefaces[i][1] = f;
            return -i;
        }
    }

    // emit an edge
    hlassume(g_numedges < MAX_MAP_EDGES, assume_MAX_MAP_EDGES);
    edge = &g_dedges[g_numedges];
    g_numedges++;
    edge->v[0] = v1;
    edge->v[1] = v2;
    edgefaces[i][0] = f;

    return i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movl 0x8(%rdx), %esi
callq 0x1a623
movl %eax, %r14d
movl 0x8(%rbx), %esi
movq %r15, %rdi
callq 0x1a623
movl %eax, %r15d
movl 0x11ea7(%rip), %ebp     # 0x2c410
leaq 0x1cf9e5c(%rip), %r13   # 0x1d143cc
movl (%r13), %eax
leaq 0x32ba505(%rip), %r12   # 0x32d4a80
cmpl %eax, %ebp
jge 0x1a5cd
movslq %ebp, %rcx
leaq 0x2(,%rcx,4), %rcx
leaq 0x1cf9e3f(%rip), %rdx   # 0x1d143d0
movzwl (%rdx,%rcx), %esi
cmpl %esi, %r14d
jne 0x1a5c3
movzwl -0x2(%rdx,%rcx), %esi
cmpl %esi, %r15d
jne 0x1a5c3
cmpq $0x0, (%r12,%rcx,4)
jne 0x1a5c3
movq -0x8(%r12,%rcx,4), %rsi
movl 0x10(%rsi), %edi
cmpl 0x10(%rbx), %edi
jne 0x1a5c3
movl 0x8(%rbx), %edi
xorl 0x8(%rsi), %edi
cmpl $0x1, %edi
jne 0x1a61b
incl %ebp
addq $0x4, %rcx
cmpl %ebp, %eax
jne 0x1a591
xorl %edi, %edi
cmpl $0x3e800, %eax          # imm = 0x3E800
setl %dil
movl $0x2d, %esi
callq 0xa731
movslq (%r13), %rax
leaq 0x1cf9de3(%rip), %rcx   # 0x1d143d0
leal 0x1(%rax), %edx
movl %edx, (%r13)
movw %r14w, (%rcx,%rax,4)
movw %r15w, 0x2(%rcx,%rax,4)
movslq %ebp, %rax
shlq $0x4, %rax
movq %rbx, (%rax,%r12)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, (%r12,%rcx,4)
negl %ebp
jmp 0x1a60a
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/surfaces.cpp
// Function: MakeFaceEdges()
static void     InitHash()
{
    vec3_t          size;
    vec_t           volume;
    vec_t           scale;
    int             newsize[2];
    int             i;

    memset(hashverts, 0, sizeof(hashverts));

    for (i = 0; i < 3; i++)
    {
        hash_min[i] = -8000;
        size[i] = 16000;
    }

    volume = size[0] * size[1];

    scale = sqrt(volume / NUM_HASH);

#ifdef HLBSP_HASH_FIX
	hash_numslots[0] = (int)floor (size[0] / scale);
	hash_numslots[1] = (int)floor (size[1] / scale);
	while (hash_numslots[0] * hash_numslots[1] > NUM_HASH)
	{
		Developer (DEVELOPER_LEVEL_WARNING, "hash_numslots[0] * hash_numslots[1] > NUM_HASH");
		hash_numslots[0]--;
		hash_numslots[1]--;
	}

	hash_scale[0] = hash_numslots[0] / size[0];
	hash_scale[1] = hash_numslots[1] / size[1];
#else
    newsize[0] = size[0] / scale;
    newsize[1] = size[1] / scale;

    hash_scale[0] = newsize[0] / size[0];
    hash_scale[1] = newsize[1] / size[1];
    hash_scale[2] = newsize[1];
#endif

    hvert_p = hvertex;
}

// Assembly:
pushq %rbx
subq $0x50, %rsp
leaq 0x36a207c(%rip), %rdi   # 0x36bca80
xorl %ebx, %ebx
movl $0x8000, %edx           # imm = 0x8000
xorl %esi, %esi
callq 0x4180
leaq 0x36aa097(%rip), %rax   # 0x36c4ab0
movabsq $-0x3f40c00000000000, %rcx # imm = 0xC0BF400000000000
movabsq $0x40cf400000000000, %rdx # imm = 0x40CF400000000000
movq %rcx, (%rbx,%rax)
movq %rdx, 0x30(%rsp,%rbx)
addq $0x8, %rbx
cmpq $0x18, %rbx
jne 0x1aa2d
movapd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
movapd %xmm1, (%rsp)
mulsd %xmm1, %xmm0
mulsd 0x91e9(%rip), %xmm0     # 0x23c48
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1aa6f
sqrtsd %xmm0, %xmm0
jmp 0x1aa74
callq 0x4240
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd (%rsp), %xmm1
divpd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movapd %xmm1, %xmm0
callq 0x4530
movapd %xmm0, 0x20(%rsp)
movapd 0x10(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x4530
movapd 0x20(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvttpd2dq %xmm1, %xmm0
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movd %xmm1, %ecx
imull %eax, %ecx
movq %xmm0, 0x36a9ffd(%rip)  # 0x36c4ac8
cmpl $0x1001, %ecx           # imm = 0x1001
jl 0x1ab19
leaq 0x91e2(%rip), %rbx      # 0x23cbc
movl $0x2, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0xa496
movq 0x36a9fd7(%rip), %xmm0  # 0x36c4ac8
paddd 0x9157(%rip), %xmm0     # 0x23c50
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movd %xmm1, %ecx
imull %eax, %ecx
movq %xmm0, 0x36a9fb7(%rip)  # 0x36c4ac8
cmpl $0x1000, %ecx           # imm = 0x1000
jg 0x1aada
cvtdq2pd %xmm0, %xmm0
divpd (%rsp), %xmm0
movapd %xmm0, 0x36a9f66(%rip)  # 0x36c4a90
leaq 0x36a9faf(%rip), %rax   # 0x36c4ae0
movq %rax, 0x36a9f48(%rip)   # 0x36c4a80
leaq 0x1cf988d(%rip), %rax   # 0x1d143cc
movl (%rax), %eax
movl %eax, 0x118c9(%rip)     # 0x2c410
addq $0x50, %rsp
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/tjunc.cpp
// Function: tjunc(node_s*)
void            tjunc(node_t* headnode)
{
    vec3_t          maxs, mins;
    int             i;

    Verbose("---- tjunc ----\n");

    if (g_notjunc)
    {
        return;
    }

    //
    // identify all points on common edges
    //

    // origin points won't allways be inside the map, so extend the hash area 
    for (i = 0; i < 3; i++)
    {
        if (fabs(headnode->maxs[i]) > fabs(headnode->mins[i]))
        {
            maxs[i] = fabs(headnode->maxs[i]);
        }
        else
        {
            maxs[i] = fabs(headnode->mins[i]);
        }
    }
    VectorSubtract(vec3_origin, maxs, mins);

    InitHash(mins, maxs);

    numwedges = numwverts = 0;

    tjunc_find_r(headnode);

    Verbose("%i world edges  %i edge points\n", numwedges, numwverts);

    //
    // add extra vertexes on edges where needed
    //
    tjuncs = tjuncfaces = 0;

    tjunc_fix_r(headnode);

    Verbose("%i edges added by tjunctions\n", tjuncs);
    Verbose("%i faces added by tjunctions\n", tjuncfaces);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x91d3(%rip), %rdi      # 0x23d30
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xa3d7
leaq 0x20b9ea7(%rip), %rax   # 0x20d4a14
cmpb $0x0, (%rax)
je 0x1ab79
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movaps 0x9170(%rip), %xmm0     # 0x23cf0
movaps %xmm0, 0x3a31f39(%rip)  # 0x3a4cac0
movabsq $-0x3f40c00000000000, %rax # imm = 0xC0BF400000000000
movq %rax, 0x3a31f38(%rip)   # 0x3a4cad0
leaq 0x3a29f11(%rip), %rdi   # 0x3a44ab0
movl $0x8000, %edx           # imm = 0x8000
xorl %esi, %esi
callq 0x4180
movabsq $0x4000000040, %rax     # imm = 0x4000000040
movq %rax, 0x3a31f1c(%rip)   # 0x3a4cad8
movaps 0x913d(%rip), %xmm0     # 0x23d00
movaps %xmm0, 0x3a31f26(%rip)  # 0x3a4caf0
movl %ebp, 0x3a31ee0(%rip)   # 0x3a4cab0
movl %ebp, 0x3a31ede(%rip)   # 0x3a4cab4
movq %rbx, %rdi
callq 0x1ac3a
movl 0x3a31ed0(%rip), %esi   # 0x3a4cab4
movl 0x3a31ec6(%rip), %edx   # 0x3a4cab0
leaq 0x9150(%rip), %rdi      # 0x23d41
xorl %eax, %eax
callq 0xa3d7
movl %ebp, 0x3a31eba(%rip)   # 0x3a4cab8
movl %ebp, 0x3a31eb8(%rip)   # 0x3a4cabc
movq %rbx, %rdi
callq 0x1ad0d
movl 0x3a31eaa(%rip), %esi   # 0x3a4cabc
leaq 0x9148(%rip), %rdi      # 0x23d61
xorl %eax, %eax
callq 0xa3d7
movl 0x3a31e92(%rip), %esi   # 0x3a4cab8
leaq 0x9152(%rip), %rdi      # 0x23d7f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xa3d7
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/tjunc.cpp
// Function: tjunc_find_r(node_s*)
static void     tjunc_find_r(node_t* node)
{
    face_t*         f;

    if (node->planenum == PLANENUM_LEAF)
    {
        return;
    }

    for (f = node->faces; f; f = f->next)
    {
        AddFaceEdges(f);
    }

    tjunc_find_r(node->children[0]);
    tjunc_find_r(node->children[1]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rbp
leaq 0x18(%rsp), %r14
cmpl $-0x1, 0x80(%rbx)
je 0x1acfe
movq %rbx, 0x8(%rsp)
movq 0x98(%rbx), %rbx
testq %rbx, %rbx
je 0x1ace1
movl 0x2c(%rbx), %ecx
testl %ecx, %ecx
jle 0x1acdc
leaq 0x38(%rbx), %r12
movq %r12, 0x10(%rsp)
xorl %r13d, %r13d
incq %r13
movl %r13d, %eax
cltd
idivl %ecx
leaq (%rdx,%rdx,2), %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rsi
movq %r12, %rdi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x1b57b
movq %rbp, %r15
movq %rax, %rbp
movsd 0x20(%rsp), %xmm0
movq %rax, %rdi
callq 0x1bb2f
movsd 0x18(%rsp), %xmm0
movq %rbp, %rdi
movq %r15, %rbp
callq 0x1bb2f
movslq 0x2c(%rbx), %rcx
addq $0x18, %r12
cmpq %rcx, %r13
jl 0x1ac86
movq (%rbx), %rbx
jmp 0x1ac6e
movq 0x8(%rsp), %rbx
movq 0x88(%rbx), %rdi
callq 0x1ac3a
movq 0x90(%rbx), %rbx
jmp 0x1ac55
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/tjunc.cpp
// Function: AddVert(wedge_s const*, double)
static void     AddVert(const wedge_t* const w, const vec_t t)
{
    wvert_t*        v;
    wvert_t*        newv;

    v = w->head.next;
    do
    {
        if (fabs(v->t - t) < T_EPSILON)
        {
            return;
        }
        if (v->t > t)
        {
            break;
        }
        v = v->next;
    }
    while (1);

    // insert a new wvert before v
    hlassume(numwverts < MAX_WVERTS, assume_MAX_WVERTS);

    newv = &wverts[numwverts];
    numwverts++;

    newv->t = t;
    newv->next = v;
    newv->prev = v->prev;
    v->prev->next = newv;
    v->prev = newv;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq 0x48(%rdi), %rbx
movsd (%rbx), %xmm1
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
andpd 0x5794(%rip), %xmm2     # 0x212e0
movsd 0x593c(%rip), %xmm4     # 0x21490
ucomisd %xmm2, %xmm4
ja 0x1bbe8
movapd 0x577a(%rip), %xmm2     # 0x212e0
ucomisd %xmm0, %xmm1
ja 0x1bb88
movq 0x10(%rbx), %rbx
movsd (%rbx), %xmm1
movapd %xmm1, %xmm3
subsd %xmm0, %xmm3
andpd %xmm2, %xmm3
ucomisd %xmm3, %xmm4
jbe 0x1bb66
jmp 0x1bbe8
xorl %edi, %edi
cmpl $0x40000, 0x3a30f1c(%rip) # imm = 0x40000
setl %dil
movl $0x14, %esi
movsd %xmm0, 0x8(%rsp)
callq 0xa731
movslq 0x3a30f01(%rip), %rax   # 0x3a4cab0
leaq (%rax,%rax,2), %rcx
leaq 0x4430f56(%rip), %rdx   # 0x444cb10
leaq (%rdx,%rcx,8), %rcx
incl %eax
movl %eax, 0x3a30eea(%rip)   # 0x3a4cab0
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rcx)
movq %rbx, 0x10(%rcx)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rcx)
movq 0x8(%rbx), %rax
movq %rcx, 0x10(%rax)
movq %rcx, 0x8(%rbx)
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/writebsp.cpp
// Function: OutputEdges_face(face_s*)
void OutputEdges_face (face_t *f)
{
	if (CheckFaceForHint(f)
		|| CheckFaceForSkip(f)
#ifdef ZHLT_NULLTEX
        || CheckFaceForNull(f)  // AJM
#endif
#ifdef HLCSG_HLBSP_SOLIDHINT
		|| CheckFaceForDiscardable (f)
#endif
#ifdef HLCSG_HLBSP_VOIDTEXINFO
		|| f->texturenum == -1
#endif
#ifdef HLBSP_REMOVECOVEREDFACES
		|| f->referenced == 0
#endif
		|| CheckFaceForEnv_Sky(f)//Cpt_Andrew - Env_Sky Check
		)
	{
		return;
	}
	f->outputedges = (int *)malloc (f->numpoints * sizeof (int));
	hlassume (f->outputedges != NULL, assume_NoMemory);
	int i;
	for (i = 0; i < f->numpoints; i++)
	{
		int e = GetEdge (f->pts[i], f->pts[(i + 1) % f->numpoints], f);
		f->outputedges[i] = e;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x1587f
testb %al, %al
jne 0x1beaa
movq %rbx, %rdi
callq 0x158a3
testb %al, %al
jne 0x1beaa
movq %rbx, %rdi
callq 0x157fd
testb %al, %al
jne 0x1beaa
movq %rbx, %rdi
callq 0x158c7
testb %al, %al
jne 0x1beaa
cmpl $-0x1, 0xc(%rbx)
je 0x1beaa
cmpl $0x0, 0x34(%rbx)
je 0x1beaa
movq %rbx, %rdi
callq 0x1585b
testb %al, %al
jne 0x1beaa
movslq 0x2c(%rbx), %rdi
shlq $0x2, %rdi
callq 0x4400
movq %rax, 0x18(%rbx)
xorl %edi, %edi
testq %rax, %rax
setne %dil
movl $0x1, %esi
callq 0xa731
movl 0x2c(%rbx), %ecx
testl %ecx, %ecx
jle 0x1beaa
leaq 0x38(%rbx), %r12
xorl %r13d, %r13d
movq %r12, %r14
leaq 0x1(%r13), %r15
movl %r15d, %eax
cltd
idivl %ecx
leaq (%rdx,%rdx,2), %rax
leaq (%r12,%rax,8), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x1a539
movq 0x18(%rbx), %rcx
movl %eax, (%rcx,%r13,4)
movslq 0x2c(%rbx), %rcx
addq $0x18, %r14
movq %r15, %r13
cmpq %rcx, %r15
jl 0x1be75
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq