#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, studentscore;
  char lettergrade;
  printf("Enter thresholds for A, B, C, D in that order, decreasing "
         "percentages > Thank you. ");
  scanf("%lf %lf %lf %lf", &A, &B, &C, &D);
  printf("Now enter student score (percent) > ");
  scanf("%lf", &studentscore);
  if (studentscore >= A) {
    lettergrade = 'A';
    printf("Student has an %c grade\n", lettergrade);
  } else if (studentscore >= B) {
    lettergrade = 'B';
    printf("Student has an %c grade\n", lettergrade);
  } else if (studentscore >= C) {
    lettergrade = 'C';
    printf("Student has an %c grade\n", lettergrade);
  } else if (studentscore >= D) {
    lettergrade = 'D';
    printf("Student has an %c grade\n", lettergrade);
  } 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    0xf10(%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    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11a6 <main+0x86>
movb   $0x41,-0x31(%rbp)
movsbl -0x31(%rbp),%esi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <main+0x124>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11d1 <main+0xb1>
movb   $0x42,-0x31(%rbp)
movsbl -0x31(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <main+0x11f>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11fc <main+0xdc>
movb   $0x43,-0x31(%rbp)
movsbl -0x31(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x11a>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     1227 <main+0x107>
movb   $0x44,-0x31(%rbp)
movsbl -0x31(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1235 <main+0x115>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x11a>
jmp    123f <main+0x11f>
jmp    1244 <main+0x124>
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    0xf0b(%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    0xef9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee7(%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    11c4 <main+0x94>
ucomisd 0x10(%rsp),%xmm0
jae    11d2 <main+0xa2>
ucomisd 0x8(%rsp),%xmm0
jae    11e0 <main+0xb0>
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
jmp    11f3 <main+0xc3>
lea    0xecc(%rip),%rdi
mov    $0x41,%esi
jmp    11ec <main+0xbc>
lea    0xebe(%rip),%rdi
mov    $0x42,%esi
jmp    11ec <main+0xbc>
lea    0xeb0(%rip),%rdi
mov    $0x43,%esi
jmp    11ec <main+0xbc>
lea    0xea2(%rip),%rdi
mov    $0x44,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [84 x i8] c"Enter thresholds for A, B, C, D in that order, decreasing percentages > Thank you. \00"
@.str.1 = [16 x i8] c"%lf %lf %lf %lf\00"
@.str.2 = [37 x i8] c"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 ([84 x i8], [84 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 ([37 x i8], [37 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 %19
15: ; preds = %0
store i8 65, i8* %7
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %17)
br label %48
19: ; preds = %0
%20 = load double, double* %6
%21 = load double, double* %3
%22 = fcmp oge double %20, %21
br i1 %22, label %23, label %27
23: ; preds = %19
store i8 66, i8* %7
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %47
27: ; preds = %19
%28 = load double, double* %6
%29 = load double, double* %4
%30 = fcmp oge double %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
store i8 67, i8* %7
%32 = load i8, i8* %7
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %46
35: ; preds = %27
%36 = load double, double* %6
%37 = load double, double* %5
%38 = fcmp oge double %36, %37
br i1 %38, label %39, label %43
39: ; preds = %35
store i8 68, i8* %7
%40 = load i8, i8* %7
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %41)
br label %45
43: ; preds = %35
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %45
45: ; preds = %43, %39
br label %46
46: ; preds = %45, %31
br label %47
47: ; preds = %46, %23
br label %48
48: ; preds = %47, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [84 x i8] c"Enter thresholds for A, B, C, D in that order, decreasing percentages > Thank you. \00"
@.str.1 = [16 x i8] c"%lf %lf %lf %lf\00"
@.str.2 = [37 x i8] c"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 ([84 x i8], [84 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 ([37 x i8], [37 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 %20, label %18
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 65)
br label %37
20: ; preds = %0
%21 = load double, double* %2
%22 = fcmp ult double %15, %21
br i1 %22, label %25, label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 66)
br label %37
25: ; preds = %20
%26 = load double, double* %3
%27 = fcmp ult double %15, %26
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 67)
br label %37
30: ; preds = %25
%31 = load double, double* %4
%32 = fcmp ult double %15, %31
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 68)
br label %37
35: ; preds = %30
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %37
37: ; preds = %23, %33, %35, %28, %18
ret i32 0
}