fn libc_memchr(haystack: &[u8], needle: u8) -> Option<usize> {
    // SAFETY: This is safe to call since all pointers are valid.
    let p = unsafe {
        libc::memchr(
            haystack.as_ptr().cast(),
            needle as libc::c_int,
            haystack.len(),
        )
    };
    if p.is_null() {
        None
    } else {
        Some(p as usize - (haystack.as_ptr() as usize))
    }
}
A safe wrapper around libc's `memchr` function. In particular, this
converts memchr's pointer return to an index offset into `haystack`.
benchmarks/engines/libc/main.rs