// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
addq $0x43f8, %rax           # imm = 0x43F8
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x9620, %rax           # imm = 0x9620
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
addq $0x95720, %rax          # imm = 0x95720
movq %rax, -0x38(%rbp)
movl -0x18(%rbp), %edi
callq 0x25810
movl %eax, -0x3c(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0xa8b90
movq -0x10(%rbp), %rdi
addq $0x4748, %rdi           # imm = 0x4748
movl -0x14(%rbp), %esi
callq 0x93d30
movl %eax, %eax
movl %eax, %ecx
leaq 0x1ab07cd9(%rip), %rax  # 0x1abb0860
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xa8b99
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3eea5(%rip), %rdx     # 0xe7a4c
subl (%rdx), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x18(%rbp), %eax
jne 0xa8bf1
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3ee89(%rip), %rdx     # 0xe7a4c
subl (%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jle 0xa8bef
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8c57
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3ee4d(%rip), %rdx     # 0xe7a4c
subl (%rdx), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x3c(%rbp), %eax
jne 0xa8c55
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3ee31(%rip), %rdx     # 0xe7a4c
subl (%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movl 0x7c0(%rax), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $0x1, -0x44(%rbp)
jle 0xa8c53
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8c55
jmp 0xa8c57
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x18(%rbp), %eax
jne 0xa8ca3
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jle 0xa8ca1
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8cfd
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x3c(%rbp), %eax
jne 0xa8cfb
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movl 0x7c0(%rax), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $0x1, -0x44(%rbp)
jle 0xa8cf9
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8cfb
jmp 0xa8cfd
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x18(%rbp), %eax
jne 0xa8d49
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jle 0xa8d47
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8da3
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x3c(%rbp), %eax
jne 0xa8da1
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movl 0x7c0(%rax), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $0x1, -0x44(%rbp)
jle 0xa8d9f
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8da1
jmp 0xa8da3
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3ec9b(%rip), %rdx     # 0xe7a4c
addl (%rdx), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x18(%rbp), %eax
jne 0xa8df8
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3ec7f(%rip), %rdx     # 0xe7a4c
addl (%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jle 0xa8df6
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8e5b
movq -0x28(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3ec46(%rip), %rdx     # 0xe7a4c
addl (%rdx), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x3c(%rbp), %eax
jne 0xa8e59
movq -0x38(%rbp), %rax
movl -0x14(%rbp), %ecx
leaq 0x3ec2a(%rip), %rdx     # 0xe7a4c
addl (%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movl 0x7c0(%rax), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpl $0x1, -0x44(%rbp)
jle 0xa8e57
movb $0x0, -0x1(%rbp)
jmp 0xa8e5f
jmp 0xa8e59
jmp 0xa8e5b
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)