// File: 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
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movss %xmm0, -0x24(%rbp)
movss %xmm1, -0x28(%rbp)
movss %xmm2, -0x2c(%rbp)
movss %xmm3, -0x30(%rbp)
movss %xmm4, -0x34(%rbp)
movss %xmm5, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x10660
movq -0x238(%rbp), %rdi
addq $0xc, %rdi
callq 0x10660
movq -0x238(%rbp), %rdi
addq $0x18, %rdi
callq 0x10660
movq -0x238(%rbp), %rdi
addq $0x24, %rdi
movq %rdi, -0x258(%rbp)
callq 0x10660
movq -0x238(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0x250(%rbp)
callq 0x10660
movq -0x238(%rbp), %rdi
addq $0x3c, %rdi
movq %rdi, -0x248(%rbp)
callq 0x10660
movq -0x238(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x240(%rbp)
callq 0x10660
movq -0x238(%rbp), %rax
movss -0x34(%rbp), %xmm0
movss %xmm0, 0x58(%rax)
movss -0x38(%rbp), %xmm0
movss %xmm0, 0x5c(%rax)
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xab3f(%rip), %xmm1     # 0x7e480
mulsd %xmm1, %xmm0
movsd 0xd493(%rip), %xmm1     # 0x80de0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x3c(%rbp), %xmm0
movss 0xa8bd(%rip), %xmm1     # 0x7e224
movss %xmm1, -0x25c(%rbp)
mulss %xmm1, %xmm0
callq 0x74770
movq -0x238(%rbp), %rax
movss %xmm0, -0x40(%rbp)
movss -0x28(%rbp), %xmm0
movss -0x40(%rbp), %xmm1
mulss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %edx
movl %edx, 0x2c(%rax)
movq (%rcx), %rcx
movq %rcx, 0x24(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11890
movss %xmm1, -0x68(%rbp)
movlpd %xmm0, -0x70(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movss -0x78(%rbp), %xmm1
callq 0x18b10
movq -0x250(%rbp), %rsi
movq -0x238(%rbp), %rax
movss %xmm1, -0x88(%rbp)
movlpd %xmm0, -0x90(%rbp)
movl -0x88(%rbp), %ecx
movl %ecx, -0x48(%rbp)
movq -0x90(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movl -0x48(%rbp), %ecx
movl %ecx, 0x38(%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rdi
callq 0x18ba0
movss %xmm1, -0xb8(%rbp)
movlpd %xmm0, -0xc0(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0xa8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0xc8(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movsd -0xd0(%rbp), %xmm0
movss -0xc8(%rbp), %xmm1
callq 0x18b10
movq -0x250(%rbp), %rdi
movq -0x248(%rbp), %rsi
movq -0x238(%rbp), %rax
movss %xmm1, -0xd8(%rbp)
movlpd %xmm0, -0xe0(%rbp)
movl -0xd8(%rbp), %ecx
movl %ecx, -0x98(%rbp)
movq -0xe0(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movl -0x98(%rbp), %ecx
movl %ecx, 0x44(%rax)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x3c(%rax)
callq 0x18ba0
movss %xmm1, -0x108(%rbp)
movlpd %xmm0, -0x110(%rbp)
movl -0x108(%rbp), %eax
movl %eax, -0xf8(%rbp)
movq -0x110(%rbp), %rax
movq %rax, -0x100(%rbp)
movl -0xf8(%rbp), %eax
movl %eax, -0x118(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x120(%rbp)
movsd -0x120(%rbp), %xmm0
movss -0x118(%rbp), %xmm1
callq 0x18b10
movq -0x248(%rbp), %rdi
movq -0x238(%rbp), %rax
movaps %xmm1, %xmm2
movss -0x25c(%rbp), %xmm1
movss %xmm2, -0x128(%rbp)
movlpd %xmm0, -0x130(%rbp)
movl -0x128(%rbp), %ecx
movl %ecx, -0xe8(%rbp)
movq -0x130(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movl -0xe8(%rbp), %ecx
movl %ecx, 0x50(%rax)
movq -0xf0(%rbp), %rcx
movq %rcx, 0x48(%rax)
movss -0x2c(%rbp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, 0x54(%rax)
movss -0x44(%rbp), %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm1, %xmm0
callq 0xfaa0
movq -0x258(%rbp), %rdi
movss %xmm1, -0x178(%rbp)
movlpd %xmm0, -0x180(%rbp)
movl -0x178(%rbp), %eax
movl %eax, -0x168(%rbp)
movq -0x180(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x170(%rbp), %rsi
callq 0x11890
movq -0x240(%rbp), %rdi
movss %xmm1, -0x188(%rbp)
movlpd %xmm0, -0x190(%rbp)
movl -0x188(%rbp), %eax
movl %eax, -0x158(%rbp)
movq -0x190(%rbp), %rax
movq %rax, -0x160(%rbp)
movss -0x40(%rbp), %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm1, %xmm0
callq 0xfaa0
movss %xmm1, -0x1a8(%rbp)
movlpd %xmm0, -0x1b0(%rbp)
movl -0x1a8(%rbp), %eax
movl %eax, -0x198(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x11890
movq -0x250(%rbp), %rdi
movss %xmm1, -0x1b8(%rbp)
movlpd %xmm0, -0x1c0(%rbp)
movl -0x1b8(%rbp), %eax
movl %eax, -0x148(%rbp)
movq -0x1c0(%rbp), %rax
movq %rax, -0x150(%rbp)
movss -0x30(%rbp), %xmm0
callq 0xfaa0
movss %xmm1, -0x1d8(%rbp)
movlpd %xmm0, -0x1e0(%rbp)
movl -0x1d8(%rbp), %eax
movl %eax, -0x1c8(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x11890
movq -0x248(%rbp), %rdi
movq -0x238(%rbp), %rax
movss %xmm1, -0x1e8(%rbp)
movlpd %xmm0, -0x1f0(%rbp)
movl -0x1e8(%rbp), %ecx
movl %ecx, -0x138(%rbp)
movq -0x1f0(%rbp), %rcx
movq %rcx, -0x140(%rbp)
movl -0x138(%rbp), %ecx
movl %ecx, 0x8(%rax)
movq -0x140(%rbp), %rcx
movq %rcx, (%rax)
movss -0x44(%rbp), %xmm0
addss %xmm0, %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm1, %xmm0
callq 0xfaa0
movq -0x240(%rbp), %rdi
movq -0x238(%rbp), %rax
movss %xmm1, -0x208(%rbp)
movlpd %xmm0, -0x210(%rbp)
movl -0x208(%rbp), %ecx
movl %ecx, -0x1f8(%rbp)
movq -0x210(%rbp), %rcx
movq %rcx, -0x200(%rbp)
movl -0x1f8(%rbp), %ecx
movl %ecx, 0x14(%rax)
movq -0x200(%rbp), %rcx
movq %rcx, 0xc(%rax)
movss -0x40(%rbp), %xmm0
addss %xmm0, %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm1, %xmm0
callq 0xfaa0
movq -0x238(%rbp), %rax
movss %xmm1, -0x228(%rbp)
movlpd %xmm0, -0x230(%rbp)
movq -0x230(%rbp), %rcx
movq %rcx, -0x21c(%rbp)
movl -0x228(%rbp), %ecx
movl %ecx, -0x214(%rbp)
movq -0x21c(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl -0x214(%rbp), %ecx
movl %ecx, 0x20(%rax)
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nop