// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe0, %rsp
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xb8(%rsi), %r14
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x7500
leaq 0x98(%rsp), %r12
leaq 0xc0(%rsp), %rdi
movq %r13, %rsi
callq 0x52b0
leaq 0x20(%rsp), %rdi
leaq 0x90(%rsp), %rdx
leaq 0xc0(%rsp), %rcx
movq %r15, %rsi
callq 0xdb38
leaq 0xc0(%rsp), %rdi
callq 0x5100
leaq 0x98(%rsp), %rdi
callq 0x6c00
leaq 0x6eeb(%rip), %rsi      # 0x18e8f
leaq 0x50(%rsp), %rdi
movq %rsp, %rdx
callq 0x67bc
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0x121aa
movq %rsp, %rdi
callq 0x17440
leaq 0x8(%rsp), %rdi
movq -0x8(%rdi), %r12
callq 0x6c00
testq %r12, %r12
je 0x121be
movq (%r14), %rsi
leaq 0x30(%rsp), %rdi
callq 0x17424
movq %rsp, %r12
leaq 0x30(%rsp), %rsi
movq %r12, %rdi
callq 0x12494
movq (%r12), %r12
movq 0x20(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0x17440
movq (%r12), %rax
leaq 0x80(%rsp), %rsi
movq %r12, %rdi
callq *0x48(%rax)
leaq 0x88(%rsp), %rdi
callq 0x6c00
leaq 0x8(%rsp), %rdi
callq 0x6c00
leaq 0x38(%rsp), %rdi
callq 0x6c00
movq 0xc8(%r15), %r12
movq 0xd0(%r15), %r13
movq 0x20(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x17440
movq 0x30(%rsp), %rsi
movq %rsp, %rdi
callq 0x16bc0
movq %rsp, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x12fc0
movq %rax, %r12
movq 0xd0(%r15), %r13
movq %rsp, %rdi
callq 0x5100
leaq 0x38(%rsp), %rdi
callq 0x6c00
cmpq %r13, %r12
jne 0x120dd
movq 0x20(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x17440
movq 0x30(%rsp), %rsi
movq %rsp, %rdi
callq 0x16bc0
addq $0xc8, %r15
movq %rsp, %rsi
movq %r15, %rdi
callq 0x1269e
movq %rsp, %rdi
callq 0x5100
leaq 0x38(%rsp), %rdi
callq 0x6c00
movq 0x20(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x17440
movq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x16bc0
leaq 0x6e10(%rip), %rdx      # 0x18f12
movq %rsp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x123fc
leaq 0x50(%rsp), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0x5270
movq %r15, %rdi
callq 0x5100
leaq 0x30(%rsp), %rdi
callq 0x5100
leaq 0x78(%rsp), %rdi
callq 0x6c00
movq 0x20(%rsp), %rdi
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rsi
movaps %xmm0, (%rsi)
callq 0x17452
leaq 0xa8(%rsp), %rdi
callq 0x6c00
movq (%r14), %r15
leaq 0xb0(%rsp), %r12
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
callq 0x7500
movq %rsp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1748a
movq %rsp, %rsi
movq %r14, %rdi
callq 0x12f92
leaq 0x8(%rsp), %rdi
callq 0x6c00
leaq 0xb8(%rsp), %rdi
callq 0x6c00
jmp 0x121cf
leaq 0x6d49(%rip), %rsi      # 0x18efa
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x67bc
jmp 0x12211
leaq 0x6d59(%rip), %rsi      # 0x18f1e
leaq 0x50(%rsp), %rdi
callq 0x53d0
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
je 0x121f2
movq %rdx, (%rbx)
movq 0x60(%rsp), %rcx
movq %rcx, 0x10(%rbx)
jmp 0x121f8
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq 0x58(%rsp), %rcx
movq %rcx, 0x8(%rbx)
movq %rax, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x5100
leaq 0x28(%rsp), %rdi
callq 0x6c00
movq %rbx, %rax
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x12278
jmp 0x12285
jmp 0x122b9
jmp 0x122b9
jmp 0x122b9
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x122b0
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x122b0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x5100
jmp 0x1226f
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
jmp 0x122b0
jmp 0x122b9
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5100
jmp 0x122ab
movq %rax, %rbx
jmp 0x122ab
jmp 0x122b9
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x6c00
jmp 0x122a1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x6c00
leaq 0x38(%rsp), %rdi
callq 0x6c00
jmp 0x122bc
jmp 0x122b9
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5100
leaq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0x6c00
movq %rbx, %rdi
callq 0x5390
movq %rax, %rbx
jmp 0x122c6
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x5100
jmp 0x122cb
movq %rax, %rbx
jmp 0x122cb