#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 /*<<< orphan*/ puts(char *);
int main(void) {
  int grades;
  unsigned int aCount = 0;
  unsigned int bCount = 0;
  unsigned int cCount = 0;
  unsigned int dCount = 0;
  unsigned int fCount = 0;
  puts("Enter the letter grades.");
  puts("Enter the EOF character to end input.");
  while ((grades = getchar()) != EOF) {
    if (grades == 'A' || grades == 'a') {
      aCount++;
    } else if (grades == 'B' || grades == 'b') {
      bCount++;
    } else if (grades == 'C' || grades == 'c') {
      cCount++;
    } else if (grades == 'D' || grades == 'd') {
      dCount++;
    } else if (grades == 'F' || grades == 'f') {
      fCount++;
    } else if (grades == '\n' || grades == '\t' || grades == ' ') {
    } else {
      printf("%s", "Incorrect letter grade entered.");
      puts("Enter a new grade.");
    }
  }
  puts("\nTotals for each letter grade are:");
  printf("A: %u\n", aCount);
  printf("B: %u\n", bCount);
  printf("C: %u\n", cCount);
  printf("D: %u\n", dCount);
  printf("F: %u\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    0xe97(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
je     129f <main+0x16f>
cmpl   $0x41,-0x8(%rbp)
je     11a7 <main+0x77>
cmpl   $0x61,-0x8(%rbp)
jne    11b5 <main+0x85>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    129a <main+0x16a>
cmpl   $0x42,-0x8(%rbp)
je     11c9 <main+0x99>
cmpl   $0x62,-0x8(%rbp)
jne    11d7 <main+0xa7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1295 <main+0x165>
cmpl   $0x43,-0x8(%rbp)
je     11eb <main+0xbb>
cmpl   $0x63,-0x8(%rbp)
jne    11f9 <main+0xc9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1290 <main+0x160>
cmpl   $0x44,-0x8(%rbp)
je     120d <main+0xdd>
cmpl   $0x64,-0x8(%rbp)
jne    121b <main+0xeb>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    128b <main+0x15b>
cmpl   $0x46,-0x8(%rbp)
je     122f <main+0xff>
cmpl   $0x66,-0x8(%rbp)
jne    123d <main+0x10d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1286 <main+0x156>
cmpl   $0xa,-0x8(%rbp)
je     125b <main+0x12b>
cmpl   $0x9,-0x8(%rbp)
je     125b <main+0x12b>
cmpl   $0x20,-0x8(%rbp)
jne    1260 <main+0x130>
jmp    1281 <main+0x151>
lea    0xdd8(%rip),%rdi
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
jmp    1286 <main+0x156>
jmp    128b <main+0x15b>
jmp    1290 <main+0x160>
jmp    1295 <main+0x165>
jmp    129a <main+0x16a>
jmp    117a <main+0x4a>
lea    0xdcf(%rip),%rdi
call   1030 <puts@plt>
mov    -0xc(%rbp),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <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    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xee3(%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    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf12(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf09(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeff(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef5(%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    $0x20,%eax
ja     1274 <main+0x144>
mov    %eax,%eax
movabs $0x100000600,%rcx
bt     %rax,%rcx
jb     1220 <main+0xf0>
lea    0xddc(%rip),%rdi
lea    0xdd8(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdea(%rip),%rdi
call   1030 <puts@plt>
jmp    1220 <main+0xf0>

LLVM IR (-O0):
@.str = [25 x i8] c"Enter the letter grades.\00"
@.str.1 = [38 x i8] c"Enter the EOF character to end input.\00"
@EOF = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [32 x i8] c"Incorrect letter grade entered.\00"
@.str.4 = [19 x i8] c"Enter a new grade.\00"
@.str.5 = [35 x i8] c"\0ATotals for each letter grade are:\00"
@.str.6 = [7 x i8] c"A: %u\0A\00"
@.str.7 = [7 x i8] c"B: %u\0A\00"
@.str.8 = [7 x i8] c"C: %u\0A\00"
@.str.9 = [7 x i8] c"D: %u\0A\00"
@.str.10 = [7 x i8] c"F: %u\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 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %77, %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 %78
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 i32 %21, 1
store i32 %22, i32* %3
br label %77
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 i32 %30, 1
store i32 %31, i32* %4
br label %76
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 i32 %39, 1
store i32 %40, i32* %5
br label %75
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 i32 %48, 1
store i32 %49, i32* %6
br label %74
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 i32 %57, 1
store i32 %58, i32* %7
br label %73
59: ; preds = %53
%60 = load i32, i32* %2
%61 = icmp eq i32 %60, 10
br i1 %61, label %68, label %62
62: ; preds = %59
%63 = load i32, i32* %2
%64 = icmp eq i32 %63, 9
br i1 %64, label %68, label %65
65: ; preds = %62
%66 = load i32, i32* %2
%67 = icmp eq i32 %66, 32
br i1 %67, label %68, label %69
68: ; preds = %65, %62, %59
br label %72
69: ; preds = %65
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%71 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %72
72: ; preds = %69, %68
br label %73
73: ; preds = %72, %56
br label %74
74: ; preds = %73, %47
br label %75
75: ; preds = %74, %38
br label %76
76: ; preds = %75, %29
br label %77
77: ; preds = %76, %20
br label %10
78: ; preds = %10
%79 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%80 = load i32, i32* %3
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %80)
%82 = load i32, i32* %4
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %82)
%84 = load i32, i32* %5
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %84)
%86 = load i32, i32* %6
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %86)
%88 = load i32, i32* %7
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %88)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Enter the letter grades.\00"
@.str.1 = [38 x i8] c"Enter the EOF character to end input.\00"
@EOF = global i32 0
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [32 x i8] c"Incorrect letter grade entered.\00"
@.str.4 = [19 x i8] c"Enter a new grade.\00"
@.str.5 = [35 x i8] c"\0ATotals for each letter grade are:\00"
@.str.6 = [7 x i8] c"A: %u\0A\00"
@.str.7 = [7 x i8] c"B: %u\0A\00"
@.str.8 = [7 x i8] c"C: %u\0A\00"
@.str.9 = [7 x i8] c"D: %u\0A\00"
@.str.10 = [7 x i8] c"F: %u\0A\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.1, 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 i32 %12, 1
br label %28
16: ; preds = %6
%17 = add i32 %11, 1
br label %28
18: ; preds = %6
%19 = add i32 %10, 1
br label %28
20: ; preds = %6
%21 = add i32 %9, 1
br label %28
22: ; preds = %6
%23 = add i32 %8, 1
br label %28
24: ; preds = %6
switch i32 %7, label %25 [
i32 32, label %28
i32 10, label %28
i32 9, label %28
]
25: ; preds = %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %24, %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 ], [ %12, %24 ]
%30 = phi i32 [ %11, %14 ], [ %17, %16 ], [ %11, %18 ], [ %11, %20 ], [ %11, %22 ], [ %11, %24 ], [ %11, %25 ], [ %11, %24 ], [ %11, %24 ]
%31 = phi i32 [ %10, %14 ], [ %10, %16 ], [ %19, %18 ], [ %10, %20 ], [ %10, %22 ], [ %10, %24 ], [ %10, %25 ], [ %10, %24 ], [ %10, %24 ]
%32 = phi i32 [ %9, %14 ], [ %9, %16 ], [ %9, %18 ], [ %21, %20 ], [ %9, %22 ], [ %9, %24 ], [ %9, %25 ], [ %9, %24 ], [ %9, %24 ]
%33 = phi i32 [ %8, %14 ], [ %8, %16 ], [ %8, %18 ], [ %8, %20 ], [ %23, %22 ], [ %8, %24 ], [ %8, %25 ], [ %8, %24 ], [ %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 ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %38)
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %39)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %40)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %41)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 %42)
ret i32 0
}