#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 glmDotProduct3d(double *, double const *);
int /*<<< orphan*/ glmSubtractVector3d(double *, double const *,
                                       double const *);
void glmClosestPointOnPlane3d(double result[3], const double planeOrigin[3],
                              const double planeNormal[3], const double p[3]) {
  double temp[3];
  double d;
  glmSubtractVector3d(temp, p, planeOrigin);
  d = glmDotProduct3d(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):
<glmClosestPointOnPlane3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <glmSubtractVector3d@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <glmDotProduct3d@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmClosestPointOnPlane3d>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%rdx
mov    %rdi,%r14
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rcx,%rsi
call   1030 <glmSubtractVector3d@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <glmDotProduct3d@plt>
movsd  (%rbx),%xmm1
movsd  (%r15),%xmm2
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
movsd  0x8(%r15),%xmm2
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%xmm1
mulsd  0x10(%r15),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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