// File: /workspace/github_cpp_makefile_star2_O3/2TallTim[P]modern-raytracing/raytrace.cpp
// Function: color(ray const&, std::shared_ptr<hitable>, int)
vec3 color(const ray &r, hitable::Ptr world, int depth = 0)
{
    hit_record rec;
    if(world->hit(r, 0.001, MAXFLOAT, rec)){
        ray scattered;
        vec3 attenuation;
        vec3 emitted = rec.mat_ptr->emitted();
        if (depth < 5 && rec.mat_ptr->scatter(r, rec, attenuation, scattered)) {
            return emitted + attenuation * color(scattered, world, depth+1);
        }else{
            return emitted;
        }
    } else {
        vec3 unit_direction = unit_vector(r.direction());
        double t = 0.5 * (unit_direction.y() + 1.0);
        return (1.0 - t) * vec3(1.0, 1.0, 1.0) + t * vec3(0.5, 0.7, 1.0);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xe8, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rdx
movups %xmm0, 0x38(%rdx)
movups %xmm0, 0x28(%rdx)
movups %xmm0, 0x18(%rdx)
movups %xmm0, 0x8(%rdx)
movq (%r14), %rdi
movq (%rdi), %rax
movsd 0x5e9b(%rip), %xmm0     # 0xa110
movsd 0x5e9b(%rip), %xmm1     # 0xa118
callq *(%rax)
testb %al, %al
je 0x4320
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0xd8(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x8(%rax)
cmpl $0x4, %ebp
jg 0x4394
leaq 0xa0(%rsp), %rdx
movq 0x38(%rdx), %rdi
movq (%rdi), %rax
leaq 0x30(%rsp), %rcx
leaq 0x70(%rsp), %r8
movq %r15, %rsi
callq *(%rax)
testb %al, %al
je 0x4394
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x43ce
movq 0x9cb9(%rip), %rcx      # 0xdfc8
cmpb $0x0, (%rcx)
je 0x43ca
incl 0x8(%rax)
jmp 0x43ce
movsd 0x18(%r15), %xmm0
movsd 0x20(%r15), %xmm1
movsd 0x28(%r15), %xmm2
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm3
mulsd %xmm0, %xmm0
addsd %xmm3, %xmm0
mulsd %xmm2, %xmm2
addsd %xmm0, %xmm2
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movsd 0x5d03(%rip), %xmm0     # 0xa060
addsd %xmm0, %xmm1
mulsd 0x5db7(%rip), %xmm1     # 0xa120
subsd %xmm1, %xmm0
movapd %xmm1, %xmm2
addsd %xmm0, %xmm2
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd 0x5e4f(%rip), %xmm1     # 0xa1d0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
addpd %xmm1, %xmm0
movupd %xmm0, (%rbx)
movsd %xmm2, 0x10(%rbx)
jmp 0x43a7
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rbx)
movapd 0x10(%rsp), %xmm0
movupd %xmm0, (%rbx)
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x43b9
callq 0x37b6
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x8(%rax)
incl %ebp
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movq %rsp, %rdx
movl %ebp, %ecx
callq 0x4234
movsd 0x40(%rsp), %xmm0
mulsd 0x60(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movapd 0x30(%rsp), %xmm1
mulpd 0x50(%rsp), %xmm1
addpd 0x10(%rsp), %xmm1
movupd %xmm1, (%rbx)
movsd %xmm0, 0x10(%rbx)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x43a7
callq 0x37b6
jmp 0x43a7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x443b
callq 0x37b6
jmp 0x443b
jmp 0x4438
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x444d
callq 0x37b6
movq %rbx, %rdi
callq 0x32d0