#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 scanf(char *, int *);
int main(void) {
  int jogadas, jogo, mary, john;
  while (scanf("%d", &jogadas), jogadas != 0) {
    mary = john = 0;
    while (jogadas-- > 0) {
      scanf("%d", &jogo);
      if (jogo == 0) {
        mary++;
      } else {
        john++;
      }
    }
    printf("Mary won %d times and John won %d times\n", mary, john);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11b8 <main+0x98>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    11a1 <main+0x81>
lea    0xe8e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1193 <main+0x73>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119c <main+0x7c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <main+0x37>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
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    0xece(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     11bd <main+0x9d>
lea    0xeb8(%rip),%r13
lea    0x4(%rsp),%r14
lea    0xeaf(%rip),%r15
mov    %rsp,%r12
jmp    1182 <main+0x62>
nopl   0x0(%rax)
xor    %ebx,%ebx
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     11bd <main+0x9d>
lea    -0x1(%rax),%ecx
mov    %ecx,(%rsp)
test   %eax,%eax
jle    1160 <main+0x40>
xor    %ebp,%ebp
xor    %ebx,%ebx
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
xor    %ecx,%ecx
cmpl   $0x0,0x4(%rsp)
setne  %al
sete   %cl
add    %ecx,%ebx
add    %eax,%ebp
mov    (%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,(%rsp)
test   %eax,%eax
jg     1190 <main+0x70>
jmp    1164 <main+0x44>
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"%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 i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %26, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %6
store i32 0, i32* %5
store i32 0, i32* %4
br label %11
11: ; preds = %25, %10
%12 = load i32, i32* %2
%13 = add nsw i32 %12, -1
store i32 %13, i32* %2
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %25
22: ; preds = %15
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %25
25: ; preds = %22, %19
br label %11
26: ; preds = %11
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %28)
br label %6
30: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 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 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %33, label %8
8: ; preds = %0, %26
%9 = phi i32 [ %31, %26 ], [ %6, %0 ]
%10 = add nsw i32 %9, -1
store i32 %10, i32* %1
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %26
12: ; preds = %8, %12
%13 = phi i32 [ %22, %12 ], [ 0, %8 ]
%14 = phi i32 [ %19, %12 ], [ 0, %8 ]
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %14, %18
%20 = xor i1 %17, true
%21 = zext i1 %20 to i32
%22 = add nuw nsw i32 %13, %21
%23 = load i32, i32* %1
%24 = add nsw i32 %23, -1
store i32 %24, i32* %1
%25 = icmp sgt i32 %23, 0
br i1 %25, label %12, label %26
26: ; preds = %12, %8
%27 = phi i32 [ 0, %8 ], [ %19, %12 ]
%28 = phi i32 [ 0, %8 ], [ %22, %12 ]
%29 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %28)
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%31 = load i32, i32* %1
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %8
33: ; preds = %26, %0
ret i32 0
}