#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*/ *fgets(char *, int, int /*<<< orphan*/);
scalar_t__ malloc(int);
int playerDidWin(int, int **, int *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, int, int, int, int);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  int bufferSize = 256;
  char buffer[bufferSize];
  char *lines = (char *)malloc(1);
  int lineCount = 0;
  while (fgets(buffer, bufferSize, stdin) != NULL) {
    if (*(buffer + strlen(buffer) - 1) == '\n') {
      *(buffer + strlen(buffer) - 1) = '\0';
    }
    lineCount++;
    lines = (char *)realloc(lines, bufferSize * lineCount * sizeof(char));
    strcpy(lines + (lineCount - 1) * bufferSize, buffer);
  }
  int board[6][7];
  int columnHeights[7] = {};
  int winningMoves[8] = {};
  int movesX[lineCount];
  int movesO[lineCount];
  int i, j;
  for (i = 0; i < 6; i++) {
    for (j = 0; j < 7; j++) {
      board[i][j] = 0;
    }
  }
  for (i = 0; i < lineCount; i++) {
    int xmove = *(lines + bufferSize * i) - 'A';
    movesX[i] = xmove;
    int h = columnHeights[xmove];
    board[h][xmove] = 1;
    columnHeights[xmove]++;
    int Xwon = playerDidWin(1, board, winningMoves);
    if (Xwon) {
      printf("X won at move %d (with %c%d %c%d %c%d %c%d)\n", i + 1,
             winningMoves[1] + 'A', winningMoves[0] + 1, winningMoves[3] + 'A',
             winningMoves[2] + 1, winningMoves[5] + 'A', winningMoves[4] + 1,
             winningMoves[7] + 'A', winningMoves[6] + 1);
      return 0;
    }
    int omove = *(lines + bufferSize * i + 3) - 'a';
    movesO[i] = omove;
    h = columnHeights[omove];
    board[h][omove] = 2;
    columnHeights[omove]++;
    int Owon = playerDidWin(2, board, winningMoves);
    if (Owon) {
      printf("O won at move %d (with %c%d %c%d %c%d %c%d)\n", i + 1,
             winningMoves[1] + 'a', winningMoves[0] + 1, winningMoves[3] + 'a',
             winningMoves[2] + 1, winningMoves[5] + 'a', winningMoves[4] + 1,
             winningMoves[7] + 'a', winningMoves[6] + 1);
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x178,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x100,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x168(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x168(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2e08(%rip),%rax
mov    (%rax),%edx
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     127d <main+0x10d>
mov    -0x168(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x168(%rbp),%rax
movslq %ecx,%rcx
movsbl -0x1(%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1234 <main+0xc4>
mov    -0x168(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x168(%rbp),%rax
movslq %ecx,%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%eax
imul   -0x3c(%rbp),%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1090 <realloc@plt>
mov    -0x168(%rbp),%rsi
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
imul   -0x1c(%rbp),%eax
cltq
add    %rax,%rdi
call   1040 <strcpy@plt>
jmp    11cf <main+0x5f>
xorps  %xmm0,%xmm0
movups %xmm0,-0x104(%rbp)
movaps %xmm0,-0x110(%rbp)
movaps %xmm0,-0x120(%rbp)
movaps %xmm0,-0x130(%rbp)
mov    -0x3c(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x178(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x138(%rbp)
mov    -0x3c(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x170(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x140(%rbp)
movl   $0x0,-0x144(%rbp)
cmpl   $0x6,-0x144(%rbp)
jge    1366 <main+0x1f6>
movl   $0x0,-0x148(%rbp)
cmpl   $0x7,-0x148(%rbp)
jge    134d <main+0x1dd>
movslq -0x144(%rbp),%rcx
lea    -0xf0(%rbp),%rax
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
movslq -0x148(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x148(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x148(%rbp)
jmp    1309 <main+0x199>
jmp    1352 <main+0x1e2>
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
jmp    12f2 <main+0x182>
movl   $0x0,-0x144(%rbp)
mov    -0x144(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    161f <main+0x4af>
mov    -0x178(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    -0x1c(%rbp),%edx
imul   -0x144(%rbp),%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x41,%ecx
mov    %ecx,-0x14c(%rbp)
mov    -0x14c(%rbp),%edx
movslq -0x144(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x14c(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%eax
mov    %eax,-0x150(%rbp)
movslq -0x150(%rbp),%rcx
lea    -0xf0(%rbp),%rax
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
movslq -0x14c(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
movslq -0x14c(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x110(%rbp,%rax,4)
lea    -0xf0(%rbp),%rsi
lea    -0x130(%rbp),%rdx
mov    $0x1,%edi
call   1030 <playerDidWin@plt>
mov    %eax,-0x154(%rbp)
cmpl   $0x0,-0x154(%rbp)
je     14c2 <main+0x352>
mov    -0x144(%rbp),%esi
add    $0x1,%esi
mov    -0x12c(%rbp),%edx
add    $0x41,%edx
mov    -0x130(%rbp),%ecx
add    $0x1,%ecx
mov    -0x124(%rbp),%r8d
add    $0x41,%r8d
mov    -0x128(%rbp),%r9d
add    $0x1,%r9d
mov    -0x11c(%rbp),%ebx
add    $0x41,%ebx
mov    -0x120(%rbp),%r11d
add    $0x1,%r11d
mov    -0x114(%rbp),%r10d
add    $0x41,%r10d
mov    -0x118(%rbp),%eax
add    $0x1,%eax
lea    0xb72(%rip),%rdi
sub    $0x20,%rsp
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1060 <printf@plt>
add    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x158(%rbp)
jmp    1630 <main+0x4c0>
mov    -0x170(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    -0x1c(%rbp),%edx
imul   -0x144(%rbp),%edx
movslq %edx,%rdx
movsbl 0x3(%rcx,%rdx,1),%ecx
sub    $0x61,%ecx
mov    %ecx,-0x15c(%rbp)
mov    -0x15c(%rbp),%edx
movslq -0x144(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x15c(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%eax
mov    %eax,-0x150(%rbp)
movslq -0x150(%rbp),%rcx
lea    -0xf0(%rbp),%rax
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
movslq -0x15c(%rbp),%rcx
movl   $0x2,(%rax,%rcx,4)
movslq -0x15c(%rbp),%rax
mov    -0x110(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x110(%rbp,%rax,4)
lea    -0xf0(%rbp),%rsi
lea    -0x130(%rbp),%rdx
mov    $0x2,%edi
call   1030 <playerDidWin@plt>
mov    %eax,-0x160(%rbp)
cmpl   $0x0,-0x160(%rbp)
je     1606 <main+0x496>
mov    -0x144(%rbp),%esi
add    $0x1,%esi
mov    -0x12c(%rbp),%edx
add    $0x61,%edx
mov    -0x130(%rbp),%ecx
add    $0x1,%ecx
mov    -0x124(%rbp),%r8d
add    $0x61,%r8d
mov    -0x128(%rbp),%r9d
add    $0x1,%r9d
mov    -0x11c(%rbp),%ebx
add    $0x61,%ebx
mov    -0x120(%rbp),%r11d
add    $0x1,%r11d
mov    -0x114(%rbp),%r10d
add    $0x61,%r10d
mov    -0x118(%rbp),%eax
add    $0x1,%eax
lea    0xa5b(%rip),%rdi
sub    $0x20,%rsp
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1060 <printf@plt>
add    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x158(%rbp)
jmp    1630 <main+0x4c0>
jmp    160b <main+0x49b>
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
jmp    1370 <main+0x200>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x158(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0xc(%rbp),%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f8,%rsp
mov    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    0x2e53(%rip),%r13
mov    0x0(%r13),%edx
lea    0xf0(%rsp),%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     122d <main+0xbd>
lea    0xf0(%rsp),%r14
xor    %ebp,%ebp
jmp    1205 <main+0x95>
nop
lea    0x100(%rbp),%rbx
mov    %r12,%rdi
mov    %ebx,%esi
call   1090 <realloc@plt>
mov    %rax,%r12
and    $0xffffff00,%ebp
add    %rax,%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
add    $0x1,%r15d
mov    %rbx,%rbp
test   %rax,%rax
je     122d <main+0xbd>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,0xef(%rsp,%rax,1)
0a
jne    11c0 <main+0x50>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,0xef(%rsp,%rax,1)
jmp    11c0 <main+0x50>
xorps  %xmm0,%xmm0
movups %xmm0,0x2c(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xd0(%rsp)
movq   $0x0,0xe0(%rsp)
test   %r15d,%r15d
je     1408 <main+0x298>
mov    %r15d,%r13d
shl    $0x8,%r13
mov    $0x1,%ebp
xor    %ebx,%ebx
lea    0x40(%rsp),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbq (%r12,%rbx,1),%rax
movslq -0xe4(%rsp,%rax,4),%rcx
ff
lea    (%rcx,%rcx,8),%rdx
lea    (%rdx,%rdx,2),%rdx
add    %rcx,%rdx
add    %rsp,%rdx
add    $0x40,%rdx
movl   $0x1,-0x104(%rdx,%rax,4)
add    $0x1,%ecx
mov    %ecx,-0xe4(%rsp,%rax,4)
mov    $0x1,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <playerDidWin@plt>
test   %eax,%eax
jne    1369 <main+0x1f9>
movsbq 0x3(%r12,%rbx,1),%rax
movslq -0x164(%rsp,%rax,4),%rcx
ff
lea    (%rcx,%rcx,8),%rdx
lea    (%rdx,%rdx,2),%rdx
add    %rcx,%rdx
add    %rsp,%rdx
add    $0x40,%rdx
movl   $0x2,-0x184(%rdx,%rax,4)
add    $0x1,%ecx
mov    %ecx,-0x164(%rsp,%rax,4)
mov    $0x2,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <playerDidWin@plt>
test   %eax,%eax
jne    13b1 <main+0x241>
add    $0x1,%ebp
add    $0x100,%rbx
cmp    %rbx,%r13
jne    12c0 <main+0x150>
jmp    1408 <main+0x298>
mov    (%rsp),%ecx
mov    0x4(%rsp),%edx
add    $0x41,%edx
add    $0x1,%ecx
mov    0xc(%rsp),%r8d
add    $0x41,%r8d
mov    0x8(%rsp),%r9d
add    $0x1,%r9d
mov    0x14(%rsp),%r10d
add    $0x41,%r10d
mov    0x10(%rsp),%r11d
add    $0x1,%r11d
mov    0x1c(%rsp),%eax
add    $0x41,%eax
mov    0x18(%rsp),%ebx
add    $0x1,%ebx
lea    0xc51(%rip),%rdi
jmp    13f7 <main+0x287>
mov    (%rsp),%ecx
mov    0x4(%rsp),%edx
add    $0x61,%edx
add    $0x1,%ecx
mov    0xc(%rsp),%r8d
add    $0x61,%r8d
mov    0x8(%rsp),%r9d
add    $0x1,%r9d
mov    0x14(%rsp),%r10d
add    $0x61,%r10d
mov    0x10(%rsp),%r11d
add    $0x1,%r11d
mov    0x1c(%rsp),%eax
add    $0x61,%eax
mov    0x18(%rsp),%ebx
add    $0x1,%ebx
lea    0xc36(%rip),%rdi
mov    %ebp,%esi
push   %rbx
push   %rax
push   %r11
push   %r10
call   1060 <printf@plt>
add    $0x20,%rsp
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [45 x i8] c"X won at move %d (with %c%d %c%d %c%d %c%d)\0A\00"
@.str.1 = [45 x i8] c"O won at move %d (with %c%d %c%d %c%d %c%d)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [6 x [7 x i32]]
%12 = alloca [7 x i32]
%13 = alloca [8 x i32]
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 256, i32* %6
%24 = load i32, i32* %6
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %7
%27 = alloca i8, i64 %25
store i64 %25, i64* %8
%28 = call i64 @malloc(i32 1)
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %9
store i32 0, i32* %10
br label %30
30: ; preds = %48, %2
%31 = load i32, i32* %6
%32 = load i32, i32* @stdin
%33 = call i32* @fgets(i8* %27, i32 %31, i32 %32)
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %68
35: ; preds = %30
%36 = call i32 @strlen(i8* %27)
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %27, i64 %37
%39 = getelementptr inbounds i8, i8* %38, i64 -1
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 10
br i1 %42, label %43, label %48
43: ; preds = %35
%44 = call i32 @strlen(i8* %27)
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %27, i64 %45
%47 = getelementptr inbounds i8, i8* %46, i64 -1
store i8 0, i8* %47
br label %48
48: ; preds = %43, %35
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
%51 = load i8*, i8** %9
%52 = load i32, i32* %6
%53 = load i32, i32* %10
%54 = mul nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = mul i64 %55, 1
%57 = trunc i64 %56 to i32
%58 = call i64 @realloc(i8* %51, i32 %57)
%59 = inttoptr i64 %58 to i8*
store i8* %59, i8** %9
%60 = load i8*, i8** %9
%61 = load i32, i32* %10
%62 = sub nsw i32 %61, 1
%63 = load i32, i32* %6
%64 = mul nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %60, i64 %65
%67 = call i32 @strcpy(i8* %66, i8* %27)
br label %30
68: ; preds = %30
%69 = bitcast [7 x i32]* %12 to i8*
%70 = bitcast [8 x i32]* %13 to i8*
%71 = load i32, i32* %10
%72 = zext i32 %71 to i64
%73 = alloca i32, i64 %72
store i64 %72, i64* %14
%74 = load i32, i32* %10
%75 = zext i32 %74 to i64
%76 = alloca i32, i64 %75
store i64 %75, i64* %15
store i32 0, i32* %16
br label %77
77: ; preds = %95, %68
%78 = load i32, i32* %16
%79 = icmp slt i32 %78, 6
br i1 %79, label %80, label %98
80: ; preds = %77
store i32 0, i32* %17
br label %81
81: ; preds = %91, %80
%82 = load i32, i32* %17
%83 = icmp slt i32 %82, 7
br i1 %83, label %84, label %94
84: ; preds = %81
%85 = load i32, i32* %16
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [6 x [7 x i32]], [6 x [7 x i32]]* %11, i64 0, i64 %86
%88 = load i32, i32* %17
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [7 x i32], [7 x i32]* %87, i64 0, i64 %89
store i32 0, i32* %90
br label %91
91: ; preds = %84
%92 = load i32, i32* %17
%93 = add nsw i32 %92, 1
store i32 %93, i32* %17
br label %81
94: ; preds = %81
br label %95
95: ; preds = %94
%96 = load i32, i32* %16
%97 = add nsw i32 %96, 1
store i32 %97, i32* %16
br label %77
98: ; preds = %77
store i32 0, i32* %16
br label %99
99: ; preds = %231, %98
%100 = load i32, i32* %16
%101 = load i32, i32* %10
%102 = icmp slt i32 %100, %101
br i1 %102, label %103, label %234
103: ; preds = %99
%104 = load i8*, i8** %9
%105 = load i32, i32* %6
%106 = load i32, i32* %16
%107 = mul nsw i32 %105, %106
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %104, i64 %108
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = sub nsw i32 %111, 65
store i32 %112, i32* %18
%113 = load i32, i32* %18
%114 = load i32, i32* %16
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32, i32* %73, i64 %115
store i32 %113, i32* %116
%117 = load i32, i32* %18
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [7 x i32], [7 x i32]* %12, i64 0, i64 %118
%120 = load i32, i32* %119
store i32 %120, i32* %19
%121 = load i32, i32* %19
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [6 x [7 x i32]], [6 x [7 x i32]]* %11, i64 0, i64 %122
%124 = load i32, i32* %18
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [7 x i32], [7 x i32]* %123, i64 0, i64 %125
store i32 1, i32* %126
%127 = load i32, i32* %18
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [7 x i32], [7 x i32]* %12, i64 0, i64 %128
%130 = load i32, i32* %129
%131 = add nsw i32 %130, 1
store i32 %131, i32* %129
%132 = getelementptr inbounds [6 x [7 x i32]], [6 x [7 x i32]]* %11, i64 0, i64 0
%133 = bitcast [7 x i32]* %132 to i32**
%134 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 0
%135 = call i32 @playerDidWin(i32 1, i32** %133, i32* %134)
store i32 %135, i32* %20
%136 = load i32, i32* %20
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %166
138: ; preds = %103
%139 = load i32, i32* %16
%140 = add nsw i32 %139, 1
%141 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 1
%142 = load i32, i32* %141
%143 = add nsw i32 %142, 65
%144 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 0
%145 = load i32, i32* %144
%146 = add nsw i32 %145, 1
%147 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 3
%148 = load i32, i32* %147
%149 = add nsw i32 %148, 65
%150 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 2
%151 = load i32, i32* %150
%152 = add nsw i32 %151, 1
%153 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 5
%154 = load i32, i32* %153
%155 = add nsw i32 %154, 65
%156 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 4
%157 = load i32, i32* %156
%158 = add nsw i32 %157, 1
%159 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 7
%160 = load i32, i32* %159
%161 = add nsw i32 %160, 65
%162 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 6
%163 = load i32, i32* %162
%164 = add nsw i32 %163, 1
%165 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %140, i32 %143, i32 %146, i32 %149, i32 %152, i32 %155, i32 %158, i32 %161, i32 %164)
store i32 0, i32* %3
store i32 1, i32* %21
br label %235
166: ; preds = %103
%167 = load i8*, i8** %9
%168 = load i32, i32* %6
%169 = load i32, i32* %16
%170 = mul nsw i32 %168, %169
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i8, i8* %167, i64 %171
%173 = getelementptr inbounds i8, i8* %172, i64 3
%174 = load i8, i8* %173
%175 = sext i8 %174 to i32
%176 = sub nsw i32 %175, 97
store i32 %176, i32* %22
%177 = load i32, i32* %22
%178 = load i32, i32* %16
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i32, i32* %76, i64 %179
store i32 %177, i32* %180
%181 = load i32, i32* %22
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds [7 x i32], [7 x i32]* %12, i64 0, i64 %182
%184 = load i32, i32* %183
store i32 %184, i32* %19
%185 = load i32, i32* %19
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds [6 x [7 x i32]], [6 x [7 x i32]]* %11, i64 0, i64 %186
%188 = load i32, i32* %22
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds [7 x i32], [7 x i32]* %187, i64 0, i64 %189
store i32 2, i32* %190
%191 = load i32, i32* %22
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds [7 x i32], [7 x i32]* %12, i64 0, i64 %192
%194 = load i32, i32* %193
%195 = add nsw i32 %194, 1
store i32 %195, i32* %193
%196 = getelementptr inbounds [6 x [7 x i32]], [6 x [7 x i32]]* %11, i64 0, i64 0
%197 = bitcast [7 x i32]* %196 to i32**
%198 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 0
%199 = call i32 @playerDidWin(i32 2, i32** %197, i32* %198)
store i32 %199, i32* %23
%200 = load i32, i32* %23
%201 = icmp ne i32 %200, 0
br i1 %201, label %202, label %230
202: ; preds = %166
%203 = load i32, i32* %16
%204 = add nsw i32 %203, 1
%205 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 1
%206 = load i32, i32* %205
%207 = add nsw i32 %206, 97
%208 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 0
%209 = load i32, i32* %208
%210 = add nsw i32 %209, 1
%211 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 3
%212 = load i32, i32* %211
%213 = add nsw i32 %212, 97
%214 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 2
%215 = load i32, i32* %214
%216 = add nsw i32 %215, 1
%217 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 5
%218 = load i32, i32* %217
%219 = add nsw i32 %218, 97
%220 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 4
%221 = load i32, i32* %220
%222 = add nsw i32 %221, 1
%223 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 7
%224 = load i32, i32* %223
%225 = add nsw i32 %224, 97
%226 = getelementptr inbounds [8 x i32], [8 x i32]* %13, i64 0, i64 6
%227 = load i32, i32* %226
%228 = add nsw i32 %227, 1
%229 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %204, i32 %207, i32 %210, i32 %213, i32 %216, i32 %219, i32 %222, i32 %225, i32 %228)
store i32 0, i32* %3
store i32 1, i32* %21
br label %235
230: ; preds = %166
br label %231
231: ; preds = %230
%232 = load i32, i32* %16
%233 = add nsw i32 %232, 1
store i32 %233, i32* %16
br label %99
234: ; preds = %99
store i32 0, i32* %3
store i32 1, i32* %21
br label %235
235: ; preds = %234, %202, %138
%236 = load i8*, i8** %7
%237 = load i32, i32* %3
ret i32 %237
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [45 x i8] c"X won at move %d (with %c%d %c%d %c%d %c%d)\0A\00"
@.str.1 = [45 x i8] c"O won at move %d (with %c%d %c%d %c%d %c%d)\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x [7 x i32]]
%4 = bitcast [6 x [7 x i32]]* %3 to i8*
%5 = alloca [7 x i32]
%6 = alloca [8 x i32]
%7 = alloca [256 x i8]
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%9 = tail call i64 @malloc(i32 1)
%10 = inttoptr i64 %9 to i8*
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %8, i32 256, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %44, label %14
14: ; preds = %2, %28
%15 = phi i64 [ %29, %28 ], [ 0, %2 ]
%16 = phi i8* [ %33, %28 ], [ %10, %2 ]
%17 = call i32 @strlen(i8* %8)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 -1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %28
23: ; preds = %14
%24 = call i32 @strlen(i8* %8)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 -1
store i8 0, i8* %27
br label %28
28: ; preds = %23, %14
%29 = add nuw i64 %15, 1
%30 = trunc i64 %29 to i32
%31 = shl nsw i32 %30, 8
%32 = call i64 @realloc(i8* %16, i32 %31)
%33 = inttoptr i64 %32 to i8*
%34 = shl i64 %15, 8
%35 = and i64 %34, 4294967040
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = call i32 @strcpy(i8* %36, i8* %8)
%38 = load i32, i32* @stdin
%39 = call i32* @fgets(i8* %8, i32 256, i32 %38)
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %14
41: ; preds = %28
%42 = trunc i64 %29 to i32
%43 = inttoptr i64 %32 to i8*
br label %44
44: ; preds = %41, %2
%45 = phi i32 [ 0, %2 ], [ %42, %41 ]
%46 = phi i8* [ %10, %2 ], [ %43, %41 ]
%47 = bitcast [7 x i32]* %5 to i8*
%48 = bitcast [8 x i32]* %6 to i8*
%49 = icmp eq i32 %45, 0
br i1 %49, label %137, label %50
50: ; preds = %44
%51 = bitcast [6 x [7 x i32]]* %3 to i32**
%52 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 0
%53 = zext i32 %45 to i64
br label %54
54: ; preds = %50, %134
%55 = phi i64 [ 0, %50 ], [ %135, %134 ]
%56 = shl nsw i64 %55, 8
%57 = getelementptr inbounds i8, i8* %46, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i64
%60 = add nsw i64 %59, -65
%61 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [6 x [7 x i32]], [6 x [7 x i32]]* %3, i64 0, i64 %63, i64 %60
store i32 1, i32* %64
%65 = add nsw i32 %62, 1
store i32 %65, i32* %61
%66 = call i32 @playerDidWin(i32 1, i32** %51, i32* %52)
%67 = icmp eq i32 %66, 0
br i1 %67, label %95, label %68
68: ; preds = %54
%69 = trunc i64 %55 to i32
%70 = add nuw nsw i32 %69, 1
%71 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 1
%72 = load i32, i32* %71
%73 = add nsw i32 %72, 65
%74 = load i32, i32* %52
%75 = add nsw i32 %74, 1
%76 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 3
%77 = load i32, i32* %76
%78 = add nsw i32 %77, 65
%79 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 2
%80 = load i32, i32* %79
%81 = add nsw i32 %80, 1
%82 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 5
%83 = load i32, i32* %82
%84 = add nsw i32 %83, 65
%85 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 4
%86 = load i32, i32* %85
%87 = add nsw i32 %86, 1
%88 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 7
%89 = load i32, i32* %88
%90 = add nsw i32 %89, 65
%91 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 6
%92 = load i32, i32* %91
%93 = add nsw i32 %92, 1
%94 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %70, i32 %73, i32 %75, i32 %78, i32 %81, i32 %84, i32 %87, i32 %90, i32 %93)
br label %137
95: ; preds = %54
%96 = getelementptr inbounds i8, i8* %57, i64 3
%97 = load i8, i8* %96
%98 = sext i8 %97 to i64
%99 = add nsw i64 %98, -97
%100 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %99
%101 = load i32, i32* %100
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [6 x [7 x i32]], [6 x [7 x i32]]* %3, i64 0, i64 %102, i64 %99
store i32 2, i32* %103
%104 = add nsw i32 %101, 1
store i32 %104, i32* %100
%105 = call i32 @playerDidWin(i32 2, i32** %51, i32* %52)
%106 = icmp eq i32 %105, 0
br i1 %106, label %134, label %107
107: ; preds = %95
%108 = trunc i64 %55 to i32
%109 = add nuw nsw i32 %108, 1
%110 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 1
%111 = load i32, i32* %110
%112 = add nsw i32 %111, 97
%113 = load i32, i32* %52
%114 = add nsw i32 %113, 1
%115 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 3
%116 = load i32, i32* %115
%117 = add nsw i32 %116, 97
%118 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 2
%119 = load i32, i32* %118
%120 = add nsw i32 %119, 1
%121 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 5
%122 = load i32, i32* %121
%123 = add nsw i32 %122, 97
%124 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 4
%125 = load i32, i32* %124
%126 = add nsw i32 %125, 1
%127 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 7
%128 = load i32, i32* %127
%129 = add nsw i32 %128, 97
%130 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 6
%131 = load i32, i32* %130
%132 = add nsw i32 %131, 1
%133 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %109, i32 %112, i32 %114, i32 %117, i32 %120, i32 %123, i32 %126, i32 %129, i32 %132)
br label %137
134: ; preds = %95
%135 = add nuw nsw i64 %55, 1
%136 = icmp eq i64 %135, %53
br i1 %136, label %137, label %54
137: ; preds = %134, %44, %107, %68
ret i32 0
}