#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 sqrtf(int /*<<< orphan*/);
int /*<<< orphan*/ vec3Dot(float const *, float const *);
void vec3Norm(float *__restrict _result, const float *__restrict _a) {
  float scale = 1.0f / sqrtf(vec3Dot(_a, _a));
  _result[0] = _a[0] * scale;
  _result[1] = _a[1] * scale;
  _result[2] = _a[2] * scale;
}


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
mov    -0x10(%rbp),%rsi
call   1030 <vec3Dot@plt>
mov    %eax,%edi
call   1040 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  0xeb1(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
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 <vec3Dot@plt>
mov    %eax,%edi
call   1040 <sqrtf@plt>
movss  0xebf(%rip),%xmm1
divss  %xmm0,%xmm1
movss  (%rbx),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,(%r14)
movss  0x4(%rbx),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%r14)
mulss  0x8(%rbx),%xmm1
movss  %xmm1,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @vec3Norm(float* noalias %0, float* noalias %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%6 = load float*, float** %4
%7 = load float*, float** %4
%8 = call i32 @vec3Dot(float* %6, float* %7)
%9 = call float @sqrtf(i32 %8)
%10 = fdiv float 1.000000e+00, %9
store float %10, float* %5
%11 = load float*, float** %4
%12 = getelementptr inbounds float, float* %11, i64 0
%13 = load float, float* %12
%14 = load float, float* %5
%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* %5
%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* %5
%29 = fmul float %27, %28
%30 = load float*, float** %3
%31 = getelementptr inbounds float, float* %30, i64 2
store float %29, float* %31
ret void
}

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