// File: /workspace/github_cpp_makefile_star2_O2/Crawler995[P]Cpp-Ray-Tracing/main.cpp
// Function: main
int main(int argc, char const *argv[])
{   
    PerspectiveCamera camera(
        1000, 
        Vector3(-WIDTH / 2, -HEIGHT / 2, -1000),
        Vector3(WIDTH, 0, 0),
        Vector3(0, HEIGHT, 0),
        Vector3(0, 0, 0)
    );
    PhongMaterial phong_white(
        0.2, 0.6, 0.4, 100,
        Color(255, 255, 255),
        Color(255, 255, 255),
        Color(255, 255, 255)
    );
    CookTorranceMaterial cook_torrance_white(
        0.2, 0.6, 0.4, 0.8, 0.1,
        Color(255, 255, 255),
        Color(255, 255, 255),
        Color(255, 255, 255)
    );
    CheckMaterial checker_material(
        0.005, 0.2, 0.6, 0.2, 10,
        Color(255, 255, 255),
        Color(255, 255, 255)
    );

    Sphere sphere_1(Vector3(-300, 0, -1200), 200, &cook_torrance_white);
    Sphere sphere_2(Vector3(300, 0, -1200), 200, &phong_white);
    Plane plane_1(Vector3(0, 1, 0), 200.0, &checker_material);

    Geometry *geos[3] = {&sphere_1, &sphere_2, &plane_1};

    GeometryUnion geometry_union(3, geos);
    
    FILE *f = fopen("test.png", "wb");
    if(!f) {
        std::cout << "Create file failed, please try again." << std::endl;
    }
    else {
        RenderEngine render_engine(WIDTH, HEIGHT, SAMPLE_TIMES, MAX_REFLECT_TIMES);
        render_engine.render(camera, geometry_union, f, output_img_data);
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x3c0, %rsp            # imm = 0x3C0
leaq -0x188(%rbp), %rbx
movsd 0x3c4b(%rip), %xmm0     # 0x6008
movsd 0x3c4b(%rip), %xmm1     # 0x6010
movsd 0x3c4b(%rip), %xmm2     # 0x6018
movq %rbx, %rdi
callq 0x283c
leaq -0x170(%rbp), %r14
movsd 0x3c3c(%rip), %xmm0     # 0x6020
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rdi
callq 0x283c
leaq -0x158(%rbp), %r15
movsd 0x3c27(%rip), %xmm1     # 0x6028
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %r15, %rdi
callq 0x283c
leaq -0x140(%rbp), %r12
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r12, %rdi
callq 0x283c
movq 0x10(%r12), %rax
movq %rax, 0x58(%rsp)
movups (%r12), %xmm0
movups %xmm0, 0x48(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x40(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x30(%rsp)
movq 0x10(%r14), %rax
movq %rax, 0x28(%rsp)
movups (%r14), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
leaq -0x280(%rbp), %rdi
movsd 0x3bb2(%rip), %xmm0     # 0x6030
callq 0x3008
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
leaq -0xb8(%rbp), %r14
movq %r14, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
movq (%rbx), %rsi
movl 0x8(%rbx), %edx
movq (%r14), %rcx
movl 0x8(%r14), %r8d
movl 0x8(%r15), %eax
movl %eax, 0x8(%rsp)
movq (%r15), %rax
movq %rax, (%rsp)
leaq -0x2d0(%rbp), %rbx
movsd 0x3b30(%rip), %xmm0     # 0x6038
movsd 0x3b30(%rip), %xmm1     # 0x6040
movsd 0x3b30(%rip), %xmm2     # 0x6048
movsd 0x3b30(%rip), %xmm3     # 0x6050
movq %rbx, %rdi
callq 0x37f4
leaq -0x98(%rbp), %r14
movq %r14, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
leaq -0x88(%rbp), %r15
movq %r15, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
leaq -0x78(%rbp), %r12
movq %r12, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
movq (%r14), %rsi
movl 0x8(%r14), %edx
movq (%r15), %rcx
movl 0x8(%r15), %r8d
movl 0x8(%r12), %eax
movl %eax, 0x8(%rsp)
movq (%r12), %rax
movq %rax, (%rsp)
leaq -0x380(%rbp), %r15
movsd 0x3aab(%rip), %xmm3     # 0x6058
movsd 0x3aab(%rip), %xmm4     # 0x6060
movq %r15, %rdi
movsd 0x3a78(%rip), %xmm0     # 0x6038
movsd 0x3a78(%rip), %xmm1     # 0x6040
movsd 0x3a78(%rip), %xmm2     # 0x6048
callq 0x3b14
leaq -0x68(%rbp), %r14
movq %r14, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35d8
movq (%r14), %rsi
movl 0x8(%r14), %edx
movq (%r12), %rcx
movl 0x8(%r12), %r8d
leaq -0x328(%rbp), %r14
movsd 0x3a3e(%rip), %xmm0     # 0x6068
movsd 0x3a3e(%rip), %xmm4     # 0x6070
movq %r14, %rdi
movsd 0x39fb(%rip), %xmm1     # 0x6038
movsd 0x39fb(%rip), %xmm2     # 0x6040
movaps %xmm1, %xmm3
callq 0x4294
leaq -0x128(%rbp), %r12
movsd 0x3a1c(%rip), %xmm0     # 0x6078
movsd 0x3a1c(%rip), %xmm2     # 0x6080
xorps %xmm1, %xmm1
movq %r12, %rdi
callq 0x283c
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
leaq -0x218(%rbp), %r12
movsd 0x39f7(%rip), %xmm0     # 0x6088
movq %r12, %rdi
movq %r15, %rsi
callq 0x2bcc
leaq -0x110(%rbp), %r15
movsd 0x39e5(%rip), %xmm0     # 0x6090
xorps %xmm1, %xmm1
movq %r15, %rdi
movsd 0x39c7(%rip), %xmm2     # 0x6080
callq 0x283c
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
leaq -0x1e8(%rbp), %r15
movq %r15, %rdi
movsd 0x39a7(%rip), %xmm0     # 0x6088
movq %rbx, %rsi
callq 0x2bcc
leaq -0xf8(%rbp), %rbx
movsd 0x39a0(%rip), %xmm1     # 0x6098
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %rbx, %rdi
callq 0x283c
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
leaq -0x1b8(%rbp), %rbx
movq %rbx, %rdi
movsd 0x3960(%rip), %xmm0     # 0x6088
movq %r14, %rsi
callq 0x455c
leaq -0xe0(%rbp), %rdx
movq %r12, (%rdx)
movq %r15, 0x8(%rdx)
movq %rbx, 0x10(%rdx)
leaq -0x38(%rbp), %rdi
pushq $0x3
popq %rsi
callq 0x3268
leaq 0x394b(%rip), %rdi      # 0x60a0
leaq 0x394d(%rip), %rsi      # 0x60a9
callq 0x2130
testq %rax, %rax
je 0x27a3
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
pushq $0x1
popq %rcx
pushq $0x14
popq %r8
movl $0x780, %esi            # imm = 0x780
movl $0x438, %edx            # imm = 0x438
callq 0x5024
leaq 0x69a6(%rip), %r8       # 0x9130
leaq -0x48(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movq %rbx, %rcx
callq 0x528e
jmp 0x27be
movq 0x682e(%rip), %rdi      # 0x8fd8
leaq 0x38fb(%rip), %rsi      # 0x60ac
callq 0x20f0
movq %rax, %rdi
callq 0x2090
leaq -0x38(%rbp), %rdi
callq 0x27fe
xorl %eax, %eax
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x27db
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x27fe
movq %rbx, %rdi
callq 0x21a0