// File: /workspace/github_cpp_makefile_star2_O3/kobanium[P]Ray/src/feature/Semeai.cpp
// Function: IsSelfAtariCaptureForSimulation(game_info_t const*, int, int, int)
bool
IsSelfAtariCaptureForSimulation( const game_info_t *game, const int pos, const int color, const int lib )
{
  const char *board = game->board;
  const string_t *string = game->string;
  const int *string_id = game->string_id;
  const int other = GetOppositeColor(color);
  int id;
  int size = 0;

  if (lib != pos || 
      nb4_empty[Pat3(game->pat, pos)] != 0) {
    return false;
  }

  if (board[NORTH(pos)] == color) {
    id = string_id[NORTH(pos)];
    if (string[id].libs > 1) {
      return false;
    }
  } else if (board[NORTH(pos)] == other) {
    id = string_id[NORTH(pos)];
    size += string[id].size;
    if (size > 1) {
      return false;
    }
  }

  if (board[WEST(pos)] == color) {
    id = string_id[WEST(pos)];
    if (string[id].libs > 1) {
      return false;
    }
  } else if (board[WEST(pos)] == other) {
    id = string_id[WEST(pos)];
    size += string[id].size;
    if (size > 1) {
      return false;
    }
  }

  if (board[EAST(pos)] == color) {
    id = string_id[EAST(pos)];
    if (string[id].libs > 1) {
      return false;
    }
  } else if (board[EAST(pos)] == other) {
    id = string_id[EAST(pos)];
    size += string[id].size;
    if (size > 1) {
      return false;
    }
  }

  if (board[SOUTH(pos)] == color) {
    id = string_id[SOUTH(pos)];
    if (string[id].libs > 1) {
      return false;
    }
  } else if (board[SOUTH(pos)] == other) {
    id = string_id[SOUTH(pos)];
    size += string[id].size;
    if (size > 1) {
      return false;
    }
  }

  return true;
}

// Assembly:
cmpl %esi, %ecx
jne 0x5bd84
pushq %rbp
pushq %r14
pushq %rbx
movl %ecx, %r14d
movl %edx, %ebp
movq %rdi, %rbx
addq $0x4748, %rdi           # imm = 0x4748
movl %ecx, %esi
callq 0x4fc2a
movl %eax, %eax
leaq 0x1aae3969(%rip), %rcx  # 0x1ab3f6e0
cmpb $0x0, (%rcx,%rax)
je 0x5bd87
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
retq
leaq 0x9620(%rbx), %rcx
movl %ebp, %edx
xorl $0x3, %edx
leaq 0x1ab22(%rip), %rax     # 0x768bc
movl (%rax), %esi
movl %r14d, %eax
subl %esi, %eax
movslq %eax, %rdi
movsbl 0x43f8(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x5bdcc
movslq 0x95720(%rbx,%rdi,4), %rax
imulq $0x7c8, %rax, %rdi      # imm = 0x7C8
xorl %eax, %eax
cmpl $0x1, 0x4(%rcx,%rdi)
jg 0x5bd7f
jmp 0x5bdee
xorl %eax, %eax
cmpl %r8d, %edx
jne 0x5bdee
movslq 0x95720(%rbx,%rdi,4), %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x7c0(%rcx,%rax), %eax
cmpl $0x1, %eax
jg 0x5bd7d
movslq %r14d, %rdi
movsbl 0x43f7(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x5be1c
movslq 0x9571c(%rbx,%rdi,4), %r8
imulq $0x7c8, %r8, %r8        # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%r8)
jg 0x5bd7d
jmp 0x5be41
cmpl %r8d, %edx
jne 0x5be41
movslq 0x9571c(%rbx,%rdi,4), %r8
imulq $0x7c8, %r8, %r8        # imm = 0x7C8
addl 0x7c0(%rcx,%r8), %eax
cmpl $0x1, %eax
jg 0x5bd7d
movsbl 0x43f9(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x5be6b
movslq 0x95724(%rbx,%rdi,4), %rdi
imulq $0x7c8, %rdi, %rdi      # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%rdi)
jg 0x5bd7d
jmp 0x5be8f
cmpl %r8d, %edx
jne 0x5be8f
movslq 0x95724(%rbx,%rdi,4), %rdi
imulq $0x7c8, %rdi, %rdi      # imm = 0x7C8
addl 0x7c0(%rcx,%rdi), %eax
cmpl $0x1, %eax
jg 0x5bd7d
addl %r14d, %esi
movslq %esi, %rsi
movsbl 0x43f8(%rbx,%rsi), %edi
cmpl %ebp, %edi
jne 0x5bebd
movslq 0x95720(%rbx,%rsi,4), %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%rax)
jg 0x5bd7d
jmp 0x5bee0
cmpl %edi, %edx
jne 0x5bee0
movslq 0x95720(%rbx,%rsi,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
addl 0x7c0(%rcx,%rdx), %eax
cmpl $0x1, %eax
jg 0x5bd7d
movb $0x1, %al
jmp 0x5bd7f