// File: /workspace/github_cpp_makefile_star2_O3/antoniogarro[P]Hara/priors.cpp
// Function: Goban::init_priors(Prior*) const
void Goban::init_priors(Prior priors[]) const
{
  const double EQUIV = size;// /2;
  priors[PASS].prior = 0.1*EQUIV, priors[PASS].equiv = EQUIV;

  for(int i = 0; i < empty_points.length(); ++i){    
    int p = empty_points[i];
       priors[p].prior = 0.5*EQUIV, priors[p].equiv = EQUIV;
    }
    for(int i = 0; i < empty_points.length(); ++i){    
    int p = empty_points[i];
    if(is_self_atari(p, side)){
      priors[p].prior = 0.2*EQUIV, priors[p].equiv = 2*EQUIV;
      continue;
    }  
    if(is_surrounded(p, side)){
      priors[p].prior = 0.3*EQUIV, priors[p].equiv = EQUIV;
      continue;
    }
    priors[p].prior = 0.5*EQUIV, priors[p].equiv = EQUIV;
    if(size > 11){
      if(distance_to_edge[p] == 0 && !stones_around(p, 4)){
        priors[p].prior = 0.1*EQUIV, priors[p].equiv = EQUIV;
      }
      else if(distance_to_edge[p] == 3 && !stones_around(p, 4)){
        priors[p].prior = 0.9*EQUIV, priors[p].equiv = EQUIV;
      }
    }
    
    GroupSet<4> neigh;
    int nneigh = neighbour_groups(p, neigh);
    for(int j = 0; j < nneigh; j++){
      if(neigh[j]->has_one_liberty()){
        if(neigh[j]->get_color() != side){
          priors[p].prior = 1.4*EQUIV, priors[p].equiv = 2*EQUIV;
          goto endloop;
        }
        else{
          priors[p].prior = 0.6*EQUIV, priors[p].equiv = EQUIV;
          goto endloop;
        }
      }
    }
    if(match_mogo_pattern(p, side)){
      priors[p].prior = 0.9*EQUIV, priors[p].equiv = EQUIV;
      continue;
    }
  endloop:;
  }
  
  if(last_point == 0) return;
  
  PointSet<MAXSIZE2> list;
  capture_heuristic(last_point, list);
  for(int i = 0; i < list.length(); i++){
    priors[list[i]].prior += 3*EQUIV, priors[list[i]].equiv += 3*EQUIV;
  }
  list.clear();

  save_heuristic(last_point, list);
  for(int i = 0; i < list.length(); i++){
    priors[list[i]].prior += 2*EQUIV, priors[list[i]].equiv += 2*EQUIV;
  }
  list.clear();

  pattern_heuristic(last_point, list);
  for(int i = 0; i < list.length(); i++){
    priors[list[i]].prior += 2*EQUIV, priors[list[i]].equiv += 2*EQUIV;
  }
  list.clear();

  
  for(int i = 0; last_point && i < 4; i++){
    for(int j = 0; j < 4*(i+1); j++){
      int v =  within_manhattan[last_point][i][j];
      if(v) {
        priors[v].prior += (1.0-0.1*i)*EQUIV, priors[v].equiv += EQUIV;
      }
    }
  }
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x608, %rsp            # imm = 0x608
movq %rsi, %rbx
movq %rdi, %r14
cvtsi2sdl 0x8(%rdi), %xmm0
movsd 0x1984(%rip), %xmm1     # 0xb028
mulsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rsp)
movsd %xmm1, (%rsi)
movsd %xmm0, 0x8(%rsi)
movslq 0xfc6d0(%rdi), %rax
testq %rax, %rax
movapd %xmm0, (%rsp)
jle 0x98db
movsd 0x210c(%rip), %xmm1     # 0xb7e0
mulsd %xmm0, %xmm1
xorl %ecx, %ecx
movslq 0xfc128(%r14,%rcx,4), %rdx
shlq $0x4, %rdx
movsd %xmm1, (%rbx,%rdx)
movsd %xmm0, 0x8(%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x96da
testl %eax, %eax
jle 0x98db
movsd 0x18ff(%rip), %xmm2     # 0xb008
mulsd %xmm0, %xmm2
movsd %xmm2, 0x10(%rsp)
movsd 0x20cd(%rip), %xmm2     # 0xb7e8
mulsd %xmm0, %xmm2
movsd %xmm2, 0x20(%rsp)
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd 0x20cf(%rip), %xmm0     # 0xb800
movapd %xmm0, 0x40(%rsp)
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movapd %xmm0, 0x30(%rsp)
xorl %r13d, %r13d
movsd %xmm1, 0x28(%rsp)
movl 0xfc128(%r14,%r13,4), %ebp
movslq %ebp, %r12
movzbl (%r14), %edx
movq %r14, %rdi
movl %r12d, %esi
callq 0x820e
testb %al, %al
je 0x977d
shlq $0x4, %r12
movapd 0x40(%rsp), %xmm0
movupd %xmm0, (%rbx,%r12)
jmp 0x98c8
movzbl (%r14), %edx
movq %r14, %rdi
movl %r12d, %esi
xorl %ecx, %ecx
callq 0x5584
movq %r12, %r15
shlq $0x4, %r15
addq %rbx, %r15
testb %al, %al
je 0x97b1
movsd 0x20(%rsp), %xmm0
movsd %xmm0, (%r15)
movapd (%rsp), %xmm0
jmp 0x98c2
movsd 0x28(%rsp), %xmm0
movsd %xmm0, (%r15)
movapd (%rsp), %xmm0
movsd %xmm0, 0x8(%r15)
cmpl $0xc, 0x8(%r14)
jl 0x982f
movl 0xdf6f8(%r14,%r12,4), %eax
testl %eax, %eax
jne 0x9800
movq %r14, %rdi
movl %ebp, %esi
movl $0x4, %edx
callq 0x8e8e
movapd (%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
testb %al, %al
je 0x9824
movl 0xdf6f8(%r14,%r12,4), %eax
cmpl $0x3, %eax
jne 0x982f
movq %r14, %rdi
movl %r12d, %esi
movl $0x4, %edx
callq 0x8e8e
movapd (%rsp), %xmm1
movsd 0x10(%rsp), %xmm0
testb %al, %al
jne 0x982f
movsd %xmm0, (%r15)
movsd %xmm1, 0x8(%r15)
movl $0x0, 0x88(%rsp)
movq $0x0, 0x58(%rsp)
movq %r14, %rdi
movl %r12d, %esi
leaq 0x58(%rsp), %rdx
callq 0x533c
movapd (%rsp), %xmm2
testl %eax, %eax
jle 0x9876
movl %eax, %eax
xorl %ecx, %ecx
movq 0x58(%rsp,%rcx,8), %rdx
cmpl $0x1, 0x96c(%rdx)
je 0x9895
incq %rcx
cmpq %rcx, %rax
jne 0x9860
movzbl (%r14), %edx
movq %r14, %rdi
movl %ebp, %esi
callq 0x89a4
movsd 0x10(%rsp), %xmm1
movapd (%rsp), %xmm0
testb %al, %al
jne 0x98bd
jmp 0x98c8
movb (%r14), %cl
xorl %eax, %eax
movapd %xmm2, %xmm0
cmpb (%rdx), %cl
sete %cl
je 0x98ab
movapd 0x30(%rsp), %xmm0
movb %cl, %al
leaq 0x1f5c(%rip), %rcx      # 0xb810
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm2, %xmm1
movsd %xmm1, (%r15)
movsd %xmm0, 0x8(%r15)
incq %r13
movslq 0xfc6d0(%r14), %rax
cmpq %rax, %r13
jl 0x974a
movl 0xd63e0(%r14), %esi
testl %esi, %esi
je 0x9aa2
xorl %ebp, %ebp
leaq 0x58(%rsp), %r15
movl %ebp, 0x5ac(%r15)
movl %ebp, 0x8(%r15)
leaq 0x63ed(%rip), %rax      # 0xfcf0
movq %rax, (%r15)
movq %r14, %rdi
movq %r15, %rdx
callq 0x8718
movslq 0x5ac(%r15), %rax
testq %rax, %rax
jle 0x994f
movapd (%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
xorl %ecx, %ecx
mulpd 0x1ef0(%rip), %xmm0     # 0xb820
movslq 0x60(%rsp,%rcx,4), %rdx
shlq $0x4, %rdx
movupd (%rbx,%rdx), %xmm1
addpd %xmm0, %xmm1
movupd %xmm1, (%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x9930
leaq 0x58(%rsp), %r15
movl %ebp, 0x5ac(%r15)
movl %ebp, 0x8(%r15)
movl 0xd63e0(%r14), %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x85d6
movslq 0x5ac(%r15), %rax
testq %rax, %rax
jle 0x99ab
movapd (%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
xorl %ecx, %ecx
addpd %xmm0, %xmm0
movslq 0x60(%rsp,%rcx,4), %rdx
shlq $0x4, %rdx
movupd (%rbx,%rdx), %xmm1
addpd %xmm0, %xmm1
movupd %xmm1, (%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x998c
xorl %eax, %eax
leaq 0x58(%rsp), %r15
movl %eax, 0x5ac(%r15)
movl %eax, 0x8(%r15)
movl 0xd63e0(%r14), %esi
movq %r14, %rdi
movq %r15, %rdx
callq 0x86b2
movslq 0x5ac(%r15), %rax
testq %rax, %rax
movapd (%rsp), %xmm4
jle 0x9a0d
movapd %xmm4, %xmm0
unpcklpd %xmm4, %xmm0            # xmm0 = xmm0[0],xmm4[0]
xorl %ecx, %ecx
addpd %xmm0, %xmm0
movslq 0x60(%rsp,%rcx,4), %rdx
shlq $0x4, %rdx
movupd (%rbx,%rdx), %xmm1
addpd %xmm0, %xmm1
movupd %xmm1, (%rbx,%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x99ee
movslq 0xd63e0(%r14), %rax
testq %rax, %rax
je 0x9aa2
leaq (%rax,%rax,4), %rax
shlq $0x6, %rax
addq %r14, %rax
addq $0xdfca0, %rax          # imm = 0xDFCA0
movl $0x4, %ecx
xorl %edx, %edx
movsd 0x1db3(%rip), %xmm0     # 0xb7f0
movsd 0x15db(%rip), %xmm1     # 0xb020
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
mulsd %xmm4, %xmm2
xorl %esi, %esi
movslq (%rax,%rsi,4), %rdi
testq %rdi, %rdi
je 0x9a85
shlq $0x4, %rdi
movsd (%rbx,%rdi), %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%rbx,%rdi)
movsd 0x8(%rbx,%rdi), %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, 0x8(%rbx,%rdi)
incq %rsi
cmpq %rsi, %rcx
jne 0x9a5a
leaq 0x1(%rdx), %rsi
addq $0x4, %rcx
addq $0x50, %rax
cmpq $0x2, %rdx
movq %rsi, %rdx
jbe 0x9a45
addq $0x608, %rsp            # imm = 0x608
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq