// File: /workspace/github_cpp_makefile_star2_O1/antoniogarro[P]Hara/heuristics.cpp
// Function: Goban::match_mogo_pattern(int, bool) const
bool Goban::match_mogo_pattern(int point, bool side) const
{    
  if (point == 1 || point == size || point == size2 || point == size*(size-1)+1) return false;  //filter corners.
  
  if (point > size && point % size && point <= size*(size-1) && point % size != 1) {
    const int *vic = vicinity[point];
    for (int i = 1; i < 8; i+=2) {
      if (points[vic[i]]) {
        bool adj_color = points[vic[i]]->get_color();
        if (points[vic[i-1]] && points[vic[i-1]]->get_color() != adj_color) {
          if (points[vic[i+2]] == 0 && points[vic[i+6]] == 0) {
            if (points[vic[i+1]] && points[vic[i+1]]->get_color() != adj_color) {
              return true;  //Hane1
            }
            if (points[vic[i+1]] == 0 && points[vic[i+4]] == 0) {
              return true;  //Hane2
            }
          }
          if (points[vic[i+2]] == 0 && points[vic[i+4]] == 0 &&
              points[vic[i+6]] && points[vic[i+6]]->get_color() != adj_color) {
              return true;  //Hane3
          }
          if (points[vic[i+6]] && points[vic[i+6]]->get_color() == adj_color) {
            if ((points[vic[i+2]] || points[vic[i+4]] == 0 || points[vic[i+4]]->get_color() == adj_color) &&
                (points[vic[i+4]] || points[vic[i+2]] == 0 || points[vic[i+2]]->get_color() == adj_color)) {
              return true;  //Cut1
            }
          }
        }
        if (points[vic[i+1]] && points[vic[i+1]]->get_color() != adj_color) {
          if (points[vic[i+2]] == 0 && points[vic[i+6]] == 0) {
            if (points[vic[i-1]] == 0 && points[vic[i+4]] == 0) {
              return true;  //Mirror Hane2
            }
          }
          if (points[vic[i+4]] == 0 && points[vic[i+6]] == 0 &&
              points[vic[i+2]] && points[vic[i+2]]->get_color() != adj_color) {
              return true;  //Mirror Hane3
          }
        }
        if (points[vic[i+2]] && points[vic[i+6]] && points[vic[i+2]]->get_color() != adj_color &&
            points[vic[i+6]]->get_color() != adj_color &&
            (points[vic[i+4]] == 0 || points[vic[i+4]]->get_color() == adj_color) &&
            (points[vic[i+3]] == 0 || points[vic[i+3]]->get_color() == adj_color) &&
            (points[vic[i+5]] == 0 || points[vic[i+5]]->get_color() == adj_color)) {
          return true;  //Cut2
        }
        if (adj_color != side && points[vic[i-1]] && points[vic[i-1]]->get_color() == side &&
            points[vic[i+2]] == 0 && points[vic[i+4]] == 0 && points[vic[i+6]] == 0 &&
            points[vic[i+1]] && points[vic[i+1]]->get_color() == adj_color) {
          return true;  //Hane4
        }
        if (adj_color != side && points[vic[i+1]] && points[vic[i+1]]->get_color() == side &&
            points[vic[i+2]] == 0 && points[vic[i+4]] == 0 && points[vic[i+6]] == 0 &&
            points[vic[i-1]] && points[vic[i-1]]->get_color() == adj_color) {
          return true;  //Mirror Hane4
        }
      }
    }
  } else {
    for (int i = 1; i < 8; i+=2) {
      const int *vic = vicinity[point];
      if (vic[i]) {
        if (points[vic[i]]) {
          if (vic[i+2] && points[vic[i+2]] && points[vic[i+2]]->get_color() != points[vic[i]]->get_color() &&
             (vic[i+6]==0 || points[vic[i+6]] == 0 || points[vic[i+6]]->get_color() != points[vic[i]]->get_color())) {
            return true;  //Side2
          }
          if (vic[i+6] && points[vic[i+6]] && points[vic[i+6]]->get_color() != points[vic[i]]->get_color() &&
             (vic[i+2]== 0 || points[vic[i+2]] == 0 || points[vic[i+2]]->get_color() != points[vic[i]]->get_color())) {
            return true;  //Mirror Side2
          }
          if (points[vic[i]]->get_color() == side) {
            if ((vic[i+1] && points[vic[i+1]] && points[vic[i+1]]->get_color() != side)) {
              return true;  //Side3
            }
            if ((vic[i-1] && points[vic[i-1]] && points[vic[i-1]]->get_color() != side)) {
              return true;  //Mirror Side3
            }
          }
          if (points[vic[i]]->get_color() != side) {
            if (vic[i+1] && points[vic[i+1]] && points[vic[i+1]]->get_color() == side) {
              if (vic[i+2] == 0 || points[vic[i+2]] == 0 || points[vic[i+2]]->get_color() == side) {
                return true;  //Side4
              }
              if (vic[i+2] && points[vic[i+2]] && points[vic[i+2]]->get_color() != side
                && vic[i+6] && points[vic[i+6]] && points[vic[i+6]]->get_color() == side) {
                return true; //Side5
              }
            }
            if (vic[i-1] && points[vic[i-1]] && points[vic[i-1]]->get_color() == side) {
              if (vic[i+6] == 0 || points[vic[i+6]] == 0 || points[vic[i+6]]->get_color() == side) {
                return true;  //Mirror Side4
              }
              if (vic[i+6] && points[vic[i+6]] && points[vic[i+6]]->get_color() != side &&
                  vic[i+2] && points[vic[i+2]] && points[vic[i+2]]->get_color() == side) {
                return true; //Mirror Side5
              }
            }
          }
        } else if ((vic[i+6] && points[vic[i+6]] && vic[i-1] && points[vic[i-1]] &&
                    points[vic[i+6]]->get_color() != points[vic[i-1]]->get_color())
               || (vic[i+2] && points[vic[i+2]] && vic[i+1] && points[vic[i+1]] &&
                    points[vic[i+2]]->get_color() != points[vic[i+1]]->get_color())) {
          return true;  //Side1 and mirror.
        }
      }
    }
  }
  return false;
}

