#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 rescalenormals(float *array) {
  float factor =
      sqrt(pow(*array, 2) + pow(*(array + 1), 2) + pow(*(array + 2), 2));
  *array = *array / factor;
  *(array + 1) = *(array + 1) / factor;
  *(array + 2) = *(array + 2) / factor;
}


x86 assembly (clang, -O0):
<rescalenormals>:
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)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rescalenormals>:
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 @rescalenormals(float* %0) {
%2 = alloca float*
%3 = alloca float
store float* %0, float** %2
%4 = load float*, float** %2
%5 = load float, float* %4
%6 = call i64 @pow(float %5, i32 2)
%7 = load float*, float** %2
%8 = getelementptr inbounds float, float* %7, i64 1
%9 = load float, float* %8
%10 = call i64 @pow(float %9, i32 2)
%11 = add nsw i64 %6, %10
%12 = load float*, float** %2
%13 = getelementptr inbounds float, float* %12, i64 2
%14 = load float, float* %13
%15 = call i64 @pow(float %14, i32 2)
%16 = add nsw i64 %11, %15
%17 = call float @sqrt(i64 %16)
store float %17, float* %3
%18 = load float*, float** %2
%19 = load float, float* %18
%20 = load float, float* %3
%21 = fdiv float %19, %20
%22 = load float*, float** %2
store float %21, float* %22
%23 = load float*, float** %2
%24 = getelementptr inbounds float, float* %23, i64 1
%25 = load float, float* %24
%26 = load float, float* %3
%27 = fdiv float %25, %26
%28 = load float*, float** %2
%29 = getelementptr inbounds float, float* %28, i64 1
store float %27, float* %29
%30 = load float*, float** %2
%31 = getelementptr inbounds float, float* %30, i64 2
%32 = load float, float* %31
%33 = load float, float* %3
%34 = fdiv float %32, %33
%35 = load float*, float** %2
%36 = getelementptr inbounds float, float* %35, i64 2
store float %34, float* %36
ret void
}

LLVM IR (-O2):
define void @rescalenormals(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
}