// File: /workspace/github_cpp_makefile_star2_O3/kobanium[P]Ray/src/feature/SimulationFeature.cpp
// Function: CheckFeatureLib2ForSimulation(game_info_t*, int, int, int*, int&)
static void
CheckFeatureLib2ForSimulation( game_info_t *game, const int color, const int id, int update[], int &update_num )
{
  const int *string_id = game->string_id;
  const string_t *string = game->string;
  const char *board = game->board;
  int neighbor = string[id].neighbor[0];
  int lib1, lib2;
  bool capturable1, capturable2;

  // 呼吸点が2つになった連の呼吸点を取り出す
  lib1 = string[id].lib[0];
  lib2 = string[id].lib[lib1];

  // 呼吸点の周囲が空点3つ, または呼吸点が3つ以上の自分の連に接続できるかで特徴を判定
  if (nb4_empty[Pat3(game->pat, lib1)] == 3 ||
      (board[NORTH(lib1)] == color && string_id[NORTH(lib1)] != id &&
       string[string_id[NORTH(lib1)]].libs >= 3) ||
      (board[ WEST(lib1)] == color && string_id[ WEST(lib1)] != id &&
       string[string_id[WEST(lib1)]].libs >= 3) ||
      (board[ EAST(lib1)] == color && string_id[ EAST(lib1)] != id &&
       string[string_id[EAST(lib1)]].libs >= 3) ||
      (board[SOUTH(lib1)] == color && string_id[SOUTH(lib1)] != id &&
       string[string_id[SOUTH(lib1)]].libs >= 3)) {
    CompareSwapFeature(game->tactical_features, lib1, EXTENSION, SIM_2POINT_EXTENSION_SAFELY);
  } else {
    CompareSwapFeature(game->tactical_features, lib1, EXTENSION, SIM_2POINT_EXTENSION);
  }

  // 呼吸点の周囲が空点3つ, または呼吸点が3つ以上の自分の連に接続できるかで特徴を判定
  if (nb4_empty[Pat3(game->pat, lib2)] == 3 ||
      (board[NORTH(lib2)] == color && string_id[NORTH(lib2)] != id &&
       string[string_id[NORTH(lib2)]].libs >= 3) ||
      (board[ WEST(lib2)] == color && string_id[ WEST(lib2)] != id &&
       string[string_id[WEST(lib2)]].libs >= 3) ||
      (board[ EAST(lib2)] == color && string_id[ EAST(lib2)] != id &&
       string[string_id[EAST(lib2)]].libs >= 3) ||
      (board[SOUTH(lib2)] == color && string_id[SOUTH(lib2)] != id &&
       string[string_id[SOUTH(lib2)]].libs >= 3)) {
    CompareSwapFeature(game->tactical_features, lib2, EXTENSION, SIM_2POINT_EXTENSION_SAFELY);
  } else {
    CompareSwapFeature(game->tactical_features, lib2, EXTENSION, SIM_2POINT_EXTENSION);
  }

  // レートの更新対象に入れる
  update[update_num++] = lib1;
  update[update_num++] = lib2;

  // 呼吸点が2つになった連の周囲の敵連を調べる
  // 1. 呼吸点が1つの敵連
  // 2. 呼吸点が2つの敵連
  // それぞれに対して, 特徴を判定する
  while (neighbor != NEIGHBOR_END) {
    if (string[neighbor].libs == 1) {
      lib1 = string[neighbor].lib[0];
      update[update_num++] = lib1;
      if (string[neighbor].size <= 2) {
        CompareSwapFeature(game->tactical_features, lib1, CAPTURE, SIM_2POINT_CAPTURE_SMALL);
      } else {
        CompareSwapFeature(game->tactical_features, lib1, CAPTURE, SIM_2POINT_CAPTURE_LARGE);
      }
    } else if (string[neighbor].libs == 2) {
      lib1 = string[neighbor].lib[0];
      lib2 = string[neighbor].lib[lib1];
      update[update_num++] = lib1;
      update[update_num++] = lib2;
      capturable1 = IsCapturableAtariForSimulation(game, lib1, color, neighbor);
      capturable2 = IsCapturableAtariForSimulation(game, lib2, color, neighbor);
      if (string[neighbor].size <= 2) {
        if (capturable1) {
          CompareSwapFeature(game->tactical_features, lib1, ATARI, SIM_2POINT_C_ATARI_SMALL);
        } else {
          CompareSwapFeature(game->tactical_features, lib1, ATARI, SIM_2POINT_ATARI_SMALL);
        }
        if (capturable2) {
          CompareSwapFeature(game->tactical_features, lib2, ATARI, SIM_2POINT_C_ATARI_SMALL);
        } else {
          CompareSwapFeature(game->tactical_features, lib2, ATARI, SIM_2POINT_ATARI_SMALL);
        }
      } else {
        if (capturable1) {
          CompareSwapFeature(game->tactical_features, lib1, ATARI, SIM_2POINT_C_ATARI_LARGE);
        } else {
          CompareSwapFeature(game->tactical_features, lib1, ATARI, SIM_2POINT_ATARI_LARGE);
        }
        if (capturable2) {
          CompareSwapFeature(game->tactical_features, lib2, ATARI, SIM_2POINT_C_ATARI_LARGE);
        } else {
          CompareSwapFeature(game->tactical_features, lib2, ATARI, SIM_2POINT_ATARI_LARGE);
        }
      }
    }
    neighbor = string[id].neighbor[neighbor];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movl %esi, 0x4(%rsp)
movq %rdi, %r15
leaq 0x9620(%rdi), %rax
movq %rax, 0x8(%rsp)
movl %edx, (%rsp)
movslq %edx, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
addq %rdi, %rax
addq $0x9620, %rax           # imm = 0x9620
movzwl 0x57c(%rax), %ebp
movswl 0x8(%rax), %r14d
movslq %r14d, %r12
movq %rax, 0x10(%rsp)
movswl 0x8(%rax,%r12,2), %ebx
leaq 0x4748(%rdi), %r13
movq %r13, %rdi
movl %r12d, %esi
callq 0x4fc2a
movl %eax, %eax
leaq 0x1aae7dfd(%rip), %rcx  # 0x1ab3f6e0
cmpb $0x3, (%rcx,%rax)
jne 0x5790d
addq %r12, %r12
leaq (%r12,%r12,2), %rax
cmpb $0x3, 0x97375(%r15,%rax)
ja 0x57a06
movb $0x4, 0x97375(%r15,%rax)
jmp 0x57a06
leaq 0x1efa8(%rip), %rax     # 0x768bc
movl (%rax), %eax
movl %r14d, %ecx
subl %eax, %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%r15,%rcx), %edx
cmpl 0x4(%rsp), %edx
jne 0x5794d
movslq 0x95720(%r15,%rcx,4), %rcx
cmpl (%rsp), %ecx
je 0x5794d
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
movq 0x8(%rsp), %rdx
cmpl $0x2, 0x4(%rdx,%rcx)
jg 0x578e9
movsbl 0x43f7(%r15,%r12), %ecx
cmpl 0x4(%rsp), %ecx
jne 0x57980
movslq 0x9571c(%r15,%r12,4), %rcx
cmpl (%rsp), %ecx
je 0x57980
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
movq 0x8(%rsp), %rdx
cmpl $0x2, 0x4(%rdx,%rcx)
jg 0x578e9
movsbl 0x43f9(%r15,%r12), %ecx
cmpl 0x4(%rsp), %ecx
jne 0x579b3
movslq 0x95724(%r15,%r12,4), %rcx
cmpl (%rsp), %ecx
je 0x579b3
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
movq 0x8(%rsp), %rdx
cmpl $0x2, 0x4(%rdx,%rcx)
jg 0x578e9
addl %r14d, %eax
cltq
movsbl 0x43f8(%r15,%rax), %ecx
cmpl 0x4(%rsp), %ecx
jne 0x579eb
movslq 0x95720(%r15,%rax,4), %rax
cmpl (%rsp), %eax
je 0x579eb
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
movq 0x8(%rsp), %rcx
cmpl $0x3, 0x4(%rcx,%rax)
jge 0x578e9
addq %r12, %r12
leaq (%r12,%r12,2), %rax
cmpb $0x1, 0x97375(%r15,%rax)
ja 0x57a06
movb $0x2, 0x97375(%r15,%rax)
movslq %ebx, %r12
movq %r13, %rdi
movl %r12d, %esi
callq 0x4fc2a
movl %eax, %eax
leaq 0x1aae7cc3(%rip), %rcx  # 0x1ab3f6e0
cmpb $0x3, (%rcx,%rax)
movq 0x8(%rsp), %r8
jne 0x57a5b
addq %r12, %r12
leaq (%r12,%r12,2), %rax
cmpb $0x3, 0x97375(%r15,%rax)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %r9
ja 0x57b51
movb $0x4, 0x97375(%r15,%rax)
jmp 0x57b51
leaq 0x1ee5a(%rip), %rax     # 0x768bc
movl (%rax), %eax
movl %ebx, %ecx
subl %eax, %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%r15,%rcx), %edx
cmpl 0x4(%rsp), %edx
jne 0x57a96
movslq 0x95720(%r15,%rcx,4), %rcx
cmpl (%rsp), %ecx
je 0x57a96
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
cmpl $0x2, 0x4(%r8,%rcx)
jg 0x57a28
movsbl 0x43f7(%r15,%r12), %ecx
cmpl 0x4(%rsp), %ecx
jne 0x57ac5
movslq 0x9571c(%r15,%r12,4), %rcx
cmpl (%rsp), %ecx
je 0x57ac5
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
cmpl $0x2, 0x4(%r8,%rcx)
jg 0x57a28
movsbl 0x43f9(%r15,%r12), %ecx
cmpl 0x4(%rsp), %ecx
jne 0x57af4
movslq 0x95724(%r15,%r12,4), %rcx
cmpl (%rsp), %ecx
je 0x57af4
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
cmpl $0x2, 0x4(%r8,%rcx)
jg 0x57a28
addl %ebx, %eax
cltq
movsbl 0x43f8(%r15,%rax), %ecx
cmpl 0x4(%rsp), %ecx
jne 0x57b27
movslq 0x95720(%r15,%rax,4), %rax
cmpl (%rsp), %eax
je 0x57b27
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
cmpl $0x3, 0x4(%r8,%rax)
jge 0x57a28
addq %r12, %r12
leaq (%r12,%r12,2), %rax
cmpb $0x1, 0x97375(%r15,%rax)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %r9
ja 0x57b51
movb $0x2, 0x97375(%r15,%rax)
movslq (%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%rdi)
movl %r14d, (%rsi,%rax,4)
movslq (%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%rdi)
movl %ebx, (%rsi,%rax,4)
movzwl %bp, %eax
cmpl $0x11f, %eax            # imm = 0x11F
je 0x57d7c
movswq %bp, %r12
imulq $0x7c8, %r12, %rax      # imm = 0x7C8
leaq (%r8,%rax), %rbx
movl 0x4(%r8,%rax), %eax
cmpl $0x2, %eax
je 0x57bdc
cmpl $0x1, %eax
jne 0x57d67
movswl 0x8(%rbx), %eax
cltq
movslq (%rdi), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rdi)
movl %eax, (%rsi,%rcx,4)
addq %rax, %rax
cmpl $0x2, 0x7c0(%rbx)
leaq (%rax,%rax,2), %rax
movb 0x97372(%r15,%rax), %cl
jg 0x57c69
cmpb $0x5, %cl
ja 0x57d67
movb $0x6, 0x97372(%r15,%rax)
jmp 0x57d67
movswl 0x8(%rbx), %eax
movslq %eax, %rbp
movswl 0x8(%rbx,%rbp,2), %eax
movslq %eax, %r13
movslq (%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%rdi)
movl %ebp, (%rsi,%rax,4)
movslq (%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%rdi)
movl %r13d, (%rsi,%rax,4)
movq %r15, %rdi
movl %ebp, %esi
movq %r15, %r14
movl 0x4(%rsp), %r15d
movl %r15d, %edx
movl %r12d, %ecx
callq 0x5bbbf
movb %al, (%rsp)
movq %r14, %rdi
movl %r13d, %esi
movl %r15d, %edx
movq %r14, %r15
movl %r12d, %ecx
callq 0x5bbbf
addq %rbp, %rbp
cmpl $0x2, 0x7c0(%rbx)
leaq (%rbp,%rbp,2), %rcx
movb 0x97374(%r14,%rcx), %dl
jg 0x57c80
cmpb $0x0, (%rsp)
je 0x57c9f
movb $0x7, %sil
cmpb $0x7, %dl
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
jb 0x57cb6
jmp 0x57cbe
cmpb $0x7, %cl
ja 0x57d67
movb $0x8, 0x97372(%r15,%rax)
jmp 0x57d67
cmpb $0x0, (%rsp)
je 0x57cf1
movb $0x9, %sil
cmpb $0x9, %dl
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
jb 0x57d08
jmp 0x57d10
movb $0x3, %sil
cmpb $0x2, %dl
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
ja 0x57cbe
movb %sil, 0x97374(%r15,%rcx)
addq %r13, %r13
leaq (,%r13,2), %rcx
addq %r13, %rcx
movb 0x97374(%r15,%rcx), %dl
testb %al, %al
je 0x57d3f
cmpb $0x6, %dl
movq 0x18(%rsp), %rsi
ja 0x57d67
movb $0x7, 0x97374(%r15,%rcx)
jmp 0x57d67
movb $0x5, %sil
cmpb $0x4, %dl
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %r9
ja 0x57d10
movb %sil, 0x97374(%r15,%rcx)
addq %r13, %r13
leaq (,%r13,2), %rcx
addq %r13, %rcx
movb 0x97374(%r15,%rcx), %dl
testb %al, %al
je 0x57d54
cmpb $0x8, %dl
movq 0x18(%rsp), %rsi
ja 0x57d67
movb $0x9, 0x97374(%r15,%rcx)
jmp 0x57d67
cmpb $0x2, %dl
movq 0x18(%rsp), %rsi
ja 0x57d67
movb $0x3, 0x97374(%r15,%rcx)
jmp 0x57d67
cmpb $0x4, %dl
movq 0x18(%rsp), %rsi
ja 0x57d67
movb $0x5, 0x97374(%r15,%rcx)
movzwl 0x57c(%r9,%r12,2), %ebp
cmpl $0x11f, %ebp            # imm = 0x11F
jne 0x57b76
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq