#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 dot(double *, double *, int);
int /*<<< orphan*/ mult(double *, double *, int, int);
double norm(double *, int);
void proj(double z[], double x[], double y[], int n) {
  double u[n];
  double d = norm(y, n);
  mult(u, y, 1 / d, n);
  mult(z, u, dot(x, u, n), n);
}


x86 assembly (clang, -O0):
<proj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <norm@plt>
mov    -0x40(%rbp),%rdi
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rsi
movsd  0xe71(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edx
mov    -0x1c(%rbp),%ecx
call   1050 <mult@plt>
mov    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
call   1030 <dot@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
mov    -0x1c(%rbp),%ecx
call   1050 <mult@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<proj>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r14
mov    %ecx,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rdx,%rdi
mov    %ecx,%esi
call   1040 <norm@plt>
movsd  0xe8d(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12d,%ecx
call   1050 <mult@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <dot@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
mov    %r12d,%ecx
call   1050 <mult@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @proj(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca double, i64 %13
store i64 %13, i64* %10
%16 = load double*, double** %7
%17 = load i32, i32* %8
%18 = call double @norm(double* %16, i32 %17)
store double %18, double* %11
%19 = load double*, double** %7
%20 = load double, double* %11
%21 = fdiv double 1.000000e+00, %20
%22 = fptosi double %21 to i32
%23 = load i32, i32* %8
%24 = call i32 @mult(double* %15, double* %19, i32 %22, i32 %23)
%25 = load double*, double** %5
%26 = load double*, double** %6
%27 = load i32, i32* %8
%28 = call i32 @dot(double* %26, double* %15, i32 %27)
%29 = load i32, i32* %8
%30 = call i32 @mult(double* %25, double* %15, i32 %28, i32 %29)
%31 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
define void @proj(double* %0, double* %1, double* %2, i32 %3) {
%5 = zext i32 %3 to i64
%6 = alloca double, i64 %5
%7 = tail call double @norm(double* %2, i32 %3)
%8 = fdiv double 1.000000e+00, %7
%9 = fptosi double %8 to i32
%10 = call i32 @mult(double* %6, double* %2, i32 %9, i32 %3)
%11 = call i32 @dot(double* %1, double* %6, i32 %3)
%12 = call i32 @mult(double* %0, double* %6, i32 %11, i32 %3)
ret void
}