#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 *, float const *);
int /*<<< orphan*/ glmSubtractVector3f(float *, float const *, float const *);
void glmClosestPointOnPlane3f(float result[3], const float planeOrigin[3],
                              const float planeNormal[3], const float p[3]) {
  float temp[3];
  float d;
  glmSubtractVector3f(temp, p, planeOrigin);
  d = glmDotProduct3f(temp, planeNormal);
  result[0] = p[0] - d * planeNormal[0];
  result[1] = p[1] - d * planeNormal[1];
  result[2] = p[2] - d * planeNormal[2];
}


x86 assembly (clang, -O0):
<glmClosestPointOnPlane3f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x2c(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <glmSubtractVector3f@plt>
lea    -0x2c(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <glmDotProduct3f@plt>
movss  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm1
movss  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  0x4(%rax),%xmm1
movss  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
movss  0x8(%rax),%xmm1
movss  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmClosestPointOnPlane3f>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0xc(%rsp),%r12
mov    %r12,%rdi
mov    %rcx,%rsi
call   1030 <glmSubtractVector3f@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <glmDotProduct3f@plt>
movss  (%rbx),%xmm1
movss  (%r15),%xmm2
mulss  %xmm0,%xmm2
subss  %xmm2,%xmm1
movss  %xmm1,(%r14)
movss  0x4(%rbx),%xmm1
movss  0x4(%r15),%xmm2
mulss  %xmm0,%xmm2
subss  %xmm2,%xmm1
movss  %xmm1,0x4(%r14)
movss  0x8(%rbx),%xmm1
mulss  0x8(%r15),%xmm0
subss  %xmm0,%xmm1
movss  %xmm1,0x8(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @glmClosestPointOnPlane3f(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca [3 x float]
%10 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%11 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%12 = load float*, float** %8
%13 = load float*, float** %6
%14 = call i32 @glmSubtractVector3f(float* %11, float* %12, float* %13)
%15 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%16 = load float*, float** %7
%17 = call float @glmDotProduct3f(float* %15, float* %16)
store float %17, float* %10
%18 = load float*, float** %8
%19 = getelementptr inbounds float, float* %18, i64 0
%20 = load float, float* %19
%21 = load float, float* %10
%22 = load float*, float** %7
%23 = getelementptr inbounds float, float* %22, i64 0
%24 = load float, float* %23
%25 = fneg float %21
%26 = call float @llvm.fmuladd.f32(float %25, float %24, float %20)
%27 = load float*, float** %5
%28 = getelementptr inbounds float, float* %27, i64 0
store float %26, float* %28
%29 = load float*, float** %8
%30 = getelementptr inbounds float, float* %29, i64 1
%31 = load float, float* %30
%32 = load float, float* %10
%33 = load float*, float** %7
%34 = getelementptr inbounds float, float* %33, i64 1
%35 = load float, float* %34
%36 = fneg float %32
%37 = call float @llvm.fmuladd.f32(float %36, float %35, float %31)
%38 = load float*, float** %5
%39 = getelementptr inbounds float, float* %38, i64 1
store float %37, float* %39
%40 = load float*, float** %8
%41 = getelementptr inbounds float, float* %40, i64 2
%42 = load float, float* %41
%43 = load float, float* %10
%44 = load float*, float** %7
%45 = getelementptr inbounds float, float* %44, i64 2
%46 = load float, float* %45
%47 = fneg float %43
%48 = call float @llvm.fmuladd.f32(float %47, float %46, float %42)
%49 = load float*, float** %5
%50 = getelementptr inbounds float, float* %49, i64 2
store float %48, float* %50
ret void
}

LLVM IR (-O2):
define void @glmClosestPointOnPlane3f(float* nocapture writeonly %0, float* %1, float* %2, float* %3) {
%5 = alloca [3 x float]
%6 = bitcast [3 x float]* %5 to i8*
%7 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
%8 = call i32 @glmSubtractVector3f(float* %7, float* %3, float* %1)
%9 = call float @glmDotProduct3f(float* %7, float* %2)
%10 = load float, float* %3
%11 = load float, float* %2
%12 = fneg float %9
%13 = call float @llvm.fmuladd.f32(float %12, float %11, float %10)
store float %13, float* %0
%14 = getelementptr inbounds float, float* %3, i64 1
%15 = load float, float* %14
%16 = getelementptr inbounds float, float* %2, i64 1
%17 = load float, float* %16
%18 = call float @llvm.fmuladd.f32(float %12, float %17, float %15)
%19 = getelementptr inbounds float, float* %0, i64 1
store float %18, float* %19
%20 = getelementptr inbounds float, float* %3, i64 2
%21 = load float, float* %20
%22 = getelementptr inbounds float, float* %2, i64 2
%23 = load float, float* %22
%24 = call float @llvm.fmuladd.f32(float %12, float %23, float %21)
%25 = getelementptr inbounds float, float* %0, i64 2
store float %24, float* %25
ret void
}