#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 score = 0, grade = 0;
  printf("enter numerical score:\n");
  scanf("%d", &score);
  if (score > 100 || score < 0) {
    printf("WRONG\n");
  } else {
    grade = score / 10;
    switch (grade) {
    case 9:
    case 10:
      printf("letter grade: A\n");
      break;
    case 8:
      printf("letter grade: B\n");
      break;
    case 7:
      printf("letter grade: C\n");
      break;
    case 6:
      printf("letter grade: D\n");
      break;
    default:
      printf("letter grade: F\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x64,-0x8(%rbp)
jg     116d <main+0x4d>
cmpl   $0x0,-0x8(%rbp)
jge    117e <main+0x5e>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
jmp    1217 <main+0xf7>
movslq -0x8(%rbp),%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffffa,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1206 <main+0xe6>
mov    -0x18(%rbp),%rax
lea    0xe47(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1217 <main+0xf7>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
lea    0xec4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x64,%eax
jbe    1158 <main+0x38>
lea    0xf14(%rip),%rdi
jmp    1185 <main+0x65>
movzbl %al,%eax
imul   $0xcd,%eax,%eax
shr    $0xb,%eax
add    $0xfffffffa,%eax
cmp    $0x4,%eax
ja     117e <main+0x5e>
cltq
lea    0xefb(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1185 <main+0x65>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [23 x i8] c"enter numerical score:\00"
@str.8 = [16 x i8] c"letter grade: D\00"
@str.9 = [16 x i8] c"letter grade: C\00"
@str.10 = [16 x i8] c"letter grade: B\00"
@str.11 = [16 x i8] c"letter grade: A\00"
@str.12 = [16 x i8] c"letter grade: F\00"
@str.13 = [6 x i8] c"WRONG\00"
@reltable.main = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.8 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.9 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.10 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.11 to i64), i64 ptrtoint ([5 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 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*
store i32 0, i32* %1
%3 = tail call i32 @puts(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 ugt i32 %5, 100
br i1 %6, label %17, label %7
7: ; preds = %0
%8 = trunc i32 %5 to i8
%9 = udiv i8 %8, 10
%10 = zext i8 %9 to i32
%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 ([6 x i8], [6 x i8]* @str.13, i64 0, i64 0), %0 ], [ %16, %13 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0), %7 ]
%19 = call i32 @puts(i8* dereferenceable(1) %18)
ret i32 0
}