// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0xb8(%rsi), %rax
movq %rax, 0x80(%rsp)
movq 0xc0(%rsi), %rax
movq %rax, 0x88(%rsp)
testq %rax, %rax
je 0x15997
movq 0x10637(%rip), %rcx     # 0x25fc0
cmpb $0x0, (%rcx)
je 0x15993
incl 0x8(%rax)
jmp 0x15997
lock
incl 0x8(%rax)
leaq 0xc0(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rdx), %rsi
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0x7954
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
movq %r14, %rsi
callq 0xebb4
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0x159f4
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x5200
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x15a06
callq 0x78e4
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x7438(%rip), %rdx      # 0x1ce4f
leaq 0x20(%rsp), %rdi
movq %rdx, %rsi
callq 0x7a9c
movq 0x60(%rsp), %rsi
testq %rsi, %rsi
je 0x15a80
movq %rsp, %rdi
callq 0x1ae8e
movq (%rsp), %r15
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15a49
callq 0x78e4
testq %r15, %r15
je 0x15aa2
movq 0xb8(%r14), %rsi
movq %rsp, %rdi
callq 0x1ae4e
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x15ac4
leaq 0xfa5b(%rip), %rsi      # 0x254c8
leaq 0x1002c(%rip), %rdx     # 0x25aa0
xorl %ecx, %ecx
callq 0x5240
movq %rax, %r12
jmp 0x15ac7
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x742c(%rip), %rsi      # 0x1ceba
leaq 0x743c(%rip), %rdx      # 0x1ced1
movq %rbx, %rdi
callq 0x7a9c
jmp 0x15dbf
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x742c(%rip), %rcx      # 0x1cede
movl $0x12, %r8d
xorl %esi, %esi
callq 0x52f0
jmp 0x15d7c
xorl %r12d, %r12d
testq %r12, %r12
je 0x15ae8
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x15af5
movq 0x104e3(%rip), %rax     # 0x25fc0
cmpb $0x0, (%rax)
je 0x15af0
incl 0x8(%r15)
jmp 0x15af5
xorl %r15d, %r15d
xorl %r12d, %r12d
jmp 0x15af5
lock
incl 0x8(%r15)
movq 0x60(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1ae8e
movq (%r12), %rax
leaq 0xa0(%rsp), %rsi
movq %r12, %rdi
callq *0x48(%rax)
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x15b2b
callq 0x78e4
testq %r15, %r15
je 0x15b38
movq %r15, %rdi
callq 0x78e4
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15b47
callq 0x78e4
movq 0xc8(%r14), %r12
movq 0xd0(%r14), %r13
movq 0x60(%rsp), %r15
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x1ae8e
movq 0x40(%rsp), %rsi
movq %rsp, %rdi
callq 0x1a2d8
movq %rsp, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x1679d
movq %rax, %r12
movq 0xd0(%r14), %rbp
leaq 0x10(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x15ba7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5200
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x15bb6
callq 0x78e4
cmpq %rbp, %r12
jne 0x15c09
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x1ae8e
movq 0x40(%rsp), %rsi
movq %rsp, %rdi
callq 0x1a2d8
leaq 0xc8(%r14), %rdi
movq %rsp, %rsi
callq 0x1618e
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x15bfa
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5200
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x15c09
callq 0x78e4
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0x1ae8e
movq 0x90(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x1a2d8
leaq 0x72a0(%rip), %rsi      # 0x1ced2
leaq 0x40(%rsp), %rdi
callq 0x53d0
movq %r13, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15c5d
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x15c65
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rsp, %r12
movq %rdx, 0x8(%r12)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x5280
movq (%r12), %rdi
cmpq %r13, %rdi
je 0x15ca3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5200
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0x30(%rsp), %r12
je 0x15cc3
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5200
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x15cd5
callq 0x78e4
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %r15, %rdi
callq 0x1aeba
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x15cfd
callq 0x78e4
movq 0xb8(%r14), %rsi
movq %r15, 0x70(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x78(%rsp)
testq %rax, %rax
je 0x15d2d
movq 0x102a1(%rip), %rcx     # 0x25fc0
cmpb $0x0, (%rcx)
je 0x15d29
incl 0x8(%rax)
jmp 0x15d2d
lock
incl 0x8(%rax)
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1af20
movaps (%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
movq 0xc0(%r14), %rdi
movups %xmm0, 0xb8(%r14)
testq %rdi, %rdi
je 0x15d5e
callq 0x78e4
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15d6d
callq 0x78e4
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x15d7c
callq 0x78e4
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x20(%rsp), %rcx
cmpq %r12, %rcx
je 0x15d9b
movq %rcx, (%rbx)
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x15da3
movups (%r12), %xmm0
movups %xmm0, (%rax)
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rbx)
movq %r12, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x15dd6
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5200
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x15de5
callq 0x78e4
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
jne 0x15e79
jmp 0x15e8b
jmp 0x15e88
jmp 0x15ece
jmp 0x15ece
jmp 0x15ece
movq %rax, %rbx
movq 0x78(%rsp), %rdi
jmp 0x15ec0
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
jmp 0x15ec0
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15e5c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5200
jmp 0x15e5c
movq %rax, %rbx
movq 0x98(%rsp), %rdi
jmp 0x15ec0
jmp 0x15ece
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15e8b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5200
jmp 0x15e8b
movq %rax, %rbx
movq 0x48(%rsp), %rdi
jmp 0x15ec0
jmp 0x15ece
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x15eae
callq 0x78e4
jmp 0x15eae
movq %rax, %rbx
testq %r15, %r15
je 0x15ebb
movq %r15, %rdi
callq 0x78e4
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15ed1
callq 0x78e4
jmp 0x15ed1
jmp 0x15ece
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x15ef2
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5200
jmp 0x15ef2
movq %rax, %rbx
movq 0x68(%rsp), %rdi
jmp 0x15f26
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f1e
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x5200
jmp 0x15f1e
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x15f30
callq 0x78e4
movq %rbx, %rdi
callq 0x5390