// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x43b0, %edx           # imm = 0x43B0
xorl %esi, %esi
callq 0x61f0
leaq 0x4748(%rbx), %r14
movslq 0x26720(%rip), %r12     # 0x618b8
imulq $0x18, %r12, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x61f0
leaq 0x43f8(%rbx), %r15
leaq 0x4(%rsp), %rdx
andl $0x0, (%rdx)
movq %r15, %rdi
movl %r12d, %esi
callq 0x3cb9e
andq $0x0, 0x99cf8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x98728(%rbx)
movq $-0xb48, %rax           # imm = 0xF4B8
testq %rax, %rax
je 0x3b1ec
andl $0x0, 0x9a848(%rbx,%rax)
addq $0x4, %rax
jmp 0x3b1d9
movq $-0x15c0, %rax          # imm = 0xEA40
testq %rax, %rax
je 0x3b206
andl $0x0, 0x99cf8(%rbx,%rax)
addq $0x4, %rax
jmp 0x3b1f3
leaq 0x97372(%rbx), %rdi
imull $0x6, 0x266a4(%rip), %esi # 0x618b8
movq %rsp, %rdx
andl $0x0, (%rdx)
callq 0x3cbc0
movl $0x2b7, %eax            # imm = 0x2B7
movl %eax, 0x99218(%rbx)
movl %eax, 0x98738(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x43d0(%rbx)
movups %xmm0, 0x43e0(%rbx)
andq $0x0, 0x43f0(%rbx)
movsd 0x26677(%rip), %xmm0    # 0x618c8
callq 0x3b0f3
movl $0x1, 0x43b0(%rbx)
andl $0x0, 0x4744(%rbx)
movq $-0x349, %rax           # imm = 0xFCB7
testq %rax, %rax
je 0x3b280
movb $0x0, 0x97029(%rbx,%rax)
incq %rax
jmp 0x3b26e
xorl %eax, %eax
pushq $0x1
popq %rcx
pushq $-0x1
popq %rdx
movb $0x3, %sil
movslq 0x2662a(%rip), %rdi     # 0x618bc
cmpl %edi, %eax
jge 0x3b308
movslq %eax, %rdi
movl %edx, %r8d
xorl %r9d, %r9d
cmpl $0x5, %r9d
je 0x3b302
movslq 0x26610(%rip), %r10     # 0x618bc
imulq %rdi, %r10
addq %r15, %r10
movb %sil, (%r9,%r10)
movl 0x265fe(%rip), %r10d    # 0x618bc
imull %r9d, %r10d
addl %eax, %r10d
movslq %r10d, %r10
movb %sil, (%r15,%r10)
movl 0x265e9(%rip), %r10d    # 0x618bc
leal (%r8,%r10), %r11d
imull %r10d, %r11d
addl %eax, %r11d
movslq %r11d, %r10
movb %sil, (%r15,%r10)
movl 0x265d0(%rip), %r10d    # 0x618bc
imull %ecx, %r10d
addl %r8d, %r10d
movslq %r10d, %r10
movb %sil, (%r15,%r10)
incq %r9
decl %r8d
jmp 0x3b29f
incl %eax
incl %ecx
jmp 0x3b28b
movslq 0x265b1(%rip), %rax     # 0x618c0
movslq 0x265ae(%rip), %rcx     # 0x618c4
leaq 0x1(%rdi), %rdx
imulq %rax, %rdx
addq %rbx, %rdx
addq $0x96ce0, %rdx          # imm = 0x96CE0
movq %rax, %rsi
movq %rdx, %r8
movq %rax, %r9
cmpq %rcx, %rsi
jg 0x3b34f
cmpq %rcx, %r9
jg 0x3b347
movb $0x1, (%r8)
incq %r9
incq %r8
jmp 0x3b336
incq %rsi
addq %rdi, %rdx
jmp 0x3b32b
movl $0x9de4, %eax           # imm = 0x9DE4
cmpq $0x95ee4, %rax          # imm = 0x95EE4
je 0x3b368
movb $0x0, (%rbx,%rax)
addq $0x7c8, %rax            # imm = 0x7C8
jmp 0x3b354
movq %r14, %rdi
callq 0x35dac
callq 0x3b386
callq 0x3b3ca
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq