// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x60, %rsp
movq %rdi, %rbx
movq 0x120(%rdi), %rax
testl %eax, %eax
jle 0x8951
movq 0x118(%rbx), %rcx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movss 0x2894(%rip), %xmm2     # 0xb0b4
movss 0x2888(%rip), %xmm4     # 0xb0b0
xorl %edx, %edx
movaps %xmm4, %xmm7
movaps %xmm4, %xmm5
movaps %xmm2, %xmm1
movaps %xmm2, %xmm0
movaps %xmm4, %xmm15
movaps %xmm4, %xmm14
movaps %xmm4, %xmm13
movaps %xmm2, %xmm12
movaps %xmm2, %xmm11
movaps %xmm2, %xmm10
movq (%rcx,%rdx,8), %rsi
movq (%rsi), %rsi
movss 0xc(%rsi), %xmm3
movss (%rsi), %xmm6
movaps %xmm6, %xmm8
addss %xmm3, %xmm8
cmpunordss %xmm15, %xmm15
movaps %xmm15, %xmm9
andps %xmm8, %xmm9
maxss %xmm5, %xmm8
movss 0x4(%rsi), %xmm5
andnps %xmm8, %xmm15
orps %xmm9, %xmm15
movaps %xmm3, %xmm8
addss %xmm5, %xmm8
cmpunordss %xmm14, %xmm14
movaps %xmm14, %xmm9
andps %xmm8, %xmm9
maxss %xmm7, %xmm8
andnps %xmm8, %xmm14
orps %xmm9, %xmm14
movss 0x8(%rsi), %xmm7
movaps %xmm3, %xmm8
addss %xmm7, %xmm8
cmpunordss %xmm13, %xmm13
movaps %xmm13, %xmm9
andps %xmm8, %xmm9
maxss %xmm4, %xmm8
andnps %xmm8, %xmm13
orps %xmm9, %xmm13
subss %xmm3, %xmm6
cmpunordss %xmm12, %xmm12
movaps %xmm12, %xmm4
andps %xmm6, %xmm4
minss %xmm2, %xmm6
andnps %xmm6, %xmm12
orps %xmm4, %xmm12
subss %xmm3, %xmm5
cmpunordss %xmm11, %xmm11
movaps %xmm11, %xmm2
andps %xmm5, %xmm2
minss %xmm1, %xmm5
andnps %xmm5, %xmm11
orps %xmm2, %xmm11
subss %xmm3, %xmm7
cmpunordss %xmm10, %xmm10
movaps %xmm10, %xmm1
andps %xmm7, %xmm1
minss %xmm0, %xmm7
andnps %xmm7, %xmm10
orps %xmm1, %xmm10
incq %rdx
movaps %xmm13, %xmm4
movaps %xmm14, %xmm7
movaps %xmm15, %xmm5
movaps %xmm12, %xmm2
movaps %xmm11, %xmm1
movaps %xmm10, %xmm0
cmpq %rdx, %rax
jne 0x884e
jmp 0x8973
movss 0x2756(%rip), %xmm15    # 0xb0b0
movss 0x2751(%rip), %xmm10    # 0xb0b4
movaps %xmm10, %xmm11
movaps %xmm10, %xmm12
movaps %xmm15, %xmm14
movaps %xmm15, %xmm13
movl $0x1, %r15d
movq (%rbx,%r15,8), %r14
testq %r14, %r14
je 0x8ace
cmpb $0x0, 0x110(%r14)
jne 0x89de
movq %r14, %rdi
movaps %xmm10, 0x50(%rsp)
movaps %xmm11, 0x40(%rsp)
movaps %xmm12, 0x30(%rsp)
movaps %xmm13, 0x20(%rsp)
movaps %xmm14, 0x10(%rsp)
movaps %xmm15, (%rsp)
callq 0x87f1
movaps (%rsp), %xmm15
movaps 0x10(%rsp), %xmm14
movaps 0x20(%rsp), %xmm13
movaps 0x30(%rsp), %xmm12
movaps 0x40(%rsp), %xmm11
movaps 0x50(%rsp), %xmm10
movss 0x104(%r14), %xmm1
movaps %xmm15, %xmm0
cmpunordss %xmm15, %xmm0
movaps %xmm0, %xmm2
andps %xmm1, %xmm2
maxss %xmm15, %xmm1
andnps %xmm1, %xmm0
orps %xmm2, %xmm0
movss 0x108(%r14), %xmm2
movaps %xmm14, %xmm1
cmpunordss %xmm14, %xmm1
movaps %xmm1, %xmm3
andps %xmm2, %xmm3
maxss %xmm14, %xmm2
andnps %xmm2, %xmm1
orps %xmm3, %xmm1
movss 0x10c(%r14), %xmm3
movaps %xmm13, %xmm2
cmpunordss %xmm13, %xmm2
movaps %xmm2, %xmm4
andps %xmm3, %xmm4
maxss %xmm13, %xmm3
andnps %xmm3, %xmm2
orps %xmm4, %xmm2
movss 0xf8(%r14), %xmm4
movss 0xfc(%r14), %xmm5
movaps %xmm12, %xmm3
cmpunordss %xmm12, %xmm3
movaps %xmm3, %xmm6
andps %xmm4, %xmm6
minss %xmm12, %xmm4
andnps %xmm4, %xmm3
orps %xmm6, %xmm3
movaps %xmm11, %xmm4
cmpunordss %xmm11, %xmm4
movaps %xmm4, %xmm6
andps %xmm5, %xmm6
minss %xmm11, %xmm5
andnps %xmm5, %xmm4
orps %xmm6, %xmm4
movss 0x100(%r14), %xmm5
movaps %xmm10, %xmm6
cmpunordss %xmm10, %xmm6
movaps %xmm6, %xmm7
andps %xmm5, %xmm7
minss %xmm10, %xmm5
andnps %xmm5, %xmm6
orps %xmm7, %xmm6
movaps %xmm6, %xmm10
movaps %xmm4, %xmm11
movaps %xmm3, %xmm12
movaps %xmm0, %xmm15
movaps %xmm1, %xmm14
movaps %xmm2, %xmm13
incq %r15
cmpq $0x1c, %r15
jne 0x8979
movss %xmm15, 0x104(%rbx)
movss %xmm14, 0x108(%rbx)
movss %xmm13, 0x10c(%rbx)
movss %xmm12, 0xf8(%rbx)
movss %xmm11, 0xfc(%rbx)
movss %xmm10, 0x100(%rbx)
movq %rbx, %rdi
callq 0x8b2a
movb $0x1, 0x110(%rbx)
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq