int main() {
  char board[9];
  char win_msg[3][20] = {"Player O wins!\n\n", "Game is a draw!\n\n",
                         "Player X wins!\n\n"};
  memset(board, 0, 9);
  int side = 1, pos;
  while (!game_over(board)) {
    print_board(board);
    printf("Enter move: ");
    scanf("%d", &pos);
    board[pos] = side;
    if (game_over(board))
      break;
    int move = get_move(board, -side);
    board[move] = -side;
  }
  print_board(board);
  printf("%s", win_msg[analyze_board(board, 1) + 1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe66(%rip),%rsi
mov    $0x3c,%edx
call   1080 <memcpy@plt>
lea    -0xd(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1070 <memset@plt>
movl   $0x1,-0x54(%rbp)
lea    -0xd(%rbp),%rdi
mov    $0x0,%al
call   10a0 <game_over@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11db <main+0x5b>
jmp    1253 <main+0xd3>
lea    -0xd(%rbp),%rdi
mov    $0x0,%al
call   1060 <print_board@plt>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4e(%rip),%rdi
lea    -0x58(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
mov    -0x54(%rbp),%eax
mov    %al,%cl
movslq -0x58(%rbp),%rax
mov    %cl,-0xd(%rbp,%rax,1)
lea    -0xd(%rbp),%rdi
mov    $0x0,%al
call   10a0 <game_over@plt>
cmp    $0x0,%eax
je     122c <main+0xac>
jmp    1253 <main+0xd3>
lea    -0xd(%rbp),%rdi
xor    %esi,%esi
sub    -0x54(%rbp),%esi
mov    $0x0,%al
call   1030 <get_move@plt>
mov    %eax,-0x5c(%rbp)
xor    %eax,%eax
sub    -0x54(%rbp),%eax
mov    %al,%cl
movslq -0x5c(%rbp),%rax
mov    %cl,-0xd(%rbp,%rax,1)
jmp    11bb <main+0x3b>
lea    -0xd(%rbp),%rdi
mov    $0x0,%al
call   1060 <print_board@plt>
lea    -0xd(%rbp),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <analyze_board@plt>
add    $0x1,%eax
cltq
lea    -0x50(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
movups 0xeba(%rip),%xmm0
movups %xmm0,0x3c(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe86(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe6a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,(%rsp)
movb   $0x0,0x8(%rsp)
mov    %rsp,%rdi
xor    %eax,%eax
call   1080 <game_over@plt>
test   %eax,%eax
jne    122b <main+0xcb>
mov    %rsp,%rbx
lea    0xe7c(%rip),%r14
lea    0xe82(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <print_board@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movslq 0xc(%rsp),%rax
movb   $0x1,(%rsp,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <game_over@plt>
test   %eax,%eax
jne    122b <main+0xcb>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1030 <get_move@plt>
cltq
movb   $0xff,(%rsp,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <game_over@plt>
test   %eax,%eax
je     11d0 <main+0x70>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <print_board@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <analyze_board@plt>
add    $0x1,%eax
cltq
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.win_msg = [3 x [20 x i8]] [[20 x i8] c"Player O wins!\0A\0A\00\00\00\00", [20 x i8] c"Game is a draw!\0A\0A\00\00\00", [20 x i8] c"Player X wins!\0A\0A\00\00\00\00"]
@.str = [13 x i8] c"Enter move: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i8]
%3 = alloca [3 x [20 x i8]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [3 x [20 x i8]]* %3 to i8*
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
store i32 1, i32* %4
br label %9
9: ; preds = %28, %0
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @game_over to i32 (i8*, ...)*)(i8* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %39
14: ; preds = %9
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @print_board to i32 (i8*, ...)*)(i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %4
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 %22
store i8 %20, i8* %23
%24 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @game_over to i32 (i8*, ...)*)(i8* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %14
br label %39
28: ; preds = %14
%29 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%30 = load i32, i32* %4
%31 = sub nsw i32 0, %30
%32 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @get_move to i32 (i8*, i32, ...)*)(i8* %29, i32 %31)
store i32 %32, i32* %6
%33 = load i32, i32* %4
%34 = sub nsw i32 0, %33
%35 = trunc i32 %34 to i8
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 %37
store i8 %35, i8* %38
br label %9
39: ; preds = %27, %9
%40 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%41 = call i32 (i8*, ...) bitcast (i32 (...)* @print_board to i32 (i8*, ...)*)(i8* %40)
%42 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%43 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @analyze_board to i32 (i8*, i32, ...)*)(i8* %42, i32 1)
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [3 x [20 x i8]], [3 x [20 x i8]]* %3, i64 0, i64 %45
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %46, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %47)
ret i32 0
}

LLVM IR (-O2):
@__const.main.win_msg = [3 x [20 x i8]] [[20 x i8] c"Player O wins!\0A\0A\00\00\00\00", [20 x i8] c"Game is a draw!\0A\0A\00\00\00", [20 x i8] c"Player X wins!\0A\0A\00\00\00\00"]
@.str = [13 x i8] c"Enter move: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = alloca [3 x [20 x i8]]
%3 = alloca i32
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [3 x [20 x i8]], [3 x [20 x i8]]* %2, i64 0, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @game_over to i32 (i8*, ...)*)(i8* %4)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %0, %18
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @print_board to i32 (i8*, ...)*)(i8* %4)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 %14
store i8 1, i8* %15
%16 = call i32 (i8*, ...) bitcast (i32 (...)* @game_over to i32 (i8*, ...)*)(i8* %4)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %9
%19 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @get_move to i32 (i8*, i32, ...)*)(i8* %4, i32 -1)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 %20
store i8 -1, i8* %21
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @game_over to i32 (i8*, ...)*)(i8* %4)
%23 = icmp eq i32 %22, 0
br i1 %23, label %9, label %24
24: ; preds = %18, %9, %0
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @print_board to i32 (i8*, ...)*)(i8* %4)
%26 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @analyze_board to i32 (i8*, i32, ...)*)(i8* %4, i32 1)
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [3 x [20 x i8]], [3 x [20 x i8]]* %2, i64 0, i64 %28, i64 0
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %29)
ret i32 0
}