// File: /workspace/github_cpp_makefile_star2_O1/Lut99[P]RayTracer/src/lib/ObjectTree.cpp
// Function: RayTracer::ObjectTreeBranch::ObjectTreeBranch(std::vector<RayTracer::RenderObject*, std::allocator<RayTracer::RenderObject*>>)
ObjectTreeBranch::ObjectTreeBranch(const std::vector<RenderObject*> elements)
    : ObjectTreeNode(false, BoundingBox())
{
    // First, construct the nodes by assigning them half each cluster
    std::vector<RenderObject*> left;
    std::vector<RenderObject*> right;
    cluster(elements, left, right);
    
    // Construct leaves instead if only one element is left
    if (left.size() == 1) {
        this->left = (ObjectTreeNode*) new ObjectTreeLeaf(left.at(0));
    } else {
        this->left = (ObjectTreeNode*) new ObjectTreeBranch(left);
    }
    if (right.size() == 1) {
        this->right = (ObjectTreeNode*) new ObjectTreeLeaf(right.at(0));
    } else {
        this->right = (ObjectTreeNode*) new ObjectTreeBranch(right);
    }

    // Update the bounding box to be a merge of those
    this->box.merge(this->left->box);
    this->box.merge(this->right->box);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf0, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xb0(%rsp), %rdi
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
callq 0x729ee
leaq 0xd0(%rsp), %r15
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r15, %rdi
callq 0x729ee
leaq 0x23068(%rip), %r13     # 0xa4ce8
movq %r13, (%rbx)
movb $0x0, 0x8(%rbx)
leaq 0x223f2(%rip), %r12     # 0xa4080
addq $0x10, %r12
movq %r12, 0x10(%rbx)
movups -0x18(%r15), %xmm0
movups %xmm0, 0x18(%rbx)
movq -0x8(%r15), %rax
movq %rax, 0x28(%rbx)
movq %r12, 0x30(%rbx)
movups 0x8(%r15), %xmm0
movups %xmm0, 0x38(%rbx)
movq 0x18(%r15), %rax
movq %rax, 0x48(%rbx)
leaq 0x22f75(%rip), %rax     # 0xa4c38
movq %rax, (%rbx)
xorl %eax, %eax
leaq 0x20(%rsp), %rsi
movq %rax, 0x10(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
movaps %xmm0, (%rdx)
movq %r14, %rdi
callq 0x81544
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %rax
subq %r14, %rax
cmpq $0x8, %rax
jne 0x81d74
movl $0x58, %edi
callq 0x3a460
movq (%r14), %rcx
movups 0x40(%rcx), %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x50(%rcx), %rdx
movq %rdx, 0x70(%rsp)
movups 0x60(%rcx), %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x70(%rcx), %rdx
movq %rdx, 0x50(%rsp)
movq %r13, (%rax)
movb $0x1, 0x8(%rax)
movq %r12, 0x10(%rax)
movaps 0x60(%rsp), %xmm0
movups %xmm0, 0x18(%rax)
movq 0x70(%rsp), %rdx
movq %rdx, 0x28(%rax)
movq %r12, 0x30(%rax)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x38(%rax)
movq 0x50(%rsp), %rdx
movq %rdx, 0x48(%rax)
leaq 0x22f09(%rip), %rdx     # 0xa4c70
movq %rdx, (%rax)
movq %rcx, 0x50(%rax)
movq %rax, 0x50(%rbx)
jmp 0x81dc4
movl $0x60, %edi
callq 0x3a460
movq %rax, %r14
leaq 0x98(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x787dc
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x81c34
movq %r14, 0x50(%rbx)
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x81dc4
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3a470
movq (%rsp), %r14
movq 0x8(%rsp), %rax
subq %r14, %rax
cmpq $0x8, %rax
jne 0x81e4e
movl $0x58, %edi
callq 0x3a460
movq (%r14), %rcx
movups 0x40(%rcx), %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x50(%rcx), %rdx
movq %rdx, 0x70(%rsp)
movups 0x60(%rcx), %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x70(%rcx), %rdx
movq %rdx, 0x50(%rsp)
movq %r13, (%rax)
movb $0x1, 0x8(%rax)
movq %r12, 0x10(%rax)
movaps 0x60(%rsp), %xmm0
movups %xmm0, 0x18(%rax)
movq 0x70(%rsp), %rdx
movq %rdx, 0x28(%rax)
movq %r12, 0x30(%rax)
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x38(%rax)
movq 0x50(%rsp), %rdx
movq %rdx, 0x48(%rax)
leaq 0x22e2f(%rip), %rdx     # 0xa4c70
movq %rdx, (%rax)
movq %rcx, 0x50(%rax)
movq %rax, 0x58(%rbx)
jmp 0x81e9c
movl $0x60, %edi
callq 0x3a460
movq %rax, %r14
leaq 0x80(%rsp), %rdi
movq %rsp, %rsi
callq 0x787dc
leaq 0x80(%rsp), %rsi
movq %r14, %rdi
callq 0x81c34
movq %r14, 0x58(%rbx)
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x81e9c
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3a470
leaq 0x10(%rbx), %r14
movq 0x50(%rbx), %rsi
addq $0x10, %rsi
movq %r14, %rdi
callq 0x81274
movq 0x58(%rbx), %rsi
addq $0x10, %rsi
movq %r14, %rdi
callq 0x81274
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x81ed6
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3a470
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x81eed
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3a470
addq $0xf0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x81f3f
movq 0x90(%rsp), %rsi
jmp 0x81f32
jmp 0x81f3c
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x81f3f
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3a470
jmp 0x81f3f
movq %rax, %rbx
movl $0x60, %esi
movq %r14, %rdi
callq 0x3a470
jmp 0x81f51
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x81f67
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x3a470
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x81f7e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3a470
movq %rbx, %rdi
callq 0x3a780