// File: /workspace/github_c_makefile_star2_O3/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 $0x40, %rsp
movq %rdi, %rbx
movq 0x120(%rdi), %rax
testl %eax, %eax
jle 0x8295
movq 0x118(%rbx), %rcx
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movaps 0x2f1f(%rip), %xmm2     # 0xb0e0
movaps 0x2f28(%rip), %xmm1     # 0xb0f0
movss 0x2f04(%rip), %xmm0     # 0xb0d4
movss 0x2ef8(%rip), %xmm5     # 0xb0d0
xorl %edx, %edx
movaps %xmm5, %xmm10
movaps %xmm2, %xmm11
movaps %xmm1, %xmm9
movaps %xmm0, %xmm8
movq (%rcx,%rdx,8), %rsi
movq (%rsi), %rsi
movss 0xc(%rsi), %xmm4
movss 0x8(%rsi), %xmm3
movaps %xmm4, %xmm6
addss %xmm3, %xmm6
cmpunordss %xmm10, %xmm10
movaps %xmm10, %xmm7
andps %xmm6, %xmm7
maxss %xmm5, %xmm6
andnps %xmm6, %xmm10
orps %xmm7, %xmm10
movsd (%rsi), %xmm5
subss %xmm4, %xmm3
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
movaps %xmm5, %xmm6
addps %xmm4, %xmm6
cmpunordps %xmm11, %xmm11
movaps %xmm6, %xmm7
andps %xmm11, %xmm7
maxps %xmm2, %xmm6
andnps %xmm6, %xmm11
orps %xmm7, %xmm11
subps %xmm4, %xmm5
cmpunordps %xmm9, %xmm9
movaps %xmm5, %xmm2
andps %xmm9, %xmm2
minps %xmm1, %xmm5
andnps %xmm5, %xmm9
orps %xmm2, %xmm9
cmpunordss %xmm8, %xmm8
movaps %xmm8, %xmm1
andps %xmm3, %xmm1
minss %xmm0, %xmm3
andnps %xmm3, %xmm8
orps %xmm1, %xmm8
incq %rdx
movaps %xmm10, %xmm5
movaps %xmm8, %xmm0
movaps %xmm9, %xmm1
movaps %xmm11, %xmm2
cmpq %rdx, %rax
jne 0x81ea
jmp 0x82b7
movaps 0x2e43(%rip), %xmm11    # 0xb0e0
movaps 0x2e4b(%rip), %xmm9     # 0xb0f0
movss 0x2e22(%rip), %xmm10    # 0xb0d0
movss 0x2e1d(%rip), %xmm8     # 0xb0d4
movl $0x1, %r15d
movq (%rbx,%r15,8), %r14
testq %r14, %r14
je 0x83a6
cmpb $0x0, 0x110(%r14)
jne 0x830a
movq %r14, %rdi
movaps %xmm8, 0x30(%rsp)
movaps %xmm9, 0x20(%rsp)
movaps %xmm10, 0x10(%rsp)
movaps %xmm11, (%rsp)
callq 0x8193
movaps (%rsp), %xmm11
movaps 0x10(%rsp), %xmm10
movaps 0x20(%rsp), %xmm9
movaps 0x30(%rsp), %xmm8
movsd 0x104(%r14), %xmm1
movaps %xmm1, %xmm2
maxps %xmm11, %xmm1
movaps %xmm11, %xmm0
cmpunordps %xmm11, %xmm0
andps %xmm0, %xmm2
andnps %xmm1, %xmm0
orps %xmm2, %xmm0
movss 0x10c(%r14), %xmm2
movaps %xmm10, %xmm1
cmpunordss %xmm10, %xmm1
movaps %xmm1, %xmm3
andps %xmm2, %xmm3
maxss %xmm10, %xmm2
andnps %xmm2, %xmm1
orps %xmm3, %xmm1
movsd 0xf8(%r14), %xmm2
movaps %xmm2, %xmm3
minps %xmm9, %xmm2
movaps %xmm9, %xmm4
cmpunordps %xmm9, %xmm4
andps %xmm4, %xmm3
andnps %xmm2, %xmm4
orps %xmm3, %xmm4
movss 0x100(%r14), %xmm2
movaps %xmm8, %xmm3
cmpunordss %xmm8, %xmm3
movaps %xmm3, %xmm5
andps %xmm2, %xmm5
minss %xmm8, %xmm2
andnps %xmm2, %xmm3
orps %xmm5, %xmm3
movaps %xmm3, %xmm8
movaps %xmm1, %xmm10
movaps %xmm4, %xmm9
movaps %xmm0, %xmm11
incq %r15
cmpq $0x1c, %r15
jne 0x82bd
movlps %xmm11, 0x104(%rbx)
movss %xmm10, 0x10c(%rbx)
movlps %xmm9, 0xf8(%rbx)
movss %xmm8, 0x100(%rbx)
movq %rbx, %rdi
callq 0x83ee
movb $0x1, 0x110(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq