#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 *, float *, ...);
int main() {
  float a;
  float b;
  float c;
  float d;
  float perc;
  char grade;
  printf("Enter thresholds for A, B, C, D\nin that order, decreasing "
         "percentages > ");
  scanf("%f %f %f %f", &a, &b, &c, &d);
  printf("Thank you. Now enter student score (percent) >");
  scanf("%f", &perc);
  if (perc >= a) {
    grade = 'A';
    printf("Student has an %c grade\n", grade);
  } else if (perc >= b) {
    grade = 'B';
    printf("Student has an %c grade\n", grade);
  } else if (perc >= c) {
    grade = 'C';
    printf("Student has an %c grade\n", grade);
  } else if (perc >= d) {
    grade = 'D';
    printf("Student has an %c grade\n", grade);
  } else {
    grade = 'F';
    printf("Student has failed the course");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     11a5 <main+0x85>
movb   $0x41,-0x19(%rbp)
movsbl -0x19(%rbp),%esi
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <main+0x124>
movss  -0x18(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     11cf <main+0xaf>
movb   $0x42,-0x19(%rbp)
movsbl -0x19(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <main+0x11f>
movss  -0x18(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     11f9 <main+0xd9>
movb   $0x43,-0x19(%rbp)
movsbl -0x19(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x11a>
movss  -0x18(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     1223 <main+0x103>
movb   $0x44,-0x19(%rbp)
movsbl -0x19(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1235 <main+0x115>
movb   $0x46,-0x19(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x11a>
jmp    123f <main+0x11f>
jmp    1244 <main+0x124>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xefa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
ucomiss 0x14(%rsp),%xmm0
jae    11a7 <main+0x87>
ucomiss 0x10(%rsp),%xmm0
jae    11b5 <main+0x95>
ucomiss 0xc(%rsp),%xmm0
jae    11c3 <main+0xa3>
ucomiss 0x8(%rsp),%xmm0
jae    11d1 <main+0xb1>
lea    0xeff(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e4 <main+0xc4>
lea    0xed6(%rip),%rdi
mov    $0x41,%esi
jmp    11dd <main+0xbd>
lea    0xec8(%rip),%rdi
mov    $0x42,%esi
jmp    11dd <main+0xbd>
lea    0xeba(%rip),%rdi
mov    $0x43,%esi
jmp    11dd <main+0xbd>
lea    0xeac(%rip),%rdi
mov    $0x44,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [73 x i8] c"Enter thresholds for A, B, C, D\0Ain that order, decreasing percentages > \00"
@.str.1 = [12 x i8] c"%f %f %f %f\00"
@.str.2 = [47 x i8] c"Thank you. Now enter student score (percent) >\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [25 x i8] c"Student has an %c grade\0A\00"
@.str.5 = [30 x i8] c"Student has failed the course\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4, float* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%12 = load float, float* %6
%13 = load float, float* %2
%14 = fcmp oge float %12, %13
br i1 %14, label %15, label %19
15: ; preds = %0
store i8 65, i8* %7
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %48
19: ; preds = %0
%20 = load float, float* %6
%21 = load float, float* %3
%22 = fcmp oge float %20, %21
br i1 %22, label %23, label %27
23: ; preds = %19
store i8 66, i8* %7
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %47
27: ; preds = %19
%28 = load float, float* %6
%29 = load float, float* %4
%30 = fcmp oge float %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
store i8 67, i8* %7
%32 = load i8, i8* %7
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %46
35: ; preds = %27
%36 = load float, float* %6
%37 = load float, float* %5
%38 = fcmp oge float %36, %37
br i1 %38, label %39, label %43
39: ; preds = %35
store i8 68, i8* %7
%40 = load i8, i8* %7
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %41)
br label %45
43: ; preds = %35
store i8 70, i8* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
br label %46
46: ; preds = %45, %31
br label %47
47: ; preds = %46, %23
br label %48
48: ; preds = %47, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [73 x i8] c"Enter thresholds for A, B, C, D\0Ain that order, decreasing percentages > \00"
@.str.1 = [12 x i8] c"%f %f %f %f\00"
@.str.2 = [47 x i8] c"Thank you. Now enter student score (percent) >\00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [25 x i8] c"Student has an %c grade\0A\00"
@.str.5 = [30 x i8] c"Student has failed the course\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = bitcast float* %1 to i8*
%7 = bitcast float* %2 to i8*
%8 = bitcast float* %3 to i8*
%9 = bitcast float* %4 to i8*
%10 = bitcast float* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2, float* %3, float* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%15 = load float, float* %5
%16 = load float, float* %1
%17 = fcmp ult float %15, %16
br i1 %17, label %20, label %18
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 65)
br label %37
20: ; preds = %0
%21 = load float, float* %2
%22 = fcmp ult float %15, %21
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 66)
br label %37
25: ; preds = %20
%26 = load float, float* %3
%27 = fcmp ult float %15, %26
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 67)
br label %37
30: ; preds = %25
%31 = load float, float* %4
%32 = fcmp ult float %15, %31
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 68)
br label %37
35: ; preds = %30
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %23, %33, %35, %28, %18
ret i32 0
}