// File: ttencate[P]pickomino/game.cc
// Function: Game::takeTurn(Strategy&) const
Dice Game::takeTurn(Strategy &strategy) const {
  strategy.prepareTurn(*this);
  Dice taken;
  while (canRoll(taken) && strategy.chooseWhetherToRoll(*this, taken)) {
    Dice roll = randomRoll(NUM_DICE - taken.count());
    cout << currentPlayer().name() << " rolled " << roll << '\n';

    if (!canTakeAny(taken, roll)) {
      cout << currentPlayer().name() << " died\n";
      return Dice();
    }

    DieSide const *side = strategy.chooseSideToTake(*this, taken, roll);
    taken[side] = roll[side];
    cout << currentPlayer().name() << " took " << side->toString() << ", now has " << taken << '\n';
  }
  cout << "Quit\n";
  return taken;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0x50(%rsp)
movq %rdi, 0x58(%rsp)
movq %rsi, 0xf0(%rsp)
movq %rdx, 0xe8(%rsp)
movq 0xf0(%rsp), %rsi
movq %rsi, 0x60(%rsp)
movq 0xe8(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0xd0(%rsp), %rdi
callq 0x5210
movq 0x60(%rsp), %rdi
movq 0xd0(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0xb8(%rsp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5230
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x4f(%rsp)
jne 0x3f23
jmp 0x3f42
movq 0x60(%rsp), %rsi
movq 0xe8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xd0(%rsp), %rdx
callq *0x18(%rax)
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x3f4f
jmp 0x4179
leaq 0xd0(%rsp), %rdi
callq 0x5250
movl $0x8, %esi
subl %eax, %esi
leaq 0xa0(%rsp), %rdi
callq 0xf6c0
movq 0x60(%rsp), %rdi
callq 0x52f0
movq %rax, %rdi
callq 0x4f30
movq %rax, %rsi
movq 0x17044(%rip), %rdi     # 0x1afd0
callq 0x2150
movq %rax, %rdi
leaq 0xe0dc(%rip), %rsi      # 0x12077
callq 0x2170
movq %rax, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2990
movq %rax, %rdi
movl $0xa, %esi
callq 0x21c0
movq 0x60(%rsp), %rdi
movq 0xd0(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rcx
leaq 0x70(%rsp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0x5310
testb $0x1, %al
jne 0x40a4
movq 0x60(%rsp), %rdi
callq 0x52f0
movq %rax, %rdi
callq 0x4f30
movq %rax, %rsi
movq 0x16f4f(%rip), %rdi     # 0x1afd0
callq 0x2150
movq %rax, %rdi
leaq 0xdff0(%rip), %rsi      # 0x12080
callq 0x2170
movq 0x50(%rsp), %rdi
callq 0x5210
jmp 0x41b4
movq 0x60(%rsp), %rsi
movq 0xe8(%rsp), %rdi
movq (%rdi), %rax
leaq 0xd0(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
callq *0x20(%rax)
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x2f50
movl (%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0x68(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x2f50
movl 0x3c(%rsp), %ecx
movq 0x60(%rsp), %rdi
movl %ecx, (%rax)
callq 0x52f0
movq %rax, %rdi
callq 0x4f30
movq %rax, %rsi
movq 0x16eb8(%rip), %rdi     # 0x1afd0
callq 0x2150
movq %rax, %rdi
leaq 0xdf60(%rip), %rsi      # 0x12087
callq 0x2170
movq %rax, 0x40(%rsp)
movq 0x68(%rsp), %rdi
callq 0x2f20
movq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x2170
movq %rax, %rdi
leaq 0xdf3c(%rip), %rsi      # 0x1208e
callq 0x2170
movq %rax, %rdi
leaq 0xd0(%rsp), %rsi
callq 0x2990
movq %rax, %rdi
movl $0xa, %esi
callq 0x21c0
jmp 0x3eb9
movq 0x16e50(%rip), %rdi     # 0x1afd0
leaq 0xdf12(%rip), %rsi      # 0x12099
callq 0x2170
movq 0x50(%rsp), %rax
movq 0xd0(%rsp), %rcx
movq %rcx, (%rax)
movq 0xd8(%rsp), %rcx
movq %rcx, 0x8(%rax)
movq 0xe0(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x58(%rsp), %rax
addq $0xf8, %rsp
retq
nopw %cs:(%rax,%rax)