// File: /workspace/github_cpp_makefile_star2_O3/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 $0x188, %rsp            # imm = 0x188
movq %rdx, %rbx
movq %rsi, 0xa8(%rsp)
movq %rdi, %r15
movdqa 0x120c8(%rip), %xmm1    # 0x202b0
pxor %xmm0, %xmm1
movdqa %xmm1, 0x70(%rsp)
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, 0x60(%rsp)
movdqa %xmm0, 0x40(%rsp)
punpcklqdq %xmm0, %xmm0    # xmm0 = xmm0[0,0]
movdqa %xmm0, 0x50(%rsp)
xorl %r14d, %r14d
movq %r15, %rdi
movl $0x1, %esi
callq 0xde38
movq %rax, 0xe0(%rsp,%r14,8)
movd %r14d, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pand 0x12229(%rip), %xmm0    # 0x20460
pcmpeqd 0x12231(%rip), %xmm0    # 0x20470
movdqa 0x60(%rsp), %xmm1
pand %xmm0, %xmm1
pandn 0x50(%rsp), %xmm0
por %xmm1, %xmm0
movdqu %xmm0, (%rax)
movdqa 0x70(%rsp), %xmm0
cmpq $0x4, %r14
jb 0xe269
movdqa 0x40(%rsp), %xmm0
movq %xmm0, 0x10(%rax)
incq %r14
cmpq $0x8, %r14
jne 0xe210
xorl %r14d, %r14d
movq %r15, %rdi
movl $0x1, %esi
callq 0xde8c
movq %rax, 0x120(%rsp,%r14,8)
incq %r14
cmpq $0xc, %r14
jne 0xe27a
movq 0x120(%rsp), %r14
movq 0xe0(%rsp), %r12
movq %r12, 0x8(%rsp)
movq 0xe8(%rsp), %rsi
movq %rsi, 0x20(%rsp)
xorl %r13d, %r13d
movq %r14, %rdi
xorl %edx, %edx
callq 0xdeef
movq %r14, 0xa0(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x128(%rsp), %r14
movq 0xf0(%rsp), %r12
movq 0xf8(%rsp), %rsi
movq %rsi, 0x28(%rsp)
movq %r14, %rdi
xorl %edx, %edx
callq 0xdeef
movq %r14, 0x98(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %r12, %r14
movq %r12, 0x90(%rsp)
movl $0x1, %edx
callq 0xdeef
movq 0x130(%rsp), %r12
movq 0x100(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq 0x108(%rsp), %rsi
movq %rsi, 0x18(%rsp)
movq %r12, %rdi
xorl %edx, %edx
callq 0xdeef
movq %r12, 0x70(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x138(%rsp), %rbp
movq 0x110(%rsp), %r12
movq 0x118(%rsp), %rsi
movq %rsi, (%rsp)
movq %rbp, %rdi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x60(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
movq %r12, 0x88(%rsp)
movl $0x1, %edx
callq 0xdeef
movq 0x140(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x50(%rsp)
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x148(%rsp), %rbp
movq %rbp, %rdi
movq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x38(%rsp)
movq %rbp, %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x150(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x40(%rsp)
movq %rbp, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x158(%rsp), %rbp
movq %rbp, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x30(%rsp)
movq %rbp, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x160(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x168(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x170(%rsp), %rbp
movq %rbp, %rdi
movq 0x88(%rsp), %rsi
xorl %edx, %edx
callq 0xdeef
movq %rbp, 0x8(%rsp)
movq %rbp, %rdi
movq 0x90(%rsp), %rsi
movl $0x1, %edx
callq 0xdeef
movq 0x178(%rsp), %r12
movq %r12, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
callq 0xdeef
movq %r12, (%rsp)
movq %r12, %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0xdeef
movq %r15, %rdi
movl $0x1, %esi
callq 0xdfa8
movq %rax, 0xb0(%rsp,%r13,8)
incq %r13
cmpq $0x6, %r13
jne 0xe51e
movq 0xb0(%rsp), %r13
movq %r13, %rdi
movq 0x50(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
xorl %ebp, %ebp
movq %r13, %rdi
movq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r13, %rdi
movq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq 0xb8(%rsp), %r13
movq %r13, %rdi
movq 0x38(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r13, %rdi
movq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq %r13, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
movl $0x1, %edx
callq 0xe00b
movq %r13, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq 0xc0(%rsp), %r13
movq %r13, %rdi
movq 0xa0(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0xe00b
movq %r13, %rdi
movq 0x70(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xe00b
movq 0xc8(%rsp), %r14
movq %r14, %rdi
movq 0x98(%rsp), %r13
movq %r13, %rsi
movl $0x1, %edx
callq 0xe00b
movq %r14, %rdi
movq 0x60(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r14, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r14, %rdi
movq (%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq 0xd0(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0xe00b
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xe00b
movq %r14, %rdi
movq 0x50(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r14, %rdi
movq 0x38(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq 0xd8(%rsp), %r14
movq %r14, %rdi
movq 0x70(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r14, %rdi
movq 0x60(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movl $0x1, %edx
callq 0xe00b
movq %r14, %rdi
movq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0xe00b
movq %r15, %rdi
xorl %esi, %esi
callq 0xe159
movq %rax, %r14
movq 0xb0(%rsp,%rbp,8), %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xe099
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xe099
incq %rbp
cmpq $0x6, %rbp
jne 0xe70e
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%r14)
movq %r14, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq