// File: /workspace/github_cpp_makefile_star2_O3/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:
movl (%rsi), %eax
testl %eax, %eax
je 0x1803f
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movapd 0x837b(%rip), %xmm4     # 0x202b0
xorpd %xmm5, %xmm5
movsd 0x30(%r15), %xmm0
xorpd %xmm4, %xmm0
leaq 0x20(%r14), %rcx
leaq 0x8(%r14), %rdx
xorl %esi, %esi
movapd %xmm0, %xmm1
movsd (%r15,%rsi,8), %xmm2
ucomisd %xmm5, %xmm2
movq %rdx, %r8
movq %rcx, %rdi
jb 0x17f69
movq %rcx, %r8
movq %rdx, %rdi
movsd (%r8,%rsi,8), %xmm3
mulsd %xmm2, %xmm3
mulsd (%rdi,%rsi,8), %xmm2
addsd %xmm3, %xmm0
addsd %xmm2, %xmm1
incq %rsi
cmpq $0x3, %rsi
jne 0x17f51
movsd 0x8(%rbx), %xmm2
ucomisd %xmm2, %xmm1
ja 0x18018
xorpd %xmm4, %xmm2
ucomisd %xmm0, %xmm2
ja 0x18027
cmpb $0x1, 0x38(%r14)
je 0x18040
movq 0x50(%r14), %rax
movq (%rax), %r12
cmpq 0x8(%rax), %r12
je 0x17fec
movq 0x20(%rbx), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x17fda
movq (%r12), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x17fe2
movq %r12, %rdx
callq 0x19e32
addq $0x8, %r12
movq 0x50(%r14), %rax
jmp 0x17fb8
movq 0x40(%r14), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x17f12
movq 0x48(%r14), %r14
movl (%r14), %eax
testl %eax, %eax
movapd 0x82a4(%rip), %xmm4     # 0x202b0
xorpd %xmm5, %xmm5
jne 0x17f39
jmp 0x18034
addl 0x18(%rbx), %eax
movl %eax, 0x18(%rbx)
subl 0x4(%r14), %eax
movl %eax, 0x18(%rbx)
jmp 0x18034
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 0x18034
movq 0x20(%rbx), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x18068
movq (%r15), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x18070
movq %r15, %rdx
callq 0x19e32
addq $0x8, %r15
movq 0x60(%r14), %rax
jmp 0x18047