// File: /workspace/github_cpp_makefile_star2_O1/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 0x5b4db
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
addq $0x4748, %rdi           # imm = 0x4748
callq 0x4f84b
movl %eax, %eax
leaq 0x1aae3212(%rip), %rcx  # 0x1ab3e6e0
cmpb $0x0, (%rcx,%rax)
je 0x5b4de
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 0x1a3cb(%rip), %rax     # 0x758bc
movl (%rax), %esi
movl %r14d, %eax
subl %esi, %eax
movslq %eax, %rdi
movsbl 0x43f8(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x5b523
movslq 0x95720(%rbx,%rdi,4), %rax
imulq $0x7c8, %rax, %rdi      # imm = 0x7C8
xorl %eax, %eax
cmpl $0x1, 0x4(%rcx,%rdi)
jg 0x5b4d6
jmp 0x5b545
xorl %eax, %eax
cmpl %r8d, %edx
jne 0x5b545
movslq 0x95720(%rbx,%rdi,4), %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x7c0(%rcx,%rax), %eax
cmpl $0x1, %eax
jg 0x5b4d4
movslq %r14d, %rdi
movsbl 0x43f7(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x5b573
movslq 0x9571c(%rbx,%rdi,4), %r8
imulq $0x7c8, %r8, %r8        # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%r8)
jg 0x5b4d4
jmp 0x5b598
cmpl %r8d, %edx
jne 0x5b598
movslq 0x9571c(%rbx,%rdi,4), %r8
imulq $0x7c8, %r8, %r8        # imm = 0x7C8
addl 0x7c0(%rcx,%r8), %eax
cmpl $0x1, %eax
jg 0x5b4d4
movsbl 0x43f9(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x5b5c2
movslq 0x95724(%rbx,%rdi,4), %rdi
imulq $0x7c8, %rdi, %rdi      # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%rdi)
jg 0x5b4d4
jmp 0x5b5e6
cmpl %r8d, %edx
jne 0x5b5e6
movslq 0x95724(%rbx,%rdi,4), %rdi
imulq $0x7c8, %rdi, %rdi      # imm = 0x7C8
addl 0x7c0(%rcx,%rdi), %eax
cmpl $0x1, %eax
jg 0x5b4d4
addl %r14d, %esi
movslq %esi, %rsi
movsbl 0x43f8(%rbx,%rsi), %edi
cmpl %ebp, %edi
jne 0x5b614
movslq 0x95720(%rbx,%rsi,4), %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%rax)
jg 0x5b4d4
jmp 0x5b637
cmpl %edi, %edx
jne 0x5b637
movslq 0x95720(%rbx,%rsi,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
addl 0x7c0(%rcx,%rdx), %eax
cmpl $0x1, %eax
jg 0x5b4d4
movb $0x1, %al
jmp 0x5b4d6