#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 */
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, float);
void avg(int array[]) {
  float numberofelements = sizeof(array) / 4;
  float sum = 0;
  int i;
  for (i = 0; i < numberofelements; i++) {
    sum += array[i];
  }
  printf("Size in bytes: %ld", sizeof(array));
  printf("Size: %f", numberofelements);
  printf("Sum: %f", sum / numberofelements);
}


x86 assembly (clang, -O0):
<avg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  0xedc(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1170 <avg+0x60>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1138 <avg+0x28>
lea    0xe91(%rip),%rdi
movss  0xe85(%rip),%xmm0
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<avg>:
sub    $0x18,%rsp
movsd  (%rdi),%xmm0
cvtdq2ps %xmm0,%xmm0
movaps %xmm0,%xmm1
shufps $0x55,%xmm0,%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,(%rsp)
lea    0xedb(%rip),%rdi
movss  0xec7(%rip),%xmm0
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
movss  0xeb7(%rip),%xmm0
call   1030 <printf@plt>
movaps (%rsp),%xmm0
mulss  0xeaa(%rip),%xmm0
lea    0xec3(%rip),%rdi
add    $0x18,%rsp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Size in bytes: %ld\00"
@.str.1 = [9 x i8] c"Size: %f\00"
@.str.2 = [8 x i8] c"Sum: %f\00"
define void @avg(i32* %0) {
%2 = alloca i32*
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32* %0, i32** %2
store float 2.000000e+00, float* %3
store float 0.000000e+00, float* %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %1
%7 = load i32, i32* %5
%8 = sitofp i32 %7 to float
%9 = load float, float* %3
%10 = fcmp olt float %8, %9
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = load i32*, i32** %2
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = sitofp i32 %16 to float
%18 = load float, float* %4
%19 = fadd float %18, %17
store float %19, float* %4
br label %20
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
%24 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float 8.000000e+00)
%25 = load float, float* %3
%26 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float %25)
%27 = load float, float* %4
%28 = load float, float* %3
%29 = fdiv float %27, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), float %29)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Size in bytes: %ld\00"
@.str.1 = [9 x i8] c"Size: %f\00"
@.str.2 = [8 x i8] c"Sum: %f\00"
define void @avg(i32* nocapture %0) {
%2 = bitcast i32* %0 to <2 x i32>*
%3 = load <2 x i32>, <2 x i32>* %2
%4 = sitofp <2 x i32> %3 to <2 x float>
%5 = shufflevector <2 x float> %4, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%6 = fadd <2 x float> %5, %4
%7 = extractelement <2 x float> %6, i64 0
%8 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float 8.000000e+00)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float 2.000000e+00)
%10 = fmul float %7, 5.000000e-01
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), float %10)
ret void
}