// File: alan0201tw[P]RayTracer/src/transform.cpp
// Function: rotate_y::hit(ray const&, float, float, hit_record&) const
bool rotate_y::hit(const ray& _ray, float t_min, float t_max, hit_record& rec) const
{
    vec3 origin = _ray.origin();
    vec3 direction = _ray.direction();
    origin[0] = cos_theta * _ray.origin()[0] - sin_theta * _ray.origin()[2];
    origin[2] = sin_theta * _ray.origin()[0] + cos_theta * _ray.origin()[2];
    direction[0] = cos_theta * _ray.direction()[0] - sin_theta * _ray.direction()[2];
    direction[2] = sin_theta * _ray.direction()[0] + cos_theta * _ray.direction()[2];

    ray rotated_ray(origin, direction, _ray.get_time());
    if(target->hit(rotated_ray, t_min, t_max, rec) == true)
    {
        vec3 hit_point = rec.hit_point;
        vec3 normal = rec.normal;

        hit_point[0] = cos_theta * rec.hit_point[0] + sin_theta * rec.hit_point[2];
        hit_point[2] = -sin_theta * rec.hit_point[0] + cos_theta * rec.hit_point[2];
        normal[0] = cos_theta * rec.normal[0] + sin_theta * rec.normal[2];
        normal[2] = -sin_theta * rec.normal[0] + cos_theta * rec.normal[2];

        rec.hit_point = hit_point;
        rec.normal = normal;
        return true;
    }
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss %xmm1, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf870
movss %xmm1, -0x40(%rbp)
movlpd %xmm0, -0x48(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf8b0
movq -0x1a8(%rbp), %rax
movss %xmm1, -0x60(%rbp)
movlpd %xmm0, -0x68(%rbp)
movl -0x60(%rbp), %ecx
movl %ecx, -0x50(%rbp)
movq -0x68(%rbp), %rcx
movq %rcx, -0x58(%rbp)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x1f8(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf870
movss %xmm1, -0x80(%rbp)
movlpd %xmm0, -0x88(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
movl %esi, -0x1bc(%rbp)
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x1f4(%rbp)
movss 0x18(%rax), %xmm0
movss %xmm0, -0x1fc(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf870
movss %xmm1, -0xa0(%rbp)
movlpd %xmm0, -0xa8(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0x90(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
movl $0x2, %esi
movl %esi, -0x1d0(%rbp)
callq 0x1b400
movss -0x1fc(%rbp), %xmm1
movss -0x1f8(%rbp), %xmm0
movss -0x1f4(%rbp), %xmm2
movl -0x1bc(%rbp), %esi
movss (%rax), %xmm3
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x1f0(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x1b400
movss -0x1f0(%rbp), %xmm0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss %xmm0, (%rcx)
movss 0x18(%rax), %xmm0
movss %xmm0, -0x1e8(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf870
movl -0x1bc(%rbp), %esi
movss %xmm1, -0xc0(%rbp)
movlpd %xmm0, -0xc8(%rbp)
movl -0xc0(%rbp), %eax
movl %eax, -0xb0(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x1e4(%rbp)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x1ec(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf870
movl -0x1d0(%rbp), %esi
movss %xmm1, -0xe0(%rbp)
movlpd %xmm0, -0xe8(%rbp)
movl -0xe0(%rbp), %eax
movl %eax, -0xd0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x1b400
movss -0x1ec(%rbp), %xmm1
movss -0x1e8(%rbp), %xmm0
movss -0x1e4(%rbp), %xmm2
movq -0x1e0(%rbp), %rdi
movl -0x1d0(%rbp), %esi
movss (%rax), %xmm3
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x1d4(%rbp)
callq 0x1b400
movss -0x1d4(%rbp), %xmm0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss %xmm0, (%rcx)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x1c8(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf8b0
movl -0x1bc(%rbp), %esi
movss %xmm1, -0x100(%rbp)
movlpd %xmm0, -0x108(%rbp)
movl -0x100(%rbp), %eax
movl %eax, -0xf0(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x1c4(%rbp)
movss 0x18(%rax), %xmm0
movss %xmm0, -0x1cc(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf8b0
movl -0x1d0(%rbp), %esi
movss %xmm1, -0x120(%rbp)
movlpd %xmm0, -0x128(%rbp)
movl -0x120(%rbp), %eax
movl %eax, -0x110(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x1b400
movss -0x1cc(%rbp), %xmm1
movss -0x1c8(%rbp), %xmm0
movss -0x1c4(%rbp), %xmm2
movl -0x1bc(%rbp), %esi
movss (%rax), %xmm3
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x1c0(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x1b400
movss -0x1c0(%rbp), %xmm0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss %xmm0, (%rcx)
movss 0x18(%rax), %xmm0
movss %xmm0, -0x1b4(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf8b0
movl -0x1bc(%rbp), %esi
movss %xmm1, -0x140(%rbp)
movlpd %xmm0, -0x148(%rbp)
movl -0x140(%rbp), %eax
movl %eax, -0x130(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x1b0(%rbp)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x1b8(%rbp)
movq -0x18(%rbp), %rdi
callq 0xf8b0
movss %xmm1, -0x160(%rbp)
movlpd %xmm0, -0x168(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0x154(%rbp)
movl -0x160(%rbp), %eax
movl %eax, -0x14c(%rbp)
leaq -0x154(%rbp), %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x1b8(%rbp), %xmm1
movss -0x1b4(%rbp), %xmm0
movss -0x1b0(%rbp), %xmm2
mulss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x1ac(%rbp)
leaq -0x58(%rbp), %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x1ac(%rbp), %xmm0
movss %xmm0, (%rax)
movq -0x18(%rbp), %rdi
callq 0x11ae0
leaq -0x184(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x55430
movq -0x1a8(%rbp), %rdi
addq $0x8, %rdi
callq 0x105a0
movq %rax, %rdi
movss -0x1c(%rbp), %xmm0
movss -0x20(%rbp), %xmm1
movq -0x28(%rbp), %rdx
movq (%rdi), %rax
leaq -0x184(%rbp), %rsi
callq *(%rax)
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x553d2
movq -0x1a8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0xc(%rcx), %rdx
movq %rdx, -0x190(%rbp)
movl 0x14(%rcx), %ecx
movl %ecx, -0x188(%rbp)
movq -0x28(%rbp), %rcx
movq 0x18(%rcx), %rdx
movq %rdx, -0x19c(%rbp)
movl 0x20(%rcx), %ecx
movl %ecx, -0x194(%rbp)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x238(%rbp)
movq -0x28(%rbp), %rdi
addq $0xc, %rdi
xorl %esi, %esi
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x234(%rbp)
movss 0x18(%rax), %xmm0
movss %xmm0, -0x23c(%rbp)
movq -0x28(%rbp), %rdi
addq $0xc, %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x23c(%rbp), %xmm1
movss -0x238(%rbp), %xmm0
movss -0x234(%rbp), %xmm2
mulss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x230(%rbp)
leaq -0x190(%rbp), %rdi
xorl %esi, %esi
callq 0x1b400
movss -0x230(%rbp), %xmm0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss %xmm0, (%rcx)
movss 0x18(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x228(%rbp)
movq -0x28(%rbp), %rdi
addq $0xc, %rdi
xorl %esi, %esi
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x224(%rbp)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x22c(%rbp)
movq -0x28(%rbp), %rdi
addq $0xc, %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x22c(%rbp), %xmm1
movss -0x228(%rbp), %xmm0
movss -0x224(%rbp), %xmm2
mulss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x220(%rbp)
leaq -0x190(%rbp), %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x220(%rbp), %xmm0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss %xmm0, (%rcx)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x218(%rbp)
movq -0x28(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x214(%rbp)
movss 0x18(%rax), %xmm0
movss %xmm0, -0x21c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x18, %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x21c(%rbp), %xmm1
movss -0x218(%rbp), %xmm0
movss -0x214(%rbp), %xmm2
mulss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x210(%rbp)
leaq -0x19c(%rbp), %rdi
xorl %esi, %esi
callq 0x1b400
movss -0x210(%rbp), %xmm0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss %xmm0, (%rcx)
movss 0x18(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
movss %xmm0, -0x208(%rbp)
movq -0x28(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
callq 0x1b400
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movss (%rcx), %xmm0
movss %xmm0, -0x204(%rbp)
movss 0x1c(%rax), %xmm0
movss %xmm0, -0x20c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x18, %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x20c(%rbp), %xmm1
movss -0x208(%rbp), %xmm0
movss -0x204(%rbp), %xmm2
mulss (%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x200(%rbp)
leaq -0x19c(%rbp), %rdi
movl $0x2, %esi
callq 0x1b400
movss -0x200(%rbp), %xmm0
movss %xmm0, (%rax)
movq -0x28(%rbp), %rax
movq -0x190(%rbp), %rcx
movq %rcx, 0xc(%rax)
movl -0x188(%rbp), %ecx
movl %ecx, 0x14(%rax)
movq -0x28(%rbp), %rax
movq -0x19c(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl -0x194(%rbp), %ecx
movl %ecx, 0x20(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x553d6
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopw %cs:(%rax,%rax)