#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, percent;
  char grade;
  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", &percent);
  if (percent >= A)
    grade = 'A';
  if ((percent < A) && (percent >= B))
    grade = 'B';
  if ((percent < B) && (percent >= C))
    grade = 'C';
  if ((percent < C) && (percent >= D))
    grade = 'D';
  if (percent < D)
    grade = 'F';
  printf("Student has an %c grade\n\n", grade);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf04(%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    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     118f <main+0x6f>
movb   $0x41,-0x31(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b7 <main+0x97>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11b7 <main+0x97>
movb   $0x42,-0x31(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11df <main+0xbf>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11df <main+0xbf>
movb   $0x43,-0x31(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1207 <main+0xe7>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     1207 <main+0xe7>
movb   $0x44,-0x31(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    121f <main+0xff>
movb   $0x46,-0x31(%rbp)
movsbl -0x31(%rbp),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xefd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
ucomisd %xmm0,%xmm1
setbe  %al
movsd  0x18(%rsp),%xmm1
ucomisd %xmm1,%xmm0
setb   %cl
or     %al,%cl
movsd  0x10(%rsp),%xmm2
movzbl %cl,%eax
mov    $0x42,%ecx
sub    %eax,%ecx
ucomisd %xmm2,%xmm0
mov    $0x43,%eax
cmovb  %ecx,%eax
ucomisd %xmm0,%xmm1
cmovbe %ecx,%eax
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
mov    $0x44,%ecx
cmovb  %eax,%ecx
ucomisd %xmm0,%xmm2
cmovbe %eax,%ecx
ucomisd %xmm0,%xmm1
mov    $0x46,%esi
cmovbe %ecx,%esi
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [72 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 = [26 x i8] c"Student has an %c grade\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%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*, 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)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, 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 %16
15: ; preds = %0
store i8 65, i8* %7
br label %16
16: ; preds = %15, %0
%17 = load double, double* %6
%18 = load double, double* %2
%19 = fcmp olt double %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load double, double* %6
%22 = load double, double* %3
%23 = fcmp oge double %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
store i8 66, i8* %7
br label %25
25: ; preds = %24, %20, %16
%26 = load double, double* %6
%27 = load double, double* %3
%28 = fcmp olt double %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load double, double* %6
%31 = load double, double* %4
%32 = fcmp oge double %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
store i8 67, i8* %7
br label %34
34: ; preds = %33, %29, %25
%35 = load double, double* %6
%36 = load double, double* %4
%37 = fcmp olt double %35, %36
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load double, double* %6
%40 = load double, double* %5
%41 = fcmp oge double %39, %40
br i1 %41, label %42, label %43
42: ; preds = %38
store i8 68, i8* %7
br label %43
43: ; preds = %42, %38, %34
%44 = load double, double* %6
%45 = load double, double* %5
%46 = fcmp olt double %44, %45
br i1 %46, label %47, label %48
47: ; preds = %43
store i8 70, i8* %7
br label %48
48: ; preds = %47, %43
%49 = load i8, i8* %7
%50 = sext i8 %49 to i32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %50)
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 = [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 = [26 x i8] c"Student has an %c grade\0A\0A\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 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 (i8*, ...) @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* %1
%17 = fcmp uge double %15, %16
%18 = load double, double* %2
%19 = fcmp ult double %15, %18
%20 = select i1 %17, i1 true, i1 %19
%21 = fcmp uge double %15, %18
%22 = load double, double* %3
%23 = fcmp ult double %15, %22
%24 = select i1 %21, i1 true, i1 %23
%25 = fcmp uge double %15, %22
%26 = load double, double* %4
%27 = fcmp ult double %15, %26
%28 = select i1 %25, i1 true, i1 %27
%29 = fcmp olt double %15, %26
%30 = select i1 %20, i32 65, i32 66
%31 = select i1 %24, i32 %30, i32 67
%32 = select i1 %28, i32 %31, i32 68
%33 = select i1 %29, i32 70, i32 %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret i32 0
}