#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");
  }
  if (grade <= 59) {
    printf("You got a F\n");
  } else if (80 <= grade <= 89) {
    printf("You got a B\n");
  } else if (70 <= grade <= 79) {
    printf("You got a C\n");
  } else if (60 <= grade <= 69) {
    printf("You got a D\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    11a1 <main+0x81>
cmpl   $0x0,-0x8(%rbp)
jge    1181 <main+0x61>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <main+0x7c>
cmpl   $0x5a,-0x8(%rbp)
jl     1197 <main+0x77>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <main+0x7c>
jmp    11a1 <main+0x81>
cmpl   $0x3b,-0x8(%rbp)
jg     11bc <main+0x9c>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
jmp    1244 <main+0x124>
mov    $0x50,%eax
cmp    -0x8(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x59,%eax
jg     11e6 <main+0xc6>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    123f <main+0x11f>
mov    $0x46,%eax
cmp    -0x8(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x4f,%eax
jg     1210 <main+0xf0>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    123a <main+0x11a>
mov    $0x3c,%eax
cmp    -0x8(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x45,%eax
jg     1235 <main+0x115>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
jmp    123a <main+0x11a>
jmp    123f <main+0x11f>
jmp    1244 <main+0x124>
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    0xef1(%rip),%rdi
cmp    $0x64,%eax
jg     116e <main+0x3e>
test   %eax,%eax
js     116e <main+0x3e>
cmp    $0x5a,%eax
jb     1173 <main+0x43>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x3c,0x4(%rsp)
lea    0xeac(%rip),%rax
lea    0xe99(%rip),%rdi
cmovl  %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 = [13 x i8] c"You got a F\0A\00"
@.str.5 = [13 x i8] c"You got a B\0A\00"
@.str.6 = [13 x i8] c"You got a C\0A\00"
@.str.7 = [13 x i8] c"You got a D\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 %21
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 %20
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 %19
19: ; preds = %17, %14
br label %20
20: ; preds = %19, %12
br label %21
21: ; preds = %20, %7
%22 = load i32, i32* %2
%23 = icmp sle i32 %22, 59
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %50
26: ; preds = %21
%27 = load i32, i32* %2
%28 = icmp sle i32 80, %27
%29 = zext i1 %28 to i32
%30 = icmp sle i32 %29, 89
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %49
33: ; preds = %26
%34 = load i32, i32* %2
%35 = icmp sle i32 70, %34
%36 = zext i1 %35 to i32
%37 = icmp sle i32 %36, 79
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %48
40: ; preds = %33
%41 = load i32, i32* %2
%42 = icmp sle i32 60, %41
%43 = zext i1 %42 to i32
%44 = icmp sle i32 %43, 69
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %47
47: ; preds = %45, %40
br label %48
48: ; preds = %47, %38
br label %49
49: ; preds = %48, %31
br label %50
50: ; preds = %49, %24
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 = [12 x i8] c"You got a B\00"
@str.8 = [12 x i8] c"You got a F\00"
@str.9 = [19 x i8] c"Letter grade is: A\00"
@str.11 = [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 %11, label %7
7: ; preds = %0
%8 = icmp slt i32 %5, 0
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = icmp ugt i32 %5, 89
br i1 %10, label %11, label %14
11: ; preds = %9, %7, %0
%12 = phi i8* [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.11, i64 0, i64 0), %0 ], [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.11, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.9, i64 0, i64 0), %9 ]
%13 = call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %9
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 60
%17 = select i1 %16, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0)
%18 = call i32 @puts(i8* dereferenceable(1) %17)
ret i32 0
}