// File: /workspace/github_cpp_makefile_star2_O3/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:
cmpl $0x0, 0xc(%rdi)
jle 0x483a
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0xdfca0(%rdi), %rax
movq %rax, -0x18(%rsp)
movl $0x1, %edx
leal -0x1(%rdx), %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq (%rdx,%rdx,4), %rax
shlq $0x6, %rax
addq -0x18(%rsp), %rax
movq %rax, -0x10(%rsp)
xorl %r11d, %r11d
movl $0x1, %esi
movq %rdx, -0x28(%rsp)
leaq -0x1(%rsi), %rax
xorl %r14d, %r14d
leaq (%rax,%rax,4), %r15
shlq $0x4, %r15
addq -0x10(%rsp), %r15
movl %ebp, -0x1c(%rsp)
movq %rsi, -0x8(%rsp)
movl %esi, %r12d
movl %edx, %r13d
xorl %r9d, %r9d
movl 0x8(%rdi), %esi
movl %ecx, %eax
cltd
idivl %esi
movl $0x0, %r8d
cmpl %r14d, %edx
jl 0x4718
notl %eax
addl %esi, %eax
cmpl %r12d, %eax
jl 0x4718
imull %r12d, %esi
addl %r13d, %esi
movl %esi, %r8d
movslq %r9d, %rsi
movl %r8d, (%r15,%rsi,4)
incl %esi
leaq (%r11,%r14), %r10
decq %r10
je 0x4758
movl 0x8(%rdi), %r8d
movl %ecx, %eax
cltd
idivl %r8d
xorl %ebx, %ebx
cmpl %r14d, %edx
jl 0x474a
cmpl %r12d, %eax
jl 0x474a
imull %ebp, %r8d
addl %r13d, %r8d
movl %r8d, %ebx
addl $0x2, %r9d
movslq %esi, %rax
movl %ebx, (%r15,%rax,4)
movl %r9d, %esi
testl %r14d, %r14d
je 0x47e1
movl 0x8(%rdi), %r9d
movl %ecx, %eax
cltd
idivl %r9d
notl %edx
addl %r9d, %edx
xorl %r8d, %r8d
cmpl %r14d, %edx
jl 0x4794
notl %eax
addl %r9d, %eax
cmpl %r12d, %eax
jl 0x4794
imull %r12d, %r9d
movq -0x28(%rsp), %rax
addl %r14d, %eax
addl %eax, %r9d
movl %r9d, %r8d
leal 0x1(%rsi), %r9d
movslq %esi, %rax
movl %r8d, (%r15,%rax,4)
testq %r10, %r10
je 0x47de
movl 0x8(%rdi), %r10d
movl %ecx, %eax
cltd
idivl %r10d
notl %edx
addl %r10d, %edx
xorl %r8d, %r8d
cmpl %r14d, %edx
jl 0x47d2
cmpl %r12d, %eax
jl 0x47d2
imull %ebp, %r10d
movq -0x28(%rsp), %rax
addl %r14d, %eax
addl %eax, %r10d
movl %r10d, %r8d
addl $0x2, %esi
movslq %r9d, %rax
movl %r8d, (%r15,%rax,4)
jmp 0x47e1
movl %r9d, %esi
decl %r13d
decl %r12d
incl %ebp
incq %r14
leal (%r11,%r14), %eax
movl %esi, %r9d
cmpl $0x2, %eax
jne 0x46f2
movq -0x8(%rsp), %rsi
incq %rsi
movl -0x1c(%rsp), %ebp
decl %ebp
decq %r11
cmpq $0x5, %rsi
movq -0x28(%rsp), %rdx
jne 0x46cc
leaq 0x1(%rdx), %rax
movslq 0xc(%rdi), %rcx
cmpq %rcx, %rdx
movq %rax, %rdx
jl 0x46a5
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop