#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 *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int qty, i;
  float score, sum, max, min;
  printf("How many scores will you provide? ");
  scanf("%i", &qty);
  printf("\n");
  for (i = 0; i < qty; i++) {
    printf("  #%i = ", i + 1);
    scanf("%f", &score);
    if (i == 0) {
      max = min = sum = score;
    } else {
      if (score > max)
        max = score;
      if (score < min)
        min = score;
      sum += score;
    }
  }
  printf("\n  Quantity: %i\n", qty);
  printf("  Total:    %.2f\n\n", sum);
  printf("  Average:  %.2f\n", (float)sum / qty);
  printf("  Maximum:  %.2f\n", max);
  printf("  Minimum:  %.2f\n", min);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1211 <main+0xf1>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11b9 <main+0x99>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  %xmm0,-0x1c(%rbp)
movss  %xmm0,-0x18(%rbp)
jmp    11fe <main+0xde>
movss  -0x10(%rbp),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11d2 <main+0xb2>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11ef <main+0xcf>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1203 <main+0xe3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x44>
mov    -0x8(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdff(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdfa(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%esi
test   %esi,%esi
jle    122d <main+0xfd>
lea    0xead(%rip),%rdi
mov    $0x1,%ebx
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm0
mov    0x8(%rsp),%esi
cmp    $0x2,%esi
jl     122f <main+0xff>
lea    0xe6f(%rip),%r14
lea    0xe71(%rip),%r15
lea    0x14(%rsp),%r12
movaps %xmm0,%xmm3
movss  %xmm0,0x4(%rsp)
nopl   0x0(%rax)
movss  %xmm3,0xc(%rsp)
movss  %xmm0,0x10(%rsp)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x14(%rsp),%xmm1
movaps %xmm1,%xmm2
maxss  0xc(%rsp),%xmm2
movss  0x4(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
minss  0x10(%rsp),%xmm1
mov    0x8(%rsp),%esi
movaps %xmm1,%xmm0
movaps %xmm2,%xmm3
cmp    %esi,%ebx
jl     11d0 <main+0xa0>
jmp    123b <main+0x10b>
jmp    123b <main+0x10b>
movss  %xmm0,0x4(%rsp)
movaps %xmm0,%xmm2
movaps %xmm0,%xmm1
movss  %xmm2,0xc(%rsp)
movss  %xmm1,0x10(%rsp)
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x8(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xdc8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdbc(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [35 x i8] c"How many scores will you provide? \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [9 x i8] c" #%i = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [17 x i8] c"\0A Quantity: %i\0A\00"
@.str.6 = [19 x i8] c" Total: %.2f\0A\0A\00"
@.str.7 = [18 x i8] c" Average: %.2f\0A\00"
@.str.8 = [18 x i8] c" Maximum: %.2f\0A\00"
@.str.9 = [18 x i8] c" Minimum: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %11
11: ; preds = %41, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %44
15: ; preds = %11
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %4)
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = load float, float* %4
store float %23, float* %5
store float %23, float* %7
store float %23, float* %6
br label %40
24: ; preds = %15
%25 = load float, float* %4
%26 = load float, float* %6
%27 = fcmp ogt float %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = load float, float* %4
store float %29, float* %6
br label %30
30: ; preds = %28, %24
%31 = load float, float* %4
%32 = load float, float* %7
%33 = fcmp olt float %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load float, float* %4
store float %35, float* %7
br label %36
36: ; preds = %34, %30
%37 = load float, float* %4
%38 = load float, float* %5
%39 = fadd float %38, %37
store float %39, float* %5
br label %40
40: ; preds = %36, %22
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %11
44: ; preds = %11
%45 = load i32, i32* %2
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = load float, float* %5
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %48)
%50 = load float, float* %5
%51 = load i32, i32* %2
%52 = sitofp i32 %51 to float
%53 = fdiv float %50, %52
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), double %54)
%56 = load float, float* %6
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), double %57)
%59 = load float, float* %7
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), double %60)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"How many scores will you provide? \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.3 = [9 x i8] c" #%i = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [17 x i8] c"\0A Quantity: %i\0A\00"
@.str.6 = [19 x i8] c" Total: %.2f\0A\0A\00"
@.str.7 = [18 x i8] c" Average: %.2f\0A\00"
@.str.8 = [18 x i8] c" Maximum: %.2f\0A\00"
@.str.9 = [18 x i8] c" Minimum: %.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 @putchar(i32 10)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 1)
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %2)
%13 = load float, float* %2
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %32
16: ; preds = %10, %16
%17 = phi float [ %28, %16 ], [ %13, %10 ]
%18 = phi float [ %26, %16 ], [ %13, %10 ]
%19 = phi float [ %29, %16 ], [ %13, %10 ]
%20 = phi i32 [ %21, %16 ], [ 1, %10 ]
%21 = add nuw nsw i32 %20, 1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %2)
%24 = load float, float* %2
%25 = fcmp ogt float %24, %18
%26 = select i1 %25, float %24, float %18
%27 = fcmp olt float %24, %17
%28 = select i1 %27, float %24, float %17
%29 = fadd float %19, %24
%30 = load i32, i32* %1
%31 = icmp slt i32 %21, %30
br i1 %31, label %16, label %32
32: ; preds = %16, %10, %0
%33 = phi float [ undef, %0 ], [ %13, %10 ], [ %29, %16 ]
%34 = phi float [ undef, %0 ], [ %13, %10 ], [ %26, %16 ]
%35 = phi float [ undef, %0 ], [ %13, %10 ], [ %28, %16 ]
%36 = phi i32 [ %8, %0 ], [ %14, %10 ], [ %30, %16 ]
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = fpext float %33 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %38)
%40 = load i32, i32* %1
%41 = sitofp i32 %40 to float
%42 = fdiv float %33, %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), double %43)
%45 = fpext float %34 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), double %45)
%47 = fpext float %35 to double
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), double %47)
ret i32 0
}