// File: /workspace/github_cpp_makefile_star2_O2/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 0x2271d(%rip), %r8      # 0x618bc
movslq (%r8), %r9
movslq %edx, %rax
movq %rax, %rdx
subq %r9, %rdx
movsbl 0x43f8(%rdi,%rdx), %r9d
cmpl %r9d, %esi
jne 0x3f204
movslq 0x95720(%rdi,%rdx,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x3f1ee
cmpl $0x1, %edx
jne 0x3f204
imulq $0x6, %rax, %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x3f204
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x3f204
imulq $0x6, %rax, %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x3f204
movb $0x1, 0x97374(%rdi,%rdx)
movsbl 0x43f7(%rdi,%rax), %edx
cmpl %edx, %esi
jne 0x3f25b
movslq 0x9571c(%rdi,%rax,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x3f245
cmpl $0x1, %edx
jne 0x3f25b
imulq $0x6, %rax, %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x3f25b
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x3f25b
imulq $0x6, %rax, %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x3f25b
movb $0x1, 0x97374(%rdi,%rdx)
movsbl 0x43f9(%rdi,%rax), %edx
cmpl %edx, %esi
jne 0x3f2b2
movslq 0x95724(%rdi,%rax,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x3f29c
cmpl $0x1, %edx
jne 0x3f2b2
imulq $0x6, %rax, %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x3f2b2
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x3f2b2
imulq $0x6, %rax, %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x3f2b2
movb $0x1, 0x97374(%rdi,%rdx)
movslq (%r8), %rdx
addq %rax, %rdx
movsbl 0x43f8(%rdi,%rdx), %r8d
cmpl %r8d, %esi
jne 0x3f308
movslq 0x95720(%rdi,%rdx,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %ecx
cmpl $0x2, %ecx
je 0x3f2fa
cmpl $0x1, %ecx
jne 0x3f308
imulq $0x6, %rax, %rax
cmpb $0x3, 0x97372(%rdi,%rax)
ja 0x3f308
movb $0x4, 0x97372(%rdi,%rax)
retq
imulq $0x6, %rax, %rax
cmpb $0x0, 0x97374(%rdi,%rax)
je 0x3f309
retq
movb $0x1, 0x97374(%rdi,%rax)
retq