#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 argc, const char *argv[]) {
  int score = 0;
  printf("Please input the score:");
  scanf("%d", &score);
  if (score > 100 || score < 0) {
    printf("Input invalid!\n");
    return 1;
  }
  printf("Grade:");
  switch (score / 10) {
  case 9:
  case 10:
    printf("A");
    break;
  case 8:
    printf("B");
    break;
  case 7:
    printf("C");
    break;
  case 6:
    printf("D");
    break;
  default:
    printf("E");
    break;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x64,-0x14(%rbp)
jg     116d <main+0x4d>
cmpl   $0x0,-0x14(%rbp)
jge    1185 <main+0x65>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1237 <main+0x117>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
movslq -0x14(%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,-0x20(%rbp)
sub    $0x4,%eax
ja     1218 <main+0xf8>
mov    -0x20(%rbp),%rax
lea    0xe35(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    1224 <main+0x104>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    1224 <main+0x104>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
jmp    1224 <main+0x104>
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
jmp    1224 <main+0x104>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe12(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeb0(%rip),%rdi
call   1050 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x65,0x4(%rsp)
jb     1180 <main+0x40>
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xe94(%rip),%rdi
call   1050 <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
mov    $0x45,%edi
cmp    $0x4,%eax
ja     11be <main+0x7e>
cltq
lea    0xe79(%rip),%rcx
mov    (%rcx,%rax,4),%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Please input the score:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Input invalid!\0A\00"
@.str.3 = [7 x i8] c"Grade:\00"
@.str.4 = [2 x i8] c"A\00"
@.str.5 = [2 x i8] c"B\00"
@.str.6 = [2 x i8] c"C\00"
@.str.7 = [2 x i8] c"D\00"
@.str.8 = [2 x i8] c"E\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 100
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %32
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%18 = load i32, i32* %6
%19 = sdiv i32 %18, 10
switch i32 %19, label %28 [
i32 9, label %20
i32 10, label %20
i32 8, label %22
i32 7, label %24
i32 6, label %26
]
20: ; preds = %16, %16
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %30
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %30
24: ; preds = %16
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %30
26: ; preds = %16
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %30
28: ; preds = %16
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %30
30: ; preds = %28, %26, %24, %22, %20
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %32
32: ; preds = %30, %14
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [24 x i8] c"Please input the score:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"Grade:\00"
@str = [15 x i8] c"Input invalid!\00"
@switch.table.main = [5 x i32] [i32 68, i32 67, i32 66, i32 65, i32 65]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp ugt i32 %7, 100
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %25
11: ; preds = %2
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* %3
%14 = sdiv i32 %13, 10
%15 = add nsw i32 %14, -6
%16 = icmp ult i32 %15, 5
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.main, i64 0, i64 %18
%20 = load i32, i32* %19
br label %21
21: ; preds = %11, %17
%22 = phi i32 [ %20, %17 ], [ 69, %11 ]
%23 = call i32 @putchar(i32 %22)
%24 = call i32 @putchar(i32 10)
br label %25
25: ; preds = %21, %9
%26 = phi i32 [ 1, %9 ], [ 0, %21 ]
ret i32 %26
}