-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuzz.h
90 lines (70 loc) · 2.39 KB
/
fuzz.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// fuzz.h
// testSM2
//
// Created by zuoyongyong on 2019/11/25.
// Copyright © 2019年 zuoyongyong. All rights reserved.
//
#ifndef fuzz_h
#define fuzz_h
#define JUNK_CODE //是否插入垃圾代码的开关
#ifdef JUNK_CODE
#define junk_fun0 lo0
#define junk_fun1 lo1
#define junk_fun2 lo2
#define junk_fun3 lo3
static inline int junk_fun0(void)
{
volatile int i = 138,j = 1949;
if((i++)%2 > 0) j *= i;
if(j < 0) i *= 2;
else return 0;
i = 1;
while( i++ < 2){ j /= i; j++ ; i++ ; }
return i;
}
static inline int junk_fun1(void)
{
volatile int i = 21,j = 75;
if((i--)%3 > 0) j *= i;
if(j > 1) i *= 3;
else return 1;
i = 1;
while( i++ < 3){ j /= i; j-- ; i++ ; }
return j;
}
static inline int junk_fun2(void)
{
volatile int i = 56,j = 17;
if((i--)%5 > 0) j *= i;
if(j > 2) i *= 5;
else return 0;
i = 1;
while( i++ < 5){ j *= i; j += 3 ; i += 3;}
return i;
}
static inline int junk_fun3(void)
{
volatile int i = 1909,j = 131;
if((i--)%7 > 0) j *= i;
if(j > 3) i *= 7;
else return 1;
i = 1;
while( i++ < 7){ j /= i; j -= 5 ; i += 5;}
return i;
}
#define _JUNK_FUN_0 {if(junk_fun2())junk_fun1();if(junk_fun0()) junk_fun3();if(junk_fun1()) junk_fun2();if(junk_fun3()) junk_fun1(); \
if(junk_fun1())junk_fun0();if(junk_fun2()) junk_fun3();if(junk_fun3()) junk_fun1();if(junk_fun1()) junk_fun0();}
#define _JUNK_FUN_1 {if(junk_fun3())junk_fun1();if(junk_fun1()) junk_fun2();if(junk_fun2()) junk_fun0();if(junk_fun0()) junk_fun1(); \
if(junk_fun2())junk_fun1();if(junk_fun0()) junk_fun3();if(junk_fun1()) junk_fun2();if(junk_fun3()) junk_fun1();}
#define _JUNK_FUN_2 {if(junk_fun1())junk_fun0();if(junk_fun2()) junk_fun3();if(junk_fun3()) junk_fun1();if(junk_fun1()) junk_fun0(); \
if(junk_fun0())junk_fun2();if(junk_fun3()) junk_fun0();if(junk_fun0()) junk_fun3();if(junk_fun2()) junk_fun3();}
#define _JUNK_FUN_3 {if(junk_fun0())junk_fun2();if(junk_fun3()) junk_fun0();if(junk_fun0()) junk_fun3();if(junk_fun2()) junk_fun3(); \
if(junk_fun3())junk_fun1();if(junk_fun1()) junk_fun2();if(junk_fun2()) junk_fun0();if(junk_fun0()) junk_fun1();}
#else
#define _JUNK_FUN_0 {}
#define _JUNK_FUN_1 {}
#define _JUNK_FUN_2 {}
#define _JUNK_FUN_3 {}
#endif
#endif /* fuzz_h */