#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 *, int *);
int main(void) {
  int grade;
  printf("Enter numerical grade: ");
  scanf("%d", &grade);
  if (grade < 0 || grade > 100) {
    printf("ERROR: Invalid Grade\n");
  } else {
    printf("Letter Grade: ");
    switch (grade / 10) {
    case 10:
    case 9:
      printf("A\n");
      break;
    case 8:
      printf("B\n");
      break;
    case 7:
      printf("C\n");
      break;
    case 6:
      printf("D\n");
      break;
    default:
      printf("F\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     115f <main+0x3f>
cmpl   $0x64,-0x8(%rbp)
jle    1170 <main+0x50>
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
jmp    1214 <main+0xf4>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
movslq -0x8(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
sar    $0x22,%rcx
mov    %ecx,%edx
shr    $0x3f,%rax
mov    %eax,%ecx
mov    %edx,%eax
lea    -0x6(%rax,%rcx,1),%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     1203 <main+0xe3>
mov    -0x10(%rbp),%rax
lea    0xe4a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xef>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xef>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xef>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xef>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
jmp    1214 <main+0xf4>
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    0xed4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x64,0x4(%rsp)
jbe    115e <main+0x2e>
lea    0xed8(%rip),%rdi
jmp    11a4 <main+0x74>
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
sar    $0x22,%rcx
shr    $0x3f,%rax
add    %ecx,%eax
add    $0xfffffffa,%eax
cmp    $0x4,%eax
ja     119d <main+0x6d>
cltq
lea    0xeb8(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    11a4 <main+0x74>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter numerical grade: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"ERROR: Invalid Grade\0A\00"
@.str.3 = [15 x i8] c"Letter Grade: \00"
@.str.4 = [3 x i8] c"A\0A\00"
@.str.5 = [3 x i8] c"B\0A\00"
@.str.6 = [3 x i8] c"C\0A\00"
@.str.7 = [3 x i8] c"D\0A\00"
@.str.8 = [3 x i8] c"F\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 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), i32* %2)
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 100
br i1 %9, label %10, label %12
10: ; preds = %7, %0
%11 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %27
12: ; preds = %7
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 10
switch i32 %15, label %24 [
i32 10, label %16
i32 9, label %16
i32 8, label %18
i32 7, label %20
i32 6, label %22
]
16: ; preds = %12, %12
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %26
18: ; preds = %12
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %26
20: ; preds = %12
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %26
22: ; preds = %12
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %26
24: ; preds = %12
%25 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
br label %26
26: ; preds = %24, %22, %20, %18, %16
br label %27
27: ; preds = %26, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter numerical grade: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [15 x i8] c"Letter Grade: \00"
@str = [2 x i8] c"D\00"
@str.9 = [2 x i8] c"C\00"
@str.10 = [2 x i8] c"B\00"
@str.11 = [2 x i8] c"A\00"
@str.12 = [2 x i8] c"F\00"
@str.13 = [21 x i8] c"ERROR: Invalid Grade\00"
@reltable.main = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str.9 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str.10 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 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), i32* %1)
%5 = load i32, i32* %1
%6 = icmp ugt i32 %5, 100
br i1 %6, label %17, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = sdiv i32 %9, 10
%11 = add nsw i32 %10, -6
%12 = icmp ult i32 %11, 5
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = sext i32 %11 to i64
%15 = shl i64 %14, 2
%16 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.main to i8*), i64 %15)
br label %17
17: ; preds = %7, %13, %0
%18 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.13, i64 0, i64 0), %0 ], [ %16, %13 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.12, i64 0, i64 0), %7 ]
%19 = call i32 @puts(i8* dereferenceable(1) %18)
ret i32 0
}