// File: antoniogarro[P]Hara/goban.cpp
// Function: Goban::init_manhattan()
void Goban::init_manhattan()
{
  for (int p = 1; p <= size2; p++) {
    for (int dis = 1; dis <= 4; dis++) {
      int len = 0;
      for (int d = 0; d <= dis; d++) {
        if ((p-1)%size >= d && size-(p-1)/size-1 >= (dis-d) ) {
          within_manhattan[p][dis-1][len++] = p - d + (dis-d)*size;
        } else {
          within_manhattan[p][dis-1][len++] = 0;
        }
        if (d != dis) {
          if ((p-1)%size >= d && (p-1)/size >= (dis-d)) {
            within_manhattan[p][dis-1][len++] = p - d - (dis-d)*size;
          } else {
            within_manhattan[p][dis-1][len++] = 0;
          }
        }
        if (d != 0) {
          if (size-(p-1)%size-1 >= d && size-(p-1)/size-1 >= (dis-d)) {
            within_manhattan[p][dis-1][len++] = p + d + (dis-d)*size;
          } else {
            within_manhattan[p][dis-1][len++] = 0;
          }
          if (d != dis) {
            if (size-(p-1)%size-1 >= d && (p-1)/size >= (dis-d)) {
              within_manhattan[p][dis-1][len++] = p + d - (dis-d)*size;
            } else {
              within_manhattan[p][dis-1][len++] = 0;
            }
          }
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x1, -0xc(%rbp)
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0xc(%rcx), %eax
jg 0x642a
movl $0x1, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jg 0x641a
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x640a
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
cmpl -0x18(%rbp), %edx
jl 0x614a
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %eax
movl %eax, -0x24(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
movl %eax, %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
subl $0x1, %eax
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jl 0x614a
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %edx
subl -0x18(%rbp), %edx
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
imull 0x8(%rax), %ecx
addl %ecx, %edx
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x14(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x6187
movq -0x20(%rbp), %rax
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
je 0x624a
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
cmpl -0x18(%rbp), %edx
jl 0x620b
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jl 0x620b
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %edx
subl -0x18(%rbp), %edx
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
imull 0x8(%rax), %ecx
subl %ecx, %edx
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x14(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x6248
movq -0x20(%rbp), %rax
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x624a
cmpl $0x0, -0x18(%rbp)
je 0x63fa
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %eax
movl %eax, -0x28(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
movl -0x28(%rbp), %eax
subl %edx, %eax
subl $0x1, %eax
cmpl -0x18(%rbp), %eax
jl 0x62ea
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
movl %eax, %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
subl $0x1, %eax
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jl 0x62ea
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %edx
addl -0x18(%rbp), %edx
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
imull 0x8(%rax), %ecx
addl %ecx, %edx
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x14(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x6327
movq -0x20(%rbp), %rax
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
je 0x63f8
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %eax
movl %eax, -0x30(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
movl -0x30(%rbp), %eax
subl %edx, %eax
subl $0x1, %eax
cmpl -0x18(%rbp), %eax
jl 0x63b9
movq -0x20(%rbp), %rcx
movl -0xc(%rbp), %eax
subl $0x1, %eax
cltd
idivl 0x8(%rcx)
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jl 0x63b9
movq -0x20(%rbp), %rax
movl -0xc(%rbp), %edx
addl -0x18(%rbp), %edx
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
imull 0x8(%rax), %ecx
subl %ecx, %edx
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x14(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x63f6
movq -0x20(%rbp), %rax
addq $0xdfca0, %rax          # imm = 0xDFCA0
movslq -0xc(%rbp), %rcx
imulq $0x140, %rcx, %rcx      # imm = 0x140
addq %rcx, %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl -0x14(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x14(%rbp)
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x63f8
jmp 0x63fa
jmp 0x63fc
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x60b6
jmp 0x640c
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x609e
jmp 0x641c
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x6087
popq %rbp
retq
nopl (%rax)