// File: kobanium[P]Ray/src/gtp/Gtp.cpp
// Function: ParseAnalysisTag(int&, int&)
static void
ParseAnalysisTag( int &color, int &centi_second )
{
  char *command;
  int token_cnt = 0;

  while (true) {
    command = STRTOK(NULL, DELIM, &next_token);
    token_cnt += 1;
    if (command != NULL && token_cnt <= 2) {
      CHOMP(command);

      // Parse the color.
      char c = static_cast<char>(tolower(static_cast<int>(command[0])));
      if (c == 'w') {
        color = S_WHITE;
        continue;
      } else if (c == 'b') {
        color = S_BLACK;
        continue;
      }

      // Parse the unused interval tag.
      if (strcmp(command, "minmoves") == 0 ||
          strcmp(command, "maxmoves") == 0) {
        STRTOK(NULL, DELIM, &next_token); // eat move numbers
        continue;
      }

      if (strcmp(command, "avoid") == 0 ||
          strcmp(command, "allow") == 0) {
        STRTOK(NULL, DELIM, &next_token); // eat color
        STRTOK(NULL, DELIM, &next_token); // eat vertices moves
        STRTOK(NULL, DELIM, &next_token); // eat until moves
        continue;
      }

      // Parse the interval tag.
      if (strcmp(command, "interval") == 0) {
        command = STRTOK(NULL, DELIM, &next_token);
        CHOMP(command);
      }

      bool is_digit = true;
      for (int i = 0; i < static_cast<int>(strlen(command)); ++i) {
        is_digit &= isdigit(command[i]);
      }

      if (is_digit) {
        centi_second = std::atoi(command);
      }
    } else {
      break;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x84b2e(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2829d
cmpl $0x2, -0x1c(%rbp)
jg 0x2829d
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x30(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x280de
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x38(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
movsbl (%rax), %edi
callq 0x77e0
movb %al, -0x1d(%rbp)
movsbl -0x1d(%rbp), %eax
cmpl $0x77, %eax
jne 0x28105
movq -0x8(%rbp), %rax
movl $0x2, (%rax)
jmp 0x28067
movsbl -0x1d(%rbp), %eax
cmpl $0x62, %eax
jne 0x2811d
movq -0x8(%rbp), %rax
movl $0x1, (%rax)
jmp 0x28067
jmp 0x2811f
movq -0x18(%rbp), %rdi
leaq 0x84a4b(%rip), %rsi     # 0xacb75
callq 0x77a0
cmpl $0x0, %eax
je 0x28149
movq -0x18(%rbp), %rdi
leaq 0x84a3f(%rip), %rsi     # 0xacb7e
callq 0x77a0
cmpl $0x0, %eax
jne 0x2815e
xorl %eax, %eax
movl %eax, %edi
leaq 0x84a4c(%rip), %rsi     # 0xacba0
callq 0x7850
jmp 0x28067
movq -0x18(%rbp), %rdi
leaq 0x84a1e(%rip), %rsi     # 0xacb87
callq 0x77a0
cmpl $0x0, %eax
je 0x28188
movq -0x18(%rbp), %rdi
leaq 0x84a0f(%rip), %rsi     # 0xacb8d
callq 0x77a0
cmpl $0x0, %eax
jne 0x281bd
xorl %eax, %eax
movl %eax, %edi
leaq 0x84a0d(%rip), %rsi     # 0xacba0
callq 0x7850
xorl %eax, %eax
movl %eax, %edi
leaq 0x849fd(%rip), %rsi     # 0xacba0
callq 0x7850
xorl %eax, %eax
movl %eax, %edi
leaq 0x849ed(%rip), %rsi     # 0xacba0
callq 0x7850
jmp 0x28067
movq -0x18(%rbp), %rdi
leaq 0x849cb(%rip), %rsi     # 0xacb93
callq 0x77a0
cmpl $0x0, %eax
jne 0x2822d
xorl %eax, %eax
movl %eax, %edi
leaq 0x849c3(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x40(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x2822b
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x48(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
jmp 0x2822d
movb $0x1, -0x1e(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jge 0x28284
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x7490
movl %eax, %ecx
movb -0x1e(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x1e(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x28238
testb $0x1, -0x1e(%rbp)
je 0x2829b
movq -0x18(%rbp), %rdi
callq 0x7840
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
jmp 0x2829f
jmp 0x282a4
jmp 0x28067
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)