#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 *, char *);
int main(void) {
  char grade;
  int excellent = 0, normal = 0, bad = 0;
  printf("Enter your grade,if wanna quit,enter Z\n");
  scanf("%c", &grade);
  while (grade != 'z') {
    switch (grade) {
    case 'A':
    case 'a':
      excellent++;
      break;
    case 'B':
    case 'b':
      normal++;
      break;
    case 'C':
    case 'c':
      bad++;
      break;
    case '\n':
    case ' ':
      break;
    default:
      printf("you suck\n");
      break;
    }
    scanf("%c", &grade);
  }
  printf("%d\n%d\n%d\n", excellent, normal, bad);
  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)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x7a,%eax
je     124d <main+0x12d>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0xa,%eax
je     1225 <main+0x105>
jmp    1184 <main+0x64>
mov    -0x18(%rbp),%eax
sub    $0x20,%eax
je     1225 <main+0x105>
jmp    1195 <main+0x75>
mov    -0x18(%rbp),%eax
sub    $0x41,%eax
je     11fb <main+0xdb>
jmp    11a6 <main+0x86>
mov    -0x18(%rbp),%eax
sub    $0x42,%eax
je     1209 <main+0xe9>
jmp    11b7 <main+0x97>
mov    -0x18(%rbp),%eax
sub    $0x43,%eax
je     1217 <main+0xf7>
jmp    11c8 <main+0xa8>
mov    -0x18(%rbp),%eax
sub    $0x61,%eax
je     11fb <main+0xdb>
jmp    11d9 <main+0xb9>
mov    -0x18(%rbp),%eax
sub    $0x62,%eax
je     1209 <main+0xe9>
jmp    11ea <main+0xca>
mov    -0x18(%rbp),%eax
sub    $0x63,%eax
je     1217 <main+0xf7>
jmp    122a <main+0x10a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1238 <main+0x118>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1238 <main+0x118>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1238 <main+0x118>
jmp    1238 <main+0x118>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde9(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1162 <main+0x42>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xdd8(%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    0xfdb(%rip),%rdi
call   1030 <puts@plt>
lea    0xfc2(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x7(%rsp),%al
xor    %ebp,%ebp
mov    $0x0,%ebx
mov    $0x0,%r14d
cmp    $0x7a,%al
jne    1193 <main+0x63>
lea    0xf9f(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
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
xor    %r14d,%r14d
lea    0xf73(%rip),%r15
lea    0x7(%rsp),%r12
lea    0xe57(%rip),%r13
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11c8 <main+0x98>
nop
add    $0x1,%r14d
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movzbl 0x7(%rsp),%eax
cmp    $0x7a,%al
je     116d <main+0x3d>
movsbl %al,%eax
lea    -0x20(%rax),%ecx
cmp    $0x43,%ecx
ja     11f5 <main+0xc5>
movslq 0x0(%r13,%rcx,4),%rax
add    %r13,%rax
jmp    *%rax
add    $0x1,%ebp
jmp    11b4 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
jmp    11b4 <main+0x84>
cmp    $0xa,%eax
je     11b4 <main+0x84>
lea    0xf43(%rip),%rdi
call   1030 <puts@plt>
jmp    11b4 <main+0x84>

LLVM IR (-O0):
@.str = [40 x i8] c"Enter your grade,if wanna quit,enter Z\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [10 x i8] c"you suck\0A\00"
@.str.3 = [10 x i8] c"%d\0A%d\0A%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %8
8: ; preds = %27, %0
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 122
br i1 %11, label %12, label %29
12: ; preds = %8
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
switch i32 %14, label %25 [
i32 65, label %15
i32 97, label %15
i32 66, label %18
i32 98, label %18
i32 67, label %21
i32 99, label %21
i32 10, label %24
i32 32, label %24
]
15: ; preds = %12, %12
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %27
18: ; preds = %12, %12
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %27
21: ; preds = %12, %12
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %27
24: ; preds = %12, %12
br label %27
25: ; preds = %12
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %24, %21, %18, %15
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %8
29: ; preds = %8
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.3 = [10 x i8] c"%d\0A%d\0A%d\0A\00"
@str = [39 x i8] c"Enter your grade,if wanna quit,enter Z\00"
@str.4 = [9 x i8] c"you suck\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 122
br i1 %5, label %27, label %6
6: ; preds = %0, %20
%7 = phi i8 [ %25, %20 ], [ %4, %0 ]
%8 = phi i32 [ %23, %20 ], [ 0, %0 ]
%9 = phi i32 [ %22, %20 ], [ 0, %0 ]
%10 = phi i32 [ %21, %20 ], [ 0, %0 ]
%11 = sext i8 %7 to i32
switch i32 %11, label %18 [
i32 65, label %12
i32 97, label %12
i32 66, label %14
i32 98, label %14
i32 67, label %16
i32 99, label %16
i32 10, label %20
i32 32, label %20
]
12: ; preds = %6, %6
%13 = add nsw i32 %10, 1
br label %20
14: ; preds = %6, %6
%15 = add nsw i32 %9, 1
br label %20
16: ; preds = %6, %6
%17 = add nsw i32 %8, 1
br label %20
18: ; preds = %6
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0))
br label %20
20: ; preds = %6, %6, %18, %16, %14, %12
%21 = phi i32 [ %10, %18 ], [ %10, %6 ], [ %10, %6 ], [ %10, %16 ], [ %10, %14 ], [ %13, %12 ]
%22 = phi i32 [ %9, %18 ], [ %9, %6 ], [ %9, %6 ], [ %9, %16 ], [ %15, %14 ], [ %9, %12 ]
%23 = phi i32 [ %8, %18 ], [ %8, %6 ], [ %8, %6 ], [ %17, %16 ], [ %8, %14 ], [ %8, %12 ]
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%25 = load i8, i8* %1
%26 = icmp eq i8 %25, 122
br i1 %26, label %27, label %6
27: ; preds = %20, %0
%28 = phi i32 [ 0, %0 ], [ %21, %20 ]
%29 = phi i32 [ 0, %0 ], [ %22, %20 ]
%30 = phi i32 [ 0, %0 ], [ %23, %20 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
ret i32 0
}