diff --git a/app/src/main/jni/Makefile b/app/src/main/jni/Makefile new file mode 100644 index 0000000..44d4f87 --- /dev/null +++ b/app/src/main/jni/Makefile @@ -0,0 +1,10 @@ +# Makefile for emscripten + +SRC := dx7note.cc env.cc exp2.cc fm_core.cc fm_op_kernel.cc freqlut.cc \ + lfo.cc log2.cc patch.cc pitchenv.cc resofilter.cc ringbuffer.cc \ + sawtooth.cc sin.cc synth_unit.cc emscripten.cc + +EXP := "['_synth_create','_synth_get_samples','_synth_send_midi']" + +synthcore.js: $(SRC) + em++ $^ -o $@ -s EXPORTED_FUNCTIONS=$(EXP) -O2 diff --git a/app/src/main/jni/aligned_buf.h b/app/src/main/jni/aligned_buf.h index 70aef2a..3b06a32 100644 --- a/app/src/main/jni/aligned_buf.h +++ b/app/src/main/jni/aligned_buf.h @@ -21,6 +21,8 @@ #ifndef __ALIGNED_BUF_H #define __ALIGNED_BUF_H +#include + template class AlignedBuf { public: diff --git a/app/src/main/jni/audio.js b/app/src/main/jni/audio.js new file mode 100644 index 0000000..05efbf6 --- /dev/null +++ b/app/src/main/jni/audio.js @@ -0,0 +1,115 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +var audio = null; // global audio context + +class Audio { + constructor(synthUnit, sendMidi) { + this._synthUnit = synthUnit; + this._sendMidi = sendMidi; + } + + sendMidi(data) { + var midiBuf = Module._malloc(data.length); + Module.writeArrayToMemory(data, midiBuf); + this._sendMidi(this._synthUnit, midiBuf, data.length); + Module._free(midiBuf); + } +} + +function start() { + var ctx = new AudioContext(); + + // Initialize the emscripten core + var sampleRate = ctx.sampleRate; + var synthUnit = Module.ccall('synth_create', 'number', ['number'], [sampleRate]); + console.log('synth pointer =', synthUnit); + var getSamples = Module.cwrap('synth_get_samples', null, ['number', 'number', 'number']); + var sendMidi = Module.cwrap('synth_send_midi', null, ['number', 'number', 'number']); + + var scriptNode = ctx.createScriptProcessor(256, 0, 1); + var bufSize = scriptNode.bufferSize; + var xferBuf = Module._malloc(bufSize * 2); + scriptNode.onaudioprocess = function(audioProcessingEvent) { + //console.log(audioProcessingEvent); + getSamples(synthUnit, bufSize, xferBuf); + var buf = audioProcessingEvent.outputBuffer.getChannelData(0); + for (var i = 0; i < bufSize; i++) { + buf[i] = Module.getValue(xferBuf + i*2, 'i16') * (1.0/32768); + } + } + scriptNode.connect(ctx.destination); + + audio = new Audio(synthUnit, sendMidi); + + var midiAccess = null; + var midiIn = null; + + function midiStateChange() { + if (midiIn != null) { + midiIn.onmidimessage = null; + } + var inputs = midiAccess.inputs.values(); + for (var input = inputs.next(); input && !input.done; input = inputs.next()) { + // we just always take the first one in the list; could be more + // sophisticated but whatevs. + midiIn = input.value; + break; + } + if (midiIn != null) { + midiIn.onmidimessage = onMIDIMessage; + } + } + + function onMIDIMessage(message) { + var data = message.data; + console.log('midi:', data); + if (data[0] == 0x90 || data[0] == 0x80) { + var shiftedNote = data[1] - 48; + var note = notes[shiftedNote]; + if (note != null && data[0] == 0x90) { + note.note_on(); + } + if (note != null && data[0] == 0x80) { + note.note_off(); + } + } + audio.sendMidi(data); + } + + function onMIDIStarted(midi) { + midiAccess = midi; + midi.onstatechange = midiStateChange; + midiStateChange(); + } + + function onMIDISystemError(err) { + console.log("MIDI error: " + err); + } + + // MIDI + navigator.requestMIDIAccess().then( onMIDIStarted, onMIDISystemError ); +} + +function audioInit() { + if (window.emscriptenRuntimeReady) { + start(); + } else { + window.onEmscriptenRuntimeReady = start; + } +} + +window.addEventListener('load', audioInit); diff --git a/app/src/main/jni/dx7note.h b/app/src/main/jni/dx7note.h index 9621309..237ab24 100644 --- a/app/src/main/jni/dx7note.h +++ b/app/src/main/jni/dx7note.h @@ -23,6 +23,8 @@ // It will continue to evolve a bit, as note-stealing logic, scaling, // and real-time control of parameters live here. +#include + #include "env.h" #include "pitchenv.h" #include "fm_core.h" diff --git a/app/src/main/jni/emscripten.cc b/app/src/main/jni/emscripten.cc new file mode 100644 index 0000000..7562c8c --- /dev/null +++ b/app/src/main/jni/emscripten.cc @@ -0,0 +1,52 @@ +/* + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// C-wrapped API entrypoints for use from Emscripten + +#ifdef __EMSCRIPTEN__ +#include +#else +#define EMSCRIPTEN_KEEPALIVE +#endif + +#include "synth.h" +#include "synth_unit.h" + +struct Synth { + RingBuffer *buf; + SynthUnit *synth_unit; +}; + +extern "C" { + EMSCRIPTEN_KEEPALIVE + Synth *synth_create(int sample_rate) { + Synth *synth = new Synth(); + synth->buf = new RingBuffer(); + synth->synth_unit = new SynthUnit(synth->buf); + synth->synth_unit->Init(sample_rate); + return synth; + } + + EMSCRIPTEN_KEEPALIVE + void synth_get_samples(Synth *synth, int n_samples, int16_t *buffer) { + synth->synth_unit->GetSamples(n_samples, buffer); + } + + EMSCRIPTEN_KEEPALIVE + void synth_send_midi(Synth *synth, const uint8_t *bytes, int size) { + synth->buf->Write(bytes, size); + } +} diff --git a/app/src/main/jni/env.cc b/app/src/main/jni/env.cc index cb9e335..998ab2b 100644 --- a/app/src/main/jni/env.cc +++ b/app/src/main/jni/env.cc @@ -17,8 +17,6 @@ #include "synth.h" #include "env.h" -using namespace std; - void Env::init(const int r[4], const int l[4], int32_t ol, int rate_scaling) { for (int i = 0; i < 4; i++) { rates_[i] = r[i]; @@ -32,7 +30,7 @@ void Env::init(const int r[4], const int l[4], int32_t ol, int rate_scaling) { } int32_t Env::getsample() { - if (ix_ < 3 || (ix_ < 4) && !down_) { + if (ix_ < 3 || ((ix_ < 4) && !down_)) { if (rising_) { const int jumptarget = 1716; if (level_ < (jumptarget << 16)) { diff --git a/app/src/main/jni/env.h b/app/src/main/jni/env.h index d76dc06..4d5a632 100644 --- a/app/src/main/jni/env.h +++ b/app/src/main/jni/env.h @@ -17,6 +17,8 @@ #ifndef __ENV_H #define __ENV_H +#include + // DX7 envelope generation class Env { diff --git a/app/src/main/jni/index.html b/app/src/main/jni/index.html new file mode 100644 index 0000000..2947068 --- /dev/null +++ b/app/src/main/jni/index.html @@ -0,0 +1,45 @@ + + + + + Synthesizer testbed + + + +

Synthesizer testbed

+ + + + +

No UI yet. Connect a MIDI keyboard (using Web MIDI). Use the inspector + to see if MIDI events are getting through.

+

Port of music-synthesizer-for-android using Emscripten.

