#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__);
float getNorm(float *vec) {
  return sqrt(pow(vec[0], 2) + pow(vec[1], 2) + pow(vec[2], 2) +
              pow(vec[3], 2));
}


x86 assembly (clang, -O0):
<getNorm>:
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    %rax,%rcx
mov    -0x18(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    -0x10(%rbp),%rdi
add    %rax,%rdi
call   1040 <sqrt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNorm>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movss  (%rdi),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,%rbx
movss  0x4(%r14),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
movss  0x8(%r14),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
movss  0xc(%r14),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define float @getNorm(float* %0) {
%2 = alloca float*
store float* %0, float** %2
%3 = load float*, float** %2
%4 = getelementptr inbounds float, float* %3, i64 0
%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 = load float*, float** %2
%18 = getelementptr inbounds float, float* %17, i64 3
%19 = load float, float* %18
%20 = call i64 @pow(float %19, i32 2)
%21 = add nsw i64 %16, %20
%22 = call float @sqrt(i64 %21)
ret float %22
}

LLVM IR (-O2):
define float @getNorm(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 = getelementptr inbounds float, float* %0, i64 3
%13 = load float, float* %12
%14 = tail call i64 @pow(float %13, i32 2)
%15 = add nsw i64 %11, %14
%16 = tail call float @sqrt(i64 %15)
ret float %16
}