// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rdx, %r8
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 0x57420
movl %esi, %ebp
movq %rdi, %r15
leaq 0x9620(%rdi), %rsi
movslq %eax, %rbx
leaq 0x1f732(%rip), %rdx     # 0x768bc
movslq (%rdx), %rcx
movq %rbx, %rax
subq %rcx, %rax
movsbl 0x43f8(%rdi,%rax), %ecx
xorl %r12d, %r12d
movl $0x0, %r14d
cmpl %ebp, %ecx
jne 0x5723d
movslq 0x95720(%r15,%rax,4), %r12
imulq $0x7c8, %r12, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x57208
cmpl $0x2, %eax
je 0x571eb
cmpl $0x1, %eax
jne 0x57232
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, %r14
movq %r13, %r8
callq 0x5746b
jmp 0x57223
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, %r14
movq %r13, %r8
callq 0x5786d
jmp 0x57223
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, %r14
movq %r13, %r8
callq 0x57d8b
leaq 0x1f692(%rip), %rdx     # 0x768bc
movq 0x8(%rsp), %rsi
movq %r14, %r8
movl %r12d, 0x18(%rsp)
movl $0x1, %r14d
movsbl 0x43f7(%r15,%rbx), %eax
cmpl %ebp, %eax
jne 0x572fb
movq %r13, 0x10(%rsp)
movl 0x9571c(%r15,%rbx,4), %r13d
cmpl %r12d, %r13d
je 0x572eb
movslq %r13d, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x572bf
cmpl $0x2, %eax
je 0x572a0
cmpl $0x1, %eax
jne 0x572eb
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r13d, %edx
movq %r8, %rcx
movq %r8, %r12
movq 0x10(%rsp), %r8
callq 0x5746b
jmp 0x572dc
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r13d, %edx
movq %r8, %rcx
movq %r8, %r12
movq 0x10(%rsp), %r8
callq 0x5786d
jmp 0x572dc
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r13d, %edx
movq %r8, %rcx
movq %r8, %r12
movq 0x10(%rsp), %r8
callq 0x57d8b
leaq 0x1f5d9(%rip), %rdx     # 0x768bc
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 0x573bb
movl 0x95724(%r15,%rbx,4), %r12d
cmpl 0x18(%rsp), %r12d
je 0x573b3
cmpl 0x1c(%rsp), %r12d
je 0x573b3
movslq %r12d, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x57385
cmpl $0x2, %eax
je 0x57366
cmpl $0x1, %eax
jne 0x573b3
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, 0x10(%rsp)
movq %r13, %r8
callq 0x5746b
jmp 0x573a2
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, 0x10(%rsp)
movq %r13, %r8
callq 0x5786d
jmp 0x573a2
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
movl %ebp, %esi
movl %r12d, %edx
movq %r8, %rcx
movq %r8, 0x10(%rsp)
movq %r13, %r8
callq 0x57d8b
leaq 0x1f513(%rip), %rdx     # 0x768bc
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 0x57420
movl 0x95720(%r15,%rax,4), %edx
cmpl 0x18(%rsp), %edx
je 0x57420
cmpl 0x1c(%rsp), %edx
je 0x57420
cmpl 0x20(%rsp), %edx
je 0x57420
movslq %edx, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movl 0x4(%rsi,%rax), %eax
cmpl $0x3, %eax
je 0x5744d
cmpl $0x2, %eax
je 0x5742f
cmpl $0x1, %eax
jne 0x57420
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 0x5746b
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 0x5786d
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 0x57d8b