#if HAS_MAIN
#if EXIT_RUNTIME
function exitRuntime(ret) {
<<< ATEXITS >>>
#if PTHREADS
PThread.terminateAllThreads();
#endif
#if ASSERTIONS
runtimeExited = true;
#endif
_proc_exit(ret);
#if STACK_OVERFLOW_CHECK
checkStackCookie();
#endif
}
#endif
function run() {
#if MEMORYPROFILER
emscriptenMemoryProfiler.onPreloadComplete();
#endif
<<< ATMAINS >>>
#if PROXY_TO_PTHREAD
__emscripten_proxy_main();
#elif ASYNCIFY == 2 && EXIT_RUNTIME
_main().then(exitRuntime);
#elif EXIT_RUNTIME
exitRuntime(_main());
#else
_main();
#endif
#if STACK_OVERFLOW_CHECK
checkStackCookie();
#endif
<<< ATPOSTRUNS >>>
}
#endif
function initRuntime(wasmExports) {
#if ASSERTIONS || SAFE_HEAP || USE_ASAN || MODULARIZE
runtimeInitialized = true;
#endif
#if PTHREADS
PThread.tlsInitFunctions.push(wasmExports['_emscripten_tls_init']);
if (ENVIRONMENT_IS_PTHREAD) return;
#endif
#if WASM_WORKERS
if (ENVIRONMENT_IS_WASM_WORKER) return _wasmWorkerInitializeRuntime();
#endif
#if STACK_OVERFLOW_CHECK
_emscripten_stack_init();
#if STACK_OVERFLOW_CHECK >= 2
setStackLimits();
#endif
writeStackCookie();
#endif
<<< ATINITS >>>
#if hasExportedSymbol('__wasm_call_ctors')
wasmExports['__wasm_call_ctors']();
#endif
<<< ATPOSTCTORS >>>
}
#if SINGLE_FILE && WASM == 1 && !WASM2JS
Module['wasm'] = base64Decode('<<< WASM_BINARY_DATA >>>');
#endif
#if LibraryManager.has('libexports.js')
var wasmExports;
#endif
#if PTHREADS || WASM_WORKERS
var wasmModule;
function loadModule() {
assignWasmImports();
#endif
#if ASYNCIFY
Asyncify.instrumentWasmImports(wasmImports);
#endif
var imports = {
#if MINIFY_WASM_IMPORTED_MODULES
'a': wasmImports,
#else
'env': wasmImports,
'{{{ WASI_MODULE_NAME }}}': wasmImports,
#endif
};
#if MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION
#if MIN_FIREFOX_VERSION < 58 || MIN_CHROME_VERSION < 61 || MIN_SAFARI_VERSION < 150000 || ENVIRONMENT_MAY_BE_NODE
#if ASSERTIONS && !WASM2JS
assert(WebAssembly.instantiateStreaming || Module['wasm'], 'Must load WebAssembly Module in to variable Module.wasm before adding compiled output .js script to the DOM');
#endif
#if AUDIO_WORKLET
instantiatePromise =
#endif
(WebAssembly.instantiateStreaming
#if ENVIRONMENT_MAY_BE_NODE
&& !ENVIRONMENT_IS_NODE
#endif
? WebAssembly.instantiateStreaming(fetch('{{{ TARGET_BASENAME }}}.wasm'), imports)
: WebAssembly.instantiate(Module['wasm'], imports)).then((output) => {
#else
#if AUDIO_WORKLET
instantiatePromise =
#endif
WebAssembly.instantiateStreaming(fetch('{{{ TARGET_BASENAME }}}.wasm'), imports).then((output) => {
#endif
#else
#if ASSERTIONS && !WASM2JS
assert(Module['wasm'], 'Must load WebAssembly Module in to variable Module.wasm before adding compiled output .js script to the DOM');
#endif
<<< ATMODULES >>>
{{{ exportJSSymbols() }}}
#if AUDIO_WORKLET
instantiatePromise =
#endif
WebAssembly.instantiate(Module['wasm'], imports).then( (output) => {
#endif
#if !LibraryManager.has('libexports.js') && ASYNCIFY != 1
var
#endif
#if PTHREADS || WASM_WORKERS
wasmExports = (output.instance || output).exports;
wasmModule = output.module || Module['wasm'];
#elif MINIMAL_RUNTIME_STREAMING_WASM_COMPILATION
wasmExports = output.exports;
#else
wasmExports = output.instance.exports;
#endif
#if ASYNCIFY
wasmExports = Asyncify.instrumentWasmExports(wasmExports);
#endif
#if MEMORY64 || CAN_ADDRESS_2GB
wasmExports = applySignatureConversions(wasmExports);
#endif
#if !DECLARE_ASM_MODULE_EXPORTS
exportWasmSymbols(wasmExports);
#else
assignWasmExports(wasmExports);
#endif
#if '$wasmTable' in addedLibraryItems
wasmTable = wasmExports['__indirect_function_table'];
#if ASSERTIONS
assert(wasmTable);
#endif
#endif
#if AUDIO_WORKLET
#if ASSERTIONS
delete Module['stackSave'];
delete Module['stackAlloc'];
delete Module['stackRestore'];
delete Module['wasmTable'];
#endif
Module['stackSave'] = stackSave;
Module['stackAlloc'] = stackAlloc;
Module['stackRestore'] = stackRestore;
Module['wasmTable'] = wasmTable;
#endif
#if !IMPORTED_MEMORY
wasmMemory = wasmExports['memory'];
#if ASSERTIONS
assert(wasmMemory);
#endif
updateMemoryViews();
#endif
<<< ATPRERUNS >>>
initRuntime(wasmExports);
#if PTHREADS && PTHREAD_POOL_SIZE
var workersReady = PThread.loadWasmModuleToAllWorkers();
#if PTHREAD_POOL_DELAY_LOAD
ready();
#else
workersReady.then(ready);
#endif
#else
ready();
#endif
}
#if WASM == 2
, (error) => {
#if ASSERTIONS
console.error(error);
#endif
#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL
if (typeof location != 'undefined') {
#endif
var search = location.search;
if (search.indexOf('_rwasm=0') < 0) {
location.href += (search ? search + '&' : '?') + '_rwasm=0';
}
#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL
}
#endif
}
#endif
);
#if PTHREADS || WASM_WORKERS
}
{{{ runIfMainThread('loadModule();') }}}
#endif