// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/feature/SimulationFeature.cpp
// Function: CheckFeatureLib1ForSimulation(game_info_t*, int, int, int*, int&)
static void
CheckFeatureLib1ForSimulation( game_info_t *game, const int color, const int id, int update[], int &update_num )
{
  const int other = GetOppositeColor(color);
  const char *board = game->board;
  const string_t *string = game->string;
  int neighbor = string[id].neighbor[0];
  int lib, liberty;
  bool contact = false;

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

  // 呼吸点の上下左右が敵石に接触しているか確認
  if (board[NORTH(lib)] == other) contact = true;
  if (board[ EAST(lib)] == other) contact = true;
  if (board[ WEST(lib)] == other) contact = true;
  if (board[SOUTH(lib)] == other) contact = true;

  // 呼吸点の上下左右が敵連に接しているか
  // また逃げ出す連の大きさで特徴を判定
  if (contact) {
    if (string[id].size == 1) {
      CompareSwapFeature(game->tactical_features, lib, SAVE_EXTENSION, SIM_SAVE_EXTENSION_1);
    } else if (string[id].size == 2) {
      CompareSwapFeature(game->tactical_features, lib, SAVE_EXTENSION, SIM_SAVE_EXTENSION_2);
    } else {
      CompareSwapFeature(game->tactical_features, lib, SAVE_EXTENSION, SIM_SAVE_EXTENSION_3);
    }
  } else {
    if (string[id].size == 1) {
      CompareSwapFeature(game->tactical_features, lib, SAVE_EXTENSION, SIM_SAVE_EXTENSION_SAFELY_1);
    } else if (string[id].size == 2) {
      CompareSwapFeature(game->tactical_features, lib, SAVE_EXTENSION, SIM_SAVE_EXTENSION_SAFELY_2);
    } else {
      CompareSwapFeature(game->tactical_features, lib, SAVE_EXTENSION, SIM_SAVE_EXTENSION_SAFELY_3);
    }
  }

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

  // 敵連を取ることによって連を助ける手の特徴の判定
  // 自分の連の大きさと敵の連の大きさで特徴を判定
  if (string[id].size == 1) {
    while (neighbor != NEIGHBOR_END) {
      if (string[neighbor].libs == 1) {
        lib = string[neighbor].lib[0];
        if (string[neighbor].size == 1) {
          CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_1_1);
        } else if (string[neighbor].size == 2) {
          CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_1_2);
        } else {
          CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_1_3);
        }
        update[update_num++] = lib;
      }
      neighbor = string[id].neighbor[neighbor];
    }
  } else if (string[id].size == 2) {
    while (neighbor != NEIGHBOR_END) {
      if (string[neighbor].libs == 1) {
        lib = string[neighbor].lib[0];
        if (string[neighbor].size == 1) {
          if (IsSelfAtariCaptureForSimulation(game, lib, color, liberty)) {
            CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_SELF_ATARI);
          } else {
            CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_2_1);
          }
        } else if (string[neighbor].size == 2) {
          CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_2_2);
        } else {
          CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_2_3);
        }
        update[update_num++] = lib;
      }
      neighbor = string[id].neighbor[neighbor];
    }
  } else if (string[id].size >= 3) {
    while (neighbor != NEIGHBOR_END) {
      if (string[neighbor].libs == 1) {
        lib = string[neighbor].lib[0];
        if (string[neighbor].size == 1) {
          if (IsSelfAtariCaptureForSimulation(game, lib, color, liberty)) {
            CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_SELF_ATARI);
          } else {
            CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_3_1);
          }
        } else if (string[neighbor].size == 2) {
          CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_3_2);
        } else {
          CompareSwapFeature(game->tactical_features, lib, CAPTURE, SIM_SAVE_CAPTURE_3_3);
        }
        update[update_num++] = lib;
      }
      neighbor = string[id].neighbor[neighbor];
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x8(%rsp)
movq %rdi, %r15
movl %esi, 0x14(%rsp)
xorl $0x3, %esi
movslq %edx, %rax
imulq $0x7c8, %rax, %rax      # imm = 0x7C8
leaq (%rdi,%rax), %rbp
addq $0x9620, %rbp           # imm = 0x9620
movswl 0x8(%rbp), %ebx
movslq %ebx, %r9
leaq 0x1edce(%rip), %rcx     # 0x758bc
movl (%rcx), %r11d
leal (%r11,%rbx), %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rdi,%rcx), %r10d
leaq (%r9,%r9), %rcx
leaq (%rcx,%rcx,2), %rdx
movb 0x97373(%rdi,%rdx), %dl
movl 0x7c0(%rbp), %edi
cmpl %r10d, %esi
je 0x56b6b
movsbl 0x43f7(%r15,%r9), %r10d
cmpl %r10d, %esi
je 0x56b6b
movsbl 0x43f9(%r15,%r9), %r9d
cmpl %r9d, %esi
je 0x56b6b
movl %ebx, %r9d
subl %r11d, %r9d
movslq %r9d, %r9
movsbl 0x43f8(%r15,%r9), %r9d
cmpl %r9d, %esi
je 0x56b6b
cmpl $0x2, %edi
je 0x56b8f
cmpl $0x1, %edi
movq 0x8(%rsp), %r9
jne 0x56eba
movb $0x4, %sil
cmpb $0x4, %dl
jb 0x56b9c
jmp 0x56bab
cmpl $0x2, %edi
je 0x56b87
cmpl $0x1, %edi
movq 0x8(%rsp), %r9
jne 0x56ea9
testb %dl, %dl
jne 0x56bab
movb $0x1, %sil
jmp 0x56b9c
movb $0x2, %sil
cmpb $0x2, %dl
jmp 0x56b95
movb $0x5, %sil
cmpb $0x5, %dl
movq 0x8(%rsp), %r9
jae 0x56bab
leaq (%rcx,%rcx,2), %rcx
incq %rcx
movb %sil, 0x97372(%r15,%rcx)
leaq 0x9620(%r15), %r12
movswl 0x9b9c(%r15,%rax), %eax
movslq (%r8), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r8)
movl %ebx, (%r9,%rcx,4)
movl 0x7c0(%rbp), %ecx
cmpl $0x1, %ecx
je 0x56d73
movq %rbx, 0x20(%rsp)
cmpl $0x2, %ecx
movq %r8, 0x18(%rsp)
jne 0x56d83
cmpl $0x11f, %eax            # imm = 0x11F
je 0x56e9a
movslq %eax, %r14
imulq $0x7c8, %r14, %rax      # imm = 0x7C8
cmpl $0x1, 0x4(%r12,%rax)
jne 0x56cde
addq %r12, %rax
movswl 0x8(%rax), %ebx
movslq %ebx, %r13
movl 0x7c0(%rax), %eax
cmpl $0x2, %eax
je 0x56c6b
cmpl $0x1, %eax
jne 0x56c8f
movq %r15, %rdi
movl %r13d, %esi
movl 0x14(%rsp), %edx
movq 0x20(%rsp), %rcx
callq 0x5b4a9
addq %r13, %r13
leaq (,%r13,2), %rcx
addq %r13, %rcx
testb %al, %al
je 0x56cb3
cmpb $0x9, 0x97372(%r15,%rcx)
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %r9
ja 0x56cd1
movb $0xa, 0x97372(%r15,%rcx)
jmp 0x56cd1
addq %r13, %r13
leaq (,%r13,2), %rax
addq %r13, %rax
cmpb $0xe, 0x97372(%r15,%rax)
ja 0x56cd1
movb $0xf, 0x97372(%r15,%rax)
jmp 0x56cd1
addq %r13, %r13
leaq (,%r13,2), %rax
addq %r13, %rax
cmpb $0xf, 0x97372(%r15,%rax)
ja 0x56cd1
movb $0x10, 0x97372(%r15,%rax)
jmp 0x56cd1
cmpb $0xd, 0x97372(%r15,%rcx)
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %r9
ja 0x56cd1
movb $0xe, 0x97372(%r15,%rcx)
movslq (%r8), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r8)
movl %ebx, (%r9,%rax,4)
movswl 0x57c(%rbp,%r14,2), %eax
jmp 0x56bea
cltq
imulq $0x7c8, %rax, %rdx      # imm = 0x7C8
cmpl $0x1, 0x4(%r12,%rdx)
jne 0x56d6b
addq %r12, %rdx
movswl 0x8(%rdx), %ecx
movslq %ecx, %rdi
movl 0x7c0(%rdx), %esi
addq %rdi, %rdi
leaq (%rdi,%rdi,2), %rdx
cmpl $0x2, %esi
je 0x56d34
cmpl $0x1, %esi
jne 0x56d4a
cmpb $0xa, 0x97372(%r15,%rdx)
ja 0x56d5e
movb $0xb, 0x97372(%r15,%rdx)
jmp 0x56d5e
cmpb $0xb, 0x97372(%r15,%rdx)
ja 0x56d5e
movb $0xc, 0x97372(%r15,%rdx)
jmp 0x56d5e
cmpb $0xc, 0x97372(%r15,%rdx)
ja 0x56d5e
movb $0xd, 0x97372(%r15,%rdx)
movslq (%r8), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%r8)
movl %ecx, (%r9,%rdx,4)
movswl 0x57c(%rbp,%rax,2), %eax
cmpl $0x11f, %eax            # imm = 0x11F
jne 0x56cec
jmp 0x56e9a
setg %cl
movzwl %ax, %edx
cmpl $0x11f, %edx            # imm = 0x11F
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x56e9a
movslq %eax, %r14
imulq $0x7c8, %r14, %rax      # imm = 0x7C8
cmpl $0x1, 0x4(%r12,%rax)
jne 0x56e86
addq %r12, %rax
movswl 0x8(%rax), %ebx
movslq %ebx, %r13
movl 0x7c0(%rax), %eax
cmpl $0x2, %eax
je 0x56e13
cmpl $0x1, %eax
jne 0x56e37
movq %r15, %rdi
movl %r13d, %esi
movl 0x14(%rsp), %edx
movq 0x20(%rsp), %rcx
callq 0x5b4a9
addq %r13, %r13
leaq (,%r13,2), %rcx
addq %r13, %rcx
testb %al, %al
je 0x56e5b
cmpb $0x9, 0x97372(%r15,%rcx)
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %r9
ja 0x56e79
movb $0xa, 0x97372(%r15,%rcx)
jmp 0x56e79
addq %r13, %r13
leaq (,%r13,2), %rax
addq %r13, %rax
cmpb $0x11, 0x97372(%r15,%rax)
ja 0x56e79
movb $0x12, 0x97372(%r15,%rax)
jmp 0x56e79
addq %r13, %r13
leaq (,%r13,2), %rax
addq %r13, %rax
cmpb $0x12, 0x97372(%r15,%rax)
ja 0x56e79
movb $0x13, 0x97372(%r15,%rax)
jmp 0x56e79
cmpb $0x10, 0x97372(%r15,%rcx)
movq 0x18(%rsp), %r8
movq 0x8(%rsp), %r9
ja 0x56e79
movb $0x11, 0x97372(%r15,%rcx)
movslq (%r8), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%r8)
movl %ebx, (%r9,%rax,4)
movswl 0x57c(%rbp,%r14,2), %eax
cmpl $0x11f, %eax            # imm = 0x11F
jne 0x56d9d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x3, %sil
cmpb $0x3, %dl
jb 0x56b9c
jmp 0x56bab
movb $0x6, %sil
cmpb $0x5, %dl
jbe 0x56b9c
jmp 0x56bab