#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 == 0 && percent < A && percent < B && percent < C && percent < D)
    printf("Student has failed the course\n");
  else 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) && (percent > 0))
    grade = 'F';
  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
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11f1 <main+0xd1>
jp     11f1 <main+0xd1>
movss  -0x18(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11f1 <main+0xd1>
movss  -0x18(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11f1 <main+0xd1>
movss  -0x18(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11f1 <main+0xd1>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11f1 <main+0xd1>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cb <main+0x1ab>
movss  -0x18(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1209 <main+0xe9>
movb   $0x41,-0x19(%rbp)
jmp    12c6 <main+0x1a6>
movss  -0x18(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1234 <main+0x114>
movss  -0x18(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     1234 <main+0x114>
movb   $0x42,-0x19(%rbp)
jmp    12c1 <main+0x1a1>
movss  -0x18(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    125f <main+0x13f>
movss  -0x18(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     125f <main+0x13f>
movb   $0x43,-0x19(%rbp)
jmp    12bc <main+0x19c>
movss  -0x18(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    128a <main+0x16a>
movss  -0x18(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     128a <main+0x16a>
movb   $0x44,-0x19(%rbp)
jmp    12b7 <main+0x197>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    12b2 <main+0x192>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    12b2 <main+0x192>
movb   $0x46,-0x19(%rbp)
jmp    12b7 <main+0x197>
jmp    12bc <main+0x19c>
jmp    12c1 <main+0x1a1>
jmp    12c6 <main+0x1a6>
jmp    12cb <main+0x1ab>
movsbl -0x19(%rbp),%esi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
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
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeff(%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    0xee9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf0a(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
movss  0x14(%rsp),%xmm4
movss  0x10(%rsp),%xmm3
movss  0xc(%rsp),%xmm2
movss  0x8(%rsp),%xmm1
jne    11d1 <main+0xa1>
jp     11d1 <main+0xa1>
ucomiss %xmm0,%xmm4
jbe    11d1 <main+0xa1>
ucomiss %xmm0,%xmm3
jbe    11d1 <main+0xa1>
ucomiss %xmm0,%xmm2
jbe    11d1 <main+0xa1>
ucomiss %xmm0,%xmm1
jbe    11d1 <main+0xa1>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %esi,%esi
jmp    121e <main+0xee>
mov    $0x41,%esi
ucomiss %xmm4,%xmm0
jae    121e <main+0xee>
ucomiss %xmm0,%xmm4
jbe    11ea <main+0xba>
mov    $0x42,%esi
ucomiss %xmm3,%xmm0
jae    121e <main+0xee>
ucomiss %xmm0,%xmm3
jbe    11f9 <main+0xc9>
mov    $0x43,%esi
ucomiss %xmm2,%xmm0
jae    121e <main+0xee>
ucomiss %xmm0,%xmm2
jbe    1208 <main+0xd8>
mov    $0x44,%esi
ucomiss %xmm1,%xmm0
jae    121e <main+0xee>
xor    %eax,%eax
ucomiss %xmm0,%xmm1
mov    $0x46,%esi
cmovbe %eax,%esi
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
cmovbe %eax,%esi
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
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 = fcmp oeq float %12, 0.000000e+00
br i1 %13, label %14, label %32
14: ; preds = %0
%15 = load float, float* %6
%16 = load float, float* %2
%17 = fcmp olt float %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load float, float* %6
%20 = load float, float* %3
%21 = fcmp olt float %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load float, float* %6
%24 = load float, float* %4
%25 = fcmp olt float %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load float, float* %6
%28 = load float, float* %5
%29 = fcmp olt float %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %77
32: ; preds = %26, %22, %18, %14, %0
%33 = load float, float* %6
%34 = load float, float* %2
%35 = fcmp oge float %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32
store i8 65, i8* %7
br label %76
37: ; preds = %32
%38 = load float, float* %6
%39 = load float, float* %2
%40 = fcmp olt float %38, %39
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load float, float* %6
%43 = load float, float* %3
%44 = fcmp oge float %42, %43
br i1 %44, label %45, label %46
45: ; preds = %41
store i8 66, i8* %7
br label %75
46: ; preds = %41, %37
%47 = load float, float* %6
%48 = load float, float* %3
%49 = fcmp olt float %47, %48
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load float, float* %6
%52 = load float, float* %4
%53 = fcmp oge float %51, %52
br i1 %53, label %54, label %55
54: ; preds = %50
store i8 67, i8* %7
br label %74
55: ; preds = %50, %46
%56 = load float, float* %6
%57 = load float, float* %4
%58 = fcmp olt float %56, %57
br i1 %58, label %59, label %64
59: ; preds = %55
%60 = load float, float* %6
%61 = load float, float* %5
%62 = fcmp oge float %60, %61
br i1 %62, label %63, label %64
63: ; preds = %59
store i8 68, i8* %7
br label %73
64: ; preds = %59, %55
%65 = load float, float* %6
%66 = load float, float* %5
%67 = fcmp olt float %65, %66
br i1 %67, label %68, label %72
68: ; preds = %64
%69 = load float, float* %6
%70 = fcmp ogt float %69, 0.000000e+00
br i1 %70, label %71, label %72
71: ; preds = %68
store i8 70, i8* %7
br label %72
72: ; preds = %71, %68, %64
br label %73
73: ; preds = %72, %63
br label %74
74: ; preds = %73, %54
br label %75
75: ; preds = %74, %45
br label %76
76: ; preds = %75, %36
br label %77
77: ; preds = %76, %30
%78 = load i8, i8* %7
%79 = sext i8 %78 to i32
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %79)
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 = fcmp oeq float %15, 0.000000e+00
%17 = load float, float* %1
%18 = fcmp olt float %15, %17
%19 = select i1 %16, i1 %18, i1 false
%20 = load float, float* %2
%21 = fcmp olt float %15, %20
%22 = select i1 %19, i1 %21, i1 false
%23 = load float, float* %3
%24 = fcmp olt float %15, %23
%25 = select i1 %22, i1 %24, i1 false
%26 = load float, float* %4
%27 = fcmp olt float %15, %26
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %29, label %31
29: ; preds = %0
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %49
31: ; preds = %0
%32 = fcmp ult float %15, %17
br i1 %32, label %33, label %49
33: ; preds = %31
%34 = fcmp uge float %15, %17
%35 = fcmp ult float %15, %20
%36 = select i1 %34, i1 true, i1 %35
br i1 %36, label %37, label %49
37: ; preds = %33
%38 = fcmp uge float %15, %20
%39 = fcmp ult float %15, %23
%40 = select i1 %38, i1 true, i1 %39
br i1 %40, label %41, label %49
41: ; preds = %37
%42 = fcmp uge float %15, %23
%43 = fcmp ult float %15, %26
%44 = select i1 %42, i1 true, i1 %43
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = fcmp ogt float %15, 0.000000e+00
%47 = and i1 %46, %27
%48 = select i1 %47, i32 70, i32 0
br label %49
49: ; preds = %45, %41, %37, %33, %31, %29
%50 = phi i32 [ 0, %29 ], [ 65, %31 ], [ 66, %33 ], [ 67, %37 ], [ 68, %41 ], [ %48, %45 ]
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %50)
ret i32 0
}