// File: /workspace/github_cpp_makefile_star2_O3/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 0x1557d
movq 0xfa51(%rip), %rcx      # 0x24fc0
cmpb $0x0, (%rcx)
je 0x15579
incl 0x8(%rax)
jmp 0x1557d
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 0x7898
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
movq %r14, %rsi
callq 0xe860
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0x155da
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x155ec
callq 0x7828
leaq 0x50(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x6893(%rip), %rdx      # 0x1be8f
leaq 0x40(%rsp), %rdi
movq %rdx, %rsi
callq 0x79f2
movq 0x60(%rsp), %r15
testq %r15, %r15
je 0x156a3
movq %rsp, %rdi
movq %r15, %rsi
callq 0x1a9ce
movq (%rsp), %r12
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15635
callq 0x7828
testq %r12, %r12
je 0x156e0
movq 0xb8(%r14), %rsi
movq %rsp, %rdi
callq 0x1a98e
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x15702
leaq 0xee67(%rip), %rsi      # 0x244c8
leaq 0xf438(%rip), %rdx      # 0x24aa0
xorl %r12d, %r12d
xorl %ecx, %ecx
callq 0x5230
testq %rax, %rax
je 0x15705
movq %rax, %r13
movq 0x8(%rsp), %r12
testq %r12, %r12
je 0x159dc
movq 0xf92d(%rip), %rax      # 0x24fc0
cmpb $0x0, (%rax)
je 0x159e4
incl 0x8(%r12)
jmp 0x15708
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6849(%rip), %rsi      # 0x1befa
leaq 0x6859(%rip), %rdx      # 0x1bf11
movq %rbx, %rdi
callq 0x79f2
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x159b8
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x159b8
leaq 0x40(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x682e(%rip), %rcx      # 0x1bf1e
movl $0x12, %r8d
xorl %esi, %esi
callq 0x52e0
jmp 0x15988
xorl %r12d, %r12d
xorl %r13d, %r13d
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
callq 0x1a9ce
movq (%r13), %rax
leaq 0xa0(%rsp), %rsi
movq %r13, %rdi
callq *0x48(%rax)
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x1573c
callq 0x7828
testq %r12, %r12
je 0x15749
movq %r12, %rdi
callq 0x7828
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15758
callq 0x7828
movq 0xc8(%r14), %r12
movq 0xd0(%r14), %r13
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x1a9ce
movq 0x20(%rsp), %rsi
movq %rsp, %rdi
callq 0x19e04
movq %rsp, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x16379
movq %rax, %r12
movq 0xd0(%r14), %rbp
leaq 0x10(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x157b3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x157c2
callq 0x7828
cmpq %rbp, %r12
jne 0x15815
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x1a9ce
movq 0x20(%rsp), %rsi
movq %rsp, %rdi
callq 0x19e04
leaq 0xc8(%r14), %rdi
movq %rsp, %rsi
callq 0x15d80
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x15806
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x15815
callq 0x7828
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0x1a9ce
movq 0x90(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x19e04
leaq 0x66d4(%rip), %rsi      # 0x1bf12
leaq 0x20(%rsp), %rdi
callq 0x53c0
movq %r13, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x15869
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x15871
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 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x5270
movq (%r12), %rdi
cmpq %r13, %rdi
je 0x158af
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x51f0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
leaq 0x50(%rsp), %r13
je 0x158cf
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x158e1
callq 0x7828
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %r15, %rdi
callq 0x1a9fa
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x15909
callq 0x7828
movq 0xb8(%r14), %rsi
movq %r15, 0x70(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x78(%rsp)
testq %rax, %rax
je 0x15939
movq 0xf695(%rip), %rcx      # 0x24fc0
cmpb $0x0, (%rcx)
je 0x15935
incl 0x8(%rax)
jmp 0x15939
lock
incl 0x8(%rax)
movq %rsp, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1aa60
movaps (%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
movq 0xc0(%r14), %rdi
movups %xmm0, 0xb8(%r14)
testq %rdi, %rdi
je 0x15979
callq 0x7828
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15979
callq 0x7828
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x15988
callq 0x7828
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x40(%rsp), %rcx
cmpq %r13, %rcx
je 0x159a7
movq %rcx, (%rbx)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x159af
movups (%r13), %xmm0
movups %xmm0, (%rax)
movq 0x48(%rsp), %rax
movq %rax, 0x8(%rbx)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x159c7
callq 0x7828
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
jmp 0x15708
lock
incl 0x8(%r12)
movq 0x60(%rsp), %r15
jmp 0x15708
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
jne 0x15a73
jmp 0x15a85
jmp 0x15a82
jmp 0x15ac8
jmp 0x15ac8
jmp 0x15ac8
movq %rax, %rbx
movq 0x78(%rsp), %rdi
jmp 0x15aba
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
jmp 0x15aba
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15a56
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x15a56
movq %rax, %rbx
movq 0x98(%rsp), %rdi
jmp 0x15aba
jmp 0x15ac8
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15a85
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x15a85
movq %rax, %rbx
movq 0x28(%rsp), %rdi
jmp 0x15aba
jmp 0x15ac8
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x15aa8
callq 0x7828
jmp 0x15aa8
movq %rax, %rbx
testq %r12, %r12
je 0x15ab5
movq %r12, %rdi
callq 0x7828
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x15acb
callq 0x7828
jmp 0x15acb
jmp 0x15ac8
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x15aec
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x15aec
movq %rax, %rbx
movq 0x68(%rsp), %rdi
jmp 0x15b20
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0x15b18
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x15b18
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x15b2a
callq 0x7828
movq %rbx, %rdi
callq 0x5380