// File: /workspace/github_cpp_makefile_star2_O2/kobanium[P]Ray/src/board/GoBoard.cpp
// Function: CheckBentFourInTheCorner(game_info_t*)
void
CheckBentFourInTheCorner( game_info_t *game )
{
  const string_t *string = game->string;
  const int *string_id = game->string_id;
  const int *string_next = game->string_next;
  char *board = game->board;
  int pos, neighbor;

  // 四隅について隅のマガリ四目が存在するか確認し
  // 存在すれば地を訂正する
  for (int i = 0; i < 4; i++) {
    const int id = string_id[corner[i]];
    if (string[id].size == 3 &&
        string[id].libs == 2 &&
        string[id].neighbors == 1) {
      const int color = string[id].color;
      const int lib1 = string[id].lib[0];
      const int lib2 = string[id].lib[lib1];
      if ((board[corner_neighbor[i][0]] == S_EMPTY ||
          board[corner_neighbor[i][0]] == color) &&
          (board[corner_neighbor[i][1]] == S_EMPTY ||
          board[corner_neighbor[i][1]] == color)) {
        neighbor = string[id].neighbor[0];
        if (string[neighbor].libs == 2 &&
            string[neighbor].size > 6) {
          // 呼吸点を共有しているかの確認
          const int neighbor_lib1 = string[neighbor].lib[0];
          const int neighbor_lib2 = string[neighbor].lib[neighbor_lib1];
          if ((neighbor_lib1 == lib1 && neighbor_lib2 == lib2) ||
              (neighbor_lib1 == lib2 && neighbor_lib2 == lib1)) {
            pos = string[neighbor].origin;
            while (pos != STRING_END) {
              board[pos] = static_cast<char>(color);
              pos = string_next[pos];
            }
            pos = string[neighbor].lib[0];
            board[pos] = static_cast<char>(color);
            pos = string[neighbor].lib[pos];
            board[pos] = static_cast<char>(color);
          }
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
leaq 0x9620(%rdi), %rax
leaq 0x96200(%rdi), %rcx
xorl %edx, %edx
leaq 0x1ab10878(%rip), %rsi  # 0x1ab4d270
leaq 0x1ab10881(%rip), %r8   # 0x1ab4d280
cmpq $0x4, %rdx
je 0x3cb14
movslq (%rsi,%rdx,4), %r9
movslq 0x95720(%rdi,%r9,4), %r9
imulq $0x7c8, %r9, %r11       # imm = 0x7C8
cmpl $0x3, 0x7c0(%rax,%r11)
jne 0x3cb0c
addq %rax, %r11
cmpl $0x2, 0x4(%r11)
jne 0x3cb0c
cmpl $0x1, 0x578(%r11)
jne 0x3cb0c
movb (%r11), %r9b
movswq 0x8(%r11), %r10
movzwl 0x8(%r11,%r10,2), %ebx
movslq (%r8,%rdx,8), %r14
movb 0x43f8(%rdi,%r14), %bpl
testb %bpl, %bpl
je 0x3ca6f
cmpb %r9b, %bpl
jne 0x3cb0c
movslq 0x4(%r8,%rdx,8), %r14
movb 0x43f8(%rdi,%r14), %bpl
testb %bpl, %bpl
je 0x3ca8a
cmpb %r9b, %bpl
jne 0x3cb0c
movswq 0x57c(%r11), %r11
imulq $0x7c8, %r11, %r11      # imm = 0x7C8
cmpl $0x2, 0x4(%rax,%r11)
jne 0x3cb0c
addq %rax, %r11
cmpl $0x7, 0x7c0(%r11)
jl 0x3cb0c
movswq 0x8(%r11), %r14
movzwl 0x8(%r11,%r14,2), %ebp
cmpw %r10w, %r14w
jne 0x3cac4
cmpw %bx, %bp
je 0x3cad0
cmpw %bx, %r14w
jne 0x3cb0c
cmpw %r10w, %bp
jne 0x3cb0c
leaq 0x7bc(%r11), %r10
movslq (%r10), %r10
cmpq $0x2b7, %r10            # imm = 0x2B7
je 0x3caf1
movb %r9b, 0x43f8(%rdi,%r10)
leaq (%rcx,%r10,4), %r10
jmp 0x3cad7
movswq 0x8(%r11), %r10
movb %r9b, 0x43f8(%rdi,%r10)
movswq 0x8(%r11,%r10,2), %r10
movb %r9b, 0x43f8(%rdi,%r10)
incq %rdx
jmp 0x3c9ff
popq %rbx
popq %r14
popq %rbp
retq