// File: kobanium[P]Ray/src/board/GoBoard.cpp
// Function: SetBoardSize(int)
void
SetBoardSize( const int size )
{
  int i;

  pure_board_size = size;
  pure_board_max = size * size;
  board_size = size + 2 * OB_SIZE;
  board_max = board_size * board_size;

  board_start = OB_SIZE;
  board_end = (pure_board_size + OB_SIZE - 1);

  i = 0;
  for (int y = board_start; y <= board_end; y++) {
    for (int x = board_start; x <= board_end; x++) {
      onboard_pos[i++] = POS(x, y);
      board_x[POS(x, y)] = x;
      board_y[POS(x, y)] = y;
    }
  }

  for (int y = board_start; y <= board_end; y++) {
    for (int x = board_start; x <= (board_start + pure_board_size / 2); x++) {
      border_dis_x[POS(x, y)] = x - (OB_SIZE - 1);
      border_dis_x[POS(board_end + OB_SIZE - x, y)] = x - (OB_SIZE - 1);
      border_dis_y[POS(y, x)] = x - (OB_SIZE - 1);
      border_dis_y[POS(y, board_end + OB_SIZE - x)] = x - (OB_SIZE - 1);
    }
  }

  for (int y = 0; y < pure_board_size; y++) {
    for (int x = 0; x < pure_board_size; x++) {
      move_dis[x][y] = x + y + ((x > y) ? x : y);
      if (move_dis[x][y] >= MOVE_DISTANCE_MAX) {
        move_dis[x][y] = MOVE_DISTANCE_MAX - 1;
      }
    }
  }

  std::fill_n(board_pos_id, BOARD_MAX, 0);
  i = 1;
  for (int y = board_start; y <= (board_start + pure_board_size / 2); y++) {
    for (int x = board_start; x <= y; x++) {
      board_pos_id[POS(x, y)] = i;
      board_pos_id[POS(board_end + OB_SIZE - x, y)] = i;
      board_pos_id[POS(y, x)] = i;
      board_pos_id[POS(y, board_end + OB_SIZE - x)] = i;
      board_pos_id[POS(x, board_end + OB_SIZE - y)] = i;
      board_pos_id[POS(board_end + OB_SIZE - x, board_end + OB_SIZE - y)] = i;
      board_pos_id[POS(board_end + OB_SIZE - y, x)] = i;
      board_pos_id[POS(board_end + OB_SIZE - y, board_end + OB_SIZE - x)] = i;
      i++;
    }
  }

  first_move_candidates = 0;
  for (int y = board_start; y <= (board_start + board_end) / 2; y++) {
    for (int x = board_end + board_start - y; x <= board_end; x++) {
      first_move_candidate[first_move_candidates++] = POS(x, y);
    }
  }

  corner[0] = POS(board_start, board_start);
  corner[1] = POS(board_start, board_end);
  corner[2] = POS(board_end, board_start);
  corner[3] = POS(board_end, board_end);

  corner_neighbor[0][0] = EAST(POS(board_start, board_start));
  corner_neighbor[0][1] = SOUTH(POS(board_start, board_start));
  corner_neighbor[1][0] = NORTH(POS(board_start, board_end));
  corner_neighbor[1][1] = EAST(POS(board_start, board_end));
  corner_neighbor[2][0] = WEST(POS(board_end, board_start));
  corner_neighbor[2][1] = SOUTH(POS(board_end, board_start));
  corner_neighbor[3][0] = NORTH(POS(board_end, board_end));
  corner_neighbor[3][1] = WEST(POS(board_end, board_end));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, 0x4c4d0(%rip)     # 0xe7a44
movl -0x4(%rbp), %eax
imull -0x4(%rbp), %eax
movl %eax, 0x4c4bf(%rip)     # 0xe7a40
movl -0x4(%rbp), %eax
addl $0xa, %eax
movl %eax, 0x4c4bf(%rip)     # 0xe7a4c
movl 0x4c4b9(%rip), %eax     # 0xe7a4c
imull 0x4c4b2(%rip), %eax     # 0xe7a4c
movl %eax, 0x4c4a8(%rip)     # 0xe7a48
movl $0x5, 0x4c4a6(%rip)     # 0xe7a50
movl 0x4c494(%rip), %eax     # 0xe7a44
addl $0x5, %eax
subl $0x1, %eax
movl %eax, 0x4c498(%rip)     # 0xe7a54
movl $0x0, -0x8(%rbp)
movl 0x4c487(%rip), %eax     # 0xe7a50
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x4c47f(%rip), %eax     # 0xe7a54
jg 0x9b66f
movl 0x4c46f(%rip), %eax     # 0xe7a50
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl 0x4c467(%rip), %eax     # 0xe7a54
jg 0x9b65f
movl -0x10(%rbp), %edx
movl -0xc(%rbp), %eax
imull 0x4c450(%rip), %eax     # 0xe7a4c
addl %eax, %edx
movl -0x8(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x8(%rbp)
movslq %eax, %rcx
leaq 0x1ab3725d(%rip), %rax  # 0x1abd2870
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %edx
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
imull 0x4c426(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae37ce(%rip), %rax  # 0x1ab7ee00
movl %edx, (%rax,%rcx,4)
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
imull 0x4c407(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae44df(%rip), %rax  # 0x1ab7fb30
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x9b5e4
jmp 0x9b661
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9b5cc
movl 0x4c3db(%rip), %eax     # 0xe7a50
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x4c3d3(%rip), %eax     # 0xe7a54
jg 0x9b771
movl 0x4c3c3(%rip), %eax     # 0xe7a50
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x38(%rbp)
movl 0x4c3b4(%rip), %ecx     # 0xe7a50
movl 0x4c3a2(%rip), %eax     # 0xe7a44
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movl -0x38(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x9b761
movl -0x18(%rbp), %edx
subl $0x4, %edx
movl -0x18(%rbp), %eax
movl -0x14(%rbp), %ecx
imull 0x4c380(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1ab35188(%rip), %rax  # 0x1abd0860
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %edx
subl $0x4, %edx
movl 0x4c36d(%rip), %eax     # 0xe7a54
addl $0x5, %eax
subl -0x18(%rbp), %eax
movl -0x14(%rbp), %ecx
imull 0x4c355(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1ab3515d(%rip), %rax  # 0x1abd0860
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %edx
subl $0x4, %edx
movl -0x14(%rbp), %eax
movl -0x18(%rbp), %ecx
imull 0x4c333(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1ab35e6b(%rip), %rax  # 0x1abd1590
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %edx
subl $0x4, %edx
movl -0x14(%rbp), %eax
movl 0x4c31d(%rip), %ecx     # 0xe7a54
addl $0x5, %ecx
subl -0x18(%rbp), %ecx
imull 0x4c308(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1ab35e40(%rip), %rax  # 0x1abd1590
movl %edx, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x9b690
jmp 0x9b763
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x9b678
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x4c2c3(%rip), %eax     # 0xe7a44
jge 0x9b836
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x4c2ad(%rip), %eax     # 0xe7a44
jge 0x9b826
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x9b7b6
movl -0x20(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x9b7bc
movl -0x1c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %eax
addl %eax, %edx
movslq -0x20(%rbp), %rcx
leaq 0x1ab36af1(%rip), %rax  # 0x1abd22c0
imulq $0x4c, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movslq -0x20(%rbp), %rcx
leaq 0x1ab36ad8(%rip), %rax  # 0x1abd22c0
imulq $0x4c, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
cmpl $0x10, (%rax,%rcx,4)
jl 0x9b816
movslq -0x20(%rbp), %rcx
leaq 0x1ab36abc(%rip), %rax  # 0x1abd22c0
imulq $0x4c, %rcx, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movl $0xf, (%rax,%rcx,4)
jmp 0x9b818
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9b78e
jmp 0x9b828
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9b778
movl $0x0, -0x24(%rbp)
leaq 0x1aae288c(%rip), %rdi  # 0x1ab7e0d0
movl $0x349, %esi            # imm = 0x349
leaq -0x24(%rbp), %rdx
callq 0x80790
movl $0x1, -0x8(%rbp)
movl 0x4c1f1(%rip), %eax     # 0xe7a50
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x44(%rbp)
movl 0x4c1e2(%rip), %ecx     # 0xe7a50
movl 0x4c1d0(%rip), %eax     # 0xe7a44
movl $0x2, %esi
cltd
idivl %esi
movl %eax, %edx
movl -0x44(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x9ba07
movl 0x4c1bf(%rip), %eax     # 0xe7a50
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jg 0x9b9f7
movl -0x8(%rbp), %edx
movl -0x2c(%rbp), %eax
movl -0x28(%rbp), %ecx
imull 0x4c19c(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae2814(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %edx
movl 0x4c18c(%rip), %eax     # 0xe7a54
addl $0x5, %eax
subl -0x2c(%rbp), %eax
movl -0x28(%rbp), %ecx
imull 0x4c174(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae27ec(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %edx
movl -0x28(%rbp), %eax
movl -0x2c(%rbp), %ecx
imull 0x4c155(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae27cd(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %edx
movl -0x28(%rbp), %eax
movl 0x4c142(%rip), %ecx     # 0xe7a54
addl $0x5, %ecx
subl -0x2c(%rbp), %ecx
imull 0x4c12d(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae27a5(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %edx
movl -0x2c(%rbp), %eax
movl 0x4c11a(%rip), %ecx     # 0xe7a54
addl $0x5, %ecx
subl -0x28(%rbp), %ecx
imull 0x4c105(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae277d(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %edx
movl 0x4c0f5(%rip), %eax     # 0xe7a54
addl $0x5, %eax
subl -0x2c(%rbp), %eax
movl 0x4c0e9(%rip), %ecx     # 0xe7a54
addl $0x5, %ecx
subl -0x28(%rbp), %ecx
imull 0x4c0d4(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae274c(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %edx
movl 0x4c0c4(%rip), %eax     # 0xe7a54
addl $0x5, %eax
subl -0x28(%rbp), %eax
movl -0x2c(%rbp), %ecx
imull 0x4c0ac(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae2724(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %edx
movl 0x4c09c(%rip), %eax     # 0xe7a54
addl $0x5, %eax
subl -0x28(%rbp), %eax
movl 0x4c090(%rip), %ecx     # 0xe7a54
addl $0x5, %ecx
subl -0x2c(%rbp), %ecx
imull 0x4c07b(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movslq %eax, %rcx
leaq 0x1aae26f3(%rip), %rax  # 0x1ab7e0d0
movl %edx, (%rax,%rcx,4)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9b894
jmp 0x9b9f9
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x9b862
movl $0x0, 0x1aae266f(%rip)  # 0x1ab7e080
movl 0x4c039(%rip), %eax     # 0xe7a50
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x48(%rbp)
movl 0x4c02a(%rip), %eax     # 0xe7a50
addl 0x4c028(%rip), %eax     # 0xe7a54
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x48(%rbp), %eax
cmpl %ecx, %eax
jg 0x9baa2
movl 0x4c011(%rip), %eax     # 0xe7a54
addl 0x4c007(%rip), %eax     # 0xe7a50
subl -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x4bffc(%rip), %eax     # 0xe7a54
jg 0x9ba92
movl -0x34(%rbp), %edx
movl -0x30(%rbp), %eax
imull 0x4bfe5(%rip), %eax     # 0xe7a4c
addl %eax, %edx
movl 0x1aae2611(%rip), %eax  # 0x1ab7e080
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x1aae2606(%rip)  # 0x1ab7e080
movslq %eax, %rcx
leaq 0x1ab3739c(%rip), %rax  # 0x1abd2e20
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x9ba4f
jmp 0x9ba94
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9ba1a
movl 0x4bfa8(%rip), %eax     # 0xe7a50
movl 0x4bfa2(%rip), %ecx     # 0xe7a50
imull 0x4bf97(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movl %eax, 0x1ab37933(%rip)  # 0x1abd33f0
movl 0x4bf8d(%rip), %eax     # 0xe7a50
movl 0x4bf8b(%rip), %ecx     # 0xe7a54
imull 0x4bf7c(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movl %eax, 0x1ab3791c(%rip)  # 0x1abd33f4
movl 0x4bf76(%rip), %eax     # 0xe7a54
movl 0x4bf6c(%rip), %ecx     # 0xe7a50
imull 0x4bf61(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movl %eax, 0x1ab37905(%rip)  # 0x1abd33f8
movl 0x4bf5b(%rip), %eax     # 0xe7a54
movl 0x4bf55(%rip), %ecx     # 0xe7a54
imull 0x4bf46(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
movl %eax, 0x1ab378ee(%rip)  # 0x1abd33fc
movl 0x4bf3c(%rip), %eax     # 0xe7a50
movl 0x4bf36(%rip), %ecx     # 0xe7a50
imull 0x4bf2b(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
addl $0x1, %eax
movl %eax, 0x1ab378d4(%rip)  # 0x1abd3400
movl 0x4bf1e(%rip), %eax     # 0xe7a50
movl 0x4bf18(%rip), %ecx     # 0xe7a50
imull 0x4bf0d(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
addl 0x4bf05(%rip), %eax     # 0xe7a4c
movl %eax, 0x1ab378b7(%rip)  # 0x1abd3404
movl 0x4befd(%rip), %eax     # 0xe7a50
movl 0x4befb(%rip), %ecx     # 0xe7a54
imull 0x4beec(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
subl 0x4bee4(%rip), %eax     # 0xe7a4c
movl %eax, 0x1ab3789a(%rip)  # 0x1abd3408
movl 0x4bedc(%rip), %eax     # 0xe7a50
movl 0x4beda(%rip), %ecx     # 0xe7a54
imull 0x4becb(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
addl $0x1, %eax
movl %eax, 0x1ab37880(%rip)  # 0x1abd340c
movl 0x4bec2(%rip), %eax     # 0xe7a54
movl 0x4beb8(%rip), %ecx     # 0xe7a50
imull 0x4bead(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
subl $0x1, %eax
movl %eax, 0x1ab37866(%rip)  # 0x1abd3410
movl 0x4bea4(%rip), %eax     # 0xe7a54
movl 0x4be9a(%rip), %ecx     # 0xe7a50
imull 0x4be8f(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
addl 0x4be87(%rip), %eax     # 0xe7a4c
movl %eax, 0x1ab37849(%rip)  # 0x1abd3414
movl 0x4be83(%rip), %eax     # 0xe7a54
movl 0x4be7d(%rip), %ecx     # 0xe7a54
imull 0x4be6e(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
subl 0x4be66(%rip), %eax     # 0xe7a4c
movl %eax, 0x1ab3782c(%rip)  # 0x1abd3418
movl 0x4be62(%rip), %eax     # 0xe7a54
movl 0x4be5c(%rip), %ecx     # 0xe7a54
imull 0x4be4d(%rip), %ecx     # 0xe7a4c
addl %ecx, %eax
subl $0x1, %eax
movl %eax, 0x1ab37812(%rip)  # 0x1abd341c
addq $0x50, %rsp
popq %rbp
retq