#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 *, int *, int *, int *);
int main() {
  int test1, test2, test3, a;
  printf("Give the marks of three tests");
  scanf("%d %d %d", &test1, &test2, &test3);
  a = (test1 + test2 + test3) / 3;
  if (a < 35) {
    printf("The student has failed");
  } else if (a >= 35 && a <= 50) {
    printf("Third class");
  } else if (a > 50 && a <= 70) {
    printf("Second class");
  } else {
    printf("First class");
  }
  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    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x23,-0x14(%rbp)
jge    1182 <main+0x62>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
jmp    11e2 <main+0xc2>
cmpl   $0x23,-0x14(%rbp)
jl     11a7 <main+0x87>
cmpl   $0x32,-0x14(%rbp)
jg     11a7 <main+0x87>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
jmp    11dd <main+0xbd>
cmpl   $0x32,-0x14(%rbp)
jle    11cc <main+0xac>
cmpl   $0x46,-0x14(%rbp)
jg     11cc <main+0xac>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
jmp    11d8 <main+0xb8>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
jmp    11dd <main+0xbd>
jmp    11e2 <main+0xc2>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
add    0x14(%rsp),%eax
add    0xc(%rsp),%eax
cmp    $0x69,%eax
jge    1165 <main+0x45>
lea    0xec4(%rip),%rdi
jmp    118c <main+0x6c>
cmp    $0x99,%eax
jae    1175 <main+0x55>
lea    0xecb(%rip),%rdi
jmp    118c <main+0x6c>
cmp    $0xd5,%eax
lea    0xec9(%rip),%rax
lea    0xecf(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Give the marks of three tests\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [23 x i8] c"The student has failed\00"
@.str.3 = [12 x i8] c"Third class\00"
@.str.4 = [13 x i8] c"Second class\00"
@.str.5 = [12 x i8] c"First class\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = add nsw i32 %8, %9
%11 = load i32, i32* %4
%12 = add nsw i32 %10, %11
%13 = sdiv i32 %12, 3
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 35
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %38
18: ; preds = %0
%19 = load i32, i32* %5
%20 = icmp sge i32 %19, 35
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %5
%23 = icmp sle i32 %22, 50
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %37
26: ; preds = %21, %18
%27 = load i32, i32* %5
%28 = icmp sgt i32 %27, 50
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* %5
%31 = icmp sle i32 %30, 70
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %36
34: ; preds = %29, %26
%35 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36, %24
br label %38
38: ; preds = %37, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"Give the marks of three tests\00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [23 x i8] c"The student has failed\00"
@.str.3 = [12 x i8] c"Third class\00"
@.str.4 = [13 x i8] c"Second class\00"
@.str.5 = [12 x i8] c"First class\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = add nsw i32 %10, %9
%12 = load i32, i32* %3
%13 = add nsw i32 %11, %12
%14 = icmp slt i32 %13, 105
br i1 %14, label %20, label %15
15: ; preds = %0
%16 = icmp ult i32 %13, 153
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = icmp ult i32 %13, 213
%19 = select i1 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0)
br label %20
20: ; preds = %17, %15, %0
%21 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %15 ], [ %19, %17 ]
%22 = call i32 @printf(i8* dereferenceable(1) %21)
ret i32 0
}