#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, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int N, win[3] = {0, 0, 0}, i;
  scanf(" %d", &N);
  while (N != 0) {
    i = N;
    win[1] = 0;
    win[2] = 0;
    while (i > 0) {
      scanf(" %d", &win[0]);
      win[0] == 0 ? win[1]++ : win[2]++;
      i--;
    }
    printf("Mary won %d times and John won %d times\n", win[1], win[2]);
    scanf(" %d", &N);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x14(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11ed <main+0xbd>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    11c6 <main+0x96>
lea    -0x14(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1050 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11af <main+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b8 <main+0x88>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    117d <main+0x4d>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
lea    0xe21(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
lea    0xec5(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%ebp
test   %ebp,%ebp
je     11cc <main+0xac>
lea    0xeab(%rip),%rbx
lea    0x4(%rsp),%r14
lea    0xea3(%rip),%r15
mov    %rsp,%r12
jmp    118e <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
xor    %edx,%edx
xor    %esi,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%ebp
test   %ebp,%ebp
je     11cc <main+0xac>
movq   $0x0,0x8(%rsp)
test   %ebp,%ebp
jle    1170 <main+0x50>
add    $0x1,%ebp
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x0,0x4(%rsp)
setne  %al
addl   $0x1,0x8(%rsp,%rax,4)
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jg     11a0 <main+0x80>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
jmp    1174 <main+0x54>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %d\00"
@.str.1 = [41 x i8] c"Mary won %d times and John won %d times\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [3 x i32]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [3 x i32]* %3 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %35, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %42
10: ; preds = %7
%11 = load i32, i32* %2
store i32 %11, i32* %4
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
store i32 0, i32* %12
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
store i32 0, i32* %13
br label %14
14: ; preds = %31, %10
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %35
17: ; preds = %14
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %18)
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 1
store i32 %26, i32* %24
br label %31
27: ; preds = %17
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %31
31: ; preds = %27, %23
%32 = phi i32 [ %25, %23 ], [ %29, %27 ]
%33 = load i32, i32* %4
%34 = add nsw i32 %33, -1
store i32 %34, i32* %4
br label %14
35: ; preds = %14
%36 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%37 = load i32, i32* %36
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%39 = load i32, i32* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %39)
%41 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
42: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c" %d\00"
@.str.1 = [41 x i8] c"Mary won %d times and John won %d times\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [3 x i32]* %2 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 0, i32* %5
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %36, label %9
9: ; preds = %0
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
br label %13
13: ; preds = %9, %29
%14 = phi i32 [ %7, %9 ], [ %34, %29 ]
store i32 0, i32* %10
store i32 0, i32* %11
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %13, %16
%17 = phi i32 [ %24, %16 ], [ %14, %13 ]
%18 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %12)
%19 = load i32, i32* %12
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i32* %10, i32* %11
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1
store i32 %23, i32* %21
%24 = add nsw i32 %17, -1
%25 = icmp sgt i32 %17, 1
br i1 %25, label %16, label %26
26: ; preds = %16
%27 = load i32, i32* %10
%28 = load i32, i32* %11
br label %29
29: ; preds = %26, %13
%30 = phi i32 [ %28, %26 ], [ 0, %13 ]
%31 = phi i32 [ %27, %26 ], [ 0, %13 ]
%32 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %30)
%33 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%34 = load i32, i32* %1
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %13
36: ; preds = %29, %0
ret i32 0
}