// File: /workspace/github_cpp_makefile_star2_O3/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 0x2838
leaq -0x170(%rbp), %r14
movsd 0x3c3c(%rip), %xmm0     # 0x6020
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r14, %rdi
callq 0x2838
leaq -0x158(%rbp), %r15
movsd 0x3c27(%rip), %xmm1     # 0x6028
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %r15, %rdi
callq 0x2838
leaq -0x140(%rbp), %r12
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %r12, %rdi
callq 0x2838
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 0x3010
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
leaq -0xb8(%rbp), %r14
movq %r14, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
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 0x3804
leaq -0x98(%rbp), %r14
movq %r14, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
leaq -0x88(%rbp), %r15
movq %r15, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
leaq -0x78(%rbp), %r12
movq %r12, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
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 0x3b34
leaq -0x68(%rbp), %r14
movq %r14, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movl $0xff, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0x35c8
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 0x42e8
leaq -0x128(%rbp), %r12
movsd 0x3a1c(%rip), %xmm0     # 0x6078
movsd 0x3a1c(%rip), %xmm2     # 0x6080
xorps %xmm1, %xmm1
movq %r12, %rdi
callq 0x2838
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 0x2bd0
leaq -0x110(%rbp), %r15
movsd 0x39e5(%rip), %xmm0     # 0x6090
xorps %xmm1, %xmm1
movq %r15, %rdi
movsd 0x39c7(%rip), %xmm2     # 0x6080
callq 0x2838
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 0x2bd0
leaq -0xf8(%rbp), %rbx
movsd 0x39a0(%rip), %xmm1     # 0x6098
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movq %rbx, %rdi
callq 0x2838
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 0x45d4
leaq -0xe0(%rbp), %rdx
movq %r12, (%rdx)
movq %r15, 0x8(%rdx)
movq %rbx, 0x10(%rdx)
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x3270
leaq 0x3949(%rip), %rdi      # 0x60a0
leaq 0x394b(%rip), %rsi      # 0x60a9
callq 0x2120
testq %rax, %rax
je 0x27a9
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
movl $0x780, %esi            # imm = 0x780
movl $0x438, %edx            # imm = 0x438
movl $0x1, %ecx
movl $0x14, %r8d
callq 0x508c
leaq 0x6990(%rip), %r8       # 0x9120
leaq -0x48(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movq %rbx, %rcx
callq 0x52f6
jmp 0x27ef
movq 0x6828(%rip), %rbx      # 0x8fd8
leaq 0x38f5(%rip), %rsi      # 0x60ac
movl $0x25, %edx
movq %rbx, %rdi
callq 0x2110
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20d0
movsbl %al, %esi
movq 0x67f6(%rip), %rdi      # 0x8fd8
callq 0x2030
movq %rax, %rdi
callq 0x2090
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x2804
movq -0x28(%rbp), %rsi
subq %rdi, %rsi
callq 0x2100
xorl %eax, %eax
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2818
movq %rax, %rbx
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x2830
movq -0x28(%rbp), %rsi
subq %rdi, %rsi
callq 0x2100
movq %rbx, %rdi
callq 0x2190