// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/feature/SimulationFeature.cpp
// Function: CheckCaptureAndAtariForSimulation(game_info_t*, int, int)
void
CheckCaptureAndAtariForSimulation( game_info_t *game, const int color, const int pos )
{
  const char *board = game->board;
  const string_t *string = game->string;
  const int *string_id = game->string_id;
  const int other = GetOppositeColor(color);

  // 上を調べる
  // 1. 敵の石
  // 2. 呼吸点が1つ
  if (board[NORTH(pos)] == other) {
    const int libs = string[string_id[NORTH(pos)]].libs;
    if (libs == 1) {
      CompareSwapFeature(game->tactical_features, pos, CAPTURE, SIM_CAPTURE);
    } else if (libs == 2) {
      CompareSwapFeature(game->tactical_features, pos, ATARI, SIM_ATARI);
    }
  }

  //  左を調べる
  // 1. 敵の石
  // 2. 呼吸点が1つ
  if (board[WEST(pos)] == other) {
    const int libs = string[string_id[WEST(pos)]].libs;
    if (libs == 1) {
      CompareSwapFeature(game->tactical_features, pos, CAPTURE, SIM_CAPTURE);
    } else if (libs == 2) {
      CompareSwapFeature(game->tactical_features, pos, ATARI, SIM_ATARI);
    }
  }

  //  右を調べる
  // 1. 敵の石
  // 2. 呼吸点が1つ
  if (board[EAST(pos)] == other) {
    const int libs = string[string_id[EAST(pos)]].libs;
    if (libs == 1) {
      CompareSwapFeature(game->tactical_features, pos, CAPTURE, SIM_CAPTURE);
    } else if (libs == 2) {
      CompareSwapFeature(game->tactical_features, pos, ATARI, SIM_ATARI);
    }
  }

  //  下を調べる
  // 1. 敵の石
  // 2. 呼吸点が1つ
  if (board[SOUTH(pos)] == other) {
    const int libs = string[string_id[SOUTH(pos)]].libs;
    if (libs == 1) {
      CompareSwapFeature(game->tactical_features, pos, CAPTURE, SIM_CAPTURE);
    } else if (libs == 2) {
      CompareSwapFeature(game->tactical_features, pos, ATARI, SIM_ATARI);
    }
  }
}

// Assembly:
leaq 0x9620(%rdi), %rcx
xorl $0x3, %esi
leaq 0x1d5ab(%rip), %r8      # 0x758bc
movslq (%r8), %r9
movslq %edx, %rax
movq %rax, %rdx
subq %r9, %rdx
movsbl 0x43f8(%rdi,%rdx), %r9d
cmpl %r9d, %esi
jne 0x5837e
movslq 0x95720(%rdi,%rdx,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x58364
cmpl $0x1, %edx
jne 0x5837e
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x5837e
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x5837e
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x5837e
movb $0x1, 0x97374(%rdi,%rdx)
movsbl 0x43f7(%rdi,%rax), %edx
cmpl %edx, %esi
jne 0x583dd
movslq 0x9571c(%rdi,%rax,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x583c3
cmpl $0x1, %edx
jne 0x583dd
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x583dd
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x583dd
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x583dd
movb $0x1, 0x97374(%rdi,%rdx)
movsbl 0x43f9(%rdi,%rax), %edx
cmpl %edx, %esi
jne 0x5843c
movslq 0x95724(%rdi,%rax,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x58422
cmpl $0x1, %edx
jne 0x5843c
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x5843c
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x5843c
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x5843c
movb $0x1, 0x97374(%rdi,%rdx)
movslq (%r8), %rdx
addq %rax, %rdx
movsbl 0x43f8(%rdi,%rdx), %r8d
cmpl %r8d, %esi
jne 0x58498
movslq 0x95720(%rdi,%rdx,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %ecx
cmpl $0x2, %ecx
je 0x58487
cmpl $0x1, %ecx
jne 0x58498
addq %rax, %rax
leaq (%rax,%rax,2), %rax
cmpb $0x3, 0x97372(%rdi,%rax)
ja 0x58498
movb $0x4, 0x97372(%rdi,%rax)
retq
addq %rax, %rax
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0x97374(%rdi,%rax)
je 0x58499
retq
movb $0x1, 0x97374(%rdi,%rax)
retq