#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("%f", &percent);
  if (percent == 0)
    printf("Student has failed the course");
  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';
  if (percent != 0)
    printf("Student has an %c grade\n\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    0xee1(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11a5 <main+0x85>
jp     11a5 <main+0x85>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127f <main+0x15f>
movss  -0x18(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     11bd <main+0x9d>
movb   $0x41,-0x19(%rbp)
jmp    127a <main+0x15a>
movss  -0x18(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11e8 <main+0xc8>
movss  -0x18(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jb     11e8 <main+0xc8>
movb   $0x42,-0x19(%rbp)
jmp    1275 <main+0x155>
movss  -0x18(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1213 <main+0xf3>
movss  -0x18(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jb     1213 <main+0xf3>
movb   $0x43,-0x19(%rbp)
jmp    1270 <main+0x150>
movss  -0x18(%rbp),%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    123e <main+0x11e>
movss  -0x18(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jb     123e <main+0x11e>
movb   $0x44,-0x19(%rbp)
jmp    126b <main+0x14b>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1266 <main+0x146>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1266 <main+0x146>
movb   $0x46,-0x19(%rbp)
jmp    126b <main+0x14b>
jmp    1270 <main+0x150>
jmp    1275 <main+0x155>
jmp    127a <main+0x15a>
jmp    127f <main+0x15f>
movss  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    129b <main+0x17b>
jp     129b <main+0x17b>
jmp    12ad <main+0x18d>
movsbl -0x19(%rbp),%esi
lea    0xdfc(%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    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xef6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0xc(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    119e <main+0x7e>
jp     119e <main+0x7e>
lea    0xef5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm0
jmp    1203 <main+0xe3>
movss  0x1c(%rsp),%xmm1
mov    $0x41,%ebx
ucomiss %xmm1,%xmm0
jae    1203 <main+0xe3>
ucomiss %xmm0,%xmm1
movss  0x18(%rsp),%xmm1
jbe    11c3 <main+0xa3>
mov    $0x42,%ebx
ucomiss %xmm1,%xmm0
jae    1203 <main+0xe3>
ucomiss %xmm0,%xmm1
movss  0x14(%rsp),%xmm1
jbe    11d8 <main+0xb8>
mov    $0x43,%ebx
ucomiss %xmm1,%xmm0
jae    1203 <main+0xe3>
ucomiss %xmm0,%xmm1
movss  0x10(%rsp),%xmm1
jbe    11ed <main+0xcd>
mov    $0x44,%ebx
ucomiss %xmm1,%xmm0
jae    1203 <main+0xe3>
xor    %eax,%eax
ucomiss %xmm0,%xmm1
mov    $0x46,%ebx
cmovbe %eax,%ebx
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
cmovbe %eax,%ebx
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    120d <main+0xed>
jnp    121d <main+0xfd>
lea    0xe8e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <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 = [48 x i8] c"Thank you. Now enter student score (percent) > \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [30 x i8] c"Student has failed the course\00"
@.str.5 = [26 x i8] c"Student has an %c grade\0A\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 ([48 x i8], [48 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 = fcmp oeq float %12, 0.000000e+00
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %61
16: ; preds = %0
%17 = load float, float* %6
%18 = load float, float* %2
%19 = fcmp oge float %17, %18
br i1 %19, label %20, label %21
20: ; preds = %16
store i8 65, i8* %7
br label %60
21: ; preds = %16
%22 = load float, float* %6
%23 = load float, float* %2
%24 = fcmp olt float %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load float, float* %6
%27 = load float, float* %3
%28 = fcmp oge float %26, %27
br i1 %28, label %29, label %30
29: ; preds = %25
store i8 66, i8* %7
br label %59
30: ; preds = %25, %21
%31 = load float, float* %6
%32 = load float, float* %3
%33 = fcmp olt float %31, %32
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load float, float* %6
%36 = load float, float* %4
%37 = fcmp oge float %35, %36
br i1 %37, label %38, label %39
38: ; preds = %34
store i8 67, i8* %7
br label %58
39: ; preds = %34, %30
%40 = load float, float* %6
%41 = load float, float* %4
%42 = fcmp olt float %40, %41
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = load float, float* %6
%45 = load float, float* %5
%46 = fcmp oge float %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
store i8 68, i8* %7
br label %57
48: ; preds = %43, %39
%49 = load float, float* %6
%50 = load float, float* %5
%51 = fcmp olt float %49, %50
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load float, float* %6
%54 = fcmp ogt float %53, 0.000000e+00
br i1 %54, label %55, label %56
55: ; preds = %52
store i8 70, i8* %7
br label %56
56: ; preds = %55, %52, %48
br label %57
57: ; preds = %56, %47
br label %58
58: ; preds = %57, %38
br label %59
59: ; preds = %58, %29
br label %60
60: ; preds = %59, %20
br label %61
61: ; preds = %60, %14
%62 = load float, float* %6
%63 = fcmp une float %62, 0.000000e+00
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = load i8, i8* %7
%66 = sext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %64, %61
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 = [48 x i8] c"Thank you. Now enter student score (percent) > \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [30 x i8] c"Student has failed the course\00"
@.str.5 = [26 x i8] c"Student has an %c grade\0A\0A\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 ([48 x i8], [48 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 = fcmp oeq float %15, 0.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%19 = load float, float* %5
br label %43
20: ; preds = %0
%21 = load float, float* %1
%22 = fcmp ult float %15, %21
br i1 %22, label %23, label %43
23: ; preds = %20
%24 = fcmp uge float %15, %21
%25 = load float, float* %2
%26 = fcmp ult float %15, %25
%27 = select i1 %24, i1 true, i1 %26
br i1 %27, label %28, label %43
28: ; preds = %23
%29 = fcmp uge float %15, %25
%30 = load float, float* %3
%31 = fcmp ult float %15, %30
%32 = select i1 %29, i1 true, i1 %31
br i1 %32, label %33, label %43
33: ; preds = %28
%34 = fcmp uge float %15, %30
%35 = load float, float* %4
%36 = fcmp ult float %15, %35
%37 = select i1 %34, i1 true, i1 %36
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = fcmp olt float %15, %35
%40 = fcmp ogt float %15, 0.000000e+00
%41 = and i1 %40, %39
%42 = select i1 %41, i32 70, i32 0
br label %43
43: ; preds = %38, %33, %28, %23, %17, %20
%44 = phi float [ %15, %20 ], [ %15, %38 ], [ %15, %33 ], [ %15, %28 ], [ %15, %23 ], [ %19, %17 ]
%45 = phi i32 [ 65, %20 ], [ %42, %38 ], [ 68, %33 ], [ 67, %28 ], [ 66, %23 ], [ 0, %17 ]
%46 = fcmp une float %44, 0.000000e+00
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %45)
br label %49
49: ; preds = %47, %43
ret i32 0
}