// File: alan0201tw[P]RayTracer/src/util.cpp
// Function: simple_light()
std::shared_ptr<hitable> simple_light()
{
    std::shared_ptr<texture> _perlin_texture = std::make_shared<perlin_noise_texture>(4.0f);
    std::shared_ptr<texture> _color_texture = std::make_shared<constant_texture>(vec3(4.0f, 4.0f, 4.0f));

    std::vector<std::shared_ptr<hitable>> list;
    list.reserve(50);

    list.push_back(std::make_shared<sphere>(
        vec3(0.0f, -1000.0f, 0.0f), 1000.0f, std::make_shared<lambertian>(_perlin_texture)));
    list.push_back(std::make_shared<sphere>(vec3(0.0f,  2.0f, 0.0f), 2.0f, std::make_shared<lambertian>(_perlin_texture)));

    auto light = std::make_shared<diffuse_light>(_color_texture);
    list.push_back(std::make_shared<sphere>(vec3(0.0f, 7.0f, 0.0f), 2.0f, light));
    list.push_back(std::make_shared<xy_rect>(3.0f, 5.0f, 1.0f, 3.0f, -2.0f, light));
    
    return std::make_shared<bvh_node>(list, 0.0f, 1.0f);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x1b0(%rbp)
movq %rdi, %rax
movq %rax, -0x1a8(%rbp)
movq %rdi, -0x8(%rbp)
movl $0x40800000, -0x2c(%rbp) # imm = 0x40800000
leaq -0x28(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
leaq -0x2c(%rbp), %rsi
callq 0x2d610
movq -0x1a0(%rbp), %rsi
leaq -0x18(%rbp), %rdi
callq 0x2d680
movq -0x1a0(%rbp), %rdi
callq 0x2d6b0
leaq -0x5c(%rbp), %rdi
movss 0x580ed(%rip), %xmm2    # 0x7e4e0
movaps %xmm2, %xmm0
movaps %xmm2, %xmm1
callq 0xf9b0
jmp 0x26400
leaq -0x50(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x2cc80
jmp 0x2640f
leaq -0x40(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rsi, -0x1c0(%rbp)
callq 0x2cf80
movq -0x1c0(%rbp), %rdi
callq 0x2cd40
leaq -0x88(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x8b80
movq -0x1b8(%rbp), %rdi
movl $0x32, %esi
callq 0x8ba0
jmp 0x26455
leaq -0xb4(%rbp), %rdi
movss 0x58078(%rip), %xmm1    # 0x7e4dc
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0xf9b0
jmp 0x26471
movl $0x447a0000, -0xb8(%rbp) # imm = 0x447A0000
leaq -0xc8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2cea0
jmp 0x2648d
leaq -0xa8(%rbp), %rdi
leaq -0xb4(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x2d590
jmp 0x264b0
leaq -0x98(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x2cf10
movq -0x1c8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x8ca0
jmp 0x264df
leaq -0x98(%rbp), %rdi
callq 0x8e00
leaq -0xa8(%rbp), %rdi
callq 0x2cf40
leaq -0xc8(%rbp), %rdi
callq 0x2cf60
leaq -0xf4(%rbp), %rdi
movss 0x57f52(%rip), %xmm1    # 0x7e464
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0xf9b0
jmp 0x2651f
movl $0x40000000, -0xf8(%rbp) # imm = 0x40000000
leaq -0x108(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x2cea0
jmp 0x2653b
leaq -0xe8(%rbp), %rdi
leaq -0xf4(%rbp), %rsi
leaq -0xf8(%rbp), %rdx
leaq -0x108(%rbp), %rcx
callq 0x2d590
jmp 0x2655e
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
leaq -0xe8(%rbp), %rsi
callq 0x2cf10
movq -0x1d0(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x8ca0
jmp 0x2658d
leaq -0xd8(%rbp), %rdi
callq 0x8e00
leaq -0xe8(%rbp), %rdi
callq 0x2cf40
leaq -0x108(%rbp), %rdi
callq 0x2cf60
leaq -0x118(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x2d3d0
jmp 0x265c3
leaq -0x144(%rbp), %rdi
movss 0x57f2a(%rip), %xmm1    # 0x7e4fc
xorps %xmm2, %xmm2
movaps %xmm2, %xmm0
callq 0xf9b0
jmp 0x265df
movl $0x40000000, -0x148(%rbp) # imm = 0x40000000
leaq -0x138(%rbp), %rdi
leaq -0x144(%rbp), %rsi
leaq -0x148(%rbp), %rdx
leaq -0x118(%rbp), %rcx
callq 0x2d6d0
jmp 0x2660c
leaq -0x128(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
leaq -0x138(%rbp), %rsi
callq 0x2cf10
movq -0x1d8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x8ca0
jmp 0x2663b
leaq -0x128(%rbp), %rdi
callq 0x8e00
leaq -0x138(%rbp), %rdi
callq 0x2cf40
movl $0x40400000, -0x16c(%rbp) # imm = 0x40400000
movl $0x40a00000, -0x170(%rbp) # imm = 0x40A00000
movl $0x3f800000, -0x174(%rbp) # imm = 0x3F800000
movl $0x40400000, -0x178(%rbp) # imm = 0x40400000
movl $0xc0000000, -0x17c(%rbp) # imm = 0xC0000000
movq %rsp, %rax
leaq -0x118(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x168(%rbp), %rdi
leaq -0x16c(%rbp), %rsi
leaq -0x170(%rbp), %rdx
leaq -0x174(%rbp), %rcx
leaq -0x178(%rbp), %r8
leaq -0x17c(%rbp), %r9
callq 0x2d750
jmp 0x266c3
leaq -0x158(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
leaq -0x168(%rbp), %rsi
callq 0x8dd0
movq -0x1e0(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x8ca0
jmp 0x266f2
leaq -0x158(%rbp), %rdi
callq 0x8e00
leaq -0x168(%rbp), %rdi
callq 0x8e20
movl $0x0, -0x194(%rbp)
movl $0x3f800000, -0x198(%rbp) # imm = 0x3F800000
leaq -0x190(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x194(%rbp), %rdx
leaq -0x198(%rbp), %rcx
callq 0x2d4e0
jmp 0x26741
movq -0x1b0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x2d560
leaq -0x190(%rbp), %rdi
callq 0x13be0
leaq -0x118(%rbp), %rdi
callq 0x2d440
leaq -0x88(%rbp), %rdi
callq 0x92d0
leaq -0x40(%rbp), %rdi
callq 0x12a50
leaq -0x18(%rbp), %rdi
callq 0x12a50
movq -0x1a8(%rbp), %rax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x268b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x268a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x267ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x8e00
leaq -0xa8(%rbp), %rdi
callq 0x2cf40
leaq -0xc8(%rbp), %rdi
callq 0x2cf60
jmp 0x268a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x26831
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x8e00
leaq -0xe8(%rbp), %rdi
callq 0x2cf40
leaq -0x108(%rbp), %rdi
callq 0x2cf60
jmp 0x268a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x26897
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x8e00
leaq -0x138(%rbp), %rdi
callq 0x2cf40
jmp 0x26897
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x8e00
leaq -0x168(%rbp), %rdi
callq 0x8e20
leaq -0x118(%rbp), %rdi
callq 0x2d440
leaq -0x88(%rbp), %rdi
callq 0x92d0
leaq -0x40(%rbp), %rdi
callq 0x12a50
leaq -0x18(%rbp), %rdi
callq 0x12a50
movq -0x68(%rbp), %rdi
callq 0x7860
nopw (%rax,%rax)