// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/movepick.cpp
// Function: MovePicker::go_next_phase()
void MovePicker::go_next_phase() {

  curMove = moves;
  phase = *(++phasePtr);
  switch (phase) {

  case PH_TT_MOVES:
      curMove = ttMoves;
      lastMove = curMove + 2;
      return;

  case PH_GOOD_CAPTURES:
      lastMove = generate<MV_CAPTURE>(pos, moves);
      score_captures();
      return;

  case PH_KILLERS:
      curMove = killers;
      lastMove = curMove + 2;
      return;

  case PH_NONCAPTURES:
      lastMove = generate<MV_NON_CAPTURE>(pos, moves);
      score_noncaptures();
      sort_moves(moves, lastMove, &lastGoodNonCapture);
      return;

  case PH_BAD_CAPTURES:
      // Bad captures SEE value is already calculated so just pick
      // them in order to get SEE move ordering.
      curMove = badCaptures;
      lastMove = moves + MAX_MOVES;
      return;

  case PH_EVASIONS:
      assert(pos.in_check());
      lastMove = generate<MV_EVASION>(pos, moves);
      score_evasions();
      return;

  case PH_QCAPTURES:
      lastMove = generate<MV_CAPTURE>(pos, moves);
      score_captures();
      return;

  case PH_QCHECKS:
      lastMove = generate<MV_NON_CAPTURE_CHECK>(pos, moves);
      return;

  case PH_STOP:
      lastMove = curMove + 1; // Avoid another go_next_phase() call
      return;

  default:
      assert(false);
      return;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0x68(%rdi), %r14
movq %r14, 0x48(%rdi)
movq 0x40(%rdi), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x40(%rdi)
movzbl 0x1(%rax), %eax
movl %eax, 0x3c(%rdi)
cmpq $0x8, %rax
ja 0x1b905
movq %rdi, %rbx
leaq 0x17216(%rip), %rcx     # 0x32980
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x1ab37
movq %rax, 0x50(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x1b9c6
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x1ae77
movq %rax, 0x50(%rbx)
cmpq %rax, %r14
je 0x1b7db
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
movq %r14, %rsi
movl (%rsi), %edi
movl %edi, %r8d
shrl $0x4, %r8d
andl $0xfc, %r8d
movl (%rcx,%r8), %r8d
andl $0x3f, %edi
shlq $0x8, %r8
addq %rdx, %r8
movl (%r8,%rdi,4), %edi
movl %edi, 0x4(%rsi)
addq $0x8, %rsi
cmpq %rax, %rsi
jne 0x1b7ad
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movl $0x60, %edi
movq %rdi, %rcx
leaq (%rbx,%rdi), %rdx
xorl %esi, %esi
addq $-0x8, %rsi
cmpl $0x0, 0xc(%rdx)
leaq 0x8(%rdx), %rdx
jg 0x1b7f0
cmpq %rax, %rdx
je 0x1b828
addq $-0x8, %rax
movq %rax, %rdi
movq %rdi, %rax
cmpq %rdx, %rdi
je 0x1b81c
leaq -0x8(%rax), %rdi
cmpl $0x0, 0x4(%rax)
jle 0x1b80a
movq (%rdx), %rdi
movq (%rax), %r8
movq %r8, (%rdx)
movq %rdi, (%rax)
movq %rcx, %rdi
subq %rsi, %rdi
cmpq %rax, %rdx
jne 0x1b7e7
subq %rsi, %rcx
addq $-0x8, %rcx
movq %rcx, %rax
andq $-0x9, %rax
cmpq $0x60, %rax
je 0x1b8a1
leaq 0x70(%rbx), %rax
movl $0x68, %esi
xorl %edi, %edi
movq 0x8(%rbx,%rsi), %r8
movq %r8, %r9
shrq $0x20, %r9
cmpl %r9d, 0x4(%rbx,%rsi)
jge 0x1b890
movq %rdi, %r10
movq %rax, %r11
movq -0x8(%r11), %r15
movq %r15, (%r11)
testq %r10, %r10
je 0x1b88a
leaq -0x8(%r11), %r15
addq $0x8, %r10
cmpl %r9d, -0xc(%r11)
movq %r15, %r11
jl 0x1b86b
jmp 0x1b88d
movq %r14, %r15
movq %r8, (%r15)
addq $0x8, %rsi
addq $0x8, %rax
addq $-0x8, %rdi
cmpq %rsi, %rcx
jne 0x1b852
movq %rdx, 0x58(%rbx)
jmp 0x1b905
leaq 0x18(%rbx), %rax
movq %rax, 0x48(%rbx)
leaq 0x28(%rbx), %rax
jmp 0x1b901
leaq 0x28(%rbx), %rax
movq %rax, 0x48(%rbx)
leaq 0x38(%rbx), %rax
jmp 0x1b901
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x190ec
jmp 0x1b901
movq 0x60(%rbx), %rax
movq %rax, 0x48(%rbx)
leaq 0x868(%rbx), %rax
jmp 0x1b901
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x19b88
movq %rax, 0x50(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x1ba76
leaq 0x70(%rbx), %rax
movq %rax, 0x50(%rbx)
popq %rbx
popq %r14
popq %r15
retq
nop