1c5f01b2fSopenharmony_ci// This file is distributed under the University of Illinois Open Source
2c5f01b2fSopenharmony_ci// License. See LICENSE.TXT for details.
3c5f01b2fSopenharmony_ci
4c5f01b2fSopenharmony_ci
5c5f01b2fSopenharmony_ci#include <cstring>
6c5f01b2fSopenharmony_ci#include <cstdint>
7c5f01b2fSopenharmony_ci#include <cstdio>
8c5f01b2fSopenharmony_ci#include <cstdlib>
9c5f01b2fSopenharmony_ci
10c5f01b2fSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
11c5f01b2fSopenharmony_ci  int Matches = 0;
12c5f01b2fSopenharmony_ci  for (size_t i = 0; i + 2 < Size; i += 3) {
13c5f01b2fSopenharmony_ci    const char *Pat = i % 2 ? "foo" : "bar";
14c5f01b2fSopenharmony_ci    if (!memcmp(Data + i, Pat, 3))
15c5f01b2fSopenharmony_ci      Matches++;
16c5f01b2fSopenharmony_ci  }
17c5f01b2fSopenharmony_ci  if (Matches > 20) {
18c5f01b2fSopenharmony_ci    fprintf(stderr, "BINGO!\n");
19c5f01b2fSopenharmony_ci    exit(1);
20c5f01b2fSopenharmony_ci  }
21c5f01b2fSopenharmony_ci  return 0;
22c5f01b2fSopenharmony_ci}
23