#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int grade;
  int aCount = 0, bCount = 0, cCount = 0, dCount = 0, fCount = 0;
  printf("Enter the letter grades.\n");
  printf("Enter the EOF character to end input.\n");
  while ((grade = getchar()) != EOF) {
    if (grade == 'A' || grade == 'a') {
      ++aCount;
    } else if (grade == 'B' || grade == 'b') {
      ++bCount;
    } else if (grade == 'C' || grade == 'c') {
      ++cCount;
    } else if (grade == 'D' || grade == 'd') {
      ++dCount;
    } else if (grade == 'F' || grade == 'f') {
      ++fCount;
    } else if (grade == '\n' || grade == ' ') {
    } else {
      printf("Incorrect letter grade entered.\n");
      printf("Enter a new grade.\n");
    }
  }
  printf("Totals for each letter grade are:\n");
  printf("A: %d\n", aCount);
  printf("B: %d\n", bCount);
  printf("C: %d\n", cCount);
  printf("D: %d\n", dCount);
  printf("F: %d\n", fCount);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%eax
je     1284 <main+0x164>
cmpl   $0x41,-0x8(%rbp)
je     119b <main+0x7b>
cmpl   $0x61,-0x8(%rbp)
jne    11a9 <main+0x89>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    127f <main+0x15f>
cmpl   $0x42,-0x8(%rbp)
je     11bd <main+0x9d>
cmpl   $0x62,-0x8(%rbp)
jne    11cb <main+0xab>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    127a <main+0x15a>
cmpl   $0x43,-0x8(%rbp)
je     11df <main+0xbf>
cmpl   $0x63,-0x8(%rbp)
jne    11ed <main+0xcd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1275 <main+0x155>
cmpl   $0x44,-0x8(%rbp)
je     1201 <main+0xe1>
cmpl   $0x64,-0x8(%rbp)
jne    120f <main+0xef>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1270 <main+0x150>
cmpl   $0x46,-0x8(%rbp)
je     1223 <main+0x103>
cmpl   $0x66,-0x8(%rbp)
jne    1231 <main+0x111>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    126b <main+0x14b>
cmpl   $0xa,-0x8(%rbp)
je     1245 <main+0x125>
cmpl   $0x20,-0x8(%rbp)
jne    124a <main+0x12a>
jmp    1266 <main+0x146>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126b <main+0x14b>
jmp    1270 <main+0x150>
jmp    1275 <main+0x155>
jmp    127a <main+0x15a>
jmp    127f <main+0x15f>
jmp    116e <main+0x4e>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xef9(%rip),%rdi
call   1030 <puts@plt>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e85(%rip),%r13
mov    $0x0,%ebx
mov    $0x0,%r12d
mov    $0x0,%r15d
movl   $0x0,0x4(%rsp)
cmp    0x0(%r13),%eax
jne    11f3 <main+0xc3>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe71(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5d(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe06(%rip),%r14
movl   $0x0,0x4(%rsp)
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1231 <main+0x101>
addl   $0x1,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    0x0(%r13),%eax
je     1182 <main+0x52>
mov    %eax,%ecx
and    $0xffffffdf,%ecx
add    $0xffffffbf,%ecx
cmp    $0x5,%ecx
ja     125d <main+0x12d>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
add    $0x1,%ebp
jmp    1220 <main+0xf0>
add    $0x1,%ebx
jmp    1220 <main+0xf0>
add    $0x1,%r12d
jmp    1220 <main+0xf0>
add    $0x1,%r15d
jmp    1220 <main+0xf0>
cmp    $0xa,%eax
je     1220 <main+0xf0>
cmp    $0x20,%eax
je     1220 <main+0xf0>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
jmp    1220 <main+0xf0>

LLVM IR (-O0):
@.str = [26 x i8] c"Enter the letter grades.\0A\00"
@.str.1 = [39 x i8] c"Enter the EOF character to end input.\0A\00"
@EOF = global i32 0
@.str.2 = [33 x i8] c"Incorrect letter grade entered.\0A\00"
@.str.3 = [20 x i8] c"Enter a new grade.\0A\00"
@.str.4 = [35 x i8] c"Totals for each letter grade are:\0A\00"
@.str.5 = [7 x i8] c"A: %d\0A\00"
@.str.6 = [7 x i8] c"B: %d\0A\00"
@.str.7 = [7 x i8] c"C: %d\0A\00"
@.str.8 = [7 x i8] c"D: %d\0A\00"
@.str.9 = [7 x i8] c"F: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %74, %0
%11 = call i32 (...) @getchar()
store i32 %11, i32* %2
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br i1 %13, label %14, label %75
14: ; preds = %10
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 65
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 97
br i1 %19, label %20, label %23
20: ; preds = %17, %14
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %74
23: ; preds = %17
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 66
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 98
br i1 %28, label %29, label %32
29: ; preds = %26, %23
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %73
32: ; preds = %26
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 67
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 99
br i1 %37, label %38, label %41
38: ; preds = %35, %32
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %72
41: ; preds = %35
%42 = load i32, i32* %2
%43 = icmp eq i32 %42, 68
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* %2
%46 = icmp eq i32 %45, 100
br i1 %46, label %47, label %50
47: ; preds = %44, %41
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %71
50: ; preds = %44
%51 = load i32, i32* %2
%52 = icmp eq i32 %51, 70
br i1 %52, label %56, label %53
53: ; preds = %50
%54 = load i32, i32* %2
%55 = icmp eq i32 %54, 102
br i1 %55, label %56, label %59
56: ; preds = %53, %50
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %70
59: ; preds = %53
%60 = load i32, i32* %2
%61 = icmp eq i32 %60, 10
br i1 %61, label %65, label %62
62: ; preds = %59
%63 = load i32, i32* %2
%64 = icmp eq i32 %63, 32
br i1 %64, label %65, label %66
65: ; preds = %62, %59
br label %69
66: ; preds = %62
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %69
69: ; preds = %66, %65
br label %70
70: ; preds = %69, %56
br label %71
71: ; preds = %70, %47
br label %72
72: ; preds = %71, %38
br label %73
73: ; preds = %72, %29
br label %74
74: ; preds = %73, %20
br label %10
75: ; preds = %10
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%77 = load i32, i32* %3
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %77)
%79 = load i32, i32* %4
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %79)
%81 = load i32, i32* %5
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %81)
%83 = load i32, i32* %6
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %83)
%85 = load i32, i32* %7
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %85)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.5 = [7 x i8] c"A: %d\0A\00"
@.str.6 = [7 x i8] c"B: %d\0A\00"
@.str.7 = [7 x i8] c"C: %d\0A\00"
@.str.8 = [7 x i8] c"D: %d\0A\00"
@.str.9 = [7 x i8] c"F: %d\0A\00"
@str = [25 x i8] c"Enter the letter grades.\00"
@str.10 = [38 x i8] c"Enter the EOF character to end input.\00"
@str.11 = [34 x i8] c"Totals for each letter grade are:\00"
@str.12 = [32 x i8] c"Incorrect letter grade entered.\00"
@str.13 = [19 x i8] c"Enter a new grade.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.10, i64 0, i64 0))
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %37, label %6
6: ; preds = %0, %28
%7 = phi i32 [ %34, %28 ], [ %3, %0 ]
%8 = phi i32 [ %33, %28 ], [ 0, %0 ]
%9 = phi i32 [ %32, %28 ], [ 0, %0 ]
%10 = phi i32 [ %31, %28 ], [ 0, %0 ]
%11 = phi i32 [ %30, %28 ], [ 0, %0 ]
%12 = phi i32 [ %29, %28 ], [ 0, %0 ]
%13 = and i32 %7, -33
switch i32 %13, label %24 [
i32 65, label %14
i32 66, label %16
i32 67, label %18
i32 68, label %20
i32 70, label %22
]
14: ; preds = %6
%15 = add nsw i32 %12, 1
br label %28
16: ; preds = %6
%17 = add nsw i32 %11, 1
br label %28
18: ; preds = %6
%19 = add nsw i32 %10, 1
br label %28
20: ; preds = %6
%21 = add nsw i32 %9, 1
br label %28
22: ; preds = %6
%23 = add nsw i32 %8, 1
br label %28
24: ; preds = %6
switch i32 %7, label %25 [
i32 32, label %28
i32 10, label %28
]
25: ; preds = %24
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.12, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.13, i64 0, i64 0))
br label %28
28: ; preds = %24, %24, %16, %20, %25, %22, %18, %14
%29 = phi i32 [ %15, %14 ], [ %12, %16 ], [ %12, %18 ], [ %12, %20 ], [ %12, %22 ], [ %12, %24 ], [ %12, %25 ], [ %12, %24 ]
%30 = phi i32 [ %11, %14 ], [ %17, %16 ], [ %11, %18 ], [ %11, %20 ], [ %11, %22 ], [ %11, %24 ], [ %11, %25 ], [ %11, %24 ]
%31 = phi i32 [ %10, %14 ], [ %10, %16 ], [ %19, %18 ], [ %10, %20 ], [ %10, %22 ], [ %10, %24 ], [ %10, %25 ], [ %10, %24 ]
%32 = phi i32 [ %9, %14 ], [ %9, %16 ], [ %9, %18 ], [ %21, %20 ], [ %9, %22 ], [ %9, %24 ], [ %9, %25 ], [ %9, %24 ]
%33 = phi i32 [ %8, %14 ], [ %8, %16 ], [ %8, %18 ], [ %8, %20 ], [ %23, %22 ], [ %8, %24 ], [ %8, %25 ], [ %8, %24 ]
%34 = tail call i32 (...) @getchar()
%35 = load i32, i32* @EOF
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %6
37: ; preds = %28, %0
%38 = phi i32 [ 0, %0 ], [ %29, %28 ]
%39 = phi i32 [ 0, %0 ], [ %30, %28 ]
%40 = phi i32 [ 0, %0 ], [ %31, %28 ]
%41 = phi i32 [ 0, %0 ], [ %32, %28 ]
%42 = phi i32 [ 0, %0 ], [ %33, %28 ]
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.11, i64 0, i64 0))
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %39)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %40)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %41)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %42)
ret i32 0
}