#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(void) {
  int grade;
  int aCount = 0;
  int bCount = 0;
  int cCount = 0;
  int dCount = 0;
  int fCount = 0;
  printf("Enter the letter grades.\n");
  printf("Enter the EOF character to end input.\n");
  while ((grade = getchar()) != EOF) {
    switch (grade) {
    case 'A':
    case 'a':
      ++aCount;
      break;
    case 'B':
    case 'b':
      ++bCount;
      break;
    case 'C':
    case 'c':
      ++cCount;
      break;
    case 'D':
    case 'd':
      ++dCount;
      break;
    case 'F':
    case 'f':
      ++fCount;
      break;
    case '\n':
    case '\t':
    case ' ':
      break;
    default:
      printf("Incorrect letter grade entered.");
      printf(" Enter a new grade.\n");
      break;
    }
  }
  printf("\nTotals 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    $0x30,%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    0x101f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0x102b(%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     121c <main+0xfc>
mov    -0x8(%rbp),%eax
add    $0xfffffff7,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5d,%eax
ja     11fb <main+0xdb>
mov    -0x28(%rbp),%rax
lea    0xe59(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1217 <main+0xf7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1217 <main+0xf7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1217 <main+0xf7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1217 <main+0xf7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1217 <main+0xf7>
jmp    1217 <main+0xf7>
lea    0xfb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfc9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116e <main+0x4e>
lea    0xfcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xfde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xfd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xfca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xfc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xfb6(%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
push   %rax
lea    0x1079(%rip),%rdi
call   1030 <puts@plt>
lea    0x1086(%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    0x1071(%rip),%rdi
call   1030 <puts@plt>
lea    0x1003(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xffa(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xff1(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfe7(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfdd(%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>
add    $0xfffffff7,%eax
cmp    $0x5d,%eax
ja     1258 <main+0x128>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
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>
lea    0xf19(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xfb0(%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 = [32 x i8] c"Incorrect letter grade entered.\00"
@.str.3 = [21 x i8] c" Enter a new grade.\0A\00"
@.str.4 = [36 x i8] c"\0ATotals 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 = %35, %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 %36
14: ; preds = %10
%15 = load i32, i32* %2
switch i32 %15, label %32 [
i32 65, label %16
i32 97, label %16
i32 66, label %19
i32 98, label %19
i32 67, label %22
i32 99, label %22
i32 68, label %25
i32 100, label %25
i32 70, label %28
i32 102, label %28
i32 10, label %31
i32 9, label %31
i32 32, label %31
]
16: ; preds = %14, %14
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %35
19: ; preds = %14, %14
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %35
22: ; preds = %14, %14
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %35
25: ; preds = %14, %14
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %35
28: ; preds = %14, %14
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %35
31: ; preds = %14, %14, %14
br label %35
32: ; preds = %14
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %32, %31, %28, %25, %22, %19, %16
br label %10
36: ; preds = %10
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %4
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %5
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %6
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %46)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.2 = [32 x i8] c"Incorrect letter grade entered.\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"
@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 = [35 x i8] c"\0ATotals for each letter grade are:\00"
@str.12 = [20 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 %35, label %6
6: ; preds = %0, %26
%7 = phi i32 [ %32, %26 ], [ %3, %0 ]
%8 = phi i32 [ %31, %26 ], [ 0, %0 ]
%9 = phi i32 [ %30, %26 ], [ 0, %0 ]
%10 = phi i32 [ %29, %26 ], [ 0, %0 ]
%11 = phi i32 [ %28, %26 ], [ 0, %0 ]
%12 = phi i32 [ %27, %26 ], [ 0, %0 ]
switch i32 %7, label %23 [
i32 65, label %13
i32 97, label %13
i32 66, label %15
i32 98, label %15
i32 67, label %17
i32 99, label %17
i32 68, label %19
i32 100, label %19
i32 70, label %21
i32 102, label %21
i32 10, label %26
i32 9, label %26
i32 32, label %26
]
13: ; preds = %6, %6
%14 = add nsw i32 %12, 1
br label %26
15: ; preds = %6, %6
%16 = add nsw i32 %11, 1
br label %26
17: ; preds = %6, %6
%18 = add nsw i32 %10, 1
br label %26
19: ; preds = %6, %6
%20 = add nsw i32 %9, 1
br label %26
21: ; preds = %6, %6
%22 = add nsw i32 %8, 1
br label %26
23: ; preds = %6
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
br label %26
26: ; preds = %6, %6, %6, %23, %21, %19, %17, %15, %13
%27 = phi i32 [ %12, %23 ], [ %12, %6 ], [ %12, %6 ], [ %12, %6 ], [ %12, %21 ], [ %12, %19 ], [ %12, %17 ], [ %12, %15 ], [ %14, %13 ]
%28 = phi i32 [ %11, %23 ], [ %11, %6 ], [ %11, %6 ], [ %11, %6 ], [ %11, %21 ], [ %11, %19 ], [ %11, %17 ], [ %16, %15 ], [ %11, %13 ]
%29 = phi i32 [ %10, %23 ], [ %10, %6 ], [ %10, %6 ], [ %10, %6 ], [ %10, %21 ], [ %10, %19 ], [ %18, %17 ], [ %10, %15 ], [ %10, %13 ]
%30 = phi i32 [ %9, %23 ], [ %9, %6 ], [ %9, %6 ], [ %9, %6 ], [ %9, %21 ], [ %20, %19 ], [ %9, %17 ], [ %9, %15 ], [ %9, %13 ]
%31 = phi i32 [ %8, %23 ], [ %8, %6 ], [ %8, %6 ], [ %8, %6 ], [ %22, %21 ], [ %8, %19 ], [ %8, %17 ], [ %8, %15 ], [ %8, %13 ]
%32 = tail call i32 (...) @getchar()
%33 = load i32, i32* @EOF
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %6
35: ; preds = %26, %0
%36 = phi i32 [ 0, %0 ], [ %27, %26 ]
%37 = phi i32 [ 0, %0 ], [ %28, %26 ]
%38 = phi i32 [ 0, %0 ], [ %29, %26 ]
%39 = phi i32 [ 0, %0 ], [ %30, %26 ]
%40 = phi i32 [ 0, %0 ], [ %31, %26 ]
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.11, i64 0, i64 0))
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %37)
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %38)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %39)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %40)
ret i32 0
}