// File: tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Isect.cpp
// Function: gaps::R3Intersects(gaps::R3Line const&, gaps::R3OrientedBox const&, gaps::R3Point*)
RNClassID R3Intersects(const R3Line& line, const R3OrientedBox& box, 
    R3Point *hit_point)
{
    // Check if box is empty
    if (box.IsEmpty()) return RN_NULL_CLASS_ID;

    // Transform line into std coordinate system
    R3Line transformed_line = line;
    R3Affine cs_to_std_xform(box.CoordSystem().InverseMatrix());
    transformed_line.Transform(cs_to_std_xform);

    // Intersect in std coordinate system
    R3Box axis_aligned_box(-box.Radius(0), -box.Radius(1), -box.Radius(2), box.Radius(0), box.Radius(1), box.Radius(2));
    int status = R3Intersects(transformed_line, axis_aligned_box, hit_point);
    if (status == RN_NULL_CLASS_ID) return RN_NULL_CLASS_ID;

    // Compute hit point
    if (hit_point) {
      R3Affine std_to_cs_xform(box.CoordSystem().Matrix());
      hit_point->Transform(std_to_cs_xform);
    }

    // Return whether hit
    return status;
}

// Assembly:
subq $0x438, %rsp            # imm = 0x438
movq %rdi, 0x428(%rsp)
movq %rsi, 0x420(%rsp)
movq %rdx, 0x418(%rsp)
movq 0x420(%rsp), %rdi
callq 0x3c180
cmpl $0x0, %eax
je 0x7a441
movl $0x0, 0x434(%rsp)
jmp 0x7a71e
movq 0x428(%rsp), %rsi
leaq 0x3e8(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x6e6e0
movq 0x420(%rsp), %rdi
callq 0x81bb0
movq %rax, %rsi
leaq 0x258(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x4e590
movq 0x60(%rsp), %rsi
leaq 0x2d8(%rsp), %rdi
movq %rdi, 0x70(%rsp)
xorl %edx, %edx
callq 0x4d390
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x6e9f0
jmp 0x7a4a7
movq 0x420(%rsp), %rdi
xorl %esi, %esi
callq 0x3c1d0
movsd %xmm0, 0x58(%rsp)
jmp 0x7a4be
movsd 0x58(%rsp), %xmm0
movaps 0xb8b65(%rip), %xmm1    # 0x133030
pxor %xmm1, %xmm0
movsd %xmm0, 0x48(%rsp)
movq 0x420(%rsp), %rdi
movl $0x1, %esi
callq 0x3c1d0
movsd %xmm0, 0x50(%rsp)
jmp 0x7a4ef
movsd 0x50(%rsp), %xmm0
movaps 0xb8b34(%rip), %xmm1    # 0x133030
pxor %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x420(%rsp), %rdi
movl $0x2, %esi
callq 0x3c1d0
movsd %xmm0, 0x40(%rsp)
jmp 0x7a520
movsd 0x40(%rsp), %xmm0
movaps 0xb8b03(%rip), %xmm1    # 0x133030
pxor %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x420(%rsp), %rdi
xorl %esi, %esi
callq 0x3c1d0
movsd %xmm0, 0x30(%rsp)
jmp 0x7a54e
movq 0x420(%rsp), %rdi
movl $0x1, %esi
callq 0x3c1d0
movsd %xmm0, 0x20(%rsp)
jmp 0x7a568
movq 0x420(%rsp), %rdi
movl $0x2, %esi
callq 0x3c1d0
movsd %xmm0, 0x18(%rsp)
jmp 0x7a582
movsd 0x18(%rsp), %xmm5
movsd 0x20(%rsp), %xmm4
movsd 0x30(%rsp), %xmm3
movsd 0x28(%rsp), %xmm2
movsd 0x38(%rsp), %xmm1
movsd 0x48(%rsp), %xmm0
leaq 0x210(%rsp), %rdi
callq 0x429c0
jmp 0x7a5b5
movq 0x418(%rsp), %rdx
leaq 0x3e8(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x79e10
movl %eax, 0x14(%rsp)
jmp 0x7a5d8
movl 0x14(%rsp), %eax
movl %eax, 0x20c(%rsp)
cmpl $0x0, 0x20c(%rsp)
jne 0x7a63a
movl $0x0, 0x434(%rsp)
movl $0x1, 0x208(%rsp)
jmp 0x7a6e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x250(%rsp)
movl %eax, 0x24c(%rsp)
jmp 0x7a70f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x250(%rsp)
movl %eax, 0x24c(%rsp)
jmp 0x7a702
cmpq $0x0, 0x418(%rsp)
je 0x7a6cd
movq 0x420(%rsp), %rdi
callq 0x81bb0
movq %rax, 0x8(%rsp)
jmp 0x7a65d
movq 0x8(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x4e500
jmp 0x7a66e
leaq 0xf8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
xorl %edx, %edx
callq 0x4d390
jmp 0x7a684
movq 0x418(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x6f7c0
jmp 0x7a69b
leaq 0xf8(%rsp), %rdi
callq 0x4d430
jmp 0x7a6cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x250(%rsp)
movl %eax, 0x24c(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x4d430
jmp 0x7a702
movl 0x20c(%rsp), %eax
movl %eax, 0x434(%rsp)
movl $0x1, 0x208(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x36a80
leaq 0x2d8(%rsp), %rdi
callq 0x4d430
jmp 0x7a71e
leaq 0x210(%rsp), %rdi
callq 0x36a80
leaq 0x2d8(%rsp), %rdi
callq 0x4d430
jmp 0x7a72d
movl 0x434(%rsp), %eax
addq $0x438, %rsp            # imm = 0x438
retq
movq 0x250(%rsp), %rdi
callq 0xf890
nopw (%rax,%rax)