#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, tens_digit;
  printf("Enter numerical grade: ");
  scanf("%d", &grade);
  tens_digit = grade / 10;
  printf("Letter grade: ");
  switch (tens_digit) {
  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;
  case 5:
  case 4:
  case 3:
  case 2:
  case 1:
  case 0:
    printf("F\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movslq -0x8(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0xa,%rax
ja     11e7 <main+0xc7>
mov    -0x18(%rbp),%rax
lea    0xe72(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
cmp    $0xa,%ebx
ja     1192 <main+0x62>
movslq %ebx,%rax
lea    0xeae(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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