// File: kobanium[P]Ray/src/feature/UctFeature.cpp
// Function: CheckRemove2StonesForTree(game_info_t const*, int, unsigned int*)
void
CheckRemove2StonesForTree( const game_info_t *game, const int color, unsigned int *tactical_features )
{
  const int other = GetOppositeColor(color);
  const int cross[4] = {- board_size - 1, - board_size + 1, board_size - 1, board_size + 1};
  int i, connect;

  if (game->capture_num[other - 1] != 2) {
    return;
  }

  const int rm1 = game->capture_pos[other - 1][0];
  const int rm2 = game->capture_pos[other - 1][rm1];

  if (rm1 - rm2 != 1 &&
      rm2 - rm1 != 1 &&
      rm1 - rm2 != board_size &&
      rm2 - rm1 != board_size) {
    return;
  }

  for (i = 0, connect = 0; i < 4; i++) {
    if ((game->board[rm1 + cross[i]] & color) == color) {
      connect++;
    }
  }

  if (connect >= 2) {
    CompareSwapFeature(tactical_features, rm1, UCT_THROW_IN_INDEX, UCT_THROW_IN_2);
  }

  for (i = 0, connect = 0; i < 4; i++) {
    if ((game->board[rm2 + cross[i]] & color) == color) {
      connect++;
    }
  }

  if (connect >= 2) {
    CompareSwapFeature(tactical_features, rm2, UCT_THROW_IN_INDEX, UCT_THROW_IN_2);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl -0xc(%rbp), %edi
callq 0x25810
movl %eax, -0x1c(%rbp)
xorl %eax, %eax
leaq 0x3fe45(%rip), %rcx     # 0xe7a4c
subl (%rcx), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
xorl %eax, %eax
leaq 0x3fe34(%rip), %rcx     # 0xe7a4c
subl (%rcx), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
leaq 0x3fe25(%rip), %rax     # 0xe7a4c
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
leaq 0x3fe16(%rip), %rax     # 0xe7a4c
movl (%rax), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x2, 0x98728(%rax,%rcx,4)
je 0xa7c5a
jmp 0xa7db0
movq -0x8(%rbp), %rax
addq $0x98738, %rax          # imm = 0x98738
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xae0, %rcx, %rcx      # imm = 0xAE0
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
addq $0x98738, %rax          # imm = 0x98738
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xae0, %rcx, %rcx      # imm = 0xAE0
addq %rcx, %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
subl -0x40(%rbp), %eax
cmpl $0x1, %eax
je 0xa7ce0
movl -0x40(%rbp), %eax
subl -0x3c(%rbp), %eax
cmpl $0x1, %eax
je 0xa7ce0
movl -0x3c(%rbp), %eax
subl -0x40(%rbp), %eax
leaq 0x3fd86(%rip), %rcx     # 0xe7a4c
cmpl (%rcx), %eax
je 0xa7ce0
movl -0x40(%rbp), %eax
subl -0x3c(%rbp), %eax
leaq 0x3fd75(%rip), %rcx     # 0xe7a4c
cmpl (%rcx), %eax
je 0xa7ce0
jmp 0xa7db0
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0xa7d2c
movq -0x8(%rbp), %rax
movl -0x3c(%rbp), %ecx
movslq -0x34(%rbp), %rdx
addl -0x30(%rbp,%rdx,4), %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
andl -0xc(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0xa7d1f
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xa7d21
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa7cee
cmpl $0x2, -0x38(%rbp)
jl 0xa7d48
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl $0x6, %edx
movl $0x1, %ecx
callq 0xa7430
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0xa7d94
movq -0x8(%rbp), %rax
movl -0x40(%rbp), %ecx
movslq -0x34(%rbp), %rdx
addl -0x30(%rbp,%rdx,4), %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
andl -0xc(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0xa7d87
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xa7d89
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa7d56
cmpl $0x2, -0x38(%rbp)
jl 0xa7db0
movq -0x18(%rbp), %rdi
movl -0x40(%rbp), %esi
movl $0x6, %edx
movl $0x1, %ecx
callq 0xa7430
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)