// File: kobanium[P]Ray/src/board/GoBoard.cpp
// Function: IsLegalNotEye(game_info_t*, int, int)
bool
IsLegalNotEye( game_info_t *game, const int pos, const int color )
{
  const int *string_id = game->string_id;
  const string_t *string = game->string;

  // 既に石がある
  if (game->board[pos] != S_EMPTY) {
    // 候補手から除外
    game->candidates[pos] = false;
    return false;
  }

  if (game->seki[pos]) {
    return false;
  }

  // 眼
  if (eye[Pat3(game->pat, pos)] != color ||
      string[string_id[NORTH(pos)]].libs == 1 ||
      string[string_id[ WEST(pos)]].libs == 1 ||
      string[string_id[ EAST(pos)]].libs == 1 ||
      string[string_id[SOUTH(pos)]].libs == 1){

    // 自殺手かどうか
    if (nb4_empty[Pat3(game->pat, pos)] == 0 &&
        IsSuicide(game, string, color, pos)) {
      return false;
    }

    // 劫
    if (game->ko_pos == pos &&
        game->ko_move == (game->moves - 1)) {
      return false;
    }

    // 盤端の特殊処理
    if (false_eye[Pat3(game->pat, pos)] == color) {
      if (IsFalseEyeConnection(game, pos, color)) {
        return true;
      } else {
        game->candidates[pos] = false;
        return false;
      }
    }

    return true;
  }

  // 候補手から除外
  game->candidates[pos] = false;

  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x95720, %rax          # imm = 0x95720
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x9620, %rax           # imm = 0x9620
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl 0x43f8(%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x9d4bc
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $0x0, 0x96ce0(%rax,%rcx)
movb $0x0, -0x1(%rbp)
jmp 0x9d68b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
testb $0x1, 0x97029(%rax,%rcx)
je 0x9d4d7
movb $0x0, -0x1(%rbp)
jmp 0x9d68b
movq -0x10(%rbp), %rdi
addq $0x4748, %rdi           # imm = 0x4748
movl -0x14(%rbp), %esi
callq 0x93d30
movl %eax, %eax
movl %eax, %ecx
leaq 0x1aae336b(%rip), %rax  # 0x1ab80860
movzbl (%rax,%rcx), %eax
cmpl -0x18(%rbp), %eax
jne 0x9d5a0
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %edx
subl 0x4a539(%rip), %edx     # 0xe7a4c
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
je 0x9d5a0
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
je 0x9d5a0
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
je 0x9d5a0
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %edx
addl 0x4a4c7(%rip), %edx     # 0xe7a4c
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jne 0x9d677
movq -0x10(%rbp), %rdi
addq $0x4748, %rdi           # imm = 0x4748
movl -0x14(%rbp), %esi
callq 0x93d30
movl %eax, %eax
movl %eax, %ecx
leaq 0x1ab132a2(%rip), %rax  # 0x1abb0860
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x9d5e9
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x18(%rbp), %edx
movl -0x14(%rbp), %ecx
callq 0x9d360
testb $0x1, %al
jne 0x9d5e0
jmp 0x9d5e9
movb $0x0, -0x1(%rbp)
jmp 0x9d68b
movq -0x10(%rbp), %rax
movl 0x43c4(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x9d619
movq -0x10(%rbp), %rax
movl 0x43c8(%rax), %eax
movq -0x10(%rbp), %rcx
movl 0x43b0(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x9d619
movb $0x0, -0x1(%rbp)
jmp 0x9d68b
movq -0x10(%rbp), %rdi
addq $0x4748, %rdi           # imm = 0x4748
movl -0x14(%rbp), %esi
callq 0x93d30
movl %eax, %eax
movl %eax, %ecx
leaq 0x1aaf3229(%rip), %rax  # 0x1ab90860
movzbl (%rax,%rcx), %eax
cmpl -0x18(%rbp), %eax
jne 0x9d671
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x9d6a0
testb $0x1, %al
jne 0x9d655
jmp 0x9d65b
movb $0x1, -0x1(%rbp)
jmp 0x9d68b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $0x0, 0x96ce0(%rax,%rcx)
movb $0x0, -0x1(%rbp)
jmp 0x9d68b
movb $0x1, -0x1(%rbp)
jmp 0x9d68b
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movb $0x0, 0x96ce0(%rax,%rcx)
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)