#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 checkColumn(int);
int checkDiagon();
int checkRow(int);
int gameState() {
  int state = checkDiagon();
  if (state != 0)
    return state;
  for (int i = 0; i < 3; i++) {
    state = checkColumn(i);
    if (state != 0)
      return state;
    state = checkRow(i);
    if (state != 0)
      return state;
  }
  return 0;
}


x86 assembly (clang, -O0):
<gameState>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <checkDiagon@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1157 <gameState+0x27>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <gameState+0x92>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11bb <gameState+0x8b>
mov    -0xc(%rbp),%edi
call   1030 <checkColumn@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1188 <gameState+0x58>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <gameState+0x92>
mov    -0xc(%rbp),%edi
call   1050 <checkRow@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11a8 <gameState+0x78>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <gameState+0x92>
jmp    11ad <gameState+0x7d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115e <gameState+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gameState>:
push   %rax
xor    %eax,%eax
call   1040 <checkDiagon@plt>
test   %eax,%eax
jne    117c <gameState+0x4c>
xor    %edi,%edi
call   1030 <checkColumn@plt>
test   %eax,%eax
jne    117c <gameState+0x4c>
xor    %edi,%edi
call   1050 <checkRow@plt>
test   %eax,%eax
jne    117c <gameState+0x4c>
mov    $0x1,%edi
call   1030 <checkColumn@plt>
test   %eax,%eax
jne    117c <gameState+0x4c>
mov    $0x1,%edi
call   1050 <checkRow@plt>
test   %eax,%eax
jne    117c <gameState+0x4c>
mov    $0x2,%edi
call   1030 <checkColumn@plt>
test   %eax,%eax
je     117e <gameState+0x4e>
pop    %rcx
ret
mov    $0x2,%edi
pop    %rax
jmp    1050 <checkRow@plt>

LLVM IR (-O0):
define i32 @gameState() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @checkDiagon()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = load i32, i32* %2
store i32 %8, i32* %1
br label %32
9: ; preds = %0
store i32 0, i32* %3
br label %10
10: ; preds = %28, %9
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %31
13: ; preds = %10
%14 = load i32, i32* %3
%15 = call i32 @checkColumn(i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i32, i32* %2
store i32 %19, i32* %1
br label %32
20: ; preds = %13
%21 = load i32, i32* %3
%22 = call i32 @checkRow(i32 %21)
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = load i32, i32* %2
store i32 %26, i32* %1
br label %32
27: ; preds = %20
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %10
31: ; preds = %10
store i32 0, i32* %1
br label %32
32: ; preds = %31, %25, %18, %7
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
define i32 @gameState() {
%1 = tail call i32 (...) @checkDiagon()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %20
3: ; preds = %0
%4 = tail call i32 @checkColumn(i32 0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %17, label %20
6: ; preds = %17
%7 = tail call i32 @checkColumn(i32 1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = tail call i32 @checkRow(i32 1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = tail call i32 @checkColumn(i32 2)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = tail call i32 @checkRow(i32 2)
br label %20
17: ; preds = %3
%18 = tail call i32 @checkRow(i32 0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %6, label %20
20: ; preds = %15, %17, %3, %6, %9, %12, %0
%21 = phi i32 [ %1, %0 ], [ %18, %17 ], [ %4, %3 ], [ %7, %6 ], [ %10, %9 ], [ %13, %12 ], [ %16, %15 ]
ret i32 %21
}