#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, percent;
  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("\n%f", &percent);
  if (percent >= A)
    grade = 'A';
  else if ((percent < A) && (percent >= B))
    grade = 'B';
  else if ((percent < B) && (percent >= C))
    grade = 'C';
  else if ((percent < C) && (percent >= D))
    grade = 'D';
  else if (percent < D)
    printf("Student has failed the course\n");
  if (percent >= D)
    printf("Student has an %c grade\n", grade);
  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    0xf04(%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
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1193 <main+0x73>
movb   $0x41,-0x19(%rbp)
jmp    1249 <main+0x129>
movss  -0x18(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11be <main+0x9e>
movss  -0x18(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     11be <main+0x9e>
movb   $0x42,-0x19(%rbp)
jmp    1244 <main+0x124>
movss  -0x18(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11e9 <main+0xc9>
movss  -0x18(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     11e9 <main+0xc9>
movb   $0x43,-0x19(%rbp)
jmp    123f <main+0x11f>
movss  -0x18(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1214 <main+0xf4>
movss  -0x18(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     1214 <main+0xf4>
movb   $0x44,-0x19(%rbp)
jmp    123a <main+0x11a>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1235 <main+0x115>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x11a>
jmp    123f <main+0x11f>
jmp    1244 <main+0x124>
jmp    1249 <main+0x129>
movss  -0x18(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     126a <main+0x14a>
movsbl -0x19(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefe(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf09(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
movss  0x1c(%rsp),%xmm1
mov    $0x41,%ebx
ucomiss %xmm1,%xmm0
jae    11f4 <main+0xc4>
ucomiss %xmm0,%xmm1
movss  0x18(%rsp),%xmm1
jbe    11b1 <main+0x81>
mov    $0x42,%ebx
ucomiss %xmm1,%xmm0
jae    11f4 <main+0xc4>
ucomiss %xmm0,%xmm1
movss  0x14(%rsp),%xmm1
jbe    11c6 <main+0x96>
mov    $0x43,%ebx
ucomiss %xmm1,%xmm0
jae    11f4 <main+0xc4>
ucomiss %xmm0,%xmm1
movss  0x10(%rsp),%xmm1
jbe    11db <main+0xab>
mov    $0x44,%ebx
ucomiss %xmm1,%xmm0
jae    11f4 <main+0xc4>
xor    %ebx,%ebx
ucomiss %xmm0,%xmm1
jbe    11f4 <main+0xc4>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
ucomiss 0x10(%rsp),%xmm0
jb     120b <main+0xdb>
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [72 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 = [4 x i8] c"\0A%f\00"
@.str.4 = [31 x i8] c"Student has failed the course\0A\00"
@.str.5 = [25 x i8] c"Student has an %c grade\0A\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 ([72 x i8], [72 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 ([4 x i8], [4 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 %16
15: ; preds = %0
store i8 65, i8* %7
br label %53
16: ; preds = %0
%17 = load float, float* %6
%18 = load float, float* %2
%19 = fcmp olt float %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load float, float* %6
%22 = load float, float* %3
%23 = fcmp oge float %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
store i8 66, i8* %7
br label %52
25: ; preds = %20, %16
%26 = load float, float* %6
%27 = load float, float* %3
%28 = fcmp olt float %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load float, float* %6
%31 = load float, float* %4
%32 = fcmp oge float %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
store i8 67, i8* %7
br label %51
34: ; preds = %29, %25
%35 = load float, float* %6
%36 = load float, float* %4
%37 = fcmp olt float %35, %36
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load float, float* %6
%40 = load float, float* %5
%41 = fcmp oge float %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
store i8 68, i8* %7
br label %50
43: ; preds = %38, %34
%44 = load float, float* %6
%45 = load float, float* %5
%46 = fcmp olt float %44, %45
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
br label %50
50: ; preds = %49, %42
br label %51
51: ; preds = %50, %33
br label %52
52: ; preds = %51, %24
br label %53
53: ; preds = %52, %15
%54 = load float, float* %6
%55 = load float, float* %5
%56 = fcmp oge float %54, %55
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i8, i8* %7
%59 = sext i8 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %57, %53
ret i32 0
}

LLVM IR (-O2):
@.str = [72 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 = [4 x i8] c"\0A%f\00"
@.str.5 = [25 x i8] c"Student has an %c grade\0A\00"
@str = [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 ([72 x i8], [72 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 ([4 x i8], [4 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 %38
18: ; preds = %0
%19 = fcmp uge float %15, %16
%20 = load float, float* %2
%21 = fcmp ult float %15, %20
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %23, label %38
23: ; preds = %18
%24 = fcmp uge float %15, %20
%25 = load float, float* %3
%26 = fcmp ult float %15, %25
%27 = select i1 %24, i1 true, i1 %26
br i1 %27, label %28, label %38
28: ; preds = %23
%29 = fcmp uge float %15, %25
%30 = load float, float* %4
%31 = fcmp ult float %15, %30
%32 = select i1 %29, i1 true, i1 %31
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = fcmp olt float %15, %30
br i1 %34, label %35, label %38
35: ; preds = %33
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%37 = load float, float* %5
br label %38
38: ; preds = %28, %23, %18, %0, %35, %33
%39 = phi float [ %37, %35 ], [ %15, %33 ], [ %15, %0 ], [ %15, %18 ], [ %15, %23 ], [ %15, %28 ]
%40 = phi i32 [ 0, %35 ], [ 0, %33 ], [ 65, %0 ], [ 66, %18 ], [ 67, %23 ], [ 68, %28 ]
%41 = load float, float* %4
%42 = fcmp ult float %39, %41
br i1 %42, label %45, label %43
43: ; preds = %38
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %45
45: ; preds = %43, %38
ret i32 0
}