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// abs(x) < 0 and y == Const puzzle.
6#include <cstddef>
7#include <cstdint>
8#include <cstdio>
9#include <cstdlib>
10#include <cstring>
11
12extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
13 if (Size < 8) return 0;
14 int x;
15 unsigned y;
16 memcpy(dest: &x, src: Data, n: sizeof(x));
17 memcpy(dest: &y, src: Data + sizeof(x), n: sizeof(y));
18 volatile int abs_x = abs(x: x);
19 if (abs_x < 0 && y == 0xbaddcafe) {
20 printf(format: "BINGO; Found the target, exiting; x = 0x%x y 0x%x\n", x, y);
21 fflush(stdout);
22 exit(status: 1);
23 }
24 return 0;
25}
26
27

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