#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 */
float vec3Length(float const *);
float vec3Norm(float *__restrict _result, const float *__restrict _a) {
  const float len = vec3Length(_a);
  const float invLen = 1.0f / len;
  _result[0] = _a[0] * invLen;
  _result[1] = _a[1] * invLen;
  _result[2] = _a[2] * invLen;
  return len;
}


x86 assembly (clang, -O0):
<vec3Norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <vec3Length@plt>
movss  %xmm0,-0x14(%rbp)
movss  0xeca(%rip),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec3Norm>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <vec3Length@plt>
movss  0xed6(%rip),%xmm1
divss  %xmm0,%xmm1
movss  (%rbx),%xmm2
mulss  %xmm1,%xmm2
movss  %xmm2,(%r14)
movss  0x4(%rbx),%xmm2
mulss  %xmm1,%xmm2
movss  %xmm2,0x4(%r14)
mulss  0x8(%rbx),%xmm1
movss  %xmm1,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float @vec3Norm(float* noalias %0, float* noalias %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%7 = load float*, float** %4
%8 = call float @vec3Length(float* %7)
store float %8, float* %5
%9 = load float, float* %5
%10 = fdiv float 1.000000e+00, %9
store float %10, float* %6
%11 = load float*, float** %4
%12 = getelementptr inbounds float, float* %11, i64 0
%13 = load float, float* %12
%14 = load float, float* %6
%15 = fmul float %13, %14
%16 = load float*, float** %3
%17 = getelementptr inbounds float, float* %16, i64 0
store float %15, float* %17
%18 = load float*, float** %4
%19 = getelementptr inbounds float, float* %18, i64 1
%20 = load float, float* %19
%21 = load float, float* %6
%22 = fmul float %20, %21
%23 = load float*, float** %3
%24 = getelementptr inbounds float, float* %23, i64 1
store float %22, float* %24
%25 = load float*, float** %4
%26 = getelementptr inbounds float, float* %25, i64 2
%27 = load float, float* %26
%28 = load float, float* %6
%29 = fmul float %27, %28
%30 = load float*, float** %3
%31 = getelementptr inbounds float, float* %30, i64 2
store float %29, float* %31
%32 = load float, float* %5
ret float %32
}

LLVM IR (-O2):
define float @vec3Norm(float* noalias nocapture writeonly %0, float* noalias %1) {
%3 = tail call float @vec3Length(float* %1)
%4 = fdiv float 1.000000e+00, %3
%5 = load float, float* %1
%6 = fmul float %5, %4
store float %6, float* %0
%7 = getelementptr inbounds float, float* %1, i64 1
%8 = load float, float* %7
%9 = fmul float %4, %8
%10 = getelementptr inbounds float, float* %0, i64 1
store float %9, float* %10
%11 = getelementptr inbounds float, float* %1, i64 2
%12 = load float, float* %11
%13 = fmul float %4, %12
%14 = getelementptr inbounds float, float* %0, i64 2
store float %13, float* %14
ret float %3
}