taler-xotp

xOTP generator
Log | Files | Refs | Submodules | README

base8.js (97387B)


      1 
      2 var Base8Module = (() => {
      3   var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
      4   if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
      5   return (
      6 function(Base8Module) {
      7   Base8Module = Base8Module || {};
      8 
      9 
     10 
     11 // The Module object: Our interface to the outside world. We import
     12 // and export values on it. There are various ways Module can be used:
     13 // 1. Not defined. We create it here
     14 // 2. A function parameter, function(Module) { ..generated code.. }
     15 // 3. pre-run appended it, var Module = {}; ..generated code..
     16 // 4. External script tag defines var Module.
     17 // We need to check if Module already exists (e.g. case 3 above).
     18 // Substitution will be replaced with actual code on later stage of the build,
     19 // this way Closure Compiler will not mangle it (e.g. case 4. above).
     20 // Note that if you want to run closure, and also to use Module
     21 // after the generated code, you will need to define   var Module = {};
     22 // before the code. Then that object will be used in the code, and you
     23 // can continue to use Module afterwards as well.
     24 var Module = typeof Base8Module != 'undefined' ? Base8Module : {};
     25 
     26 // See https://caniuse.com/mdn-javascript_builtins_object_assign
     27 
     28 // Set up the promise that indicates the Module is initialized
     29 var readyPromiseResolve, readyPromiseReject;
     30 Module['ready'] = new Promise(function(resolve, reject) {
     31   readyPromiseResolve = resolve;
     32   readyPromiseReject = reject;
     33 });
     34 
     35       if (!Object.getOwnPropertyDescriptor(Module['ready'], '_base8_encodeBytes')) {
     36         Object.defineProperty(Module['ready'], '_base8_encodeBytes', { configurable: true, get: function() { abort('You are getting _base8_encodeBytes on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     37         Object.defineProperty(Module['ready'], '_base8_encodeBytes', { configurable: true, set: function() { abort('You are setting _base8_encodeBytes on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     38       }
     39     
     40 
     41       if (!Object.getOwnPropertyDescriptor(Module['ready'], '_base8_stringToNum')) {
     42         Object.defineProperty(Module['ready'], '_base8_stringToNum', { configurable: true, get: function() { abort('You are getting _base8_stringToNum on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     43         Object.defineProperty(Module['ready'], '_base8_stringToNum', { configurable: true, set: function() { abort('You are setting _base8_stringToNum on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     44       }
     45     
     46 
     47       if (!Object.getOwnPropertyDescriptor(Module['ready'], '_base8_decodeNum')) {
     48         Object.defineProperty(Module['ready'], '_base8_decodeNum', { configurable: true, get: function() { abort('You are getting _base8_decodeNum on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     49         Object.defineProperty(Module['ready'], '_base8_decodeNum', { configurable: true, set: function() { abort('You are setting _base8_decodeNum on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     50       }
     51     
     52 
     53       if (!Object.getOwnPropertyDescriptor(Module['ready'], '_malloc')) {
     54         Object.defineProperty(Module['ready'], '_malloc', { configurable: true, get: function() { abort('You are getting _malloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     55         Object.defineProperty(Module['ready'], '_malloc', { configurable: true, set: function() { abort('You are setting _malloc on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     56       }
     57     
     58 
     59       if (!Object.getOwnPropertyDescriptor(Module['ready'], '_free')) {
     60         Object.defineProperty(Module['ready'], '_free', { configurable: true, get: function() { abort('You are getting _free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     61         Object.defineProperty(Module['ready'], '_free', { configurable: true, set: function() { abort('You are setting _free on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     62       }
     63     
     64 
     65       if (!Object.getOwnPropertyDescriptor(Module['ready'], '___stdio_exit')) {
     66         Object.defineProperty(Module['ready'], '___stdio_exit', { configurable: true, get: function() { abort('You are getting ___stdio_exit on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     67         Object.defineProperty(Module['ready'], '___stdio_exit', { configurable: true, set: function() { abort('You are setting ___stdio_exit on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     68       }
     69     
     70 
     71       if (!Object.getOwnPropertyDescriptor(Module['ready'], 'onRuntimeInitialized')) {
     72         Object.defineProperty(Module['ready'], 'onRuntimeInitialized', { configurable: true, get: function() { abort('You are getting onRuntimeInitialized on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     73         Object.defineProperty(Module['ready'], 'onRuntimeInitialized', { configurable: true, set: function() { abort('You are setting onRuntimeInitialized on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js') } });
     74       }
     75     
     76 
     77 // --pre-jses are emitted after the Module integration code, so that they can
     78 // refer to Module (if they choose; they can also define Module)
     79 // {{PRE_JSES}}
     80 
     81 // Sometimes an existing Module object exists with properties
     82 // meant to overwrite the default module functionality. Here
     83 // we collect those properties and reapply _after_ we configure
     84 // the current environment's defaults to avoid having to be so
     85 // defensive during initialization.
     86 var moduleOverrides = Object.assign({}, Module);
     87 
     88 var arguments_ = [];
     89 var thisProgram = './this.program';
     90 var quit_ = (status, toThrow) => {
     91   throw toThrow;
     92 };
     93 
     94 // Determine the runtime environment we are in. You can customize this by
     95 // setting the ENVIRONMENT setting at compile time (see settings.js).
     96 
     97 // Attempt to auto-detect the environment
     98 var ENVIRONMENT_IS_WEB = typeof window == 'object';
     99 var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
    100 // N.b. Electron.js environment is simultaneously a NODE-environment, but
    101 // also a web environment.
    102 var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
    103 var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
    104 
    105 if (Module['ENVIRONMENT']) {
    106   throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)');
    107 }
    108 
    109 // `/` should be present at the end if `scriptDirectory` is not empty
    110 var scriptDirectory = '';
    111 function locateFile(path) {
    112   if (Module['locateFile']) {
    113     return Module['locateFile'](path, scriptDirectory);
    114   }
    115   return scriptDirectory + path;
    116 }
    117 
    118 // Hooks that are implemented differently in different runtime environments.
    119 var read_,
    120     readAsync,
    121     readBinary,
    122     setWindowTitle;
    123 
    124 // Normally we don't log exceptions but instead let them bubble out the top
    125 // level where the embedding environment (e.g. the browser) can handle
    126 // them.
    127 // However under v8 and node we sometimes exit the process direcly in which case
    128 // its up to use us to log the exception before exiting.
    129 // If we fix https://github.com/emscripten-core/emscripten/issues/15080
    130 // this may no longer be needed under node.
    131 function logExceptionOnExit(e) {
    132   if (e instanceof ExitStatus) return;
    133   let toLog = e;
    134   if (e && typeof e == 'object' && e.stack) {
    135     toLog = [e, e.stack];
    136   }
    137   err('exiting due to exception: ' + toLog);
    138 }
    139 
    140 var fs;
    141 var nodePath;
    142 var requireNodeFS;
    143 
    144 if (ENVIRONMENT_IS_NODE) {
    145   if (!(typeof process == 'object' && typeof require == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
    146   if (ENVIRONMENT_IS_WORKER) {
    147     scriptDirectory = require('path').dirname(scriptDirectory) + '/';
    148   } else {
    149     scriptDirectory = __dirname + '/';
    150   }
    151 
    152 // include: node_shell_read.js
    153 
    154 
    155 requireNodeFS = () => {
    156   // Use nodePath as the indicator for these not being initialized,
    157   // since in some environments a global fs may have already been
    158   // created.
    159   if (!nodePath) {
    160     fs = require('fs');
    161     nodePath = require('path');
    162   }
    163 };
    164 
    165 read_ = function shell_read(filename, binary) {
    166   requireNodeFS();
    167   filename = nodePath['normalize'](filename);
    168   return fs.readFileSync(filename, binary ? undefined : 'utf8');
    169 };
    170 
    171 readBinary = (filename) => {
    172   var ret = read_(filename, true);
    173   if (!ret.buffer) {
    174     ret = new Uint8Array(ret);
    175   }
    176   assert(ret.buffer);
    177   return ret;
    178 };
    179 
    180 readAsync = (filename, onload, onerror) => {
    181   requireNodeFS();
    182   filename = nodePath['normalize'](filename);
    183   fs.readFile(filename, function(err, data) {
    184     if (err) onerror(err);
    185     else onload(data.buffer);
    186   });
    187 };
    188 
    189 // end include: node_shell_read.js
    190   if (process['argv'].length > 1) {
    191     thisProgram = process['argv'][1].replace(/\\/g, '/');
    192   }
    193 
    194   arguments_ = process['argv'].slice(2);
    195 
    196   // MODULARIZE will export the module in the proper place outside, we don't need to export here
    197 
    198   process['on']('uncaughtException', function(ex) {
    199     // suppress ExitStatus exceptions from showing an error
    200     if (!(ex instanceof ExitStatus)) {
    201       throw ex;
    202     }
    203   });
    204 
    205   // Without this older versions of node (< v15) will log unhandled rejections
    206   // but return 0, which is not normally the desired behaviour.  This is
    207   // not be needed with node v15 and about because it is now the default
    208   // behaviour:
    209   // See https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode
    210   process['on']('unhandledRejection', function(reason) { throw reason; });
    211 
    212   quit_ = (status, toThrow) => {
    213     if (keepRuntimeAlive()) {
    214       process['exitCode'] = status;
    215       throw toThrow;
    216     }
    217     logExceptionOnExit(toThrow);
    218     process['exit'](status);
    219   };
    220 
    221   Module['inspect'] = function () { return '[Emscripten Module object]'; };
    222 
    223 } else
    224 if (ENVIRONMENT_IS_SHELL) {
    225 
    226   if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
    227 
    228   if (typeof read != 'undefined') {
    229     read_ = function shell_read(f) {
    230       return read(f);
    231     };
    232   }
    233 
    234   readBinary = function readBinary(f) {
    235     let data;
    236     if (typeof readbuffer == 'function') {
    237       return new Uint8Array(readbuffer(f));
    238     }
    239     data = read(f, 'binary');
    240     assert(typeof data == 'object');
    241     return data;
    242   };
    243 
    244   readAsync = function readAsync(f, onload, onerror) {
    245     setTimeout(() => onload(readBinary(f)), 0);
    246   };
    247 
    248   if (typeof scriptArgs != 'undefined') {
    249     arguments_ = scriptArgs;
    250   } else if (typeof arguments != 'undefined') {
    251     arguments_ = arguments;
    252   }
    253 
    254   if (typeof quit == 'function') {
    255     quit_ = (status, toThrow) => {
    256       // Unlike node which has process.exitCode, d8 has no such mechanism. So we
    257       // have no way to set the exit code and then let the program exit with
    258       // that code when it naturally stops running (say, when all setTimeouts
    259       // have completed). For that reason we must call `quit` - the only way to
    260       // set the exit code - but quit also halts immediately, so we need to be
    261       // careful of whether the runtime is alive or not, which is why this code
    262       // path looks different than node. It also has the downside that it will
    263       // halt the entire program when no code remains to run, which means this
    264       // is not friendly for bundling this code into a larger codebase, and for
    265       // that reason the "shell" environment is mainly useful for testing whole
    266       // programs by themselves, basically.
    267       if (runtimeKeepaliveCounter) {
    268         throw toThrow;
    269       }
    270       logExceptionOnExit(toThrow);
    271       quit(status);
    272     };
    273   }
    274 
    275   if (typeof print != 'undefined') {
    276     // Prefer to use print/printErr where they exist, as they usually work better.
    277     if (typeof console == 'undefined') console = /** @type{!Console} */({});
    278     console.log = /** @type{!function(this:Console, ...*): undefined} */ (print);
    279     console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */ (typeof printErr != 'undefined' ? printErr : print);
    280   }
    281 
    282 } else
    283 
    284 // Note that this includes Node.js workers when relevant (pthreads is enabled).
    285 // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
    286 // ENVIRONMENT_IS_NODE.
    287 if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
    288   if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
    289     scriptDirectory = self.location.href;
    290   } else if (typeof document != 'undefined' && document.currentScript) { // web
    291     scriptDirectory = document.currentScript.src;
    292   }
    293   // When MODULARIZE, this JS may be executed later, after document.currentScript
    294   // is gone, so we saved it, and we use it here instead of any other info.
    295   if (_scriptDir) {
    296     scriptDirectory = _scriptDir;
    297   }
    298   // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
    299   // otherwise, slice off the final part of the url to find the script directory.
    300   // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
    301   // and scriptDirectory will correctly be replaced with an empty string.
    302   // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
    303   // they are removed because they could contain a slash.
    304   if (scriptDirectory.indexOf('blob:') !== 0) {
    305     scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
    306   } else {
    307     scriptDirectory = '';
    308   }
    309 
    310   if (!(typeof window == 'object' || typeof importScripts == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
    311 
    312   // Differentiate the Web Worker from the Node Worker case, as reading must
    313   // be done differently.
    314   {
    315 // include: web_or_worker_shell_read.js
    316 
    317 
    318   read_ = (url) => {
    319       var xhr = new XMLHttpRequest();
    320       xhr.open('GET', url, false);
    321       xhr.send(null);
    322       return xhr.responseText;
    323   }
    324 
    325   if (ENVIRONMENT_IS_WORKER) {
    326     readBinary = (url) => {
    327         var xhr = new XMLHttpRequest();
    328         xhr.open('GET', url, false);
    329         xhr.responseType = 'arraybuffer';
    330         xhr.send(null);
    331         return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
    332     };
    333   }
    334 
    335   readAsync = (url, onload, onerror) => {
    336     var xhr = new XMLHttpRequest();
    337     xhr.open('GET', url, true);
    338     xhr.responseType = 'arraybuffer';
    339     xhr.onload = () => {
    340       if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
    341         onload(xhr.response);
    342         return;
    343       }
    344       onerror();
    345     };
    346     xhr.onerror = onerror;
    347     xhr.send(null);
    348   }
    349 
    350 // end include: web_or_worker_shell_read.js
    351   }
    352 
    353   setWindowTitle = (title) => document.title = title;
    354 } else
    355 {
    356   throw new Error('environment detection error');
    357 }
    358 
    359 var out = Module['print'] || console.log.bind(console);
    360 var err = Module['printErr'] || console.warn.bind(console);
    361 
    362 // Merge back in the overrides
    363 Object.assign(Module, moduleOverrides);
    364 // Free the object hierarchy contained in the overrides, this lets the GC
    365 // reclaim data used e.g. in memoryInitializerRequest, which is a large typed array.
    366 moduleOverrides = null;
    367 checkIncomingModuleAPI();
    368 
    369 // Emit code to handle expected values on the Module object. This applies Module.x
    370 // to the proper local x. This has two benefits: first, we only emit it if it is
    371 // expected to arrive, and second, by using a local everywhere else that can be
    372 // minified.
    373 
    374 if (Module['arguments']) arguments_ = Module['arguments'];legacyModuleProp('arguments', 'arguments_');
    375 
    376 if (Module['thisProgram']) thisProgram = Module['thisProgram'];legacyModuleProp('thisProgram', 'thisProgram');
    377 
    378 if (Module['quit']) quit_ = Module['quit'];legacyModuleProp('quit', 'quit_');
    379 
    380 // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
    381 // Assertions on removed incoming Module JS APIs.
    382 assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
    383 assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
    384 assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
    385 assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
    386 assert(typeof Module['read'] == 'undefined', 'Module.read option was removed (modify read_ in JS)');
    387 assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
    388 assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
    389 assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify setWindowTitle in JS)');
    390 assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
    391 legacyModuleProp('read', 'read_');
    392 legacyModuleProp('readAsync', 'readAsync');
    393 legacyModuleProp('readBinary', 'readBinary');
    394 legacyModuleProp('setWindowTitle', 'setWindowTitle');
    395 var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
    396 var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
    397 var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
    398 var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
    399 function alignMemory() { abort('`alignMemory` is now a library function and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line'); }
    400 
    401 assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time.  Add 'shell' to `-s ENVIRONMENT` to enable.");
    402 
    403 
    404 
    405 
    406 var STACK_ALIGN = 16;
    407 var POINTER_SIZE = 4;
    408 
    409 function getNativeTypeSize(type) {
    410   switch (type) {
    411     case 'i1': case 'i8': return 1;
    412     case 'i16': return 2;
    413     case 'i32': return 4;
    414     case 'i64': return 8;
    415     case 'float': return 4;
    416     case 'double': return 8;
    417     default: {
    418       if (type[type.length - 1] === '*') {
    419         return POINTER_SIZE;
    420       } else if (type[0] === 'i') {
    421         const bits = Number(type.substr(1));
    422         assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type);
    423         return bits / 8;
    424       } else {
    425         return 0;
    426       }
    427     }
    428   }
    429 }
    430 
    431 function warnOnce(text) {
    432   if (!warnOnce.shown) warnOnce.shown = {};
    433   if (!warnOnce.shown[text]) {
    434     warnOnce.shown[text] = 1;
    435     err(text);
    436   }
    437 }
    438 
    439 // include: runtime_functions.js
    440 
    441 
    442 // Wraps a JS function as a wasm function with a given signature.
    443 function convertJsFunctionToWasm(func, sig) {
    444 
    445   // If the type reflection proposal is available, use the new
    446   // "WebAssembly.Function" constructor.
    447   // Otherwise, construct a minimal wasm module importing the JS function and
    448   // re-exporting it.
    449   if (typeof WebAssembly.Function == "function") {
    450     var typeNames = {
    451       'i': 'i32',
    452       'j': 'i64',
    453       'f': 'f32',
    454       'd': 'f64'
    455     };
    456     var type = {
    457       parameters: [],
    458       results: sig[0] == 'v' ? [] : [typeNames[sig[0]]]
    459     };
    460     for (var i = 1; i < sig.length; ++i) {
    461       type.parameters.push(typeNames[sig[i]]);
    462     }
    463     return new WebAssembly.Function(type, func);
    464   }
    465 
    466   // The module is static, with the exception of the type section, which is
    467   // generated based on the signature passed in.
    468   var typeSection = [
    469     0x01, // id: section,
    470     0x00, // length: 0 (placeholder)
    471     0x01, // count: 1
    472     0x60, // form: func
    473   ];
    474   var sigRet = sig.slice(0, 1);
    475   var sigParam = sig.slice(1);
    476   var typeCodes = {
    477     'i': 0x7f, // i32
    478     'j': 0x7e, // i64
    479     'f': 0x7d, // f32
    480     'd': 0x7c, // f64
    481   };
    482 
    483   // Parameters, length + signatures
    484   typeSection.push(sigParam.length);
    485   for (var i = 0; i < sigParam.length; ++i) {
    486     typeSection.push(typeCodes[sigParam[i]]);
    487   }
    488 
    489   // Return values, length + signatures
    490   // With no multi-return in MVP, either 0 (void) or 1 (anything else)
    491   if (sigRet == 'v') {
    492     typeSection.push(0x00);
    493   } else {
    494     typeSection = typeSection.concat([0x01, typeCodes[sigRet]]);
    495   }
    496 
    497   // Write the overall length of the type section back into the section header
    498   // (excepting the 2 bytes for the section id and length)
    499   typeSection[1] = typeSection.length - 2;
    500 
    501   // Rest of the module is static
    502   var bytes = new Uint8Array([
    503     0x00, 0x61, 0x73, 0x6d, // magic ("\0asm")
    504     0x01, 0x00, 0x00, 0x00, // version: 1
    505   ].concat(typeSection, [
    506     0x02, 0x07, // import section
    507       // (import "e" "f" (func 0 (type 0)))
    508       0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00,
    509     0x07, 0x05, // export section
    510       // (export "f" (func 0 (type 0)))
    511       0x01, 0x01, 0x66, 0x00, 0x00,
    512   ]));
    513 
    514    // We can compile this wasm module synchronously because it is very small.
    515   // This accepts an import (at "e.f"), that it reroutes to an export (at "f")
    516   var module = new WebAssembly.Module(bytes);
    517   var instance = new WebAssembly.Instance(module, {
    518     'e': {
    519       'f': func
    520     }
    521   });
    522   var wrappedFunc = instance.exports['f'];
    523   return wrappedFunc;
    524 }
    525 
    526 var freeTableIndexes = [];
    527 
    528 // Weak map of functions in the table to their indexes, created on first use.
    529 var functionsInTableMap;
    530 
    531 function getEmptyTableSlot() {
    532   // Reuse a free index if there is one, otherwise grow.
    533   if (freeTableIndexes.length) {
    534     return freeTableIndexes.pop();
    535   }
    536   // Grow the table
    537   try {
    538     wasmTable.grow(1);
    539   } catch (err) {
    540     if (!(err instanceof RangeError)) {
    541       throw err;
    542     }
    543     throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.';
    544   }
    545   return wasmTable.length - 1;
    546 }
    547 
    548 function updateTableMap(offset, count) {
    549   for (var i = offset; i < offset + count; i++) {
    550     var item = getWasmTableEntry(i);
    551     // Ignore null values.
    552     if (item) {
    553       functionsInTableMap.set(item, i);
    554     }
    555   }
    556 }
    557 
    558 /**
    559  * Add a function to the table.
    560  * 'sig' parameter is required if the function being added is a JS function.
    561  * @param {string=} sig
    562  */
    563 function addFunction(func, sig) {
    564   assert(typeof func != 'undefined');
    565 
    566   // Check if the function is already in the table, to ensure each function
    567   // gets a unique index. First, create the map if this is the first use.
    568   if (!functionsInTableMap) {
    569     functionsInTableMap = new WeakMap();
    570     updateTableMap(0, wasmTable.length);
    571   }
    572   if (functionsInTableMap.has(func)) {
    573     return functionsInTableMap.get(func);
    574   }
    575 
    576   // It's not in the table, add it now.
    577 
    578   var ret = getEmptyTableSlot();
    579 
    580   // Set the new value.
    581   try {
    582     // Attempting to call this with JS function will cause of table.set() to fail
    583     setWasmTableEntry(ret, func);
    584   } catch (err) {
    585     if (!(err instanceof TypeError)) {
    586       throw err;
    587     }
    588     assert(typeof sig != 'undefined', 'Missing signature argument to addFunction: ' + func);
    589     var wrapped = convertJsFunctionToWasm(func, sig);
    590     setWasmTableEntry(ret, wrapped);
    591   }
    592 
    593   functionsInTableMap.set(func, ret);
    594 
    595   return ret;
    596 }
    597 
    598 function removeFunction(index) {
    599   functionsInTableMap.delete(getWasmTableEntry(index));
    600   freeTableIndexes.push(index);
    601 }
    602 
    603 // end include: runtime_functions.js
    604 // include: runtime_debug.js
    605 
    606 
    607 function legacyModuleProp(prop, newName) {
    608   if (!Object.getOwnPropertyDescriptor(Module, prop)) {
    609     Object.defineProperty(Module, prop, {
    610       configurable: true,
    611       get: function() {
    612         abort('Module.' + prop + ' has been replaced with plain ' + newName + ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)');
    613       }
    614     });
    615   }
    616 }
    617 
    618 function ignoredModuleProp(prop) {
    619   if (Object.getOwnPropertyDescriptor(Module, prop)) {
    620     abort('`Module.' + prop + '` was supplied but `' + prop + '` not included in INCOMING_MODULE_JS_API');
    621   }
    622 }
    623 
    624 function unexportedMessage(sym, isFSSybol) {
    625   var msg = "'" + sym + "' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";
    626   if (isFSSybol) {
    627     msg += '. Alternatively, forcing filesystem support (-s FORCE_FILESYSTEM=1) can export this for you';
    628   }
    629   return msg;
    630 }
    631 
    632 function unexportedRuntimeSymbol(sym, isFSSybol) {
    633   if (!Object.getOwnPropertyDescriptor(Module, sym)) {
    634     Object.defineProperty(Module, sym, {
    635       configurable: true,
    636       get: function() {
    637         abort(unexportedMessage(sym, isFSSybol));
    638       }
    639     });
    640   }
    641 }
    642 
    643 function unexportedRuntimeFunction(sym, isFSSybol) {
    644   if (!Object.getOwnPropertyDescriptor(Module, sym)) {
    645     Module[sym] = () => abort(unexportedMessage(sym, isFSSybol));
    646   }
    647 }
    648 
    649 // end include: runtime_debug.js
    650 var tempRet0 = 0;
    651 var setTempRet0 = (value) => { tempRet0 = value; };
    652 var getTempRet0 = () => tempRet0;
    653 
    654 
    655 
    656 // === Preamble library stuff ===
    657 
    658 // Documentation for the public APIs defined in this file must be updated in:
    659 //    site/source/docs/api_reference/preamble.js.rst
    660 // A prebuilt local version of the documentation is available at:
    661 //    site/build/text/docs/api_reference/preamble.js.txt
    662 // You can also build docs locally as HTML or other formats in site/
    663 // An online HTML version (which may be of a different version of Emscripten)
    664 //    is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
    665 
    666 var wasmBinary;
    667 if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
    668 var noExitRuntime = Module['noExitRuntime'] || true;legacyModuleProp('noExitRuntime', 'noExitRuntime');
    669 
    670 if (typeof WebAssembly != 'object') {
    671   abort('no native wasm support detected');
    672 }
    673 
    674 // include: runtime_safe_heap.js
    675 
    676 
    677 // In MINIMAL_RUNTIME, setValue() and getValue() are only available when building with safe heap enabled, for heap safety checking.
    678 // In traditional runtime, setValue() and getValue() are always available (although their use is highly discouraged due to perf penalties)
    679 
    680 /** @param {number} ptr
    681     @param {number} value
    682     @param {string} type
    683     @param {number|boolean=} noSafe */
    684 function setValue(ptr, value, type = 'i8', noSafe) {
    685   if (type.charAt(type.length-1) === '*') type = 'i32';
    686     switch (type) {
    687       case 'i1': HEAP8[((ptr)>>0)] = value; break;
    688       case 'i8': HEAP8[((ptr)>>0)] = value; break;
    689       case 'i16': HEAP16[((ptr)>>1)] = value; break;
    690       case 'i32': HEAP32[((ptr)>>2)] = value; break;
    691       case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math.min((+(Math.floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[((ptr)>>2)] = tempI64[0],HEAP32[(((ptr)+(4))>>2)] = tempI64[1]); break;
    692       case 'float': HEAPF32[((ptr)>>2)] = value; break;
    693       case 'double': HEAPF64[((ptr)>>3)] = value; break;
    694       default: abort('invalid type for setValue: ' + type);
    695     }
    696 }
    697 
    698 /** @param {number} ptr
    699     @param {string} type
    700     @param {number|boolean=} noSafe */
    701 function getValue(ptr, type = 'i8', noSafe) {
    702   if (type.charAt(type.length-1) === '*') type = 'i32';
    703     switch (type) {
    704       case 'i1': return HEAP8[((ptr)>>0)];
    705       case 'i8': return HEAP8[((ptr)>>0)];
    706       case 'i16': return HEAP16[((ptr)>>1)];
    707       case 'i32': return HEAP32[((ptr)>>2)];
    708       case 'i64': return HEAP32[((ptr)>>2)];
    709       case 'float': return HEAPF32[((ptr)>>2)];
    710       case 'double': return Number(HEAPF64[((ptr)>>3)]);
    711       default: abort('invalid type for getValue: ' + type);
    712     }
    713   return null;
    714 }
    715 
    716 // end include: runtime_safe_heap.js
    717 // Wasm globals
    718 
    719 var wasmMemory;
    720 
    721 //========================================
    722 // Runtime essentials
    723 //========================================
    724 
    725 // whether we are quitting the application. no code should run after this.
    726 // set in exit() and abort()
    727 var ABORT = false;
    728 
    729 // set by exit() and abort().  Passed to 'onExit' handler.
    730 // NOTE: This is also used as the process return code code in shell environments
    731 // but only when noExitRuntime is false.
    732 var EXITSTATUS;
    733 
    734 /** @type {function(*, string=)} */
    735 function assert(condition, text) {
    736   if (!condition) {
    737     abort('Assertion failed' + (text ? ': ' + text : ''));
    738   }
    739 }
    740 
    741 // Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
    742 function getCFunc(ident) {
    743   var func = Module['_' + ident]; // closure exported function
    744   assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported');
    745   return func;
    746 }
    747 
    748 // C calling interface.
    749 /** @param {string|null=} returnType
    750     @param {Array=} argTypes
    751     @param {Arguments|Array=} args
    752     @param {Object=} opts */
    753 function ccall(ident, returnType, argTypes, args, opts) {
    754   // For fast lookup of conversion functions
    755   var toC = {
    756     'string': function(str) {
    757       var ret = 0;
    758       if (str !== null && str !== undefined && str !== 0) { // null string
    759         // at most 4 bytes per UTF-8 code point, +1 for the trailing '\0'
    760         var len = (str.length << 2) + 1;
    761         ret = stackAlloc(len);
    762         stringToUTF8(str, ret, len);
    763       }
    764       return ret;
    765     },
    766     'array': function(arr) {
    767       var ret = stackAlloc(arr.length);
    768       writeArrayToMemory(arr, ret);
    769       return ret;
    770     }
    771   };
    772 
    773   function convertReturnValue(ret) {
    774     if (returnType === 'string') return UTF8ToString(ret);
    775     if (returnType === 'boolean') return Boolean(ret);
    776     return ret;
    777   }
    778 
    779   var func = getCFunc(ident);
    780   var cArgs = [];
    781   var stack = 0;
    782   assert(returnType !== 'array', 'Return type should not be "array".');
    783   if (args) {
    784     for (var i = 0; i < args.length; i++) {
    785       var converter = toC[argTypes[i]];
    786       if (converter) {
    787         if (stack === 0) stack = stackSave();
    788         cArgs[i] = converter(args[i]);
    789       } else {
    790         cArgs[i] = args[i];
    791       }
    792     }
    793   }
    794   var ret = func.apply(null, cArgs);
    795   function onDone(ret) {
    796     if (stack !== 0) stackRestore(stack);
    797     return convertReturnValue(ret);
    798   }
    799 
    800   ret = onDone(ret);
    801   return ret;
    802 }
    803 
    804 /** @param {string=} returnType
    805     @param {Array=} argTypes
    806     @param {Object=} opts */
    807 function cwrap(ident, returnType, argTypes, opts) {
    808   return function() {
    809     return ccall(ident, returnType, argTypes, arguments, opts);
    810   }
    811 }
    812 
    813 // We used to include malloc/free by default in the past. Show a helpful error in
    814 // builds with assertions.
    815 
    816 // include: runtime_legacy.js
    817 
    818 
    819 var ALLOC_NORMAL = 0; // Tries to use _malloc()
    820 var ALLOC_STACK = 1; // Lives for the duration of the current function call
    821 
    822 /**
    823  * allocate(): This function is no longer used by emscripten but is kept around to avoid
    824  *             breaking external users.
    825  *             You should normally not use allocate(), and instead allocate
    826  *             memory using _malloc()/stackAlloc(), initialize it with
    827  *             setValue(), and so forth.
    828  * @param {(Uint8Array|Array<number>)} slab: An array of data.
    829  * @param {number=} allocator : How to allocate memory, see ALLOC_*
    830  */
    831 function allocate(slab, allocator) {
    832   var ret;
    833   assert(typeof allocator == 'number', 'allocate no longer takes a type argument')
    834   assert(typeof slab != 'number', 'allocate no longer takes a number as arg0')
    835 
    836   if (allocator == ALLOC_STACK) {
    837     ret = stackAlloc(slab.length);
    838   } else {
    839     ret = _malloc(slab.length);
    840   }
    841 
    842   if (!slab.subarray && !slab.slice) {
    843     slab = new Uint8Array(slab);
    844   }
    845   HEAPU8.set(slab, ret);
    846   return ret;
    847 }
    848 
    849 // end include: runtime_legacy.js
    850 // include: runtime_strings.js
    851 
    852 
    853 // runtime_strings.js: Strings related runtime functions that are part of both MINIMAL_RUNTIME and regular runtime.
    854 
    855 // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns
    856 // a copy of that string as a Javascript String object.
    857 
    858 var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined;
    859 
    860 /**
    861  * @param {number} idx
    862  * @param {number=} maxBytesToRead
    863  * @return {string}
    864  */
    865 function UTF8ArrayToString(heap, idx, maxBytesToRead) {
    866   var endIdx = idx + maxBytesToRead;
    867   var endPtr = idx;
    868   // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
    869   // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
    870   // (As a tiny code save trick, compare endPtr against endIdx using a negation, so that undefined means Infinity)
    871   while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr;
    872 
    873   if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) {
    874     return UTF8Decoder.decode(heap.subarray(idx, endPtr));
    875   } else {
    876     var str = '';
    877     // If building with TextDecoder, we have already computed the string length above, so test loop end condition against that
    878     while (idx < endPtr) {
    879       // For UTF8 byte structure, see:
    880       // http://en.wikipedia.org/wiki/UTF-8#Description
    881       // https://www.ietf.org/rfc/rfc2279.txt
    882       // https://tools.ietf.org/html/rfc3629
    883       var u0 = heap[idx++];
    884       if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
    885       var u1 = heap[idx++] & 63;
    886       if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
    887       var u2 = heap[idx++] & 63;
    888       if ((u0 & 0xF0) == 0xE0) {
    889         u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
    890       } else {
    891         if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte 0x' + u0.toString(16) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!');
    892         u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heap[idx++] & 63);
    893       }
    894 
    895       if (u0 < 0x10000) {
    896         str += String.fromCharCode(u0);
    897       } else {
    898         var ch = u0 - 0x10000;
    899         str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
    900       }
    901     }
    902   }
    903   return str;
    904 }
    905 
    906 // Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns a
    907 // copy of that string as a Javascript String object.
    908 // maxBytesToRead: an optional length that specifies the maximum number of bytes to read. You can omit
    909 //                 this parameter to scan the string until the first \0 byte. If maxBytesToRead is
    910 //                 passed, and the string at [ptr, ptr+maxBytesToReadr[ contains a null byte in the
    911 //                 middle, then the string will cut short at that byte index (i.e. maxBytesToRead will
    912 //                 not produce a string of exact length [ptr, ptr+maxBytesToRead[)
    913 //                 N.B. mixing frequent uses of UTF8ToString() with and without maxBytesToRead may
    914 //                 throw JS JIT optimizations off, so it is worth to consider consistently using one
    915 //                 style or the other.
    916 /**
    917  * @param {number} ptr
    918  * @param {number=} maxBytesToRead
    919  * @return {string}
    920  */
    921 function UTF8ToString(ptr, maxBytesToRead) {
    922   ;
    923   return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
    924 }
    925 
    926 // Copies the given Javascript String object 'str' to the given byte array at address 'outIdx',
    927 // encoded in UTF8 form and null-terminated. The copy will require at most str.length*4+1 bytes of space in the HEAP.
    928 // Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
    929 // Parameters:
    930 //   str: the Javascript string to copy.
    931 //   heap: the array to copy to. Each index in this array is assumed to be one 8-byte element.
    932 //   outIdx: The starting offset in the array to begin the copying.
    933 //   maxBytesToWrite: The maximum number of bytes this function can write to the array.
    934 //                    This count should include the null terminator,
    935 //                    i.e. if maxBytesToWrite=1, only the null terminator will be written and nothing else.
    936 //                    maxBytesToWrite=0 does not write any bytes to the output, not even the null terminator.
    937 // Returns the number of bytes written, EXCLUDING the null terminator.
    938 
    939 function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
    940   if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes.
    941     return 0;
    942 
    943   var startIdx = outIdx;
    944   var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
    945   for (var i = 0; i < str.length; ++i) {
    946     // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
    947     // See http://unicode.org/faq/utf_bom.html#utf16-3
    948     // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description and https://www.ietf.org/rfc/rfc2279.txt and https://tools.ietf.org/html/rfc3629
    949     var u = str.charCodeAt(i); // possibly a lead surrogate
    950     if (u >= 0xD800 && u <= 0xDFFF) {
    951       var u1 = str.charCodeAt(++i);
    952       u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
    953     }
    954     if (u <= 0x7F) {
    955       if (outIdx >= endIdx) break;
    956       heap[outIdx++] = u;
    957     } else if (u <= 0x7FF) {
    958       if (outIdx + 1 >= endIdx) break;
    959       heap[outIdx++] = 0xC0 | (u >> 6);
    960       heap[outIdx++] = 0x80 | (u & 63);
    961     } else if (u <= 0xFFFF) {
    962       if (outIdx + 2 >= endIdx) break;
    963       heap[outIdx++] = 0xE0 | (u >> 12);
    964       heap[outIdx++] = 0x80 | ((u >> 6) & 63);
    965       heap[outIdx++] = 0x80 | (u & 63);
    966     } else {
    967       if (outIdx + 3 >= endIdx) break;
    968       if (u > 0x10FFFF) warnOnce('Invalid Unicode code point 0x' + u.toString(16) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).');
    969       heap[outIdx++] = 0xF0 | (u >> 18);
    970       heap[outIdx++] = 0x80 | ((u >> 12) & 63);
    971       heap[outIdx++] = 0x80 | ((u >> 6) & 63);
    972       heap[outIdx++] = 0x80 | (u & 63);
    973     }
    974   }
    975   // Null-terminate the pointer to the buffer.
    976   heap[outIdx] = 0;
    977   return outIdx - startIdx;
    978 }
    979 
    980 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
    981 // null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP.
    982 // Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write.
    983 // Returns the number of bytes written, EXCLUDING the null terminator.
    984 
    985 function stringToUTF8(str, outPtr, maxBytesToWrite) {
    986   assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
    987   return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite);
    988 }
    989 
    990 // Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte.
    991 function lengthBytesUTF8(str) {
    992   var len = 0;
    993   for (var i = 0; i < str.length; ++i) {
    994     // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! So decode UTF16->UTF32->UTF8.
    995     // See http://unicode.org/faq/utf_bom.html#utf16-3
    996     var u = str.charCodeAt(i); // possibly a lead surrogate
    997     if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF);
    998     if (u <= 0x7F) ++len;
    999     else if (u <= 0x7FF) len += 2;
   1000     else if (u <= 0xFFFF) len += 3;
   1001     else len += 4;
   1002   }
   1003   return len;
   1004 }
   1005 
   1006 // end include: runtime_strings.js
   1007 // include: runtime_strings_extra.js
   1008 
   1009 
   1010 // runtime_strings_extra.js: Strings related runtime functions that are available only in regular runtime.
   1011 
   1012 // Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns
   1013 // a copy of that string as a Javascript String object.
   1014 
   1015 function AsciiToString(ptr) {
   1016   var str = '';
   1017   while (1) {
   1018     var ch = HEAPU8[((ptr++)>>0)];
   1019     if (!ch) return str;
   1020     str += String.fromCharCode(ch);
   1021   }
   1022 }
   1023 
   1024 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
   1025 // null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP.
   1026 
   1027 function stringToAscii(str, outPtr) {
   1028   return writeAsciiToMemory(str, outPtr, false);
   1029 }
   1030 
   1031 // Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
   1032 // a copy of that string as a Javascript String object.
   1033 
   1034 var UTF16Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf-16le') : undefined;
   1035 
   1036 function UTF16ToString(ptr, maxBytesToRead) {
   1037   assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
   1038   var endPtr = ptr;
   1039   // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself.
   1040   // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage.
   1041   var idx = endPtr >> 1;
   1042   var maxIdx = idx + maxBytesToRead / 2;
   1043   // If maxBytesToRead is not passed explicitly, it will be undefined, and this
   1044   // will always evaluate to true. This saves on code size.
   1045   while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
   1046   endPtr = idx << 1;
   1047 
   1048   if (endPtr - ptr > 32 && UTF16Decoder) {
   1049     return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
   1050   } else {
   1051     var str = '';
   1052 
   1053     // If maxBytesToRead is not passed explicitly, it will be undefined, and the for-loop's condition
   1054     // will always evaluate to true. The loop is then terminated on the first null char.
   1055     for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
   1056       var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
   1057       if (codeUnit == 0) break;
   1058       // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
   1059       str += String.fromCharCode(codeUnit);
   1060     }
   1061 
   1062     return str;
   1063   }
   1064 }
   1065 
   1066 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
   1067 // null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP.
   1068 // Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write.
   1069 // Parameters:
   1070 //   str: the Javascript string to copy.
   1071 //   outPtr: Byte address in Emscripten HEAP where to write the string to.
   1072 //   maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
   1073 //                    terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else.
   1074 //                    maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator.
   1075 // Returns the number of bytes written, EXCLUDING the null terminator.
   1076 
   1077 function stringToUTF16(str, outPtr, maxBytesToWrite) {
   1078   assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
   1079   assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
   1080   // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
   1081   if (maxBytesToWrite === undefined) {
   1082     maxBytesToWrite = 0x7FFFFFFF;
   1083   }
   1084   if (maxBytesToWrite < 2) return 0;
   1085   maxBytesToWrite -= 2; // Null terminator.
   1086   var startPtr = outPtr;
   1087   var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
   1088   for (var i = 0; i < numCharsToWrite; ++i) {
   1089     // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
   1090     var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
   1091     HEAP16[((outPtr)>>1)] = codeUnit;
   1092     outPtr += 2;
   1093   }
   1094   // Null-terminate the pointer to the HEAP.
   1095   HEAP16[((outPtr)>>1)] = 0;
   1096   return outPtr - startPtr;
   1097 }
   1098 
   1099 // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
   1100 
   1101 function lengthBytesUTF16(str) {
   1102   return str.length*2;
   1103 }
   1104 
   1105 function UTF32ToString(ptr, maxBytesToRead) {
   1106   assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
   1107   var i = 0;
   1108 
   1109   var str = '';
   1110   // If maxBytesToRead is not passed explicitly, it will be undefined, and this
   1111   // will always evaluate to true. This saves on code size.
   1112   while (!(i >= maxBytesToRead / 4)) {
   1113     var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
   1114     if (utf32 == 0) break;
   1115     ++i;
   1116     // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
   1117     // See http://unicode.org/faq/utf_bom.html#utf16-3
   1118     if (utf32 >= 0x10000) {
   1119       var ch = utf32 - 0x10000;
   1120       str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
   1121     } else {
   1122       str += String.fromCharCode(utf32);
   1123     }
   1124   }
   1125   return str;
   1126 }
   1127 
   1128 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
   1129 // null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP.
   1130 // Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write.
   1131 // Parameters:
   1132 //   str: the Javascript string to copy.
   1133 //   outPtr: Byte address in Emscripten HEAP where to write the string to.
   1134 //   maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null
   1135 //                    terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else.
   1136 //                    maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator.
   1137 // Returns the number of bytes written, EXCLUDING the null terminator.
   1138 
   1139 function stringToUTF32(str, outPtr, maxBytesToWrite) {
   1140   assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
   1141   assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
   1142   // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
   1143   if (maxBytesToWrite === undefined) {
   1144     maxBytesToWrite = 0x7FFFFFFF;
   1145   }
   1146   if (maxBytesToWrite < 4) return 0;
   1147   var startPtr = outPtr;
   1148   var endPtr = startPtr + maxBytesToWrite - 4;
   1149   for (var i = 0; i < str.length; ++i) {
   1150     // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
   1151     // See http://unicode.org/faq/utf_bom.html#utf16-3
   1152     var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
   1153     if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
   1154       var trailSurrogate = str.charCodeAt(++i);
   1155       codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
   1156     }
   1157     HEAP32[((outPtr)>>2)] = codeUnit;
   1158     outPtr += 4;
   1159     if (outPtr + 4 > endPtr) break;
   1160   }
   1161   // Null-terminate the pointer to the HEAP.
   1162   HEAP32[((outPtr)>>2)] = 0;
   1163   return outPtr - startPtr;
   1164 }
   1165 
   1166 // Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte.
   1167 
   1168 function lengthBytesUTF32(str) {
   1169   var len = 0;
   1170   for (var i = 0; i < str.length; ++i) {
   1171     // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
   1172     // See http://unicode.org/faq/utf_bom.html#utf16-3
   1173     var codeUnit = str.charCodeAt(i);
   1174     if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
   1175     len += 4;
   1176   }
   1177 
   1178   return len;
   1179 }
   1180 
   1181 // Allocate heap space for a JS string, and write it there.
   1182 // It is the responsibility of the caller to free() that memory.
   1183 function allocateUTF8(str) {
   1184   var size = lengthBytesUTF8(str) + 1;
   1185   var ret = _malloc(size);
   1186   if (ret) stringToUTF8Array(str, HEAP8, ret, size);
   1187   return ret;
   1188 }
   1189 
   1190 // Allocate stack space for a JS string, and write it there.
   1191 function allocateUTF8OnStack(str) {
   1192   var size = lengthBytesUTF8(str) + 1;
   1193   var ret = stackAlloc(size);
   1194   stringToUTF8Array(str, HEAP8, ret, size);
   1195   return ret;
   1196 }
   1197 
   1198 // Deprecated: This function should not be called because it is unsafe and does not provide
   1199 // a maximum length limit of how many bytes it is allowed to write. Prefer calling the
   1200 // function stringToUTF8Array() instead, which takes in a maximum length that can be used
   1201 // to be secure from out of bounds writes.
   1202 /** @deprecated
   1203     @param {boolean=} dontAddNull */
   1204 function writeStringToMemory(string, buffer, dontAddNull) {
   1205   warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!');
   1206 
   1207   var /** @type {number} */ lastChar, /** @type {number} */ end;
   1208   if (dontAddNull) {
   1209     // stringToUTF8Array always appends null. If we don't want to do that, remember the
   1210     // character that existed at the location where the null will be placed, and restore
   1211     // that after the write (below).
   1212     end = buffer + lengthBytesUTF8(string);
   1213     lastChar = HEAP8[end];
   1214   }
   1215   stringToUTF8(string, buffer, Infinity);
   1216   if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character.
   1217 }
   1218 
   1219 function writeArrayToMemory(array, buffer) {
   1220   assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)')
   1221   HEAP8.set(array, buffer);
   1222 }
   1223 
   1224 /** @param {boolean=} dontAddNull */
   1225 function writeAsciiToMemory(str, buffer, dontAddNull) {
   1226   for (var i = 0; i < str.length; ++i) {
   1227     assert(str.charCodeAt(i) === (str.charCodeAt(i) & 0xff));
   1228     HEAP8[((buffer++)>>0)] = str.charCodeAt(i);
   1229   }
   1230   // Null-terminate the pointer to the HEAP.
   1231   if (!dontAddNull) HEAP8[((buffer)>>0)] = 0;
   1232 }
   1233 
   1234 // end include: runtime_strings_extra.js
   1235 // Memory management
   1236 
   1237 var HEAP,
   1238 /** @type {!ArrayBuffer} */
   1239   buffer,
   1240 /** @type {!Int8Array} */
   1241   HEAP8,
   1242 /** @type {!Uint8Array} */
   1243   HEAPU8,
   1244 /** @type {!Int16Array} */
   1245   HEAP16,
   1246 /** @type {!Uint16Array} */
   1247   HEAPU16,
   1248 /** @type {!Int32Array} */
   1249   HEAP32,
   1250 /** @type {!Uint32Array} */
   1251   HEAPU32,
   1252 /** @type {!Float32Array} */
   1253   HEAPF32,
   1254 /** @type {!Float64Array} */
   1255   HEAPF64;
   1256 
   1257 function updateGlobalBufferAndViews(buf) {
   1258   buffer = buf;
   1259   Module['HEAP8'] = HEAP8 = new Int8Array(buf);
   1260   Module['HEAP16'] = HEAP16 = new Int16Array(buf);
   1261   Module['HEAP32'] = HEAP32 = new Int32Array(buf);
   1262   Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf);
   1263   Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf);
   1264   Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf);
   1265   Module['HEAPF32'] = HEAPF32 = new Float32Array(buf);
   1266   Module['HEAPF64'] = HEAPF64 = new Float64Array(buf);
   1267 }
   1268 
   1269 var TOTAL_STACK = 5242880;
   1270 if (Module['TOTAL_STACK']) assert(TOTAL_STACK === Module['TOTAL_STACK'], 'the stack size can no longer be determined at runtime')
   1271 
   1272 var INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216;legacyModuleProp('INITIAL_MEMORY', 'INITIAL_MEMORY');
   1273 
   1274 assert(INITIAL_MEMORY >= TOTAL_STACK, 'INITIAL_MEMORY should be larger than TOTAL_STACK, was ' + INITIAL_MEMORY + '! (TOTAL_STACK=' + TOTAL_STACK + ')');
   1275 
   1276 // check for full engine support (use string 'subarray' to avoid closure compiler confusion)
   1277 assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
   1278        'JS engine does not provide full typed array support');
   1279 
   1280 // If memory is defined in wasm, the user can't provide it.
   1281 assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected.  Use -s IMPORTED_MEMORY to define wasmMemory externally');
   1282 assert(INITIAL_MEMORY == 16777216, 'Detected runtime INITIAL_MEMORY setting.  Use -s IMPORTED_MEMORY to define wasmMemory dynamically');
   1283 
   1284 // include: runtime_init_table.js
   1285 // In regular non-RELOCATABLE mode the table is exported
   1286 // from the wasm module and this will be assigned once
   1287 // the exports are available.
   1288 var wasmTable;
   1289 
   1290 // end include: runtime_init_table.js
   1291 // include: runtime_stack_check.js
   1292 
   1293 
   1294 // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
   1295 function writeStackCookie() {
   1296   var max = _emscripten_stack_get_end();
   1297   assert((max & 3) == 0);
   1298   // The stack grows downwards
   1299   HEAP32[((max + 4)>>2)] = 0x2135467;
   1300   HEAP32[((max + 8)>>2)] = 0x89BACDFE;
   1301   // Also test the global address 0 for integrity.
   1302   HEAP32[0] = 0x63736d65; /* 'emsc' */
   1303 }
   1304 
   1305 function checkStackCookie() {
   1306   if (ABORT) return;
   1307   var max = _emscripten_stack_get_end();
   1308   var cookie1 = HEAPU32[((max + 4)>>2)];
   1309   var cookie2 = HEAPU32[((max + 8)>>2)];
   1310   if (cookie1 != 0x2135467 || cookie2 != 0x89BACDFE) {
   1311     abort('Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x' + cookie2.toString(16) + ' 0x' + cookie1.toString(16));
   1312   }
   1313   // Also test the global address 0 for integrity.
   1314   if (HEAP32[0] !== 0x63736d65 /* 'emsc' */) abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
   1315 }
   1316 
   1317 // end include: runtime_stack_check.js
   1318 // include: runtime_assertions.js
   1319 
   1320 
   1321 // Endianness check
   1322 (function() {
   1323   var h16 = new Int16Array(1);
   1324   var h8 = new Int8Array(h16.buffer);
   1325   h16[0] = 0x6373;
   1326   if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -s SUPPORT_BIG_ENDIAN=1 to bypass)';
   1327 })();
   1328 
   1329 // end include: runtime_assertions.js
   1330 var __ATPRERUN__  = []; // functions called before the runtime is initialized
   1331 var __ATINIT__    = []; // functions called during startup
   1332 var __ATEXIT__    = []; // functions called during shutdown
   1333 var __ATPOSTRUN__ = []; // functions called after the main() is called
   1334 
   1335 var runtimeInitialized = false;
   1336 var runtimeExited = false;
   1337 var runtimeKeepaliveCounter = 0;
   1338 
   1339 function keepRuntimeAlive() {
   1340   return noExitRuntime || runtimeKeepaliveCounter > 0;
   1341 }
   1342 
   1343 function preRun() {
   1344 
   1345   if (Module['preRun']) {
   1346     if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
   1347     while (Module['preRun'].length) {
   1348       addOnPreRun(Module['preRun'].shift());
   1349     }
   1350   }
   1351 
   1352   callRuntimeCallbacks(__ATPRERUN__);
   1353 }
   1354 
   1355 function initRuntime() {
   1356   checkStackCookie();
   1357   assert(!runtimeInitialized);
   1358   runtimeInitialized = true;
   1359 
   1360   
   1361   callRuntimeCallbacks(__ATINIT__);
   1362 }
   1363 
   1364 function exitRuntime() {
   1365   checkStackCookie();
   1366   runtimeExited = true;
   1367 }
   1368 
   1369 function postRun() {
   1370   checkStackCookie();
   1371 
   1372   if (Module['postRun']) {
   1373     if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
   1374     while (Module['postRun'].length) {
   1375       addOnPostRun(Module['postRun'].shift());
   1376     }
   1377   }
   1378 
   1379   callRuntimeCallbacks(__ATPOSTRUN__);
   1380 }
   1381 
   1382 function addOnPreRun(cb) {
   1383   __ATPRERUN__.unshift(cb);
   1384 }
   1385 
   1386 function addOnInit(cb) {
   1387   __ATINIT__.unshift(cb);
   1388 }
   1389 
   1390 function addOnExit(cb) {
   1391 }
   1392 
   1393 function addOnPostRun(cb) {
   1394   __ATPOSTRUN__.unshift(cb);
   1395 }
   1396 
   1397 // include: runtime_math.js
   1398 
   1399 
   1400 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
   1401 
   1402 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
   1403 
   1404 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
   1405 
   1406 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
   1407 
   1408 assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
   1409 assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
   1410 assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
   1411 assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
   1412 
   1413 // end include: runtime_math.js
   1414 // A counter of dependencies for calling run(). If we need to
   1415 // do asynchronous work before running, increment this and
   1416 // decrement it. Incrementing must happen in a place like
   1417 // Module.preRun (used by emcc to add file preloading).
   1418 // Note that you can add dependencies in preRun, even though
   1419 // it happens right before run - run will be postponed until
   1420 // the dependencies are met.
   1421 var runDependencies = 0;
   1422 var runDependencyWatcher = null;
   1423 var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
   1424 var runDependencyTracking = {};
   1425 
   1426 function getUniqueRunDependency(id) {
   1427   var orig = id;
   1428   while (1) {
   1429     if (!runDependencyTracking[id]) return id;
   1430     id = orig + Math.random();
   1431   }
   1432 }
   1433 
   1434 function addRunDependency(id) {
   1435   runDependencies++;
   1436 
   1437   if (Module['monitorRunDependencies']) {
   1438     Module['monitorRunDependencies'](runDependencies);
   1439   }
   1440 
   1441   if (id) {
   1442     assert(!runDependencyTracking[id]);
   1443     runDependencyTracking[id] = 1;
   1444     if (runDependencyWatcher === null && typeof setInterval != 'undefined') {
   1445       // Check for missing dependencies every few seconds
   1446       runDependencyWatcher = setInterval(function() {
   1447         if (ABORT) {
   1448           clearInterval(runDependencyWatcher);
   1449           runDependencyWatcher = null;
   1450           return;
   1451         }
   1452         var shown = false;
   1453         for (var dep in runDependencyTracking) {
   1454           if (!shown) {
   1455             shown = true;
   1456             err('still waiting on run dependencies:');
   1457           }
   1458           err('dependency: ' + dep);
   1459         }
   1460         if (shown) {
   1461           err('(end of list)');
   1462         }
   1463       }, 10000);
   1464     }
   1465   } else {
   1466     err('warning: run dependency added without ID');
   1467   }
   1468 }
   1469 
   1470 function removeRunDependency(id) {
   1471   runDependencies--;
   1472 
   1473   if (Module['monitorRunDependencies']) {
   1474     Module['monitorRunDependencies'](runDependencies);
   1475   }
   1476 
   1477   if (id) {
   1478     assert(runDependencyTracking[id]);
   1479     delete runDependencyTracking[id];
   1480   } else {
   1481     err('warning: run dependency removed without ID');
   1482   }
   1483   if (runDependencies == 0) {
   1484     if (runDependencyWatcher !== null) {
   1485       clearInterval(runDependencyWatcher);
   1486       runDependencyWatcher = null;
   1487     }
   1488     if (dependenciesFulfilled) {
   1489       var callback = dependenciesFulfilled;
   1490       dependenciesFulfilled = null;
   1491       callback(); // can add another dependenciesFulfilled
   1492     }
   1493   }
   1494 }
   1495 
   1496 Module["preloadedImages"] = {}; // maps url to image data
   1497 Module["preloadedAudios"] = {}; // maps url to audio data
   1498 
   1499 /** @param {string|number=} what */
   1500 function abort(what) {
   1501   {
   1502     if (Module['onAbort']) {
   1503       Module['onAbort'](what);
   1504     }
   1505   }
   1506 
   1507   what = 'Aborted(' + what + ')';
   1508   // TODO(sbc): Should we remove printing and leave it up to whoever
   1509   // catches the exception?
   1510   err(what);
   1511 
   1512   ABORT = true;
   1513   EXITSTATUS = 1;
   1514 
   1515   // Use a wasm runtime error, because a JS error might be seen as a foreign
   1516   // exception, which means we'd run destructors on it. We need the error to
   1517   // simply make the program stop.
   1518 
   1519   // Suppress closure compiler warning here. Closure compiler's builtin extern
   1520   // defintion for WebAssembly.RuntimeError claims it takes no arguments even
   1521   // though it can.
   1522   // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
   1523 
   1524   /** @suppress {checkTypes} */
   1525   var e = new WebAssembly.RuntimeError(what);
   1526 
   1527   readyPromiseReject(e);
   1528   // Throw the error whether or not MODULARIZE is set because abort is used
   1529   // in code paths apart from instantiation where an exception is expected
   1530   // to be thrown when abort is called.
   1531   throw e;
   1532 }
   1533 
   1534 // {{MEM_INITIALIZER}}
   1535 
   1536 // include: memoryprofiler.js
   1537 
   1538 
   1539 // end include: memoryprofiler.js
   1540 // show errors on likely calls to FS when it was not included
   1541 var FS = {
   1542   error: function() {
   1543     abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with  -s FORCE_FILESYSTEM=1');
   1544   },
   1545   init: function() { FS.error() },
   1546   createDataFile: function() { FS.error() },
   1547   createPreloadedFile: function() { FS.error() },
   1548   createLazyFile: function() { FS.error() },
   1549   open: function() { FS.error() },
   1550   mkdev: function() { FS.error() },
   1551   registerDevice: function() { FS.error() },
   1552   analyzePath: function() { FS.error() },
   1553   loadFilesFromDB: function() { FS.error() },
   1554 
   1555   ErrnoError: function ErrnoError() { FS.error() },
   1556 };
   1557 Module['FS_createDataFile'] = FS.createDataFile;
   1558 Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
   1559 
   1560 // include: URIUtils.js
   1561 
   1562 
   1563 // Prefix of data URIs emitted by SINGLE_FILE and related options.
   1564 var dataURIPrefix = 'data:application/octet-stream;base64,';
   1565 
   1566 // Indicates whether filename is a base64 data URI.
   1567 function isDataURI(filename) {
   1568   // Prefix of data URIs emitted by SINGLE_FILE and related options.
   1569   return filename.startsWith(dataURIPrefix);
   1570 }
   1571 
   1572 // Indicates whether filename is delivered via file protocol (as opposed to http/https)
   1573 function isFileURI(filename) {
   1574   return filename.startsWith('file://');
   1575 }
   1576 
   1577 // end include: URIUtils.js
   1578 /** @param {boolean=} fixedasm */
   1579 function createExportWrapper(name, fixedasm) {
   1580   return function() {
   1581     var displayName = name;
   1582     var asm = fixedasm;
   1583     if (!fixedasm) {
   1584       asm = Module['asm'];
   1585     }
   1586     assert(runtimeInitialized, 'native function `' + displayName + '` called before runtime initialization');
   1587     assert(!runtimeExited, 'native function `' + displayName + '` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)');
   1588     if (!asm[name]) {
   1589       assert(asm[name], 'exported native function `' + displayName + '` not found');
   1590     }
   1591     return asm[name].apply(null, arguments);
   1592   };
   1593 }
   1594 
   1595 var wasmBinaryFile;
   1596   wasmBinaryFile = 'base8.wasm';
   1597   if (!isDataURI(wasmBinaryFile)) {
   1598     wasmBinaryFile = locateFile(wasmBinaryFile);
   1599   }
   1600 
   1601 function getBinary(file) {
   1602   try {
   1603     if (file == wasmBinaryFile && wasmBinary) {
   1604       return new Uint8Array(wasmBinary);
   1605     }
   1606     if (readBinary) {
   1607       return readBinary(file);
   1608     } else {
   1609       throw "both async and sync fetching of the wasm failed";
   1610     }
   1611   }
   1612   catch (err) {
   1613     abort(err);
   1614   }
   1615 }
   1616 
   1617 function getBinaryPromise() {
   1618   // If we don't have the binary yet, try to to load it asynchronously.
   1619   // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
   1620   // See https://github.com/github/fetch/pull/92#issuecomment-140665932
   1621   // Cordova or Electron apps are typically loaded from a file:// url.
   1622   // So use fetch if it is available and the url is not a file, otherwise fall back to XHR.
   1623   if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
   1624     if (typeof fetch == 'function'
   1625       && !isFileURI(wasmBinaryFile)
   1626     ) {
   1627       return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
   1628         if (!response['ok']) {
   1629           throw "failed to load wasm binary file at '" + wasmBinaryFile + "'";
   1630         }
   1631         return response['arrayBuffer']();
   1632       }).catch(function () {
   1633           return getBinary(wasmBinaryFile);
   1634       });
   1635     }
   1636     else {
   1637       if (readAsync) {
   1638         // fetch is not available or url is file => try XHR (readAsync uses XHR internally)
   1639         return new Promise(function(resolve, reject) {
   1640           readAsync(wasmBinaryFile, function(response) { resolve(new Uint8Array(/** @type{!ArrayBuffer} */(response))) }, reject)
   1641         });
   1642       }
   1643     }
   1644   }
   1645 
   1646   // Otherwise, getBinary should be able to get it synchronously
   1647   return Promise.resolve().then(function() { return getBinary(wasmBinaryFile); });
   1648 }
   1649 
   1650 // Create the wasm instance.
   1651 // Receives the wasm imports, returns the exports.
   1652 function createWasm() {
   1653   // prepare imports
   1654   var info = {
   1655     'env': asmLibraryArg,
   1656     'wasi_snapshot_preview1': asmLibraryArg,
   1657   };
   1658   // Load the wasm module and create an instance of using native support in the JS engine.
   1659   // handle a generated wasm instance, receiving its exports and
   1660   // performing other necessary setup
   1661   /** @param {WebAssembly.Module=} module*/
   1662   function receiveInstance(instance, module) {
   1663     var exports = instance.exports;
   1664 
   1665     Module['asm'] = exports;
   1666 
   1667     wasmMemory = Module['asm']['memory'];
   1668     assert(wasmMemory, "memory not found in wasm exports");
   1669     // This assertion doesn't hold when emscripten is run in --post-link
   1670     // mode.
   1671     // TODO(sbc): Read INITIAL_MEMORY out of the wasm file in post-link mode.
   1672     //assert(wasmMemory.buffer.byteLength === 16777216);
   1673     updateGlobalBufferAndViews(wasmMemory.buffer);
   1674 
   1675     wasmTable = Module['asm']['__indirect_function_table'];
   1676     assert(wasmTable, "table not found in wasm exports");
   1677 
   1678     addOnInit(Module['asm']['__wasm_call_ctors']);
   1679 
   1680     removeRunDependency('wasm-instantiate');
   1681   }
   1682   // we can't run yet (except in a pthread, where we have a custom sync instantiator)
   1683   addRunDependency('wasm-instantiate');
   1684 
   1685   // Prefer streaming instantiation if available.
   1686   // Async compilation can be confusing when an error on the page overwrites Module
   1687   // (for example, if the order of elements is wrong, and the one defining Module is
   1688   // later), so we save Module and check it later.
   1689   var trueModule = Module;
   1690   function receiveInstantiationResult(result) {
   1691     // 'result' is a ResultObject object which has both the module and instance.
   1692     // receiveInstance() will swap in the exports (to Module.asm) so they can be called
   1693     assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
   1694     trueModule = null;
   1695     // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
   1696     // When the regression is fixed, can restore the above USE_PTHREADS-enabled path.
   1697     receiveInstance(result['instance']);
   1698   }
   1699 
   1700   function instantiateArrayBuffer(receiver) {
   1701     return getBinaryPromise().then(function(binary) {
   1702       return WebAssembly.instantiate(binary, info);
   1703     }).then(function (instance) {
   1704       return instance;
   1705     }).then(receiver, function(reason) {
   1706       err('failed to asynchronously prepare wasm: ' + reason);
   1707 
   1708       // Warn on some common problems.
   1709       if (isFileURI(wasmBinaryFile)) {
   1710         err('warning: Loading from a file URI (' + wasmBinaryFile + ') is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing');
   1711       }
   1712       abort(reason);
   1713     });
   1714   }
   1715 
   1716   function instantiateAsync() {
   1717     if (!wasmBinary &&
   1718         typeof WebAssembly.instantiateStreaming == 'function' &&
   1719         !isDataURI(wasmBinaryFile) &&
   1720         // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
   1721         !isFileURI(wasmBinaryFile) &&
   1722         typeof fetch == 'function') {
   1723       return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) {
   1724         // Suppress closure warning here since the upstream definition for
   1725         // instantiateStreaming only allows Promise<Repsponse> rather than
   1726         // an actual Response.
   1727         // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
   1728         /** @suppress {checkTypes} */
   1729         var result = WebAssembly.instantiateStreaming(response, info);
   1730 
   1731         return result.then(
   1732           receiveInstantiationResult,
   1733           function(reason) {
   1734             // We expect the most common failure cause to be a bad MIME type for the binary,
   1735             // in which case falling back to ArrayBuffer instantiation should work.
   1736             err('wasm streaming compile failed: ' + reason);
   1737             err('falling back to ArrayBuffer instantiation');
   1738             return instantiateArrayBuffer(receiveInstantiationResult);
   1739           });
   1740       });
   1741     } else {
   1742       return instantiateArrayBuffer(receiveInstantiationResult);
   1743     }
   1744   }
   1745 
   1746   // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
   1747   // to manually instantiate the Wasm module themselves. This allows pages to run the instantiation parallel
   1748   // to any other async startup actions they are performing.
   1749   if (Module['instantiateWasm']) {
   1750     try {
   1751       var exports = Module['instantiateWasm'](info, receiveInstance);
   1752       return exports;
   1753     } catch(e) {
   1754       err('Module.instantiateWasm callback failed with error: ' + e);
   1755       return false;
   1756     }
   1757   }
   1758 
   1759   // If instantiation fails, reject the module ready promise.
   1760   instantiateAsync().catch(readyPromiseReject);
   1761   return {}; // no exports yet; we'll fill them in later
   1762 }
   1763 
   1764 // Globals used by JS i64 conversions (see makeSetValue)
   1765 var tempDouble;
   1766 var tempI64;
   1767 
   1768 // === Body ===
   1769 
   1770 var ASM_CONSTS = {
   1771   
   1772 };
   1773 
   1774 
   1775 
   1776 
   1777 
   1778 
   1779   function callRuntimeCallbacks(callbacks) {
   1780       while (callbacks.length > 0) {
   1781         var callback = callbacks.shift();
   1782         if (typeof callback == 'function') {
   1783           callback(Module); // Pass the module as the first argument.
   1784           continue;
   1785         }
   1786         var func = callback.func;
   1787         if (typeof func == 'number') {
   1788           if (callback.arg === undefined) {
   1789             getWasmTableEntry(func)();
   1790           } else {
   1791             getWasmTableEntry(func)(callback.arg);
   1792           }
   1793         } else {
   1794           func(callback.arg === undefined ? null : callback.arg);
   1795         }
   1796       }
   1797     }
   1798 
   1799   function withStackSave(f) {
   1800       var stack = stackSave();
   1801       var ret = f();
   1802       stackRestore(stack);
   1803       return ret;
   1804     }
   1805   function demangle(func) {
   1806       warnOnce('warning: build with  -s DEMANGLE_SUPPORT=1  to link in libcxxabi demangling');
   1807       return func;
   1808     }
   1809 
   1810   function demangleAll(text) {
   1811       var regex =
   1812         /\b_Z[\w\d_]+/g;
   1813       return text.replace(regex,
   1814         function(x) {
   1815           var y = demangle(x);
   1816           return x === y ? x : (y + ' [' + x + ']');
   1817         });
   1818     }
   1819 
   1820   var wasmTableMirror = [];
   1821   function getWasmTableEntry(funcPtr) {
   1822       var func = wasmTableMirror[funcPtr];
   1823       if (!func) {
   1824         if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
   1825         wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
   1826       }
   1827       assert(wasmTable.get(funcPtr) == func, "JavaScript-side Wasm function table mirror is out of date!");
   1828       return func;
   1829     }
   1830 
   1831   function handleException(e) {
   1832       // Certain exception types we do not treat as errors since they are used for
   1833       // internal control flow.
   1834       // 1. ExitStatus, which is thrown by exit()
   1835       // 2. "unwind", which is thrown by emscripten_unwind_to_js_event_loop() and others
   1836       //    that wish to return to JS event loop.
   1837       if (e instanceof ExitStatus || e == 'unwind') {
   1838         return EXITSTATUS;
   1839       }
   1840       quit_(1, e);
   1841     }
   1842 
   1843   function jsStackTrace() {
   1844       var error = new Error();
   1845       if (!error.stack) {
   1846         // IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown,
   1847         // so try that as a special-case.
   1848         try {
   1849           throw new Error();
   1850         } catch(e) {
   1851           error = e;
   1852         }
   1853         if (!error.stack) {
   1854           return '(no stack trace available)';
   1855         }
   1856       }
   1857       return error.stack.toString();
   1858     }
   1859 
   1860   function setWasmTableEntry(idx, func) {
   1861       wasmTable.set(idx, func);
   1862       wasmTableMirror[idx] = func;
   1863     }
   1864 
   1865   function stackTrace() {
   1866       var js = jsStackTrace();
   1867       if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace']();
   1868       return demangleAll(js);
   1869     }
   1870 
   1871   function _emscripten_get_heap_max() {
   1872       // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
   1873       // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
   1874       // for any code that deals with heap sizes, which would require special
   1875       // casing all heap size related code to treat 0 specially.
   1876       return 2147483648;
   1877     }
   1878   
   1879   function emscripten_realloc_buffer(size) {
   1880       try {
   1881         // round size grow request up to wasm page size (fixed 64KB per spec)
   1882         wasmMemory.grow((size - buffer.byteLength + 65535) >>> 16); // .grow() takes a delta compared to the previous size
   1883         updateGlobalBufferAndViews(wasmMemory.buffer);
   1884         return 1 /*success*/;
   1885       } catch(e) {
   1886         err('emscripten_realloc_buffer: Attempted to grow heap from ' + buffer.byteLength  + ' bytes to ' + size + ' bytes, but got error: ' + e);
   1887       }
   1888       // implicit 0 return to save code size (caller will cast "undefined" into 0
   1889       // anyhow)
   1890     }
   1891   function _emscripten_resize_heap(requestedSize) {
   1892       var oldSize = HEAPU8.length;
   1893       requestedSize = requestedSize >>> 0;
   1894       // With pthreads, races can happen (another thread might increase the size
   1895       // in between), so return a failure, and let the caller retry.
   1896       assert(requestedSize > oldSize);
   1897   
   1898       // Memory resize rules:
   1899       // 1.  Always increase heap size to at least the requested size, rounded up
   1900       //     to next page multiple.
   1901       // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
   1902       //     geometrically: increase the heap size according to
   1903       //     MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
   1904       //     overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
   1905       // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
   1906       //     linearly: increase the heap size by at least
   1907       //     MEMORY_GROWTH_LINEAR_STEP bytes.
   1908       // 3.  Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
   1909       //     MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
   1910       // 4.  If we were unable to allocate as much memory, it may be due to
   1911       //     over-eager decision to excessively reserve due to (3) above.
   1912       //     Hence if an allocation fails, cut down on the amount of excess
   1913       //     growth, in an attempt to succeed to perform a smaller allocation.
   1914   
   1915       // A limit is set for how much we can grow. We should not exceed that
   1916       // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
   1917       var maxHeapSize = _emscripten_get_heap_max();
   1918       if (requestedSize > maxHeapSize) {
   1919         err('Cannot enlarge memory, asked to go up to ' + requestedSize + ' bytes, but the limit is ' + maxHeapSize + ' bytes!');
   1920         return false;
   1921       }
   1922   
   1923       let alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
   1924   
   1925       // Loop through potential heap size increases. If we attempt a too eager
   1926       // reservation that fails, cut down on the attempted size and reserve a
   1927       // smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
   1928       for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
   1929         var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
   1930         // but limit overreserving (default to capping at +96MB overgrowth at most)
   1931         overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 );
   1932   
   1933         var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
   1934   
   1935         var replacement = emscripten_realloc_buffer(newSize);
   1936         if (replacement) {
   1937   
   1938           return true;
   1939         }
   1940       }
   1941       err('Failed to grow the heap from ' + oldSize + ' bytes to ' + newSize + ' bytes, not enough memory!');
   1942       return false;
   1943     }
   1944 var ASSERTIONS = true;
   1945 
   1946 
   1947 
   1948 /** @type {function(string, boolean=, number=)} */
   1949 function intArrayFromString(stringy, dontAddNull, length) {
   1950   var len = length > 0 ? length : lengthBytesUTF8(stringy)+1;
   1951   var u8array = new Array(len);
   1952   var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
   1953   if (dontAddNull) u8array.length = numBytesWritten;
   1954   return u8array;
   1955 }
   1956 
   1957 function intArrayToString(array) {
   1958   var ret = [];
   1959   for (var i = 0; i < array.length; i++) {
   1960     var chr = array[i];
   1961     if (chr > 0xFF) {
   1962       if (ASSERTIONS) {
   1963         assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ')  at offset ' + i + ' not in 0x00-0xFF.');
   1964       }
   1965       chr &= 0xFF;
   1966     }
   1967     ret.push(String.fromCharCode(chr));
   1968   }
   1969   return ret.join('');
   1970 }
   1971 
   1972 
   1973 function checkIncomingModuleAPI() {
   1974   ignoredModuleProp('fetchSettings');
   1975 }
   1976 var asmLibraryArg = {
   1977   "emscripten_resize_heap": _emscripten_resize_heap
   1978 };
   1979 var asm = createWasm();
   1980 /** @type {function(...*):?} */
   1981 var ___wasm_call_ctors = Module["___wasm_call_ctors"] = createExportWrapper("__wasm_call_ctors");
   1982 
   1983 /** @type {function(...*):?} */
   1984 var _base8_encodeBytes = Module["_base8_encodeBytes"] = createExportWrapper("base8_encodeBytes");
   1985 
   1986 /** @type {function(...*):?} */
   1987 var _base8_stringToNum = Module["_base8_stringToNum"] = createExportWrapper("base8_stringToNum");
   1988 
   1989 /** @type {function(...*):?} */
   1990 var _base8_decodeNum = Module["_base8_decodeNum"] = createExportWrapper("base8_decodeNum");
   1991 
   1992 /** @type {function(...*):?} */
   1993 var ___errno_location = Module["___errno_location"] = createExportWrapper("__errno_location");
   1994 
   1995 /** @type {function(...*):?} */
   1996 var ___stdio_exit = Module["___stdio_exit"] = createExportWrapper("__stdio_exit");
   1997 
   1998 /** @type {function(...*):?} */
   1999 var _malloc = Module["_malloc"] = createExportWrapper("malloc");
   2000 
   2001 /** @type {function(...*):?} */
   2002 var _free = Module["_free"] = createExportWrapper("free");
   2003 
   2004 /** @type {function(...*):?} */
   2005 var _emscripten_stack_init = Module["_emscripten_stack_init"] = function() {
   2006   return (_emscripten_stack_init = Module["_emscripten_stack_init"] = Module["asm"]["emscripten_stack_init"]).apply(null, arguments);
   2007 };
   2008 
   2009 /** @type {function(...*):?} */
   2010 var _emscripten_stack_get_free = Module["_emscripten_stack_get_free"] = function() {
   2011   return (_emscripten_stack_get_free = Module["_emscripten_stack_get_free"] = Module["asm"]["emscripten_stack_get_free"]).apply(null, arguments);
   2012 };
   2013 
   2014 /** @type {function(...*):?} */
   2015 var _emscripten_stack_get_base = Module["_emscripten_stack_get_base"] = function() {
   2016   return (_emscripten_stack_get_base = Module["_emscripten_stack_get_base"] = Module["asm"]["emscripten_stack_get_base"]).apply(null, arguments);
   2017 };
   2018 
   2019 /** @type {function(...*):?} */
   2020 var _emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = function() {
   2021   return (_emscripten_stack_get_end = Module["_emscripten_stack_get_end"] = Module["asm"]["emscripten_stack_get_end"]).apply(null, arguments);
   2022 };
   2023 
   2024 /** @type {function(...*):?} */
   2025 var stackSave = Module["stackSave"] = createExportWrapper("stackSave");
   2026 
   2027 /** @type {function(...*):?} */
   2028 var stackRestore = Module["stackRestore"] = createExportWrapper("stackRestore");
   2029 
   2030 /** @type {function(...*):?} */
   2031 var stackAlloc = Module["stackAlloc"] = createExportWrapper("stackAlloc");
   2032 
   2033 
   2034 
   2035 
   2036 
   2037 // === Auto-generated postamble setup entry stuff ===
   2038 
   2039 Module["intArrayFromString"] = intArrayFromString;
   2040 unexportedRuntimeFunction('intArrayToString', false);
   2041 unexportedRuntimeFunction('ccall', false);
   2042 Module["cwrap"] = cwrap;
   2043 unexportedRuntimeFunction('setValue', false);
   2044 unexportedRuntimeFunction('getValue', false);
   2045 Module["allocate"] = allocate;
   2046 unexportedRuntimeFunction('UTF8ArrayToString', false);
   2047 Module["UTF8ToString"] = UTF8ToString;
   2048 unexportedRuntimeFunction('stringToUTF8Array', false);
   2049 unexportedRuntimeFunction('stringToUTF8', false);
   2050 unexportedRuntimeFunction('lengthBytesUTF8', false);
   2051 unexportedRuntimeFunction('stackTrace', false);
   2052 unexportedRuntimeFunction('addOnPreRun', false);
   2053 unexportedRuntimeFunction('addOnInit', false);
   2054 unexportedRuntimeFunction('addOnPreMain', false);
   2055 unexportedRuntimeFunction('addOnExit', false);
   2056 unexportedRuntimeFunction('addOnPostRun', false);
   2057 unexportedRuntimeFunction('writeStringToMemory', false);
   2058 unexportedRuntimeFunction('writeArrayToMemory', false);
   2059 unexportedRuntimeFunction('writeAsciiToMemory', false);
   2060 unexportedRuntimeFunction('addRunDependency', true);
   2061 unexportedRuntimeFunction('removeRunDependency', true);
   2062 unexportedRuntimeFunction('FS_createFolder', false);
   2063 unexportedRuntimeFunction('FS_createPath', true);
   2064 unexportedRuntimeFunction('FS_createDataFile', true);
   2065 unexportedRuntimeFunction('FS_createPreloadedFile', true);
   2066 unexportedRuntimeFunction('FS_createLazyFile', true);
   2067 unexportedRuntimeFunction('FS_createLink', false);
   2068 unexportedRuntimeFunction('FS_createDevice', true);
   2069 unexportedRuntimeFunction('FS_unlink', true);
   2070 unexportedRuntimeFunction('getLEB', false);
   2071 unexportedRuntimeFunction('getFunctionTables', false);
   2072 unexportedRuntimeFunction('alignFunctionTables', false);
   2073 unexportedRuntimeFunction('registerFunctions', false);
   2074 unexportedRuntimeFunction('addFunction', false);
   2075 unexportedRuntimeFunction('removeFunction', false);
   2076 unexportedRuntimeFunction('getFuncWrapper', false);
   2077 unexportedRuntimeFunction('prettyPrint', false);
   2078 unexportedRuntimeFunction('dynCall', false);
   2079 unexportedRuntimeFunction('getCompilerSetting', false);
   2080 unexportedRuntimeFunction('print', false);
   2081 unexportedRuntimeFunction('printErr', false);
   2082 unexportedRuntimeFunction('getTempRet0', false);
   2083 unexportedRuntimeFunction('setTempRet0', false);
   2084 unexportedRuntimeFunction('callMain', false);
   2085 unexportedRuntimeFunction('abort', false);
   2086 unexportedRuntimeFunction('keepRuntimeAlive', false);
   2087 unexportedRuntimeFunction('zeroMemory', false);
   2088 unexportedRuntimeFunction('stringToNewUTF8', false);
   2089 unexportedRuntimeFunction('emscripten_realloc_buffer', false);
   2090 unexportedRuntimeFunction('ENV', false);
   2091 unexportedRuntimeFunction('withStackSave', false);
   2092 unexportedRuntimeFunction('ERRNO_CODES', false);
   2093 unexportedRuntimeFunction('ERRNO_MESSAGES', false);
   2094 unexportedRuntimeFunction('setErrNo', false);
   2095 unexportedRuntimeFunction('inetPton4', false);
   2096 unexportedRuntimeFunction('inetNtop4', false);
   2097 unexportedRuntimeFunction('inetPton6', false);
   2098 unexportedRuntimeFunction('inetNtop6', false);
   2099 unexportedRuntimeFunction('readSockaddr', false);
   2100 unexportedRuntimeFunction('writeSockaddr', false);
   2101 unexportedRuntimeFunction('DNS', false);
   2102 unexportedRuntimeFunction('getHostByName', false);
   2103 unexportedRuntimeFunction('Protocols', false);
   2104 unexportedRuntimeFunction('Sockets', false);
   2105 unexportedRuntimeFunction('getRandomDevice', false);
   2106 unexportedRuntimeFunction('traverseStack', false);
   2107 unexportedRuntimeFunction('convertFrameToPC', false);
   2108 unexportedRuntimeFunction('UNWIND_CACHE', false);
   2109 unexportedRuntimeFunction('saveInUnwindCache', false);
   2110 unexportedRuntimeFunction('convertPCtoSourceLocation', false);
   2111 unexportedRuntimeFunction('readAsmConstArgsArray', false);
   2112 unexportedRuntimeFunction('readAsmConstArgs', false);
   2113 unexportedRuntimeFunction('mainThreadEM_ASM', false);
   2114 unexportedRuntimeFunction('jstoi_q', false);
   2115 unexportedRuntimeFunction('jstoi_s', false);
   2116 unexportedRuntimeFunction('getExecutableName', false);
   2117 unexportedRuntimeFunction('listenOnce', false);
   2118 unexportedRuntimeFunction('autoResumeAudioContext', false);
   2119 unexportedRuntimeFunction('dynCallLegacy', false);
   2120 unexportedRuntimeFunction('getDynCaller', false);
   2121 unexportedRuntimeFunction('dynCall', false);
   2122 unexportedRuntimeFunction('callRuntimeCallbacks', false);
   2123 unexportedRuntimeFunction('wasmTableMirror', false);
   2124 unexportedRuntimeFunction('setWasmTableEntry', false);
   2125 unexportedRuntimeFunction('getWasmTableEntry', false);
   2126 unexportedRuntimeFunction('handleException', false);
   2127 unexportedRuntimeFunction('runtimeKeepalivePush', false);
   2128 unexportedRuntimeFunction('runtimeKeepalivePop', false);
   2129 unexportedRuntimeFunction('callUserCallback', false);
   2130 unexportedRuntimeFunction('maybeExit', false);
   2131 unexportedRuntimeFunction('safeSetTimeout', false);
   2132 unexportedRuntimeFunction('asmjsMangle', false);
   2133 unexportedRuntimeFunction('asyncLoad', false);
   2134 unexportedRuntimeFunction('alignMemory', false);
   2135 unexportedRuntimeFunction('mmapAlloc', false);
   2136 unexportedRuntimeFunction('reallyNegative', false);
   2137 unexportedRuntimeFunction('unSign', false);
   2138 unexportedRuntimeFunction('reSign', false);
   2139 unexportedRuntimeFunction('formatString', false);
   2140 unexportedRuntimeFunction('PATH', false);
   2141 unexportedRuntimeFunction('PATH_FS', false);
   2142 unexportedRuntimeFunction('SYSCALLS', false);
   2143 unexportedRuntimeFunction('getSocketFromFD', false);
   2144 unexportedRuntimeFunction('getSocketAddress', false);
   2145 unexportedRuntimeFunction('JSEvents', false);
   2146 unexportedRuntimeFunction('registerKeyEventCallback', false);
   2147 unexportedRuntimeFunction('specialHTMLTargets', false);
   2148 unexportedRuntimeFunction('maybeCStringToJsString', false);
   2149 unexportedRuntimeFunction('findEventTarget', false);
   2150 unexportedRuntimeFunction('findCanvasEventTarget', false);
   2151 unexportedRuntimeFunction('getBoundingClientRect', false);
   2152 unexportedRuntimeFunction('fillMouseEventData', false);
   2153 unexportedRuntimeFunction('registerMouseEventCallback', false);
   2154 unexportedRuntimeFunction('registerWheelEventCallback', false);
   2155 unexportedRuntimeFunction('registerUiEventCallback', false);
   2156 unexportedRuntimeFunction('registerFocusEventCallback', false);
   2157 unexportedRuntimeFunction('fillDeviceOrientationEventData', false);
   2158 unexportedRuntimeFunction('registerDeviceOrientationEventCallback', false);
   2159 unexportedRuntimeFunction('fillDeviceMotionEventData', false);
   2160 unexportedRuntimeFunction('registerDeviceMotionEventCallback', false);
   2161 unexportedRuntimeFunction('screenOrientation', false);
   2162 unexportedRuntimeFunction('fillOrientationChangeEventData', false);
   2163 unexportedRuntimeFunction('registerOrientationChangeEventCallback', false);
   2164 unexportedRuntimeFunction('fillFullscreenChangeEventData', false);
   2165 unexportedRuntimeFunction('registerFullscreenChangeEventCallback', false);
   2166 unexportedRuntimeFunction('registerRestoreOldStyle', false);
   2167 unexportedRuntimeFunction('hideEverythingExceptGivenElement', false);
   2168 unexportedRuntimeFunction('restoreHiddenElements', false);
   2169 unexportedRuntimeFunction('setLetterbox', false);
   2170 unexportedRuntimeFunction('currentFullscreenStrategy', false);
   2171 unexportedRuntimeFunction('restoreOldWindowedStyle', false);
   2172 unexportedRuntimeFunction('softFullscreenResizeWebGLRenderTarget', false);
   2173 unexportedRuntimeFunction('doRequestFullscreen', false);
   2174 unexportedRuntimeFunction('fillPointerlockChangeEventData', false);
   2175 unexportedRuntimeFunction('registerPointerlockChangeEventCallback', false);
   2176 unexportedRuntimeFunction('registerPointerlockErrorEventCallback', false);
   2177 unexportedRuntimeFunction('requestPointerLock', false);
   2178 unexportedRuntimeFunction('fillVisibilityChangeEventData', false);
   2179 unexportedRuntimeFunction('registerVisibilityChangeEventCallback', false);
   2180 unexportedRuntimeFunction('registerTouchEventCallback', false);
   2181 unexportedRuntimeFunction('fillGamepadEventData', false);
   2182 unexportedRuntimeFunction('registerGamepadEventCallback', false);
   2183 unexportedRuntimeFunction('registerBeforeUnloadEventCallback', false);
   2184 unexportedRuntimeFunction('fillBatteryEventData', false);
   2185 unexportedRuntimeFunction('battery', false);
   2186 unexportedRuntimeFunction('registerBatteryEventCallback', false);
   2187 unexportedRuntimeFunction('setCanvasElementSize', false);
   2188 unexportedRuntimeFunction('getCanvasElementSize', false);
   2189 unexportedRuntimeFunction('demangle', false);
   2190 unexportedRuntimeFunction('demangleAll', false);
   2191 unexportedRuntimeFunction('jsStackTrace', false);
   2192 unexportedRuntimeFunction('stackTrace', false);
   2193 unexportedRuntimeFunction('getEnvStrings', false);
   2194 unexportedRuntimeFunction('checkWasiClock', false);
   2195 unexportedRuntimeFunction('flush_NO_FILESYSTEM', false);
   2196 unexportedRuntimeFunction('writeI53ToI64', false);
   2197 unexportedRuntimeFunction('writeI53ToI64Clamped', false);
   2198 unexportedRuntimeFunction('writeI53ToI64Signaling', false);
   2199 unexportedRuntimeFunction('writeI53ToU64Clamped', false);
   2200 unexportedRuntimeFunction('writeI53ToU64Signaling', false);
   2201 unexportedRuntimeFunction('readI53FromI64', false);
   2202 unexportedRuntimeFunction('readI53FromU64', false);
   2203 unexportedRuntimeFunction('convertI32PairToI53', false);
   2204 unexportedRuntimeFunction('convertU32PairToI53', false);
   2205 unexportedRuntimeFunction('setImmediateWrapped', false);
   2206 unexportedRuntimeFunction('clearImmediateWrapped', false);
   2207 unexportedRuntimeFunction('polyfillSetImmediate', false);
   2208 unexportedRuntimeFunction('uncaughtExceptionCount', false);
   2209 unexportedRuntimeFunction('exceptionLast', false);
   2210 unexportedRuntimeFunction('exceptionCaught', false);
   2211 unexportedRuntimeFunction('ExceptionInfo', false);
   2212 unexportedRuntimeFunction('CatchInfo', false);
   2213 unexportedRuntimeFunction('exception_addRef', false);
   2214 unexportedRuntimeFunction('exception_decRef', false);
   2215 unexportedRuntimeFunction('Browser', false);
   2216 unexportedRuntimeFunction('funcWrappers', false);
   2217 unexportedRuntimeFunction('getFuncWrapper', false);
   2218 unexportedRuntimeFunction('setMainLoop', false);
   2219 unexportedRuntimeFunction('wget', false);
   2220 unexportedRuntimeFunction('FS', false);
   2221 unexportedRuntimeFunction('MEMFS', false);
   2222 unexportedRuntimeFunction('TTY', false);
   2223 unexportedRuntimeFunction('PIPEFS', false);
   2224 unexportedRuntimeFunction('SOCKFS', false);
   2225 unexportedRuntimeFunction('_setNetworkCallback', false);
   2226 unexportedRuntimeFunction('tempFixedLengthArray', false);
   2227 unexportedRuntimeFunction('miniTempWebGLFloatBuffers', false);
   2228 unexportedRuntimeFunction('heapObjectForWebGLType', false);
   2229 unexportedRuntimeFunction('heapAccessShiftForWebGLHeap', false);
   2230 unexportedRuntimeFunction('GL', false);
   2231 unexportedRuntimeFunction('emscriptenWebGLGet', false);
   2232 unexportedRuntimeFunction('computeUnpackAlignedImageSize', false);
   2233 unexportedRuntimeFunction('emscriptenWebGLGetTexPixelData', false);
   2234 unexportedRuntimeFunction('emscriptenWebGLGetUniform', false);
   2235 unexportedRuntimeFunction('webglGetUniformLocation', false);
   2236 unexportedRuntimeFunction('webglPrepareUniformLocationsBeforeFirstUse', false);
   2237 unexportedRuntimeFunction('webglGetLeftBracePos', false);
   2238 unexportedRuntimeFunction('emscriptenWebGLGetVertexAttrib', false);
   2239 unexportedRuntimeFunction('writeGLArray', false);
   2240 unexportedRuntimeFunction('AL', false);
   2241 unexportedRuntimeFunction('SDL_unicode', false);
   2242 unexportedRuntimeFunction('SDL_ttfContext', false);
   2243 unexportedRuntimeFunction('SDL_audio', false);
   2244 unexportedRuntimeFunction('SDL', false);
   2245 unexportedRuntimeFunction('SDL_gfx', false);
   2246 unexportedRuntimeFunction('GLUT', false);
   2247 unexportedRuntimeFunction('EGL', false);
   2248 unexportedRuntimeFunction('GLFW_Window', false);
   2249 unexportedRuntimeFunction('GLFW', false);
   2250 unexportedRuntimeFunction('GLEW', false);
   2251 unexportedRuntimeFunction('IDBStore', false);
   2252 unexportedRuntimeFunction('runAndAbortIfError', false);
   2253 unexportedRuntimeFunction('warnOnce', false);
   2254 unexportedRuntimeFunction('stackSave', false);
   2255 unexportedRuntimeFunction('stackRestore', false);
   2256 unexportedRuntimeFunction('stackAlloc', false);
   2257 unexportedRuntimeFunction('AsciiToString', false);
   2258 unexportedRuntimeFunction('stringToAscii', false);
   2259 unexportedRuntimeFunction('UTF16ToString', false);
   2260 unexportedRuntimeFunction('stringToUTF16', false);
   2261 unexportedRuntimeFunction('lengthBytesUTF16', false);
   2262 unexportedRuntimeFunction('UTF32ToString', false);
   2263 unexportedRuntimeFunction('stringToUTF32', false);
   2264 unexportedRuntimeFunction('lengthBytesUTF32', false);
   2265 Module["allocateUTF8"] = allocateUTF8;
   2266 unexportedRuntimeFunction('allocateUTF8OnStack', false);
   2267 Module["writeStackCookie"] = writeStackCookie;
   2268 Module["checkStackCookie"] = checkStackCookie;
   2269 unexportedRuntimeSymbol('ALLOC_NORMAL', false);
   2270 unexportedRuntimeSymbol('ALLOC_STACK', false);
   2271 
   2272 var calledRun;
   2273 
   2274 /**
   2275  * @constructor
   2276  * @this {ExitStatus}
   2277  */
   2278 function ExitStatus(status) {
   2279   this.name = "ExitStatus";
   2280   this.message = "Program terminated with exit(" + status + ")";
   2281   this.status = status;
   2282 }
   2283 
   2284 var calledMain = false;
   2285 
   2286 dependenciesFulfilled = function runCaller() {
   2287   // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
   2288   if (!calledRun) run();
   2289   if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
   2290 };
   2291 
   2292 function stackCheckInit() {
   2293   // This is normally called automatically during __wasm_call_ctors but need to
   2294   // get these values before even running any of the ctors so we call it redundantly
   2295   // here.
   2296   // TODO(sbc): Move writeStackCookie to native to to avoid this.
   2297   _emscripten_stack_init();
   2298   writeStackCookie();
   2299 }
   2300 
   2301 /** @type {function(Array=)} */
   2302 function run(args) {
   2303   args = args || arguments_;
   2304 
   2305   if (runDependencies > 0) {
   2306     return;
   2307   }
   2308 
   2309   stackCheckInit();
   2310 
   2311   preRun();
   2312 
   2313   // a preRun added a dependency, run will be called later
   2314   if (runDependencies > 0) {
   2315     return;
   2316   }
   2317 
   2318   function doRun() {
   2319     // run may have just been called through dependencies being fulfilled just in this very frame,
   2320     // or while the async setStatus time below was happening
   2321     if (calledRun) return;
   2322     calledRun = true;
   2323     Module['calledRun'] = true;
   2324 
   2325     if (ABORT) return;
   2326 
   2327     initRuntime();
   2328 
   2329     readyPromiseResolve(Module);
   2330     if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized']();
   2331 
   2332     assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
   2333 
   2334     postRun();
   2335   }
   2336 
   2337   if (Module['setStatus']) {
   2338     Module['setStatus']('Running...');
   2339     setTimeout(function() {
   2340       setTimeout(function() {
   2341         Module['setStatus']('');
   2342       }, 1);
   2343       doRun();
   2344     }, 1);
   2345   } else
   2346   {
   2347     doRun();
   2348   }
   2349   checkStackCookie();
   2350 }
   2351 Module['run'] = run;
   2352 
   2353 function checkUnflushedContent() {
   2354   // Compiler settings do not allow exiting the runtime, so flushing
   2355   // the streams is not possible. but in ASSERTIONS mode we check
   2356   // if there was something to flush, and if so tell the user they
   2357   // should request that the runtime be exitable.
   2358   // Normally we would not even include flush() at all, but in ASSERTIONS
   2359   // builds we do so just for this check, and here we see if there is any
   2360   // content to flush, that is, we check if there would have been
   2361   // something a non-ASSERTIONS build would have not seen.
   2362   // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
   2363   // mode (which has its own special function for this; otherwise, all
   2364   // the code is inside libc)
   2365   var oldOut = out;
   2366   var oldErr = err;
   2367   var has = false;
   2368   out = err = (x) => {
   2369     has = true;
   2370   }
   2371   try { // it doesn't matter if it fails
   2372     var flush = null;
   2373     if (flush) flush();
   2374   } catch(e) {}
   2375   out = oldOut;
   2376   err = oldErr;
   2377   if (has) {
   2378     warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc.');
   2379     warnOnce('(this may also be due to not including full filesystem support - try building with -s FORCE_FILESYSTEM=1)');
   2380   }
   2381 }
   2382 
   2383 /** @param {boolean|number=} implicit */
   2384 function exit(status, implicit) {
   2385   EXITSTATUS = status;
   2386 
   2387   // Skip this check if the runtime is being kept alive deliberately.
   2388   // For example if `exit_with_live_runtime` is called.
   2389   if (!runtimeKeepaliveCounter) {
   2390     checkUnflushedContent();
   2391   }
   2392 
   2393   if (keepRuntimeAlive()) {
   2394     // if exit() was called, we may warn the user if the runtime isn't actually being shut down
   2395     if (!implicit) {
   2396       var msg = 'program exited (with status: ' + status + '), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)';
   2397       readyPromiseReject(msg);
   2398       err(msg);
   2399     }
   2400   } else {
   2401     exitRuntime();
   2402   }
   2403 
   2404   procExit(status);
   2405 }
   2406 
   2407 function procExit(code) {
   2408   EXITSTATUS = code;
   2409   if (!keepRuntimeAlive()) {
   2410     if (Module['onExit']) Module['onExit'](code);
   2411     ABORT = true;
   2412   }
   2413   quit_(code, new ExitStatus(code));
   2414 }
   2415 
   2416 if (Module['preInit']) {
   2417   if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
   2418   while (Module['preInit'].length > 0) {
   2419     Module['preInit'].pop()();
   2420   }
   2421 }
   2422 
   2423 run();
   2424 
   2425 
   2426 
   2427 
   2428 
   2429 
   2430 
   2431   return Base8Module.ready
   2432 }
   2433 );
   2434 })();
   2435 if (typeof exports === 'object' && typeof module === 'object')
   2436   module.exports = Base8Module;
   2437 else if (typeof define === 'function' && define['amd'])
   2438   define([], function() { return Base8Module; });
   2439 else if (typeof exports === 'object')
   2440   exports["Base8Module"] = Base8Module;