#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 */
char const board_get_position(int, int);
char strat_can_play_opposite_corner(const char opponent_id, char *row,
                                    char *col) {
  int i;
  int r;
  int c;
  for (i = 0; i < 4; i++) {
    r = i & 1;
    c = (i >> 1) & 1;
    if (board_get_position(r * 2, c * 2) == opponent_id &&
        board_get_position((~r & 1) * 2, (~c & 1) * 2) == 0) {
      *row = (~r & 1) * 2;
      *col = (~c & 1) * 2;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<strat_can_play_opposite_corner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11d9 <strat_can_play_opposite_corner+0xc9>
mov    -0x1c(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x1,%eax
and    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
shl    $0x1,%edi
mov    -0x24(%rbp),%esi
shl    $0x1,%esi
call   1030 <board_get_position@plt>
movsbl %al,%eax
movsbl -0x2(%rbp),%ecx
cmp    %ecx,%eax
jne    11c6 <strat_can_play_opposite_corner+0xb6>
mov    -0x20(%rbp),%edi
xor    $0xffffffff,%edi
and    $0x1,%edi
shl    $0x1,%edi
mov    -0x24(%rbp),%esi
xor    $0xffffffff,%esi
and    $0x1,%esi
shl    $0x1,%esi
call   1030 <board_get_position@plt>
movsbl %al,%eax
cmp    $0x0,%eax
jne    11c6 <strat_can_play_opposite_corner+0xb6>
mov    -0x20(%rbp),%eax
xor    $0xffffffff,%eax
and    $0x1,%eax
shl    $0x1,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x24(%rbp),%eax
xor    $0xffffffff,%eax
and    $0x1,%eax
shl    $0x1,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movb   $0x1,-0x1(%rbp)
jmp    11dd <strat_can_play_opposite_corner+0xcd>
jmp    11cb <strat_can_play_opposite_corner+0xbb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112d <strat_can_play_opposite_corner+0x1d>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strat_can_play_opposite_corner>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   1030 <board_get_position@plt>
cmp    %bpl,%al
jne    1141 <strat_can_play_opposite_corner+0x31>
mov    $0x2,%edi
mov    $0x2,%esi
call   1030 <board_get_position@plt>
test   %al,%al
je     11b3 <strat_can_play_opposite_corner+0xa3>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <board_get_position@plt>
cmp    %bpl,%al
jne    1164 <strat_can_play_opposite_corner+0x54>
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x2,%esi
call   1030 <board_get_position@plt>
test   %al,%al
je     11b5 <strat_can_play_opposite_corner+0xa5>
xor    %edi,%edi
mov    $0x2,%esi
call   1030 <board_get_position@plt>
cmp    %bpl,%al
jne    1188 <strat_can_play_opposite_corner+0x78>
xor    %r12d,%r12d
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <board_get_position@plt>
test   %al,%al
je     11ba <strat_can_play_opposite_corner+0xaa>
mov    $0x2,%edi
mov    $0x2,%esi
call   1030 <board_get_position@plt>
xor    %ebx,%ebx
cmp    %bpl,%al
jne    11c4 <strat_can_play_opposite_corner+0xb4>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <board_get_position@plt>
mov    $0x0,%r12d
test   %al,%al
jne    11c4 <strat_can_play_opposite_corner+0xb4>
jmp    11bc <strat_can_play_opposite_corner+0xac>
mov    $0x2,%bl
mov    $0x2,%r12b
jmp    11bc <strat_can_play_opposite_corner+0xac>
mov    $0x2,%bl
mov    %bl,(%r15)
mov    %r12b,(%r14)
mov    $0x1,%bl
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @strat_can_play_opposite_corner(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 i32
store i8 %0, i8* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 0, i32* %8
br label %11
11: ; preds = %55, %3
%12 = load i32, i32* %8
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %58
14: ; preds = %11
%15 = load i32, i32* %8
%16 = and i32 %15, 1
store i32 %16, i32* %9
%17 = load i32, i32* %8
%18 = ashr i32 %17, 1
%19 = and i32 %18, 1
store i32 %19, i32* %10
%20 = load i32, i32* %9
%21 = mul nsw i32 %20, 2
%22 = load i32, i32* %10
%23 = mul nsw i32 %22, 2
%24 = call signext i8 @board_get_position(i32 %21, i32 %23)
%25 = sext i8 %24 to i32
%26 = load i8, i8* %5
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %54
29: ; preds = %14
%30 = load i32, i32* %9
%31 = xor i32 %30, -1
%32 = and i32 %31, 1
%33 = mul nsw i32 %32, 2
%34 = load i32, i32* %10
%35 = xor i32 %34, -1
%36 = and i32 %35, 1
%37 = mul nsw i32 %36, 2
%38 = call signext i8 @board_get_position(i32 %33, i32 %37)
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %54
41: ; preds = %29
%42 = load i32, i32* %9
%43 = xor i32 %42, -1
%44 = and i32 %43, 1
%45 = mul nsw i32 %44, 2
%46 = trunc i32 %45 to i8
%47 = load i8*, i8** %6
store i8 %46, i8* %47
%48 = load i32, i32* %10
%49 = xor i32 %48, -1
%50 = and i32 %49, 1
%51 = mul nsw i32 %50, 2
%52 = trunc i32 %51 to i8
%53 = load i8*, i8** %7
store i8 %52, i8* %53
store i8 1, i8* %4
br label %59
54: ; preds = %29, %14
br label %55
55: ; preds = %54
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
br label %11
58: ; preds = %11
store i8 0, i8* %4
br label %59
59: ; preds = %58, %41
%60 = load i8, i8* %4
ret i8 %60
}

LLVM IR (-O2):
define signext i8 @strat_can_play_opposite_corner(i8 signext %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2) {
%4 = tail call signext i8 @board_get_position(i32 0, i32 0)
%5 = icmp eq i8 %4, %0
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call signext i8 @board_get_position(i32 2, i32 2)
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %27, %21, %15, %6
%10 = phi i8 [ 2, %6 ], [ 0, %15 ], [ 2, %21 ], [ 0, %27 ]
%11 = phi i8 [ 2, %6 ], [ 2, %15 ], [ 0, %21 ], [ 0, %27 ]
store i8 %10, i8* %1
store i8 %11, i8* %2
br label %30
12: ; preds = %3, %6
%13 = tail call signext i8 @board_get_position(i32 2, i32 0)
%14 = icmp eq i8 %13, %0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = tail call signext i8 @board_get_position(i32 0, i32 2)
%17 = icmp eq i8 %16, 0
br i1 %17, label %9, label %18
18: ; preds = %15, %12
%19 = tail call signext i8 @board_get_position(i32 0, i32 2)
%20 = icmp eq i8 %19, %0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call signext i8 @board_get_position(i32 2, i32 0)
%23 = icmp eq i8 %22, 0
br i1 %23, label %9, label %24
24: ; preds = %21, %18
%25 = tail call signext i8 @board_get_position(i32 2, i32 2)
%26 = icmp eq i8 %25, %0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = tail call signext i8 @board_get_position(i32 0, i32 0)
%29 = icmp eq i8 %28, 0
br i1 %29, label %9, label %30
30: ; preds = %24, %27, %9
%31 = phi i8 [ 1, %9 ], [ 0, %27 ], [ 0, %24 ]
ret i8 %31
}