#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 vdot(double *, double *);
int /*<<< orphan*/ vnorm2(double *, double *);
int /*<<< orphan*/ vscale(double, double *, double *);
int /*<<< orphan*/ vsub(double *, double *, double *);
void vproj_plane(double v[3], double plane[3], double proj[3]) {
  double vp[3], nplane[3];
  vnorm2(plane, nplane);
  double dot = vdot(v, nplane);
  vscale(dot, nplane, vp);
  vsub(v, vp, proj);
}


x86 assembly (clang, -O0):
<vproj_plane>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <vnorm2@plt>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <vdot@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
lea    -0x50(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <vscale@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <vsub@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vproj_plane>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1040 <vnorm2@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <vdot@plt>
lea    0x20(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <vscale@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <vsub@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @vproj_plane(double* %0, double* %1, double* %2) {
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = bitcast [3 x double]* %4 to i8*
%7 = bitcast [3 x double]* %5 to i8*
%8 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%9 = call i32 @vnorm2(double* %1, double* %8)
%10 = call double @vdot(double* %0, double* %8)
%11 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%12 = call i32 @vscale(double %10, double* %8, double* %11)
%13 = call i32 @vsub(double* %0, double* %11, double* %2)
ret void
}