#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 */
typedef int uint8_t;
typedef scalar_t__ pos;

/* Variables and functions */
int cp_GetColor(int);
int cp_GetFromBoard(int);
uint8_t cu_IsIllegalPosition(uint8_t pos, uint8_t my_color) {
  uint8_t board_cp;
  if (((pos)&0x088) != 0)
    return 1;
  board_cp = cp_GetFromBoard(pos);
  if (board_cp != 0)
    if (cp_GetColor(board_cp) == my_color)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<cu_IsIllegalPosition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x88,%eax
cmp    $0x0,%eax
je     114b <cu_IsIllegalPosition+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    1189 <cu_IsIllegalPosition+0x69>
mov    -0x8(%rbp),%edi
call   1030 <cp_GetFromBoard@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1182 <cu_IsIllegalPosition+0x62>
mov    -0x10(%rbp),%edi
call   1040 <cp_GetColor@plt>
cmp    -0xc(%rbp),%eax
jne    117d <cu_IsIllegalPosition+0x5d>
movl   $0x1,-0x4(%rbp)
jmp    1189 <cu_IsIllegalPosition+0x69>
jmp    1182 <cu_IsIllegalPosition+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cu_IsIllegalPosition>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebx
test   $0x88,%dil
jne    1146 <cu_IsIllegalPosition+0x26>
mov    %esi,%ebp
call   1030 <cp_GetFromBoard@plt>
test   %eax,%eax
je     1144 <cu_IsIllegalPosition+0x24>
mov    %eax,%edi
call   1040 <cp_GetColor@plt>
cmp    %ebp,%eax
je     1146 <cu_IsIllegalPosition+0x26>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cu_IsIllegalPosition(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = and i32 %7, 136
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %24
11: ; preds = %2
%12 = load i32, i32* %4
%13 = call i32 @cp_GetFromBoard(i32 %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* %6
%18 = call i32 @cp_GetColor(i32 %17)
%19 = load i32, i32* %5
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 1, i32* %3
br label %24
22: ; preds = %16
br label %23
23: ; preds = %22, %11
store i32 0, i32* %3
br label %24
24: ; preds = %23, %21, %10
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @cu_IsIllegalPosition(i32 %0, i32 %1) {
%3 = and i32 %0, 136
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i32 @cp_GetFromBoard(i32 %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @cp_GetColor(i32 %6)
%10 = icmp eq i32 %9, %1
br i1 %10, label %12, label %11
11: ; preds = %8, %5
br label %12
12: ; preds = %8, %2, %11
%13 = phi i32 [ 0, %11 ], [ 1, %2 ], [ 1, %8 ]
ret i32 %13
}