// File: /workspace/github_cpp_makefile_star2_O2/alan0201tw[P]RayTracer/include/camera.hpp
// Function: camera::camera(vec3 const&, vec3 const&, vec3 const&, float, float, float, float, float, float)
camera(const vec3& _lookfrom, const vec3& _lookat, const vec3& _up , float _vfov, float _aspect, float _aperture, float _focus_distance, float _t0, float _t1)
    {
        open_time = _t0;
        close_time = _t1;

        float theta = _vfov * M_PI / 180.0f;
        float half_height = tan(theta / 2.0f);
        float half_width = _aspect * half_height;

        origin = _lookfrom;
        camera_forward = unit_vector(_lookfrom - _lookat);
        camera_right = unit_vector( cross(_up, camera_forward) );
        camera_up = unit_vector( cross(camera_forward, camera_right) );

        lens_radius = _aperture / 2.0f;

        lower_left_corner = origin - half_width * _focus_distance * camera_right 
            - half_height * _focus_distance * camera_up - _focus_distance * camera_forward;
        
        horizontal = 2.0f * half_width * _focus_distance * camera_right;
        vertical = 2.0f * half_height * _focus_distance * camera_up;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movss %xmm3, 0x8(%rsp)
movss %xmm2, 0x20(%rsp)
movss %xmm1, 0xc(%rsp)
movq %rcx, %rbp
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x24(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x30(%rdi), %r12
leaq 0x3c(%rdi), %r15
leaq 0x48(%rdi), %rax
movq %rax, 0x38(%rsp)
movss %xmm4, 0x58(%rdi)
movss %xmm5, 0x5c(%rdi)
cvtss2sd %xmm0, %xmm0
mulsd 0x2ca0(%rip), %xmm0     # 0x304c0
divsd 0x5d98(%rip), %xmm0     # 0x335c0
cvtsd2ss %xmm0, %xmm0
mulss 0x2a10(%rip), %xmm0     # 0x30244
callq 0x6580
movaps %xmm0, %xmm1
movss %xmm0, 0x1c(%rsp)
movss 0xc(%rsp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
movq (%r14), %rax
movq %rax, 0x24(%rbx)
movl 0x8(%r14), %eax
movl %eax, 0x2c(%rbx)
movq %r14, %rdi
movq %r13, %rsi
callq 0x9449
callq 0xbbab
movlps %xmm0, 0x30(%rbx)
movss %xmm1, 0x38(%rbx)
movq %rbp, %rdi
movq %r12, %rsi
callq 0xbbdb
callq 0xbbab
movlps %xmm0, 0x3c(%rbx)
movss %xmm1, 0x44(%rbx)
movq %r12, %rdi
movq %r15, %rsi
callq 0xbbdb
callq 0xbbab
movlps %xmm0, 0x48(%rbx)
movss %xmm1, 0x50(%rbx)
movss 0x20(%rsp), %xmm0
mulss 0x298b(%rip), %xmm0     # 0x30244
movss %xmm0, 0x54(%rbx)
movss 0xc(%rsp), %xmm0
mulss 0x8(%rsp), %xmm0
movq %r15, %rdi
callq 0x8980
leaq 0x58(%rsp), %rsi
movlps %xmm0, (%rsi)
movss %xmm1, 0x8(%rsi)
movq 0x10(%rsp), %rdi
callq 0x9449
movaps %xmm0, 0x20(%rsp)
movss %xmm1, 0x10(%rsp)
movss 0x1c(%rsp), %xmm0
mulss 0x8(%rsp), %xmm0
movq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x8980
movaps %xmm0, 0x40(%rsp)
movss 0x10(%rsp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x10(%rsp)
movss 0x8(%rsp), %xmm0
movq %r12, %rdi
callq 0x8980
movaps 0x20(%rsp), %xmm2
subps 0x40(%rsp), %xmm2
subps %xmm0, %xmm2
movss 0x10(%rsp), %xmm0
subss %xmm1, %xmm0
movlps %xmm2, (%rbx)
movss %xmm0, 0x8(%rbx)
movss 0xc(%rsp), %xmm0
addss %xmm0, %xmm0
mulss 0x8(%rsp), %xmm0
movq %r15, %rdi
callq 0x8980
movlps %xmm0, 0xc(%rbx)
movss %xmm1, 0x14(%rbx)
movss 0x1c(%rsp), %xmm0
addss %xmm0, %xmm0
mulss 0x8(%rsp), %xmm0
movq %r14, %rdi
callq 0x8980
movlps %xmm0, 0x18(%rbx)
movss %xmm1, 0x20(%rbx)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq