#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, score;
  printf("Enter thresholds for A, B, C, D\n");
  printf("in that order, decreasing percentages > ");
  scanf("%lf%lf%lf%lf", &A, &B, &C, &D);
  printf("\nThank 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 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    0xedf(%rip),%rdi
call   1030 <printf@plt>
lea    0xefc(%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    0xeeb(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11a4 <main+0x84>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
jmp    1215 <main+0xf5>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11c5 <main+0xa5>
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
jmp    1210 <main+0xf0>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11e6 <main+0xc6>
lea    0xedb(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <main+0xeb>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1206 <main+0xe6>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
jmp    120b <main+0xeb>
jmp    1210 <main+0xf0>
jmp    1215 <main+0xf5>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
lea    0xed6(%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    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
ucomisd 0x20(%rsp),%xmm0
jae    11bd <main+0x8d>
ucomisd 0x18(%rsp),%xmm0
jae    11c6 <main+0x96>
ucomisd 0x10(%rsp),%xmm0
jae    11cf <main+0x9f>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11db <main+0xab>
lea    0xecb(%rip),%rdi
jmp    11d6 <main+0xa6>
lea    0xf0e(%rip),%rdi
jmp    11d6 <main+0xa6>
lea    0xeee(%rip),%rdi
jmp    11d6 <main+0xa6>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter thresholds for A, B, C, D\0A\00"
@.str.1 = [41 x i8] c"in that order, decreasing percentages > \00"
@.str.2 = [13 x i8] c"%lf%lf%lf%lf\00"
@.str.3 = [48 x i8] c"\0AThank you. Now enter student score (percent) >\00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [24 x i8] c"Student has an A grade\0A\00"
@.str.6 = [24 x i8] c"Student has an B grade\0A\00"
@.str.7 = [24 x i8] c"Student has an C 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 ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double* %2, double* %3, double* %4, double* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %6)
%12 = load double, double* %6
%13 = load double, double* %2
%14 = fcmp oge double %12, %13
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %38
17: ; preds = %0
%18 = load double, double* %6
%19 = load double, double* %3
%20 = fcmp oge double %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %37
23: ; preds = %17
%24 = load double, double* %6
%25 = load double, double* %4
%26 = fcmp oge double %24, %25
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %36
29: ; preds = %23
%30 = load double, double* %6
%31 = load double, double* %5
%32 = fcmp olt double %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
br label %36
36: ; preds = %35, %27
br label %37
37: ; preds = %36, %21
br label %38
38: ; preds = %37, %15
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [41 x i8] c"in that order, decreasing percentages > \00"
@.str.2 = [13 x i8] c"%lf%lf%lf%lf\00"
@.str.3 = [48 x i8] c"\0AThank you. Now enter student score (percent) >\00"
@.str.4 = [4 x i8] c"%lf\00"
@str = [32 x i8] c"Enter thresholds for A, B, C, D\00"
@str.9 = [30 x i8] c"Student has failed the course\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %5)
%16 = load double, double* %5
%17 = load double, double* %1
%18 = fcmp ult double %16, %17
br i1 %18, label %19, label %28
19: ; preds = %0
%20 = load double, double* %2
%21 = fcmp ult double %16, %20
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load double, double* %3
%24 = fcmp ult double %16, %23
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load double, double* %4
%27 = fcmp olt double %16, %26
br i1 %27, label %28, label %31
28: ; preds = %25, %22, %19, %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), %19 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0), %22 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0), %25 ]
%30 = call i32 @puts(i8* dereferenceable(1) %29)
br label %31
31: ; preds = %28, %25
ret i32 0
}