#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*/ getscores(int **, int *, int *);
int nextturn(int **, int);
int won(int board[8][8]) {
  int red, green;
  getscores(board, &red, &green);
  if ((nextturn(board, 0) == 0) && (nextturn(board, 1) == 1)) {
    if (red > green)
      return 0;
    else
      return 1;
  }
  return 2;
}


x86 assembly (clang, -O0):
<won>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <getscores@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <nextturn@plt>
cmp    $0x0,%eax
jne    118c <won+0x6c>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <nextturn@plt>
cmp    $0x1,%eax
jne    118c <won+0x6c>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    1180 <won+0x60>
movl   $0x0,-0x4(%rbp)
jmp    1193 <won+0x73>
movl   $0x1,-0x4(%rbp)
jmp    1193 <won+0x73>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<won>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <getscores@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nextturn@plt>
mov    $0x2,%ebp
test   %eax,%eax
jne    1165 <won+0x45>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <nextturn@plt>
cmp    $0x1,%eax
jne    1165 <won+0x45>
mov    0x4(%rsp),%eax
xor    %ebp,%ebp
cmp    (%rsp),%eax
setle  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @won([8 x i32]* %0) {
%2 = alloca i32
%3 = alloca [8 x i32]*
%4 = alloca i32
%5 = alloca i32
store [8 x i32]* %0, [8 x i32]** %3
%6 = load [8 x i32]*, [8 x i32]** %3
%7 = bitcast [8 x i32]* %6 to i32**
%8 = call i32 @getscores(i32** %7, i32* %4, i32* %5)
%9 = load [8 x i32]*, [8 x i32]** %3
%10 = bitcast [8 x i32]* %9 to i32**
%11 = call i32 @nextturn(i32** %10, i32 0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %1
%14 = load [8 x i32]*, [8 x i32]** %3
%15 = bitcast [8 x i32]* %14 to i32**
%16 = call i32 @nextturn(i32** %15, i32 1)
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 0, i32* %2
br label %25
23: ; preds = %18
store i32 1, i32* %2
br label %25
24: ; preds = %13, %1
store i32 2, i32* %2
br label %25
25: ; preds = %24, %23, %22
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @won([8 x i32]* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = bitcast [8 x i32]* %0 to i32**
%7 = call i32 @getscores(i32** %6, i32* %2, i32* %3)
%8 = call i32 @nextturn(i32** %6, i32 0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %1
%11 = call i32 @nextturn(i32** %6, i32 1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = icmp sle i32 %14, %15
%17 = zext i1 %16 to i32
br label %18
18: ; preds = %1, %10, %13
%19 = phi i32 [ %17, %13 ], [ 2, %10 ], [ 2, %1 ]
ret i32 %19
}