// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movaps %xmm3, 0x20(%rsp)
movss %xmm2, 0xc(%rsp)
movaps %xmm1, 0x10(%rsp)
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
movss %xmm4, 0x58(%rdi)
movss %xmm5, 0x5c(%rdi)
cvtss2sd %xmm0, %xmm0
mulsd 0x32f1(%rip), %xmm0     # 0x3c798
divsd 0x6209(%rip), %xmm0     # 0x3f6b8
cvtsd2ss %xmm0, %xmm0
mulss 0x2d89(%rip), %xmm0     # 0x3c244
callq 0x6540
movaps 0x10(%rsp), %xmm11
mulss %xmm0, %xmm11
movq (%r12), %rax
movq %rax, 0x24(%rbx)
movl 0x8(%r12), %eax
movl %eax, 0x2c(%rbx)
movss 0x8(%r12), %xmm1
subss 0x8(%r15), %xmm1
movsd (%r12), %xmm4
movsd (%r15), %xmm2
subps %xmm2, %xmm4
movaps %xmm4, %xmm2
mulps %xmm4, %xmm2
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
movaps %xmm4, %xmm3
mulss %xmm4, %xmm3
addss %xmm2, %xmm3
movaps %xmm1, %xmm2
mulss %xmm1, %xmm2
addss %xmm3, %xmm2
sqrtss %xmm2, %xmm2
divss %xmm2, %xmm1
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
divps %xmm2, %xmm4
movlps %xmm4, 0x30(%rbx)
movss %xmm1, 0x38(%rbx)
movss (%r14), %xmm3
movss 0x4(%r14), %xmm6
movss 0x8(%r14), %xmm7
movaps %xmm4, %xmm2
shufps $0x55, %xmm4, %xmm2     # xmm2 = xmm2[1,1],xmm4[1,1]
movaps %xmm2, %xmm8
mulss %xmm7, %xmm8
mulss %xmm4, %xmm7
movaps %xmm4, %xmm5
movaps %xmm4, %xmm9
mulss %xmm6, %xmm9
mulss %xmm1, %xmm6
subss %xmm8, %xmm6
movaps %xmm3, %xmm8
mulss %xmm1, %xmm8
subss %xmm7, %xmm8
movaps 0x2da3(%rip), %xmm7     # 0x3c320
movaps %xmm8, %xmm10
xorps %xmm7, %xmm10
mulss %xmm2, %xmm3
subss %xmm9, %xmm3
mulss %xmm8, %xmm8
movaps %xmm6, %xmm9
mulss %xmm6, %xmm9
addss %xmm8, %xmm9
movaps %xmm3, %xmm8
mulss %xmm3, %xmm8
addss %xmm9, %xmm8
sqrtss %xmm8, %xmm8
unpcklps %xmm10, %xmm6           # xmm6 = xmm6[0],xmm10[0],xmm6[1],xmm10[1]
divss %xmm8, %xmm3
shufps $0x0, %xmm8, %xmm8      # xmm8 = xmm8[0,0,0,0]
divps %xmm8, %xmm6
movlps %xmm6, 0x3c(%rbx)
movaps %xmm6, %xmm8
movaps %xmm11, %xmm9
movaps %xmm11, %xmm13
movaps 0x20(%rsp), %xmm14
mulss %xmm14, %xmm9
movaps %xmm9, %xmm10
unpcklps %xmm9, %xmm9            # xmm9 = xmm9[0,0,1,1]
mulps %xmm6, %xmm9
movaps %xmm6, %xmm11
shufps $0x55, %xmm6, %xmm11    # xmm11 = xmm11[1,1],xmm6[1,1]
mulss %xmm11, %xmm5
mulss %xmm1, %xmm11
mulss %xmm2, %xmm8
mulss %xmm3, %xmm2
subss %xmm11, %xmm2
addss %xmm13, %xmm13
mulss %xmm14, %xmm13
movaps %xmm13, %xmm11
unpcklps %xmm13, %xmm11          # xmm11 = xmm11[0],xmm13[0],xmm11[1],xmm13[1]
mulps %xmm6, %xmm11
movaps %xmm6, %xmm12
movaps %xmm14, %xmm6
unpcklps %xmm14, %xmm6           # xmm6 = xmm6[0],xmm14[0],xmm6[1],xmm14[1]
mulps %xmm4, %xmm6
mulss %xmm1, %xmm12
mulss %xmm3, %xmm4
subss %xmm12, %xmm4
xorps %xmm4, %xmm7
subss %xmm8, %xmm5
mulss %xmm4, %xmm4
movaps %xmm2, %xmm8
mulss %xmm2, %xmm8
addss %xmm4, %xmm8
movaps %xmm5, %xmm4
mulss %xmm5, %xmm4
addss %xmm8, %xmm4
movss %xmm3, 0x44(%rbx)
sqrtss %xmm4, %xmm4
unpcklps %xmm7, %xmm2            # xmm2 = xmm2[0],xmm7[0],xmm2[1],xmm7[1]
divss %xmm4, %xmm5
shufps $0x0, %xmm4, %xmm4      # xmm4 = xmm4[0,0,0,0]
divps %xmm4, %xmm2
movlps %xmm2, 0x48(%rbx)
movss %xmm5, 0x50(%rbx)
movss 0xc(%rsp), %xmm4
mulss 0x2baf(%rip), %xmm4     # 0x3c244
movss %xmm4, 0x54(%rbx)
mulss %xmm3, %xmm10
movss 0x2c(%rbx), %xmm4
subss %xmm10, %xmm4
movaps %xmm0, %xmm7
mulss %xmm14, %xmm7
movaps %xmm7, %xmm8
mulss %xmm5, %xmm8
subss %xmm8, %xmm4
mulss %xmm14, %xmm1
subss %xmm1, %xmm4
movsd 0x24(%rbx), %xmm1
subps %xmm9, %xmm1
unpcklps %xmm7, %xmm7            # xmm7 = xmm7[0,0,1,1]
mulps %xmm2, %xmm7
subps %xmm7, %xmm1
subps %xmm6, %xmm1
movlps %xmm1, (%rbx)
movss %xmm4, 0x8(%rbx)
mulss %xmm3, %xmm13
movlps %xmm11, 0xc(%rbx)
movss %xmm13, 0x14(%rbx)
addss %xmm0, %xmm0
mulss %xmm14, %xmm0
movaps %xmm0, %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
mulps %xmm2, %xmm1
mulss %xmm5, %xmm0
movlps %xmm1, 0x18(%rbx)
movss %xmm0, 0x20(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq