<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find_all(s, sub, start=0, end=0, limit=-1, reverse=False):
 """ Find all indexes of sub in s. :param s: the string to search :param sub: the string to search for :param start: the index in s at which to begin the search (same as in ''.find) :param end: the index in s at which to stop searching (same as in ''.find) :param limit: the maximum number of matches to find :param reverse: if False search s forwards; otherwise search backwards :return: all occurrences of substring sub in string s """


    indexes = []

    if not bool(s and sub):
        return indexes

    lstr = len(s)
    if lstr <= start:
        return indexes

    lsub = len(sub)
    if lstr < lsub:
        return indexes

    if limit == 0:
        return indexes
    elif limit < 0:
        limit = lstr

    end = min(end, lstr) or lstr
    idx = s.rfind(sub, start, end) if reverse else s.find(sub, start, end)

    while idx != -1:
        indexes.append(idx)
        if reverse:
            idx = s.rfind(sub, start, idx - lstr)
        else:
            idx = s.find(sub, idx + lsub, end)

        if len(indexes) >= limit:
            break

    return indexes