// File: 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
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x9620, %rax           # imm = 0x9620
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x95720, %rax          # imm = 0x95720
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
addq $0x96200, %rax          # imm = 0x96200
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq $0x43f8, %rax           # imm = 0x43F8
movq %rax, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jge 0x9ea14
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rdx
leaq 0x1ab34c70(%rip), %rcx  # 0x1abd33f0
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x3, 0x7c0(%rax)
jne 0x9ea04
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x4(%rax)
jne 0x9ea04
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x578(%rax)
jne 0x9ea04
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movsbl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x8(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movslq -0x40(%rbp), %rcx
movswl 0x8(%rax,%rcx,2), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rdx
leaq 0x1ab34bbe(%rip), %rcx  # 0x1abd3400
movslq (%rcx,%rdx,8), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x9e86f
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rdx
leaq 0x1ab34ba2(%rip), %rcx  # 0x1abd3400
movslq (%rcx,%rdx,8), %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x3c(%rbp), %eax
jne 0x9ea02
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rdx
leaq 0x1ab34b82(%rip), %rcx  # 0x1abd3400
movslq 0x4(%rcx,%rdx,8), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x9e8ad
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rdx
leaq 0x1ab34b65(%rip), %rcx  # 0x1abd3400
movslq 0x4(%rcx,%rdx,8), %rcx
movsbl (%rax,%rcx), %eax
cmpl -0x3c(%rbp), %eax
jne 0x9ea02
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x57c(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x4(%rax)
jne 0x9ea00
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x6, 0x7c0(%rax)
jle 0x9ea00
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x8(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movslq -0x48(%rbp), %rcx
movswl 0x8(%rax,%rcx,2), %eax
movl %eax, -0x4c(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x9e94b
movl -0x4c(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x9e963
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jne 0x9e9fe
movl -0x4c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x9e9fe
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movl 0x7bc(%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x2b7, -0x2c(%rbp)     # imm = 0x2B7
je 0x9e9a7
movl -0x3c(%rbp), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
jmp 0x9e97e
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x8(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x3c(%rbp), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movslq -0x2c(%rbp), %rcx
movswl 0x8(%rax,%rcx,2), %eax
movl %eax, -0x2c(%rbp)
movl -0x3c(%rbp), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x9ea00
jmp 0x9ea02
jmp 0x9ea04
jmp 0x9ea06
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x9e767
popq %rbp
retq
nopw %cs:(%rax,%rax)