// File: /workspace/github_cpp_makefile_star2_O3/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 0x1dc86(%rip), %r8      # 0x768bc
movslq (%r8), %r9
movslq %edx, %rax
movq %rax, %rdx
subq %r9, %rdx
movsbl 0x43f8(%rdi,%rdx), %r9d
cmpl %r9d, %esi
jne 0x58ca3
movslq 0x95720(%rdi,%rdx,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x58c89
cmpl $0x1, %edx
jne 0x58ca3
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x58ca3
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x58ca3
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x58ca3
movb $0x1, 0x97374(%rdi,%rdx)
movsbl 0x43f7(%rdi,%rax), %edx
cmpl %edx, %esi
jne 0x58d02
movslq 0x9571c(%rdi,%rax,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x58ce8
cmpl $0x1, %edx
jne 0x58d02
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x58d02
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x58d02
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x58d02
movb $0x1, 0x97374(%rdi,%rdx)
movsbl 0x43f9(%rdi,%rax), %edx
cmpl %edx, %esi
jne 0x58d61
movslq 0x95724(%rdi,%rax,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %edx
cmpl $0x2, %edx
je 0x58d47
cmpl $0x1, %edx
jne 0x58d61
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x3, 0x97372(%rdi,%rdx)
ja 0x58d61
movb $0x4, 0x97372(%rdi,%rdx)
jmp 0x58d61
leaq (%rax,%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
cmpb $0x0, 0x97374(%rdi,%rdx)
jne 0x58d61
movb $0x1, 0x97374(%rdi,%rdx)
movslq (%r8), %rdx
addq %rax, %rdx
movsbl 0x43f8(%rdi,%rdx), %r8d
cmpl %r8d, %esi
jne 0x58dbd
movslq 0x95720(%rdi,%rdx,4), %rdx
imulq $0x7c8, %rdx, %rdx      # imm = 0x7C8
movl 0x4(%rcx,%rdx), %ecx
cmpl $0x2, %ecx
je 0x58dac
cmpl $0x1, %ecx
jne 0x58dbd
addq %rax, %rax
leaq (%rax,%rax,2), %rax
cmpb $0x3, 0x97372(%rdi,%rax)
ja 0x58dbd
movb $0x4, 0x97372(%rdi,%rax)
retq
addq %rax, %rax
leaq (%rax,%rax,2), %rax
cmpb $0x0, 0x97374(%rdi,%rax)
je 0x58dbe
retq
movb $0x1, 0x97374(%rdi,%rax)
retq