// File: /workspace/github_cpp_makefile_star2_O1/koraa[P]sbcrack/cube/geom.cpp
// Function: linecylinderintersect(vec const&, vec const&, vec const&, vec const&, float, float&)
bool linecylinderintersect(const vec &from, const vec &to, const vec &start, const vec &end, float radius, float &dist)
{
    vec d(end), m(from), n(to);
    d.sub(start);
    m.sub(start);
    n.sub(from);
    float md = m.dot(d),
          nd = n.dot(d),
          dd = d.squaredlen();
    if(md < 0 && md + nd < 0) return false;
    if(md > dd && md + nd > dd) return false;
    float nn = n.squaredlen(),
          mn = m.dot(n),
          a = dd*nn - nd*nd,
          k = m.squaredlen() - radius*radius,
          c = dd*k - md*md;
    if(fabs(a) < 0.005f)
    {
        if(c > 0) return false;
        if(md < 0) dist = -mn / nn;
        else if(md > dd) dist = (nd - mn) / nn;
        else dist = 0;
        return true;
    }
    else if(c > 0)
    {
        float b = dd*mn - nd*md,
              discrim = b*b - a*c;
        if(discrim < 0) return false;
        dist = (-b - sqrtf(discrim)) / a;
    }
    else dist = 0;
    float offset = md + dist*nd;
    if(offset < 0)
    {
        if(nd <= 0) return false;
        dist = -md / nd;
        if(k + dist*(2*mn + dist*nn) > 0) return false;
    }
    else if(offset > dd)
    {
        if(nd >= 0) return false;
        dist = (dd - md) / nd;
        if(k + dd - 2*md + dist*(2*(mn-nd) + dist*nn) > 0) return false;
    }
    return dist >= 0 && dist <= 1;
}

// Assembly:
movss 0x8(%rcx), %xmm2
movss 0x8(%rdx), %xmm3
subss %xmm3, %xmm2
movss (%rsi), %xmm1
movss 0x4(%rsi), %xmm4
movss 0x8(%rsi), %xmm5
movss (%rdi), %xmm8
movss 0x4(%rdi), %xmm9
movss 0x8(%rdi), %xmm6
movaps %xmm9, %xmm7
unpcklps %xmm1, %xmm7            # xmm7 = xmm7[0],xmm1[0],xmm7[1],xmm1[1]
movaps %xmm8, %xmm1
unpcklps %xmm4, %xmm1            # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
unpcklps %xmm6, %xmm3            # xmm3 = xmm3[0],xmm6[0],xmm3[1],xmm6[1]
unpcklps %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0],xmm6[1],xmm5[1]
subps %xmm3, %xmm6
movaps %xmm2, %xmm5
mulss %xmm6, %xmm5
movsd (%rcx), %xmm4
movsd (%rdx), %xmm3
subps %xmm3, %xmm4
shufps $0xd4, %xmm3, %xmm8     # xmm8 = xmm8[0,1],xmm3[1,3]
shufps $0x52, %xmm3, %xmm8     # xmm8 = xmm8[2,0],xmm3[1,1]
subps %xmm8, %xmm7
movlhps %xmm3, %xmm9            # xmm9 = xmm9[0],xmm3[0]
shufps $0xe2, %xmm3, %xmm9     # xmm9 = xmm9[2,0],xmm3[2,3]
subps %xmm9, %xmm1
movaps %xmm4, %xmm8
mulss %xmm1, %xmm8
movaps %xmm4, %xmm3
shufps $0x55, %xmm4, %xmm3     # xmm3 = xmm3[1,1],xmm4[1,1]
mulss %xmm7, %xmm3
addss %xmm8, %xmm3
addss %xmm5, %xmm3
movaps %xmm1, %xmm5
shufps $0x1, %xmm4, %xmm5      # xmm5 = xmm5[1,0],xmm4[0,0]
shufps $0xe2, %xmm4, %xmm5     # xmm5 = xmm5[2,0],xmm4[2,3]
mulps %xmm4, %xmm5
movaps %xmm7, %xmm8
shufps $0x55, %xmm4, %xmm8     # xmm8 = xmm8[1,1],xmm4[1,1]
shufps $0xe2, %xmm4, %xmm8     # xmm8 = xmm8[2,0],xmm4[2,3]
shufps $0xe1, %xmm4, %xmm4     # xmm4 = xmm4[1,0,2,3]
mulps %xmm8, %xmm4
addps %xmm5, %xmm4
movaps %xmm6, %xmm5
movss %xmm2, %xmm5            # xmm5 = xmm2[0],xmm5[1,2,3]
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
mulps %xmm5, %xmm2
addps %xmm4, %xmm2
movaps %xmm2, %xmm4
shufps $0x55, %xmm2, %xmm4     # xmm4 = xmm4[1,1],xmm2[1,1]
xorps %xmm8, %xmm8
ucomiss %xmm8, %xmm3
movaps %xmm3, %xmm5
addss %xmm4, %xmm5
jae 0x474d
ucomiss %xmm8, %xmm5
jb 0x4757
ucomiss %xmm2, %xmm3
jbe 0x475a
ucomiss %xmm2, %xmm5
jbe 0x475a
xorl %eax, %eax
retq
movaps %xmm7, %xmm8
shufps $0x11, %xmm1, %xmm8     # xmm8 = xmm8[1,0],xmm1[1,0]
movaps %xmm8, %xmm5
shufps $0xe2, %xmm1, %xmm5     # xmm5 = xmm5[2,0],xmm1[2,3]
mulps %xmm7, %xmm5
shufps $0xe8, %xmm1, %xmm8     # xmm8 = xmm8[0,2],xmm1[2,3]
mulps %xmm1, %xmm8
addps %xmm5, %xmm8
movaps %xmm6, %xmm5
shufps $0x55, %xmm6, %xmm5     # xmm5 = xmm5[1,1],xmm6[1,1]
mulps %xmm6, %xmm5
addps %xmm8, %xmm5
movaps %xmm2, %xmm8
shufps $0x11, %xmm5, %xmm8     # xmm8 = xmm8[1,0],xmm5[1,0]
shufps $0xe2, %xmm5, %xmm8     # xmm8 = xmm8[2,0],xmm5[2,3]
mulps %xmm2, %xmm8
movaps %xmm8, %xmm9
shufps $0x55, %xmm8, %xmm9     # xmm9 = xmm9[1,1],xmm8[1,1]
subss %xmm9, %xmm8
mulss %xmm1, %xmm1
mulss %xmm7, %xmm7
mulss %xmm6, %xmm6
addss %xmm7, %xmm6
mulss %xmm0, %xmm0
subss %xmm0, %xmm1
addss %xmm6, %xmm1
movaps %xmm1, %xmm6
mulss %xmm2, %xmm6
movaps %xmm3, %xmm0
mulss %xmm3, %xmm0
subss %xmm0, %xmm6
movaps 0x9e2(%rip), %xmm0      # 0x51c0
andps %xmm8, %xmm0
ucomiss 0x9fb(%rip), %xmm0      # 0x51e4
jae 0x481c
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm6
ja 0x4757
ucomiss %xmm0, %xmm3
jae 0x493d
movaps 0x9a9(%rip), %xmm0      # 0x51b0
xorps %xmm5, %xmm0
shufps $0x55, %xmm5, %xmm5     # xmm5 = xmm5[1,1,1,1]
divss %xmm5, %xmm0
movss %xmm0, (%r8)
jmp 0x495c
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm6
xorps %xmm7, %xmm7
jbe 0x4879
movaps %xmm3, %xmm7
movlhps %xmm5, %xmm7            # xmm7 = xmm7[0],xmm5[0]
shufps $0xe2, %xmm5, %xmm7     # xmm7 = xmm7[2,0],xmm5[2,3]
movaps %xmm2, %xmm9
mulps %xmm7, %xmm9
movaps %xmm9, %xmm7
shufps $0x55, %xmm9, %xmm7     # xmm7 = xmm7[1,1],xmm9[1,1]
subps %xmm7, %xmm9
movaps %xmm9, %xmm7
mulss %xmm9, %xmm7
mulss %xmm8, %xmm6
subss %xmm6, %xmm7
xorps %xmm6, %xmm6
ucomiss %xmm6, %xmm7
jb 0x4757
sqrtss %xmm7, %xmm7
addss %xmm9, %xmm7
xorps 0x93c(%rip), %xmm7      # 0x51b0
divss %xmm8, %xmm7
movss %xmm7, (%r8)
mulss %xmm4, %xmm7
addss %xmm3, %xmm7
ucomiss %xmm0, %xmm7
jae 0x48cf
ucomiss %xmm0, %xmm4
jbe 0x4757
xorps 0x915(%rip), %xmm3      # 0x51b0
divss %xmm4, %xmm3
movss %xmm3, (%r8)
movaps 0x925(%rip), %xmm2      # 0x51d0
unpcklps %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
mulps %xmm5, %xmm2
movaps %xmm2, %xmm4
shufps $0x55, %xmm2, %xmm4     # xmm4 = xmm4[1,1],xmm2[1,1]
addss %xmm2, %xmm4
mulss %xmm3, %xmm4
addss %xmm1, %xmm4
ucomiss %xmm0, %xmm4
ja 0x4757
jmp 0x491e
ucomiss %xmm2, %xmm7
jbe 0x491e
ucomiss %xmm0, %xmm4
jae 0x4757
addss %xmm2, %xmm1
subss %xmm3, %xmm2
divss %xmm4, %xmm2
movss %xmm2, (%r8)
addss %xmm3, %xmm3
subss %xmm3, %xmm1
movaps %xmm5, %xmm3
subss %xmm4, %xmm3
addss %xmm3, %xmm3
shufps $0x55, %xmm5, %xmm5     # xmm5 = xmm5[1,1,1,1]
mulss %xmm2, %xmm5
addss %xmm3, %xmm5
mulss %xmm2, %xmm5
addss %xmm1, %xmm5
ucomiss %xmm0, %xmm5
ja 0x4757
movss (%r8), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
setbe %cl
movss 0x8ac(%rip), %xmm1      # 0x51e0
ucomiss %xmm0, %xmm1
setae %al
andb %cl, %al
retq
ucomiss %xmm2, %xmm3
jbe 0x4955
subss %xmm5, %xmm4
shufps $0x55, %xmm5, %xmm5     # xmm5 = xmm5[1,1,1,1]
divss %xmm5, %xmm4
movss %xmm4, (%r8)
jmp 0x495c
movl $0x0, (%r8)
movb $0x1, %al
retq