#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 grade;
  printf("Enter the student's grade: ");
  scanf("%d", &grade);
  if (grade > 100) {
    printf("Invalid grade entered.  Expected 0 <= grade <= 100\n");
  } else if (grade < 0) {
    printf("Invalid grade entered.  Expected 0 <= grade <= 100\n");
  } else if (grade >= 90) {
    printf("Letter grade is: A\n");
  } else if (grade >= 80) {
    printf("Letter grade is: B\n");
  } else if (grade >= 70) {
    printf("Letter grade is: C\n");
  } else if (grade >= 60) {
    printf("Letter grade is: D\n");
  } else if (grade >= 0) {
    printf("Letter grade is: F\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x64,-0x8(%rbp)
jle    1166 <main+0x46>
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0x101>
cmpl   $0x0,-0x8(%rbp)
jge    1181 <main+0x61>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    121c <main+0xfc>
cmpl   $0x5a,-0x8(%rbp)
jl     119c <main+0x7c>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
jmp    1217 <main+0xf7>
cmpl   $0x50,-0x8(%rbp)
jl     11b7 <main+0x97>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
jmp    1212 <main+0xf2>
cmpl   $0x46,-0x8(%rbp)
jl     11d2 <main+0xb2>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    120d <main+0xed>
cmpl   $0x3c,-0x8(%rbp)
jl     11ed <main+0xcd>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    1208 <main+0xe8>
cmpl   $0x0,-0x8(%rbp)
jl     1203 <main+0xe3>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    1208 <main+0xe8>
jmp    120d <main+0xed>
jmp    1212 <main+0xf2>
jmp    1217 <main+0xf7>
jmp    121c <main+0xfc>
jmp    1221 <main+0x101>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    0xf25(%rip),%rdi
cmp    $0x64,%eax
jg     11a1 <main+0x71>
test   %eax,%eax
js     11a1 <main+0x71>
cmp    $0x59,%eax
jbe    1170 <main+0x40>
lea    0xefd(%rip),%rdi
jmp    11a1 <main+0x71>
cmp    $0x4f,%eax
jbe    117e <main+0x4e>
lea    0xedc(%rip),%rdi
jmp    11a1 <main+0x71>
cmp    $0x45,%eax
jbe    118c <main+0x5c>
lea    0xebb(%rip),%rdi
jmp    11a1 <main+0x71>
cmp    $0x3c,%eax
lea    0xe9c(%rip),%rax
lea    0xe82(%rip),%rdi
cmovae %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter the student's grade: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [52 x i8] c"Invalid grade entered. Expected 0 <= grade <= 100\0A\00"
@.str.3 = [20 x i8] c"Letter grade is: A\0A\00"
@.str.4 = [20 x i8] c"Letter grade is: B\0A\00"
@.str.5 = [20 x i8] c"Letter grade is: C\0A\00"
@.str.6 = [20 x i8] c"Letter grade is: D\0A\00"
@.str.7 = [20 x i8] c"Letter grade is: F\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 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* %2)
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 100
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
br label %45
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
br label %44
14: ; preds = %9
%15 = load i32, i32* %2
%16 = icmp sge i32 %15, 90
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %43
19: ; preds = %14
%20 = load i32, i32* %2
%21 = icmp sge i32 %20, 80
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %42
24: ; preds = %19
%25 = load i32, i32* %2
%26 = icmp sge i32 %25, 70
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %41
29: ; preds = %24
%30 = load i32, i32* %2
%31 = icmp sge i32 %30, 60
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %40
34: ; preds = %29
%35 = load i32, i32* %2
%36 = icmp sge i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
br label %40
40: ; preds = %39, %32
br label %41
41: ; preds = %40, %27
br label %42
42: ; preds = %41, %22
br label %43
43: ; preds = %42, %17
br label %44
44: ; preds = %43, %12
br label %45
45: ; preds = %44, %7
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter the student's grade: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [19 x i8] c"Letter grade is: F\00"
@str.8 = [19 x i8] c"Letter grade is: D\00"
@str.9 = [19 x i8] c"Letter grade is: C\00"
@str.10 = [19 x i8] c"Letter grade is: B\00"
@str.11 = [19 x i8] c"Letter grade is: A\00"
@str.13 = [51 x i8] c"Invalid grade entered. Expected 0 <= grade <= 100\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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 sgt i32 %5, 100
br i1 %6, label %18, label %7
7: ; preds = %0
%8 = icmp slt i32 %5, 0
br i1 %8, label %18, label %9
9: ; preds = %7
%10 = icmp ugt i32 %5, 89
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = icmp ugt i32 %5, 79
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = icmp ugt i32 %5, 69
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = icmp ugt i32 %5, 59
%17 = select i1 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0)
br label %18
18: ; preds = %15, %13, %11, %9, %7, %0
%19 = phi i8* [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.13, i64 0, i64 0), %0 ], [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.13, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0), %9 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), %13 ], [ %17, %15 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
ret i32 0
}