// File: 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
movq %rsp, %rbp
subq $0x1560, %rsp           # imm = 0x1560
leaq -0x800(%rbp), %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x72b0
callq 0x892c0
leaq -0x1530(%rbp), %rdi
callq 0x8a9f0
xorl %eax, %eax
movl %eax, %edi
leaq 0x866f6(%rip), %rsi     # 0xacba0
callq 0x7850
movq %rax, -0x1538(%rbp)
movq -0x1538(%rbp), %rax
movq %rax, -0x1550(%rbp)
movq -0x1538(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x1550(%rbp), %rax
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x26513
movq -0x1538(%rbp), %rax
movq %rax, -0x1558(%rbp)
movq -0x1538(%rbp), %rdi
callq 0x7200
movq %rax, %rcx
movq -0x1558(%rbp), %rax
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movq -0x1538(%rbp), %rdi
leaq 0x865f1(%rip), %rsi     # 0xacb12
callq 0x77a0
cmpl $0x0, %eax
jne 0x26714
leaq 0xc151a(%rip), %rax     # 0xe7a50
movl (%rax), %eax
movl %eax, -0x153c(%rbp)
movl -0x153c(%rbp), %eax
leaq 0xc1509(%rip), %rcx     # 0xe7a54
cmpl (%rcx), %eax
jg 0x2670f
leaq 0xc14f6(%rip), %rax     # 0xe7a50
movl (%rax), %eax
movl %eax, -0x1540(%rbp)
movl -0x1540(%rbp), %eax
leaq 0xc14e5(%rip), %rcx     # 0xe7a54
cmpl (%rcx), %eax
jg 0x266f9
movq 0xc1fa2(%rip), %rax     # 0xe8520
movl -0x1540(%rbp), %ecx
movl -0x153c(%rbp), %edx
leaq 0xc14bb(%rip), %rsi     # 0xe7a4c
imull (%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
cmpl 0xc0fe9(%rip), %eax     # 0xe7590
jne 0x265cd
movl -0x1540(%rbp), %eax
movl -0x153c(%rbp), %ecx
leaq 0xc1490(%rip), %rdx     # 0xe7a4c
imull (%rdx), %ecx
addl %ecx, %eax
cltq
cmpl $0x1e, -0x1530(%rbp,%rax,4)
jle 0x26640
movq 0xc1f4c(%rip), %rax     # 0xe8520
movl -0x1540(%rbp), %ecx
movl -0x153c(%rbp), %edx
leaq 0xc1465(%rip), %rsi     # 0xe7a4c
imull (%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
movl %eax, -0x155c(%rbp)
movl 0xc0f8d(%rip), %edi     # 0xe7590
callq 0x25810
movl %eax, %ecx
movl -0x155c(%rbp), %eax
cmpl %ecx, %eax
jne 0x266e3
movl -0x1540(%rbp), %eax
movl -0x153c(%rbp), %ecx
leaq 0xc1421(%rip), %rdx     # 0xe7a4c
imull (%rdx), %ecx
addl %ecx, %eax
cltq
cmpl $0x46, -0x1530(%rbp,%rax,4)
jl 0x266e3
leaq -0x805(%rbp), %rdi
movl -0x1540(%rbp), %eax
movl -0x153c(%rbp), %ecx
leaq 0xc13f2(%rip), %rdx     # 0xe7a4c
imull (%rdx), %ecx
addl %ecx, %eax
leaq 0xc13e6(%rip), %rcx     # 0xe7a4c
cltd
idivl (%rcx)
movl %edx, %eax
subl $0x5, %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x86565(%rip), %rax     # 0xacbe0
movsbl (%rax,%rcx), %ecx
leaq 0xc13be(%rip), %rax     # 0xe7a44
movl (%rax), %r8d
addl $0x1, %r8d
movl -0x1540(%rbp), %eax
movl -0x153c(%rbp), %edx
leaq 0xc13ac(%rip), %rsi     # 0xe7a4c
imull (%rsi), %edx
addl %edx, %eax
leaq 0xc13a0(%rip), %rsi     # 0xe7a4c
cltd
idivl (%rsi)
subl $0x5, %eax
addl $0x1, %eax
subl %eax, %r8d
movl $0x5, %esi
leaq 0x86453(%rip), %rdx     # 0xacb17
movb $0x0, %al
callq 0x78a0
leaq -0x800(%rbp), %rdi
leaq -0x805(%rbp), %rsi
movl $0x5, %edx
callq 0x7360
jmp 0x266e5
movl -0x1540(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1540(%rbp)
jmp 0x26562
jmp 0x266fb
movl -0x153c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x153c(%rbp)
jmp 0x2653e
jmp 0x26914
movq -0x1538(%rbp), %rdi
leaq 0x863fb(%rip), %rsi     # 0xacb1d
callq 0x77a0
cmpl $0x0, %eax
jne 0x26912
leaq 0xc1319(%rip), %rax     # 0xe7a50
movl (%rax), %eax
movl %eax, -0x1544(%rbp)
movl -0x1544(%rbp), %eax
leaq 0xc1308(%rip), %rcx     # 0xe7a54
cmpl (%rcx), %eax
jg 0x26910
leaq 0xc12f5(%rip), %rax     # 0xe7a50
movl (%rax), %eax
movl %eax, -0x1548(%rbp)
movl -0x1548(%rbp), %eax
leaq 0xc12e4(%rip), %rcx     # 0xe7a54
cmpl (%rcx), %eax
jg 0x268fa
movq 0xc1da1(%rip), %rax     # 0xe8520
movl -0x1548(%rbp), %ecx
movl -0x1544(%rbp), %edx
leaq 0xc12ba(%rip), %rsi     # 0xe7a4c
imull (%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
cmpl 0xc0de8(%rip), %eax     # 0xe7590
jne 0x267ce
movl -0x1548(%rbp), %eax
movl -0x1544(%rbp), %ecx
leaq 0xc128f(%rip), %rdx     # 0xe7a4c
imull (%rdx), %ecx
addl %ecx, %eax
cltq
cmpl $0x46, -0x1530(%rbp,%rax,4)
jge 0x26841
movq 0xc1d4b(%rip), %rax     # 0xe8520
movl -0x1548(%rbp), %ecx
movl -0x1544(%rbp), %edx
leaq 0xc1264(%rip), %rsi     # 0xe7a4c
imull (%rsi), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsbl 0x43f8(%rax,%rcx), %eax
movl %eax, -0x1560(%rbp)
movl 0xc0d8c(%rip), %edi     # 0xe7590
callq 0x25810
movl %eax, %ecx
movl -0x1560(%rbp), %eax
cmpl %ecx, %eax
jne 0x268e4
movl -0x1548(%rbp), %eax
movl -0x1544(%rbp), %ecx
leaq 0xc1220(%rip), %rdx     # 0xe7a4c
imull (%rdx), %ecx
addl %ecx, %eax
cltq
cmpl $0x1e, -0x1530(%rbp,%rax,4)
jg 0x268e4
leaq -0x805(%rbp), %rdi
movl -0x1548(%rbp), %eax
movl -0x1544(%rbp), %ecx
leaq 0xc11f1(%rip), %rdx     # 0xe7a4c
imull (%rdx), %ecx
addl %ecx, %eax
leaq 0xc11e5(%rip), %rcx     # 0xe7a4c
cltd
idivl (%rcx)
movl %edx, %eax
subl $0x5, %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x86364(%rip), %rax     # 0xacbe0
movsbl (%rax,%rcx), %ecx
leaq 0xc11bd(%rip), %rax     # 0xe7a44
movl (%rax), %r8d
addl $0x1, %r8d
movl -0x1548(%rbp), %eax
movl -0x1544(%rbp), %edx
leaq 0xc11ab(%rip), %rsi     # 0xe7a4c
imull (%rsi), %edx
addl %edx, %eax
leaq 0xc119f(%rip), %rsi     # 0xe7a4c
cltd
idivl (%rsi)
subl $0x5, %eax
addl $0x1, %eax
subl %eax, %r8d
movl $0x5, %esi
leaq 0x86252(%rip), %rdx     # 0xacb17
movb $0x0, %al
callq 0x78a0
leaq -0x800(%rbp), %rdi
leaq -0x805(%rbp), %rsi
movl $0x5, %edx
callq 0x7360
jmp 0x268e6
movl -0x1548(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1548(%rbp)
jmp 0x26763
jmp 0x268fc
movl -0x1544(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1544(%rbp)
jmp 0x2673f
jmp 0x26912
jmp 0x26914
leaq -0x800(%rbp), %rdi
movl $0x1, %esi
callq 0x27f30
addq $0x1560, %rsp           # imm = 0x1560
popq %rbp
retq
nop