#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 */
scalar_t__ PlayersAlive(int);
int /*<<< orphan*/ printField(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ runARound(int);
int runSeveralRounds(int NumberOfRounds) {
  for (int g = 1; g < NumberOfRounds; g++) {
    if (PlayersAlive(1) == 0) {
      printField(g);
      printf(
          "Team 2 has successfully defeated team 1 in Smashball in round %d.\n",
          g);
      return 2;
    } else if (PlayersAlive(2) == 0) {
      printField(g);
      printf(
          "Team 1 has successfully defeated team 2 in Smashball in round %d.\n",
          g);
      return 1;
    } else {
      runARound(g);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<runSeveralRounds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ec <runSeveralRounds+0xac>
mov    $0x1,%edi
call   1050 <PlayersAlive@plt>
cmp    $0x0,%rax
jne    1195 <runSeveralRounds+0x55>
mov    -0xc(%rbp),%edi
call   1040 <printField@plt>
mov    -0xc(%rbp),%esi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    11f3 <runSeveralRounds+0xb3>
mov    $0x2,%edi
call   1050 <PlayersAlive@plt>
cmp    $0x0,%rax
jne    11cc <runSeveralRounds+0x8c>
mov    -0xc(%rbp),%edi
call   1040 <printField@plt>
mov    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f3 <runSeveralRounds+0xb3>
mov    -0xc(%rbp),%edi
call   1060 <runARound@plt>
jmp    11d9 <runSeveralRounds+0x99>
jmp    11de <runSeveralRounds+0x9e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <runSeveralRounds+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runSeveralRounds>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
cmp    $0x2,%edi
jl     11bd <runSeveralRounds+0x7d>
mov    %edi,%ebp
mov    $0x1,%ebx
lea    0xe9f(%rip),%r13
mov    $0x2,%r12d
lea    0xed5(%rip),%r14
xchg   %ax,%ax
mov    $0x1,%edi
call   1050 <PlayersAlive@plt>
test   %rax,%rax
je     119e <runSeveralRounds+0x5e>
mov    $0x2,%edi
call   1050 <PlayersAlive@plt>
test   %rax,%rax
je     11a3 <runSeveralRounds+0x63>
mov    %ebx,%edi
call   1060 <runARound@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1170 <runSeveralRounds+0x30>
jmp    11bd <runSeveralRounds+0x7d>
mov    %r13,%r14
jmp    11a9 <runSeveralRounds+0x69>
mov    $0x1,%r12d
mov    %ebx,%edi
call   1040 <printField@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r12d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [67 x i8] c"Team 2 has successfully defeated team 1 in Smashball in round %d.\0A\00"
@.str.1 = [67 x i8] c"Team 1 has successfully defeated team 2 in Smashball in round %d.\0A\00"
define i32 @runSeveralRounds(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %30, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %33
9: ; preds = %5
%10 = call i64 @PlayersAlive(i32 1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %4
%14 = call i32 @printField(i32 %13)
%15 = load i32, i32* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 2, i32* %2
br label %34
17: ; preds = %9
%18 = call i64 @PlayersAlive(i32 2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %4
%22 = call i32 @printField(i32 %21)
%23 = load i32, i32* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 1, i32* %2
br label %34
25: ; preds = %17
%26 = load i32, i32* %4
%27 = call i32 @runARound(i32 %26)
br label %28
28: ; preds = %25
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %5
33: ; preds = %5
store i32 0, i32* %2
br label %34
34: ; preds = %33, %20, %12
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [67 x i8] c"Team 2 has successfully defeated team 1 in Smashball in round %d.\0A\00"
@.str.1 = [67 x i8] c"Team 1 has successfully defeated team 2 in Smashball in round %d.\0A\00"
define i32 @runSeveralRounds(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %3, label %19
3: ; preds = %1, %10
%4 = phi i32 [ %12, %10 ], [ 1, %1 ]
%5 = tail call i64 @PlayersAlive(i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = tail call i64 @PlayersAlive(i32 2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @runARound(i32 %4)
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, %0
br i1 %13, label %19, label %3
14: ; preds = %7, %3
%15 = phi i8* [ getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), %7 ]
%16 = phi i32 [ 2, %3 ], [ 1, %7 ]
%17 = tail call i32 @printField(i32 %4)
%18 = tail call i32 @printf(i8* %15, i32 %4)
br label %19
19: ; preds = %10, %14, %1
%20 = phi i32 [ 0, %1 ], [ %16, %14 ], [ 0, %10 ]
ret i32 %20
}