// File: /workspace/github_cpp_makefile_star2_O2/alan0201tw[P]RayTracer/src/util.cpp
// Function: cornell_box()
std::shared_ptr<hitable> cornell_box()
{
    std::vector<std::shared_ptr<hitable>> list;
    list.reserve(50);

    std::shared_ptr<texture> red_texture = std::make_shared<constant_texture>(vec3(0.65f, 0.05f, 0.05f));
    std::shared_ptr<texture> white_texture = std::make_shared<constant_texture>(vec3(0.73f, 0.73f, 0.73f));
    std::shared_ptr<texture> green_texture = std::make_shared<constant_texture>(vec3(0.12f, 0.45f, 0.15f));
    std::shared_ptr<texture> light_texture = std::make_shared<constant_texture>(vec3(15.0f, 15.0f, 15.0f));

    auto red_material = std::make_shared<lambertian>(red_texture);
    auto white_material = std::make_shared<lambertian>(white_texture);
    auto green_material = std::make_shared<lambertian>(green_texture);
    auto light = std::make_shared<diffuse_light>(light_texture);

    list.push_back(std::make_shared<flip_normals>(std::make_shared<yz_rect>(0, 555, 0, 555, 555, green_material)));
    list.push_back(std::make_shared<yz_rect>(0, 555, 0, 555, 0, red_material));
    list.push_back(std::make_shared<xz_rect>(213, 343, 227, 332, 554, light));
    list.push_back(std::make_shared<flip_normals>(std::make_shared<xz_rect>(0, 555, 0, 555, 555, white_material)));
    list.push_back(std::make_shared<xz_rect>(0, 555, 0, 555, 0, white_material));
    list.push_back(std::make_shared<flip_normals>(std::make_shared<xy_rect>(0, 555, 0, 555, 555, white_material)));

    //list.push_back(std::make_shared<sphere>(vec3(200, 250, 250), 150.0, std::make_shared<metal>(vec3(1.0, 1.0, 1.0), 0.0)));

    // not rotated
    // list.push_back(std::make_shared<box>(vec3(130, 0, 65), vec3(295, 165, 230), white_material));
    // list.push_back(std::make_shared<box>(vec3(265, 0, 295), vec3(430, 330, 460), white_material));

    list.push_back(std::make_shared<translate>(std::make_shared<rotate_y>(std::make_shared<box>(vec3(0, 0, 0), vec3(165, 165, 165), white_material), -18.0f), vec3(130, 0, 65)));
    list.push_back(std::make_shared<translate>(std::make_shared<rotate_y>(std::make_shared<box>(vec3(0, 0, 0), vec3(165, 330, 165), white_material),  15.0f), vec3(265, 0, 295)));

    return std::make_shared<bvh_node>(list, 0.0f, 1.0f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdi, %r13
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
pushq $0x32
popq %rsi
callq 0x71e8
movsd 0x1d22e(%rip), %xmm0    # 0x30630
leaq 0xb0(%rsp), %rsi
movsd %xmm0, (%rsi)
movl $0x3d4ccccd, 0x8(%rsi)  # imm = 0x3D4CCCCD
leaq 0xd0(%rsp), %rdi
callq 0x16b90
leaq 0xf8(%rsp), %rax
leaq 0xd8(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
movaps %xmm0, -0x8(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rdi)
callq 0x7426
movsd 0x1d1f2(%rip), %xmm0    # 0x30640
leaq 0xa0(%rsp), %rsi
movsd %xmm0, (%rsi)
movl $0x3f3ae148, 0x8(%rsi)  # imm = 0x3F3AE148
leaq 0xb0(%rsp), %rdi
callq 0x16b90
leaq 0xd8(%rsp), %rax
leaq 0xb8(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
movaps %xmm0, -0x8(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rdi)
callq 0x7426
movsd 0x1d1b6(%rip), %xmm0    # 0x30650
leaq 0xc0(%rsp), %rsi
movsd %xmm0, (%rsi)
movl $0x3e19999a, 0x8(%rsi)  # imm = 0x3E19999A
leaq 0xa0(%rsp), %rdi
callq 0x16b90
leaq 0xb8(%rsp), %rax
leaq 0xa8(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
movaps %xmm0, -0x8(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rdi)
callq 0x7426
movsd 0x1d17a(%rip), %xmm0    # 0x30660
leaq 0xe0(%rsp), %rsi
movsd %xmm0, (%rsi)
movl $0x41700000, 0x8(%rsi)  # imm = 0x41700000
leaq 0xc0(%rsp), %rdi
callq 0x16b90
leaq 0xa8(%rsp), %rax
leaq 0xc8(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
movaps %xmm0, -0x8(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rdi)
callq 0x7426
leaq 0xc0(%rsp), %r14
leaq 0xf0(%rsp), %rsi
movq %r14, %rdi
callq 0x16bf0
leaq 0xe0(%rsp), %rbp
leaq 0xd0(%rsp), %rsi
movq %rbp, %rdi
callq 0x16bf0
leaq 0x118(%rsp), %r15
leaq 0xb0(%rsp), %rsi
movq %r15, %rdi
callq 0x16bf0
leaq 0x108(%rsp), %rbx
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0x16d0e
leaq 0x40(%rsp), %rsi
andl $0x0, (%rsi)
movl $0x22b, %eax            # imm = 0x22B
leaq 0x70(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x60(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x50(%rsp), %r8
movl %eax, (%r8)
leaq 0x1c(%rsp), %r9
movl %eax, (%r9)
movq %r15, (%rsp)
leaq 0x8(%rsp), %rdi
callq 0x16e0b
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x734b
leaq 0x28(%rsp), %r12
leaq 0x38(%rsp), %r15
movaps -0x8(%r15), %xmm0
movaps %xmm0, -0x8(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%r15)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r12, %rdi
callq 0x7426
movq %r15, %rdi
callq 0x7426
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x7426
andl $0x0, -0x8(%r15)
movl $0x22b, %eax            # imm = 0x22B
leaq 0x70(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x40(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x60(%rsp), %r8
movl %eax, (%r8)
leaq 0x50(%rsp), %r9
andl $0x0, (%r9)
movq %r14, (%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16e0b
leaq 0x28(%rsp), %r15
leaq 0x38(%rsp), %r14
movaps -0x8(%r14), %xmm0
movaps %xmm0, -0x8(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%r14)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r15, %rdi
callq 0x7426
movq %r14, %rdi
callq 0x7426
leaq 0x8(%rsp), %rsi
movl $0xd5, (%rsi)
leaq 0x40(%rsp), %rdx
movl $0x157, (%rdx)          # imm = 0x157
leaq 0x70(%rsp), %rcx
movl $0xe3, (%rcx)
leaq 0x60(%rsp), %r8
movl $0x14c, (%r8)           # imm = 0x14C
leaq 0x50(%rsp), %r9
movl $0x22a, (%r9)           # imm = 0x22A
movq %rbx, (%rsp)
leaq 0x30(%rsp), %rdi
callq 0x16e3c
leaq 0x28(%rsp), %r14
leaq 0x38(%rsp), %rbx
movaps -0x8(%rbx), %xmm0
movaps %xmm0, -0x8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rbx)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
callq 0x7426
leaq 0x40(%rsp), %rsi
andl $0x0, (%rsi)
movl $0x22b, %eax            # imm = 0x22B
leaq 0x70(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x60(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x50(%rsp), %r8
movl %eax, (%r8)
leaq 0x1c(%rsp), %r9
movl %eax, (%r9)
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rdi
callq 0x16e6d
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72fc
leaq 0x28(%rsp), %r14
leaq 0x38(%rsp), %rbx
movaps -0x8(%rbx), %xmm0
movaps %xmm0, -0x8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rbx)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
callq 0x7426
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x7426
andl $0x0, -0x8(%rbx)
movl $0x22b, %eax            # imm = 0x22B
leaq 0x70(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x40(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x60(%rsp), %r8
movl %eax, (%r8)
leaq 0x50(%rsp), %r9
andl $0x0, (%r9)
movq %rbp, (%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16e6d
leaq 0x28(%rsp), %r14
leaq 0x38(%rsp), %rbx
movaps -0x8(%rbx), %xmm0
movaps %xmm0, -0x8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rbx)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
callq 0x7426
leaq 0x40(%rsp), %rsi
andl $0x0, (%rsi)
movl $0x22b, %eax            # imm = 0x22B
leaq 0x70(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x60(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x50(%rsp), %r8
movl %eax, (%r8)
leaq 0x1c(%rsp), %r9
movl %eax, (%r9)
movq %rbp, (%rsp)
leaq 0x8(%rsp), %rdi
callq 0x16e9e
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x72ad
leaq 0x28(%rsp), %r14
leaq 0x38(%rsp), %rbx
movaps -0x8(%rbx), %xmm0
movaps %xmm0, -0x8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rbx)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
callq 0x7426
leaq 0x10(%rsp), %rdi
callq 0x7426
leaq 0x70(%rsp), %rsi
andq $0x0, (%rsi)
andl $0x0, 0x8(%rsi)
movsd 0x1cda5(%rip), %xmm0    # 0x30670
leaq 0x60(%rsp), %rdx
movsd %xmm0, (%rdx)
movl $0x43250000, 0x8(%rdx)  # imm = 0x43250000
leaq 0x40(%rsp), %rdi
leaq 0xe0(%rsp), %rcx
callq 0x16f11
leaq 0x1c(%rsp), %rdx
movl $0xc1900000, (%rdx)     # imm = 0xC1900000
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x16ef0
movss 0x1cc09(%rip), %xmm0    # 0x30518
leaq 0x50(%rsp), %rdx
movlps %xmm0, (%rdx)
movl $0x42820000, 0x8(%rdx)  # imm = 0x42820000
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16ecf
leaq 0x28(%rsp), %r14
leaq 0x38(%rsp), %rbx
movaps -0x8(%rbx), %xmm0
movaps %xmm0, -0x8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rbx)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
callq 0x7426
leaq 0x10(%rsp), %rdi
callq 0x7426
leaq 0x48(%rsp), %rdi
callq 0x7426
leaq 0x70(%rsp), %rsi
andq $0x0, (%rsi)
andl $0x0, 0x8(%rsi)
movsd 0x1ccee(%rip), %xmm0    # 0x30680
leaq 0x60(%rsp), %rdx
movsd %xmm0, (%rdx)
movl $0x43250000, 0x8(%rdx)  # imm = 0x43250000
leaq 0x40(%rsp), %rdi
leaq 0xe0(%rsp), %rcx
callq 0x16f11
leaq 0x1c(%rsp), %rdx
movl $0x41700000, (%rdx)     # imm = 0x41700000
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x16ef0
movss 0x1cb46(%rip), %xmm0    # 0x3051c
leaq 0x50(%rsp), %rdx
movlps %xmm0, (%rdx)
movl $0x43938000, 0x8(%rdx)  # imm = 0x43938000
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x16ecf
leaq 0x28(%rsp), %r14
leaq 0x38(%rsp), %rbx
movaps -0x8(%rbx), %xmm0
movaps %xmm0, -0x8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rbx)
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x7b8a
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
callq 0x7426
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x7426
leaq 0x48(%rsp), %rdi
callq 0x7426
leaq 0x30(%rsp), %rdx
andl $0x0, (%rdx)
movl $0x3f800000, -0x8(%rbx) # imm = 0x3F800000
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x8(%rsp), %rcx
callq 0x16d50
leaq 0x28(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movups %xmm0, (%r13)
andq $0x0, -0x8(%rdi)
callq 0x7426
leaq 0x110(%rsp), %rdi
callq 0x7426
leaq 0x120(%rsp), %rdi
callq 0x7426
leaq 0xe8(%rsp), %rdi
callq 0x7426
leaq 0xc8(%rsp), %rdi
callq 0x7426
leaq 0xa8(%rsp), %rdi
callq 0x7426
leaq 0xb8(%rsp), %rdi
callq 0x7426
leaq 0xd8(%rsp), %rdi
callq 0x7426
leaq 0xf8(%rsp), %rdi
callq 0x7426
leaq 0x80(%rsp), %rdi
callq 0x7404
movq %r13, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x13bb9
jmp 0x13b23
jmp 0x13b38
jmp 0x13b47
jmp 0x13bb9
movq %rax, %r13
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
callq 0x7426
jmp 0x13b3b
movq %rax, %r13
leaq 0x10(%rsp), %rdi
callq 0x7426
jmp 0x13b4a
movq %rax, %r13
leaq 0x48(%rsp), %rdi
jmp 0x13bb2
jmp 0x13bb9
jmp 0x13b5d
jmp 0x13baa
jmp 0x13bb9
jmp 0x13b71
jmp 0x13bb9
movq %rax, %r13
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
jmp 0x13ba3
jmp 0x13baa
jmp 0x13bb9
movq %rax, %r13
movq %r14, %rdi
callq 0x7426
movq %rbx, %rdi
jmp 0x13bb2
jmp 0x13bb9
movq %rax, %r13
movq %r15, %rdi
callq 0x7426
movq %r14, %rdi
jmp 0x13bb2
jmp 0x13bb9
movq %rax, %r13
movq %r12, %rdi
callq 0x7426
movq %r15, %rdi
callq 0x7426
jmp 0x13bad
movq %rax, %r13
leaq 0x10(%rsp), %rdi
callq 0x7426
jmp 0x13bbc
movq %rax, %r13
leaq 0x110(%rsp), %rdi
callq 0x7426
leaq 0x120(%rsp), %rdi
callq 0x7426
leaq 0xe8(%rsp), %rdi
callq 0x7426
leaq 0xc8(%rsp), %rdi
callq 0x7426
leaq 0xa8(%rsp), %rdi
callq 0x7426
leaq 0xb8(%rsp), %rdi
callq 0x7426
leaq 0xd8(%rsp), %rdi
callq 0x7426
leaq 0xf8(%rsp), %rdi
callq 0x7426
leaq 0x80(%rsp), %rdi
callq 0x7404
movq %r13, %rdi
callq 0x6710
movq %rax, %r13
jmp 0x13bc9
movq %rax, %r13
jmp 0x13bd6
movq %rax, %r13
jmp 0x13be3
movq %rax, %r13
jmp 0x13bf0
movq %rax, %r13
jmp 0x13bfd
movq %rax, %r13
jmp 0x13c0a
movq %rax, %r13
jmp 0x13c17
jmp 0x13c5e
movq %rax, %r13
jmp 0x13c24