#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 *, ...);
int main(void) {
  float a, b, c, d;
  double score;
  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("%lf", &score);
  if (score >= a)
    printf("Student has a A grade\n");
  else if (score >= b)
    printf("Student has a B grade\n");
  else if (score >= c)
    printf("Student has a C grade\n");
  else if (score >= d)
    printf("Student has a D grade\n");
  else
    printf("Student has failed the course\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xf07(%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
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a0 <main+0x80>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
jmp    1236 <main+0x116>
movsd  -0x20(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c9 <main+0xa9>
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
jmp    1231 <main+0x111>
movsd  -0x20(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11f2 <main+0xd2>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
jmp    122c <main+0x10c>
movsd  -0x20(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     121b <main+0xfb>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0x107>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
jmp    122c <main+0x10c>
jmp    1231 <main+0x111>
jmp    1236 <main+0x116>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
lea    0xf02(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rsp,%r8
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeeb(%rip),%rdi
call   1040 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    11d6 <main+0xa6>
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    11df <main+0xaf>
movss  0x4(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    11e8 <main+0xb8>
movss  (%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
lea    0xebc(%rip),%rax
lea    0xed3(%rip),%rdi
cmovb  %rax,%rdi
jmp    11ef <main+0xbf>
lea    0xf08(%rip),%rdi
jmp    11ef <main+0xbf>
lea    0xee9(%rip),%rdi
jmp    11ef <main+0xbf>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%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 = [9 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"%lf\00"
@.str.4 = [23 x i8] c"Student has a A grade\0A\00"
@.str.5 = [23 x i8] c"Student has a B grade\0A\00"
@.str.6 = [23 x i8] c"Student has a C grade\0A\00"
@.str.7 = [23 x i8] c"Student has a 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 float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%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*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4, float* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @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 float, float* %2
%13 = fpext float %12 to double
%14 = fcmp oge double %11, %13
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %43
17: ; preds = %0
%18 = load double, double* %6
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = fcmp oge double %18, %20
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %42
24: ; preds = %17
%25 = load double, double* %6
%26 = load float, float* %4
%27 = fpext float %26 to double
%28 = fcmp oge double %25, %27
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %41
31: ; preds = %24
%32 = load double, double* %6
%33 = load float, float* %5
%34 = fpext float %33 to double
%35 = fcmp oge double %32, %34
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %40
38: ; preds = %31
%39 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %40, %29
br label %42
42: ; preds = %41, %22
br label %43
43: ; preds = %42, %15
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 = [9 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"%lf\00"
@str = [30 x i8] c"Student has failed the course\00"
@str.9 = [22 x i8] c"Student has a D grade\00"
@str.10 = [22 x i8] c"Student has a C grade\00"
@str.11 = [22 x i8] c"Student has a B grade\00"
@str.12 = [22 x i8] c"Student has a A grade\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca double
%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 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*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2, float* %3, float* %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*, ...) @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 float, float* %1
%17 = fpext float %16 to double
%18 = fcmp ult double %15, %17
br i1 %18, label %19, label %32
19: ; preds = %0
%20 = load float, float* %2
%21 = fpext float %20 to double
%22 = fcmp ult double %15, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load float, float* %3
%25 = fpext float %24 to double
%26 = fcmp ult double %15, %25
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = load float, float* %4
%29 = fpext float %28 to double
%30 = fcmp ult double %15, %29
%31 = select i1 %30, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0)
br label %32
32: ; preds = %27, %23, %19, %0
%33 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0), %0 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0), %19 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.10, i64 0, i64 0), %23 ], [ %31, %27 ]
%34 = call i32 @puts(i8* dereferenceable(1) %33)
ret i32 0
}