#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*/ draw(char **);
int /*<<< orphan*/ move(int, char **);
int /*<<< orphan*/ printf(char *, ...);
int winner(char **);
int main(int argc, const char *argv[]) {
  int i, row, column;
  int player = 0;
  char board[3][3] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
  for (i = 0; i < 9 && winner(board) == '0'; i++) {
    player = i % 2 + 1;
    move(player, board);
  }
  if (winner(board) != '0') {
    draw(board);
    printf("%c Wins!!\n", winner(board));
  } else {
    draw(board);
    printf("Tie.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
mov    0xe9c(%rip),%rax
mov    %rax,-0x29(%rbp)
mov    0xe9a(%rip),%al
mov    %al,-0x21(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0x14(%rbp)
mov    %al,-0x2a(%rbp)
jge    1199 <main+0x59>
lea    -0x29(%rbp),%rdi
call   1050 <winner@plt>
cmp    $0x30,%eax
sete   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    11a9 <main+0x69>
jmp    11d4 <main+0x94>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x29(%rbp),%rsi
call   1060 <move@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <main+0x38>
lea    -0x29(%rbp),%rdi
call   1050 <winner@plt>
cmp    $0x30,%eax
je     120d <main+0xcd>
lea    -0x29(%rbp),%rdi
call   1030 <draw@plt>
lea    -0x29(%rbp),%rdi
call   1050 <winner@plt>
mov    %eax,%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1224 <main+0xe4>
lea    -0x29(%rbp),%rdi
call   1030 <draw@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    0xeac(%rip),%al
mov    %al,0x10(%rsp)
mov    0xe99(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x2,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x2,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x2,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rbx
mov    $0x2,%edi
mov    %rbx,%rsi
call   1070 <move@plt>
mov    %rbx,%rdi
call   1060 <winner@plt>
cmp    $0x30,%eax
jne    1296 <main+0x146>
lea    0x8(%rsp),%rsi
mov    $0x1,%edi
call   1070 <move@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <winner@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <draw@plt>
cmp    $0x30,%ebp
jne    12c0 <main+0x170>
lea    0xd5b(%rip),%rdi
call   1030 <puts@plt>
jmp    12da <main+0x18a>
lea    0x8(%rsp),%rdi
call   1060 <winner@plt>
lea    0xd38(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.board = [3 x [3 x i8]] [[3 x i8] c"123", [3 x i8] c"456", [3 x i8] c"789"]
@.str = [11 x i8] c"%c Wins!!\0A\00"
@.str.1 = [6 x i8] c"Tie.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [3 x [3 x i8]]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%11 = bitcast [3 x [3 x i8]]* %10 to i8*
store i32 0, i32* %6
br label %12
12: ; preds = %30, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 9
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %10, i64 0, i64 0
%17 = bitcast [3 x i8]* %16 to i8**
%18 = call i32 @winner(i8** %17)
%19 = icmp eq i32 %18, 48
br label %20
20: ; preds = %15, %12
%21 = phi i1 [ false, %12 ], [ %19, %15 ]
br i1 %21, label %22, label %33
22: ; preds = %20
%23 = load i32, i32* %6
%24 = srem i32 %23, 2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %10, i64 0, i64 0
%28 = bitcast [3 x i8]* %27 to i8**
%29 = call i32 @move(i32 %26, i8** %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %12
33: ; preds = %20
%34 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %10, i64 0, i64 0
%35 = bitcast [3 x i8]* %34 to i8**
%36 = call i32 @winner(i8** %35)
%37 = icmp ne i32 %36, 48
br i1 %37, label %38, label %46
38: ; preds = %33
%39 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %10, i64 0, i64 0
%40 = bitcast [3 x i8]* %39 to i8**
%41 = call i32 @draw(i8** %40)
%42 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %10, i64 0, i64 0
%43 = bitcast [3 x i8]* %42 to i8**
%44 = call i32 @winner(i8** %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %44)
br label %51
46: ; preds = %33
%47 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %10, i64 0, i64 0
%48 = bitcast [3 x i8]* %47 to i8**
%49 = call i32 @draw(i8** %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %46, %38
ret i32 0
}

LLVM IR (-O2):
@__const.main.board = [3 x [3 x i8]] [[3 x i8] c"123", [3 x i8] c"456", [3 x i8] c"789"]
@.str = [11 x i8] c"%c Wins!!\0A\00"
@str = [5 x i8] c"Tie.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x [3 x i8]]
%4 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %3, i64 0, i64 0, i64 0
%5 = bitcast [3 x [3 x i8]]* %3 to i8**
%6 = call i32 @winner(i8** %5)
%7 = icmp eq i32 %6, 48
br i1 %7, label %8, label %42
8: ; preds = %2
%9 = call i32 @move(i32 1, i8** %5)
%10 = call i32 @winner(i8** %5)
%11 = icmp eq i32 %10, 48
br i1 %11, label %12, label %42
12: ; preds = %8
%13 = call i32 @move(i32 2, i8** %5)
%14 = call i32 @winner(i8** %5)
%15 = icmp eq i32 %14, 48
br i1 %15, label %16, label %42
16: ; preds = %12
%17 = call i32 @move(i32 1, i8** %5)
%18 = call i32 @winner(i8** %5)
%19 = icmp eq i32 %18, 48
br i1 %19, label %20, label %42
20: ; preds = %16
%21 = call i32 @move(i32 2, i8** %5)
%22 = call i32 @winner(i8** %5)
%23 = icmp eq i32 %22, 48
br i1 %23, label %24, label %42
24: ; preds = %20
%25 = call i32 @move(i32 1, i8** %5)
%26 = call i32 @winner(i8** %5)
%27 = icmp eq i32 %26, 48
br i1 %27, label %28, label %42
28: ; preds = %24
%29 = call i32 @move(i32 2, i8** %5)
%30 = call i32 @winner(i8** %5)
%31 = icmp eq i32 %30, 48
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = call i32 @move(i32 1, i8** %5)
%34 = call i32 @winner(i8** %5)
%35 = icmp eq i32 %34, 48
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = call i32 @move(i32 2, i8** %5)
%38 = call i32 @winner(i8** %5)
%39 = icmp eq i32 %38, 48
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @move(i32 1, i8** %5)
br label %42
42: ; preds = %40, %36, %32, %28, %24, %20, %16, %12, %8, %2
%43 = call i32 @winner(i8** %5)
%44 = icmp eq i32 %43, 48
%45 = call i32 @draw(i8** %5)
br i1 %44, label %49, label %46
46: ; preds = %42
%47 = call i32 @winner(i8** %5)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %47)
br label %51
49: ; preds = %42
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
ret i32 0
}