#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  unsigned int passes = 0;
  unsigned int failures = 0;
  unsigned int student = 1;
  int result;
  while (student <= 10) {
    printf("%s", "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;
    }
  }
  printf("Passed %u\n", passes);
  printf("Failed %u\n", failures);
  if (passes > 8) {
    puts("Bonus to istructor!");
  }
  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)
ja     11ca <main+0x9a>
lea    0xe9b(%rip),%rdi
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11a4 <main+0x74>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c5 <main+0x95>
cmpl   $0x2,-0x14(%rbp)
jne    11c0 <main+0x90>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c5 <main+0x95>
jmp    1154 <main+0x24>
mov    -0x8(%rbp),%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x8,-0x8(%rbp)
jbe    1202 <main+0xd2>
lea    0xe40(%rip),%rdi
call   1030 <puts@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,%r14d
lea    0xebb(%rip),%r15
lea    0xed5(%rip),%r12
lea    0x4(%rsp),%r13
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    116d <main+0x3d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0x1,%r14d
cmp    $0xb,%r14d
jae    119c <main+0x6c>
lea    0xe8c(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
je     1160 <main+0x30>
cmp    $0x1,%eax
jne    1167 <main+0x37>
add    $0x1,%ebx
jmp    1163 <main+0x33>
lea    0xe84(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebx
jb     11cd <main+0x9d>
lea    0xe75(%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 = [3 x i8] c"%s\00"
@.str.1 = [33 x i8] c"Enter result ( 1=pass,2=fail ): \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [11 x i8] c"Passed %u\0A\00"
@.str.4 = [11 x i8] c"Failed %u\0A\00"
@.str.5 = [20 x i8] c"Bonus to istructor!\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 = %28, %0
%7 = load i32, i32* %4
%8 = icmp ule i32 %7, 10
br i1 %8, label %9, label %29
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, 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 i32 %15, 1
store i32 %16, i32* %2
%17 = load i32, i32* %4
%18 = add i32 %17, 1
store i32 %18, i32* %4
br label %28
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 i32 %23, 1
store i32 %24, i32* %3
%25 = load i32, i32* %4
%26 = add i32 %25, 1
store i32 %26, i32* %4
br label %27
27: ; preds = %22, %19
br label %28
28: ; preds = %27, %14
br label %6
29: ; preds = %6
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = icmp ugt i32 %34, 8
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %29
ret i32 0
}

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