// File: alan0201tw[P]RayTracer/src/util.cpp
// Function: two_sphere()
std::shared_ptr<hitable> two_sphere()
{
    std::shared_ptr<texture> _checker_texture = std::make_shared<checker_texture>(
        std::make_shared<constant_texture>(vec3(0.1f, 0.2f, 0.3f)),
        std::make_shared<constant_texture>(vec3(0.9f, 0.9f, 0.9f))
    );

    std::shared_ptr<texture> _image_texture = std::make_shared<image_texture>("./resources/texture.jpg");

    std::vector<std::shared_ptr<hitable>> list;
    list.reserve(50);

    list.push_back(std::make_shared<sphere>(vec3(0.0f, -10.0f, 0.0f), 10.0f, std::make_shared<lambertian>(_image_texture)));
    list.push_back(std::make_shared<sphere>(vec3(0.0f,  10.0f, 0.0f), 10.0f, std::make_shared<lambertian>(_checker_texture)));

    return std::make_shared<bvh_node>(list, 0.0f, 1.0f);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x160(%rbp)
movq %rdi, %rax
movq %rax, -0x158(%rbp)
movq %rdi, -0x8(%rbp)
leaq -0x44(%rbp), %rdi
movq %rdi, -0x150(%rbp)
movss 0x58801(%rip), %xmm0    # 0x7e4d4
movss 0x587f1(%rip), %xmm1    # 0x7e4cc
movss 0x587ed(%rip), %xmm2    # 0x7e4d0
callq 0xf9b0
movq -0x150(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x2cc80
leaq -0x64(%rbp), %rdi
movss 0x587d4(%rip), %xmm2    # 0x7e4d8
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xf9b0
jmp 0x25d11
leaq -0x58(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x2cc80
jmp 0x25d20
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x2cc00
jmp 0x25d33
leaq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movq %rsi, -0x168(%rbp)
callq 0x2ccf0
movq -0x168(%rbp), %rdi
callq 0x2cd20
leaq -0x58(%rbp), %rdi
callq 0x2cd40
leaq -0x38(%rbp), %rdi
callq 0x2cd40
leaq 0x58d9a(%rip), %rsi     # 0x7eb06
leaq -0x98(%rbp), %rdi
callq 0x2cd60
jmp 0x25d7a
leaq -0x88(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movq %rsi, -0x178(%rbp)
callq 0x2cdd0
movq -0x178(%rbp), %rdi
callq 0x2ce00
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x8b80
movq -0x170(%rbp), %rdi
movl $0x32, %esi
callq 0x8ba0
jmp 0x25dc6
leaq -0xdc(%rbp), %rdi
movss 0x58723(%rip), %xmm1    # 0x7e4f8
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0xf9b0
jmp 0x25de2
movl $0x41200000, -0xe0(%rbp) # imm = 0x41200000
leaq -0xf0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x2cea0
jmp 0x25e01
leaq -0xd0(%rbp), %rdi
leaq -0xdc(%rbp), %rsi
leaq -0xe0(%rbp), %rdx
leaq -0xf0(%rbp), %rcx
callq 0x2d590
jmp 0x25e24
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x180(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x2cf10
movq -0x180(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x8ca0
jmp 0x25e53
leaq -0xc0(%rbp), %rdi
callq 0x8e00
leaq -0xd0(%rbp), %rdi
callq 0x2cf40
leaq -0xf0(%rbp), %rdi
callq 0x2cf60
leaq -0x11c(%rbp), %rdi
movss 0x5839a(%rip), %xmm1    # 0x7e220
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0xf9b0
jmp 0x25e93
movl $0x41200000, -0x120(%rbp) # imm = 0x41200000
leaq -0x130(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2cea0
jmp 0x25eaf
leaq -0x110(%rbp), %rdi
leaq -0x11c(%rbp), %rsi
leaq -0x120(%rbp), %rdx
leaq -0x130(%rbp), %rcx
callq 0x2d590
jmp 0x25ed2
leaq -0x100(%rbp), %rdi
movq %rdi, -0x188(%rbp)
leaq -0x110(%rbp), %rsi
callq 0x2cf10
movq -0x188(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x8ca0
jmp 0x25f01
leaq -0x100(%rbp), %rdi
callq 0x8e00
leaq -0x110(%rbp), %rdi
callq 0x2cf40
leaq -0x130(%rbp), %rdi
callq 0x2cf60
movl $0x0, -0x144(%rbp)
movl $0x3f800000, -0x148(%rbp) # imm = 0x3F800000
leaq -0x140(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0x144(%rbp), %rdx
leaq -0x148(%rbp), %rcx
callq 0x2d4e0
jmp 0x25f5c
movq -0x160(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x2d560
leaq -0x140(%rbp), %rdi
callq 0x13be0
leaq -0xb0(%rbp), %rdi
callq 0x92d0
leaq -0x88(%rbp), %rdi
callq 0x12a50
leaq -0x18(%rbp), %rdi
callq 0x12a50
movq -0x158(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x25fcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2cd40
leaq -0x38(%rbp), %rdi
callq 0x2cd40
jmp 0x2609b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x26092
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2607a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2602e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x8e00
leaq -0xd0(%rbp), %rdi
callq 0x2cf40
leaq -0xf0(%rbp), %rdi
callq 0x2cf60
jmp 0x2607a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2606e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x8e00
leaq -0x110(%rbp), %rdi
callq 0x2cf40
leaq -0x130(%rbp), %rdi
callq 0x2cf60
leaq -0xb0(%rbp), %rdi
callq 0x92d0
leaq -0x88(%rbp), %rdi
callq 0x12a50
leaq -0x18(%rbp), %rdi
callq 0x12a50
movq -0x70(%rbp), %rdi
callq 0x7860
nopw %cs:(%rax,%rax)