// File: /workspace/github_cpp_makefile_star2_O2/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 $0x128, %rsp            # imm = 0x128
movq %rdi, %rbx
leaq 0x18(%rdi), %rax
leaq 0xa8(%rsp), %rsi
movq %rax, (%rsi)
movq %rdi, 0x8(%rsi)
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
callq 0x1726e
movups 0x8(%r14), %xmm0
leaq 0x58(%rsp), %rsi
movups %xmm0, 0x10(%rsi)
movsd 0x28(%r14), %xmm0
movsd %xmm0, 0x30(%rsi)
movq %rbx, 0x40(%rsi)
leaq 0xc0(%rsp), %rdi
callq 0x17854
cmpq $0xb, 0x80(%rbx)
jb 0x1687e
cmpl $0x0, 0xa0(%rbx)
jle 0x1687e
leaq 0xa0(%rbx), %rax
movq %rax, 0x30(%rsp)
movsd 0x18(%rbx), %xmm1
movsd 0x20(%rbx), %xmm2
subsd (%rbx), %xmm1
movsd 0x575c(%rip), %xmm0     # 0x1be58
mulsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
subsd 0x8(%rbx), %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, 0x20(%rsp)
movsd 0x28(%rbx), %xmm1
subsd 0x10(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x38(%rsp)
leaq 0x40(%rbx), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
leaq 0xd8(%rsp), %r12
leaq 0x58(%rsp), %r13
leaq 0xf0(%rsp), %r14
leaq 0xa8(%rsp), %r15
cmpl $0x2, %eax
je 0x1687e
cvtsi2sd %eax, %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
xorl %ecx, %ecx
movl %eax, 0x10(%rsp)
cmpl $0x2, %ecx
je 0x16877
movl %ecx, 0x14(%rsp)
cvtsi2sd %ecx, %xmm0
mulsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
xorl %ebp, %ebp
cmpl $0x2, %ebp
je 0x16868
movq %r12, 0x58(%rsp)
andq $0x0, 0x60(%rsp)
pushq $0x1
popq %rax
movq %rax, 0x68(%rsp)
movq %rax, 0x70(%rsp)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0x6232
cvtsi2sd %ebp, %xmm0
mulsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movq %rax, %rdi
leaq 0x50(%rsp), %rsi
callq 0x6232
movq %r13, %rdi
callq 0x62da
movq %rbx, 0x58(%rsp)
movq %r12, 0x60(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0xc8b9
leaq 0xc0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %r12, 0x60(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0xc8b9
movq %rbx, 0x8(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r14, %rcx
movq %r15, %r8
callq 0x172be
movq 0x28(%rsp), %rdi
movq %r13, %rsi
callq 0x179b8
movq %r13, %rdi
callq 0xa32e
incl %ebp
jmp 0x1678f
movl 0x14(%rsp), %ecx
incl %ecx
movl 0x10(%rsp), %eax
jmp 0x16770
incl %eax
jmp 0x16751
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16892
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x62da
jmp 0x168ae
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0xa32e
movq %rbx, %rdi
callq 0x3490