#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() {
  char letterGrade;
  printf("Enter the letter grade you hope to get in this class -- ");
  scanf("%s", &letterGrade);
  switch (letterGrade) {
  case 'A':
    printf("A's are great for the GPA - good luck!\n");
    break;
  case 'B':
    printf("B's are ok. \n");
    break;
  case 'C':
    printf("Got a C, I passed!\n");
    break;
  case 'D':
  case 'F':
    printf("Oh no, do I have to do this again?\n");
    break;
  default:
    printf("Valid grades are A, B, C ,D and F.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     11b9 <main+0x99>
mov    -0x10(%rbp),%rax
lea    0xe94(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
movsbq 0x7(%rsp),%rax
add    $0xffffffffffffffbf,%rax
cmp    $0x5,%eax
ja     116d <main+0x3d>
lea    0xf68(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1174 <main+0x44>
lea    0xf32(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [57 x i8] c"Enter the letter grade you hope to get in this class -- \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [40 x i8] c"A's are great for the GPA - good luck!\0A\00"
@.str.3 = [14 x i8] c"B's are ok. \0A\00"
@.str.4 = [20 x i8] c"Got a C, I passed!\0A\00"
@.str.5 = [36 x i8] c"Oh no, do I have to do this again?\0A\00"
@.str.6 = [36 x i8] c"Valid grades are A, B, C ,D and F.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
switch i32 %6, label %15 [
i32 65, label %7
i32 66, label %9
i32 67, label %11
i32 68, label %13
i32 70, label %13
]
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
br label %17
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %17
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %17
13: ; preds = %0, %0
%14 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
br label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %11, %9, %7
ret i32 0
}

LLVM IR (-O2):
@.str = [57 x i8] c"Enter the letter grade you hope to get in this class -- \00"
@.str.1 = [3 x i8] c"%s\00"
@str = [35 x i8] c"Oh no, do I have to do this again?\00"
@str.7 = [19 x i8] c"Got a C, I passed!\00"
@str.8 = [13 x i8] c"B's are ok. \00"
@str.9 = [39 x i8] c"A's are great for the GPA - good luck!\00"
@str.10 = [35 x i8] c"Valid grades are A, B, C ,D and F.\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([39 x i8]* @str.9 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.8 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @str to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @str to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 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 = sext i8 %4 to i32
%6 = add nsw i32 %5, -65
%7 = icmp ult i32 %6, 6
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = sext i32 %6 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %10)
br label %12
12: ; preds = %0, %8
%13 = phi i8* [ %11, %8 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.10, i64 0, i64 0), %0 ]
%14 = call i32 @puts(i8* dereferenceable(1) %13)
ret i32 0
}