// File: kobanium[P]Ray/src/feature/SimulationFeature.cpp
// Function: CheckRemove2StonesForSimulation(game_info_t*, int, int*, int&)
void
CheckRemove2StonesForSimulation( game_info_t *game, const int color, int update[], int &update_num )
{
  const int other = GetOppositeColor(color);
  int i, check;

  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, check = 0; i < 4; i++) {
    if ((game->board[rm1 + cross[i]] & color) == color) {
      check++;
    }
  }

  if (check >= 2) {
    CompareSwapFeature(game->tactical_features, rm1, THROW_IN, SIM_THROW_IN_2);
    update[update_num++] = rm1;
  }

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

  if (check >= 2) {
    CompareSwapFeature(game->tactical_features, rm2, THROW_IN, SIM_THROW_IN_2);
    update[update_num++] = rm2;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0xc(%rbp), %edi
callq 0x25810
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x2, 0x98728(%rax,%rcx,4)
je 0xa343e
jmp 0xa35e2
movq -0x8(%rbp), %rax
addq $0x98738, %rax          # imm = 0x98738
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xae0, %rcx, %rcx      # imm = 0xAE0
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
addq $0x98738, %rax          # imm = 0x98738
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xae0, %rcx, %rcx      # imm = 0xAE0
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
subl -0x34(%rbp), %eax
cmpl $0x1, %eax
je 0xa34c4
movl -0x34(%rbp), %eax
subl -0x30(%rbp), %eax
cmpl $0x1, %eax
je 0xa34c4
movl -0x30(%rbp), %eax
subl -0x34(%rbp), %eax
leaq 0x445a2(%rip), %rcx     # 0xe7a4c
cmpl (%rcx), %eax
je 0xa34c4
movl -0x34(%rbp), %eax
subl -0x30(%rbp), %eax
leaq 0x44591(%rip), %rcx     # 0xe7a4c
cmpl (%rcx), %eax
je 0xa34c4
jmp 0xa35e2
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x4, -0x28(%rbp)
jge 0xa3516
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
movslq -0x28(%rbp), %rsi
leaq 0x1c704356(%rip), %rdx  # 0x1c7a7840
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
andl -0xc(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0xa3509
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xa350b
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa34d2
cmpl $0x2, -0x2c(%rbp)
jl 0xa3553
movq -0x8(%rbp), %rdi
addq $0x97372, %rdi          # imm = 0x97372
movl -0x30(%rbp), %esi
movl $0x5, %edx
movl $0x1, %ecx
callq 0xa35f0
movl -0x30(%rbp), %edx
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x4, -0x28(%rbp)
jge 0xa35a5
movq -0x8(%rbp), %rax
movl -0x34(%rbp), %ecx
movslq -0x28(%rbp), %rsi
leaq 0x1c7042c7(%rip), %rdx  # 0x1c7a7840
addl (%rdx,%rsi,4), %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
andl -0xc(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0xa3598
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xa359a
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xa3561
cmpl $0x2, -0x2c(%rbp)
jl 0xa35e2
movq -0x8(%rbp), %rdi
addq $0x97372, %rdi          # imm = 0x97372
movl -0x34(%rbp), %esi
movl $0x5, %edx
movl $0x1, %ecx
callq 0xa35f0
movl -0x34(%rbp), %edx
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)