// File: /workspace/github_cpp_makefile_star2_O3/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, 0x58273(%rip)     # 0x76430
jne 0x1e55f
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 0x543a6
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r12, %rsi
callq 0x549d9
movq 0x57df0(%rip), %rdi     # 0x75fe8
leaq 0x3ef11(%rip), %rsi     # 0x5d110
movl $0x10, %edx
callq 0x6490
movslq %r15d, %r15
imulq $0x4548, %r15, %rdx     # imm = 0x4548
leaq (%r14,%rdx), %rax
addq $0x1c, %rax
movslq -0x4(%rax), %rcx
testq %rcx, %rcx
jle 0x1e253
addq %r14, %rdx
addq $0x20, %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %r8d, %r8d
movl (%rdx), %r9d
cmpl %r8d, %r9d
jle 0x1e242
movl (%rdx), %r8d
movl %esi, %edi
incq %rsi
addq $0x1c, %rdx
cmpq %rsi, %rcx
jne 0x1e235
movslq %edi, %rcx
jmp 0x1e25a
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 0x1e2c4
leaq 0x58644(%rip), %rbx     # 0x768bc
cltd
idivl (%rbx)
movslq %edx, %rax
leaq 0x3f11b(%rip), %rcx     # 0x5d3a0
movb -0x4(%rax,%rcx), %al
leaq 0x7(%rsp), %rsi
movb %al, (%rsi)
movq 0x57d51(%rip), %rdi     # 0x75fe8
movl $0x1, %edx
callq 0x6490
movq %rax, %rdi
leaq 0x58609(%rip), %rax     # 0x768b4
movl (%rax), %ecx
movswl (%r12), %eax
cltd
idivl (%rbx)
negl %eax
leal (%rcx,%rax), %esi
addl $0x5, %esi
callq 0x6730
jmp 0x1e2dc
movq 0x57d1d(%rip), %rdi     # 0x75fe8
leaq 0x3ee4f(%rip), %rsi     # 0x5d121
movl $0x4, %edx
callq 0x6490
leaq 0x1c717da5(%rip), %rax  # 0x1c736088
movq (%rax), %rax
leaq (%r15,%r15,2), %rcx
movl 0x8(%rax,%rcx,8), %eax
cmpl $0x1, %eax
je 0x1e301
cmpl $0x2, %eax
jne 0x1e319
leaq 0x3ee31(%rip), %rsi     # 0x5d130
jmp 0x1e308
leaq 0x3ee1e(%rip), %rsi     # 0x5d126
movq 0x57cd9(%rip), %rdi     # 0x75fe8
movl $0x9, %edx
callq 0x6490
movswl (%r12), %esi
movq 0x8(%rsp), %rdi
movl %ebp, %edx
callq 0x55ae8
movl 0xc(%r12), %esi
movq 0x57cb2(%rip), %rdi     # 0x75fe8
callq 0x6730
movq %rax, %r15
leaq 0x3ed03(%rip), %rsi     # 0x5d048
movl $0x1, %edx
movq %rax, %rdi
callq 0x6490
movl 0x4(%r12), %esi
movq %r15, %rdi
callq 0x6730
leaq 0x4059a(%rip), %rsi     # 0x5e900
movl $0x1, %edx
movq %rax, %rdi
callq 0x6490
movl 0x10(%r12), %eax
cmpl $-0x1, %eax
je 0x1e50e
leaq 0x20(%r14), %rcx
movq %rcx, 0x10(%rsp)
movq 0x57c57(%rip), %r12     # 0x75fe8
movslq %eax, %r15
imulq $0x4548, %r15, %rax     # imm = 0x4548
movslq 0x18(%r14,%rax), %rcx
testq %rcx, %rcx
jle 0x1e50e
xorl $0x3, %ebp
leaq (%r14,%rax), %r13
addq $0x1c, %r13
addq 0x10(%rsp), %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0x32, %edx
xorl %esi, %esi
movl (%rax), %edi
cmpl %edx, %edi
jle 0x1e3cf
movl (%rax), %edx
movl %esi, %ebx
incq %rsi
addq $0x1c, %rax
cmpq %rsi, %rcx
jne 0x1e3c5
cmpl $-0x1, %ebx
je 0x1e50e
movl $0x2, %edx
movq %r12, %rdi
leaq 0x3ed47(%rip), %rsi     # 0x5d13a
callq 0x6490
movslq %ebx, %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
leaq (%rcx,%r13), %rbx
movswl (%r13,%rcx), %eax
testl %eax, %eax
je 0x1e467
cltd
leaq 0x584a0(%rip), %r13     # 0x768bc
idivl (%r13)
movslq %edx, %rax
leaq 0x3ef76(%rip), %rcx     # 0x5d3a0
movb -0x4(%rax,%rcx), %al
movb %al, 0x6(%rsp)
movl $0x1, %edx
movq %r12, %rdi
leaq 0x6(%rsp), %rsi
callq 0x6490
movq %rax, %rdi
leaq 0x58466(%rip), %rax     # 0x768b4
movl (%rax), %ecx
movswl (%rbx), %eax
cltd
idivl (%r13)
negl %eax
leal (%rcx,%rax), %esi
addl $0x5, %esi
callq 0x6730
jmp 0x1e47b
movl $0x4, %edx
movq %r12, %rdi
leaq 0x3ecab(%rip), %rsi     # 0x5d121
callq 0x6490
leaq 0x1c717c06(%rip), %rax  # 0x1c736088
movq (%rax), %rax
leaq (%r15,%r15,2), %rcx
movl 0x8(%rax,%rcx,8), %eax
leaq 0x3ec92(%rip), %rsi     # 0x5d126
cmpl $0x1, %eax
je 0x1e4a5
cmpl $0x2, %eax
jne 0x1e4b2
leaq 0x3ec8b(%rip), %rsi     # 0x5d130
movl $0x9, %edx
movq %r12, %rdi
callq 0x6490
movswl (%rbx), %esi
movq 0x8(%rsp), %rdi
movl %ebp, %edx
callq 0x55ae8
movl 0xc(%rbx), %esi
movq %r12, %rdi
callq 0x6730
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3eb6a(%rip), %rsi     # 0x5d048
callq 0x6490
movl 0x4(%rbx), %esi
movq %r15, %rdi
callq 0x6730
movl $0x1, %edx
movq %rax, %rdi
leaq 0x40403(%rip), %rsi     # 0x5e900
callq 0x6490
movl 0x10(%rbx), %eax
cmpl $-0x1, %eax
jne 0x1e391
movq 0x57ad3(%rip), %rbx     # 0x75fe8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x63c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x6290
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1cea4
movq %rbx, %rdi
callq 0x543c1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq