#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 vectorLength(float const *);
int /*<<< orphan*/ vectorSet(float *, float const, float const, float const);
float vectorNormalize(float out[3], const float src[3]) {
  const float length = vectorLength(src);
  if (length) {
    vectorSet(out, src[0] / length, src[1] / length, src[2] / length);
  }
  return length;
}


x86 assembly (clang, -O0):
<vectorNormalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <vectorLength@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    115a <vectorNormalize+0x3a>
jp     115a <vectorNormalize+0x3a>
jmp    118c <vectorNormalize+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
divss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm1
divss  -0x14(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
divss  -0x14(%rbp),%xmm2
call   1040 <vectorSet@plt>
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectorNormalize>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <vectorLength@plt>
movaps %xmm0,%xmm3
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm3
jne    113f <vectorNormalize+0x1f>
jnp    116d <vectorNormalize+0x4d>
movss  (%rbx),%xmm0
movss  0x4(%rbx),%xmm1
divss  %xmm3,%xmm0
divss  %xmm3,%xmm1
movss  0x8(%rbx),%xmm2
divss  %xmm3,%xmm2
mov    %r14,%rdi
movss  %xmm3,0x4(%rsp)
call   1040 <vectorSet@plt>
movss  0x4(%rsp),%xmm3
movaps %xmm3,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float @vectorNormalize(float* %0, float* %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 = call float @vectorLength(float* %6)
store float %7, float* %5
%8 = load float, float* %5
%9 = fcmp une float %8, 0.000000e+00
br i1 %9, label %10, label %28
10: ; preds = %2
%11 = load float*, float** %3
%12 = load float*, float** %4
%13 = getelementptr inbounds float, float* %12, i64 0
%14 = load float, float* %13
%15 = load float, float* %5
%16 = fdiv float %14, %15
%17 = load float*, float** %4
%18 = getelementptr inbounds float, float* %17, i64 1
%19 = load float, float* %18
%20 = load float, float* %5
%21 = fdiv float %19, %20
%22 = load float*, float** %4
%23 = getelementptr inbounds float, float* %22, i64 2
%24 = load float, float* %23
%25 = load float, float* %5
%26 = fdiv float %24, %25
%27 = call i32 @vectorSet(float* %11, float %16, float %21, float %26)
br label %28
28: ; preds = %10, %2
%29 = load float, float* %5
ret float %29
}

LLVM IR (-O2):
define float @vectorNormalize(float* %0, float* %1) {
%3 = tail call float @vectorLength(float* %1)
%4 = fcmp une float %3, 0.000000e+00
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = load float, float* %1
%7 = fdiv float %6, %3
%8 = getelementptr inbounds float, float* %1, i64 1
%9 = load float, float* %8
%10 = fdiv float %9, %3
%11 = getelementptr inbounds float, float* %1, i64 2
%12 = load float, float* %11
%13 = fdiv float %12, %3
%14 = tail call i32 @vectorSet(float* %0, float %7, float %10, float %13)
br label %15
15: ; preds = %5, %2
ret float %3
}