if (typeof console === 'undefined') {
console = { log: print };
}
var tempRet0;
var binary;
if (typeof process === 'object' && typeof require === 'function' ) {
var args = process.argv.slice(2);
binary = require('fs').readFileSync(args[0]);
if (!binary.buffer) binary = new Uint8Array(binary);
} else {
var args;
if (typeof scriptArgs != 'undefined') {
args = scriptArgs;
} else if (typeof arguments != 'undefined') {
args = arguments;
}
if (typeof readbuffer === 'function') {
binary = new Uint8Array(readbuffer(args[0]));
} else {
binary = read(args[0], 'binary');
}
}
function assert(x, y) {
if (!x) throw (y || 'assertion failed');}
var detrand = (function() {
var hash = 5381; var x = 0;
return function() {
hash = (((hash << 5) + hash) ^ (x & 0xff)) >>> 0;
x = (x + 1) % 256;
return (hash % 256) / 256;
};
})();
function printed(x, y) {
if (typeof y !== 'undefined') {
return x + ' ' + y;
} else if (x === null) {
return 'null';
} else if (typeof x === 'string') {
return 'string("' + x + '")';
} else if (typeof x === 'bigint') {
return (Number(x) | 0) + ' ' + (Number(x >> 32n) | 0)
} else if (typeof x !== 'number') {
return typeof x;
} else {
return '' + x;
}
}
function logValue(x, y) {
console.log('[LoggingExternalInterface logging ' + printed(x, y) + ']');
}
var imports = {
'fuzzing-support': {
'log-i32': logValue,
'log-i64': logValue,
'log-f32': logValue,
'log-f64': logValue,
'log-v128': logValue,
},
'env': {
'setTempRet0': function(x) { tempRet0 = x },
'getTempRet0': function() { return tempRet0 },
},
};
if (typeof WebAssembly.Tag !== 'undefined') {
imports['imports'] = {
'j2wasm.ExceptionUtils.tag': new WebAssembly.Tag({
'parameters': ['externref']
}),
};
}
var module = new WebAssembly.Module(binary);
var instance;
try {
instance = new WebAssembly.Instance(module, imports);
} catch (e) {
console.log('exception thrown: failed to instantiate module');
quit();
}
var exports = instance.exports;
var view;
function refreshView() {
if (exports.memory) {
view = new Int32Array(exports.memory.buffer);
}
}
for (var e in exports) {
if (typeof exports[e] !== 'function') {
continue;
}
var func = exports[e];
var args = [];
for (var i = 0; i < func.length; i++) {
args.push(null);
}
try {
console.log('[fuzz-exec] calling ' + e);
var result = func.apply(null, args);
if (typeof result !== 'undefined') {
console.log('[fuzz-exec] note result: ' + e + ' => ' + printed(result));
}
} catch (e) {
console.log('exception thrown: ' + e);
}
}