// File: kobanium[P]Ray/src/board/ZobristHash.cpp
// Function: InitializeHash()
void
InitializeHash( void )
{
  std::random_device rnd;
  std::mt19937_64 mt(rnd());

  for (int i = 0; i < MAX_RECORDS; i++) {
    for (int j = 0; j < BOARD_MAX; j++) {
      move_bit[i][j][HASH_PASS] = mt();
      move_bit[i][j][HASH_BLACK] = mt();
      move_bit[i][j][HASH_WHITE] = mt();
      move_bit[i][j][HASH_KO] = mt();
    }
  }
    
  for (int i = 0; i < BOARD_MAX; i++) {  
    hash_bit[i][HASH_PASS]  = mt();
    hash_bit[i][HASH_BLACK] = mt();
    hash_bit[i][HASH_WHITE] = mt();
    hash_bit[i][HASH_KO]    = mt();
    shape_bit[i] = mt();
  }

  node_hash = new node_hash_t[uct_hash_size];

  if (node_hash == NULL) {
    std::cerr << "Cannot allocate memory" << std::endl;
    exit(1);
  }

  enough_size = true;

  InitializeNakadeHash();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1dd0, %rsp           # imm = 0x1DD0
leaq -0x1388(%rbp), %rdi
movq %rdi, -0x1d78(%rbp)
callq 0x630a0
movq -0x1d78(%rbp), %rdi
callq 0x63140
movl %eax, -0x1d6c(%rbp)
jmp 0x9f4c2
movl -0x1d6c(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x1d50(%rbp), %rdi
callq 0x63160
jmp 0x9f4da
movl $0x0, -0x1d60(%rbp)
cmpl $0x43b, -0x1d60(%rbp)   # imm = 0x43B
jge 0x9f66c
movl $0x0, -0x1d64(%rbp)
cmpl $0x349, -0x1d64(%rbp)   # imm = 0x349
jge 0x9f656
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1d80(%rbp)
jmp 0x9f523
movq -0x1d80(%rbp), %rdx
movslq -0x1d60(%rbp), %rax
imulq $0x6920, %rax, %rax     # imm = 0x6920
leaq 0x1ab33f01(%rip), %rcx  # 0x1abd3440
addq %rax, %rcx
movslq -0x1d64(%rbp), %rax
shlq $0x5, %rax
movq %rdx, (%rax,%rcx)
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1d88(%rbp)
jmp 0x9f566
movq -0x1d88(%rbp), %rdx
movslq -0x1d60(%rbp), %rax
imulq $0x6920, %rax, %rax     # imm = 0x6920
leaq 0x1ab33ebe(%rip), %rcx  # 0x1abd3440
addq %rax, %rcx
movslq -0x1d64(%rbp), %rax
shlq $0x5, %rax
movq %rdx, 0x8(%rax,%rcx)
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1d90(%rbp)
jmp 0x9f5aa
movq -0x1d90(%rbp), %rdx
movslq -0x1d60(%rbp), %rax
imulq $0x6920, %rax, %rax     # imm = 0x6920
leaq 0x1ab33e7a(%rip), %rcx  # 0x1abd3440
addq %rax, %rcx
movslq -0x1d64(%rbp), %rax
shlq $0x5, %rax
movq %rdx, 0x10(%rax,%rcx)
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1d98(%rbp)
jmp 0x9f5ee
movq -0x1d98(%rbp), %rcx
movslq -0x1d60(%rbp), %rdx
leaq 0x1ab33e3d(%rip), %rax  # 0x1abd3440
imulq $0x6920, %rdx, %rdx     # imm = 0x6920
addq %rdx, %rax
movslq -0x1d64(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movl -0x1d64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d64(%rbp)
jmp 0x9f4fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d58(%rbp)
movl %eax, -0x1d5c(%rbp)
leaq -0x1388(%rbp), %rdi
callq 0x635d0
jmp 0x9f825
jmp 0x9f658
movl -0x1d60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d60(%rbp)
jmp 0x9f4e4
movl $0x0, -0x1d68(%rbp)
cmpl $0x349, -0x1d68(%rbp)   # imm = 0x349
jge 0x9f793
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1da0(%rbp)
jmp 0x9f69b
movq -0x1da0(%rbp), %rdx
movslq -0x1d68(%rbp), %rax
shlq $0x5, %rax
leaq 0x1c6ff7ec(%rip), %rcx  # 0x1c79eea0
movq %rdx, (%rax,%rcx)
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1da8(%rbp)
jmp 0x9f6cd
movq -0x1da8(%rbp), %rdx
movslq -0x1d68(%rbp), %rax
shlq $0x5, %rax
leaq 0x1c6ff7ba(%rip), %rcx  # 0x1c79eea0
movq %rdx, 0x8(%rax,%rcx)
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1db0(%rbp)
jmp 0x9f700
movq -0x1db0(%rbp), %rdx
movslq -0x1d68(%rbp), %rax
shlq $0x5, %rax
leaq 0x1c6ff787(%rip), %rcx  # 0x1c79eea0
movq %rdx, 0x10(%rax,%rcx)
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1db8(%rbp)
jmp 0x9f733
movq -0x1db8(%rbp), %rdx
movslq -0x1d68(%rbp), %rax
shlq $0x5, %rax
leaq 0x1c6ff754(%rip), %rcx  # 0x1c79eea0
movq %rdx, 0x18(%rax,%rcx)
leaq -0x1d50(%rbp), %rdi
callq 0x65a00
movq %rax, -0x1dc0(%rbp)
jmp 0x9f766
movq -0x1dc0(%rbp), %rdx
movslq -0x1d68(%rbp), %rcx
leaq 0x1c706045(%rip), %rax  # 0x1c7a57c0
movq %rdx, (%rax,%rcx,8)
movl -0x1d68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d68(%rbp)
jmp 0x9f676
movl 0x482c7(%rip), %eax     # 0xe7a60
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
callq 0x7040
movq %rax, -0x1dc8(%rbp)
jmp 0x9f7af
movq -0x1dc8(%rbp), %rax
movq %rax, 0x1c707a4b(%rip)  # 0x1c7a7208
cmpq $0x0, 0x1c707a43(%rip)  # 0x1c7a7208
jne 0x9f802
movq 0x47822(%rip), %rdi     # 0xe6ff0
leaq 0x107fc(%rip), %rsi     # 0xaffd1
callq 0x7530
movq %rax, -0x1dd0(%rbp)
jmp 0x9f7e3
movq -0x1dd0(%rbp), %rdi
movq 0x47777(%rip), %rsi     # 0xe6f68
callq 0x75b0
jmp 0x9f7f8
movl $0x1, %edi
callq 0x76a0
movb $0x1, 0x1c707a07(%rip)  # 0x1c7a7210
callq 0xa3920
jmp 0x9f810
leaq -0x1388(%rbp), %rdi
callq 0x635d0
addq $0x1dd0, %rsp           # imm = 0x1DD0
popq %rbp
retq
movq -0x1d58(%rbp), %rdi
callq 0x79b0
nopw %cs:(%rax,%rax)