#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 {
    printf("Letter grade is: F\n");
    printf("Sorry you failed\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    121e <main+0xfe>
cmpl   $0x0,-0x8(%rbp)
jge    1181 <main+0x61>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1219 <main+0xf9>
cmpl   $0x5a,-0x8(%rbp)
jl     119c <main+0x7c>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
jmp    1214 <main+0xf4>
cmpl   $0x50,-0x8(%rbp)
jl     11b7 <main+0x97>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xef>
cmpl   $0x46,-0x8(%rbp)
jl     11d2 <main+0xb2>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <main+0xea>
cmpl   $0x3c,-0x8(%rbp)
jl     11ed <main+0xcd>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
jmp    1205 <main+0xe5>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <main+0xea>
jmp    120f <main+0xef>
jmp    1214 <main+0xf4>
jmp    1219 <main+0xf9>
jmp    121e <main+0xfe>
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    0xf36(%rip),%rdi
cmp    $0x64,%eax
jg     11ad <main+0x7d>
test   %eax,%eax
js     11ad <main+0x7d>
cmp    $0x59,%eax
jbe    1170 <main+0x40>
lea    0xf0e(%rip),%rdi
jmp    11ad <main+0x7d>
cmp    $0x4f,%eax
jbe    117e <main+0x4e>
lea    0xeed(%rip),%rdi
jmp    11ad <main+0x7d>
cmp    $0x45,%eax
jbe    118c <main+0x5c>
lea    0xecc(%rip),%rdi
jmp    11ad <main+0x7d>
cmp    $0x3b,%eax
jbe    119a <main+0x6a>
lea    0xeab(%rip),%rdi
jmp    11ad <main+0x7d>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe85(%rip),%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"
@.str.8 = [18 x i8] c"Sorry you failed\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 %42
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 %41
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 %40
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 %39
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 %38
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 %37
34: ; preds = %29
%35 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%36 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %37
37: ; preds = %34, %32
br label %38
38: ; preds = %37, %27
br label %39
39: ; preds = %38, %22
br label %40
40: ; preds = %39, %17
br label %41
41: ; preds = %40, %12
br label %42
42: ; preds = %41, %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.9 = [17 x i8] c"Sorry you failed\00"
@str.10 = [19 x i8] c"Letter grade is: D\00"
@str.11 = [19 x i8] c"Letter grade is: C\00"
@str.12 = [19 x i8] c"Letter grade is: B\00"
@str.13 = [19 x i8] c"Letter grade is: A\00"
@str.15 = [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 %19, label %7
7: ; preds = %0
%8 = icmp slt i32 %5, 0
br i1 %8, label %19, label %9
9: ; preds = %7
%10 = icmp ugt i32 %5, 89
br i1 %10, label %19, label %11
11: ; preds = %9
%12 = icmp ugt i32 %5, 79
br i1 %12, label %19, label %13
13: ; preds = %11
%14 = icmp ugt i32 %5, 69
br i1 %14, label %19, label %15
15: ; preds = %13
%16 = icmp ugt i32 %5, 59
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %15, %13, %11, %9, %7, %0, %17
%20 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0), %17 ], [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0), %0 ], [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.13, i64 0, i64 0), %9 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.12, i64 0, i64 0), %11 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0), %13 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0), %15 ]
%21 = call i32 @puts(i8* dereferenceable(1) %20)
ret i32 0
}