#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(float);
void ur_normalize(float *vec) {
  float x, y, z;
  float len;
  x = vec[0];
  y = vec[1];
  z = vec[2];
  len = sqrtf(x * x + y * y + z * z);
  if (len) {
    len = 1.0f / len;
    vec[0] = x * len;
    vec[1] = y * len;
    vec[2] = z * len;
  }
}


x86 assembly (clang, -O0):
<ur_normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
movss  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrtf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1199 <ur_normalize+0x89>
jp     1199 <ur_normalize+0x89>
jmp    11e3 <ur_normalize+0xd3>
movss  0xe5f(%rip),%xmm0
divss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x10(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x14(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ur_normalize>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  (%rdi),%xmm4
movss  0x4(%rdi),%xmm3
movss  0x8(%rdi),%xmm2
movaps %xmm3,%xmm0
mulss  %xmm3,%xmm0
movaps %xmm4,%xmm1
mulss  %xmm4,%xmm1
addss  %xmm0,%xmm1
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1151 <ur_normalize+0x41>
sqrtss %xmm0,%xmm0
jmp    117d <ur_normalize+0x6d>
movss  %xmm2,0xc(%rsp)
movss  %xmm3,0x8(%rsp)
movss  %xmm4,0x4(%rsp)
call   1030 <sqrtf@plt>
xorps  %xmm1,%xmm1
movss  0x4(%rsp),%xmm4
movss  0x8(%rsp),%xmm3
movss  0xc(%rsp),%xmm2
ucomiss %xmm1,%xmm0
jne    1184 <ur_normalize+0x74>
jnp    11aa <ur_normalize+0x9a>
movss  0xe74(%rip),%xmm1
divss  %xmm0,%xmm1
mulss  %xmm1,%xmm4
movss  %xmm4,(%rbx)
mulss  %xmm1,%xmm3
movss  %xmm3,0x4(%rbx)
mulss  %xmm1,%xmm2
movss  %xmm2,0x8(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @ur_normalize(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float* %0, float** %2
%7 = load float*, float** %2
%8 = getelementptr inbounds float, float* %7, i64 0
%9 = load float, float* %8
store float %9, float* %3
%10 = load float*, float** %2
%11 = getelementptr inbounds float, float* %10, i64 1
%12 = load float, float* %11
store float %12, float* %4
%13 = load float*, float** %2
%14 = getelementptr inbounds float, float* %13, i64 2
%15 = load float, float* %14
store float %15, float* %5
%16 = load float, float* %3
%17 = load float, float* %3
%18 = load float, float* %4
%19 = load float, float* %4
%20 = fmul float %18, %19
%21 = call float @llvm.fmuladd.f32(float %16, float %17, float %20)
%22 = load float, float* %5
%23 = load float, float* %5
%24 = call float @llvm.fmuladd.f32(float %22, float %23, float %21)
%25 = call float @sqrtf(float %24)
store float %25, float* %6
%26 = load float, float* %6
%27 = fcmp une float %26, 0.000000e+00
br i1 %27, label %28, label %46
28: ; preds = %1
%29 = load float, float* %6
%30 = fdiv float 1.000000e+00, %29
store float %30, float* %6
%31 = load float, float* %3
%32 = load float, float* %6
%33 = fmul float %31, %32
%34 = load float*, float** %2
%35 = getelementptr inbounds float, float* %34, i64 0
store float %33, float* %35
%36 = load float, float* %4
%37 = load float, float* %6
%38 = fmul float %36, %37
%39 = load float*, float** %2
%40 = getelementptr inbounds float, float* %39, i64 1
store float %38, float* %40
%41 = load float, float* %5
%42 = load float, float* %6
%43 = fmul float %41, %42
%44 = load float*, float** %2
%45 = getelementptr inbounds float, float* %44, i64 2
store float %43, float* %45
br label %46
46: ; preds = %28, %1
ret void
}

LLVM IR (-O2):
define void @ur_normalize(float* nocapture %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 1
%4 = load float, float* %3
%5 = getelementptr inbounds float, float* %0, i64 2
%6 = load float, float* %5
%7 = fmul float %4, %4
%8 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %7)
%9 = tail call float @llvm.fmuladd.f32(float %6, float %6, float %8)
%10 = tail call float @sqrtf(float %9)
%11 = fcmp une float %10, 0.000000e+00
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = fdiv float 1.000000e+00, %10
%14 = fmul float %2, %13
store float %14, float* %0
%15 = fmul float %4, %13
store float %15, float* %3
%16 = fmul float %6, %13
store float %16, float* %5
br label %17
17: ; preds = %12, %1
ret void
}