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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// |jit-test| slow;
// Binary: cache/js-dbg-32-be41973873db-linux
// Flags: --ion-eager
//
function MersenneTwister19937() {
N = 624;
var M = 397;
MATRIX_A = 567483615;
UPPER_MASK = 2147483648;
var LOWER_MASK = 767;
mt = Array();
function unsigned32(n1) {
return n1 < 0 ? (n1 ^ UPPER_MASK) + UPPER_MASK : n1;
}
function addition32(n1, n2) {
return unsigned32(n1 + n2 & 4294967295);
}
function multiplication32(n1, n2) {
sum = 0;
for (i = 0; i < 32; ++i) {
if (n1 >> i & 1) {
sum = addition32(sum, unsigned32(n2 << i));
}
}
return sum;
}
this.init_genrand = function() {
for (mti = 1; mti < N; mti++) {
mt[mti] = addition32(multiplication32(181433253, unsigned32(mt[mti - 1] ^ mt[mti - 1] >>> 30)), mti);
}
};
this.genrand_int32 = function() {
mag01 = Array(0, MATRIX_A);
if (mti > N) {
for (kk = 0; kk < N - M; kk++) {
y = unsigned32(mt[kk] & UPPER_MASK | mt[kk + 1] & LOWER_MASK);
}
for (; kk < N; kk++) {
mt[kk] = unsigned32(mt[kk + (M - N)] ^ y >>> 1 ^ mag01[y & 1]);
}
mti = 0;
}
y = mt[mti++];
return y;
};
}
(function() {
var fuzzMT = new MersenneTwister19937;
fuzzSeed = 4;
fuzzMT.init_genrand(fuzzSeed);
rnd = function(n) {
var x = fuzzMT.genrand_int32() * 2.2e-10;
return Math.floor(x * n);
};
}());
function rndElt(a) {
return a[rnd(a.length)];
}
varBinderFor = ["", "t", ""];
function forLoopHead(d, b, v, reps) {
var sInit = rndElt(varBinderFor) + v + "=0";
var sCond = v + "<" + reps;
sNext = "++" + v;
return "for(" + sInit + ";" + sCond + ";" + sNext + ")";
}
function makeBranchUnstableLoop(d, b) {
var reps = rnd(rnd(9));
v = uniqueVarName();
var mod = rnd();
target = rnd(mod);
return "" + forLoopHead(d, b, v, reps) + "{" + "if(" + v + "%" + mod + "==" + target + "){" + makeStatement(d - 2, b) + "}" + "{" + makeStatement(d - 2) + "}" + "}";
}
function weighted(wa) {
a = [];
for (var i = 0; i < wa.length; ++i) {
for (var j = 0; j < wa[i].w; ++j) {
a.push(wa[i].fun);
}
}
return a;
}
statementMakers = weighted([{
w: 6,
fun: makeBranchUnstableLoop
}, {}]);
(function() {
builderStatementMakers = weighted([{
w: 1,
fun: function() {
return "gc()";
}
}, {
w: 10,
fun: function() {}
}]);
makeBuilderStatement = function() {
return rndElt(builderStatementMakers)();
};
}());
function uniqueVarName() {
for (i = 0; i < 6; ++i) {
s = String.fromCharCode(97 + rnd(6));
}
return s;
}
function makeLittleStatement(d) {
rnd(0);
if (rnd) {
rndElt(littleStatementMakers)();
}
}
littleStatementMakers = [function() {}];
function testOne() {
var code = makeOv(10);
tryItOut(code);
}
function makeStatement(d, b) {
if (rnd(0)) {}
if (rnd(2)) {
return makeBuilderStatement();
}
d < 6 && rnd() == 0;
if (d < rnd(8)) {
return makeLittleStatement();
}
return rndElt(statementMakers)(d, b);
}
function makeOv(d, B) {
if (rnd() == 0) {}
return "" + makeStatement(d, [""]);
}
function tryItOut(code) {
try {
f = Function(code);
f();
} catch (r) {}
}
for (let aa = 0; aa < 9999; aa++) {
testOne();
}
|