#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 */
double glmDotProduct2d(double const *, double const *);
double glmRayLineIntersectiond(const double rayOrigin[2],
                               const double rayDirection[2],
                               const double lineOrigin[2],
                               const double lineNormal[2],
                               double intersection[2]) {
  double numer, denom, d;
  d = glmDotProduct2d(lineNormal, lineOrigin);
  numer = -glmDotProduct2d(lineNormal, rayOrigin) + d;
  denom = glmDotProduct2d(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):
<glmRayLineIntersectiond>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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 <glmDotProduct2d@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <glmDotProduct2d@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <glmDotProduct2d@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a8 <glmRayLineIntersectiond+0x98>
jp     11a8 <glmRayLineIntersectiond+0x98>
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1239 <glmRayLineIntersectiond+0x129>
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    11d7 <glmRayLineIntersectiond+0xc7>
movsd  0xe33(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1239 <glmRayLineIntersectiond+0x129>
cmpq   $0x0,-0x30(%rbp)
je     122f <glmRayLineIntersectiond+0x11f>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmRayLineIntersectiond>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rcx,%rdi
mov    %rdx,%rsi
call   1030 <glmDotProduct2d@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <glmDotProduct2d@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <glmDotProduct2d@plt>
movapd %xmm0,%xmm1
movsd  0xea0(%rip),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jne    116c <glmRayLineIntersectiond+0x5c>
jnp    11ba <glmRayLineIntersectiond+0xaa>
movsd  0x10(%rsp),%xmm3
subsd  0x8(%rsp),%xmm3
divsd  %xmm1,%xmm3
ucomisd %xmm3,%xmm2
ja     11ba <glmRayLineIntersectiond+0xaa>
movapd %xmm3,%xmm1
test   %r14,%r14
je     11b6 <glmRayLineIntersectiond+0xa6>
movsd  (%r12),%xmm0
mulsd  %xmm1,%xmm0
addsd  (%r15),%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%r12),%xmm0
mulsd  %xmm1,%xmm0
addsd  0x8(%r15),%xmm0
movsd  %xmm0,0x8(%r14)
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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