#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 vec3_len(float *);
float vec3_normalize(float *a) {
  float len = vec3_len(a);
  if (len) {
    a[0] /= len;
    a[1] /= len;
    a[2] /= len;
  }
  return len;
}


x86 assembly (clang, -O0):
<vec3_normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <vec3_len@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1146 <vec3_normalize+0x36>
jp     1146 <vec3_normalize+0x36>
jmp    1189 <vec3_normalize+0x79>
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x8(%rax)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec3_normalize>:
push   %rbx
mov    %rdi,%rbx
call   1030 <vec3_len@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1123 <vec3_normalize+0x13>
jnp    114b <vec3_normalize+0x3b>
movss  (%rbx),%xmm1
movss  0x4(%rbx),%xmm2
divss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
divss  %xmm0,%xmm2
movss  %xmm2,0x4(%rbx)
movss  0x8(%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define float @vec3_normalize(float* %0) {
%2 = alloca float*
%3 = alloca float
store float* %0, float** %2
%4 = load float*, float** %2
%5 = call float @vec3_len(float* %4)
store float %5, float* %3
%6 = load float, float* %3
%7 = fcmp une float %6, 0.000000e+00
br i1 %7, label %8, label %24
8: ; preds = %1
%9 = load float, float* %3
%10 = load float*, float** %2
%11 = getelementptr inbounds float, float* %10, i64 0
%12 = load float, float* %11
%13 = fdiv float %12, %9
store float %13, float* %11
%14 = load float, float* %3
%15 = load float*, float** %2
%16 = getelementptr inbounds float, float* %15, i64 1
%17 = load float, float* %16
%18 = fdiv float %17, %14
store float %18, float* %16
%19 = load float, float* %3
%20 = load float*, float** %2
%21 = getelementptr inbounds float, float* %20, i64 2
%22 = load float, float* %21
%23 = fdiv float %22, %19
store float %23, float* %21
br label %24
24: ; preds = %8, %1
%25 = load float, float* %3
ret float %25
}

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