#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 *, double *);
int main() {
  double averageGrade;
  double totalGrade;
  double inputGrade;
  int counter;
  char gradeLetter;
  char anOrA;
  totalGrade = 0;
  averageGrade = 0;
  counter = 0;
  inputGrade = 0;
  gradeLetter = 'F';
  anOrA = 'n';
  printf("\nPlease input a grade or -1 to exit -->  ");
  scanf("%lf", &inputGrade);
  printf("\nYou have entered %.2lf\n", inputGrade);
  while (inputGrade >= 0) {
    totalGrade = totalGrade + inputGrade;
    counter++;
    printf("\nPlease input a grade or -1 to exit -->  ");
    scanf("%lf", &inputGrade);
    printf("\nYou have entered %.2lf\n", inputGrade);
  }
  averageGrade = totalGrade / counter;
  if (averageGrade >= 90) {
    gradeLetter = 'A';
    anOrA = 'n';
  } else if (averageGrade >= 80) {
    gradeLetter = 'B';
    anOrA = ' ';
  } else if (averageGrade >= 70) {
    gradeLetter = 'C';
    anOrA = ' ';
  } else {
    gradeLetter = 'F';
    anOrA = 'n';
  }
  printf("\n Your current total is %c%.2lf out of %d tests which amounts to "
         "a%c %c.\n",
         37, averageGrade, counter, anOrA, gradeLetter);
  printf("%c\n", gradeLetter);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x46,-0x25(%rbp)
movb   $0x6e,-0x26(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xec6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e7 <main+0xc7>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe6b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1187 <main+0x67>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdf9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     121e <main+0xfe>
movb   $0x41,-0x25(%rbp)
movb   $0x6e,-0x26(%rbp)
jmp    1278 <main+0x158>
movsd  -0x10(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1242 <main+0x122>
movb   $0x42,-0x25(%rbp)
movb   $0x20,-0x26(%rbp)
jmp    1273 <main+0x153>
movsd  -0x10(%rbp),%xmm0
movsd  0xdc1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1266 <main+0x146>
movb   $0x43,-0x25(%rbp)
movb   $0x20,-0x26(%rbp)
jmp    126e <main+0x14e>
movb   $0x46,-0x25(%rbp)
movb   $0x6e,-0x26(%rbp)
jmp    1273 <main+0x153>
jmp    1278 <main+0x158>
movsd  -0x10(%rbp),%xmm0
mov    -0x24(%rbp),%edx
movsbl -0x26(%rbp),%ecx
movsbl -0x25(%rbp),%r8d
lea    0xdcf(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movsbl -0x25(%rbp),%esi
lea    0xe02(%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
movq   $0x0,0x8(%rsp)
lea    0xee2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
lea    0xee9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     11e8 <main+0xc8>
lea    0xe9d(%rip),%r14
lea    0xec0(%rip),%r15
lea    0x8(%rsp),%r12
lea    0xeb8(%rip),%r13
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
nopl   0x0(%rax)
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd 0xe32(%rip),%xmm1
jae    11a0 <main+0x80>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
ucomisd 0xe05(%rip),%xmm0
jae    1227 <main+0x107>
ucomisd 0xe03(%rip),%xmm0
jae    1233 <main+0x113>
xor    %eax,%eax
ucomisd 0xdff(%rip),%xmm0
setb   %al
lea    0x43(%rax,%rax,2),%ebp
mov    $0x6e,%eax
mov    $0x20,%ecx
cmovb  %eax,%ecx
jmp    123d <main+0x11d>
mov    $0x6e,%ecx
mov    $0x41,%ebp
jmp    123d <main+0x11d>
mov    $0x20,%ecx
mov    $0x42,%ebp
lea    0xe23(%rip),%rdi
mov    $0x25,%esi
mov    %ebx,%edx
mov    %ebp,%r8d
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"\0APlease input a grade or -1 to exit --> \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [25 x i8] c"\0AYou have entered %.2lf\0A\00"
@.str.3 = [74 x i8] c"\0A Your current total is %c%.2lf out of %d tests which amounts to a%c %c.\0A\00"
@.str.4 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
store i32 0, i32* %1
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %2
store i32 0, i32* %5
store double 0.000000e+00, double* %4
store i8 70, i8* %6
store i8 110, i8* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%10 = load double, double* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %10)
br label %12
12: ; preds = %15, %0
%13 = load double, double* %4
%14 = fcmp oge double %13, 0.000000e+00
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load double, double* %3
%17 = load double, double* %4
%18 = fadd double %16, %17
store double %18, double* %3
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %4)
%23 = load double, double* %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %23)
br label %12
25: ; preds = %12
%26 = load double, double* %3
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to double
%29 = fdiv double %26, %28
store double %29, double* %2
%30 = load double, double* %2
%31 = fcmp oge double %30, 9.000000e+01
br i1 %31, label %32, label %33
32: ; preds = %25
store i8 65, i8* %6
store i8 110, i8* %7
br label %44
33: ; preds = %25
%34 = load double, double* %2
%35 = fcmp oge double %34, 8.000000e+01
br i1 %35, label %36, label %37
36: ; preds = %33
store i8 66, i8* %6
store i8 32, i8* %7
br label %43
37: ; preds = %33
%38 = load double, double* %2
%39 = fcmp oge double %38, 7.000000e+01
br i1 %39, label %40, label %41
40: ; preds = %37
store i8 67, i8* %6
store i8 32, i8* %7
br label %42
41: ; preds = %37
store i8 70, i8* %6
store i8 110, i8* %7
br label %42
42: ; preds = %41, %40
br label %43
43: ; preds = %42, %36
br label %44
44: ; preds = %43, %32
%45 = load double, double* %2
%46 = load i32, i32* %5
%47 = load i8, i8* %7
%48 = sext i8 %47 to i32
%49 = load i8, i8* %6
%50 = sext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i32 37, double %45, i32 %46, i32 %48, i32 %50)
%52 = load i8, i8* %6
%53 = sext i8 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %53)
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"\0APlease input a grade or -1 to exit --> \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [25 x i8] c"\0AYou have entered %.2lf\0A\00"
@.str.3 = [74 x i8] c"\0A Your current total is %c%.2lf out of %d tests which amounts to a%c %c.\0A\00"
@.str.4 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
store double 0.000000e+00, double* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %5)
%7 = load double, double* %1
%8 = fcmp ult double %7, 0.000000e+00
br i1 %8, label %21, label %9
9: ; preds = %0, %9
%10 = phi double [ %19, %9 ], [ %7, %0 ]
%11 = phi i32 [ %14, %9 ], [ 0, %0 ]
%12 = phi double [ %13, %9 ], [ 0.000000e+00, %0 ]
%13 = fadd double %12, %10
%14 = add nuw nsw i32 %11, 1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%17 = load double, double* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = load double, double* %1
%20 = fcmp ult double %19, 0.000000e+00
br i1 %20, label %21, label %9
21: ; preds = %9, %0
%22 = phi double [ 0.000000e+00, %0 ], [ %13, %9 ]
%23 = phi i32 [ 0, %0 ], [ %14, %9 ]
%24 = sitofp i32 %23 to double
%25 = fdiv double %22, %24
%26 = fcmp ult double %25, 9.000000e+01
br i1 %26, label %27, label %33
27: ; preds = %21
%28 = fcmp ult double %25, 8.000000e+01
br i1 %28, label %29, label %33
29: ; preds = %27
%30 = fcmp ult double %25, 7.000000e+01
%31 = select i1 %30, i32 70, i32 67
%32 = select i1 %30, i32 110, i32 32
br label %33
33: ; preds = %29, %27, %21
%34 = phi i32 [ 65, %21 ], [ 66, %27 ], [ %31, %29 ]
%35 = phi i32 [ 110, %21 ], [ 32, %27 ], [ %32, %29 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i32 37, double %25, i32 %23, i32 %35, i32 %34)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %34)
ret i32 0
}