#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 */
scalar_t__ board_get_position(int, int);
int /*<<< orphan*/ board_set_position(int, int, char const);
scalar_t__ strat_can_win(char const, char *, char *);
char _strat_can_win(const char pid, char *row, char *col) {
  int i;
  int j;
  char temp;
  char can_win = 0;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      if (board_get_position(i, j) == 0) {
        board_set_position(i, j, pid);
        if (strat_can_win(pid, &temp, &temp)) {
          can_win = 1;
        }
        board_set_position(i, j, 0);
        if (can_win) {
          *row = i;
          *col = j;
          return 1;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<_strat_can_win>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movb   $0x0,-0x22(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    120f <_strat_can_win+0xdf>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11fc <_strat_can_win+0xcc>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <board_get_position@plt>
cmp    $0x0,%rax
jne    11e9 <_strat_can_win+0xb9>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
movsbl -0x2(%rbp),%edx
call   1040 <board_set_position@plt>
lea    -0x21(%rbp),%rdx
movsbl -0x2(%rbp),%edi
mov    %rdx,%rsi
call   1030 <strat_can_win@plt>
cmp    $0x0,%rax
je     11ae <_strat_can_win+0x7e>
movb   $0x1,-0x22(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
xor    %edx,%edx
call   1040 <board_set_position@plt>
cmpb   $0x0,-0x22(%rbp)
je     11e4 <_strat_can_win+0xb4>
mov    -0x1c(%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    1213 <_strat_can_win+0xe3>
jmp    11e9 <_strat_can_win+0xb9>
jmp    11ee <_strat_can_win+0xbe>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1162 <_strat_can_win+0x32>
jmp    1201 <_strat_can_win+0xd1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <_strat_can_win+0x21>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_strat_can_win>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,%r15
xor    %ebp,%ebp
movsbl %dil,%r13d
lea    0xf(%rsp),%r12
xor    %r14d,%r14d
jmp    116c <_strat_can_win+0x3c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x3,%ebp
je     1240 <_strat_can_win+0x110>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <board_get_position@plt>
test   %rax,%rax
jne    11ab <_strat_can_win+0x7b>
mov    %ebp,%edi
xor    %esi,%esi
mov    %r13d,%edx
call   1040 <board_set_position@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r12,%rdx
call   1030 <strat_can_win@plt>
mov    %rax,%rbx
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <board_set_position@plt>
test   %rbx,%rbx
jne    1247 <_strat_can_win+0x117>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <board_get_position@plt>
test   %rax,%rax
jne    11ef <_strat_can_win+0xbf>
mov    %ebp,%edi
mov    $0x1,%esi
mov    %r13d,%edx
call   1040 <board_set_position@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r12,%rdx
call   1030 <strat_can_win@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <board_set_position@plt>
test   %rbx,%rbx
jne    1244 <_strat_can_win+0x114>
mov    %ebp,%edi
mov    $0x2,%esi
call   1050 <board_get_position@plt>
test   %rax,%rax
jne    1160 <_strat_can_win+0x30>
mov    %ebp,%edi
mov    $0x2,%esi
mov    %r13d,%edx
call   1040 <board_set_position@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r12,%rdx
call   1030 <strat_can_win@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1040 <board_set_position@plt>
test   %rbx,%rbx
je     1160 <_strat_can_win+0x30>
mov    $0x2,%r14b
jmp    1247 <_strat_can_win+0x117>
xor    %eax,%eax
jmp    1254 <_strat_can_win+0x124>
mov    $0x1,%r14b
mov    %bpl,(%r15)
mov    0x10(%rsp),%rax
mov    %r14b,(%rax)
mov    $0x1,%al
add    $0x18,%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 i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8
store i8 %0, i8* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8 0, i8* %11
store i32 0, i32* %8
br label %12
12: ; preds = %52, %3
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %55
15: ; preds = %12
store i32 0, i32* %9
br label %16
16: ; preds = %48, %15
%17 = load i32, i32* %9
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %51
19: ; preds = %16
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = call i64 @board_get_position(i32 %20, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %47
24: ; preds = %19
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = load i8, i8* %5
%28 = call i32 @board_set_position(i32 %25, i32 %26, i8 signext %27)
%29 = load i8, i8* %5
%30 = call i64 @strat_can_win(i8 signext %29, i8* %10, i8* %10)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %24
store i8 1, i8* %11
br label %33
33: ; preds = %32, %24
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = call i32 @board_set_position(i32 %34, i32 %35, i8 signext 0)
%37 = load i8, i8* %11
%38 = icmp ne i8 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %33
%40 = load i32, i32* %8
%41 = trunc i32 %40 to i8
%42 = load i8*, i8** %6
store i8 %41, i8* %42
%43 = load i32, i32* %9
%44 = trunc i32 %43 to i8
%45 = load i8*, i8** %7
store i8 %44, i8* %45
store i8 1, i8* %4
br label %56
46: ; preds = %33
br label %47
47: ; preds = %46, %19
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %16
51: ; preds = %16
br label %52
52: ; preds = %51
%53 = load i32, i32* %8
%54 = add nsw i32 %53, 1
store i32 %54, i32* %8
br label %12
55: ; preds = %12
store i8 0, i8* %4
br label %56
56: ; preds = %55, %39
%57 = load i8, i8* %4
ret i8 %57
}

LLVM IR (-O2):
define signext i8 @_strat_can_win(i8 signext %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2) {
%4 = alloca i8
br label %5
5: ; preds = %3, %33
%6 = phi i32 [ 0, %3 ], [ %34, %33 ]
%7 = call i64 @board_get_position(i32 %6, i32 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = call i32 @board_set_position(i32 %6, i32 0, i8 signext %0)
%11 = call i64 @strat_can_win(i8 signext %0, i8* %4, i8* %4)
%12 = icmp eq i64 %11, 0
%13 = call i32 @board_set_position(i32 %6, i32 0, i8 signext 0)
br i1 %12, label %17, label %14
14: ; preds = %28, %20, %9
%15 = phi i8 [ 0, %9 ], [ 1, %20 ], [ 2, %28 ]
%16 = trunc i32 %6 to i8
store i8 %16, i8* %1
store i8 %15, i8* %2
br label %36
17: ; preds = %5, %9
%18 = call i64 @board_get_position(i32 %6, i32 1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = call i32 @board_set_position(i32 %6, i32 1, i8 signext %0)
%22 = call i64 @strat_can_win(i8 signext %0, i8* %4, i8* %4)
%23 = icmp eq i64 %22, 0
%24 = call i32 @board_set_position(i32 %6, i32 1, i8 signext 0)
br i1 %23, label %25, label %14
25: ; preds = %20, %17
%26 = call i64 @board_get_position(i32 %6, i32 2)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = call i32 @board_set_position(i32 %6, i32 2, i8 signext %0)
%30 = call i64 @strat_can_win(i8 signext %0, i8* %4, i8* %4)
%31 = icmp eq i64 %30, 0
%32 = call i32 @board_set_position(i32 %6, i32 2, i8 signext 0)
br i1 %31, label %33, label %14
33: ; preds = %28, %25
%34 = add nuw nsw i32 %6, 1
%35 = icmp eq i32 %34, 3
br i1 %35, label %36, label %5
36: ; preds = %33, %14
%37 = phi i8 [ 1, %14 ], [ 0, %33 ]
ret i8 %37
}