// Assembly:
cmpl $0x1, %esi
jne 0x8b38
xorl %eax, %eax
retq
movl 0x8(%rdi), %r8d
xorl %eax, %eax
cmpl %esi, %r8d
je 0x8b37
cmpl %esi, 0xc(%rdi)
je 0x8b37
leal -0x1(%r8), %r10d
imull %r8d, %r10d
leal 0x1(%r10), %eax
cmpl %esi, %eax
je 0x8b35
pushq %rbx
movl %edx, %ecx
movslq %esi, %r9
cmpl %esi, %r8d
jge 0x8e02
movl %esi, %eax
cltd
idivl %r8d
cmpl %esi, %r10d
jl 0x8e02
cmpl $0x2, %edx
jb 0x8e02
shlq $0x6, %r9
leaq (%r9,%rdi), %rax
addq $0xd9c94, %rax          # imm = 0xD9C94
movq $-0x1, %rdx
xorl %esi, %esi
movslq -0x14(%rax,%rdx,4), %r8
movq 0x18(%rdi,%r8,8), %r8
testq %r8, %r8
je 0x8dca
movb (%r8), %r8b
movslq -0x18(%rax,%rdx,4), %r9
movq 0x18(%rdi,%r9,8), %r9
testq %r9, %r9
je 0x8c7c
cmpb %r8b, (%r9)
je 0x8c7c
movslq -0xc(%rax,%rdx,4), %r10
movq 0x18(%rdi,%r10,8), %r10
testq %r10, %r10
jne 0x8c3c
movslq 0x4(%rax,%rdx,4), %r11
cmpq $0x0, 0x18(%rdi,%r11,8)
jne 0x8c12
movslq -0x10(%rax,%rdx,4), %r11
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x8c01
cmpb %r8b, (%r11)
jne 0x901d
testq %r11, %r11
jne 0x8c12
movslq -0x4(%rax,%rdx,4), %r11
cmpq $0x0, 0x18(%rdi,%r11,8)
je 0x901d
testq %r10, %r10
jne 0x8c3c
movslq -0x4(%rax,%rdx,4), %r11
cmpq $0x0, 0x18(%rdi,%r11,8)
jne 0x8c3c
movslq 0x4(%rax,%rdx,4), %r11
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x8c3c
cmpb %r8b, (%r11)
jne 0x901d
movslq 0x4(%rax,%rdx,4), %r11
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x8c7c
cmpb %r8b, (%r11)
jne 0x8c7c
testq %r10, %r10
je 0x8de1
testq %r10, %r10
je 0x901d
movslq -0x4(%rax,%rdx,4), %r11
cmpq $0x0, 0x18(%rdi,%r11,8)
jne 0x901d
cmpb %r8b, (%r10)
je 0x901d
movslq -0x10(%rax,%rdx,4), %r10
movq 0x18(%rdi,%r10,8), %r10
testq %r10, %r10
je 0x8ce7
cmpb %r8b, (%r10)
je 0x8ce7
movslq -0xc(%rax,%rdx,4), %r11
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
jne 0x8cbf
movslq 0x4(%rax,%rdx,4), %rbx
movq 0x18(%rdi,%rbx,8), %rbx
orq %r9, %rbx
jne 0x8cbf
movslq -0x4(%rax,%rdx,4), %rbx
cmpq $0x0, 0x18(%rdi,%rbx,8)
je 0x901d
movslq -0x4(%rax,%rdx,4), %rbx
cmpq $0x0, 0x18(%rdi,%rbx,8)
jne 0x8ce7
testq %r11, %r11
je 0x8ce7
movslq 0x4(%rax,%rdx,4), %rbx
cmpq $0x0, 0x18(%rdi,%rbx,8)
jne 0x8ce7
cmpb %r8b, (%r11)
jne 0x901d
movslq -0xc(%rax,%rdx,4), %r11
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x8d52
movslq 0x4(%rax,%rdx,4), %rbx
movq 0x18(%rdi,%rbx,8), %rbx
testq %rbx, %rbx
je 0x8d52
cmpb %r8b, (%r11)
je 0x8d52
cmpb %r8b, (%rbx)
je 0x8d52
movslq -0x4(%rax,%rdx,4), %rbx
movq 0x18(%rdi,%rbx,8), %rbx
testq %rbx, %rbx
je 0x8d23
cmpb %r8b, (%rbx)
jne 0x8d52
movslq -0x8(%rax,%rdx,4), %rbx
movq 0x18(%rdi,%rbx,8), %rbx
testq %rbx, %rbx
je 0x8d37
cmpb %r8b, (%rbx)
jne 0x8d52
movslq (%rax,%rdx,4), %rbx
movq 0x18(%rdi,%rbx,8), %rbx
testq %rbx, %rbx
je 0x901d
cmpb %r8b, (%rbx)
je 0x901d
cmpb %cl, %r8b
je 0x8dca
testq %r9, %r9
je 0x8d90
testq %r11, %r11
jne 0x8d90
movb (%r9), %bl
xorb %cl, %bl
jne 0x8d90
movslq -0x4(%rax,%rdx,4), %rbx
cmpq $0x0, 0x18(%rdi,%rbx,8)
jne 0x8d90
testq %r10, %r10
je 0x8d90
movslq 0x4(%rax,%rdx,4), %rbx
cmpq $0x0, 0x18(%rdi,%rbx,8)
jne 0x8d90
cmpb %r8b, (%r10)
je 0x901d
testq %r10, %r10
je 0x8dca
testq %r11, %r11
jne 0x8dca
movb (%r10), %r10b
xorb %cl, %r10b
jne 0x8dca
movslq -0x4(%rax,%rdx,4), %r10
cmpq $0x0, 0x18(%rdi,%r10,8)
jne 0x8dca
testq %r9, %r9
je 0x8dca
movslq 0x4(%rax,%rdx,4), %r10
cmpq $0x0, 0x18(%rdi,%r10,8)
jne 0x8dca
cmpb %r8b, (%r9)
je 0x901d
addq $0x2, %rdx
cmpq $0x6, %rdx
setae %sil
jb 0x8b96
jmp 0x9025
movslq -0x4(%rax,%rdx,4), %r11
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x8c59
cmpb %r8b, (%r11)
je 0x8c59
jmp 0x8c7c
shlq $0x6, %r9
leaq (%r9,%rdi), %rax
addq $0xd9c94, %rax          # imm = 0xD9C94
movq $-0x1, %rdx
xorl %esi, %esi
movslq -0x14(%rax,%rdx,4), %r8
testq %r8, %r8
je 0x9009
movq 0x18(%rdi,%r8,8), %r10
testq %r10, %r10
je 0x8fa9
movslq -0xc(%rax,%rdx,4), %r8
testq %r8, %r8
je 0x8e76
movq 0x18(%rdi,%r8,8), %r11
testq %r11, %r11
je 0x8e76
movb (%r10), %r9b
cmpb %r9b, (%r11)
je 0x8e76
movslq 0x4(%rax,%rdx,4), %r11
testq %r11, %r11
je 0x901d
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x901d
cmpb %r9b, (%r11)
jne 0x901d
movslq 0x4(%rax,%rdx,4), %r9
testq %r9, %r9
je 0x8eb2
movq 0x18(%rdi,%r9,8), %rbx
testq %rbx, %rbx
je 0x8eb2
movb (%r10), %r11b
cmpb %r11b, (%rbx)
je 0x8eb2
testl %r8d, %r8d
je 0x901d
movq 0x18(%rdi,%r8,8), %rbx
testq %rbx, %rbx
je 0x901d
cmpb %r11b, (%rbx)
jne 0x901d
movb (%r10), %r10b
xorb %cl, %r10b
jne 0x8efd
movslq -0x10(%rax,%rdx,4), %r11
testq %r11, %r11
je 0x8ed7
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x8ed7
cmpb %cl, (%r11)
jne 0x901d
movslq -0x18(%rax,%rdx,4), %r11
testq %r11, %r11
je 0x8ef4
movq 0x18(%rdi,%r11,8), %r11
testq %r11, %r11
je 0x8ef4
cmpb %cl, (%r11)
jne 0x901d
testb %r10b, %r10b
je 0x9009
movslq -0x10(%rax,%rdx,4), %r10
testq %r10, %r10
je 0x8f4e
movq 0x18(%rdi,%r10,8), %r10
testq %r10, %r10
je 0x8f4e
cmpb %cl, (%r10)
jne 0x8f4e
testl %r8d, %r8d
je 0x901d
movq 0x18(%rdi,%r8,8), %r10
testq %r10, %r10
je 0x901d
cmpb %cl, (%r10)
je 0x901d
testl %r9d, %r9d
je 0x8f4e
movq 0x18(%rdi,%r9,8), %r10
testq %r10, %r10
je 0x8f4e
cmpb %cl, (%r10)
je 0x901d
movslq -0x18(%rax,%rdx,4), %r10
testq %r10, %r10
je 0x9009
movq 0x18(%rdi,%r10,8), %r10
testq %r10, %r10
je 0x9009
cmpb %cl, (%r10)
jne 0x9009
testl %r9d, %r9d
je 0x901d
movq 0x18(%rdi,%r9,8), %r9
testq %r9, %r9
je 0x901d
cmpb %cl, (%r9)
je 0x901d
testl %r8d, %r8d
je 0x9009
movq 0x18(%rdi,%r8,8), %r8
testq %r8, %r8
je 0x9009
cmpb %cl, (%r8)
jne 0x9009
jmp 0x901d
movslq 0x4(%rax,%rdx,4), %r8
testq %r8, %r8
je 0x8fd9
movq 0x18(%rdi,%r8,8), %r8
testq %r8, %r8
je 0x8fd9
movslq -0x18(%rax,%rdx,4), %r9
testq %r9, %r9
je 0x8fd9
movq 0x18(%rdi,%r9,8), %r9
testq %r9, %r9
je 0x8fd9
movb (%r8), %r8b
cmpb (%r9), %r8b
jne 0x901d
movslq -0xc(%rax,%rdx,4), %r8
testq %r8, %r8
je 0x9009
movq 0x18(%rdi,%r8,8), %r8
testq %r8, %r8
je 0x9009
movslq -0x10(%rax,%rdx,4), %r9
testq %r9, %r9
je 0x9009
movq 0x18(%rdi,%r9,8), %r9
testq %r9, %r9
je 0x9009
movb (%r8), %r8b
cmpb (%r9), %r8b
jne 0x901d
addq $0x2, %rdx
cmpq $0x6, %rdx
setae %sil
jb 0x8e19
jmp 0x9025
movb $0x1, %al
testb $0x1, %sil
je 0x9027
xorl %eax, %eax
popq %rbx
retq
nop