+ + + + diff --git a/app/src/main/jni/pitchenv.cc b/app/src/main/jni/pitchenv.cc index 7cb564c..c289323 100644 --- a/app/src/main/jni/pitchenv.cc +++ b/app/src/main/jni/pitchenv.cc @@ -53,7 +53,7 @@ void PitchEnv::set(const int r[4], const int l[4]) { } int32_t PitchEnv::getsample() { - if (ix_ < 3 || (ix_ < 4) && !down_) { + if (ix_ < 3 || ((ix_ < 4) && !down_)) { if (rising_) { level_ += inc_; if (level_ >= targetlevel_) { diff --git a/app/src/main/jni/synth.css b/app/src/main/jni/synth.css new file mode 100644 index 0000000..aa868fe --- /dev/null +++ b/app/src/main/jni/synth.css @@ -0,0 +1,14 @@ +svg .white { + fill: white; + stroke: gray; +} + +svg .black { + fill: black; + stroke: gray; +} + +svg .pressed { + fill: #80a0c0; + stroke: gray; +} diff --git a/app/src/main/jni/synthcore.js b/app/src/main/jni/synthcore.js new file mode 100644 index 0000000..41da814 --- /dev/null +++ b/app/src/main/jni/synthcore.js @@ -0,0 +1,16 @@ +var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER}if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=console.log;if(!Module["printErr"])Module["printErr"]=console.warn;var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function shell_read(){throw"no read() available"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status,toThrow){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function shell_read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}Module["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)}else{onerror()}};xhr.onerror=onerror;xhr.send(null)};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function shell_print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function shell_printErr(x){console.warn(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}if(!Module["quit"]){Module["quit"]=(function(status,toThrow){throw toThrow})}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var Runtime={setTempRet0:(function(value){tempRet0=value;return value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(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 Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}),getNativeFieldSize:(function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)}),STACK_ALIGN:16,prepVararg:(function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr}),getAlignSize:(function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)}),dynCall:(function(sig,ptr,args){if(args&&args.length){return Module["dynCall_"+sig].apply(null,[ptr].concat(args))}else{return Module["dynCall_"+sig].call(null,ptr)}}),functionPointers:[],addFunction:(function(func){for(var i=0;i>2];var end=(ret+size+15|0)&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}),alignMemory:(function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret}),makeBigInt:(function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret}),GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module["Runtime"]=Runtime;var ABORT=0;var EXITSTATUS=0;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}function getCFunc(ident){var func=Module["_"+ident];if(!func){try{func=eval("_"+ident)}catch(e){}}assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)");return func}var cwrap,ccall;((function(){var JSfuncs={"stackSave":(function(){Runtime.stackSave()}),"stackRestore":(function(){Runtime.stackRestore()}),"arrayToC":(function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=Runtime.stackAlloc(len);stringToUTF8(str,ret,len)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};ccall=function ccallFunc(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>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)}}Module["setValue"]=setValue;function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";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 setValue: "+type)}return null}Module["getValue"]=getValue;var ALLOC_NORMAL=0;var ALLOC_STACK=1;var ALLOC_STATIC=2;var ALLOC_DYNAMIC=3;var ALLOC_NONE=4;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["ALLOC_STACK"]=ALLOC_STACK;Module["ALLOC_STATIC"]=ALLOC_STATIC;Module["ALLOC_DYNAMIC"]=ALLOC_DYNAMIC;Module["ALLOC_NONE"]=ALLOC_NONE;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=[typeof _malloc==="function"?_malloc:Runtime.staticAlloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var ptr=ret,stop;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}Module["Pointer_stringify"]=Pointer_stringify;function AsciiToString(ptr){var str="";while(1){var ch=HEAP8[ptr++>>0];if(!ch)return str;str+=String.fromCharCode(ch)}}Module["AsciiToString"]=AsciiToString;function stringToAscii(str,outPtr){return writeAsciiToMemory(str,outPtr,false)}Module["stringToAscii"]=stringToAscii;var UTF8Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(u8Array,idx){var endPtr=idx;while(u8Array[endPtr])++endPtr;if(endPtr-idx>16&&u8Array.subarray&&UTF8Decoder){return UTF8Decoder.decode(u8Array.subarray(idx,endPtr))}else{var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}}Module["UTF8ArrayToString"]=UTF8ArrayToString;function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}Module["UTF8ToString"]=UTF8ToString;function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}Module["stringToUTF8Array"]=stringToUTF8Array;function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}Module["stringToUTF8"]=stringToUTF8;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 if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}Module["lengthBytesUTF8"]=lengthBytesUTF8;var UTF16Decoder=typeof TextDecoder!=="undefined"?new TextDecoder("utf-16le"):undefined;function demangle(func){var __cxa_demangle_func=Module["___cxa_demangle"]||Module["__cxa_demangle"];if(__cxa_demangle_func){try{var s=func.substr(1);var len=lengthBytesUTF8(s)+1;var buf=_malloc(len);stringToUTF8(s,buf,len);var status=_malloc(4);var ret=__cxa_demangle_func(buf,0,0,status);if(getValue(status,"i32")===0&&ret){return Pointer_stringify(ret)}}catch(e){}finally{if(buf)_free(buf);if(status)_free(status);if(ret)_free(ret)}return func}Runtime.warnOnce("warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling");return func}function demangleAll(text){var regex=/__Z[\w\d_]+/g;return text.replace(regex,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}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)}Module["stackTrace"]=stackTrace;var HEAP,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateGlobalBufferViews(){Module["HEAP8"]=HEAP8=new Int8Array(buffer);Module["HEAP16"]=HEAP16=new Int16Array(buffer);Module["HEAP32"]=HEAP32=new Int32Array(buffer);Module["HEAPU8"]=HEAPU8=new Uint8Array(buffer);Module["HEAPU16"]=HEAPU16=new Uint16Array(buffer);Module["HEAPU32"]=HEAPU32=new Uint32Array(buffer);Module["HEAPF32"]=HEAPF32=new Float32Array(buffer);Module["HEAPF64"]=HEAPF64=new Float64Array(buffer)}var STATIC_BASE,STATICTOP,staticSealed;var STACK_BASE,STACKTOP,STACK_MAX;var DYNAMIC_BASE,DYNAMICTOP_PTR;STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0;staticSealed=false;function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;if(TOTAL_MEMORY0){var callback=callbacks.shift();if(typeof callback=="function"){callback();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 __ATEXIT__=[];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 ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);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)}Module["addOnPreRun"]=addOnPreRun;function addOnInit(cb){__ATINIT__.unshift(cb)}Module["addOnInit"]=addOnInit;function addOnPreMain(cb){__ATMAIN__.unshift(cb)}Module["addOnPreMain"]=addOnPreMain;function addOnExit(cb){__ATEXIT__.unshift(cb)}Module["addOnExit"]=addOnExit;function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}Module["addOnPostRun"]=addOnPostRun;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}Module["intArrayFromString"]=intArrayFromString;function intArrayToString(array){var ret=[];for(var i=0;i255){chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}Module["intArrayToString"]=intArrayToString;function writeStringToMemory(string,buffer,dontAddNull){Runtime.warnOnce("writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!");var lastChar,end;if(dontAddNull){end=buffer+lengthBytesUTF8(string);lastChar=HEAP8[end]}stringToUTF8(string,buffer,Infinity);if(dontAddNull)HEAP8[end]=lastChar}Module["writeStringToMemory"]=writeStringToMemory;function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}Module["writeArrayToMemory"]=writeArrayToMemory;function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}Module["writeAsciiToMemory"]=writeAsciiToMemory;if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=(function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32});Math.clz32=Math["clz32"];if(!Math["trunc"])Math["trunc"]=(function(x){return x<0?Math.ceil(x):Math.floor(x)});Math.trunc=Math["trunc"];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_clz32=Math.clz32;var Math_trunc=Math.trunc;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}Module["addRunDependency"]=addRunDependency;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["removeRunDependency"]=removeRunDependency;Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var ASM_CONSTS=[];STATIC_BASE=Runtime.GLOBAL_BASE;STATICTOP=STATIC_BASE+32528;__ATINIT__.push();memoryInitializer="synthcore.js.mem";var tempDoublePtr=STATICTOP;STATICTOP+=16;Module["_bitshift64Ashr"]=_bitshift64Ashr;Module["_i64Add"]=_i64Add;Module["_memset"]=_memset;Module["_bitshift64Lshr"]=_bitshift64Lshr;function ___lock(){}function ___unlock(){}var SYSCALLS={varargs:0,get:(function(varargs){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret}),getStr:(function(){var ret=Pointer_stringify(SYSCALLS.get());return ret}),get64:(function(){var low=SYSCALLS.get(),high=SYSCALLS.get();if(low>=0)assert(high===0);else assert(high===-1);return low}),getZero:(function(){assert(SYSCALLS.get()===0)})};function ___syscall6(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD();FS.close(stream);return 0}catch(e){if(typeof FS==="undefined"||!(e instanceof FS.ErrnoError))abort(e);return-e.errno}}Module["___muldsi3"]=___muldsi3;Module["___muldi3"]=___muldi3;function ___setErrNo(value){if(Module["___errno_location"])HEAP32[Module["___errno_location"]()>>2]=value;return value}Module["_sbrk"]=_sbrk;function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest);return dest}Module["_memcpy"]=_memcpy;Module["_memmove"]=_memmove;function _usleep(useconds){var msec=useconds/1e3;if((ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)&&self["performance"]&&self["performance"]["now"]){var start=self["performance"]["now"]();while(self["performance"]["now"]()-start>2];var nanoseconds=HEAP32[rqtp+4>>2];if(rmtp!==0){HEAP32[rmtp>>2]=0;HEAP32[rmtp+4>>2]=0}return _usleep(seconds*1e6+nanoseconds/1e3)}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:(function(adjusted){if(!adjusted||EXCEPTIONS.infos[adjusted])return adjusted;for(var ptr in EXCEPTIONS.infos){var info=EXCEPTIONS.infos[ptr];if(info.adjusted===adjusted){return ptr}}return adjusted}),addRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount++}),decRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];assert(info.refcount>0);info.refcount--;if(info.refcount===0&&!info.rethrown){if(info.destructor){Module["dynCall_vi"](info.destructor,ptr)}delete EXCEPTIONS.infos[ptr];___cxa_free_exception(ptr)}}),clearRef:(function(ptr){if(!ptr)return;var info=EXCEPTIONS.infos[ptr];info.refcount=0})};function ___resumeException(ptr){if(!EXCEPTIONS.last){EXCEPTIONS.last=ptr}throw ptr+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var thrown=EXCEPTIONS.last;if(!thrown){return(Runtime.setTempRet0(0),0)|0}var info=EXCEPTIONS.infos[thrown];var throwntype=info.type;if(!throwntype){return(Runtime.setTempRet0(0),thrown)|0}var typeArray=Array.prototype.slice.call(arguments);var pointer=Module["___cxa_is_pointer_type"](throwntype);if(!___cxa_find_matching_catch.buffer)___cxa_find_matching_catch.buffer=_malloc(4);HEAP32[___cxa_find_matching_catch.buffer>>2]=thrown;thrown=___cxa_find_matching_catch.buffer;for(var i=0;i>2];info.adjusted=thrown;return(Runtime.setTempRet0(typeArray[i]),thrown)|0}}thrown=HEAP32[thrown>>2];return(Runtime.setTempRet0(throwntype),thrown)|0}function ___gxx_personality_v0(){}function ___syscall140(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(),offset_high=SYSCALLS.get(),offset_low=SYSCALLS.get(),result=SYSCALLS.get(),whence=SYSCALLS.get();var offset=offset_low;FS.llseek(stream,offset,whence);HEAP32[result>>2]=stream.position;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 ___syscall146(which,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.get(),iov=SYSCALLS.get(),iovcnt=SYSCALLS.get();var ret=0;if(!___syscall146.buffer){___syscall146.buffers=[null,[],[]];___syscall146.printChar=(function(stream,curr){var buffer=___syscall146.buffers[stream];assert(buffer);if(curr===0||curr===10){(stream===1?Module["print"]:Module["printErr"])(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}})}for(var i=0;i>2];var len=HEAP32[iov+(i*8+4)>>2];for(var j=0;j>2]=DYNAMIC_BASE;staticSealed=true;function invoke_iiii(index,a1,a2,a3){try{return Module["dynCall_iiii"](index,a1,a2,a3)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;Module["setThrew"](1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){try{Module["dynCall_viiiii"](index,a1,a2,a3,a4,a5)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;Module["setThrew"](1,0)}}function invoke_vi(index,a1){try{Module["dynCall_vi"](index,a1)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;Module["setThrew"](1,0)}}function invoke_ii(index,a1){try{return Module["dynCall_ii"](index,a1)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;Module["setThrew"](1,0)}}function invoke_v(index){try{Module["dynCall_v"](index)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;Module["setThrew"](1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){try{Module["dynCall_viiiiii"](index,a1,a2,a3,a4,a5,a6)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;Module["setThrew"](1,0)}}function invoke_viiii(index,a1,a2,a3,a4){try{Module["dynCall_viiii"](index,a1,a2,a3,a4)}catch(e){if(typeof e!=="number"&&e!=="longjmp")throw e;Module["setThrew"](1,0)}}Module.asmGlobalArg={"Math":Math,"Int8Array":Int8Array,"Int16Array":Int16Array,"Int32Array":Int32Array,"Uint8Array":Uint8Array,"Uint16Array":Uint16Array,"Uint32Array":Uint32Array,"Float32Array":Float32Array,"Float64Array":Float64Array,"NaN":NaN,"Infinity":Infinity};Module.asmLibraryArg={"abort":abort,"assert":assert,"enlargeMemory":enlargeMemory,"getTotalMemory":getTotalMemory,"abortOnCannotGrowMemory":abortOnCannotGrowMemory,"invoke_iiii":invoke_iiii,"invoke_viiiii":invoke_viiiii,"invoke_vi":invoke_vi,"invoke_ii":invoke_ii,"invoke_v":invoke_v,"invoke_viiiiii":invoke_viiiiii,"invoke_viiii":invoke_viiii,"___syscall54":___syscall54,"_nanosleep":_nanosleep,"___lock":___lock,"___syscall6":___syscall6,"___setErrNo":___setErrNo,"___syscall140":___syscall140,"___syscall146":___syscall146,"_emscripten_memcpy_big":_emscripten_memcpy_big,"___gxx_personality_v0":___gxx_personality_v0,"___unlock":___unlock,"___resumeException":___resumeException,"__ZSt18uncaught_exceptionv":__ZSt18uncaught_exceptionv,"_usleep":_usleep,"___cxa_find_matching_catch":___cxa_find_matching_catch,"DYNAMICTOP_PTR":DYNAMICTOP_PTR,"tempDoublePtr":tempDoublePtr,"ABORT":ABORT,"STACKTOP":STACKTOP,"STACK_MAX":STACK_MAX};// EMSCRIPTEN_START_ASM +var asm=(function(global,env,buffer) { +"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.DYNAMICTOP_PTR|0;var j=env.tempDoublePtr|0;var k=env.ABORT|0;var l=env.STACKTOP|0;var m=env.STACK_MAX|0;var n=0;var o=0;var p=0;var q=0;var r=global.NaN,s=global.Infinity;var t=0,u=0,v=0,w=0,x=0.0;var y=0;var z=global.Math.floor;var A=global.Math.abs;var B=global.Math.sqrt;var C=global.Math.pow;var D=global.Math.cos;var E=global.Math.sin;var F=global.Math.tan;var G=global.Math.acos;var H=global.Math.asin;var I=global.Math.atan;var J=global.Math.atan2;var K=global.Math.exp;var L=global.Math.log;var M=global.Math.ceil;var N=global.Math.imul;var O=global.Math.min;var P=global.Math.max;var Q=global.Math.clz32;var R=env.abort;var S=env.assert;var T=env.enlargeMemory;var U=env.getTotalMemory;var V=env.abortOnCannotGrowMemory;var W=env.invoke_iiii;var X=env.invoke_viiiii;var Y=env.invoke_vi;var Z=env.invoke_ii;var _=env.invoke_v;var $=env.invoke_viiiiii;var aa=env.invoke_viiii;var ba=env.___syscall54;var ca=env._nanosleep;var da=env.___lock;var ea=env.___syscall6;var fa=env.___setErrNo;var ga=env.___syscall140;var ha=env.___syscall146;var ia=env._emscripten_memcpy_big;var ja=env.___gxx_personality_v0;var ka=env.___unlock;var la=env.___resumeException;var ma=env.__ZSt18uncaught_exceptionv;var na=env._usleep;var oa=env.___cxa_find_matching_catch;var pa=0.0; +// EMSCRIPTEN_START_FUNCS +function xa(a){a=a|0;var b=0;b=l;l=l+a|0;l=l+15&-16;return b|0}function ya(){return l|0}function za(a){a=a|0;l=a}function Aa(a,b){a=a|0;b=b|0;l=a;m=b}function Ba(a,b){a=a|0;b=b|0;if(!n){n=a;o=b}}function Ca(a){a=a|0;y=a}function Da(){return y|0}function Ea(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=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;h=l;l=l+32|0;i=h+16|0;j=h;k=1608+((g|0)>0?((g|0)<127?g:127)>>1:0)|0;g=((f|0)/3|0)+-7|0;m=(g|0)>0?g:0;g=(m|0)<31?m:31;m=(N(f,1398101)|0)+50857777|0;n=i+4|0;o=j+4|0;p=i+8|0;q=j+8|0;r=i+12|0;s=j+12|0;t=0;do{u=t*21|0;c[i>>2]=a[e+u>>0];c[j>>2]=a[e+(u+4)>>0];c[n>>2]=a[e+(u+1)>>0];c[o>>2]=a[e+(u+5)>>0];c[p>>2]=a[e+(u+2)>>0];c[q>>2]=a[e+(u+6)>>0];c[r>>2]=a[e+(u+3)>>0];c[s>>2]=a[e+(u+7)>>0];v=Ka(a[e+(u+16)>>0]|0)|0;w=a[e+(u+9)>>0]|0;x=a[e+(u+10)>>0]|0;y=a[e+(u+11)>>0]|0;A=a[e+(u+12)>>0]|0;B=f-(a[e+(u+8)>>0]|0)|0;C=B+-17|0;a:do if((C|0)>-1){D=(C>>>0)/3|0;switch(A|0){case 0:case 3:{E=x;F=D;G=12;H=A;break a;break}default:{}}E=x;F=d[1672+(D>>>0<32?D:32)>>0]|0;G=15;H=A}else{D=(17-B|0)/3|0;switch(y|0){case 0:case 3:{E=w;F=D;G=12;H=y;break a;break}default:{}}E=w;F=d[1672+((D|0)<32?D:32)>>0]|0;G=15;H=y}while(0);y=(N(E*329|0,F)|0)>>G;w=((H|0)<2?0-y|0:y)+v|0;y=(((N((d[k>>0]|0)+-239|0,a[e+(u+15)>>0]|0)|0)+7|0)>>>3<<4)+(((w|0)<127?w:127)<<5)|0;Ha(b+544+(t<<6)|0,i,j,(y|0)>0?y:0,(N(a[e+(u+13)>>0]|0,g)|0)>>3);y=a[e+(u+18)>>0]|0;w=a[e+(u+19)>>0]|0;B=a[e+(u+20)>>0]|0;A=B<<24>>24;if(!(a[e+(u+17)>>0]|0)){x=m+(c[112+((y&31)<<2)>>2]|0)|0;if(!(w<<24>>24))I=x;else I=~~+z(+(+L(+(+(w<<24>>24)*.01+1.0))*24204406.323123+.5))+x|0;J=(A*12606|0)+-88242+I|0}else{x=(N(((y&3)*100|0)+(w<<24>>24)|0,4458616)|0)>>3;J=x+(B<<24>>24>7?(A*13457|0)+-94199|0:0)|0}c[b+1080+(t<<2)>>2]=J;c[b+928+(t<<4)+12>>2]=0;c[b+928+(t<<4)+4>>2]=0;t=t+1|0}while((t|0)!=6);c[i>>2]=a[e+126>>0];c[j>>2]=a[e+130>>0];c[n>>2]=a[e+127>>0];c[o>>2]=a[e+131>>0];c[p>>2]=a[e+128>>0];c[q>>2]=a[e+132>>0];c[r>>2]=a[e+129>>0];c[s>>2]=a[e+133>>0];_a(b+1024|0,i,j);c[b+1116>>2]=a[e+134>>0];j=a[e+135>>0]|0;c[b+1112>>2]=j<<24>>24?8-(j<<24>>24)|0:16;c[b+1120>>2]=(a[e+139>>0]|0)*165>>6;c[b+1124>>2]=d[1705+(a[e+143>>0]&7)>>0];l=h;return}function Fa(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0;g=$a(a+1024|0)|0;h=N(c[a+1120>>2]|0,e)|0;e=N(c[a+1124>>2]|0,d+-8388608|0)|0;d=pc(e|0,((e|0)<0)<<31>>31|0,h|0,0)|0;h=kc(d|0,y|0,39)|0;d=lc(h|0,y|0,g|0,0)|0;g=(c[f+512>>2]<<9)+-4194304+d|0;d=0;do{f=a+928+(d<<4)+4|0;c[a+928+(d<<4)>>2]=c[f>>2];h=(Ia(a+544+(d<<6)|0)|0)+-234881024|0;e=h>>>13&2046;i=c[2224+(e<<2)>>2]|0;j=c[2224+((e|1)<<2)>>2]|0;e=pc(h&16383|0,0,i|0,((i|0)<0)<<31>>31|0)|0;i=nc(e|0,y|0,14)|0;e=lc(i|0,y|0,j|0,0)|0;c[a+928+(d<<4)+8>>2]=Sa(g+(c[a+1080+(d<<2)>>2]|0)|0)|0;c[f>>2]=e>>6-(h>>24);d=d+1|0}while((d|0)!=6);Na(a,b,a+928|0,c[a+1116>>2]|0,a+1104|0,c[a+1112>>2]|0);return}function Ga(a){a=a|0;var b=0;b=a+1024|0;Ja(a+544|0,0);ab(b,0);Ja(a+608|0,0);ab(b,0);Ja(a+672|0,0);ab(b,0);Ja(a+736|0,0);ab(b,0);Ja(a+800|0,0);ab(b,0);Ja(a+864|0,0);ab(b,0);return}function Ha(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;h=c[d>>2]|0;c[b>>2]=h;i=c[e>>2]|0;c[b+16>>2]=i;c[b+4>>2]=c[d+4>>2];c[b+20>>2]=c[e+4>>2];c[b+8>>2]=c[d+8>>2];c[b+24>>2]=c[e+8>>2];c[b+12>>2]=c[d+12>>2];c[b+28>>2]=c[e+12>>2];c[b+32>>2]=f;c[b+36>>2]=g;c[b+40>>2]=0;a[b+60>>0]=1;c[b+52>>2]=0;if((i|0)>19)j=i+28|0;else j=c[240+(i<<2)>>2]|0;i=f+-4256+(j>>>1<<6)|0;j=((i|0)>16?i:16)<<16;c[b+44>>2]=j;a[b+48>>0]=(j|0)>0&1;j=(h*41>>6)+g|0;g=(j|0)<63?j:63;c[b+56>>2]=(g&3|4)<<(g>>2)+8;return}function Ia(b){b=b|0;var 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;d=b+52|0;e=c[d>>2]|0;if((e|0)>=3){if((e|0)!=3){f=b+40|0;g=c[f>>2]|0;return g|0}if(a[b+60>>0]|0){f=b+40|0;g=c[f>>2]|0;return g|0}}h=b+48|0;i=b+44|0;j=c[i>>2]|0;k=b+56|0;l=c[k>>2]|0;m=b+40|0;n=c[m>>2]|0;if(!(a[h>>0]|0)){o=n-l|0;c[m>>2]=o;if((o|0)>(j|0)){f=b+40|0;g=c[f>>2]|0;return g|0}c[m>>2]=j;o=e+1|0;c[d>>2]=o;if((o|0)>=4){f=b+40|0;g=c[f>>2]|0;return g|0}p=c[b+16+(o<<2)>>2]|0;if((p|0)>19)q=p+28|0;else q=c[240+(p<<2)>>2]|0;p=(c[b+32>>2]|0)+-4256+(q>>>1<<6)|0;q=((p|0)>16?p:16)<<16;c[i>>2]=q;a[h>>0]=(q|0)>(j|0)&1;q=((c[b+(o<<2)>>2]|0)*41>>6)+(c[b+36>>2]|0)|0;o=(q|0)<63?q:63;c[k>>2]=(o&3|4)<<(o>>2)+8;f=b+40|0;g=c[f>>2]|0;return g|0}if((n|0)<112459776){c[m>>2]=112459776;r=112459776}else r=n;n=(N(285212672-r>>24,l)|0)+r|0;c[m>>2]=n;if((n|0)<(j|0)){f=b+40|0;g=c[f>>2]|0;return g|0}c[m>>2]=j;m=e+1|0;c[d>>2]=m;if((m|0)>=4){f=b+40|0;g=c[f>>2]|0;return g|0}d=c[b+16+(m<<2)>>2]|0;if((d|0)>19)s=d+28|0;else s=c[240+(d<<2)>>2]|0;d=(c[b+32>>2]|0)+-4256+(s>>>1<<6)|0;s=((d|0)>16?d:16)<<16;c[i>>2]=s;a[h>>0]=(s|0)>(j|0)&1;j=((c[b+(m<<2)>>2]|0)*41>>6)+(c[b+36>>2]|0)|0;m=(j|0)<63?j:63;c[k>>2]=(m&3|4)<<(m>>2)+8;f=b+40|0;g=c[f>>2]|0;return g|0}function Ja(b,e){b=b|0;e=e|0;var f=0,g=0;f=b+60|0;if((d[f>>0]|0|0)==(e&1|0))return;a[f>>0]=e&1;f=e?0:3;c[b+52>>2]=f;e=c[b+16+(f<<2)>>2]|0;if((e|0)>19)g=e+28|0;else g=c[240+(e<<2)>>2]|0;e=(c[b+32>>2]|0)+-4256+(g>>>1<<6)|0;g=((e|0)>16?e:16)<<16;c[b+44>>2]=g;a[b+48>>0]=(g|0)>(c[b+40>>2]|0)&1;g=((c[b+(f<<2)>>2]|0)*41>>6)+(c[b+36>>2]|0)|0;f=(g|0)<63?g:63;c[b+56>>2]=(f&3|4)<<(f>>2)+8;return}function Ka(a){a=a|0;var b=0;if((a|0)>19){b=a+28|0;return b|0}else{b=c[240+(a<<2)>>2]|0;return b|0}return 0}function La(){var a=0,b=0.0,d=0;a=0;b=1073741824.0;while(1){c[2224+((a<<1|1)<<2)>>2]=~~+z(+(b+.5));a=a+1|0;if((a|0)==1024){d=0;break}else b=b*1.0006771306930664}do{a=d<<1;c[2224+(a<<2)>>2]=(c[2224+(a+3<<2)>>2]|0)-(c[2224+((a|1)<<2)>>2]|0);d=d+1|0}while((d|0)!=1023);c[2602]=-2147483648-(c[2603]|0);return}function Ma(){var a=0,b=0.0,d=0.0,e=0.0,f=0.0,g=0.0,h=0;a=0;b=0.0;do{c[10416+((a<<1|1)<<2)>>2]=~~(b*16777216.0+.5);d=1.0-b*b;e=b+d*.001953125;f=1.0-e*e;e=b+f*.001953125;g=1.0-e*e;e=b+g*.00390625;b=b+((f+g)*2.0+(d+(1.0-e*e)))*6.510416666666666e-04;a=a+1|0}while((a|0)!=1024);h=0;do{a=h<<1;c[10416+(a<<2)>>2]=(c[10416+(a+3<<2)>>2]|0)-(c[10416+((a|1)<<2)>>2]|0);h=h+1|0}while((h|0)!=1023);c[4650]=~~(b*16777216.0+.5)-(c[4651]|0);return}function Na(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;i=l;l=l+32|0;j=i;k=i+24|0;m=320+(f*24|0)|0;c[j>>2]=c[m>>2];c[j+4>>2]=c[m+4>>2];c[j+8>>2]=c[m+8>>2];c[j+12>>2]=c[m+12>>2];c[j+16>>2]=c[m+16>>2];c[j+20>>2]=c[m+20>>2];a[k>>0]=a[1713]|0;a[k+1>>0]=a[1714]|0;a[k+2>>0]=a[1715]|0;if((h|0)<16)n=0;else{m=0;do{f=c[j+(m<<2)>>2]|0;o=f&4;p=f>>>4&3;q=f&3;f=(q|0)==0?d:b+((q+-1|0)*272|0)+15&-16;r=c[e+(m<<4)>>2]|0;s=c[e+(m<<4)+4>>2]|0;do if(!((r|0)>1119|(s|0)>1119)){if(!o){t=k+q|0;u=0;v=21}}else{w=k+q|0;x=(o|0)!=0&(a[w>>0]|0)!=0;if(p|0?a[k+p>>0]|0:0){Oa(f,b+((p+-1|0)*272|0)+15&-16,c[e+(m<<4)+12>>2]|0,c[e+(m<<4)+8>>2]|0,r,s,x);t=w;u=1;v=21;break}Pa(f,c[e+(m<<4)+12>>2]|0,c[e+(m<<4)+8>>2]|0,r,s,x);t=w;u=1;v=21}while(0);if((v|0)==21){v=0;a[t>>0]=u}s=e+(m<<4)+12|0;c[s>>2]=(c[s>>2]|0)+(c[e+(m<<4)+8>>2]<<6);m=m+1|0}while((m|0)!=6);l=i;return}do{m=c[j+(n<<2)>>2]|0;u=m&4;t=m>>>4&3;s=m&3;r=(s|0)==0?d:b+((s+-1|0)*272|0)+15&-16;f=c[e+(n<<4)>>2]|0;p=c[e+(n<<4)+4>>2]|0;do if((f|0)>1119|(p|0)>1119){o=k+s|0;q=(u|0)!=0&(a[o>>0]|0)!=0;if(t|0?a[k+t>>0]|0:0){Oa(r,b+((t+-1|0)*272|0)+15&-16,c[e+(n<<4)+12>>2]|0,c[e+(n<<4)+8>>2]|0,f,p,q);y=o;z=1;v=11;break}w=c[e+(n<<4)+12>>2]|0;x=c[e+(n<<4)+8>>2]|0;if((m&192|0)==192){Qa(r,w,x,f,p,g,h,q);y=o;z=1;v=11;break}else{Pa(r,w,x,f,p,q);y=o;z=1;v=11;break}}else if(!u){y=k+s|0;z=0;v=11}while(0);if((v|0)==11){v=0;a[y>>0]=z}s=e+(n<<4)+12|0;c[s>>2]=(c[s>>2]|0)+(c[e+(n<<4)+8>>2]<<6);n=n+1|0}while((n|0)!=6);l=i;return}function Oa(a,b,d,e,f,g,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0;i=32-f+g>>6;if(h){h=d;g=0;j=f;while(1){j=j+i|0;k=(c[b+(g<<2)>>2]|0)+h|0;l=k>>>13&2046;m=c[22716+(l<<2)>>2]|0;n=c[22716+((l|1)<<2)>>2]|0;l=pc(k&16383|0,0,m|0,((m|0)<0)<<31>>31|0)|0;m=nc(l|0,y|0,14)|0;l=lc(m|0,y|0,n|0,0)|0;n=kc(0,l|0,32)|0;l=pc(n|0,y|0,j|0,((j|0)<0)<<31>>31|0)|0;n=nc(l|0,y|0,24)|0;l=a+(g<<2)|0;m=lc(n|0,y|0,c[l>>2]|0,0)|0;c[l>>2]=m;g=g+1|0;if((g|0)==64)break;else h=h+e|0}return}else{h=0;g=d;d=f;while(1){d=d+i|0;f=(c[b+(h<<2)>>2]|0)+g|0;j=f>>>13&2046;m=c[22716+(j<<2)>>2]|0;l=c[22716+((j|1)<<2)>>2]|0;j=pc(f&16383|0,0,m|0,((m|0)<0)<<31>>31|0)|0;m=nc(j|0,y|0,14)|0;j=lc(m|0,y|0,l|0,0)|0;l=kc(0,j|0,32)|0;j=pc(l|0,y|0,d|0,((d|0)<0)<<31>>31|0)|0;l=nc(j|0,y|0,24)|0;c[a+(h<<2)>>2]=l;h=h+1|0;if((h|0)==64)break;else g=g+e|0}return}}function Pa(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0;h=32-e+f>>6;if(g){g=b;f=0;i=e;while(1){i=i+h|0;j=g>>>13&2046;k=c[22716+(j<<2)>>2]|0;l=c[22716+((j|1)<<2)>>2]|0;j=pc(k|0,((k|0)<0)<<31>>31|0,g&16383|0,0)|0;k=nc(j|0,y|0,14)|0;j=lc(k|0,y|0,l|0,0)|0;l=kc(0,j|0,32)|0;j=pc(l|0,y|0,i|0,((i|0)<0)<<31>>31|0)|0;l=nc(j|0,y|0,24)|0;j=a+(f<<2)|0;k=lc(l|0,y|0,c[j>>2]|0,0)|0;c[j>>2]=k;f=f+1|0;if((f|0)==64)break;else g=g+d|0}return}else{g=0;f=b;b=e;while(1){b=b+h|0;e=f>>>13&2046;i=c[22716+(e<<2)>>2]|0;k=c[22716+((e|1)<<2)>>2]|0;e=pc(i|0,((i|0)<0)<<31>>31|0,f&16383|0,0)|0;i=nc(e|0,y|0,14)|0;e=lc(i|0,y|0,k|0,0)|0;k=kc(0,e|0,32)|0;e=pc(k|0,y|0,b|0,((b|0)<0)<<31>>31|0)|0;k=nc(e|0,y|0,24)|0;c[a+(g<<2)>>2]=k;g=g+1|0;if((g|0)==64)break;else f=f+d|0}return}}function Qa(a,b,d,e,f,g,h,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;j=32-e+f>>6;f=c[g>>2]|0;k=g+4|0;l=c[k>>2]|0;m=h+1|0;if(i){i=b;h=0;n=l;o=f;p=e;while(1){p=p+j|0;q=i+(n+o>>m)|0;r=q>>>13&2046;s=c[22716+(r<<2)>>2]|0;t=c[22716+((r|1)<<2)>>2]|0;r=pc(s|0,((s|0)<0)<<31>>31|0,q&16383|0,0)|0;q=nc(r|0,y|0,14)|0;r=lc(q|0,y|0,t|0,0)|0;t=kc(0,r|0,32)|0;r=pc(t|0,y|0,p|0,((p|0)<0)<<31>>31|0)|0;t=nc(r|0,y|0,24)|0;r=a+(h<<2)|0;c[r>>2]=t+(c[r>>2]|0);h=h+1|0;if((h|0)==64){u=t;v=n;break}else{r=n;i=i+d|0;n=t;o=r}}c[g>>2]=v;c[k>>2]=u;return}else{o=0;n=b;b=l;l=f;f=e;while(1){f=f+j|0;e=(b+l>>m)+n|0;i=e>>>13&2046;h=c[22716+(i<<2)>>2]|0;p=c[22716+((i|1)<<2)>>2]|0;i=pc(h|0,((h|0)<0)<<31>>31|0,e&16383|0,0)|0;e=nc(i|0,y|0,14)|0;i=lc(e|0,y|0,p|0,0)|0;p=kc(0,i|0,32)|0;i=pc(p|0,y|0,f|0,((f|0)<0)<<31>>31|0)|0;p=nc(i|0,y|0,24)|0;c[a+(o<<2)>>2]=p;o=o+1|0;if((o|0)==64){u=p;v=b;break}else{i=b;n=n+d|0;b=p;l=i}}c[g>>2]=v;c[k>>2]=u;return}}function Ra(a){a=+a;var b=0.0,d=0;b=17592186044416.0/a;d=0;while(1){c[18608+(d<<2)>>2]=~~+z(+(b+.5));d=d+1|0;if((d|0)==1025)break;else b=b*1.0006771306930664}return}function Sa(a){a=a|0;var b=0,d=0,e=0;b=a>>>14&1023;d=c[18608+(b<<2)>>2]|0;e=(c[18608+(b+1<<2)>>2]|0)-d|0;b=pc(e|0,((e|0)<0)<<31>>31|0,a&16383|0,0)|0;e=nc(b|0,y|0,14)|0;b=lc(e|0,y|0,d|0,0)|0;return b>>20-(a>>24)|0}function Ta(a){a=+a;c[5677]=~~(1612187136.0/a+.5);return}function Ua(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=a[d>>0]|0;f=(e<<24>>24)*165>>6;if(!(e<<24>>24)){g=11;h=1}else{g=(f|0)<160?11:(f+-160>>4)+11|0;h=f}f=N(g,h)|0;h=c[5677]|0;c[b+4>>2]=N(f,h)|0;f=a[d+1>>0]|0;g=99-(f<<24>>24)|0;if(!(f<<24>>24)){i=-1;j=-1}else{f=(g&15|16)<<(g>>4)+1;g=N(f,h)|0;e=f&65408;i=N(h,e>>>0>128?e:128)|0;j=g}c[b+16>>2]=j;c[b+20>>2]=i;a[b+8>>0]=a[d+5>>0]|0;a[b+10>>0]=(a[d+4>>0]|0)!=0&1;return}function Va(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;d=c[b+4>>2]|0;e=(c[b>>2]|0)+d|0;c[b>>2]=e;switch(a[b+8>>0]|0){case 0:{f=(e>>>7^e>>31)&16777215;return f|0}case 1:{f=e>>>8^8388607;return f|0}case 2:{f=e>>>8^8388608;return f|0}case 3:{f=e>>>7&16777216^16777216;return f|0}case 4:{g=e>>>21;h=c[22716+((g&2046)<<2)>>2]|0;i=c[22716+((g|1)<<2)>>2]|0;f=((lc(nc(pc(h|0,((h|0)<0)<<31>>31|0,e>>>8&16383|0,0)|0,y|0,14)|0,y|0,i|0,0)|0)>>1)+8388608|0;return f|0}case 5:{i=b+9|0;b=a[i>>0]|0;if(e>>>0>>0){d=((b&255)*179|0)+17&255;a[i>>0]=d;j=d}else j=b;f=(((j^-128)&255)<<16)+65536|0;return f|0}default:{f=8388608;return f|0}}return 0}function Wa(a){a=a|0;var b=0,d=0,e=0,f=0;b=a+12|0;d=c[b>>2]|0;e=a+16|0;f=(c[((d|0)>-1?e:a+20|0)>>2]|0)+d|0;if(f>>>0<(c[e>>2]|0)>>>0)return 16777216;else{c[b>>2]=f;return ((f|0)>-1?0:f>>>7&16777215)|0}return 0}function Xa(b){b=b|0;if(a[b+10>>0]|0)c[b>>2]=2147483647;c[b+12>>2]=0;return}function Ya(b,c){b=b|0;c=c|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;e=0;do{f=e*21|0;g=e*17|0;h=c+f|0;i=b+g|0;j=h+11|0;do{a[h>>0]=a[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));k=a[b+(g+11)>>0]|0;a[c+(f+11)>>0]=k&3;a[c+(f+12)>>0]=k>>>2&3;k=a[b+(g+12)>>0]|0;a[c+(f+13)>>0]=k&7;a[c+(f+20)>>0]=k>>>3;k=a[b+(g+13)>>0]|0;a[c+(f+14)>>0]=k&3;a[c+(f+15)>>0]=k>>>2;a[c+(f+16)>>0]=a[b+(g+14)>>0]|0;k=a[b+(g+15)>>0]|0;a[c+(f+17)>>0]=k&1;a[c+(f+18)>>0]=k>>>1;a[c+(f+19)>>0]=a[b+(g+16)>>0]|0;e=e+1|0}while((e|0)!=6);h=c+126|0;i=b+102|0;j=h+9|0;do{a[h>>0]=a[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));e=a[b+111>>0]|0;a[c+135>>0]=e&7;a[c+136>>0]=e>>>3;e=c+137|0;k=b+112|0;l=d[k>>0]|d[k+1>>0]<<8|d[k+2>>0]<<16|d[k+3>>0]<<24;a[e>>0]=l;a[e+1>>0]=l>>8;a[e+2>>0]=l>>16;a[e+3>>0]=l>>24;l=a[b+116>>0]|0;a[c+141>>0]=l&1;a[c+142>>0]=l>>>1&7;a[c+143>>0]=l>>>4;h=c+144|0;i=b+117|0;j=h+11|0;do{a[h>>0]=a[i>>0]|0;h=h+1|0;i=i+1|0}while((h|0)<(j|0));a[c+155>>0]=63;return}function Za(a){a=+a;c[5678]=~~(1073741824.0/(a*21.3)+.5);return}function _a(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0;g=c[e>>2]|0;c[b>>2]=g;h=c[f>>2]|0;c[b+16>>2]=h;c[b+4>>2]=c[e+4>>2];c[b+20>>2]=c[f+4>>2];c[b+8>>2]=c[e+8>>2];c[b+24>>2]=c[f+8>>2];c[b+12>>2]=c[e+12>>2];e=f+12|0;c[b+28>>2]=c[e>>2];f=a[1716+(c[e>>2]|0)>>0]<<19;c[b+32>>2]=f;a[b+52>>0]=1;c[b+44>>2]=0;e=a[1716+h>>0]<<19;c[b+36>>2]=e;a[b+40>>0]=(e|0)>(f|0)&1;c[b+48>>2]=N(d[1816+g>>0]|0,c[5678]|0)|0;return}function $a(b){b=b|0;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;e=b+44|0;f=c[e>>2]|0;if((f|0)>=3){if((f|0)==3?(a[b+52>>0]|0)==0:0)g=4}else g=4;do if((g|0)==4){h=b+40|0;i=b+48|0;j=c[i>>2]|0;k=b+32|0;l=c[k>>2]|0;m=b+36|0;n=c[m>>2]|0;if(!(a[h>>0]|0)){o=l-j|0;c[k>>2]=o;if((o|0)>(n|0))break;c[k>>2]=n;o=f+1|0;c[e>>2]=o;if((o|0)>=4)break;p=a[1716+(c[b+16+(o<<2)>>2]|0)>>0]<<19;c[m>>2]=p;a[h>>0]=(p|0)>(n|0)&1;c[i>>2]=N(d[1816+(c[b+(o<<2)>>2]|0)>>0]|0,c[5678]|0)|0;break}else{o=l+j|0;c[k>>2]=o;if((o|0)<(n|0))break;c[k>>2]=n;k=f+1|0;c[e>>2]=k;if((k|0)>=4)break;o=a[1716+(c[b+16+(k<<2)>>2]|0)>>0]<<19;c[m>>2]=o;a[h>>0]=(o|0)>(n|0)&1;c[i>>2]=N(d[1816+(c[b+(k<<2)>>2]|0)>>0]|0,c[5678]|0)|0;break}}while(0);return c[b+32>>2]|0}function ab(b,e){b=b|0;e=e|0;var f=0;f=b+52|0;if((d[f>>0]|0)==(e&1|0))return;a[f>>0]=e&1;f=e?0:3;c[b+44>>2]=f;e=a[1716+(c[b+16+(f<<2)>>2]|0)>>0]<<19;c[b+36>>2]=e;a[b+40>>0]=(e|0)>(c[b+32>>2]|0)&1;c[b+48>>2]=N(d[1816+(c[b+(f<<2)>>2]|0)>>0]|0,c[5678]|0)|0;return}function bb(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=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.0,O=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0;e=l;l=l+112|0;h=e;i=+(c[d+8>>2]|0)*5.9604644775390625e-08;j=c[b>>2]|0;b=c[f>>2]|0;f=e+16+15&-16;k=Sa(c[d>>2]|0)|0;m=d+4|0;cb(f,(k|0)<16777216?k:16777216,c[m>>2]|0);if(i<.01){k=f+16|0;d=a+4+15&-16;n=f+32|0;o=d+4|0;p=f+48|0;q=d+8|0;r=f+64|0;s=d+12|0;t=f+20|0;u=f+36|0;v=f+52|0;w=f+68|0;x=h+4|0;y=f+24|0;z=f+40|0;A=f+56|0;C=f+72|0;D=h+8|0;E=f+28|0;F=f+44|0;G=f+60|0;H=f+76|0;I=h+12|0;J=f+4|0;K=f+8|0;L=f+12|0;M=0;do{N=+(c[j+(M<<2)>>2]|0);O=+g[o>>2];P=+g[q>>2];Q=+g[s>>2];R=+g[k>>2]*+g[d>>2]+ +g[n>>2]*O+ +g[p>>2]*P+ +g[r>>2]*Q;g[h>>2]=R;g[x>>2]=+g[t>>2]*+g[d>>2]+ +g[u>>2]*O+ +g[v>>2]*P+ +g[w>>2]*Q;g[D>>2]=+g[y>>2]*+g[d>>2]+ +g[z>>2]*+g[o>>2]+ +g[A>>2]*P+ +g[C>>2]*Q;g[I>>2]=+g[E>>2]*+g[d>>2]+ +g[F>>2]*+g[o>>2]+ +g[G>>2]*+g[q>>2]+ +g[H>>2]*Q;g[d>>2]=R+N*+g[f>>2];g[o>>2]=+g[x>>2]+N*+g[J>>2];g[q>>2]=+g[D>>2]+N*+g[K>>2];R=+g[I>>2]+N*+g[L>>2];g[s>>2]=R;c[b+(M<<2)>>2]=~~R;M=M+1|0}while((M|0)!=64);l=e;return}R=+(c[m>>2]|0)*5.9604644775390625e-08;m=f+16|0;N=+g[m>>2]+-1.0;g[m>>2]=N;M=f+64|0;Q=+g[M>>2]+R*+g[f>>2];g[M>>2]=Q;s=f+36|0;P=+g[s>>2]+-1.0;g[s>>2]=P;L=f+4|0;I=f+68|0;O=+g[I>>2]+R*+g[L>>2];g[I>>2]=O;K=f+56|0;S=+g[K>>2]+-1.0;g[K>>2]=S;D=f+8|0;q=f+72|0;T=+g[q>>2]+R*+g[D>>2];g[q>>2]=T;J=f+76|0;x=f+12|0;U=+g[J>>2]+-1.0+R*+g[x>>2];g[J>>2]=U;V=i+1.0;o=a+4+15&-16;a=f+32|0;d=f+48|0;H=f+20|0;G=f+52|0;F=h+4|0;E=f+24|0;C=f+40|0;A=h+8|0;z=f+28|0;y=f+44|0;w=f+60|0;v=h+12|0;u=o+12|0;t=o+4|0;r=o+8|0;p=0;W=N;N=Q;Q=P;P=O;O=S;S=T;T=U;while(1){U=+g[o>>2];X=i*U*5.9604644775390625e-08;Y=U*(1.0/+B(+(X*X+1.0)));X=+g[t>>2];U=i*X*5.9604644775390625e-08;Z=X*(1.0/+B(+(U*U+1.0)));U=+g[r>>2];X=i*U*5.9604644775390625e-08;_=U*(1.0/+B(+(X*X+1.0)));X=+g[u>>2];U=i*X*5.9604644775390625e-08;$=X*(1.0/+B(+(U*U+1.0)));U=+(c[j+(p<<2)>>2]|0);X=W*Y+ +g[a>>2]*Z+ +g[d>>2]*_+N*$;g[h>>2]=X;g[F>>2]=+g[H>>2]*Y+Q*Z+ +g[G>>2]*_+P*$;g[A>>2]=+g[E>>2]*Y+ +g[C>>2]*Z+O*_+S*$;g[v>>2]=+g[z>>2]*Y+ +g[y>>2]*Z+ +g[w>>2]*_+T*$;$=+g[u>>2];_=U-R*$;U=i*_*5.9604644775390625e-08;Z=1.0/+B(+(U*U+1.0))*_;g[o>>2]=+g[o>>2]+(X+Z*+g[f>>2]);g[t>>2]=+g[t>>2]+(+g[F>>2]+Z*+g[L>>2]);g[r>>2]=+g[r>>2]+(+g[A>>2]+Z*+g[D>>2]);X=$+(+g[v>>2]+Z*+g[x>>2]);g[u>>2]=X;c[b+(p<<2)>>2]=~~(V*X);n=p+1|0;if((n|0)==64)break;p=n;W=+g[m>>2];N=+g[M>>2];Q=+g[s>>2];P=+g[I>>2];O=+g[K>>2];S=+g[q>>2];T=+g[J>>2]}l=e;return}function cb(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0.0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=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,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0.0,ja=0.0,ka=0.0,la=0.0,ma=0.0,na=0.0,oa=0.0,pa=0.0,qa=0.0,ra=0.0,sa=0.0,ta=0.0,ua=0.0,va=0.0,wa=0.0,xa=0.0,ya=0.0,za=0.0,Aa=0.0,Ba=0.0,Ca=0.0,Da=0.0,Ea=0.0,Fa=0.0,Ga=0.0,Ha=0.0,Ia=0.0,Ja=0.0,Ka=0.0,La=0.0,Ma=0.0,Na=0.0,Oa=0.0,Pa=0.0,Qa=0.0,Ra=0.0,Sa=0;e=l;l=l+320|0;f=e+240|0;h=e+160|0;i=e+80|0;j=e;k=+(b|0)*3.725290298461914e-09;m=+(d|0)*5.9604644775390625e-08;n=m<3.9800000190734863?m:3.9800000190734863;d=f+4|0;b=d+72|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(b|0));g[f>>2]=k;m=-k;o=f+16|0;g[o>>2]=m;g[f+20>>2]=k;g[f+36>>2]=m;g[f+40>>2]=k;g[f+56>>2]=m;g[f+60>>2]=k;g[f+64>>2]=-(k*n);g[f+76>>2]=m;d=h;b=d+76|0;do{c[d>>2]=0;d=d+4|0}while((d|0)<(b|0));p=h+16|0;g[p>>2]=1.0;q=h+36|0;g[q>>2]=1.0;r=h+56|0;g[r>>2]=1.0;s=h+76|0;g[s>>2]=1.0;d=i;t=f;b=d+80|0;do{c[d>>2]=c[t>>2];d=d+4|0;t=t+4|0}while((d|0)<(b|0));u=i+4|0;v=h+4|0;w=i+8|0;x=h+8|0;y=i+12|0;z=h+12|0;A=i+16|0;B=i+20|0;C=h+20|0;D=i+24|0;E=h+24|0;F=i+28|0;G=h+28|0;H=i+32|0;I=h+32|0;J=i+36|0;K=i+40|0;L=h+40|0;M=i+44|0;N=h+44|0;O=i+48|0;P=h+48|0;Q=i+52|0;R=h+52|0;S=i+56|0;T=i+60|0;U=h+60|0;V=i+64|0;W=h+64|0;X=i+68|0;Y=h+68|0;Z=i+72|0;_=h+72|0;$=i+76|0;aa=f+4|0;ba=f+8|0;ca=f+12|0;da=j+4|0;ea=j+8|0;fa=j+12|0;ga=j+16|0;ha=0;m=0.0;n=0.0;k=0.0;ia=0.0;ja=1.0;ka=0.0;la=0.0;ma=0.0;na=0.0;oa=1.0;pa=0.0;qa=0.0;ra=0.0;sa=0.0;ta=0.0;ua=0.0;va=0.0;wa=0.0;xa=1.0;while(1){ya=+g[1100+(ha<<2)>>2];g[h>>2]=ta+ya*+g[i>>2];g[v>>2]=ua+ya*+g[u>>2];g[x>>2]=va+ya*+g[w>>2];g[z>>2]=wa+ya*+g[y>>2];za=+g[A>>2];g[p>>2]=xa+ya*za;Aa=+g[B>>2];g[C>>2]=m+ya*Aa;Ba=+g[D>>2];g[E>>2]=n+ya*Ba;Ca=+g[F>>2];g[G>>2]=k+ya*Ca;Da=+g[H>>2];g[I>>2]=ia+ya*Da;Ea=+g[J>>2];g[q>>2]=ja+ya*Ea;Fa=+g[K>>2];g[L>>2]=ka+ya*Fa;Ga=+g[M>>2];g[N>>2]=la+ya*Ga;Ha=+g[O>>2];g[P>>2]=ma+ya*Ha;Ia=+g[Q>>2];g[R>>2]=na+ya*Ia;Ja=+g[S>>2];g[r>>2]=oa+ya*Ja;Ka=+g[T>>2];g[U>>2]=pa+ya*Ka;La=+g[V>>2];g[W>>2]=qa+ya*La;Ma=+g[X>>2];g[Y>>2]=ra+ya*Ma;Na=+g[Z>>2];g[_>>2]=sa+ya*Na;Oa=+g[$>>2];g[s>>2]=+g[s>>2]+ya*Oa;if((ha|0)==3)break;ya=+g[f>>2];Pa=+g[aa>>2];Qa=+g[ba>>2];Ra=+g[ca>>2];g[j>>2]=za*ya+Da*Pa+Ha*Qa+La*Ra;g[da>>2]=Aa*ya+Ea*Pa+Ia*Qa+Ma*Ra;g[ea>>2]=Ba*ya+Fa*Pa+Ja*Qa+Na*Ra;g[fa>>2]=Ca*ya+Ga*Pa+Ka*Qa+Oa*Ra;db(ga,A,o);d=i;t=j;b=d+80|0;do{c[d>>2]=c[t>>2];d=d+4|0;t=t+4|0}while((d|0)<(b|0));Sa=ha+1|0;if((Sa|0)==4)break;ha=Sa;m=+g[C>>2];n=+g[E>>2];k=+g[G>>2];ia=+g[I>>2];ja=+g[q>>2];ka=+g[L>>2];la=+g[N>>2];ma=+g[P>>2];na=+g[R>>2];oa=+g[r>>2];pa=+g[U>>2];qa=+g[W>>2];ra=+g[Y>>2];sa=+g[_>>2];ta=+g[h>>2];ua=+g[v>>2];va=+g[x>>2];wa=+g[z>>2];xa=+g[p>>2]}ha=j+4|0;i=j+8|0;o=j+12|0;A=j+16|0;ga=0;xa=+g[h>>2];wa=+g[v>>2];va=+g[x>>2];ua=+g[z>>2];do{g[j>>2]=+g[p>>2]*xa+ +g[I>>2]*wa+ +g[P>>2]*va+ +g[W>>2]*ua;g[ha>>2]=+g[C>>2]*xa+ +g[q>>2]*wa+ +g[R>>2]*va+ +g[Y>>2]*ua;g[i>>2]=+g[E>>2]*xa+ +g[L>>2]*wa+ +g[r>>2]*va+ +g[_>>2]*ua;g[o>>2]=+g[G>>2]*xa+ +g[N>>2]*wa+ +g[U>>2]*va+ +g[s>>2]*ua;db(A,p,p);xa=+g[j>>2]+ +g[h>>2];g[h>>2]=xa;wa=+g[ha>>2]+ +g[v>>2];g[v>>2]=wa;va=+g[i>>2]+ +g[x>>2];g[x>>2]=va;ua=+g[o>>2]+ +g[z>>2];g[z>>2]=ua;d=p;t=A;b=d+64|0;do{c[d>>2]=c[t>>2];d=d+4|0;t=t+4|0}while((d|0)<(b|0));ga=ga+1|0}while((ga|0)!=4);d=a;t=h;b=d+80|0;do{c[d>>2]=c[t>>2];d=d+4|0;t=t+4|0}while((d|0)<(b|0));l=e;return}function db(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=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,t=0,u=0,v=0,w=0;d=b+16|0;e=c+4|0;f=b+32|0;h=c+8|0;i=b+48|0;j=c+12|0;g[a>>2]=+g[b>>2]*+g[c>>2]+ +g[d>>2]*+g[e>>2]+ +g[f>>2]*+g[h>>2]+ +g[i>>2]*+g[j>>2];k=b+4|0;l=b+20|0;m=b+36|0;n=b+52|0;g[a+4>>2]=+g[k>>2]*+g[c>>2]+ +g[l>>2]*+g[e>>2]+ +g[m>>2]*+g[h>>2]+ +g[n>>2]*+g[j>>2];o=b+8|0;p=b+24|0;q=b+40|0;r=b+56|0;g[a+8>>2]=+g[o>>2]*+g[c>>2]+ +g[p>>2]*+g[e>>2]+ +g[q>>2]*+g[h>>2]+ +g[r>>2]*+g[j>>2];s=b+12|0;t=b+28|0;u=b+44|0;v=b+60|0;g[a+12>>2]=+g[s>>2]*+g[c>>2]+ +g[t>>2]*+g[e>>2]+ +g[u>>2]*+g[h>>2]+ +g[v>>2]*+g[j>>2];j=c+16|0;h=c+20|0;e=c+24|0;w=c+28|0;g[a+16>>2]=+g[b>>2]*+g[j>>2]+ +g[d>>2]*+g[h>>2]+ +g[f>>2]*+g[e>>2]+ +g[i>>2]*+g[w>>2];g[a+20>>2]=+g[k>>2]*+g[j>>2]+ +g[l>>2]*+g[h>>2]+ +g[m>>2]*+g[e>>2]+ +g[n>>2]*+g[w>>2];g[a+24>>2]=+g[o>>2]*+g[j>>2]+ +g[p>>2]*+g[h>>2]+ +g[q>>2]*+g[e>>2]+ +g[r>>2]*+g[w>>2];g[a+28>>2]=+g[s>>2]*+g[j>>2]+ +g[t>>2]*+g[h>>2]+ +g[u>>2]*+g[e>>2]+ +g[v>>2]*+g[w>>2];w=c+32|0;e=c+36|0;h=c+40|0;j=c+44|0;g[a+32>>2]=+g[b>>2]*+g[w>>2]+ +g[d>>2]*+g[e>>2]+ +g[f>>2]*+g[h>>2]+ +g[i>>2]*+g[j>>2];g[a+36>>2]=+g[k>>2]*+g[w>>2]+ +g[l>>2]*+g[e>>2]+ +g[m>>2]*+g[h>>2]+ +g[n>>2]*+g[j>>2];g[a+40>>2]=+g[o>>2]*+g[w>>2]+ +g[p>>2]*+g[e>>2]+ +g[q>>2]*+g[h>>2]+ +g[r>>2]*+g[j>>2];g[a+44>>2]=+g[s>>2]*+g[w>>2]+ +g[t>>2]*+g[e>>2]+ +g[u>>2]*+g[h>>2]+ +g[v>>2]*+g[j>>2];j=c+48|0;h=c+52|0;e=c+56|0;w=c+60|0;g[a+48>>2]=+g[b>>2]*+g[j>>2]+ +g[d>>2]*+g[h>>2]+ +g[f>>2]*+g[e>>2]+ +g[i>>2]*+g[w>>2];g[a+52>>2]=+g[k>>2]*+g[j>>2]+ +g[l>>2]*+g[h>>2]+ +g[m>>2]*+g[e>>2]+ +g[n>>2]*+g[w>>2];g[a+56>>2]=+g[o>>2]*+g[j>>2]+ +g[p>>2]*+g[h>>2]+ +g[q>>2]*+g[e>>2]+ +g[r>>2]*+g[w>>2];g[a+60>>2]=+g[s>>2]*+g[j>>2]+ +g[t>>2]*+g[h>>2]+ +g[u>>2]*+g[e>>2]+ +g[v>>2]*+g[w>>2];return}function eb(a){a=a|0;var b=0;c[a>>2]=1096;b=a+4+15&-16;c[b>>2]=0;c[b+4>>2]=0;c[b+8>>2]=0;c[b+12>>2]=0;return}function fb(a){a=a|0;c[a+65536>>2]=0;c[a+65540>>2]=0;return}function gb(a){a=a|0;return (c[a+65540>>2]|0)-(c[a+65536>>2]|0)&65535|0}function hb(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=a+65536|0;f=c[e>>2]|0;g=65536-f|0;h=g>>>0>b>>>0?b:g;rc(d|0,a+f|0,h|0)|0;if(g>>>0>>0)rc(d+h|0,a|0,b-h|0)|0;c[e>>2]=f+b&65535;return b|0}function ib(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0;e=l;l=l+16|0;f=e;if(!d){l=e;return}g=a+65536|0;h=a+65540|0;i=f+4|0;j=b;b=d;while(1){d=c[h>>2]|0;k=(c[g>>2]|0)+65535-d&65535;if(!k){do{c[f>>2]=0;c[i>>2]=1e6;ca(f|0,0)|0;m=c[h>>2]|0;n=(c[g>>2]|0)+65535-m&65535}while(!(n|0));o=n;p=m}else{o=k;p=d}m=b>>>0>>0?b:o;n=65536-p|0;q=m>>>0>>0?m:n;rc(a+p|0,j|0,q|0)|0;if(m>>>0>n>>>0)rc(a|0,j+q|0,m-q|0)|0;c[h>>2]=m+p&65535;b=b-m|0;if(!b)break;else j=j+m|0}l=e;return}function jb(){var a=0,b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;a=1073741824;b=0;d=0;do{e=d+32>>6;f=b<<1;c[22716+((f|1)<<2)>>2]=e;c[22716+(f+1025<<2)>>2]=0-e;e=((a|0)<0)<<31>>31;f=pc(a|0,e|0,6588356,0)|0;g=y;h=((d|0)<0)<<31>>31;i=pc(d|0,h|0,1073721611,0)|0;j=lc(i|0,y|0,536870912,0)|0;i=lc(j|0,y|0,f|0,g|0)|0;g=d;d=nc(i|0,y|0,30)|0;i=pc(a|0,e|0,1073721611,0)|0;e=y;f=pc(g|0,h|0,-6588356,-1)|0;h=lc(f|0,y|0,536870912,0)|0;f=lc(h|0,y|0,i|0,e|0)|0;a=nc(f|0,y|0,30)|0;b=b+1|0}while((b|0)!=512);k=0;do{b=k<<1;c[22716+(b<<2)>>2]=(c[22716+(b+3<<2)>>2]|0)-(c[22716+((b|1)<<2)>>2]|0);k=k+1|0}while((k|0)!=1023);c[7725]=0-(c[7726]|0);return}function kb(a){a=+a;Ra(a);La();Ma();jb();Ta(a);Za(a);return}function lb(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;eb(b+13192|0);c[b>>2]=d;d=0;do{c[b+4+(d*12|0)+8>>2]=Jb(1128)|0;a[b+4+(d*12|0)+4>>0]=0;a[b+4+(d*12|0)+5>>0]=0;a[b+4+(d*12|0)+6>>0]=0;d=d+1|0}while((d|0)!=16);c[b+8392>>2]=0;d=b+8396|0;e=d;f=1937;g=e+128|0;do{a[e>>0]=a[f>>0]|0;e=e+1|0;f=f+1|0}while((e|0)<(g|0));c[b+12492>>2]=0;Ya(d,b+12496|0);Ua(b+12652|0,b+12633|0);c[b+196>>2]=0;c[b+13228>>2]=258847126;c[b+13232>>2]=0;c[b+13236>>2]=0;c[b+13188>>2]=8192;a[b+13240>>0]=0;c[b+13372>>2]=0;return}function mb(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=a[e>>0]|0;switch(((g&255)>>>4^8)&15){case 0:break;case 1:{h=e+2|0;if(a[h>>0]|0){if((f|0)<=2){i=0;return i|0}j=b+196|0;k=0;l=c[j>>2]|0;while(1){m=b+4+(l*12|0)+4|0;n=(l+1|0)%16|0;k=k+1|0;if(!(a[m>>0]|0))break;if((k|0)>=16){i=3;o=40;break}else l=n}if((o|0)==40)return i|0;c[j>>2]=n;if((l|0)<=-1){i=3;return i|0}Xa(b+12652|0);n=e+1|0;c[b+4+(l*12|0)>>2]=d[n>>0];a[m>>0]=1;a[b+4+(l*12|0)+5>>0]=a[b+13240>>0]|0;a[b+4+(l*12|0)+6>>0]=1;Ea(c[b+4+(l*12|0)+8>>2]|0,b+12496|0,d[n>>0]|0,d[h>>0]|0);i=3;return i|0}break}case 3:{if((f|0)<=2){i=0;return i|0}h=a[e+2>>0]|0;n=h&255;switch(a[e+1>>0]|0){case 1:{c[b+13228>>2]=(n*917175|0)+142365917;i=3;return i|0}case 2:{c[b+13232>>2]=n*528416;i=3;return i|0}case 3:{c[b+13236>>2]=n*528416;i=3;return i|0}case 64:{n=h<<24>>24!=0;a[b+13240>>0]=n&1;if(n){i=3;return i|0}else p=0;do{n=b+4+(p*12|0)+5|0;if(a[n>>0]|0?(a[b+4+(p*12|0)+4>>0]|0)==0:0){Ga(c[b+4+(p*12|0)+8>>2]|0);a[n>>0]=0}p=p+1|0}while((p|0)!=16);i=3;return i|0}default:{i=3;return i|0}}break}case 4:{if((f|0)<=1){i=0;return i|0}p=d[e+1>>0]|0;n=p>>>0<31?p:31;c[b+12492>>2]=n;Ya((n<<7)+(b+8396)|0,b+12496|0);Ua(b+12652|0,b+12633|0);i=2;return i|0}default:{if(g<<24>>24==-32){c[b+13188>>2]=d[e+2>>0]<<7|d[e+1>>0];i=3;return i|0}if(!((f|0)>5&g<<24>>24==-16)){i=f;return i|0}if((a[e+1>>0]|0)!=67){i=f;return i|0}if(a[e+2>>0]|0){i=f;return i|0}if((a[e+3>>0]|0)!=9){i=f;return i|0}if((a[e+4>>0]|0)!=32){i=f;return i|0}if(a[e+5>>0]|0){i=f;return i|0}if((f|0)<=4103){i=0;return i|0}rc(b+8396|0,e+6|0,4096)|0;Ya((c[b+12492>>2]<<7)+(b+8396)|0,b+12496|0);Ua(b+12652|0,b+12633|0);i=4104;return i|0}}if((f|0)<=2){i=0;return i|0}f=e+1|0;e=b+13240|0;g=0;do{if((c[b+4+(g*12|0)>>2]|0)==(d[f>>0]|0)?(n=b+4+(g*12|0)+4|0,a[n>>0]|0):0){if(!(a[e>>0]|0))Ga(c[b+4+(g*12|0)+8>>2]|0);else a[b+4+(g*12|0)+5>>0]=1;a[n>>0]=0}g=g+1|0}while((g|0)!=16);i=3;return i|0}function nb(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;g=l;l=l+560|0;h=g+280|0;i=g+8|0;j=g+4|0;k=g;m=gb(c[d>>2]|0)|0;n=d+8392|0;o=c[n>>2]|0;p=8192-o|0;q=m>>>0

>>0?m:p;if((q|0)>0){hb(c[d>>2]|0,q,d+200+o|0)|0;p=(c[n>>2]|0)+q|0;c[n>>2]=p;r=p}else r=o;if(!r){s=0;t=r}else{o=0;p=r;while(1){r=mb(d,d+200+o|0,p-o|0)|0;q=r+o|0;m=c[n>>2]|0;if((r|0)!=0&m>>>0>q>>>0){o=q;p=m}else{s=q;t=m;break}}}if(t>>>0>s>>>0){sc(d+200|0,d+200+s|0,t-s|0)|0;u=c[n>>2]|0}else u=t;c[n>>2]=u-s;s=d+13372|0;u=c[s>>2]|0;if((e|0)>0&(u|0)>0){n=0;while(1){b[f+(n<<1)>>1]=b[d+13242+(n<<1)>>1]|0;t=n+1|0;if((t|0)<(e|0)&(t|0)<(u|0))n=t;else{v=t;break}}}else v=0;if((u|0)>(e|0)){n=u-e|0;if((n|0)>0)w=0;else{x=n;c[s>>2]=x;l=g;return}do{b[d+13242+(w<<1)>>1]=b[d+13242+(w+e<<1)>>1]|0;w=w+1|0;n=(c[s>>2]|0)-e|0}while((w|0)<(n|0));x=n;c[s>>2]=x;l=g;return}if((v|0)<(e|0)){w=h+15&-16;h=w;n=w;w=d+12652|0;u=d+12676|0;t=i+15&-16;i=d+13192|0;p=d+13228|0;o=v;while(1){mc(n|0,0,256)|0;m=Va(w)|0;q=Wa(w)|0;r=0;do{if(a[d+4+(r*12|0)+6>>0]|0)Fa(c[d+4+(r*12|0)+8>>2]|0,h,m,q,u);r=r+1|0}while((r|0)!=16);c[j>>2]=h;c[k>>2]=t;bb(i,j,p,p,k);r=e-o|0;q=0;do{m=c[t+(q<<2)>>2]|0;y=m>>4;b[((q|0)<(r|0)?f+(q+o<<1)|0:d+13242+(q-r<<1)|0)>>1]=(y|0)<-16777216?-32768:(y|0)>16777215?32767:m>>>13&65535;q=q+1|0}while((q|0)!=64);q=o+64|0;if((q|0)<(e|0))o=q;else{z=q;break}}}else z=v;x=z-e|0;c[s>>2]=x;l=g;return}function ob(a){a=a|0;var b=0,d=0,e=0;b=Jb(8)|0;d=b;c[d>>2]=0;c[d+4>>2]=0;d=Jb(65544)|0;fb(d);c[b>>2]=d;e=Jb(13376)|0;lb(e,d);c[b+4>>2]=e;kb(+(a|0));return b|0}function pb(a,b,d){a=a|0;b=b|0;d=d|0;nb(c[a+4>>2]|0,b,d);return}function qb(a,b,d){a=a|0;b=b|0;d=d|0;ib(c[a>>2]|0,b,d);return}function rb(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=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,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0;b=l;l=l+16|0;d=b;do if(a>>>0<245){e=a>>>0<11?16:a+11&-8;f=e>>>3;g=c[7727]|0;h=g>>>f;if(h&3|0){i=(h&1^1)+f|0;j=30948+(i<<1<<2)|0;k=j+8|0;m=c[k>>2]|0;n=m+8|0;o=c[n>>2]|0;if((j|0)==(o|0))c[7727]=g&~(1<>2]=j;c[k>>2]=o}o=i<<3;c[m+4>>2]=o|3;i=m+o+4|0;c[i>>2]=c[i>>2]|1;p=n;l=b;return p|0}n=c[7729]|0;if(e>>>0>n>>>0){if(h|0){i=2<>>12&16;f=i>>>o;i=f>>>5&8;h=f>>>i;f=h>>>2&4;m=h>>>f;h=m>>>1&2;k=m>>>h;m=k>>>1&1;j=(i|o|f|h|m)+(k>>>m)|0;m=30948+(j<<1<<2)|0;k=m+8|0;h=c[k>>2]|0;f=h+8|0;o=c[f>>2]|0;if((m|0)==(o|0)){i=g&~(1<>2]=m;c[k>>2]=o;q=g}o=(j<<3)-e|0;c[h+4>>2]=e|3;j=h+e|0;c[j+4>>2]=o|1;c[j+o>>2]=o;if(n|0){h=c[7732]|0;k=n>>>3;m=30948+(k<<1<<2)|0;i=1<>2]|0;s=i}c[s>>2]=h;c[r+12>>2]=h;c[h+8>>2]=r;c[h+12>>2]=m}c[7729]=o;c[7732]=j;p=f;l=b;return p|0}f=c[7728]|0;if(f){j=(f&0-f)+-1|0;o=j>>>12&16;m=j>>>o;j=m>>>5&8;h=m>>>j;m=h>>>2&4;i=h>>>m;h=i>>>1&2;k=i>>>h;i=k>>>1&1;t=c[31212+((j|o|m|h|i)+(k>>>i)<<2)>>2]|0;i=(c[t+4>>2]&-8)-e|0;k=c[t+16+(((c[t+16>>2]|0)==0&1)<<2)>>2]|0;if(!k){u=t;v=i}else{h=t;t=i;i=k;while(1){k=(c[i+4>>2]&-8)-e|0;m=k>>>0>>0;o=m?k:t;k=m?i:h;i=c[i+16+(((c[i+16>>2]|0)==0&1)<<2)>>2]|0;if(!i){u=k;v=o;break}else{h=k;t=o}}}t=u+e|0;if(u>>>0>>0){h=c[u+24>>2]|0;i=c[u+12>>2]|0;do if((i|0)==(u|0)){o=u+20|0;k=c[o>>2]|0;if(!k){m=u+16|0;j=c[m>>2]|0;if(!j){w=0;break}else{x=j;y=m}}else{x=k;y=o}while(1){o=x+20|0;k=c[o>>2]|0;if(k|0){x=k;y=o;continue}o=x+16|0;k=c[o>>2]|0;if(!k)break;else{x=k;y=o}}c[y>>2]=0;w=x}else{o=c[u+8>>2]|0;c[o+12>>2]=i;c[i+8>>2]=o;w=i}while(0);do if(h|0){i=c[u+28>>2]|0;o=31212+(i<<2)|0;if((u|0)==(c[o>>2]|0)){c[o>>2]=w;if(!w){c[7728]=f&~(1<>2]|0)!=(u|0)&1)<<2)>>2]=w;if(!w)break}c[w+24>>2]=h;i=c[u+16>>2]|0;if(i|0){c[w+16>>2]=i;c[i+24>>2]=w}i=c[u+20>>2]|0;if(i|0){c[w+20>>2]=i;c[i+24>>2]=w}}while(0);if(v>>>0<16){h=v+e|0;c[u+4>>2]=h|3;f=u+h+4|0;c[f>>2]=c[f>>2]|1}else{c[u+4>>2]=e|3;c[t+4>>2]=v|1;c[t+v>>2]=v;if(n|0){f=c[7732]|0;h=n>>>3;i=30948+(h<<1<<2)|0;o=1<>2]|0;A=o}c[A>>2]=f;c[z+12>>2]=f;c[f+8>>2]=z;c[f+12>>2]=i}c[7729]=v;c[7732]=t}p=u+8|0;l=b;return p|0}else B=e}else B=e}else B=e}else if(a>>>0<=4294967231){i=a+11|0;f=i&-8;o=c[7728]|0;if(o){h=0-f|0;k=i>>>8;if(k)if(f>>>0>16777215)C=31;else{i=(k+1048320|0)>>>16&8;m=k<>>16&4;j=m<>>16&2;D=14-(k|i|m)+(j<>>15)|0;C=f>>>(D+7|0)&1|D<<1}else C=0;D=c[31212+(C<<2)>>2]|0;a:do if(!D){E=0;F=0;G=h;H=57}else{m=0;j=h;i=D;k=f<<((C|0)==31?0:25-(C>>>1)|0);I=0;while(1){J=(c[i+4>>2]&-8)-f|0;if(J>>>0>>0)if(!J){K=i;L=0;M=i;H=61;break a}else{N=i;O=J}else{N=m;O=j}J=c[i+20>>2]|0;i=c[i+16+(k>>>31<<2)>>2]|0;P=(J|0)==0|(J|0)==(i|0)?I:J;J=(i|0)==0;if(J){E=P;F=N;G=O;H=57;break}else{m=N;j=O;k=k<<((J^1)&1);I=P}}}while(0);if((H|0)==57){if((E|0)==0&(F|0)==0){D=2<>>12&16;e=D>>>h;D=e>>>5&8;t=e>>>D;e=t>>>2&4;g=t>>>e;t=g>>>1&2;n=g>>>t;g=n>>>1&1;Q=0;R=c[31212+((D|h|e|t|g)+(n>>>g)<<2)>>2]|0}else{Q=F;R=E}if(!R){S=Q;T=G}else{K=Q;L=G;M=R;H=61}}if((H|0)==61)while(1){H=0;g=(c[M+4>>2]&-8)-f|0;n=g>>>0>>0;t=n?g:L;g=n?M:K;M=c[M+16+(((c[M+16>>2]|0)==0&1)<<2)>>2]|0;if(!M){S=g;T=t;break}else{K=g;L=t;H=61}}if((S|0)!=0?T>>>0<((c[7729]|0)-f|0)>>>0:0){t=S+f|0;if(S>>>0>=t>>>0){p=0;l=b;return p|0}g=c[S+24>>2]|0;n=c[S+12>>2]|0;do if((n|0)==(S|0)){e=S+20|0;h=c[e>>2]|0;if(!h){D=S+16|0;I=c[D>>2]|0;if(!I){U=0;break}else{V=I;W=D}}else{V=h;W=e}while(1){e=V+20|0;h=c[e>>2]|0;if(h|0){V=h;W=e;continue}e=V+16|0;h=c[e>>2]|0;if(!h)break;else{V=h;W=e}}c[W>>2]=0;U=V}else{e=c[S+8>>2]|0;c[e+12>>2]=n;c[n+8>>2]=e;U=n}while(0);do if(g){n=c[S+28>>2]|0;e=31212+(n<<2)|0;if((S|0)==(c[e>>2]|0)){c[e>>2]=U;if(!U){e=o&~(1<>2]|0)!=(S|0)&1)<<2)>>2]=U;if(!U){X=o;break}}c[U+24>>2]=g;e=c[S+16>>2]|0;if(e|0){c[U+16>>2]=e;c[e+24>>2]=U}e=c[S+20>>2]|0;if(e){c[U+20>>2]=e;c[e+24>>2]=U;X=o}else X=o}else X=o;while(0);do if(T>>>0>=16){c[S+4>>2]=f|3;c[t+4>>2]=T|1;c[t+T>>2]=T;o=T>>>3;if(T>>>0<256){g=30948+(o<<1<<2)|0;e=c[7727]|0;n=1<>2]|0;Z=n}c[Z>>2]=t;c[Y+12>>2]=t;c[t+8>>2]=Y;c[t+12>>2]=g;break}g=T>>>8;if(g)if(T>>>0>16777215)_=31;else{n=(g+1048320|0)>>>16&8;e=g<>>16&4;o=e<>>16&2;h=14-(g|n|e)+(o<>>15)|0;_=T>>>(h+7|0)&1|h<<1}else _=0;h=31212+(_<<2)|0;c[t+28>>2]=_;e=t+16|0;c[e+4>>2]=0;c[e>>2]=0;e=1<<_;if(!(X&e)){c[7728]=X|e;c[h>>2]=t;c[t+24>>2]=h;c[t+12>>2]=t;c[t+8>>2]=t;break}e=T<<((_|0)==31?0:25-(_>>>1)|0);o=c[h>>2]|0;while(1){if((c[o+4>>2]&-8|0)==(T|0)){H=97;break}$=o+16+(e>>>31<<2)|0;h=c[$>>2]|0;if(!h){H=96;break}else{e=e<<1;o=h}}if((H|0)==96){c[$>>2]=t;c[t+24>>2]=o;c[t+12>>2]=t;c[t+8>>2]=t;break}else if((H|0)==97){e=o+8|0;h=c[e>>2]|0;c[h+12>>2]=t;c[e>>2]=t;c[t+8>>2]=h;c[t+12>>2]=o;c[t+24>>2]=0;break}}else{h=T+f|0;c[S+4>>2]=h|3;e=S+h+4|0;c[e>>2]=c[e>>2]|1}while(0);p=S+8|0;l=b;return p|0}else B=f}else B=f}else B=-1;while(0);S=c[7729]|0;if(S>>>0>=B>>>0){T=S-B|0;$=c[7732]|0;if(T>>>0>15){_=$+B|0;c[7732]=_;c[7729]=T;c[_+4>>2]=T|1;c[_+T>>2]=T;c[$+4>>2]=B|3}else{c[7729]=0;c[7732]=0;c[$+4>>2]=S|3;T=$+S+4|0;c[T>>2]=c[T>>2]|1}p=$+8|0;l=b;return p|0}$=c[7730]|0;if($>>>0>B>>>0){T=$-B|0;c[7730]=T;S=c[7733]|0;_=S+B|0;c[7733]=_;c[_+4>>2]=T|1;c[S+4>>2]=B|3;p=S+8|0;l=b;return p|0}if(!(c[7845]|0)){c[7847]=4096;c[7846]=4096;c[7848]=-1;c[7849]=-1;c[7850]=0;c[7838]=0;S=d&-16^1431655768;c[d>>2]=S;c[7845]=S;aa=4096}else aa=c[7847]|0;S=B+48|0;d=B+47|0;T=aa+d|0;_=0-aa|0;aa=T&_;if(aa>>>0<=B>>>0){p=0;l=b;return p|0}X=c[7837]|0;if(X|0?(Y=c[7835]|0,Z=Y+aa|0,Z>>>0<=Y>>>0|Z>>>0>X>>>0):0){p=0;l=b;return p|0}b:do if(!(c[7838]&4)){X=c[7733]|0;c:do if(X){Z=31356;while(1){Y=c[Z>>2]|0;if(Y>>>0<=X>>>0?(ba=Z+4|0,(Y+(c[ba>>2]|0)|0)>>>0>X>>>0):0)break;Y=c[Z+8>>2]|0;if(!Y){H=118;break c}else Z=Y}o=T-$&_;if(o>>>0<2147483647){Y=qc(o|0)|0;if((Y|0)==((c[Z>>2]|0)+(c[ba>>2]|0)|0))if((Y|0)==(-1|0))ca=o;else{da=o;ea=Y;H=135;break b}else{fa=Y;ga=o;H=126}}else ca=0}else H=118;while(0);do if((H|0)==118){X=qc(0)|0;if((X|0)!=(-1|0)?(f=X,o=c[7846]|0,Y=o+-1|0,U=((Y&f|0)==0?0:(Y+f&0-o)-f|0)+aa|0,f=c[7835]|0,o=U+f|0,U>>>0>B>>>0&U>>>0<2147483647):0){Y=c[7837]|0;if(Y|0?o>>>0<=f>>>0|o>>>0>Y>>>0:0){ca=0;break}Y=qc(U|0)|0;if((Y|0)==(X|0)){da=U;ea=X;H=135;break b}else{fa=Y;ga=U;H=126}}else ca=0}while(0);do if((H|0)==126){U=0-ga|0;if(!(S>>>0>ga>>>0&(ga>>>0<2147483647&(fa|0)!=(-1|0))))if((fa|0)==(-1|0)){ca=0;break}else{da=ga;ea=fa;H=135;break b}Y=c[7847]|0;X=d-ga+Y&0-Y;if(X>>>0>=2147483647){da=ga;ea=fa;H=135;break b}if((qc(X|0)|0)==(-1|0)){qc(U|0)|0;ca=0;break}else{da=X+ga|0;ea=fa;H=135;break b}}while(0);c[7838]=c[7838]|4;ha=ca;H=133}else{ha=0;H=133}while(0);if(((H|0)==133?aa>>>0<2147483647:0)?(ca=qc(aa|0)|0,aa=qc(0)|0,fa=aa-ca|0,ga=fa>>>0>(B+40|0)>>>0,!((ca|0)==(-1|0)|ga^1|ca>>>0>>0&((ca|0)!=(-1|0)&(aa|0)!=(-1|0))^1)):0){da=ga?fa:ha;ea=ca;H=135}if((H|0)==135){ca=(c[7835]|0)+da|0;c[7835]=ca;if(ca>>>0>(c[7836]|0)>>>0)c[7836]=ca;ca=c[7733]|0;do if(ca){ha=31356;while(1){ia=c[ha>>2]|0;ja=ha+4|0;ka=c[ja>>2]|0;if((ea|0)==(ia+ka|0)){H=145;break}fa=c[ha+8>>2]|0;if(!fa)break;else ha=fa}if(((H|0)==145?(c[ha+12>>2]&8|0)==0:0)?ca>>>0>>0&ca>>>0>=ia>>>0:0){c[ja>>2]=ka+da;fa=ca+8|0;ga=(fa&7|0)==0?0:0-fa&7;fa=ca+ga|0;aa=(c[7730]|0)+(da-ga)|0;c[7733]=fa;c[7730]=aa;c[fa+4>>2]=aa|1;c[fa+aa+4>>2]=40;c[7734]=c[7849];break}if(ea>>>0<(c[7731]|0)>>>0)c[7731]=ea;aa=ea+da|0;fa=31356;while(1){if((c[fa>>2]|0)==(aa|0)){H=153;break}ga=c[fa+8>>2]|0;if(!ga)break;else fa=ga}if((H|0)==153?(c[fa+12>>2]&8|0)==0:0){c[fa>>2]=ea;ha=fa+4|0;c[ha>>2]=(c[ha>>2]|0)+da;ha=ea+8|0;ga=ea+((ha&7|0)==0?0:0-ha&7)|0;ha=aa+8|0;d=aa+((ha&7|0)==0?0:0-ha&7)|0;ha=ga+B|0;S=d-ga-B|0;c[ga+4>>2]=B|3;do if((d|0)!=(ca|0)){if((d|0)==(c[7732]|0)){ba=(c[7729]|0)+S|0;c[7729]=ba;c[7732]=ha;c[ha+4>>2]=ba|1;c[ha+ba>>2]=ba;break}ba=c[d+4>>2]|0;if((ba&3|0)==1){_=ba&-8;$=ba>>>3;d:do if(ba>>>0<256){T=c[d+8>>2]|0;X=c[d+12>>2]|0;if((X|0)==(T|0)){c[7727]=c[7727]&~(1<<$);break}else{c[T+12>>2]=X;c[X+8>>2]=T;break}}else{T=c[d+24>>2]|0;X=c[d+12>>2]|0;do if((X|0)==(d|0)){U=d+16|0;Y=U+4|0;o=c[Y>>2]|0;if(!o){f=c[U>>2]|0;if(!f){la=0;break}else{ma=f;na=U}}else{ma=o;na=Y}while(1){Y=ma+20|0;o=c[Y>>2]|0;if(o|0){ma=o;na=Y;continue}Y=ma+16|0;o=c[Y>>2]|0;if(!o)break;else{ma=o;na=Y}}c[na>>2]=0;la=ma}else{Y=c[d+8>>2]|0;c[Y+12>>2]=X;c[X+8>>2]=Y;la=X}while(0);if(!T)break;X=c[d+28>>2]|0;Y=31212+(X<<2)|0;do if((d|0)!=(c[Y>>2]|0)){c[T+16+(((c[T+16>>2]|0)!=(d|0)&1)<<2)>>2]=la;if(!la)break d}else{c[Y>>2]=la;if(la|0)break;c[7728]=c[7728]&~(1<>2]=T;X=d+16|0;Y=c[X>>2]|0;if(Y|0){c[la+16>>2]=Y;c[Y+24>>2]=la}Y=c[X+4>>2]|0;if(!Y)break;c[la+20>>2]=Y;c[Y+24>>2]=la}while(0);oa=d+_|0;pa=_+S|0}else{oa=d;pa=S}$=oa+4|0;c[$>>2]=c[$>>2]&-2;c[ha+4>>2]=pa|1;c[ha+pa>>2]=pa;$=pa>>>3;if(pa>>>0<256){ba=30948+($<<1<<2)|0;Z=c[7727]|0;Y=1<<$;if(!(Z&Y)){c[7727]=Z|Y;qa=ba;ra=ba+8|0}else{Y=ba+8|0;qa=c[Y>>2]|0;ra=Y}c[ra>>2]=ha;c[qa+12>>2]=ha;c[ha+8>>2]=qa;c[ha+12>>2]=ba;break}ba=pa>>>8;do if(!ba)sa=0;else{if(pa>>>0>16777215){sa=31;break}Y=(ba+1048320|0)>>>16&8;Z=ba<>>16&4;X=Z<<$;Z=(X+245760|0)>>>16&2;o=14-($|Y|Z)+(X<>>15)|0;sa=pa>>>(o+7|0)&1|o<<1}while(0);ba=31212+(sa<<2)|0;c[ha+28>>2]=sa;_=ha+16|0;c[_+4>>2]=0;c[_>>2]=0;_=c[7728]|0;o=1<>2]=ha;c[ha+24>>2]=ba;c[ha+12>>2]=ha;c[ha+8>>2]=ha;break}o=pa<<((sa|0)==31?0:25-(sa>>>1)|0);_=c[ba>>2]|0;while(1){if((c[_+4>>2]&-8|0)==(pa|0)){H=194;break}ta=_+16+(o>>>31<<2)|0;ba=c[ta>>2]|0;if(!ba){H=193;break}else{o=o<<1;_=ba}}if((H|0)==193){c[ta>>2]=ha;c[ha+24>>2]=_;c[ha+12>>2]=ha;c[ha+8>>2]=ha;break}else if((H|0)==194){o=_+8|0;ba=c[o>>2]|0;c[ba+12>>2]=ha;c[o>>2]=ha;c[ha+8>>2]=ba;c[ha+12>>2]=_;c[ha+24>>2]=0;break}}else{ba=(c[7730]|0)+S|0;c[7730]=ba;c[7733]=ha;c[ha+4>>2]=ba|1}while(0);p=ga+8|0;l=b;return p|0}ha=31356;while(1){S=c[ha>>2]|0;if(S>>>0<=ca>>>0?(ua=S+(c[ha+4>>2]|0)|0,ua>>>0>ca>>>0):0)break;ha=c[ha+8>>2]|0}ha=ua+-47|0;ga=ha+8|0;S=ha+((ga&7|0)==0?0:0-ga&7)|0;ga=ca+16|0;ha=S>>>0>>0?ca:S;S=ha+8|0;d=ea+8|0;aa=(d&7|0)==0?0:0-d&7;d=ea+aa|0;fa=da+-40-aa|0;c[7733]=d;c[7730]=fa;c[d+4>>2]=fa|1;c[d+fa+4>>2]=40;c[7734]=c[7849];fa=ha+4|0;c[fa>>2]=27;c[S>>2]=c[7839];c[S+4>>2]=c[7840];c[S+8>>2]=c[7841];c[S+12>>2]=c[7842];c[7839]=ea;c[7840]=da;c[7842]=0;c[7841]=S;S=ha+24|0;do{d=S;S=S+4|0;c[S>>2]=7}while((d+8|0)>>>0>>0);if((ha|0)!=(ca|0)){S=ha-ca|0;c[fa>>2]=c[fa>>2]&-2;c[ca+4>>2]=S|1;c[ha>>2]=S;d=S>>>3;if(S>>>0<256){aa=30948+(d<<1<<2)|0;ba=c[7727]|0;o=1<>2]|0;wa=o}c[wa>>2]=ca;c[va+12>>2]=ca;c[ca+8>>2]=va;c[ca+12>>2]=aa;break}aa=S>>>8;if(aa)if(S>>>0>16777215)xa=31;else{o=(aa+1048320|0)>>>16&8;ba=aa<>>16&4;d=ba<>>16&2;Z=14-(aa|o|ba)+(d<>>15)|0;xa=S>>>(Z+7|0)&1|Z<<1}else xa=0;Z=31212+(xa<<2)|0;c[ca+28>>2]=xa;c[ca+20>>2]=0;c[ga>>2]=0;ba=c[7728]|0;d=1<>2]=ca;c[ca+24>>2]=Z;c[ca+12>>2]=ca;c[ca+8>>2]=ca;break}d=S<<((xa|0)==31?0:25-(xa>>>1)|0);ba=c[Z>>2]|0;while(1){if((c[ba+4>>2]&-8|0)==(S|0)){H=216;break}ya=ba+16+(d>>>31<<2)|0;Z=c[ya>>2]|0;if(!Z){H=215;break}else{d=d<<1;ba=Z}}if((H|0)==215){c[ya>>2]=ca;c[ca+24>>2]=ba;c[ca+12>>2]=ca;c[ca+8>>2]=ca;break}else if((H|0)==216){d=ba+8|0;S=c[d>>2]|0;c[S+12>>2]=ca;c[d>>2]=ca;c[ca+8>>2]=S;c[ca+12>>2]=ba;c[ca+24>>2]=0;break}}}else{S=c[7731]|0;if((S|0)==0|ea>>>0>>0)c[7731]=ea;c[7839]=ea;c[7840]=da;c[7842]=0;c[7736]=c[7845];c[7735]=-1;S=0;do{d=30948+(S<<1<<2)|0;c[d+12>>2]=d;c[d+8>>2]=d;S=S+1|0}while((S|0)!=32);S=ea+8|0;ba=(S&7|0)==0?0:0-S&7;S=ea+ba|0;d=da+-40-ba|0;c[7733]=S;c[7730]=d;c[S+4>>2]=d|1;c[S+d+4>>2]=40;c[7734]=c[7849]}while(0);da=c[7730]|0;if(da>>>0>B>>>0){ea=da-B|0;c[7730]=ea;da=c[7733]|0;ca=da+B|0;c[7733]=ca;c[ca+4>>2]=ea|1;c[da+4>>2]=B|3;p=da+8|0;l=b;return p|0}}c[(yb()|0)>>2]=12;p=0;l=b;return p|0}function sb(a){a=a|0;var b=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,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;if(!a)return;b=a+-8|0;d=c[7731]|0;e=c[a+-4>>2]|0;a=e&-8;f=b+a|0;do if(!(e&1)){g=c[b>>2]|0;if(!(e&3))return;h=b+(0-g)|0;i=g+a|0;if(h>>>0>>0)return;if((h|0)==(c[7732]|0)){j=f+4|0;k=c[j>>2]|0;if((k&3|0)!=3){l=h;m=i;n=h;break}c[7729]=i;c[j>>2]=k&-2;c[h+4>>2]=i|1;c[h+i>>2]=i;return}k=g>>>3;if(g>>>0<256){g=c[h+8>>2]|0;j=c[h+12>>2]|0;if((j|0)==(g|0)){c[7727]=c[7727]&~(1<>2]=j;c[j+8>>2]=g;l=h;m=i;n=h;break}}g=c[h+24>>2]|0;j=c[h+12>>2]|0;do if((j|0)==(h|0)){k=h+16|0;o=k+4|0;p=c[o>>2]|0;if(!p){q=c[k>>2]|0;if(!q){r=0;break}else{s=q;t=k}}else{s=p;t=o}while(1){o=s+20|0;p=c[o>>2]|0;if(p|0){s=p;t=o;continue}o=s+16|0;p=c[o>>2]|0;if(!p)break;else{s=p;t=o}}c[t>>2]=0;r=s}else{o=c[h+8>>2]|0;c[o+12>>2]=j;c[j+8>>2]=o;r=j}while(0);if(g){j=c[h+28>>2]|0;o=31212+(j<<2)|0;if((h|0)==(c[o>>2]|0)){c[o>>2]=r;if(!r){c[7728]=c[7728]&~(1<>2]|0)!=(h|0)&1)<<2)>>2]=r;if(!r){l=h;m=i;n=h;break}}c[r+24>>2]=g;j=h+16|0;o=c[j>>2]|0;if(o|0){c[r+16>>2]=o;c[o+24>>2]=r}o=c[j+4>>2]|0;if(o){c[r+20>>2]=o;c[o+24>>2]=r;l=h;m=i;n=h}else{l=h;m=i;n=h}}else{l=h;m=i;n=h}}else{l=b;m=a;n=b}while(0);if(n>>>0>=f>>>0)return;b=f+4|0;a=c[b>>2]|0;if(!(a&1))return;if(!(a&2)){r=c[7732]|0;if((f|0)==(c[7733]|0)){s=(c[7730]|0)+m|0;c[7730]=s;c[7733]=l;c[l+4>>2]=s|1;if((l|0)!=(r|0))return;c[7732]=0;c[7729]=0;return}if((f|0)==(r|0)){r=(c[7729]|0)+m|0;c[7729]=r;c[7732]=n;c[l+4>>2]=r|1;c[n+r>>2]=r;return}r=(a&-8)+m|0;s=a>>>3;do if(a>>>0<256){t=c[f+8>>2]|0;d=c[f+12>>2]|0;if((d|0)==(t|0)){c[7727]=c[7727]&~(1<>2]=d;c[d+8>>2]=t;break}}else{t=c[f+24>>2]|0;d=c[f+12>>2]|0;do if((d|0)==(f|0)){e=f+16|0;o=e+4|0;j=c[o>>2]|0;if(!j){p=c[e>>2]|0;if(!p){u=0;break}else{v=p;w=e}}else{v=j;w=o}while(1){o=v+20|0;j=c[o>>2]|0;if(j|0){v=j;w=o;continue}o=v+16|0;j=c[o>>2]|0;if(!j)break;else{v=j;w=o}}c[w>>2]=0;u=v}else{o=c[f+8>>2]|0;c[o+12>>2]=d;c[d+8>>2]=o;u=d}while(0);if(t|0){d=c[f+28>>2]|0;h=31212+(d<<2)|0;if((f|0)==(c[h>>2]|0)){c[h>>2]=u;if(!u){c[7728]=c[7728]&~(1<>2]|0)!=(f|0)&1)<<2)>>2]=u;if(!u)break}c[u+24>>2]=t;d=f+16|0;h=c[d>>2]|0;if(h|0){c[u+16>>2]=h;c[h+24>>2]=u}h=c[d+4>>2]|0;if(h|0){c[u+20>>2]=h;c[h+24>>2]=u}}}while(0);c[l+4>>2]=r|1;c[n+r>>2]=r;if((l|0)==(c[7732]|0)){c[7729]=r;return}else x=r}else{c[b>>2]=a&-2;c[l+4>>2]=m|1;c[n+m>>2]=m;x=m}m=x>>>3;if(x>>>0<256){n=30948+(m<<1<<2)|0;a=c[7727]|0;b=1<>2]|0;z=b}c[z>>2]=l;c[y+12>>2]=l;c[l+8>>2]=y;c[l+12>>2]=n;return}n=x>>>8;if(n)if(x>>>0>16777215)A=31;else{y=(n+1048320|0)>>>16&8;z=n<>>16&4;b=z<>>16&2;a=14-(n|y|z)+(b<>>15)|0;A=x>>>(a+7|0)&1|a<<1}else A=0;a=31212+(A<<2)|0;c[l+28>>2]=A;c[l+20>>2]=0;c[l+16>>2]=0;z=c[7728]|0;b=1<>>1)|0);n=c[a>>2]|0;while(1){if((c[n+4>>2]&-8|0)==(x|0)){B=73;break}C=n+16+(y>>>31<<2)|0;m=c[C>>2]|0;if(!m){B=72;break}else{y=y<<1;n=m}}if((B|0)==72){c[C>>2]=l;c[l+24>>2]=n;c[l+12>>2]=l;c[l+8>>2]=l;break}else if((B|0)==73){y=n+8|0;t=c[y>>2]|0;c[t+12>>2]=l;c[y>>2]=l;c[l+8>>2]=t;c[l+12>>2]=n;c[l+24>>2]=0;break}}else{c[7728]=z|b;c[a>>2]=l;c[l+24>>2]=a;c[l+12>>2]=l;c[l+8>>2]=l}while(0);l=(c[7735]|0)+-1|0;c[7735]=l;if(!l)D=31364;else return;while(1){l=c[D>>2]|0;if(!l)break;else D=l+8|0}c[7735]=-1;return}function tb(){return 31404}function ub(a){a=a|0;var b=0,d=0;b=l;l=l+16|0;d=b;c[d>>2]=Bb(c[a+60>>2]|0)|0;a=xb(ea(6,d|0)|0)|0;l=b;return a|0}function vb(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;e=l;l=l+48|0;f=e+16|0;g=e;h=e+32|0;i=a+28|0;j=c[i>>2]|0;c[h>>2]=j;k=a+20|0;m=(c[k>>2]|0)-j|0;c[h+4>>2]=m;c[h+8>>2]=b;c[h+12>>2]=d;b=m+d|0;m=a+60|0;c[g>>2]=c[m>>2];c[g+4>>2]=h;c[g+8>>2]=2;j=xb(ha(146,g|0)|0)|0;a:do if((b|0)!=(j|0)){g=2;n=b;o=h;p=j;while(1){if((p|0)<0)break;n=n-p|0;q=c[o+4>>2]|0;r=p>>>0>q>>>0;s=r?o+8|0:o;t=(r<<31>>31)+g|0;u=p-(r?q:0)|0;c[s>>2]=(c[s>>2]|0)+u;q=s+4|0;c[q>>2]=(c[q>>2]|0)-u;c[f>>2]=c[m>>2];c[f+4>>2]=s;c[f+8>>2]=t;p=xb(ha(146,f|0)|0)|0;if((n|0)==(p|0)){v=3;break a}else{g=t;o=s}}c[a+16>>2]=0;c[i>>2]=0;c[k>>2]=0;c[a>>2]=c[a>>2]|32;if((g|0)==2)w=0;else w=d-(c[o+4>>2]|0)|0}else v=3;while(0);if((v|0)==3){v=c[a+44>>2]|0;c[a+16>>2]=v+(c[a+48>>2]|0);c[i>>2]=v;c[k>>2]=v;w=d}l=e;return w|0}function wb(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=l;l=l+32|0;f=e;g=e+20|0;c[f>>2]=c[a+60>>2];c[f+4>>2]=0;c[f+8>>2]=b;c[f+12>>2]=g;c[f+16>>2]=d;if((xb(ga(140,f|0)|0)|0)<0){c[g>>2]=-1;h=-1}else h=c[g>>2]|0;l=e;return h|0}function xb(a){a=a|0;var b=0;if(a>>>0>4294963200){c[(yb()|0)>>2]=0-a;b=-1}else b=a;return b|0}function yb(){return (zb()|0)+64|0}function zb(){return Ab()|0}function Ab(){return 1116}function Bb(a){a=a|0;return a|0}function Cb(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;f=l;l=l+32|0;g=f;c[b+36>>2]=4;if((c[b>>2]&64|0)==0?(c[g>>2]=c[b+60>>2],c[g+4>>2]=21523,c[g+8>>2]=f+16,ba(54,g|0)|0):0)a[b+75>>0]=-1;g=vb(b,d,e)|0;l=f;return g|0}function Db(a){a=a|0;return 0}function Eb(a){a=a|0;return}function Fb(){da(31468);return 31476}function Gb(){ka(31468);return}function Hb(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;do if(a){if((c[a+76>>2]|0)<=-1){b=Ib(a)|0;break}d=(Db(a)|0)==0;e=Ib(a)|0;if(d)b=e;else{Eb(a);b=e}}else{if(!(c[371]|0))f=0;else f=Hb(c[371]|0)|0;e=c[(Fb()|0)>>2]|0;if(!e)g=f;else{d=e;e=f;while(1){if((c[d+76>>2]|0)>-1)h=Db(d)|0;else h=0;if((c[d+20>>2]|0)>>>0>(c[d+28>>2]|0)>>>0)i=Ib(d)|0|e;else i=e;if(h|0)Eb(d);d=c[d+56>>2]|0;if(!d){g=i;break}else e=i}}Gb();b=g}while(0);return b|0}function Ib(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;b=a+20|0;d=a+28|0;if((c[b>>2]|0)>>>0>(c[d>>2]|0)>>>0?(qa[c[a+36>>2]&7](a,0,0)|0,(c[b>>2]|0)==0):0)e=-1;else{f=a+4|0;g=c[f>>2]|0;h=a+8|0;i=c[h>>2]|0;if(g>>>0>>0)qa[c[a+40>>2]&7](a,g-i|0,1)|0;c[a+16>>2]=0;c[d>>2]=0;c[b>>2]=0;c[h>>2]=0;c[f>>2]=0;e=0}return e|0}function Jb(a){a=a|0;var b=0,c=0;b=(a|0)==0?1:a;while(1){a=rb(b)|0;if(a|0){c=a;break}a=ic()|0;if(!a){c=0;break}ua[a&0]()}return c|0}function Kb(a){a=a|0;sb(a);return}function Lb(a){a=a|0;return}function Mb(a){a=a|0;Lb(a);Kb(a);return}function Nb(a){a=a|0;return}function Ob(a){a=a|0;return}function Pb(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=l;l=l+64|0;f=e;if(!(Tb(a,b,0)|0))if((b|0)!=0?(g=Xb(b,56,40,0)|0,(g|0)!=0):0){b=f+4|0;h=b+52|0;do{c[b>>2]=0;b=b+4|0}while((b|0)<(h|0));c[f>>2]=g;c[f+8>>2]=a;c[f+12>>2]=-1;c[f+48>>2]=1;wa[c[(c[g>>2]|0)+28>>2]&3](g,f,c[d>>2]|0,1);if((c[f+24>>2]|0)==1){c[d>>2]=c[f+16>>2];i=1}else i=0;j=i}else j=0;else j=1;l=e;return j|0}function Qb(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;if(Tb(a,c[b+8>>2]|0,g)|0)Wb(0,b,d,e,f);return}function Rb(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0;do if(!(Tb(b,c[d+8>>2]|0,g)|0)){if(Tb(b,c[d>>2]|0,g)|0){h=d+32|0;if((c[d+16>>2]|0)!=(e|0)?(i=d+20|0,(c[i>>2]|0)!=(e|0)):0){c[h>>2]=f;c[i>>2]=e;i=d+40|0;c[i>>2]=(c[i>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0)a[d+54>>0]=1;c[d+44>>2]=4;break}if((f|0)==1)c[h>>2]=1}}else Vb(0,d,e,f);while(0);return}function Sb(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;if(Tb(a,c[b+8>>2]|0,0)|0)Ub(0,b,d,e);return}function Tb(a,b,c){a=a|0;b=b|0;c=c|0;return (a|0)==(b|0)|0}function Ub(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;b=d+16|0;g=c[b>>2]|0;h=d+36|0;i=d+24|0;do if(g){if((g|0)!=(e|0)){c[h>>2]=(c[h>>2]|0)+1;c[i>>2]=2;a[d+54>>0]=1;break}if((c[i>>2]|0)==2)c[i>>2]=f}else{c[b>>2]=e;c[i>>2]=f;c[h>>2]=1}while(0);return}function Vb(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;if((c[b+4>>2]|0)==(d|0)?(d=b+28|0,(c[d>>2]|0)!=1):0)c[d>>2]=e;return}function Wb(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0;a[d+53>>0]=1;do if((c[d+4>>2]|0)==(f|0)){a[d+52>>0]=1;b=d+16|0;h=c[b>>2]|0;i=d+54|0;j=d+48|0;k=d+24|0;l=d+36|0;if(!h){c[b>>2]=e;c[k>>2]=g;c[l>>2]=1;if(!((c[j>>2]|0)==1&(g|0)==1))break;a[i>>0]=1;break}if((h|0)!=(e|0)){c[l>>2]=(c[l>>2]|0)+1;a[i>>0]=1;break}l=c[k>>2]|0;if((l|0)==2){c[k>>2]=g;m=g}else m=l;if((c[j>>2]|0)==1&(m|0)==1)a[i>>0]=1}while(0);return}function Xb(d,e,f,g){d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,m=0,n=0,o=0,p=0,q=0,r=0;h=l;l=l+64|0;i=h;j=c[d>>2]|0;k=d+(c[j+-8>>2]|0)|0;m=c[j+-4>>2]|0;c[i>>2]=f;c[i+4>>2]=d;c[i+8>>2]=e;c[i+12>>2]=g;g=i+16|0;e=i+20|0;d=i+24|0;j=i+28|0;n=i+32|0;o=i+40|0;p=g;q=p+36|0;do{c[p>>2]=0;p=p+4|0}while((p|0)<(q|0));b[g+36>>1]=0;a[g+38>>0]=0;a:do if(Tb(m,f,0)|0){c[i+48>>2]=1;va[c[(c[m>>2]|0)+20>>2]&3](m,i,k,k,1,0);r=(c[d>>2]|0)==1?k:0}else{ra[c[(c[m>>2]|0)+24>>2]&7](m,i,k,1,0);switch(c[i+36>>2]|0){case 0:{r=(c[o>>2]|0)==1&(c[j>>2]|0)==1&(c[n>>2]|0)==1?c[e>>2]|0:0;break a;break}case 1:break;default:{r=0;break a}}if((c[d>>2]|0)!=1?!((c[o>>2]|0)==0&(c[j>>2]|0)==1&(c[n>>2]|0)==1):0){r=0;break}r=c[g>>2]|0}while(0);l=h;return r|0}function Yb(a){a=a|0;Lb(a);Kb(a);return}function Zb(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0;if(Tb(a,c[b+8>>2]|0,g)|0)Wb(0,b,d,e,f);else{h=c[a+8>>2]|0;va[c[(c[h>>2]|0)+20>>2]&3](h,b,d,e,f,g)}return}function _b(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;do if(!(Tb(b,c[d+8>>2]|0,g)|0)){h=b+8|0;if(!(Tb(b,c[d>>2]|0,g)|0)){i=c[h>>2]|0;ra[c[(c[i>>2]|0)+24>>2]&7](i,d,e,f,g);break}i=d+32|0;if((c[d+16>>2]|0)!=(e|0)?(j=d+20|0,(c[j>>2]|0)!=(e|0)):0){c[i>>2]=f;k=d+44|0;if((c[k>>2]|0)==4)break;l=d+52|0;a[l>>0]=0;m=d+53|0;a[m>>0]=0;n=c[h>>2]|0;va[c[(c[n>>2]|0)+20>>2]&3](n,d,e,e,1,g);if(a[m>>0]|0)if(!(a[l>>0]|0)){o=3;p=11}else q=3;else{o=4;p=11}if((p|0)==11){c[j>>2]=e;j=d+40|0;c[j>>2]=(c[j>>2]|0)+1;if((c[d+36>>2]|0)==1?(c[d+24>>2]|0)==2:0){a[d+54>>0]=1;q=o}else q=o}c[k>>2]=q;break}if((f|0)==1)c[i>>2]=1}else Vb(0,d,e,f);while(0);return}function $b(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;if(Tb(a,c[b+8>>2]|0,0)|0)Ub(0,b,d,e);else{f=c[a+8>>2]|0;wa[c[(c[f>>2]|0)+28>>2]&3](f,b,d,e)}return}function ac(a){a=a|0;return}function bc(a){a=a|0;Lb(a);Kb(a);return}function cc(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;if(Tb(b,c[d+8>>2]|0,h)|0)Wb(0,d,e,f,g);else{i=d+52|0;j=a[i>>0]|0;k=d+53|0;l=a[k>>0]|0;m=c[b+12>>2]|0;n=b+16+(m<<3)|0;a[i>>0]=0;a[k>>0]=0;gc(b+16|0,d,e,f,g,h);a:do if((m|0)>1){o=d+24|0;p=d+54|0;q=b+8|0;r=b+24|0;do{if(a[p>>0]|0)break a;if(!(a[i>>0]|0)){if(a[k>>0]|0?(c[q>>2]&1|0)==0:0)break a}else{if((c[o>>2]|0)==1)break a;if(!(c[q>>2]&2))break a}a[i>>0]=0;a[k>>0]=0;gc(r,d,e,f,g,h);r=r+8|0}while(r>>>0>>0)}while(0);a[i>>0]=j;a[k>>0]=l}return}function dc(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;a:do if(!(Tb(b,c[d+8>>2]|0,g)|0)){h=b+12|0;i=d+24|0;j=d+36|0;k=d+54|0;l=b+8|0;m=b+16|0;if(!(Tb(b,c[d>>2]|0,g)|0)){n=c[h>>2]|0;o=b+16+(n<<3)|0;hc(m,d,e,f,g);p=b+24|0;if((n|0)<=1)break;n=c[l>>2]|0;if((n&2|0)==0?(c[j>>2]|0)!=1:0){if(!(n&1)){n=p;while(1){if(a[k>>0]|0)break a;if((c[j>>2]|0)==1)break a;hc(n,d,e,f,g);n=n+8|0;if(n>>>0>=o>>>0)break a}}else q=p;while(1){if(a[k>>0]|0)break a;if((c[j>>2]|0)==1?(c[i>>2]|0)==1:0)break a;hc(q,d,e,f,g);q=q+8|0;if(q>>>0>=o>>>0)break a}}else r=p;while(1){if(a[k>>0]|0)break a;hc(r,d,e,f,g);r=r+8|0;if(r>>>0>=o>>>0)break a}}o=d+32|0;if((c[d+16>>2]|0)!=(e|0)?(p=d+20|0,(c[p>>2]|0)!=(e|0)):0){c[o>>2]=f;n=d+44|0;if((c[n>>2]|0)==4)break;s=b+16+(c[h>>2]<<3)|0;t=d+52|0;u=d+53|0;v=0;w=m;x=0;b:while(1){if(w>>>0>=s>>>0){y=v;z=18;break}a[t>>0]=0;a[u>>0]=0;gc(w,d,e,e,1,g);if(a[k>>0]|0){y=v;z=18;break}do if(a[u>>0]|0){if(!(a[t>>0]|0))if(!(c[l>>2]&1)){y=1;z=18;break b}else{A=1;B=x;break}if((c[i>>2]|0)==1){z=23;break b}if(!(c[l>>2]&2)){z=23;break b}else{A=1;B=1}}else{A=v;B=x}while(0);v=A;w=w+8|0;x=B}do if((z|0)==18){if((!x?(c[p>>2]=e,w=d+40|0,c[w>>2]=(c[w>>2]|0)+1,(c[j>>2]|0)==1):0)?(c[i>>2]|0)==2:0){a[k>>0]=1;if(y){z=23;break}else{C=4;break}}if(y)z=23;else C=4}while(0);if((z|0)==23)C=3;c[n>>2]=C;break}if((f|0)==1)c[o>>2]=1}else Vb(0,d,e,f);while(0);return}function ec(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;a:do if(!(Tb(b,c[d+8>>2]|0,0)|0)){g=c[b+12>>2]|0;h=b+16+(g<<3)|0;fc(b+16|0,d,e,f);if((g|0)>1){g=d+54|0;i=b+24|0;do{fc(i,d,e,f);if(a[g>>0]|0)break a;i=i+8|0}while(i>>>0>>0)}}else Ub(0,d,e,f);while(0);return}function fc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=c[a+4>>2]|0;g=f>>8;if(!(f&1))h=g;else h=c[(c[d>>2]|0)+g>>2]|0;g=c[a>>2]|0;wa[c[(c[g>>2]|0)+28>>2]&3](g,b,d+h|0,f&2|0?e:2);return}function gc(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0;h=c[a+4>>2]|0;i=h>>8;if(!(h&1))j=i;else j=c[(c[e>>2]|0)+i>>2]|0;i=c[a>>2]|0;va[c[(c[i>>2]|0)+20>>2]&3](i,b,d,e+j|0,h&2|0?f:2,g);return}function hc(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;g=c[a+4>>2]|0;h=g>>8;if(!(g&1))i=h;else i=c[(c[d>>2]|0)+h>>2]|0;h=c[a>>2]|0;ra[c[(c[h>>2]|0)+24>>2]&7](h,b,d+i|0,g&2|0?e:2,f);return}function ic(){var a=0;a=c[7870]|0;c[7870]=a+0;return a|0}function jc(){}function kc(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){y=b>>c;return a>>>c|(b&(1<>c-32|0}function lc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=a+c>>>0;return (y=b+d+(e>>>0>>0|0)>>>0,e|0)|0}function mc(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=b+e|0;d=d&255;if((e|0)>=67){while(b&3){a[b>>0]=d;b=b+1|0}g=f&-4|0;h=g-64|0;i=d|d<<8|d<<16|d<<24;while((b|0)<=(h|0)){c[b>>2]=i;c[b+4>>2]=i;c[b+8>>2]=i;c[b+12>>2]=i;c[b+16>>2]=i;c[b+20>>2]=i;c[b+24>>2]=i;c[b+28>>2]=i;c[b+32>>2]=i;c[b+36>>2]=i;c[b+40>>2]=i;c[b+44>>2]=i;c[b+48>>2]=i;c[b+52>>2]=i;c[b+56>>2]=i;c[b+60>>2]=i;b=b+64|0}while((b|0)<(g|0)){c[b>>2]=i;b=b+4|0}}while((b|0)<(f|0)){a[b>>0]=d;b=b+1|0}return f-e|0}function nc(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){y=b>>>c;return a>>>c|(b&(1<>>c-32|0}function oc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;c=a&65535;d=b&65535;e=N(d,c)|0;f=a>>>16;a=(e>>>16)+(N(d,f)|0)|0;d=b>>>16;b=N(d,c)|0;return (y=(a>>>16)+(N(d,f)|0)+(((a&65535)+b|0)>>>16)|0,a+b<<16|e&65535|0)|0}function pc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;a=c;c=oc(e,a)|0;f=y;return (y=(N(b,a)|0)+(N(d,e)|0)+f|f&0,c|0|0)|0}function qc(a){a=a|0;var b=0,d=0;a=a+15&-16|0;b=c[i>>2]|0;d=b+a|0;if((a|0)>0&(d|0)<(b|0)|(d|0)<0){V()|0;fa(12);return -1}c[i>>2]=d;if((d|0)>(U()|0)?(T()|0)==0:0){c[i>>2]=b;fa(12);return -1}return b|0}function rc(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;if((e|0)>=8192)return ia(b|0,d|0,e|0)|0;f=b|0;g=b+e|0;if((b&3)==(d&3)){while(b&3){if(!e)return f|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}h=g&-4|0;e=h-64|0;while((b|0)<=(e|0)){c[b>>2]=c[d>>2];c[b+4>>2]=c[d+4>>2];c[b+8>>2]=c[d+8>>2];c[b+12>>2]=c[d+12>>2];c[b+16>>2]=c[d+16>>2];c[b+20>>2]=c[d+20>>2];c[b+24>>2]=c[d+24>>2];c[b+28>>2]=c[d+28>>2];c[b+32>>2]=c[d+32>>2];c[b+36>>2]=c[d+36>>2];c[b+40>>2]=c[d+40>>2];c[b+44>>2]=c[d+44>>2];c[b+48>>2]=c[d+48>>2];c[b+52>>2]=c[d+52>>2];c[b+56>>2]=c[d+56>>2];c[b+60>>2]=c[d+60>>2];b=b+64|0;d=d+64|0}while((b|0)<(h|0)){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0}}else{h=g-4|0;while((b|0)<(h|0)){a[b>>0]=a[d>>0]|0;a[b+1>>0]=a[d+1>>0]|0;a[b+2>>0]=a[d+2>>0]|0;a[b+3>>0]=a[d+3>>0]|0;b=b+4|0;d=d+4|0}}while((b|0)<(g|0)){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0}return f|0}function sc(b,c,d){b=b|0;c=c|0;d=d|0;var e=0;if((c|0)<(b|0)&(b|0)<(c+d|0)){e=b;c=c+d|0;b=b+d|0;while((d|0)>0){b=b-1|0;c=c-1|0;d=d-1|0;a[b>>0]=a[c>>0]|0}b=e}else rc(b,c,d)|0;return b|0}function tc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return qa[a&7](b|0,c|0,d|0)|0}function uc(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;ra[a&7](b|0,c|0,d|0,e|0,f|0)}function vc(a,b){a=a|0;b=b|0;sa[a&7](b|0)}function wc(a,b){a=a|0;b=b|0;return ta[a&1](b|0)|0}function xc(a){a=a|0;ua[a&0]()}function yc(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;va[a&3](b|0,c|0,d|0,e|0,f|0,g|0)}function zc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;wa[a&3](b|0,c|0,d|0,e|0)}function Ac(a,b,c){a=a|0;b=b|0;c=c|0;R(0);return 0}function Bc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;R(1)}function Cc(a){a=a|0;R(2)}function Dc(a){a=a|0;R(3);return 0}function Ec(){R(4)}function Fc(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;R(5)}function Gc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;R(6)} + +// EMSCRIPTEN_END_FUNCS +var qa=[Ac,Cb,wb,Pb,vb,Ac,Ac,Ac];var ra=[Bc,bb,Rb,_b,dc,Bc,Bc,Bc];var sa=[Cc,Lb,Mb,Nb,Ob,Yb,bc,Cc];var ta=[Dc,ub];var ua=[Ec];var va=[Fc,Qb,Zb,cc];var wa=[Gc,Sb,$b,ec];return{_synth_send_midi:qb,setThrew:Ba,_bitshift64Lshr:nc,_sbrk:qc,_fflush:Hb,_synth_create:ob,___errno_location:yb,_bitshift64Ashr:kc,_memset:mc,_synth_get_samples:pb,_memcpy:rc,stackAlloc:xa,___muldi3:pc,getTempRet0:Da,setTempRet0:Ca,_i64Add:lc,_emscripten_get_global_libc:tb,stackSave:ya,___muldsi3:oc,_free:sb,runPostSets:jc,establishStackSpace:Aa,_memmove:sc,stackRestore:za,_malloc:rb,stackAlloc:xa,stackSave:ya,stackRestore:za,establishStackSpace:Aa,setThrew:Ba,setTempRet0:Ca,getTempRet0:Da,dynCall_iiii:tc,dynCall_viiiii:uc,dynCall_vi:vc,dynCall_ii:wc,dynCall_v:xc,dynCall_viiiiii:yc,dynCall_viiii:zc}}) + + +// EMSCRIPTEN_END_ASM +(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _synth_send_midi=Module["_synth_send_midi"]=asm["_synth_send_midi"];var setThrew=Module["setThrew"]=asm["setThrew"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var _fflush=Module["_fflush"]=asm["_fflush"];var _synth_create=Module["_synth_create"]=asm["_synth_create"];var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var _bitshift64Ashr=Module["_bitshift64Ashr"]=asm["_bitshift64Ashr"];var _memset=Module["_memset"]=asm["_memset"];var _synth_get_samples=Module["_synth_get_samples"]=asm["_synth_get_samples"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _emscripten_get_global_libc=Module["_emscripten_get_global_libc"]=asm["_emscripten_get_global_libc"];var stackSave=Module["stackSave"]=asm["stackSave"];var ___muldsi3=Module["___muldsi3"]=asm["___muldsi3"];var _free=Module["_free"]=asm["_free"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var _memmove=Module["_memmove"]=asm["_memmove"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var _malloc=Module["_malloc"]=asm["_malloc"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_viiiii=Module["dynCall_viiiii"]=asm["dynCall_viiiii"];var dynCall_vi=Module["dynCall_vi"]=asm["dynCall_vi"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_v=Module["dynCall_v"]=asm["dynCall_v"];var dynCall_viiiiii=Module["dynCall_viiiiii"]=asm["dynCall_viiiiii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=Module["stackAlloc"];Runtime.stackSave=Module["stackSave"];Runtime.stackRestore=Module["stackRestore"];Runtime.establishStackSpace=Module["establishStackSpace"];Runtime.setTempRet0=Module["setTempRet0"];Runtime.getTempRet0=Module["getTempRet0"];Module["asm"]=asm;if(memoryInitializer){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,Runtime.GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,Runtime.GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];if(request.status!==200&&request.status!==0){console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}applyMemoryInitializer(request.response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=Module.run=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["exit"](status)}Module["quit"](status,new ExitStatus(status))}Module["exit"]=Module.exit=exit;var abortDecorators=[];function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;var extra="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";var output="abort("+what+") at "+stackTrace()+extra;if(abortDecorators){abortDecorators.forEach((function(decorator){output=decorator(output,what)}))}throw output}Module["abort"]=Module.abort=abort;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}run() + + + + diff --git a/app/src/main/jni/synthcore.js.mem b/app/src/main/jni/synthcore.js.mem new file mode 100644 index 0000000..692bd5b Binary files /dev/null and b/app/src/main/jni/synthcore.js.mem differ diff --git a/app/src/main/jni/ui.js b/app/src/main/jni/ui.js new file mode 100644 index 0000000..a10410d --- /dev/null +++ b/app/src/main/jni/ui.js @@ -0,0 +1,86 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +var svgns = "http://www.w3.org/2000/svg"; + +var noteX = [0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12]; +var noteY = [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0]; + +var xscale = 25; +var yscale = 70; + +var notes = {}; + +class Note { + constructor(rect, cls) { + this.rect = rect; + this.cls = cls; + } + + note_on() { + this.rect.setAttribute("class", "pressed"); + } + + note_off() { + this.rect.setAttribute("class", this.cls); + } +} + +function addNote(parent, noteNum) { + var octave = Math.floor(noteNum / 12); + var noteId = noteNum % 12; + var x = 1 + xscale * (octave * 14 + noteX[noteId]); + var y = 100 - yscale * noteY[noteId]; + var rect = document.createElementNS(svgns, "rect"); + rect.setAttribute("x", x); + rect.setAttribute("y", y); + rect.setAttribute("rx", 5); + rect.setAttribute("ry", 5); + rect.setAttribute("width", 2 * xscale - 2); + rect.setAttribute("height", yscale - 2); + var cls = noteY[noteId] ? "black" : "white"; + rect.setAttribute("class", cls); + parent.appendChild(rect); + rect.addEventListener('mouseover', function(e) { + console.log('mouseover', noteNum); + }); + rect.addEventListener('mousedown', function(e) { + //e.target.setCapture(); + e.preventDefault(); + rect.setAttribute("class", "pressed"); + console.log(noteNum, 'down'); + audio.sendMidi(new Uint8Array([0x90, noteNum + 48, 64])); + function upEvent(e) { + e.preventDefault(); + rect.setAttribute("class", cls); + console.log(noteNum, 'up'); + audio.sendMidi(new Uint8Array([0x80, noteNum + 48, 64])); + document.removeEventListener('mouseup', upEvent); + } + document.addEventListener('mouseup', upEvent); + }); + notes[noteNum] = new Note(rect, cls); +} + +function uiInit() { + var svg = document.getElementById('svg'); + var svgns = "http://www.w3.org/2000/svg"; + for (var note = 0; note < 25; note++) { + addNote(svg, note); + } +} + +window.addEventListener('load', uiInit);