// File: koraa[P]sbcrack/cube/geom.cpp
// Function: rayrectintersect(vec const&, vec const&, vec const&, vec const&, float&, int&)
bool rayrectintersect(const vec &b, const vec &s, const vec &o, const vec &ray, float &dist, int &orient)
{
    loop(d, 3) if(ray[d])
    {
        int dc = ray[d]<0 ? 1 : 0;
        float pdist = (b[d]+s[d]*dc - o[d]) / ray[d];
        vec v(ray);
        v.mul(pdist).add(o);
        if(v[R[d]] >= b[R[d]] && v[R[d]] <= b[R[d]]+s[R[d]]
        && v[C[d]] >= b[C[d]] && v[C[d]] <= b[C[d]]+s[C[d]])
        {
            dist = pdist;
            orient = 2*d+dc;
            return true;
        }
    }
    return false;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %r9, 0x40(%rsp)
movl $0x0, 0x3c(%rsp)
cmpl $0x3, 0x3c(%rsp)
jge 0xd34a
movq 0x50(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xd990
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xd0b2
jp 0xd0b2
jmp 0xd338
movq 0x50(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xd990
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x1, %ecx
ucomiss %xmm1, %xmm0
cmoval %ecx, %eax
movl %eax, 0x38(%rsp)
movq 0x68(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xd990
movss %xmm0, 0x18(%rsp)
movq 0x60(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xd990
movaps %xmm0, %xmm1
movss 0x18(%rsp), %xmm0
cvtsi2ssl 0x38(%rsp), %xmm2
mulss %xmm2, %xmm1
addss %xmm1, %xmm0
movss %xmm0, 0x1c(%rsp)
movq 0x58(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xd990
movaps %xmm0, %xmm1
movss 0x1c(%rsp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x20(%rsp)
movq 0x50(%rsp), %rdi
movl 0x3c(%rsp), %esi
callq 0xd990
movaps %xmm0, %xmm1
movss 0x20(%rsp), %xmm0
divss %xmm1, %xmm0
movss %xmm0, 0x34(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x28(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x30(%rsp)
movss 0x34(%rsp), %xmm0
leaq 0x28(%rsp), %rdi
callq 0xd9b0
movq %rax, %rdi
movq 0x58(%rsp), %rsi
callq 0xd9f0
movslq 0x3c(%rsp), %rcx
leaq 0x12fb(%rip), %rax      # 0xe490
movl (%rax,%rcx,4), %esi
leaq 0x28(%rsp), %rdi
callq 0xda40
movss (%rax), %xmm0
movss %xmm0, 0x24(%rsp)
movq 0x68(%rsp), %rdi
movslq 0x3c(%rsp), %rcx
leaq 0x12d3(%rip), %rax      # 0xe490
movl (%rax,%rcx,4), %esi
callq 0xd990
movaps %xmm0, %xmm1
movss 0x24(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jb 0xd336
movslq 0x3c(%rsp), %rcx
leaq 0x12ad(%rip), %rax      # 0xe490
movl (%rax,%rcx,4), %esi
leaq 0x28(%rsp), %rdi
callq 0xda40
movss (%rax), %xmm0
movss %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rdi
movslq 0x3c(%rsp), %rcx
leaq 0x1285(%rip), %rax      # 0xe490
movl (%rax,%rcx,4), %esi
callq 0xd990
movss %xmm0, 0x14(%rsp)
movq 0x60(%rsp), %rdi
movslq 0x3c(%rsp), %rcx
leaq 0x1266(%rip), %rax      # 0xe490
movl (%rax,%rcx,4), %esi
callq 0xd990
movss 0x10(%rsp), %xmm1
movaps %xmm0, %xmm2
movss 0x14(%rsp), %xmm0
addss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jb 0xd336
movslq 0x3c(%rsp), %rcx
leaq 0x1242(%rip), %rax      # 0xe49c
movl (%rax,%rcx,4), %esi
leaq 0x28(%rsp), %rdi
callq 0xda40
movss (%rax), %xmm0
movss %xmm0, 0xc(%rsp)
movq 0x68(%rsp), %rdi
movslq 0x3c(%rsp), %rcx
leaq 0x121a(%rip), %rax      # 0xe49c
movl (%rax,%rcx,4), %esi
callq 0xd990
movaps %xmm0, %xmm1
movss 0xc(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jb 0xd336
movslq 0x3c(%rsp), %rcx
leaq 0x11f4(%rip), %rax      # 0xe49c
movl (%rax,%rcx,4), %esi
leaq 0x28(%rsp), %rdi
callq 0xda40
movss (%rax), %xmm0
movss %xmm0, 0x4(%rsp)
movq 0x68(%rsp), %rdi
movslq 0x3c(%rsp), %rcx
leaq 0x11cc(%rip), %rax      # 0xe49c
movl (%rax,%rcx,4), %esi
callq 0xd990
movss %xmm0, 0x8(%rsp)
movq 0x60(%rsp), %rdi
movslq 0x3c(%rsp), %rcx
leaq 0x11ad(%rip), %rax      # 0xe49c
movl (%rax,%rcx,4), %esi
callq 0xd990
movss 0x4(%rsp), %xmm1
movaps %xmm0, %xmm2
movss 0x8(%rsp), %xmm0
addss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jb 0xd336
movss 0x34(%rsp), %xmm0
movq 0x48(%rsp), %rax
movss %xmm0, (%rax)
movl 0x3c(%rsp), %ecx
shll %ecx
addl 0x38(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movb $0x1, 0x77(%rsp)
jmp 0xd34f
jmp 0xd338
jmp 0xd33a
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0xd08a
movb $0x0, 0x77(%rsp)
movb 0x77(%rsp), %al
andb $0x1, %al
addq $0x78, %rsp
retq
nopw (%rax,%rax)