// File: kobanium[P]Ray/src/gtp/Gtp.cpp
// Function: GTP_main()
void
GTP_main( void )
{
  game = AllocateGame();
  InitializeBoard(game);

  while (fgets(input, sizeof(input), stdin) != NULL) {
    char *command;
    bool nocommand = true;
    command_id = -1;

    if (isdigit(input[0])) {
      char buf[BUF_SIZE];
      STRCPY(buf, BUF_SIZE, input);
      char *strid = STRTOK(buf, DELIM, &next_token);
      command_id = atoi(strid);
      command = STRTOK(nullptr, DELIM, &next_token);
      int offset = command - buf;
      STRCPY(input_copy, BUF_SIZE, input + offset);
    } else {
      STRCPY(input_copy, BUF_SIZE, input);
      command = STRTOK(input, DELIM, &next_token);
    }
    CHOMP(command);

    for (const GTP_command_t& cmd : gtpcmd) {
      if (!strcmp(command, cmd.command)) {
        (*cmd.function)();
        nocommand = false;
        break;
      }
    }

    if (nocommand) {
      std::cout << err_command << std::endl << std::endl;
    }

    fflush(stdin);
    fflush(stdout);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
callq 0x9bce0
movq %rax, 0xc2939(%rip)     # 0xe8520
movq 0xc2932(%rip), %rdi     # 0xe8520
callq 0x9bd70
movq 0xc1396(%rip), %rax     # 0xe6f90
movq (%rax), %rdx
leaq 0xc270c(%rip), %rdi     # 0xe8310
movl $0x100, %esi            # imm = 0x100
callq 0x7870
cmpq $0x0, %rax
je 0x25e1f
movb $0x1, -0x9(%rbp)
movl $0xffffffff, 0xc28f2(%rip) # imm = 0xFFFFFFFF
movsbl 0xc26e3(%rip), %edi     # 0xe8310
callq 0x7490
cmpl $0x0, %eax
je 0x25cc1
leaq -0x110(%rbp), %rdi
leaq 0xc26c7(%rip), %rsi     # 0xe8310
callq 0x74d0
leaq -0x110(%rbp), %rdi
leaq 0x86f44(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
callq 0x7840
movl %eax, 0xc289e(%rip)     # 0xe8518
xorl %eax, %eax
movl %eax, %edi
leaq 0x86f1b(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
leaq -0x110(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x11c(%rbp)
movslq -0x11c(%rbp), %rax
leaq 0xc2660(%rip), %rsi     # 0xe8310
addq %rax, %rsi
leaq 0xc2756(%rip), %rdi     # 0xe8410
callq 0x74d0
jmp 0x25ceb
leaq 0xc2748(%rip), %rdi     # 0xe8410
leaq 0xc2641(%rip), %rsi     # 0xe8310
callq 0x74d0
leaq 0xc2635(%rip), %rdi     # 0xe8310
leaq 0x86ebe(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x148(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x25d3c
movq -0x8(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x150(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
leaq 0xc057d(%rip), %rax     # 0xe62c0
movq %rax, -0x128(%rbp)
leaq 0xc056f(%rip), %rax     # 0xe62c0
movq %rax, -0x130(%rbp)
leaq 0xc0561(%rip), %rax     # 0xe62c0
addq $0x708, %rax            # imm = 0x708
movq %rax, -0x138(%rbp)
movq -0x130(%rbp), %rax
cmpq -0x138(%rbp), %rax
je 0x25dc5
movq -0x130(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x8(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x77a0
cmpl $0x0, %eax
jne 0x25daf
movq -0x140(%rbp), %rax
callq *0x40(%rax)
movb $0x0, -0x9(%rbp)
jmp 0x25dc5
jmp 0x25db1
movq -0x130(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x130(%rbp)
jmp 0x25d6c
testb $0x1, -0x9(%rbp)
je 0x25dfc
movq 0xc11d6(%rip), %rdi     # 0xe6fa8
leaq 0x86dd7(%rip), %rsi     # 0xacbb0
callq 0x7530
movq %rax, %rdi
movq 0xc1180(%rip), %rsi     # 0xe6f68
callq 0x75b0
movq %rax, %rdi
movq 0xc1171(%rip), %rsi     # 0xe6f68
callq 0x75b0
movq 0xc118d(%rip), %rax     # 0xe6f90
movq (%rax), %rdi
callq 0x7670
movq 0xc113e(%rip), %rax     # 0xe6f50
movq (%rax), %rdi
callq 0x7670
jmp 0x25bf3
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopl (%rax,%rax)