#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");
  }
  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    0xeb4(%rip),%rdi
call   1030 <printf@plt>
jmp    120d <main+0xed>
cmpl   $0x3c,-0x8(%rbp)
jl     11ed <main+0xcd>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    1208 <main+0xe8>
cmpl   $0x0,-0x8(%rbp)
jl     1203 <main+0xe3>
lea    0xea8(%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
cmp    $0x65,%eax
jge    1169 <main+0x39>
test   %eax,%eax
js     1169 <main+0x39>
cmp    $0x5a,%eax
jb     1179 <main+0x49>
lea    0xf07(%rip),%rdi
jmp    1170 <main+0x40>
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
cmp    $0x50,%eax
jb     1187 <main+0x57>
lea    0xed5(%rip),%rdi
jmp    1170 <main+0x40>
cmp    $0x46,%eax
jb     1195 <main+0x65>
lea    0xeb3(%rip),%rdi
jmp    1170 <main+0x40>
cmp    $0x3c,%eax
jb     11a3 <main+0x73>
lea    0xe91(%rip),%rdi
jmp    1170 <main+0x40>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
jmp    1175 <main+0x45>

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 = [21 x i8] c"Letter grade is: B \0A\00"
@.str.5 = [21 x i8] c"Letter grade is: C \0A\00"
@.str.6 = [21 x i8] c"Letter grade is: D \0A\00"
@.str.7 = [19 x i8] c"Letter grade is: F\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 ([21 x i8], [21 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 ([21 x i8], [21 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 ([21 x i8], [21 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 ([19 x i8], [19 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.7 = [19 x i8] c"Letter grade is: F\00"
@str = [20 x i8] c"Letter grade is: D \00"
@str.8 = [20 x i8] c"Letter grade is: C \00"
@str.9 = [20 x i8] c"Letter grade is: B \00"
@str.10 = [19 x i8] c"Letter grade is: A\00"
@str.12 = [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 %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
br label %31
9: ; preds = %0
%10 = icmp slt i32 %5, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
br label %31
13: ; preds = %9
%14 = icmp ugt i32 %5, 89
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
br label %31
17: ; preds = %13
%18 = icmp ugt i32 %5, 79
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.9, i64 0, i64 0))
br label %31
21: ; preds = %17
%22 = icmp ugt i32 %5, 69
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.8, i64 0, i64 0))
br label %31
25: ; preds = %21
%26 = icmp ugt i32 %5, 59
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %31
29: ; preds = %25
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %31
31: ; preds = %11, %19, %27, %29, %23, %15, %7
ret i32 0
}