// File: Lut99[P]RayTracer/src/lib/Camera.cpp
// Function: RayTracer::Camera::get_ray(int, int) const
Ray Camera::get_ray(int x, int y) const {
    // Compute u and v
    double s, t;
    if (this->rays > 1) {
        s = double(x + random_double()) / double(this->width);
        t = double(this->height - 1 - y + random_double()) / double(this->height);
    } else {
        s = double(x) / double(this->width);
        t = double(this->height - 1 - y) / double(this->height);
    }

    // Return a ray shot through this pixel
    Vec3 rd = this->lens_radius * random_in_unit_disc();
    Vec3 offset = this->u * rd.x + this->v * rd.y;
    return Ray(this->origin + offset, this->lower_left_corner + s * this->horizontal + t * this->vertical - this->origin - offset);
}

// Assembly:
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, 0x28(%rsp)
movq %rdi, %rax
movq %rax, 0x30(%rsp)
movq %rdi, 0x1e0(%rsp)
movq %rsi, 0x1d8(%rsp)
movl %edx, 0x1d4(%rsp)
movl %ecx, 0x1d0(%rsp)
movq 0x1d8(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpl $0x1, 0x10(%rax)
jle 0x16137f
cvtsi2sdl 0x1d4(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x15eca0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl 0x8(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
movl 0xc(%rax), %eax
subl $0x1, %eax
subl 0x1d0(%rsp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%rsp)
callq 0x15eca0
movq 0x38(%rsp), %rax
movaps %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl 0xc(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x1c0(%rsp)
jmp 0x1613c2
movq 0x38(%rsp), %rax
cvtsi2sdl 0x1d4(%rsp), %xmm0
cvtsi2sdl 0x8(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rsp)
movl 0xc(%rax), %ecx
subl $0x1, %ecx
subl 0x1d0(%rsp), %ecx
cvtsi2sd %ecx, %xmm0
cvtsi2sdl 0xc(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x1c0(%rsp)
movq 0x38(%rsp), %rax
movsd 0x170(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x15eed0
movsd 0x8(%rsp), %xmm0
leaq 0x1a0(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x155ae0
movq 0x38(%rsp), %rsi
addq $0x110, %rsi            # imm = 0x110
movsd 0x1a8(%rsp), %xmm0
leaq 0x140(%rsp), %rdi
callq 0x155a80
movq 0x38(%rsp), %rsi
addq $0x150, %rsi            # imm = 0x150
movsd 0x1b0(%rsp), %xmm0
leaq 0x120(%rsp), %rdi
callq 0x155a80
leaq 0x160(%rsp), %rdi
leaq 0x140(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x1557b0
movq 0x38(%rsp), %rsi
addq $0xf0, %rsi
leaq 0x100(%rsp), %rdi
leaq 0x160(%rsp), %rdx
callq 0x1557b0
movq 0x38(%rsp), %rsi
movq %rsi, %rax
addq $0x90, %rax
movq %rax, 0x10(%rsp)
movsd 0x1c8(%rsp), %xmm0
addq $0xb0, %rsi
leaq 0x60(%rsp), %rdi
callq 0x155ae0
movq 0x10(%rsp), %rsi
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x1557b0
movq 0x38(%rsp), %rsi
movsd 0x1c0(%rsp), %xmm0
addq $0xd0, %rsi
leaq 0x40(%rsp), %rdi
callq 0x155ae0
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x1557b0
movq 0x38(%rsp), %rdx
addq $0xf0, %rdx
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x1558e0
leaq 0xe0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x160(%rsp), %rdx
callq 0x1558e0
movq 0x28(%rsp), %rdi
leaq 0x100(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x139c00
movq 0x30(%rsp), %rax
addq $0x1e8, %rsp            # imm = 0x1E8
retq
nopw %cs:(%rax,%rax)