#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 normalise(double *a, double *norm) {
  double n;
  n = sqrt(a[1] * a[1] + a[2] * a[2] + a[3] * a[3]);
  norm[1] = a[1] / n;
  norm[2] = a[2] / n;
  norm[3] = a[3] / n;
}


x86 assembly (clang, -O0):
<normalise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x20,%rsp
pop    %rbp
ret

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

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

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