#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 */
scalar_t__ pow(float, int);
float sqrt(scalar_t__);
void linalg_normalize(float *vect) {
  float length;
  int a;
  length = sqrt(pow(vect[0], 2) + pow(vect[1], 2) + pow(vect[2], 2));
  for (a = 0; a < 3; ++a) {
    vect[a] /= length;
  }
}


x86 assembly (clang, -O0):
<linalg_normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    -0x18(%rbp),%rdi
add    %rax,%rdi
call   1040 <sqrt@plt>
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    11c1 <linalg_normalize+0xa1>
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118e <linalg_normalize+0x6e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linalg_normalize>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movss  (%rdi),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%r14
movss  0x4(%rbx),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%r14
movss  0x8(%rbx),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%r14
mov    %r14,%rdi
call   1040 <sqrt@plt>
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)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @linalg_normalize(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca i32
store float* %0, float** %2
%5 = load float*, float** %2
%6 = getelementptr inbounds float, float* %5, i64 0
%7 = load float, float* %6
%8 = call i64 @pow(float %7, i32 2)
%9 = load float*, float** %2
%10 = getelementptr inbounds float, float* %9, i64 1
%11 = load float, float* %10
%12 = call i64 @pow(float %11, i32 2)
%13 = add nsw i64 %8, %12
%14 = load float*, float** %2
%15 = getelementptr inbounds float, float* %14, i64 2
%16 = load float, float* %15
%17 = call i64 @pow(float %16, i32 2)
%18 = add nsw i64 %13, %17
%19 = call float @sqrt(i64 %18)
store float %19, float* %3
store i32 0, i32* %4
br label %20
20: ; preds = %31, %1
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load float, float* %3
%25 = load float*, float** %2
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
%29 = load float, float* %28
%30 = fdiv float %29, %24
store float %30, float* %28
br label %31
31: ; preds = %23
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %20
34: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @linalg_normalize(float* nocapture %0) {
%2 = load float, float* %0
%3 = tail call i64 @pow(float %2, i32 2)
%4 = getelementptr inbounds float, float* %0, i64 1
%5 = load float, float* %4
%6 = tail call i64 @pow(float %5, i32 2)
%7 = add nsw i64 %6, %3
%8 = getelementptr inbounds float, float* %0, i64 2
%9 = load float, float* %8
%10 = tail call i64 @pow(float %9, i32 2)
%11 = add nsw i64 %7, %10
%12 = tail call float @sqrt(i64 %11)
%13 = load float, float* %0
%14 = fdiv float %13, %12
store float %14, float* %0
%15 = load float, float* %4
%16 = fdiv float %15, %12
store float %16, float* %4
%17 = load float, float* %8
%18 = fdiv float %17, %12
store float %18, float* %8
ret void
}