def binrepr(integer):
    """
    Convert an integer to a string representation of bits:

    >>> binrepr(1)
    '0b1'
    >>> binrepr(-(16384 | 1))
    '-(0b01000000<<8 | 0b00000001)'
    """
    if not integer:
        return '0b0'
    if integer < 0:
        return '-' + binrepr(-integer)
    out = []
    i = 0
    while integer > 0:
        i += 1
        out.append('01'[integer & 1])
        integer >>= 1
        if (i % 8) == 0:
            out.append('<<%d | 0b' % (i,))
    if out[-1].startswith('<'):
        out.pop()
    if i > 8:
        return '(0b%s)' % (''.join(reversed(out)),)
    return '0b%s' % (''.join(reversed(out)),)