#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 glmDotProduct4f(float const *, float const *);
float glmRaySpaceIntersectionf(const float rayOrigin[4],
                               const float rayDirection[4],
                               const float spaceOrigin[4],
                               const float spaceNormal[4],
                               float intersection[4]) {
  float numer, denom, d;
  d = glmDotProduct4f(spaceNormal, spaceOrigin);
  numer = -glmDotProduct4f(spaceNormal, rayOrigin) + d;
  denom = glmDotProduct4f(spaceNormal, 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];
    intersection[3] = rayOrigin[3] + d * rayDirection[3];
  }
  return d;
}


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

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

LLVM IR (-O0):
define float @glmRaySpaceIntersectionf(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 @glmDotProduct4f(float* %15, float* %16)
store float %17, float* %14
%18 = load float*, float** %10
%19 = load float*, float** %7
%20 = call float @glmDotProduct4f(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 @glmDotProduct4f(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 %83
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 %83
37: ; preds = %30
%38 = load float*, float** %11
%39 = icmp ne float* %38, null
br i1 %39, label %40, label %81
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
%71 = load float*, float** %7
%72 = getelementptr inbounds float, float* %71, i64 3
%73 = load float, float* %72
%74 = load float, float* %14
%75 = load float*, float** %8
%76 = getelementptr inbounds float, float* %75, i64 3
%77 = load float, float* %76
%78 = call float @llvm.fmuladd.f32(float %74, float %77, float %73)
%79 = load float*, float** %11
%80 = getelementptr inbounds float, float* %79, i64 3
store float %78, float* %80
br label %81
81: ; preds = %40, %37
%82 = load float, float* %14
store float %82, float* %6
br label %83
83: ; preds = %81, %36, %29
%84 = load float, float* %6
ret float %84
}

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