// File: /workspace/github_cpp_makefile_star2_O1/FreeSlave[P]vhlt/hlbsp/brink.cpp
// Function: BuildBaseCell(int&, bclipnode_s*, double, btreeleaf_s*)
btreeleaf_t *BuildBaseCell (int &numobjects, bclipnode_t *clipnode, vec_t range, btreeleaf_t *leaf_outside)
{
	btreepoint_t *tp[8];
	for (int i = 0; i < 8; i++)
	{
		tp[i] = AllocTreepoint (numobjects, true);
		if (i & 1)
			tp[i]->v[0] = range;
		else
			tp[i]->v[0] = -range;
		if (i & 2)
			tp[i]->v[1] = range;
		else
			tp[i]->v[1] = -range;
		if (i & 4)
			tp[i]->v[2] = range;
		else
			tp[i]->v[2] = -range;
	}
	btreeedge_t *te[12];
	for (int i = 0; i < 12; i++)
	{
		te[i] = AllocTreeedge (numobjects, true);
	}
	SetEdgePoints (te[0], tp[1], tp[0]);
	SetEdgePoints (te[1], tp[3], tp[2]);
	SetEdgePoints (te[2], tp[5], tp[4]);
	SetEdgePoints (te[3], tp[7], tp[6]);
	SetEdgePoints (te[4], tp[2], tp[0]);
	SetEdgePoints (te[5], tp[3], tp[1]);
	SetEdgePoints (te[6], tp[6], tp[4]);
	SetEdgePoints (te[7], tp[7], tp[5]);
	SetEdgePoints (te[8], tp[4], tp[0]);
	SetEdgePoints (te[9], tp[5], tp[1]);
	SetEdgePoints (te[10], tp[6], tp[2]);
	SetEdgePoints (te[11], tp[7], tp[3]);
	btreeface_t *tf[6];
	for (int i = 0; i < 6; i++)
	{
		tf[i] = AllocTreeface (numobjects, true);
	}
	AttachEdgeToFace (tf[0], te[4], true);
	AttachEdgeToFace (tf[0], te[6], false);
	AttachEdgeToFace (tf[0], te[8], false);
	AttachEdgeToFace (tf[0], te[10], true);
	AttachEdgeToFace (tf[1], te[5], false);
	AttachEdgeToFace (tf[1], te[7], true);
	AttachEdgeToFace (tf[1], te[9], true);
	AttachEdgeToFace (tf[1], te[11], false);
	AttachEdgeToFace (tf[2], te[0], false);
	AttachEdgeToFace (tf[2], te[2], true);
	AttachEdgeToFace (tf[2], te[8], true);
	AttachEdgeToFace (tf[2], te[9], false);
	AttachEdgeToFace (tf[3], te[1], true);
	AttachEdgeToFace (tf[3], te[3], false);
	AttachEdgeToFace (tf[3], te[10], false);
	AttachEdgeToFace (tf[3], te[11], true);
	AttachEdgeToFace (tf[4], te[0], true);
	AttachEdgeToFace (tf[4], te[1], false);
	AttachEdgeToFace (tf[4], te[4], false);
	AttachEdgeToFace (tf[4], te[5], true);
	AttachEdgeToFace (tf[5], te[2], false);
	AttachEdgeToFace (tf[5], te[3], true);
	AttachEdgeToFace (tf[5], te[6], true);
	AttachEdgeToFace (tf[5], te[7], false);
	btreeleaf_t *tl;
	tl = AllocTreeleaf (numobjects, false);
	for (int i = 0; i < 6; i++)
	{
		SetFaceLeafs (tf[i], tl, leaf_outside);
	}
	tl->clipnode = clipnode;
	return tl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdx, %rbx
movq %rsi, 0x98(%rsp)
movq %rdi, %r15
movaps 0x12ea7(%rip), %xmm1    # 0x212d0
movaps %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm1
movaps %xmm1, 0x60(%rsp)
xorl %r14d, %r14d
movq %r15, %rdi
movl $0x1, %esi
callq 0xe062
movq %rax, 0xd0(%rsp,%r14,8)
movaps 0x60(%rsp), %xmm1
movaps %xmm1, %xmm0
testb $0x1, %r14b
je 0xe461
movaps 0x20(%rsp), %xmm0
movsd %xmm0, (%rax)
movaps %xmm1, %xmm0
testb $0x2, %r14b
je 0xe473
movaps 0x20(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movaps %xmm1, %xmm0
cmpq $0x4, %r14
jb 0xe486
movaps 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rax)
incq %r14
cmpq $0x8, %r14
jne 0xe439
xorl %r14d, %r14d
movq %r15, %rdi
movl $0x1, %esi
callq 0xe0bc
movq %rax, 0x110(%rsp,%r14,8)
incq %r14
cmpq $0xc, %r14
jne 0xe497
movq 0x110(%rsp), %r14
movq 0xd0(%rsp), %r12
movq %r12, 0x8(%rsp)
movq 0xd8(%rsp), %rsi
movq %rsi, 0x30(%rsp)
xorl %r13d, %r13d
movq %r14, %rdi
xorl %edx, %edx
callq 0xe125
movq %r14, 0x90(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xe125
movq 0x118(%rsp), %r14
movq 0xe0(%rsp), %r12
movq 0xe8(%rsp), %rsi
movq %rsi, 0x38(%rsp)
movq %r14, %rdi
xorl %edx, %edx
callq 0xe125
movq %r14, 0x88(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r12, %r14
movq %r12, 0x80(%rsp)
movl $0x1, %edx
callq 0xe125
movq 0x120(%rsp), %r12
movq 0xf0(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq 0xf8(%rsp), %rsi
movq %rsi, 0x18(%rsp)
movq %r12, %rdi
xorl %edx, %edx
callq 0xe125
movq %r12, 0x20(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
callq 0xe125
movq 0x128(%rsp), %rbp
movq 0x100(%rsp), %r12
movq 0x108(%rsp), %rsi
movq %rsi, (%rsp)
movq %rbp, %rdi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x60(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
movq %r12, 0x78(%rsp)
movl $0x1, %edx
callq 0xe125
movq 0x130(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x58(%rsp)
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0xe125
movq 0x138(%rsp), %rbp
movq %rbp, %rdi
movq 0x38(%rsp), %rsi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x48(%rsp)
movq %rbp, %rdi
movq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0xe125
movq 0x140(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x50(%rsp)
movq %rbp, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
movl $0x1, %edx
callq 0xe125
movq 0x148(%rsp), %rbp
movq %rbp, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x40(%rsp)
movq %rbp, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
movl $0x1, %edx
callq 0xe125
movq 0x150(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0xe125
movq 0x158(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
movq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0xe125
movq 0x160(%rsp), %rbp
movq %rbp, %rdi
movq 0x78(%rsp), %rsi
xorl %edx, %edx
callq 0xe125
movq %rbp, 0x8(%rsp)
movq %rbp, %rdi
movq 0x80(%rsp), %rsi
movl $0x1, %edx
callq 0xe125
movq 0x168(%rsp), %r12
movq %r12, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
callq 0xe125
movq %r12, (%rsp)
movq %r12, %rdi
movq 0x38(%rsp), %rsi
movl $0x1, %edx
callq 0xe125
movq %r15, %rdi
movl $0x1, %esi
callq 0xe1de
movq %rax, 0xa0(%rsp,%r13,8)
incq %r13
cmpq $0x6, %r13
jne 0xe735
movq 0xa0(%rsp), %r13
movq %r13, %rdi
movq 0x58(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
xorl %ebp, %ebp
movq %r13, %rdi
movq 0x50(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r13, %rdi
movq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq 0xa8(%rsp), %r13
movq %r13, %rdi
movq 0x48(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r13, %rdi
movq 0x40(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq %r13, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
movl $0x1, %edx
callq 0xe247
movq %r13, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq 0xb0(%rsp), %r13
movq %r13, %rdi
movq 0x90(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0xe247
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xe247
movq 0xb8(%rsp), %r14
movq %r14, %rdi
movq 0x88(%rsp), %r13
movq %r13, %rsi
movl $0x1, %edx
callq 0xe247
movq %r14, %rdi
movq 0x60(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r14, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r14, %rdi
movq (%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq 0xc0(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xe247
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xe247
movq %r14, %rdi
movq 0x58(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r14, %rdi
movq 0x48(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq 0xc8(%rsp), %r14
movq %r14, %rdi
movq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r14, %rdi
movq 0x60(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq %r14, %rdi
movq 0x50(%rsp), %rsi
movl $0x1, %edx
callq 0xe247
movq %r14, %rdi
movq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0xe247
movq %r15, %rdi
xorl %esi, %esi
callq 0xe395
movq %rax, %r14
movq 0xa0(%rsp,%rbp,8), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xe2d5
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xe2d5
incq %rbp
cmpq $0x6, %rbp
jne 0xe925
movq 0x98(%rsp), %rax
movq %rax, 0x10(%r14)
movq %r14, %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq