// File: /workspace/github_c_makefile_star2_O2/AlexCharlton[P]Hyperscene/src/aabb-tree.c
// Function: updateExtents
static void updateExtents(AABBtree *tree){
    HPSvector *nodes = &tree->nodes;
    int nCurrentNodes = nodes->size;
    Point max = {-INFINITY, -INFINITY, -INFINITY};
    Point min = {INFINITY, INFINITY, INFINITY};
    int i;
    for (i = 0; i < nCurrentNodes; i++){
	Node *node = nodes->data[i];
	BoundingSphere *bs = node->boundingSphere;
	max.x = fmax(max.x, bs->x + bs->r);
	max.y = fmax(max.y, bs->y + bs->r);
	max.z = fmax(max.z, bs->z + bs->r);
	min.x = fmin(min.x, bs->x - bs->r);
	min.y = fmin(min.y, bs->y - bs->r);
	min.z = fmin(min.z, bs->z - bs->r);
    }
    for (i = 0; i < 27; i++){
	AABBtree *child = tree->children[i];
	if (child){
	    if (!child->extentsCorrect)
		updateExtents(child);
	    max.x = fmax(max.x, child->max.x);
	    max.y = fmax(max.y, child->max.y);
	    max.z = fmax(max.z, child->max.z);
	    min.x = fmin(min.x, child->min.x);
	    min.y = fmin(min.y, child->min.y);
	    min.z = fmin(min.z, child->min.z);
	}
    }
    tree->max = max;
    tree->min = min;
    setSplitLocation(tree);
    tree->extentsCorrect = true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movl 0x120(%rdi), %r14d
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
movaps 0x2652(%rip), %xmm3     # 0xa0c0
movaps 0x265b(%rip), %xmm2     # 0xa0d0
movss 0x2637(%rip), %xmm0     # 0xa0b4
movss %xmm0, 0x8(%rsp)
movss 0x262d(%rip), %xmm0     # 0xa0b8
cmpq %r15, %r14
je 0x7b62
movq 0x118(%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %r12
movss 0xc(%r12), %xmm1
movaps %xmm1, 0x40(%rsp)
movss 0x8(%r12), %xmm4
movss %xmm4, 0x3c(%rsp)
addss %xmm4, %xmm1
movss %xmm0, 0xc(%rsp)
movss 0x8(%rsp), %xmm0
movaps %xmm2, 0x20(%rsp)
movaps %xmm3, 0x10(%rsp)
callq 0x4250
movss %xmm0, 0x8(%rsp)
movsd (%r12), %xmm0
movaps 0x40(%rsp), %xmm5
movaps %xmm5, %xmm1
shufps $0x0, %xmm5, %xmm1      # xmm1 = xmm1[0,0],xmm5[0,0]
movaps %xmm0, %xmm2
addps %xmm1, %xmm2
movaps 0x10(%rsp), %xmm6
movaps %xmm6, %xmm4
cmpunordps %xmm6, %xmm4
movaps %xmm2, %xmm3
andps %xmm4, %xmm3
maxps %xmm6, %xmm2
andnps %xmm2, %xmm4
orps %xmm3, %xmm4
movaps %xmm4, 0x10(%rsp)
subps %xmm1, %xmm0
movaps 0x20(%rsp), %xmm2
movaps %xmm2, %xmm3
cmpunordps %xmm2, %xmm3
movaps %xmm0, %xmm1
andps %xmm3, %xmm1
minps %xmm2, %xmm0
andnps %xmm0, %xmm3
orps %xmm1, %xmm3
movaps %xmm3, 0x20(%rsp)
movss 0x3c(%rsp), %xmm1
subss %xmm5, %xmm1
movss 0xc(%rsp), %xmm0
callq 0x41e0
incq %r15
movaps 0x20(%rsp), %xmm2
movaps 0x10(%rsp), %xmm3
jmp 0x7a8b
pushq $0x1
popq %r15
cmpq $0x1c, %r15
je 0x7c31
movq (%rbx,%r15,8), %r14
testq %r14, %r14
je 0x7c29
movaps %xmm2, 0x20(%rsp)
movss %xmm0, 0xc(%rsp)
cmpb $0x0, 0x110(%r14)
jne 0x7ba4
movq %r14, %rdi
movaps %xmm3, 0x10(%rsp)
callq 0x7a48
movaps 0x10(%rsp), %xmm3
movsd 0x104(%r14), %xmm0
movaps %xmm3, %xmm2
cmpunordps %xmm3, %xmm2
movaps %xmm0, %xmm1
andps %xmm2, %xmm1
maxps %xmm3, %xmm0
andnps %xmm0, %xmm2
orps %xmm1, %xmm2
movaps %xmm2, 0x10(%rsp)
movss 0x10c(%r14), %xmm1
movss 0x8(%rsp), %xmm0
callq 0x4250
movss %xmm0, 0x8(%rsp)
movsd 0xf8(%r14), %xmm0
movaps 0x20(%rsp), %xmm2
movaps %xmm2, %xmm3
cmpunordps %xmm2, %xmm3
movaps %xmm0, %xmm1
andps %xmm3, %xmm1
minps %xmm2, %xmm0
andnps %xmm0, %xmm3
orps %xmm1, %xmm3
movaps %xmm3, 0x20(%rsp)
movss 0x100(%r14), %xmm1
movss 0xc(%rsp), %xmm0
callq 0x41e0
movaps 0x20(%rsp), %xmm2
movaps 0x10(%rsp), %xmm3
incq %r15
jmp 0x7b66
movlps %xmm3, 0x104(%rbx)
movss 0x8(%rsp), %xmm1
movss %xmm1, 0x10c(%rbx)
movlps %xmm2, 0xf8(%rbx)
movss %xmm0, 0x100(%rbx)
movq %rbx, %rdi
callq 0x7c70
movb $0x1, 0x110(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq