#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
float glmDotProduct2f(float const *, float const *);
float glmRayLineIntersectionf(const float rayOrigin[2],
                              const float rayDirection[2],
                              const float lineOrigin[2],
                              const float lineNormal[2],
                              float intersection[2]) {
  float numer, denom, d;
  d = glmDotProduct2f(lineNormal, lineOrigin);
  numer = -glmDotProduct2f(lineNormal, rayOrigin) + d;
  denom = glmDotProduct2f(lineNormal, rayDirection);
  if (denom == 0)
    return -1;
  d = numer / denom;
  if (d < 0)
    return -1;
  if (intersection) {
    intersection[0] = rayOrigin[0] + d * rayDirection[0];
    intersection[1] = rayOrigin[1] + d * rayDirection[1];
  }
  return d;
}


x86 assembly (clang, -O0):
<glmRayLineIntersectionf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <glmDotProduct2f@plt>
movss  %xmm0,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <glmDotProduct2f@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
addss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <glmDotProduct2f@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    119d <glmRayLineIntersectionf+0x8d>
jp     119d <glmRayLineIntersectionf+0x8d>
movss  0xe6d(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    122d <glmRayLineIntersectionf+0x11d>
movss  -0x34(%rbp),%xmm0
divss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x3c(%rbp),%xmm0
jbe    11cb <glmRayLineIntersectionf+0xbb>
movss  0xe3f(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    122d <glmRayLineIntersectionf+0x11d>
cmpq   $0x0,-0x30(%rbp)
je     1223 <glmRayLineIntersectionf+0x113>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x3c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm1
movss  -0x3c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmRayLineIntersectionf>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rcx,%rdi
mov    %rdx,%rsi
call   1030 <glmDotProduct2f@plt>
movss  %xmm0,0x4(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <glmDotProduct2f@plt>
movss  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <glmDotProduct2f@plt>
movaps %xmm0,%xmm1
movss  0xea5(%rip),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jne    1165 <glmRayLineIntersectionf+0x55>
jnp    11af <glmRayLineIntersectionf+0x9f>
movss  0x4(%rsp),%xmm3
subss  (%rsp),%xmm3
divss  %xmm1,%xmm3
ucomiss %xmm3,%xmm2
ja     11af <glmRayLineIntersectionf+0x9f>
movaps %xmm3,%xmm1
test   %r14,%r14
je     11ac <glmRayLineIntersectionf+0x9c>
movss  (%r12),%xmm0
mulss  %xmm1,%xmm0
addss  (%r15),%xmm0
movss  %xmm0,(%r14)
movss  0x4(%r12),%xmm0
mulss  %xmm1,%xmm0
addss  0x4(%r15),%xmm0
movss  %xmm0,0x4(%r14)
movaps %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @glmRayLineIntersectionf(float* %0, float* %1, float* %2, float* %3, float* %4) {
%6 = alloca float
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca float
%13 = alloca float
%14 = alloca float
store float* %0, float** %7
store float* %1, float** %8
store float* %2, float** %9
store float* %3, float** %10
store float* %4, float** %11
%15 = load float*, float** %10
%16 = load float*, float** %9
%17 = call float @glmDotProduct2f(float* %15, float* %16)
store float %17, float* %14
%18 = load float*, float** %10
%19 = load float*, float** %7
%20 = call float @glmDotProduct2f(float* %18, float* %19)
%21 = fneg float %20
%22 = load float, float* %14
%23 = fadd float %21, %22
store float %23, float* %12
%24 = load float*, float** %10
%25 = load float*, float** %8
%26 = call float @glmDotProduct2f(float* %24, float* %25)
store float %26, float* %13
%27 = load float, float* %13
%28 = fcmp oeq float %27, 0.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %5
store float -1.000000e+00, float* %6
br label %63
30: ; preds = %5
%31 = load float, float* %12
%32 = load float, float* %13
%33 = fdiv float %31, %32
store float %33, float* %14
%34 = load float, float* %14
%35 = fcmp olt float %34, 0.000000e+00
br i1 %35, label %36, label %37
36: ; preds = %30
store float -1.000000e+00, float* %6
br label %63
37: ; preds = %30
%38 = load float*, float** %11
%39 = icmp ne float* %38, null
br i1 %39, label %40, label %61
40: ; preds = %37
%41 = load float*, float** %7
%42 = getelementptr inbounds float, float* %41, i64 0
%43 = load float, float* %42
%44 = load float, float* %14
%45 = load float*, float** %8
%46 = getelementptr inbounds float, float* %45, i64 0
%47 = load float, float* %46
%48 = call float @llvm.fmuladd.f32(float %44, float %47, float %43)
%49 = load float*, float** %11
%50 = getelementptr inbounds float, float* %49, i64 0
store float %48, float* %50
%51 = load float*, float** %7
%52 = getelementptr inbounds float, float* %51, i64 1
%53 = load float, float* %52
%54 = load float, float* %14
%55 = load float*, float** %8
%56 = getelementptr inbounds float, float* %55, i64 1
%57 = load float, float* %56
%58 = call float @llvm.fmuladd.f32(float %54, float %57, float %53)
%59 = load float*, float** %11
%60 = getelementptr inbounds float, float* %59, i64 1
store float %58, float* %60
br label %61
61: ; preds = %40, %37
%62 = load float, float* %14
store float %62, float* %6
br label %63
63: ; preds = %61, %36, %29
%64 = load float, float* %6
ret float %64
}

LLVM IR (-O2):
define float @glmRayLineIntersectionf(float* %0, float* %1, float* %2, float* %3, float* writeonly %4) {
%6 = tail call float @glmDotProduct2f(float* %3, float* %2)
%7 = tail call float @glmDotProduct2f(float* %3, float* %0)
%8 = tail call float @glmDotProduct2f(float* %3, float* %1)
%9 = fcmp oeq float %8, 0.000000e+00
br i1 %9, label %26, label %10
10: ; preds = %5
%11 = fsub float %6, %7
%12 = fdiv float %11, %8
%13 = fcmp olt float %12, 0.000000e+00
br i1 %13, label %26, label %14
14: ; preds = %10
%15 = icmp eq float* %4, null
br i1 %15, label %26, label %16
16: ; preds = %14
%17 = load float, float* %0
%18 = load float, float* %1
%19 = tail call float @llvm.fmuladd.f32(float %12, float %18, float %17)
store float %19, float* %4
%20 = getelementptr inbounds float, float* %0, i64 1
%21 = load float, float* %20
%22 = getelementptr inbounds float, float* %1, i64 1
%23 = load float, float* %22
%24 = tail call float @llvm.fmuladd.f32(float %12, float %23, float %21)
%25 = getelementptr inbounds float, float* %4, i64 1
store float %24, float* %25
br label %26
26: ; preds = %14, %16, %10, %5
%27 = phi float [ -1.000000e+00, %5 ], [ -1.000000e+00, %10 ], [ %12, %16 ], [ %12, %14 ]
ret float %27
}