// File: kaiming[P]Chamber-Crawler-3k/Board/board.cc
// Function: Board::usePotion(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string Board::usePotion(std::string direction) {
    std::shared_ptr<WalkableTile> target = validDest(player, direction);
    std::string message = "";

    // Check if valid destination
    if (target == nullptr) {
        return "Invalid Potion Target. ";
    }

    // Check if destination is occupied by a potion
    if (target->getPotion() != nullptr) {
        // Use potion
        std::dynamic_pointer_cast<Player>(player->getOccupant())->usePotion(target->getPotion());

        // Add potion to memory, if new
        bool usedBefore = false;

        if (std::find(potionsUsed.begin(), potionsUsed.end(), target->getPotion()->getType()) != potionsUsed.end()) {
            usedBefore = true;
        }

        if (!usedBefore) {
            potionsUsed.emplace_back(target->getPotion()->getType());
        }

        message = target->getPotion()->getType() + " was Used. ";

        // Remove potion from board
        target->setPotion(nullptr);
        player = player->move(target);
    } else {
        message = "No Potion to Use. ";
    }
    
    return message;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdx, -0x1e0(%rbp)
movq %rdi, -0x1f8(%rbp)
movq %rdi, %rax
movq %rax, -0x1f0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x1e8(%rbp)
addq $0xb8, %rsi
leaq -0x38(%rbp), %rdi
callq 0xd550
movq -0x1e0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x6130
jmp 0x2d5ac
movq -0x1e8(%rbp), %rsi
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x250e0
jmp 0x2d5c6
leaq -0x58(%rbp), %rdi
callq 0x61c0
leaq -0x38(%rbp), %rdi
callq 0x99e0
leaq -0x89(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x6550
movq -0x200(%rbp), %rdx
leaq 0x1083e(%rip), %rsi     # 0x3de37
leaq -0x88(%rbp), %rdi
callq 0x8a00
jmp 0x2d607
leaq -0x89(%rbp), %rdi
callq 0x6340
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12ac0
testb $0x1, %al
jne 0x2d629
jmp 0x2d6de
leaq -0x8a(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x6550
movq -0x1f8(%rbp), %rdi
movq -0x208(%rbp), %rdx
leaq 0x10851(%rip), %rsi     # 0x3dea2
callq 0x8a00
jmp 0x2d658
leaq -0x8a(%rbp), %rdi
callq 0x6340
movl $0x1, -0x90(%rbp)
jmp 0x2dc1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2d696
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x61c0
leaq -0x38(%rbp), %rdi
callq 0x99e0
jmp 0x2dc59
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x89(%rbp), %rdi
callq 0x6340
jmp 0x2dc50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x8a(%rbp), %rdi
callq 0x6340
jmp 0x2dc44
leaq -0x28(%rbp), %rdi
callq 0x2e040
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x3bfc0
jmp 0x2d6f8
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2e4d0
movb %al, -0x209(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x11f80
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x2d729
jmp 0x2dbeb
movq -0x1e8(%rbp), %rdi
addq $0xb8, %rdi
callq 0x2e040
movq %rax, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x3bf60
jmp 0x2d74d
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x220(%rbp)
leaq -0xc0(%rbp), %rsi
callq 0x2e600
movq -0x220(%rbp), %rdi
callq 0x2e020
movq %rax, -0x218(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2e040
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x3bfc0
jmp 0x2d794
movq -0x218(%rbp), %rdi
movq (%rdi), %rax
movq 0x48(%rax), %rax
leaq -0xd0(%rbp), %rsi
callq *%rax
jmp 0x2d7ad
leaq -0xd0(%rbp), %rdi
callq 0x11f80
leaq -0xb0(%rbp), %rdi
callq 0x9960
leaq -0xc0(%rbp), %rdi
callq 0x11fa0
movq -0x1e8(%rbp), %rdi
movb $0x0, -0xd1(%rbp)
addq $0xc8, %rdi
movq %rdi, -0x228(%rbp)
callq 0x2ea90
movq -0x228(%rbp), %rdi
movq %rax, -0xe8(%rbp)
callq 0x2eac0
movq %rax, -0xf0(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2e040
movq %rax, %rsi
leaq -0x120(%rbp), %rdi
callq 0x3bfc0
jmp 0x2d826
leaq -0x120(%rbp), %rdi
callq 0x2e9e0
movq %rax, %rsi
leaq -0x110(%rbp), %rdi
callq 0x3ae10
jmp 0x2d843
movq -0xe8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
leaq -0x110(%rbp), %rdx
callq 0x2ea40
movq %rax, -0x230(%rbp)
jmp 0x2d866
movq -0x1e8(%rbp), %rdi
movq -0x230(%rbp), %rax
movq %rax, -0xe0(%rbp)
addq $0xc8, %rdi
callq 0x2eac0
movq %rax, -0x128(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x2ea00
movb %al, -0x231(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x61c0
leaq -0x120(%rbp), %rdi
callq 0x11f80
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0x2d8ce
jmp 0x2d965
movb $0x1, -0xd1(%rbp)
jmp 0x2d965
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2dc44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2d911
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x11f80
leaq -0xb0(%rbp), %rdi
callq 0x9960
leaq -0xc0(%rbp), %rdi
callq 0x11fa0
jmp 0x2dc44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2d954
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x61c0
leaq -0x120(%rbp), %rdi
callq 0x11f80
jmp 0x2dc44
testb $0x1, -0xd1(%rbp)
jne 0x2da23
movq -0x1e8(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x240(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2e040
movq %rax, %rsi
leaq -0x158(%rbp), %rdi
callq 0x3bfc0
jmp 0x2d9a0
leaq -0x158(%rbp), %rdi
callq 0x2e9e0
movq %rax, %rsi
leaq -0x148(%rbp), %rdi
callq 0x3ae10
jmp 0x2d9bd
movq -0x240(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x2ef50
jmp 0x2d9d2
leaq -0x148(%rbp), %rdi
callq 0x61c0
leaq -0x158(%rbp), %rdi
callq 0x11f80
jmp 0x2da23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2da12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x61c0
leaq -0x158(%rbp), %rdi
callq 0x11f80
jmp 0x2dc44
leaq -0x28(%rbp), %rdi
callq 0x2e040
movq %rax, %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x3bfc0
jmp 0x2da3d
leaq -0x1a8(%rbp), %rdi
callq 0x2e9e0
movq %rax, %rsi
leaq -0x198(%rbp), %rdi
callq 0x3ae10
jmp 0x2da5a
leaq 0x10459(%rip), %rdx     # 0x3deba
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x2e400
jmp 0x2da76
leaq -0x88(%rbp), %rdi
leaq -0x178(%rbp), %rsi
movq %rsi, -0x258(%rbp)
callq 0x63c0
movq -0x258(%rbp), %rdi
callq 0x61c0
leaq -0x198(%rbp), %rdi
callq 0x61c0
leaq -0x1a8(%rbp), %rdi
callq 0x11f80
leaq -0x28(%rbp), %rdi
callq 0x2e040
movq %rax, -0x250(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x11f20
movq -0x250(%rbp), %rdi
movq -0x248(%rbp), %rsi
callq 0x3bff0
jmp 0x2daf0
leaq -0x1b8(%rbp), %rdi
callq 0x11f80
movq -0x1e8(%rbp), %rdi
addq $0xb8, %rdi
callq 0x2e040
movq %rax, -0x268(%rbp)
leaq -0x1d8(%rbp), %rdi
movq %rdi, -0x260(%rbp)
leaq -0x28(%rbp), %rsi
callq 0xd550
movq -0x268(%rbp), %rsi
movq -0x260(%rbp), %rdx
leaq -0x1c8(%rbp), %rdi
callq 0x3c100
jmp 0x2db49
movq -0x1e8(%rbp), %rdi
addq $0xb8, %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x2e8f0
leaq -0x1c8(%rbp), %rdi
callq 0x99e0
leaq -0x1d8(%rbp), %rdi
callq 0x99e0
jmp 0x2dc02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2dba6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x61c0
leaq -0x1a8(%rbp), %rdi
callq 0x11f80
jmp 0x2dc44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x11f80
jmp 0x2dc44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x99e0
jmp 0x2dc44
leaq 0x102d4(%rip), %rsi     # 0x3dec6
leaq -0x88(%rbp), %rdi
callq 0x6420
jmp 0x2dc00
jmp 0x2dc02
movq -0x1f8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x61a0
movl $0x1, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x61c0
leaq -0x28(%rbp), %rdi
callq 0x99e0
movq -0x1f0(%rbp), %rax
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
leaq -0x88(%rbp), %rdi
callq 0x61c0
leaq -0x28(%rbp), %rdi
callq 0x99e0
movq -0x60(%rbp), %rdi
callq 0x6540
nopw %cs:(%rax,%rax)
nopl (%rax)