// File: /workspace/github_cpp_makefile_star2_O3/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, %r15d
movl %edi, 0x22b31(%rip)     # 0x768b4
movl %edi, %eax
imull %edi, %eax
movl %eax, 0x22b22(%rip)     # 0x768b0
leal 0xa(%r15), %r13d
movl %r13d, 0x22b23(%rip)    # 0x768bc
movl %r13d, %eax
imull %r13d, %eax
movl %eax, 0x22b12(%rip)     # 0x768b8
movl $0x5, 0x22b10(%rip)     # 0x768c0
leal 0x4(%r15), %r12d
movl %r12d, 0x22b09(%rip)    # 0x768c4
testl %edi, %edi
movq %r15, 0x10(%rsp)
movq %r12, 0x8(%rsp)
jle 0x540bf
cmpl $0x6, %r12d
movl $0x5, %eax
cmovgel %r12d, %eax
leal 0x1(%rax), %edx
movl %r13d, %ecx
leaq (%rcx,%rcx,4), %r8
leaq 0x1aababc5(%rip), %rsi  # 0x1ab0e9b0
leaq 0x14(%rsi,%r8,4), %rsi
leaq (,%rcx,4), %rdi
leaq 0x1aab9e81(%rip), %r9   # 0x1ab0dc80
leaq (%r9,%r8,4), %r8
addq $0x14, %r8
leal (%r15,%r15,4), %r9d
addl $0x37, %r9d
addq $-0x4, %rax
movl $0x5, %r10d
xorl %r11d, %r11d
leaq 0x1ab0d8cd(%rip), %rbx  # 0x1ab616f0
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, %rax
jne 0x53e31
incq %r10
addq %r14, %r11
addq %rdi, %rsi
addq %rdi, %r8
addq %rcx, %r9
cmpq %rdx, %r10
jne 0x53e23
movq 0x10(%rsp), %r15
testl %r15d, %r15d
movq 0x8(%rsp), %r12
jle 0x540bf
movq %r13, (%rsp)
movl %r15d, %edx
cmpl $0x6, %r12d
movl $0x5, %eax
cmovgel %r12d, %eax
incl %eax
movq %rax, 0x20(%rsp)
leaq 0x4(%rdx), %rax
imulq %rcx, %rax
leaq 0x1ab0c56e(%rip), %rsi  # 0x1ab60410
leaq (%rsi,%rax,4), %rax
addq $0x14, %rax
shlq $0x2, %rcx
movq %rcx, %rdi
negq %rdi
leaq (%rcx,%rcx,4), %r8
leaq 0x1ab0b821(%rip), %rsi  # 0x1ab5f6e0
movq %rdx, 0x18(%rsp)
leaq (%rsi,%rdx,4), %r9
addq $0x10, %r9
movl %r15d, %r10d
shrl %r10d
movl $0x5, %r11d
leaq 0x1ab0c545(%rip), %rbx  # 0x1ab60424
leaq 0x1ab0b80e(%rip), %r14  # 0x1ab5f6f4
movq $-0x1, %r15
movq %r14, %r12
movq %rbx, %r13
movq %r9, %rbp
movq %rax, %rsi
leal 0x2(%r15), %edx
movl %edx, (%r12,%r8)
movl %edx, (%rbp,%r8)
movl %edx, (%r13,%r8)
movl %edx, (%rsi)
incq %r15
addq %rdi, %rsi
addq $-0x4, %rbp
addq %rcx, %r13
addq $0x4, %r12
cmpq %r15, %r10
jne 0x53ef9
incq %r11
addq $0x4, %rax
addq %rcx, %r9
addq $0x4, %rbx
addq %rcx, %r14
cmpq 0x20(%rsp), %r11
jne 0x53ee6
movq 0x10(%rsp), %r15
leal 0x1(%r15), %ecx
andl $-0x2, %ecx
movq 0x18(%rsp), %r9
leaq -0x1(%r9), %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0x1ab0d1df(%rip), %rdx  # 0x1ab61140
xorl %esi, %esi
movdqa 0xb925(%rip), %xmm2     # 0x5f890
movdqa 0xb92d(%rip), %xmm3     # 0x5f8a0
pxor %xmm3, %xmm0
movdqa 0xcec1(%rip), %xmm4     # 0x60e40
pcmpeqd %xmm5, %xmm5
movdqa 0xcec5(%rip), %xmm6     # 0x60e50
movdqa 0xcecd(%rip), %xmm7     # 0x60e60
movq (%rsp), %r13
movq 0x8(%rsp), %r12
movd %esi, %xmm8
pshufd $0x50, %xmm8, %xmm8     # xmm8 = xmm8[0,0,1,1]
movq %rsi, %xmm9
pshufd $0x44, %xmm9, %xmm9     # xmm9 = xmm9[0,1,0,1]
movdqa %xmm8, %xmm10
pxor %xmm3, %xmm10
movq %rdx, %rdi
xorl %r8d, %r8d
movdqa %xmm2, %xmm11
movq 0xbfc0(%rip), %xmm12    # 0x5ff90
movdqa %xmm11, %xmm13
pxor %xmm3, %xmm13
movdqa %xmm13, %xmm14
pcmpgtd %xmm0, %xmm14
pcmpeqd %xmm0, %xmm13
pshufd $0xf5, %xmm13, %xmm15   # xmm15 = xmm13[1,1,3,3]
pand %xmm14, %xmm15
pshufd $0xf5, %xmm14, %xmm13   # xmm13 = xmm14[1,1,3,3]
por %xmm15, %xmm13
movdqa %xmm12, %xmm14
pxor %xmm3, %xmm14
pcmpgtd %xmm10, %xmm14
movdqa %xmm12, %xmm15
pand %xmm14, %xmm15
pandn %xmm8, %xmm14
por %xmm15, %xmm14
movq %r8, %xmm15
incq %r8
movq %r8, %xmm1
punpcklqdq %xmm1, %xmm15   # xmm15 = xmm15[0],xmm1[0]
paddq %xmm9, %xmm15
pshufd $0xe8, %xmm15, %xmm1    # xmm1 = xmm15[0,2,2,3]
paddd %xmm14, %xmm1
movdqa %xmm1, %xmm14
pxor %xmm3, %xmm14
pcmpgtd %xmm4, %xmm14
movdqa %xmm14, %xmm15
pandn %xmm1, %xmm15
psrld $0x1c, %xmm14
por %xmm15, %xmm14
movd %xmm13, %eax
notl %eax
testb $0x1, %al
je 0x54078
movd %xmm14, (%rdi)
pxor %xmm5, %xmm13
pextrw $0x4, %xmm13, %eax
testb $0x1, %al
je 0x54092
pshufd $0x55, %xmm14, %xmm1    # xmm1 = xmm14[1,1,1,1]
movd %xmm1, 0x4c(%rdi)
paddq %xmm6, %xmm11
paddd %xmm7, %xmm12
addq $0x98, %rdi
incq %r8
cmpq %rcx, %r8
jne 0x53fd0
incq %rsi
addq $0x4, %rdx
cmpq %r9, %rsi
jne 0x53f9c
leaq 0x1aab8e8a(%rip), %r14  # 0x1ab0cf50
movl $0xd24, %edx            # imm = 0xD24
movq %r14, %rdi
xorl %esi, %esi
callq 0x6200
cmpl $-0x2, %r15d
jg 0x540ea
movl $0x0, 0x1aab8e1b(%rip)  # 0x1ab0cf00
jmp 0x542b3
movl %r15d, %eax
shrl $0x1f, %eax
addl %r15d, %eax
sarl %eax
leal 0x9(%r15), %ecx
movq %r13, (%rsp)
movslq %r13d, %rdx
addl $0x6, %eax
movq %rax, 0x38(%rsp)
leaq -0x5(%rcx), %rsi
imulq %rdx, %rsi
leaq (%rdx,%rdx,4), %rax
leaq (%rcx,%rax), %r12
addq $-0x5, %r12
leaq (%rdx,%rdx,4), %rdi
addq $0x5, %rdi
movq %rcx, 0x28(%rsp)
leaq (%rcx,%rsi), %rbx
addq $-0x5, %rbx
addq $0x5, %rsi
leaq 0x14(,%rax,4), %r10
leaq (,%rdx,4), %rax
movq %rax, 0x30(%rsp)
movl $0x1, %ebp
movl $0x5, %eax
movl $0x1, %r15d
movq %rbx, %r8
movq %r12, %r13
movq %rsi, %r11
movq %rax, 0x48(%rsp)
movq %r15, 0x40(%rsp)
movq %r10, 0x50(%rsp)
movq %r12, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movq %rsi, %rax
movq %rbx, 0x58(%rsp)
movq %r8, %r9
movq %rdi, 0x60(%rsp)
movq %rdi, %rcx
movq %r13, %rdi
movq %r11, %rsi
movl %ebp, (%r10,%r14)
movl %ebp, (%r14,%r12,4)
movl %ebp, (%r14,%rcx,4)
movl %ebp, (%r14,%rax,4)
movl %ebp, (%r14,%rsi,4)
movl %ebp, (%r14,%r9,4)
movl %ebp, (%r14,%rdi,4)
movl %ebp, (%r14,%rbx,4)
incl %ebp
incq %rsi
addq %rdx, %rdi
addq %rdx, %rcx
decq %r9
subq %rdx, %rbx
subq %rdx, %rax
decq %r12
addq $0x4, %r10
decq %r15
jne 0x54195
movq 0x48(%rsp), %rax
incq %rax
subq %rdx, %r11
decq %r13
movq 0x60(%rsp), %rdi
incq %rdi
subq %rdx, %r8
movq 0x58(%rsp), %rbx
decq %rbx
movq 0x20(%rsp), %rsi
incq %rsi
movq 0x18(%rsp), %r12
addq %rdx, %r12
movq 0x50(%rsp), %r10
addq 0x30(%rsp), %r10
movq 0x40(%rsp), %r15
incq %r15
cmpq 0x38(%rsp), %rax
jne 0x54163
movl $0x0, 0x1aab8cd3(%rip)  # 0x1ab0cf00
movq 0x10(%rsp), %r15
testl %r15d, %r15d
movq (%rsp), %r13
movq 0x8(%rsp), %r12
movq 0x28(%rsp), %rbp
jle 0x542b3
movl %ebp, %eax
shrl %eax
cmpl $0x6, %eax
movl $0x5, %ecx
cmovll %ecx, %eax
leal (%r15,%r15,2), %edx
leal 0x36(,%rdx,2), %edx
movl %ebp, %esi
xorl %edi, %edi
movl $0x1, %r8d
leaq 0x1ab0da30(%rip), %r9   # 0x1ab61ca0
movl %ebp, %r10d
subl %ecx, %r10d
cmpl %r12d, %r10d
jg 0x542a2
movslq %edi, %r10
shlq $0x2, %r10
xorl %r11d, %r11d
leal (%rdx,%r11), %ebx
leaq (%r10,%r11,4), %r14
movl %ebx, (%r9,%r14)
incq %r11
cmpl %r11d, %r8d
jne 0x54285
addl %r11d, %edi
movl %edi, 0x1aab8c5e(%rip)  # 0x1ab0cf00
leal 0x1(%rcx), %r10d
incq %r8
addq %rsi, %rdx
cmpl %eax, %ecx
movl %r10d, %ecx
jne 0x54270
addl $0xb, %r15d
leal (%r15,%r15,4), %eax
movl %eax, 0x1ab0dfaf(%rip)  # 0x1ab62270
movl %r12d, %ecx
imull %r13d, %ecx
leal 0x5(%rcx), %edx
movl %edx, 0x1ab0dfa3(%rip)  # 0x1ab62274
leal (%r13,%r13,4), %esi
leal (%rsi,%r12), %edi
movl %edi, 0x1ab0df98(%rip)  # 0x1ab62278
movl %r15d, %r8d
imull %r12d, %r8d
movl %r8d, 0x1ab0df8e(%rip)  # 0x1ab6227c
leal (%r15,%r15,4), %r9d
incl %r9d
movl %r9d, 0x1ab0df84(%rip)  # 0x1ab62280
addl %r13d, %eax
movl %eax, 0x1ab0df7f(%rip)  # 0x1ab62284
subl %r13d, %edx
movl %edx, 0x1ab0df7a(%rip)  # 0x1ab62288
addl $0x6, %ecx
movl %ecx, 0x1ab0df75(%rip)  # 0x1ab6228c
leal (%r12,%rsi), %eax
decl %eax
movl %eax, 0x1ab0df6d(%rip)  # 0x1ab62290
addl %r13d, %edi
movl %edi, 0x1ab0df68(%rip)  # 0x1ab62294
movl %r8d, %eax
subl %r13d, %eax
movl %eax, 0x1ab0df60(%rip)  # 0x1ab62298
decl %r8d
movl %r8d, 0x1ab0df5a(%rip)  # 0x1ab6229c
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq