#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(void) {
  int passes = 0;
  int failures = 0;
  int student = 1;
  int result;
  while (student <= 10) {
    printf("Enter result ( 1=pass,2=fail ): ");
    scanf("%d", &result);
    if (result == 1) {
      passes = passes + 1;
    } else {
      failures = failures + 1;
    }
    student = student + 1;
  }
  printf("Passed %d\n", passes);
  printf("Failed %d\n", failures);
  if (passes > 8) {
    printf("Bonus to instructor!\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     119b <main+0x7b>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    1184 <main+0x64>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118d <main+0x6d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <main+0x24>
mov    -0x8(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x8,-0x8(%rbp)
jle    11d5 <main+0xb5>
lea    0xe6c(%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
lea    0xebe(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xece(%rip),%r12
lea    0x4(%rsp),%rbp
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
xor    %r13d,%r13d
xor    %ebx,%ebx
cmpl   $0x1,0x4(%rsp)
setne  %r13b
sete   %bl
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbp,%r12
call   1050 <scanf@plt>
xor    %ebp,%ebp
xor    %r14d,%r14d
cmpl   $0x1,0x4(%rsp)
setne  %bpl
sete   %r14b
add    %ebx,%r14d
add    %r13d,%ebp
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
xor    %r13d,%r13d
xor    %ebx,%ebx
cmpl   $0x1,0x4(%rsp)
setne  %r13b
sete   %bl
add    %r14d,%ebx
add    %ebp,%r13d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
cmpl   $0x1,0x4(%rsp)
setne  %r14b
sete   %bpl
add    %ebx,%ebp
add    %r13d,%r14d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0c(%rip),%rdi
mov    %rdi,%r12
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %r13d,%r13d
xor    %ebx,%ebx
cmpl   $0x1,0x4(%rsp)
setne  %r13b
sete   %bl
add    %ebp,%ebx
add    %r14d,%r13d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
cmpl   $0x1,0x4(%rsp)
setne  %r14b
sete   %bpl
add    %ebx,%ebp
add    %r13d,%r14d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %r13d,%r13d
xor    %ebx,%ebx
cmpl   $0x1,0x4(%rsp)
setne  %r13b
sete   %bl
add    %ebp,%ebx
add    %r14d,%r13d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
cmpl   $0x1,0x4(%rsp)
setne  %r14b
sete   %bpl
add    %ebx,%ebp
add    %r13d,%r14d
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x4(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
xor    %r13d,%r13d
xor    %r15d,%r15d
cmpl   $0x1,0x4(%rsp)
setne  %r13b
sete   %r15b
add    %ebp,%r15d
add    %r14d,%r13d
lea    0xd05(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
cmpl   $0x1,0x4(%rsp)
setne  %bl
sete   %bpl
add    %r15d,%ebp
add    %r13d,%ebx
lea    0xcfa(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcf5(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebp
jb     1354 <main+0x224>
lea    0xceb(%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 = [33 x i8] c"Enter result ( 1=pass,2=fail ): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Passed %d\0A\00"
@.str.3 = [11 x i8] c"Failed %d\0A\00"
@.str.4 = [22 x i8] c"Bonus to instructor!\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 = %20, %0
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 10
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 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 %17
14: ; preds = %9
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
br label %20
17: ; preds = %9
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %6
23: ; preds = %6
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %2
%29 = icmp sgt i32 %28, 8
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter result ( 1=pass,2=fail ): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Passed %d\0A\00"
@.str.3 = [11 x i8] c"Failed %d\0A\00"
@str = [21 x i8] c"Bonus to instructor!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i32
%8 = xor i1 %6, true
%9 = zext i1 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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* %1)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %7, %14
%16 = xor i1 %13, true
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %9, %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 1
%23 = zext i1 %22 to i32
%24 = add nuw nsw i32 %15, %23
%25 = xor i1 %22, true
%26 = zext i1 %25 to i32
%27 = add nuw nsw i32 %18, %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%30 = load i32, i32* %1
%31 = icmp eq i32 %30, 1
%32 = zext i1 %31 to i32
%33 = add nuw nsw i32 %24, %32
%34 = xor i1 %31, true
%35 = zext i1 %34 to i32
%36 = add nuw nsw i32 %27, %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%39 = load i32, i32* %1
%40 = icmp eq i32 %39, 1
%41 = zext i1 %40 to i32
%42 = add nuw nsw i32 %33, %41
%43 = xor i1 %40, true
%44 = zext i1 %43 to i32
%45 = add nuw nsw i32 %36, %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%48 = load i32, i32* %1
%49 = icmp eq i32 %48, 1
%50 = zext i1 %49 to i32
%51 = add nuw nsw i32 %42, %50
%52 = xor i1 %49, true
%53 = zext i1 %52 to i32
%54 = add nuw nsw i32 %45, %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%57 = load i32, i32* %1
%58 = icmp eq i32 %57, 1
%59 = zext i1 %58 to i32
%60 = add nuw nsw i32 %51, %59
%61 = xor i1 %58, true
%62 = zext i1 %61 to i32
%63 = add nuw nsw i32 %54, %62
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%65 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%66 = load i32, i32* %1
%67 = icmp eq i32 %66, 1
%68 = zext i1 %67 to i32
%69 = add nuw nsw i32 %60, %68
%70 = xor i1 %67, true
%71 = zext i1 %70 to i32
%72 = add nuw nsw i32 %63, %71
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%74 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%75 = load i32, i32* %1
%76 = icmp eq i32 %75, 1
%77 = zext i1 %76 to i32
%78 = add nuw nsw i32 %69, %77
%79 = xor i1 %76, true
%80 = zext i1 %79 to i32
%81 = add nuw nsw i32 %72, %80
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%83 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%84 = load i32, i32* %1
%85 = icmp eq i32 %84, 1
%86 = zext i1 %85 to i32
%87 = add nuw nsw i32 %78, %86
%88 = xor i1 %85, true
%89 = zext i1 %88 to i32
%90 = add nuw nsw i32 %81, %89
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %87)
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %90)
%93 = icmp ugt i32 %87, 8
br i1 %93, label %94, label %96
94: ; preds = %0
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %96
96: ; preds = %94, %0
ret i32 0
}