#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 glmDotProduct3f(float const *, float const *);
float glmRayPlaneIntersectionf(const float rayOrigin[3],
                               const float rayDirection[3],
                               const float planeOrigin[3],
                               const float planeNormal[3],
                               float intersection[3]) {
  float numer, denom, d;
  d = glmDotProduct3f(planeNormal, planeOrigin);
  numer = -glmDotProduct3f(planeNormal, rayOrigin) + d;
  denom = glmDotProduct3f(planeNormal, 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];
    intersection[2] = rayOrigin[2] + d * rayDirection[2];
  }
  return d;
}


x86 assembly (clang, -O0):
<glmRayPlaneIntersectionf>:
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 <glmDotProduct3f@plt>
movss  %xmm0,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <glmDotProduct3f@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 <glmDotProduct3f@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    119d <glmRayPlaneIntersectionf+0x8d>
jp     119d <glmRayPlaneIntersectionf+0x8d>
movss  0xe6d(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1255 <glmRayPlaneIntersectionf+0x145>
movss  -0x34(%rbp),%xmm0
divss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x3c(%rbp),%xmm0
jbe    11cb <glmRayPlaneIntersectionf+0xbb>
movss  0xe3f(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1255 <glmRayPlaneIntersectionf+0x145>
cmpq   $0x0,-0x30(%rbp)
je     124b <glmRayPlaneIntersectionf+0x13b>
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)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm1
movss  -0x3c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmRayPlaneIntersectionf>:
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 <glmDotProduct3f@plt>
movss  %xmm0,0x4(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <glmDotProduct3f@plt>
movss  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <glmDotProduct3f@plt>
movaps %xmm0,%xmm1
movss  0xea5(%rip),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm1
jne    1165 <glmRayPlaneIntersectionf+0x55>
jnp    11c6 <glmRayPlaneIntersectionf+0xb6>
movss  0x4(%rsp),%xmm3
subss  (%rsp),%xmm3
divss  %xmm1,%xmm3
ucomiss %xmm3,%xmm2
ja     11c6 <glmRayPlaneIntersectionf+0xb6>
movaps %xmm3,%xmm1
test   %r14,%r14
je     11c3 <glmRayPlaneIntersectionf+0xb3>
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)
movss  0x8(%r12),%xmm0
mulss  %xmm1,%xmm0
addss  0x8(%r15),%xmm0
movss  %xmm0,0x8(%r14)
movaps %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @glmRayPlaneIntersectionf(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 @glmDotProduct3f(float* %15, float* %16)
store float %17, float* %14
%18 = load float*, float** %10
%19 = load float*, float** %7
%20 = call float @glmDotProduct3f(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 @glmDotProduct3f(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 %73
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 %73
37: ; preds = %30
%38 = load float*, float** %11
%39 = icmp ne float* %38, null
br i1 %39, label %40, label %71
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
%61 = load float*, float** %7
%62 = getelementptr inbounds float, float* %61, i64 2
%63 = load float, float* %62
%64 = load float, float* %14
%65 = load float*, float** %8
%66 = getelementptr inbounds float, float* %65, i64 2
%67 = load float, float* %66
%68 = call float @llvm.fmuladd.f32(float %64, float %67, float %63)
%69 = load float*, float** %11
%70 = getelementptr inbounds float, float* %69, i64 2
store float %68, float* %70
br label %71
71: ; preds = %40, %37
%72 = load float, float* %14
store float %72, float* %6
br label %73
73: ; preds = %71, %36, %29
%74 = load float, float* %6
ret float %74
}

LLVM IR (-O2):
define float @glmRayPlaneIntersectionf(float* %0, float* %1, float* %2, float* %3, float* writeonly %4) {
%6 = tail call float @glmDotProduct3f(float* %3, float* %2)
%7 = tail call float @glmDotProduct3f(float* %3, float* %0)
%8 = tail call float @glmDotProduct3f(float* %3, float* %1)
%9 = fcmp oeq float %8, 0.000000e+00
br i1 %9, label %32, 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 %32, label %14
14: ; preds = %10
%15 = icmp eq float* %4, null
br i1 %15, label %32, 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
%26 = getelementptr inbounds float, float* %0, i64 2
%27 = load float, float* %26
%28 = getelementptr inbounds float, float* %1, i64 2
%29 = load float, float* %28
%30 = tail call float @llvm.fmuladd.f32(float %12, float %29, float %27)
%31 = getelementptr inbounds float, float* %4, i64 2
store float %30, float* %31
br label %32
32: ; preds = %14, %16, %10, %5
%33 = phi float [ -1.000000e+00, %5 ], [ -1.000000e+00, %10 ], [ %12, %16 ], [ %12, %14 ]
ret float %33
}