#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 */
void *_strat_can_win_3(char const, int /*<<< orphan*/, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ board_get_position(int, int);
char strat_can_win(const char pid, char *row, char *col) {
  char r;
  char c;
  int i;
  for (i = 0; i < 3; i++) {
    c = _strat_can_win_3(pid, board_get_position(i, 0),
                         board_get_position(i, 1), board_get_position(i, 2));
    if (c != -1) {
      *row = i;
      *col = c;
      return 1;
    }
    r = _strat_can_win_3(pid, board_get_position(0, i),
                         board_get_position(1, i), board_get_position(2, i));
    if (r != -1) {
      *row = r;
      *col = i;
      return 1;
    }
  }
  i = _strat_can_win_3(pid, board_get_position(0, 0), board_get_position(1, 1),
                       board_get_position(2, 2));
  if (i != -1) {
    *row = i;
    *col = i;
    return 1;
  }
  i = _strat_can_win_3(pid, board_get_position(2, 0), board_get_position(1, 1),
                       board_get_position(0, 2));
  if (i != -1) {
    *row = 2 - i;
    *col = i;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<strat_can_win>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    123a <strat_can_win+0x11a>
mov    -0x2(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
mov    -0x21(%rbp),%al
movsbl %al,%edi
call   1030 <_strat_can_win_3@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x1a(%rbp),%eax
cmp    $0xffffffff,%eax
je     11b7 <strat_can_win+0x97>
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x1a(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movb   $0x1,-0x1(%rbp)
jmp    131e <strat_can_win+0x1fe>
mov    -0x2(%rbp),%al
mov    %al,-0x2d(%rbp)
mov    -0x20(%rbp),%esi
xor    %edi,%edi
call   1040 <board_get_position@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%esi
mov    $0x1,%edi
call   1040 <board_get_position@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%esi
mov    $0x2,%edi
call   1040 <board_get_position@plt>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    %eax,%ecx
mov    -0x2d(%rbp),%al
movsbl %al,%edi
call   1030 <_strat_can_win_3@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0xffffffff,%eax
je     1227 <strat_can_win+0x107>
mov    -0x19(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movb   $0x1,-0x1(%rbp)
jmp    131e <strat_can_win+0x1fe>
jmp    122c <strat_can_win+0x10c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <strat_can_win+0x1d>
mov    -0x2(%rbp),%al
mov    %al,-0x39(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1040 <board_get_position@plt>
mov    %eax,-0x44(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <board_get_position@plt>
mov    %eax,-0x40(%rbp)
mov    $0x2,%esi
mov    %esi,%edi
call   1040 <board_get_position@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    %eax,%ecx
mov    -0x39(%rbp),%al
movsbl %al,%edi
call   1030 <_strat_can_win_3@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     12a6 <strat_can_win+0x186>
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movb   $0x1,-0x1(%rbp)
jmp    131e <strat_can_win+0x1fe>
mov    -0x2(%rbp),%al
mov    %al,-0x45(%rbp)
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,-0x50(%rbp)
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <board_get_position@plt>
mov    %eax,-0x4c(%rbp)
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    -0x50(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    %eax,%ecx
mov    -0x45(%rbp),%al
movsbl %al,%edi
call   1030 <_strat_can_win_3@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     131a <strat_can_win+0x1fa>
mov    $0x2,%eax
sub    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movb   $0x1,-0x1(%rbp)
jmp    131e <strat_can_win+0x1fe>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strat_can_win>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %edi,%r15d
xor    %r13d,%r13d
xor    %edi,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %r15d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%rbp
cmp    $0xff,%bpl
jne    1381 <strat_can_win+0x261>
xor    %ebp,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,%r13d
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebx
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
movsbl %r15b,%r15d
mov    %r15d,%edi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%r13
cmp    $0xff,%r13b
jne    1381 <strat_can_win+0x261>
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebx
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebp
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%rbp
mov    $0x1,%r13b
cmp    $0xff,%bpl
jne    1381 <strat_can_win+0x261>
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebx
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebp
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%r13
mov    $0x1,%bpl
cmp    $0xff,%r13b
jne    1381 <strat_can_win+0x261>
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebx
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebp
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%rbp
mov    $0x2,%r13b
cmp    $0xff,%bpl
jne    1381 <strat_can_win+0x261>
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebx
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebp
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%r13
mov    $0x2,%bpl
cmp    $0xff,%r13b
jne    1381 <strat_can_win+0x261>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebx
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebp
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%r13
cmp    $0xffffffff,%r13d
je     1336 <strat_can_win+0x216>
mov    %r13d,%ebp
jmp    1381 <strat_can_win+0x261>
xor    %ebx,%ebx
mov    $0x2,%edi
xor    %esi,%esi
call   1040 <board_get_position@plt>
mov    %eax,%r13d
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <board_get_position@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    $0x2,%esi
call   1040 <board_get_position@plt>
mov    %r15d,%edi
mov    %r13d,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <_strat_can_win_3@plt>
mov    %rax,%rbp
cmp    $0xffffffff,%ebp
je     138a <strat_can_win+0x26a>
mov    $0x2,%r13b
sub    %bpl,%r13b
mov    %r13b,(%r12)
mov    %bpl,(%r14)
mov    $0x1,%bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @strat_can_win(i8 signext %0, i8* %1, i8* %2) {
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
store i8 %0, i8* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %10
br label %11
11: ; preds = %53, %3
%12 = load i32, i32* %10
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %56
14: ; preds = %11
%15 = load i8, i8* %5
%16 = load i32, i32* %10
%17 = call i32 @board_get_position(i32 %16, i32 0)
%18 = load i32, i32* %10
%19 = call i32 @board_get_position(i32 %18, i32 1)
%20 = load i32, i32* %10
%21 = call i32 @board_get_position(i32 %20, i32 2)
%22 = call i8* @_strat_can_win_3(i8 signext %15, i32 %17, i32 %19, i32 %21)
%23 = ptrtoint i8* %22 to i8
store i8 %23, i8* %9
%24 = load i8, i8* %9
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, -1
br i1 %26, label %27, label %33
27: ; preds = %14
%28 = load i32, i32* %10
%29 = trunc i32 %28 to i8
%30 = load i8*, i8** %6
store i8 %29, i8* %30
%31 = load i8, i8* %9
%32 = load i8*, i8** %7
store i8 %31, i8* %32
store i8 1, i8* %4
br label %90
33: ; preds = %14
%34 = load i8, i8* %5
%35 = load i32, i32* %10
%36 = call i32 @board_get_position(i32 0, i32 %35)
%37 = load i32, i32* %10
%38 = call i32 @board_get_position(i32 1, i32 %37)
%39 = load i32, i32* %10
%40 = call i32 @board_get_position(i32 2, i32 %39)
%41 = call i8* @_strat_can_win_3(i8 signext %34, i32 %36, i32 %38, i32 %40)
%42 = ptrtoint i8* %41 to i8
store i8 %42, i8* %8
%43 = load i8, i8* %8
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, -1
br i1 %45, label %46, label %52
46: ; preds = %33
%47 = load i8, i8* %8
%48 = load i8*, i8** %6
store i8 %47, i8* %48
%49 = load i32, i32* %10
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %7
store i8 %50, i8* %51
store i8 1, i8* %4
br label %90
52: ; preds = %33
br label %53
53: ; preds = %52
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %11
56: ; preds = %11
%57 = load i8, i8* %5
%58 = call i32 @board_get_position(i32 0, i32 0)
%59 = call i32 @board_get_position(i32 1, i32 1)
%60 = call i32 @board_get_position(i32 2, i32 2)
%61 = call i8* @_strat_can_win_3(i8 signext %57, i32 %58, i32 %59, i32 %60)
%62 = ptrtoint i8* %61 to i32
store i32 %62, i32* %10
%63 = load i32, i32* %10
%64 = icmp ne i32 %63, -1
br i1 %64, label %65, label %72
65: ; preds = %56
%66 = load i32, i32* %10
%67 = trunc i32 %66 to i8
%68 = load i8*, i8** %6
store i8 %67, i8* %68
%69 = load i32, i32* %10
%70 = trunc i32 %69 to i8
%71 = load i8*, i8** %7
store i8 %70, i8* %71
store i8 1, i8* %4
br label %90
72: ; preds = %56
%73 = load i8, i8* %5
%74 = call i32 @board_get_position(i32 2, i32 0)
%75 = call i32 @board_get_position(i32 1, i32 1)
%76 = call i32 @board_get_position(i32 0, i32 2)
%77 = call i8* @_strat_can_win_3(i8 signext %73, i32 %74, i32 %75, i32 %76)
%78 = ptrtoint i8* %77 to i32
store i32 %78, i32* %10
%79 = load i32, i32* %10
%80 = icmp ne i32 %79, -1
br i1 %80, label %81, label %89
81: ; preds = %72
%82 = load i32, i32* %10
%83 = sub nsw i32 2, %82
%84 = trunc i32 %83 to i8
%85 = load i8*, i8** %6
store i8 %84, i8* %85
%86 = load i32, i32* %10
%87 = trunc i32 %86 to i8
%88 = load i8*, i8** %7
store i8 %87, i8* %88
store i8 1, i8* %4
br label %90
89: ; preds = %72
store i8 0, i8* %4
br label %90
90: ; preds = %89, %81, %65, %46, %27
%91 = load i8, i8* %4
ret i8 %91
}

LLVM IR (-O2):
define signext i8 @strat_can_win(i8 signext %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2) {
%4 = tail call i32 @board_get_position(i32 0, i32 0)
%5 = tail call i32 @board_get_position(i32 0, i32 1)
%6 = tail call i32 @board_get_position(i32 0, i32 2)
%7 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %4, i32 %5, i32 %6)
%8 = ptrtoint i8* %7 to i64
%9 = trunc i64 %8 to i8
%10 = icmp eq i8 %9, -1
br i1 %10, label %11, label %72
11: ; preds = %3
%12 = tail call i32 @board_get_position(i32 0, i32 0)
%13 = tail call i32 @board_get_position(i32 1, i32 0)
%14 = tail call i32 @board_get_position(i32 2, i32 0)
%15 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %12, i32 %13, i32 %14)
%16 = ptrtoint i8* %15 to i64
%17 = trunc i64 %16 to i8
%18 = icmp eq i8 %17, -1
br i1 %18, label %19, label %72
19: ; preds = %11
%20 = tail call i32 @board_get_position(i32 1, i32 0)
%21 = tail call i32 @board_get_position(i32 1, i32 1)
%22 = tail call i32 @board_get_position(i32 1, i32 2)
%23 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %20, i32 %21, i32 %22)
%24 = ptrtoint i8* %23 to i64
%25 = trunc i64 %24 to i8
%26 = icmp eq i8 %25, -1
br i1 %26, label %27, label %72
27: ; preds = %19
%28 = tail call i32 @board_get_position(i32 0, i32 1)
%29 = tail call i32 @board_get_position(i32 1, i32 1)
%30 = tail call i32 @board_get_position(i32 2, i32 1)
%31 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %28, i32 %29, i32 %30)
%32 = ptrtoint i8* %31 to i64
%33 = trunc i64 %32 to i8
%34 = icmp eq i8 %33, -1
br i1 %34, label %35, label %72
35: ; preds = %27
%36 = tail call i32 @board_get_position(i32 2, i32 0)
%37 = tail call i32 @board_get_position(i32 2, i32 1)
%38 = tail call i32 @board_get_position(i32 2, i32 2)
%39 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %36, i32 %37, i32 %38)
%40 = ptrtoint i8* %39 to i64
%41 = trunc i64 %40 to i8
%42 = icmp eq i8 %41, -1
br i1 %42, label %43, label %72
43: ; preds = %35
%44 = tail call i32 @board_get_position(i32 0, i32 2)
%45 = tail call i32 @board_get_position(i32 1, i32 2)
%46 = tail call i32 @board_get_position(i32 2, i32 2)
%47 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %44, i32 %45, i32 %46)
%48 = ptrtoint i8* %47 to i64
%49 = trunc i64 %48 to i8
%50 = icmp eq i8 %49, -1
br i1 %50, label %51, label %72
51: ; preds = %43
%52 = tail call i32 @board_get_position(i32 0, i32 0)
%53 = tail call i32 @board_get_position(i32 1, i32 1)
%54 = tail call i32 @board_get_position(i32 2, i32 2)
%55 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %52, i32 %53, i32 %54)
%56 = ptrtoint i8* %55 to i64
%57 = trunc i64 %56 to i32
%58 = icmp eq i32 %57, -1
br i1 %58, label %61, label %59
59: ; preds = %51
%60 = trunc i64 %56 to i8
br label %72
61: ; preds = %51
%62 = tail call i32 @board_get_position(i32 2, i32 0)
%63 = tail call i32 @board_get_position(i32 1, i32 1)
%64 = tail call i32 @board_get_position(i32 0, i32 2)
%65 = tail call i8* @_strat_can_win_3(i8 signext %0, i32 %62, i32 %63, i32 %64)
%66 = ptrtoint i8* %65 to i64
%67 = trunc i64 %66 to i32
%68 = icmp eq i32 %67, -1
br i1 %68, label %75, label %69
69: ; preds = %61
%70 = trunc i64 %66 to i8
%71 = sub i8 2, %70
br label %72
72: ; preds = %11, %27, %43, %3, %19, %35, %59, %69
%73 = phi i8 [ %71, %69 ], [ %60, %59 ], [ 2, %35 ], [ 1, %19 ], [ 0, %3 ], [ %49, %43 ], [ %33, %27 ], [ %17, %11 ]
%74 = phi i8 [ %70, %69 ], [ %60, %59 ], [ %41, %35 ], [ %25, %19 ], [ %9, %3 ], [ 2, %43 ], [ 1, %27 ], [ 0, %11 ]
store i8 %73, i8* %1
store i8 %74, i8* %2
br label %75
75: ; preds = %72, %61
%76 = phi i8 [ 0, %61 ], [ 1, %72 ]
ret i8 %76
}