diff --git a/doc/notes.txt b/doc/notes.txt index af6b0df9..dfa6391d 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -134,6 +134,7 @@ TODO: - VCS asm game library - VCS skips step on lsr/lsr after run to line - better VCS single stepping, maybe also listings + - upgrade to 4.1 for Supercharger format - upload multiple files/zip file to subdirectory - allow "include graphics.asm" instead of "include project/graphics.asm" - convert more stuff to Promises @@ -160,6 +161,7 @@ TODO: - ctrl+alt+l on ubuntu locks screen - alt-D doesn't work anymore - facade/kbd shortcuts for emulators, focus + - maybe eat key events? ("'" messes things up) - cookie - list of stuff for policy - popup @@ -193,6 +195,7 @@ TODO: - Debug Browser - more stuff like 7800 display lists - don't include start/end line on platforms w/o raster timing +- memory map shows subroutine symbol even after RTS WEB WORKER FORMAT diff --git a/lib/makewav.js b/lib/makewav.js new file mode 100644 index 00000000..4d7a30b1 --- /dev/null +++ b/lib/makewav.js @@ -0,0 +1,40 @@ + +var makewav = (function() { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(makewav) { + makewav = makewav || {}; + +var Module=typeof makewav!=="undefined"?makewav:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var arguments_=[];var thisProgram="./this.program";var quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;var nodeFS;var nodePath;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=function shell_read(filename,binary){var ret=tryParseAsDataURI(filename);if(ret){return binary?ret:ret.toString()}if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);return nodeFS["readFileSync"](filename,binary?null:"utf8")};readBinary=function readBinary(filename){var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",abort);quit_=function(status){process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){read_=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}readBinary=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){arguments_=scriptArgs}else if(typeof arguments!="undefined"){arguments_=arguments}if(typeof quit==="function"){quit_=function(status){quit(status)}}if(typeof print!=="undefined"){if(typeof console==="undefined")console={};console.log=print;console.warn=console.error=typeof printErr!=="undefined"?printErr:print}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){readBinary=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}readAsync=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=function(title){document.title=title}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var STACK_ALIGN=16;function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=Number(type.substr(1));assert(bits%8===0,"getNativeTypeSize invalid bits "+bits+", type "+type);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;err(text)}}function convertJsFunctionToWasm(func,sig){return func}var freeTableIndexes=[];var functionsInTableMap;function addFunctionWasm(func,sig){var table=wasmTable;if(!functionsInTableMap){functionsInTableMap=new WeakMap;for(var i=0;i=11+0){abort("Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH.")}ret.push(null)};ret.set=function(i,func){ret[i]=func};ret.get=function(i){return ret[i]};return ret},Module:function(binary){return{}},Instance:function(module,info){var exports=( +// EMSCRIPTEN_START_ASM +function a(asmLibraryArg,wasmMemory,wasmTable){var scratchBuffer=new ArrayBuffer(8);var b=new Int32Array(scratchBuffer);var c=new Float32Array(scratchBuffer);var d=new Float64Array(scratchBuffer);function e(index){return b[index]}function f(index,value){b[index]=value}function g(){return d[0]}function h(value){d[0]=value}function i(low,high){b[0]=low;b[1]=high}function j(value){c[0]=value}function k(){return c[0]}function l(global,env,buffer){var m=env.memory;var n=wasmTable;var o=new global.Int8Array(buffer);var p=new global.Int16Array(buffer);var q=new global.Int32Array(buffer);var r=new global.Uint8Array(buffer);var s=new global.Uint16Array(buffer);var t=new global.Uint32Array(buffer);var u=new global.Float32Array(buffer);var v=new global.Float64Array(buffer);var w=global.Math.imul;var x=global.Math.fround;var y=global.Math.abs;var z=global.Math.clz32;var A=global.Math.min;var B=global.Math.max;var C=global.Math.floor;var D=global.Math.ceil;var E=global.Math.sqrt;var F=env.abort;var G=global.NaN;var H=global.Infinity;var I=env.exit;var J=env.__sys_open;var K=env.__sys_fcntl64;var L=env.__sys_ioctl;var M=env.fd_write;var N=env.fd_close;var O=env.fd_read;var P=env.emscripten_resize_heap;var Q=env.emscripten_memcpy_big;var R=env.setTempRet0;var S=env.fd_seek;var T=5325824;var U=82784;var V=0; +// EMSCRIPTEN_START_FUNCS +function kc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;l=T-16|0;T=l;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{if(a>>>0<=244){f=q[20572];h=a>>>0<11?16:a+11&-8;b=h>>>3|0;a=f>>>b|0;if(a&3){d=b+((a^-1)&1)|0;b=d<<3;e=q[b+82336>>2];a=e+8|0;c=q[e+8>>2];b=b+82328|0;l:{if((c|0)==(b|0)){q[20572]=Rc(d)&f;break l}q[c+12>>2]=b;q[b+8>>2]=c}b=d<<3;q[e+4>>2]=b|3;b=b+e|0;q[b+4>>2]=q[b+4>>2]|1;break a}k=q[20574];if(h>>>0<=k>>>0){break k}if(a){c=a<>>12&16;c=a;b=b>>>a|0;a=b>>>5&8;c=c|a;b=b>>>a|0;a=b>>>2&4;c=c|a;b=b>>>a|0;a=b>>>1&2;c=c|a;b=b>>>a|0;a=b>>>1&1;c=(c|a)+(b>>>a|0)|0;a=c<<3;g=q[a+82336>>2];b=q[g+8>>2];a=a+82328|0;m:{if((b|0)==(a|0)){f=Rc(c)&f;q[20572]=f;break m}q[b+12>>2]=a;q[a+8>>2]=b}a=g+8|0;q[g+4>>2]=h|3;d=g+h|0;b=c<<3;e=b-h|0;q[d+4>>2]=e|1;q[b+g>>2]=e;if(k){b=k>>>3|0;c=(b<<3)+82328|0;h=q[20577];b=1<>2]}q[c+8>>2]=h;q[b+12>>2]=h;q[h+12>>2]=c;q[h+8>>2]=b}q[20577]=d;q[20574]=e;break a}i=q[20573];if(!i){break k}b=(i&0-i)+ -1|0;a=b>>>12&16;c=a;b=b>>>a|0;a=b>>>5&8;c=c|a;b=b>>>a|0;a=b>>>2&4;c=c|a;b=b>>>a|0;a=b>>>1&2;c=c|a;b=b>>>a|0;a=b>>>1&1;b=q[((c|a)+(b>>>a|0)<<2)+82592>>2];d=(q[b+4>>2]&-8)-h|0;c=b;while(1){o:{a=q[c+16>>2];if(!a){a=q[c+20>>2];if(!a){break o}}c=(q[a+4>>2]&-8)-h|0;e=c>>>0>>0;d=e?c:d;b=e?a:b;c=a;continue}break}j=q[b+24>>2];e=q[b+12>>2];if((e|0)!=(b|0)){a=q[b+8>>2];q[a+12>>2]=e;q[e+8>>2]=a;break b}c=b+20|0;a=q[c>>2];if(!a){a=q[b+16>>2];if(!a){break j}c=b+16|0}while(1){g=c;e=a;c=a+20|0;a=q[c>>2];if(a){continue}c=e+16|0;a=q[e+16>>2];if(a){continue}break}q[g>>2]=0;break b}h=-1;if(a>>>0>4294967231){break k}a=a+11|0;h=a&-8;i=q[20573];if(!i){break k}a=a>>>8|0;g=0;p:{if(!a){break p}g=31;if(h>>>0>16777215){break p}b=a+1048320>>>16&8;a=a<>>16&4;a=a<>>16&2;a=(a<>>15|0)-(c|(b|d))|0;g=(a<<1|h>>>a+21&1)+28|0}c=0-h|0;d=q[(g<<2)+82592>>2];q:{r:{s:{if(!d){a=0;break s}b=h<<((g|0)==31?0:25-(g>>>1|0)|0);a=0;while(1){t:{f=(q[d+4>>2]&-8)-h|0;if(f>>>0>=c>>>0){break t}e=d;c=f;if(c){break t}c=0;a=d;break r}f=q[d+20>>2];d=q[((b>>>29&4)+d|0)+16>>2];a=f?(f|0)==(d|0)?a:f:a;b=b<<((d|0)!=0);if(d){continue}break}}if(!(a|e)){a=2<>>12&16;d=a;b=b>>>a|0;a=b>>>5&8;d=d|a;b=b>>>a|0;a=b>>>2&4;d=d|a;b=b>>>a|0;a=b>>>1&2;d=d|a;b=b>>>a|0;a=b>>>1&1;a=q[((d|a)+(b>>>a|0)<<2)+82592>>2]}if(!a){break q}}while(1){b=(q[a+4>>2]&-8)-h|0;d=b>>>0>>0;c=d?b:c;e=d?a:e;b=q[a+16>>2];if(b){a=b}else{a=q[a+20>>2]}if(a){continue}break}}if(!e|c>>>0>=q[20574]-h>>>0){break k}g=q[e+24>>2];b=q[e+12>>2];if((e|0)!=(b|0)){a=q[e+8>>2];q[a+12>>2]=b;q[b+8>>2]=a;break c}d=e+20|0;a=q[d>>2];if(!a){a=q[e+16>>2];if(!a){break i}d=e+16|0}while(1){f=d;b=a;d=a+20|0;a=q[d>>2];if(a){continue}d=b+16|0;a=q[b+16>>2];if(a){continue}break}q[f>>2]=0;break c}c=q[20574];if(c>>>0>=h>>>0){d=q[20577];b=c-h|0;u:{if(b>>>0>=16){q[20574]=b;a=d+h|0;q[20577]=a;q[a+4>>2]=b|1;q[c+d>>2]=b;q[d+4>>2]=h|3;break u}q[20577]=0;q[20574]=0;q[d+4>>2]=c|3;a=c+d|0;q[a+4>>2]=q[a+4>>2]|1}a=d+8|0;break a}j=q[20575];if(j>>>0>h>>>0){b=j-h|0;q[20575]=b;c=q[20578];a=c+h|0;q[20578]=a;q[a+4>>2]=b|1;q[c+4>>2]=h|3;a=c+8|0;break a}a=0;i=h+47|0;b=i;if(q[20690]){c=q[20692]}else{q[20693]=-1;q[20694]=-1;q[20691]=4096;q[20692]=4096;q[20690]=l+12&-16^1431655768;q[20695]=0;q[20683]=0;c=4096}g=b+c|0;f=0-c|0;c=g&f;if(c>>>0<=h>>>0){break a}e=q[20682];if(e){d=q[20680];b=d+c|0;if(b>>>0<=d>>>0|b>>>0>e>>>0){break a}}if(r[82732]&4){break f}v:{w:{d=q[20578];if(d){a=82736;while(1){b=q[a>>2];if(b+q[a+4>>2]>>>0>d>>>0?b>>>0<=d>>>0:0){break w}a=q[a+8>>2];if(a){continue}break}}b=pc(0);if((b|0)==-1){break g}f=c;d=q[20691];a=d+ -1|0;if(a&b){f=(c-b|0)+(a+b&0-d)|0}if(f>>>0<=h>>>0|f>>>0>2147483646){break g}e=q[20682];if(e){d=q[20680];a=d+f|0;if(a>>>0<=d>>>0|a>>>0>e>>>0){break g}}a=pc(f);if((b|0)!=(a|0)){break v}break e}f=f&g-j;if(f>>>0>2147483646){break g}b=pc(f);if((b|0)==(q[a>>2]+q[a+4>>2]|0)){break h}a=b}if(!((a|0)==-1|h+48>>>0<=f>>>0)){b=q[20692];b=b+(i-f|0)&0-b;if(b>>>0>2147483646){b=a;break e}if((pc(b)|0)!=-1){f=b+f|0;b=a;break e}pc(0-f|0);break g}b=a;if((a|0)!=-1){break e}break g}e=0;break b}b=0;break c}if((b|0)!=-1){break e}}q[20683]=q[20683]|4}if(c>>>0>2147483646){break d}b=pc(c);a=pc(0);if(b>>>0>=a>>>0|(b|0)==-1|(a|0)==-1){break d}f=a-b|0;if(f>>>0<=h+40>>>0){break d}}a=q[20680]+f|0;q[20680]=a;if(a>>>0>t[20681]){q[20681]=a}x:{y:{z:{d=q[20578];if(d){a=82736;while(1){e=q[a>>2];c=q[a+4>>2];if((e+c|0)==(b|0)){break z}a=q[a+8>>2];if(a){continue}break}break y}a=q[20576];if(!(b>>>0>=a>>>0?a:0)){q[20576]=b}a=0;q[20685]=f;q[20684]=b;q[20580]=-1;q[20581]=q[20690];q[20687]=0;while(1){d=a<<3;c=d+82328|0;q[d+82336>>2]=c;q[d+82340>>2]=c;a=a+1|0;if((a|0)!=32){continue}break}d=f+ -40|0;a=b+8&7?-8-b&7:0;c=d-a|0;q[20575]=c;a=a+b|0;q[20578]=a;q[a+4>>2]=c|1;q[(b+d|0)+4>>2]=40;q[20579]=q[20694];break x}if(r[a+12|0]&8|b>>>0<=d>>>0|e>>>0>d>>>0){break y}q[a+4>>2]=c+f;a=d+8&7?-8-d&7:0;c=a+d|0;q[20578]=c;b=q[20575]+f|0;a=b-a|0;q[20575]=a;q[c+4>>2]=a|1;q[(b+d|0)+4>>2]=40;q[20579]=q[20694];break x}e=q[20576];if(b>>>0>>0){q[20576]=b;e=0}c=b+f|0;a=82736;A:{B:{C:{D:{E:{F:{while(1){if((c|0)!=q[a>>2]){a=q[a+8>>2];if(a){continue}break F}break}if(!(r[a+12|0]&8)){break E}}a=82736;while(1){c=q[a>>2];if(c>>>0<=d>>>0){g=c+q[a+4>>2]|0;if(g>>>0>d>>>0){break D}}a=q[a+8>>2];continue}}q[a>>2]=b;q[a+4>>2]=q[a+4>>2]+f;j=(b+8&7?-8-b&7:0)+b|0;q[j+4>>2]=h|3;b=c+(c+8&7?-8-c&7:0)|0;a=(b-j|0)-h|0;g=h+j|0;if((b|0)==(d|0)){q[20578]=g;a=q[20575]+a|0;q[20575]=a;q[g+4>>2]=a|1;break B}if(q[20577]==(b|0)){q[20577]=g;a=q[20574]+a|0;q[20574]=a;q[g+4>>2]=a|1;q[a+g>>2]=a;break B}c=q[b+4>>2];if((c&3)==1){i=c&-8;G:{if(c>>>0<=255){e=q[b+8>>2];c=c>>>3|0;d=q[b+12>>2];if((d|0)==(e|0)){q[20572]=q[20572]&Rc(c);break G}q[e+12>>2]=d;q[d+8>>2]=e;break G}k=q[b+24>>2];f=q[b+12>>2];H:{if((f|0)!=(b|0)){c=q[b+8>>2];q[c+12>>2]=f;q[f+8>>2]=c;break H}I:{d=b+20|0;h=q[d>>2];if(h){break I}d=b+16|0;h=q[d>>2];if(h){break I}f=0;break H}while(1){c=d;f=h;d=f+20|0;h=q[d>>2];if(h){continue}d=f+16|0;h=q[f+16>>2];if(h){continue}break}q[c>>2]=0}if(!k){break G}d=q[b+28>>2];c=(d<<2)+82592|0;J:{if(q[c>>2]==(b|0)){q[c>>2]=f;if(f){break J}q[20573]=q[20573]&Rc(d);break G}q[k+(q[k+16>>2]==(b|0)?16:20)>>2]=f;if(!f){break G}}q[f+24>>2]=k;c=q[b+16>>2];if(c){q[f+16>>2]=c;q[c+24>>2]=f}c=q[b+20>>2];if(!c){break G}q[f+20>>2]=c;q[c+24>>2]=f}b=b+i|0;a=a+i|0}q[b+4>>2]=q[b+4>>2]&-2;q[g+4>>2]=a|1;q[a+g>>2]=a;if(a>>>0<=255){a=a>>>3|0;b=(a<<3)+82328|0;c=q[20572];a=1<>2]}q[b+8>>2]=g;q[a+12>>2]=g;q[g+12>>2]=b;q[g+8>>2]=a;break B}b=g;d=a>>>8|0;c=0;L:{if(!d){break L}c=31;if(a>>>0>16777215){break L}c=d;d=d+1048320>>>16&8;c=c<>>16&4;c=c<>>16&2;c=(c<>>15|0)-(e|(d|f))|0;c=(c<<1|a>>>c+21&1)+28|0}q[b+28>>2]=c;q[g+16>>2]=0;q[g+20>>2]=0;e=(c<<2)+82592|0;d=q[20573];b=1<>2]=g;q[g+24>>2]=e;break M}d=a<<((c|0)==31?0:25-(c>>>1|0)|0);b=q[e>>2];while(1){c=b;if((q[b+4>>2]&-8)==(a|0)){break C}b=d>>>29|0;d=d<<1;e=(c+(b&4)|0)+16|0;b=q[e>>2];if(b){continue}break}q[e>>2]=g;q[g+24>>2]=c}q[g+12>>2]=g;q[g+8>>2]=g;break B}e=f+ -40|0;a=b+8&7?-8-b&7:0;c=e-a|0;q[20575]=c;a=a+b|0;q[20578]=a;q[a+4>>2]=c|1;q[(b+e|0)+4>>2]=40;q[20579]=q[20694];a=(g+(g+ -39&7?39-g&7:0)|0)+ -47|0;c=a>>>0>>0?d:a;q[c+4>>2]=27;a=q[20687];q[c+16>>2]=q[20686];q[c+20>>2]=a;a=q[20685];q[c+8>>2]=q[20684];q[c+12>>2]=a;q[20686]=c+8;q[20685]=f;q[20684]=b;q[20687]=0;a=c+24|0;while(1){q[a+4>>2]=7;b=a+8|0;a=a+4|0;if(g>>>0>b>>>0){continue}break}if((c|0)==(d|0)){break x}q[c+4>>2]=q[c+4>>2]&-2;g=c-d|0;q[d+4>>2]=g|1;q[c>>2]=g;if(g>>>0<=255){a=g>>>3|0;b=(a<<3)+82328|0;c=q[20572];a=1<>2]}q[b+8>>2]=d;q[a+12>>2]=d;q[d+12>>2]=b;q[d+8>>2]=a;break x}q[d+16>>2]=0;q[d+20>>2]=0;a=d;c=g>>>8|0;b=0;O:{if(!c){break O}b=31;if(g>>>0>16777215){break O}b=c;c=c+1048320>>>16&8;b=b<>>16&4;b=b<>>16&2;b=(b<>>15|0)-(e|(c|f))|0;b=(b<<1|g>>>b+21&1)+28|0}q[a+28>>2]=b;e=(b<<2)+82592|0;c=q[20573];a=1<>2]=d;q[d+24>>2]=e;break P}a=g<<((b|0)==31?0:25-(b>>>1|0)|0);b=q[e>>2];while(1){c=b;if((g|0)==(q[b+4>>2]&-8)){break A}b=a>>>29|0;a=a<<1;e=(c+(b&4)|0)+16|0;b=q[e>>2];if(b){continue}break}q[e>>2]=d;q[d+24>>2]=c}q[d+12>>2]=d;q[d+8>>2]=d;break x}a=q[c+8>>2];q[a+12>>2]=g;q[c+8>>2]=g;q[g+24>>2]=0;q[g+12>>2]=c;q[g+8>>2]=a}a=j+8|0;break a}a=q[c+8>>2];q[a+12>>2]=d;q[c+8>>2]=d;q[d+24>>2]=0;q[d+12>>2]=c;q[d+8>>2]=a}a=q[20575];if(a>>>0<=h>>>0){break d}b=a-h|0;q[20575]=b;c=q[20578];a=c+h|0;q[20578]=a;q[a+4>>2]=b|1;q[c+4>>2]=h|3;a=c+8|0;break a}q[20555]=48;a=0;break a}Q:{if(!g){break Q}d=q[e+28>>2];a=(d<<2)+82592|0;R:{if(q[a>>2]==(e|0)){q[a>>2]=b;if(b){break R}i=Rc(d)&i;q[20573]=i;break Q}q[g+(q[g+16>>2]==(e|0)?16:20)>>2]=b;if(!b){break Q}}q[b+24>>2]=g;a=q[e+16>>2];if(a){q[b+16>>2]=a;q[a+24>>2]=b}a=q[e+20>>2];if(!a){break Q}q[b+20>>2]=a;q[a+24>>2]=b}S:{if(c>>>0<=15){a=c+h|0;q[e+4>>2]=a|3;a=a+e|0;q[a+4>>2]=q[a+4>>2]|1;break S}q[e+4>>2]=h|3;d=e+h|0;q[d+4>>2]=c|1;q[c+d>>2]=c;if(c>>>0<=255){a=c>>>3|0;b=(a<<3)+82328|0;c=q[20572];a=1<>2]}q[b+8>>2]=d;q[a+12>>2]=d;q[d+12>>2]=b;q[d+8>>2]=a;break S}a=d;f=c>>>8|0;b=0;U:{if(!f){break U}b=31;if(c>>>0>16777215){break U}b=f;f=f+1048320>>>16&8;b=b<>>16&4;b=b<>>16&2;b=(b<>>15|0)-(h|(f|g))|0;b=(b<<1|c>>>b+21&1)+28|0}q[a+28>>2]=b;q[d+16>>2]=0;q[d+20>>2]=0;f=(b<<2)+82592|0;V:{a=1<>2]=d;q[d+24>>2]=f;break W}a=c<<((b|0)==31?0:25-(b>>>1|0)|0);h=q[f>>2];while(1){b=h;if((q[b+4>>2]&-8)==(c|0)){break V}f=a>>>29|0;a=a<<1;f=(b+(f&4)|0)+16|0;h=q[f>>2];if(h){continue}break}q[f>>2]=d;q[d+24>>2]=b}q[d+12>>2]=d;q[d+8>>2]=d;break S}a=q[b+8>>2];q[a+12>>2]=d;q[b+8>>2]=d;q[d+24>>2]=0;q[d+12>>2]=b;q[d+8>>2]=a}a=e+8|0;break a}X:{if(!j){break X}c=q[b+28>>2];a=(c<<2)+82592|0;Y:{if(q[a>>2]==(b|0)){q[a>>2]=e;if(e){break Y}q[20573]=Rc(c)&i;break X}q[(q[j+16>>2]==(b|0)?16:20)+j>>2]=e;if(!e){break X}}q[e+24>>2]=j;a=q[b+16>>2];if(a){q[e+16>>2]=a;q[a+24>>2]=e}a=q[b+20>>2];if(!a){break X}q[e+20>>2]=a;q[a+24>>2]=e}Z:{if(d>>>0<=15){a=d+h|0;q[b+4>>2]=a|3;a=a+b|0;q[a+4>>2]=q[a+4>>2]|1;break Z}q[b+4>>2]=h|3;e=b+h|0;q[e+4>>2]=d|1;q[d+e>>2]=d;if(k){a=k>>>3|0;c=(a<<3)+82328|0;h=q[20577];a=1<>2]}q[c+8>>2]=h;q[a+12>>2]=h;q[h+12>>2]=c;q[h+8>>2]=a}q[20577]=e;q[20574]=d}a=b+8|0}T=l+16|0;return a|0}function xa(a,b){a=a|0;b=b|0;var c=0,d=x(0),e=0,f=0,g=0,h=x(0),i=0,j=0,k=0,l=0,m=0,n=0,p=0,s=0,z=0,A=x(0),B=0,D=0,E=0,G=0,H=0,J=0,K=0;c=T-1840|0;T=c;ha(c+928|0);qa(a,b,c+1200|0);a=q[c+1244>>2];if(!a){a=q[((q[c+1208>>2]<<4)+(q[c+1212>>2]<<3)|0)+10592>>2]}o[12688]=a;a=q[c+1248>>2];if(!a){a=q[((q[c+1208>>2]<<4)+(q[c+1212>>2]<<3)|0)+10596>>2]}o[12416]=a;pa(14016,r[q[c+1212>>2]+10576|0],+t[c+1816>>2],1);pa(12432,r[12688],+t[c+1816>>2],q[c+1216>>2]);pa(12160,r[12416],+t[c+1816>>2],q[c+1216>>2]);b=((q[c+1212>>2]?44100:22050)>>>0)/(r[12688]+r[12416]>>>0)|0;A=x(b>>>2|0);u[c+1276>>2]=C(x(u[c+1268>>2]*A));if(q[c+1220>>2]){na(14016,10577);na(12432,12688);na(12160,12416)}a=q[c+1260>>2];a:{b:{if((a|0)<5){break b}q[c+400>>2]=a;bb(q[1624],2939,c+400|0);q[c+384>>2]=c+944;if((nb(c+384|0)|0)>0){break b}while(1){if((r[c+944|0]|32)!=121){break a}q[c+368>>2]=c+944;if((nb(c+368|0)|0)<1){continue}break}}if(q[c+1204>>2]>=1){a=q[c+1260>>2];q[c+352>>2]=a;q[c+356>>2]=(a|0)>1?3041:1689;q[c+360>>2]=r[c+1240|0]==115?3043:3056;zc(2998,c+352|0);q[c+336>>2]=q[c+1220>>2]?3086:3100;q[c+340>>2]=q[c+1212>>2]?3114:3111;zc(3068,c+336|0);zc(q[c+1200>>2]?3117:3130,0);v[c+320>>3]=u[c+1268>>2];Ac(c+320|0);a=(q[c+1220>>2]!=0)<<1;q[c+304>>2]=r[12688]>>>a;q[c+308>>2]=r[12416]>>>a;zc(3176,c+304|0);q[c+288>>2]=q[c+1216>>2]?3255:3248;zc(3215,c+288|0)}c:{d:{e:{a=q[c+1808>>2];if(a){D=b>>>3|0;H=q[1624];E=c+1280|0;J=b>>>0>15;while(1){if(q[c+1204>>2]>=1){q[c+272>>2]=a;zc(3260,c+272|0)}q[3569]=0;q[3568]=0;a=Fb(c+672|0,q[c+1808>>2]);b=Fb(c+416|0,zb(q[c+1808>>2],3267));if(!r[c+1280|0]){q[c+256>>2]=b;za(E,c+256|0)}B=0;b=zb(a,3277);q[3570]=0;f=-1;f:{if(!b){break f}while(1){a=Ya(b,3279);q[3173]=a;g:{if(a){Ea(a,0,2);a=q[3173];h:{if(q[a+76>>2]<=-1){a=ya(a);b=V;break h}a=ya(a);b=V}if((b|0)>0?1:(b|0)>=0?a>>>0<2147483648?0:1:0){q[20555]=61;a=-1}Ea(q[3173],0,0);e=a;ka(14288,a,q[3173]);if(r[c+1240|0]!=115){break g}i:{if((e|0)<=6143){if((e|0)==2048){break g}if((e|0)!=4096){break i}break g}if((e|0)==6144|(e|0)==8448|(e|0)==32767){break g}}yc(3318,45,1,H);break f}q[c>>2]=b;bb(q[1624],3282,c);break a}j:{if(q[3570]|q[c+1256>>2]==2){break j}a=Fb(c+944|0,E);b=Ya(a,3364);q[3570]=b;if(!b){break e}if(q[c+1204>>2]<1){break j}q[c+240>>2]=a;zc(3403,c+240|0)}if(!(q[c+1256>>2]|B)){a=0;while(1){cb(r[(w(q[c+1220>>2]+q[c+1212>>2]|0,80)+a|0)+10672|0],q[3570]);a=a+1|0;if((a|0)!=44){continue}break}}K=r[c+1240|0];n=(e|0)==32767;k:{l:{m:{if(!((e|0)==6144|(e|0)==8448|(e|0)==32767)){a=q[2572];g=!a;if(!a){break l}b=0;if((a|0)!=(e|0)){while(1){b=b+1|0;a=q[(b<<2)+10288>>2];g=!a;if(!a){break l}if((a|0)!=(e|0)){continue}break}}f=q[c+1264>>2];if((f|0)>=0){break m}f=b;break l}i=q[c+1252>>2]?i:13;if((e|0)<8448){j=0;l=24;break k}ma(32);if(!q[c+1232>>2]){o[c+1821|0]=r[12704];o[c+1820|0]=r[12705]}a=q[3181];q[19956]=q[3180];q[19957]=a;a=q[3183];q[19958]=q[3182];q[19959]=a;a=q[3185];q[19960]=q[3184];q[19961]=a;i=q[c+1252>>2]?i:r[12706];j=r[12709];n=1;l=r[12707];break k}if((e|0)!=q[(f<<2)+10288>>2]){break c}}if(g){break d}j=0;l=q[(f<<2)+10288>>2]/256|0}g=0;b=0;G=(l|0)<1;if(!G){while(1){ma(b);k=b+79856|0;o[k|0]=1;a=0;while(1){m=a+12705|0;z=a+12704|0;a=a+1|0;if(r[z|0]!=r[m|0]){o[k|0]=0}if((a|0)!=255){continue}break}g=!r[k|0]+g|0;b=b+1|0;if((l|0)!=(b|0)){continue}break}}m=(g<<8>>>0)/21|0;k=(g>>>0)/21|0;n:{if(B){break n}a=0;b=q[c+1212>>2];d=x(C(x(u[c+1272>>2]*x(((b?44100:22050)>>>0)/r[b+10576|0]|0))));d=q[c+1220>>2]?x(d*x(.5)):d;if(!(d>x(0))){break n}while(1){ia(c+928|0,q[c+1212>>2]+10576|0,1);a=a+1|0;if(d>x(a|0)){continue}break}}b=1;a=q[c+1256>>2];if(!!(u[c+1276>>2]>x(1))){while(1){la(c+928|0,85,a);a=q[c+1256>>2];b=b+1|0;if(u[c+1276>>2]>x(b|0)){continue}break}}z=(e|0)==2048;la(c+928|0,84,a);o:{if(q[c+1264>>2]>-1){break o}a=0;q[3500]=0;sa();if((e|0)>=1){while(1){ta(r[a+14288|0]);a=a+1|0;if((e|0)!=(a|0)){continue}break}}p:{q:{r:{if((e|0)<=16383){if(z){break r}if((e|0)!=8192){break o}a=0;p=r[14288];while(1){b=a;s=a<<12;a=0;while(1){f=(p|0)==r[(a+s|0)+14288|0]?f:5;a=a+1|0;if((a|0)!=256){continue}break}a=b+1|0;if(!b){continue}break}a=ua(10944);s:{if((a|0)<0){break s}f=9;if(q[c+1204>>2]<1){break s}q[c+160>>2]=q[(a<<2)+11056>>2];zc(3555,c+160|0)}a=ua(11168);t:{if((a|0)<0){break t}f=8;if(q[c+1204>>2]<1){break t}q[c+144>>2]=q[(a<<2)+11232>>2];zc(3555,c+144|0)}a=ua(11296);u:{if((a|0)<0){break u}f=7;if(q[c+1204>>2]<1){break u}q[c+128>>2]=q[(a<<2)+11328>>2];zc(3555,c+128|0)}a=ua(11360);if((a|0)<0){break o}f=6;if(q[c+1204>>2]<1){break o}q[c+112>>2]=q[(a<<2)+11376>>2];zc(3555,c+112|0);break o}if((e|0)==16384){break q}if((e|0)==65536){break p}if((e|0)!=32768){break o}b=0;p=r[14288];while(1){s=b<<12;a=0;while(1){f=(p|0)==r[(a+s|0)+14288|0]?f:30;a=a+1|0;if((a|0)!=256){continue}break}b=b+1|0;if((b|0)!=8){continue}break}break o}a=ua(10912);if((a|0)<0){break o}f=1;if(q[c+1204>>2]<1){break o}q[c+96>>2]=q[(a<<2)+10928>>2];zc(3555,c+96|0);break o}b=0;p=r[14288];while(1){s=b<<12;a=0;while(1){f=(p|0)==r[(a+s|0)+14288|0]?f:20;a=a+1|0;if((a|0)!=256){continue}break}b=b+1|0;if((b|0)!=4){continue}break}a=ua(11392);v:{if((a|0)<0){break v}f=16;if(q[c+1204>>2]<1){break v}q[c+192>>2]=q[(a<<2)+11408>>2];zc(3555,c+192|0)}a=ua(11424);if((a|0)<0){break o}f=24;if(q[c+1204>>2]<1){break o}q[c+176>>2]=q[(a<<2)+11456>>2];zc(3555,c+176|0);break o}if((f|0)!=34){break o}q[c+1228>>2]=1;Bc(5727);Bc(5769);f=34}b=q[c+1228>>2];a=q[c+1252>>2];w:{if(a){i=a;break w}if(r[c+1240|0]==115){i=n?i:29;if((e|0)!=2048){break w}ma(q[(f<<2)+10432>>2]);i=r[12957]<248?9:i;break w}if(n){break w}i=q[(f<<2)+10144>>2]}a=k+1|0;k=b?l:g;if(!(q[c+1232>>2]|n)){ma(q[(f<<2)+10432>>2]);o[c+1821|0]=r[12956];o[c+1820|0]=r[12957]}la(c+928|0,r[c+1821|0],q[c+1256>>2]);la(c+928|0,r[c+1820|0],q[c+1256>>2]);b=i&255;la(c+928|0,b,q[c+1256>>2]);g=k&255;la(c+928|0,g,q[c+1256>>2]);j=q[c+1224>>2]?r[c+1812|0]:j;la(c+928|0,85-(a+(j+(r[c+1820|0]+(r[c+1821|0]+((k+m|0)+i|0)|0)|0)|0)|0)&255,q[c+1256>>2]);j=j&255;la(c+928|0,j,q[c+1256>>2]);la(c+928|0,m&255,q[c+1256>>2]);la(c+928|0,a&255,q[c+1256>>2]);if(q[c+1204>>2]>=1){rb(10)}if(q[c+1204>>2]>=2){zc(3560,0);x:{if(n){Bc(5714);break x}Bc(w(f,5)+9952|0)}q[c+80>>2]=e;zc(3583,c+80|0);q[c+64>>2]=r[c+1820|0];q[c+68>>2]=r[c+1821|0];zc(3611,c- -64|0);q[c+52>>2]=g;q[c+48>>2]=j;zc(3644,c+48|0);q[c+36>>2]=l-k&255;q[c+32>>2]=b;zc(3704,c+32|0)}if(!G){j=(K|0)==115?z?2:(e|0)==4096:0;g=0;while(1){m=g+79856|0;y:{if(q[c+1228>>2]?0:r[m|0]){break y}ma(g);if(q[c+1204>>2]+ -1>>>0>1){break y}wa(g,k)}if(n){e=r[g+79824|0]}else{e=(g>>>3&3|g&224)+(j|g<<2&28)|0}a=0;b=0;while(1){b=o[a+12704|0]+b|0;a=a+1|0;if((a|0)!=256){continue}break}if(!(q[c+1228>>2]?0:r[m|0])){a=e<<24>>24;b=85-(a+b|0)|0;if(q[c+1204>>2]>=3){q[c+28>>2]=b&255;q[c+24>>2]=e&255;q[c+20>>2]=a>>>2&7;q[c+16>>2]=a>>>3&28|a&3;zc(3764,c+16|0)}la(c+928|0,e&255,q[c+1256>>2]);la(c+928|0,b&255,q[c+1256>>2]);a=0;while(1){la(c+928|0,r[a+12704|0],q[c+1256>>2]);a=a+1|0;if((a|0)!=256){continue}break}}g=g+1|0;if((l|0)!=(g|0)){continue}break}}eb(q[3173]);b=zb(0,3277);z:{if(b){B=1;a=1;d=x(u[c+1268>>2]*A);if(!(x(d+d)>x(1))){break z}while(1){la(c+928|0,85,q[c+1256>>2]);d=x(u[c+1268>>2]*A);a=a+1|0;if(x(d+d)>x(a|0)){continue}break}break z}a=1;if(!J){break z}while(1){la(c+928|0,85,q[c+1256>>2]);a=a+1|0;if((a|0)!=((D>>>0>2?D:2)|0)){continue}break}}if(b){continue}break}}A:{if(q[c+1256>>2]){break A}a=q[3570];if(!a){break A}d=x(q[c+932>>2]);u[3568]=d;u[3569]=d+x(36);Ea(a,40,0);q[c+1836>>2]=0;q[c+1828>>2]=0;q[c+1832>>2]=0;d=u[3568];if(!!(d>x(16777216))){a=c;h=x(C(x(d*x(5.960464477539063e-8))));B:{if(x(y(h))>2]=b;u[3568]=d-x(b<<24>>>0)}d=u[3568];if(!!(d>x(65535))){a=c;h=x(C(x(d*x(152587890625e-16))));C:{if(x(y(h))>2]=b;u[3568]=d-x(b<<16>>>0)}d=u[3568];if(!!(d>x(255))){a=c;h=x(C(x(d*x(.00390625))));D:{if(x(y(h))>2]=b;u[3568]=d-x(b<<8>>>0)}a=0;b=c;d=u[3568];E:{if(d=x(0)){e=~~d>>>0;break E}e=0}q[b+1824>>2]=e;while(1){cb(q[(c+1824|0)+(a<<2)>>2],q[3570]);a=a+1|0;if((a|0)!=4){continue}break}Ea(q[3570],4,0);q[c+1836>>2]=0;d=u[3569];if(!!(d>x(65535))){a=c;h=x(C(x(d*x(152587890625e-16))));F:{if(h=x(0)){b=~~h>>>0;break F}b=0}q[a+1832>>2]=b;u[3569]=d-x(b<<16>>>0)}d=u[3569];if(!!(d>x(256))){a=c;h=x(C(x(d*x(.00390625))));G:{if(h=x(0)){b=~~h>>>0;break G}b=0}q[a+1828>>2]=b;u[3569]=d-x(b<<8>>>0)}a=0;b=c;d=u[3569];H:{if(d=x(0)){e=~~d>>>0;break H}e=0}q[b+1824>>2]=e;while(1){cb(q[(c+1824|0)+(a<<2)>>2],q[3570]);a=a+1|0;if((a|0)!=4){continue}break}Ea(q[3570],44,0)}a=q[3570];if(a){yc(q[c+928>>2],q[c+932>>2],1,a);_a(q[3570]);eb(q[3570])}o[c+1280|0]=0;q[c+1808>>2]=ga(q[c+1808>>2]);if(q[c+1204>>2]+ -1>>>0<=1){va()}a=q[c+1808>>2];if(a){continue}break}}ja(c+928|0);T=c+1840|0;return 0}q[c+224>>2]=a;bb(q[1624],3367,c+224|0);break a}yc(3455,99,1,q[1624]);break a}q[c+212>>2]=(e|0)/1024;q[c+208>>2]=w(f,5)+9952;bb(q[1624],3406,c+208|0)}I(1);F()}function Wb(a,b,c,d,e,f,g,h,i){var j=0,k=0,l=0,m=0,n=0,o=0,p=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;n=T-192|0;T=n;F=h;I=i&65535;r=d;o=e&65535;E=(e^i)&-2147483648;s=i>>>16&32767;a:{u=e>>>16&32767;b:{c:{if(s+ -1>>>0<32766?u+ -1>>>0<=32765:0){break c}m=e&2147483647;k=m;j=d;if(!(!j&(k|0)==2147418112?!(b|c):(k|0)==2147418112&j>>>0<0|k>>>0<2147418112)){J=d;E=e|32768;break b}m=i&2147483647;e=m;d=h;if(!(!d&(e|0)==2147418112?!(f|g):(e|0)==2147418112&d>>>0<0|e>>>0<2147418112)){J=h;E=i|32768;b=f;c=g;break b}if(!(b|j|(k^2147418112|c))){if(!(d|f|(e^2147418112|g))){b=0;c=0;E=2147450880;break b}E=E|2147418112;b=0;c=0;break b}if(!(d|f|(e^2147418112|g))){b=0;c=0;break b}if(!(b|j|(c|k))){break a}if(!(d|f|(e|g))){E=E|2147418112;b=0;c=0;break b}if((k|0)==65535&j>>>0<=4294967295|k>>>0<65535){j=b;h=!(o|r);i=h<<6;k=z(h?b:r)+32|0;b=z(h?c:o);b=i+((b|0)==32?k:b)|0;Tb(n+176|0,j,c,r,o,b+ -15|0);l=16-b|0;r=q[n+184>>2];o=q[n+188>>2];c=q[n+180>>2];b=q[n+176>>2]}if((e|0)==65535&d>>>0>4294967295|e>>>0>65535){break c}d=!(F|I);e=d<<6;h=z(d?f:F)+32|0;d=z(d?g:I);d=e+((d|0)==32?h:d)|0;Tb(n+160|0,f,g,F,I,d+ -15|0);l=(d+l|0)+ -16|0;F=q[n+168>>2];I=q[n+172>>2];f=q[n+160>>2];g=q[n+164>>2]}e=I|65536;H=e;O=F;d=F;k=e<<15|d>>>17;d=d<<15|g>>>17;h=-102865788-d|0;e=k;i=1963258675-(k+(4192101508>>0)|0)|0;bc(n+144|0,d,k,h,i);j=q[n+152>>2];bc(n+128|0,0-j|0,0-(q[n+156>>2]+(0>>0)|0)|0,h,i);h=q[n+136>>2];i=h<<1|q[n+132>>2]>>>31;h=q[n+140>>2]<<1|h>>>31;bc(n+112|0,i,h,d,k);j=h;h=q[n+120>>2];bc(n+96|0,i,j,0-h|0,0-(q[n+124>>2]+(0>>0)|0)|0);h=q[n+104>>2];i=h<<1|q[n+100>>2]>>>31;h=q[n+108>>2]<<1|h>>>31;bc(n+80|0,i,h,d,k);j=h;h=q[n+88>>2];bc(n- -64|0,i,j,0-h|0,0-(q[n+92>>2]+(0>>0)|0)|0);h=q[n+72>>2];i=h<<1|q[n+68>>2]>>>31;h=q[n+76>>2]<<1|h>>>31;bc(n+48|0,i,h,d,k);j=h;h=q[n+56>>2];bc(n+32|0,i,j,0-h|0,0-(q[n+60>>2]+(0>>0)|0)|0);h=q[n+40>>2];i=h<<1|q[n+36>>2]>>>31;h=q[n+44>>2]<<1|h>>>31;bc(n+16|0,i,h,d,k);j=h;h=q[n+24>>2];bc(n,i,j,0-h|0,0-(q[n+28>>2]+(0>>0)|0)|0);K=(u-s|0)+l|0;h=q[n+8>>2];j=q[n+12>>2]<<1|h>>>31;i=h<<1;k=j+ -1|0;i=(q[n+4>>2]>>>31|i)+ -1|0;if(i>>>0<4294967295){k=k+1|0}h=i;j=0;w=j;v=e;l=0;m=Pc(h,j,e,l);e=V;u=e;x=k;s=0;j=d;h=Pc(k,s,j,0);d=h+m|0;k=V+e|0;k=d>>>0>>0?k+1|0:k;h=d;d=k;p=Pc(i,w,j,p);e=0+p|0;k=h;j=k+V|0;j=e>>>0

>>0?j+1|0:j;p=e;e=j;j=(k|0)==(j|0)&p>>>0>>0|j>>>0>>0;k=(d|0)==(u|0)&k>>>0>>0|d>>>0>>0;h=d;d=Pc(x,s,v,l)+d|0;l=k+V|0;l=d>>>0>>0?l+1|0:l;h=d;d=j+d|0;j=l;C=d;h=d>>>0>>0?j+1|0:j;d=g;A=(d&131071)<<15|f>>>17;v=Pc(i,w,A,0);d=V;y=d;k=f;t=k<<15&-32768;m=Pc(x,s,t,0);j=m+v|0;k=V+d|0;k=j>>>0>>0?k+1|0:k;d=k;B=Pc(i,w,t,B);t=0+B|0;k=j+V|0;k=t>>>0>>0?k+1|0:k;k=(j|0)==(k|0)&t>>>0>>0|k>>>0>>0;j=(d|0)==(y|0)&j>>>0>>0|d>>>0>>0;m=d;d=Pc(x,s,A,D)+d|0;l=j+V|0;l=d>>>0>>0?l+1|0:l;j=d;d=k+j|0;m=d>>>0>>0?l+1|0:l;k=d;d=p+d|0;j=m+e|0;j=d>>>0>>0?j+1|0:j;u=d;k=h;v=j;d=(e|0)==(j|0)&d>>>0

>>0|j>>>0>>0;e=d+C|0;if(e>>>0>>0){k=k+1|0}j=k;d=(u|0)!=0|(v|0)!=0;e=e+d|0;if(e>>>0>>0){j=j+1|0}k=e;e=0-k|0;p=0;h=Pc(e,p,i,w);d=V;y=d;t=Pc(x,s,e,p);e=V;C=e;A=0-((0>>0)+j|0)|0;j=0;p=Pc(i,w,A,j);l=p+t|0;k=V+e|0;k=l>>>0

>>0?k+1|0:k;e=l;p=0+h|0;l=d+e|0;l=p>>>0>>0?l+1|0:l;m=p;d=l;l=(y|0)==(d|0)&m>>>0>>0|d>>>0>>0;m=(k|0)==(C|0)&e>>>0>>0|k>>>0>>0;e=Pc(x,s,A,j)+k|0;j=m+V|0;j=e>>>0>>0?j+1|0:j;h=e;e=l+e|0;if(e>>>0>>0){j=j+1|0}A=e;h=j;l=p;e=0-u|0;D=0-((0>>0)+v|0)|0;u=0;C=Pc(D,u,i,w);t=V;v=e;B=0;j=Pc(e,B,x,s);e=j+C|0;k=V+t|0;m=e;e=e>>>0>>0?k+1|0:k;v=Pc(i,w,v,B);i=0+v|0;j=m;k=j+V|0;k=i>>>0>>0?k+1|0:k;k=(j|0)==(k|0)&i>>>0>>0|k>>>0>>0;j=(e|0)==(t|0)&j>>>0>>0|e>>>0>>0;i=e;e=Pc(D,u,x,s)+e|0;m=j+V|0;m=e>>>0>>0?m+1|0:m;i=e;e=k+e|0;j=m;j=e>>>0>>0?j+1|0:j;i=e;e=e+l|0;j=j+d|0;j=e>>>0>>0?j+1|0:j;i=e;k=h;e=j;d=(d|0)==(j|0)&i>>>0>>0|j>>>0>>0;h=d+A|0;if(h>>>0>>0){k=k+1|0}d=h;j=k;m=d;l=e+ -1|0;d=i+ -2|0;if(d>>>0<4294967294){l=l+1|0}h=d;k=d;d=l;e=(e|0)==(d|0)&k>>>0>>0|d>>>0>>0;i=m+e|0;if(i>>>0>>0){j=j+1|0}e=i+ -1|0;k=j+ -1|0;k=e>>>0<4294967295?k+1|0:k;i=0;x=i;s=e;j=r;t=j<<2|c>>>30;A=0;p=Pc(e,i,t,A);i=V;m=i;i=c;D=(i&1073741823)<<2|b>>>30;B=k;i=0;j=Pc(D,0,k,i);e=j+p|0;l=V+m|0;l=e>>>0>>0?l+1|0:l;j=e;v=l;y=(m|0)==(l|0)&j>>>0

>>0|l>>>0>>0;m=l;l=0;p=l;k=0;C=d;G=((o&1073741823)<<2|r>>>30)&-262145|262144;e=Pc(d,l,G,0);d=e+j|0;m=V+m|0;m=d>>>0>>0?m+1|0:m;r=d;e=m;d=(v|0)==(e|0)&d>>>0>>0|e>>>0>>0;j=d+y|0;if(j>>>0>>0){k=1}m=Pc(B,i,G,L);d=m+j|0;j=V+k|0;k=d>>>0>>0?j+1|0:j;l=Pc(s,x,G,L);j=V;c=d;o=Pc(t,A,B,i);d=o+l|0;m=V+j|0;m=d>>>0>>0?m+1|0:m;o=d;d=m;m=(j|0)==(d|0)&o>>>0>>0|d>>>0>>0;l=c+d|0;k=k+m|0;j=l;m=j>>>0>>0?k+1|0:k;c=j;l=e+o|0;k=0;d=k+r|0;if(d>>>0>>0){l=l+1|0}o=d;j=d;d=l;e=(e|0)==(d|0)&j>>>0>>0|d>>>0>>0;j=c+e|0;if(j>>>0>>0){m=m+1|0}P=j;e=o;k=d;r=Pc(D,u,C,p);l=V;v=h;y=Pc(h,0,t,A);h=y+r|0;j=V+l|0;j=h>>>0>>0?j+1|0:j;w=h;h=j;r=(l|0)==(j|0)&w>>>0>>0|j>>>0>>0;Q=e;j=0;R=r;M=b<<2&-4;c=0;r=Pc(s,x,M,c);e=r+w|0;l=V+h|0;l=e>>>0>>0?l+1|0:l;y=e;r=e;e=l;h=(h|0)==(e|0)&r>>>0>>0|e>>>0>>0;l=R+h|0;if(l>>>0>>0){j=1}h=Q+l|0;k=j+k|0;k=h>>>0>>0?k+1|0:k;r=h;l=m;h=k;d=(d|0)==(k|0)&r>>>0>>0|k>>>0>>0;j=d+P|0;if(j>>>0>>0){l=l+1|0}Q=j;o=r;w=h;P=Pc(B,i,M,c);B=V;i=Pc(G,L,v,N);d=i+P|0;m=V+B|0;m=d>>>0>>0?m+1|0:m;G=d;j=Pc(t,A,C,p);d=d+j|0;i=m;k=i+V|0;k=d>>>0>>0?k+1|0:k;t=d;m=Pc(s,x,D,u);d=d+m|0;j=V+k|0;s=d;j=d>>>0>>0?j+1|0:j;x=0;m=l;d=j;j=(j|0)==(k|0)&s>>>0>>0|j>>>0>>0;l=(i|0)==(B|0)&G>>>0

>>0|i>>>0>>0;i=(i|0)==(k|0)&t>>>0>>0|k>>>0>>0;k=l+i|0;k>>>0>>0;i=j+k|0;k=i;j=d|0;i=j+o|0;k=(k|x)+w|0;k=i>>>0>>0?k+1|0:k;w=i;o=k;h=(h|0)==(k|0)&i>>>0>>0|k>>>0>>0;i=h+Q|0;if(i>>>0>>0){m=m+1|0}A=i;i=m;m=w;r=o;x=y;C=Pc(C,p,M,c);p=V;j=Pc(D,u,v,N);h=j+C|0;l=V+p|0;l=h>>>0>>0?l+1|0:l;k=l;u=k;l=0;j=(k|0)==(p|0)&h>>>0>>0|k>>>0

>>0;h=k+x|0;k=(j|l)+e|0;k=h>>>0>>0?k+1|0:k;u=h;j=h;h=k;j=(e|0)==(k|0)&j>>>0>>0|k>>>0>>0;y=m;e=j;j=k+s|0;m=0;d=m+u|0;if(d>>>0>>0){j=j+1|0}d=(h|0)==(j|0)&d>>>0>>0|j>>>0>>0;e=e+d|0;if(e>>>0>>0){l=1}d=y+e|0;m=l+r|0;h=d;j=i;m=d>>>0>>0?m+1|0:m;i=m;d=(o|0)==(i|0)&d>>>0>>0|i>>>0>>0;e=d+A|0;if(e>>>0>>0){j=j+1|0}d=e;e=j;d:{if((j|0)==131071&d>>>0<=4294967295|j>>>0<131071){x=0;o=f;t=0;k=Pc(h,x,o,t);l=V;j=b<<17;b=0;c=(k|0)!=0|(l|0)!=0;r=b-c|0;G=j-(b>>>0>>0)|0;u=0-k|0;p=0-((0>>0)+l|0)|0;c=0;A=Pc(i,c,o,t);b=V;D=b;s=0;k=Pc(h,x,g,s);j=k+A|0;l=V+b|0;l=j>>>0>>0?l+1|0:l;b=j;k=j;v=0;j=v;y=k;j=(k|0)==(p|0)&u>>>0>>0|p>>>0>>0;w=r-j|0;G=G-(r>>>0>>0)|0;j=Pc(d,0,o,t);k=V;o=Pc(h,x,F,0);j=o+j|0;m=V+k|0;m=j>>>0>>0?m+1|0:m;o=Pc(i,c,g,s);j=o+j|0;k=V+m|0;k=j>>>0>>0?k+1|0:k;m=k;k=(l|0)==(D|0)&b>>>0>>0|l>>>0>>0;b=l+j|0;k=k+m|0;m=b;b=m>>>0>>0?k+1|0:k;j=Pc(h,i,H,0);l=V;r=m;m=Pc(f,g,e,0);k=m+j|0;j=V+l|0;j=k>>>0>>0?j+1|0:j;l=Pc(d,e,g,s);m=l+k|0;j=Pc(i,c,F,I);c=j+m|0;j=c;k=0;c=r+k|0;j=b+j|0;b=c;r=w-b|0;c=G-((w>>>0>>0)+(b>>>0>>0?j+1|0:j)|0)|0;K=K+ -1|0;F=u-v|0;b=p-((u>>>0>>0)+y|0)|0;break d}s=i>>>1|0;l=0;m=b<<16;k=d<<31;h=(i&1)<<31|h>>>1;i=i>>>1|k;D=0;B=0;b=Pc(h,D,f,B);j=V;k=j;j=(b|0)!=0|(j|0)!=0;o=c-j|0;N=m-(c>>>0>>0)|0;w=0-b|0;x=0-((0>>0)+k|0)|0;m=x;p=0;v=Pc(h,D,g,p);b=V;L=b;y=s|d<<31;M=e<<31|d>>>1|l;k=y;s=Pc(k,0,f,B);c=s+v|0;j=V+b|0;j=c>>>0>>0?j+1|0:j;b=j;j=c;C=j;t=0;j=(j|0)==(m|0)&w>>>0>>0|m>>>0>>0;A=o-j|0;N=N-(o>>>0>>0)|0;k=Pc(g,p,k,l);l=V;j=e;m=j>>>1|0;s=(j&1)<<31|d>>>1;o=m;m=Pc(s,0,f,B);j=m+k|0;k=V+l|0;k=j>>>0>>0?k+1|0:k;l=Pc(h,D,F,0);m=l+j|0;j=V+k|0;k=m;m=k>>>0>>0?j+1|0:j;j=(b|0)==(L|0)&c>>>0>>0|b>>>0>>0;c=b;b=b+k|0;l=j+m|0;j=b;b=j>>>0>>0?l+1|0:l;c=Pc(h,i,H,0);k=V;m=j;d=Pc(f,g,e>>>1|0,0);c=d+c|0;j=V+k|0;j=c>>>0>>0?j+1|0:j;d=Pc(g,p,s,o);c=d+c|0;j=V+j|0;d=Pc(y,M,F,I);c=d+c|0;j=c;d=0;c=m+d|0;k=b+j|0;b=c;r=A-b|0;c=N-((A>>>0>>0)+(b>>>0>>0?k+1|0:k)|0)|0;d=s;e=o;F=w-t|0;b=x-((w>>>0>>0)+C|0)|0}if((K|0)>=16384){E=E|2147418112;b=0;c=0;break b}l=K+16383|0;if((K|0)<=-16383){e:{if(l){break e}l=i;o=F;m=b<<1|o>>>31;j=o<<1;g=(g|0)==(m|0)&j>>>0>f>>>0|m>>>0>g>>>0;j=e&65535;f=r;m=c<<1|f>>>31;c=f<<1|b>>>31;e=c;b=(e|0)==(O|0)&(m|0)==(H|0)?g:(H|0)==(m|0)&e>>>0>O>>>0|m>>>0>H>>>0;c=b+h|0;if(c>>>0>>0){l=l+1|0}b=c;e=b;c=l;e=d+((i|0)==(l|0)&e>>>0>>0|l>>>0>>0)|0;if(e>>>0>>0){j=j+1|0}d=j;if(!(j&65536)){break e}J=e|J;E=d|E;break b}b=0;c=0;break b}k=i;e=e&65535;o=F;j=b<<1|o>>>31;o=o<<1;g=(g|0)==(j|0)&o>>>0>=f>>>0|j>>>0>g>>>0;f=r;j=c<<1|f>>>31;c=f<<1|b>>>31;b=(c|0)==(O|0)&(j|0)==(H|0)?g:(H|0)==(j|0)&c>>>0>=O>>>0|j>>>0>H>>>0;c=b+h|0;if(c>>>0>>0){k=k+1|0}b=c;c=k;f=d;d=((i|0)==(k|0)&b>>>0>>0|k>>>0>>0)+d|0;k=l<<16|e;J=d|J;E=E|(d>>>0>>0?k+1|0:k)}q[a>>2]=b;q[a+4>>2]=c;q[a+8>>2]=J;q[a+12>>2]=E;T=n+192|0;return}q[a>>2]=0;q[a+4>>2]=0;b=(d|f)!=0|(e|g)!=0;q[a+8>>2]=b?J:0;q[a+12>>2]=b?E:2147450880;T=n+192|0}function Pb(a,b,c,d,e,f){var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,s=0,u=0,v=0,x=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0;g=T-8960|0;T=g;z=d+e|0;F=0-z|0;a:{b:{while(1){c:{if((c|0)!=48){if((c|0)!=46){break a}c=q[b+4>>2];if(c>>>0>=t[b+104>>2]){break c}q[b+4>>2]=c+1;c=r[c|0];break b}c=q[b+4>>2];if(c>>>0>2]){o=1;q[b+4>>2]=c+1;c=r[c|0]}else{o=1;c=Kb(b)}continue}break}c=Kb(b)}m=1;if((c|0)!=48){break a}while(1){i=i+ -1|0;c=h+ -1|0;if(c>>>0<4294967295){i=i+1|0}h=c;c=q[b+4>>2];d:{if(c>>>0>2]){q[b+4>>2]=c+1;c=r[c|0];break d}c=Kb(b)}if((c|0)==48){continue}break}o=1}q[g+768>>2]=0;G=a;H=a;e:{f:{j=(c|0)==46;p=c+ -48|0;g:{h:{i:{j:{if(!(j|p>>>0<=9)){break j}while(1){k:{if(j&1){if(!m){h=n;i=l;m=1;break k}o=(o|0)!=0;break i}j=n+1|0;if(j>>>0<1){l=l+1|0}n=j;if((k|0)<=2044){x=(c|0)!=48?n:x;j=(g+768|0)+(k<<2)|0;o=j;if(s){p=(w(q[j>>2],10)+c|0)+ -48|0}q[o>>2]=p;o=1;j=s+1|0;c=(j|0)==9;s=c?0:j;k=c+k|0;break k}if((c|0)==48){break k}q[g+8944>>2]=q[g+8944>>2]|1}c=q[b+4>>2];l:{if(c>>>0>2]){q[b+4>>2]=c+1;c=r[c|0];break l}c=Kb(b)}j=(c|0)==46;p=c+ -48|0;if(j|p>>>0<10){continue}break}}h=m?h:n;i=m?i:l;if(!(!o|(c&-33)!=69)){c=Qb(b);j=V;m=j;if(!c&(j|0)==-2147483648){break g}i=i+m|0;b=c+h|0;if(b>>>0>>0){i=i+1|0}h=b;break f}o=(o|0)!=0;if((c|0)<0){break h}}if(!q[b+104>>2]){break h}q[b+4>>2]=q[b+4>>2]+ -1}if(o){break f}q[20555]=28}Jb(b,0,0);h=0;i=0;c=0;b=0;break e}b=q[g+768>>2];if(!b){Xb(g,+(f|0)*0);h=q[g+8>>2];i=q[g+12>>2];c=q[g+4>>2];b=q[g>>2];break e}if(!((h|0)!=(n|0)|(i|0)!=(l|0)|((l|0)>0?1:(l|0)>=0?n>>>0<=9?0:1:0)|(b>>>d|0?(d|0)<=30:0))){Zb(g+48|0,f);_b(g+32|0,b);ac(g+16|0,q[g+48>>2],q[g+52>>2],q[g+56>>2],q[g+60>>2],q[g+32>>2],q[g+36>>2],q[g+40>>2],q[g+44>>2]);h=q[g+24>>2];i=q[g+28>>2];c=q[g+20>>2];b=q[g+16>>2];break e}b=(e|0)/-2|0;c=h>>>0<=b>>>0?0:1;b=b>>31;if((i|0)>(b|0)?1:(i|0)>=(b|0)?c:0){q[20555]=68;Zb(g+96|0,f);ac(g+80|0,q[g+96>>2],q[g+100>>2],q[g+104>>2],q[g+108>>2],-1,-1,-1,2147418111);ac(g- -64|0,q[g+80>>2],q[g+84>>2],q[g+88>>2],q[g+92>>2],-1,-1,-1,2147418111);h=q[g+72>>2];i=q[g+76>>2];c=q[g+68>>2];b=q[g+64>>2];break e}b=e+ -226|0;c=h>>>0>=b>>>0?0:1;b=b>>31;if((i|0)<(b|0)?1:(i|0)<=(b|0)?c:0){q[20555]=68;Zb(g+144|0,f);ac(g+128|0,q[g+144>>2],q[g+148>>2],q[g+152>>2],q[g+156>>2],0,0,0,65536);ac(g+112|0,q[g+128>>2],q[g+132>>2],q[g+136>>2],q[g+140>>2],0,0,0,65536);h=q[g+120>>2];i=q[g+124>>2];c=q[g+116>>2];b=q[g+112>>2];break e}if(s){if((s|0)<=8){c=(g+768|0)+(k<<2)|0;b=q[c>>2];while(1){b=w(b,10);s=s+1|0;if((s|0)!=9){continue}break}q[c>>2]=b}k=k+1|0}m:{m=h;if((x|0)>8|(x|0)>(h|0)|(h|0)>17){break m}if((m|0)==9){Zb(g+192|0,f);_b(g+176|0,q[g+768>>2]);ac(g+160|0,q[g+192>>2],q[g+196>>2],q[g+200>>2],q[g+204>>2],q[g+176>>2],q[g+180>>2],q[g+184>>2],q[g+188>>2]);h=q[g+168>>2];i=q[g+172>>2];c=q[g+164>>2];b=q[g+160>>2];break e}if((m|0)<=8){Zb(g+272|0,f);_b(g+256|0,q[g+768>>2]);ac(g+240|0,q[g+272>>2],q[g+276>>2],q[g+280>>2],q[g+284>>2],q[g+256>>2],q[g+260>>2],q[g+264>>2],q[g+268>>2]);Zb(g+224|0,q[(0-m<<2)+7072>>2]);Wb(g+208|0,q[g+240>>2],q[g+244>>2],q[g+248>>2],q[g+252>>2],q[g+224>>2],q[g+228>>2],q[g+232>>2],q[g+236>>2]);h=q[g+216>>2];i=q[g+220>>2];c=q[g+212>>2];b=q[g+208>>2];break e}b=(w(m,-3)+d|0)+27|0;c=q[g+768>>2];if(c>>>b|0?(b|0)<=30:0){break m}Zb(g+352|0,f);_b(g+336|0,c);ac(g+320|0,q[g+352>>2],q[g+356>>2],q[g+360>>2],q[g+364>>2],q[g+336>>2],q[g+340>>2],q[g+344>>2],q[g+348>>2]);Zb(g+304|0,q[(m<<2)+7e3>>2]);ac(g+288|0,q[g+320>>2],q[g+324>>2],q[g+328>>2],q[g+332>>2],q[g+304>>2],q[g+308>>2],q[g+312>>2],q[g+316>>2]);h=q[g+296>>2];i=q[g+300>>2];c=q[g+292>>2];b=q[g+288>>2];break e}s=0;b=(m|0)%9|0;n:{if(!b){c=0;break n}i=(m|0)>-1?b:b+9|0;o:{if(!k){c=0;k=0;break o}h=q[(0-i<<2)+7072>>2];l=1e9/(h|0)|0;o=0;b=0;c=0;while(1){j=o;n=(g+768|0)+(b<<2)|0;o=q[n>>2];p=(o>>>0)/(h>>>0)|0;j=j+p|0;q[n>>2]=j;j=!j&(b|0)==(c|0);c=j?c+1&2047:c;m=j?m+ -9|0:m;o=w(l,o-w(h,p)|0);b=b+1|0;if((k|0)!=(b|0)){continue}break}if(!o){break o}q[(g+768|0)+(k<<2)>>2]=o;k=k+1|0}m=(m-i|0)+9|0}while(1){n=(g+768|0)+(c<<2)|0;p:{while(1){if((m|0)!=36|t[n>>2]>=10384593?(m|0)>=36:0){break p}p=k+2047|0;o=0;j=k;while(1){k=j;l=p&2047;p=(g+768|0)+(l<<2)|0;b=q[p>>2];i=b>>>3|0;h=b<<29;b=h+o|0;if(b>>>0>>0){i=i+1|0}h=b;j=0;q:{if(!i&b>>>0<1000000001|i>>>0<0){break q}j=Qc(b,i,1e9);h=h-Pc(j,V,1e9,0)|0}o=j;q[p>>2]=h;j=(l|0)!=(k+ -1&2047)?k:(c|0)==(l|0)?k:h?k:l;p=l+ -1|0;if((c|0)!=(l|0)){continue}break}s=s+ -29|0;if(!o){continue}break}c=c+ -1&2047;if((j|0)==(c|0)){b=(g+768|0)+((j+2046&2047)<<2)|0;k=j+ -1&2047;q[b>>2]=q[b>>2]|q[(g+768|0)+(k<<2)>>2]}m=m+9|0;q[(g+768|0)+(c<<2)>>2]=o;continue}break}r:{s:while(1){i=k+1&2047;l=(g+768|0)+((k+ -1&2047)<<2)|0;while(1){h=(m|0)>45?9:1;t:{while(1){j=c;b=0;u:{while(1){v:{c=b+j&2047;if((c|0)==(k|0)){break v}c=q[(g+768|0)+(c<<2)>>2];n=q[(b<<2)+7024>>2];if(c>>>0>>0){break v}if(c>>>0>n>>>0){break u}b=b+1|0;if((b|0)!=4){continue}}break}if((m|0)!=36){break u}h=0;i=0;b=0;n=0;l=0;while(1){c=b+j&2047;if((c|0)==(k|0)){k=k+1&2047;q[((k<<2)+g|0)+764>>2]=0}ac(g+752|0,h,i,n,l,0,0,1342177280,1075633366);_b(g+736|0,q[(g+768|0)+(c<<2)>>2]);Sb(g+720|0,q[g+752>>2],q[g+756>>2],q[g+760>>2],q[g+764>>2],q[g+736>>2],q[g+740>>2],q[g+744>>2],q[g+748>>2]);n=q[g+728>>2];l=q[g+732>>2];h=q[g+720>>2];i=q[g+724>>2];b=b+1|0;if((b|0)!=4){continue}break}Zb(g+704|0,f);ac(g+688|0,h,i,n,l,q[g+704>>2],q[g+708>>2],q[g+712>>2],q[g+716>>2]);n=q[g+696>>2];l=q[g+700>>2];h=0;i=0;b=q[g+688>>2];c=q[g+692>>2];p=s+113|0;m=p-e|0;o=(m|0)<(d|0);e=o?(m|0)>0?m:0:d;if((e|0)<=112){break t}break r}s=h+s|0;c=k;if((j|0)==(c|0)){continue}break}n=1e9>>>h|0;o=-1<>2];b=(x>>>h|0)+b|0;q[p>>2]=b;b=!b&(c|0)==(j|0);c=b?c+1&2047:c;m=b?m+ -9|0:m;b=w(n,o&x);j=j+1&2047;if((j|0)!=(k|0)){continue}break}if(!b){continue}if((c|0)!=(i|0)){q[(g+768|0)+(k<<2)>>2]=b;k=i;continue s}q[l>>2]=q[l>>2]|1;c=i;continue}break}break}Xb(g+640|0,rc(1,225-e|0));Lb(g+672|0,q[g+640>>2],q[g+644>>2],q[g+648>>2],q[g+652>>2],b,c,n,l);A=q[g+680>>2];B=q[g+684>>2];C=q[g+672>>2];D=q[g+676>>2];Xb(g+624|0,rc(1,113-e|0));qc(g+656|0,b,c,n,l,q[g+624>>2],q[g+628>>2],q[g+632>>2],q[g+636>>2]);h=q[g+656>>2];i=q[g+660>>2];u=q[g+664>>2];v=q[g+668>>2];cc(g+608|0,b,c,n,l,h,i,u,v);Sb(g+592|0,C,D,A,B,q[g+608>>2],q[g+612>>2],q[g+616>>2],q[g+620>>2]);n=q[g+600>>2];l=q[g+604>>2];b=q[g+592>>2];c=q[g+596>>2]}d=j+4&2047;w:{if((d|0)==(k|0)){break w}d=q[(g+768|0)+(d<<2)>>2];x:{if(d>>>0<=499999999){if((j+5&2047)==(k|0)?!d:0){break x}Xb(g+480|0,+(f|0)*.25);Sb(g+464|0,h,i,u,v,q[g+480>>2],q[g+484>>2],q[g+488>>2],q[g+492>>2]);u=q[g+472>>2];v=q[g+476>>2];h=q[g+464>>2];i=q[g+468>>2];break x}if((d|0)!=5e8){Xb(g+576|0,+(f|0)*.75);Sb(g+560|0,h,i,u,v,q[g+576>>2],q[g+580>>2],q[g+584>>2],q[g+588>>2]);u=q[g+568>>2];v=q[g+572>>2];h=q[g+560>>2];i=q[g+564>>2];break x}E=+(f|0);if((j+5&2047)==(k|0)){Xb(g+512|0,E*.5);Sb(g+496|0,h,i,u,v,q[g+512>>2],q[g+516>>2],q[g+520>>2],q[g+524>>2]);u=q[g+504>>2];v=q[g+508>>2];h=q[g+496>>2];i=q[g+500>>2];break x}Xb(g+544|0,E*.75);Sb(g+528|0,h,i,u,v,q[g+544>>2],q[g+548>>2],q[g+552>>2],q[g+556>>2]);u=q[g+536>>2];v=q[g+540>>2];h=q[g+528>>2];i=q[g+532>>2]}if((e|0)>111){break w}qc(g+448|0,h,i,u,v,0,0,0,1073676288);if(Ub(q[g+448>>2],q[g+452>>2],q[g+456>>2],q[g+460>>2],0,0,0,0)){break w}Sb(g+432|0,h,i,u,v,0,0,0,1073676288);u=q[g+440>>2];v=q[g+444>>2];h=q[g+432>>2];i=q[g+436>>2]}Sb(g+416|0,b,c,n,l,h,i,u,v);cc(g+400|0,q[g+416>>2],q[g+420>>2],q[g+424>>2],q[g+428>>2],C,D,A,B);n=q[g+408>>2];l=q[g+412>>2];b=q[g+400>>2];c=q[g+404>>2];y:{if((p&2147483647)<=(-2-z|0)){break y}ac(g+384|0,b,c,n,l,0,0,0,1073610752);f=Ub(h,i,u,v,0,0,0,0);d=y(dc(b,c,n,l))>=1.0384593717069655e+34;n=d?q[g+392>>2]:n;l=d?q[g+396>>2]:l;b=d?q[g+384>>2]:b;c=d?q[g+388>>2]:c;s=d+s|0;if((s+110|0)<=(F|0)?!(o&(d^1|(e|0)!=(m|0))&(f|0)!=0):0){break y}q[20555]=68}Mb(g+368|0,b,c,n,l,s);h=q[g+376>>2];i=q[g+380>>2];c=q[g+372>>2];b=q[g+368>>2]}q[H>>2]=b;q[G+4>>2]=c;q[a+8>>2]=h;q[a+12>>2]=i;T=g+8960|0}function hb(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,s=0,x=0,y=0,z=0,A=0,B=0,C=0;g=T-304|0;T=g;e=r[b|0];a:{if(!e){break a}j=a+4|0;b:{c:{d:{while(1){e:{f:{if(fb(e&255)){while(1){e=b;b=b+1|0;if(fb(r[e+1|0])){continue}break}Jb(a,0,0);while(1){b=q[a+4>>2];g:{if(b>>>0>2]){q[j>>2]=b+1;b=r[b|0];break g}b=Kb(a)}if(fb(b)){continue}break}h:{if(!q[a+104>>2]){b=q[j>>2];break h}b=q[j>>2]+ -1|0;q[j>>2]=b}d=b-q[a+8>>2]|0;b=d;d=d>>31;f=b;h=h+q[a+124>>2]|0;b=l+q[a+120>>2]|0;if(b>>>0>>0){h=h+1|0}l=f+b|0;h=d+h|0;h=l>>>0>>0?h+1|0:h;break f}i:{j:{k:{e=r[b|0];if((e|0)==37){d=r[b+1|0];if((d|0)==42){break k}if((d|0)!=37){break j}}Jb(a,0,0);e=((e|0)==37)+b|0;b=q[a+4>>2];l:{if(b>>>0>2]){q[j>>2]=b+1;b=r[b|0];break l}b=Kb(a)}if((b|0)!=r[e|0]){if(q[a+104>>2]){q[j>>2]=q[j>>2]+ -1}A=0;if((b|0)>=0){break a}break c}b=l+1|0;if(b>>>0<1){h=h+1|0}l=b;break f}k=0;e=b+2|0;break i}if(!(!Ga(d)|r[b+2|0]!=36)){k=ib(c,r[b+1|0]+ -48|0);e=b+3|0;break i}k=q[c>>2];c=c+4|0;e=b+1|0}A=0;b=0;if(Ga(r[e|0])){while(1){b=(r[e|0]+w(b,10)|0)+ -48|0;d=r[e+1|0];e=e+1|0;if(Ga(d)){continue}break}}d=e;f=r[d|0];m:{if((f|0)!=109){break m}n=0;A=(k|0)!=0;f=r[e+1|0];s=0;d=e+1|0}e=d+1|0;i=3;n:{o:{switch(f+ -65|0){case 39:f=d+2|0;d=r[d+1|0]==104;e=d?f:e;i=d?-2:-1;break n;case 43:f=d+2|0;d=r[d+1|0]==108;e=d?f:e;i=d?3:1;break n;case 51:case 57:i=1;break n;case 11:i=2;break n;case 41:break n;case 0:case 2:case 4:case 5:case 6:case 18:case 23:case 26:case 32:case 34:case 35:case 36:case 37:case 38:case 40:case 45:case 46:case 47:case 50:case 52:case 55:break o;default:break c}}i=0;e=d}f=r[e|0];d=(f&47)==3;y=d?1:i;x=d?f|32:f;p:{if((x|0)==91){break p}q:{if((x|0)!=110){if((x|0)!=99){break q}b=(b|0)>1?b:1;break p}jb(k,y,l,h);break f}Jb(a,0,0);while(1){d=q[a+4>>2];r:{if(d>>>0>2]){q[j>>2]=d+1;d=r[d|0];break r}d=Kb(a)}if(fb(d)){continue}break}s:{if(!q[a+104>>2]){d=q[j>>2];break s}d=q[j>>2]+ -1|0;q[j>>2]=d}d=d-q[a+8>>2]|0;f=d;d=d>>31;m=f;f=h+q[a+124>>2]|0;h=l+q[a+120>>2]|0;if(h>>>0>>0){f=f+1|0}l=m+h|0;d=d+f|0;d=l>>>0>>0?d+1|0:d;h=d}z=b;C=b>>31;Jb(a,b,C);f=q[a+4>>2];d=q[a+104>>2];t:{if(f>>>0>>0){q[j>>2]=f+1;break t}if((Kb(a)|0)<0){break c}d=q[a+104>>2]}if(d){q[j>>2]=q[j>>2]+ -1}d=16;u:{v:{w:{x:{y:{z:{A:{switch(x+ -88|0){default:b=x+ -65|0;if(b>>>0>6|!(1<>2]-q[a+8>>2]|0;if(q[a+120>>2]==(0-d|0)&q[a+124>>2]==(0-((d>>31)+(0>>0)|0)|0)){break b}if(!k){break u}z=q[g+8>>2];f=q[g+12>>2];d=q[g>>2];b=q[g+4>>2];switch(y|0){case 2:break w;case 1:break x;case 0:break y;default:break u};case 3:case 11:case 27:if((x&239)==99){uc(g+32|0,-1,257);o[g+32|0]=0;if((x|0)!=115){break v}o[g+65|0]=0;o[g+46|0]=0;p[g+42>>1]=0;p[g+44>>1]=0;break v}m=r[e+1|0];f=(m|0)==94;uc(g+32|0,f,257);o[g+32|0]=0;d=f?e+2|0:e+1|0;B:{C:{D:{e=r[(f?2:1)+e|0];if((e|0)!=45){if((e|0)==93){break D}i=(m|0)!=94;break B}i=(m|0)!=94;o[g+78|0]=i;break C}i=(m|0)!=94;o[g+126|0]=i}d=d+1|0}e=d;while(1){d=r[e|0];E:{if((d|0)!=45){if(!d){break c}if((d|0)!=93){break E}break v}d=45;m=r[e+1|0];if(!m|(m|0)==93){break E}f=e+1|0;e=r[e+ -1|0];F:{if(e>>>0>=m>>>0){d=m;break F}while(1){e=e+1|0;o[e+(g+32|0)|0]=i;d=r[f|0];if(e>>>0>>0){continue}break}}e=f}o[(d+g|0)+33|0]=i;e=e+1|0;continue};case 23:d=8;break z;case 12:case 29:d=10;break z;case 1:case 2:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 22:case 25:case 26:case 28:case 30:case 31:break u;case 0:case 24:case 32:break z;case 17:break A}}d=0}z=Hb(a,d);f=V;d=q[a+4>>2]-q[a+8>>2]|0;if(q[a+120>>2]==(0-d|0)&q[a+124>>2]==(0-((d>>31)+(0>>0)|0)|0)){break b}if(!(!k|(x|0)!=112)){q[k>>2]=z;break u}jb(k,y,z,f);break u}u[k>>2]=ec(d,b,z,f);break u}v[k>>3]=dc(d,b,z,f);break u}q[k>>2]=d;q[k+4>>2]=b;q[k+8>>2]=z;q[k+12>>2]=f;break u}x=(x|0)==99;i=x?b+1|0:31;m=(y|0)!=1;G:{if(!m){d=k;if(A){d=kc(i<<2);if(!d){break d}}q[g+296>>2]=0;q[g+300>>2]=0;b=0;while(1){s=d;H:{while(1){d=q[a+4>>2];I:{if(d>>>0>2]){q[j>>2]=d+1;d=r[d|0];break I}d=Kb(a)}if(!r[(d+g|0)+33|0]){break H}o[g+27|0]=d;d=gb(g+28|0,g+27|0,g+296|0);if((d|0)==-2){continue}if((d|0)==-1){break e}if(s){q[(b<<2)+s>>2]=q[g+28>>2];b=b+1|0}if(!A|(b|0)!=(i|0)){continue}break}i=i<<1|1;d=mc(s,i<<2);if(d){continue}break e}break}d=g+296|0;f=1;J:{if(!d){break J}f=!q[d>>2]}if(!f){break e}n=0;break G}if(A){b=0;d=kc(i);if(!d){break d}while(1){n=d;while(1){d=q[a+4>>2];K:{if(d>>>0>2]){q[j>>2]=d+1;d=r[d|0];break K}d=Kb(a)}if(!r[(d+g|0)+33|0]){s=0;break G}o[b+n|0]=d;b=b+1|0;if((i|0)!=(b|0)){continue}break}s=0;i=i<<1|1;d=mc(n,i);if(d){continue}break}break c}b=0;if(k){while(1){d=q[a+4>>2];L:{if(d>>>0>2]){q[j>>2]=d+1;d=r[d|0];break L}d=Kb(a)}if(r[(d+g|0)+33|0]){o[b+k|0]=d;b=b+1|0;continue}else{s=0;n=k;break G}}}while(1){b=q[a+4>>2];M:{if(b>>>0>2]){q[j>>2]=b+1;b=r[b|0];break M}b=Kb(a)}if(r[(b+g|0)+33|0]){continue}break}n=0;s=0;b=0}N:{if(!q[a+104>>2]){d=q[j>>2];break N}d=q[j>>2]+ -1|0;q[j>>2]=d}d=d-q[a+8>>2]|0;f=d;y=d+q[a+120>>2]|0;d=q[a+124>>2]+(d>>31)|0;d=y>>>0>>0?d+1|0:d;if(!(d|y)|(x?(y|0)!=(z|0)|(d|0)!=(C|0):0)){break b}O:{if(!A){break O}if(!m){q[k>>2]=s;break O}q[k>>2]=n}if(x){break u}if(s){q[(b<<2)+s>>2]=0}if(!n){n=0;break u}o[b+n|0]=0}d=q[a+4>>2]-q[a+8>>2]|0;b=d;d=d>>31;f=b;h=h+q[a+124>>2]|0;b=l+q[a+120>>2]|0;if(b>>>0>>0){h=h+1|0}l=f+b|0;h=d+h|0;h=l>>>0>>0?h+1|0:h;B=((k|0)!=0)+B|0}b=e+1|0;e=r[e+1|0];if(e){continue}break a}break}n=0;break c}n=0;s=0}B=B?B:-1}if(!A){break a}lc(n);lc(s)}T=g+304|0;return B}function Ta(a,b,c,d,f,g){a=a|0;b=+b;c=c|0;d=d|0;f=f|0;g=g|0;var i=0,j=0,k=0,l=0,m=0,n=0,p=0,s=0,t=0,u=0,v=0,x=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;m=T-560|0;T=m;q[m+44>>2]=0;h(+b);i=e(1)|0;a:{if(H=1,I=(K=e(0)>>>0>4294967295?0:1,L=0,M=(i|0)<=-1,M?K:L),J=(i|0)<-1,J?H:I){C=1;b=-b;h(+b);i=e(1)|0;e(0)|0;E=6448;break a}if(f&2048){C=1;E=6451;break a}C=f&1;E=C?6454:6449}b:{if((i&2146435072)==2146435072){j=C+3|0;Sa(a,32,c,j,f&-65537);Ma(a,E,C);d=g>>>5&1;Ma(a,b!=b?d?6475:6479:d?6467:6471,3);break b}z=m+16|0;c:{d:{e:{b=Ja(b,m+44|0);b=b+b;if(b!=0){i=q[m+44>>2];q[m+44>>2]=i+ -1;D=g|32;if((D|0)!=97){break e}break c}D=g|32;if((D|0)==97){break c}p=q[m+44>>2];n=(d|0)<0?6:d;break d}p=i+ -29|0;q[m+44>>2]=p;b=b*268435456;n=(d|0)<0?6:d}u=(p|0)<0?m+48|0:m+336|0;l=u;while(1){d=l;if(b<4294967296&b>=0){i=~~b>>>0}else{i=0}q[d>>2]=i;l=l+4|0;b=(b- +(i>>>0))*1e9;if(b!=0){continue}break}f:{if((p|0)<1){d=p;i=l;k=u;break f}k=u;d=p;while(1){s=(d|0)<29?d:29;i=l+ -4|0;g:{if(i>>>0>>0){break g}d=s;j=0;while(1){t=i;F=j;x=q[i>>2];v=d&31;if(32<=(d&63)>>>0){j=x<>>32-v;x=x<>>0>>0?j+1|0:j;j=Qc(v,j,1e9);x=t;t=Pc(j,V,1e9,0);q[x>>2]=v-t;i=i+ -4|0;if(i>>>0>=k>>>0){continue}break}if(!j){break g}k=k+ -4|0;q[k>>2]=j}while(1){i=l;if(i>>>0>k>>>0){l=i+ -4|0;if(!q[l>>2]){continue}}break}d=q[m+44>>2]-s|0;q[m+44>>2]=d;l=i;if((d|0)>0){continue}break}}if((d|0)<=-1){A=((n+25|0)/9|0)+1|0;s=(D|0)==102;while(1){j=(d|0)<-9?9:0-d|0;h:{if(k>>>0>=i>>>0){k=q[k>>2]?k:k+4|0;break h}t=1e9>>>j|0;v=-1<>2];q[l>>2]=x+(d>>>j|0);d=w(t,d&v);l=l+4|0;if(l>>>0>>0){continue}break}k=q[k>>2]?k:k+4|0;if(!d){break h}q[i>>2]=d;i=i+4|0}d=j+q[m+44>>2]|0;q[m+44>>2]=d;l=s?u:k;i=i-l>>2>(A|0)?l+(A<<2)|0:i;if((d|0)<0){continue}break}}l=0;i:{if(k>>>0>=i>>>0){break i}l=w(u-k>>2,9);d=10;j=q[k>>2];if(j>>>0<10){break i}while(1){l=l+1|0;d=w(d,10);if(j>>>0>=d>>>0){continue}break}}d=(n-((D|0)==102?0:l)|0)-((D|0)==103&(n|0)!=0)|0;if((d|0)<(w(i-u>>2,9)+ -9|0)){s=d+9216|0;t=(s|0)/9|0;j=((t<<2)+((p|0)<0?m+48|4:m+340|0)|0)+ -4096|0;d=10;s=s-w(t,9)|0;if((s|0)<=7){while(1){d=w(d,10);s=s+1|0;if((s|0)!=8){continue}break}}s=q[j>>2];t=(s>>>0)/(d>>>0)|0;A=j+4|0;p=s-w(d,t)|0;j:{if(p?0:(A|0)==(i|0)){break j}v=d>>>1|0;B=p>>>0>>0?.5:(i|0)==(A|0)?(v|0)==(p|0)?1:1.5:1.5;b=t&1?9007199254740994:9007199254740992;if(!(!C|r[E|0]!=45)){B=-B;b=-b}p=s-p|0;q[j>>2]=p;if(b+B==b){break j}d=d+p|0;q[j>>2]=d;if(d>>>0>=1e9){while(1){q[j>>2]=0;j=j+ -4|0;if(j>>>0>>0){k=k+ -4|0;q[k>>2]=0}d=q[j>>2]+1|0;q[j>>2]=d;if(d>>>0>999999999){continue}break}}l=w(u-k>>2,9);d=10;p=q[k>>2];if(p>>>0<10){break j}while(1){l=l+1|0;d=w(d,10);if(p>>>0>=d>>>0){continue}break}}d=j+4|0;i=i>>>0>d>>>0?d:i}k:{while(1){d=i;p=0;if(i>>>0<=k>>>0){break k}i=d+ -4|0;if(!q[i>>2]){continue}break}p=1}l:{if((D|0)!=103){t=f&8;break l}i=n?n:1;j=(i|0)>(l|0)&(l|0)>-5;n=(j?l^-1:-1)+i|0;g=(j?-1:-2)+g|0;t=f&8;if(t){break l}i=9;m:{if(!p){break m}j=q[d+ -4>>2];if(!j){break m}s=10;i=0;if((j>>>0)%10){break m}while(1){i=i+1|0;s=w(s,10);if(!((j>>>0)%(s>>>0))){continue}break}}j=w(d-u>>2,9)+ -9|0;if((g&-33)==70){t=0;i=j-i|0;i=(i|0)>0?i:0;n=(n|0)<(i|0)?n:i;break l}t=0;i=(j+l|0)-i|0;i=(i|0)>0?i:0;n=(n|0)<(i|0)?n:i}v=n|t;D=(v|0)!=0;s=a;F=c;x=g&-33;i=(l|0)>0?l:0;n:{if((x|0)==70){break n}i=l>>31;i=Ra(i+l^i,0,z);if((z-i|0)<=1){while(1){i=i+ -1|0;o[i|0]=48;if((z-i|0)<2){continue}break}}A=i+ -2|0;o[A|0]=g;o[i+ -1|0]=(l|0)<0?45:43;i=z-A|0}j=(i+(D+(n+C|0)|0)|0)+1|0;Sa(s,32,F,j,f);Ma(a,E,C);Sa(a,48,c,j,f^65536);o:{p:{q:{if((x|0)==70){g=m+16|8;l=m+16|9;p=k>>>0>u>>>0?u:k;k=p;while(1){i=Ra(q[k>>2],0,l);r:{if((k|0)!=(p|0)){if(i>>>0<=m+16>>>0){break r}while(1){i=i+ -1|0;o[i|0]=48;if(i>>>0>m+16>>>0){continue}break}break r}if((i|0)!=(l|0)){break r}o[m+24|0]=48;i=g}Ma(a,i,l-i|0);k=k+4|0;if(k>>>0<=u>>>0){continue}break}if(v){Ma(a,6483,1)}if((n|0)<1|k>>>0>=d>>>0){break q}while(1){i=Ra(q[k>>2],0,l);if(i>>>0>m+16>>>0){while(1){i=i+ -1|0;o[i|0]=48;if(i>>>0>m+16>>>0){continue}break}}Ma(a,i,(n|0)<9?n:9);i=n+ -9|0;k=k+4|0;if(k>>>0>=d>>>0){break p}g=(n|0)>9;n=i;if(g){continue}break}break p}s:{if((n|0)<0){break s}u=p?d:k+4|0;d=m+16|8;g=m+16|9;l=k;while(1){i=Ra(q[l>>2],0,g);if((g|0)==(i|0)){o[m+24|0]=48;i=d}t:{if((k|0)!=(l|0)){if(i>>>0<=m+16>>>0){break t}while(1){i=i+ -1|0;o[i|0]=48;if(i>>>0>m+16>>>0){continue}break}break t}Ma(a,i,1);i=i+1|0;if((n|0)<1?!t:0){break t}Ma(a,6483,1)}p=i;i=g-i|0;Ma(a,p,(n|0)>(i|0)?i:n);n=n-i|0;l=l+4|0;if(l>>>0>=u>>>0){break s}if((n|0)>-1){continue}break}}Sa(a,48,n+18|0,18,0);Ma(a,A,z-A|0);break o}i=n}Sa(a,48,i+9|0,9,0)}break b}n=g&32;p=n?E+9|0:E;u:{if(d>>>0>11){break u}i=12-d|0;if(!i){break u}B=8;while(1){B=B*16;i=i+ -1|0;if(i){continue}break}if(r[p|0]==45){b=-(B+(-b-B));break u}b=b+B-B}l=q[m+44>>2];i=l>>31;i=Ra(i^i+l,0,z);if((z|0)==(i|0)){o[m+15|0]=48;i=m+15|0}l=C|2;k=q[m+44>>2];u=i+ -2|0;o[u|0]=g+15;o[i+ -1|0]=(k|0)<0?45:43;j=f&8;k=m+16|0;while(1){g=k;t=n;if(y(b)<2147483648){i=~~b}else{i=-2147483648}o[k|0]=t|r[i+6432|0];b=(b- +(i|0))*16;k=g+1|0;if(!((k-(m+16|0)|0)!=1|(b==0?!((d|0)>0|j):0))){o[g+1|0]=46;k=g+2|0}if(b!=0){continue}break}g=a;n=c;if(!d|((k-m|0)+ -18|0)>=(d|0)){i=((z-(m+16|0)|0)-u|0)+k|0}else{i=((d+z|0)-u|0)+2|0}d=i;j=d+l|0;Sa(g,32,n,j,f);Ma(a,p,l);Sa(a,48,c,j,f^65536);g=k-(m+16|0)|0;Ma(a,m+16|0,g);d=z-u|0;Sa(a,48,i-(d+g|0)|0,0,0);Ma(a,u,d)}Sa(a,32,c,j,f^8192);T=m+560|0;return((j|0)<(c|0)?c:j)|0}function La(a,b,c,d,e,f,g){var h=0,i=0,j=0,k=0,l=0,m=0,s=0,t=0,u=0,x=0,y=0,z=0,A=0,B=0,C=0;h=T-80|0;T=h;q[h+76>>2]=b;C=h+55|0;z=h+56|0;b=0;a:{b:{c:while(1){d:{if((u|0)<0){break d}if((b|0)>(2147483647-u|0)){q[20555]=61;u=-1;break d}u=b+u|0}e:{f:{l=q[h+76>>2];b=l;k=r[b|0];if(k){while(1){g:{i=k&255;h:{if(!i){k=b;break h}if((i|0)!=37){break g}k=b;while(1){if(r[b+1|0]!=37){break h}i=b+2|0;q[h+76>>2]=i;k=k+1|0;j=r[b+2|0];b=i;if((j|0)==37){continue}break}}b=k-l|0;if(a){Ma(a,l,b)}if(b){continue c}x=-1;k=1;i=h;j=!Ga(o[q[h+76>>2]+1|0]);b=q[h+76>>2];if(!(j|r[b+2|0]!=36)){x=o[b+1|0]+ -48|0;A=1;k=3}b=k+b|0;q[i+76>>2]=b;k=0;y=o[b|0];j=y+ -32|0;i:{if(j>>>0>31){i=b;break i}i=b;j=1<>2]=i;k=k|j;y=o[b+1|0];j=y+ -32|0;if(j>>>0>31){break i}b=i;j=1<>2];if(r[b+2|0]!=36){break l}q[((o[b+1|0]<<2)+e|0)+ -192>>2]=10;t=q[((o[b+1|0]<<3)+d|0)+ -384>>2];A=1;b=b+3|0;break k}if(A){break b}A=0;t=0;if(a){b=q[c>>2];q[c>>2]=b+4;t=q[b>>2]}b=q[h+76>>2]+1|0}q[j+76>>2]=b;if((t|0)>-1){break j}t=0-t|0;k=k|8192;break j}t=Na(h+76|0);if((t|0)<0){break b}b=q[h+76>>2]}m=-1;m:{if(r[b|0]!=46){break m}if(r[b+1|0]==42){n:{if(!Ga(o[b+2|0])){break n}b=q[h+76>>2];if(r[b+3|0]!=36){break n}q[((o[b+2|0]<<2)+e|0)+ -192>>2]=10;m=q[((o[b+2|0]<<3)+d|0)+ -384>>2];b=b+4|0;q[h+76>>2]=b;break m}if(A){break b}if(a){b=q[c>>2];q[c>>2]=b+4;m=q[b>>2]}else{m=0}b=q[h+76>>2]+2|0;q[h+76>>2]=b;break m}q[h+76>>2]=b+1;m=Na(h+76|0);b=q[h+76>>2]}i=0;while(1){B=i;s=-1;if(o[b|0]+ -65>>>0>57){break a}y=b+1|0;q[h+76>>2]=y;i=o[b|0];b=y;i=r[(i+w(B,58)|0)+5903|0];if(i+ -1>>>0<8){continue}break}if(!i){break a}o:{p:{q:{if((i|0)==19){if((x|0)<=-1){break q}break a}if((x|0)<0){break p}q[(x<<2)+e>>2]=i;b=(x<<3)+d|0;i=q[b+4>>2];q[h+64>>2]=q[b>>2];q[h+68>>2]=i}b=0;if(!a){continue c}break o}if(!a){break e}Oa(h- -64|0,i,c,g);y=q[h+76>>2]}j=k&-65537;k=k&8192?j:k;s=0;x=5936;i=z;r:{s:{t:{u:{v:{w:{x:{y:{z:{A:{B:{C:{D:{E:{F:{G:{b=o[y+ -1|0];b=B?(b&15)==3?b&-33:b:b;switch(b+ -88|0){case 11:break r;case 9:case 13:case 14:case 15:break s;case 27:break x;case 12:case 17:break A;case 23:break B;case 0:case 32:break C;case 24:break D;case 22:break E;case 29:break F;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break f;default:break G}}H:{switch(b+ -65|0){case 0:case 4:case 5:case 6:break s;case 2:break v;case 1:case 3:break f;default:break H}}if((b|0)==83){break w}break f}b=q[h+64>>2];l=q[h+68>>2];x=5936;break z}b=0;I:{switch(B&255){case 0:q[q[h+64>>2]>>2]=u;continue c;case 1:q[q[h+64>>2]>>2]=u;continue c;case 2:i=q[h+64>>2];q[i>>2]=u;q[i+4>>2]=u>>31;continue c;case 3:p[q[h+64>>2]>>1]=u;continue c;case 4:o[q[h+64>>2]]=u;continue c;case 6:q[q[h+64>>2]>>2]=u;continue c;case 7:break I;default:continue c}}i=q[h+64>>2];q[i>>2]=u;q[i+4>>2]=u>>31;continue c}m=m>>>0>8?m:8;k=k|8;b=120}l=Pa(q[h+64>>2],q[h+68>>2],z,b&32);if(!(k&8)|!(q[h+64>>2]|q[h+68>>2])){break y}x=(b>>>4|0)+5936|0;s=2;break y}l=Qa(q[h+64>>2],q[h+68>>2],z);if(!(k&8)){break y}b=z-l|0;m=(m|0)>(b|0)?m:b+1|0;break y}j=q[h+68>>2];l=j;b=q[h+64>>2];if((j|0)<-1?1:(j|0)<=-1?b>>>0>4294967295?0:1:0){l=0-(l+(0>>0)|0)|0;b=0-b|0;q[h+64>>2]=b;q[h+68>>2]=l;s=1;x=5936;break z}if(k&2048){s=1;x=5937;break z}s=k&1;x=s?5938:5936}l=Ra(b,l,z)}k=(m|0)>-1?k&-65537:k;b=q[h+64>>2];j=q[h+68>>2];if(!(!!(b|j)|m)){m=0;l=z;break f}b=!(b|j)+(z-l|0)|0;m=(m|0)>(b|0)?m:b;break f}b=q[h+64>>2];l=b?b:5946;b=vb(l,m);i=b?b:l+m|0;k=j;m=b?b-l|0:m;break f}i=q[h+64>>2];if(m){break u}b=0;Sa(a,32,t,0,k);break t}q[h+12>>2]=0;q[h+8>>2]=q[h+64>>2];q[h+64>>2]=h+8;m=-1;i=h+8|0}b=0;J:{while(1){l=q[i>>2];if(!l){break J}l=Ia(h+4|0,l);j=(l|0)<0;if(!(j|l>>>0>m-b>>>0)){i=i+4|0;b=b+l|0;if(m>>>0>b>>>0){continue}break J}break}s=-1;if(j){break a}}Sa(a,32,t,b,k);if(!b){b=0;break t}j=0;i=q[h+64>>2];while(1){l=q[i>>2];if(!l){break t}l=Ia(h+4|0,l);j=l+j|0;if((j|0)>(b|0)){break t}Ma(a,h+4|0,l);i=i+4|0;if(j>>>0>>0){continue}break}}Sa(a,32,t,b,k^8192);b=(t|0)>(b|0)?t:b;continue c}b=n[f](a,v[h+64>>3],t,m,k,b)|0;continue c}o[h+55|0]=q[h+64>>2];m=1;l=C;k=j;break f}i=b+1|0;q[h+76>>2]=i;k=r[b+1|0];b=i;continue}}s=u;if(a){break a}if(!A){break e}b=1;while(1){a=q[(b<<2)+e>>2];if(a){Oa((b<<3)+d|0,a,c,g);s=1;b=b+1|0;if((b|0)!=10){continue}break a}break}s=1;if(b>>>0>9){break a}s=-1;if(q[(b<<2)+e>>2]){break a}while(1){a=b;b=b+1|0;if(q[(b<<2)+e>>2]?0:(b|0)!=10){continue}break}s=a>>>0<9?-1:1;break a}j=i-l|0;m=(m|0)<(j|0)?j:m;i=m+s|0;b=(t|0)<(i|0)?i:t;Sa(a,32,b,i,k);Ma(a,x,s);Sa(a,48,b,i,k^65536);Sa(a,48,m,j,0);Ma(a,l,j);Sa(a,32,b,i,k^8192);continue}break}s=0;break a}s=-1}T=h+80|0;return s}function ac(a,b,c,d,e,f,g,h,i){var j=0,k=0,l=0,m=0,n=0,o=0,p=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,U=0,W=0,X=0,Y=0,Z=0;n=T-96|0;T=n;p=c;k=g;u=(k&131071)<<15|f>>>17;j=i&65535;w=j;s=h;k=h;B=k<<15|g>>>17;o=(e^i)&-2147483648;k=e&65535;m=k;r=d;E=k;k=j;C=(k&131071)<<15|h>>>17;F=i>>>16&32767;N=e>>>16&32767;a:{b:{if(N+ -1>>>0<=32765){v=0;if(F+ -1>>>0<32766){break b}}x=e&2147483647;j=x;k=d;if(!(!d&(j|0)==2147418112?!(b|c):(j|0)==2147418112&d>>>0<0|j>>>0<2147418112)){y=d;o=e|32768;break a}x=i&2147483647;e=x;d=h;if(!(!d&(e|0)==2147418112?!(f|g):(e|0)==2147418112&d>>>0<0|e>>>0<2147418112)){y=h;o=i|32768;b=f;c=g;break a}if(!(b|k|(j^2147418112|c))){if(!(d|f|(e|g))){o=2147450880;b=0;c=0;break a}o=o|2147418112;b=0;c=0;break a}if(!(d|f|(e^2147418112|g))){d=b|k;e=c|j;b=0;c=0;if(!(d|e)){o=2147450880;break a}o=o|2147418112;break a}if(!(b|k|(c|j))){b=0;c=0;break a}if(!(d|f|(e|g))){b=0;c=0;break a}if((j|0)==65535&k>>>0<=4294967295|j>>>0<65535){j=b;k=c;h=!(m|r);i=h<<6;l=z(h?b:r)+32|0;b=z(h?c:m);b=i+((b|0)==32?l:b)|0;Tb(n+80|0,j,k,r,m,b+ -15|0);r=q[n+88>>2];p=q[n+84>>2];E=q[n+92>>2];l=16-b|0;b=q[n+80>>2]}v=l;if((e|0)==65535&d>>>0>4294967295|e>>>0>65535){break b}c=!(s|w);d=c<<6;e=z(c?f:s)+32|0;c=z(c?g:w);c=d+((c|0)==32?e:c)|0;h=c;Tb(n- -64|0,f,g,s,w,c+ -15|0);f=q[n+76>>2];c=f;i=q[n+68>>2];g=i;e=q[n+72>>2];d=e;B=d<<15|g>>>17;d=g;f=q[n+64>>2];u=(d&131071)<<15|f>>>17;C=(c&131071)<<15|e>>>17;v=(l-h|0)+16|0}d=u;s=0;i=Pc(d,0,b,s);c=V;D=c;A=f<<15&-32768;f=Pc(A,0,p,0);e=f+i|0;l=V+c|0;l=e>>>0>>0?l+1|0:l;c=e;f=0;g=Pc(A,G,b,s);e=f+g|0;j=V+c|0;j=e>>>0>>0?j+1|0:j;u=e;g=j;Z=(c|0)==(j|0)&e>>>0>>0|j>>>0>>0;Q=Pc(d,O,p,P);J=V;x=r;f=Pc(A,G,r,0);e=f+Q|0;m=V+J|0;m=e>>>0>>0?m+1|0:m;R=e;h=Pc(B,0,b,s);e=e+h|0;f=V+m|0;K=e;f=e>>>0>>0?f+1|0:f;w=f;h=f;f=(l|0)==(D|0)&c>>>0>>0|l>>>0>>0;e=l;c=e+K|0;j=f+h|0;D=c;j=c>>>0>>0?j+1|0:j;e=j;h=c;U=Pc(d,O,r,S);L=V;c=A;H=E|65536;A=t;f=Pc(c,G,H,t);c=f+U|0;j=V+L|0;j=c>>>0>>0?j+1|0:j;W=c;k=Pc(p,P,B,X);c=c+k|0;t=j;f=j+V|0;f=c>>>0>>0?f+1|0:f;M=c;I=C&2147483647|-2147483648;c=Pc(I,0,b,s);b=M+c|0;s=f;k=f+V|0;G=b;c=b>>>0>>0?k+1|0:k;j=e+b|0;f=0;b=f+h|0;if(b>>>0>>0){j=j+1|0}E=b;C=j;f=j;h=b+Z|0;if(h>>>0>>0){f=f+1|0}i=f;r=(v+(F+N|0)|0)+ -16383|0;f=Pc(x,S,B,X);b=V;l=0;k=Pc(d,O,H,A);d=k+f|0;j=V+b|0;j=d>>>0>>0?j+1|0:j;v=d;k=d;d=j;j=(b|0)==(d|0)&k>>>0>>0|d>>>0>>0;f=Pc(I,Y,p,P);b=f+k|0;k=V+d|0;k=b>>>0>>0?k+1|0:k;p=b;f=b;b=k;d=(d|0)==(b|0)&f>>>0>>0|b>>>0>>0;f=j+d|0;if(f>>>0>>0){l=1}k=f;d=b;f=l;F=k;j=0;k=(m|0)==(w|0)&K>>>0>>0|w>>>0>>0;m=k+((m|0)==(J|0)&R>>>0>>0|m>>>0>>0)|0;if(m>>>0>>0){j=1}l=m;m=m+p|0;k=d+j|0;v=m;j=m;k=j>>>0>>0?k+1|0:k;d=k;b=(b|0)==(d|0)&j>>>0

>>0|d>>>0>>0;k=F+b|0;if(k>>>0>>0){f=f+1|0}b=k;k=Pc(I,Y,H,A);b=b+k|0;j=V+f|0;j=b>>>0>>0?j+1|0:j;l=b;m=Pc(I,Y,x,S);f=V;p=Pc(B,X,H,A);b=p+m|0;k=V+f|0;k=b>>>0

>>0?k+1|0:k;p=b;b=k;k=(f|0)==(b|0)&p>>>0>>0|b>>>0>>0;f=b+l|0;l=j+k|0;k=f>>>0>>0?l+1|0:l;x=f;j=d+p|0;l=0;b=l+v|0;if(b>>>0>>0){j=j+1|0}m=b;f=b;b=j;d=(d|0)==(b|0)&f>>>0>>0|b>>>0>>0;f=x+d|0;if(f>>>0>>0){k=k+1|0}p=f;l=b;j=0;f=(t|0)==(s|0)&M>>>0>>0|s>>>0>>0;t=f+((t|0)==(L|0)&W>>>0>>0|t>>>0>>0)|0;if(t>>>0>>0){j=1}f=t+((c|0)==(s|0)&G>>>0>>0|c>>>0>>0)|0;d=c;c=d+m|0;l=f+l|0;l=c>>>0>>0?l+1|0:l;t=c;d=c;c=l;b=(b|0)==(c|0)&d>>>0>>0|c>>>0>>0;d=b+p|0;if(d>>>0>>0){k=k+1|0}b=c;j=k;k=d;f=0;d=(e|0)==(C|0)&E>>>0>>0|C>>>0>>0;e=d+((e|0)==(w|0)&D>>>0>>0|e>>>0>>0)|0;if(e>>>0>>0){f=1}d=e+t|0;l=b+f|0;l=d>>>0>>0?l+1|0:l;b=d;e=l;b=(c|0)==(e|0)&b>>>0>>0|e>>>0>>0;c=k+b|0;if(c>>>0>>0){j=j+1|0}b=c;c=j;c:{if(c&65536){r=r+1|0;break c}m=g>>>31|0;j=c<<1|b>>>31;b=b<<1|e>>>31;c=j;j=e<<1|d>>>31;d=d<<1|i>>>31;e=j;k=u;j=g<<1|k>>>31;u=k<<1;g=j;k=i<<1|h>>>31;h=h<<1|m;i=k}if((r|0)>=32767){o=o|2147418112;b=0;c=0;break a}d:{if((r|0)<=0){f=1-r|0;if(f>>>0<=127){k=r+127|0;Tb(n+48|0,u,g,h,i,k);Tb(n+32|0,d,e,b,c,k);$b(n+16|0,u,g,h,i,f);$b(n,d,e,b,c,f);u=(q[n+48>>2]|q[n+56>>2])!=0|(q[n+52>>2]|q[n+60>>2])!=0|(q[n+32>>2]|q[n+16>>2]);g=q[n+36>>2]|q[n+20>>2];h=q[n+40>>2]|q[n+24>>2];i=q[n+44>>2]|q[n+28>>2];d=q[n>>2];e=q[n+4>>2];c=q[n+12>>2];b=q[n+8>>2];break d}b=0;c=0;break a}c=c&65535|r<<16}y=b|y;o=c|o;if(!(!h&(i|0)==-2147483648?!(g|u):(i|0)>-1?1:(i|0)>=-1?h>>>0<=4294967295?0:1:0)){l=o;m=e;b=d+1|0;if(b>>>0<1){m=m+1|0}c=m;d=(e|0)==(c|0)&b>>>0>>0|c>>>0>>0;e=d+y|0;if(e>>>0>>0){l=l+1|0}y=e;o=l;break a}if(h|u|(i^-2147483648|g)){b=d;c=e;break a}m=o;j=e;b=d&1;c=b+d|0;if(c>>>0>>0){j=j+1|0}b=c;c=j;d=(e|0)==(c|0)&b>>>0>>0|c>>>0>>0;e=d+y|0;if(e>>>0>>0){m=m+1|0}y=e;o=m}q[a>>2]=b;q[a+4>>2]=c;q[a+8>>2]=y;q[a+12>>2]=o;T=n+96|0}function Ob(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,s=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;f=T-432|0;T=f;g=q[b+4>>2];a:{if(g>>>0>2]){q[b+4>>2]=g+1;h=r[g|0];break a}h=Kb(b)}b:{c:{while(1){d:{if((h|0)!=48){if((h|0)!=46){break b}g=q[b+4>>2];if(g>>>0>=t[b+104>>2]){break d}q[b+4>>2]=g+1;h=r[g|0];break c}g=q[b+4>>2];if(g>>>0>2]){x=1;q[b+4>>2]=g+1;h=r[g|0]}else{x=1;h=Kb(b)}continue}break}h=Kb(b)}y=1;if((h|0)!=48){break b}while(1){j=j+ -1|0;g=o+ -1|0;if(g>>>0<4294967295){j=j+1|0}o=g;g=q[b+4>>2];e:{if(g>>>0>2]){q[b+4>>2]=g+1;h=r[g|0];break e}h=Kb(b)}if((h|0)==48){continue}break}x=1}g=1073676288;while(1){f:{z=h|32;g:{h:{A=h+ -48|0;if(A>>>0<10){break h}if(z+ -97>>>0>5?(h|0)!=46:0){break f}if((h|0)!=46){break h}if(y){break f}y=1;o=m;j=i;break g}h=(h|0)>57?z+ -87|0:A;i:{if((i|0)<0?1:(i|0)<=0?m>>>0>7?0:1:0){p=h+(p<<4)|0;break i}if((i|0)<0?1:(i|0)<=0?m>>>0>28?0:1:0){Zb(f+48|0,h);ac(f+32|0,v,w,n,g,0,0,0,1073414144);v=q[f+32>>2];w=q[f+36>>2];n=q[f+40>>2];g=q[f+44>>2];ac(f+16|0,v,w,n,g,q[f+48>>2],q[f+52>>2],q[f+56>>2],q[f+60>>2]);Sb(f,k,l,s,u,q[f+16>>2],q[f+20>>2],q[f+24>>2],q[f+28>>2]);s=q[f+8>>2];u=q[f+12>>2];k=q[f>>2];l=q[f+4>>2];break i}if(!h|D){break i}ac(f+80|0,v,w,n,g,0,0,0,1073610752);Sb(f- -64|0,k,l,s,u,q[f+80>>2],q[f+84>>2],q[f+88>>2],q[f+92>>2]);s=q[f+72>>2];u=q[f+76>>2];D=1;k=q[f+64>>2];l=q[f+68>>2]}m=m+1|0;if(m>>>0<1){i=i+1|0}x=1}h=q[b+4>>2];if(h>>>0>2]){q[b+4>>2]=h+1;h=r[h|0]}else{h=Kb(b)}continue}break}j:{k:{if(!x){if(!q[b+104>>2]){break k}q[b+4>>2]=q[b+4>>2]+ -1;break k}if((i|0)<0?1:(i|0)<=0?m>>>0>7?0:1:0){n=m;g=i;while(1){p=p<<4;n=n+1|0;if(n>>>0<1){g=g+1|0}if((n|0)!=8|g){continue}break}}l:{if((h&-33)==80){n=Qb(b);h=V;g=h;if(n|(g|0)!=-2147483648){break l}k=0;l=0;Jb(b,0,0);c=0;b=0;break j}n=0;g=0;if(!q[b+104>>2]){break l}q[b+4>>2]=q[b+4>>2]+ -1}if(!p){Xb(f+112|0,+(e|0)*0);k=q[f+112>>2];l=q[f+116>>2];c=q[f+120>>2];b=q[f+124>>2];break j}b=y?j:i;i=y?o:m;j=b<<2|i>>>30;b=n+(i<<2)|0;i=g+j|0;i=b>>>0>>0?i+1|0:i;b=b+ -32|0;g=i+ -1|0;g=b>>>0<4294967264?g+1|0:g;m=b;b=0-d|0;h=m>>>0<=b>>>0?0:1;i=g;b=b>>31;if((g|0)>(b|0)?1:(g|0)>=(b|0)?h:0){q[20555]=68;Zb(f+160|0,e);ac(f+144|0,q[f+160>>2],q[f+164>>2],q[f+168>>2],q[f+172>>2],-1,-1,-1,2147418111);ac(f+128|0,q[f+144>>2],q[f+148>>2],q[f+152>>2],q[f+156>>2],-1,-1,-1,2147418111);k=q[f+128>>2];l=q[f+132>>2];c=q[f+136>>2];b=q[f+140>>2];break j}b=d+ -226|0;g=m>>>0>>0?0:1;b=b>>31;if((i|0)>(b|0)?1:(i|0)>=(b|0)?g:0){if((p|0)>-1){while(1){Sb(f+416|0,k,l,s,u,0,0,0,-1073807360);h=Vb(k,l,s,u);g=(h|0)<0;b=g;Sb(f+400|0,k,l,s,u,b?k:q[f+416>>2],b?l:q[f+420>>2],b?s:q[f+424>>2],b?u:q[f+428>>2]);i=i+ -1|0;b=m+ -1|0;if(b>>>0<4294967295){i=i+1|0}m=b;s=q[f+408>>2];u=q[f+412>>2];k=q[f+400>>2];l=q[f+404>>2];p=p<<1|(h|0)>-1;if((p|0)>-1){continue}break}}g=m;b=d;o=(g-b|0)+32|0;j=i-((b>>31)+(g>>>0>>0)|0)|0;d=o;b=d;g=(b|0)>0?b:0;h=c;j=b>>>0<32?j+1|0:j;b=h>>31;c=((j|0)<(b|0)?1:(j|0)<=(b|0)?d>>>0>=h>>>0?0:1:0)?g:h;m:{if((c|0)>=113){Zb(f+384|0,e);o=q[f+392>>2];j=q[f+396>>2];v=q[f+384>>2];w=q[f+388>>2];d=0;b=0;break m}Xb(f+352|0,rc(1,144-c|0));Zb(f+336|0,e);v=q[f+336>>2];w=q[f+340>>2];o=q[f+344>>2];j=q[f+348>>2];Lb(f+368|0,q[f+352>>2],q[f+356>>2],q[f+360>>2],q[f+364>>2],v,w,o,j);B=q[f+376>>2];C=q[f+380>>2];d=q[f+372>>2];b=q[f+368>>2]}c=!(p&1)&((Ub(k,l,s,u,0,0,0,0)|0)!=0&(c|0)<32);_b(f+320|0,c+p|0);ac(f+304|0,v,w,o,j,q[f+320>>2],q[f+324>>2],q[f+328>>2],q[f+332>>2]);Sb(f+272|0,q[f+304>>2],q[f+308>>2],q[f+312>>2],q[f+316>>2],b,d,B,C);ac(f+288|0,c?0:k,c?0:l,c?0:s,c?0:u,v,w,o,j);Sb(f+256|0,q[f+288>>2],q[f+292>>2],q[f+296>>2],q[f+300>>2],q[f+272>>2],q[f+276>>2],q[f+280>>2],q[f+284>>2]);cc(f+240|0,q[f+256>>2],q[f+260>>2],q[f+264>>2],q[f+268>>2],b,d,B,C);e=q[f+240>>2];d=q[f+244>>2];c=q[f+248>>2];b=q[f+252>>2];if(!Ub(e,d,c,b,0,0,0,0)){q[20555]=68}Mb(f+224|0,e,d,c,b,m);k=q[f+224>>2];l=q[f+228>>2];c=q[f+232>>2];b=q[f+236>>2];break j}q[20555]=68;Zb(f+208|0,e);ac(f+192|0,q[f+208>>2],q[f+212>>2],q[f+216>>2],q[f+220>>2],0,0,0,65536);ac(f+176|0,q[f+192>>2],q[f+196>>2],q[f+200>>2],q[f+204>>2],0,0,0,65536);k=q[f+176>>2];l=q[f+180>>2];c=q[f+184>>2];b=q[f+188>>2];break j}Jb(b,0,0);Xb(f+96|0,+(e|0)*0);k=q[f+96>>2];l=q[f+100>>2];c=q[f+104>>2];b=q[f+108>>2]}q[a>>2]=k;q[a+4>>2]=l;q[a+8>>2]=c;q[a+12>>2]=b;T=f+432|0}function Sb(a,b,c,d,e,f,g,h,i){var j=0,k=0,l=0,m=0,n=0,o=0,p=0,r=0,s=0,t=0,u=0,v=0;l=T-112|0;T=l;m=h;o=i&2147483647;k=c+ -1|0;j=b+ -1|0;if(j>>>0<4294967295){k=k+1|0}n=j;r=(j|0)==-1&(k|0)==-1;p=e&2147483647;j=p;s=d;k=(c|0)==(k|0)&n>>>0>>0|k>>>0>>0;n=d+k|0;if(n>>>0>>0){j=j+1|0}n=n+ -1|0;k=j+ -1|0;j=n;a:{b:{k=j>>>0<4294967295?k+1|0:k;if(!((j|0)==-1&(k|0)==2147418111?r:(k|0)==2147418111&j>>>0>4294967295|k>>>0>2147418111)){k=g+ -1|0;j=f+ -1|0;if(j>>>0<4294967295){k=k+1|0}n=j;r=(j|0)!=-1|(k|0)!=-1;j=o;k=(g|0)==(k|0)&n>>>0>>0|k>>>0>>0;n=k+m|0;if(n>>>0>>0){j=j+1|0}k=n+ -1|0;j=j+ -1|0;j=k>>>0<4294967295?j+1|0:j;if((k|0)==-1&(j|0)==2147418111?r:(j|0)==2147418111&k>>>0<4294967295|j>>>0<2147418111){break b}}if(!(!s&(p|0)==2147418112?!(b|c):(p|0)==2147418112&s>>>0<0|p>>>0<2147418112)){h=d;i=e|32768;f=b;g=c;break a}if(!(!m&(o|0)==2147418112?!(f|g):(o|0)==2147418112&m>>>0<0|o>>>0<2147418112)){i=i|32768;break a}if(!(b|s|(p^2147418112|c))){j=d;d=!(b^f|d^h|(c^g|e^i^-2147483648));h=d?0:j;i=d?2147450880:e;f=d?0:b;g=d?0:c;break a}if(!(f|m|(o^2147418112|g))){break a}if(!(b|s|(c|p))){if(f|m|(g|o)){break a}f=b&f;g=c&g;h=d&h;i=e&i;break a}if(f|m|(g|o)){break b}f=b;g=c;h=d;i=e;break a}k=(m|0)==(s|0)&(o|0)==(p|0)?(c|0)==(g|0)&f>>>0>b>>>0|g>>>0>c>>>0:(o|0)==(p|0)&m>>>0>s>>>0|o>>>0>p>>>0;j=k;p=j?f:b;o=j?g:c;m=j?i:e;s=m;t=j?h:d;n=t;j=m&65535;i=k?e:i;u=i;e=k?d:h;r=i>>>16&32767;m=m>>>16&32767;if(!m){d=!(j|n);h=d<<6;i=z(d?p:n)+32|0;d=z(d?o:j);d=h+((d|0)==32?i:d)|0;Tb(l+96|0,p,o,n,j,d+ -15|0);n=q[l+104>>2];p=q[l+96>>2];o=q[l+100>>2];m=16-d|0;j=q[l+108>>2]}f=k?b:f;g=k?c:g;b=e;c=u&65535;if(r){d=b;b=c}else{i=b;d=!(b|c);h=d<<6;k=z(d?f:b)+32|0;b=z(d?g:c);b=h+((b|0)==32?k:b)|0;Tb(l+80|0,f,g,i,c,b+ -15|0);r=16-b|0;f=q[l+80>>2];g=q[l+84>>2];d=q[l+88>>2];b=q[l+92>>2]}c=d;k=b<<3|c>>>29;h=c<<3|g>>>29;i=k|524288;b=n;d=j<<3|b>>>29;k=b<<3|o>>>29;v=d;t=e^t;n=s^u;b=f;j=g<<3|b>>>29;b=b<<3;c=j;e=m-r|0;d=b;c:{if(!e){break c}if(e>>>0>127){h=0;i=0;j=0;d=1;break c}Tb(l- -64|0,b,c,h,i,128-e|0);$b(l+48|0,b,c,h,i,e);h=q[l+56>>2];i=q[l+60>>2];j=q[l+52>>2];d=q[l+48>>2]|((q[l+64>>2]|q[l+72>>2])!=0|(q[l+68>>2]|q[l+76>>2])!=0)}g=j;e=k;r=v|524288;b=p;j=o<<3|b>>>29;c=b<<3;d:{if((n|0)<-1?1:(n|0)<=-1?t>>>0>4294967295?0:1:0){o=d;b=c-d|0;p=e-h|0;d=(g|0)==(j|0)&c>>>0>>0|j>>>0>>0;f=p-d|0;c=j-((c>>>0>>0)+g|0)|0;g=(r-((e>>>0>>0)+i|0)|0)-(p>>>0>>0)|0;if(!(b|f|(c|g))){f=0;g=0;h=0;i=0;break a}if((g|0)==524287&f>>>0>4294967295|g>>>0>524287){break d}h=b;d=!(f|g);e=d<<6;i=z(d?b:f)+32|0;b=z(d?c:g);b=e+((b|0)==32?i:b)|0;b=b+ -12|0;Tb(l+32|0,h,c,f,g,b);m=m-b|0;f=q[l+40>>2];g=q[l+44>>2];b=q[l+32>>2];c=q[l+36>>2];break d}k=g+j|0;b=d;c=b+c|0;if(c>>>0>>0){k=k+1|0}b=c;c=k;g=(g|0)==(c|0)&b>>>0>>0|c>>>0>>0;k=i+r|0;d=e+h|0;if(d>>>0>>0){k=k+1|0}f=d;e=g+d|0;d=k;d=e>>>0>>0?d+1|0:d;f=e;g=d;if(!(d&1048576)){break d}b=b&1|((c&1)<<31|b>>>1);c=f<<31|c>>>1;m=m+1|0;f=(g&1)<<31|f>>>1;g=g>>>1|0}h=0;j=s&-2147483648;if((m|0)>=32767){i=j|2147418112;f=0;g=0;break a}e=0;e:{if((m|0)>0){e=m;break e}Tb(l+16|0,b,c,f,g,m+127|0);$b(l,b,c,f,g,1-m|0);b=q[l>>2]|((q[l+16>>2]|q[l+24>>2])!=0|(q[l+20>>2]|q[l+28>>2])!=0);c=q[l+4>>2];f=q[l+8>>2];g=q[l+12>>2]}h=h|((g&7)<<29|f>>>3);e=j|g>>>3&65535|e<<16;j=f<<29;d=0;f=j;g=(c&7)<<29|b>>>3|d;j=e;d=c>>>3|f;k=d;e=b&7;b=e>>>0>4;c=b+g|0;if(c>>>0>>0){k=k+1|0}b=c;c=k;d=(d|0)==(c|0)&b>>>0>>0|c>>>0>>0;f=d+h|0;if(f>>>0>>0){j=j+1|0}e=(e|0)==4;d=e?b&1:0;i=j;h=f;e=0;j=c+e|0;c=b+d|0;if(c>>>0>>0){j=j+1|0}f=c;b=c;g=j;b=(e|0)==(j|0)&b>>>0>>0|j>>>0>>0;c=h+b|0;if(c>>>0>>0){i=i+1|0}h=c}q[a>>2]=f;q[a+4>>2]=g;q[a+8>>2]=h;q[a+12>>2]=i;T=l+112|0}function qa(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=x(0),j=0,k=0,l=0,m=0,n=0,t=0,v=0,w=0,y=0,z=0,A=0,B=0,C=0;e=T-784|0;T=e;d=uc(c,0,624);q[d+12>>2]=1;q[d+16>>2]=0;q[d+68>>2]=1065353216;q[d+72>>2]=1036831949;o[d+40|0]=99;q[d+4>>2]=1;q[d+8>>2]=-1;q[d+64>>2]=-1;q[d+56>>2]=0;j=d+40|0;h=d+8|0;a:{b:{c:{d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{c=a+ -1|0;g=c;n:{if((a|0)<2){break n}z=d- -64|0;l=d+72|0;m=d+68|0;A=d+4|0;n=d+16|0;k=d+12|0;t=d+52|0;v=d+44|0;w=d+48|0;B=d+80|0;C=d+612|0;y=d+616|0;while(1){f=b;b=f+4|0;a=c;f=q[f+4>>2];g=c;if(r[f|0]!=45){break n}c=f+1|0;q[b>>2]=c;o:{p:{q:{r:{s:{t:{u:{v:{w:{x:{y:{z:{A:{B:{C:{D:{E:{F:{G:{H:{I:{g=o[f+1|0];switch(g+ -48|0){case 64:break p;case 70:break r;case 66:break s;case 61:break t;case 63:break u;case 59:break v;case 71:break w;case 68:break x;case 67:break y;case 57:break z;case 1:break A;case 0:break B;case 56:break C;case 51:break D;case 50:break E;case 54:break F;case 52:break G;case 60:break H;case 49:break I;default:break q}}q[d>>2]=1;c=f+2|0;if(!Cc(c)){break o}q[d+604>>2]=c;break o}I(0);F()}q[e+16>>2]=A;if((Fa(c,2335,e+16|0)|0)!=-1){break o}yc(2340,22,1,q[1624]);break a}q[e+32>>2]=h;if((Fa(c,2363,e+32|0)|0)==-1){break m}if(q[h>>2]<5){break o}q[h>>2]=4;break o}oa(f+2|0,z);break o}if((Cc(c)|0)!=3){break e}q[e+64>>2]=t;if((Fa(c,2418,e- -64|0)|0)==-1){break e}q[e+48>>2]=q[t>>2];zc(2423,e+48|0);break o}q[e+80>>2]=m;if((Fa(c,2449,e+80|0)|0)==-1){break l}i=u[m>>2];if(i<=x(0)^1?!(i>x(10)):0){break o}Bc(5695);break a}q[e+96>>2]=v;if((Fa(c,2477,e+96|0)|0)==-1){break k}if(q[v>>2]+ -1>>>0<80){break o}yc(2527,21,1,q[1624]);break a}q[e+112>>2]=w;if((Fa(c,2549,e+112|0)|0)==-1){break j}if(q[w>>2]+ -1>>>0<80){break o}Bc(5631);break a}q[e+128>>2]=l;if((Fa(c,2553,e+128|0)|0)==-1){break i}i=u[l>>2];if(+i<=.1^1?!(i>x(10)):0){break o}yc(2588,26,1,q[1624]);break a}if((Cc(c)|0)!=5){break d}c=q[b>>2];q[e+144>>2]=e+528;if((Fa(c,2639,e+144|0)|0)==-1){break d}c=s[e+528>>1];p[d+620>>1]=(c<<24|c<<8&16711680)>>>16;q[d+32>>2]=1;break o}q[e+160>>2]=j;if((Fa(c,2645,e+160|0)|0)!=-1){c=r[j|0]+ -99|0;if(!c|(c|0)==16){break o}}yc(2649,66,1,q[1624]);break a}q[e+176>>2]=n;if((Fa(c,2716,e+176|0)|0)==-1){break g}if(q[n>>2]<2){break o}break g}q[k>>2]=0;q[e+192>>2]=k;if((Fa(c,2745,e+192|0)|0)==-1){break c}c=q[k>>2];if((c|0)<=-1){break c}if((c|0)<2){break o}q[d+20>>2]=1;q[d+12>>2]=1;break o}q[e+208>>2]=B;if((Fa(c,2772,e+208|0)|0)!=-1){break o}yc(2776,36,1,q[1624]);break a}if((Cc(c)|0)!=3){break b}q[e+240>>2]=C;if((Fa(c,2840,e+240|0)|0)==-1){break b}q[e+224>>2]=q[d+612>>2];zc(2845,e+224|0);q[d+24>>2]=1;break o}q[d+56>>2]=1;break o}if((Cc(c)|0)==1){break f}if(Cc(c)>>>0>=4){break f}q[d+36>>2]=1;q[e+256>>2]=y;if((Fa(c,2907,e+256|0)|0)==-1){break f}if(q[y>>2]+ -1>>>0<10){break o}break f}q[e>>2]=g;bb(q[1624],2912,e);break a}q[d+28>>2]=1}c=a+ -1|0;if((a|0)>1){continue}break}g=0}q[d+608>>2]=0;q[d+60>>2]=0;a=d+60|0;c=g;if(c){while(1){g=Fb(e+528|0,q[b>>2]);zb(q[b>>2],2929);f=zb(0,2931);if(f){Fb(e+272|0,f)}q[d+608>>2]=fa(q[d+608>>2],g,a);b=b+4|0;c=c+ -1|0;if(c){continue}break}}if(q[d>>2]){q[d+20>>2]=0;q[d+56>>2]=2;q[d+12>>2]=1}if(q[h>>2]<=-1){q[h>>2]=r[j|0]==99}if(!q[a>>2]){break h}T=e+784|0;return}yc(2368,20,1,q[1624]);break a}yc(2453,23,1,q[1624]);break a}yc(2481,45,1,q[1624]);break a}Bc(5651);break a}yc(2557,30,1,q[1624]);break a}Bc(3829);I(0);F()}yc(2721,23,1,q[1624]);break a}yc(2871,35,1,q[1624]);break a}yc(2389,28,1,q[1624]);break a}yc(2615,23,1,q[1624]);break a}yc(2750,21,1,q[1624]);break a}yc(2813,26,1,q[1624])}I(1);F()}function gc(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,r=0,s=0,t=0,u=0,x=0,z=0;h=T-560|0;T=h;f=c;c=(c+ -3|0)/24|0;r=(c|0)>0?c:0;k=f+w(r,-24)|0;m=q[1777];i=d+ -1|0;if((m+i|0)>=0){f=d+m|0;c=r-i|0;while(1){v[(h+320|0)+(g<<3)>>3]=(c|0)<0?0:+q[(c<<2)+7120>>2];c=c+1|0;g=g+1|0;if((f|0)!=(g|0)){continue}break}}n=k+ -24|0;f=0;g=(m|0)>0?m:0;l=(d|0)<1;while(1){a:{if(l){e=0;break a}j=f+i|0;c=0;e=0;while(1){e=e+v[(c<<3)+a>>3]*v[(h+320|0)+(j-c<<3)>>3];c=c+1|0;if((d|0)!=(c|0)){continue}break}}v[(f<<3)+h>>3]=e;c=(f|0)==(g|0);f=f+1|0;if(!c){continue}break}x=47-k|0;s=48-k|0;z=k+ -25|0;f=m;b:{while(1){e=v[(f<<3)+h>>3];c=0;g=f;j=(f|0)<1;if(!j){while(1){l=(h+480|0)+(c<<2)|0;o=e;e=e*5.960464477539063e-8;c:{if(y(e)<2147483648){i=~~e;break c}i=-2147483648}e=+(i|0);o=o+e*-16777216;d:{if(y(o)<2147483648){i=~~o;break d}i=-2147483648}q[l>>2]=i;g=g+ -1|0;e=v[(g<<3)+h>>3]+e;c=c+1|0;if((f|0)!=(c|0)){continue}break}}e=rc(e,n);e=e+C(e*.125)*-8;e:{if(y(e)<2147483648){l=~~e;break e}l=-2147483648}e=e- +(l|0);f:{g:{h:{t=(n|0)<1;i:{if(!t){g=((f<<2)+h|0)+476|0;i=q[g>>2];c=i>>s;p=g;g=i-(c<>2]=g;l=c+l|0;i=g>>x;break i}if(n){break h}i=q[((f<<2)+h|0)+476>>2]>>23}if((i|0)<1){break f}break g}i=2;if(!!(e>=.5)){break g}i=0;break f}c=0;g=0;if(!j){while(1){p=(h+480|0)+(c<<2)|0;u=q[p>>2];j=16777215;j:{k:{if(g){break k}j=16777216;if(u){break k}g=0;break j}q[p>>2]=j-u;g=1}c=c+1|0;if((f|0)!=(c|0)){continue}break}}l:{if(t){break l}m:{switch(z|0){case 0:c=((f<<2)+h|0)+476|0;q[c>>2]=q[c>>2]&8388607;break l;case 1:break m;default:break l}}c=((f<<2)+h|0)+476|0;q[c>>2]=q[c>>2]&4194303}l=l+1|0;if((i|0)!=2){break f}e=1-e;i=2;if(!g){break f}e=e-rc(1,n)}if(e==0){g=0;n:{c=f;if((c|0)<=(m|0)){break n}while(1){c=c+ -1|0;g=q[(h+480|0)+(c<<2)>>2]|g;if((c|0)>(m|0)){continue}break}if(!g){break n}k=n;while(1){k=k+ -24|0;f=f+ -1|0;if(!q[(h+480|0)+(f<<2)>>2]){continue}break}break b}c=1;while(1){g=c;c=c+1|0;if(!q[(h+480|0)+(m-g<<2)>>2]){continue}break}g=f+g|0;while(1){i=d+f|0;f=f+1|0;v[(h+320|0)+(i<<3)>>3]=q[(r+f<<2)+7120>>2];c=0;e=0;if((d|0)>=1){while(1){e=e+v[(c<<3)+a>>3]*v[(h+320|0)+(i-c<<3)>>3];c=c+1|0;if((d|0)!=(c|0)){continue}break}}v[(f<<3)+h>>3]=e;if((f|0)<(g|0)){continue}break}f=g;continue}break}e=rc(e,0-n|0);o:{if(!!(e>=16777216)){d=(h+480|0)+(f<<2)|0;o=e;e=e*5.960464477539063e-8;p:{if(y(e)<2147483648){c=~~e;break p}c=-2147483648}e=o+ +(c|0)*-16777216;q:{if(y(e)<2147483648){a=~~e;break q}a=-2147483648}q[d>>2]=a;f=f+1|0;break o}if(y(e)<2147483648){c=~~e}else{c=-2147483648}k=n}q[(h+480|0)+(f<<2)>>2]=c}e=rc(1,k);r:{if((f|0)<=-1){break r}c=f;while(1){v[(c<<3)+h>>3]=e*+q[(h+480|0)+(c<<2)>>2];e=e*5.960464477539063e-8;a=(c|0)>0;c=c+ -1|0;if(a){continue}break}j=0;if((f|0)<0){break r}a=(m|0)>0?m:0;g=f;while(1){d=a>>>0>>0?a:j;k=f-g|0;c=0;e=0;while(1){e=e+v[(c<<3)+9888>>3]*v[(c+g<<3)+h>>3];n=(c|0)!=(d|0);c=c+1|0;if(n){continue}break}v[(h+160|0)+(k<<3)>>3]=e;g=g+ -1|0;c=(f|0)!=(j|0);j=j+1|0;if(c){continue}break}}e=0;if((f|0)>=0){c=f;while(1){e=e+v[(h+160|0)+(c<<3)>>3];a=(c|0)>0;c=c+ -1|0;if(a){continue}break}}v[b>>3]=i?-e:e;e=v[h+160>>3]-e;c=1;if((f|0)>=1){while(1){e=e+v[(h+160|0)+(c<<3)>>3];a=(c|0)!=(f|0);c=c+1|0;if(a){continue}break}}v[b+8>>3]=i?-e:e;T=h+560|0;return l&7}function Hb(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,p=0,s=0,u=0,v=0;j=-1;k=-1;l=T-16|0;T=l;a:{b:{c:{d:{e:{f:{if(b>>>0<=36){while(1){c=q[a+4>>2];g:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break g}c=Kb(a)}if(fb(c)){continue}break}h:{i:{switch(c+ -43|0){case 0:case 2:break i;default:break h}}n=(c|0)==45?-1:0;c=q[a+4>>2];if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break h}c=Kb(a)}j:{if(!(b&-17|(c|0)!=48)){c=q[a+4>>2];k:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break k}c=Kb(a)}if((c&-33)==88){b=16;c=q[a+4>>2];l:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break l}c=Kb(a)}if(r[c+6737|0]<16){break e}if(!q[a+104>>2]){break b}q[a+4>>2]=q[a+4>>2]+ -1;break b}if(b){break j}b=8;break e}b=b?b:10;if(b>>>0>r[c+6737|0]){break j}if(q[a+104>>2]){q[a+4>>2]=q[a+4>>2]+ -1}j=0;k=0;Jb(a,0,0);q[20555]=28;break a}if((b|0)!=10){break e}d=c+ -48|0;if(d>>>0<=9){b=0;while(1){b=w(b,10)+d|0;c=q[a+4>>2];m:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break m}c=Kb(a)}d=c+ -48|0;if(b>>>0<429496729?d>>>0<=9:0){continue}break}e=b}if(d>>>0>9){break f}h=Pc(e,0,10,0);g=V;b=d;while(1){f=g;c=b+h|0;if(c>>>0>>0){f=f+1|0}e=c;g=(f|0)==429496729&c>>>0>=2576980378|f>>>0>429496729;b=q[a+4>>2];n:{if(b>>>0>2]){q[a+4>>2]=b+1;c=r[b|0];break n}c=Kb(a)}d=c+ -48|0;if(g|d>>>0>9){break f}h=Pc(e,f,10,0);g=V;b=d;if((g|0)==-1&h>>>0<=(b^-1)>>>0|g>>>0<4294967295){continue}break}b=10;break d}q[20555]=28;j=0;k=0;break a}b=10;if(d>>>0<=9){break d}break c}if(b+ -1&b){d=r[c+6737|0];if(b>>>0>d>>>0){while(1){g=w(b,g)+d|0;i=g>>>0<=119304646;e=b;c=q[a+4>>2];o:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break o}c=Kb(a)}d=r[c+6737|0];if(e>>>0>d>>>0?i:0){continue}break}e=g}if(b>>>0<=d>>>0){break d}g=b;while(1){i=Pc(e,f,g,0);h=V;d=d&255;if((h|0)==-1&i>>>0>(d^-1)>>>0|h>>>0>4294967295){break d}f=h;c=d+i|0;if(c>>>0>>0){f=f+1|0}e=c;i=b;c=q[a+4>>2];p:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break p}c=Kb(a)}d=r[c+6737|0];if(i>>>0<=d>>>0){break d}bc(l,g,0,e,f);if(!(q[l+8>>2]|q[l+12>>2])){continue}break}break d}p=o[(w(b,23)>>>5&7)+6993|0];i=p;d=i;h=d&31;if(32<=(d&63)>>>0){d=0;m=-1>>>h|0}else{d=-1>>>h|0;m=(1<>>h}u=m;h=d;s=d;d=r[c+6737|0];if(b>>>0>d>>>0){while(1){g=g<>>0<=134217727;e=b;c=q[a+4>>2];q:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break q}c=Kb(a)}d=r[c+6737|0];if(e>>>0>d>>>0?v:0){continue}break}e=g}if(!s&u>>>0>>0|s>>>0<0|b>>>0<=d>>>0){break d}while(1){g=d&255;d=e;c=i;e=c&31;if(32<=(c&63)>>>0){f=d<>>32-e|f<>2];r:{if(c>>>0>2]){q[a+4>>2]=c+1;c=r[c|0];break r}c=Kb(a)}if((f|0)==(h|0)&e>>>0>m>>>0|f>>>0>h>>>0){break d}d=r[c+6737|0];if(b>>>0>d>>>0){continue}break}}if(b>>>0<=r[c+6737|0]){break c}while(1){c=b;f=q[a+4>>2];s:{if(f>>>0>2]){q[a+4>>2]=f+1;d=r[f|0];break s}d=Kb(a)}if(c>>>0>r[d+6737|0]){continue}break}q[20555]=68;n=0;e=-1;f=-1}if(q[a+104>>2]){q[a+4>>2]=q[a+4>>2]+ -1}if(!((f|0)==-1&e>>>0<4294967295|f>>>0<4294967295|((f|0)==-1&e>>>0<=4294967295|f>>>0<4294967295))){q[20555]=68;break a}a=n;b=a^e;j=b-a|0;c=a>>31;k=(c^f)-(c+(b>>>0>>0)|0)|0;break a}j=0;k=0;Jb(a,0,0)}T=l+16|0;V=k;return j}function lc(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0;a:{if(!a){break a}d=a+ -8|0;c=q[a+ -4>>2];a=c&-8;f=d+a|0;b:{if(c&1){break b}if(!(c&3)){break a}c=q[d>>2];d=d-c|0;if(d>>>0>>0<=255){e=q[d+8>>2];c=c>>>3|0;b=q[d+12>>2];if((b|0)==(e|0)){q[20572]=q[20572]&Rc(c);break b}q[e+12>>2]=b;q[b+8>>2]=e;break b}h=q[d+24>>2];c=q[d+12>>2];c:{if((c|0)!=(d|0)){b=q[d+8>>2];q[b+12>>2]=c;q[c+8>>2]=b;break c}d:{e=d+20|0;b=q[e>>2];if(b){break d}e=d+16|0;b=q[e>>2];if(b){break d}c=0;break c}while(1){g=e;c=b;e=c+20|0;b=q[e>>2];if(b){continue}e=c+16|0;b=q[c+16>>2];if(b){continue}break}q[g>>2]=0}if(!h){break b}e=q[d+28>>2];b=(e<<2)+82592|0;e:{if(q[b>>2]==(d|0)){q[b>>2]=c;if(c){break e}q[20573]=q[20573]&Rc(e);break b}q[h+(q[h+16>>2]==(d|0)?16:20)>>2]=c;if(!c){break b}}q[c+24>>2]=h;b=q[d+16>>2];if(b){q[c+16>>2]=b;q[b+24>>2]=c}b=q[d+20>>2];if(!b){break b}q[c+20>>2]=b;q[b+24>>2]=c;break b}c=q[f+4>>2];if((c&3)!=3){break b}q[20574]=a;q[f+4>>2]=c&-2;q[d+4>>2]=a|1;q[a+d>>2]=a;return}if(f>>>0<=d>>>0){break a}c=q[f+4>>2];if(!(c&1)){break a}f:{if(!(c&2)){if((f|0)==q[20578]){q[20578]=d;a=q[20575]+a|0;q[20575]=a;q[d+4>>2]=a|1;if(q[20577]!=(d|0)){break a}q[20574]=0;q[20577]=0;return}if((f|0)==q[20577]){q[20577]=d;a=q[20574]+a|0;q[20574]=a;q[d+4>>2]=a|1;q[a+d>>2]=a;return}a=(c&-8)+a|0;g:{if(c>>>0<=255){b=q[f+8>>2];c=c>>>3|0;e=q[f+12>>2];if((b|0)==(e|0)){q[20572]=q[20572]&Rc(c);break g}q[b+12>>2]=e;q[e+8>>2]=b;break g}h=q[f+24>>2];c=q[f+12>>2];h:{if((f|0)!=(c|0)){b=q[f+8>>2];q[b+12>>2]=c;q[c+8>>2]=b;break h}i:{e=f+20|0;b=q[e>>2];if(b){break i}e=f+16|0;b=q[e>>2];if(b){break i}c=0;break h}while(1){g=e;c=b;e=c+20|0;b=q[e>>2];if(b){continue}e=c+16|0;b=q[c+16>>2];if(b){continue}break}q[g>>2]=0}if(!h){break g}e=q[f+28>>2];b=(e<<2)+82592|0;j:{if((f|0)==q[b>>2]){q[b>>2]=c;if(c){break j}q[20573]=q[20573]&Rc(e);break g}q[h+((f|0)==q[h+16>>2]?16:20)>>2]=c;if(!c){break g}}q[c+24>>2]=h;b=q[f+16>>2];if(b){q[c+16>>2]=b;q[b+24>>2]=c}b=q[f+20>>2];if(!b){break g}q[c+20>>2]=b;q[b+24>>2]=c}q[d+4>>2]=a|1;q[a+d>>2]=a;if(q[20577]!=(d|0)){break f}q[20574]=a;return}q[f+4>>2]=c&-2;q[d+4>>2]=a|1;q[a+d>>2]=a}if(a>>>0<=255){a=a>>>3|0;c=(a<<3)+82328|0;b=q[20572];a=1<>2]}q[c+8>>2]=d;q[a+12>>2]=d;q[d+12>>2]=c;q[d+8>>2]=a;return}q[d+16>>2]=0;q[d+20>>2]=0;f=d;e=a>>>8|0;b=0;l:{if(!e){break l}b=31;if(a>>>0>16777215){break l}c=e;e=e+1048320>>>16&8;b=c<>>16&4;b=b<>>16&2;b=(b<>>15|0)-(g|(e|h))|0;b=(b<<1|a>>>b+21&1)+28|0}q[f+28>>2]=b;g=(b<<2)+82592|0;m:{n:{e=q[20573];c=1<>2]=d;q[d+24>>2]=g;break o}e=a<<((b|0)==31?0:25-(b>>>1|0)|0);c=q[g>>2];while(1){b=c;if((q[c+4>>2]&-8)==(a|0)){break n}c=e>>>29|0;e=e<<1;g=(b+(c&4)|0)+16|0;c=q[g>>2];if(c){continue}break}q[g>>2]=d;q[d+24>>2]=b}q[d+12>>2]=d;q[d+8>>2]=d;break m}a=q[b+8>>2];q[a+12>>2]=d;q[b+8>>2]=d;q[d+24>>2]=0;q[d+12>>2]=b;q[d+8>>2]=a}a=q[20580]+ -1|0;q[20580]=a;if(a){break a}d=82744;while(1){a=q[d>>2];d=a+8|0;if(a){continue}break}q[20580]=-1}}function oc(a,b){var c=0,d=0,e=0,f=0,g=0,h=0;f=a+b|0;a:{b:{c=q[a+4>>2];if(c&1){break b}if(!(c&3)){break a}c=q[a>>2];b=c+b|0;a=a-c|0;if((a|0)!=q[20577]){if(c>>>0<=255){e=c>>>3|0;c=q[a+8>>2];d=q[a+12>>2];if((d|0)==(c|0)){q[20572]=q[20572]&Rc(e);break b}q[c+12>>2]=d;q[d+8>>2]=c;break b}h=q[a+24>>2];c=q[a+12>>2];c:{if((c|0)!=(a|0)){d=q[a+8>>2];q[d+12>>2]=c;q[c+8>>2]=d;break c}d:{d=a+20|0;e=q[d>>2];if(e){break d}d=a+16|0;e=q[d>>2];if(e){break d}c=0;break c}while(1){g=d;c=e;d=c+20|0;e=q[d>>2];if(e){continue}d=c+16|0;e=q[c+16>>2];if(e){continue}break}q[g>>2]=0}if(!h){break b}d=q[a+28>>2];e=(d<<2)+82592|0;e:{if(q[e>>2]==(a|0)){q[e>>2]=c;if(c){break e}q[20573]=q[20573]&Rc(d);break b}q[h+(q[h+16>>2]==(a|0)?16:20)>>2]=c;if(!c){break b}}q[c+24>>2]=h;d=q[a+16>>2];if(d){q[c+16>>2]=d;q[d+24>>2]=c}d=q[a+20>>2];if(!d){break b}q[c+20>>2]=d;q[d+24>>2]=c;break b}c=q[f+4>>2];if((c&3)!=3){break b}q[20574]=b;q[f+4>>2]=c&-2;q[a+4>>2]=b|1;q[f>>2]=b;return}c=q[f+4>>2];f:{if(!(c&2)){if((f|0)==q[20578]){q[20578]=a;b=q[20575]+b|0;q[20575]=b;q[a+4>>2]=b|1;if(q[20577]!=(a|0)){break a}q[20574]=0;q[20577]=0;return}if((f|0)==q[20577]){q[20577]=a;b=q[20574]+b|0;q[20574]=b;q[a+4>>2]=b|1;q[a+b>>2]=b;return}b=(c&-8)+b|0;g:{if(c>>>0<=255){e=c>>>3|0;c=q[f+8>>2];d=q[f+12>>2];if((c|0)==(d|0)){q[20572]=q[20572]&Rc(e);break g}q[c+12>>2]=d;q[d+8>>2]=c;break g}h=q[f+24>>2];c=q[f+12>>2];h:{if((f|0)!=(c|0)){d=q[f+8>>2];q[d+12>>2]=c;q[c+8>>2]=d;break h}i:{d=f+20|0;e=q[d>>2];if(e){break i}d=f+16|0;e=q[d>>2];if(e){break i}c=0;break h}while(1){g=d;c=e;d=c+20|0;e=q[d>>2];if(e){continue}d=c+16|0;e=q[c+16>>2];if(e){continue}break}q[g>>2]=0}if(!h){break g}d=q[f+28>>2];e=(d<<2)+82592|0;j:{if((f|0)==q[e>>2]){q[e>>2]=c;if(c){break j}q[20573]=q[20573]&Rc(d);break g}q[h+((f|0)==q[h+16>>2]?16:20)>>2]=c;if(!c){break g}}q[c+24>>2]=h;d=q[f+16>>2];if(d){q[c+16>>2]=d;q[d+24>>2]=c}d=q[f+20>>2];if(!d){break g}q[c+20>>2]=d;q[d+24>>2]=c}q[a+4>>2]=b|1;q[a+b>>2]=b;if(q[20577]!=(a|0)){break f}q[20574]=b;return}q[f+4>>2]=c&-2;q[a+4>>2]=b|1;q[a+b>>2]=b}if(b>>>0<=255){c=b>>>3|0;b=(c<<3)+82328|0;d=q[20572];c=1<>2]}q[b+8>>2]=a;q[c+12>>2]=a;q[a+12>>2]=b;q[a+8>>2]=c;return}q[a+16>>2]=0;q[a+20>>2]=0;d=a;e=b>>>8|0;c=0;l:{if(!e){break l}c=31;if(b>>>0>16777215){break l}g=e+1048320>>>16&8;e=e<>>16&4;f=e<>>16&2;c=(f<>>15|0)-(e|(c|g))|0;c=(c<<1|b>>>c+21&1)+28|0}q[d+28>>2]=c;e=(c<<2)+82592|0;m:{d=q[20573];g=1<>2]=a;break n}d=b<<((c|0)==31?0:25-(c>>>1|0)|0);c=q[e>>2];while(1){e=c;if((q[c+4>>2]&-8)==(b|0)){break m}c=d>>>29|0;d=d<<1;g=(e+(c&4)|0)+16|0;c=q[g>>2];if(c){continue}break}q[g>>2]=a}q[a+24>>2]=e;q[a+12>>2]=a;q[a+8>>2]=a;return}b=q[e+8>>2];q[b+12>>2]=a;q[e+8>>2]=a;q[a+24>>2]=0;q[a+12>>2]=e;q[a+8>>2]=b}}function hc(a,b){var c=0,d=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;j=T-48|0;T=j;h(+a);d=e(1)|0;m=e(0)|0;a:{b:{i=d;d=i;k=i&2147483647;c:{if(k>>>0<=1074752122){if((d&1048575)==598523){break c}if(k>>>0<=1073928572){if((i|0)>0?1:(i|0)>=0?m>>>0<0?0:1:0){a=a+ -1.5707963267341256;c=a+ -6.077100506506192e-11;v[b>>3]=c;v[b+8>>3]=a-c+ -6.077100506506192e-11;d=1;break a}a=a+1.5707963267341256;c=a+6.077100506506192e-11;v[b>>3]=c;v[b+8>>3]=a-c+6.077100506506192e-11;d=-1;break a}if((i|0)>0?1:(i|0)>=0?m>>>0<0?0:1:0){a=a+ -3.1415926534682512;c=a+ -1.2154201013012384e-10;v[b>>3]=c;v[b+8>>3]=a-c+ -1.2154201013012384e-10;d=2;break a}a=a+3.1415926534682512;c=a+1.2154201013012384e-10;v[b>>3]=c;v[b+8>>3]=a-c+1.2154201013012384e-10;d=-2;break a}if(k>>>0<=1075594811){if(k>>>0<=1075183036){if((k|0)==1074977148){break c}if((i|0)>0?1:(i|0)>=0?m>>>0<0?0:1:0){a=a+ -4.712388980202377;c=a+ -1.8231301519518578e-10;v[b>>3]=c;v[b+8>>3]=a-c+ -1.8231301519518578e-10;d=3;break a}a=a+4.712388980202377;c=a+1.8231301519518578e-10;v[b>>3]=c;v[b+8>>3]=a-c+1.8231301519518578e-10;d=-3;break a}if((k|0)==1075388923){break c}if((i|0)>0?1:(i|0)>=0?m>>>0<0?0:1:0){a=a+ -6.2831853069365025;c=a+ -2.430840202602477e-10;v[b>>3]=c;v[b+8>>3]=a-c+ -2.430840202602477e-10;d=4;break a}a=a+6.2831853069365025;c=a+2.430840202602477e-10;v[b>>3]=c;v[b+8>>3]=a-c+2.430840202602477e-10;d=-4;break a}if(k>>>0>1094263290){break b}}n=a*.6366197723675814+6755399441055744+ -6755399441055744;c=a+n*-1.5707963267341256;l=n*6.077100506506192e-11;a=c-l;v[b>>3]=a;h(+a);d=e(1)|0;e(0)|0;i=k>>>20|0;m=(i-(d>>>20&2047)|0)<17;if(y(n)<2147483648){d=~~n}else{d=-2147483648}d:{if(m){break d}l=c;a=n*6.077100506303966e-11;c=c-a;l=n*2.0222662487959506e-21-(l-c-a);a=c-l;v[b>>3]=a;o=i;h(+a);i=e(1)|0;e(0)|0;if((o-(i>>>20&2047)|0)<50){break d}l=c;a=n*2.0222662487111665e-21;c=c-a;l=n*8.4784276603689e-32-(l-c-a);a=c-l;v[b>>3]=a}v[b+8>>3]=c-a-l;break a}if(k>>>0>=2146435072){a=a-a;v[b>>3]=a;v[b+8>>3]=a;d=0;break a}f(0,m|0);f(1,i&1048575|1096810496);a=+g();d=0;o=1;while(1){p=(j+16|0)+(d<<3)|0;if(y(a)<2147483648){d=~~a}else{d=-2147483648}c=+(d|0);v[p>>3]=c;a=(a-c)*16777216;d=1;p=o&1;o=0;if(p){continue}break}v[j+32>>3]=a;e:{if(a!=0){d=2;break e}o=1;while(1){d=o;o=d+ -1|0;if(v[(j+16|0)+(d<<3)>>3]==0){continue}break}}d=gc(j+16|0,j,(k>>>20|0)+ -1046|0,d+1|0);a=v[j>>3];if((i|0)<-1?1:(i|0)<=-1?m>>>0>4294967295?0:1:0){v[b>>3]=-a;v[b+8>>3]=-v[j+8>>3];d=0-d|0;break a}v[b>>3]=a;i=q[j+12>>2];q[b+8>>2]=q[j+8>>2];q[b+12>>2]=i}T=j+48|0;return d}function qc(a,b,c,d,e,f,g,h,i){var j=0,k=0,l=0,m=0,n=0,o=0,p=0,r=0,s=0,t=0,u=0,v=0,w=0;j=T-128|0;T=j;a:{b:{c:{if(!Ub(f,g,h,i,0,0,0,0)){break c}l=sc(f,g,h,i);u=e>>>16|0;o=u&32767;if((o|0)==32767){break c}if(l){break b}}ac(j+16|0,b,c,d,e,f,g,h,i);e=q[j+16>>2];d=q[j+20>>2];c=q[j+24>>2];b=q[j+28>>2];Wb(j,e,d,c,b,e,d,c,b);d=q[j+8>>2];e=q[j+12>>2];h=q[j>>2];i=q[j+4>>2];break a}k=e&65535|o<<16;n=k;m=d;p=h;t=i>>>16&32767;l=i&65535|t<<16;if((Ub(b,c,m,k,f,g,h,l)|0)<=0){if(Ub(b,c,m,n,f,g,p,l)){h=b;i=c;break a}ac(j+112|0,b,c,d,e,0,0,0,0);d=q[j+120>>2];e=q[j+124>>2];h=q[j+112>>2];i=q[j+116>>2];break a}if(o){i=c;h=b}else{ac(j+96|0,b,c,m,n,0,0,0,1081540608);h=q[j+108>>2];n=h;m=q[j+104>>2];o=(h>>>16|0)+ -120|0;i=q[j+100>>2];h=q[j+96>>2]}if(!t){ac(j+80|0,f,g,p,l,0,0,0,1081540608);f=q[j+92>>2];l=f;p=q[j+88>>2];t=(l>>>16|0)+ -120|0;g=q[j+84>>2];f=q[j+80>>2]}w=p;k=p;p=m-k|0;n=n&65535|65536;v=l&65535|65536;l=(g|0)==(i|0)&h>>>0>>0|i>>>0>>0;k=(n-(v+(m>>>0>>0)|0)|0)-(p>>>0>>0)|0;r=p-l|0;s=(k|0)>-1?1:(k|0)>=-1?r>>>0<=4294967295?0:1:0;p=h-f|0;l=i-((h>>>0>>0)+g|0)|0;if((o|0)>(t|0)){while(1){d:{if(s&1){if(!(p|r|(k|l))){ac(j+32|0,b,c,d,e,0,0,0,0);d=q[j+40>>2];e=q[j+44>>2];h=q[j+32>>2];i=q[j+36>>2];break a}h=r;s=k<<1|h>>>31;r=h<<1;k=s;s=0;h=l>>>31|0;break d}k=0;l=i;r=i>>>31|0;p=h;h=m;s=n<<1|h>>>31;h=h<<1}m=h|r;i=m;h=w;r=i-h|0;n=k|s;k=n-((i>>>0>>0)+v|0)|0;h=p;s=l<<1|h>>>31;h=h<<1;i=s;l=(g|0)==(i|0)&h>>>0>>0|i>>>0>>0;k=k-(r>>>0>>0)|0;r=r-l|0;s=(k|0)>-1?1:(k|0)>=-1?r>>>0<=4294967295?0:1:0;p=h-f|0;l=i-((h>>>0>>0)+g|0)|0;o=o+ -1|0;if((o|0)>(t|0)){continue}break}o=t}e:{if(!s){break e}h=p;m=r;i=l;n=k;if(h|m|(i|k)){break e}ac(j+48|0,b,c,d,e,0,0,0,0);d=q[j+56>>2];e=q[j+60>>2];h=q[j+48>>2];i=q[j+52>>2];break a}if((n|0)==65535&m>>>0<=4294967295|n>>>0<65535){while(1){d=i>>>31|0;b=0;o=o+ -1|0;k=i<<1|h>>>31;h=h<<1;i=k;s=n<<1|m>>>31;m=m<<1|d;b=b|s;n=b;if((b|0)==65536&m>>>0<0|b>>>0<65536){continue}break}}b=u&32768;if((o|0)<=0){ac(j- -64|0,h,i,m,n&65535|(b|o+120)<<16,0,0,0,1065811968);d=q[j+72>>2];e=q[j+76>>2];h=q[j+64>>2];i=q[j+68>>2];break a}d=m;e=n&65535|(b|o)<<16}q[a>>2]=h;q[a+4>>2]=i;q[a+8>>2]=d;q[a+12>>2]=e;T=j+128|0}function Nb(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;e=T-48|0;T=e;a:{if(c>>>0<=2){f=b+4|0;c=c<<2;j=q[c+7084>>2];k=q[c+7072>>2];while(1){c=q[b+4>>2];b:{if(c>>>0>2]){q[f>>2]=c+1;c=r[c|0];break b}c=Kb(b)}if(fb(c)){continue}break}g=1;c:{d:{switch(c+ -43|0){case 0:case 2:break d;default:break c}}g=(c|0)==45?-1:1;c=q[b+4>>2];if(c>>>0>2]){q[f>>2]=c+1;c=r[c|0];break c}c=Kb(b)}e:{f:{while(1){if(o[d+7002|0]==(c|32)){g:{if(d>>>0>6){break g}c=q[b+4>>2];if(c>>>0>2]){q[f>>2]=c+1;c=r[c|0];break g}c=Kb(b)}d=d+1|0;if((d|0)!=8){continue}break f}break}if((d|0)!=3){if((d|0)==8){break f}break e}if(q[b+104>>2]){q[f>>2]=q[f>>2]+ -1}}Yb(e,x(x(g|0)*x(H)));d=q[e+8>>2];g=q[e+12>>2];h=q[e>>2];i=q[e+4>>2];break a}h:{i:{j:{if(d){break j}d=0;while(1){if(o[d+7011|0]!=(c|32)){break j}k:{if(d>>>0>1){break k}c=q[b+4>>2];if(c>>>0>2]){q[f>>2]=c+1;c=r[c|0];break k}c=Kb(b)}d=d+1|0;if((d|0)!=3){continue}break}break i}l:{switch(d|0){case 0:m:{if((c|0)!=48){break m}d=q[b+4>>2];n:{if(d>>>0>2]){q[f>>2]=d+1;d=r[d|0];break n}d=Kb(b)}if((d&-33)==88){Ob(e+16|0,b,k,j,g);d=q[e+24>>2];g=q[e+28>>2];h=q[e+16>>2];i=q[e+20>>2];break a}if(!q[b+104>>2]){break m}q[f>>2]=q[f>>2]+ -1}Pb(e+32|0,b,c,k,j,g);d=q[e+40>>2];g=q[e+44>>2];h=q[e+32>>2];i=q[e+36>>2];break a;case 3:break i;default:break l}}break h}o:{c=q[b+4>>2];p:{if(c>>>0>2]){q[f>>2]=c+1;c=r[c|0];break p}c=Kb(b)}if((c|0)==40){d=1;break o}d=0;g=2147450880;if(!q[b+104>>2]){break a}q[f>>2]=q[f>>2]+ -1;break a}while(1){q:{c=q[b+4>>2];r:{if(c>>>0>2]){q[f>>2]=c+1;c=r[c|0];break r}c=Kb(b)}if(!(c+ -48>>>0<10|c+ -65>>>0<26|(c|0)==95)){if(c+ -97>>>0>=26){break q}}d=d+1|0;continue}break}d=0;g=2147450880;if((c|0)==41){break a}}if(q[b+104>>2]){q[f>>2]=q[f>>2]+ -1}q[20555]=28;Jb(b,0,0)}d=0;g=0}q[a>>2]=h;q[a+4>>2]=i;q[a+8>>2]=d;q[a+12>>2]=g;T=e+48|0}function nc(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;g=q[a+4>>2];c=g&3;d=g&-8;f=d+a|0;a:{if(!c){c=0;if(b>>>0<256){break a}if(d>>>0>=b+4>>>0){c=a;if(d-b>>>0<=q[20692]<<1>>>0){break a}}return 0}b:{if(d>>>0>=b>>>0){c=d-b|0;if(c>>>0<16){break b}q[a+4>>2]=g&1|b|2;b=a+b|0;q[b+4>>2]=c|3;q[f+4>>2]=q[f+4>>2]|1;oc(b,c);break b}c=0;if((f|0)==q[20578]){d=d+q[20575]|0;if(d>>>0<=b>>>0){break a}q[a+4>>2]=g&1|b|2;c=a+b|0;b=d-b|0;q[c+4>>2]=b|1;q[20575]=b;q[20578]=c;break b}if((f|0)==q[20577]){d=d+q[20574]|0;if(d>>>0>>0){break a}c=d-b|0;c:{if(c>>>0>=16){q[a+4>>2]=g&1|b|2;b=a+b|0;q[b+4>>2]=c|1;d=a+d|0;q[d>>2]=c;q[d+4>>2]=q[d+4>>2]&-2;break c}q[a+4>>2]=d|g&1|2;b=a+d|0;q[b+4>>2]=q[b+4>>2]|1;c=0;b=0}q[20577]=b;q[20574]=c;break b}e=q[f+4>>2];if(e&2){break a}h=d+(e&-8)|0;if(h>>>0>>0){break a}j=h-b|0;d:{if(e>>>0<=255){c=q[f+8>>2];e=e>>>3|0;d=q[f+12>>2];if((c|0)==(d|0)){q[20572]=q[20572]&Rc(e);break d}q[c+12>>2]=d;q[d+8>>2]=c;break d}i=q[f+24>>2];d=q[f+12>>2];e:{if((f|0)!=(d|0)){c=q[f+8>>2];q[c+12>>2]=d;q[d+8>>2]=c;break e}f:{c=f+20|0;e=q[c>>2];if(e){break f}c=f+16|0;e=q[c>>2];if(e){break f}d=0;break e}while(1){k=c;d=e;c=d+20|0;e=q[c>>2];if(e){continue}c=d+16|0;e=q[d+16>>2];if(e){continue}break}q[k>>2]=0}if(!i){break d}c=q[f+28>>2];e=(c<<2)+82592|0;g:{if((f|0)==q[e>>2]){q[e>>2]=d;if(d){break g}q[20573]=q[20573]&Rc(c);break d}q[((f|0)==q[i+16>>2]?16:20)+i>>2]=d;if(!d){break d}}q[d+24>>2]=i;c=q[f+16>>2];if(c){q[d+16>>2]=c;q[c+24>>2]=d}c=q[f+20>>2];if(!c){break d}q[d+20>>2]=c;q[c+24>>2]=d}if(j>>>0<=15){q[a+4>>2]=g&1|h|2;b=a+h|0;q[b+4>>2]=q[b+4>>2]|1;break b}q[a+4>>2]=g&1|b|2;b=a+b|0;q[b+4>>2]=j|3;c=a+h|0;q[c+4>>2]=q[c+4>>2]|1;oc(b,j)}c=a}return c}function dc(a,b,c,d){var e=0,h=0,i=0,j=0,k=0,l=0,m=0;i=T-32|0;T=i;e=d&2147483647;k=e;e=e+ -1006698496|0;j=c;h=c;if(c>>>0<0){e=e+1|0}l=h;h=e;e=k+ -1140785152|0;m=j;if(j>>>0<0){e=e+1|0}a:{if((e|0)==(h|0)&l>>>0>>0|h>>>0>>0){e=d<<4|c>>>28;c=c<<4|b>>>28;b=b&268435455;j=b;if((b|0)==134217728&a>>>0>=1|b>>>0>134217728){e=e+1073741824|0;a=c+1|0;if(a>>>0<1){e=e+1|0}h=a;break a}h=c;e=e-((c>>>0<0)+ -1073741824|0)|0;if(a|j^134217728){break a}a=h+(h&1)|0;if(a>>>0>>0){e=e+1|0}h=a;break a}if(!(!j&(k|0)==2147418112?!(a|b):(k|0)==2147418112&j>>>0<0|k>>>0<2147418112)){e=d<<4|c>>>28;h=c<<4|b>>>28;e=e&524287|2146959360;break a}h=0;e=2146435072;if((k|0)==1140785151&j>>>0>4294967295|k>>>0>1140785151){break a}e=0;j=k>>>16|0;if(j>>>0<15249){break a}e=d&65535|65536;Tb(i+16|0,a,b,c,e,j+ -15233|0);$b(i,a,b,c,e,15361-j|0);c=q[i+4>>2];a=q[i+8>>2];e=q[i+12>>2]<<4|a>>>28;h=a<<4|c>>>28;a=c&268435455;c=a;b=q[i>>2]|((q[i+16>>2]|q[i+24>>2])!=0|(q[i+20>>2]|q[i+28>>2])!=0);if((a|0)==134217728&b>>>0>=1|a>>>0>134217728){a=h+1|0;if(a>>>0<1){e=e+1|0}h=a;break a}if(b|c^134217728){break a}a=h+(h&1)|0;if(a>>>0>>0){e=e+1|0}h=a}T=i+32|0;f(0,h|0);f(1,d&-2147483648|e);return+g()}function Qb(a){var b=0,c=0,d=0,e=0,f=0;a:{b:{c:{d:{b=q[a+4>>2];e:{if(b>>>0>2]){q[a+4>>2]=b+1;b=r[b|0];break e}b=Kb(a)}switch(b+ -43|0){case 0:case 2:break c;default:break d}}e=b+ -48|0;break b}f=(b|0)==45;b=q[a+4>>2];f:{if(b>>>0>2]){q[a+4>>2]=b+1;b=r[b|0];break f}b=Kb(a)}e=b+ -48|0}if(e>>>0<10){while(1){d=w(c,10)+b|0;b=q[a+4>>2];g:{if(b>>>0>2]){q[a+4>>2]=b+1;b=r[b|0];break g}b=Kb(a)}e=b+ -48|0;c=d+ -48|0;if((c|0)<214748364?e>>>0<=9:0){continue}break}d=c;c=c>>31;h:{if(e>>>0>=10){break h}while(1){c=Pc(d,c,10,0);d=c+b|0;b=V;b=d>>>0>>0?b+1|0:b;d=d+ -48|0;c=b+ -1|0;c=d>>>0<4294967248?c+1|0:c;b=q[a+4>>2];i:{if(b>>>0>2]){q[a+4>>2]=b+1;b=r[b|0];break i}b=Kb(a)}e=b+ -48|0;if(e>>>0>9){break h}if((c|0)<21474836?1:(c|0)<=21474836?d>>>0>=2061584302?0:1:0){continue}break}}if(e>>>0<10){while(1){b=q[a+4>>2];j:{if(b>>>0>2]){q[a+4>>2]=b+1;b=r[b|0];break j}b=Kb(a)}if(b+ -48>>>0<10){continue}break}}if(q[a+104>>2]){q[a+4>>2]=q[a+4>>2]+ -1}a=d;d=f?0-a|0:a;c=f?0-(c+(0>>0)|0)|0:c;break a}c=-2147483648;if(!q[a+104>>2]){break a}q[a+4>>2]=q[a+4>>2]+ -1;V=-2147483648;return 0}V=c;return d}function tc(a,b,c){var d=0,e=0;if(c>>>0>=512){Q(a|0,b|0,c|0)|0;return}d=a+c|0;a:{if(!((a^b)&3)){b:{if((c|0)<1){c=a;break b}if(!(a&3)){c=a;break b}c=a;while(1){o[c|0]=r[b|0];b=b+1|0;c=c+1|0;if(c>>>0>=d>>>0){break b}if(c&3){continue}break}}a=d&-4;c:{if(a>>>0<64){break c}e=a+ -64|0;if(c>>>0>e>>>0){break c}while(1){q[c>>2]=q[b>>2];q[c+4>>2]=q[b+4>>2];q[c+8>>2]=q[b+8>>2];q[c+12>>2]=q[b+12>>2];q[c+16>>2]=q[b+16>>2];q[c+20>>2]=q[b+20>>2];q[c+24>>2]=q[b+24>>2];q[c+28>>2]=q[b+28>>2];q[c+32>>2]=q[b+32>>2];q[c+36>>2]=q[b+36>>2];q[c+40>>2]=q[b+40>>2];q[c+44>>2]=q[b+44>>2];q[c+48>>2]=q[b+48>>2];q[c+52>>2]=q[b+52>>2];q[c+56>>2]=q[b+56>>2];q[c+60>>2]=q[b+60>>2];b=b- -64|0;c=c- -64|0;if(c>>>0<=e>>>0){continue}break}}if(c>>>0>=a>>>0){break a}while(1){q[c>>2]=q[b>>2];b=b+4|0;c=c+4|0;if(c>>>0>>0){continue}break}break a}if(d>>>0<4){c=a;break a}e=d+ -4|0;if(e>>>0>>0){c=a;break a}c=a;while(1){o[c|0]=r[b|0];o[c+1|0]=r[b+1|0];o[c+2|0]=r[b+2|0];o[c+3|0]=r[b+3|0];b=b+4|0;c=c+4|0;if(c>>>0<=e>>>0){continue}break}}if(c>>>0>>0){while(1){o[c|0]=r[b|0];b=b+1|0;c=c+1|0;if((d|0)!=(c|0)){continue}break}}}function ec(a,b,c,d){var e=0,g=0,h=0,i=0,j=0,l=0,m=0;i=T-32|0;T=i;g=d&2147483647;h=g;e=g+ -1065418752|0;g=c;j=g;if(g>>>0<0){e=e+1|0}m=j;l=h+ -1082064896|0;j=g;if(g>>>0<0){l=l+1|0}a:{if((e|0)==(l|0)&m>>>0>>0|e>>>0>>0){h=(d&33554431)<<7|c>>>25;g=0;l=g;j=c&33554431;if(!(!g&(j|0)==16777216?!(a|b):!g&j>>>0<16777216|g>>>0<0)){e=h+1073741825|0;break a}e=h+1073741824|0;if(j^16777216|a|(b|l)){break a}e=(e&1)+e|0;break a}if(!(!g&(h|0)==2147418112?!(a|b):(h|0)==2147418112&g>>>0<0|h>>>0<2147418112)){e=((d&33554431)<<7|c>>>25)&4194303|2143289344;break a}e=2139095040;if((h|0)==1082064895&g>>>0>4294967295|h>>>0>1082064895){break a}e=0;h=h>>>16|0;if(h>>>0<16145){break a}e=d&65535|65536;Tb(i+16|0,a,b,c,e,h+ -16129|0);$b(i,a,b,g,e,16257-h|0);b=q[i+8>>2];e=(q[i+12>>2]&33554431)<<7|b>>>25;g=q[i+4>>2];h=g;a=0;j=a;l=q[i>>2]|((q[i+16>>2]|q[i+24>>2])!=0|(q[i+20>>2]|q[i+28>>2])!=0);b=b&33554431;if(!(!a&(b|0)==16777216?!(g|l):!a&b>>>0<16777216|a>>>0<0)){e=e+1|0;break a}if(b^16777216|l|(h|j)){break a}e=(e&1)+e|0}T=i+32|0;return f(0,d&-2147483648|e),k()}function Oc(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;a:{b:{c:{d:{e:{f:{g:{h:{i:{e=b;if(e){d=c;if(!d){break i}break h}b=a;a=(a>>>0)/(c>>>0)|0;Mc(b-w(a,c)|0,0);V=0;return a}if(!a){break g}break f}g=d+ -1|0;if(!(g&d)){break e}g=(z(d)+33|0)-z(e)|0;h=0-g|0;break c}a=(e>>>0)/0|0;Mc(0,e-w(a,0)|0);V=0;return a}d=32-z(e)|0;if(d>>>0<31){break d}break b}Mc(a&g,0);if((d|0)==1){break a}if(d){d=31-z(d+ -1^d)|0}else{d=32}c=d&31;if(32<=(d&63)>>>0){e=0;a=b>>>c|0}else{e=b>>>c|0;a=((1<>>c}V=e;return a}g=d+1|0;h=63-d|0}d=b;e=g&63;f=e&31;if(32<=e>>>0){e=0;f=d>>>f|0}else{e=d>>>f|0;f=((1<>>f}h=h&63;d=h&31;if(32<=h>>>0){b=a<>>32-d|b<>>0<4294967295){d=0}while(1){i=f<<1|b>>>31;j=i;e=e<<1|f>>>31;i=d-(e+(h>>>0>>0)|0)>>31;k=c&i;f=j-k|0;e=e-(j>>>0>>0)|0;b=b<<1|a>>>31;a=l|a<<1;i=i&1;l=i;g=g+ -1|0;if(g){continue}break}}Mc(f,e);V=b<<1|a>>>31;return i|a<<1}Mc(a,b);a=0;b=0}V=b;return a}function Wa(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;d=T-32|0;T=d;e=q[a+28>>2];q[d+16>>2]=e;f=q[a+20>>2];q[d+28>>2]=c;q[d+24>>2]=b;b=f-e|0;q[d+20>>2]=b;e=b+c|0;j=2;b=d+16|0;a:{b:{c:{if(!Rb(M(q[a+60>>2],d+16|0,2,d+12|0)|0)){while(1){f=q[d+12>>2];if((f|0)==(e|0)){break c}if((f|0)<=-1){break b}g=q[b+4>>2];h=f>>>0>g>>>0;i=(h<<3)+b|0;g=f-(h?g:0)|0;q[i>>2]=g+q[i>>2];i=(h?12:4)+b|0;q[i>>2]=q[i>>2]-g;e=e-f|0;b=h?b+8|0:b;j=j-h|0;if(!Rb(M(q[a+60>>2],b|0,j|0,d+12|0)|0)){continue}break}}q[d+12>>2]=-1;if((e|0)!=-1){break b}}b=q[a+44>>2];q[a+28>>2]=b;q[a+20>>2]=b;q[a+16>>2]=b+q[a+48>>2];a=c;break a}q[a+28>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;q[a>>2]=q[a>>2]|32;a=0;if((j|0)==2){break a}a=c-q[b+4>>2]|0}T=d+32|0;return a|0}function uc(a,b,c){var d=0,e=0,f=0,g=0;a:{if(!c){break a}d=a+c|0;o[d+ -1|0]=b;o[a|0]=b;if(c>>>0<3){break a}o[d+ -2|0]=b;o[a+1|0]=b;o[d+ -3|0]=b;o[a+2|0]=b;if(c>>>0<7){break a}o[d+ -4|0]=b;o[a+3|0]=b;if(c>>>0<9){break a}d=0-a&3;e=d+a|0;b=w(b&255,16843009);q[e>>2]=b;c=c-d&-4;d=c+e|0;q[d+ -4>>2]=b;if(c>>>0<9){break a}q[e+8>>2]=b;q[e+4>>2]=b;q[d+ -8>>2]=b;q[d+ -12>>2]=b;if(c>>>0<25){break a}q[e+24>>2]=b;q[e+20>>2]=b;q[e+16>>2]=b;q[e+12>>2]=b;q[d+ -16>>2]=b;q[d+ -20>>2]=b;q[d+ -24>>2]=b;q[d+ -28>>2]=b;g=e&4|24;c=c-g|0;if(c>>>0<32){break a}d=b;f=b;b=e+g|0;while(1){q[b+24>>2]=f;q[b+28>>2]=d;q[b+16>>2]=f;q[b+20>>2]=d;q[b+8>>2]=f;q[b+12>>2]=d;q[b>>2]=f;q[b+4>>2]=d;b=b+32|0;c=c+ -32|0;if(c>>>0>31){continue}break}}return a}function Mb(a,b,c,d,e,f){var g=0;g=T-80|0;T=g;a:{if((f|0)>=16384){ac(g+32|0,b,c,d,e,0,0,0,2147352576);d=q[g+40>>2];e=q[g+44>>2];b=q[g+32>>2];c=q[g+36>>2];if((f|0)<32767){f=f+ -16383|0;break a}ac(g+16|0,b,c,d,e,0,0,0,2147352576);f=((f|0)<49149?f:49149)+ -32766|0;d=q[g+24>>2];e=q[g+28>>2];b=q[g+16>>2];c=q[g+20>>2];break a}if((f|0)>-16383){break a}ac(g- -64|0,b,c,d,e,0,0,0,65536);d=q[g+72>>2];e=q[g+76>>2];b=q[g+64>>2];c=q[g+68>>2];if((f|0)>-32765){f=f+16382|0;break a}ac(g+48|0,b,c,d,e,0,0,0,65536);f=((f|0)>-49146?f:-49146)+32764|0;d=q[g+56>>2];e=q[g+60>>2];b=q[g+48>>2];c=q[g+52>>2]}ac(g,b,c,d,e,0,0,0,f+16383<<16);b=q[g+12>>2];q[a+8>>2]=q[g+8>>2];q[a+12>>2]=b;b=q[g+4>>2];q[a>>2]=q[g>>2];q[a+4>>2]=b;T=g+80|0}function Kb(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0;c=q[a+116>>2];d=c;a:{f=q[a+112>>2];b:{if(c|f){c=q[a+124>>2];if((c|0)>(d|0)?1:(c|0)>=(d|0)?t[a+120>>2]>>0?0:1:0){break b}}f=Ib(a);if((f|0)>-1){break a}}q[a+104>>2]=0;return-1}c=q[a+8>>2];d=q[a+116>>2];e=d;c:{d:{b=q[a+112>>2];if(!(d|b)){break d}d=(q[a+124>>2]^-1)+e|0;e=q[a+120>>2]^-1;b=e+b|0;if(b>>>0>>0){d=d+1|0}e=b;b=q[a+4>>2];g=c-b|0;h=e>>>0>>0?0:1;g=g>>31;if((d|0)>(g|0)?1:(d|0)>=(g|0)?h:0){break d}q[a+104>>2]=e+b;break c}q[a+104>>2]=c}e:{if(!c){c=q[a+4>>2];break e}d=a;b=c;c=q[a+4>>2];b=(b-c|0)+1|0;e=b+q[a+120>>2]|0;a=q[a+124>>2]+(b>>31)|0;q[d+120>>2]=e;q[d+124>>2]=e>>>0>>0?a+1|0:a}a=c+ -1|0;if(r[a|0]!=(f|0)){o[a|0]=f}return f}function Ub(a,b,c,d,e,f,g,h){var i=0,j=0,k=0,l=0,m=0,n=0;j=1;i=d&2147483647;m=i;k=c;a:{if(!c&(i|0)==2147418112?a|b:(i|0)==2147418112&c>>>0>0|i>>>0>2147418112){break a}l=h&2147483647;n=l;i=g;if(!g&(l|0)==2147418112?e|f:(l|0)==2147418112&g>>>0>0|l>>>0>2147418112){break a}if(!(a|e|(i|k)|(b|f|(m|n)))){return 0}k=d&h;if((k|0)>0?1:(k|0)>=0?(c&g)>>>0<0?0:1:0){j=-1;if((c|0)==(g|0)&(d|0)==(h|0)?(b|0)==(f|0)&a>>>0>>0|b>>>0>>0:(d|0)<(h|0)?1:(d|0)<=(h|0)?c>>>0>=g>>>0?0:1:0){break a}return(a^e|c^g)!=0|(b^f|d^h)!=0}j=-1;if((c|0)==(g|0)&(d|0)==(h|0)?(b|0)==(f|0)&a>>>0>e>>>0|b>>>0>f>>>0:(d|0)>(h|0)?1:(d|0)>=(h|0)?c>>>0<=g>>>0?0:1:0){break a}j=(a^e|c^g)!=0|(b^f|d^h)!=0}return j}function Oa(a,b,c,d){a:{b:{if(b>>>0>20){break b}c:{switch(b+ -9|0){case 0:b=q[c>>2];q[c>>2]=b+4;q[a>>2]=q[b>>2];return;case 1:b=q[c>>2];q[c>>2]=b+4;b=q[b>>2];q[a>>2]=b;q[a+4>>2]=b>>31;return;case 2:b=q[c>>2];q[c>>2]=b+4;q[a>>2]=q[b>>2];q[a+4>>2]=0;return;case 4:b=q[c>>2];q[c>>2]=b+4;b=p[b>>1];q[a>>2]=b;q[a+4>>2]=b>>31;return;case 5:b=q[c>>2];q[c>>2]=b+4;q[a>>2]=s[b>>1];q[a+4>>2]=0;return;case 6:b=q[c>>2];q[c>>2]=b+4;b=o[b|0];q[a>>2]=b;q[a+4>>2]=b>>31;return;case 7:b=q[c>>2];q[c>>2]=b+4;q[a>>2]=r[b|0];q[a+4>>2]=0;return;case 3:case 8:break a;case 9:break c;default:break b}}n[d](a,c)}return}b=q[c>>2]+7&-8;q[c>>2]=b+8;c=q[b+4>>2];q[a>>2]=q[b>>2];q[a+4>>2]=c}function Xb(a,b){var c=0,d=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0;g=T-16|0;T=g;h(+b);j=e(1)|0;i=e(0)|0;f=j&2147483647;c=f;f=c+ -1048576|0;d=i;l=d;if(d>>>0<0){f=f+1|0}a:{if((f|0)==2145386495&l>>>0<=4294967295|f>>>0<2145386495){k=d<<28;f=(c&15)<<28|d>>>4;c=(c>>>4|0)+1006632960|0;d=f;c=d>>>0<0?c+1|0:c;break a}if((c|0)==2146435072&d>>>0>=0|c>>>0>2146435072){k=i<<28;f=i;c=j;i=c>>>4|0;d=(c&15)<<28|f>>>4;c=i|2147418112;break a}if(!(c|d)){d=0;c=0;break a}f=c;c=(c|0)==1&d>>>0<0|c>>>0<1?z(i)+32|0:z(c);Tb(g,d,f,0,0,c+49|0);m=q[g>>2];k=q[g+4>>2];d=q[g+8>>2];c=q[g+12>>2]^65536|15372-c<<16}q[a>>2]=m;q[a+4>>2]=k;q[a+8>>2]=d;q[a+12>>2]=j&-2147483648|c;T=g+16|0}function pa(a,b,c,d){var e=0,f=0,g=0,h=0,i=0;c=c<.1?.98:c/10;a:{if(d){if((b|0)<1){break a}g=6.283185307/+(b|0);d=0;while(1){h=a+d|0;e=C((c*jc(g*+(d|0))+1)*128);b:{if(e<4294967296&e>=0){f=~~e>>>0;break b}f=0}o[h|0]=f;d=d+1|0;if((d|0)!=(b|0)){continue}break}break a}e=+x(b|0);g=D(e*.5);e=C(e)*.5;c:{if(y(e)<2147483648){d=~~e;break c}d=-2147483648}e=g- +(d|0);d:{if(y(e)<2147483648){f=~~e;break d}f=-2147483648}e:{if((d|0)<1){d=0;break e}h=a;e=C(c*252);f:{if(e<4294967296&e>=0){i=~~e>>>0;break f}i=0}uc(h,i,d)}if(f){o[a+d|0]=128;d=d+1|0}if((d|0)>=(b|0)){break a}b=b-d|0;a=a+d|0;c=C(c*6);if(c<4294967296&c>=0){uc(a,~~c>>>0,b);return}uc(a,0,b)}}function gb(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0;g=T-16|0;T=g;e=c?c:80132;c=q[e>>2];a:{b:{c:{if(!b){if(c){break c}break a}d=-2;h=a?a:g+12|0;d:{if(c){a=1;break d}a=r[b|0];c=a<<24>>24;if((c|0)>=0){q[h>>2]=a;d=(c|0)!=0;break a}a=o[b|0];if(!q[q[2913]>>2]){q[h>>2]=a&57343;d=1;break a}a=(a&255)+ -194|0;if(a>>>0>50){break c}c=q[(a<<2)+6512>>2];break b}f=r[b|0];i=f>>>3|0;if((i+ -16|(c>>26)+i)>>>0>7){break c}while(1){a=a+ -1|0;c=f+ -128|c<<6;if((c|0)>=0){q[e>>2]=0;q[h>>2]=c;d=1-a|0;break a}if(!a){break b}b=b+1|0;f=r[b|0];if((f&192)==128){continue}break}}q[e>>2]=0;q[20555]=25;d=-1;break a}q[e>>2]=c}T=g+16|0;return d}function Ka(a,b,c,d,e){var f=0,g=0,h=0;f=T-208|0;T=f;q[f+204>>2]=c;c=0;uc(f+160|0,0,40);q[f+200>>2]=q[f+204>>2];a:{if((La(0,b,f+200|0,f+80|0,f+160|0,d,e)|0)<0){break a}c=q[a+76>>2]>=0?1:c;g=q[a>>2];if(o[a+74|0]<=0){q[a>>2]=g&-33}h=g&32;b:{if(q[a+48>>2]){La(a,b,f+200|0,f+80|0,f+160|0,d,e);break b}q[a+48>>2]=80;q[a+16>>2]=f+80;q[a+28>>2]=f;q[a+20>>2]=f;g=q[a+44>>2];q[a+44>>2]=f;La(a,b,f+200|0,f+80|0,f+160|0,d,e);if(!g){break b}n[q[a+36>>2]](a,0,0)|0;q[a+48>>2]=0;q[a+44>>2]=g;q[a+28>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0}q[a>>2]=h|q[a>>2];if(!c){break a}}T=f+208|0}function Xa(a,b){var c=0,d=0;d=T-32|0;T=d;a:{b:{c:{if(!Bb(6485,o[b|0])){q[20555]=28;break c}c=kc(1176);if(c){break b}}a=0;break a}uc(c,0,144);if(!Bb(b,43)){q[c>>2]=r[b|0]==114?8:4}d:{if(r[b|0]!=97){b=q[c>>2];break d}b=K(a|0,3,0)|0;if(!(b&1024)){q[d+16>>2]=b|1024;K(a|0,4,d+16|0)|0}b=q[c>>2]|128;q[c>>2]=b}o[c+75|0]=255;q[c+48>>2]=1024;q[c+60>>2]=a;q[c+44>>2]=c+152;e:{if(b&8){break e}q[d>>2]=d+24;if(L(a|0,21523,d|0)){break e}o[c+75|0]=10}q[c+40>>2]=4;q[c+36>>2]=5;q[c+32>>2]=6;q[c+12>>2]=7;if(!q[20557]){q[c+76>>2]=-1}a=db(c)}T=d+32|0;return a}function Vb(a,b,c,d){var e=0,f=0,g=0,h=0;g=-1;e=d&2147483647;h=e;f=c;a:{if(!c&(e|0)==2147418112?a|b:(e|0)==2147418112&c>>>0>0|e>>>0>2147418112){break a}if(!(a|f|(h|1073610752|b))){return 0}f=d&1073610752;if((f|0)>0?1:(f|0)>=0?1:0){if(!c&(d|0)==1073610752?!b&a>>>0<0|b>>>0<0:(d|0)<1073610752?1:(d|0)<=1073610752?c>>>0>=0?0:1:0){break a}return(a|c)!=0|(d^1073610752|b)!=0}if(!c&(d|0)==1073610752?!b&a>>>0>0|b>>>0>0:(d|0)>1073610752?1:(d|0)>=1073610752?c>>>0<=0?0:1:0){break a}g=(a|c)!=0|(d^1073610752|b)!=0}return g}function $b(a,b,c,d,e,f){var g=0,h=0,i=0,j=0;a:{if(f&64){c=f+ -64|0;b=c&31;if(32<=(c&63)>>>0){c=0;b=e>>>b|0}else{c=e>>>b|0;b=((1<>>b}d=0;e=0;break a}if(!f){break a}h=e;i=d;j=64-f|0;g=j&31;if(32<=(j&63)>>>0){h=i<>>32-g|h<>>0){g=0;b=c>>>b|0}else{g=c>>>b|0;b=((1<>>b}b=j|b;c=g|h;g=d;d=f&31;if(32<=(f&63)>>>0){h=0;d=e>>>d|0}else{h=e>>>d|0;d=((1<>>d}e=h}q[a>>2]=b;q[a+4>>2]=c;q[a+8>>2]=d;q[a+12>>2]=e}function Tb(a,b,c,d,e,f){var g=0,h=0,i=0,j=0;a:{if(f&64){d=b;e=f+ -64|0;b=e&31;if(32<=(e&63)>>>0){e=d<>>32-b|c<>>0){h=g<>>32-d|e<>>0){f=0;d=d>>>e|0}else{f=d>>>e|0;d=((1<>>e}d=j|d;e=f|h;f=b;b=i&31;if(32<=(i&63)>>>0){h=f<>>32-b|c<>2]=b;q[a+4>>2]=c;q[a+8>>2]=d;q[a+12>>2]=e}function xb(a,b){var c=0,d=0,e=0;e=T-32|0;c=e;q[c+24>>2]=0;q[c+28>>2]=0;q[c+16>>2]=0;q[c+20>>2]=0;q[c+8>>2]=0;q[c+12>>2]=0;q[c>>2]=0;q[c+4>>2]=0;d=r[b|0];if(!d){return 0}if(!r[b+1|0]){b=a;while(1){c=b;b=c+1|0;if(r[c|0]==(d|0)){continue}break}return c-a|0}while(1){c=(d>>>3&28)+e|0;q[c>>2]=q[c>>2]|1<<(d&31);d=r[b+1|0];b=b+1|0;if(d){continue}break}c=a;d=r[c|0];a:{if(!d){break a}b=a;while(1){if(!(q[(d>>>3&28)+e>>2]>>>(d&31)&1)){c=b;break a}d=r[b+1|0];c=b+1|0;b=c;if(d){continue}break}}return c-a|0}function sb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;d=T-32|0;T=d;q[d+16>>2]=b;e=q[a+48>>2];q[d+20>>2]=c-((e|0)!=0);f=q[a+44>>2];q[d+28>>2]=e;q[d+24>>2]=f;a:{b:{c:{if(Rb(O(q[a+60>>2],d+16|0,2,d+12|0)|0)){q[d+12>>2]=-1;c=-1;break c}e=q[d+12>>2];if((e|0)>0){break b}c=e}q[a>>2]=q[a>>2]|c&48^16;break a}g=q[d+20>>2];if(e>>>0<=g>>>0){c=e;break a}f=q[a+44>>2];q[a+4>>2]=f;q[a+8>>2]=f+(e-g|0);if(!q[a+48>>2]){break a}q[a+4>>2]=f+1;o[(b+c|0)+ -1|0]=r[f|0]}T=d+32|0;return c|0}function Yb(a,b){var c=0,d=0,f=0,g=0,h=0,i=0,k=0;f=T-16|0;T=f;g=(j(b),e(0));c=g&2147483647;a:{if(c+ -8388608>>>0<=2130706431){d=c;c=c>>>7|0;d=d<<25;c=c+1065353216|0;h=d;c=d>>>0<0?c+1|0:c;break a}if(c>>>0>=2139095040){c=g;d=c>>>7|0;h=c<<25;c=d|2147418112;break a}if(!c){c=0;break a}d=c;c=z(c);Tb(f,d,0,0,0,c+81|0);i=q[f>>2];k=q[f+4>>2];h=q[f+8>>2];c=q[f+12>>2]^65536|16265-c<<16}q[a>>2]=i;q[a+4>>2]=k;q[a+8>>2]=h;q[a+12>>2]=g&-2147483648|c;T=f+16|0}function Ab(a,b){var c=0,d=0;a:{d=b&255;if(d){if(a&3){while(1){c=r[a|0];if(!c|(c|0)==(b&255)){break a}a=a+1|0;if(a&3){continue}break}}c=q[a>>2];b:{if((c^-1)&c+ -16843009&-2139062144){break b}d=w(d,16843009);while(1){c=c^d;if((c^-1)&c+ -16843009&-2139062144){break b}c=q[a+4>>2];a=a+4|0;if(!(c+ -16843009&(c^-1)&-2139062144)){continue}break}}while(1){c=a;d=r[c|0];if(d){a=c+1|0;if((d|0)!=(b&255)){continue}}break}return c}return Cc(a)+a|0}return a}function Ha(a,b){a:{if(a){if(b>>>0<=127){break a}b:{if(!q[q[2913]>>2]){if((b&-128)==57216){break a}break b}if(b>>>0<=2047){o[a+1|0]=b&63|128;o[a|0]=b>>>6|192;return 2}if(!((b&-8192)!=57344?b>>>0>=55296:0)){o[a+2|0]=b&63|128;o[a|0]=b>>>12|224;o[a+1|0]=b>>>6&63|128;return 3}if(b+ -65536>>>0<=1048575){o[a+3|0]=b&63|128;o[a|0]=b>>>18|240;o[a+2|0]=b>>>6&63|128;o[a+1|0]=b>>>12&63|128;return 4}}q[20555]=25;a=-1}else{a=1}return a}o[a|0]=b;return 1}function vb(a,b){var c=0;c=(b|0)!=0;a:{b:{c:{if(!b|!(a&3)){break c}while(1){if(!r[a|0]){break b}a=a+1|0;b=b+ -1|0;c=(b|0)!=0;if(!b){break c}if(a&3){continue}break}}if(!c){break a}}d:{if(!r[a|0]|b>>>0<4){break d}while(1){c=q[a>>2];if((c^-1)&c+ -16843009&-2139062144){break d}a=a+4|0;b=b+ -4|0;if(b>>>0>3){continue}break}}if(!b){break a}while(1){if(!r[a|0]){return a}a=a+1|0;b=b+ -1|0;if(b){continue}break}}return 0}function Eb(a,b){var c=0;a:{b:{if((a^b)&3){break b}if(b&3){while(1){c=r[b|0];o[a|0]=c;if(!c){break a}a=a+1|0;b=b+1|0;if(b&3){continue}break}}c=q[b>>2];if((c^-1)&c+ -16843009&-2139062144){break b}while(1){q[a>>2]=c;c=q[b+4>>2];a=a+4|0;b=b+4|0;if(!(c+ -16843009&(c^-1)&-2139062144)){continue}break}}c=r[b|0];o[a|0]=c;if(!c){break a}while(1){c=r[b+1|0];o[a+1|0]=c;a=a+1|0;b=b+1|0;if(c){continue}break}}}function jc(a){var b=0,c=0;b=T-16|0;T=b;h(+a);c=e(1)|0;e(0)|0;c=c&2147483647;a:{if(c>>>0<=1072243195){if(c>>>0<1045430272){break a}a=fc(a,0,0);break a}if(c>>>0>=2146435072){a=a-a;break a}b:{switch(hc(a,b)&3){case 0:a=fc(v[b>>3],v[b+8>>3],1);break a;case 1:a=ic(v[b>>3],v[b+8>>3]);break a;case 2:a=-fc(v[b>>3],v[b+8>>3],1);break a;default:break b}}a=-ic(v[b>>3],v[b+8>>3])}T=b+16|0;return a}function xc(a,b,c){var d=0,e=0,f=0,g=0;d=q[c+16>>2];a:{if(!d){if(vc(c)){break a}d=q[c+16>>2]}f=q[c+20>>2];if(d-f>>>0>>0){return n[q[c+36>>2]](c,a,b)|0}b:{if(o[c+75|0]<0){break b}e=b;while(1){d=e;if(!d){break b}e=d+ -1|0;if(r[e+a|0]!=10){continue}break}e=n[q[c+36>>2]](c,a,d)|0;if(e>>>0>>0){break a}b=b-d|0;a=a+d|0;f=q[c+20>>2];g=d}tc(f,a,b);q[c+20>>2]=q[c+20>>2]+b;e=b+g|0}return e}function yb(a,b){var c=0,d=0,e=0;e=T-32|0;T=e;c=o[b|0];a:{if(!(r[b+1|0]?c:0)){c=Ab(a,c);break a}uc(e,0,32);d=r[b|0];if(d){while(1){c=(d>>>3&28)+e|0;q[c>>2]=q[c>>2]|1<<(d&31);d=r[b+1|0];b=b+1|0;if(d){continue}break}}c=a;d=r[c|0];if(!d){break a}b=a;while(1){if(q[(d>>>3&28)+e>>2]>>>(d&31)&1){c=b;break a}d=r[b+1|0];c=b+1|0;b=c;if(d){continue}break}}T=e+32|0;return c-a|0}function bc(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;j=e;e=0;k=e;h=c;c=0;g=Pc(j,e,h,c);e=V;l=g;g=g>>>0<0?e+1|0:e;f=d;e=0;i=b;d=Pc(f,e,b,0);b=V;f=Pc(f,e,h,c);c=b+f|0;b=V;b=c>>>0>>0?b+1|0:b;h=b;f=b+l|0;b=g;b=f>>>0>>0?b+1|0:b;g=b;b=Pc(i,m,j,k)+c|0;e=V;e=b>>>0>>0?e+1|0:e;i=e;f=e+f|0;e=g;q[a+8>>2]=f;q[a+12>>2]=f>>>0>>0?e+1|0:e;q[a>>2]=d;q[a+4>>2]=b}function Ca(a,b,c,d){var e=0,f=0;if((d|0)==1){f=b;e=q[a+8>>2]-q[a+4>>2]|0;b=b-e|0;c=c-((e>>31)+(f>>>0>>0)|0)|0}a:{if(t[a+20>>2]>t[a+28>>2]){n[q[a+36>>2]](a,0,0)|0;if(!q[a+20>>2]){break a}}q[a+28>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;c=n[q[a+40>>2]](a,b,c,d)>>>0>=0?0:1;b=V;if((b|0)<0?1:(b|0)<=0?c:0){break a}q[a+4>>2]=0;q[a+8>>2]=0;q[a>>2]=q[a>>2]&-17}}function ia(a,b,c){var d=0;d=T-16|0;T=d;q[d+12>>2]=a;q[d+8>>2]=b;q[d+4>>2]=c;if((q[q[d+12>>2]+4>>2]+q[d+4>>2]|0)>q[q[d+12>>2]+8>>2]){a=q[d+12>>2];q[a+8>>2]=q[a+8>>2]+262144;a=mc(q[q[d+12>>2]>>2],q[q[d+12>>2]+8>>2]);q[q[d+12>>2]>>2]=a}tc(q[q[d+12>>2]>>2]+q[q[d+12>>2]+4>>2]|0,q[d+8>>2],q[d+4>>2]);a=q[d+12>>2];q[a+4>>2]=q[d+4>>2]+q[a+4>>2];T=d+16|0}function rc(a,b){a:{if((b|0)>=1024){a=a*8.98846567431158e+307;if((b|0)<2047){b=b+ -1023|0;break a}a=a*8.98846567431158e+307;b=((b|0)<3069?b:3069)+ -2046|0;break a}if((b|0)>-1023){break a}a=a*2.2250738585072014e-308;if((b|0)>-2045){b=b+1022|0;break a}a=a*2.2250738585072014e-308;b=((b|0)>-3066?b:-3066)+2044|0}f(0,0);f(1,b+1023<<20);return a*+g()}function ub(a,b,c){var d=0,e=0,f=0,g=0;e=r[c+74|0];o[c+74|0]=e+ -1|e;e=b;d=q[c+4>>2];f=q[c+8>>2]-d|0;g=e;a:{if((f|0)<1){break a}g=d;d=f>>>0>>0?f:e;tc(a,g,d);q[c+4>>2]=d+q[c+4>>2];a=a+d|0;g=e-d|0}d=g;if(d){while(1){b:{if(!tb(c)){f=n[q[c+32>>2]](c,a,d)|0;if(f+1>>>0>1){break b}}return e-d|0}a=a+f|0;d=d-f|0;if(d){continue}break}}return b}function Cc(a){var b=0,c=0,d=0;a:{b:{b=a;if(!(b&3)){break b}if(!r[a|0]){return 0}while(1){b=b+1|0;if(!(b&3)){break b}if(r[b|0]){continue}break}break a}while(1){c=b;b=b+4|0;d=q[c>>2];if(!((d^-1)&d+ -16843009&-2139062144)){continue}break}if(!(d&255)){return c-a|0}while(1){d=r[c+1|0];b=c+1|0;c=b;if(d){continue}break}}return b-a|0}function fa(a,b,c){var d=0;d=T-16|0;T=d;q[d+12>>2]=a;q[d+8>>2]=b;q[d+4>>2]=c;a:{if(!q[d+12>>2]){q[d+12>>2]=kc(260);Fb(q[d+12>>2],q[d+8>>2]);q[q[d+12>>2]+256>>2]=0;a=q[d+4>>2];q[a>>2]=q[a>>2]+1;break a}if(wb(q[d+12>>2],q[d+8>>2])){a=fa(q[q[d+12>>2]+256>>2],q[d+8>>2],q[d+4>>2]);q[q[d+12>>2]+256>>2]=a}}T=d+16|0;return q[d+12>>2]}function Ra(a,b,c){var d=0,e=0,f=0;a:{if((b|0)==1&a>>>0<0|b>>>0<1){d=a;break a}while(1){d=Qc(a,b,10);e=V;f=e;e=Pc(d,e,10,0);c=c+ -1|0;o[c|0]=a-e|48;e=(b|0)==9&a>>>0>4294967295|b>>>0>9;a=d;b=f;if(e){continue}break}}if(d){while(1){c=c+ -1|0;a=(d>>>0)/10|0;o[c|0]=d-w(a,10)|48;b=d>>>0>9;d=a;if(b){continue}break}}return c}function Zb(a,b){var c=0,d=0,e=0,f=0,g=0,h=0;d=T-16|0;T=d;g=a;h=a;a:{if(!b){b=0;break a}c=b>>31;e=c+b^c;c=z(e);Tb(d,e,0,0,0,c+81|0);c=(q[d+12>>2]^65536)+(16414-c<<16)|0;e=0+q[d+8>>2]|0;if(e>>>0>>0){c=c+1|0}f=b&-2147483648|c;c=q[d+4>>2];b=q[d>>2]}q[h>>2]=b;q[g+4>>2]=c;q[a+8>>2]=e;q[a+12>>2]=f;T=d+16|0}function ya(a){var b=0,c=0,d=0,e=0,f=0;b=q[a+40>>2];c=n[b](a,0,0,r[a|0]&128?t[a+20>>2]>t[a+28>>2]?2:1:1)|0;b=V;d=b;if((b|0)>0?1:(b|0)>=0?c>>>0<0?0:1:0){e=q[a+20>>2]-q[a+28>>2]|0;a=q[a+8>>2]-q[a+4>>2]|0;f=c-a|0;b=e+f|0;a=(d-((a>>31)+(c>>>0>>0)|0)|0)+(e>>31)|0;c=b;d=b>>>0>>0?a+1|0:a}V=d;return c}function _b(a,b){var c=0,d=0,e=0,f=0,g=0,h=0;c=T-16|0;T=c;g=a;h=a;a:{if(!b){b=0;e=0;break a}d=b;b=z(b)^31;Tb(c,d,0,0,0,112-b|0);b=(q[c+12>>2]^65536)+(b+16383<<16)|0;d=0+q[c+8>>2]|0;if(d>>>0>>0){b=b+1|0}f=d;d=b;b=q[c+4>>2];e=q[c>>2]}q[h>>2]=e;q[g+4>>2]=b;q[a+8>>2]=f;q[a+12>>2]=d;T=c+16|0}function cb(a,b){var c=0;if(q[b+76>>2]<0){a:{if(o[b+75|0]==(a&255)){break a}c=q[b+20>>2];if(c>>>0>=t[b+16>>2]){break a}q[b+20>>2]=c+1;o[c|0]=a;return}wc(b,a);return}b:{c:{if(o[b+75|0]==(a&255)){break c}c=q[b+20>>2];if(c>>>0>=t[b+16>>2]){break c}q[b+20>>2]=c+1;o[c|0]=a;break b}wc(b,a)}}function fc(a,b,c){var d=0,e=0,f=0;d=a*a;f=d*(d*d)*(d*1.58969099521155e-10+ -2.5050760253406863e-8)+(d*(d*27557313707070068e-22+ -.0001984126982985795)+.00833333333332249);e=d*a;if(!c){return e*(d*f+ -.16666666666666632)+a}return a-(d*(b*.5-e*f)-b+e*.16666666666666632)}function eb(a){var b=0,c=0,d=0,e=0;d=q[a+76>>2]>=0?1:d;e=q[a>>2]&1;if(!e){b=q[a+52>>2];if(b){q[b+56>>2]=q[a+56>>2]}c=q[a+56>>2];if(c){q[c+52>>2]=b}if(q[20030]==(a|0)){q[20030]=c}}_a(a);n[q[a+12>>2]](a)|0;b=q[a+96>>2];if(b){lc(b)}a:{if(!e){lc(a);break a}if(!d){break a}}}function na(a,b){var c=0,d=0,e=0,f=0;e=T-256|0;T=e;if(r[b|0]){d=r[b|0];tc(e,a,d>>>0>1?d:1)}c=r[b|0];if(c){d=0;while(1){c=d<<2;o[c+a|0]=0;f=r[d+e|0]^-128;o[(c|1)+a|0]=f;o[(c|2)+a|0]=0;o[(c|3)+a|0]=f;d=d+1|0;c=r[b|0];if(d>>>0>>0){continue}break}}o[b|0]=c<<2;T=e+256|0}function $a(a){var b=0,c=0;a:{if(t[a+20>>2]<=t[a+28>>2]){break a}n[q[a+36>>2]](a,0,0)|0;if(q[a+20>>2]){break a}return-1}b=q[a+4>>2];c=q[a+8>>2];if(b>>>0>>0){b=b-c|0;n[q[a+40>>2]](a,b,b>>31,1)|0}q[a+28>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0;return 0}function wa(a,b){var c=x(0);rb(91);c=x(x(x(a|0)/x(b+ -1|0))*x(32));a:{if(x(y(c))>>20&2047;if((c|0)!=2047){if(!c){c=b;if(a==0){b=0}else{a=Ja(a*0x10000000000000000,b);b=q[b>>2]+ -64|0}q[c>>2]=b;return a}q[b>>2]=c+ -1022;f(0,d|0);f(1,i&-2146435073|1071644672);a=+g()}return a}function tb(a){var b=0,c=0;b=r[a+74|0];o[a+74|0]=b+ -1|b;if(t[a+20>>2]>t[a+28>>2]){n[q[a+36>>2]](a,0,0)|0}q[a+28>>2]=0;q[a+16>>2]=0;q[a+20>>2]=0;b=q[a>>2];if(b&4){q[a>>2]=b|32;return-1}c=q[a+44>>2]+q[a+48>>2]|0;q[a+8>>2]=c;q[a+4>>2]=c;return b<<27>>31}function wc(a,b){var c=0,d=0,e=0;c=T-16|0;T=c;o[c+15|0]=b;d=q[a+16>>2];a:{if(!d){if(vc(a)){break a}d=q[a+16>>2]}e=q[a+20>>2];if(!(o[a+75|0]==(b&255)|e>>>0>=d>>>0)){q[a+20>>2]=e+1;o[e|0]=b;break a}if((n[q[a+36>>2]](a,c+15|0,1)|0)!=1){break a}}T=c+16|0}function Ya(a,b){var c=0,d=0,e=0;c=T-16|0;T=c;a:{b:{if(!Bb(6489,o[b|0])){q[20555]=28;break b}e=ab(b);q[c>>2]=438;a=J(a|0,e|32768,c|0)|0;if(a>>>0>=4294963201){q[20555]=0-a;a=-1}if((a|0)<0){break a}d=Xa(a,b);if(d){break a}N(a|0)|0}d=0}T=c+16|0;return d}function mc(a,b){var c=0,d=0;if(!a){return kc(b)}if(b>>>0>=4294967232){q[20555]=48;return 0}c=nc(a+ -8|0,b>>>0<11?16:b+11&-8);if(c){return c+8|0}c=kc(b);if(!c){return 0}d=q[a+ -4>>2];d=(d&3?-4:-8)+(d&-8)|0;tc(c,a,d>>>0>>0?d:b);lc(a);return c}function ic(a,b){var c=0,d=0,e=0,f=0;c=a*a;d=c*.5;e=1-d;f=1-e-d;d=c*c;return e+(f+(c*(c*(c*(c*2480158728947673e-20+ -.001388888888887411)+.0416666666666666)+d*d*(c*(c*-1.1359647557788195e-11+2.087572321298175e-9)+ -2.7557314351390663e-7))-a*b))}function Aa(a,b){var c=0,d=0;c=T-160|0;T=c;tc(c+8|0,5792,144);q[c+52>>2]=a;q[c+28>>2]=a;d=-2-a|0;d=260>d>>>0?d:260;q[c+56>>2]=d;a=a+d|0;q[c+36>>2]=a;q[c+24>>2]=a;Ka(c+8|0,3270,b,2,3);if(d){a=q[c+28>>2];o[a-((a|0)==q[c+24>>2])|0]=0}T=c+160|0}function ka(a,b,c){var d=0,e=0,f=0,g=0;d=T-16|0;T=d;a:{if(!b){break a}while(1){if(!ub(a+e|0,b-e|0,c)){f=e;break a}f=b+e|0;g=f>>>0>>0;e=f;if(g){continue}break}}if((b|0)!=(f|0)){q[d+4>>2]=b;q[d>>2]=f;bb(q[1624],2255,d);I(2);F()}T=d+16|0}function Jb(a,b,c){var d=0,e=0,f=0,g=0;q[a+112>>2]=b;q[a+116>>2]=c;f=q[a+8>>2];g=q[a+4>>2];d=f-g|0;e=d>>31;q[a+120>>2]=d;q[a+124>>2]=e;if(!(!(b|c)|((e|0)<(c|0)?1:(e|0)<=(c|0)?d>>>0>b>>>0?0:1:0))){q[a+104>>2]=b+g;return}q[a+104>>2]=f}function la(a,b,c){var d=0;d=T-16|0;T=d;o[d+15|0]=b;a:{if(!(c&-3)){c=0;while(1){b=o[d+15|0]<0;ia(a,b?12160:12432,r[(b?12416:12688)|0]);o[d+15|0]=r[d+15|0]<<1;c=c+1|0;if((c|0)!=8){continue}break}break a}ia(a,d+15|0,1)}T=d+16|0}function Nc(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0;e=c>>>16|0;f=a>>>16|0;j=w(e,f);g=c&65535;h=a&65535;i=w(g,h);f=(i>>>16|0)+w(f,g)|0;e=(f&65535)+w(e,h)|0;a=(w(b,c)+j|0)+w(a,d)+(f>>>16)+(e>>>16)|0;b=i&65535|e<<16;V=a;return b}function Bc(a){var b=0,c=0;b=q[1680];b;c=a;a=Cc(a);a:{if((((yc(c,1,a,b)|0)!=(a|0)?-1:0)|0)<0){break a}b:{if(r[b+75|0]==10){break b}a=q[b+20>>2];if(a>>>0>=t[b+16>>2]){break b}q[b+20>>2]=a+1;o[a|0]=10;break a}wc(b,10)}}function Za(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=T-16|0;T=e;a:{if(!Rb(S(q[a+60>>2],b|0,c|0,d&255,e+8|0)|0)){b=q[e+12>>2];a=q[e+8>>2];break a}q[e+8>>2]=-1;q[e+12>>2]=-1;b=-1;a=-1}T=e+16|0;V=b;return a|0}function oa(a,b){var c=0,d=0;a:{if(!r[9952]){break a}d=9952;while(1){if(!Db(a,d)){q[b>>2]=c;break a}c=c+1|0;d=w(c,5)+9952|0;if(r[d|0]){continue}break}}if(!q[(c<<2)+10144>>2]){yc(2309,25,1,q[1624]);I(1);F()}}function _a(a){var b=0;if(a){if(q[a+76>>2]<=-1){return $a(a)}return $a(a)}if(q[3036]){b=_a(q[3036])}a=q[20030];if(a){while(1){if(t[a+20>>2]>t[a+28>>2]){b=$a(a)|b}a=q[a+56>>2];if(a){continue}break}}return b}function Sa(a,b,c,d,e){var f=0;f=T-256|0;T=f;if(!(e&73728|(c|0)<=(d|0))){c=c-d|0;d=c>>>0<256;uc(f,b,d?c:256);if(!d){while(1){Ma(a,f,256);c=c+ -256|0;if(c>>>0>255){continue}break}}Ma(a,f,c)}T=f+256|0}function zb(a,b){var c=0;a:{if(!a){a=q[20554];if(!a){break a}}c=xb(a,b)+a|0;if(!r[c|0]){q[20554]=0;return 0}a=yb(c,b)+c|0;q[20554]=a;if(r[a|0]){q[20554]=a+1;o[a|0]=0;return c}q[20554]=0}return c}function vc(a){var b=0;b=r[a+74|0];o[a+74|0]=b+ -1|b;b=q[a>>2];if(b&8){q[a>>2]=b|32;return-1}q[a+4>>2]=0;q[a+8>>2]=0;b=q[a+44>>2];q[a+28>>2]=b;q[a+20>>2]=b;q[a+16>>2]=b+q[a+48>>2];return 0}function jb(a,b,c,d){a:{if(!a){break a}b:{switch(b+2|0){case 0:o[a|0]=c;return;case 1:p[a>>1]=c;return;case 2:case 3:q[a>>2]=c;return;case 5:break b;default:break a}}q[a>>2]=c;q[a+4>>2]=d}}function wb(a,b){var c=0,d=0;c=r[a|0];d=r[b|0];a:{if(!c|(c|0)!=(d|0)){break a}while(1){d=r[b+1|0];c=r[a+1|0];if(!c){break a}b=b+1|0;a=a+1|0;if((c|0)==(d|0)){continue}break}}return c-d|0}function cc(a,b,c,d,e,f,g,h,i){var j=0;j=T-16|0;T=j;Sb(j,b,c,d,e,f,g,h,i^-2147483648);b=q[j+4>>2];q[a>>2]=q[j>>2];q[a+4>>2]=b;b=q[j+12>>2];q[a+8>>2]=q[j+8>>2];q[a+12>>2]=b;T=j+16|0}function pc(a){var b=0,c=0;b=q[20696];c=a+3&-4;a=b+c|0;a:{if(a>>>0<=b>>>0?(c|0)>=1:0){break a}if(a>>>0>W()<<16>>>0){if(!P(a|0)){break a}}q[20696]=a;return b}q[20555]=48;return-1}function ab(a){var b=0;b=2;if(!Bb(a,43)){b=r[a|0]!=114}b=Bb(a,120)?b|128:b;b=Bb(a,101)?b|524288:b;a=r[a|0];b=(a|0)==114?b:b|64;b=(a|0)==119?b|512:b;return(a|0)==97?b|1024:b}function ua(a){var b=0,c=0,d=0;b=q[a>>2];if((b|0)!=-1){d=q[3500];while(1){if((b|0)==(d|0)){return c}c=c+1|0;b=q[(c<<2)+a>>2];if((b|0)!=-1){continue}break}}return-1}function kb(a,b,c){var d=0,e=0,f=0;e=q[a+84>>2];d=c+256|0;f=vb(e,d);d=f?f-e|0:d;c=d>>>0>>0?d:c;tc(b,e,c);b=e+d|0;q[a+84>>2]=b;q[a+8>>2]=b;q[a+4>>2]=c+e;return c}function ga(a){var b=0;b=T-16|0;T=b;q[b+12>>2]=a;q[b+8>>2]=q[b+12>>2];if(q[b+12>>2]){q[b+8>>2]=q[q[b+12>>2]+256>>2];lc(q[b+12>>2])}T=b+16|0;return q[b+8>>2]}function Na(a){var b=0,c=0,d=0;if(Ga(o[q[a>>2]])){while(1){b=q[a>>2];d=o[b|0];q[a>>2]=b+1;c=(w(c,10)+d|0)+ -48|0;if(Ga(o[b+1|0])){continue}break}}return c}function yc(a,b,c,d){var e=0,f=0;e=w(b,c);f=e;a:{if(q[d+76>>2]<=-1){a=xc(a,e,d);break a}a=xc(a,e,d)}if((f|0)==(a|0)){return b?c:0}return(a>>>0)/(b>>>0)|0}function ra(a){var b=0,c=0,d=0;b=a<<1;a=8;while(1){b=b>>>1|0;c=0-((b^c)&1)&-1610612735^c>>>1;d=a>>>0>1;a=a+ -1|0;if(d){continue}break}return c}function Ba(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;e=q[a+20>>2];d=q[a+16>>2]-e|0;d=d>>>0>c>>>0?c:d;tc(e,b,d);q[a+20>>2]=d+q[a+20>>2];return c|0}function sc(a,b,c,d){var e=0,f=0;f=d&65535;d=d>>>16&32767;a:{if((d|0)!=32767){e=4;if(d){break a}return a|c|(b|f)?3:2}e=!(a|c|(b|f))}return e}function Ib(a){var b=0,c=0;b=T-16|0;T=b;c=-1;a:{if(tb(a)){break a}if((n[q[a+32>>2]](a,b+15|0,1)|0)!=1){break a}c=r[b+15|0]}T=b+16|0;return c}function lb(a,b,c){var d=0;d=T-144|0;T=d;d=uc(d,0,144);q[d+76>>2]=-1;q[d+44>>2]=a;q[d+32>>2]=8;q[d+84>>2]=a;a=hb(d,b,c);T=d+144|0;return a}function va(){var a=0,b=0;a=T-16|0;T=a;q[a+4>>2]=2937;q[a>>2]=34;zc(2933,a);while(1){rb(8);b=b+1|0;if((b|0)!=34){continue}break}T=a+16|0}function Pa(a,b,c,d){if(a|b){while(1){c=c+ -1|0;o[c|0]=r[(a&15)+6432|0]|d;a=(b&15)<<28|a>>>4;b=b>>>4|0;if(a|b){continue}break}}return c}function Ua(a,b){a=a|0;b=b|0;var c=0;c=b;b=q[b>>2]+15&-16;q[c>>2]=b+16;v[a>>3]=dc(q[b>>2],q[b+4>>2],q[b+8>>2],q[b+12>>2])}function Qa(a,b,c){if(a|b){while(1){c=c+ -1|0;o[c|0]=a&7|48;a=(b&7)<<29|a>>>3;b=b>>>3|0;if(a|b){continue}break}}return c}function Lb(a,b,c,d,e,f,g,h,i){q[a>>2]=b;q[a+4>>2]=c;q[a+8>>2]=d;q[a+12>>2]=e&65535|(i>>>16&32768|e>>>16&32767)<<16}function ib(a,b){var c=0;c=T-16|0;q[c+12>>2]=a;a=((b<<2)-(((b|0)!=0)<<2)|0)+a|0;q[c+8>>2]=a+4;return q[a>>2]}function sa(){var a=0;while(1){q[(a<<2)+12976>>2]=ra(a);a=a+1|0;if((a|0)!=256){continue}break}}function Ic(a,b,c,d,e,f,g){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;f=f|0;g=g|0;return n[a](b,c,d,e,f,g)|0}function ja(a){var b=0;b=T-16|0;T=b;q[b+12>>2]=a;lc(q[q[b+12>>2]>>2]);ha(q[b+12>>2]);T=b+16|0}function db(a){var b=0;q[a+56>>2]=q[20030];b=q[20030];if(b){q[b+52>>2]=a}q[20030]=a;return a}function ha(a){var b=0;b=T-16|0;q[b+12>>2]=a;a=q[b+12>>2];q[a>>2]=0;q[a+4>>2]=0;q[a+8>>2]=0}function Lc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;a=n[a](b,c,d,e)|0;R(V|0);return a|0}function nb(a){var b=0;b=T-16|0;T=b;q[b+12>>2]=a;a=hb(q[1679],2995,a);T=b+16|0;return a}function ma(a){var b=0;b=T-16|0;T=b;Ea(q[3173],a<<8,0);ka(12704,256,q[3173]);T=b+16|0}function Fa(a,b,c){var d=0;d=T-16|0;T=d;q[d+12>>2]=c;a=lb(a,b,c);T=d+16|0;return a}function Ac(a){var b=0;b=T-16|0;T=b;q[b+12>>2]=a;Ka(q[1680],3142,a,2,0);T=b+16|0}function Rc(a){var b=0;b=a&31;a=0-a&31;return(-1>>>b&-2)<>>a} + + + +function zc(a,b){var c=0;c=T-16|0;T=c;q[c+12>>2]=b;Va(q[1680],a,b);T=c+16|0}function ta(a){var b=0;b=q[3500];q[3500]=b>>>8^q[((b&255^a)<<2)+12976>>2]}function bb(a,b,c){var d=0;d=T-16|0;T=d;q[d+12>>2]=c;Va(a,b,c);T=d+16|0}function Da(a,b,c,d){if(q[a+76>>2]<=-1){Ca(a,b,c,d);return}Ca(a,b,c,d)}function za(a,b){var c=0;c=T-16|0;T=c;q[c+12>>2]=b;Aa(a,b);T=c+16|0}function Hc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return n[a](b,c,d)|0}function qb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;V=0;return 0}function mb(a,b,c){a=a|0;b=b|0;c=c|0;return kb(a,b,c)|0}function Bb(a,b){a=Ab(a,b);return r[a|0]==(b&255)?a:0}function Rb(a){if(!a){return 0}q[20555]=a;return-1}function Ia(a,b){if(!a){return 0}return Ha(a,b)}function Ma(a,b,c){if(!(r[a|0]&32)){xc(b,c,a)}}function Jc(a,b,c){a=a|0;b=b|0;c=c|0;n[a](b,c)}function Kc(a,b){a=a|0;b=b|0;return n[a](b)|0}function Fc(a){a=a|0;a=T-a&-16;T=a;return a|0}function ob(a){a=a|0;return N(q[a+60>>2])|0}function Pc(a,b,c,d){a=Nc(a,b,c,d);return a}function fb(a){return(a|0)==32|a+ -9>>>0<5}function Cb(a){return a+ -65>>>0<26?a|32:a}function Qc(a,b,c){return Oc(a,b,c)}function Ga(a){return a+ -48>>>0<10}function Ea(a,b,c){Da(a,b,b>>31,c)}function Gc(a){a=a|0;return F()|0}function Fb(a,b){Eb(a,b);return a}function Va(a,b,c){Ka(a,b,c,0,0)}function pb(a){a=a|0;return 0}function rb(a){cb(a,q[1680])}function Mc(a,b){i(a|0,b|0)}function Gb(){return 82220}function Ec(a){a=a|0;T=a}function Dc(){return T|0}function ea(){} +// EMSCRIPTEN_END_FUNCS +n[1]=Ba;n[2]=Ta;n[3]=Ua;n[4]=Za;n[5]=Wa;n[6]=sb;n[7]=ob;n[8]=mb;n[9]=pb;n[10]=qb;function W(){return buffer.byteLength/65536|0}return{"__wasm_call_ctors":ea,"malloc":kc,"free":lc,"main":xa,"__errno_location":Gb,"stackSave":Dc,"stackRestore":Ec,"stackAlloc":Fc,"__growWasmMemory":Gc,"dynCall_iiii":Hc,"dynCall_iidiiii":Ic,"dynCall_vii":Jc,"dynCall_jiji":Lc,"dynCall_ii":Kc}}for(var X=new Uint8Array(123),Y=25;Y>=0;--Y){X[48+Y]=52+Y;X[65+Y]=Y;X[97+Y]=26+Y}X[43]=62;X[47]=63;function Z(uint8Array,offset,b64){var _,$,Y=0,aa=offset,ba=b64.length,ca=offset+(ba*3>>2)-(b64[ba-2]=="=")-(b64[ba-1]=="=");for(;Y>4;if(aa>2;if(aa>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}var wasmMemory;var wasmTable=new WebAssembly.Table({"initial":11,"maximum":11+0,"element":"anyfunc"});var ABORT=false;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];assert(func,"Cannot call unknown function "+ident+", make sure it is exported");return func}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":function(arr){var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string")return UTF8ToString(ret);if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i=endIdx))++endPtr;if(endPtr-idx>16&&heap.subarray&&UTF8Decoder){return UTF8Decoder.decode(heap.subarray(idx,endPtr))}else{var str="";while(idx>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function allocateUTF8OnStack(str){var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8Array(str,HEAP8,ret,size);return ret}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}var WASM_PAGE_SIZE=65536;var buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferAndViews(buf){buffer=buf;Module["HEAP8"]=HEAP8=new Int8Array(buf);Module["HEAP16"]=HEAP16=new Int16Array(buf);Module["HEAP32"]=HEAP32=new Int32Array(buf);Module["HEAPU8"]=HEAPU8=new Uint8Array(buf);Module["HEAPU16"]=HEAPU16=new Uint16Array(buf);Module["HEAPU32"]=HEAPU32=new Uint32Array(buf);Module["HEAPF32"]=HEAPF32=new Float32Array(buf);Module["HEAPF64"]=HEAPF64=new Float64Array(buf)}var STACK_BASE=5325824,DYNAMIC_BASE=5325824,DYNAMICTOP_PTR=82784;var INITIAL_INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_INITIAL_MEMORY/WASM_PAGE_SIZE,"maximum":INITIAL_INITIAL_MEMORY/WASM_PAGE_SIZE})}if(wasmMemory){buffer=wasmMemory.buffer}INITIAL_INITIAL_MEMORY=buffer.byteLength;updateGlobalBufferAndViews(buffer);HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE;function callRuntimeCallbacks(callbacks){while(callbacks.length>0){var callback=callbacks.shift();if(typeof callback=="function"){callback(Module);continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Module["dynCall_v"](func)}else{Module["dynCall_vi"](func,callback.arg)}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();TTY.init();callRuntimeCallbacks(__ATINIT__)}function preMain(){FS.ignorePermissions=false;callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var Math_abs=Math.abs;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_min=Math.min;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["preloadedImages"]={};Module["preloadedAudios"]={};function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what+="";out(what);err(what);ABORT=true;EXITSTATUS=1;what="abort("+what+"). Build with -s ASSERTIONS=1 for more info.";throw new WebAssembly.RuntimeError(what)}function hasPrefix(str,prefix){return String.prototype.startsWith?str.startsWith(prefix):str.indexOf(prefix)===0}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return hasPrefix(filename,dataURIPrefix)}var fileURIPrefix="file://";function isFileURI(filename){return hasPrefix(filename,fileURIPrefix)}var wasmBinaryFile="makewav.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(){try{if(wasmBinary){return new Uint8Array(wasmBinary)}var binary=tryParseAsDataURI(wasmBinaryFile);if(binary){return binary}if(readBinary){return readBinary(wasmBinaryFile)}else{throw"both async and sync fetching of the wasm failed"}}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&typeof fetch==="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary()})}return new Promise(function(resolve,reject){resolve(getBinary())})}function createWasm(){var info={"env":asmLibraryArg,"wasi_snapshot_preview1":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiatedSource(output){receiveInstance(output["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming==="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&typeof fetch==="function"){fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiatedSource,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiatedSource)})})}else{return instantiateArrayBuffer(receiveInstantiatedSource)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);return false}}instantiateAsync();return{}}var tempDouble;var tempI64;__ATINIT__.push({func:function(){___wasm_call_ctors()}});function demangle(func){return func}function demangleAll(text){var regex=/\b_Z[\w\d_]+/g;return text.replace(regex,function(x){var y=demangle(x);return x===y?x:y+" ["+x+"]"})}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){var js=jsStackTrace();if(Module["extraStackTrace"])js+="\n"+Module["extraStackTrace"]();return demangleAll(js)}function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}var PATH={splitPath:function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},extname:function(path){return PATH.splitPath(path)[3]},join:function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))},join2:function(l,r){return PATH.normalize(l+"/"+r)}};var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:function(from,to){from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},flush:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node}return node},getFileDataAsRegularArray:function(node){if(node.contents&&node.contents.subarray){var arr=[];for(var i=0;i=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0);return},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0;return}if(!node.contents||node.contents.subarray){var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize;return}if(!node.contents)node.contents=[];if(node.contents.length>newSize)node.contents.length=newSize;else while(node.contents.length=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length=stream.node.size)return 0;var chunk=stream.node.contents.slice(position,position+length);var ab=WORKERFS.reader.readAsArrayBuffer(chunk);buffer.set(new Uint8Array(ab),offset);return chunk.size},write:function(stream,buffer,offset,length,position){throw new FS.ErrnoError(29)},llseek:function(stream,offset,whence){var position=offset;if(whence===1){position+=stream.position}else if(whence===2){if(FS.isFile(stream.node.mode)){position+=stream.node.size}}if(position<0){throw new FS.ErrnoError(28)}return position}}};var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function(e){if(!(e instanceof FS.ErrnoError))throw e+" : "+stackTrace();return setErrNo(e.errno)},lookupPath:function(path,opts){path=PATH_FS.resolve(FS.cwd(),path);opts=opts||{};if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};for(var key in defaults){if(opts[key]===undefined){opts[key]=defaults[key]}}if(opts.recurse_count>8){throw new FS.ErrnoError(32)}var parts=PATH.normalizeArray(path.split("/").filter(function(p){return!!p}),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:function(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:function(parentid,name){var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:function(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:function(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:function(parent,name){var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:function(parent,name,mode,rdev){var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:function(node){FS.hashRemoveNode(node)},isRoot:function(node){return node===node.parent},isMountpoint:function(node){return!!node.mounted},isFile:function(mode){return(mode&61440)===32768},isDir:function(mode){return(mode&61440)===16384},isLink:function(mode){return(mode&61440)===40960},isChrdev:function(mode){return(mode&61440)===8192},isBlkdev:function(mode){return(mode&61440)===24576},isFIFO:function(mode){return(mode&61440)===4096},isSocket:function(mode){return(mode&49152)===49152},flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(str){var flags=FS.flagModes[str];if(typeof flags==="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:function(flag){var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:function(node,perms){if(FS.ignorePermissions){return 0}if(perms.indexOf("r")!==-1&&!(node.mode&292)){return 2}else if(perms.indexOf("w")!==-1&&!(node.mode&146)){return 2}else if(perms.indexOf("x")!==-1&&!(node.mode&73)){return 2}return 0},mayLookup:function(dir){var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate:function(dir,name){try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:function(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen:function(node,flags){if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:function(fd_start,fd_end){fd_start=fd_start||0;fd_end=fd_end||FS.MAX_OPEN_FDS;for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStream:function(fd){return FS.streams[fd]},createStream:function(stream,fd_start,fd_end){if(!FS.FSStream){FS.FSStream=function(){};FS.FSStream.prototype={object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}}}}var newStream=new FS.FSStream;for(var p in stream){newStream[p]=stream[p]}stream=newStream;var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:function(fd){FS.streams[fd]=null},chrdev_stream_ops:{open:function(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:function(){throw new FS.ErrnoError(70)}},major:function(dev){return dev>>8},minor:function(dev){return dev&255},makedev:function(ma,mi){return ma<<8|mi},registerDevice:function(dev,ops){FS.devices[dev]={stream_ops:ops}},getDevice:function(dev){return FS.devices[dev]},getMounts:function(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:function(populate,callback){if(typeof populate==="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(function(mount){if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:function(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:function(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(function(hash){var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.indexOf(current.mount)!==-1){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup:function(parent,name){return parent.node_ops.lookup(parent,name)},mknod:function(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create:function(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:function(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree:function(path,mode){var dirs=path.split("/");var d="";for(var i=0;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=function(from,to){if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);if(typeof Uint8Array!="undefined")xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}else{return intArrayFromString(xhr.responseText||"",true)}};var lazyArray=this;lazyArray.setDataGetter(function(chunkNum){var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!=="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(function(key){var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(29)}return fn.apply(null,arguments)}});stream_ops.read=function stream_ops_read(stream,buffer,offset,length,position){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(29)}var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i>2]=stat.dev;HEAP32[buf+4>>2]=0;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAP32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;HEAP32[buf+32>>2]=0;tempI64=[stat.size>>>0,(tempDouble=stat.size,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+40>>2]=tempI64[0],HEAP32[buf+44>>2]=tempI64[1];HEAP32[buf+48>>2]=4096;HEAP32[buf+52>>2]=stat.blocks;HEAP32[buf+56>>2]=stat.atime.getTime()/1e3|0;HEAP32[buf+60>>2]=0;HEAP32[buf+64>>2]=stat.mtime.getTime()/1e3|0;HEAP32[buf+68>>2]=0;HEAP32[buf+72>>2]=stat.ctime.getTime()/1e3|0;HEAP32[buf+76>>2]=0;tempI64=[stat.ino>>>0,(tempDouble=stat.ino,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+80>>2]=tempI64[0],HEAP32[buf+84>>2]=tempI64[1];return 0},doMsync:function(addr,stream,len,flags,offset){var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},doMkdir:function(path,mode){path=PATH.normalize(path);if(path[path.length-1]==="/")path=path.substr(0,path.length-1);FS.mkdir(path,mode,0);return 0},doMknod:function(path,mode,dev){switch(mode&61440){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}FS.mknod(path,mode,dev);return 0},doReadlink:function(path,buf,bufsize){if(bufsize<=0)return-28;var ret=FS.readlink(path);var len=Math.min(bufsize,lengthBytesUTF8(ret));var endChar=HEAP8[buf+len];stringToUTF8(ret,buf,bufsize+1);HEAP8[buf+len]=endChar;return len},doAccess:function(path,amode){if(amode&~7){return-28}var node;var lookup=FS.lookupPath(path,{follow:true});node=lookup.node;if(!node){return-44}var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-2}return 0},doDup:function(path,flags,suggestFD){var suggest=FS.getStream(suggestFD);if(suggest)FS.close(suggest);return FS.open(path,flags,0,suggestFD,suggestFD).fd},doReadv:function(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2];var len=HEAP32[iov+(i*8+4)>>2];var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr}return ret},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD:function(fd){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);return stream},get64:function(low,high){return low}};function ___sys_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}var newStream;newStream=FS.open(stream.path,stream.flags,0,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 12:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 13:case 14:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_ioctl(fd,op,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(op){case 21509:case 21505:{if(!stream.tty)return-59;return 0}case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:{if(!stream.tty)return-59;return 0}case 21519:{if(!stream.tty)return-59;var argp=SYSCALLS.get();HEAP32[argp>>2]=0;return 0}case 21520:{if(!stream.tty)return-59;return-28}case 21531:{var argp=SYSCALLS.get();return FS.ioctl(stream,op,argp)}case 21523:{if(!stream.tty)return-59;return 0}case 21524:{if(!stream.tty)return-59;return 0}default:abort("bad ioctl syscall "+op)}}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function ___sys_open(path,flags,varargs){SYSCALLS.varargs=varargs;try{var pathname=SYSCALLS.getStr(path);var mode=SYSCALLS.get();var stream=FS.open(pathname,flags,mode);return stream.fd}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}function _emscripten_get_sbrk_ptr(){return 82784}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num)}function abortOnCannotGrowMemory(requestedSize){abort("OOM")}function _emscripten_resize_heap(requestedSize){requestedSize=requestedSize>>>0;abortOnCannotGrowMemory(requestedSize)}function _exit(status){exit(status)}function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_read(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doReadv(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){try{var stream=SYSCALLS.getStreamFromFD(fd);var HIGH_OFFSET=4294967296;var offset=offset_high*HIGH_OFFSET+(offset_low>>>0);var DOUBLE_LIMIT=9007199254740992;if(offset<=-DOUBLE_LIMIT||offset>=DOUBLE_LIMIT){return-61}FS.llseek(stream,offset,whence);tempI64=[stream.position>>>0,(tempDouble=stream.position,+Math_abs(tempDouble)>=1?tempDouble>0?(Math_min(+Math_floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[newOffset>>2]=tempI64[0],HEAP32[newOffset+4>>2]=tempI64[1];if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=SYSCALLS.doWritev(stream,iov,iovcnt);HEAP32[pnum>>2]=num;return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return e.errno}}var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.staticInit();Module["FS_createFolder"]=FS.createFolder;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createLink"]=FS.createLink;Module["FS_createDevice"]=FS.createDevice;Module["FS_unlink"]=FS.unlink;var ASSERTIONS=false;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}function intArrayToString(array){var ret=[];for(var i=0;i255){if(ASSERTIONS){assert(false,"Character code "+chr+" ("+String.fromCharCode(chr)+") at offset "+i+" not in 0x00-0xFF.")}chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}var decodeBase64=typeof atob==="function"?atob:function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64){output=output+String.fromCharCode(chr2)}if(enc4!==64){output=output+String.fromCharCode(chr3)}}while(i>2]=allocateUTF8OnStack(thisProgram);for(var i=1;i>2)+i]=allocateUTF8OnStack(args[i-1])}HEAP32[(argv>>2)+argc]=0;try{var ret=entryFunction(argc,argv);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="unwind"){noExitRuntime=true;return}else{var toLog=e;if(e&&typeof e==="object"&&e.stack){toLog=[e,e.stack]}err("exception thrown: "+toLog);quit_(1,e)}}finally{calledMain=true}}function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();preMain();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(shouldRunNow)callMain(args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}Module["run"]=run;function exit(status,implicit){if(implicit&&noExitRuntime&&status===0){return}if(noExitRuntime){}else{ABORT=true;EXITSTATUS=status;exitRuntime();if(Module["onExit"])Module["onExit"](status)}quit_(status,new ExitStatus(status))}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"])shouldRunNow=false;noExitRuntime=true;run(); + + + return makewav;//.ready +} +); +})(); +if (typeof exports === 'object' && typeof module === 'object') + module.exports = makewav; + else if (typeof define === 'function' && define['amd']) + define([], function() { return makewav; }); + else if (typeof exports === 'object') + exports["makewav"] = makewav; + \ No newline at end of file diff --git a/presets/atari7800/sprites.dasm b/presets/atari7800/sprites.dasm index b4f59f93..eaf7ffbe 100644 --- a/presets/atari7800/sprites.dasm +++ b/presets/atari7800/sprites.dasm @@ -1,5 +1,5 @@ ; Atari 7800 sprite sample -; Written by Daniel Boris (dboris@home.com) +; Written by Daniel Boris (danlb_2000@yahoo.com) ; ; Assemble with DASM ; diff --git a/src/ide/project.ts b/src/ide/project.ts index fb7b1aa1..68df4ec1 100644 --- a/src/ide/project.ts +++ b/src/ide/project.ts @@ -104,7 +104,8 @@ export class CodeProject { this.pushAllFiles(files, m[2]); } // for XASM only (USE include.ext) - let re4 = /^\s+(USE)\s+(\S+[.]\S+)/gm; + // for merlin32 (ASM include.ext) + let re4 = /^\s+(USE|ASM)\s+(\S+[.]\S+)/gm; while (m = re4.exec(text)) { this.pushAllFiles(files, m[2]); } diff --git a/src/ide/ui.ts b/src/ide/ui.ts index ef5fa49b..90889d41 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -779,16 +779,8 @@ function get8bitworkshopLink(linkqs : string, fn : string) { return fulllink; } -function _downloadCassetteFile(e) { - if (current_output == null) { - alertError("Please fix errors before exporting."); - return true; - } +function _downloadCassetteFile_apple2(e) { var addr = compparams && compparams.code_start; - if (addr === undefined) { - alertError("Cassette export is not supported on this platform."); - return true; - } loadScript('lib/c2t.js').then( () => { var stdout = ''; var print_fn = function(s) { stdout += s + "\n"; } @@ -813,6 +805,53 @@ function _downloadCassetteFile(e) { }); } +function _downloadCassetteFile_vcs(e) { + loadScript('lib/makewav.js').then( () => { + let stdout = ''; + let print_fn = function(s) { stdout += s + "\n"; } + var prefix = getFilenamePrefix(getCurrentMainFilename()); + let rompath = prefix + ".bin"; + let audpath = prefix + ".wav"; + let _makewav = window['makewav']({ + noInitialRun:false, + print:print_fn, + printErr:print_fn, + arguments:['-ts', '-f0', '-v10', rompath], + preRun: (mod) => { + let FS = mod['FS']; + FS.writeFile(rompath, current_output, {encoding:'binary'}); + } + }); + _makewav.ready.then((makewav) => { + let args = [rompath]; + makewav.run(args); + console.log(stdout); + let FS = makewav['FS']; + let audout = FS.readFile(audpath, {'encoding':'binary'}); + if (audout) { + let blob = new Blob([audout], {type: "audio/wav"}); + saveAs(blob, audpath); + stdout += "\nConnect your audio output to the SuperCharger input, turn up the volume, and play the audio file."; + alertInfo('

'+stdout+'
'); + } + }); + }); +} + +function _downloadCassetteFile(e) { + if (current_output == null) { + alertError("Please fix errors before exporting."); + return true; + } + var fn = window['_downloadCassetteFile_' + getBasePlatform(platform_id)]; + if (fn === undefined) { + alertError("Cassette export is not supported on this platform."); + return true; + } + fn(e); +} + + function _revertFile(e) { var wnd = projectWindows.getActive(); if (wnd && wnd.setText) { @@ -1607,7 +1646,7 @@ function setupDebugControls() { $("#item_download_zip").click(_downloadProjectZipFile); $("#item_download_allzip").click(_downloadAllFilesZipFile); $("#item_record_video").click(_recordVideo); - if (platform_id.startsWith('apple2')) + if (platform_id.startsWith('apple2') || platform_id.startsWith('vcs')) // TODO: look for function $("#item_export_cassette").click(_downloadCassetteFile); else $("#item_export_cassette").hide(); diff --git a/src/ide/views.ts b/src/ide/views.ts index 971c9d4d..1d250014 100644 --- a/src/ide/views.ts +++ b/src/ide/views.ts @@ -270,8 +270,10 @@ export class SourceEditor implements ProjectView { } else if (platform.getOpcodeMetadata) { var opcode = parseInt(info.insns.split(" ")[0], 16); var meta = platform.getOpcodeMetadata(opcode, info.offset); - var clockstr = meta.minCycles+""; - this.setGutter("gutter-clock", info.line-1, clockstr); + if (meta) { + var clockstr = meta.minCycles+""; + this.setGutter("gutter-clock", info.line-1, clockstr); + } } } } diff --git a/src/platform/apple2.ts b/src/platform/apple2.ts index c312f917..f15f72d7 100644 --- a/src/platform/apple2.ts +++ b/src/platform/apple2.ts @@ -83,6 +83,10 @@ class NewApple2Platform extends Base6502MachinePlatform implements Plat if (rom && rom.length == 35*16*256) return ".dsk"; // DSK image return ".bin"; }; + getToolForFilename = (fn:string) : string => { + if (fn.endsWith(".lnk")) return "merlin32"; + else return getToolForFilename_6502(fn); + } /* newCodeAnalyzer() { return new CodeAnalyzer_apple2(this); diff --git a/src/worker/wasm/merlin32.js b/src/worker/wasm/merlin32.js new file mode 100644 index 00000000..dd6d526b --- /dev/null +++ b/src/worker/wasm/merlin32.js @@ -0,0 +1,5550 @@ + +var merlin32 = (function() { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(merlin32) { + merlin32 = merlin32 || {}; + + + +// The Module object: Our interface to the outside world. We import +// and export values on it. There are various ways Module can be used: +// 1. Not defined. We create it here +// 2. A function parameter, function(Module) { ..generated code.. } +// 3. pre-run appended it, var Module = {}; ..generated code.. +// 4. External script tag defines var Module. +// We need to check if Module already exists (e.g. case 3 above). +// Substitution will be replaced with actual code on later stage of the build, +// this way Closure Compiler will not mangle it (e.g. case 4. above). +// Note that if you want to run closure, and also to use Module +// after the generated code, you will need to define var Module = {}; +// before the code. Then that object will be used in the code, and you +// can continue to use Module afterwards as well. +var Module = typeof merlin32 !== 'undefined' ? merlin32 : {}; + + +// Set up the promise that indicates the Module is initialized +var readyPromiseResolve, readyPromiseReject; +Module['ready'] = new Promise(function(resolve, reject) { + readyPromiseResolve = resolve; + readyPromiseReject = reject; +}); + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_main')) { + Object.defineProperty(Module['ready'], '_main', { configurable: true, get: function() { abort('You are getting _main 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') } }); + Object.defineProperty(Module['ready'], '_main', { configurable: true, set: function() { abort('You are setting _main 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_malloc')) { + 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') } }); + 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_free')) { + 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') } }); + 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_stackSave')) { + Object.defineProperty(Module['ready'], '_stackSave', { configurable: true, get: function() { abort('You are getting _stackSave 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') } }); + Object.defineProperty(Module['ready'], '_stackSave', { configurable: true, set: function() { abort('You are setting _stackSave 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_stackRestore')) { + Object.defineProperty(Module['ready'], '_stackRestore', { configurable: true, get: function() { abort('You are getting _stackRestore 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') } }); + Object.defineProperty(Module['ready'], '_stackRestore', { configurable: true, set: function() { abort('You are setting _stackRestore 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_stackAlloc')) { + Object.defineProperty(Module['ready'], '_stackAlloc', { configurable: true, get: function() { abort('You are getting _stackAlloc 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') } }); + Object.defineProperty(Module['ready'], '_stackAlloc', { configurable: true, set: function() { abort('You are setting _stackAlloc 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '___data_end')) { + Object.defineProperty(Module['ready'], '___data_end', { configurable: true, get: function() { abort('You are getting ___data_end 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') } }); + Object.defineProperty(Module['ready'], '___data_end', { configurable: true, set: function() { abort('You are setting ___data_end 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '___wasm_call_ctors')) { + Object.defineProperty(Module['ready'], '___wasm_call_ctors', { configurable: true, get: function() { abort('You are getting ___wasm_call_ctors 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') } }); + Object.defineProperty(Module['ready'], '___wasm_call_ctors', { configurable: true, set: function() { abort('You are setting ___wasm_call_ctors 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_fflush')) { + Object.defineProperty(Module['ready'], '_fflush', { configurable: true, get: function() { abort('You are getting _fflush 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') } }); + Object.defineProperty(Module['ready'], '_fflush', { configurable: true, set: function() { abort('You are setting _fflush 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '___errno_location')) { + Object.defineProperty(Module['ready'], '___errno_location', { configurable: true, get: function() { abort('You are getting ___errno_location 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') } }); + Object.defineProperty(Module['ready'], '___errno_location', { configurable: true, set: function() { abort('You are setting ___errno_location 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_setThrew')) { + Object.defineProperty(Module['ready'], '_setThrew', { configurable: true, get: function() { abort('You are getting _setThrew 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') } }); + Object.defineProperty(Module['ready'], '_setThrew', { configurable: true, set: function() { abort('You are setting _setThrew 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_realloc')) { + Object.defineProperty(Module['ready'], '_realloc', { configurable: true, get: function() { abort('You are getting _realloc 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') } }); + Object.defineProperty(Module['ready'], '_realloc', { configurable: true, set: function() { abort('You are setting _realloc 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_testSetjmp')) { + Object.defineProperty(Module['ready'], '_testSetjmp', { configurable: true, get: function() { abort('You are getting _testSetjmp 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') } }); + Object.defineProperty(Module['ready'], '_testSetjmp', { configurable: true, set: function() { abort('You are setting _testSetjmp 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '_saveSetjmp')) { + Object.defineProperty(Module['ready'], '_saveSetjmp', { configurable: true, get: function() { abort('You are getting _saveSetjmp 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') } }); + Object.defineProperty(Module['ready'], '_saveSetjmp', { configurable: true, set: function() { abort('You are setting _saveSetjmp 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '__get_tzname')) { + Object.defineProperty(Module['ready'], '__get_tzname', { configurable: true, get: function() { abort('You are getting __get_tzname 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') } }); + Object.defineProperty(Module['ready'], '__get_tzname', { configurable: true, set: function() { abort('You are setting __get_tzname 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '__get_daylight')) { + Object.defineProperty(Module['ready'], '__get_daylight', { configurable: true, get: function() { abort('You are getting __get_daylight 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') } }); + Object.defineProperty(Module['ready'], '__get_daylight', { configurable: true, set: function() { abort('You are setting __get_daylight 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], '__get_timezone')) { + Object.defineProperty(Module['ready'], '__get_timezone', { configurable: true, get: function() { abort('You are getting __get_timezone 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') } }); + Object.defineProperty(Module['ready'], '__get_timezone', { configurable: true, set: function() { abort('You are setting __get_timezone 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') } }); + } + + + if (!Object.getOwnPropertyDescriptor(Module['ready'], 'onRuntimeInitialized')) { + 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') } }); + 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') } }); + } + + +// --pre-jses are emitted after the Module integration code, so that they can +// refer to Module (if they choose; they can also define Module) +// {{PRE_JSES}} + +// Sometimes an existing Module object exists with properties +// meant to overwrite the default module functionality. Here +// we collect those properties and reapply _after_ we configure +// the current environment's defaults to avoid having to be so +// defensive during initialization. +var moduleOverrides = {}; +var key; +for (key in Module) { + if (Module.hasOwnProperty(key)) { + moduleOverrides[key] = Module[key]; + } +} + +var arguments_ = []; +var thisProgram = './this.program'; +var quit_ = function(status, toThrow) { + throw toThrow; +}; + +// Determine the runtime environment we are in. You can customize this by +// setting the ENVIRONMENT setting at compile time (see settings.js). + +var ENVIRONMENT_IS_WEB = false; +var ENVIRONMENT_IS_WORKER = false; +var ENVIRONMENT_IS_NODE = false; +var ENVIRONMENT_IS_SHELL = false; +ENVIRONMENT_IS_WEB = typeof window === 'object'; +ENVIRONMENT_IS_WORKER = typeof importScripts === 'function'; +// N.b. Electron.js environment is simultaneously a NODE-environment, but +// also a web environment. +ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string'; +ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; + +if (Module['ENVIRONMENT']) { + 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)'); +} + + + +// `/` should be present at the end if `scriptDirectory` is not empty +var scriptDirectory = ''; +function locateFile(path) { + if (Module['locateFile']) { + return Module['locateFile'](path, scriptDirectory); + } + return scriptDirectory + path; +} + +// Hooks that are implemented differently in different runtime environments. +var read_, + readAsync, + readBinary, + setWindowTitle; + +var nodeFS; +var nodePath; + +if (ENVIRONMENT_IS_NODE) { + if (ENVIRONMENT_IS_WORKER) { + scriptDirectory = require('path').dirname(scriptDirectory) + '/'; + } else { + scriptDirectory = __dirname + '/'; + } + + + + + read_ = function shell_read(filename, binary) { + if (!nodeFS) nodeFS = require('fs'); + if (!nodePath) nodePath = require('path'); + filename = nodePath['normalize'](filename); + return nodeFS['readFileSync'](filename, binary ? null : 'utf8'); + }; + + readBinary = function readBinary(filename) { + var ret = read_(filename, true); + if (!ret.buffer) { + ret = new Uint8Array(ret); + } + assert(ret.buffer); + return ret; + }; + + + + + if (process['argv'].length > 1) { + thisProgram = process['argv'][1].replace(/\\/g, '/'); + } + + arguments_ = process['argv'].slice(2); + + // MODULARIZE will export the module in the proper place outside, we don't need to export here + + process['on']('uncaughtException', function(ex) { + // suppress ExitStatus exceptions from showing an error + if (!(ex instanceof ExitStatus)) { + throw ex; + } + }); + + process['on']('unhandledRejection', abort); + + quit_ = function(status) { + process['exit'](status); + }; + + Module['inspect'] = function () { return '[Emscripten Module object]'; }; + + + +} else +if (ENVIRONMENT_IS_SHELL) { + + + if (typeof read != 'undefined') { + read_ = function shell_read(f) { + return read(f); + }; + } + + readBinary = function readBinary(f) { + var data; + if (typeof readbuffer === 'function') { + return new Uint8Array(readbuffer(f)); + } + data = read(f, 'binary'); + assert(typeof data === 'object'); + return data; + }; + + if (typeof scriptArgs != 'undefined') { + arguments_ = scriptArgs; + } else if (typeof arguments != 'undefined') { + arguments_ = arguments; + } + + if (typeof quit === 'function') { + quit_ = function(status) { + quit(status); + }; + } + + if (typeof print !== 'undefined') { + // Prefer to use print/printErr where they exist, as they usually work better. + if (typeof console === 'undefined') console = /** @type{!Console} */({}); + console.log = /** @type{!function(this:Console, ...*): undefined} */ (print); + console.warn = console.error = /** @type{!function(this:Console, ...*): undefined} */ (typeof printErr !== 'undefined' ? printErr : print); + } + + +} else + +// Note that this includes Node.js workers when relevant (pthreads is enabled). +// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and +// ENVIRONMENT_IS_NODE. +if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { + if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled + scriptDirectory = self.location.href; + } else if (document.currentScript) { // web + scriptDirectory = document.currentScript.src; + } + // When MODULARIZE, this JS may be executed later, after document.currentScript + // is gone, so we saved it, and we use it here instead of any other info. + if (_scriptDir) { + scriptDirectory = _scriptDir; + } + // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them. + // otherwise, slice off the final part of the url to find the script directory. + // if scriptDirectory does not contain a slash, lastIndexOf will return -1, + // and scriptDirectory will correctly be replaced with an empty string. + if (scriptDirectory.indexOf('blob:') !== 0) { + scriptDirectory = scriptDirectory.substr(0, scriptDirectory.lastIndexOf('/')+1); + } else { + scriptDirectory = ''; + } + + + // Differentiate the Web Worker from the Node Worker case, as reading must + // be done differently. + { + + + + + read_ = function shell_read(url) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, false); + xhr.send(null); + return xhr.responseText; + }; + + if (ENVIRONMENT_IS_WORKER) { + readBinary = function readBinary(url) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, false); + xhr.responseType = 'arraybuffer'; + xhr.send(null); + return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response)); + }; + } + + readAsync = function readAsync(url, onload, onerror) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.responseType = 'arraybuffer'; + xhr.onload = function xhr_onload() { + if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 + onload(xhr.response); + return; + } + onerror(); + }; + xhr.onerror = onerror; + xhr.send(null); + }; + + + + + } + + setWindowTitle = function(title) { document.title = title }; +} else +{ + throw new Error('environment detection error'); +} + + +// Set up the out() and err() hooks, which are how we can print to stdout or +// stderr, respectively. +var out = Module['print'] || console.log.bind(console); +var err = Module['printErr'] || console.warn.bind(console); + +// Merge back in the overrides +for (key in moduleOverrides) { + if (moduleOverrides.hasOwnProperty(key)) { + Module[key] = moduleOverrides[key]; + } +} +// Free the object hierarchy contained in the overrides, this lets the GC +// reclaim data used e.g. in memoryInitializerRequest, which is a large typed array. +moduleOverrides = null; + +// Emit code to handle expected values on the Module object. This applies Module.x +// to the proper local x. This has two benefits: first, we only emit it if it is +// expected to arrive, and second, by using a local everywhere else that can be +// minified. +if (Module['arguments']) arguments_ = Module['arguments'];if (!Object.getOwnPropertyDescriptor(Module, 'arguments')) Object.defineProperty(Module, 'arguments', { configurable: true, get: function() { abort('Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); +if (Module['thisProgram']) thisProgram = Module['thisProgram'];if (!Object.getOwnPropertyDescriptor(Module, 'thisProgram')) Object.defineProperty(Module, 'thisProgram', { configurable: true, get: function() { abort('Module.thisProgram has been replaced with plain thisProgram (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); +if (Module['quit']) quit_ = Module['quit'];if (!Object.getOwnPropertyDescriptor(Module, 'quit')) Object.defineProperty(Module, 'quit', { configurable: true, get: function() { abort('Module.quit has been replaced with plain quit_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); + +// perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message +// Assertions on removed incoming Module JS APIs. +assert(typeof Module['memoryInitializerPrefixURL'] === 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead'); +assert(typeof Module['pthreadMainPrefixURL'] === 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead'); +assert(typeof Module['cdInitializerPrefixURL'] === 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead'); +assert(typeof Module['filePackagePrefixURL'] === 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead'); +assert(typeof Module['read'] === 'undefined', 'Module.read option was removed (modify read_ in JS)'); +assert(typeof Module['readAsync'] === 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)'); +assert(typeof Module['readBinary'] === 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)'); +assert(typeof Module['setWindowTitle'] === 'undefined', 'Module.setWindowTitle option was removed (modify setWindowTitle in JS)'); +assert(typeof Module['TOTAL_MEMORY'] === 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY'); +if (!Object.getOwnPropertyDescriptor(Module, 'read')) Object.defineProperty(Module, 'read', { configurable: true, get: function() { abort('Module.read has been replaced with plain read_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); +if (!Object.getOwnPropertyDescriptor(Module, 'readAsync')) Object.defineProperty(Module, 'readAsync', { configurable: true, get: function() { abort('Module.readAsync has been replaced with plain readAsync (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); +if (!Object.getOwnPropertyDescriptor(Module, 'readBinary')) Object.defineProperty(Module, 'readBinary', { configurable: true, get: function() { abort('Module.readBinary has been replaced with plain readBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); +if (!Object.getOwnPropertyDescriptor(Module, 'setWindowTitle')) Object.defineProperty(Module, 'setWindowTitle', { configurable: true, get: function() { abort('Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); +var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js'; +var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js'; + +var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js'; + + + + + + +// {{PREAMBLE_ADDITIONS}} + +var STACK_ALIGN = 16; + +function dynamicAlloc(size) { + assert(DYNAMICTOP_PTR); + var ret = HEAP32[DYNAMICTOP_PTR>>2]; + var end = (ret + size + 15) & -16; + assert(end <= HEAP8.length, 'failure to dynamicAlloc - memory growth etc. is not supported there, call malloc/sbrk directly'); + HEAP32[DYNAMICTOP_PTR>>2] = end; + return ret; +} + +function alignMemory(size, factor) { + if (!factor) factor = STACK_ALIGN; // stack alignment (16-byte) by default + return Math.ceil(size / factor) * factor; +} + +function getNativeTypeSize(type) { + switch (type) { + case 'i1': case 'i8': return 1; + case 'i16': return 2; + case 'i32': return 4; + case 'i64': return 8; + case 'float': return 4; + case 'double': return 8; + default: { + if (type[type.length-1] === '*') { + return 4; // A pointer + } else if (type[0] === 'i') { + var bits = Number(type.substr(1)); + assert(bits % 8 === 0, 'getNativeTypeSize invalid bits ' + bits + ', type ' + type); + return bits / 8; + } else { + return 0; + } + } + } +} + +function warnOnce(text) { + if (!warnOnce.shown) warnOnce.shown = {}; + if (!warnOnce.shown[text]) { + warnOnce.shown[text] = 1; + err(text); + } +} + + + + + + + + +// Wraps a JS function as a wasm function with a given signature. +function convertJsFunctionToWasm(func, sig) { + + // If the type reflection proposal is available, use the new + // "WebAssembly.Function" constructor. + // Otherwise, construct a minimal wasm module importing the JS function and + // re-exporting it. + if (typeof WebAssembly.Function === "function") { + var typeNames = { + 'i': 'i32', + 'j': 'i64', + 'f': 'f32', + 'd': 'f64' + }; + var type = { + parameters: [], + results: sig[0] == 'v' ? [] : [typeNames[sig[0]]] + }; + for (var i = 1; i < sig.length; ++i) { + type.parameters.push(typeNames[sig[i]]); + } + return new WebAssembly.Function(type, func); + } + + // The module is static, with the exception of the type section, which is + // generated based on the signature passed in. + var typeSection = [ + 0x01, // id: section, + 0x00, // length: 0 (placeholder) + 0x01, // count: 1 + 0x60, // form: func + ]; + var sigRet = sig.slice(0, 1); + var sigParam = sig.slice(1); + var typeCodes = { + 'i': 0x7f, // i32 + 'j': 0x7e, // i64 + 'f': 0x7d, // f32 + 'd': 0x7c, // f64 + }; + + // Parameters, length + signatures + typeSection.push(sigParam.length); + for (var i = 0; i < sigParam.length; ++i) { + typeSection.push(typeCodes[sigParam[i]]); + } + + // Return values, length + signatures + // With no multi-return in MVP, either 0 (void) or 1 (anything else) + if (sigRet == 'v') { + typeSection.push(0x00); + } else { + typeSection = typeSection.concat([0x01, typeCodes[sigRet]]); + } + + // Write the overall length of the type section back into the section header + // (excepting the 2 bytes for the section id and length) + typeSection[1] = typeSection.length - 2; + + // Rest of the module is static + var bytes = new Uint8Array([ + 0x00, 0x61, 0x73, 0x6d, // magic ("\0asm") + 0x01, 0x00, 0x00, 0x00, // version: 1 + ].concat(typeSection, [ + 0x02, 0x07, // import section + // (import "e" "f" (func 0 (type 0))) + 0x01, 0x01, 0x65, 0x01, 0x66, 0x00, 0x00, + 0x07, 0x05, // export section + // (export "f" (func 0 (type 0))) + 0x01, 0x01, 0x66, 0x00, 0x00, + ])); + + // We can compile this wasm module synchronously because it is very small. + // This accepts an import (at "e.f"), that it reroutes to an export (at "f") + var module = new WebAssembly.Module(bytes); + var instance = new WebAssembly.Instance(module, { + 'e': { + 'f': func + } + }); + var wrappedFunc = instance.exports['f']; + return wrappedFunc; +} + +var freeTableIndexes = []; + +// Weak map of functions in the table to their indexes, created on first use. +var functionsInTableMap; + +// Add a wasm function to the table. +function addFunctionWasm(func, sig) { + var table = wasmTable; + + // Check if the function is already in the table, to ensure each function + // gets a unique index. First, create the map if this is the first use. + if (!functionsInTableMap) { + functionsInTableMap = new WeakMap(); + for (var i = 0; i < table.length; i++) { + var item = table.get(i); + // Ignore null values. + if (item) { + functionsInTableMap.set(item, i); + } + } + } + if (functionsInTableMap.has(func)) { + return functionsInTableMap.get(func); + } + + // It's not in the table, add it now. + + + var ret; + // Reuse a free index if there is one, otherwise grow. + if (freeTableIndexes.length) { + ret = freeTableIndexes.pop(); + } else { + ret = table.length; + // Grow the table + try { + table.grow(1); + } catch (err) { + if (!(err instanceof RangeError)) { + throw err; + } + throw 'Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.'; + } + } + + // Set the new value. + try { + // Attempting to call this with JS function will cause of table.set() to fail + table.set(ret, func); + } catch (err) { + if (!(err instanceof TypeError)) { + throw err; + } + assert(typeof sig !== 'undefined', 'Missing signature argument to addFunction'); + var wrapped = convertJsFunctionToWasm(func, sig); + table.set(ret, wrapped); + } + + functionsInTableMap.set(func, ret); + + return ret; +} + +function removeFunctionWasm(index) { + functionsInTableMap.delete(wasmTable.get(index)); + freeTableIndexes.push(index); +} + +// 'sig' parameter is required for the llvm backend but only when func is not +// already a WebAssembly function. +function addFunction(func, sig) { + assert(typeof func !== 'undefined'); + + return addFunctionWasm(func, sig); +} + +function removeFunction(index) { + removeFunctionWasm(index); +} + + + +var funcWrappers = {}; + +function getFuncWrapper(func, sig) { + if (!func) return; // on null pointer, return undefined + assert(sig); + if (!funcWrappers[sig]) { + funcWrappers[sig] = {}; + } + var sigCache = funcWrappers[sig]; + if (!sigCache[func]) { + // optimize away arguments usage in common cases + if (sig.length === 1) { + sigCache[func] = function dynCall_wrapper() { + return dynCall(sig, func); + }; + } else if (sig.length === 2) { + sigCache[func] = function dynCall_wrapper(arg) { + return dynCall(sig, func, [arg]); + }; + } else { + // general case + sigCache[func] = function dynCall_wrapper() { + return dynCall(sig, func, Array.prototype.slice.call(arguments)); + }; + } + } + return sigCache[func]; +} + + + + + + + +function makeBigInt(low, high, unsigned) { + return unsigned ? ((+((low>>>0)))+((+((high>>>0)))*4294967296.0)) : ((+((low>>>0)))+((+((high|0)))*4294967296.0)); +} + +/** @param {Array=} args */ +function dynCall(sig, ptr, args) { + if (args && args.length) { + // j (64-bit integer) must be passed in as two numbers [low 32, high 32]. + assert(args.length === sig.substring(1).replace(/j/g, '--').length); + assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\''); + return Module['dynCall_' + sig].apply(null, [ptr].concat(args)); + } else { + assert(sig.length == 1); + assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\''); + return Module['dynCall_' + sig].call(null, ptr); + } +} + +var tempRet0 = 0; + +var setTempRet0 = function(value) { + tempRet0 = value; +}; + +var getTempRet0 = function() { + return tempRet0; +}; + +function getCompilerSetting(name) { + throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for getCompilerSetting or emscripten_get_compiler_setting to work'; +} + +// The address globals begin at. Very low in memory, for code size and optimization opportunities. +// Above 0 is static memory, starting with globals. +// Then the stack. +// Then 'dynamic' memory for sbrk. +var GLOBAL_BASE = 1024; + + + + + +// === Preamble library stuff === + +// Documentation for the public APIs defined in this file must be updated in: +// site/source/docs/api_reference/preamble.js.rst +// A prebuilt local version of the documentation is available at: +// site/build/text/docs/api_reference/preamble.js.txt +// You can also build docs locally as HTML or other formats in site/ +// An online HTML version (which may be of a different version of Emscripten) +// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html + + +var wasmBinary;if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];if (!Object.getOwnPropertyDescriptor(Module, 'wasmBinary')) Object.defineProperty(Module, 'wasmBinary', { configurable: true, get: function() { abort('Module.wasmBinary has been replaced with plain wasmBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); +var noExitRuntime;if (Module['noExitRuntime']) noExitRuntime = Module['noExitRuntime'];if (!Object.getOwnPropertyDescriptor(Module, 'noExitRuntime')) Object.defineProperty(Module, 'noExitRuntime', { configurable: true, get: function() { abort('Module.noExitRuntime has been replaced with plain noExitRuntime (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); + + +if (typeof WebAssembly !== 'object') { + abort('No WebAssembly support found. Build with -s WASM=0 to target JavaScript instead.'); +} + + + + +// In MINIMAL_RUNTIME, setValue() and getValue() are only available when building with safe heap enabled, for heap safety checking. +// In traditional runtime, setValue() and getValue() are always available (although their use is highly discouraged due to perf penalties) + +/** @param {number} ptr + @param {number} value + @param {string} type + @param {number|boolean=} noSafe */ +function setValue(ptr, value, type, noSafe) { + type = type || 'i8'; + if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit + switch(type) { + case 'i1': HEAP8[((ptr)>>0)]=value; break; + case 'i8': HEAP8[((ptr)>>0)]=value; break; + case 'i16': HEAP16[((ptr)>>1)]=value; break; + case 'i32': HEAP32[((ptr)>>2)]=value; break; + 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; + case 'float': HEAPF32[((ptr)>>2)]=value; break; + case 'double': HEAPF64[((ptr)>>3)]=value; break; + default: abort('invalid type for setValue: ' + type); + } +} + +/** @param {number} ptr + @param {string} type + @param {number|boolean=} noSafe */ +function getValue(ptr, type, noSafe) { + type = type || 'i8'; + if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit + switch(type) { + case 'i1': return HEAP8[((ptr)>>0)]; + case 'i8': return HEAP8[((ptr)>>0)]; + case 'i16': return HEAP16[((ptr)>>1)]; + case 'i32': return HEAP32[((ptr)>>2)]; + case 'i64': return HEAP32[((ptr)>>2)]; + case 'float': return HEAPF32[((ptr)>>2)]; + case 'double': return HEAPF64[((ptr)>>3)]; + default: abort('invalid type for getValue: ' + type); + } + return null; +} + + + + + + +// Wasm globals + +var wasmMemory; + +// In fastcomp asm.js, we don't need a wasm Table at all. +// In the wasm backend, we polyfill the WebAssembly object, +// so this creates a (non-native-wasm) table for us. +var wasmTable = new WebAssembly.Table({ + 'initial': 27, + 'maximum': 27 + 0, + 'element': 'anyfunc' +}); + + +//======================================== +// Runtime essentials +//======================================== + +// whether we are quitting the application. no code should run after this. +// set in exit() and abort() +var ABORT = false; + +// set by exit() and abort(). Passed to 'onExit' handler. +// NOTE: This is also used as the process return code code in shell environments +// but only when noExitRuntime is false. +var EXITSTATUS = 0; + +/** @type {function(*, string=)} */ +function assert(condition, text) { + if (!condition) { + abort('Assertion failed: ' + text); + } +} + +// Returns the C function with a specified identifier (for C++, you need to do manual name mangling) +function getCFunc(ident) { + var func = Module['_' + ident]; // closure exported function + assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported'); + return func; +} + +// C calling interface. +/** @param {string|null=} returnType + @param {Array=} argTypes + @param {Arguments|Array=} args + @param {Object=} opts */ +function ccall(ident, returnType, argTypes, args, opts) { + // For fast lookup of conversion functions + var toC = { + 'string': function(str) { + var ret = 0; + if (str !== null && str !== undefined && str !== 0) { // null string + // at most 4 bytes per UTF-8 code point, +1 for the trailing '\0' + var len = (str.length << 2) + 1; + ret = stackAlloc(len); + stringToUTF8(str, ret, len); + } + return ret; + }, + 'array': function(arr) { + var ret = stackAlloc(arr.length); + writeArrayToMemory(arr, ret); + return ret; + } + }; + + function convertReturnValue(ret) { + if (returnType === 'string') return UTF8ToString(ret); + if (returnType === 'boolean') return Boolean(ret); + return ret; + } + + var func = getCFunc(ident); + var cArgs = []; + var stack = 0; + assert(returnType !== 'array', 'Return type should not be "array".'); + if (args) { + for (var i = 0; i < args.length; i++) { + var converter = toC[argTypes[i]]; + if (converter) { + if (stack === 0) stack = stackSave(); + cArgs[i] = converter(args[i]); + } else { + cArgs[i] = args[i]; + } + } + } + var ret = func.apply(null, cArgs); + + ret = convertReturnValue(ret); + if (stack !== 0) stackRestore(stack); + return ret; +} + +/** @param {string=} returnType + @param {Array=} argTypes + @param {Object=} opts */ +function cwrap(ident, returnType, argTypes, opts) { + return function() { + return ccall(ident, returnType, argTypes, arguments, opts); + } +} + +var ALLOC_NORMAL = 0; // Tries to use _malloc() +var ALLOC_STACK = 1; // Lives for the duration of the current function call +var ALLOC_DYNAMIC = 2; // Cannot be freed except through sbrk +var ALLOC_NONE = 3; // Do not allocate + +// allocate(): This is for internal use. You can use it yourself as well, but the interface +// is a little tricky (see docs right below). The reason is that it is optimized +// for multiple syntaxes to save space in generated code. So you should +// normally not use allocate(), and instead allocate memory using _malloc(), +// initialize it with setValue(), and so forth. +// @slab: An array of data, or a number. If a number, then the size of the block to allocate, +// in *bytes* (note that this is sometimes confusing: the next parameter does not +// affect this!) +// @types: Either an array of types, one for each byte (or 0 if no type at that position), +// or a single type which is used for the entire block. This only matters if there +// is initial data - if @slab is a number, then this does not matter at all and is +// ignored. +// @allocator: How to allocate memory, see ALLOC_* +/** @type {function((TypedArray|Array|number), string, number, number=)} */ +function allocate(slab, types, allocator, ptr) { + var zeroinit, size; + if (typeof slab === 'number') { + zeroinit = true; + size = slab; + } else { + zeroinit = false; + size = slab.length; + } + + var singleType = typeof types === 'string' ? types : null; + + var ret; + if (allocator == ALLOC_NONE) { + ret = ptr; + } else { + ret = [_malloc, + stackAlloc, + dynamicAlloc][allocator](Math.max(size, singleType ? 1 : types.length)); + } + + if (zeroinit) { + var stop; + ptr = ret; + assert((ret & 3) == 0); + stop = ret + (size & ~3); + for (; ptr < stop; ptr += 4) { + HEAP32[((ptr)>>2)]=0; + } + stop = ret + size; + while (ptr < stop) { + HEAP8[((ptr++)>>0)]=0; + } + return ret; + } + + if (singleType === 'i8') { + if (slab.subarray || slab.slice) { + HEAPU8.set(/** @type {!Uint8Array} */ (slab), ret); + } else { + HEAPU8.set(new Uint8Array(slab), ret); + } + return ret; + } + + var i = 0, type, typeSize, previousType; + while (i < size) { + var curr = slab[i]; + + type = singleType || types[i]; + if (type === 0) { + i++; + continue; + } + assert(type, 'Must know what type to store in allocate!'); + + if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later + + setValue(ret+i, curr, type); + + // no need to look up size unless type changes, so cache it + if (previousType !== type) { + typeSize = getNativeTypeSize(type); + previousType = type; + } + i += typeSize; + } + + return ret; +} + +// Allocate memory during any stage of startup - static memory early on, dynamic memory later, malloc when ready +function getMemory(size) { + if (!runtimeInitialized) return dynamicAlloc(size); + return _malloc(size); +} + + + + +// runtime_strings.js: Strings related runtime functions that are part of both MINIMAL_RUNTIME and regular runtime. + +// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the given array that contains uint8 values, returns +// a copy of that string as a Javascript String object. + +var UTF8Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf8') : undefined; + +/** + * @param {number} idx + * @param {number=} maxBytesToRead + * @return {string} + */ +function UTF8ArrayToString(heap, idx, maxBytesToRead) { + var endIdx = idx + maxBytesToRead; + var endPtr = idx; + // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself. + // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage. + // (As a tiny code save trick, compare endPtr against endIdx using a negation, so that undefined means Infinity) + while (heap[endPtr] && !(endPtr >= endIdx)) ++endPtr; + + if (endPtr - idx > 16 && heap.subarray && UTF8Decoder) { + return UTF8Decoder.decode(heap.subarray(idx, endPtr)); + } else { + var str = ''; + // If building with TextDecoder, we have already computed the string length above, so test loop end condition against that + while (idx < endPtr) { + // For UTF8 byte structure, see: + // http://en.wikipedia.org/wiki/UTF-8#Description + // https://www.ietf.org/rfc/rfc2279.txt + // https://tools.ietf.org/html/rfc3629 + var u0 = heap[idx++]; + if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; } + var u1 = heap[idx++] & 63; + if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; } + var u2 = heap[idx++] & 63; + if ((u0 & 0xF0) == 0xE0) { + u0 = ((u0 & 15) << 12) | (u1 << 6) | u2; + } else { + if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte 0x' + u0.toString(16) + ' encountered when deserializing a UTF-8 string on the asm.js/wasm heap to a JS string!'); + u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heap[idx++] & 63); + } + + if (u0 < 0x10000) { + str += String.fromCharCode(u0); + } else { + var ch = u0 - 0x10000; + str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); + } + } + } + return str; +} + +// Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the emscripten HEAP, returns a +// copy of that string as a Javascript String object. +// maxBytesToRead: an optional length that specifies the maximum number of bytes to read. You can omit +// this parameter to scan the string until the first \0 byte. If maxBytesToRead is +// passed, and the string at [ptr, ptr+maxBytesToReadr[ contains a null byte in the +// middle, then the string will cut short at that byte index (i.e. maxBytesToRead will +// not produce a string of exact length [ptr, ptr+maxBytesToRead[) +// N.B. mixing frequent uses of UTF8ToString() with and without maxBytesToRead may +// throw JS JIT optimizations off, so it is worth to consider consistently using one +// style or the other. +/** + * @param {number} ptr + * @param {number=} maxBytesToRead + * @return {string} + */ +function UTF8ToString(ptr, maxBytesToRead) { + return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ''; +} + +// Copies the given Javascript String object 'str' to the given byte array at address 'outIdx', +// encoded in UTF8 form and null-terminated. The copy will require at most str.length*4+1 bytes of space in the HEAP. +// Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write. +// Parameters: +// str: the Javascript string to copy. +// heap: the array to copy to. Each index in this array is assumed to be one 8-byte element. +// outIdx: The starting offset in the array to begin the copying. +// maxBytesToWrite: The maximum number of bytes this function can write to the array. +// This count should include the null terminator, +// i.e. if maxBytesToWrite=1, only the null terminator will be written and nothing else. +// maxBytesToWrite=0 does not write any bytes to the output, not even the null terminator. +// Returns the number of bytes written, EXCLUDING the null terminator. + +function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { + if (!(maxBytesToWrite > 0)) // Parameter maxBytesToWrite is not optional. Negative values, 0, null, undefined and false each don't write out any bytes. + return 0; + + var startIdx = outIdx; + var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator. + for (var i = 0; i < str.length; ++i) { + // 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. + // See http://unicode.org/faq/utf_bom.html#utf16-3 + // 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 + var u = str.charCodeAt(i); // possibly a lead surrogate + if (u >= 0xD800 && u <= 0xDFFF) { + var u1 = str.charCodeAt(++i); + u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF); + } + if (u <= 0x7F) { + if (outIdx >= endIdx) break; + heap[outIdx++] = u; + } else if (u <= 0x7FF) { + if (outIdx + 1 >= endIdx) break; + heap[outIdx++] = 0xC0 | (u >> 6); + heap[outIdx++] = 0x80 | (u & 63); + } else if (u <= 0xFFFF) { + if (outIdx + 2 >= endIdx) break; + heap[outIdx++] = 0xE0 | (u >> 12); + heap[outIdx++] = 0x80 | ((u >> 6) & 63); + heap[outIdx++] = 0x80 | (u & 63); + } else { + if (outIdx + 3 >= endIdx) break; + if (u >= 0x200000) warnOnce('Invalid Unicode code point 0x' + u.toString(16) + ' encountered when serializing a JS string to an UTF-8 string on the asm.js/wasm heap! (Valid unicode code points should be in range 0-0x1FFFFF).'); + heap[outIdx++] = 0xF0 | (u >> 18); + heap[outIdx++] = 0x80 | ((u >> 12) & 63); + heap[outIdx++] = 0x80 | ((u >> 6) & 63); + heap[outIdx++] = 0x80 | (u & 63); + } + } + // Null-terminate the pointer to the buffer. + heap[outIdx] = 0; + return outIdx - startIdx; +} + +// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', +// null-terminated and encoded in UTF8 form. The copy will require at most str.length*4+1 bytes of space in the HEAP. +// Use the function lengthBytesUTF8 to compute the exact number of bytes (excluding null terminator) that this function will write. +// Returns the number of bytes written, EXCLUDING the null terminator. + +function stringToUTF8(str, outPtr, maxBytesToWrite) { + assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); + return stringToUTF8Array(str, HEAPU8,outPtr, maxBytesToWrite); +} + +// Returns the number of bytes the given Javascript string takes if encoded as a UTF8 byte array, EXCLUDING the null terminator byte. +function lengthBytesUTF8(str) { + var len = 0; + for (var i = 0; i < str.length; ++i) { + // 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. + // See http://unicode.org/faq/utf_bom.html#utf16-3 + var u = str.charCodeAt(i); // possibly a lead surrogate + if (u >= 0xD800 && u <= 0xDFFF) u = 0x10000 + ((u & 0x3FF) << 10) | (str.charCodeAt(++i) & 0x3FF); + if (u <= 0x7F) ++len; + else if (u <= 0x7FF) len += 2; + else if (u <= 0xFFFF) len += 3; + else len += 4; + } + return len; +} + + + + + +// runtime_strings_extra.js: Strings related runtime functions that are available only in regular runtime. + +// Given a pointer 'ptr' to a null-terminated ASCII-encoded string in the emscripten HEAP, returns +// a copy of that string as a Javascript String object. + +function AsciiToString(ptr) { + var str = ''; + while (1) { + var ch = HEAPU8[((ptr++)>>0)]; + if (!ch) return str; + str += String.fromCharCode(ch); + } +} + +// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', +// null-terminated and encoded in ASCII form. The copy will require at most str.length+1 bytes of space in the HEAP. + +function stringToAscii(str, outPtr) { + return writeAsciiToMemory(str, outPtr, false); +} + +// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns +// a copy of that string as a Javascript String object. + +var UTF16Decoder = typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-16le') : undefined; + +function UTF16ToString(ptr, maxBytesToRead) { + assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!'); + var endPtr = ptr; + // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself. + // Also, use the length info to avoid running tiny strings through TextDecoder, since .subarray() allocates garbage. + var idx = endPtr >> 1; + var maxIdx = idx + maxBytesToRead / 2; + // If maxBytesToRead is not passed explicitly, it will be undefined, and this + // will always evaluate to true. This saves on code size. + while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx; + endPtr = idx << 1; + + if (endPtr - ptr > 32 && UTF16Decoder) { + return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr)); + } else { + var i = 0; + + var str = ''; + while (1) { + var codeUnit = HEAP16[(((ptr)+(i*2))>>1)]; + if (codeUnit == 0 || i == maxBytesToRead / 2) return str; + ++i; + // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through. + str += String.fromCharCode(codeUnit); + } + } +} + +// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', +// null-terminated and encoded in UTF16 form. The copy will require at most str.length*4+2 bytes of space in the HEAP. +// Use the function lengthBytesUTF16() to compute the exact number of bytes (excluding null terminator) that this function will write. +// Parameters: +// str: the Javascript string to copy. +// outPtr: Byte address in Emscripten HEAP where to write the string to. +// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null +// terminator, i.e. if maxBytesToWrite=2, only the null terminator will be written and nothing else. +// maxBytesToWrite<2 does not write any bytes to the output, not even the null terminator. +// Returns the number of bytes written, EXCLUDING the null terminator. + +function stringToUTF16(str, outPtr, maxBytesToWrite) { + assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!'); + assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); + // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed. + if (maxBytesToWrite === undefined) { + maxBytesToWrite = 0x7FFFFFFF; + } + if (maxBytesToWrite < 2) return 0; + maxBytesToWrite -= 2; // Null terminator. + var startPtr = outPtr; + var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length; + for (var i = 0; i < numCharsToWrite; ++i) { + // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP. + var codeUnit = str.charCodeAt(i); // possibly a lead surrogate + HEAP16[((outPtr)>>1)]=codeUnit; + outPtr += 2; + } + // Null-terminate the pointer to the HEAP. + HEAP16[((outPtr)>>1)]=0; + return outPtr - startPtr; +} + +// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte. + +function lengthBytesUTF16(str) { + return str.length*2; +} + +function UTF32ToString(ptr, maxBytesToRead) { + assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!'); + var i = 0; + + var str = ''; + // If maxBytesToRead is not passed explicitly, it will be undefined, and this + // will always evaluate to true. This saves on code size. + while (!(i >= maxBytesToRead / 4)) { + var utf32 = HEAP32[(((ptr)+(i*4))>>2)]; + if (utf32 == 0) break; + ++i; + // 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. + // See http://unicode.org/faq/utf_bom.html#utf16-3 + if (utf32 >= 0x10000) { + var ch = utf32 - 0x10000; + str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF)); + } else { + str += String.fromCharCode(utf32); + } + } + return str; +} + +// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', +// null-terminated and encoded in UTF32 form. The copy will require at most str.length*4+4 bytes of space in the HEAP. +// Use the function lengthBytesUTF32() to compute the exact number of bytes (excluding null terminator) that this function will write. +// Parameters: +// str: the Javascript string to copy. +// outPtr: Byte address in Emscripten HEAP where to write the string to. +// maxBytesToWrite: The maximum number of bytes this function can write to the array. This count should include the null +// terminator, i.e. if maxBytesToWrite=4, only the null terminator will be written and nothing else. +// maxBytesToWrite<4 does not write any bytes to the output, not even the null terminator. +// Returns the number of bytes written, EXCLUDING the null terminator. + +function stringToUTF32(str, outPtr, maxBytesToWrite) { + assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!'); + assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); + // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed. + if (maxBytesToWrite === undefined) { + maxBytesToWrite = 0x7FFFFFFF; + } + if (maxBytesToWrite < 4) return 0; + var startPtr = outPtr; + var endPtr = startPtr + maxBytesToWrite - 4; + for (var i = 0; i < str.length; ++i) { + // 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. + // See http://unicode.org/faq/utf_bom.html#utf16-3 + var codeUnit = str.charCodeAt(i); // possibly a lead surrogate + if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) { + var trailSurrogate = str.charCodeAt(++i); + codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF); + } + HEAP32[((outPtr)>>2)]=codeUnit; + outPtr += 4; + if (outPtr + 4 > endPtr) break; + } + // Null-terminate the pointer to the HEAP. + HEAP32[((outPtr)>>2)]=0; + return outPtr - startPtr; +} + +// Returns the number of bytes the given Javascript string takes if encoded as a UTF16 byte array, EXCLUDING the null terminator byte. + +function lengthBytesUTF32(str) { + var len = 0; + for (var i = 0; i < str.length; ++i) { + // 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. + // See http://unicode.org/faq/utf_bom.html#utf16-3 + var codeUnit = str.charCodeAt(i); + if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate. + len += 4; + } + + return len; +} + +// Allocate heap space for a JS string, and write it there. +// It is the responsibility of the caller to free() that memory. +function allocateUTF8(str) { + var size = lengthBytesUTF8(str) + 1; + var ret = _malloc(size); + if (ret) stringToUTF8Array(str, HEAP8, ret, size); + return ret; +} + +// Allocate stack space for a JS string, and write it there. +function allocateUTF8OnStack(str) { + var size = lengthBytesUTF8(str) + 1; + var ret = stackAlloc(size); + stringToUTF8Array(str, HEAP8, ret, size); + return ret; +} + +// Deprecated: This function should not be called because it is unsafe and does not provide +// a maximum length limit of how many bytes it is allowed to write. Prefer calling the +// function stringToUTF8Array() instead, which takes in a maximum length that can be used +// to be secure from out of bounds writes. +/** @deprecated + @param {boolean=} dontAddNull */ +function writeStringToMemory(string, buffer, dontAddNull) { + warnOnce('writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!'); + + var /** @type {number} */ lastChar, /** @type {number} */ end; + if (dontAddNull) { + // stringToUTF8Array always appends null. If we don't want to do that, remember the + // character that existed at the location where the null will be placed, and restore + // that after the write (below). + end = buffer + lengthBytesUTF8(string); + lastChar = HEAP8[end]; + } + stringToUTF8(string, buffer, Infinity); + if (dontAddNull) HEAP8[end] = lastChar; // Restore the value under the null character. +} + +function writeArrayToMemory(array, buffer) { + assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)') + HEAP8.set(array, buffer); +} + +/** @param {boolean=} dontAddNull */ +function writeAsciiToMemory(str, buffer, dontAddNull) { + for (var i = 0; i < str.length; ++i) { + assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff); + HEAP8[((buffer++)>>0)]=str.charCodeAt(i); + } + // Null-terminate the pointer to the HEAP. + if (!dontAddNull) HEAP8[((buffer)>>0)]=0; +} + + + +// Memory management + +var PAGE_SIZE = 16384; +var WASM_PAGE_SIZE = 65536; +var ASMJS_PAGE_SIZE = 16777216; + +function alignUp(x, multiple) { + if (x % multiple > 0) { + x += multiple - (x % multiple); + } + return x; +} + +var HEAP, +/** @type {ArrayBuffer} */ + buffer, +/** @type {Int8Array} */ + HEAP8, +/** @type {Uint8Array} */ + HEAPU8, +/** @type {Int16Array} */ + HEAP16, +/** @type {Uint16Array} */ + HEAPU16, +/** @type {Int32Array} */ + HEAP32, +/** @type {Uint32Array} */ + HEAPU32, +/** @type {Float32Array} */ + HEAPF32, +/** @type {Float64Array} */ + HEAPF64; + +function updateGlobalBufferAndViews(buf) { + buffer = buf; + Module['HEAP8'] = HEAP8 = new Int8Array(buf); + Module['HEAP16'] = HEAP16 = new Int16Array(buf); + Module['HEAP32'] = HEAP32 = new Int32Array(buf); + Module['HEAPU8'] = HEAPU8 = new Uint8Array(buf); + Module['HEAPU16'] = HEAPU16 = new Uint16Array(buf); + Module['HEAPU32'] = HEAPU32 = new Uint32Array(buf); + Module['HEAPF32'] = HEAPF32 = new Float32Array(buf); + Module['HEAPF64'] = HEAPF64 = new Float64Array(buf); +} + +var STATIC_BASE = 1024, + STACK_BASE = 5270048, + STACKTOP = STACK_BASE, + STACK_MAX = 27168, + DYNAMIC_BASE = 5270048, + DYNAMICTOP_PTR = 27008; + +assert(STACK_BASE % 16 === 0, 'stack must start aligned'); +assert(DYNAMIC_BASE % 16 === 0, 'heap must start aligned'); + + +var TOTAL_STACK = 5242880; +if (Module['TOTAL_STACK']) assert(TOTAL_STACK === Module['TOTAL_STACK'], 'the stack size can no longer be determined at runtime') + +var INITIAL_INITIAL_MEMORY = Module['INITIAL_MEMORY'] || 16777216;if (!Object.getOwnPropertyDescriptor(Module, 'INITIAL_MEMORY')) Object.defineProperty(Module, 'INITIAL_MEMORY', { configurable: true, get: function() { abort('Module.INITIAL_MEMORY has been replaced with plain INITIAL_INITIAL_MEMORY (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)') } }); + +assert(INITIAL_INITIAL_MEMORY >= TOTAL_STACK, 'INITIAL_MEMORY should be larger than TOTAL_STACK, was ' + INITIAL_INITIAL_MEMORY + '! (TOTAL_STACK=' + TOTAL_STACK + ')'); + +// check for full engine support (use string 'subarray' to avoid closure compiler confusion) +assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray !== undefined && Int32Array.prototype.set !== undefined, + 'JS engine does not provide full typed array support'); + + + + + + + + +// In non-standalone/normal mode, we create the memory here. + + + +// Create the main memory. (Note: this isn't used in STANDALONE_WASM mode since the wasm +// memory is created in the wasm, not in JS.) + + if (Module['wasmMemory']) { + wasmMemory = Module['wasmMemory']; + } else + { + wasmMemory = new WebAssembly.Memory({ + 'initial': INITIAL_INITIAL_MEMORY / WASM_PAGE_SIZE + , + 'maximum': INITIAL_INITIAL_MEMORY / WASM_PAGE_SIZE + }); + } + + +if (wasmMemory) { + buffer = wasmMemory.buffer; +} + +// If the user provides an incorrect length, just use that length instead rather than providing the user to +// specifically provide the memory length with Module['INITIAL_MEMORY']. +INITIAL_INITIAL_MEMORY = buffer.byteLength; +assert(INITIAL_INITIAL_MEMORY % WASM_PAGE_SIZE === 0); +updateGlobalBufferAndViews(buffer); + +HEAP32[DYNAMICTOP_PTR>>2] = DYNAMIC_BASE; + + + + + + +// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. +function writeStackCookie() { + assert((STACK_MAX & 3) == 0); + // The stack grows downwards + HEAPU32[(STACK_MAX >> 2)+1] = 0x2135467; + HEAPU32[(STACK_MAX >> 2)+2] = 0x89BACDFE; + // Also test the global address 0 for integrity. + // We don't do this with ASan because ASan does its own checks for this. + HEAP32[0] = 0x63736d65; /* 'emsc' */ +} + +function checkStackCookie() { + var cookie1 = HEAPU32[(STACK_MAX >> 2)+1]; + var cookie2 = HEAPU32[(STACK_MAX >> 2)+2]; + if (cookie1 != 0x2135467 || cookie2 != 0x89BACDFE) { + abort('Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x' + cookie2.toString(16) + ' ' + cookie1.toString(16)); + } + // Also test the global address 0 for integrity. + // We don't do this with ASan because ASan does its own checks for this. + if (HEAP32[0] !== 0x63736d65 /* 'emsc' */) abort('Runtime error: The application has corrupted its heap memory area (address zero)!'); +} + + + + + +// Endianness check (note: assumes compiler arch was little-endian) +(function() { + var h16 = new Int16Array(1); + var h8 = new Int8Array(h16.buffer); + h16[0] = 0x6373; + if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian!'; +})(); + +function abortFnPtrError(ptr, sig) { + abort("Invalid function pointer " + ptr + " called with signature '" + sig + "'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this). Build with ASSERTIONS=2 for more info."); +} + + + +function callRuntimeCallbacks(callbacks) { + while(callbacks.length > 0) { + var callback = callbacks.shift(); + if (typeof callback == 'function') { + callback(Module); // Pass the module as the first argument. + continue; + } + var func = callback.func; + if (typeof func === 'number') { + if (callback.arg === undefined) { + Module['dynCall_v'](func); + } else { + Module['dynCall_vi'](func, callback.arg); + } + } else { + func(callback.arg === undefined ? null : callback.arg); + } + } +} + +var __ATPRERUN__ = []; // functions called before the runtime is initialized +var __ATINIT__ = []; // functions called during startup +var __ATMAIN__ = []; // functions called when main() is to be run +var __ATEXIT__ = []; // functions called during shutdown +var __ATPOSTRUN__ = []; // functions called after the main() is called + +var runtimeInitialized = false; +var runtimeExited = false; + + +function preRun() { + + if (Module['preRun']) { + if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']]; + while (Module['preRun'].length) { + addOnPreRun(Module['preRun'].shift()); + } + } + + callRuntimeCallbacks(__ATPRERUN__); +} + +function initRuntime() { + checkStackCookie(); + assert(!runtimeInitialized); + runtimeInitialized = true; + if (!Module["noFSInit"] && !FS.init.initialized) FS.init(); +TTY.init(); + callRuntimeCallbacks(__ATINIT__); +} + +function preMain() { + checkStackCookie(); + FS.ignorePermissions = false; + callRuntimeCallbacks(__ATMAIN__); +} + +function exitRuntime() { + checkStackCookie(); + runtimeExited = true; +} + +function postRun() { + checkStackCookie(); + + if (Module['postRun']) { + if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']]; + while (Module['postRun'].length) { + addOnPostRun(Module['postRun'].shift()); + } + } + + callRuntimeCallbacks(__ATPOSTRUN__); +} + +function addOnPreRun(cb) { + __ATPRERUN__.unshift(cb); +} + +function addOnInit(cb) { + __ATINIT__.unshift(cb); +} + +function addOnPreMain(cb) { + __ATMAIN__.unshift(cb); +} + +function addOnExit(cb) { +} + +function addOnPostRun(cb) { + __ATPOSTRUN__.unshift(cb); +} + +/** @param {number|boolean=} ignore */ +function unSign(value, bits, ignore) { + if (value >= 0) { + return value; + } + return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts + : Math.pow(2, bits) + value; +} +/** @param {number|boolean=} ignore */ +function reSign(value, bits, ignore) { + if (value <= 0) { + return value; + } + var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32 + : Math.pow(2, bits-1); + if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that + // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors + // TODO: In i64 mode 1, resign the two parts separately and safely + value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts + } + return value; +} + + + + +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul + +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround + +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 + +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc + +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'); +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'); +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'); +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'); + +var Math_abs = Math.abs; +var Math_cos = Math.cos; +var Math_sin = Math.sin; +var Math_tan = Math.tan; +var Math_acos = Math.acos; +var Math_asin = Math.asin; +var Math_atan = Math.atan; +var Math_atan2 = Math.atan2; +var Math_exp = Math.exp; +var Math_log = Math.log; +var Math_sqrt = Math.sqrt; +var Math_ceil = Math.ceil; +var Math_floor = Math.floor; +var Math_pow = Math.pow; +var Math_imul = Math.imul; +var Math_fround = Math.fround; +var Math_round = Math.round; +var Math_min = Math.min; +var Math_max = Math.max; +var Math_clz32 = Math.clz32; +var Math_trunc = Math.trunc; + + + +// A counter of dependencies for calling run(). If we need to +// do asynchronous work before running, increment this and +// decrement it. Incrementing must happen in a place like +// Module.preRun (used by emcc to add file preloading). +// Note that you can add dependencies in preRun, even though +// it happens right before run - run will be postponed until +// the dependencies are met. +var runDependencies = 0; +var runDependencyWatcher = null; +var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled +var runDependencyTracking = {}; + +function getUniqueRunDependency(id) { + var orig = id; + while (1) { + if (!runDependencyTracking[id]) return id; + id = orig + Math.random(); + } +} + +function addRunDependency(id) { + runDependencies++; + + if (Module['monitorRunDependencies']) { + Module['monitorRunDependencies'](runDependencies); + } + + if (id) { + assert(!runDependencyTracking[id]); + runDependencyTracking[id] = 1; + if (runDependencyWatcher === null && typeof setInterval !== 'undefined') { + // Check for missing dependencies every few seconds + runDependencyWatcher = setInterval(function() { + if (ABORT) { + clearInterval(runDependencyWatcher); + runDependencyWatcher = null; + return; + } + var shown = false; + for (var dep in runDependencyTracking) { + if (!shown) { + shown = true; + err('still waiting on run dependencies:'); + } + err('dependency: ' + dep); + } + if (shown) { + err('(end of list)'); + } + }, 10000); + } + } else { + err('warning: run dependency added without ID'); + } +} + +function removeRunDependency(id) { + runDependencies--; + + if (Module['monitorRunDependencies']) { + Module['monitorRunDependencies'](runDependencies); + } + + if (id) { + assert(runDependencyTracking[id]); + delete runDependencyTracking[id]; + } else { + err('warning: run dependency removed without ID'); + } + if (runDependencies == 0) { + if (runDependencyWatcher !== null) { + clearInterval(runDependencyWatcher); + runDependencyWatcher = null; + } + if (dependenciesFulfilled) { + var callback = dependenciesFulfilled; + dependenciesFulfilled = null; + callback(); // can add another dependenciesFulfilled + } + } +} + +Module["preloadedImages"] = {}; // maps url to image data +Module["preloadedAudios"] = {}; // maps url to audio data + +/** @param {string|number=} what */ +function abort(what) { + if (Module['onAbort']) { + Module['onAbort'](what); + } + + what += ''; + out(what); + err(what); + + ABORT = true; + EXITSTATUS = 1; + + var output = 'abort(' + what + ') at ' + stackTrace(); + what = output; + + // Throw a wasm runtime error, because a JS error might be seen as a foreign + // exception, which means we'd run destructors on it. We need the error to + // simply make the program stop. + throw new WebAssembly.RuntimeError(what); +} + + +var memoryInitializer = null; + + + + + + + + + + + + +function hasPrefix(str, prefix) { + return String.prototype.startsWith ? + str.startsWith(prefix) : + str.indexOf(prefix) === 0; +} + +// Prefix of data URIs emitted by SINGLE_FILE and related options. +var dataURIPrefix = 'data:application/octet-stream;base64,'; + +// Indicates whether filename is a base64 data URI. +function isDataURI(filename) { + return hasPrefix(filename, dataURIPrefix); +} + +var fileURIPrefix = "file://"; + +// Indicates whether filename is delivered via file protocol (as opposed to http/https) +function isFileURI(filename) { + return hasPrefix(filename, fileURIPrefix); +} + + + +function createExportWrapper(name, fixedasm) { + return function() { + var displayName = name; + var asm = fixedasm; + if (!fixedasm) { + asm = Module['asm']; + } + assert(runtimeInitialized, 'native function `' + displayName + '` called before runtime initialization'); + assert(!runtimeExited, 'native function `' + displayName + '` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)'); + if (!asm[name]) { + assert(asm[name], 'exported native function `' + displayName + '` not found'); + } + return asm[name].apply(null, arguments); + }; +} + +var wasmBinaryFile = 'merlin32.wasm'; +if (!isDataURI(wasmBinaryFile)) { + wasmBinaryFile = locateFile(wasmBinaryFile); +} + +function getBinary() { + try { + if (wasmBinary) { + return new Uint8Array(wasmBinary); + } + + if (readBinary) { + return readBinary(wasmBinaryFile); + } else { + throw "both async and sync fetching of the wasm failed"; + } + } + catch (err) { + abort(err); + } +} + +function getBinaryPromise() { + // If we don't have the binary yet, and have the Fetch api, use that; + // in some environments, like Electron's render process, Fetch api may be present, but have a different context than expected, let's only use it on the Web + if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) && typeof fetch === 'function' + // Let's not use fetch to get objects over file:// as it's most likely Cordova which doesn't support fetch for file:// + && !isFileURI(wasmBinaryFile) + ) { + return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function(response) { + if (!response['ok']) { + throw "failed to load wasm binary file at '" + wasmBinaryFile + "'"; + } + return response['arrayBuffer'](); + }).catch(function () { + return getBinary(); + }); + } + // Otherwise, getBinary should be able to get it synchronously + return new Promise(function(resolve, reject) { + resolve(getBinary()); + }); +} + + + +// Create the wasm instance. +// Receives the wasm imports, returns the exports. +function createWasm() { + // prepare imports + var info = { + 'env': asmLibraryArg, + 'wasi_snapshot_preview1': asmLibraryArg + }; + // Load the wasm module and create an instance of using native support in the JS engine. + // handle a generated wasm instance, receiving its exports and + // performing other necessary setup + /** @param {WebAssembly.Module=} module*/ + function receiveInstance(instance, module) { + var exports = instance.exports; + Module['asm'] = exports; + removeRunDependency('wasm-instantiate'); + } + // we can't run yet (except in a pthread, where we have a custom sync instantiator) + addRunDependency('wasm-instantiate'); + + + // Async compilation can be confusing when an error on the page overwrites Module + // (for example, if the order of elements is wrong, and the one defining Module is + // later), so we save Module and check it later. + var trueModule = Module; + function receiveInstantiatedSource(output) { + // 'output' is a WebAssemblyInstantiatedSource object which has both the module and instance. + // receiveInstance() will swap in the exports (to Module.asm) so they can be called + assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?'); + trueModule = null; + // 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. + // When the regression is fixed, can restore the above USE_PTHREADS-enabled path. + receiveInstance(output['instance']); + } + + + function instantiateArrayBuffer(receiver) { + return getBinaryPromise().then(function(binary) { + return WebAssembly.instantiate(binary, info); + }).then(receiver, function(reason) { + err('failed to asynchronously prepare wasm: ' + reason); + abort(reason); + }); + } + + // Prefer streaming instantiation if available. + function instantiateAsync() { + if (!wasmBinary && + typeof WebAssembly.instantiateStreaming === 'function' && + !isDataURI(wasmBinaryFile) && + // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously. + !isFileURI(wasmBinaryFile) && + typeof fetch === 'function') { + fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(function (response) { + var result = WebAssembly.instantiateStreaming(response, info); + return result.then(receiveInstantiatedSource, function(reason) { + // We expect the most common failure cause to be a bad MIME type for the binary, + // in which case falling back to ArrayBuffer instantiation should work. + err('wasm streaming compile failed: ' + reason); + err('falling back to ArrayBuffer instantiation'); + return instantiateArrayBuffer(receiveInstantiatedSource); + }); + }); + } else { + return instantiateArrayBuffer(receiveInstantiatedSource); + } + } + // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback + // to manually instantiate the Wasm module themselves. This allows pages to run the instantiation parallel + // to any other async startup actions they are performing. + if (Module['instantiateWasm']) { + try { + var exports = Module['instantiateWasm'](info, receiveInstance); + return exports; + } catch(e) { + err('Module.instantiateWasm callback failed with error: ' + e); + return false; + } + } + + instantiateAsync(); + return {}; // no exports yet; we'll fill them in later +} + + +// Globals used by JS i64 conversions +var tempDouble; +var tempI64; + +// === Body === + +var ASM_CONSTS = { + +}; + + + + +// STATICTOP = STATIC_BASE + 26144; +/* global initializers */ __ATINIT__.push({ func: function() { ___wasm_call_ctors() } }); + + + + +/* no memory initializer */ +// {{PRE_LIBRARY}} + + + function abortStackOverflow(allocSize) { + abort('Stack overflow! Attempted to allocate ' + allocSize + ' bytes on the stack, but stack has only ' + (STACK_MAX - stackSave() + allocSize) + ' bytes available!'); + } + + function demangle(func) { + warnOnce('warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling'); + return func; + } + + function demangleAll(text) { + var regex = + /\b_Z[\w\d_]+/g; + return text.replace(regex, + function(x) { + var y = demangle(x); + return x === y ? x : (y + ' [' + x + ']'); + }); + } + + function jsStackTrace() { + var err = new Error(); + if (!err.stack) { + // IE10+ special cases: It does have callstack info, but it is only populated if an Error object is thrown, + // so try that as a special-case. + try { + throw new Error(); + } catch(e) { + err = e; + } + if (!err.stack) { + return '(no stack trace available)'; + } + } + return err.stack.toString(); + } + + function stackTrace() { + var js = jsStackTrace(); + if (Module['extraStackTrace']) js += '\n' + Module['extraStackTrace'](); + return demangleAll(js); + } + + function ___handle_stack_overflow() { + abort('stack overflow') + } + + + function setErrNo(value) { + HEAP32[((___errno_location())>>2)]=value; + return value; + } + + + var PATH={splitPath:function(filename) { + var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; + return splitPathRe.exec(filename).slice(1); + },normalizeArray:function(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length - 1; i >= 0; i--) { + var last = parts[i]; + if (last === '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up; up--) { + parts.unshift('..'); + } + } + return parts; + },normalize:function(path) { + var isAbsolute = path.charAt(0) === '/', + trailingSlash = path.substr(-1) === '/'; + // Normalize the path + path = PATH.normalizeArray(path.split('/').filter(function(p) { + return !!p; + }), !isAbsolute).join('/'); + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + return (isAbsolute ? '/' : '') + path; + },dirname:function(path) { + var result = PATH.splitPath(path), + root = result[0], + dir = result[1]; + if (!root && !dir) { + // No dirname whatsoever + return '.'; + } + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1); + } + return root + dir; + },basename:function(path) { + // EMSCRIPTEN return '/'' for '/', not an empty string + if (path === '/') return '/'; + var lastSlash = path.lastIndexOf('/'); + if (lastSlash === -1) return path; + return path.substr(lastSlash+1); + },extname:function(path) { + return PATH.splitPath(path)[3]; + },join:function() { + var paths = Array.prototype.slice.call(arguments, 0); + return PATH.normalize(paths.join('/')); + },join2:function(l, r) { + return PATH.normalize(l + '/' + r); + }}; + + + var PATH_FS={resolve:function() { + var resolvedPath = '', + resolvedAbsolute = false; + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) ? arguments[i] : FS.cwd(); + // Skip empty and invalid entries + if (typeof path !== 'string') { + throw new TypeError('Arguments to path.resolve must be strings'); + } else if (!path) { + return ''; // an invalid portion invalidates the whole thing + } + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charAt(0) === '/'; + } + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; + },relative:function(from, to) { + from = PATH_FS.resolve(from).substr(1); + to = PATH_FS.resolve(to).substr(1); + function trim(arr) { + var start = 0; + for (; start < arr.length; start++) { + if (arr[start] !== '') break; + } + var end = arr.length - 1; + for (; end >= 0; end--) { + if (arr[end] !== '') break; + } + if (start > end) return []; + return arr.slice(start, end - start + 1); + } + var fromParts = trim(from.split('/')); + var toParts = trim(to.split('/')); + var length = Math.min(fromParts.length, toParts.length); + var samePartsLength = length; + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i; + break; + } + } + var outputParts = []; + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..'); + } + outputParts = outputParts.concat(toParts.slice(samePartsLength)); + return outputParts.join('/'); + }}; + + var TTY={ttys:[],init:function () { + // https://github.com/emscripten-core/emscripten/pull/1555 + // if (ENVIRONMENT_IS_NODE) { + // // currently, FS.init does not distinguish if process.stdin is a file or TTY + // // device, it always assumes it's a TTY device. because of this, we're forcing + // // process.stdin to UTF8 encoding to at least make stdin reading compatible + // // with text files until FS.init can be refactored. + // process['stdin']['setEncoding']('utf8'); + // } + },shutdown:function() { + // https://github.com/emscripten-core/emscripten/pull/1555 + // if (ENVIRONMENT_IS_NODE) { + // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)? + // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation + // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists? + // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle + // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call + // process['stdin']['pause'](); + // } + },register:function(dev, ops) { + TTY.ttys[dev] = { input: [], output: [], ops: ops }; + FS.registerDevice(dev, TTY.stream_ops); + },stream_ops:{open:function(stream) { + var tty = TTY.ttys[stream.node.rdev]; + if (!tty) { + throw new FS.ErrnoError(43); + } + stream.tty = tty; + stream.seekable = false; + },close:function(stream) { + // flush any pending line data + stream.tty.ops.flush(stream.tty); + },flush:function(stream) { + stream.tty.ops.flush(stream.tty); + },read:function(stream, buffer, offset, length, pos /* ignored */) { + if (!stream.tty || !stream.tty.ops.get_char) { + throw new FS.ErrnoError(60); + } + var bytesRead = 0; + for (var i = 0; i < length; i++) { + var result; + try { + result = stream.tty.ops.get_char(stream.tty); + } catch (e) { + throw new FS.ErrnoError(29); + } + if (result === undefined && bytesRead === 0) { + throw new FS.ErrnoError(6); + } + if (result === null || result === undefined) break; + bytesRead++; + buffer[offset+i] = result; + } + if (bytesRead) { + stream.node.timestamp = Date.now(); + } + return bytesRead; + },write:function(stream, buffer, offset, length, pos) { + if (!stream.tty || !stream.tty.ops.put_char) { + throw new FS.ErrnoError(60); + } + try { + for (var i = 0; i < length; i++) { + stream.tty.ops.put_char(stream.tty, buffer[offset+i]); + } + } catch (e) { + throw new FS.ErrnoError(29); + } + if (length) { + stream.node.timestamp = Date.now(); + } + return i; + }},default_tty_ops:{get_char:function(tty) { + if (!tty.input.length) { + var result = null; + if (ENVIRONMENT_IS_NODE) { + // we will read data by chunks of BUFSIZE + var BUFSIZE = 256; + var buf = Buffer.alloc ? Buffer.alloc(BUFSIZE) : new Buffer(BUFSIZE); + var bytesRead = 0; + + try { + bytesRead = nodeFS.readSync(process.stdin.fd, buf, 0, BUFSIZE, null); + } catch(e) { + // Cross-platform differences: on Windows, reading EOF throws an exception, but on other OSes, + // reading EOF returns 0. Uniformize behavior by treating the EOF exception to return 0. + if (e.toString().indexOf('EOF') != -1) bytesRead = 0; + else throw e; + } + + if (bytesRead > 0) { + result = buf.slice(0, bytesRead).toString('utf-8'); + } else { + result = null; + } + } else + if (typeof window != 'undefined' && + typeof window.prompt == 'function') { + // Browser. + result = window.prompt('Input: '); // returns null on cancel + if (result !== null) { + result += '\n'; + } + } else if (typeof readline == 'function') { + // Command line. + result = readline(); + if (result !== null) { + result += '\n'; + } + } + if (!result) { + return null; + } + tty.input = intArrayFromString(result, true); + } + return tty.input.shift(); + },put_char:function(tty, val) { + if (val === null || val === 10) { + out(UTF8ArrayToString(tty.output, 0)); + tty.output = []; + } else { + if (val != 0) tty.output.push(val); // val == 0 would cut text output off in the middle. + } + },flush:function(tty) { + if (tty.output && tty.output.length > 0) { + out(UTF8ArrayToString(tty.output, 0)); + tty.output = []; + } + }},default_tty1_ops:{put_char:function(tty, val) { + if (val === null || val === 10) { + err(UTF8ArrayToString(tty.output, 0)); + tty.output = []; + } else { + if (val != 0) tty.output.push(val); + } + },flush:function(tty) { + if (tty.output && tty.output.length > 0) { + err(UTF8ArrayToString(tty.output, 0)); + tty.output = []; + } + }}}; + + var MEMFS={ops_table:null,mount:function(mount) { + return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0); + },createNode:function(parent, name, mode, dev) { + if (FS.isBlkdev(mode) || FS.isFIFO(mode)) { + // no supported + throw new FS.ErrnoError(63); + } + if (!MEMFS.ops_table) { + MEMFS.ops_table = { + dir: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr, + lookup: MEMFS.node_ops.lookup, + mknod: MEMFS.node_ops.mknod, + rename: MEMFS.node_ops.rename, + unlink: MEMFS.node_ops.unlink, + rmdir: MEMFS.node_ops.rmdir, + readdir: MEMFS.node_ops.readdir, + symlink: MEMFS.node_ops.symlink + }, + stream: { + llseek: MEMFS.stream_ops.llseek + } + }, + file: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr + }, + stream: { + llseek: MEMFS.stream_ops.llseek, + read: MEMFS.stream_ops.read, + write: MEMFS.stream_ops.write, + allocate: MEMFS.stream_ops.allocate, + mmap: MEMFS.stream_ops.mmap, + msync: MEMFS.stream_ops.msync + } + }, + link: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr, + readlink: MEMFS.node_ops.readlink + }, + stream: {} + }, + chrdev: { + node: { + getattr: MEMFS.node_ops.getattr, + setattr: MEMFS.node_ops.setattr + }, + stream: FS.chrdev_stream_ops + } + }; + } + var node = FS.createNode(parent, name, mode, dev); + if (FS.isDir(node.mode)) { + node.node_ops = MEMFS.ops_table.dir.node; + node.stream_ops = MEMFS.ops_table.dir.stream; + node.contents = {}; + } else if (FS.isFile(node.mode)) { + node.node_ops = MEMFS.ops_table.file.node; + node.stream_ops = MEMFS.ops_table.file.stream; + node.usedBytes = 0; // The actual number of bytes used in the typed array, as opposed to contents.length which gives the whole capacity. + // When the byte data of the file is populated, this will point to either a typed array, or a normal JS array. Typed arrays are preferred + // for performance, and used by default. However, typed arrays are not resizable like normal JS arrays are, so there is a small disk size + // penalty involved for appending file writes that continuously grow a file similar to std::vector capacity vs used -scheme. + node.contents = null; + } else if (FS.isLink(node.mode)) { + node.node_ops = MEMFS.ops_table.link.node; + node.stream_ops = MEMFS.ops_table.link.stream; + } else if (FS.isChrdev(node.mode)) { + node.node_ops = MEMFS.ops_table.chrdev.node; + node.stream_ops = MEMFS.ops_table.chrdev.stream; + } + node.timestamp = Date.now(); + // add the new node to the parent + if (parent) { + parent.contents[name] = node; + } + return node; + },getFileDataAsRegularArray:function(node) { + if (node.contents && node.contents.subarray) { + var arr = []; + for (var i = 0; i < node.usedBytes; ++i) arr.push(node.contents[i]); + return arr; // Returns a copy of the original data. + } + return node.contents; // No-op, the file contents are already in a JS array. Return as-is. + },getFileDataAsTypedArray:function(node) { + if (!node.contents) return new Uint8Array(0); + if (node.contents.subarray) return node.contents.subarray(0, node.usedBytes); // Make sure to not return excess unused bytes. + return new Uint8Array(node.contents); + },expandFileStorage:function(node, newCapacity) { + var prevCapacity = node.contents ? node.contents.length : 0; + if (prevCapacity >= newCapacity) return; // No need to expand, the storage was already large enough. + // Don't expand strictly to the given requested limit if it's only a very small increase, but instead geometrically grow capacity. + // For small filesizes (<1MB), perform size*2 geometric increase, but for large sizes, do a much more conservative size*1.125 increase to + // avoid overshooting the allocation cap by a very large margin. + var CAPACITY_DOUBLING_MAX = 1024 * 1024; + newCapacity = Math.max(newCapacity, (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2.0 : 1.125)) >>> 0); + if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256); // At minimum allocate 256b for each file when expanding. + var oldContents = node.contents; + node.contents = new Uint8Array(newCapacity); // Allocate new storage. + if (node.usedBytes > 0) node.contents.set(oldContents.subarray(0, node.usedBytes), 0); // Copy old data over to the new storage. + return; + },resizeFileStorage:function(node, newSize) { + if (node.usedBytes == newSize) return; + if (newSize == 0) { + node.contents = null; // Fully decommit when requesting a resize to zero. + node.usedBytes = 0; + return; + } + if (!node.contents || node.contents.subarray) { // Resize a typed array if that is being used as the backing store. + var oldContents = node.contents; + node.contents = new Uint8Array(newSize); // Allocate new storage. + if (oldContents) { + node.contents.set(oldContents.subarray(0, Math.min(newSize, node.usedBytes))); // Copy old data over to the new storage. + } + node.usedBytes = newSize; + return; + } + // Backing with a JS array. + if (!node.contents) node.contents = []; + if (node.contents.length > newSize) node.contents.length = newSize; + else while (node.contents.length < newSize) node.contents.push(0); + node.usedBytes = newSize; + },node_ops:{getattr:function(node) { + var attr = {}; + // device numbers reuse inode numbers. + attr.dev = FS.isChrdev(node.mode) ? node.id : 1; + attr.ino = node.id; + attr.mode = node.mode; + attr.nlink = 1; + attr.uid = 0; + attr.gid = 0; + attr.rdev = node.rdev; + if (FS.isDir(node.mode)) { + attr.size = 4096; + } else if (FS.isFile(node.mode)) { + attr.size = node.usedBytes; + } else if (FS.isLink(node.mode)) { + attr.size = node.link.length; + } else { + attr.size = 0; + } + attr.atime = new Date(node.timestamp); + attr.mtime = new Date(node.timestamp); + attr.ctime = new Date(node.timestamp); + // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize), + // but this is not required by the standard. + attr.blksize = 4096; + attr.blocks = Math.ceil(attr.size / attr.blksize); + return attr; + },setattr:function(node, attr) { + if (attr.mode !== undefined) { + node.mode = attr.mode; + } + if (attr.timestamp !== undefined) { + node.timestamp = attr.timestamp; + } + if (attr.size !== undefined) { + MEMFS.resizeFileStorage(node, attr.size); + } + },lookup:function(parent, name) { + throw FS.genericErrors[44]; + },mknod:function(parent, name, mode, dev) { + return MEMFS.createNode(parent, name, mode, dev); + },rename:function(old_node, new_dir, new_name) { + // if we're overwriting a directory at new_name, make sure it's empty. + if (FS.isDir(old_node.mode)) { + var new_node; + try { + new_node = FS.lookupNode(new_dir, new_name); + } catch (e) { + } + if (new_node) { + for (var i in new_node.contents) { + throw new FS.ErrnoError(55); + } + } + } + // do the internal rewiring + delete old_node.parent.contents[old_node.name]; + old_node.name = new_name; + new_dir.contents[new_name] = old_node; + old_node.parent = new_dir; + },unlink:function(parent, name) { + delete parent.contents[name]; + },rmdir:function(parent, name) { + var node = FS.lookupNode(parent, name); + for (var i in node.contents) { + throw new FS.ErrnoError(55); + } + delete parent.contents[name]; + },readdir:function(node) { + var entries = ['.', '..']; + for (var key in node.contents) { + if (!node.contents.hasOwnProperty(key)) { + continue; + } + entries.push(key); + } + return entries; + },symlink:function(parent, newname, oldpath) { + var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0); + node.link = oldpath; + return node; + },readlink:function(node) { + if (!FS.isLink(node.mode)) { + throw new FS.ErrnoError(28); + } + return node.link; + }},stream_ops:{read:function(stream, buffer, offset, length, position) { + var contents = stream.node.contents; + if (position >= stream.node.usedBytes) return 0; + var size = Math.min(stream.node.usedBytes - position, length); + assert(size >= 0); + if (size > 8 && contents.subarray) { // non-trivial, and typed array + buffer.set(contents.subarray(position, position + size), offset); + } else { + for (var i = 0; i < size; i++) buffer[offset + i] = contents[position + i]; + } + return size; + },write:function(stream, buffer, offset, length, position, canOwn) { + // The data buffer should be a typed array view + assert(!(buffer instanceof ArrayBuffer)); + + if (!length) return 0; + var node = stream.node; + node.timestamp = Date.now(); + + if (buffer.subarray && (!node.contents || node.contents.subarray)) { // This write is from a typed array to a typed array? + if (canOwn) { + assert(position === 0, 'canOwn must imply no weird position inside the file'); + node.contents = buffer.subarray(offset, offset + length); + node.usedBytes = length; + return length; + } else if (node.usedBytes === 0 && position === 0) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data. + node.contents = buffer.slice(offset, offset + length); + node.usedBytes = length; + return length; + } else if (position + length <= node.usedBytes) { // Writing to an already allocated and used subrange of the file? + node.contents.set(buffer.subarray(offset, offset + length), position); + return length; + } + } + + // Appending to an existing file and we need to reallocate, or source data did not come as a typed array. + MEMFS.expandFileStorage(node, position+length); + if (node.contents.subarray && buffer.subarray) node.contents.set(buffer.subarray(offset, offset + length), position); // Use typed array write if available. + else { + for (var i = 0; i < length; i++) { + node.contents[position + i] = buffer[offset + i]; // Or fall back to manual write if not. + } + } + node.usedBytes = Math.max(node.usedBytes, position + length); + return length; + },llseek:function(stream, offset, whence) { + var position = offset; + if (whence === 1) { + position += stream.position; + } else if (whence === 2) { + if (FS.isFile(stream.node.mode)) { + position += stream.node.usedBytes; + } + } + if (position < 0) { + throw new FS.ErrnoError(28); + } + return position; + },allocate:function(stream, offset, length) { + MEMFS.expandFileStorage(stream.node, offset + length); + stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length); + },mmap:function(stream, address, length, position, prot, flags) { + // We don't currently support location hints for the address of the mapping + assert(address === 0); + + if (!FS.isFile(stream.node.mode)) { + throw new FS.ErrnoError(43); + } + var ptr; + var allocated; + var contents = stream.node.contents; + // Only make a new copy when MAP_PRIVATE is specified. + if (!(flags & 2) && contents.buffer === buffer) { + // We can't emulate MAP_SHARED when the file is not backed by the buffer + // we're mapping to (e.g. the HEAP buffer). + allocated = false; + ptr = contents.byteOffset; + } else { + // Try to avoid unnecessary slices. + if (position > 0 || position + length < contents.length) { + if (contents.subarray) { + contents = contents.subarray(position, position + length); + } else { + contents = Array.prototype.slice.call(contents, position, position + length); + } + } + allocated = true; + ptr = _malloc(length); + if (!ptr) { + throw new FS.ErrnoError(48); + } + HEAP8.set(contents, ptr); + } + return { ptr: ptr, allocated: allocated }; + },msync:function(stream, buffer, offset, length, mmapFlags) { + if (!FS.isFile(stream.node.mode)) { + throw new FS.ErrnoError(43); + } + if (mmapFlags & 2) { + // MAP_PRIVATE calls need not to be synced back to underlying fs + return 0; + } + + var bytesWritten = MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false); + // should we check if bytesWritten and length are the same? + return 0; + }}}; + + var WORKERFS={DIR_MODE:16895,FILE_MODE:33279,reader:null,mount:function (mount) { + assert(ENVIRONMENT_IS_WORKER); + if (!WORKERFS.reader) WORKERFS.reader = new FileReaderSync(); + var root = WORKERFS.createNode(null, '/', WORKERFS.DIR_MODE, 0); + var createdParents = {}; + function ensureParent(path) { + // return the parent node, creating subdirs as necessary + var parts = path.split('/'); + var parent = root; + for (var i = 0; i < parts.length-1; i++) { + var curr = parts.slice(0, i+1).join('/'); + // Issue 4254: Using curr as a node name will prevent the node + // from being found in FS.nameTable when FS.open is called on + // a path which holds a child of this node, + // given that all FS functions assume node names + // are just their corresponding parts within their given path, + // rather than incremental aggregates which include their parent's + // directories. + if (!createdParents[curr]) { + createdParents[curr] = WORKERFS.createNode(parent, parts[i], WORKERFS.DIR_MODE, 0); + } + parent = createdParents[curr]; + } + return parent; + } + function base(path) { + var parts = path.split('/'); + return parts[parts.length-1]; + } + // We also accept FileList here, by using Array.prototype + Array.prototype.forEach.call(mount.opts["files"] || [], function(file) { + WORKERFS.createNode(ensureParent(file.name), base(file.name), WORKERFS.FILE_MODE, 0, file, file.lastModifiedDate); + }); + (mount.opts["blobs"] || []).forEach(function(obj) { + WORKERFS.createNode(ensureParent(obj["name"]), base(obj["name"]), WORKERFS.FILE_MODE, 0, obj["data"]); + }); + (mount.opts["packages"] || []).forEach(function(pack) { + pack['metadata'].files.forEach(function(file) { + var name = file.filename.substr(1); // remove initial slash + WORKERFS.createNode(ensureParent(name), base(name), WORKERFS.FILE_MODE, 0, pack['blob'].slice(file.start, file.end)); + }); + }); + return root; + },createNode:function (parent, name, mode, dev, contents, mtime) { + var node = FS.createNode(parent, name, mode); + node.mode = mode; + node.node_ops = WORKERFS.node_ops; + node.stream_ops = WORKERFS.stream_ops; + node.timestamp = (mtime || new Date).getTime(); + assert(WORKERFS.FILE_MODE !== WORKERFS.DIR_MODE); + if (mode === WORKERFS.FILE_MODE) { + node.size = contents.size; + node.contents = contents; + } else { + node.size = 4096; + node.contents = {}; + } + if (parent) { + parent.contents[name] = node; + } + return node; + },node_ops:{getattr:function(node) { + return { + dev: 1, + ino: node.id, + mode: node.mode, + nlink: 1, + uid: 0, + gid: 0, + rdev: undefined, + size: node.size, + atime: new Date(node.timestamp), + mtime: new Date(node.timestamp), + ctime: new Date(node.timestamp), + blksize: 4096, + blocks: Math.ceil(node.size / 4096), + }; + },setattr:function(node, attr) { + if (attr.mode !== undefined) { + node.mode = attr.mode; + } + if (attr.timestamp !== undefined) { + node.timestamp = attr.timestamp; + } + },lookup:function(parent, name) { + throw new FS.ErrnoError(44); + },mknod:function (parent, name, mode, dev) { + throw new FS.ErrnoError(63); + },rename:function (oldNode, newDir, newName) { + throw new FS.ErrnoError(63); + },unlink:function(parent, name) { + throw new FS.ErrnoError(63); + },rmdir:function(parent, name) { + throw new FS.ErrnoError(63); + },readdir:function(node) { + var entries = ['.', '..']; + for (var key in node.contents) { + if (!node.contents.hasOwnProperty(key)) { + continue; + } + entries.push(key); + } + return entries; + },symlink:function(parent, newName, oldPath) { + throw new FS.ErrnoError(63); + },readlink:function(node) { + throw new FS.ErrnoError(63); + }},stream_ops:{read:function (stream, buffer, offset, length, position) { + if (position >= stream.node.size) return 0; + var chunk = stream.node.contents.slice(position, position + length); + var ab = WORKERFS.reader.readAsArrayBuffer(chunk); + buffer.set(new Uint8Array(ab), offset); + return chunk.size; + },write:function (stream, buffer, offset, length, position) { + throw new FS.ErrnoError(29); + },llseek:function (stream, offset, whence) { + var position = offset; + if (whence === 1) { + position += stream.position; + } else if (whence === 2) { + if (FS.isFile(stream.node.mode)) { + position += stream.node.size; + } + } + if (position < 0) { + throw new FS.ErrnoError(28); + } + return position; + }}}; + + var ERRNO_MESSAGES={0:"Success",1:"Arg list too long",2:"Permission denied",3:"Address already in use",4:"Address not available",5:"Address family not supported by protocol family",6:"No more processes",7:"Socket already connected",8:"Bad file number",9:"Trying to read unreadable message",10:"Mount device busy",11:"Operation canceled",12:"No children",13:"Connection aborted",14:"Connection refused",15:"Connection reset by peer",16:"File locking deadlock error",17:"Destination address required",18:"Math arg out of domain of func",19:"Quota exceeded",20:"File exists",21:"Bad address",22:"File too large",23:"Host is unreachable",24:"Identifier removed",25:"Illegal byte sequence",26:"Connection already in progress",27:"Interrupted system call",28:"Invalid argument",29:"I/O error",30:"Socket is already connected",31:"Is a directory",32:"Too many symbolic links",33:"Too many open files",34:"Too many links",35:"Message too long",36:"Multihop attempted",37:"File or path name too long",38:"Network interface is not configured",39:"Connection reset by network",40:"Network is unreachable",41:"Too many open files in system",42:"No buffer space available",43:"No such device",44:"No such file or directory",45:"Exec format error",46:"No record locks available",47:"The link has been severed",48:"Not enough core",49:"No message of desired type",50:"Protocol not available",51:"No space left on device",52:"Function not implemented",53:"Socket is not connected",54:"Not a directory",55:"Directory not empty",56:"State not recoverable",57:"Socket operation on non-socket",59:"Not a typewriter",60:"No such device or address",61:"Value too large for defined data type",62:"Previous owner died",63:"Not super-user",64:"Broken pipe",65:"Protocol error",66:"Unknown protocol",67:"Protocol wrong type for socket",68:"Math result not representable",69:"Read only file system",70:"Illegal seek",71:"No such process",72:"Stale file handle",73:"Connection timed out",74:"Text file busy",75:"Cross-device link",100:"Device not a stream",101:"Bad font file fmt",102:"Invalid slot",103:"Invalid request code",104:"No anode",105:"Block device required",106:"Channel number out of range",107:"Level 3 halted",108:"Level 3 reset",109:"Link number out of range",110:"Protocol driver not attached",111:"No CSI structure available",112:"Level 2 halted",113:"Invalid exchange",114:"Invalid request descriptor",115:"Exchange full",116:"No data (for no delay io)",117:"Timer expired",118:"Out of streams resources",119:"Machine is not on the network",120:"Package not installed",121:"The object is remote",122:"Advertise error",123:"Srmount error",124:"Communication error on send",125:"Cross mount point (not really error)",126:"Given log. name not unique",127:"f.d. invalid for this operation",128:"Remote address changed",129:"Can access a needed shared lib",130:"Accessing a corrupted shared lib",131:".lib section in a.out corrupted",132:"Attempting to link in too many libs",133:"Attempting to exec a shared library",135:"Streams pipe error",136:"Too many users",137:"Socket type not supported",138:"Not supported",139:"Protocol family not supported",140:"Can't send after socket shutdown",141:"Too many references",142:"Host is down",148:"No medium (in tape drive)",156:"Level 2 not synchronized"}; + + var ERRNO_CODES={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135};var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,handleFSError:function(e) { + if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace(); + return setErrNo(e.errno); + },lookupPath:function(path, opts) { + path = PATH_FS.resolve(FS.cwd(), path); + opts = opts || {}; + + if (!path) return { path: '', node: null }; + + var defaults = { + follow_mount: true, + recurse_count: 0 + }; + for (var key in defaults) { + if (opts[key] === undefined) { + opts[key] = defaults[key]; + } + } + + if (opts.recurse_count > 8) { // max recursive lookup of 8 + throw new FS.ErrnoError(32); + } + + // split the path + var parts = PATH.normalizeArray(path.split('/').filter(function(p) { + return !!p; + }), false); + + // start at the root + var current = FS.root; + var current_path = '/'; + + for (var i = 0; i < parts.length; i++) { + var islast = (i === parts.length-1); + if (islast && opts.parent) { + // stop resolving + break; + } + + current = FS.lookupNode(current, parts[i]); + current_path = PATH.join2(current_path, parts[i]); + + // jump to the mount's root node if this is a mountpoint + if (FS.isMountpoint(current)) { + if (!islast || (islast && opts.follow_mount)) { + current = current.mounted.root; + } + } + + // by default, lookupPath will not follow a symlink if it is the final path component. + // setting opts.follow = true will override this behavior. + if (!islast || opts.follow) { + var count = 0; + while (FS.isLink(current.mode)) { + var link = FS.readlink(current_path); + current_path = PATH_FS.resolve(PATH.dirname(current_path), link); + + var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count }); + current = lookup.node; + + if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX). + throw new FS.ErrnoError(32); + } + } + } + } + + return { path: current_path, node: current }; + },getPath:function(node) { + var path; + while (true) { + if (FS.isRoot(node)) { + var mount = node.mount.mountpoint; + if (!path) return mount; + return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path; + } + path = path ? node.name + '/' + path : node.name; + node = node.parent; + } + },hashName:function(parentid, name) { + var hash = 0; + + + for (var i = 0; i < name.length; i++) { + hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0; + } + return ((parentid + hash) >>> 0) % FS.nameTable.length; + },hashAddNode:function(node) { + var hash = FS.hashName(node.parent.id, node.name); + node.name_next = FS.nameTable[hash]; + FS.nameTable[hash] = node; + },hashRemoveNode:function(node) { + var hash = FS.hashName(node.parent.id, node.name); + if (FS.nameTable[hash] === node) { + FS.nameTable[hash] = node.name_next; + } else { + var current = FS.nameTable[hash]; + while (current) { + if (current.name_next === node) { + current.name_next = node.name_next; + break; + } + current = current.name_next; + } + } + },lookupNode:function(parent, name) { + var errCode = FS.mayLookup(parent); + if (errCode) { + throw new FS.ErrnoError(errCode, parent); + } + var hash = FS.hashName(parent.id, name); + for (var node = FS.nameTable[hash]; node; node = node.name_next) { + var nodeName = node.name; + if (node.parent.id === parent.id && nodeName === name) { + return node; + } + } + // if we failed to find it in the cache, call into the VFS + return FS.lookup(parent, name); + },createNode:function(parent, name, mode, rdev) { + var node = new FS.FSNode(parent, name, mode, rdev); + + FS.hashAddNode(node); + + return node; + },destroyNode:function(node) { + FS.hashRemoveNode(node); + },isRoot:function(node) { + return node === node.parent; + },isMountpoint:function(node) { + return !!node.mounted; + },isFile:function(mode) { + return (mode & 61440) === 32768; + },isDir:function(mode) { + return (mode & 61440) === 16384; + },isLink:function(mode) { + return (mode & 61440) === 40960; + },isChrdev:function(mode) { + return (mode & 61440) === 8192; + },isBlkdev:function(mode) { + return (mode & 61440) === 24576; + },isFIFO:function(mode) { + return (mode & 61440) === 4096; + },isSocket:function(mode) { + return (mode & 49152) === 49152; + },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function(str) { + var flags = FS.flagModes[str]; + if (typeof flags === 'undefined') { + throw new Error('Unknown file open mode: ' + str); + } + return flags; + },flagsToPermissionString:function(flag) { + var perms = ['r', 'w', 'rw'][flag & 3]; + if ((flag & 512)) { + perms += 'w'; + } + return perms; + },nodePermissions:function(node, perms) { + if (FS.ignorePermissions) { + return 0; + } + // return 0 if any user, group or owner bits are set. + if (perms.indexOf('r') !== -1 && !(node.mode & 292)) { + return 2; + } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) { + return 2; + } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) { + return 2; + } + return 0; + },mayLookup:function(dir) { + var errCode = FS.nodePermissions(dir, 'x'); + if (errCode) return errCode; + if (!dir.node_ops.lookup) return 2; + return 0; + },mayCreate:function(dir, name) { + try { + var node = FS.lookupNode(dir, name); + return 20; + } catch (e) { + } + return FS.nodePermissions(dir, 'wx'); + },mayDelete:function(dir, name, isdir) { + var node; + try { + node = FS.lookupNode(dir, name); + } catch (e) { + return e.errno; + } + var errCode = FS.nodePermissions(dir, 'wx'); + if (errCode) { + return errCode; + } + if (isdir) { + if (!FS.isDir(node.mode)) { + return 54; + } + if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) { + return 10; + } + } else { + if (FS.isDir(node.mode)) { + return 31; + } + } + return 0; + },mayOpen:function(node, flags) { + if (!node) { + return 44; + } + if (FS.isLink(node.mode)) { + return 32; + } else if (FS.isDir(node.mode)) { + if (FS.flagsToPermissionString(flags) !== 'r' || // opening for write + (flags & 512)) { // TODO: check for O_SEARCH? (== search for dir only) + return 31; + } + } + return FS.nodePermissions(node, FS.flagsToPermissionString(flags)); + },MAX_OPEN_FDS:4096,nextfd:function(fd_start, fd_end) { + fd_start = fd_start || 0; + fd_end = fd_end || FS.MAX_OPEN_FDS; + for (var fd = fd_start; fd <= fd_end; fd++) { + if (!FS.streams[fd]) { + return fd; + } + } + throw new FS.ErrnoError(33); + },getStream:function(fd) { + return FS.streams[fd]; + },createStream:function(stream, fd_start, fd_end) { + if (!FS.FSStream) { + FS.FSStream = /** @constructor */ function(){}; + FS.FSStream.prototype = { + object: { + get: function() { return this.node; }, + set: function(val) { this.node = val; } + }, + isRead: { + get: function() { return (this.flags & 2097155) !== 1; } + }, + isWrite: { + get: function() { return (this.flags & 2097155) !== 0; } + }, + isAppend: { + get: function() { return (this.flags & 1024); } + } + }; + } + // clone it, so we can return an instance of FSStream + var newStream = new FS.FSStream(); + for (var p in stream) { + newStream[p] = stream[p]; + } + stream = newStream; + var fd = FS.nextfd(fd_start, fd_end); + stream.fd = fd; + FS.streams[fd] = stream; + return stream; + },closeStream:function(fd) { + FS.streams[fd] = null; + },chrdev_stream_ops:{open:function(stream) { + var device = FS.getDevice(stream.node.rdev); + // override node's stream ops with the device's + stream.stream_ops = device.stream_ops; + // forward the open call + if (stream.stream_ops.open) { + stream.stream_ops.open(stream); + } + },llseek:function() { + throw new FS.ErrnoError(70); + }},major:function(dev) { + return ((dev) >> 8); + },minor:function(dev) { + return ((dev) & 0xff); + },makedev:function(ma, mi) { + return ((ma) << 8 | (mi)); + },registerDevice:function(dev, ops) { + FS.devices[dev] = { stream_ops: ops }; + },getDevice:function(dev) { + return FS.devices[dev]; + },getMounts:function(mount) { + var mounts = []; + var check = [mount]; + + while (check.length) { + var m = check.pop(); + + mounts.push(m); + + check.push.apply(check, m.mounts); + } + + return mounts; + },syncfs:function(populate, callback) { + if (typeof(populate) === 'function') { + callback = populate; + populate = false; + } + + FS.syncFSRequests++; + + if (FS.syncFSRequests > 1) { + err('warning: ' + FS.syncFSRequests + ' FS.syncfs operations in flight at once, probably just doing extra work'); + } + + var mounts = FS.getMounts(FS.root.mount); + var completed = 0; + + function doCallback(errCode) { + assert(FS.syncFSRequests > 0); + FS.syncFSRequests--; + return callback(errCode); + } + + function done(errCode) { + if (errCode) { + if (!done.errored) { + done.errored = true; + return doCallback(errCode); + } + return; + } + if (++completed >= mounts.length) { + doCallback(null); + } + }; + + // sync all mounts + mounts.forEach(function (mount) { + if (!mount.type.syncfs) { + return done(null); + } + mount.type.syncfs(mount, populate, done); + }); + },mount:function(type, opts, mountpoint) { + if (typeof type === 'string') { + // The filesystem was not included, and instead we have an error + // message stored in the variable. + throw type; + } + var root = mountpoint === '/'; + var pseudo = !mountpoint; + var node; + + if (root && FS.root) { + throw new FS.ErrnoError(10); + } else if (!root && !pseudo) { + var lookup = FS.lookupPath(mountpoint, { follow_mount: false }); + + mountpoint = lookup.path; // use the absolute path + node = lookup.node; + + if (FS.isMountpoint(node)) { + throw new FS.ErrnoError(10); + } + + if (!FS.isDir(node.mode)) { + throw new FS.ErrnoError(54); + } + } + + var mount = { + type: type, + opts: opts, + mountpoint: mountpoint, + mounts: [] + }; + + // create a root node for the fs + var mountRoot = type.mount(mount); + mountRoot.mount = mount; + mount.root = mountRoot; + + if (root) { + FS.root = mountRoot; + } else if (node) { + // set as a mountpoint + node.mounted = mount; + + // add the new mount to the current mount's children + if (node.mount) { + node.mount.mounts.push(mount); + } + } + + return mountRoot; + },unmount:function (mountpoint) { + var lookup = FS.lookupPath(mountpoint, { follow_mount: false }); + + if (!FS.isMountpoint(lookup.node)) { + throw new FS.ErrnoError(28); + } + + // destroy the nodes for this mount, and all its child mounts + var node = lookup.node; + var mount = node.mounted; + var mounts = FS.getMounts(mount); + + Object.keys(FS.nameTable).forEach(function (hash) { + var current = FS.nameTable[hash]; + + while (current) { + var next = current.name_next; + + if (mounts.indexOf(current.mount) !== -1) { + FS.destroyNode(current); + } + + current = next; + } + }); + + // no longer a mountpoint + node.mounted = null; + + // remove this mount from the child mounts + var idx = node.mount.mounts.indexOf(mount); + assert(idx !== -1); + node.mount.mounts.splice(idx, 1); + },lookup:function(parent, name) { + return parent.node_ops.lookup(parent, name); + },mknod:function(path, mode, dev) { + var lookup = FS.lookupPath(path, { parent: true }); + var parent = lookup.node; + var name = PATH.basename(path); + if (!name || name === '.' || name === '..') { + throw new FS.ErrnoError(28); + } + var errCode = FS.mayCreate(parent, name); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + if (!parent.node_ops.mknod) { + throw new FS.ErrnoError(63); + } + return parent.node_ops.mknod(parent, name, mode, dev); + },create:function(path, mode) { + mode = mode !== undefined ? mode : 438 /* 0666 */; + mode &= 4095; + mode |= 32768; + return FS.mknod(path, mode, 0); + },mkdir:function(path, mode) { + mode = mode !== undefined ? mode : 511 /* 0777 */; + mode &= 511 | 512; + mode |= 16384; + return FS.mknod(path, mode, 0); + },mkdirTree:function(path, mode) { + var dirs = path.split('/'); + var d = ''; + for (var i = 0; i < dirs.length; ++i) { + if (!dirs[i]) continue; + d += '/' + dirs[i]; + try { + FS.mkdir(d, mode); + } catch(e) { + if (e.errno != 20) throw e; + } + } + },mkdev:function(path, mode, dev) { + if (typeof(dev) === 'undefined') { + dev = mode; + mode = 438 /* 0666 */; + } + mode |= 8192; + return FS.mknod(path, mode, dev); + },symlink:function(oldpath, newpath) { + if (!PATH_FS.resolve(oldpath)) { + throw new FS.ErrnoError(44); + } + var lookup = FS.lookupPath(newpath, { parent: true }); + var parent = lookup.node; + if (!parent) { + throw new FS.ErrnoError(44); + } + var newname = PATH.basename(newpath); + var errCode = FS.mayCreate(parent, newname); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + if (!parent.node_ops.symlink) { + throw new FS.ErrnoError(63); + } + return parent.node_ops.symlink(parent, newname, oldpath); + },rename:function(old_path, new_path) { + var old_dirname = PATH.dirname(old_path); + var new_dirname = PATH.dirname(new_path); + var old_name = PATH.basename(old_path); + var new_name = PATH.basename(new_path); + // parents must exist + var lookup, old_dir, new_dir; + try { + lookup = FS.lookupPath(old_path, { parent: true }); + old_dir = lookup.node; + lookup = FS.lookupPath(new_path, { parent: true }); + new_dir = lookup.node; + } catch (e) { + throw new FS.ErrnoError(10); + } + if (!old_dir || !new_dir) throw new FS.ErrnoError(44); + // need to be part of the same mount + if (old_dir.mount !== new_dir.mount) { + throw new FS.ErrnoError(75); + } + // source must exist + var old_node = FS.lookupNode(old_dir, old_name); + // old path should not be an ancestor of the new path + var relative = PATH_FS.relative(old_path, new_dirname); + if (relative.charAt(0) !== '.') { + throw new FS.ErrnoError(28); + } + // new path should not be an ancestor of the old path + relative = PATH_FS.relative(new_path, old_dirname); + if (relative.charAt(0) !== '.') { + throw new FS.ErrnoError(55); + } + // see if the new path already exists + var new_node; + try { + new_node = FS.lookupNode(new_dir, new_name); + } catch (e) { + // not fatal + } + // early out if nothing needs to change + if (old_node === new_node) { + return; + } + // we'll need to delete the old entry + var isdir = FS.isDir(old_node.mode); + var errCode = FS.mayDelete(old_dir, old_name, isdir); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + // need delete permissions if we'll be overwriting. + // need create permissions if new doesn't already exist. + errCode = new_node ? + FS.mayDelete(new_dir, new_name, isdir) : + FS.mayCreate(new_dir, new_name); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + if (!old_dir.node_ops.rename) { + throw new FS.ErrnoError(63); + } + if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) { + throw new FS.ErrnoError(10); + } + // if we are going to change the parent, check write permissions + if (new_dir !== old_dir) { + errCode = FS.nodePermissions(old_dir, 'w'); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + } + try { + if (FS.trackingDelegate['willMovePath']) { + FS.trackingDelegate['willMovePath'](old_path, new_path); + } + } catch(e) { + err("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message); + } + // remove the node from the lookup hash + FS.hashRemoveNode(old_node); + // do the underlying fs rename + try { + old_dir.node_ops.rename(old_node, new_dir, new_name); + } catch (e) { + throw e; + } finally { + // add the node back to the hash (in case node_ops.rename + // changed its name) + FS.hashAddNode(old_node); + } + try { + if (FS.trackingDelegate['onMovePath']) FS.trackingDelegate['onMovePath'](old_path, new_path); + } catch(e) { + err("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: " + e.message); + } + },rmdir:function(path) { + var lookup = FS.lookupPath(path, { parent: true }); + var parent = lookup.node; + var name = PATH.basename(path); + var node = FS.lookupNode(parent, name); + var errCode = FS.mayDelete(parent, name, true); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + if (!parent.node_ops.rmdir) { + throw new FS.ErrnoError(63); + } + if (FS.isMountpoint(node)) { + throw new FS.ErrnoError(10); + } + try { + if (FS.trackingDelegate['willDeletePath']) { + FS.trackingDelegate['willDeletePath'](path); + } + } catch(e) { + err("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message); + } + parent.node_ops.rmdir(parent, name); + FS.destroyNode(node); + try { + if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path); + } catch(e) { + err("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message); + } + },readdir:function(path) { + var lookup = FS.lookupPath(path, { follow: true }); + var node = lookup.node; + if (!node.node_ops.readdir) { + throw new FS.ErrnoError(54); + } + return node.node_ops.readdir(node); + },unlink:function(path) { + var lookup = FS.lookupPath(path, { parent: true }); + var parent = lookup.node; + var name = PATH.basename(path); + var node = FS.lookupNode(parent, name); + var errCode = FS.mayDelete(parent, name, false); + if (errCode) { + // According to POSIX, we should map EISDIR to EPERM, but + // we instead do what Linux does (and we must, as we use + // the musl linux libc). + throw new FS.ErrnoError(errCode); + } + if (!parent.node_ops.unlink) { + throw new FS.ErrnoError(63); + } + if (FS.isMountpoint(node)) { + throw new FS.ErrnoError(10); + } + try { + if (FS.trackingDelegate['willDeletePath']) { + FS.trackingDelegate['willDeletePath'](path); + } + } catch(e) { + err("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: " + e.message); + } + parent.node_ops.unlink(parent, name); + FS.destroyNode(node); + try { + if (FS.trackingDelegate['onDeletePath']) FS.trackingDelegate['onDeletePath'](path); + } catch(e) { + err("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: " + e.message); + } + },readlink:function(path) { + var lookup = FS.lookupPath(path); + var link = lookup.node; + if (!link) { + throw new FS.ErrnoError(44); + } + if (!link.node_ops.readlink) { + throw new FS.ErrnoError(28); + } + return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link)); + },stat:function(path, dontFollow) { + var lookup = FS.lookupPath(path, { follow: !dontFollow }); + var node = lookup.node; + if (!node) { + throw new FS.ErrnoError(44); + } + if (!node.node_ops.getattr) { + throw new FS.ErrnoError(63); + } + return node.node_ops.getattr(node); + },lstat:function(path) { + return FS.stat(path, true); + },chmod:function(path, mode, dontFollow) { + var node; + if (typeof path === 'string') { + var lookup = FS.lookupPath(path, { follow: !dontFollow }); + node = lookup.node; + } else { + node = path; + } + if (!node.node_ops.setattr) { + throw new FS.ErrnoError(63); + } + node.node_ops.setattr(node, { + mode: (mode & 4095) | (node.mode & ~4095), + timestamp: Date.now() + }); + },lchmod:function(path, mode) { + FS.chmod(path, mode, true); + },fchmod:function(fd, mode) { + var stream = FS.getStream(fd); + if (!stream) { + throw new FS.ErrnoError(8); + } + FS.chmod(stream.node, mode); + },chown:function(path, uid, gid, dontFollow) { + var node; + if (typeof path === 'string') { + var lookup = FS.lookupPath(path, { follow: !dontFollow }); + node = lookup.node; + } else { + node = path; + } + if (!node.node_ops.setattr) { + throw new FS.ErrnoError(63); + } + node.node_ops.setattr(node, { + timestamp: Date.now() + // we ignore the uid / gid for now + }); + },lchown:function(path, uid, gid) { + FS.chown(path, uid, gid, true); + },fchown:function(fd, uid, gid) { + var stream = FS.getStream(fd); + if (!stream) { + throw new FS.ErrnoError(8); + } + FS.chown(stream.node, uid, gid); + },truncate:function(path, len) { + if (len < 0) { + throw new FS.ErrnoError(28); + } + var node; + if (typeof path === 'string') { + var lookup = FS.lookupPath(path, { follow: true }); + node = lookup.node; + } else { + node = path; + } + if (!node.node_ops.setattr) { + throw new FS.ErrnoError(63); + } + if (FS.isDir(node.mode)) { + throw new FS.ErrnoError(31); + } + if (!FS.isFile(node.mode)) { + throw new FS.ErrnoError(28); + } + var errCode = FS.nodePermissions(node, 'w'); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + node.node_ops.setattr(node, { + size: len, + timestamp: Date.now() + }); + },ftruncate:function(fd, len) { + var stream = FS.getStream(fd); + if (!stream) { + throw new FS.ErrnoError(8); + } + if ((stream.flags & 2097155) === 0) { + throw new FS.ErrnoError(28); + } + FS.truncate(stream.node, len); + },utime:function(path, atime, mtime) { + var lookup = FS.lookupPath(path, { follow: true }); + var node = lookup.node; + node.node_ops.setattr(node, { + timestamp: Math.max(atime, mtime) + }); + },open:function(path, flags, mode, fd_start, fd_end) { + if (path === "") { + throw new FS.ErrnoError(44); + } + flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags; + mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode; + if ((flags & 64)) { + mode = (mode & 4095) | 32768; + } else { + mode = 0; + } + var node; + if (typeof path === 'object') { + node = path; + } else { + path = PATH.normalize(path); + try { + var lookup = FS.lookupPath(path, { + follow: !(flags & 131072) + }); + node = lookup.node; + } catch (e) { + // ignore + } + } + // perhaps we need to create the node + var created = false; + if ((flags & 64)) { + if (node) { + // if O_CREAT and O_EXCL are set, error out if the node already exists + if ((flags & 128)) { + throw new FS.ErrnoError(20); + } + } else { + // node doesn't exist, try to create it + node = FS.mknod(path, mode, 0); + created = true; + } + } + if (!node) { + throw new FS.ErrnoError(44); + } + // can't truncate a device + if (FS.isChrdev(node.mode)) { + flags &= ~512; + } + // if asked only for a directory, then this must be one + if ((flags & 65536) && !FS.isDir(node.mode)) { + throw new FS.ErrnoError(54); + } + // check permissions, if this is not a file we just created now (it is ok to + // create and write to a file with read-only permissions; it is read-only + // for later use) + if (!created) { + var errCode = FS.mayOpen(node, flags); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + } + // do truncation if necessary + if ((flags & 512)) { + FS.truncate(node, 0); + } + // we've already handled these, don't pass down to the underlying vfs + flags &= ~(128 | 512 | 131072); + + // register the stream with the filesystem + var stream = FS.createStream({ + node: node, + path: FS.getPath(node), // we want the absolute path to the node + flags: flags, + seekable: true, + position: 0, + stream_ops: node.stream_ops, + // used by the file family libc calls (fopen, fwrite, ferror, etc.) + ungotten: [], + error: false + }, fd_start, fd_end); + // call the new stream's open function + if (stream.stream_ops.open) { + stream.stream_ops.open(stream); + } + if (Module['logReadFiles'] && !(flags & 1)) { + if (!FS.readFiles) FS.readFiles = {}; + if (!(path in FS.readFiles)) { + FS.readFiles[path] = 1; + err("FS.trackingDelegate error on read file: " + path); + } + } + try { + if (FS.trackingDelegate['onOpenFile']) { + var trackingFlags = 0; + if ((flags & 2097155) !== 1) { + trackingFlags |= FS.tracking.openFlags.READ; + } + if ((flags & 2097155) !== 0) { + trackingFlags |= FS.tracking.openFlags.WRITE; + } + FS.trackingDelegate['onOpenFile'](path, trackingFlags); + } + } catch(e) { + err("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: " + e.message); + } + return stream; + },close:function(stream) { + if (FS.isClosed(stream)) { + throw new FS.ErrnoError(8); + } + if (stream.getdents) stream.getdents = null; // free readdir state + try { + if (stream.stream_ops.close) { + stream.stream_ops.close(stream); + } + } catch (e) { + throw e; + } finally { + FS.closeStream(stream.fd); + } + stream.fd = null; + },isClosed:function(stream) { + return stream.fd === null; + },llseek:function(stream, offset, whence) { + if (FS.isClosed(stream)) { + throw new FS.ErrnoError(8); + } + if (!stream.seekable || !stream.stream_ops.llseek) { + throw new FS.ErrnoError(70); + } + if (whence != 0 && whence != 1 && whence != 2) { + throw new FS.ErrnoError(28); + } + stream.position = stream.stream_ops.llseek(stream, offset, whence); + stream.ungotten = []; + return stream.position; + },read:function(stream, buffer, offset, length, position) { + if (length < 0 || position < 0) { + throw new FS.ErrnoError(28); + } + if (FS.isClosed(stream)) { + throw new FS.ErrnoError(8); + } + if ((stream.flags & 2097155) === 1) { + throw new FS.ErrnoError(8); + } + if (FS.isDir(stream.node.mode)) { + throw new FS.ErrnoError(31); + } + if (!stream.stream_ops.read) { + throw new FS.ErrnoError(28); + } + var seeking = typeof position !== 'undefined'; + if (!seeking) { + position = stream.position; + } else if (!stream.seekable) { + throw new FS.ErrnoError(70); + } + var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position); + if (!seeking) stream.position += bytesRead; + return bytesRead; + },write:function(stream, buffer, offset, length, position, canOwn) { + if (length < 0 || position < 0) { + throw new FS.ErrnoError(28); + } + if (FS.isClosed(stream)) { + throw new FS.ErrnoError(8); + } + if ((stream.flags & 2097155) === 0) { + throw new FS.ErrnoError(8); + } + if (FS.isDir(stream.node.mode)) { + throw new FS.ErrnoError(31); + } + if (!stream.stream_ops.write) { + throw new FS.ErrnoError(28); + } + if (stream.seekable && stream.flags & 1024) { + // seek to the end before writing in append mode + FS.llseek(stream, 0, 2); + } + var seeking = typeof position !== 'undefined'; + if (!seeking) { + position = stream.position; + } else if (!stream.seekable) { + throw new FS.ErrnoError(70); + } + var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn); + if (!seeking) stream.position += bytesWritten; + try { + if (stream.path && FS.trackingDelegate['onWriteToFile']) FS.trackingDelegate['onWriteToFile'](stream.path); + } catch(e) { + err("FS.trackingDelegate['onWriteToFile']('"+stream.path+"') threw an exception: " + e.message); + } + return bytesWritten; + },allocate:function(stream, offset, length) { + if (FS.isClosed(stream)) { + throw new FS.ErrnoError(8); + } + if (offset < 0 || length <= 0) { + throw new FS.ErrnoError(28); + } + if ((stream.flags & 2097155) === 0) { + throw new FS.ErrnoError(8); + } + if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) { + throw new FS.ErrnoError(43); + } + if (!stream.stream_ops.allocate) { + throw new FS.ErrnoError(138); + } + stream.stream_ops.allocate(stream, offset, length); + },mmap:function(stream, address, length, position, prot, flags) { + // User requests writing to file (prot & PROT_WRITE != 0). + // Checking if we have permissions to write to the file unless + // MAP_PRIVATE flag is set. According to POSIX spec it is possible + // to write to file opened in read-only mode with MAP_PRIVATE flag, + // as all modifications will be visible only in the memory of + // the current process. + if ((prot & 2) !== 0 + && (flags & 2) === 0 + && (stream.flags & 2097155) !== 2) { + throw new FS.ErrnoError(2); + } + if ((stream.flags & 2097155) === 1) { + throw new FS.ErrnoError(2); + } + if (!stream.stream_ops.mmap) { + throw new FS.ErrnoError(43); + } + return stream.stream_ops.mmap(stream, address, length, position, prot, flags); + },msync:function(stream, buffer, offset, length, mmapFlags) { + if (!stream || !stream.stream_ops.msync) { + return 0; + } + return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags); + },munmap:function(stream) { + return 0; + },ioctl:function(stream, cmd, arg) { + if (!stream.stream_ops.ioctl) { + throw new FS.ErrnoError(59); + } + return stream.stream_ops.ioctl(stream, cmd, arg); + },readFile:function(path, opts) { + opts = opts || {}; + opts.flags = opts.flags || 'r'; + opts.encoding = opts.encoding || 'binary'; + if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') { + throw new Error('Invalid encoding type "' + opts.encoding + '"'); + } + var ret; + var stream = FS.open(path, opts.flags); + var stat = FS.stat(path); + var length = stat.size; + var buf = new Uint8Array(length); + FS.read(stream, buf, 0, length, 0); + if (opts.encoding === 'utf8') { + ret = UTF8ArrayToString(buf, 0); + } else if (opts.encoding === 'binary') { + ret = buf; + } + FS.close(stream); + return ret; + },writeFile:function(path, data, opts) { + opts = opts || {}; + opts.flags = opts.flags || 'w'; + var stream = FS.open(path, opts.flags, opts.mode); + if (typeof data === 'string') { + var buf = new Uint8Array(lengthBytesUTF8(data)+1); + var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length); + FS.write(stream, buf, 0, actualNumBytes, undefined, opts.canOwn); + } else if (ArrayBuffer.isView(data)) { + FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn); + } else { + throw new Error('Unsupported data type'); + } + FS.close(stream); + },cwd:function() { + return FS.currentPath; + },chdir:function(path) { + var lookup = FS.lookupPath(path, { follow: true }); + if (lookup.node === null) { + throw new FS.ErrnoError(44); + } + if (!FS.isDir(lookup.node.mode)) { + throw new FS.ErrnoError(54); + } + var errCode = FS.nodePermissions(lookup.node, 'x'); + if (errCode) { + throw new FS.ErrnoError(errCode); + } + FS.currentPath = lookup.path; + },createDefaultDirectories:function() { + FS.mkdir('/tmp'); + FS.mkdir('/home'); + FS.mkdir('/home/web_user'); + },createDefaultDevices:function() { + // create /dev + FS.mkdir('/dev'); + // setup /dev/null + FS.registerDevice(FS.makedev(1, 3), { + read: function() { return 0; }, + write: function(stream, buffer, offset, length, pos) { return length; } + }); + FS.mkdev('/dev/null', FS.makedev(1, 3)); + // setup /dev/tty and /dev/tty1 + // stderr needs to print output using Module['printErr'] + // so we register a second tty just for it. + TTY.register(FS.makedev(5, 0), TTY.default_tty_ops); + TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops); + FS.mkdev('/dev/tty', FS.makedev(5, 0)); + FS.mkdev('/dev/tty1', FS.makedev(6, 0)); + // setup /dev/[u]random + var random_device; + if (typeof crypto === 'object' && typeof crypto['getRandomValues'] === 'function') { + // for modern web browsers + var randomBuffer = new Uint8Array(1); + random_device = function() { crypto.getRandomValues(randomBuffer); return randomBuffer[0]; }; + } else + if (ENVIRONMENT_IS_NODE) { + // for nodejs with or without crypto support included + try { + var crypto_module = require('crypto'); + // nodejs has crypto support + random_device = function() { return crypto_module['randomBytes'](1)[0]; }; + } catch (e) { + // nodejs doesn't have crypto support + } + } else + {} + if (!random_device) { + // we couldn't find a proper implementation, as Math.random() is not suitable for /dev/random, see emscripten-core/emscripten/pull/7096 + random_device = function() { abort("no cryptographic support found for random_device. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: function(array) { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };"); }; + } + FS.createDevice('/dev', 'random', random_device); + FS.createDevice('/dev', 'urandom', random_device); + // we're not going to emulate the actual shm device, + // just create the tmp dirs that reside in it commonly + FS.mkdir('/dev/shm'); + FS.mkdir('/dev/shm/tmp'); + },createSpecialDirectories:function() { + // create /proc/self/fd which allows /proc/self/fd/6 => readlink gives the name of the stream for fd 6 (see test_unistd_ttyname) + FS.mkdir('/proc'); + FS.mkdir('/proc/self'); + FS.mkdir('/proc/self/fd'); + FS.mount({ + mount: function() { + var node = FS.createNode('/proc/self', 'fd', 16384 | 511 /* 0777 */, 73); + node.node_ops = { + lookup: function(parent, name) { + var fd = +name; + var stream = FS.getStream(fd); + if (!stream) throw new FS.ErrnoError(8); + var ret = { + parent: null, + mount: { mountpoint: 'fake' }, + node_ops: { readlink: function() { return stream.path } } + }; + ret.parent = ret; // make it look like a simple root node + return ret; + } + }; + return node; + } + }, {}, '/proc/self/fd'); + },createStandardStreams:function() { + // TODO deprecate the old functionality of a single + // input / output callback and that utilizes FS.createDevice + // and instead require a unique set of stream ops + + // by default, we symlink the standard streams to the + // default tty devices. however, if the standard streams + // have been overwritten we create a unique device for + // them instead. + if (Module['stdin']) { + FS.createDevice('/dev', 'stdin', Module['stdin']); + } else { + FS.symlink('/dev/tty', '/dev/stdin'); + } + if (Module['stdout']) { + FS.createDevice('/dev', 'stdout', null, Module['stdout']); + } else { + FS.symlink('/dev/tty', '/dev/stdout'); + } + if (Module['stderr']) { + FS.createDevice('/dev', 'stderr', null, Module['stderr']); + } else { + FS.symlink('/dev/tty1', '/dev/stderr'); + } + + // open default streams for the stdin, stdout and stderr devices + var stdin = FS.open('/dev/stdin', 'r'); + var stdout = FS.open('/dev/stdout', 'w'); + var stderr = FS.open('/dev/stderr', 'w'); + assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')'); + assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')'); + assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')'); + },ensureErrnoError:function() { + if (FS.ErrnoError) return; + FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno, node) { + this.node = node; + this.setErrno = /** @this{Object} */ function(errno) { + this.errno = errno; + for (var key in ERRNO_CODES) { + if (ERRNO_CODES[key] === errno) { + this.code = key; + break; + } + } + }; + this.setErrno(errno); + this.message = ERRNO_MESSAGES[errno]; + + // Try to get a maximally helpful stack trace. On Node.js, getting Error.stack + // now ensures it shows what we want. + if (this.stack) { + // Define the stack property for Node.js 4, which otherwise errors on the next line. + Object.defineProperty(this, "stack", { value: (new Error).stack, writable: true }); + this.stack = demangleAll(this.stack); + } + }; + FS.ErrnoError.prototype = new Error(); + FS.ErrnoError.prototype.constructor = FS.ErrnoError; + // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info) + [44].forEach(function(code) { + FS.genericErrors[code] = new FS.ErrnoError(code); + FS.genericErrors[code].stack = ''; + }); + },staticInit:function() { + FS.ensureErrnoError(); + + FS.nameTable = new Array(4096); + + FS.mount(MEMFS, {}, '/'); + + FS.createDefaultDirectories(); + FS.createDefaultDevices(); + FS.createSpecialDirectories(); + + FS.filesystems = { + 'MEMFS': MEMFS, + 'WORKERFS': WORKERFS, + }; + },init:function(input, output, error) { + assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)'); + FS.init.initialized = true; + + FS.ensureErrnoError(); + + // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here + Module['stdin'] = input || Module['stdin']; + Module['stdout'] = output || Module['stdout']; + Module['stderr'] = error || Module['stderr']; + + FS.createStandardStreams(); + },quit:function() { + FS.init.initialized = false; + // force-flush all streams, so we get musl std streams printed out + var fflush = Module['_fflush']; + if (fflush) fflush(0); + // close all of our streams + for (var i = 0; i < FS.streams.length; i++) { + var stream = FS.streams[i]; + if (!stream) { + continue; + } + FS.close(stream); + } + },getMode:function(canRead, canWrite) { + var mode = 0; + if (canRead) mode |= 292 | 73; + if (canWrite) mode |= 146; + return mode; + },joinPath:function(parts, forceRelative) { + var path = PATH.join.apply(null, parts); + if (forceRelative && path[0] == '/') path = path.substr(1); + return path; + },absolutePath:function(relative, base) { + return PATH_FS.resolve(base, relative); + },standardizePath:function(path) { + return PATH.normalize(path); + },findObject:function(path, dontResolveLastLink) { + var ret = FS.analyzePath(path, dontResolveLastLink); + if (ret.exists) { + return ret.object; + } else { + setErrNo(ret.error); + return null; + } + },analyzePath:function(path, dontResolveLastLink) { + // operate from within the context of the symlink's target + try { + var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); + path = lookup.path; + } catch (e) { + } + var ret = { + isRoot: false, exists: false, error: 0, name: null, path: null, object: null, + parentExists: false, parentPath: null, parentObject: null + }; + try { + var lookup = FS.lookupPath(path, { parent: true }); + ret.parentExists = true; + ret.parentPath = lookup.path; + ret.parentObject = lookup.node; + ret.name = PATH.basename(path); + lookup = FS.lookupPath(path, { follow: !dontResolveLastLink }); + ret.exists = true; + ret.path = lookup.path; + ret.object = lookup.node; + ret.name = lookup.node.name; + ret.isRoot = lookup.path === '/'; + } catch (e) { + ret.error = e.errno; + }; + return ret; + },createFolder:function(parent, name, canRead, canWrite) { + var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); + var mode = FS.getMode(canRead, canWrite); + return FS.mkdir(path, mode); + },createPath:function(parent, path, canRead, canWrite) { + parent = typeof parent === 'string' ? parent : FS.getPath(parent); + var parts = path.split('/').reverse(); + while (parts.length) { + var part = parts.pop(); + if (!part) continue; + var current = PATH.join2(parent, part); + try { + FS.mkdir(current); + } catch (e) { + // ignore EEXIST + } + parent = current; + } + return current; + },createFile:function(parent, name, properties, canRead, canWrite) { + var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); + var mode = FS.getMode(canRead, canWrite); + return FS.create(path, mode); + },createDataFile:function(parent, name, data, canRead, canWrite, canOwn) { + var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent; + var mode = FS.getMode(canRead, canWrite); + var node = FS.create(path, mode); + if (data) { + if (typeof data === 'string') { + var arr = new Array(data.length); + for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i); + data = arr; + } + // make sure we can write to the file + FS.chmod(node, mode | 146); + var stream = FS.open(node, 'w'); + FS.write(stream, data, 0, data.length, 0, canOwn); + FS.close(stream); + FS.chmod(node, mode); + } + return node; + },createDevice:function(parent, name, input, output) { + var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); + var mode = FS.getMode(!!input, !!output); + if (!FS.createDevice.major) FS.createDevice.major = 64; + var dev = FS.makedev(FS.createDevice.major++, 0); + // Create a fake device that a set of stream ops to emulate + // the old behavior. + FS.registerDevice(dev, { + open: function(stream) { + stream.seekable = false; + }, + close: function(stream) { + // flush any pending line data + if (output && output.buffer && output.buffer.length) { + output(10); + } + }, + read: function(stream, buffer, offset, length, pos /* ignored */) { + var bytesRead = 0; + for (var i = 0; i < length; i++) { + var result; + try { + result = input(); + } catch (e) { + throw new FS.ErrnoError(29); + } + if (result === undefined && bytesRead === 0) { + throw new FS.ErrnoError(6); + } + if (result === null || result === undefined) break; + bytesRead++; + buffer[offset+i] = result; + } + if (bytesRead) { + stream.node.timestamp = Date.now(); + } + return bytesRead; + }, + write: function(stream, buffer, offset, length, pos) { + for (var i = 0; i < length; i++) { + try { + output(buffer[offset+i]); + } catch (e) { + throw new FS.ErrnoError(29); + } + } + if (length) { + stream.node.timestamp = Date.now(); + } + return i; + } + }); + return FS.mkdev(path, mode, dev); + },createLink:function(parent, name, target, canRead, canWrite) { + var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name); + return FS.symlink(target, path); + },forceLoadFile:function(obj) { + if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true; + var success = true; + if (typeof XMLHttpRequest !== 'undefined') { + throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread."); + } else if (read_) { + // Command-line. + try { + // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as + // read() will try to parse UTF8. + obj.contents = intArrayFromString(read_(obj.url), true); + obj.usedBytes = obj.contents.length; + } catch (e) { + success = false; + } + } else { + throw new Error('Cannot load without read() or XMLHttpRequest.'); + } + if (!success) setErrNo(29); + return success; + },createLazyFile:function(parent, name, url, canRead, canWrite) { + // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse. + /** @constructor */ + function LazyUint8Array() { + this.lengthKnown = false; + this.chunks = []; // Loaded chunks. Index is the chunk number + } + LazyUint8Array.prototype.get = /** @this{Object} */ function LazyUint8Array_get(idx) { + if (idx > this.length-1 || idx < 0) { + return undefined; + } + var chunkOffset = idx % this.chunkSize; + var chunkNum = (idx / this.chunkSize)|0; + return this.getter(chunkNum)[chunkOffset]; + }; + LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) { + this.getter = getter; + }; + LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() { + // Find length + var xhr = new XMLHttpRequest(); + xhr.open('HEAD', url, false); + xhr.send(null); + if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status); + var datalength = Number(xhr.getResponseHeader("Content-length")); + var header; + var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes"; + var usesGzip = (header = xhr.getResponseHeader("Content-Encoding")) && header === "gzip"; + + var chunkSize = 1024*1024; // Chunk size in bytes + + if (!hasByteServing) chunkSize = datalength; + + // Function to get a range from the remote URL. + var doXHR = (function(from, to) { + if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!"); + if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!"); + + // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available. + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, false); + if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to); + + // Some hints to the browser that we want binary data. + if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer'; + if (xhr.overrideMimeType) { + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + } + + xhr.send(null); + if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status); + if (xhr.response !== undefined) { + return new Uint8Array(/** @type{Array} */(xhr.response || [])); + } else { + return intArrayFromString(xhr.responseText || '', true); + } + }); + var lazyArray = this; + lazyArray.setDataGetter(function(chunkNum) { + var start = chunkNum * chunkSize; + var end = (chunkNum+1) * chunkSize - 1; // including this byte + end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block + if (typeof(lazyArray.chunks[chunkNum]) === "undefined") { + lazyArray.chunks[chunkNum] = doXHR(start, end); + } + if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!"); + return lazyArray.chunks[chunkNum]; + }); + + if (usesGzip || !datalength) { + // if the server uses gzip or doesn't supply the length, we have to download the whole file to get the (uncompressed) length + chunkSize = datalength = 1; // this will force getter(0)/doXHR do download the whole file + datalength = this.getter(0).length; + chunkSize = datalength; + out("LazyFiles on gzip forces download of the whole file when length is accessed"); + } + + this._length = datalength; + this._chunkSize = chunkSize; + this.lengthKnown = true; + }; + if (typeof XMLHttpRequest !== 'undefined') { + if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc'; + var lazyArray = new LazyUint8Array(); + Object.defineProperties(lazyArray, { + length: { + get: /** @this{Object} */ function() { + if(!this.lengthKnown) { + this.cacheLength(); + } + return this._length; + } + }, + chunkSize: { + get: /** @this{Object} */ function() { + if(!this.lengthKnown) { + this.cacheLength(); + } + return this._chunkSize; + } + } + }); + + var properties = { isDevice: false, contents: lazyArray }; + } else { + var properties = { isDevice: false, url: url }; + } + + var node = FS.createFile(parent, name, properties, canRead, canWrite); + // This is a total hack, but I want to get this lazy file code out of the + // core of MEMFS. If we want to keep this lazy file concept I feel it should + // be its own thin LAZYFS proxying calls to MEMFS. + if (properties.contents) { + node.contents = properties.contents; + } else if (properties.url) { + node.contents = null; + node.url = properties.url; + } + // Add a function that defers querying the file size until it is asked the first time. + Object.defineProperties(node, { + usedBytes: { + get: /** @this {FSNode} */ function() { return this.contents.length; } + } + }); + // override each stream op with one that tries to force load the lazy file first + var stream_ops = {}; + var keys = Object.keys(node.stream_ops); + keys.forEach(function(key) { + var fn = node.stream_ops[key]; + stream_ops[key] = function forceLoadLazyFile() { + if (!FS.forceLoadFile(node)) { + throw new FS.ErrnoError(29); + } + return fn.apply(null, arguments); + }; + }); + // use a custom read function + stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) { + if (!FS.forceLoadFile(node)) { + throw new FS.ErrnoError(29); + } + var contents = stream.node.contents; + if (position >= contents.length) + return 0; + var size = Math.min(contents.length - position, length); + assert(size >= 0); + if (contents.slice) { // normal array + for (var i = 0; i < size; i++) { + buffer[offset + i] = contents[position + i]; + } + } else { + for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR + buffer[offset + i] = contents.get(position + i); + } + } + return size; + }; + node.stream_ops = stream_ops; + return node; + },createPreloadedFile:function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) { + Browser.init(); // XXX perhaps this method should move onto Browser? + // TODO we should allow people to just pass in a complete filename instead + // of parent and name being that we just join them anyways + var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent; + var dep = getUniqueRunDependency('cp ' + fullname); // might have several active requests for the same fullname + function processData(byteArray) { + function finish(byteArray) { + if (preFinish) preFinish(); + if (!dontCreateFile) { + FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn); + } + if (onload) onload(); + removeRunDependency(dep); + } + var handled = false; + Module['preloadPlugins'].forEach(function(plugin) { + if (handled) return; + if (plugin['canHandle'](fullname)) { + plugin['handle'](byteArray, fullname, finish, function() { + if (onerror) onerror(); + removeRunDependency(dep); + }); + handled = true; + } + }); + if (!handled) finish(byteArray); + } + addRunDependency(dep); + if (typeof url == 'string') { + Browser.asyncLoad(url, function(byteArray) { + processData(byteArray); + }, onerror); + } else { + processData(url); + } + },indexedDB:function() { + return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; + },DB_NAME:function() { + return 'EM_FS_' + window.location.pathname; + },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function(paths, onload, onerror) { + onload = onload || function(){}; + onerror = onerror || function(){}; + var indexedDB = FS.indexedDB(); + try { + var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION); + } catch (e) { + return onerror(e); + } + openRequest.onupgradeneeded = function openRequest_onupgradeneeded() { + out('creating db'); + var db = openRequest.result; + db.createObjectStore(FS.DB_STORE_NAME); + }; + openRequest.onsuccess = function openRequest_onsuccess() { + var db = openRequest.result; + var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite'); + var files = transaction.objectStore(FS.DB_STORE_NAME); + var ok = 0, fail = 0, total = paths.length; + function finish() { + if (fail == 0) onload(); else onerror(); + } + paths.forEach(function(path) { + var putRequest = files.put(FS.analyzePath(path).object.contents, path); + putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() }; + putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() }; + }); + transaction.onerror = onerror; + }; + openRequest.onerror = onerror; + },loadFilesFromDB:function(paths, onload, onerror) { + onload = onload || function(){}; + onerror = onerror || function(){}; + var indexedDB = FS.indexedDB(); + try { + var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION); + } catch (e) { + return onerror(e); + } + openRequest.onupgradeneeded = onerror; // no database to load from + openRequest.onsuccess = function openRequest_onsuccess() { + var db = openRequest.result; + try { + var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly'); + } catch(e) { + onerror(e); + return; + } + var files = transaction.objectStore(FS.DB_STORE_NAME); + var ok = 0, fail = 0, total = paths.length; + function finish() { + if (fail == 0) onload(); else onerror(); + } + paths.forEach(function(path) { + var getRequest = files.get(path); + getRequest.onsuccess = function getRequest_onsuccess() { + if (FS.analyzePath(path).exists) { + FS.unlink(path); + } + FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true); + ok++; + if (ok + fail == total) finish(); + }; + getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() }; + }); + transaction.onerror = onerror; + }; + openRequest.onerror = onerror; + }};var SYSCALLS={mappings:{},DEFAULT_POLLMASK:5,umask:511,calculateAt:function(dirfd, path) { + if (path[0] !== '/') { + // relative path + var dir; + if (dirfd === -100) { + dir = FS.cwd(); + } else { + var dirstream = FS.getStream(dirfd); + if (!dirstream) throw new FS.ErrnoError(8); + dir = dirstream.path; + } + path = PATH.join2(dir, path); + } + return path; + },doStat:function(func, path, buf) { + try { + var stat = func(path); + } catch (e) { + if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) { + // an error occurred while trying to look up the path; we should just report ENOTDIR + return -54; + } + throw e; + } + HEAP32[((buf)>>2)]=stat.dev; + HEAP32[(((buf)+(4))>>2)]=0; + HEAP32[(((buf)+(8))>>2)]=stat.ino; + HEAP32[(((buf)+(12))>>2)]=stat.mode; + HEAP32[(((buf)+(16))>>2)]=stat.nlink; + HEAP32[(((buf)+(20))>>2)]=stat.uid; + HEAP32[(((buf)+(24))>>2)]=stat.gid; + HEAP32[(((buf)+(28))>>2)]=stat.rdev; + HEAP32[(((buf)+(32))>>2)]=0; + (tempI64 = [stat.size>>>0,(tempDouble=stat.size,(+(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[(((buf)+(40))>>2)]=tempI64[0],HEAP32[(((buf)+(44))>>2)]=tempI64[1]); + HEAP32[(((buf)+(48))>>2)]=4096; + HEAP32[(((buf)+(52))>>2)]=stat.blocks; + HEAP32[(((buf)+(56))>>2)]=(stat.atime.getTime() / 1000)|0; + HEAP32[(((buf)+(60))>>2)]=0; + HEAP32[(((buf)+(64))>>2)]=(stat.mtime.getTime() / 1000)|0; + HEAP32[(((buf)+(68))>>2)]=0; + HEAP32[(((buf)+(72))>>2)]=(stat.ctime.getTime() / 1000)|0; + HEAP32[(((buf)+(76))>>2)]=0; + (tempI64 = [stat.ino>>>0,(tempDouble=stat.ino,(+(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[(((buf)+(80))>>2)]=tempI64[0],HEAP32[(((buf)+(84))>>2)]=tempI64[1]); + return 0; + },doMsync:function(addr, stream, len, flags, offset) { + var buffer = HEAPU8.slice(addr, addr + len); + FS.msync(stream, buffer, offset, len, flags); + },doMkdir:function(path, mode) { + // remove a trailing slash, if one - /a/b/ has basename of '', but + // we want to create b in the context of this function + path = PATH.normalize(path); + if (path[path.length-1] === '/') path = path.substr(0, path.length-1); + FS.mkdir(path, mode, 0); + return 0; + },doMknod:function(path, mode, dev) { + // we don't want this in the JS API as it uses mknod to create all nodes. + switch (mode & 61440) { + case 32768: + case 8192: + case 24576: + case 4096: + case 49152: + break; + default: return -28; + } + FS.mknod(path, mode, dev); + return 0; + },doReadlink:function(path, buf, bufsize) { + if (bufsize <= 0) return -28; + var ret = FS.readlink(path); + + var len = Math.min(bufsize, lengthBytesUTF8(ret)); + var endChar = HEAP8[buf+len]; + stringToUTF8(ret, buf, bufsize+1); + // readlink is one of the rare functions that write out a C string, but does never append a null to the output buffer(!) + // stringToUTF8() always appends a null byte, so restore the character under the null byte after the write. + HEAP8[buf+len] = endChar; + + return len; + },doAccess:function(path, amode) { + if (amode & ~7) { + // need a valid mode + return -28; + } + var node; + var lookup = FS.lookupPath(path, { follow: true }); + node = lookup.node; + if (!node) { + return -44; + } + var perms = ''; + if (amode & 4) perms += 'r'; + if (amode & 2) perms += 'w'; + if (amode & 1) perms += 'x'; + if (perms /* otherwise, they've just passed F_OK */ && FS.nodePermissions(node, perms)) { + return -2; + } + return 0; + },doDup:function(path, flags, suggestFD) { + var suggest = FS.getStream(suggestFD); + if (suggest) FS.close(suggest); + return FS.open(path, flags, 0, suggestFD, suggestFD).fd; + },doReadv:function(stream, iov, iovcnt, offset) { + var ret = 0; + for (var i = 0; i < iovcnt; i++) { + var ptr = HEAP32[(((iov)+(i*8))>>2)]; + var len = HEAP32[(((iov)+(i*8 + 4))>>2)]; + var curr = FS.read(stream, HEAP8,ptr, len, offset); + if (curr < 0) return -1; + ret += curr; + if (curr < len) break; // nothing more to read + } + return ret; + },doWritev:function(stream, iov, iovcnt, offset) { + var ret = 0; + for (var i = 0; i < iovcnt; i++) { + var ptr = HEAP32[(((iov)+(i*8))>>2)]; + var len = HEAP32[(((iov)+(i*8 + 4))>>2)]; + var curr = FS.write(stream, HEAP8,ptr, len, offset); + if (curr < 0) return -1; + ret += curr; + } + return ret; + },varargs:undefined,get:function() { + assert(SYSCALLS.varargs != undefined); + SYSCALLS.varargs += 4; + var ret = HEAP32[(((SYSCALLS.varargs)-(4))>>2)]; + return ret; + },getStr:function(ptr) { + var ret = UTF8ToString(ptr); + return ret; + },getStreamFromFD:function(fd) { + var stream = FS.getStream(fd); + if (!stream) throw new FS.ErrnoError(8); + return stream; + },get64:function(low, high) { + if (low >= 0) assert(high === 0); + else assert(high === -1); + return low; + }};function ___sys_fcntl64(fd, cmd, varargs) {SYSCALLS.varargs = varargs; + try { + + var stream = SYSCALLS.getStreamFromFD(fd); + switch (cmd) { + case 0: { + var arg = SYSCALLS.get(); + if (arg < 0) { + return -28; + } + var newStream; + newStream = FS.open(stream.path, stream.flags, 0, arg); + return newStream.fd; + } + case 1: + case 2: + return 0; // FD_CLOEXEC makes no sense for a single process. + case 3: + return stream.flags; + case 4: { + var arg = SYSCALLS.get(); + stream.flags |= arg; + return 0; + } + case 12: + /* case 12: Currently in musl F_GETLK64 has same value as F_GETLK, so omitted to avoid duplicate case blocks. If that changes, uncomment this */ { + + var arg = SYSCALLS.get(); + var offset = 0; + // We're always unlocked. + HEAP16[(((arg)+(offset))>>1)]=2; + return 0; + } + case 13: + case 14: + /* case 13: Currently in musl F_SETLK64 has same value as F_SETLK, so omitted to avoid duplicate case blocks. If that changes, uncomment this */ + /* case 14: Currently in musl F_SETLKW64 has same value as F_SETLKW, so omitted to avoid duplicate case blocks. If that changes, uncomment this */ + + + return 0; // Pretend that the locking is successful. + case 16: + case 8: + return -28; // These are for sockets. We don't have them fully implemented yet. + case 9: + // musl trusts getown return values, due to a bug where they must be, as they overlap with errors. just return -1 here, so fnctl() returns that, and we set errno ourselves. + setErrNo(28); + return -1; + default: { + return -28; + } + } + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return -e.errno; + } + } + + function ___sys_getcwd(buf, size) {try { + + if (size === 0) return -28; + var cwd = FS.cwd(); + var cwdLengthInBytes = lengthBytesUTF8(cwd); + if (size < cwdLengthInBytes + 1) return -68; + stringToUTF8(cwd, buf, size); + return buf; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return -e.errno; + } + } + + function ___sys_getdents64(fd, dirp, count) {try { + + var stream = SYSCALLS.getStreamFromFD(fd) + if (!stream.getdents) { + stream.getdents = FS.readdir(stream.path); + } + + var struct_size = 280; + var pos = 0; + var off = FS.llseek(stream, 0, 1); + + var idx = Math.floor(off / struct_size); + + while (idx < stream.getdents.length && pos + struct_size <= count) { + var id; + var type; + var name = stream.getdents[idx]; + if (name[0] === '.') { + id = 1; + type = 4; // DT_DIR + } else { + var child = FS.lookupNode(stream.node, name); + id = child.id; + type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device. + FS.isDir(child.mode) ? 4 : // DT_DIR, directory. + FS.isLink(child.mode) ? 10 : // DT_LNK, symbolic link. + 8; // DT_REG, regular file. + } + (tempI64 = [id>>>0,(tempDouble=id,(+(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[((dirp + pos)>>2)]=tempI64[0],HEAP32[(((dirp + pos)+(4))>>2)]=tempI64[1]); + (tempI64 = [(idx + 1) * struct_size>>>0,(tempDouble=(idx + 1) * struct_size,(+(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[(((dirp + pos)+(8))>>2)]=tempI64[0],HEAP32[(((dirp + pos)+(12))>>2)]=tempI64[1]); + HEAP16[(((dirp + pos)+(16))>>1)]=280; + HEAP8[(((dirp + pos)+(18))>>0)]=type; + stringToUTF8(name, dirp + pos + 19, 256); + pos += struct_size; + idx += 1; + } + FS.llseek(stream, idx * struct_size, 0); + return pos; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return -e.errno; + } + } + + function ___sys_ioctl(fd, op, varargs) {SYSCALLS.varargs = varargs; + try { + + var stream = SYSCALLS.getStreamFromFD(fd); + switch (op) { + case 21509: + case 21505: { + if (!stream.tty) return -59; + return 0; + } + case 21510: + case 21511: + case 21512: + case 21506: + case 21507: + case 21508: { + if (!stream.tty) return -59; + return 0; // no-op, not actually adjusting terminal settings + } + case 21519: { + if (!stream.tty) return -59; + var argp = SYSCALLS.get(); + HEAP32[((argp)>>2)]=0; + return 0; + } + case 21520: { + if (!stream.tty) return -59; + return -28; // not supported + } + case 21531: { + var argp = SYSCALLS.get(); + return FS.ioctl(stream, op, argp); + } + case 21523: { + // TODO: in theory we should write to the winsize struct that gets + // passed in, but for now musl doesn't read anything on it + if (!stream.tty) return -59; + return 0; + } + case 21524: { + // TODO: technically, this ioctl call should change the window size. + // but, since emscripten doesn't have any concept of a terminal window + // yet, we'll just silently throw it away as we do TIOCGWINSZ + if (!stream.tty) return -59; + return 0; + } + default: abort('bad ioctl syscall ' + op); + } + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return -e.errno; + } + } + + function ___sys_open(path, flags, varargs) {SYSCALLS.varargs = varargs; + try { + + var pathname = SYSCALLS.getStr(path); + var mode = SYSCALLS.get(); + var stream = FS.open(pathname, flags, mode); + return stream.fd; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return -e.errno; + } + } + + function ___sys_stat64(path, buf) {try { + + path = SYSCALLS.getStr(path); + return SYSCALLS.doStat(FS.stat, path, buf); + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return -e.errno; + } + } + + function ___sys_unlink(path) {try { + + path = SYSCALLS.getStr(path); + FS.unlink(path); + return 0; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return -e.errno; + } + } + + function _emscripten_get_sbrk_ptr() { + return 27008; + } + + + function _longjmp(env, value) { + _setThrew(env, value || 1); + throw 'longjmp'; + }function _emscripten_longjmp(env, value) { + _longjmp(env, value); + } + + function _emscripten_memcpy_big(dest, src, num) { + HEAPU8.copyWithin(dest, src, src + num); + } + + + function _emscripten_get_heap_size() { + return HEAPU8.length; + } + + function abortOnCannotGrowMemory(requestedSize) { + abort('Cannot enlarge memory arrays to size ' + requestedSize + ' bytes (OOM). Either (1) compile with -s INITIAL_MEMORY=X with X higher than the current value ' + HEAP8.length + ', (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 '); + }function _emscripten_resize_heap(requestedSize) { + requestedSize = requestedSize >>> 0; + abortOnCannotGrowMemory(requestedSize); + } + + function _exit(status) { + // void _exit(int status); + // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html + exit(status); + } + + function _fd_close(fd) {try { + + var stream = SYSCALLS.getStreamFromFD(fd); + FS.close(stream); + return 0; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return e.errno; + } + } + + function _fd_read(fd, iov, iovcnt, pnum) {try { + + var stream = SYSCALLS.getStreamFromFD(fd); + var num = SYSCALLS.doReadv(stream, iov, iovcnt); + HEAP32[((pnum)>>2)]=num + return 0; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return e.errno; + } + } + + function _fd_seek(fd, offset_low, offset_high, whence, newOffset) {try { + + + var stream = SYSCALLS.getStreamFromFD(fd); + var HIGH_OFFSET = 0x100000000; // 2^32 + // use an unsigned operator on low and shift high by 32-bits + var offset = offset_high * HIGH_OFFSET + (offset_low >>> 0); + + var DOUBLE_LIMIT = 0x20000000000000; // 2^53 + // we also check for equality since DOUBLE_LIMIT + 1 == DOUBLE_LIMIT + if (offset <= -DOUBLE_LIMIT || offset >= DOUBLE_LIMIT) { + return -61; + } + + FS.llseek(stream, offset, whence); + (tempI64 = [stream.position>>>0,(tempDouble=stream.position,(+(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[((newOffset)>>2)]=tempI64[0],HEAP32[(((newOffset)+(4))>>2)]=tempI64[1]); + if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null; // reset readdir state + return 0; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return e.errno; + } + } + + function _fd_write(fd, iov, iovcnt, pnum) {try { + + var stream = SYSCALLS.getStreamFromFD(fd); + var num = SYSCALLS.doWritev(stream, iov, iovcnt); + HEAP32[((pnum)>>2)]=num + return 0; + } catch (e) { + if (typeof FS === 'undefined' || !(e instanceof FS.ErrnoError)) abort(e); + return e.errno; + } + } + + function _getTempRet0() { + return (getTempRet0() | 0); + } + + + var ___tm_current=27024; + + + var ___tm_timezone=(stringToUTF8("GMT", 27072, 4), 27072); + + function _tzset() { + // TODO: Use (malleable) environment variables instead of system settings. + if (_tzset.called) return; + _tzset.called = true; + + // timezone is specified as seconds west of UTC ("The external variable + // `timezone` shall be set to the difference, in seconds, between + // Coordinated Universal Time (UTC) and local standard time."), the same + // as returned by getTimezoneOffset(). + // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html + HEAP32[((__get_timezone())>>2)]=(new Date()).getTimezoneOffset() * 60; + + var currentYear = new Date().getFullYear(); + var winter = new Date(currentYear, 0, 1); + var summer = new Date(currentYear, 6, 1); + HEAP32[((__get_daylight())>>2)]=Number(winter.getTimezoneOffset() != summer.getTimezoneOffset()); + + function extractZone(date) { + var match = date.toTimeString().match(/\(([A-Za-z ]+)\)$/); + return match ? match[1] : "GMT"; + }; + var winterName = extractZone(winter); + var summerName = extractZone(summer); + var winterNamePtr = allocateUTF8(winterName); + var summerNamePtr = allocateUTF8(summerName); + if (summer.getTimezoneOffset() < winter.getTimezoneOffset()) { + // Northern hemisphere + HEAP32[((__get_tzname())>>2)]=winterNamePtr; + HEAP32[(((__get_tzname())+(4))>>2)]=summerNamePtr; + } else { + HEAP32[((__get_tzname())>>2)]=summerNamePtr; + HEAP32[(((__get_tzname())+(4))>>2)]=winterNamePtr; + } + }function _localtime_r(time, tmPtr) { + _tzset(); + var date = new Date(HEAP32[((time)>>2)]*1000); + HEAP32[((tmPtr)>>2)]=date.getSeconds(); + HEAP32[(((tmPtr)+(4))>>2)]=date.getMinutes(); + HEAP32[(((tmPtr)+(8))>>2)]=date.getHours(); + HEAP32[(((tmPtr)+(12))>>2)]=date.getDate(); + HEAP32[(((tmPtr)+(16))>>2)]=date.getMonth(); + HEAP32[(((tmPtr)+(20))>>2)]=date.getFullYear()-1900; + HEAP32[(((tmPtr)+(24))>>2)]=date.getDay(); + + var start = new Date(date.getFullYear(), 0, 1); + var yday = ((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24))|0; + HEAP32[(((tmPtr)+(28))>>2)]=yday; + HEAP32[(((tmPtr)+(36))>>2)]=-(date.getTimezoneOffset() * 60); + + // Attention: DST is in December in South, and some regions don't have DST at all. + var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset(); + var winterOffset = start.getTimezoneOffset(); + var dst = (summerOffset != winterOffset && date.getTimezoneOffset() == Math.min(winterOffset, summerOffset))|0; + HEAP32[(((tmPtr)+(32))>>2)]=dst; + + var zonePtr = HEAP32[(((__get_tzname())+(dst ? 4 : 0))>>2)]; + HEAP32[(((tmPtr)+(40))>>2)]=zonePtr; + + return tmPtr; + }function _localtime(time) { + return _localtime_r(time, ___tm_current); + } + + function _setTempRet0($i) { + setTempRet0(($i) | 0); + } + + function _time(ptr) { + var ret = (Date.now()/1000)|0; + if (ptr) { + HEAP32[((ptr)>>2)]=ret; + } + return ret; + } + +var FSNode = /** @constructor */ function(parent, name, mode, rdev) { + if (!parent) { + parent = this; // root node sets parent to itself + } + this.parent = parent; + this.mount = parent.mount; + this.mounted = null; + this.id = FS.nextInode++; + this.name = name; + this.mode = mode; + this.node_ops = {}; + this.stream_ops = {}; + this.rdev = rdev; + }; + var readMode = 292/*292*/ | 73/*73*/; + var writeMode = 146/*146*/; + Object.defineProperties(FSNode.prototype, { + read: { + get: /** @this{FSNode} */function() { + return (this.mode & readMode) === readMode; + }, + set: /** @this{FSNode} */function(val) { + val ? this.mode |= readMode : this.mode &= ~readMode; + } + }, + write: { + get: /** @this{FSNode} */function() { + return (this.mode & writeMode) === writeMode; + }, + set: /** @this{FSNode} */function(val) { + val ? this.mode |= writeMode : this.mode &= ~writeMode; + } + }, + isFolder: { + get: /** @this{FSNode} */function() { + return FS.isDir(this.mode); + } + }, + isDevice: { + get: /** @this{FSNode} */function() { + return FS.isChrdev(this.mode); + } + } + }); + FS.FSNode = FSNode; + FS.staticInit();Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;Module["FS_unlink"] = FS.unlink;; +var ASSERTIONS = true; + + + +/** @type {function(string, boolean=, number=)} */ +function intArrayFromString(stringy, dontAddNull, length) { + var len = length > 0 ? length : lengthBytesUTF8(stringy)+1; + var u8array = new Array(len); + var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length); + if (dontAddNull) u8array.length = numBytesWritten; + return u8array; +} + +function intArrayToString(array) { + var ret = []; + for (var i = 0; i < array.length; i++) { + var chr = array[i]; + if (chr > 0xFF) { + if (ASSERTIONS) { + assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.'); + } + chr &= 0xFF; + } + ret.push(String.fromCharCode(chr)); + } + return ret.join(''); +} + + +var asmGlobalArg = {}; +var asmLibraryArg = { "__handle_stack_overflow": ___handle_stack_overflow, "__sys_fcntl64": ___sys_fcntl64, "__sys_getcwd": ___sys_getcwd, "__sys_getdents64": ___sys_getdents64, "__sys_ioctl": ___sys_ioctl, "__sys_open": ___sys_open, "__sys_stat64": ___sys_stat64, "__sys_unlink": ___sys_unlink, "emscripten_get_sbrk_ptr": _emscripten_get_sbrk_ptr, "emscripten_longjmp": _emscripten_longjmp, "emscripten_memcpy_big": _emscripten_memcpy_big, "emscripten_resize_heap": _emscripten_resize_heap, "exit": _exit, "fd_close": _fd_close, "fd_read": _fd_read, "fd_seek": _fd_seek, "fd_write": _fd_write, "getTempRet0": _getTempRet0, "invoke_i": invoke_i, "invoke_ii": invoke_ii, "invoke_iii": invoke_iii, "invoke_iiii": invoke_iiii, "invoke_vii": invoke_vii, "invoke_viiii": invoke_viiii, "invoke_viiiii": invoke_viiiii, "localtime": _localtime, "memory": wasmMemory, "setTempRet0": _setTempRet0, "table": wasmTable, "time": _time }; +var asm = createWasm(); +/** @type {function(...*):?} */ +var ___wasm_call_ctors = Module["___wasm_call_ctors"] = createExportWrapper("__wasm_call_ctors"); + +/** @type {function(...*):?} */ +var _free = Module["_free"] = createExportWrapper("free"); + +/** @type {function(...*):?} */ +var _main = Module["_main"] = createExportWrapper("main"); + +/** @type {function(...*):?} */ +var _malloc = Module["_malloc"] = createExportWrapper("malloc"); + +/** @type {function(...*):?} */ +var _testSetjmp = Module["_testSetjmp"] = createExportWrapper("testSetjmp"); + +/** @type {function(...*):?} */ +var _saveSetjmp = Module["_saveSetjmp"] = createExportWrapper("saveSetjmp"); + +/** @type {function(...*):?} */ +var ___errno_location = Module["___errno_location"] = createExportWrapper("__errno_location"); + +/** @type {function(...*):?} */ +var _fflush = Module["_fflush"] = createExportWrapper("fflush"); + +/** @type {function(...*):?} */ +var _realloc = Module["_realloc"] = createExportWrapper("realloc"); + +/** @type {function(...*):?} */ +var __get_tzname = Module["__get_tzname"] = createExportWrapper("_get_tzname"); + +/** @type {function(...*):?} */ +var __get_daylight = Module["__get_daylight"] = createExportWrapper("_get_daylight"); + +/** @type {function(...*):?} */ +var __get_timezone = Module["__get_timezone"] = createExportWrapper("_get_timezone"); + +/** @type {function(...*):?} */ +var _setThrew = Module["_setThrew"] = createExportWrapper("setThrew"); + +/** @type {function(...*):?} */ +var stackSave = Module["stackSave"] = createExportWrapper("stackSave"); + +/** @type {function(...*):?} */ +var stackRestore = Module["stackRestore"] = createExportWrapper("stackRestore"); + +/** @type {function(...*):?} */ +var stackAlloc = Module["stackAlloc"] = createExportWrapper("stackAlloc"); + +/** @type {function(...*):?} */ +var dynCall_vii = Module["dynCall_vii"] = createExportWrapper("dynCall_vii"); + +/** @type {function(...*):?} */ +var dynCall_viiii = Module["dynCall_viiii"] = createExportWrapper("dynCall_viiii"); + +/** @type {function(...*):?} */ +var dynCall_viiiii = Module["dynCall_viiiii"] = createExportWrapper("dynCall_viiiii"); + +/** @type {function(...*):?} */ +var dynCall_i = Module["dynCall_i"] = createExportWrapper("dynCall_i"); + +/** @type {function(...*):?} */ +var dynCall_ii = Module["dynCall_ii"] = createExportWrapper("dynCall_ii"); + +/** @type {function(...*):?} */ +var dynCall_iii = Module["dynCall_iii"] = createExportWrapper("dynCall_iii"); + +/** @type {function(...*):?} */ +var dynCall_iiii = Module["dynCall_iiii"] = createExportWrapper("dynCall_iiii"); + +/** @type {function(...*):?} */ +var ___set_stack_limit = Module["___set_stack_limit"] = createExportWrapper("__set_stack_limit"); + +/** @type {function(...*):?} */ +var __growWasmMemory = Module["__growWasmMemory"] = createExportWrapper("__growWasmMemory"); + +/** @type {function(...*):?} */ +var dynCall_jiji = Module["dynCall_jiji"] = createExportWrapper("dynCall_jiji"); + + +function invoke_iiii(index,a1,a2,a3) { + var sp = stackSave(); + try { + return dynCall_iiii(index,a1,a2,a3); + } catch(e) { + stackRestore(sp); + if (e !== e+0 && e !== 'longjmp') throw e; + _setThrew(1, 0); + } +} + +function invoke_iii(index,a1,a2) { + var sp = stackSave(); + try { + return dynCall_iii(index,a1,a2); + } catch(e) { + stackRestore(sp); + if (e !== e+0 && e !== 'longjmp') throw e; + _setThrew(1, 0); + } +} + +function invoke_viiiii(index,a1,a2,a3,a4,a5) { + var sp = stackSave(); + try { + dynCall_viiiii(index,a1,a2,a3,a4,a5); + } catch(e) { + stackRestore(sp); + if (e !== e+0 && e !== 'longjmp') throw e; + _setThrew(1, 0); + } +} + +function invoke_viiii(index,a1,a2,a3,a4) { + var sp = stackSave(); + try { + dynCall_viiii(index,a1,a2,a3,a4); + } catch(e) { + stackRestore(sp); + if (e !== e+0 && e !== 'longjmp') throw e; + _setThrew(1, 0); + } +} + +function invoke_vii(index,a1,a2) { + var sp = stackSave(); + try { + dynCall_vii(index,a1,a2); + } catch(e) { + stackRestore(sp); + if (e !== e+0 && e !== 'longjmp') throw e; + _setThrew(1, 0); + } +} + +function invoke_i(index) { + var sp = stackSave(); + try { + return dynCall_i(index); + } catch(e) { + stackRestore(sp); + if (e !== e+0 && e !== 'longjmp') throw e; + _setThrew(1, 0); + } +} + +function invoke_ii(index,a1) { + var sp = stackSave(); + try { + return dynCall_ii(index,a1); + } catch(e) { + stackRestore(sp); + if (e !== e+0 && e !== 'longjmp') throw e; + _setThrew(1, 0); + } +} + + + + +// === Auto-generated postamble setup entry stuff === + + +if (!Object.getOwnPropertyDescriptor(Module, "intArrayFromString")) Module["intArrayFromString"] = function() { abort("'intArrayFromString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "intArrayToString")) Module["intArrayToString"] = function() { abort("'intArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "ccall")) Module["ccall"] = function() { abort("'ccall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "cwrap")) Module["cwrap"] = function() { abort("'cwrap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "setValue")) Module["setValue"] = function() { abort("'setValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "getValue")) Module["getValue"] = function() { abort("'getValue' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "allocate")) Module["allocate"] = function() { abort("'allocate' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +Module["getMemory"] = getMemory; +if (!Object.getOwnPropertyDescriptor(Module, "UTF8ArrayToString")) Module["UTF8ArrayToString"] = function() { abort("'UTF8ArrayToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "UTF8ToString")) Module["UTF8ToString"] = function() { abort("'UTF8ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF8Array")) Module["stringToUTF8Array"] = function() { abort("'stringToUTF8Array' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF8")) Module["stringToUTF8"] = function() { abort("'stringToUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF8")) Module["lengthBytesUTF8"] = function() { abort("'lengthBytesUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stackTrace")) Module["stackTrace"] = function() { abort("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "addOnPreRun")) Module["addOnPreRun"] = function() { abort("'addOnPreRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "addOnInit")) Module["addOnInit"] = function() { abort("'addOnInit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "addOnPreMain")) Module["addOnPreMain"] = function() { abort("'addOnPreMain' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "addOnExit")) Module["addOnExit"] = function() { abort("'addOnExit' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "addOnPostRun")) Module["addOnPostRun"] = function() { abort("'addOnPostRun' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeStringToMemory")) Module["writeStringToMemory"] = function() { abort("'writeStringToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeArrayToMemory")) Module["writeArrayToMemory"] = function() { abort("'writeArrayToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeAsciiToMemory")) Module["writeAsciiToMemory"] = function() { abort("'writeAsciiToMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +Module["addRunDependency"] = addRunDependency; +Module["removeRunDependency"] = removeRunDependency; +Module["FS_createFolder"] = FS.createFolder; +Module["FS_createPath"] = FS.createPath; +Module["FS_createDataFile"] = FS.createDataFile; +Module["FS_createPreloadedFile"] = FS.createPreloadedFile; +Module["FS_createLazyFile"] = FS.createLazyFile; +Module["FS_createLink"] = FS.createLink; +Module["FS_createDevice"] = FS.createDevice; +Module["FS_unlink"] = FS.unlink; +if (!Object.getOwnPropertyDescriptor(Module, "dynamicAlloc")) Module["dynamicAlloc"] = function() { abort("'dynamicAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "loadDynamicLibrary")) Module["loadDynamicLibrary"] = function() { abort("'loadDynamicLibrary' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "loadWebAssemblyModule")) Module["loadWebAssemblyModule"] = function() { abort("'loadWebAssemblyModule' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "getLEB")) Module["getLEB"] = function() { abort("'getLEB' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "getFunctionTables")) Module["getFunctionTables"] = function() { abort("'getFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "alignFunctionTables")) Module["alignFunctionTables"] = function() { abort("'alignFunctionTables' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "registerFunctions")) Module["registerFunctions"] = function() { abort("'registerFunctions' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "addFunction")) Module["addFunction"] = function() { abort("'addFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "removeFunction")) Module["removeFunction"] = function() { abort("'removeFunction' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "getFuncWrapper")) Module["getFuncWrapper"] = function() { abort("'getFuncWrapper' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "prettyPrint")) Module["prettyPrint"] = function() { abort("'prettyPrint' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "makeBigInt")) Module["makeBigInt"] = function() { abort("'makeBigInt' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "dynCall")) Module["dynCall"] = function() { abort("'dynCall' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "getCompilerSetting")) Module["getCompilerSetting"] = function() { abort("'getCompilerSetting' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "print")) Module["print"] = function() { abort("'print' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "printErr")) Module["printErr"] = function() { abort("'printErr' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "getTempRet0")) Module["getTempRet0"] = function() { abort("'getTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "setTempRet0")) Module["setTempRet0"] = function() { abort("'setTempRet0' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +Module["callMain"] = callMain; +if (!Object.getOwnPropertyDescriptor(Module, "abort")) Module["abort"] = function() { abort("'abort' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stringToNewUTF8")) Module["stringToNewUTF8"] = function() { abort("'stringToNewUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "abortOnCannotGrowMemory")) Module["abortOnCannotGrowMemory"] = function() { abort("'abortOnCannotGrowMemory' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "emscripten_realloc_buffer")) Module["emscripten_realloc_buffer"] = function() { abort("'emscripten_realloc_buffer' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "ENV")) Module["ENV"] = function() { abort("'ENV' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "ERRNO_CODES")) Module["ERRNO_CODES"] = function() { abort("'ERRNO_CODES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "ERRNO_MESSAGES")) Module["ERRNO_MESSAGES"] = function() { abort("'ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "setErrNo")) Module["setErrNo"] = function() { abort("'setErrNo' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "DNS")) Module["DNS"] = function() { abort("'DNS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "GAI_ERRNO_MESSAGES")) Module["GAI_ERRNO_MESSAGES"] = function() { abort("'GAI_ERRNO_MESSAGES' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "Protocols")) Module["Protocols"] = function() { abort("'Protocols' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "Sockets")) Module["Sockets"] = function() { abort("'Sockets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "UNWIND_CACHE")) Module["UNWIND_CACHE"] = function() { abort("'UNWIND_CACHE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "readAsmConstArgs")) Module["readAsmConstArgs"] = function() { abort("'readAsmConstArgs' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "jstoi_q")) Module["jstoi_q"] = function() { abort("'jstoi_q' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "jstoi_s")) Module["jstoi_s"] = function() { abort("'jstoi_s' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "abortStackOverflow")) Module["abortStackOverflow"] = function() { abort("'abortStackOverflow' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "reallyNegative")) Module["reallyNegative"] = function() { abort("'reallyNegative' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "formatString")) Module["formatString"] = function() { abort("'formatString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "PATH")) Module["PATH"] = function() { abort("'PATH' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "PATH_FS")) Module["PATH_FS"] = function() { abort("'PATH_FS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "SYSCALLS")) Module["SYSCALLS"] = function() { abort("'SYSCALLS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "syscallMmap2")) Module["syscallMmap2"] = function() { abort("'syscallMmap2' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "syscallMunmap")) Module["syscallMunmap"] = function() { abort("'syscallMunmap' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "JSEvents")) Module["JSEvents"] = function() { abort("'JSEvents' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "specialHTMLTargets")) Module["specialHTMLTargets"] = function() { abort("'specialHTMLTargets' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "demangle")) Module["demangle"] = function() { abort("'demangle' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "demangleAll")) Module["demangleAll"] = function() { abort("'demangleAll' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "jsStackTrace")) Module["jsStackTrace"] = function() { abort("'jsStackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stackTrace")) Module["stackTrace"] = function() { abort("'stackTrace' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "getEnvStrings")) Module["getEnvStrings"] = function() { abort("'getEnvStrings' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "checkWasiClock")) Module["checkWasiClock"] = function() { abort("'checkWasiClock' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64")) Module["writeI53ToI64"] = function() { abort("'writeI53ToI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Clamped")) Module["writeI53ToI64Clamped"] = function() { abort("'writeI53ToI64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Signaling")) Module["writeI53ToI64Signaling"] = function() { abort("'writeI53ToI64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Clamped")) Module["writeI53ToU64Clamped"] = function() { abort("'writeI53ToU64Clamped' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Signaling")) Module["writeI53ToU64Signaling"] = function() { abort("'writeI53ToU64Signaling' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "readI53FromI64")) Module["readI53FromI64"] = function() { abort("'readI53FromI64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "readI53FromU64")) Module["readI53FromU64"] = function() { abort("'readI53FromU64' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "convertI32PairToI53")) Module["convertI32PairToI53"] = function() { abort("'convertI32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "convertU32PairToI53")) Module["convertU32PairToI53"] = function() { abort("'convertU32PairToI53' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "Browser")) Module["Browser"] = function() { abort("'Browser' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +Module["FS"] = FS; +if (!Object.getOwnPropertyDescriptor(Module, "MEMFS")) Module["MEMFS"] = function() { abort("'MEMFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "TTY")) Module["TTY"] = function() { abort("'TTY' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "PIPEFS")) Module["PIPEFS"] = function() { abort("'PIPEFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "SOCKFS")) Module["SOCKFS"] = function() { abort("'SOCKFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "GL")) Module["GL"] = function() { abort("'GL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGet")) Module["emscriptenWebGLGet"] = function() { abort("'emscriptenWebGLGet' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetTexPixelData")) Module["emscriptenWebGLGetTexPixelData"] = function() { abort("'emscriptenWebGLGetTexPixelData' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetUniform")) Module["emscriptenWebGLGetUniform"] = function() { abort("'emscriptenWebGLGetUniform' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetVertexAttrib")) Module["emscriptenWebGLGetVertexAttrib"] = function() { abort("'emscriptenWebGLGetVertexAttrib' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "AL")) Module["AL"] = function() { abort("'AL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "SDL_unicode")) Module["SDL_unicode"] = function() { abort("'SDL_unicode' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "SDL_ttfContext")) Module["SDL_ttfContext"] = function() { abort("'SDL_ttfContext' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "SDL_audio")) Module["SDL_audio"] = function() { abort("'SDL_audio' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "SDL")) Module["SDL"] = function() { abort("'SDL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "SDL_gfx")) Module["SDL_gfx"] = function() { abort("'SDL_gfx' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "GLUT")) Module["GLUT"] = function() { abort("'GLUT' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "EGL")) Module["EGL"] = function() { abort("'EGL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "GLFW_Window")) Module["GLFW_Window"] = function() { abort("'GLFW_Window' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "GLFW")) Module["GLFW"] = function() { abort("'GLFW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "GLEW")) Module["GLEW"] = function() { abort("'GLEW' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "IDBStore")) Module["IDBStore"] = function() { abort("'IDBStore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "runAndAbortIfError")) Module["runAndAbortIfError"] = function() { abort("'runAndAbortIfError' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "WORKERFS")) Module["WORKERFS"] = function() { abort("'WORKERFS' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "warnOnce")) Module["warnOnce"] = function() { abort("'warnOnce' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stackSave")) Module["stackSave"] = function() { abort("'stackSave' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stackRestore")) Module["stackRestore"] = function() { abort("'stackRestore' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stackAlloc")) Module["stackAlloc"] = function() { abort("'stackAlloc' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "AsciiToString")) Module["AsciiToString"] = function() { abort("'AsciiToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stringToAscii")) Module["stringToAscii"] = function() { abort("'stringToAscii' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "UTF16ToString")) Module["UTF16ToString"] = function() { abort("'UTF16ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF16")) Module["stringToUTF16"] = function() { abort("'stringToUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF16")) Module["lengthBytesUTF16"] = function() { abort("'lengthBytesUTF16' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "UTF32ToString")) Module["UTF32ToString"] = function() { abort("'UTF32ToString' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "stringToUTF32")) Module["stringToUTF32"] = function() { abort("'stringToUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF32")) Module["lengthBytesUTF32"] = function() { abort("'lengthBytesUTF32' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "allocateUTF8")) Module["allocateUTF8"] = function() { abort("'allocateUTF8' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +if (!Object.getOwnPropertyDescriptor(Module, "allocateUTF8OnStack")) Module["allocateUTF8OnStack"] = function() { abort("'allocateUTF8OnStack' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") }; +Module["writeStackCookie"] = writeStackCookie; +Module["checkStackCookie"] = checkStackCookie;if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_NORMAL")) Object.defineProperty(Module, "ALLOC_NORMAL", { configurable: true, get: function() { abort("'ALLOC_NORMAL' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } }); +if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_STACK")) Object.defineProperty(Module, "ALLOC_STACK", { configurable: true, get: function() { abort("'ALLOC_STACK' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } }); +if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_DYNAMIC")) Object.defineProperty(Module, "ALLOC_DYNAMIC", { configurable: true, get: function() { abort("'ALLOC_DYNAMIC' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } }); +if (!Object.getOwnPropertyDescriptor(Module, "ALLOC_NONE")) Object.defineProperty(Module, "ALLOC_NONE", { configurable: true, get: function() { abort("'ALLOC_NONE' was not exported. add it to EXTRA_EXPORTED_RUNTIME_METHODS (see the FAQ)") } }); + + + +var calledRun; + +/** + * @constructor + * @this {ExitStatus} + */ +function ExitStatus(status) { + this.name = "ExitStatus"; + this.message = "Program terminated with exit(" + status + ")"; + this.status = status; +} + +var calledMain = false; + + +dependenciesFulfilled = function runCaller() { + // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false) + if (!calledRun) run(); + if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled +}; + +function callMain(args) { + assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on Module["onRuntimeInitialized"])'); + assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called'); + + var entryFunction = Module['_main']; + + + args = args || []; + + var argc = args.length+1; + var argv = stackAlloc((argc + 1) * 4); + HEAP32[argv >> 2] = allocateUTF8OnStack(thisProgram); + for (var i = 1; i < argc; i++) { + HEAP32[(argv >> 2) + i] = allocateUTF8OnStack(args[i - 1]); + } + HEAP32[(argv >> 2) + argc] = 0; + + try { + + Module['___set_stack_limit'](STACK_MAX); + + var ret = entryFunction(argc, argv); + + + // In PROXY_TO_PTHREAD builds, we should never exit the runtime below, as execution is asynchronously handed + // off to a pthread. + // if we're not running an evented main loop, it's time to exit + exit(ret, /* implicit = */ true); + } + catch(e) { + if (e instanceof ExitStatus) { + // exit() throws this once it's done to make sure execution + // has been stopped completely + return; + } else if (e == 'unwind') { + // running an evented main loop, don't immediately exit + noExitRuntime = true; + return; + } else { + var toLog = e; + if (e && typeof e === 'object' && e.stack) { + toLog = [e, e.stack]; + } + err('exception thrown: ' + toLog); + quit_(1, e); + } + } finally { + calledMain = true; + } +} + + + + +/** @type {function(Array=)} */ +function run(args) { + args = args || arguments_; + + if (runDependencies > 0) { + return; + } + + writeStackCookie(); + + preRun(); + + if (runDependencies > 0) return; // a preRun added a dependency, run will be called later + + function doRun() { + // run may have just been called through dependencies being fulfilled just in this very frame, + // or while the async setStatus time below was happening + if (calledRun) return; + calledRun = true; + Module['calledRun'] = true; + + if (ABORT) return; + + initRuntime(); + + preMain(); + + readyPromiseResolve(Module); + if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized'](); + + if (shouldRunNow) callMain(args); + + postRun(); + } + + if (Module['setStatus']) { + Module['setStatus']('Running...'); + setTimeout(function() { + setTimeout(function() { + Module['setStatus'](''); + }, 1); + doRun(); + }, 1); + } else + { + doRun(); + } + checkStackCookie(); +} +Module['run'] = run; + +function checkUnflushedContent() { + // Compiler settings do not allow exiting the runtime, so flushing + // the streams is not possible. but in ASSERTIONS mode we check + // if there was something to flush, and if so tell the user they + // should request that the runtime be exitable. + // Normally we would not even include flush() at all, but in ASSERTIONS + // builds we do so just for this check, and here we see if there is any + // content to flush, that is, we check if there would have been + // something a non-ASSERTIONS build would have not seen. + // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0 + // mode (which has its own special function for this; otherwise, all + // the code is inside libc) + var print = out; + var printErr = err; + var has = false; + out = err = function(x) { + has = true; + } + try { // it doesn't matter if it fails + var flush = Module['_fflush']; + if (flush) flush(0); + // also flush in the JS FS layer + ['stdout', 'stderr'].forEach(function(name) { + var info = FS.analyzePath('/dev/' + name); + if (!info) return; + var stream = info.object; + var rdev = stream.rdev; + var tty = TTY.ttys[rdev]; + if (tty && tty.output && tty.output.length) { + has = true; + } + }); + } catch(e) {} + out = print; + err = printErr; + if (has) { + 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.'); + } +} + +/** @param {boolean|number=} implicit */ +function exit(status, implicit) { + checkUnflushedContent(); + + // if this is just main exit-ing implicitly, and the status is 0, then we + // don't need to do anything here and can just leave. if the status is + // non-zero, though, then we need to report it. + // (we may have warned about this earlier, if a situation justifies doing so) + if (implicit && noExitRuntime && status === 0) { + return; + } + + if (noExitRuntime) { + // if exit() was called, we may warn the user if the runtime isn't actually being shut down + if (!implicit) { + 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)'; + readyPromiseReject(msg); + } + } else { + + ABORT = true; + EXITSTATUS = status; + + exitRuntime(); + + if (Module['onExit']) Module['onExit'](status); + } + + quit_(status, new ExitStatus(status)); +} + +if (Module['preInit']) { + if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; + while (Module['preInit'].length > 0) { + Module['preInit'].pop()(); + } +} + +// shouldRunNow refers to calling main(), not run(). +var shouldRunNow = true; + +if (Module['noInitialRun']) shouldRunNow = false; + + + noExitRuntime = true; + +run(); + + + + + + +// {{MODULE_ADDITIONS}} + + + + + + return merlin32;//.ready +} +); +})(); +if (typeof exports === 'object' && typeof module === 'object') + module.exports = merlin32; + else if (typeof define === 'function' && define['amd']) + define([], function() { return merlin32; }); + else if (typeof exports === 'object') + exports["merlin32"] = merlin32; + \ No newline at end of file diff --git a/src/worker/wasm/merlin32.wasm b/src/worker/wasm/merlin32.wasm new file mode 100644 index 00000000..8aa0bb15 Binary files /dev/null and b/src/worker/wasm/merlin32.wasm differ diff --git a/src/worker/workermain.ts b/src/worker/workermain.ts index 2daf5e22..1ed0708e 100644 --- a/src/worker/workermain.ts +++ b/src/worker/workermain.ts @@ -2515,6 +2515,104 @@ function compileInform6(step:BuildStep) { } } +/* +------+-------------------+-------------+----+---------+------+-----------------------+------------------------------------------------------------------- + Line | # File Line | Line Type | MX | Reloc | Size | Address Object Code | Source Code +------+-------------------+-------------+----+---------+------+-----------------------+------------------------------------------------------------------- + 1 | 1 zap.asm 1 | Unknown | ?? | | -1 | 00/FFFF | broak + 2 | 1 zap.asm 2 | Comment | ?? | | -1 | 00/FFFF | * SPACEGAME + + => [Error] Impossible to decode address mode for instruction 'BNE KABOOM!' (line 315, file 'zap.asm') : The number of element in 'KABOOM!' is even (should be value [operator value [operator value]...]). + => [Error] Unknown line 'foo' in source file 'zap.asm' (line 315) + => Creating Object file 'pcs.bin' + => Creating Output file 'pcs.bin_S01__Output.txt' + +*/ +function assembleMerlin32(step:BuildStep) { + loadNative("merlin32"); + var errors = []; + var lstfiles = []; + gatherFiles(step, {mainFilePath:"main.lnk"}); + var objpath = step.prefix+".bin"; + if (staleFiles(step, [objpath])) { + var args = [ '-v', step.path ]; + var merlin32 = emglobal.merlin32({ + instantiateWasm: moduleInstFn('merlin32'), + noInitialRun:true, + print:(s:string) => { + var m = /\s*=>\s*Creating Output file '(.+?)'/.exec(s); + if (m) { + lstfiles.push(m[1]); + } + var errpos = s.indexOf('Error'); + if (errpos >= 0) { + s = s.slice(errpos+6).trim(); + var mline = /\bline (\d+)\b/.exec(s); + var mpath = /\bfile '(.+?)'/.exec(s); + errors.push({ + line:parseInt(mline[1]) || 0, + msg:s, + path:mpath[1] || step.path, + }); + } + }, + printErr:print_fn, + }); + var FS = merlin32['FS']; + populateFiles(step, FS); + execMain(step, merlin32, args); + if (errors.length) + return {errors:errors}; + + var errout = null; + try { + errout = FS.readFile("error_output.txt", {encoding:'utf8'}); + } catch (e) { + // + } + + var objout = FS.readFile(objpath, {encoding:'binary'}); + putWorkFile(objpath, objout); + if (!anyTargetChanged(step, [objpath])) + return; + + var symbolmap = {}; + var segments = []; + var listings : CodeListingMap = {}; + lstfiles.forEach((lstfn) => { + var lst = FS.readFile(lstfn, {encoding:'utf8'}) as string; + lst.split('\n').forEach((line) => { + var toks = line.split(/\s*\|\s*/); + if (toks && toks[6]) { + var toks2 = toks[1].split(/\s+/); + var toks3 = toks[6].split(/[:/]/, 4); + var path = toks2[1]; + if (path && toks2[2] && toks3[1]) { + var lstline = { + line:parseInt(toks2[2]), + offset:parseInt(toks3[1].trim(),16), + insns:toks3[2], + cycles:null, + iscode:false // TODO + }; + var lst = listings[path]; + if (!lst) listings[path] = lst = {lines:[]}; + lst.lines.push(lstline); + //console.log(path,toks2,toks3); + } + } + }); + }); + return { + output:objout, //.slice(0), + listings:listings, + errors:errors, + symbolmap:symbolmap, + segments:segments + }; + } +} + //////////////////////////// var TOOLS = { @@ -2546,6 +2644,7 @@ var TOOLS = { 'markdown': translateShowdown, 'js': runJavascript, 'inform6': compileInform6, + 'merlin32': assembleMerlin32, } var TOOL_PRELOADFS = {