#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() {
  int n;
  char grad;
  printf("Enter numerical grade:");
  scanf("%d", &n);
  if ((n >= 0) && (n <= 100)) {
    n /= 10;
    switch (n) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
      grad = 'F';
      break;
    case 6:
      grad = 'D';
      break;
    case 7:
      grad = 'C';
      break;
    case 8:
      grad = 'B';
      break;
    case 9:
    case 10:
      grad = 'A';
      break;
    default:
      break;
    }
  } else {
    printf("Input Error!\n");
    return -1;
  }
  printf("grade level: %c\n", grad);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     11d8 <main+0xb8>
cmpl   $0x64,-0x8(%rbp)
jg     11d8 <main+0xb8>
movslq -0x8(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0xa,%rax
ja     11ce <main+0xae>
mov    -0x18(%rbp),%rax
lea    0xe68(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x46,-0x9(%rbp)
jmp    11d3 <main+0xb3>
movb   $0x44,-0x9(%rbp)
jmp    11d3 <main+0xb3>
movb   $0x43,-0x9(%rbp)
jmp    11d3 <main+0xb3>
movb   $0x42,-0x9(%rbp)
jmp    11d3 <main+0xb3>
movb   $0x41,-0x9(%rbp)
jmp    11d3 <main+0xb3>
jmp    11d3 <main+0xb3>
jmp    11f2 <main+0xd2>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    120b <main+0xeb>
movsbl -0x9(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x64,%eax
ja     1193 <main+0x63>
movzbl %al,%ecx
imul   $0xcd,%ecx,%eax
shr    $0xb,%eax
mov    %eax,0x4(%rsp)
cmp    $0x6e,%cl
jae    117f <main+0x4f>
movzbl %al,%eax
lea    0xebc(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
lea    0xe94(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a4 <main+0x74>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Enter numerical grade:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [14 x i8] c"Input Error!\0A\00"
@.str.3 = [17 x i8] c"grade level: %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 100
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 10
store i32 %13, i32* %2
%14 = load i32, i32* %2
switch i32 %14, label %20 [
i32 0, label %15
i32 1, label %15
i32 2, label %15
i32 3, label %15
i32 4, label %15
i32 5, label %15
i32 6, label %16
i32 7, label %17
i32 8, label %18
i32 9, label %19
i32 10, label %19
]
15: ; preds = %11, %11, %11, %11, %11, %11
store i8 70, i8* %3
br label %21
16: ; preds = %11
store i8 68, i8* %3
br label %21
17: ; preds = %11
store i8 67, i8* %3
br label %21
18: ; preds = %11
store i8 66, i8* %3
br label %21
19: ; preds = %11, %11
store i8 65, i8* %3
br label %21
20: ; preds = %11
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15
br label %24
22: ; preds = %8, %0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %28
24: ; preds = %21
%25 = load i8, i8* %3
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %26)
store i32 0, i32* %1
br label %28
28: ; preds = %24, %22
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter numerical grade:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [17 x i8] c"grade level: %c\0A\00"
@str = [13 x i8] c"Input Error!\00"
@switch.table.main = [11 x i32] [i32 70, i32 70, i32 70, i32 70, i32 70, i32 70, i32 68, i32 67, i32 66, i32 65, i32 65]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 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 ult i32 %5, 101
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = trunc i32 %5 to i8
%9 = udiv i8 %8, 10
%10 = zext i8 %9 to i32
store i32 %10, i32* %1
%11 = icmp ult i8 %8, 110
br i1 %11, label %14, label %18
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %21
14: ; preds = %7
%15 = zext i8 %9 to i64
%16 = getelementptr inbounds [11 x i32], [11 x i32]* @switch.table.main, i64 0, i64 %15
%17 = load i32, i32* %16
br label %18
18: ; preds = %14, %7
%19 = phi i32 [ 0, %7 ], [ %17, %14 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %12
%22 = phi i32 [ 0, %18 ], [ -1, %12 ]
ret i32 %22
}