// File: kobanium[P]Ray/src/board/GoBoard.cpp
// Function: InitializeBoard(game_info_t*)
void
InitializeBoard( game_info_t *game )
{
  memset(game->record, 0, sizeof(record_t) * MAX_RECORDS);
  memset(game->pat,    0, sizeof(pattern_t) * board_max);

  std::fill_n(game->board, board_max, 0);
  std::fill_n(game->update_num, 2, 0);
  std::fill_n(game->capture_num, 2, 0);
  std::fill_n(game->capture_dir, 2, 0);
  std::fill(game->update_pos[0], game->update_pos[2], 0);
  std::fill(game->capture_pos[0], game->capture_pos[2], 0);
  std::fill_n(game->tactical_features, board_max * ALL_MAX, 0);

  game->capture_pos[0][0] = game->capture_pos[1][0] = CAPTURE_END;
  
  game->current_hash = 0;
  game->previous1_hash = 0;
  game->previous2_hash = 0;
  game->positional_hash = 0;
  game->move_hash = 0;

  SetKomi(default_komi);

  game->moves = 1;

  game->pass_count = 0;

  std::fill_n(game->candidates, BOARD_MAX, false);

  for (int y = 0; y < board_size; y++){
    for (int x = 0; x < OB_SIZE; x++) {
      game->board[POS(x, y)] = S_OB;
      game->board[POS(y, x)] = S_OB;
      game->board[POS(y, board_size - 1 - x)] = S_OB;
      game->board[POS(board_size - 1 - x, y)] = S_OB;
    }
  }

  for (int y = board_start; y <= board_end; y++) {
    for (int x = board_start; x <= board_end; x++) {
      game->candidates[POS(x, y)] = true;
    }
  }

  for (int i = 0; i < MAX_STRING; i++) {
    game->string[i].flag = false;
  }

  ClearPattern(game->pat);

  InitializeNeighbor();
  InitializeEye();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x43b0, %edx           # imm = 0x43B0
callq 0x72b0
movq -0x8(%rbp), %rdi
addq $0x4748, %rdi           # imm = 0x4748
movslq 0x4bcaa(%rip), %rax     # 0xe7a48
imulq $0x18, %rax, %rdx
xorl %esi, %esi
callq 0x72b0
movq -0x8(%rbp), %rdi
addq $0x43f8, %rdi           # imm = 0x43F8
movl 0x4bc8e(%rip), %esi     # 0xe7a48
movl $0x0, -0xc(%rbp)
leaq -0xc(%rbp), %rdx
callq 0x9ead0
movq -0x8(%rbp), %rdi
addq $0x99cf8, %rdi          # imm = 0x99CF8
movl $0x0, -0x10(%rbp)
movl $0x2, %esi
leaq -0x10(%rbp), %rdx
callq 0x80790
movq -0x8(%rbp), %rdi
addq $0x98728, %rdi          # imm = 0x98728
movl $0x0, -0x14(%rbp)
movl $0x2, %esi
leaq -0x14(%rbp), %rdx
callq 0x80790
movq -0x8(%rbp), %rdi
addq $0x98730, %rdi          # imm = 0x98730
movl $0x0, -0x18(%rbp)
movl $0x2, %esi
leaq -0x18(%rbp), %rdx
callq 0x80790
movq -0x8(%rbp), %rdi
addq $0x99d00, %rdi          # imm = 0x99D00
movq -0x8(%rbp), %rsi
addq $0x99d00, %rsi          # imm = 0x99D00
addq $0xb48, %rsi            # imm = 0xB48
movl $0x0, -0x1c(%rbp)
leaq -0x1c(%rbp), %rdx
callq 0x9eb20
movq -0x8(%rbp), %rdi
addq $0x98738, %rdi          # imm = 0x98738
movq -0x8(%rbp), %rsi
addq $0x98738, %rsi          # imm = 0x98738
addq $0x15c0, %rsi           # imm = 0x15C0
movl $0x0, -0x20(%rbp)
leaq -0x20(%rbp), %rdx
callq 0x9eb20
movq -0x8(%rbp), %rdi
addq $0x97372, %rdi          # imm = 0x97372
imull $0x6, 0x4bbb2(%rip), %esi # 0xe7a48
movl $0x0, -0x24(%rbp)
leaq -0x24(%rbp), %rdx
callq 0x9eb50
movq -0x8(%rbp), %rax
movl $0x2b7, 0x99218(%rax)   # imm = 0x2B7
movq -0x8(%rbp), %rax
movl $0x2b7, 0x98738(%rax)   # imm = 0x2B7
movq -0x8(%rbp), %rax
movq $0x0, 0x43d0(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x43d8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x43e0(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x43e8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x43f0(%rax)
movsd 0x4bb43(%rip), %xmm0    # 0xe7a58
callq 0x9bc10
movq -0x8(%rbp), %rax
movl $0x1, 0x43b0(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x4744(%rax)
movq -0x8(%rbp), %rdi
addq $0x96ce0, %rdi          # imm = 0x96CE0
movb $0x0, -0x25(%rbp)
movl $0x349, %esi            # imm = 0x349
leaq -0x25(%rbp), %rdx
callq 0x884f0
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x4bae9(%rip), %eax     # 0xe7a4c
jge 0x9c022
movl $0x0, -0x30(%rbp)
cmpl $0x5, -0x30(%rbp)
jge 0x9c012
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %edx
imull 0x4bac1(%rip), %edx     # 0xe7a4c
addl %edx, %ecx
movslq %ecx, %rcx
movb $0x3, 0x43f8(%rax,%rcx)
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl -0x30(%rbp), %edx
imull 0x4baa3(%rip), %edx     # 0xe7a4c
addl %edx, %ecx
movslq %ecx, %rcx
movb $0x3, 0x43f8(%rax,%rcx)
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl 0x4ba89(%rip), %edx     # 0xe7a4c
subl $0x1, %edx
subl -0x30(%rbp), %edx
imull 0x4ba7c(%rip), %edx     # 0xe7a4c
addl %edx, %ecx
movslq %ecx, %rcx
movb $0x3, 0x43f8(%rax,%rcx)
movq -0x8(%rbp), %rax
movl 0x4ba65(%rip), %ecx     # 0xe7a4c
subl $0x1, %ecx
subl -0x30(%rbp), %ecx
movl -0x2c(%rbp), %edx
imull 0x4ba55(%rip), %edx     # 0xe7a4c
addl %edx, %ecx
movslq %ecx, %rcx
movb $0x3, 0x43f8(%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9bf70
jmp 0x9c014
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x9bf5a
movl 0x4ba28(%rip), %eax     # 0xe7a50
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x4ba20(%rip), %eax     # 0xe7a54
jg 0x9c080
movl 0x4ba14(%rip), %eax     # 0xe7a50
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl 0x4ba0c(%rip), %eax     # 0xe7a54
jg 0x9c073
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
movl -0x34(%rbp), %edx
imull 0x4b9f1(%rip), %edx     # 0xe7a4c
addl %edx, %ecx
movslq %ecx, %rcx
movb $0x1, 0x96ce0(%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x9c03f
jmp 0x9c075
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x9c02b
movl $0x0, -0x3c(%rbp)
cmpl $0x120, -0x3c(%rbp)     # imm = 0x120
jge 0x9c0ba
movq -0x8(%rbp), %rax
addq $0x9620, %rax           # imm = 0x9620
movslq -0x3c(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movb $0x0, 0x7c4(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x9c087
movq -0x8(%rbp), %rdi
addq $0x4748, %rdi           # imm = 0x4748
callq 0x8fc10
callq 0x9c0e0
callq 0x9c180
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)