#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 sqrt(float);
void hpmNormalize(float x, float y, float z, float *rx, float *ry, float *rz) {
  float len = sqrt(x * x + y * y + z * z);
  *rx = x / len;
  *ry = y / len;
  *rz = z / len;
}


x86 assembly (clang, -O0):
<hpmNormalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movss  -0x4(%rbp),%xmm1
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrt@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x4(%rbp),%xmm0
divss  -0x2c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x8(%rbp),%xmm0
divss  -0x2c(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm0
divss  -0x2c(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hpmNormalize>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movaps %xmm0,%xmm4
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
movaps %xmm4,%xmm3
mulss  %xmm4,%xmm3
addss  %xmm0,%xmm3
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm3,%xmm0
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm0
jb     1150 <hpmNormalize+0x40>
sqrtss %xmm0,%xmm0
jmp    1179 <hpmNormalize+0x69>
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x8(%rsp)
movss  %xmm4,0x4(%rsp)
call   1030 <sqrt@plt>
movss  0x4(%rsp),%xmm4
movss  0x8(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
divss  %xmm0,%xmm4
movss  %xmm4,(%rbx)
divss  %xmm0,%xmm1
movss  %xmm1,(%r15)
divss  %xmm0,%xmm2
movss  %xmm2,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @hpmNormalize(float %0, float %1, float %2, float* %3, float* %4, float* %5) {
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float
store float %0, float* %7
store float %1, float* %8
store float %2, float* %9
store float* %3, float** %10
store float* %4, float** %11
store float* %5, float** %12
%14 = load float, float* %7
%15 = load float, float* %7
%16 = load float, float* %8
%17 = load float, float* %8
%18 = fmul float %16, %17
%19 = call float @llvm.fmuladd.f32(float %14, float %15, float %18)
%20 = load float, float* %9
%21 = load float, float* %9
%22 = call float @llvm.fmuladd.f32(float %20, float %21, float %19)
%23 = call float @sqrt(float %22)
store float %23, float* %13
%24 = load float, float* %7
%25 = load float, float* %13
%26 = fdiv float %24, %25
%27 = load float*, float** %10
store float %26, float* %27
%28 = load float, float* %8
%29 = load float, float* %13
%30 = fdiv float %28, %29
%31 = load float*, float** %11
store float %30, float* %31
%32 = load float, float* %9
%33 = load float, float* %13
%34 = fdiv float %32, %33
%35 = load float*, float** %12
store float %34, float* %35
ret void
}

LLVM IR (-O2):
define void @hpmNormalize(float %0, float %1, float %2, float* nocapture writeonly %3, float* nocapture writeonly %4, float* nocapture writeonly %5) {
%7 = fmul float %1, %1
%8 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %7)
%9 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %8)
%10 = tail call float @sqrt(float %9)
%11 = fdiv float %0, %10
store float %11, float* %3
%12 = fdiv float %1, %10
store float %12, float* %4
%13 = fdiv float %2, %10
store float %13, float* %5
ret void
}