def _norm_slice(sl, start, stop):
    """Return a slice normalized to an farray start index."""
    length = stop - start
    if sl.start is None:
        normstart = 0
    elif sl.start < 0:
        if sl.start < -length:
            normstart = 0
        else:
            normstart = sl.start + length
    elif sl.start > stop:
        normstart = length
    else:
        normstart = sl.start - start
    if sl.stop is None:
        normstop = length
    elif sl.stop < 0:
        if sl.stop < -length:
            normstop = 0
        else:
            normstop = sl.stop + length
    elif sl.stop > stop:
        normstop = length
    else:
        normstop = sl.stop - start
    if normstop < normstart:
        normstop = normstart
    return slice(normstart, normstop)
