KMP implementation for amuzi lookup