// File: antoniogarro[P]Hara/heuristics.cpp
// Function: Goban::total_liberties(int, bool, PList*, int, Group const*) const
int Goban::total_liberties(int point, bool color, PList *liberties, int enough=0, const Group *exclude=0) const
{
  PointSet<MAXSIZE2> libs;
  if (liberties) point_liberties(point, *liberties);
  point_liberties(point, libs);
  if (enough && libs.length() > enough) return libs.length();
  
  GroupSet<4> neighbours;
  int nneigh = neighbour_groups(point, neighbours);
  for (int i = 0; i < nneigh; i++) {
    const Group *curr_neigh = neighbours[i];
    if (curr_neigh != exclude) {
      if (curr_neigh->get_color() == color) {
        for (Group::LibertyIterator lib(curr_neigh); lib; ++lib) {
          if (*lib != point) {
            if (liberties) liberties->add(*lib);
            libs.add(*lib);
            if (enough && libs.length() > enough) return libs.length();
          }
        }
      } else if (curr_neigh->get_nliberties() == 1) {
        for (Group::StoneIterator st(curr_neigh); st; ++st) {
          for (int j = 0; adjacent[*st][j]; j++) {
            if (adjacent[*st][j] == point) {
              libs.add(*st);
              if (enough && libs.length() > enough) return libs.length();
            } else if (points[adjacent[*st][j]] &&
                       points[adjacent[*st][j]]->get_color() == color) {
              for (int k = 0; k < nneigh; k++) {
                if (points[adjacent[*st][j]] == neighbours[k]) {
                  libs.add(*st);
                  if (enough && libs.length() > enough) return libs.length();
                }
              }
            }
          }
        }
      }
    }
  }
  return libs.length();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x680, %rsp            # imm = 0x680
movb %dl, %al
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
andb $0x1, %al
movb %al, -0x15(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x648(%rbp)
leaq -0x5e0(%rbp), %rdi
callq 0x10ee0
cmpq $0x0, -0x20(%rbp)
je 0x10606
movq -0x648(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x7aa0
movq -0x648(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x5e0(%rbp), %rdx
callq 0x7aa0
cmpl $0x0, -0x24(%rbp)
je 0x10647
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
cmpl -0x24(%rbp), %eax
jle 0x10647
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
movl %eax, -0x4(%rbp)
jmp 0x10aa8
leaq -0x618(%rbp), %rdi
callq 0x73c0
movq -0x648(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x618(%rbp), %rdx
callq 0x7a10
movl %eax, -0x61c(%rbp)
movl $0x0, -0x620(%rbp)
movl -0x620(%rbp), %eax
cmpl -0x61c(%rbp), %eax
jge 0x10a99
movl -0x620(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x73e0
movq %rax, -0x628(%rbp)
movq -0x628(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x10a83
movq -0x628(%rbp), %rdi
callq 0x7400
andb $0x1, %al
movzbl %al, %eax
movb -0x15(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x1079b
movq -0x628(%rbp), %rsi
leaq -0x630(%rbp), %rdi
callq 0x10fd0
leaq -0x630(%rbp), %rdi
callq 0x74a0
testb $0x1, %al
jne 0x106ff
jmp 0x10796
leaq -0x630(%rbp), %rdi
callq 0x74c0
cmpl -0x14(%rbp), %eax
je 0x10783
cmpq $0x0, -0x20(%rbp)
je 0x1073c
movq -0x20(%rbp), %rax
movq %rax, -0x650(%rbp)
leaq -0x630(%rbp), %rdi
callq 0x74c0
movq -0x650(%rbp), %rdi
movl %eax, %esi
movq (%rdi), %rax
callq *(%rax)
leaq -0x630(%rbp), %rdi
callq 0x74c0
movl %eax, %esi
leaq -0x5e0(%rbp), %rdi
callq 0x11010
cmpl $0x0, -0x24(%rbp)
je 0x10781
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
cmpl -0x24(%rbp), %eax
jle 0x10781
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
movl %eax, -0x4(%rbp)
jmp 0x10aa8
jmp 0x10783
jmp 0x10785
leaq -0x630(%rbp), %rdi
callq 0x74e0
jmp 0x106ea
jmp 0x10a81
movq -0x628(%rbp), %rdi
callq 0x7380
cmpl $0x1, %eax
jne 0x10a7f
movq -0x628(%rbp), %rsi
leaq -0x638(%rbp), %rdi
callq 0x7460
leaq -0x638(%rbp), %rdi
callq 0x74a0
testb $0x1, %al
jne 0x107d8
jmp 0x10a7d
movl $0x0, -0x63c(%rbp)
movq -0x648(%rbp), %rax
addq $0xd63e8, %rax          # imm = 0xD63E8
movq %rax, -0x658(%rbp)
leaq -0x638(%rbp), %rdi
callq 0x74c0
movl %eax, %ecx
movq -0x658(%rbp), %rax
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movslq -0x63c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x10a6a
movq -0x648(%rbp), %rax
addq $0xd63e8, %rax          # imm = 0xD63E8
movq %rax, -0x660(%rbp)
leaq -0x638(%rbp), %rdi
callq 0x74c0
movl %eax, %ecx
movq -0x660(%rbp), %rax
movslq %ecx, %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movslq -0x63c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x14(%rbp), %eax
jne 0x108b2
leaq -0x638(%rbp), %rdi
callq 0x74c0
movl %eax, %esi
leaq -0x5e0(%rbp), %rdi
callq 0x11010
cmpl $0x0, -0x24(%rbp)
je 0x108ad
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
cmpl -0x24(%rbp), %eax
jle 0x108ad
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
movl %eax, -0x4(%rbp)
jmp 0x10aa8
jmp 0x10a54
movq -0x648(%rbp), %rax
addq $0xd63e8, %rax          # imm = 0xD63E8
movq %rax, -0x668(%rbp)
leaq -0x638(%rbp), %rdi
callq 0x74c0
movq -0x668(%rbp), %rcx
movl %eax, %edx
movq -0x648(%rbp), %rax
movslq %edx, %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rcx
movslq -0x63c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpq $0x0, 0x18(%rax,%rcx,8)
je 0x10a52
movq -0x648(%rbp), %rax
addq $0xd63e8, %rax          # imm = 0xD63E8
movq %rax, -0x670(%rbp)
leaq -0x638(%rbp), %rdi
callq 0x74c0
movq -0x670(%rbp), %rcx
movl %eax, %edx
movq -0x648(%rbp), %rax
movslq %edx, %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rcx
movslq -0x63c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq 0x18(%rax,%rcx,8), %rdi
callq 0x7400
andb $0x1, %al
movzbl %al, %eax
movb -0x15(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x10a52
movl $0x0, -0x640(%rbp)
movl -0x640(%rbp), %eax
cmpl -0x61c(%rbp), %eax
jge 0x10a50
movq -0x648(%rbp), %rax
addq $0xd63e8, %rax          # imm = 0xD63E8
movq %rax, -0x680(%rbp)
leaq -0x638(%rbp), %rdi
callq 0x74c0
movq -0x680(%rbp), %rcx
movl %eax, %edx
movq -0x648(%rbp), %rax
movslq %edx, %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rcx
movslq -0x63c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x678(%rbp)
movl -0x640(%rbp), %esi
leaq -0x618(%rbp), %rdi
callq 0x73e0
movq %rax, %rcx
movq -0x678(%rbp), %rax
cmpq %rcx, %rax
jne 0x10a3a
leaq -0x638(%rbp), %rdi
callq 0x74c0
movl %eax, %esi
leaq -0x5e0(%rbp), %rdi
callq 0x11010
cmpl $0x0, -0x24(%rbp)
je 0x10a38
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
cmpl -0x24(%rbp), %eax
jle 0x10a38
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
movl %eax, -0x4(%rbp)
jmp 0x10aa8
jmp 0x10a3a
jmp 0x10a3c
movl -0x640(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x640(%rbp)
jmp 0x10972
jmp 0x10a52
jmp 0x10a54
jmp 0x10a56
movl -0x63c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x63c(%rbp)
jmp 0x107e2
jmp 0x10a6c
leaq -0x638(%rbp), %rdi
callq 0x74e0
jmp 0x107c3
jmp 0x10a7f
jmp 0x10a81
jmp 0x10a83
jmp 0x10a85
movl -0x620(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x620(%rbp)
jmp 0x10679
leaq -0x5e0(%rbp), %rdi
callq 0x10fb0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x680, %rsp            # imm = 0x680
popq %rbp
retq
nopw %cs:(%rax,%rax)