// File: /workspace/github_cpp_makefile_star2_O1/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, %r8
movq %rdx, %r14
movslq 0x43b0(%rdi), %rax
cmpq $0x2, %rax
setl %cl
shlq $0x4, %rax
movl -0xc(%rax,%rdi), %eax
movl $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
testl %eax, %eax
sete %dl
orb %cl, %dl
jne 0x56a69
movl %esi, %ebp
movq %rdi, %r15
leaq 0x9620(%rdi), %rsi
movslq %eax, %r13
leaq 0x1f0d8(%rip), %rdx     # 0x758bc
movslq (%rdx), %rcx
movq %r13, %rax
subq %rcx, %rax
movsbl 0x43f8(%rdi,%rax), %ecx
xorl %ebx, %ebx
cmpl %ebp, %ecx
jne 0x56886
movslq 0x95720(%r15,%rax,4), %r12
imulq $0x7c8, %r12, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x56855
cmpl $0x2, %eax
je 0x5683b
cmpl $0x1, %eax
jne 0x5687c
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, %rbx
callq 0x56aae
jmp 0x5686d
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, %rbx
callq 0x56ecb
jmp 0x5686d
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, %rbx
callq 0x57442
leaq 0x1f048(%rip), %rdx     # 0x758bc
movq 0x10(%rsp), %rsi
movq %rbx, %r8
movl %r12d, 0x18(%rsp)
movl $0x1, %ebx
movsbl 0x43f7(%r15,%r13), %eax
cmpl %ebp, %eax
jne 0x56942
movl 0x9571c(%r15,%r13,4), %r12d
cmpl 0x18(%rsp), %r12d
je 0x56939
movslq %r12d, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x56909
cmpl $0x2, %eax
je 0x568e8
cmpl $0x1, %eax
jne 0x56939
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, 0x8(%rsp)
movq 0x8(%rsp), %r8
callq 0x56aae
jmp 0x56928
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, 0x8(%rsp)
movq 0x8(%rsp), %r8
callq 0x56ecb
jmp 0x56928
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, 0x8(%rsp)
movq 0x8(%rsp), %r8
callq 0x57442
leaq 0x1ef8d(%rip), %rdx     # 0x758bc
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %r8
movl %ebx, %eax
incl %ebx
movl %r12d, 0x18(%rsp,%rax,4)
movsbl 0x43f9(%r15,%r13), %eax
cmpl %ebp, %eax
jne 0x56a07
movl 0x95724(%r15,%r13,4), %r12d
cmpl 0x18(%rsp), %r12d
je 0x56a00
cmpl 0x1c(%rsp), %r12d
je 0x56a00
movslq %r12d, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x569d0
cmpl $0x2, %eax
je 0x569af
cmpl $0x1, %eax
jne 0x56a00
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, 0x8(%rsp)
movq 0x8(%rsp), %r8
callq 0x56aae
jmp 0x569ef
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, 0x8(%rsp)
movq 0x8(%rsp), %r8
callq 0x56ecb
jmp 0x569ef
movq %r15, %rdi
movq %rsi, 0x10(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r14, %rcx
movq %r8, 0x8(%rsp)
movq 0x8(%rsp), %r8
callq 0x57442
leaq 0x1eec6(%rip), %rdx     # 0x758bc
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %r8
movl %ebx, %eax
movl %r12d, 0x18(%rsp,%rax,4)
movslq (%rdx), %rax
addq %r13, %rax
movsbl 0x43f8(%r15,%rax), %ecx
cmpl %ebp, %ecx
jne 0x56a69
movl 0x95720(%r15,%rax,4), %edx
cmpl 0x18(%rsp), %edx
je 0x56a69
cmpl 0x1c(%rsp), %edx
je 0x56a69
cmpl 0x20(%rsp), %edx
je 0x56a69
movslq %edx, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x56a93
cmpl $0x2, %eax
je 0x56a78
cmpl $0x1, %eax
jne 0x56a69
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x56aae
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x56ecb
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rcx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x57442