// === Auto-generated preamble library stuff ===
//========================================
// Runtime code shared with compiler
//========================================
{{RUNTIME}}
Module['Runtime'] = Runtime;
#if ASM_JS
#if RESERVED_FUNCTION_POINTERS
function jsCall() {
var args = Array.prototype.slice.call(arguments);
return Runtime.functionPointers[args[0]].apply(null, args.slice(1));
}
#endif
#endif
#if BENCHMARK
Module.realPrint = Module.print;
Module.print = Module.printErr = function(){};
#endif
#if SAFE_HEAP
#if ASM_JS == 0
//========================================
// Debugging tools - Heap
//========================================
var HEAP_WATCHED = [];
var HEAP_HISTORY = [];
function SAFE_HEAP_CLEAR(dest) {
#if SAFE_HEAP_LOG
Module.print('SAFE_HEAP clear: ' + dest);
#endif
HEAP_HISTORY[dest] = undefined;
}
var SAFE_HEAP_ERRORS = 0;
var ACCEPTABLE_SAFE_HEAP_ERRORS = 0;
function SAFE_HEAP_ACCESS(dest, type, store, ignore, storeValue) {
//if (dest === A_NUMBER) Module.print ([dest, type, store, ignore, storeValue] + ' ' + stackTrace()); // Something like this may be useful, in debugging
assert(dest > 0, 'segmentation fault');
#if USE_TYPED_ARRAYS
// When using typed arrays, reads over the top of TOTAL_MEMORY will fail silently, so we must
// correct that by growing TOTAL_MEMORY as needed. Without typed arrays, memory is a normal
// JS array so it will work (potentially slowly, depending on the engine).
assert(ignore || dest < Math.max(DYNAMICTOP, STATICTOP));
assert(ignore || DYNAMICTOP <= TOTAL_MEMORY);
#endif
#if USE_TYPED_ARRAYS == 2
return; // It is legitimate to violate the load-store assumption in this case
#endif
if (type && type.charAt(type.length-1) == '*') type = 'i32'; // pointers are ints, for our purposes here
// Note that this will pass even with unions: You can store X, load X, then store Y and load Y.
// You cannot, however, do the nonportable act of store X and load Y!
if (store) {
HEAP_HISTORY[dest] = ignore ? null : type;
} else {
#if USE_TYPED_ARRAYS == 0
if (!HEAP[dest] && HEAP[dest] !== 0 && HEAP[dest] !== false && !ignore) { // false can be the result of a mathop comparator
var error = true;
try {
if (HEAP[dest].toString() === 'NaN') error = false; // NaN is acceptable, as a double value
} catch(e){}
if (error) throw('Warning: Reading an invalid value at ' + dest +