// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edi, 0x26c18(%rip)     # 0x618b4
movl %edi, %eax
imull %edi, %eax
movl %eax, 0x26c09(%rip)     # 0x618b0
leal 0xa(%rdi), %r12d
movl %r12d, 0x26c0a(%rip)    # 0x618bc
movl %r12d, %eax
imull %r12d, %eax
movl %eax, 0x26bf9(%rip)     # 0x618b8
movl $0x5, 0x26bf7(%rip)     # 0x618c0
leal 0x4(%rdi), %ecx
movl %ecx, 0x26bf2(%rip)     # 0x618c4
leal 0x5(%rdi), %eax
movq %rcx, -0x50(%rsp)
movslq %ecx, %r13
movslq %r12d, %r9
addq $-0x5, %rax
imulq $0x14, %r9, %rsi
leaq 0x1aabdf91(%rip), %rcx  # 0x1aaf8c80
addq %rsi, %rcx
addq $0x14, %rcx
leaq (,%r9,4), %r11
leaq 0x1aabecab(%rip), %rdx  # 0x1aaf99b0
movq %rsi, -0x58(%rsp)
leaq 0x14(%rsi,%rdx), %rdx
movq %rdi, -0x68(%rsp)
leal (%rdi,%rdi,4), %esi
addl $0x37, %esi
movabsq $0x5, %rdi
xorl %r10d, %r10d
leaq 0x1ab119c2(%rip), %rbx  # 0x1ab4c6f0
cmpq %r13, %rdi
jg 0x3ad74
movslq %r10d, %r10
leaq (,%r10,4), %r14
xorl %r8d, %r8d
cmpq %r8, %rax
je 0x3ad63
leal (%rsi,%r8), %ebp
leaq (%r14,%r8,4), %r15
movl %ebp, (%rbx,%r15)
leal 0x5(%r8), %ebp
movl %ebp, (%rcx,%r8,4)
movl %edi, (%rdx,%r8,4)
incq %r8
jmp 0x3ad41
incq %rdi
addq %r11, %rcx
addq %r11, %rdx
addq %r12, %rsi
addq %r8, %r10
jmp 0x3ad2e
movl $0x2, %esi
movq -0x68(%rsp), %rcx
movl %ecx, %eax
cltd
idivl %esi
addl $0x5, %eax
leal 0x9(%rcx), %edx
movl %edx, -0x6c(%rsp)
cltq
movq %r12, -0x38(%rsp)
movl %r12d, %edx
imull -0x50(%rsp), %edx
movl %edx, -0x48(%rsp)
movl $0xfffffff6, %edx       # imm = 0xFFFFFFF6
subl %ecx, %edx
leaq 0x1ab0f932(%rip), %rsi  # 0x1ab4a6e0
movq -0x58(%rsp), %rcx
leaq (%rsi,%rcx), %rdi
leaq 0x1ab10652(%rip), %r10  # 0x1ab4b410
leaq (%rcx,%r10), %rbp
addq $0x14, %rbp
movabsq $0x5, %r12
movq %r13, -0x40(%rsp)
cmpq %r13, %r12
jg 0x3ae45
movq %r12, %r13
imulq %r9, %r13
movq %rbp, -0x60(%rsp)
movl -0x48(%rsp), %ecx
movl %ecx, %r15d
movq -0x50(%rsp), %r8
movabsq $0x5, %r14
cmpq %rax, %r14
jg 0x3ae2f
leal -0x4(%r14), %ecx
movl %ecx, (%rdi,%r14,4)
movslq %r8d, %r8
leaq (%r8,%r13), %rbx
movl %ecx, (%rsi,%rbx,4)
movl %ecx, (%rbp)
movslq %r15d, %r15
leaq (%r12,%r15), %rbx
movl %ecx, (%r10,%rbx,4)
incq %r14
decl %r8d
addl %edx, %r15d
addq %r11, %rbp
jmp 0x3adfc
incq %r12
addq %r11, %rdi
movq -0x60(%rsp), %rbp
addq $0x4, %rbp
movq -0x40(%rsp), %r13
jmp 0x3add5
xorl %ecx, %ecx
movq -0x68(%rsp), %rsi
testl %esi, %esi
movl $0x0, %edx
cmovgl %esi, %edx
movl %esi, %esi
leaq 0x1ab112e1(%rip), %rdi  # 0x1ab4c140
movl $0xf, %r10d
movl -0x6c(%rsp), %ebp
cmpq %rdx, %rcx
je 0x3aea4
movq %rdi, %r8
xorl %ebx, %ebx
cmpl %ebx, %ecx
movl %ebx, %r14d
cmoval %ecx, %r14d
cmpq %rbx, %rsi
je 0x3ae9b
addl %ecx, %r14d
addl %ebx, %r14d
cmpl $0xf, %r14d
cmovael %r10d, %r14d
movl %r14d, (%r8)
incq %rbx
addq $0x4c, %r8
jmp 0x3ae73
incq %rcx
addq $0x4, %rdi
jmp 0x3ae69
xorl %ecx, %ecx
leaq 0x1aabd0a3(%rip), %rdx  # 0x1aaf7f50
movq -0x58(%rsp), %r10
cmpq $0xd24, %rcx            # imm = 0xD24
je 0x3aec5
andl $0x0, (%rcx,%rdx)
addq $0x4, %rcx
jmp 0x3aeb2
movslq %ebp, %rcx
addq $0x14, %r10
leaq -0x5(%rcx), %rdi
imulq %r9, %rdi
leaq (%rcx,%rdi), %r8
addq $-0x5, %r8
addq $0x5, %rdi
leaq (%r9,%r9,4), %rsi
addq %rcx, %rsi
addq $-0x5, %rsi
leaq 0x5(%r9,%r9,4), %r13
movl $0x1, %ebp
movabsq $0x5, %rcx
movq %rcx, -0x60(%rsp)
movabsq $0x1, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq %r8, %r15
movq %rdi, -0x40(%rsp)
movq %rdi, %rcx
movq %r13, -0x10(%rsp)
movq %rsi, -0x8(%rsp)
movq %r12, -0x20(%rsp)
movq %r14, -0x28(%rsp)
movq %r8, -0x48(%rsp)
movq %r8, %rdi
movq %r15, -0x30(%rsp)
movq %r10, -0x58(%rsp)
movq %rbx, -0x18(%rsp)
cmpq %rax, -0x60(%rsp)
jg 0x3afe7
subq $0x1, %rbx
jb 0x3af95
movl %ebp, (%r10,%rdx)
movl %ebp, (%rdx,%r12,4)
movl %ebp, (%rdx,%r13,4)
movl %ebp, (%rdx,%r14,4)
movl %ebp, (%rdx,%rcx,4)
movl %ebp, (%rdx,%r15,4)
movl %ebp, (%rdx,%rsi,4)
movl %ebp, (%rdx,%rdi,4)
incl %ebp
addq $0x4, %r10
decq %r15
subq %r9, %rdi
subq %r9, %r14
decq %r12
addq %r9, %rsi
addq %r9, %r13
incq %rcx
jmp 0x3af55
incq -0x60(%rsp)
movq -0x18(%rsp), %rbx
incq %rbx
movq -0x58(%rsp), %r10
addq %r11, %r10
movq -0x30(%rsp), %r15
subq %r9, %r15
movq -0x48(%rsp), %r8
decq %r8
movq -0x28(%rsp), %r14
incq %r14
movq -0x20(%rsp), %r12
addq %r9, %r12
movq -0x8(%rsp), %rsi
decq %rsi
movq -0x10(%rsp), %r13
incq %r13
movq -0x40(%rsp), %rdi
subq %r9, %rdi
jmp 0x3af17
andl $0x0, 0x1aabcf12(%rip)  # 0x1aaf7f00
movl -0x6c(%rsp), %ebp
movl %ebp, %eax
cltd
movl $0x2, %ecx
idivl %ecx
imull $0x6, -0x68(%rsp), %ecx
addl $0x36, %ecx
movl $0x5, %edx
xorl %esi, %esi
leaq 0x1ab11c8e(%rip), %rdi  # 0x1ab4cca0
movq -0x38(%rsp), %rbx
movq -0x50(%rsp), %r14
cmpl %eax, %edx
jg 0x3b05b
movl %ebp, %r9d
subl %edx, %r9d
movslq %esi, %rsi
leaq (%rdi,%rsi,4), %r8
leal 0x1(%rsi), %r10d
movl %ecx, %r11d
cmpl %r14d, %r9d
jg 0x3b055
incq %rsi
movl %r10d, 0x1aabcebd(%rip) # 0x1aaf7f00
movl %r11d, (%r8)
incl %r9d
addq $0x4, %r8
incl %r10d
incl %r11d
jmp 0x3b034
incl %edx
addl %ebp, %ecx
jmp 0x3b01c
movq -0x68(%rsp), %r9
addl $0xb, %r9d
leal (%r9,%r9,4), %eax
movl %eax, 0x1ab12202(%rip)  # 0x1ab4d270
movl %ebx, %ecx
imull %r14d, %ecx
leal 0x5(%rcx), %edx
movl %edx, 0x1ab121f7(%rip)  # 0x1ab4d274
leal (%rbx,%rbx,4), %esi
leal (%rsi,%r14), %edi
movl %edi, 0x1ab121ee(%rip)  # 0x1ab4d278
movl %r9d, %r8d
imull %r14d, %r8d
movl %r8d, 0x1ab121e4(%rip)  # 0x1ab4d27c
leal (%r9,%r9,4), %r9d
incl %r9d
movl %r9d, 0x1ab121da(%rip)  # 0x1ab4d280
addl %ebx, %eax
movl %eax, 0x1ab121d6(%rip)  # 0x1ab4d284
subl %ebx, %edx
movl %edx, 0x1ab121d2(%rip)  # 0x1ab4d288
addl $0x6, %ecx
movl %ecx, 0x1ab121cd(%rip)  # 0x1ab4d28c
leal (%r14,%rsi), %eax
decl %eax
movl %eax, 0x1ab121c5(%rip)  # 0x1ab4d290
addl %ebx, %edi
movl %edi, 0x1ab121c1(%rip)  # 0x1ab4d294
movl %r8d, %eax
subl %ebx, %eax
movl %eax, 0x1ab121ba(%rip)  # 0x1ab4d298
decl %r8d
movl %r8d, 0x1ab121b4(%rip)  # 0x1ab4d29c
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq