// File: /workspace/github_c_makefile_star2_O0/AlexCharlton[P]Hyperscene/src/aabb-tree.c
// Function: whichBranch
static AABBtree *whichBranch(AABBtree *tree, BoundingSphere *bs){
    float radius = bs->r;
    float ov = radius * radius * radius;
    float bv = (tree->max.x - tree->min.x) *
	(tree->max.y - tree->min.y) * (tree->max.z - tree->min.z);
    if (!tree->split ||
	(tree->extentsCorrect && (ov > bv/8) &&
	 (tree->nodes.size != tree->nodes.capacity)))
	return tree;
    int x = 0, y =0, z = 0;
    if (tree->split & SPLIT_X){
	if (bs->x + radius < tree->splitPoint.x)
	    x = 0;
	else if (bs->x - radius > tree->splitPoint.x)
	    x = 2;
	else x = 1;
    }
    if (tree->split & SPLIT_Y){
	if (bs->y + radius < tree->splitPoint.y)
	    y = 0;
	else if (bs->y - radius > tree->splitPoint.y)
	    y = 2;
	else y = 1;
    }
    if (tree->split & SPLIT_Z){
	if (bs->z + radius < tree->splitPoint.z)
	    z = 0;
	else if (bs->z - radius > tree->splitPoint.z)
	    z = 2;
	else z = 1;
    }
    int i = x + y*3 + z*9;
    if (tree->children[i])
	return tree->children[i];
    else
	return tree->children[i] = newTree(tree->pool, tree);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x1c(%rbp), %xmm0
mulss -0x1c(%rbp), %xmm0
mulss -0x1c(%rbp), %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movss 0x104(%rax), %xmm0
movq -0x10(%rbp), %rax
subss 0xf8(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x108(%rax), %xmm1
movq -0x10(%rbp), %rax
subss 0xfc(%rax), %xmm1
mulss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movss 0x10c(%rax), %xmm1
movq -0x10(%rbp), %rax
subss 0x100(%rax), %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpw $0x0, 0xe8(%rax)
je 0x9c05
movq -0x10(%rbp), %rax
testb $0x1, 0x110(%rax)
je 0x9c12
movss -0x20(%rbp), %xmm0
movss -0x24(%rbp), %xmm1
movss 0x5494(%rip), %xmm2     # 0xf078
divss %xmm2, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x9c12
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x128(%rcx), %rax
je 0x9c12
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9dbd
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movzwl 0xe8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x9c8f
movq -0x18(%rbp), %rax
movss (%rax), %xmm1
addss -0x1c(%rbp), %xmm1
movq -0x10(%rbp), %rax
movss 0xec(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x9c61
movl $0x0, -0x28(%rbp)
jmp 0x9c8d
movq -0x18(%rbp), %rax
movss (%rax), %xmm0
subss -0x1c(%rbp), %xmm0
movq -0x10(%rbp), %rax
ucomiss 0xec(%rax), %xmm0
jbe 0x9c84
movl $0x2, -0x28(%rbp)
jmp 0x9c8b
movl $0x1, -0x28(%rbp)
jmp 0x9c8d
jmp 0x9c8f
movq -0x10(%rbp), %rax
movzwl 0xe8(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x9cf9
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm1
addss -0x1c(%rbp), %xmm1
movq -0x10(%rbp), %rax
movss 0xf0(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x9cca
movl $0x0, -0x2c(%rbp)
jmp 0x9cf7
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
subss -0x1c(%rbp), %xmm0
movq -0x10(%rbp), %rax
ucomiss 0xf0(%rax), %xmm0
jbe 0x9cee
movl $0x2, -0x2c(%rbp)
jmp 0x9cf5
movl $0x1, -0x2c(%rbp)
jmp 0x9cf7
jmp 0x9cf9
movq -0x10(%rbp), %rax
movzwl 0xe8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x9d63
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm1
addss -0x1c(%rbp), %xmm1
movq -0x10(%rbp), %rax
movss 0xf4(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x9d34
movl $0x0, -0x30(%rbp)
jmp 0x9d61
movq -0x18(%rbp), %rax
movss 0x8(%rax), %xmm0
subss -0x1c(%rbp), %xmm0
movq -0x10(%rbp), %rax
ucomiss 0xf4(%rax), %xmm0
jbe 0x9d58
movl $0x2, -0x30(%rbp)
jmp 0x9d5f
movl $0x1, -0x30(%rbp)
jmp 0x9d61
jmp 0x9d63
movl -0x28(%rbp), %eax
imull $0x3, -0x2c(%rbp), %ecx
addl %ecx, %eax
imull $0x9, -0x30(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpq $0x0, 0x8(%rax,%rcx,8)
je 0x9d98
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x9dbd
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x9a30
movq -0x10(%rbp), %rcx
movslq -0x34(%rbp), %rdx
movq %rax, 0x8(%rcx,%rdx,8)
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)