#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 *, double *, double *, double *);
int main() {
  double a, b, c, d;
  double per;
  printf("Enter thresholds for A, B, C, D\n");
  printf("in that order, decreasing percentages > ");
  scanf("%lf"
        "%lf"
        "%lf"
        "%lf",
        &a, &b, &c, &d);
  per = (a + b + c + d) / 4;
  if (per < 60)
    printf("Thank you. Now enter student score (percent) >Student has an B "
           "grade\n");
  else if (per >= 60 && per < 70)
    printf("Thank you. Now enter student score (percent) >Student has an B "
           "grade\n");
  else if (per >= 70 && per < 80)
    printf("Thank you. Now enter student score (percent) >Student has an B "
           "grade\n");
  else if (per >= 80)
    printf("Thank you. Now enter student score (percent) >Student has an B "
           "grade\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeea(%rip),%rdi
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1c(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe70(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11ac <main+0x8c>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
jmp    1254 <main+0x134>
movsd  -0x30(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11e7 <main+0xc7>
movsd  0xe45(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11e7 <main+0xc7>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    124f <main+0x12f>
movsd  -0x30(%rbp),%xmm0
movsd  0xe1c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1222 <main+0x102>
movsd  0xe12(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1222 <main+0x102>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    124a <main+0x12a>
movsd  -0x30(%rbp),%xmm0
movsd  0xde9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1245 <main+0x125>
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
jmp    124a <main+0x12a>
jmp    124f <main+0x12f>
jmp    1254 <main+0x134>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
lea    0xed9(%rip),%rdi
call   1040 <printf@plt>
lea    0xef6(%rip),%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <scanf@plt>
movsd  0x20(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  0xe74(%rip),%xmm0
movsd  0xe74(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11d4 <main+0xa4>
ucomisd 0xe66(%rip),%xmm0
jb     11b2 <main+0x82>
movsd  0xe64(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11d4 <main+0xa4>
ucomisd 0xe56(%rip),%xmm0
jb     11ca <main+0x9a>
movsd  0xe54(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     11d4 <main+0xa4>
ucomisd 0xe46(%rip),%xmm0
jb     11e0 <main+0xb0>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%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 = [13 x i8] c"%lf%lf%lf%lf\00"
@.str.3 = [70 x i8] c"Thank you. Now enter student score (percent) >Student has an B grade\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
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 @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double* %2, double* %3, double* %4, double* %5)
%10 = load double, double* %2
%11 = load double, double* %3
%12 = fadd double %10, %11
%13 = load double, double* %4
%14 = fadd double %12, %13
%15 = load double, double* %5
%16 = fadd double %14, %15
%17 = fdiv double %16, 4.000000e+00
store double %17, double* %6
%18 = load double, double* %6
%19 = fcmp olt double %18, 6.000000e+01
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
br label %46
22: ; preds = %0
%23 = load double, double* %6
%24 = fcmp oge double %23, 6.000000e+01
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load double, double* %6
%27 = fcmp olt double %26, 7.000000e+01
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
br label %45
30: ; preds = %25, %22
%31 = load double, double* %6
%32 = fcmp oge double %31, 7.000000e+01
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load double, double* %6
%35 = fcmp olt double %34, 8.000000e+01
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
br label %44
38: ; preds = %33, %30
%39 = load double, double* %6
%40 = fcmp oge double %39, 8.000000e+01
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %38
br label %44
44: ; preds = %43, %36
br label %45
45: ; preds = %44, %28
br label %46
46: ; preds = %45, %20
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [41 x i8] c"in that order, decreasing percentages > \00"
@.str.2 = [13 x i8] c"%lf%lf%lf%lf\00"
@str = [32 x i8] c"Enter thresholds for A, B, C, D\00"
@str.7 = [69 x i8] c"Thank you. Now enter student score (percent) >Student has an B grade\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4)
%12 = load double, double* %1
%13 = load double, double* %2
%14 = fadd double %12, %13
%15 = load double, double* %3
%16 = fadd double %14, %15
%17 = load double, double* %4
%18 = fadd double %16, %17
%19 = fmul double %18, 2.500000e-01
%20 = fcmp olt double %19, 6.000000e+01
br i1 %20, label %31, label %21
21: ; preds = %0
%22 = fcmp oge double %19, 6.000000e+01
%23 = fcmp olt double %19, 7.000000e+01
%24 = and i1 %22, %23
br i1 %24, label %31, label %25
25: ; preds = %21
%26 = fcmp oge double %19, 7.000000e+01
%27 = fcmp olt double %19, 8.000000e+01
%28 = and i1 %26, %27
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = fcmp ult double %19, 8.000000e+01
br i1 %30, label %34, label %31
31: ; preds = %29, %25, %21, %0
%32 = phi i8* [ getelementptr inbounds ([69 x i8], [69 x i8]* @str.7, i64 0, i64 0), %0 ], [ getelementptr inbounds ([69 x i8], [69 x i8]* @str.7, i64 0, i64 0), %21 ], [ getelementptr inbounds ([69 x i8], [69 x i8]* @str.7, i64 0, i64 0), %25 ], [ getelementptr inbounds ([69 x i8], [69 x i8]* @str.7, i64 0, i64 0), %29 ]
%33 = call i32 @puts(i8* dereferenceable(1) %32)
br label %34
34: ; preds = %31, %29
ret i32 0
}