#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 *, float *, ...);
int main() {
  float A, B, C, D, grade;
  printf("Enter thresholds for A, B, C, D\n");
  printf("in that order, decreasing percentages > ");
  scanf("%f%f%f%f", &A, &B, &C, &D);
  printf("Thank you. Now enter student score (percent) >");
  scanf("%f", &grade);
  if (grade < 60)
    printf("Student has failed the course\n");
  else if (grade < 70)
    printf("Student has an D grade\n");
  else if (grade < 80)
    printf("Student has an C grade\n");
  else if (grade < 90)
    printf("Student has an B grade\n");
  else
    printf("Student has an A grade\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0c(%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    0xef7(%rip),%rdi
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  0xe75(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11a6 <main+0x86>
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
jmp    122a <main+0x10a>
movss  0xe56(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11c9 <main+0xa9>
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
jmp    1225 <main+0x105>
movss  0xe37(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    11ec <main+0xcc>
lea    0xee7(%rip),%rdi
call   1030 <printf@plt>
jmp    1220 <main+0x100>
movss  0xe18(%rip),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    120f <main+0xef>
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
jmp    121b <main+0xfb>
lea    0xee3(%rip),%rdi
call   1030 <printf@plt>
jmp    1220 <main+0x100>
jmp    1225 <main+0x105>
jmp    122a <main+0x10a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
lea    0xee6(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xecd(%rip),%rdi
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
movss  0xe65(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11a9 <main+0x79>
lea    0xf46(%rip),%rdi
jmp    11f2 <main+0xc2>
movss  0xe53(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11bf <main+0x8f>
lea    0xf19(%rip),%rdi
jmp    11f2 <main+0xc2>
movss  0xe41(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    11d5 <main+0xa5>
lea    0xeec(%rip),%rdi
jmp    11f2 <main+0xc2>
movss  0xe2f(%rip),%xmm1
ucomiss %xmm0,%xmm1
lea    0xec1(%rip),%rax
lea    0xea3(%rip),%rdi
cmova  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%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 = [9 x i8] c"%f%f%f%f\00"
@.str.3 = [47 x i8] c"Thank you. Now enter student score (percent) >\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [31 x i8] c"Student has failed the course\0A\00"
@.str.6 = [24 x i8] c"Student has an D grade\0A\00"
@.str.7 = [24 x i8] c"Student has an C grade\0A\00"
@.str.8 = [24 x i8] c"Student has an B grade\0A\00"
@.str.9 = [24 x i8] c"Student has an A grade\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
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*, float*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %2, float* %3, float* %4, float* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %6)
%12 = load float, float* %6
%13 = fcmp olt float %12, 6.000000e+01
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %36
16: ; preds = %0
%17 = load float, float* %6
%18 = fcmp olt float %17, 7.000000e+01
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %35
21: ; preds = %16
%22 = load float, float* %6
%23 = fcmp olt float %22, 8.000000e+01
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %34
26: ; preds = %21
%27 = load float, float* %6
%28 = fcmp olt float %27, 9.000000e+01
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %33
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
br label %34
34: ; preds = %33, %24
br label %35
35: ; preds = %34, %19
br label %36
36: ; preds = %35, %14
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [41 x i8] c"in that order, decreasing percentages > \00"
@.str.2 = [9 x i8] c"%f%f%f%f\00"
@.str.3 = [47 x i8] c"Thank you. Now enter student score (percent) >\00"
@.str.4 = [3 x i8] c"%f\00"
@str = [32 x i8] c"Enter thresholds for A, B, C, D\00"
@str.10 = [23 x i8] c"Student has an A grade\00"
@str.11 = [23 x i8] c"Student has an B grade\00"
@str.12 = [23 x i8] c"Student has an C grade\00"
@str.13 = [23 x i8] c"Student has an D grade\00"
@str.14 = [30 x i8] c"Student has failed the course\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%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 float* %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*, float*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float* %1, float* %2, float* %3, float* %4)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%16 = load float, float* %5
%17 = fcmp olt float %16, 6.000000e+01
br i1 %17, label %25, label %18
18: ; preds = %0
%19 = fcmp olt float %16, 7.000000e+01
br i1 %19, label %25, label %20
20: ; preds = %18
%21 = fcmp olt float %16, 8.000000e+01
br i1 %21, label %25, label %22
22: ; preds = %20
%23 = fcmp olt float %16, 9.000000e+01
%24 = select i1 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0)
br label %25
25: ; preds = %22, %20, %18, %0
%26 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.14, i64 0, i64 0), %0 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0), %18 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.12, i64 0, i64 0), %20 ], [ %24, %22 ]
%27 = call i32 @puts(i8* dereferenceable(1) %26)
ret i32 0
}