// File: /workspace/github_cpp_makefile_star2_O1/permui[P]CastleAdventure/src/command.cpp
// Function: EncounterMonster(Player&, Grid&)
void EncounterMonster(Player &player, Grid &grid) {
	cout << "Encounter Monster!" << endl;
	cout << "A shield (" << shield_price << " BTC) can defend against one time of monster attact, but cannot kill the monster." << endl;
	cout << "A sword (" << sword_price << " BTC) can kill the monster." << endl;
	cout << "Commands: use_shield use_sword give_up" << endl;
	while (true) {
		string com = GetA<string>();
		if (com == "use_shield") {
			if (player.shield > 0) {
				--player.shield;
				cout << "You defend the monster!" << endl;
				break;
			}
			cout << "not enough shield, choose an alternative" << endl;
		} else if (com == "use_sword") {
			if (player.sword > 0) {
				--player.sword;
				grid.info.t = GT::None;
				cout << "You kill the monster!" << endl;
				break;
			}
			cout << "not enogh sword, choose an alternative" << endl;
		} else if (com == "give_up") {
			player.pos = FAIL_POS;
			break;
		} else {
			cout << "given command not available, see the command list" << endl;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, (%rsp)
movq %rdi, %r14
movq 0x53a3(%rip), %r15      # 0xdfd0
leaq 0x1de3(%rip), %rsi      # 0xaa17
movl $0x12, %edx
movq %r15, %rdi
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x1dbb(%rip), %rsi      # 0xaa2a
movl $0xa, %edx
movq %r15, %rdi
callq 0x21e0
movq %r15, %rdi
movl $0xa, %esi
callq 0x2280
movq %rax, %rbx
leaq 0x1da2(%rip), %rsi      # 0xaa35
movl $0x51, %edx
movq %rax, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x1db9(%rip), %rsi      # 0xaa87
movl $0x9, %edx
movq %r15, %rdi
callq 0x21e0
movq %r15, %rdi
movl $0xf, %esi
callq 0x2280
movq %rax, %rbx
leaq 0x1d9f(%rip), %rsi      # 0xaa91
movl $0x1b, %edx
movq %rax, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x1d80(%rip), %rsi      # 0xaaad
movl $0x26, %edx
movq %r15, %rdi
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x18(%rsp), %rbx
leaq 0x8(%rsp), %r12
leaq 0x1d62(%rip), %r13      # 0xaad4
movq %r12, %rdi
callq 0x8fee
movq %r12, %rdi
movq %r13, %rsi
callq 0x2080
testl %eax, %eax
je 0x8dce
movq %r12, %rdi
leaq 0x1d8d(%rip), %rsi      # 0xab20
callq 0x2080
testl %eax, %eax
je 0x8dea
movq %r12, %rdi
leaq 0x1d26(%rip), %rsi      # 0xaacc
callq 0x2080
movl $0x31, %edx
leaq 0x1c2e(%rip), %rsi      # 0xa9e5
testl %eax, %eax
jne 0x8e5c
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, (%r14)
jmp 0x8e3e
movl 0x8(%r14), %eax
testl %eax, %eax
jle 0x8e42
decl %eax
movl %eax, 0x8(%r14)
movl $0x17, %edx
leaq 0x1cf7(%rip), %rsi      # 0xaadf
jmp 0x8e0f
movl 0xc(%r14), %eax
testl %eax, %eax
jle 0x8e50
decl %eax
movl %eax, 0xc(%r14)
movq (%rsp), %rax
movl $0x3, 0x8(%rax)
movl $0x15, %edx
leaq 0x1d1b(%rip), %rsi      # 0xab2a
movq %r15, %rdi
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
xorl %ebp, %ebp
jmp 0x8e8e
movl $0x28, %edx
leaq 0x1ca9(%rip), %rsi      # 0xaaf7
jmp 0x8e5c
movl $0x26, %edx
leaq 0x1ce4(%rip), %rsi      # 0xab40
movq %r15, %rdi
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movb $0x1, %bpl
movq %rax, %rdi
callq 0x2120
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x8ea5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
testb %bpl, %bpl
jne 0x8d72
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x8ed7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21c0
movq %r14, %rdi
callq 0x22a0