// File: /workspace/github_cpp_makefile_star2_O1/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 0x14b12
movq %rdi, %rbx
cmpl $0x0, 0xa0(%rdi)
jle 0x14b12
movupd 0x18(%rbx), %xmm1
movupd (%rbx), %xmm0
subpd %xmm0, %xmm1
mulpd 0x407e(%rip), %xmm1     # 0x18950
addpd %xmm0, %xmm1
movapd %xmm1, 0xd0(%rsp)
movsd 0x28(%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
subsd %xmm1, %xmm0
mulsd 0x3ffb(%rip), %xmm0     # 0x188f0
movsd %xmm0, 0x68(%rsp)
addsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rsp)
movsd 0x18(%rbx), %xmm1
movsd 0x20(%rbx), %xmm2
subsd (%rbx), %xmm1
movsd 0x3fd5(%rip), %xmm0     # 0x188f0
mulsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
subsd 0x8(%rbx), %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, 0x48(%rsp)
leaq 0x40(%rbx), %rax
movq %rax, 0x58(%rsp)
xorl %eax, %eax
leaq 0x10(%rsp), %r15
leaq 0xb0(%rsp), %r12
leaq 0x8(%rsp), %r13
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
xorl %eax, %eax
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
xorl %r14d, %r14d
leaq 0x90(%rsp), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movl $0x1, %eax
movq %rax, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x5b26
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd 0x68(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x5b26
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x14b6a
cmpq $0x1, 0x20(%rsp)
jne 0x14b6a
movupd (%rbx), %xmm1
movapd 0x90(%rsp), %xmm0
addpd %xmm0, %xmm1
movapd %xmm1, 0xf0(%rsp)
movsd 0xa0(%rsp), %xmm1
movsd 0x10(%rbx), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, 0x88(%rsp)
addpd 0xd0(%rsp), %xmm0
movapd %xmm0, 0xe0(%rsp)
addsd 0x60(%rsp), %xmm1
movsd %xmm1, 0x80(%rsp)
movl $0xa8, %edi
callq 0x32c0
movq %rax, %rbp
movl 0xa0(%rbx), %edx
movaps 0xf0(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movsd 0x88(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movaps 0xe0(%rsp), %xmm0
movaps %xmm0, 0xb0(%rsp)
movsd 0x80(%rsp), %xmm0
movsd %xmm0, 0xc0(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rcx
movq %r12, %r8
callq 0x14b8a
movq %rbp, 0x8(%rsp)
movq 0x58(%rsp), %rdi
movq %r13, %rsi
callq 0x15928
movq %r13, %rdi
callq 0x15552
incl %r14d
cmpl $0x1, %r14d
je 0x14986
movq 0x50(%rsp), %rcx
leal 0x1(%rcx), %eax
testl %ecx, %ecx
je 0x1496b
movq 0x40(%rsp), %rcx
leal 0x1(%rcx), %eax
testl %ecx, %ecx
je 0x14951
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x15552
jmp 0x14b62
movq %rax, %rbx
movl $0xa8, %esi
movq %rbp, %rdi
callq 0x32d0
jmp 0x14b62
jmp 0x14b47
movq %rax, %rbx
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x14b6a
cmpq $0x1, 0x20(%rsp)
jne 0x14b6a
movq %rbx, %rdi
callq 0x34b0
leaq 0x1dd7(%rip), %rdi      # 0x16948
leaq 0x1e6e(%rip), %rsi      # 0x169e6
leaq 0x1e91(%rip), %rcx      # 0x16a10
movl $0x78, %edx
callq 0x31a0
nop