// File: /workspace/github_cpp_makefile_star2_O3/IsaacLaw12[P]RayTracer/./src/OctTree.cpp
// Function: OctTree::subdivide_box()
void OctTree::subdivide_box(){
    // Binary divide the current cube into 8 smaller cubes
    Eigen::Vector3d transform;
    Eigen::Vector3d cube_center = (max_corner - min_corner) * .5 + min_corner;
    Eigen::Vector3d temp_min;
    Eigen::Vector3d temp_max;
    if (contained_faces.size()>10 && recursion_limit>0){
        double half_x = (max_corner(0) - min_corner(0)) / 2.0;
        double half_y = (max_corner(1) - min_corner(1)) / 2.0;
        double half_z = (max_corner(2) - min_corner(2)) / 2.0;
        for (int x=0; x<2; x++){
            for (int y=0; y<2; y++){
                for (int z=0; z<2; z++){
                    transform << x*half_x, y*half_y, z*half_z;
                    temp_min = min_corner + transform;
                    temp_max = cube_center + transform;
                    contained_boxes.push_back(std::make_unique<OctTree>(this, recursion_limit, temp_min, temp_max));
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
cmpq $0xb, 0x80(%rdi)
jb 0x14ae1
movq %rdi, %rbx
cmpl $0x0, 0xa0(%rdi)
jle 0x14ae1
movupd 0x18(%rbx), %xmm1
movupd (%rbx), %xmm0
subpd %xmm0, %xmm1
movapd 0x40b4(%rip), %xmm2     # 0x18950
mulpd %xmm1, %xmm2
movsd 0x28(%rbx), %xmm3
movsd 0x10(%rbx), %xmm4
subsd %xmm4, %xmm3
mulsd 0x403a(%rip), %xmm3     # 0x188f0
addpd %xmm0, %xmm2
movapd %xmm2, 0xe0(%rsp)
movsd %xmm3, 0x58(%rsp)
addsd %xmm3, %xmm4
movsd %xmm4, 0x50(%rsp)
movsd 0x4015(%rip), %xmm0     # 0x188f0
movapd %xmm1, %xmm2
mulsd %xmm0, %xmm2
movapd %xmm2, 0xc0(%rsp)
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
mulsd %xmm0, %xmm1
movapd %xmm1, 0xd0(%rsp)
leaq 0x40(%rbx), %rax
movq %rax, 0x48(%rsp)
xorpd %xmm0, %xmm0
movb $0x1, %al
leaq 0x10(%rsp), %r15
leaq 0xa0(%rsp), %r12
movq %rsp, %r13
movl %eax, 0x8(%rsp)
mulsd 0xc0(%rsp), %xmm0
movb $0x1, %al
xorpd %xmm1, %xmm1
movsd %xmm0, 0x60(%rsp)
movl %eax, 0xc(%rsp)
mulsd 0xd0(%rsp), %xmm1
xorpd %xmm2, %xmm2
movb $0x1, %r14b
movsd %xmm1, 0x68(%rsp)
movsd %xmm2, 0x30(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movl $0x1, %eax
movq %rax, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movsd %xmm0, 0x80(%rsp)
movsd %xmm1, 0xa0(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x5b22
movsd 0x30(%rsp), %xmm0
mulsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x5b22
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x14b37
cmpq $0x1, 0x20(%rsp)
jne 0x14b37
movupd (%rbx), %xmm1
movapd 0x80(%rsp), %xmm0
addpd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movsd 0x90(%rsp), %xmm1
movsd 0x10(%rbx), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x78(%rsp)
addpd 0xe0(%rsp), %xmm0
movapd %xmm0, 0xf0(%rsp)
addsd 0x50(%rsp), %xmm1
movsd %xmm1, 0x70(%rsp)
movl $0xa8, %edi
callq 0x32c0
movq %rax, %rbp
movl 0xa0(%rbx), %edx
movaps 0x30(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movaps 0xf0(%rsp), %xmm0
movaps %xmm0, 0xa0(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rcx
movq %r12, %r8
callq 0x14b56
movq %rbp, (%rsp)
movq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x158f0
movq %r13, %rdi
callq 0x1551e
movsd 0x1596(%rip), %xmm2     # 0x16030
testb $0x1, %r14b
movl $0x0, %r14d
movsd 0x60(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
jne 0x1494f
movsd 0x1572(%rip), %xmm1     # 0x16030
testb $0x1, 0xc(%rsp)
movl $0x0, %eax
jne 0x14935
movsd 0x155a(%rip), %xmm0     # 0x16030
testb $0x1, 0x8(%rsp)
jne 0x1491c
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x1551e
jmp 0x14b2f
movq %rax, %rbx
movl $0xa8, %esi
movq %rbp, %rdi
callq 0x32d0
jmp 0x14b2f
jmp 0x14b14
movq %rax, %rbx
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x14b37
cmpq $0x1, 0x20(%rsp)
jne 0x14b37
movq %rbx, %rdi
callq 0x34b0
leaq 0x1e0a(%rip), %rdi      # 0x16948
leaq 0x1ea1(%rip), %rsi      # 0x169e6
leaq 0x1ec4(%rip), %rcx      # 0x16a10
movl $0x78, %edx
callq 0x31a0