#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 */
typedef int /*<<< orphan*/ uint;

/* Variables and functions */
double dot_vnvn(double const *, double const *, int /*<<< orphan*/ const);
int /*<<< orphan*/ mul_vnvn_fl(double *, double const *, double const,
                               int /*<<< orphan*/ const);
void project_vn_vnvn(double v_out[], const double p[], const double v_proj[],
                     const uint dims) {
  const double mul = dot_vnvn(p, v_proj, dims) / dot_vnvn(v_proj, v_proj, dims);
  mul_vnvn_fl(v_out, v_proj, mul, dims);
}


x86 assembly (clang, -O0):
<project_vn_vnvn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <dot_vnvn@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <dot_vnvn@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%edx
call   1040 <mul_vnvn_fl@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<project_vn_vnvn>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
call   1030 <dot_vnvn@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <dot_vnvn@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
mov    %r14,%rdi
mov    %rbx,%rsi
movapd %xmm1,%xmm0
mov    %ebp,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <mul_vnvn_fl@plt>

LLVM IR (-O0):
define void @project_vn_vnvn(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%10 = load double*, double** %6
%11 = load double*, double** %7
%12 = load i32, i32* %8
%13 = call double @dot_vnvn(double* %10, double* %11, i32 %12)
%14 = load double*, double** %7
%15 = load double*, double** %7
%16 = load i32, i32* %8
%17 = call double @dot_vnvn(double* %14, double* %15, i32 %16)
%18 = fdiv double %13, %17
store double %18, double* %9
%19 = load double*, double** %5
%20 = load double*, double** %7
%21 = load double, double* %9
%22 = load i32, i32* %8
%23 = call i32 @mul_vnvn_fl(double* %19, double* %20, double %21, i32 %22)
ret void
}

LLVM IR (-O2):
define void @project_vn_vnvn(double* %0, double* %1, double* %2, i32 %3) {
%5 = tail call double @dot_vnvn(double* %1, double* %2, i32 %3)
%6 = tail call double @dot_vnvn(double* %2, double* %2, i32 %3)
%7 = fdiv double %5, %6
%8 = tail call i32 @mul_vnvn_fl(double* %0, double* %2, double %7, i32 %3)
ret void
}