// File: kobanium[P]Ray/src/feature/SimulationFeature.cpp
// Function: CheckFeaturesForSimulation(game_info_t*, int, int*, int&)
void
CheckFeaturesForSimulation( game_info_t *game, const int color, int update[], int &update_num )
{
  const string_t *string = game->string;
  const char *board = game->board;
  const int *string_id = game->string_id;
  const int previous_move = game->record[game->moves - 1].pos;
  int id, checked = 0;
  int check[3] = { 0 };

  if (game->moves < 2) return;

  if (previous_move == PASS) return;

  // 直前の着手の上を確認
  if (board[NORTH(previous_move)] == color) {
    id = string_id[NORTH(previous_move)];
    if (string[id].libs == 1) {
      CheckFeatureLib1ForSimulation(game, color, id, update, update_num);
    } else if (string[id].libs == 2) {
      CheckFeatureLib2ForSimulation(game, color, id, update, update_num);
    } else if (string[id].libs == 3) {
      CheckFeatureLib3ForSimulation(game, color, id, update, update_num);
    }
    check[checked++] = id;
  }

  // 直前の着手の左を確認
  if (board[WEST(previous_move)] == color) {
    id = string_id[WEST(previous_move)];
    if (id != check[0]) {
      if (string[id].libs == 1) {
        CheckFeatureLib1ForSimulation(game, color, id, update, update_num);
      } else if (string[id].libs == 2) {
        CheckFeatureLib2ForSimulation(game, color, id, update, update_num);
      } else if (string[id].libs == 3) {
        CheckFeatureLib3ForSimulation(game, color, id, update, update_num);
      }
    }
    check[checked++] = id;
  }

  // 直前の着手の右を確認
  if (board[EAST(previous_move)] == color) {
    id = string_id[EAST(previous_move)];
    if (id != check[0] && id != check[1]) {
      if (string[id].libs == 1) {
        CheckFeatureLib1ForSimulation(game, color, id, update, update_num);
      } else if (string[id].libs == 2) {
        CheckFeatureLib2ForSimulation(game, color, id, update, update_num);
      } else if (string[id].libs == 3) {
        CheckFeatureLib3ForSimulation(game, color, id, update, update_num);
      }
    }
    check[checked++] = id;
  }

  // 直前の着手の下の確認
  if (board[SOUTH(previous_move)] == color) {
    id = string_id[SOUTH(previous_move)];
    if (id != check[0] && id != check[1] && id != check[2]) {
      if (string[id].libs == 1) {
        CheckFeatureLib1ForSimulation(game, color, id, update, update_num);
      } else if (string[id].libs == 2) {
        CheckFeatureLib2ForSimulation(game, color, id, update, update_num);
      } else if (string[id].libs == 3) {
        CheckFeatureLib3ForSimulation(game, color, id, update, update_num);
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq $0x9620, %rax           # imm = 0x9620
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
addq $0x43f8, %rax           # imm = 0x43F8
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
addq $0x95720, %rax          # imm = 0x95720
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x43b0(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x44(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x72b0
movq -0x8(%rbp), %rax
cmpl $0x2, 0x43b0(%rax)
jge 0xa08ab
jmp 0xa0c62
cmpl $0x0, -0x3c(%rbp)
jne 0xa08b6
jmp 0xa0c62
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
leaq 0x47188(%rip), %rdx     # 0xe7a4c
subl (%rdx), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0xc(%rbp), %eax
jne 0xa0998
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %ecx
leaq 0x47168(%rip), %rdx     # 0xe7a4c
subl (%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jne 0xa0920
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa0c70
jmp 0xa0984
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x4(%rax)
jne 0xa0951
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa12c0
jmp 0xa0982
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x3, 0x4(%rax)
jne 0xa0980
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa1a00
jmp 0xa0982
jmp 0xa0984
movl -0x40(%rbp), %ecx
movl -0x44(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x44(%rbp)
cltq
movl %ecx, -0x50(%rbp,%rax,4)
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0xc(%rbp), %eax
jne 0xa0a7c
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x50(%rbp), %eax
je 0xa0a68
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jne 0xa0a02
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa0c70
jmp 0xa0a66
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x4(%rax)
jne 0xa0a33
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa12c0
jmp 0xa0a64
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x3, 0x4(%rax)
jne 0xa0a62
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa1a00
jmp 0xa0a64
jmp 0xa0a66
jmp 0xa0a68
movl -0x40(%rbp), %ecx
movl -0x44(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x44(%rbp)
cltq
movl %ecx, -0x50(%rbp,%rax,4)
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0xc(%rbp), %eax
jne 0xa0b6c
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x50(%rbp), %eax
je 0xa0b58
movl -0x40(%rbp), %eax
cmpl -0x4c(%rbp), %eax
je 0xa0b58
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jne 0xa0af2
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa0c70
jmp 0xa0b56
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x4(%rax)
jne 0xa0b23
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa12c0
jmp 0xa0b54
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x3, 0x4(%rax)
jne 0xa0b52
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa1a00
jmp 0xa0b54
jmp 0xa0b56
jmp 0xa0b58
movl -0x40(%rbp), %ecx
movl -0x44(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x44(%rbp)
cltq
movl %ecx, -0x50(%rbp,%rax,4)
movq -0x30(%rbp), %rax
movl -0x3c(%rbp), %ecx
leaq 0x46ed2(%rip), %rdx     # 0xe7a4c
addl (%rdx), %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl -0xc(%rbp), %eax
jne 0xa0c62
movq -0x38(%rbp), %rax
movl -0x3c(%rbp), %ecx
leaq 0x46eb2(%rip), %rdx     # 0xe7a4c
addl (%rdx), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x50(%rbp), %eax
je 0xa0c60
movl -0x40(%rbp), %eax
cmpl -0x4c(%rbp), %eax
je 0xa0c60
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0xa0c60
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jne 0xa0bfa
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa0c70
jmp 0xa0c5e
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x4(%rax)
jne 0xa0c2b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa12c0
jmp 0xa0c5c
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x3, 0x4(%rax)
jne 0xa0c5a
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
callq 0xa1a00
jmp 0xa0c5c
jmp 0xa0c5e
jmp 0xa0c60
jmp 0xa0c62
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)