// File: czinn[P]homeworlds/negamax.cc
// Function: Negamax::get_turns(Game const*)
std::vector<Turn*> Negamax::get_turns(const Game *game) {
  std::unordered_map<int, Turn*> result;
  std::vector<Action> actions;
  game->legal_actions(actions);

  for (Action& action : actions) {
    if (action.type == PASS) {
      Game *g = new Game(*game);
      g->perform_action(action);
      result.emplace(g->hash(), new Turn{g, std::deque<Action>({action})});
      continue;
    }

    Game *g = new Game(*game);
    g->perform_action(action);
    for (Turn *turn : get_turns(g)) {
      if (result.count(turn->game->hash()) == 0) {
        turn->actions.push_front(action);
        result.emplace(turn->game->hash(), turn);
      } else {
        delete turn;
      }
    }
    delete g;
  }

  std::vector<Turn*> real_result;
  for (const auto& p : result) {
    real_result.push_back(p.second);
  }
  return real_result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x198(%rbp)
movq %rdi, %rax
movq %rax, -0x190(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x188(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x16d10
leaq -0x68(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x16d30
movq -0x180(%rbp), %rsi
movq -0x18(%rbp), %rdi
callq 0x46b0
jmp 0x13a6e
leaq -0x68(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0xd2a0
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
callq 0x9270
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x16d50
testb $0x1, %al
jne 0x13ab2
jmp 0x13f1b
leaq -0x88(%rbp), %rdi
callq 0xd7b0
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x13cb1
movl $0x68, %edi
callq 0x3230
movq %rax, -0x1a0(%rbp)
jmp 0x13ae9
movq -0x1a0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x16d90
jmp 0x13afb
movq -0x1a0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x5900
jmp 0x13b1e
movq -0xa0(%rbp), %rdi
callq 0x3f60
movl %eax, -0x1a4(%rbp)
jmp 0x13b32
movl -0x1a4(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl $0x58, %edi
callq 0x3230
movq %rax, -0x1b0(%rbp)
jmp 0x13b51
movq -0x1b0(%rbp), %rax
movb $0x1, -0xe2(%rbp)
movq -0xa0(%rbp), %rcx
movq %rcx, (%rax)
addq $0x8, %rax
movq %rax, -0x1c0(%rbp)
movq -0x98(%rbp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm1, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq $0x1, -0xb8(%rbp)
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x168c0
movq -0x1c0(%rbp), %rdi
movq -0x1b8(%rbp), %rcx
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x16e60
jmp 0x13bdf
movq -0x1b0(%rbp), %rax
movb $0x0, -0xe2(%rbp)
movq %rax, -0xb0(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0xa4(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x16e10
movb %dl, -0x1c9(%rbp)
movq %rax, -0x1c8(%rbp)
jmp 0x13c1a
movb -0x1c9(%rbp), %al
movq -0x1c8(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
movb %al, -0xf0(%rbp)
leaq -0xe1(%rbp), %rdi
callq 0x16960
jmp 0x13f0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1400c
movq -0x1a0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
movl $0x68, %esi
callq 0x3240
jmp 0x1400c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xe1(%rbp), %rdi
callq 0x16960
testb $0x1, -0xe2(%rbp)
jne 0x13c9b
jmp 0x13cac
movq -0x1b0(%rbp), %rdi
movl $0x58, %esi
callq 0x3240
jmp 0x1400c
movl $0x68, %edi
callq 0x3230
movq %rax, -0x1d8(%rbp)
jmp 0x13cc4
movq -0x1d8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x16d90
jmp 0x13cd6
movq -0x1d8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x5900
jmp 0x13cf9
movq -0x188(%rbp), %rsi
movq -0x100(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0x13a10
jmp 0x13d15
leaq -0x120(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rdi
callq 0x16980
movq %rax, -0x128(%rbp)
movq -0x108(%rbp), %rdi
callq 0x169b0
movq %rax, -0x130(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x169e0
testb $0x1, %al
jne 0x13d93
leaq -0x120(%rbp), %rdi
callq 0x16c10
jmp 0x13ed7
movq -0x1d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
movl $0x68, %esi
callq 0x3240
jmp 0x1400c
leaq -0x128(%rbp), %rdi
callq 0x16a20
movq (%rax), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq (%rax), %rdi
callq 0x3f60
movl %eax, -0x1dc(%rbp)
jmp 0x13dc0
movl -0x1dc(%rbp), %eax
movl %eax, -0x13c(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x13c(%rbp), %rsi
callq 0x16ee0
movq %rax, -0x1e8(%rbp)
jmp 0x13de5
movq -0x1e8(%rbp), %rax
cmpq $0x0, %rax
jne 0x13e91
movq -0x138(%rbp), %rdi
addq $0x8, %rdi
movq -0x98(%rbp), %rsi
callq 0x16f10
jmp 0x13e0f
movq -0x138(%rbp), %rax
movq (%rax), %rdi
callq 0x3f60
movl %eax, -0x1ec(%rbp)
jmp 0x13e26
movl -0x1ec(%rbp), %eax
movl %eax, -0x140(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x140(%rbp), %rsi
leaq -0x138(%rbp), %rdx
callq 0x16f70
movb %dl, -0x1f9(%rbp)
movq %rax, -0x1f8(%rbp)
jmp 0x13e58
movb -0x1f9(%rbp), %al
movq -0x1f8(%rbp), %rcx
movq %rcx, -0x150(%rbp)
movb %al, -0x148(%rbp)
jmp 0x13ec4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x16c10
jmp 0x1400c
movq -0x138(%rbp), %rax
movq %rax, -0x208(%rbp)
cmpq $0x0, %rax
je 0x13ec2
movq -0x208(%rbp), %rdi
callq 0x13580
movq -0x208(%rbp), %rdi
movl $0x58, %esi
callq 0x3240
jmp 0x13ec4
jmp 0x13ec6
leaq -0x128(%rbp), %rdi
callq 0x16a80
jmp 0x13d49
movq -0x100(%rbp), %rax
movq %rax, -0x210(%rbp)
cmpq $0x0, %rax
je 0x13f08
movq -0x210(%rbp), %rdi
callq 0x16800
movq -0x210(%rbp), %rdi
movl $0x68, %esi
callq 0x3240
jmp 0x13f0a
leaq -0x88(%rbp), %rdi
callq 0x16fc0
jmp 0x13a96
movq -0x198(%rbp), %rdi
movb $0x0, -0x151(%rbp)
callq 0x16fe0
leaq -0x50(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rdi
callq 0x17000
movq %rax, -0x168(%rbp)
movq -0x160(%rbp), %rdi
callq 0x17030
movq %rax, -0x170(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x17060
testb $0x1, %al
jne 0x13f78
jmp 0x13fce
leaq -0x168(%rbp), %rdi
callq 0x17090
movq -0x198(%rbp), %rdi
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rsi
addq $0x8, %rsi
callq 0x170c0
jmp 0x13fa4
jmp 0x13fa6
leaq -0x168(%rbp), %rdi
callq 0x17130
jmp 0x13f5f
movq -0x198(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
callq 0x16c10
jmp 0x1400c
movb $0x1, -0x151(%rbp)
testb $0x1, -0x151(%rbp)
jne 0x13fea
movq -0x198(%rbp), %rdi
callq 0x16c10
leaq -0x68(%rbp), %rdi
callq 0x16bb0
leaq -0x50(%rbp), %rdi
callq 0x17160
movq -0x190(%rbp), %rax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x16bb0
leaq -0x50(%rbp), %rdi
callq 0x17160
movq -0x70(%rbp), %rdi
callq 0x33c0
nopw (%rax,%rax)