#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(void) {
  const float MIN = 0.0f;
  const float MAX = 100.0f;
  float score;
  float total = 0.0f;
  int n = 0;
  float min = MAX;
  float max = MIN;
  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 %d 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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xec1(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movss  0xea5(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1278 <main+0x158>
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
ja     11b2 <main+0x92>
movss  -0x10(%rbp),%xmm0
movss  0xe57(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11ce <main+0xae>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1176 <main+0x56>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1207 <main+0xe7>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1211 <main+0xf1>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
ucomiss -0x20(%rbp),%xmm0
jbe    1239 <main+0x119>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
jmp    1243 <main+0x123>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1176 <main+0x56>
cmpl   $0x0,-0x18(%rbp)
jle    12ca <main+0x1aa>
mov    -0x18(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xde6(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12d8 <main+0x1b8>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%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
xorps  %xmm1,%xmm1
movss  %xmm1,0x10(%rsp)
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 %d 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() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca float
%8 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 1.000000e+02, float* %3
store float 0.000000e+00, float* %5
store i32 0, i32* %6
store float 1.000000e+02, float* %7
store float 0.000000e+00, float* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %43, %19, %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %51
13: ; preds = %10
%14 = load float, float* %4
%15 = fcmp olt float %14, 0.000000e+00
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load float, float* %4
%18 = fcmp ogt float %17, 1.000000e+02
br i1 %18, label %19, label %23
19: ; preds = %16, %13
%20 = load float, float* %4
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %10
23: ; preds = %16
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %25)
%27 = load float, float* %4
%28 = load float, float* %7
%29 = fcmp olt float %27, %28
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = load float, float* %4
br label %34
32: ; preds = %23
%33 = load float, float* %7
br label %34
34: ; preds = %32, %30
%35 = phi float [ %31, %30 ], [ %33, %32 ]
store float %35, float* %7
%36 = load float, float* %4
%37 = load float, float* %8
%38 = fcmp ogt float %36, %37
br i1 %38, label %39, label %41
39: ; preds = %34
%40 = load float, float* %4
br label %43
41: ; preds = %34
%42 = load float, float* %8
br label %43
43: ; preds = %41, %39
%44 = phi float [ %40, %39 ], [ %42, %41 ]
store float %44, float* %8
%45 = load float, float* %4
%46 = load float, float* %5
%47 = fadd float %46, %45
store float %47, float* %5
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %10
51: ; preds = %10
%52 = load i32, i32* %6
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %67
54: ; preds = %51
%55 = load i32, i32* %6
%56 = load float, float* %5
%57 = load i32, i32* %6
%58 = sitofp i32 %57 to float
%59 = fdiv float %56, %58
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %55, double %60)
%62 = load float, float* %7
%63 = fpext float %62 to double
%64 = load float, float* %8
%65 = fpext float %64 to double
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %63, double %65)
br label %69
67: ; preds = %51
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %69
69: ; preds = %67, %54
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 %d 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() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %47
6: ; preds = %0, %21
%7 = phi float [ %27, %21 ], [ 0.000000e+00, %0 ]
%8 = phi float [ %25, %21 ], [ 1.000000e+02, %0 ]
%9 = phi i32 [ %29, %21 ], [ 0, %0 ]
%10 = phi float [ %28, %21 ], [ 0.000000e+00, %0 ]
br label %11
11: ; preds = %6, %17
%12 = load float, float* %1
%13 = fcmp olt float %12, 0.000000e+00
%14 = fcmp ogt float %12, 1.000000e+02
%15 = or i1 %13, %14
%16 = fpext float %12 to double
br i1 %15, label %17, label %21
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), double %16)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%20 = icmp eq i32 %19, 1
br i1 %20, label %11, label %33
21: ; preds = %11
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %16)
%23 = load float, float* %1
%24 = fcmp olt float %23, %8
%25 = select i1 %24, float %23, float %8
%26 = fcmp ogt float %23, %7
%27 = select i1 %26, float %23, float %7
%28 = fadd float %10, %23
%29 = add nuw nsw i32 %9, 1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%32 = icmp eq i32 %31, 1
br i1 %32, label %6, label %35
33: ; preds = %17
%34 = icmp eq i32 %9, 0
br i1 %34, label %47, label %35
35: ; preds = %21, %33
%36 = phi float [ %7, %33 ], [ %27, %21 ]
%37 = phi float [ %8, %33 ], [ %25, %21 ]
%38 = phi i32 [ %9, %33 ], [ %29, %21 ]
%39 = phi float [ %10, %33 ], [ %28, %21 ]
%40 = sitofp i32 %38 to float
%41 = fdiv float %39, %40
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %38, double %42)
%44 = fpext float %37 to double
%45 = fpext float %36 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %44, double %45)
br label %49
47: ; preds = %0, %33
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %47, %35
ret i32 0
}