#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 */
scalar_t__ pow(double, int);
double sqrt(scalar_t__);
void normalizeVector(double x, double y, double z, double *ret) {
  double l = (sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)));
  ret[0] = x / l;
  ret[1] = y / l;
  ret[2] = z / l;
}


x86 assembly (clang, -O0):
<normalizeVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    -0x30(%rbp),%rdi
add    %rax,%rdi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalizeVector>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
movsd  %xmm2,0x8(%rsp)
movaps %xmm1,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%rbx
movaps 0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
movsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
movapd 0x20(%rsp),%xmm2
unpcklpd 0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm2
movupd %xmm2,(%r14)
movsd  %xmm1,0x10(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @normalizeVector(double %0, double %1, double %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%10 = load double, double* %5
%11 = call i64 @pow(double %10, i32 2)
%12 = load double, double* %6
%13 = call i64 @pow(double %12, i32 2)
%14 = add nsw i64 %11, %13
%15 = load double, double* %7
%16 = call i64 @pow(double %15, i32 2)
%17 = add nsw i64 %14, %16
%18 = call double @sqrt(i64 %17)
store double %18, double* %9
%19 = load double, double* %5
%20 = load double, double* %9
%21 = fdiv double %19, %20
%22 = load double*, double** %8
%23 = getelementptr inbounds double, double* %22, i64 0
store double %21, double* %23
%24 = load double, double* %6
%25 = load double, double* %9
%26 = fdiv double %24, %25
%27 = load double*, double** %8
%28 = getelementptr inbounds double, double* %27, i64 1
store double %26, double* %28
%29 = load double, double* %7
%30 = load double, double* %9
%31 = fdiv double %29, %30
%32 = load double*, double** %8
%33 = getelementptr inbounds double, double* %32, i64 2
store double %31, double* %33
ret void
}

LLVM IR (-O2):
define void @normalizeVector(double %0, double %1, double %2, double* nocapture writeonly %3) {
%5 = tail call i64 @pow(double %0, i32 2)
%6 = tail call i64 @pow(double %1, i32 2)
%7 = add nsw i64 %6, %5
%8 = tail call i64 @pow(double %2, i32 2)
%9 = add nsw i64 %7, %8
%10 = tail call double @sqrt(i64 %9)
%11 = insertelement <2 x double> poison, double %0, i64 0
%12 = insertelement <2 x double> %11, double %1, i64 1
%13 = insertelement <2 x double> poison, double %10, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = fdiv <2 x double> %12, %14
%16 = bitcast double* %3 to <2 x double>*
store <2 x double> %15, <2 x double>* %16
%17 = fdiv double %2, %10
%18 = getelementptr inbounds double, double* %3, i64 2
store double %17, double* %18
ret void
}