// File: /workspace/github_cpp_makefile_star2_O2/ujjwal-ism[P]Jumping_game/gameUtil.cpp
// Function: GameUtil::shortestPathDistance(Game*, Player*)
int GameUtil::shortestPathDistance(Game* game, Player* player){
  
  std::vector<Square*> board = game->getBoard();
  int board_array[board.size()];
  //std::vector<int> board_array(board.size());
  for (int i = 0; i < board.size(); ++i)
  {
    board_array[i] = compute(board[i],player);
  }
  for (int i = 0; i < board.size(); ++i)
  {
    std::cout<<board_array[i]<<" ";
  }
  std::cout<<"\n\n\n";

  std::vector<int> path;
  path.push_back(0);
  int path_index[board.size()];
  path_index[0] = 0;
  int size = board.size();
  int i=1;

  while(1){
    if((path_index[i-1]+board_array[path_index[i-1]]) >= board.size()-1)
      break;

    path_index[i] = max_distance(path_index[i-1],board_array,size);
    path.push_back(path_index[i]);
    i++;
  }

  path.push_back(size-1);
  std::cout<<path.size()<<"\n\n";

  for (int i = 0; i < path.size(); ++i)
  {
    std::cout<<path[i]<<" ";  
  }
    std::cout<<"\n";

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movq %rsi, %rdi
callq 0x12c6
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x12d0
movq %rsp, %r13
movq 0x8(%rbx), %rax
subq (%rbx), %rax
movq %rsp, %rbx
sarq %rax
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
xorl %r15d, %r15d
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
jbe 0x1668
movq (%rax,%r15,8), %rsi
movq %r14, %rdx
callq 0x1398
movl %eax, (%rbx,%r15,4)
incq %r15
jmp 0x163c
xorl %r12d, %r12d
movq 0x3966(%rip), %r14      # 0x4fd8
leaq 0x1a5b(%rip), %r15      # 0x30d4
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x16a9
movl (%rbx,%r12,4), %esi
movq %r14, %rdi
callq 0x1120
movq %rax, %rdi
movq %r15, %rsi
callq 0x10c0
incq %r12
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
jmp 0x1679
movq 0x3928(%rip), %rdi      # 0x4fd8
leaq 0x1971(%rip), %rsi      # 0x3028
callq 0x10c0
xorps %xmm0, %xmm0
leaq -0x60(%rbp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
leaq -0x2c(%rbp), %rsi
andl $0x0, (%rsi)
callq 0x19e8
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rax, %rdx
subq %rcx, %rdx
movq %rdx, %r14
shrq $0x3, %r14
movq %rsp, %rsi
sarq %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsi, %r15
subq %rdx, %r15
movq %r15, %rsp
negq %rdx
andl $0x0, (%rsi,%rdx)
addq $0x4, %r15
leaq -0x60(%rbp), %r12
subq %rcx, %rax
movslq -0x4(%r15), %rsi
movslq (%rbx,%rsi,4), %rcx
addq %rsi, %rcx
sarq $0x3, %rax
decq %rax
cmpq %rcx, %rax
jbe 0x1753
movq %rbx, %rdx
movl %r14d, %ecx
callq 0x15b2
movl %eax, (%r15)
movq %r12, %rdi
movq %r15, %rsi
callq 0x190a
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
addq $0x4, %r15
jmp 0x1712
decl %r14d
leaq -0x2c(%rbp), %rsi
movl %r14d, (%rsi)
leaq -0x60(%rbp), %rdi
callq 0x19e8
movq -0x58(%rbp), %rsi
subq -0x60(%rbp), %rsi
sarq $0x2, %rsi
movq 0x385f(%rip), %rdi      # 0x4fd8
callq 0x1080
leaq 0x18a4(%rip), %rsi      # 0x3029
movq %rax, %rdi
callq 0x10c0
xorl %r15d, %r15d
movq 0x3841(%rip), %rbx      # 0x4fd8
leaq 0x1936(%rip), %r14      # 0x30d4
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
jbe 0x17ce
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
callq 0x1120
movq %rax, %rdi
movq %r14, %rsi
callq 0x10c0
incq %r15
jmp 0x179e
movq 0x3803(%rip), %rdi      # 0x4fd8
leaq 0x184e(%rip), %rsi      # 0x302a
callq 0x10c0
leaq -0x60(%rbp), %rdi
callq 0x19aa
movq %r13, %rsp
leaq -0x48(%rbp), %rdi
callq 0x193e
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1813
jmp 0x1813
jmp 0x1821
jmp 0x1813
jmp 0x1813
jmp 0x1821
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x19aa
jmp 0x1824
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x193e
movq %rbx, %rdi
callq 0x1140
nop