#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 subject_1, subject_2, subject_3;
  float subject_total;
  float percentage;
  float total = 300;
  printf("Enter marks for subject 1: ");
  scanf("%f", &subject_1);
  printf("Enter marks for subject 2: ");
  scanf("%f", &subject_2);
  printf("Enter marks for subject 3: ");
  scanf("%f", &subject_3);
  subject_total = subject_1 + subject_2 + subject_3;
  percentage = subject_total / total;
  if (percentage >= 0.7) {
    printf("Distinction.\n");
  } else if (percentage >= 0.6 && percentage < 0.7) {
    printf("First class.\n");
  } else if (percentage >= 0.5 && percentage < 0.6) {
    printf("Second class.\n");
  } else if (percentage >= 0.4 && percentage < 0.5) {
    printf("Pass class.\n");
  } else {
    printf("Fail.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xee9(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11df <main+0xbf>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
jmp    12cf <main+0x1af>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe18(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1226 <main+0x106>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdf5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1226 <main+0x106>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    12ca <main+0x1aa>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     126d <main+0x14d>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdb6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    126d <main+0x14d>
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
jmp    12c5 <main+0x1a5>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12b4 <main+0x194>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd77(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12b4 <main+0x194>
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
jmp    12c0 <main+0x1a0>
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
jmp    12c5 <main+0x1a5>
jmp    12ca <main+0x1aa>
jmp    12cf <main+0x1af>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xee4(%rip),%rdi
call   1040 <printf@plt>
lea    0xef4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xee3(%rip),%rdi
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xee6(%rip),%rdi
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
addss  0x4(%rsp),%xmm0
divss  0xe5f(%rip),%xmm0
cvtss2sd %xmm0,%xmm1
ucomisd 0xe5b(%rip),%xmm1
jae    11d0 <main+0xa0>
ucomisd 0xe59(%rip),%xmm1
jb     11d9 <main+0xa9>
movsd  0xe47(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    11d9 <main+0xa9>
lea    0xec9(%rip),%rdi
jmp    1222 <main+0xf2>
lea    0xecd(%rip),%rdi
jmp    1222 <main+0xf2>
ucomiss 0xe24(%rip),%xmm0
jb     11f9 <main+0xc9>
movsd  0xe26(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    11f9 <main+0xc9>
lea    0xe92(%rip),%rdi
jmp    1222 <main+0xf2>
ucomisd 0xe17(%rip),%xmm1
lea    0xe75(%rip),%rdi
lea    0xe68(%rip),%rax
cmovb  %rax,%rdi
movss  0xde9(%rip),%xmm1
ucomiss %xmm0,%xmm1
cmovbe %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter marks for subject 1: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [28 x i8] c"Enter marks for subject 2: \00"
@.str.3 = [28 x i8] c"Enter marks for subject 3: \00"
@.str.4 = [14 x i8] c"Distinction.\0A\00"
@.str.5 = [14 x i8] c"First class.\0A\00"
@.str.6 = [15 x i8] c"Second class.\0A\00"
@.str.7 = [13 x i8] c"Pass class.\0A\00"
@.str.8 = [7 x i8] c"Fail.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store i32 0, i32* %1
store float 3.000000e+02, float* %7
%8 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%10 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %4)
%14 = load float, float* %2
%15 = load float, float* %3
%16 = fadd float %14, %15
%17 = load float, float* %4
%18 = fadd float %16, %17
store float %18, float* %5
%19 = load float, float* %5
%20 = load float, float* %7
%21 = fdiv float %19, %20
store float %21, float* %6
%22 = load float, float* %6
%23 = fpext float %22 to double
%24 = fcmp oge double %23, 0x3FE6666666666666
br i1 %24, label %25, label %27
25: ; preds = %0
%26 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %62
27: ; preds = %0
%28 = load float, float* %6
%29 = fpext float %28 to double
%30 = fcmp oge double %29, 6.000000e-01
br i1 %30, label %31, label %37
31: ; preds = %27
%32 = load float, float* %6
%33 = fpext float %32 to double
%34 = fcmp olt double %33, 0x3FE6666666666666
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %61
37: ; preds = %31, %27
%38 = load float, float* %6
%39 = fpext float %38 to double
%40 = fcmp oge double %39, 5.000000e-01
br i1 %40, label %41, label %47
41: ; preds = %37
%42 = load float, float* %6
%43 = fpext float %42 to double
%44 = fcmp olt double %43, 6.000000e-01
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %60
47: ; preds = %41, %37
%48 = load float, float* %6
%49 = fpext float %48 to double
%50 = fcmp oge double %49, 4.000000e-01
br i1 %50, label %51, label %57
51: ; preds = %47
%52 = load float, float* %6
%53 = fpext float %52 to double
%54 = fcmp olt double %53, 5.000000e-01
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %59
57: ; preds = %51, %47
%58 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %59
59: ; preds = %57, %55
br label %60
60: ; preds = %59, %45
br label %61
61: ; preds = %60, %35
br label %62
62: ; preds = %61, %25
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter marks for subject 1: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [28 x i8] c"Enter marks for subject 2: \00"
@.str.3 = [28 x i8] c"Enter marks for subject 3: \00"
@str = [6 x i8] c"Fail.\00"
@str.9 = [12 x i8] c"Pass class.\00"
@str.10 = [14 x i8] c"Second class.\00"
@str.11 = [13 x i8] c"First class.\00"
@str.12 = [13 x i8] c"Distinction.\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%13 = load float, float* %1
%14 = load float, float* %2
%15 = fadd float %13, %14
%16 = load float, float* %3
%17 = fadd float %15, %16
%18 = fdiv float %17, 3.000000e+02
%19 = fpext float %18 to double
%20 = fcmp ult double %19, 0x3FE6666666666666
br i1 %20, label %21, label %34
21: ; preds = %0
%22 = fcmp oge double %19, 6.000000e-01
%23 = fcmp olt double %19, 0x3FE6666666666666
%24 = and i1 %22, %23
br i1 %24, label %34, label %25
25: ; preds = %21
%26 = fcmp oge float %18, 5.000000e-01
%27 = fcmp olt double %19, 6.000000e-01
%28 = and i1 %26, %27
br i1 %28, label %34, label %29
29: ; preds = %25
%30 = fcmp oge double %19, 4.000000e-01
%31 = fcmp olt float %18, 5.000000e-01
%32 = and i1 %31, %30
%33 = select i1 %32, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0)
br label %34
34: ; preds = %29, %25, %21, %0
%35 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0), %0 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0), %21 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.10, i64 0, i64 0), %25 ], [ %33, %29 ]
%36 = call i32 @puts(i8* dereferenceable(1) %35)
ret i32 0
}