#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 main() {
  int passes = 0, failures = 0, student = 1, result;
  while (student <= 10) {
    printf("Enter result ( 1=pass, 2=fail ): ");
    scanf("%d", &result);
    if (result == 1) {
      passes = passes + 1;
      student = student + 1;
    } else if (result == 2) {
      failures = failures + 1;
      student = student + 1;
    } else
      printf("<< Invalid input. >>\n");
  }
  printf("Passed %d\n", passes);
  printf("Failed %d\n", failures);
  if (passes > 8)
    printf("Raise tuition\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jg     11c6 <main+0xa6>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    118d <main+0x6d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c1 <main+0xa1>
cmpl   $0x2,-0x14(%rbp)
jne    11ae <main+0x8e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bc <main+0x9c>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c1 <main+0xa1>
jmp    1144 <main+0x24>
mov    -0x8(%rbp),%esi
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x8,-0x8(%rbp)
jle    1200 <main+0xe0>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r13d
lea    0xeb8(%rip),%r14
lea    0xed3(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1172 <main+0x42>
nopw   0x0(%rax,%rax,1)
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
cmp    $0xb,%r13d
jge    11a9 <main+0x79>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     11a0 <main+0x70>
cmp    $0x1,%eax
jne    1160 <main+0x30>
add    $0x1,%ebx
add    $0x1,%r13d
jmp    116c <main+0x3c>
xchg   %ax,%ax
add    $0x1,%ebp
add    $0x1,%r13d
jmp    116c <main+0x3c>
lea    0xe75(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebx
jl     11da <main+0xaa>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter result ( 1=pass, 2=fail ): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"<< Invalid input. >>\0A\00"
@.str.3 = [11 x i8] c"Passed %d\0A\00"
@.str.4 = [11 x i8] c"Failed %d\0A\00"
@.str.5 = [15 x i8] c"Raise tuition\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %30, %0
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 10
br i1 %8, label %9, label %31
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %30
19: ; preds = %9
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %29
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
br label %30
30: ; preds = %29, %14
br label %6
31: ; preds = %6
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %2
%37 = icmp sgt i32 %36, 8
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %31
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Enter result ( 1=pass, 2=fail ): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [11 x i8] c"Passed %d\0A\00"
@.str.4 = [11 x i8] c"Failed %d\0A\00"
@str = [14 x i8] c"Raise tuition\00"
@str.6 = [21 x i8] c"<< Invalid input. >>\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %0, %18
%4 = phi i32 [ 1, %0 ], [ %21, %18 ]
%5 = phi i32 [ 0, %0 ], [ %20, %18 ]
%6 = phi i32 [ 0, %0 ], [ %19, %18 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 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), i32* %1)
%9 = load i32, i32* %1
switch i32 %9, label %16 [
i32 1, label %10
i32 2, label %13
]
10: ; preds = %3
%11 = add nsw i32 %6, 1
%12 = add nsw i32 %4, 1
br label %18
13: ; preds = %3
%14 = add nsw i32 %5, 1
%15 = add nsw i32 %4, 1
br label %18
16: ; preds = %3
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0))
br label %18
18: ; preds = %13, %16, %10
%19 = phi i32 [ %11, %10 ], [ %6, %13 ], [ %6, %16 ]
%20 = phi i32 [ %5, %10 ], [ %14, %13 ], [ %5, %16 ]
%21 = phi i32 [ %12, %10 ], [ %15, %13 ], [ %4, %16 ]
%22 = icmp slt i32 %21, 11
br i1 %22, label %3, label %23
23: ; preds = %18
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%26 = icmp sgt i32 %19, 8
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %27, %23
ret i32 0
}