// File: /workspace/github_cpp_makefile_star2_O1/kobanium[P]Ray/src/gtp/Gtp.cpp
// Function: GTP_final_status_list()
static void
GTP_final_status_list( void )
{
  char dead[2048] = { 0 };
  char pos[5];
  int owner[BOARD_MAX]; 
  char *command;

  StopPondering();
  
  OwnerCopy(owner);
  
  command = STRTOK(NULL, DELIM, &next_token);

  CHOMP(command);
  
  if (!strcmp(command, "dead")){
    for (int y = board_start; y <= board_end; y++) {
      for (int x = board_start; x <= board_end; x++) {
        if ((game->board[POS(x, y)] == player_color && owner[POS(x, y)] <= 30) ||
            (game->board[POS(x, y)] == GetOppositeColor(player_color) && owner[POS(x, y)] >= 70)) {
#if defined (_WIN32)
          sprintf_s(pos, 5, "%c%d ", GOGUI_X(POS(x, y)), GOGUI_Y(POS(x, y)));
          strcat_s(dead, 2048, pos);
#else
          snprintf(pos, 5, "%c%d ", GOGUI_X(POS(x, y)), GOGUI_Y(POS(x, y)));
          strncat(dead, pos, 5);
#endif
        }
      }
    }
  } else if (!strcmp(command, "alive")){
    for (int y = board_start; y <= board_end; y++) {
      for (int x = board_start; x <= board_end; x++) {
        if ((game->board[POS(x, y)] == player_color && owner[POS(x, y)] >= 70) ||
            (game->board[POS(x, y)] == GetOppositeColor(player_color) && owner[POS(x, y)] <= 30)) {
#if defined (_WIN32)
          sprintf_s(pos, 5, "%c%d ", GOGUI_X(POS(x, y)), GOGUI_Y(POS(x, y)));
          strcat_s(dead, 2048, pos);
#else
          snprintf(pos, 5, "%c%d ", GOGUI_X(POS(x, y)), GOGUI_Y(POS(x, y)));
          strncat(dead, pos, 5);
#endif
        }
      }
    }
  }
  
  GTP_response(dead, true);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1538, %rsp           # imm = 0x1538
leaq 0x10(%rsp), %rdi
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x6210
callq 0x4a61e
leaq 0x810(%rsp), %rdi
callq 0x4b5ec
leaq 0x3c929(%rip), %rsi     # 0x5d402
xorl %edi, %edi
callq 0x6650
movq %rax, %rbx
movq %rax, %rdi
callq 0x6160
cmpb $0xa, -0x1(%rbx,%rax)
jne 0x20af7
movb $0x0, -0x1(%rbx,%rax)
leaq 0x3d1cc(%rip), %rsi     # 0x5dcca
movq %rbx, %rdi
callq 0x6590
testl %eax, %eax
je 0x20c17
leaq 0x3d1c0(%rip), %rsi     # 0x5dcd5
movq %rbx, %rdi
callq 0x6590
testl %eax, %eax
jne 0x20d04
leaq 0x54d94(%rip), %rax     # 0x758c0
movl (%rax), %ebp
leaq 0x54d8f(%rip), %r13     # 0x758c4
cmpl (%r13), %ebp
jg 0x20d04
leaq 0x54d76(%rip), %r12     # 0x758bc
leaq 0xb(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0x54d69(%rip), %rax     # 0x758c0
movslq (%rax), %rbx
cmpl (%r13), %ebx
jg 0x20c03
movl (%r12), %ecx
movl %ebp, %eax
imull %ecx, %eax
movslq %eax, %rsi
leaq (%rbx,%rsi), %rdx
addq 0x55815(%rip), %rsi     # 0x76390
movsbl 0x43f8(%rbx,%rsi), %esi
movl 0x548b7(%rip), %edi     # 0x75440
cmpl %esi, %edi
jne 0x20b97
cmpl $0x45, 0x810(%rsp,%rdx,4)
jg 0x20ba8
xorl %esi, %edi
cmpl $0x3, %edi
jne 0x20bf3
cmpl $0x1e, 0x810(%rsp,%rdx,4)
jg 0x20bf3
addl %ebx, %eax
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x3c869(%rip), %rdx     # 0x5d420
movsbl -0x4(%rcx,%rdx), %ecx
leaq 0x54cf1(%rip), %rdx     # 0x758b4
movl (%rdx), %r8d
subl %eax, %r8d
addl $0x5, %r8d
movl $0x5, %esi
movq %r14, %rdi
leaq 0x3d0f3(%rip), %rdx     # 0x5dccf
xorl %eax, %eax
callq 0x6690
movl $0x5, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x6260
incq %rbx
leal -0x1(%rbx), %eax
cmpl (%r13), %eax
jl 0x20b64
leal 0x1(%rbp), %eax
cmpl (%r13), %ebp
movl %eax, %ebp
jl 0x20b50
jmp 0x20d04
leaq 0x54ca2(%rip), %rax     # 0x758c0
movl (%rax), %ebp
leaq 0x54c9d(%rip), %r13     # 0x758c4
cmpl (%r13), %ebp
jg 0x20d04
leaq 0x54c84(%rip), %r12     # 0x758bc
leaq 0xb(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0x54c77(%rip), %rax     # 0x758c0
movslq (%rax), %rbx
cmpl (%r13), %ebx
jg 0x20cf5
movl (%r12), %ecx
movl %ebp, %eax
imull %ecx, %eax
movslq %eax, %rsi
leaq (%rbx,%rsi), %rdx
addq 0x55723(%rip), %rsi     # 0x76390
movsbl 0x43f8(%rbx,%rsi), %esi
movl 0x547c5(%rip), %edi     # 0x75440
cmpl %esi, %edi
jne 0x20c89
cmpl $0x1f, 0x810(%rsp,%rdx,4)
jl 0x20c9a
xorl %esi, %edi
cmpl $0x3, %edi
jne 0x20ce5
cmpl $0x46, 0x810(%rsp,%rdx,4)
jl 0x20ce5
addl %ebx, %eax
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x3c777(%rip), %rdx     # 0x5d420
movsbl -0x4(%rcx,%rdx), %ecx
leaq 0x54bff(%rip), %rdx     # 0x758b4
movl (%rdx), %r8d
subl %eax, %r8d
addl $0x5, %r8d
movl $0x5, %esi
movq %r14, %rdi
leaq 0x3d001(%rip), %rdx     # 0x5dccf
xorl %eax, %eax
callq 0x6690
movl $0x5, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x6260
incq %rbx
leal -0x1(%rbx), %eax
cmpl (%r13), %eax
jl 0x20c56
leal 0x1(%rbp), %eax
cmpl (%r13), %ebp
movl %eax, %ebp
jl 0x20c42
leaq 0x10(%rsp), %rdi
movl $0x1, %esi
callq 0x21c1a
addq $0x1538, %rsp           # imm = 0x1538
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq