fn reverse(
        needle: &[u8],
        period_lower_bound: usize,
        critical_pos: usize,
    ) -> Shift {
        let large = cmp::max(critical_pos, needle.len() - critical_pos);
        if (needle.len() - critical_pos) * 2 >= needle.len() {
            return Shift::Large { shift: large };
        }

        let (v, u) = needle.split_at(critical_pos);
        if !is_prefix(&v[v.len() - period_lower_bound..], u) {
            return Shift::Large { shift: large };
        }
        Shift::Small { period: period_lower_bound }
    }
Compute the shift for a given needle in the reverse direction.

This requires a lower bound on the period and a critical position.
These can be computed by extracting both the minimal and maximal
lexicographic suffixes, and choosing the left-most starting position.
The lower bound on the period is then the period of the chosen suffix.
src/arch/all/twoway.rs