#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 */
int EXIT_SUCCESS;
float computeMean(int *, int);
int /*<<< orphan*/ printf(char *, float);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int data[10];
  int numValues;
  float average;
  puts("How many values are there?");
  scanf("%d", &numValues);
  printf("Please enter %d values: \n", numValues);
  int i = 0;
  for (i = 0; i < numValues; i++) {
    scanf("%d", &data[i]);
  }
  puts("You inputted the ff.:");
  for (i = 0; i < numValues; i++) {
    printf("%d ", data[i]);
  }
  puts("");
  average = computeMean(data, numValues);
  printf("The mean is %0.2f.", average);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1060 <scanf@plt>
cvtsi2ssl -0x34(%rbp),%xmm0
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11bf <main+0x7f>
movslq -0x3c(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6f(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    118a <main+0x4a>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1202 <main+0xc2>
movslq -0x3c(%rbp),%rax
cvtsi2ssl -0x30(%rbp,%rax,4),%xmm0
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d2 <main+0x92>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <computeMean@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
lea    0xe27(%rip),%rdi
call   1040 <printf@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cvtsi2ssl 0xc(%rsp),%xmm0
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11bd <main+0x6d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe7e(%rip),%r14
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     11a0 <main+0x50>
lea    0xe74(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ff <main+0xaf>
xor    %ebx,%ebx
lea    0xe75(%rip),%r14
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2ssl 0x10(%rsp,%rbx,4),%xmm0
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11e0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1060 <computeMean@plt>
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"How many values are there?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Please enter %d values: \0A\00"
@.str.3 = [22 x i8] c"You inputted the ff.:\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [19 x i8] c"The mean is %0.2f.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = sitofp i32 %8 to float
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), float %9)
store i32 0, i32* %5
store i32 0, i32* %5
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %11
23: ; preds = %11
%24 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %25
25: ; preds = %36, %23
%26 = load i32, i32* %5
%27 = load i32, i32* %3
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = sitofp i32 %33 to float
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %34)
br label %36
36: ; preds = %29
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %25
39: ; preds = %25
%40 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%42 = load i32, i32* %3
%43 = call float @computeMean(i32* %41, i32 %42)
store float %43, float* %4
%44 = load float, float* %4
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), float %44)
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}

LLVM IR (-O2):
@.str = [27 x i8] c"How many values are there?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Please enter %d values: \0A\00"
@.str.3 = [22 x i8] c"You inputted the ff.:\00"
@.str.4 = [4 x i8] c"%d \00"
@.str.6 = [19 x i8] c"The mean is %0.2f.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = sitofp i32 %7 to float
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), float %8)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %34
24: ; preds = %20, %24
%25 = phi i64 [ %30, %24 ], [ 0, %20 ]
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = sitofp i32 %27 to float
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), float %28)
%30 = add nuw nsw i64 %25, 1
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %24, label %34
34: ; preds = %24, %20
%35 = call i32 @putchar(i32 10)
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%37 = load i32, i32* %2
%38 = call float @computeMean(i32* %36, i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), float %38)
%40 = load i32, i32* @EXIT_SUCCESS
ret i32 %40
}