// File: antoniogarro[P]Hara/goban.cpp
// Function: Goban::init_vicinity()
void Goban::init_vicinity()
{  
  for (int i = 0; i <= size2; i++) {
    for (int j = 0; j < 16; j++) {
      vicinity[i][j] = 0;
    }
  }
  //Duplicate to calculate rotations,avoiding run-time modulo division:
  for (int i = 0; i < 2; i++) {
    for (int k = 1; k <= size2; k++) {
      if (k <= size*(size-1)) {
        if (k % size != 1) {  //NW
          vicinity[k][0+8*i] =  k + size - 1;
        }
        vicinity[k][1+8*i] =  k + size;  //N
      }
      if (k % size ) {
        if (k <= size*(size-1)) {  //NE
          vicinity[k][2+8*i] =  k + size + 1;
        }
        vicinity[k][3+8*i] =  k + 1;  //E
      }
      if (k > size) {
        if (k % size) {  //SE
          vicinity[k][4+8*i] = k - size +1;
        }
        vicinity[k][5+8*i] = k - size;  //S
      }
      if (k % size != 1) {
        if (k > size) {  //SW
          vicinity[k][6+8*i] = k - size -1;
        }
        vicinity[k][7+8*i] = k - 1;  //W
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0xc(%rcx), %eax
jg 0x5d18
movl $0x0, -0x10(%rbp)
cmpl $0x10, -0x10(%rbp)
jge 0x5d0b
movq -0x20(%rbp), %rax
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0xc(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movslq -0x10(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5cda
jmp 0x5d0d
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x5cc7
movl $0x0, -0x14(%rbp)
cmpl $0x2, -0x14(%rbp)
jge 0x5f42
movl $0x1, -0x18(%rbp)
movq -0x20(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0xc(%rcx), %eax
jg 0x5f32
movq -0x20(%rbp), %rdx
movl -0x18(%rbp), %eax
movl 0x8(%rdx), %ecx
movl 0x8(%rdx), %edx
subl $0x1, %edx
imull %edx, %ecx
cmpl %ecx, %eax
jg 0x5dbe
movq -0x20(%rbp), %rcx
movl -0x18(%rbp), %eax
cltd
idivl 0x8(%rcx)
cmpl $0x1, %edx
je 0x5d94
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
addl 0x8(%rax), %edx
subl $0x1, %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
addl 0x8(%rax), %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rcx
movl -0x18(%rbp), %eax
cltd
idivl 0x8(%rcx)
cmpl $0x0, %edx
je 0x5e3c
movq -0x20(%rbp), %rdx
movl -0x18(%rbp), %eax
movl 0x8(%rdx), %ecx
movl 0x8(%rdx), %edx
subl $0x1, %edx
imull %edx, %ecx
cmpl %ecx, %eax
jg 0x5e12
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
addl 0x8(%rax), %edx
addl $0x1, %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
addl $0x1, %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x8(%rcx), %eax
jle 0x5eaf
movq -0x20(%rbp), %rcx
movl -0x18(%rbp), %eax
cltd
idivl 0x8(%rcx)
cmpl $0x0, %edx
je 0x5e85
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
subl 0x8(%rax), %edx
addl $0x1, %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
subl 0x8(%rax), %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rcx
movl -0x18(%rbp), %eax
cltd
idivl 0x8(%rcx)
cmpl $0x1, %edx
je 0x5f22
movq -0x20(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x8(%rcx), %eax
jle 0x5ef8
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
subl 0x8(%rax), %edx
subl $0x1, %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x6, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %edx
subl $0x1, %edx
addq $0xd9c78, %rax          # imm = 0xD9C78
movslq -0x18(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
shll $0x3, %ecx
addl $0x7, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x5f24
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x5d30
jmp 0x5f34
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x5d1f
popq %rbp
retq
nopw %cs:(%rax,%rax)