#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 scanf(char *, float *);
int main(int argc, char const *argv[]) {
  const float MIN = 0.0f;
  const float MAX = 100.0f;
  float score;
  float total = 0.0f;
  int n = 0;
  float min = MIN;
  float max = MAX;
  printf("Enter the first score (q to quit): ");
  while (scanf("%f", &score) == 1) {
    if (score < MIN || score > MAX) {
      printf("%0.1f is an invalid value. Try again: ", score);
      continue;
    }
    printf("Accepting %0.1f: \n", score);
    min = (score < min) ? score : min;
    max = (score > max) ? score : max;
    total += score;
    n++;
    printf("Enter next score (q to quit): ");
  }
  if (n > 0) {
    printf("Average of %c scores is %0.1f.\n", n, total / n);
    printf("Low = %0.1f, high = %0.1f\n", min, max);
  } else {
    printf("No valid scores were entered.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xeba(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xe96(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    127f <main+0x15f>
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
ja     11b9 <main+0x99>
movss  -0x1c(%rbp),%xmm0
movss  0xe50(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11d5 <main+0xb5>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    117d <main+0x5d>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm1
movss  -0x28(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    120e <main+0xee>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    1218 <main+0xf8>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    1240 <main+0x120>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
jmp    124a <main+0x12a>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117d <main+0x5d>
cmpl   $0x0,-0x24(%rbp)
jle    12d1 <main+0x1b1>
mov    -0x24(%rbp),%esi
movss  -0x20(%rbp),%xmm0
cvtsi2ssl -0x24(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xddf(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12df <main+0x1bf>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    12ca <main+0x19a>
movss  0xe92(%rip),%xmm0
lea    0xeba(%rip),%r15
lea    0xeb0(%rip),%rbp
lea    0x14(%rsp),%rbx
lea    0xece(%rip),%r12
lea    0xeda(%rip),%r13
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
xor    %r14d,%r14d
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
jmp    11ce <main+0x9e>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1261 <main+0x131>
movss  0x14(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
ja     11b0 <main+0x80>
ucomiss 0xe16(%rip),%xmm1
ja     11b0 <main+0x80>
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm1
movaps %xmm1,%xmm0
minss  0xc(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
maxss  0x10(%rsp),%xmm1
movss  %xmm1,(%rsp)
add    $0x1,%r14d
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm1
movss  (%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
movss  %xmm1,0xc(%rsp)
cmp    $0x1,%eax
je     11ce <main+0x9e>
jmp    1272 <main+0x142>
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
test   %r14d,%r14d
je     12ca <main+0x19a>
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xdeb(%rip),%rdi
mov    %r14d,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  (%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xde7(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    12d6 <main+0x1a6>
lea    0xdf2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Enter the first score (q to quit): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [39 x i8] c"%0.1f is an invalid value. Try again: \00"
@.str.3 = [19 x i8] c"Accepting %0.1f: \0A\00"
@.str.4 = [31 x i8] c"Enter next score (q to quit): \00"
@.str.5 = [32 x i8] c"Average of %c scores is %0.1f.\0A\00"
@.str.6 = [27 x i8] c"Low = %0.1f, high = %0.1f\0A\00"
@.str.7 = [31 x i8] c"No valid scores were entered.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
%11 = alloca float
%12 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0.000000e+00, float* %6
store float 1.000000e+02, float* %7
store float 0.000000e+00, float* %9
store i32 0, i32* %10
store float 0.000000e+00, float* %11
store float 1.000000e+02, float* %12
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %47, %23, %2
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %8)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %55
17: ; preds = %14
%18 = load float, float* %8
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load float, float* %8
%22 = fcmp ogt float %21, 1.000000e+02
br i1 %22, label %23, label %27
23: ; preds = %20, %17
%24 = load float, float* %8
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %25)
br label %14
27: ; preds = %20
%28 = load float, float* %8
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = load float, float* %8
%32 = load float, float* %11
%33 = fcmp olt float %31, %32
br i1 %33, label %34, label %36
34: ; preds = %27
%35 = load float, float* %8
br label %38
36: ; preds = %27
%37 = load float, float* %11
br label %38
38: ; preds = %36, %34
%39 = phi float [ %35, %34 ], [ %37, %36 ]
store float %39, float* %11
%40 = load float, float* %8
%41 = load float, float* %12
%42 = fcmp ogt float %40, %41
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = load float, float* %8
br label %47
45: ; preds = %38
%46 = load float, float* %12
br label %47
47: ; preds = %45, %43
%48 = phi float [ %44, %43 ], [ %46, %45 ]
store float %48, float* %12
%49 = load float, float* %8
%50 = load float, float* %9
%51 = fadd float %50, %49
store float %51, float* %9
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %14
55: ; preds = %14
%56 = load i32, i32* %10
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %71
58: ; preds = %55
%59 = load i32, i32* %10
%60 = load float, float* %9
%61 = load i32, i32* %10
%62 = sitofp i32 %61 to float
%63 = fdiv float %60, %62
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %59, double %64)
%66 = load float, float* %11
%67 = fpext float %66 to double
%68 = load float, float* %12
%69 = fpext float %68 to double
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %67, double %69)
br label %73
71: ; preds = %55
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %73
73: ; preds = %71, %58
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"Enter the first score (q to quit): \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [39 x i8] c"%0.1f is an invalid value. Try again: \00"
@.str.3 = [19 x i8] c"Accepting %0.1f: \0A\00"
@.str.4 = [31 x i8] c"Enter next score (q to quit): \00"
@.str.5 = [32 x i8] c"Average of %c scores is %0.1f.\0A\00"
@.str.6 = [27 x i8] c"Low = %0.1f, high = %0.1f\0A\00"
@str = [30 x i8] c"No valid scores were entered.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca float
%4 = bitcast float* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 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), float* %3)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %49
8: ; preds = %2, %23
%9 = phi float [ %29, %23 ], [ 1.000000e+02, %2 ]
%10 = phi float [ %27, %23 ], [ 0.000000e+00, %2 ]
%11 = phi i32 [ %31, %23 ], [ 0, %2 ]
%12 = phi float [ %30, %23 ], [ 0.000000e+00, %2 ]
br label %13
13: ; preds = %8, %19
%14 = load float, float* %3
%15 = fcmp olt float %14, 0.000000e+00
%16 = fcmp ogt float %14, 1.000000e+02
%17 = or i1 %15, %16
%18 = fpext float %14 to double
br i1 %17, label %19, label %23
19: ; preds = %13
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %18)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%22 = icmp eq i32 %21, 1
br i1 %22, label %13, label %35
23: ; preds = %13
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %18)
%25 = load float, float* %3
%26 = fcmp olt float %25, %10
%27 = select i1 %26, float %25, float %10
%28 = fcmp ogt float %25, %9
%29 = select i1 %28, float %25, float %9
%30 = fadd float %12, %25
%31 = add nuw nsw i32 %11, 1
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%34 = icmp eq i32 %33, 1
br i1 %34, label %8, label %37
35: ; preds = %19
%36 = icmp eq i32 %11, 0
br i1 %36, label %49, label %37
37: ; preds = %23, %35
%38 = phi float [ %9, %35 ], [ %29, %23 ]
%39 = phi float [ %10, %35 ], [ %27, %23 ]
%40 = phi i32 [ %11, %35 ], [ %31, %23 ]
%41 = phi float [ %12, %35 ], [ %30, %23 ]
%42 = sitofp i32 %40 to float
%43 = fdiv float %41, %42
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %40, double %44)
%46 = fpext float %39 to double
%47 = fpext float %38 to double
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %46, double %47)
br label %51
49: ; preds = %2, %35
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %51
51: ; preds = %49, %37
ret i32 0
}