#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 sqrt(double);
void getNormal(double *positions, double *normeToFill) {
  int i;
  double norme =
      sqrt(positions[0] * positions[0] + positions[1] * positions[1] +
           positions[2] * positions[2]);
  for (i = 0; i < 3; ++i) {
    normeToFill[i] = positions[i] / norme;
  }
}


x86 assembly (clang, -O0):
<getNormal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11ac <getNormal+0x9c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1175 <getNormal+0x65>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNormal>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     114c <getNormal+0x3c>
sqrtsd %xmm0,%xmm0
jmp    1151 <getNormal+0x41>
call   1030 <sqrt@plt>
movsd  (%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @getNormal(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%7 = load double*, double** %3
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = load double*, double** %3
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = load double*, double** %3
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = fmul double %15, %18
%20 = call double @llvm.fmuladd.f64(double %9, double %12, double %19)
%21 = load double*, double** %3
%22 = getelementptr inbounds double, double* %21, i64 2
%23 = load double, double* %22
%24 = load double*, double** %3
%25 = getelementptr inbounds double, double* %24, i64 2
%26 = load double, double* %25
%27 = call double @llvm.fmuladd.f64(double %23, double %26, double %20)
%28 = call double @sqrt(double %27)
store double %28, double* %6
store i32 0, i32* %5
br label %29
29: ; preds = %44, %2
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 3
br i1 %31, label %32, label %47
32: ; preds = %29
%33 = load double*, double** %3
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load double, double* %6
%39 = fdiv double %37, %38
%40 = load double*, double** %4
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
store double %39, double* %43
br label %44
44: ; preds = %32
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %29
47: ; preds = %29
ret void
}

LLVM IR (-O2):
define void @getNormal(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = fmul double %5, %5
%7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %7)
%11 = tail call double @sqrt(double %10)
%12 = load double, double* %0
%13 = fdiv double %12, %11
store double %13, double* %1
%14 = load double, double* %4
%15 = fdiv double %14, %11
%16 = getelementptr inbounds double, double* %1, i64 1
store double %15, double* %16
%17 = load double, double* %8
%18 = fdiv double %17, %11
%19 = getelementptr inbounds double, double* %1, i64 2
store double %18, double* %19
ret void
}