1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11
10 
11 #include <algorithm>
12 #include <cstddef>
13 #include <cstdint>
14 #include <vector>
15 
16 #include "fuzz.h"
17 
LLVMFuzzerTestOneInput(const std::uint8_t * data,std::size_t size)18 extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) {
19     auto is_even = [](auto x) { return x % 2 == 0; };
20     std::vector<std::uint8_t> working(data, data + size);
21     auto iter = std::partition(working.begin(), working.end(), is_even);
22 
23     if (!std::all_of(working.begin(), iter, is_even))
24         return 1;
25     if (!std::none_of(iter,   working.end(), is_even))
26         return 2;
27     if (!fast_is_permutation(data, data + size, working.cbegin()))
28         return 99;
29     return 0;
30 }
31