// File: /workspace/github_cpp_makefile_star2_O2/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 0x420bc
pushq %rbp
pushq %r14
pushq %rbx
movl %ecx, %r14d
movl %edx, %ebp
movq %rdi, %rbx
addq $0x4748, %rdi           # imm = 0x4748
movl %ecx, %esi
callq 0x37bc6
movl %eax, %eax
leaq 0x1aae8631(%rip), %rcx  # 0x1ab2a6e0
cmpb $0x0, (%rcx,%rax)
je 0x420bf
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 0x1f7ea(%rip), %rax     # 0x618bc
movl (%rax), %esi
movl %r14d, %eax
subl %esi, %eax
movslq %eax, %rdi
movsbl 0x43f8(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x42104
movslq 0x95720(%rbx,%rdi,4), %rax
imulq $0x7c8, %rax, %rdi      # imm = 0x7C8
xorl %eax, %eax
cmpl $0x1, 0x4(%rcx,%rdi)
jg 0x420b7
jmp 0x42126
xorl %eax, %eax
cmpl %r8d, %edx
jne 0x42126
movslq 0x95720(%rbx,%rdi,4), %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x7c0(%rcx,%rax), %eax
cmpl $0x1, %eax
jg 0x420b5
movslq %r14d, %rdi
movsbl 0x43f7(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x42154
movslq 0x9571c(%rbx,%rdi,4), %r8
imulq $0x7c8, %r8, %r8        # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%r8)
jg 0x420b5
jmp 0x42179
cmpl %r8d, %edx
jne 0x42179
movslq 0x9571c(%rbx,%rdi,4), %r8
imulq $0x7c8, %r8, %r8        # imm = 0x7C8
addl 0x7c0(%rcx,%r8), %eax
cmpl $0x1, %eax
jg 0x420b5
movsbl 0x43f9(%rbx,%rdi), %r8d
cmpl %ebp, %r8d
jne 0x421a3
movslq 0x95724(%rbx,%rdi,4), %rdi
imulq $0x7c8, %rdi, %rdi      # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%rdi)
jg 0x420b5
jmp 0x421c7
cmpl %r8d, %edx
jne 0x421c7
movslq 0x95724(%rbx,%rdi,4), %rdi
imulq $0x7c8, %rdi, %rdi      # imm = 0x7C8
addl 0x7c0(%rcx,%rdi), %eax
cmpl $0x1, %eax
jg 0x420b5
addl %r14d, %esi
movslq %esi, %rsi
movsbl 0x43f8(%rbx,%rsi), %edi
cmpl %ebp, %edi
jne 0x421f5
movslq 0x95720(%rbx,%rsi,4), %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
cmpl $0x1, 0x4(%rcx,%rax)
jg 0x420b5
jmp 0x42218
cmpl %edi, %edx
jne 0x42218
movslq 0x95720(%rbx,%rsi,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
addl 0x7c0(%rcx,%rdx), %eax
cmpl $0x1, %eax
jg 0x420b5
movb $0x1, %al
jmp 0x420b7