#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, B, C, D, Std;
  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", &Std);
  if (Std >= A) {
    printf("Student has an A grade\n");
    return 0;
  } else if (Std >= B) {
    printf("Student has an B grade\n");
    return 0;
  } else if (Std >= C) {
    printf("Student has an C grade\n");
    return 0;
  } else if (Std >= D) {
    printf("Student has a D grade\n");
    return 0;
  } else if (Std < D) {
    printf("Student has failed the course\n");
    return 0;
  } else {
    printf("Program did not understand that grade, please try again and "
           "remember to enter a percentage\n");
    return 666;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xf07(%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    0xef2(%rip),%rdi
call   1030 <printf@plt>
lea    0xee3(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     119e <main+0x7e>
lea    0xef4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1251 <main+0x131>
movss  -0x18(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     11c5 <main+0xa5>
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1251 <main+0x131>
movss  -0x18(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     11ec <main+0xcc>
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1251 <main+0x131>
movss  -0x18(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     1213 <main+0xf3>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1251 <main+0x131>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    123e <main+0x11e>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1251 <main+0x131>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
movl   $0x29a,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
call   1040 <printf@plt>
lea    0xf01(%rip),%rdi
xor    %ebx,%ebx
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xee6(%rip),%rdi
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0x1c(%rsp),%xmm0
jae    11cb <main+0x9b>
ucomiss 0x18(%rsp),%xmm0
jae    11d4 <main+0xa4>
ucomiss 0x14(%rsp),%xmm0
jae    11dd <main+0xad>
movss  0x10(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jae    11e6 <main+0xb6>
xor    %eax,%eax
ucomiss %xmm0,%xmm1
lea    0xf26(%rip),%rcx
lea    0xec4(%rip),%rdi
cmova  %rcx,%rdi
mov    $0x29a,%ebx
cmova  %eax,%ebx
jmp    11ed <main+0xbd>
lea    0xf6c(%rip),%rdi
jmp    11ed <main+0xbd>
lea    0xf4c(%rip),%rdi
jmp    11ed <main+0xbd>
lea    0xf2c(%rip),%rdi
jmp    11ed <main+0xbd>
lea    0xf0d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [73 x i8] c"Enter thresholds for A, B, C, D\0Ain that order, decreasing percentages > \00"
@.str.1 = [9 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 = [24 x i8] c"Student has an A grade\0A\00"
@.str.5 = [24 x i8] c"Student has an B grade\0A\00"
@.str.6 = [24 x i8] c"Student has an C grade\0A\00"
@.str.7 = [23 x i8] c"Student has a D grade\0A\00"
@.str.8 = [31 x i8] c"Student has failed the course\0A\00"
@.str.9 = [92 x i8] c"Program did not understand that grade, please try again and remember to enter a percentage\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4, float* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%11 = load float, float* %6
%12 = load float, float* %2
%13 = fcmp oge float %11, %12
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %42
16: ; preds = %0
%17 = load float, float* %6
%18 = load float, float* %3
%19 = fcmp oge float %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %42
22: ; preds = %16
%23 = load float, float* %6
%24 = load float, float* %4
%25 = fcmp oge float %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %42
28: ; preds = %22
%29 = load float, float* %6
%30 = load float, float* %5
%31 = fcmp oge float %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %42
34: ; preds = %28
%35 = load float, float* %6
%36 = load float, float* %5
%37 = fcmp olt float %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
br label %42
40: ; preds = %34
%41 = call i32 @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.9, i64 0, i64 0))
store i32 666, i32* %1
br label %42
42: ; preds = %40, %38, %32, %26, %20, %14
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [73 x i8] c"Enter thresholds for A, B, C, D\0Ain that order, decreasing percentages > \00"
@.str.1 = [9 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 = [91 x i8] c"Program did not understand that grade, please try again and remember to enter a percentage\00"
@str.10 = [30 x i8] c"Student has failed the course\00"
@str.11 = [22 x i8] c"Student has a D grade\00"
@str.12 = [23 x i8] c"Student has an C grade\00"
@str.13 = [23 x i8] c"Student has an B grade\00"
@str.14 = [23 x i8] c"Student has an A grade\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 @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 ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2, float* %3, float* %4)
%13 = call i32 @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 %18, label %31
18: ; preds = %0
%19 = load float, float* %2
%20 = fcmp ult float %15, %19
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load float, float* %3
%23 = fcmp ult float %15, %22
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load float, float* %4
%26 = fcmp ult float %15, %25
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = fcmp olt float %15, %25
%29 = select i1 %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([91 x i8], [91 x i8]* @str, i64 0, i64 0)
%30 = select i1 %28, i32 0, i32 666
br label %31
31: ; preds = %27, %24, %21, %18, %0
%32 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.14, i64 0, i64 0), %0 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0), %18 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0), %21 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0), %24 ], [ %29, %27 ]
%33 = phi i32 [ 0, %0 ], [ 0, %18 ], [ 0, %21 ], [ 0, %24 ], [ %30, %27 ]
%34 = call i32 @puts(i8* dereferenceable(1) %32)
ret i32 %33
}