def _ll_subvoxel_overlap(xs, x1, x2):
    """For an interval [x1, x2], return the index of the lower limit of the
    overlapping subvoxels whose borders are defined by the elements of xs."""
    xmin = min(x1, x2)
    if xmin <= xs[0]:
        return 0
    elif xmin >= xs[-1]:
        ll = len(xs) - 1
        return ll
    else:
        for i, x in enumerate(xs):
            if x > xmin:
                ll = i - 1
                return ll
        ll = 0
        return ll