// File: kobanium[P]Ray/src/feature/UctFeature.cpp
// Function: CheckFeaturesLib1ForTree(game_info_t const*, int, int, bool, unsigned int*)
static void
CheckFeaturesLib1ForTree( const game_info_t *game, const int color, const int id, const bool ladder, unsigned int *tactical_features )
{
  const string_t *string = game->string;
  int lib, neighbor;

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

  // シチョウを逃げる手かどうかで特徴を判定
  if (ladder) {
    CompareSwapFeature(tactical_features, lib, UCT_SAVE_EXTENSION_INDEX, UCT_LADDER_EXTENSION);
  } else {
    if (string[id].size == 1) {
      CompareSwapFeature(tactical_features, lib, UCT_SAVE_EXTENSION_INDEX, UCT_SAVE_EXTENSION_1);
    } else if (string[id].size == 2) {
      CompareSwapFeature(tactical_features, lib, UCT_SAVE_EXTENSION_INDEX, UCT_SAVE_EXTENSION_2);
    } else {
      CompareSwapFeature(tactical_features, lib, UCT_SAVE_EXTENSION_INDEX, UCT_SAVE_EXTENSION_3);
    }
  }

  // 敵連を取ることによって連を助ける手の特徴の判定
  // 自分の連の大きさと敵の連の大きさで特徴を判定
  neighbor = string[id].neighbor[0];
  while (neighbor != NEIGHBOR_END) {
    if (string[neighbor].libs == 1) {
      lib = string[neighbor].lib[0];
      if (string[id].size == 1) {
        if (string[neighbor].size == 1) {
          CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_1_1);
        } else if (string[neighbor].size == 2) {
          CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_1_2);
        } else {
          CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_1_3);
        }
      } else if (string[id].size == 2){
        if (string[neighbor].size == 1) {
          if (IsSelfAtariCapture(game, lib, color, id)) {
            CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_SELF_ATARI);
          } else {
            CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_2_1);
          }
        } else if (string[neighbor].size == 2) {
          CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_2_2);
        } else {
          CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_2_3);
        }
      } else {
        if (string[neighbor].size == 1) {
          if (IsSelfAtariCapture(game, lib, color, id)) {
            CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_SELF_ATARI);
          } else {
            CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_3_1);
          }
        } else if (string[neighbor].size == 2) {
          CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_3_2);
        } else {
          CompareSwapFeature(tactical_features, lib, UCT_CAPTURE_INDEX, UCT_SAVE_CAPTURE_3_3);
        }
      }
    }
    neighbor = string[id].neighbor[neighbor];
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq $0x9620, %rax           # imm = 0x9620
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
testb $0x1, -0x11(%rbp)
je 0xa5fb2
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl $0x1, %edx
movl $0x4, %ecx
callq 0xa7430
jmp 0xa602f
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x7c0(%rax)
jne 0xa5fe2
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0xa7430
jmp 0xa602d
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x7c0(%rax)
jne 0xa6015
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl $0x1, %edx
movl $0x2, %ecx
callq 0xa7430
jmp 0xa602b
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl $0x1, %edx
movl $0x3, %ecx
callq 0xa7430
jmp 0xa602d
jmp 0xa602f
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x57c(%rax), %eax
movl %eax, -0x30(%rbp)
cmpl $0x11f, -0x30(%rbp)     # imm = 0x11F
je 0xa62b6
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jne 0xa6290
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x7c0(%rax)
jne 0xa6122
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x7c0(%rax)
jne 0xa60d8
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x11, %ecx
callq 0xa7430
jmp 0xa611d
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x7c0(%rax)
jne 0xa6108
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x12, %ecx
callq 0xa7430
jmp 0xa611b
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x13, %ecx
callq 0xa7430
jmp 0xa611d
jmp 0xa628e
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x7c0(%rax)
jne 0xa61e8
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x7c0(%rax)
jne 0xa619e
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
callq 0xa84b0
testb $0x1, %al
jne 0xa6174
jmp 0xa6189
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x1a, %ecx
callq 0xa7430
jmp 0xa619c
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x14, %ecx
callq 0xa7430
jmp 0xa61e3
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x7c0(%rax)
jne 0xa61ce
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x15, %ecx
callq 0xa7430
jmp 0xa61e1
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x16, %ecx
callq 0xa7430
jmp 0xa61e3
jmp 0xa628c
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x7c0(%rax)
jne 0xa6245
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
callq 0xa84b0
testb $0x1, %al
jne 0xa621b
jmp 0xa6230
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x1a, %ecx
callq 0xa7430
jmp 0xa6243
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x17, %ecx
callq 0xa7430
jmp 0xa628a
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x7c0(%rax)
jne 0xa6275
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x18, %ecx
callq 0xa7430
jmp 0xa6288
movq -0x20(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
movl $0x19, %ecx
callq 0xa7430
jmp 0xa628a
jmp 0xa628c
jmp 0xa628e
jmp 0xa6290
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movslq -0x30(%rbp), %rcx
movswl 0x57c(%rax,%rcx,2), %eax
movl %eax, -0x30(%rbp)
jmp 0xa604b
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)