1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2// See https://llvm.org/LICENSE.txt for license information.
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5// A fuzz target with lots of edges.
6#include <cstdint>
7#include <cstdlib>
8
9static inline void break_optimization(const void *arg) {
10 __asm__ __volatile__("" : : "r" (arg) : "memory");
11}
12
13#define A \
14 do { \
15 i++; \
16 c++; \
17 if (Data[(i + __LINE__) % Size] == (c % 256)) \
18 break_optimization(Data); \
19 else \
20 break_optimization(0); \
21 } while (0)
22
23// for (int i = 0, n = Data[(__LINE__ - 1) % Size] % 16; i < n; i++)
24
25#define B do{A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; A; }while(0)
26#define C do{B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; B; }while(0)
27#define D do{C; C; C; C; C; C; C; C; C; }while(0)
28
29volatile int sink;
30extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
31 if (!Size) return 0;
32 int c = 0;
33 int i = 0;
34 D;
35 return 0;
36}
37
38

source code of compiler-rt/test/fuzzer/LargeTest.cpp