// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, -0x20(%rsp)
cmpl $0x0, 0xc(%rdi)
jle 0x46e0
movq -0x20(%rsp), %rax
leaq 0xdfca0(%rax), %rdi
movl $0x1, %r8d
leal -0x1(%r8), %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq $0x0, -0x18(%rsp)
movl $0x1, %eax
leaq -0x1(%rax), %rbx
xorl %r14d, %r14d
movl %ebp, -0xc(%rsp)
movq %rax, -0x8(%rsp)
movl %eax, %r15d
movl %r8d, %r12d
xorl %r13d, %r13d
movq -0x20(%rsp), %rax
movl 0x8(%rax), %r10d
movl %ecx, %eax
cltd
idivl %r10d
movslq %r13d, %r9
cmpl %r14d, %edx
jl 0x44d4
movl %ecx, %eax
cltd
idivl %r10d
notl %eax
addl %r10d, %eax
cmpl %r15d, %eax
jge 0x44f4
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl $0x0, (%rdx,%r9,4)
jmp 0x4515
imull %r15d, %r10d
addl %r12d, %r10d
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl %r10d, (%rdx,%r9,4)
leal 0x1(%r13), %r11d
movq -0x18(%rsp), %rax
leaq (%rax,%r14), %r9
decq %r9
je 0x4591
movq -0x20(%rsp), %rax
movl 0x8(%rax), %esi
movl %ecx, %eax
cltd
idivl %esi
movslq %r11d, %r10
cmpl %r14d, %edx
jl 0x4546
movl %ecx, %eax
cltd
idivl %esi
cmpl %r15d, %eax
jge 0x456a
addl $0x2, %r13d
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl $0x0, (%rdx,%r10,4)
jmp 0x458e
imull %ebp, %esi
addl %r12d, %esi
addl $0x2, %r13d
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl %esi, (%rdx,%r10,4)
movl %r13d, %r11d
testl %r14d, %r14d
je 0x468b
movq -0x20(%rsp), %rax
movl 0x8(%rax), %r13d
movl %ecx, %eax
cltd
idivl %r13d
notl %edx
addl %r13d, %edx
movslq %r11d, %r10
cmpl %r14d, %edx
jl 0x45c6
movl %ecx, %eax
cltd
idivl %r13d
notl %eax
addl %r13d, %eax
cmpl %r15d, %eax
jge 0x45e6
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl $0x0, (%rdx,%r10,4)
jmp 0x460a
imull %r15d, %r13d
addl %r8d, %r13d
addl %r14d, %r13d
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl %r13d, (%rdx,%r10,4)
leal 0x1(%r11), %esi
testq %r9, %r9
je 0x465e
movq -0x20(%rsp), %rax
movl 0x8(%rax), %r10d
movl %ecx, %eax
cltd
idivl %r10d
notl %edx
addl %r10d, %edx
movslq %esi, %r9
cmpl %r14d, %edx
jl 0x463a
movl %ecx, %eax
cltd
idivl %r10d
cmpl %r15d, %eax
jge 0x4663
addl $0x2, %r11d
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl $0x0, (%rdx,%r9,4)
jmp 0x468b
movl %esi, %r11d
jmp 0x468b
imull %ebp, %r10d
addl %r8d, %r10d
addl %r14d, %r10d
addl $0x2, %r11d
leaq (%r8,%r8,4), %rax
shlq $0x6, %rax
addq %rdi, %rax
leaq (%rbx,%rbx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movl %r10d, (%rdx,%r9,4)
decl %r12d
decl %r15d
incl %ebp
incq %r14
movq -0x18(%rsp), %rax
addl %r14d, %eax
movl %r11d, %r13d
cmpl $0x2, %eax
jne 0x44ad
movq -0x8(%rsp), %rax
incq %rax
movl -0xc(%rsp), %ebp
decl %ebp
decq -0x18(%rsp)
cmpq $0x5, %rax
jne 0x4494
leaq 0x1(%r8), %rax
movq -0x20(%rsp), %rcx
movslq 0xc(%rcx), %rcx
cmpq %rcx, %r8
movq %rax, %r8
jl 0x447d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop