// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/common/Message.cpp
// Function: PrintBestSequence(game_info_t const*, uct_node_t const*, int, int)
void
PrintBestSequence( const game_info_t *game, const uct_node_t *uct_node, const int root, const int start_color )
{
  game_info_t *search_result;
  int current = root;
  int index = -1;
  int max = 0;
  int color = start_color;
  int child_num;
  const child_node_t *uct_child;

  if (!debug_message) return ;

  search_result = AllocateGame();
  CopyGame(search_result, game);

  std::cerr << "Best Sequence : ";

  uct_child = uct_node[current].child;
  child_num = uct_node[current].child_num;

  for (int i = 0; i < child_num; i++) {
    if (uct_child[i].move_count > max) {
      max = uct_child[i].move_count;
      index = i;
    }
  }

  if (uct_child[index].pos == PASS) std::cerr << "PASS";
  else std::cerr << GOGUI_X(uct_child[index].pos) << GOGUI_Y(uct_child[index].pos);
  if (node_hash[current].color == S_BLACK) std::cerr << "(BLACK : ";
  else if (node_hash[current].color == S_WHITE) std::cerr << "(WHITE : ";


  PutStone(search_result, uct_child[index].pos, color);
  color = GetOppositeColor(color);

  std::cerr << uct_child[index].win << "/" << uct_child[index].move_count << ")";

  current = uct_child[index].index;
  
  while (current != NOT_EXPANDED) {
    uct_child = uct_node[current].child;
    child_num = uct_node[current].child_num;

    max = 50;
    index = -1;

    for (int i = 0; i < child_num; i++) {
      if (uct_child[i].move_count > max) {
        max = uct_child[i].move_count;
        index = i;
      }
    }

    if (index == -1) break;

    std::cerr << "->";

    if (uct_child[index].pos == PASS) std::cerr << "PASS";
    else std::cerr << GOGUI_X(uct_child[index].pos) << GOGUI_Y(uct_child[index].pos);

    if (node_hash[current].color == S_BLACK) std::cerr << "(BLACK : ";
    else if (node_hash[current].color == S_WHITE) std::cerr << "(WHITE : ";

    PutStone(search_result, uct_child[index].pos, color);

    color = GetOppositeColor(color);

    std::cerr << uct_child[index].win << "/" << uct_child[index].move_count << ")";

    current = uct_child[index].index;

  }

  std::cerr << std::endl;

  PrintBoard(search_result);
  FreeGame(search_result);
}

// Assembly:
cmpb $0x1, 0x57063(%rip)     # 0x75430
jne 0x1e780
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %r12
callq 0x53e60
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r12, %rsi
callq 0x5432c
movq 0x56be0(%rip), %rdi     # 0x74fe8
leaq 0x3ed01(%rip), %rsi     # 0x5d110
movl $0x10, %edx
callq 0x64a0
movslq %r15d, %r15
imulq $0x4548, %r15, %rdx     # imm = 0x4548
leaq (%r14,%rdx), %rax
addq $0x1c, %rax
movslq -0x4(%rax), %rcx
testq %rcx, %rcx
jle 0x1e463
addq %r14, %rdx
addq $0x20, %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %r8d, %r8d
movl (%rdx), %r9d
cmpl %r8d, %r9d
jle 0x1e452
movl (%rdx), %r8d
movl %esi, %edi
incq %rsi
addq $0x1c, %rdx
cmpq %rsi, %rcx
jne 0x1e445
movslq %edi, %rcx
jmp 0x1e46a
movq $-0x1, %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
leaq (%rax,%rdx), %r12
movswl (%rax,%rdx), %eax
testl %eax, %eax
je 0x1e4d8
leaq 0x57434(%rip), %r13     # 0x758bc
cltd
idivl (%r13)
movslq %edx, %rax
leaq 0x3ef09(%rip), %rcx     # 0x5d3a0
movb -0x4(%rax,%rcx), %al
leaq 0x7(%rsp), %rsi
movb %al, (%rsi)
movq 0x56b3f(%rip), %rdi     # 0x74fe8
movl $0x1, %edx
callq 0x64a0
movq %rax, %rdi
leaq 0x573f7(%rip), %rax     # 0x758b4
movl (%rax), %ecx
movswl (%r12), %eax
cltd
idivl (%r13)
negl %eax
leal (%rcx,%rax), %esi
addl $0x5, %esi
callq 0x6740
jmp 0x1e4f0
movq 0x56b09(%rip), %rdi     # 0x74fe8
leaq 0x3ec3b(%rip), %rsi     # 0x5d121
movl $0x4, %edx
callq 0x64a0
leaq 0x1c716b91(%rip), %rax  # 0x1c735088
movq (%rax), %rax
leaq (%r15,%r15,2), %rcx
movl 0x8(%rax,%rcx,8), %eax
cmpl $0x1, %eax
je 0x1e515
cmpl $0x2, %eax
jne 0x1e52d
leaq 0x3ec1d(%rip), %rsi     # 0x5d130
jmp 0x1e51c
leaq 0x3ec0a(%rip), %rsi     # 0x5d126
movq 0x56ac5(%rip), %rdi     # 0x74fe8
movl $0x9, %edx
callq 0x64a0
movswl (%r12), %esi
movq 0x8(%rsp), %rdi
movl %ebp, %edx
callq 0x55134
movl 0xc(%r12), %esi
movq 0x56a9e(%rip), %rdi     # 0x74fe8
callq 0x6740
movq %rax, %r15
leaq 0x3eaef(%rip), %rsi     # 0x5d048
movl $0x1, %edx
movq %rax, %rdi
callq 0x64a0
movl 0x4(%r12), %esi
movq %r15, %rdi
callq 0x6740
leaq 0x40386(%rip), %rsi     # 0x5e900
movl $0x1, %edx
movq %rax, %rdi
callq 0x64a0
movl 0x10(%r12), %eax
cmpl $-0x1, %eax
je 0x1e72f
leaq 0x20(%r14), %rcx
movq %rcx, 0x10(%rsp)
movq 0x56a43(%rip), %r12     # 0x74fe8
movslq %eax, %r15
imulq $0x4548, %r15, %rax     # imm = 0x4548
movslq 0x18(%r14,%rax), %rcx
testq %rcx, %rcx
jle 0x1e5e9
movq 0x10(%rsp), %rdx
addq %rax, %rdx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x32, %esi
xorl %edi, %edi
movl (%rdx), %r8d
cmpl %esi, %r8d
jle 0x1e5db
movl (%rdx), %esi
movl %edi, %r13d
incq %rdi
addq $0x1c, %rdx
cmpq %rdi, %rcx
jne 0x1e5ce
jmp 0x1e5ef
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $-0x1, %r13d
je 0x1e72f
leaq (%r14,%rax), %rbx
addq $0x1c, %rbx
movl $0x2, %edx
movq %r12, %rdi
leaq 0x3eb2a(%rip), %rsi     # 0x5d13a
callq 0x64a0
movslq %r13d, %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
leaq (%rbx,%rcx), %r13
movswl (%rbx,%rcx), %eax
testl %eax, %eax
je 0x1e680
cltd
leaq 0x57285(%rip), %rbx     # 0x758bc
idivl (%rbx)
movslq %edx, %rax
leaq 0x3ed5d(%rip), %rcx     # 0x5d3a0
movb -0x4(%rax,%rcx), %al
movb %al, 0x6(%rsp)
movl $0x1, %edx
movq %r12, %rdi
leaq 0x6(%rsp), %rsi
callq 0x64a0
movq %rax, %rdi
leaq 0x5724d(%rip), %rax     # 0x758b4
movl (%rax), %ecx
movswl (%r13), %eax
cltd
idivl (%rbx)
negl %eax
leal (%rcx,%rax), %esi
addl $0x5, %esi
callq 0x6740
jmp 0x1e694
movl $0x4, %edx
movq %r12, %rdi
leaq 0x3ea92(%rip), %rsi     # 0x5d121
callq 0x64a0
leaq 0x1c7169ed(%rip), %rax  # 0x1c735088
movq (%rax), %rax
leaq (%r15,%r15,2), %rcx
movl 0x8(%rax,%rcx,8), %eax
leaq 0x3ea79(%rip), %rsi     # 0x5d126
cmpl $0x1, %eax
je 0x1e6be
cmpl $0x2, %eax
jne 0x1e6cb
leaq 0x3ea72(%rip), %rsi     # 0x5d130
movl $0x9, %edx
movq %r12, %rdi
callq 0x64a0
xorl $0x3, %ebp
movswl (%r13), %esi
movq 0x8(%rsp), %rdi
movl %ebp, %edx
callq 0x55134
movl 0xc(%r13), %esi
movq %r12, %rdi
callq 0x6740
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3e94b(%rip), %rsi     # 0x5d048
callq 0x64a0
movl 0x4(%r13), %esi
movq %r15, %rdi
callq 0x6740
movl $0x1, %edx
movq %rax, %rdi
leaq 0x401e3(%rip), %rsi     # 0x5e900
callq 0x64a0
movl 0x10(%r13), %eax
cmpl $-0x1, %eax
jne 0x1e5a5
movq 0x568b2(%rip), %rbx     # 0x74fe8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x63d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x62a0
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1d0b4
movq %rbx, %rdi
callq 0x53e7b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq