#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, in;
  char g;
  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", &in);
  if (in >= a)
    g = 'A';
  else if (in >= b)
    g = 'B';
  else if (in >= c)
    g = 'C';
  else if (in >= d)
    g = 'D';
  else
    g = 'F';
  if (g == 'A' || g == 'B' || g == 'C' || g == 'D')
    printf("Student has an %c grade\n", g);
  else
    printf("Student has failed the course\n");
  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    0xf05(%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    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1194 <main+0x74>
movb   $0x41,-0x31(%rbp)
jmp    11f2 <main+0xd2>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11ad <main+0x8d>
movb   $0x42,-0x31(%rbp)
jmp    11ed <main+0xcd>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11c6 <main+0xa6>
movb   $0x43,-0x31(%rbp)
jmp    11e8 <main+0xc8>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11df <main+0xbf>
movb   $0x44,-0x31(%rbp)
jmp    11e3 <main+0xc3>
movb   $0x46,-0x31(%rbp)
jmp    11e8 <main+0xc8>
jmp    11ed <main+0xcd>
jmp    11f2 <main+0xd2>
movsbl -0x31(%rbp),%eax
cmp    $0x41,%eax
je     1226 <main+0x106>
movsbl -0x31(%rbp),%eax
cmp    $0x42,%eax
je     1226 <main+0x106>
movsbl -0x31(%rbp),%eax
cmp    $0x43,%eax
je     1226 <main+0x106>
movsbl -0x31(%rbp),%eax
cmp    $0x44,%eax
jne    123d <main+0x11d>
movsbl -0x31(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124b <main+0x12b>
lea    0xe5a(%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    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf00(%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    0xeeb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
mov    $0x41,%esi
ucomisd 0x20(%rsp),%xmm0
jae    11ca <main+0x9a>
mov    $0x42,%esi
ucomisd 0x18(%rsp),%xmm0
jae    11ca <main+0x9a>
mov    $0x43,%esi
ucomisd 0x10(%rsp),%xmm0
jae    11ca <main+0x9a>
mov    $0x44,%esi
ucomisd 0x8(%rsp),%xmm0
jae    11ca <main+0x9a>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
jmp    11d8 <main+0xa8>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@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 = [13 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 = [25 x i8] c"Student has an %c grade\0A\00"
@.str.5 = [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
%7 = alloca i8
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4, double* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 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 %35
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 %21
20: ; preds = %16
store i8 66, i8* %7
br label %34
21: ; preds = %16
%22 = load double, double* %6
%23 = load double, double* %4
%24 = fcmp oge double %22, %23
br i1 %24, label %25, label %26
25: ; preds = %21
store i8 67, i8* %7
br label %33
26: ; preds = %21
%27 = load double, double* %6
%28 = load double, double* %5
%29 = fcmp oge double %27, %28
br i1 %29, label %30, label %31
30: ; preds = %26
store i8 68, i8* %7
br label %32
31: ; preds = %26
store i8 70, i8* %7
br label %32
32: ; preds = %31, %30
br label %33
33: ; preds = %32, %25
br label %34
34: ; preds = %33, %20
br label %35
35: ; preds = %34, %15
%36 = load i8, i8* %7
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 65
br i1 %38, label %51, label %39
39: ; preds = %35
%40 = load i8, i8* %7
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 66
br i1 %42, label %51, label %43
43: ; preds = %39
%44 = load i8, i8* %7
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 67
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = load i8, i8* %7
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 68
br i1 %50, label %51, label %55
51: ; preds = %47, %43, %39, %35
%52 = load i8, i8* %7
%53 = sext i8 %52 to i32
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %53)
br label %57
55: ; preds = %47
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %57
57: ; preds = %55, %51
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 = [13 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 = [25 x i8] c"Student has an %c grade\0A\00"
@str = [30 x i8] c"Student has failed the course\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 ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([13 x i8], [13 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 ([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 %27
18: ; preds = %0
%19 = load double, double* %2
%20 = fcmp ult double %15, %19
br i1 %20, label %21, label %27
21: ; preds = %18
%22 = load double, double* %3
%23 = fcmp ult double %15, %22
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load double, double* %4
%26 = fcmp ult double %15, %25
br i1 %26, label %30, label %27
27: ; preds = %21, %18, %0, %24
%28 = phi i32 [ 68, %24 ], [ 67, %21 ], [ 66, %18 ], [ 65, %0 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %32
30: ; preds = %24
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
ret i32 0
}