// File: kobanium[P]Ray/src/mcts/UctSearch.cpp
// Function: CalculateOwner(int)
static void
CalculateOwner( int color )
{
  const double inv_count = (statistic_count.load() > 0) ? 1.0 / statistic_count.load() : 1.0;

  for (int i = 0; i < pure_board_max; i++){
    const int pos = onboard_pos[i];
    owner_index[pos] = static_cast<int>(static_cast<double>(statistic[pos].colors[color]) * 10.0 * inv_count + 0.5);
    if (owner_index[pos] > OWNER_MAX - 1) owner_index[pos] = OWNER_MAX - 1;
    if (owner_index[pos] < 0)             owner_index[pos] = 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x30(%rbp)
leaq 0x1aaee9fe(%rip), %rax  # 0x1ab7a3e0
movq %rax, -0x8(%rbp)
movl $0x5, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0xc(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x25b00
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x44(%rbp)
decl %eax
subl $0x2, %eax
jb 0x8ba29
jmp 0x8ba14
movl -0x44(%rbp), %eax
subl $0x5, %eax
je 0x8ba34
jmp 0x8ba1e
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x8ba3d
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x8ba3d
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0x8babd
leaq 0x1aaee996(%rip), %rax  # 0x1ab7a3e0
movq %rax, -0x20(%rbp)
movl $0x5, -0x24(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x24(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x25b00
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x54(%rbp)
decl %eax
subl $0x2, %eax
jb 0x8ba91
jmp 0x8ba7c
movl -0x54(%rbp), %eax
subl $0x5, %eax
je 0x8ba9c
jmp 0x8ba86
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x8baa5
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x8baa5
movq -0x60(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp), %xmm1
movsd 0x20556(%rip), %xmm0    # 0xac008
divsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0x8bacc
movsd 0x20543(%rip), %xmm0    # 0xac008
movsd %xmm0, -0x68(%rbp)
jmp 0x8bacc
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
leaq 0x5bf59(%rip), %rcx     # 0xe7a40
cmpl (%rcx), %eax
jge 0x8bbaf
movslq -0x3c(%rbp), %rcx
leaq 0x1ab46d76(%rip), %rax  # 0x1abd2870
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movslq -0x40(%rbp), %rax
leaq 0x1aaeb445(%rip), %rdi  # 0x1ab76f50
shlq $0x4, %rax
addq %rax, %rdi
movslq -0x30(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
callq 0x25780
cvtsi2sd %eax, %xmm0
movsd 0x23592(%rip), %xmm1    # 0xaf0c0
mulsd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x204cd(%rip), %xmm1    # 0xac010
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
movslq -0x40(%rbp), %rcx
leaq 0x1aaea17a(%rip), %rax  # 0x1ab75cd0
movl %edx, (%rax,%rcx,4)
movslq -0x40(%rbp), %rcx
leaq 0x1aaea16c(%rip), %rax  # 0x1ab75cd0
cmpl $0xa, (%rax,%rcx,4)
jle 0x8bb7c
movslq -0x40(%rbp), %rcx
leaq 0x1aaea15b(%rip), %rax  # 0x1ab75cd0
movl $0xa, (%rax,%rcx,4)
movslq -0x40(%rbp), %rcx
leaq 0x1aaea149(%rip), %rax  # 0x1ab75cd0
cmpl $0x0, (%rax,%rcx,4)
jge 0x8bb9f
movslq -0x40(%rbp), %rcx
leaq 0x1aaea138(%rip), %rax  # 0x1ab75cd0
movl $0x0, (%rax,%rcx,4)
jmp 0x8bba1
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8badd
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)