// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r13
movslq 0x43b0(%rdi), %rax
cmpq $0x2, %rax
setl %cl
shlq $0x4, %rax
movl -0xc(%rax,%rdi), %eax
andl $0x0, 0x20(%rsp)
movq %rdx, %r8
andq $0x0, 0x18(%rsp)
testl %eax, %eax
sete %dl
orb %cl, %dl
jne 0x3da16
movq %rdi, %r15
movl %esi, %ebp
leaq 0x9620(%rdi), %rsi
movslq %eax, %rbx
leaq 0x2413a(%rip), %rdx     # 0x618bc
movslq (%rdx), %rcx
movq %rbx, %rax
subq %rcx, %rax
movsbl 0x43f8(%rdi,%rax), %ecx
xorl %r12d, %r12d
movl $0x0, %r14d
cmpl %ebp, %ecx
jne 0x3d833
movslq 0x95720(%r15,%rax,4), %r12
imulq $0x7c8, %r12, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x3d800
cmpl $0x2, %eax
je 0x3d7e3
cmpl $0x1, %eax
jne 0x3d82a
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, %r14
movq %r13, %r8
callq 0x3da61
jmp 0x3d81b
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, %r14
movq %r13, %r8
callq 0x3de1c
jmp 0x3d81b
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, %r14
movq %r13, %r8
callq 0x3e31e
leaq 0x2409a(%rip), %rdx     # 0x618bc
movq 0x8(%rsp), %rsi
movq %r14, %r8
movl %r12d, 0x18(%rsp)
pushq $0x1
popq %r14
movsbl 0x43f7(%r15,%rbx), %eax
cmpl %ebp, %eax
jne 0x3d8f1
movq %r13, 0x10(%rsp)
movl 0x9571c(%r15,%rbx,4), %r13d
cmpl %r12d, %r13d
je 0x3d8e1
movslq %r13d, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x3d8b5
cmpl $0x2, %eax
je 0x3d896
cmpl $0x1, %eax
jne 0x3d8e1
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r13d, %edx
movq %r8, %rcx
movq %r8, %r12
movq 0x10(%rsp), %r8
callq 0x3da61
jmp 0x3d8d2
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r13d, %edx
movq %r8, %rcx
movq %r8, %r12
movq 0x10(%rsp), %r8
callq 0x3de1c
jmp 0x3d8d2
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r13d, %edx
movq %r8, %rcx
movq %r8, %r12
movq 0x10(%rsp), %r8
callq 0x3e31e
leaq 0x23fe3(%rip), %rdx     # 0x618bc
movq 0x8(%rsp), %rsi
movq %r12, %r8
movl %r14d, %eax
incl %r14d
movl %r13d, 0x18(%rsp,%rax,4)
movq 0x10(%rsp), %r13
movsbl 0x43f9(%r15,%rbx), %eax
cmpl %ebp, %eax
jne 0x3d9b1
movl 0x95724(%r15,%rbx,4), %r12d
cmpl 0x18(%rsp), %r12d
je 0x3d9a9
cmpl 0x1c(%rsp), %r12d
je 0x3d9a9
movslq %r12d, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x3d97b
cmpl $0x2, %eax
je 0x3d95c
cmpl $0x1, %eax
jne 0x3d9a9
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, 0x10(%rsp)
movq %r13, %r8
callq 0x3da61
jmp 0x3d998
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, 0x10(%rsp)
movq %r13, %r8
callq 0x3de1c
jmp 0x3d998
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, 0x10(%rsp)
movq %r13, %r8
callq 0x3e31e
leaq 0x23f1d(%rip), %rdx     # 0x618bc
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %r8
movl %r14d, %eax
movl %r12d, 0x18(%rsp,%rax,4)
movslq (%rdx), %rax
addq %rbx, %rax
movsbl 0x43f8(%r15,%rax), %ecx
cmpl %ebp, %ecx
jne 0x3da16
movl 0x95720(%r15,%rax,4), %edx
cmpl 0x18(%rsp), %edx
je 0x3da16
cmpl 0x1c(%rsp), %edx
je 0x3da16
cmpl 0x20(%rsp), %edx
je 0x3da16
movslq %edx, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x3da43
cmpl $0x2, %eax
je 0x3da25
cmpl $0x1, %eax
jne 0x3da16
movq %r15, %rdi
movl %ebp, %esi
movq %r8, %rcx
movq %r13, %r8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3da61
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movl %ebp, %esi
movq %r8, %rcx
movq %r13, %r8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3de1c
movq %r15, %rdi
movl %ebp, %esi
movq %r8, %rcx
movq %r13, %r8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3e31e