#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*/ glmCopyVector2d(double const *, double *);
double glmDotProduct2d(double const *, double const *);
int /*<<< orphan*/ glmMultVectorByScalar2d(double *, double);
int /*<<< orphan*/ glmSubtractVector2d(double *, double const *, double *);
void glmProjectVector2d(double result[2], const double v[2],
                        const double normal[2]) {
  double temp;
  double tempVector[2];
  temp = glmDotProduct2d(v, normal);
  glmCopyVector2d(normal, tempVector);
  glmMultVectorByScalar2d(tempVector, temp);
  glmSubtractVector2d(result, v, tempVector);
}


x86 assembly (clang, -O0):
<glmProjectVector2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <glmDotProduct2d@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <glmCopyVector2d@plt>
lea    -0x30(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
call   1040 <glmMultVectorByScalar2d@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <glmSubtractVector2d@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmProjectVector2d>:
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   1060 <glmDotProduct2d@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <glmCopyVector2d@plt>
mov    %r12,%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <glmMultVectorByScalar2d@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <glmSubtractVector2d@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @glmProjectVector2d(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca [2 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 @glmDotProduct2d(double* %9, double* %10)
store double %11, double* %7
%12 = load double*, double** %6
%13 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%14 = call i32 @glmCopyVector2d(double* %12, double* %13)
%15 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%16 = load double, double* %7
%17 = call i32 @glmMultVectorByScalar2d(double* %15, double %16)
%18 = load double*, double** %4
%19 = load double*, double** %5
%20 = getelementptr inbounds [2 x double], [2 x double]* %8, i64 0, i64 0
%21 = call i32 @glmSubtractVector2d(double* %18, double* %19, double* %20)
ret void
}

LLVM IR (-O2):
define void @glmProjectVector2d(double* %0, double* %1, double* %2) {
%4 = alloca [2 x double]
%5 = bitcast [2 x double]* %4 to i8*
%6 = tail call double @glmDotProduct2d(double* %1, double* %2)
%7 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%8 = call i32 @glmCopyVector2d(double* %2, double* %7)
%9 = call i32 @glmMultVectorByScalar2d(double* %7, double %6)
%10 = call i32 @glmSubtractVector2d(double* %0, double* %1, double* %7)
ret void
}