import itertools


def strip_qualifiers(typename):
    """Remove const/volatile qualifiers, references, and pointers of a type"""
    qps = []

    while True:
        typename = typename.rstrip()
        qual = next(itertools.dropwhile(lambda q: not typename.endswith(q), ('&', '*', 'const', 'volatile', '')))
        if not qual: break
        typename = typename[:-len(qual)]
        qps.append(qual)

    while True:
        typename = typename.lstrip()
        qual = next(itertools.dropwhile(lambda q: not typename.startswith(q), ('const', 'volatile', '')))
        if not qual: break
        typename = typename[len(qual):]
        qps.append(qual)

    return typename, qps[::-1]