#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("Entet your score_(q to quit):");
  while (scanf("%f", &score) == 1) {
    if (score < MIN || score > MAX) {
      printf("%.1f is invalid.", score);
      break;
    }
    printf("Accepting %.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 score is %.1f.\n", n, total / n);
    printf("Low=%.1f , High=%.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    0xea5(%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    0xe63(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1278 <main+0x158>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe58(%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    0xddb(%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    0xdc8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x20(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdc6(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    12d8 <main+0x1b8>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    128d <main+0x15d>
movss  0xe93(%rip),%xmm2
lea    0xec6(%rip),%r14
lea    0xed0(%rip),%r15
lea    0xea4(%rip),%r12
lea    0xc(%rsp),%r13
xorps  %xmm1,%xmm1
xor    %ebx,%ebx
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm2,(%rsp)
movss  %xmm1,0x4(%rsp)
movss  0xc(%rsp),%xmm1
xorps  %xmm0,%xmm0
ucomiss %xmm1,%xmm0
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
ja     1230 <main+0x100>
ucomiss 0xe39(%rip),%xmm1
ja     1230 <main+0x100>
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
minss  (%rsp),%xmm0
movss  %xmm0,(%rsp)
movss  0x8(%rsp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
maxss  0x4(%rsp),%xmm1
movss  %xmm1,0x4(%rsp)
add    $0x1,%ebx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm1
movss  (%rsp),%xmm2
cmp    $0x1,%eax
je     11a0 <main+0x70>
jmp    1242 <main+0x112>
lea    0xdf2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
test   %ebx,%ebx
je     128d <main+0x15d>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe09(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe04(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
jmp    1299 <main+0x169>
lea    0xe0a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Entet your score_(q to quit):\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [17 x i8] c"%.1f is invalid.\00"
@.str.3 = [17 x i8] c"Accepting %.1f:\0A\00"
@.str.4 = [31 x i8] c"Enter next score (q to quit): \00"
@.str.5 = [30 x i8] c"Average of %d score is %.1f.\0A\00"
@.str.6 = [22 x i8] c"Low=%.1f , High=%.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 ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %43, %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 ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %51
23: ; preds = %16
%24 = load float, float* %4
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 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 = %19, %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 ([30 x i8], [30 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 ([22 x i8], [22 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 = [30 x i8] c"Entet your score_(q to quit):\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [17 x i8] c"%.1f is invalid.\00"
@.str.3 = [17 x i8] c"Accepting %.1f:\0A\00"
@.str.4 = [31 x i8] c"Enter next score (q to quit): \00"
@.str.5 = [30 x i8] c"Average of %d score is %.1f.\0A\00"
@.str.6 = [22 x i8] c"Low=%.1f , High=%.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 ([30 x i8], [30 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 %43
6: ; preds = %0, %16
%7 = phi float [ %22, %16 ], [ 0.000000e+00, %0 ]
%8 = phi float [ %20, %16 ], [ 1.000000e+02, %0 ]
%9 = phi i32 [ %24, %16 ], [ 0, %0 ]
%10 = phi float [ %23, %16 ], [ 0.000000e+00, %0 ]
%11 = load float, float* %1
%12 = fcmp olt float %11, 0.000000e+00
%13 = fcmp ogt float %11, 1.000000e+02
%14 = or i1 %12, %13
%15 = fpext float %11 to double
br i1 %14, label %28, label %16
16: ; preds = %6
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %15)
%18 = load float, float* %1
%19 = fcmp olt float %18, %8
%20 = select i1 %19, float %18, float %8
%21 = fcmp ogt float %18, %7
%22 = select i1 %21, float %18, float %7
%23 = fadd float %10, %18
%24 = add nuw nsw i32 %9, 1
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%27 = icmp eq i32 %26, 1
br i1 %27, label %6, label %31
28: ; preds = %6
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %15)
%30 = icmp eq i32 %9, 0
br i1 %30, label %43, label %31
31: ; preds = %16, %28
%32 = phi float [ %7, %28 ], [ %22, %16 ]
%33 = phi float [ %8, %28 ], [ %20, %16 ]
%34 = phi i32 [ %9, %28 ], [ %24, %16 ]
%35 = phi float [ %10, %28 ], [ %23, %16 ]
%36 = sitofp i32 %34 to float
%37 = fdiv float %35, %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %34, double %38)
%40 = fpext float %33 to double
%41 = fpext float %32 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %40, double %41)
br label %45
43: ; preds = %0, %28
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %45
45: ; preds = %43, %31
ret i32 0
}