#include #include int bt_skip_func(const __uint32_t len_limit, const __uint8_t *cur, int delta, __uint32_t len) { const __uint8_t *pb = cur - delta; const __uint8_t *orig_pb = pb; const __uint8_t *last_pb = pb + len_limit; pb += len; cur += len + 1; while (++pb != last_pb) { if (*pb != *cur) break; cur++; /* 2nd iteration */ if (++pb == last_pb) break; if (*pb != *cur) break; cur++; /* 3rd iteration */ if (++pb == last_pb) break; if (*pb != *cur) break; cur++; /* 4th iteration */ if (++pb == last_pb) break; if (*pb != *cur) break; cur++; /* 4th iteration */ } return pb - orig_pb; } int main (int argc, char *argv[]) { char *text_input = "ttttttttttttttttthis is some text that should be longer"; int len_limit = strlen (text_input); int pos = 0; int cur_match = 0; int depth = 0; int result = bt_skip_func(len_limit, text_input + 3, 3, 1); }