#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 = 0;
  char letterGrade = 'F';
  printf("Enter numerical grade: ");
  scanf("%d", &grade);
  printf("Grade before: %d", grade);
  grade = grade / 10;
  printf("Grade after: %d", grade);
  switch (grade) {
  case 0:
  case 1:
  case 2:
  case 3:
  case 4:
  case 5:
    letterGrade = 'F';
    break;
  case 6:
    letterGrade = 'D';
    break;
  case 7:
    letterGrade = 'C';
    break;
  case 8:
    letterGrade = 'B';
    break;
  default:
    letterGrade = 'A';
    break;
  }
  printf("Letter grade: %c", letterGrade);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x46,-0x9(%rbp)
lea    0xee3(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x19(%rbp),%al
mov    -0x8(%rbp),%esi
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
movslq -0x8(%rbp),%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
mov    %ecx,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x8,%rax
ja     11e3 <main+0xc3>
mov    -0x18(%rbp),%rax
lea    0xe4a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x46,-0x9(%rbp)
jmp    11e7 <main+0xc7>
movb   $0x44,-0x9(%rbp)
jmp    11e7 <main+0xc7>
movb   $0x43,-0x9(%rbp)
jmp    11e7 <main+0xc7>
movb   $0x42,-0x9(%rbp)
jmp    11e7 <main+0xc7>
movb   $0x41,-0x9(%rbp)
movsbl -0x9(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x22,%rsi
add    %eax,%esi
mov    %esi,0x4(%rsp)
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movslq 0x4(%rsp),%rax
mov    $0x41,%esi
cmp    $0x8,%rax
ja     119f <main+0x7f>
lea    0xeb0(%rip),%rcx
mov    (%rcx,%rax,4),%esi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@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 = [17 x i8] c"Grade before: %d\00"
@.str.3 = [16 x i8] c"Grade after: %d\00"
@.str.4 = [17 x i8] c"Letter grade: %c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i8 70, i8* %3
%4 = call i32 (i8*, ...) @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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = sdiv i32 %8, 10
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
switch i32 %12, label %17 [
i32 0, label %13
i32 1, label %13
i32 2, label %13
i32 3, label %13
i32 4, label %13
i32 5, label %13
i32 6, label %14
i32 7, label %15
i32 8, label %16
]
13: ; preds = %0, %0, %0, %0, %0, %0
store i8 70, i8* %3
br label %18
14: ; preds = %0
store i8 68, i8* %3
br label %18
15: ; preds = %0
store i8 67, i8* %3
br label %18
16: ; preds = %0
store i8 66, i8* %3
br label %18
17: ; preds = %0
store i8 65, i8* %3
br label %18
18: ; preds = %17, %16, %15, %14, %13
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter numerical grade: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Grade before: %d\00"
@.str.3 = [16 x i8] c"Grade after: %d\00"
@.str.4 = [17 x i8] c"Letter grade: %c\00"
@switch.table.main = [9 x i32] [i32 70, i32 70, i32 70, i32 70, i32 70, i32 70, i32 68, i32 67, i32 66]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %1
%8 = sdiv i32 %7, 10
store i32 %8, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %1
%11 = icmp ult i32 %10, 9
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds [9 x i32], [9 x i32]* @switch.table.main, i64 0, i64 %13
%15 = load i32, i32* %14
br label %16
16: ; preds = %0, %12
%17 = phi i32 [ %15, %12 ], [ 65, %0 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %17)
ret i32 0
}