#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, 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", &Grade);
  if (Grade >= A)
    printf("the student has an A grade\n");
  if (Grade >= B && Grade < A)
    printf("the student has an B grade\n");
  if (Grade >= C && Grade < B)
    printf("the student has an C grade\n");
  if (Grade < C && Grade >= D)
    printf("the student has an D grade\n");
  if (Grade < D)
    printf("the student has an F grade\n");
  return (0);
}


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    0xef5(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1192 <main+0x72>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     11c0 <main+0xa0>
movss  -0x18(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11c0 <main+0xa0>
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     11ee <main+0xce>
movss  -0x18(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11ee <main+0xce>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    121c <main+0xfc>
movss  -0x18(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     121c <main+0xfc>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    123b <main+0x11b>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    0xf02(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeec(%rip),%rdi
call   1040 <printf@plt>
lea    0xedd(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
movss  0x14(%rsp),%xmm2
ucomiss %xmm2,%xmm0
jb     11aa <main+0x7a>
lea    0xf57(%rip),%rdi
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
movss  0x14(%rsp),%xmm2
movss  0x10(%rsp),%xmm1
ucomiss %xmm1,%xmm0
jb     11d2 <main+0xa2>
ucomiss %xmm0,%xmm2
jbe    11d2 <main+0xa2>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
ucomiss %xmm2,%xmm0
jb     11fa <main+0xca>
ucomiss %xmm0,%xmm1
jbe    11fa <main+0xca>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
movss  0xc(%rsp),%xmm2
ucomiss %xmm0,%xmm2
movss  0x8(%rsp),%xmm1
jbe    1222 <main+0xf2>
ucomiss %xmm1,%xmm0
jb     1222 <main+0xf2>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
movss  0x4(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    1233 <main+0x103>
lea    0xe56(%rip),%rdi
call   1030 <puts@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 = [28 x i8] c"the student has an A grade\0A\00"
@.str.5 = [28 x i8] c"the student has an B grade\0A\00"
@.str.6 = [28 x i8] c"the student has an C grade\0A\00"
@.str.7 = [28 x i8] c"the student has an D grade\0A\00"
@.str.8 = [28 x i8] c"the student has an F grade\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 ([12 x i8], [12 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 ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
%17 = load float, float* %6
%18 = load float, float* %3
%19 = fcmp oge float %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load float, float* %6
%22 = load float, float* %2
%23 = fcmp olt float %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %20, %16
%27 = load float, float* %6
%28 = load float, float* %4
%29 = fcmp oge float %27, %28
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load float, float* %6
%32 = load float, float* %3
%33 = fcmp olt float %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %36
36: ; preds = %34, %30, %26
%37 = load float, float* %6
%38 = load float, float* %4
%39 = fcmp olt float %37, %38
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load float, float* %6
%42 = load float, float* %5
%43 = fcmp oge float %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
br label %46
46: ; preds = %44, %40, %36
%47 = load float, float* %6
%48 = load float, float* %5
%49 = fcmp olt float %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
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 = [27 x i8] c"the student has an F grade\00"
@str.9 = [27 x i8] c"the student has an D grade\00"
@str.10 = [27 x i8] c"the student has an C grade\00"
@str.11 = [27 x i8] c"the student has an B grade\00"
@str.12 = [27 x i8] c"the 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 ([12 x i8], [12 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 %22, label %18
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
%20 = load float, float* %5
%21 = load float, float* %1
br label %22
22: ; preds = %18, %0
%23 = phi float [ %21, %18 ], [ %16, %0 ]
%24 = phi float [ %20, %18 ], [ %15, %0 ]
%25 = load float, float* %2
%26 = fcmp oge float %24, %25
%27 = fcmp olt float %24, %23
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %29, label %33
29: ; preds = %22
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.11, i64 0, i64 0))
%31 = load float, float* %5
%32 = load float, float* %2
br label %33
33: ; preds = %29, %22
%34 = phi float [ %32, %29 ], [ %25, %22 ]
%35 = phi float [ %31, %29 ], [ %24, %22 ]
%36 = load float, float* %3
%37 = fcmp oge float %35, %36
%38 = fcmp olt float %35, %34
%39 = select i1 %37, i1 %38, i1 false
br i1 %39, label %40, label %44
40: ; preds = %33
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%42 = load float, float* %5
%43 = load float, float* %3
br label %44
44: ; preds = %40, %33
%45 = phi float [ %43, %40 ], [ %36, %33 ]
%46 = phi float [ %42, %40 ], [ %35, %33 ]
%47 = fcmp uge float %46, %45
%48 = load float, float* %4
%49 = fcmp ult float %46, %48
%50 = select i1 %47, i1 true, i1 %49
br i1 %50, label %55, label %51
51: ; preds = %44
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%53 = load float, float* %5
%54 = load float, float* %4
br label %55
55: ; preds = %51, %44
%56 = phi float [ %54, %51 ], [ %48, %44 ]
%57 = phi float [ %53, %51 ], [ %46, %44 ]
%58 = fcmp olt float %57, %56
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
ret i32 0
}