def METHOD_NAME(indata, decompressed_size, _overlay=False):
    """Decompress LZSS-compressed bytes. Returns a bytearray."""
    data = bytearray()
    it = iter(indata)
    if _overlay:
        disp_extra = 3
    else:
        disp_extra = 1
    def writebyte(b):
        data.append(b)
    def readbyte():
        return next(it)
    def readshort():
        # big-endian
        a = next(it)
        b = next(it)
        return (a << 8) | b
    def copybyte():
        data.append(next(it))
    while len(data) < decompressed_size:
        b = readbyte()
        flags = bits(b)
        for flag in flags:
            if flag == 0:
                copybyte()
            elif flag == 1:
                sh = readshort()
                count = (sh >> 0xc) + 3
                disp = (sh & 0xfff) + disp_extra
                for _ in range(count):
                    writebyte(data[-disp])
            else:
                raise ValueError(flag)
            if decompressed_size <= len(data):
                break
    if len(data) != decompressed_size:
        raise DecompressionError("decompressed size does not match the expected size")
    return data