// File: /workspace/github_cpp_makefile_star2_O3/permui[P]CastleAdventure/src/command.cpp
// Function: Command(Player&, Grid&, std::map<Position, Grid, std::less<Position>, std::allocator<std::pair<Position const, Grid>>>&)
void Command(Player &player, Grid &grid, map<Position, Grid> &mp) {
	switch (grid.info.t) {
		case GT::Monster: {
			EncounterMonster(player, grid);
			if (player.pos == FAIL_POS || player.pos == QUIT_POS) return;
			break;
		}
		case GT::Princess: {
			EncounterPrincess(player, grid);
			break;
		}
		default:
			break;
	}
	cout << "Commands:";
	if (grid.commands.empty()) {
		// if the design is right, this is impossible
		cout << " no commands availible" << endl;
		return;
	}
	for (const auto &pr: grid.commands) cout << ' ' << pr.first;
	cout << endl;
	map<string, Action>::iterator it;
	while (true) {
		string com = GetA<string>();
		it = grid.commands.find(com);
		if (it != grid.commands.end()) break;
		cout << "given command not available, see the command list" << endl;
	}
	it->second(player, grid, mp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r14
movl 0x8(%rsi), %eax
testl %eax, %eax
je 0x8609
cmpl $0x1, %eax
jne 0x8614
movq %r14, %rdi
movq %rbp, %rsi
callq 0x87e1
leaq 0x13d3(%rip), %rsi      # 0x99b4
movq %r14, %rdi
callq 0x3c6e
testb %al, %al
jne 0x875f
leaq 0x13c4(%rip), %rsi      # 0x99bc
movq %r14, %rdi
callq 0x3c6e
testb %al, %al
je 0x8614
jmp 0x875f
movq %r14, %rdi
movq %rbp, %rsi
callq 0x8aaf
movq 0x49b5(%rip), %r12      # 0xcfd0
leaq 0x13a2(%rip), %rsi      # 0x99c4
movl $0x9, %edx
movq %r12, %rdi
callq 0x21e0
cmpq $0x0, 0x78(%rbp)
je 0x876e
movq %r14, (%rsp)
movq %rbx, 0x10(%rsp)
movq 0x68(%rbp), %rbx
leaq 0x58(%rbp), %r14
cmpq %r14, %rbx
je 0x8691
movq 0x4979(%rip), %r15      # 0xcfd0
leaq 0x18(%rsp), %r13
movb $0x20, 0x18(%rsp)
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x21e0
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %rax, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x2130
movq %rax, %rbx
cmpq %r14, %rax
jne 0x865c
movq %rbp, 0x8(%rsp)
leaq 0x50(%rbp), %r13
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x28(%rsp), %rbx
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x8bbe
movq %r13, %rdi
movq %rbp, %rsi
callq 0x8cc0
movq %rax, %r15
cmpq %r14, %rax
jne 0x8723
movl $0x31, %edx
movq %r12, %rdi
leaq 0x12ef(%rip), %rsi      # 0x99e5
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x18(%rsp), %rdi
cmpq %rbx, %rdi
je 0x873a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21c0
cmpq %r14, %r15
je 0x86cc
cmpq $0x0, 0x50(%r15)
je 0x87b8
movq %r15, %rdi
addq $0x40, %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
callq *0x58(%r15)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1259(%rip), %rsi      # 0x99ce
movl $0x16, %edx
movq %r12, %rdi
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2120
callq 0x20a0
jmp 0x87bf
movq %rax, %r14
movq 0x18(%rsp), %rdi
cmpq %rbx, %rdi
je 0x87d9
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r14, %rdi
callq 0x22a0