// File: /workspace/github_cpp_makefile_star2_O2/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 $0x198, %rsp            # imm = 0x198
movq %rdx, %rbx
movq %rsi, 0xb8(%rsp)
movq %rdi, %r15
movdqa 0x1197d(%rip), %xmm1    # 0x1e200
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
pushq $0x1
popq %rbp
cmpq $0x8, %r14
je 0xc914
movq %r15, %rdi
movl %ebp, %esi
callq 0xc53f
movq %rax, 0xf0(%rsp,%r14,8)
movd %r14d, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pand 0x11ad8(%rip), %xmm0    # 0x1e3b0
pcmpeqd 0x11ae0(%rip), %xmm0    # 0x1e3c0
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 0xc90a
movdqa 0x40(%rsp), %xmm0
movq %xmm0, 0x10(%rax)
incq %r14
jmp 0xc8ae
xorl %r14d, %r14d
pushq $0x1
popq %rbp
cmpq $0xc, %r14
je 0xc937
movq %r15, %rdi
movl %ebp, %esi
callq 0xc58a
movq %rax, 0x130(%rsp,%r14,8)
incq %r14
jmp 0xc91a
movq 0x130(%rsp), %rdi
movq 0xf0(%rsp), %rdx
movq %rdx, 0x18(%rsp)
movq 0xf8(%rsp), %rsi
movq %rsi, 0x10(%rsp)
movq %rdi, 0x50(%rsp)
callq 0xc669
movq 0x138(%rsp), %rdi
movq 0x100(%rsp), %rbp
movq 0x108(%rsp), %r12
movq %rdi, 0xb0(%rsp)
movq %r12, %rsi
movq %r12, 0xa8(%rsp)
movq %rbp, %rdx
movq %rbp, 0x8(%rsp)
callq 0xc669
movq 0x140(%rsp), %rdi
movq 0x110(%rsp), %rdx
movq %rdx, 0x98(%rsp)
movq 0x118(%rsp), %rsi
movq %rsi, 0xa0(%rsp)
movq %rdi, 0x70(%rsp)
callq 0xc669
movq 0x148(%rsp), %rdi
movq 0x120(%rsp), %r13
movq 0x128(%rsp), %r14
movq %rdi, 0x60(%rsp)
movq %r14, %rsi
movq %r14, 0x90(%rsp)
movq %r13, %rdx
movq %r13, 0x88(%rsp)
callq 0xc669
movq 0x150(%rsp), %rdi
movq %rdi, 0x30(%rsp)
movq %rbp, %rsi
movq 0x18(%rsp), %rbp
movq %rbp, %rdx
callq 0xc669
movq 0x158(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movq %r12, %rsi
movq 0x10(%rsp), %r12
movq %r12, %rdx
callq 0xc669
movq 0x160(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movq %r13, %rsi
movq 0x98(%rsp), %r13
movq %r13, %rdx
callq 0xc669
movq 0x168(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movq %r14, %rsi
movq 0xa0(%rsp), %r14
movq %r14, %rdx
callq 0xc669
movq 0x170(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movq %r13, %rsi
movq %rbp, %rdx
callq 0xc669
movq 0x178(%rsp), %rdi
movq %rdi, 0x18(%rsp)
movq %r14, %rsi
movq %r12, %rdx
callq 0xc669
movq 0x180(%rsp), %rdi
movq %rdi, 0x10(%rsp)
movq 0x88(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0xc669
movq 0x188(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq 0x90(%rsp), %rsi
movq 0xa8(%rsp), %rdx
callq 0xc669
xorl %r12d, %r12d
pushq $0x1
popq %r14
cmpq $0x6, %r12
je 0xcb15
movq %r15, %rdi
movl %r14d, %esi
callq 0xc68f
movq %rax, 0xc0(%rsp,%r12,8)
incq %r12
jmp 0xcaf7
movq 0xc0(%rsp), %r14
pushq $0x1
popq %r12
movq %r14, %rdi
movq 0x30(%rsp), %rsi
movl %r12d, %edx
callq 0xc6ed
xorl %ebp, %ebp
movq %r14, %rdi
movq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %r12d, %edx
callq 0xc6ed
movq 0xc8(%rsp), %r14
movq %r14, %rdi
movq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x38(%rsp), %rsi
movl %r12d, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x18(%rsp), %r13
movq %r13, %rsi
movl %r12d, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq 0xd0(%rsp), %r14
movq %r14, %rdi
movq 0x50(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x70(%rsp), %rsi
movl %r12d, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x20(%rsp), %rsi
movl %r12d, %edx
callq 0xc6ed
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xc6ed
movq 0xd8(%rsp), %r14
movq %r14, %rdi
movq 0xb0(%rsp), %r12
movq %r12, %rsi
pushq $0x1
popq %rdx
movl %edx, %r13d
callq 0xc6ed
movq %r14, %rdi
movq 0x60(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x8(%rsp), %rsi
movl %r13d, %edx
callq 0xc6ed
movq 0xe0(%rsp), %r14
movq %r14, %rdi
movq 0x50(%rsp), %rsi
movl %r13d, %edx
callq 0xc6ed
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x28(%rsp), %rsi
movl %r13d, %edx
callq 0xc6ed
movq 0xe8(%rsp), %r14
movq %r14, %rdi
movq 0x70(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x60(%rsp), %rsi
movl %r13d, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movl %r13d, %edx
callq 0xc6ed
movq %r14, %rdi
movq 0x38(%rsp), %rsi
xorl %edx, %edx
callq 0xc6ed
movq %r15, %rdi
xorl %esi, %esi
callq 0xc7ff
movq %rax, %r14
cmpq $0x6, %rbp
je 0xccf2
movq 0xc0(%rsp,%rbp,8), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xc7d3
incq %rbp
jmp 0xccd4
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%r14)
movq %r14, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq