// File: permui[P]CastleAdventure/src/main.cpp
// Function: main
int main(int args, char *argv[]) {
	std::map<Position, Grid> mp = GenMap();
	Player player{{1, 0}, 0, 0, args > 1 ? atoi(argv[1]) : 0};
	std::map<Position, std::string> note {
		{SUCC_POS, "success"}, {FAIL_POS, "fail"}, {QUIT_POS, "quit"}
	};
	while (true) {
		bool go_out = false;
		for (const auto &pr: note) if (player.pos == pr.first) {
			std::cout << pr.second << std::endl;
			go_out = true;
			break;
		}
		if (go_out) break;
		std::map<Position, Grid>::iterator it = mp.find(player.pos);
		assert(it != mp.end());
		Grid &gd = it->second;
		std::cout << "---------------" << std::endl;
		player.show_state(gd);
		std::cout << "---------------" << std::endl;
		if (!gd.desc.empty()) {
			std::cout << gd.desc << std::endl;
			std::cout << "---------------" << std::endl;
		}
		Command(player, gd, mp);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xc7a0
leaq -0x60(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x3b70
jmp 0x3664
cmpl $0x1, -0x8(%rbp)
jle 0x367f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3320
movl %eax, -0x174(%rbp)
jmp 0x3689
xorl %eax, %eax
movl %eax, -0x174(%rbp)
jmp 0x3689
movl -0x174(%rbp), %r8d
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x7840
jmp 0x36a3
leaq -0x128(%rbp), %rdi
movq %rdi, -0x130(%rbp)
leaq 0xe94c(%rip), %rsi      # 0x12004
leaq 0xe95d(%rip), %rdx      # 0x1201c
callq 0x3b90
jmp 0x36c6
leaq -0x100(%rbp), %rdi
movq %rdi, -0x130(%rbp)
leaq 0xe931(%rip), %rsi      # 0x1200c
leaq 0xe942(%rip), %rdx      # 0x12024
callq 0x3c10
jmp 0x36e9
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x130(%rbp)
leaq 0xe916(%rip), %rsi      # 0x12014
leaq 0xe924(%rip), %rdx      # 0x12029
callq 0x3c10
jmp 0x370c
leaq -0x128(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq $0x3, -0xa8(%rbp)
leaq -0x132(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x3cb0
movq -0x180(%rbp), %r8
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
leaq -0x131(%rbp), %rcx
callq 0x3cd0
jmp 0x3762
leaq -0x132(%rbp), %rdi
callq 0x3da0
leaq -0x128(%rbp), %rax
movq %rax, -0x190(%rbp)
addq $0x78, %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x198(%rbp)
callq 0x3c90
movq -0x190(%rbp), %rcx
movq -0x198(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x188(%rbp)
jne 0x3787
jmp 0x37ba
jmp 0x37bc
movb $0x0, -0x133(%rbp)
leaq -0xa0(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rdi
callq 0x3dc0
movq %rax, -0x148(%rbp)
movq -0x140(%rbp), %rdi
callq 0x3df0
movq %rax, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x3e20
testb $0x1, %al
jne 0x3813
jmp 0x3992
leaq -0x148(%rbp), %rdi
callq 0x3e50
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x7800
movb %al, -0x199(%rbp)
jmp 0x383e
movb -0x199(%rbp), %al
testb $0x1, %al
jne 0x384d
jmp 0x397f
movq -0x158(%rbp), %rsi
addq $0x8, %rsi
movq 0x16771(%rip), %rdi     # 0x19fd0
callq 0x31f0
movq %rax, -0x1a8(%rbp)
jmp 0x386d
movq -0x1a8(%rbp), %rdi
movq 0x16745(%rip), %rsi     # 0x19fc0
callq 0x3250
jmp 0x3882
movb $0x1, -0x133(%rbp)
jmp 0x3992
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x3b58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
movq -0x130(%rbp), %rax
leaq -0x128(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x1b0(%rbp)
je 0x38f6
movq -0x1b0(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x3c90
movq -0x1b8(%rbp), %rax
leaq -0x128(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x1b0(%rbp)
jne 0x38c5
jmp 0x3b58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x132(%rbp), %rdi
callq 0x3da0
leaq -0x128(%rbp), %rax
movq %rax, -0x1c8(%rbp)
addq $0x78, %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x3c90
movq -0x1c8(%rbp), %rcx
movq -0x1d0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x1c0(%rbp)
jne 0x392c
jmp 0x3b58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3f50
jmp 0x3b58
jmp 0x3981
leaq -0x148(%rbp), %rdi
callq 0x3e70
jmp 0x37f7
testb $0x1, -0x133(%rbp)
je 0x39a0
jmp 0x3b30
leaq -0x40(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3ea0
movq %rax, -0x1d8(%rbp)
jmp 0x39b6
movq -0x1d8(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3f00
movq %rax, -0x168(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x3ed0
testb $0x1, %al
jne 0x39ed
jmp 0x39ef
jmp 0x3a0e
leaq 0xe638(%rip), %rdi      # 0x1202e
leaq 0xe640(%rip), %rsi      # 0x1203d
movl $0x18, %edx
leaq 0xe641(%rip), %rcx      # 0x1204a
callq 0x3150
leaq -0x160(%rbp), %rdi
callq 0x3f30
addq $0x8, %rax
movq %rax, -0x170(%rbp)
movq 0x165a4(%rip), %rdi     # 0x19fd0
leaq 0xe62e(%rip), %rsi      # 0x12061
callq 0x3210
movq %rax, -0x1e0(%rbp)
jmp 0x3a41
movq -0x1e0(%rbp), %rdi
movq 0x16571(%rip), %rsi     # 0x19fc0
callq 0x3250
jmp 0x3a56
movq -0x170(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x7880
jmp 0x3a68
movq 0x16561(%rip), %rdi     # 0x19fd0
leaq 0xe5eb(%rip), %rsi      # 0x12061
callq 0x3210
movq %rax, -0x1e8(%rbp)
jmp 0x3a84
movq -0x1e8(%rbp), %rdi
movq 0x1652e(%rip), %rsi     # 0x19fc0
callq 0x3250
jmp 0x3a99
movq -0x170(%rbp), %rdi
addq $0x30, %rdi
callq 0x3350
testb $0x1, %al
jne 0x3b15
movq -0x170(%rbp), %rsi
addq $0x30, %rsi
movq 0x16511(%rip), %rdi     # 0x19fd0
callq 0x31f0
movq %rax, -0x1f0(%rbp)
jmp 0x3acd
movq -0x1f0(%rbp), %rdi
movq 0x164e5(%rip), %rsi     # 0x19fc0
callq 0x3250
jmp 0x3ae2
movq 0x164e7(%rip), %rdi     # 0x19fd0
leaq 0xe571(%rip), %rsi      # 0x12061
callq 0x3210
movq %rax, -0x1f8(%rbp)
jmp 0x3afe
movq -0x1f8(%rbp), %rdi
movq 0x164b4(%rip), %rsi     # 0x19fc0
callq 0x3250
jmp 0x3b13
jmp 0x3b15
movq -0x170(%rbp), %rsi
leaq -0x58(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x10e20
jmp 0x3b2b
jmp 0x37ba
movl $0x0, -0x4(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3f50
leaq -0x40(%rbp), %rdi
callq 0x3f70
movl -0x4(%rbp), %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x3f70
movq -0x68(%rbp), %rdi
callq 0x33a0
nopw (%rax,%rax)