// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0xdfca0(%rdi), %rax
movq %rax, -0x18(%rsp)
movabsq $0x1, %rdx
movslq 0xc(%rdi), %rax
cmpq %rax, %rdx
jg 0x45a8
leal -0x1(%rdx), %ecx
movq %rdx, -0x28(%rsp)
imulq $0x140, %rdx, %rax      # imm = 0x140
addq -0x18(%rsp), %rax
movq %rax, -0x10(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movabsq $0x1, %rdx
cmpq $0x5, %rdx
je 0x459b
leaq -0x1(%rdx), %rax
xorl %r12d, %r12d
imulq $0x50, %rax, %r13
addq -0x10(%rsp), %r13
movq %rdx, -0x8(%rsp)
movl %edx, %ebp
movl %ebx, -0x1c(%rsp)
xorl %r8d, %r8d
xorl %r11d, %r11d
leal (%r14,%r8), %eax
cmpl $-0x2, %eax
je 0x4585
movl 0x8(%rdi), %esi
movl %ecx, %eax
cltd
idivl %esi
xorl %r9d, %r9d
cmpl %r12d, %edx
jl 0x448e
notl %eax
addl %esi, %eax
leal (%r14,%r8), %edx
incl %edx
cmpl %edx, %eax
jl 0x448e
imull %ebp, %esi
movq -0x28(%rsp), %rax
addl %r8d, %eax
addl %eax, %esi
movl %esi, %r9d
movslq %r11d, %rsi
movl %r9d, (%r13,%rsi,4)
incl %esi
leaq (%r14,%r8), %r9
incq %r9
je 0x44de
movl 0x8(%rdi), %r15d
movl %ecx, %eax
cltd
idivl %r15d
xorl %r10d, %r10d
cmpl %r12d, %edx
jl 0x44cf
leal (%r14,%r8), %edx
incl %edx
cmpl %edx, %eax
jl 0x44cf
imull %ebx, %r15d
movq -0x28(%rsp), %rax
addl %r8d, %eax
addl %eax, %r15d
movl %r15d, %r10d
addl $0x2, %r11d
movslq %esi, %rax
movl %r10d, (%r13,%rax,4)
movl %r11d, %esi
testl %r8d, %r8d
je 0x4573
movl 0x8(%rdi), %r11d
movl %ecx, %eax
cltd
idivl %r11d
notl %edx
addl %r11d, %edx
xorl %r15d, %r15d
cmpl %r12d, %edx
jl 0x451f
notl %eax
addl %r11d, %eax
leal (%r14,%r8), %edx
incl %edx
cmpl %edx, %eax
jl 0x451f
imull %ebp, %r11d
movq -0x28(%rsp), %rax
addl %r12d, %eax
addl %eax, %r11d
movl %r11d, %r15d
leal 0x1(%rsi), %r11d
movslq %esi, %rax
movl %r15d, (%r13,%rax,4)
testq %r9, %r9
je 0x4570
movl 0x8(%rdi), %r9d
movl %ecx, %eax
cltd
idivl %r9d
notl %edx
addl %r9d, %edx
xorl %r10d, %r10d
cmpl %r12d, %edx
jl 0x4563
leal (%r14,%r8), %edx
incl %edx
cmpl %edx, %eax
jl 0x4563
imull %ebx, %r9d
movq -0x28(%rsp), %rax
addl %r12d, %eax
addl %eax, %r9d
movl %r9d, %r10d
addl $0x2, %esi
movslq %r11d, %rax
movl %r10d, (%r13,%rax,4)
jmp 0x4573
movl %r11d, %esi
decq %r8
incl %ebx
decl %ebp
incq %r12
movl %esi, %r11d
jmp 0x4453
movq -0x8(%rsp), %rdx
incq %rdx
incq %r14
movl -0x1c(%rsp), %ebx
decl %ebx
jmp 0x4428
movq -0x28(%rsp), %rdx
incq %rdx
jmp 0x43f0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop