#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 = 0;
  int flag = -1;
  while (student <= 10) {
    printf("%s", "Enter result ( 1=pass,2=fail ): ");
    scanf("%d", &result);
    while (flag != 1) {
      if (result == 1) {
        passes = passes + 1;
        flag = 1;
      } else if (result == 2) {
        failures = failures + 1;
        flag = 1;
      } else {
        flag = -1;
        printf("%s\n",
               "You did not enter n accepted input!!!Please try again!!! ");
        printf("%s", "Enter result ( 1=pass,2=fail ): ");
        scanf("%d", &result);
      }
    }
    student = student + 1;
    flag = -1;
  }
  printf("Passed %u\n", passes);
  printf("Failed %u\n", failures);
  if (passes > 8) {
    puts("Bonus to instructor!");
  }
  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)
movl   $0x0,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
cmpl   $0xa,-0x10(%rbp)
ja     1239 <main+0x109>
lea    0xe8d(%rip),%rdi
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
je     1224 <main+0xf4>
cmpl   $0x1,-0x14(%rbp)
jne    11ba <main+0x8a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    121f <main+0xef>
cmpl   $0x2,-0x14(%rbp)
jne    11d9 <main+0xa9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    121a <main+0xea>
movl   $0xffffffff,-0x18(%rbp)
lea    0xe40(%rip),%rdi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe04(%rip),%rdi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
jmp    121f <main+0xef>
jmp    1191 <main+0x61>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
jmp    1162 <main+0x32>
mov    -0x8(%rbp),%esi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x8,-0x8(%rbp)
jbe    1271 <main+0x141>
lea    0xe0f(%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
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
mov    $0x1,%r15d
lea    0xead(%rip),%r12
lea    0xea9(%rip),%r13
lea    0xec3(%rip),%rbp
lea    0x14(%rsp),%rbx
lea    0xeba(%rip),%r14
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
jmp    1188 <main+0x58>
nop
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     11b5 <main+0x85>
cmp    $0x1,%eax
jne    1180 <main+0x50>
addl   $0x1,0x10(%rsp)
jmp    11ba <main+0x8a>
addl   $0x1,0xc(%rsp)
add    $0x1,%r15d
cmp    $0xb,%r15d
jne    1188 <main+0x58>
lea    0xe96(%rip),%rdi
mov    0x10(%rsp),%ebx
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebx
jb     11fb <main+0xcb>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%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 = [4 x i8] c"%s\0A\00"
@.str.4 = [58 x i8] c"You did not enter n accepted input!!!Please try again!!! \00"
@.str.5 = [11 x i8] c"Passed %u\0A\00"
@.str.6 = [11 x i8] c"Failed %u\0A\00"
@.str.7 = [21 x i8] c"Bonus to instructor!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
store i32 0, i32* %5
store i32 -1, i32* %6
br label %7
7: ; preds = %34, %0
%8 = load i32, i32* %4
%9 = icmp ule i32 %8, 10
br i1 %9, label %10, label %37
10: ; preds = %7
%11 = 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))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
br label %13
13: ; preds = %33, %10
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = add i32 %20, 1
store i32 %21, i32* %2
store i32 1, i32* %6
br label %33
22: ; preds = %16
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %3
%27 = add i32 %26, 1
store i32 %27, i32* %3
store i32 1, i32* %6
br label %32
28: ; preds = %22
store i32 -1, i32* %6
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
%30 = 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))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
br label %32
32: ; preds = %28, %25
br label %33
33: ; preds = %32, %19
br label %13
34: ; preds = %13
%35 = load i32, i32* %4
%36 = add i32 %35, 1
store i32 %36, i32* %4
store i32 -1, i32* %6
br label %7
37: ; preds = %7
%38 = load i32, i32* %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %2
%43 = icmp ugt i32 %42, 8
br i1 %43, label %44, label %46
44: ; preds = %37
%45 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %46
46: ; preds = %44, %37
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.4 = [58 x i8] c"You did not enter n accepted input!!!Please try again!!! \00"
@.str.5 = [11 x i8] c"Passed %u\0A\00"
@.str.6 = [11 x i8] c"Failed %u\0A\00"
@.str.7 = [21 x i8] c"Bonus to instructor!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %0, %17
%4 = phi i32 [ 1, %0 ], [ %20, %17 ]
%5 = phi i32 [ 0, %0 ], [ %19, %17 ]
%6 = phi i32 [ 0, %0 ], [ %18, %17 ]
br label %7
7: ; preds = %15, %3
%8 = 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))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
switch i32 %10, label %15 [
i32 1, label %11
i32 2, label %13
]
11: ; preds = %7
%12 = add i32 %6, 1
br label %17
13: ; preds = %7
%14 = add i32 %5, 1
br label %17
15: ; preds = %7
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
br label %7
17: ; preds = %11, %13
%18 = phi i32 [ %6, %13 ], [ %12, %11 ]
%19 = phi i32 [ %14, %13 ], [ %5, %11 ]
%20 = add nuw nsw i32 %4, 1
%21 = icmp eq i32 %20, 11
br i1 %21, label %22, label %3
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %19)
%25 = icmp ugt i32 %18, 8
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
ret i32 0
}