// File: kobanium[P]Ray/src/gtp/Gtp.cpp
// Function: GTP_kgs_genmove_cleanup()
static void
GTP_kgs_genmove_cleanup( void )
{
  char *command;
  char c;
  char pos[10];
  int color;
  int point = PASS;

  StopPondering();
 
  command = STRTOK(input_copy, DELIM, &next_token);
  
  CHOMP(command);
  if (!strcmp("genmove_black", command)) {
    color = S_BLACK;
  } else if (!strcmp("genmove_white", command)) {
    color = S_WHITE;
  } else {
    command = STRTOK(NULL, DELIM, &next_token);
    if (command == NULL){
      GTP_response(err_genmove, false);
      return;
    }
    CHOMP(command);
    c = static_cast<char>(tolower(static_cast<int>(command[0])));
    if (c == 'w') {
      color = S_WHITE;
    } else if (c == 'b') {
      color = S_BLACK;
    } else {
      GTP_response(err_genmove, false);
      return;
    }
  }
  
  player_color = color;
  
  point = UctSearchGenmoveCleanUp(game, color);
  if (point != RESIGN) {
    PutStone(game, point, color);
  }
  
  IntegerToString(point, pos);
  
  GTP_response(pos, true);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x1c(%rbp)
callq 0x892c0
leaq 0xc1555(%rip), %rdi     # 0xe8410
leaq 0x85cde(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x28(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x26f10
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x30(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rsi
leaq 0x85c0c(%rip), %rdi     # 0xacb27
callq 0x77a0
cmpl $0x0, %eax
jne 0x26f31
movl $0x1, -0x18(%rbp)
jmp 0x2700e
movq -0x8(%rbp), %rsi
leaq 0x85bf9(%rip), %rdi     # 0xacb35
callq 0x77a0
cmpl $0x0, %eax
jne 0x26f52
movl $0x2, -0x18(%rbp)
jmp 0x2700c
xorl %eax, %eax
movl %eax, %edi
leaq 0x85c43(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x26f80
leaq 0x85c4f(%rip), %rdi     # 0xacbc3
xorl %esi, %esi
callq 0x27f30
jmp 0x2705b
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x38(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x26fc5
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x40(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x8(%rbp), %rax
movsbl (%rax), %edi
callq 0x77e0
movb %al, -0x9(%rbp)
movsbl -0x9(%rbp), %eax
cmpl $0x77, %eax
jne 0x26fe6
movl $0x2, -0x18(%rbp)
jmp 0x2700a
movsbl -0x9(%rbp), %eax
cmpl $0x62, %eax
jne 0x26ff8
movl $0x1, -0x18(%rbp)
jmp 0x27008
leaq 0x85bc4(%rip), %rdi     # 0xacbc3
xorl %esi, %esi
callq 0x27f30
jmp 0x2705b
jmp 0x2700a
jmp 0x2700c
jmp 0x2700e
movl -0x18(%rbp), %eax
movl %eax, 0xc0579(%rip)     # 0xe7590
movq 0xc1502(%rip), %rdi     # 0xe8520
movl -0x18(%rbp), %esi
callq 0x8ab80
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
je 0x27041
movq 0xc14ea(%rip), %rdi     # 0xe8520
movl -0x1c(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x9dbc0
movl -0x1c(%rbp), %edi
leaq -0x13(%rbp), %rsi
callq 0x9ef70
leaq -0x13(%rbp), %rdi
movl $0x1, %esi
callq 0x27f30
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)