#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 */
int /*<<< orphan*/ glmCopyVector3d(double const *, double *);
double glmDotProduct3d(double const *, double const *);
int /*<<< orphan*/ glmMultVectorByScalar3d(double *, double);
int /*<<< orphan*/ glmSubtractVector3d(double *, double const *, double *);
void glmProjectVector3d(double result[3], const double v[3],
                        const double normal[3]) {
  double temp;
  double tempVector[3];
  temp = glmDotProduct3d(v, normal);
  glmCopyVector3d(normal, tempVector);
  glmMultVectorByScalar3d(tempVector, temp);
  glmSubtractVector3d(result, v, tempVector);
}


x86 assembly (clang, -O0):
<glmProjectVector3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <glmDotProduct3d@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <glmCopyVector3d@plt>
lea    -0x40(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1030 <glmMultVectorByScalar3d@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <glmSubtractVector3d@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmProjectVector3d>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1050 <glmDotProduct3d@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <glmCopyVector3d@plt>
mov    %r12,%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <glmMultVectorByScalar3d@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1040 <glmSubtractVector3d@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @glmProjectVector3d(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca [3 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%9 = load double*, double** %5
%10 = load double*, double** %6
%11 = call double @glmDotProduct3d(double* %9, double* %10)
store double %11, double* %7
%12 = load double*, double** %6
%13 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%14 = call i32 @glmCopyVector3d(double* %12, double* %13)
%15 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%16 = load double, double* %7
%17 = call i32 @glmMultVectorByScalar3d(double* %15, double %16)
%18 = load double*, double** %4
%19 = load double*, double** %5
%20 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%21 = call i32 @glmSubtractVector3d(double* %18, double* %19, double* %20)
ret void
}

LLVM IR (-O2):
define void @glmProjectVector3d(double* %0, double* %1, double* %2) {
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %4 to i8*
%6 = tail call double @glmDotProduct3d(double* %1, double* %2)
%7 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%8 = call i32 @glmCopyVector3d(double* %2, double* %7)
%9 = call i32 @glmMultVectorByScalar3d(double* %7, double %6)
%10 = call i32 @glmSubtractVector3d(double* %0, double* %1, double* %7)
ret void
}