#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*/ computerMove(int *);
int /*<<< orphan*/ draw(int *);
int /*<<< orphan*/ playerMove(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int win(int *);
int main() {
  int board[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  printf("Computer: O, You: X\nPlay (1)st or (2)nd? ");
  int player = 0;
  scanf("%d", &player);
  printf("\n");
  unsigned turn;
  for (turn = 0; turn < 9 && win(board) == 0; ++turn) {
    if ((turn + player) % 2 == 0)
      computerMove(board);
    else {
      draw(board);
      playerMove(board);
    }
  }
  switch (win(board)) {
  case 0:
    printf("A draw. How droll.\n");
    break;
  case 1:
    draw(board);
    printf("You lose.\n");
    break;
  case -1:
    printf("You win. Inconceivable!\n");
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1050 <memset@plt>
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x34(%rbp)
lea    0xe81(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0x38(%rbp)
mov    %al,-0x39(%rbp)
jae    11e6 <main+0x76>
lea    -0x30(%rbp),%rdi
call   1060 <win@plt>
cmp    $0x0,%eax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11f6 <main+0x86>
jmp    123b <main+0xcb>
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1216 <main+0xa6>
lea    -0x30(%rbp),%rdi
call   1070 <computerMove@plt>
jmp    1228 <main+0xb8>
lea    -0x30(%rbp),%rdi
call   1030 <draw@plt>
lea    -0x30(%rbp),%rdi
call   1090 <playerMove@plt>
jmp    122d <main+0xbd>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11c5 <main+0x55>
lea    -0x30(%rbp),%rdi
call   1060 <win@plt>
mov    %eax,%ecx
mov    %ecx,-0x40(%rbp)
sub    $0xffffffff,%eax
je     12a3 <main+0x133>
jmp    1257 <main+0xe7>
mov    -0x40(%rbp),%eax
test   %eax,%eax
je     1278 <main+0x108>
jmp    1267 <main+0xf7>
mov    -0x40(%rbp),%eax
sub    $0x1,%eax
je     1289 <main+0x119>
jmp    12af <main+0x13f>
lea    0xdae(%rip),%rdi
call   1040 <printf@plt>
jmp    12af <main+0x13f>
lea    -0x30(%rbp),%rdi
call   1030 <draw@plt>
lea    0xda8(%rip),%rdi
call   1040 <printf@plt>
jmp    12af <main+0x13f>
lea    0xda2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x30(%rsp)
lea    0xe5e(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,0xc(%rsp)
lea    0xe74(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1090 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
lea    0x10(%rsp),%rbx
jmp    11f5 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1050 <draw@plt>
mov    %rbx,%rdi
call   10a0 <playerMove@plt>
add    $0x1,%ebp
cmp    $0x9,%ebp
je     1215 <main+0x95>
mov    %rbx,%rdi
call   1070 <win@plt>
test   %eax,%eax
jne    1215 <main+0x95>
mov    0xc(%rsp),%eax
add    %ebp,%eax
mov    %rbx,%rdi
test   $0x1,%al
jne    11e0 <main+0x60>
call   1080 <computerMove@plt>
jmp    11ed <main+0x6d>
lea    0x10(%rsp),%rdi
call   1070 <win@plt>
cmp    $0xffffffff,%eax
je     1240 <main+0xc0>
test   %eax,%eax
je     1249 <main+0xc9>
cmp    $0x1,%eax
jne    1255 <main+0xd5>
lea    0x10(%rsp),%rdi
call   1050 <draw@plt>
lea    0xe07(%rip),%rdi
jmp    1250 <main+0xd0>
lea    0xde6(%rip),%rdi
jmp    1250 <main+0xd0>
lea    0xdff(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Computer: O, You: X\0APlay (1)st or (2)nd? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [20 x i8] c"A draw. How droll.\0A\00"
@.str.4 = [11 x i8] c"You lose.\0A\00"
@.str.5 = [25 x i8] c"You win. Inconceivable!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [9 x i32]* %2 to i8*
%6 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %9
9: ; preds = %33, %0
%10 = load i32, i32* %4
%11 = icmp ult i32 %10, 9
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%14 = call i32 @win(i32* %13)
%15 = icmp eq i32 %14, 0
br label %16
16: ; preds = %12, %9
%17 = phi i1 [ false, %9 ], [ %15, %12 ]
br i1 %17, label %18, label %36
18: ; preds = %16
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = add i32 %19, %20
%22 = urem i32 %21, 2
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%26 = call i32 @computerMove(i32* %25)
br label %32
27: ; preds = %18
%28 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%29 = call i32 @draw(i32* %28)
%30 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%31 = call i32 @playerMove(i32* %30)
br label %32
32: ; preds = %27, %24
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add i32 %34, 1
store i32 %35, i32* %4
br label %9
36: ; preds = %16
%37 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%38 = call i32 @win(i32* %37)
switch i32 %38, label %47 [
i32 0, label %39
i32 1, label %41
i32 -1, label %45
]
39: ; preds = %36
%40 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %47
41: ; preds = %36
%42 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%43 = call i32 @draw(i32* %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %47
45: ; preds = %36
%46 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %47
47: ; preds = %36, %45, %41, %39
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [42 x i8] c"Computer: O, You: X\0APlay (1)st or (2)nd? \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [24 x i8] c"You win. Inconceivable!\00"
@str.6 = [10 x i8] c"You lose.\00"
@str.7 = [19 x i8] c"A draw. How droll.\00"
define i32 @main() {
%1 = alloca [9 x i32]
%2 = alloca i32
%3 = bitcast [9 x i32]* %1 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 @putchar(i32 10)
%8 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
br label %9
9: ; preds = %0, %23
%10 = phi i32 [ 0, %0 ], [ %24, %23 ]
%11 = call i32 @win(i32* %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add i32 %14, %10
%16 = and i32 %15, 1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @computerMove(i32* %8)
br label %23
20: ; preds = %13
%21 = call i32 @draw(i32* %8)
%22 = call i32 @playerMove(i32* %8)
br label %23
23: ; preds = %18, %20
%24 = add nuw nsw i32 %10, 1
%25 = icmp eq i32 %24, 9
br i1 %25, label %26, label %9
26: ; preds = %23, %9
%27 = call i32 @win(i32* %8)
switch i32 %27, label %34 [
i32 0, label %31
i32 1, label %28
i32 -1, label %30
]
28: ; preds = %26
%29 = call i32 @draw(i32* %8)
br label %31
30: ; preds = %26
br label %31
31: ; preds = %26, %28, %30
%32 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0), %30 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.6, i64 0, i64 0), %28 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0), %26 ]
%33 = call i32 @puts(i8* dereferenceable(1) %32)
br label %34
34: ; preds = %31, %26
ret i32 0
}