// File: czinn[P]homeworlds/game.cc
// Function: Game::legal_actions(std::vector<Action, std::allocator<Action>>&) const
void Game::legal_actions(std::vector<Action>& result) const {
  if (done_main_action_) {
    result.push_back(Action{cur_player_, PASS});
  }

  for (const System& system : systems_) {
    legal_system_actions(result, system, CATASTROPHE);

    if (!done_main_action_) {
      legal_system_actions(result, system, SACRIFICE);
    }

    if ((!done_main_action_ && colour_available(system, cur_player_, RED)) ||
        (sacrifice_actions_ > 0 && sacrifice_colour_ == RED)) {
      legal_system_actions(result, system, ATTACK);
    }

    if ((!done_main_action_ && colour_available(system, cur_player_, YELLOW)) ||
        (sacrifice_actions_ > 0 && sacrifice_colour_ == YELLOW)) {
      legal_system_actions(result, system, DISCOVER);
      legal_system_actions(result, system, TRAVEL);
    }

    if ((!done_main_action_ && colour_available(system, cur_player_, GREEN)) ||
        (sacrifice_actions_ > 0 && sacrifice_colour_ == GREEN)) {
      legal_system_actions(result, system, BUILD);
    }

    if ((!done_main_action_ && colour_available(system, cur_player_, BLUE)) ||
        (sacrifice_actions_ > 0 && sacrifice_colour_ == BLUE)) {
      legal_system_actions(result, system, TRADE);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
testb $0x1, 0x8(%rax)
je 0x4704
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3120
movq -0x58(%rbp), %rax
movq -0x60(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
leaq -0x30(%rbp), %rsi
callq 0x8f60
movq -0x58(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x8ae0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x8b10
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x8b40
testb $0x1, %al
jne 0x4740
jmp 0x48eb
leaq -0x40(%rbp), %rdi
callq 0x8b80
movq -0x58(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x7, %ecx
callq 0x4900
movq -0x58(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x4783
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x6, %ecx
callq 0x4900
movq -0x58(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x47a8
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rdi
movl 0x4(%rax), %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5680
testb $0x1, %al
jne 0x47bc
movq -0x58(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jle 0x47d2
movq -0x58(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x47d2
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x1, %ecx
callq 0x4900
movq -0x58(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x47f7
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rdi
movl 0x4(%rax), %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x5680
testb $0x1, %al
jne 0x480b
movq -0x58(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jle 0x4837
movq -0x58(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x4837
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x2, %ecx
callq 0x4900
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x3, %ecx
callq 0x4900
movq -0x58(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x485f
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rdi
movl 0x4(%rax), %esi
movl $0x2, %edx
movl $0x1, %ecx
callq 0x5680
testb $0x1, %al
jne 0x4873
movq -0x58(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jle 0x4889
movq -0x58(%rbp), %rax
cmpl $0x2, 0x18(%rax)
jne 0x4889
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x4, %ecx
callq 0x4900
movq -0x58(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x48b1
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rdi
movl 0x4(%rax), %esi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x5680
testb $0x1, %al
jne 0x48c5
movq -0x58(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jle 0x48db
movq -0x58(%rbp), %rax
cmpl $0x3, 0x18(%rax)
jne 0x48db
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x5, %ecx
callq 0x4900
jmp 0x48dd
leaq -0x40(%rbp), %rdi
callq 0x8c40
jmp 0x472a
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)