#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 th_1, th_2, th_3, th_4, score;
  printf("Enter thresholds for A, B, C, D \n in that order, decreasing "
         "percentages> ");
  scanf("%f %f %f %f", &th_1, &th_2, &th_3, &th_4);
  printf("Thank you. Now enter student score (percent) > ");
  scanf("%f", &score);
  if (score >= th_1) {
    printf("Student has an A grade \n");
  } else {
    if (th_2 <= score < th_1) {
      printf("Student has an B grade \n");
    } else {
      if (th_3 <= score < th_2) {
        printf("Student has an C grade \n");
      } else {
        if (th_4 <= score < th_3) {
          printf("Student has an D \n");
        } else {
          if (score < th_4) {
            printf("Student has an F grade \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    0xf08(%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    0xef6(%rip),%rdi
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jb     1197 <main+0x77>
lea    0xef9(%rip),%rdi
call   1030 <printf@plt>
jmp    1279 <main+0x159>
movss  -0xc(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2ss %eax,%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11cf <main+0xaf>
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
jmp    1274 <main+0x154>
movss  -0x10(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2ss %eax,%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1207 <main+0xe7>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
jmp    1268 <main+0x148>
movss  -0x14(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2ss %eax,%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    123f <main+0x11f>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
jmp    1263 <main+0x143>
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    125e <main+0x13e>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    1263 <main+0x143>
jmp    1268 <main+0x148>
movl   $0x0,-0x4(%rbp)
jmp    1279 <main+0x159>
jmp    1279 <main+0x159>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec9(%rip),%rdi
call   1040 <printf@plt>
lea    0xf07(%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    0xef1(%rip),%rdi
call   1040 <printf@plt>
lea    0xee2(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x4(%rsp),%xmm0
movss  0x14(%rsp),%xmm3
ucomiss %xmm3,%xmm0
jae    11b9 <main+0x89>
movss  0x10(%rsp),%xmm2
movaps %xmm2,%xmm4
cmpless %xmm0,%xmm4
movss  0xe58(%rip),%xmm1
andps  %xmm1,%xmm4
ucomiss %xmm4,%xmm3
jbe    11cc <main+0x9c>
lea    0xf15(%rip),%rdi
jmp    11c0 <main+0x90>
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm4
cmpless %xmm0,%xmm4
andps  %xmm1,%xmm4
ucomiss %xmm4,%xmm2
jbe    11eb <main+0xbb>
lea    0xecb(%rip),%rdi
jmp    11c0 <main+0x90>
movss  0x8(%rsp),%xmm2
movaps %xmm2,%xmm4
cmpless %xmm0,%xmm4
andps  %xmm1,%xmm4
ucomiss %xmm4,%xmm3
jbe    120a <main+0xda>
lea    0xe9a(%rip),%rdi
jmp    11c0 <main+0x90>
ucomiss %xmm0,%xmm2
jbe    11c5 <main+0x95>
lea    0xe74(%rip),%rdi
jmp    11c0 <main+0x90>

LLVM IR (-O0):
@.str = [74 x i8] c"Enter thresholds for A, B, C, D \0A in that order, decreasing percentages> \00"
@.str.1 = [12 x i8] c"%f %f %f %f\00"
@.str.2 = [48 x i8] c"Thank you. Now enter student score (percent) > \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [25 x i8] c"Student has an A grade \0A\00"
@.str.5 = [25 x i8] c"Student has an B grade \0A\00"
@.str.6 = [25 x i8] c"Student has an C grade \0A\00"
@.str.7 = [19 x i8] c"Student has an D \0A\00"
@.str.8 = [25 x i8] c"Student has an F 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 ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3, float* %4, float* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%11 = load float, float* %6
%12 = load float, float* %2
%13 = fcmp oge float %11, %12
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %56
16: ; preds = %0
%17 = load float, float* %3
%18 = load float, float* %6
%19 = fcmp ole float %17, %18
%20 = zext i1 %19 to i32
%21 = sitofp i32 %20 to float
%22 = load float, float* %2
%23 = fcmp olt float %21, %22
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %55
26: ; preds = %16
%27 = load float, float* %4
%28 = load float, float* %6
%29 = fcmp ole float %27, %28
%30 = zext i1 %29 to i32
%31 = sitofp i32 %30 to float
%32 = load float, float* %3
%33 = fcmp olt float %31, %32
br i1 %33, label %34, label %36
34: ; preds = %26
%35 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %54
36: ; preds = %26
%37 = load float, float* %5
%38 = load float, float* %6
%39 = fcmp ole float %37, %38
%40 = zext i1 %39 to i32
%41 = sitofp i32 %40 to float
%42 = load float, float* %4
%43 = fcmp olt float %41, %42
br i1 %43, label %44, label %46
44: ; preds = %36
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %53
46: ; preds = %36
%47 = load float, float* %6
%48 = load float, float* %5
%49 = fcmp olt float %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
br label %53
53: ; preds = %52, %44
br label %54
54: ; preds = %53, %34
store i32 0, i32* %1
br label %56
55: ; preds = %24
br label %56
56: ; preds = %54, %55, %14
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@.str = [74 x i8] c"Enter thresholds for A, B, C, D \0A in that order, decreasing percentages> \00"
@.str.1 = [12 x i8] c"%f %f %f %f\00"
@.str.2 = [48 x i8] c"Thank you. Now enter student score (percent) > \00"
@.str.3 = [3 x i8] c"%f\00"
@str = [24 x i8] c"Student has an F grade \00"
@str.9 = [18 x i8] c"Student has an D \00"
@str.10 = [24 x i8] c"Student has an C grade \00"
@str.11 = [24 x i8] c"Student has an B grade \00"
@str.12 = [24 x i8] c"Student has an A grade \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 @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 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 ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%15 = load float, float* %5
%16 = load float, float* %1
%17 = fcmp ult float %15, %16
br i1 %17, label %18, label %35
18: ; preds = %0
%19 = load float, float* %2
%20 = fcmp ole float %19, %15
%21 = uitofp i1 %20 to float
%22 = fcmp ogt float %16, %21
br i1 %22, label %35, label %23
23: ; preds = %18
%24 = load float, float* %3
%25 = fcmp ole float %24, %15
%26 = uitofp i1 %25 to float
%27 = fcmp ogt float %19, %26
br i1 %27, label %35, label %28
28: ; preds = %23
%29 = load float, float* %4
%30 = fcmp ole float %29, %15
%31 = uitofp i1 %30 to float
%32 = fcmp ogt float %24, %31
br i1 %32, label %35, label %33
33: ; preds = %28
%34 = fcmp olt float %15, %29
br i1 %34, label %35, label %38
35: ; preds = %33, %28, %23, %18, %0
%36 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.12, i64 0, i64 0), %0 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0), %18 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.10, i64 0, i64 0), %23 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0), %28 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0), %33 ]
%37 = call i32 @puts(i8* dereferenceable(1) %36)
br label %38
38: ; preds = %35, %33
ret i32 0
}