#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 *, double *, ...);
int main(void) {
  double A, B, C, D, score;
  printf("Enter thresholds for A, B, C, D\nin that order, decreasing "
         "percentages > ");
  scanf("%lf %lf %lf %lf", &A, &B, &C, &D);
  printf("Thank you. Now enter student score (percent) > ");
  scanf("%lf", &score);
  if (score < D) {
    printf("Student has an F grade\n");
  } else if (score >= D && score < C) {
    printf("Student has an D grade\n");
  } else if (score >= C && score < B) {
    printf("Student has an C grade\n");
  } else if (score >= B && score < A) {
    printf("Student has an B grade\n");
  } else if (score >= A) {
    printf("Student has an A grade\n");
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xef9(%rip),%rdi
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    119c <main+0x7c>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
jmp    126b <main+0x14b>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11d1 <main+0xb1>
movsd  -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d1 <main+0xb1>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
jmp    1266 <main+0x146>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1206 <main+0xe6>
movsd  -0x30(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1206 <main+0xe6>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
jmp    1261 <main+0x141>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     123b <main+0x11b>
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    123b <main+0x11b>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
jmp    125c <main+0x13c>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1257 <main+0x137>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
jmp    125c <main+0x13c>
jmp    1261 <main+0x141>
jmp    1266 <main+0x146>
jmp    126b <main+0x14b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    0xf02(%rip),%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xef0(%rip),%rdi
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1199 <main+0x69>
lea    0xf4e(%rip),%rdi
jmp    11f7 <main+0xc7>
ucomisd %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
jb     11b4 <main+0x84>
ucomisd %xmm0,%xmm1
jbe    11b4 <main+0x84>
lea    0xf1c(%rip),%rdi
jmp    11f7 <main+0xc7>
ucomisd %xmm1,%xmm0
movsd  0x18(%rsp),%xmm1
jb     11cf <main+0x9f>
ucomisd %xmm0,%xmm1
jbe    11cf <main+0x9f>
lea    0xeea(%rip),%rdi
jmp    11f7 <main+0xc7>
ucomisd %xmm1,%xmm0
movsd  0x20(%rsp),%xmm1
jb     11ea <main+0xba>
ucomisd %xmm0,%xmm1
jbe    11ea <main+0xba>
lea    0xeb8(%rip),%rdi
jmp    11f7 <main+0xc7>
ucomisd %xmm1,%xmm0
jb     11fc <main+0xcc>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%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 = [16 x i8] c"%lf %lf %lf %lf\00"
@.str.2 = [48 x i8] c"Thank you. Now enter student score (percent) > \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [24 x i8] c"Student has an F grade\0A\00"
@.str.5 = [24 x i8] c"Student has an D grade\0A\00"
@.str.6 = [24 x i8] c"Student has an C grade\0A\00"
@.str.7 = [24 x i8] c"Student has an B grade\0A\00"
@.str.8 = [24 x i8] c"Student has an A grade\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
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*, double*, ...) @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4, double* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %6)
%11 = load double, double* %6
%12 = load double, double* %5
%13 = fcmp olt double %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))
br label %56
16: ; preds = %0
%17 = load double, double* %6
%18 = load double, double* %5
%19 = fcmp oge double %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load double, double* %6
%22 = load double, double* %4
%23 = fcmp olt double %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %55
26: ; preds = %20, %16
%27 = load double, double* %6
%28 = load double, double* %4
%29 = fcmp oge double %27, %28
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load double, double* %6
%32 = load double, double* %3
%33 = fcmp olt double %31, %32
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %54
36: ; preds = %30, %26
%37 = load double, double* %6
%38 = load double, double* %3
%39 = fcmp oge double %37, %38
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load double, double* %6
%42 = load double, double* %2
%43 = fcmp olt double %41, %42
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %53
46: ; preds = %40, %36
%47 = load double, double* %6
%48 = load double, double* %2
%49 = fcmp oge double %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
br label %53
53: ; preds = %52, %44
br label %54
54: ; preds = %53, %34
br label %55
55: ; preds = %54, %24
br label %56
56: ; preds = %55, %14
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 = [16 x i8] c"%lf %lf %lf %lf\00"
@.str.2 = [48 x i8] c"Thank you. Now enter student score (percent) > \00"
@.str.3 = [4 x i8] c"%lf\00"
@str = [23 x i8] c"Student has an A grade\00"
@str.9 = [23 x i8] c"Student has an B grade\00"
@str.10 = [23 x i8] c"Student has an C grade\00"
@str.11 = [23 x i8] c"Student has an D grade\00"
@str.12 = [23 x i8] c"Student has an F grade\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %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*, double*, ...) @scanf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %5)
%15 = load double, double* %5
%16 = load double, double* %4
%17 = fcmp olt double %15, %16
br i1 %17, label %35, label %18
18: ; preds = %0
%19 = fcmp oge double %15, %16
%20 = load double, double* %3
%21 = fcmp olt double %15, %20
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %35, label %23
23: ; preds = %18
%24 = fcmp oge double %15, %20
%25 = load double, double* %2
%26 = fcmp olt double %15, %25
%27 = select i1 %24, i1 %26, i1 false
br i1 %27, label %35, label %28
28: ; preds = %23
%29 = fcmp oge double %15, %25
%30 = load double, double* %1
%31 = fcmp olt double %15, %30
%32 = select i1 %29, i1 %31, i1 false
br i1 %32, label %35, label %33
33: ; preds = %28
%34 = fcmp ult double %15, %30
br i1 %34, label %38, label %35
35: ; preds = %33, %28, %23, %18, %0
%36 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0), %0 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0), %18 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0), %23 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0), %28 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), %33 ]
%37 = call i32 @puts(i8* dereferenceable(1) %36)
br label %38
38: ; preds = %35, %33
ret i32 0
}