// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x68, %rsp
movl %edi, 0x21f44(%rip)     # 0x758b4
movl %edi, %eax
imull %edi, %eax
movl %eax, 0x21f35(%rip)     # 0x758b0
leal 0xa(%rdi), %ecx
movl %ecx, 0x21f38(%rip)     # 0x758bc
movl %ecx, %eax
imull %ecx, %eax
movl %eax, 0x21f29(%rip)     # 0x758b8
movl $0x5, 0x21f27(%rip)     # 0x758c0
leal 0x4(%rdi), %eax
movq %rax, 0x10(%rsp)
movl %eax, 0x21f1d(%rip)     # 0x758c4
movq %rcx, 0x28(%rsp)
movl %ecx, %eax
testl %edi, %edi
jle 0x53a4e
movq 0x10(%rsp), %rdx
cmpl $0x6, %edx
movl $0x5, %ecx
cmovgel %edx, %ecx
leal 0x1(%rcx), %edx
leaq (%rax,%rax,4), %r8
leaq 0x1aab9fdc(%rip), %rsi  # 0x1ab0d9b0
leaq 0x14(%rsi,%r8,4), %rsi
leaq (,%rax,4), %r13
leaq 0x1aab9298(%rip), %r9   # 0x1ab0cc80
leaq (%r9,%r8,4), %r8
addq $0x14, %r8
leal (%rdi,%rdi,4), %r9d
addl $0x37, %r9d
addq $-0x4, %rcx
movl $0x5, %r10d
xorl %r11d, %r11d
leaq 0x1ab0cce4(%rip), %rbx  # 0x1ab606f0
movslq %r11d, %r11
leaq (,%r11,4), %r15
xorl %r14d, %r14d
leal (%r9,%r14), %ebp
leaq (%r15,%r14,4), %r12
movl %ebp, (%rbx,%r12)
leal 0x5(%r14), %ebp
movl %ebp, (%r8,%r14,4)
movl %r10d, (%rsi,%r14,4)
incq %r14
cmpq %r14, %rcx
jne 0x53a1a
incq %r10
addq %r14, %r11
addq %r13, %rsi
addq %r13, %r8
addq %rax, %r9
cmpq %rdx, %r10
jne 0x53a0c
movl %edi, %ecx
movq %rdi, 0x8(%rsp)
testl %edi, %edi
jle 0x53b23
movq 0x10(%rsp), %rdx
cmpl $0x6, %edx
movl $0x5, %esi
cmovgel %edx, %esi
incl %esi
movq %rsi, 0x18(%rsp)
leaq 0x4(%rcx), %rdx
imulq %rax, %rdx
leaq 0x1ab0b98d(%rip), %rsi  # 0x1ab5f410
leaq (%rsi,%rdx,4), %rdx
addq $0x14, %rdx
shlq $0x2, %rax
movq %rax, %rdi
negq %rdi
leaq (%rax,%rax,4), %r8
leaq 0x1ab0ac40(%rip), %rsi  # 0x1ab5e6e0
leaq (%rsi,%rcx,4), %r9
addq $0x10, %r9
movq 0x8(%rsp), %r10
shrl %r10d
movl $0x5, %r11d
leaq 0x1ab0b967(%rip), %rbx  # 0x1ab5f424
leaq 0x1ab0ac30(%rip), %r14  # 0x1ab5e6f4
movq $-0x1, %r15
movq %r14, %r12
movq %rbx, %r13
movq %r9, %rbp
movq %rdx, 0x20(%rsp)
movq %rdx, %rsi
leal 0x2(%r15), %edx
movl %edx, (%r12,%r8)
movl %edx, (%rbp,%r8)
movl %edx, (%r13,%r8)
movl %edx, (%rsi)
addq %rdi, %rsi
addq $-0x4, %rbp
addq %rax, %r13
addq $0x4, %r12
incq %r15
cmpq %r15, %r10
jne 0x53adc
incq %r11
movq 0x20(%rsp), %rdx
addq $0x4, %rdx
addq %rax, %r9
addq $0x4, %rbx
addq %rax, %r14
cmpq 0x18(%rsp), %r11
jne 0x53ac4
movq 0x8(%rsp), %rbx
testl %ebx, %ebx
jle 0x53b76
leaq 0x1ab0c60d(%rip), %rax  # 0x1ab60140
xorl %edx, %edx
movl $0xf, %esi
movq %rax, %rdi
movl %edx, %r8d
xorl %r9d, %r9d
cmpl %r9d, %edx
movl %r9d, %r10d
cmoval %edx, %r10d
addl %r8d, %r10d
cmpl $0xf, %r10d
cmovael %esi, %r10d
movl %r10d, (%rdi)
incq %r9
incl %r8d
addq $0x4c, %rdi
cmpq %r9, %rcx
jne 0x53b43
incq %rdx
addq $0x4, %rax
cmpq %rcx, %rdx
jne 0x53b3a
leaq 0x1aab83d3(%rip), %r14  # 0x1ab0bf50
movl $0xd24, %edx            # imm = 0xD24
movq %r14, %rdi
xorl %esi, %esi
callq 0x6210
cmpl $-0x1, %ebx
jl 0x53cc6
movq 0x8(%rsp), %rax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
cltq
movslq 0x28(%rsp), %rcx
addl $0x6, %edx
movq %rdx, 0x38(%rsp)
leaq 0x4(%rax), %r12
imulq %rcx, %r12
leaq (%rcx,%rcx,4), %rdx
leaq (%rax,%rdx), %rbx
addq $0x4, %rbx
leaq (%rcx,%rcx,4), %rsi
addq $0x5, %rsi
leaq (%rax,%r12), %r15
addq $0x4, %r15
addq $0x5, %r12
leaq 0x14(,%rdx,4), %r9
leaq (,%rcx,4), %rax
movq %rax, 0x30(%rsp)
movl $0x1, %r11d
movl $0x5, %eax
movl $0x1, %ebp
movq %r15, %rdi
movq %rbx, %r13
movq %r12, %r10
movq %rax, 0x48(%rsp)
movq %rbp, 0x40(%rsp)
movq %r9, 0x50(%rsp)
movq %rbx, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq %r15, 0x58(%rsp)
movq %rdi, %r8
movq %rsi, 0x60(%rsp)
movq %rsi, %rax
movq %r13, %rsi
movq %r10, %rdx
movl %r11d, (%r9,%r14)
movl %r11d, (%r14,%rbx,4)
movl %r11d, (%r14,%rax,4)
movl %r11d, (%r14,%r12,4)
movl %r11d, (%r14,%rdx,4)
movl %r11d, (%r14,%r8,4)
movl %r11d, (%r14,%rsi,4)
movl %r11d, (%r14,%r15,4)
incl %r11d
incq %rdx
addq %rcx, %rsi
addq %rcx, %rax
decq %r8
subq %rcx, %r15
subq %rcx, %r12
decq %rbx
addq $0x4, %r9
decq %rbp
jne 0x53c37
movq 0x48(%rsp), %rax
incq %rax
subq %rcx, %r10
decq %r13
movq 0x60(%rsp), %rsi
incq %rsi
subq %rcx, %rdi
movq 0x58(%rsp), %r15
decq %r15
movq 0x20(%rsp), %r12
incq %r12
movq 0x18(%rsp), %rbx
addq %rcx, %rbx
movq 0x50(%rsp), %r9
addq 0x30(%rsp), %r9
movq 0x40(%rsp), %rbp
incq %rbp
cmpq 0x38(%rsp), %rax
jne 0x53c08
movl $0x0, 0x1aab8230(%rip)  # 0x1ab0bf00
movq 0x8(%rsp), %r15
testl %r15d, %r15d
movq 0x10(%rsp), %r12
jle 0x53d51
leal 0x9(%r15), %eax
movl %eax, %ecx
shrl %ecx
cmpl $0x6, %ecx
movl $0x5, %edx
cmovll %edx, %ecx
leal (%r15,%r15,2), %esi
leal 0x36(,%rsi,2), %esi
movl %eax, %edi
xorl %r8d, %r8d
movl $0x1, %r9d
leaq 0x1ab0cf91(%rip), %r10  # 0x1ab60ca0
movl %eax, %r11d
subl %edx, %r11d
cmpl %r12d, %r11d
jg 0x53d40
movslq %r8d, %r11
shlq $0x2, %r11
xorl %ebx, %ebx
leal (%rsi,%rbx), %ebp
leaq (%r11,%rbx,4), %r14
movl %ebp, (%r10,%r14)
incq %rbx
cmpl %ebx, %r9d
jne 0x53d23
addl %ebx, %r8d
movl %r8d, 0x1aab81c0(%rip)  # 0x1ab0bf00
leal 0x1(%rdx), %r11d
incq %r9
addq %rdi, %rsi
cmpl %ecx, %edx
movl %r11d, %edx
jne 0x53d0f
addl $0xb, %r15d
leal (%r15,%r15,4), %eax
movl %eax, 0x1ab0d511(%rip)  # 0x1ab61270
movl %r12d, %ecx
movq 0x28(%rsp), %r10
imull %r10d, %ecx
leal 0x5(%rcx), %edx
movl %edx, 0x1ab0d500(%rip)  # 0x1ab61274
leal (%r10,%r10,4), %esi
leal (%rsi,%r12), %edi
movl %edi, 0x1ab0d4f6(%rip)  # 0x1ab61278
movl %r15d, %r8d
imull %r12d, %r8d
movl %r8d, 0x1ab0d4ec(%rip)  # 0x1ab6127c
leal (%r15,%r15,4), %r9d
incl %r9d
movl %r9d, 0x1ab0d4e2(%rip)  # 0x1ab61280
addl %r10d, %eax
movl %eax, 0x1ab0d4dd(%rip)  # 0x1ab61284
subl %r10d, %edx
movl %edx, 0x1ab0d4d8(%rip)  # 0x1ab61288
addl $0x6, %ecx
movl %ecx, 0x1ab0d4d3(%rip)  # 0x1ab6128c
leal (%r12,%rsi), %eax
decl %eax
movl %eax, 0x1ab0d4cb(%rip)  # 0x1ab61290
addl %r10d, %edi
movl %edi, 0x1ab0d4c6(%rip)  # 0x1ab61294
movl %r8d, %eax
subl %r10d, %eax
movl %eax, 0x1ab0d4be(%rip)  # 0x1ab61298
decl %r8d
movl %r8d, 0x1ab0d4b8(%rip)  # 0x1ab6129c
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq