#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() {
  double a, b, c, d;
  double 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 >= a)
    printf("Student has an A grade\n");
  else if (score >= b)
    printf("Student has an B grade\n");
  else if (score >= c)
    printf("Student has an C grade\n");
  else if (score >= d)
    printf("Student has an D grade\n");
  else
    printf("Student has failed the course\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),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1198 <main+0x78>
lea    0xefa(%rip),%rdi
call   1030 <printf@plt>
jmp    1216 <main+0xf6>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11b9 <main+0x99>
lea    0xef1(%rip),%rdi
call   1030 <printf@plt>
jmp    1211 <main+0xf1>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11da <main+0xba>
lea    0xee8(%rip),%rdi
call   1030 <printf@plt>
jmp    120c <main+0xec>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11fb <main+0xdb>
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
lea    0xee6(%rip),%rdi
call   1030 <printf@plt>
jmp    120c <main+0xec>
jmp    1211 <main+0xf1>
jmp    1216 <main+0xf6>
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
ucomisd 0x20(%rsp),%xmm0
jae    11b6 <main+0x86>
ucomisd 0x18(%rsp),%xmm0
jae    11bf <main+0x8f>
ucomisd 0x10(%rsp),%xmm0
jae    11c8 <main+0x98>
ucomisd 0x8(%rsp),%xmm0
lea    0xedf(%rip),%rax
lea    0xef6(%rip),%rdi
cmovb  %rax,%rdi
jmp    11cf <main+0x9f>
lea    0xf2e(%rip),%rdi
jmp    11cf <main+0x9f>
lea    0xf0e(%rip),%rdi
jmp    11cf <main+0x9f>
lea    0xeee(%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 = [47 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 A grade\0A\00"
@.str.5 = [24 x i8] c"Student has an B 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 D grade\0A\00"
@.str.8 = [31 x i8] c"Student has failed the course\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 ([47 x i8], [47 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* %2
%13 = fcmp oge 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 %39
16: ; preds = %0
%17 = load double, double* %6
%18 = load double, double* %3
%19 = fcmp oge double %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %38
22: ; preds = %16
%23 = load double, double* %6
%24 = load double, double* %4
%25 = fcmp oge double %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %37
28: ; preds = %22
%29 = load double, double* %6
%30 = load double, double* %5
%31 = fcmp oge double %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %36
34: ; preds = %28
%35 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36, %26
br label %38
38: ; preds = %37, %20
br label %39
39: ; preds = %38, %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 = [47 x i8] c"Thank you. Now enter student score (percent) >\00"
@.str.3 = [4 x i8] c"%lf\00"
@str = [30 x i8] c"Student has failed the course\00"
@str.9 = [23 x i8] c"Student has an D grade\00"
@str.10 = [23 x i8] c"Student has an C grade\00"
@str.11 = [23 x i8] c"Student has an B grade\00"
@str.12 = [23 x i8] c"Student has an A 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 ([47 x i8], [47 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* %1
%17 = fcmp ult double %15, %16
br i1 %17, label %18, label %28
18: ; preds = %0
%19 = load double, double* %2
%20 = fcmp ult double %15, %19
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load double, double* %3
%23 = fcmp ult double %15, %22
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load double, double* %4
%26 = fcmp ult double %15, %25
%27 = select i1 %26, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.9, i64 0, i64 0)
br label %28
28: ; preds = %24, %21, %18, %0
%29 = 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), %21 ], [ %27, %24 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
ret i32 0
}