#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 */
double GetReal();
int /*<<< orphan*/ printf(char *, ...);
main() {
  double gymnasticScores[5];
  double total, average;
  int i;
  printf("Please enter a score for each judge.\n");
  for (i = 0; i < 5; i++) {
    printf("Score for judge #%d:  ", i);
    gymnasticScores[i] = GetReal();
  }
  total = 0;
  for (i = 0; i < 5; i++) {
    total += gymnasticScores[i];
  }
  average = total / 5;
  printf("The average score is %.2f\n", average);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    117e <main+0x5e>
mov    -0x44(%rbp),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <GetReal@plt>
movslq -0x44(%rbp),%rax
movsd  %xmm0,-0x30(%rbp,%rax,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1144 <main+0x24>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    11b9 <main+0x99>
movslq -0x44(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    118d <main+0x6d>
movsd  -0x38(%rbp),%xmm0
movsd  0xe3a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xefe(%rip),%rdi
call   1040 <puts@plt>
lea    0xec0(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <GetReal@plt>
movsd  %xmm0,0x18(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <GetReal@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <GetReal@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <GetReal@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <GetReal@plt>
xorpd  %xmm1,%xmm1
addsd  0x18(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
addsd  (%rsp),%xmm1
addsd  %xmm1,%xmm0
divsd  0xe0f(%rip),%xmm0
lea    0xe27(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Please enter a score for each judge.\0A\00"
@.str.1 = [23 x i8] c"Score for judge #%d: \00"
@.str.2 = [27 x i8] c"The average score is %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x double]
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call double (...) @GetReal()
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 %15
store double %13, double* %16
br label %17
17: ; preds = %10
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %7
20: ; preds = %7
store double 0.000000e+00, double* %3
store i32 0, i32* %5
br label %21
21: ; preds = %31, %20
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 5
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 %26
%28 = load double, double* %27
%29 = load double, double* %3
%30 = fadd double %29, %28
store double %30, double* %3
br label %31
31: ; preds = %24
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %21
34: ; preds = %21
%35 = load double, double* %3
%36 = fdiv double %35, 5.000000e+00
store double %36, double* %4
%37 = load double, double* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"Score for judge #%d: \00"
@.str.2 = [27 x i8] c"The average score is %.2f\0A\00"
@str = [37 x i8] c"Please enter a score for each judge.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 0)
%3 = tail call double (...) @GetReal()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 1)
%5 = tail call double (...) @GetReal()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 2)
%7 = tail call double (...) @GetReal()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 3)
%9 = tail call double (...) @GetReal()
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 4)
%11 = tail call double (...) @GetReal()
%12 = fadd double %3, 0.000000e+00
%13 = fadd double %12, %5
%14 = fadd double %13, %7
%15 = fadd double %14, %9
%16 = fadd double %15, %11
%17 = fdiv double %16, 5.000000e+00
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %17)
ret i32 0
}