#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 /*<<< orphan*/ printf(char *, ...);
void main() {
  float aver;
  float average(float array[]);
  int i, amount = 10;
  float score[10] = {100, 56, 78, 98.5, 76, 87, 99, 67.5, 75, 97};
  printf("List the array:");
  for (i = 0; i < amount; i++) {
    printf("%6.2f", score[i]);
  }
  aver = average(score);
  printf("\nthe average score is %5.2f", aver);
  printf("\nthe average score is %5.2f", average(score));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0xa,-0xc(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119f <main+0x6f>
movslq -0x8(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeae(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <main+0x39>
lea    -0x40(%rbp),%rdi
call   1050 <average@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe81(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <average@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe66(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xf42(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xf26(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xf0a(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xf27(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf29(%rip),%rbx
movsd  0xe99(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe8f(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe85(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe7b(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe71(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe67(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe5d(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe53(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe49(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe3f(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <average@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe65(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <average@plt>
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.score = [10 x float] [float 1.000000e+02, float 5.600000e+01, float 7.800000e+01, float 9.850000e+01, float 7.600000e+01, float 8.700000e+01, float 9.900000e+01, float 6.750000e+01, float 7.500000e+01, float 9.700000e+01]
@.str = [16 x i8] c"List the array:\00"
@.str.1 = [6 x i8] c"%6.2f\00"
@.str.2 = [28 x i8] c"\0Athe average score is %5.2f\00"
define void @main() {
%1 = alloca float
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x float]
store i32 10, i32* %3
%5 = bitcast [10 x float]* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x float], [10 x float]* %4, i64 0, i64 %13
%15 = load float, float* %14
%16 = fpext float %15 to double
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %16)
br label %18
18: ; preds = %11
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %7
21: ; preds = %7
%22 = getelementptr inbounds [10 x float], [10 x float]* %4, i64 0, i64 0
%23 = call float @average(float* %22)
store float %23, float* %1
%24 = load float, float* %1
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = getelementptr inbounds [10 x float], [10 x float]* %4, i64 0, i64 0
%28 = call float @average(float* %27)
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), double %29)
ret void
}

LLVM IR (-O2):
@__const.main.score = [10 x float] [float 1.000000e+02, float 5.600000e+01, float 7.800000e+01, float 9.850000e+01, float 7.600000e+01, float 8.700000e+01, float 9.900000e+01, float 6.750000e+01, float 7.500000e+01, float 9.700000e+01]
@.str = [16 x i8] c"List the array:\00"
@.str.1 = [6 x i8] c"%6.2f\00"
@.str.2 = [28 x i8] c"\0Athe average score is %5.2f\00"
define void @main() {
%1 = alloca [10 x float]
%2 = bitcast [10 x float]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [10 x float], [10 x float]* %1, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+02)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 5.600000e+01)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 7.800000e+01)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 9.850000e+01)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 7.600000e+01)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 8.700000e+01)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 9.900000e+01)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 6.750000e+01)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 7.500000e+01)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double 9.700000e+01)
%15 = call float @average(float* %4)
%16 = fpext float %15 to double
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), double %16)
%18 = call float @average(float* %4)
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), double %19)
ret void
}