Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / fuzzer / AbsNegAndConstantTest.cpp
bloba0eedc19ca4dc5035491425ccc2c3f02711e18ba
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
5 // abs(x) < 0 and y == Const puzzle.
6 #include <cstddef>
7 #include <cstdint>
8 #include <cstdio>
9 #include <cstdlib>
10 #include <cstring>
12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
13 if (Size < 8) return 0;
14 int x;
15 unsigned y;
16 memcpy(&x, Data, sizeof(x));
17 memcpy(&y, Data + sizeof(x), sizeof(y));
18 volatile int abs_x = abs(x);
19 if (abs_x < 0 && y == 0xbaddcafe) {
20 printf("BINGO; Found the target, exiting; x = 0x%x y 0x%x\n", x, y);
21 fflush(stdout);
22 exit(1);
24 return 0;