#include <cstddef>
#include <cstdint>
#include <fstream>
#include <sstream>
#include <thread>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);

int main(int argc, char **argv) {
  auto doTest = [&]() {
    for (int i = 1; i < argc; ++i) {
      std::ifstream t(argv[i], std::ios::binary);
      std::stringstream buffer;
      buffer << t.rdbuf();
      auto str = buffer.str();
      LLVMFuzzerTestOneInput((const uint8_t *)str.data(), str.size());
    }
  };
#ifdef THREAD_TEST
  std::thread thread2{doTest};
#endif
  doTest();
#ifdef THREAD_TEST
  thread2.join();
#endif
}
