Rewrite, simplify and rename to exec-longest-prefix