// File: /workspace/github_cpp_makefile_star2_O2/kobanium[P]Ray/src/gtp/Gtp.cpp
// Function: GTP_fixed_handicap()
static void
GTP_fixed_handicap( void )
{
  char *command;
  int num;
  char buf[1024];
  char pos[5];
  int handicap[9];
  const int place_index[8][9] = {
    {2, 6},
    {0, 2, 6},
    {0, 2, 6, 8},
    {0, 2, 4, 6, 8},
    {0, 2, 3, 5, 6, 8},
    {0, 2, 3, 4, 5, 6, 8},
    {0, 1, 2, 3, 5, 6, 7, 8},
    {0, 1, 2, 3, 4, 5, 6, 7, 8},
  };

  StopPondering();
  
  command = STRTOK(NULL, DELIM, &next_token);
  
#if defined (_WIN32)
  sscanf_s(command, "%d", &num);
  sprintf_s(buf, 1024, " ");
#else
  sscanf(command, "%d", &num);
  snprintf(buf, 1024, " ");
#endif

  if (num < 2 || 9 < num) {
    GTP_response(blank, false);
    return ;
  }

  handicap[0] = POS(board_start +  3, board_start +  3);
  handicap[1] = POS(board_start +  9, board_start +  3);
  handicap[2] = POS(board_start + 15, board_start +  3);
  handicap[3] = POS(board_start +  3, board_start +  9);
  handicap[4] = POS(board_start +  9, board_start +  9);
  handicap[5] = POS(board_start + 15, board_start +  9);
  handicap[6] = POS(board_start +  3, board_start + 15);
  handicap[7] = POS(board_start +  9, board_start + 15);
  handicap[8] = POS(board_start + 15, board_start + 15);

  for (int i = 0; i < num; i++) {
    PutStone(game, handicap[place_index[num - 2][i]], S_BLACK);
#if defined (_WIN32)
    sprintf_s(pos, 5, "%c%d ", GOGUI_X(handicap[place_index[num - 2][i]]), GOGUI_Y(handicap[place_index[num - 2][i]]));
    strcat_s(buf, 1024, pos);
#else
    snprintf(pos, 5, "%c%d ", GOGUI_X(handicap[place_index[num - 2][i]]), GOGUI_Y(handicap[place_index[num - 2][i]]));
    strncat(buf, pos, 5);
#endif
  }
  
  SetKomi(0.5);
  SetHandicapNum(num);
  GTP_response(buf, true);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
callq 0x32ecd
leaq 0x32eb4(%rip), %rsi     # 0x44bd2
xorl %edi, %edi
callq 0x6610
leaq 0x32cc0(%rip), %rsi     # 0x449ec
leaq 0xc(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x63b0
movw $0x20, 0x40(%rsp)
movl (%rbx), %eax
leal -0xa(%rax), %ecx
cmpl $-0x9, %ecx
ja 0x11d5d
leaq 0x32e5a(%rip), %rdi     # 0x44bb0
xorl %esi, %esi
jmp 0x11ebe
leaq 0x4fb5c(%rip), %rcx     # 0x618c0
movl (%rcx), %ecx
leal 0x3(%rcx), %edi
leaq 0x4fb4c(%rip), %rdx     # 0x618bc
movl (%rdx), %esi
leal 0x1(%rsi), %edx
movl %edx, %r8d
imull %edi, %r8d
movl %r8d, 0x10(%rsp)
leal 0x9(%rcx), %r8d
imull %esi, %edi
leal (%rdi,%rcx), %r9d
addl $0x9, %r9d
movl %r9d, 0x14(%rsp)
movl %ecx, %r9d
addl $0xf, %r9d
addl %ecx, %edi
addl $0xf, %edi
movl %edi, 0x18(%rsp)
movl %edx, %edi
imull %r8d, %edi
imull %esi, %r8d
leal (%r8,%rcx), %r10d
addl $0x3, %r10d
movl %r10d, 0x1c(%rsp)
movl %edi, 0x20(%rsp)
leal (%r8,%rcx), %edi
addl $0xf, %edi
movl %edi, 0x24(%rsp)
imull %r9d, %esi
leal (%rsi,%rcx), %edi
addl $0x3, %edi
movl %edi, 0x28(%rsp)
addl %esi, %ecx
addl $0x9, %ecx
movl %ecx, 0x2c(%rsp)
imull %edx, %r9d
movl %r9d, 0x30(%rsp)
leaq 0x32e1e(%rip), %rbp     # 0x44c10
leaq 0x32d24(%rip), %r14     # 0x44b1d
leaq 0x3b(%rsp), %r15
pushq $0x5
popq %r12
leaq 0x40(%rsp), %r13
xorl %ebx, %ebx
movslq %eax, %rcx
cmpq %rcx, %rbx
jge 0x11ea0
movq 0x50574(%rip), %rdi     # 0x62390
addl $-0x2, %eax
cltq
imulq $0x24, %rax, %rax
movslq (%rbp,%rax), %rax
movl 0x10(%rsp,%rax,4), %esi
pushq $0x1
popq %rdx
callq 0x3c2f8
movslq 0xc(%rsp), %rax
imulq $0x24, %rax, %rax
movslq -0x48(%rbp,%rax), %rax
movl 0x10(%rsp,%rax,4), %eax
cltd
leaq 0x4fa6c(%rip), %rcx     # 0x618bc
idivl (%rcx)
movslq %edx, %rcx
leaq 0x32d94(%rip), %rdx     # 0x44bf0
movsbl -0x4(%rcx,%rdx), %ecx
leaq 0x4fa4c(%rip), %rdx     # 0x618b4
movl (%rdx), %r8d
subl %eax, %r8d
addl $0x5, %r8d
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x6660
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6240
incq %rbx
movl 0xc(%rsp), %eax
addq $0x4, %rbp
jmp 0x11e09
movsd 0x32168(%rip), %xmm0    # 0x44010
callq 0x3b0f3
movl 0xc(%rsp), %edi
callq 0x3d2b3
leaq 0x40(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x12a66
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq