Add JetStream to PerformanceTests
[WebKit-https.git] / PerformanceTests / JetStream / simple / container.cpp.js
1 // The Module object: Our interface to the outside world. We import
2 // and export values on it, and do the work to get that through
3 // closure compiler if necessary. There are various ways Module can be used:
4 // 1. Not defined. We create it here
5 // 2. A function parameter, function(Module) { ..generated code.. }
6 // 3. pre-run appended it, var Module = {}; ..generated code..
7 // 4. External script tag defines var Module.
8 // We need to do an eval in order to handle the closure compiler
9 // case, where this code here is minified but Module was defined
10 // elsewhere (e.g. case 4 above). We also need to check if Module
11 // already exists (e.g. case 3 above).
12 // Note that if you want to run closure, and also to use Module
13 // after the generated code, you will need to define   var Module = {};
14 // before the code. Then that object will be used in the code, and you
15 // can continue to use Module afterwards as well.
16 var Module;
17 if (!Module) Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
18
19 // Sometimes an existing Module object exists with properties
20 // meant to overwrite the default module functionality. Here
21 // we collect those properties and reapply _after_ we configure
22 // the current environment's defaults to avoid having to be so
23 // defensive during initialization.
24 var moduleOverrides = {};
25 for (var key in Module) {
26   if (Module.hasOwnProperty(key)) {
27     moduleOverrides[key] = Module[key];
28   }
29 }
30
31 // The environment setup code below is customized to use Module.
32 // *** Environment setup code ***
33 var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
34 var ENVIRONMENT_IS_WEB = typeof window === 'object';
35 var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
36 var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
37
38 if (ENVIRONMENT_IS_NODE) {
39   // Expose functionality in the same simple way that the shells work
40   // Note that we pollute the global namespace here, otherwise we break in node
41   if (!Module['print']) Module['print'] = function print(x) {
42     process['stdout'].write(x + '\n');
43   };
44   if (!Module['printErr']) Module['printErr'] = function printErr(x) {
45     process['stderr'].write(x + '\n');
46   };
47
48   var nodeFS = require('fs');
49   var nodePath = require('path');
50
51   Module['read'] = function read(filename, binary) {
52     filename = nodePath['normalize'](filename);
53     var ret = nodeFS['readFileSync'](filename);
54     // The path is absolute if the normalized version is the same as the resolved.
55     if (!ret && filename != nodePath['resolve'](filename)) {
56       filename = path.join(__dirname, '..', 'src', filename);
57       ret = nodeFS['readFileSync'](filename);
58     }
59     if (ret && !binary) ret = ret.toString();
60     return ret;
61   };
62
63   Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
64
65   Module['load'] = function load(f) {
66     globalEval(read(f));
67   };
68
69   Module['arguments'] = process['argv'].slice(2);
70
71   module['exports'] = Module;
72 }
73 else if (ENVIRONMENT_IS_SHELL) {
74   if (!Module['print']) Module['print'] = print;
75   if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
76
77   if (typeof read != 'undefined') {
78     Module['read'] = read;
79   } else {
80     Module['read'] = function read() { throw 'no read() available (jsc?)' };
81   }
82
83   Module['readBinary'] = function readBinary(f) {
84     return read(f, 'binary');
85   };
86
87   if (typeof scriptArgs != 'undefined') {
88     Module['arguments'] = scriptArgs;
89   } else if (typeof arguments != 'undefined') {
90     Module['arguments'] = arguments;
91   }
92
93   this['Module'] = Module;
94
95   eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
96 }
97 else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
98   Module['read'] = function read(url) {
99     var xhr = new XMLHttpRequest();
100     xhr.open('GET', url, false);
101     xhr.send(null);
102     return xhr.responseText;
103   };
104
105   if (typeof arguments != 'undefined') {
106     Module['arguments'] = arguments;
107   }
108
109   if (typeof console !== 'undefined') {
110     if (!Module['print']) Module['print'] = function print(x) {
111       console.log(x);
112     };
113     if (!Module['printErr']) Module['printErr'] = function printErr(x) {
114       console.log(x);
115     };
116   } else {
117     // Probably a worker, and without console.log. We can do very little here...
118     var TRY_USE_DUMP = false;
119     if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
120       dump(x);
121     }) : (function(x) {
122       // self.postMessage(x); // enable this if you want stdout to be sent as messages
123     }));
124   }
125
126   if (ENVIRONMENT_IS_WEB) {
127     this['Module'] = Module;
128   } else {
129     Module['load'] = importScripts;
130   }
131 }
132 else {
133   // Unreachable because SHELL is dependant on the others
134   throw 'Unknown runtime environment. Where are we?';
135 }
136
137 function globalEval(x) {
138   eval.call(null, x);
139 }
140 if (!Module['load'] == 'undefined' && Module['read']) {
141   Module['load'] = function load(f) {
142     globalEval(Module['read'](f));
143   };
144 }
145 if (!Module['print']) {
146   Module['print'] = function(){};
147 }
148 if (!Module['printErr']) {
149   Module['printErr'] = Module['print'];
150 }
151 if (!Module['arguments']) {
152   Module['arguments'] = [];
153 }
154 // *** Environment setup code ***
155
156 // Closure helpers
157 Module.print = Module['print'];
158 Module.printErr = Module['printErr'];
159
160 // Callbacks
161 Module['preRun'] = [];
162 Module['postRun'] = [];
163
164 // Merge back in the overrides
165 for (var key in moduleOverrides) {
166   if (moduleOverrides.hasOwnProperty(key)) {
167     Module[key] = moduleOverrides[key];
168   }
169 }
170
171
172
173 // === Auto-generated preamble library stuff ===
174
175 //========================================
176 // Runtime code shared with compiler
177 //========================================
178
179 var Runtime = {
180   stackSave: function () {
181     return STACKTOP;
182   },
183   stackRestore: function (stackTop) {
184     STACKTOP = stackTop;
185   },
186   forceAlign: function (target, quantum) {
187     quantum = quantum || 4;
188     if (quantum == 1) return target;
189     if (isNumber(target) && isNumber(quantum)) {
190       return Math.ceil(target/quantum)*quantum;
191     } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
192       return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
193     }
194     return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
195   },
196   isNumberType: function (type) {
197     return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
198   },
199   isPointerType: function isPointerType(type) {
200   return type[type.length-1] == '*';
201 },
202   isStructType: function isStructType(type) {
203   if (isPointerType(type)) return false;
204   if (isArrayType(type)) return true;
205   if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
206   // See comment in isStructPointerType()
207   return type[0] == '%';
208 },
209   INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
210   FLOAT_TYPES: {"float":0,"double":0},
211   or64: function (x, y) {
212     var l = (x | 0) | (y | 0);
213     var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
214     return l + h;
215   },
216   and64: function (x, y) {
217     var l = (x | 0) & (y | 0);
218     var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
219     return l + h;
220   },
221   xor64: function (x, y) {
222     var l = (x | 0) ^ (y | 0);
223     var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
224     return l + h;
225   },
226   getNativeTypeSize: function (type) {
227     switch (type) {
228       case 'i1': case 'i8': return 1;
229       case 'i16': return 2;
230       case 'i32': return 4;
231       case 'i64': return 8;
232       case 'float': return 4;
233       case 'double': return 8;
234       default: {
235         if (type[type.length-1] === '*') {
236           return Runtime.QUANTUM_SIZE; // A pointer
237         } else if (type[0] === 'i') {
238           var bits = parseInt(type.substr(1));
239           assert(bits % 8 === 0);
240           return bits/8;
241         } else {
242           return 0;
243         }
244       }
245     }
246   },
247   getNativeFieldSize: function (type) {
248     return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
249   },
250   dedup: function dedup(items, ident) {
251   var seen = {};
252   if (ident) {
253     return items.filter(function(item) {
254       if (seen[item[ident]]) return false;
255       seen[item[ident]] = true;
256       return true;
257     });
258   } else {
259     return items.filter(function(item) {
260       if (seen[item]) return false;
261       seen[item] = true;
262       return true;
263     });
264   }
265 },
266   set: function set() {
267   var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
268   var ret = {};
269   for (var i = 0; i < args.length; i++) {
270     ret[args[i]] = 0;
271   }
272   return ret;
273 },
274   STACK_ALIGN: 8,
275   getAlignSize: function (type, size, vararg) {
276     // we align i64s and doubles on 64-bit boundaries, unlike x86
277     if (!vararg && (type == 'i64' || type == 'double')) return 8;
278     if (!type) return Math.min(size, 8); // align structures internally to 64 bits
279     return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
280   },
281   calculateStructAlignment: function calculateStructAlignment(type) {
282     type.flatSize = 0;
283     type.alignSize = 0;
284     var diffs = [];
285     var prev = -1;
286     var index = 0;
287     type.flatIndexes = type.fields.map(function(field) {
288       index++;
289       var size, alignSize;
290       if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
291         size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
292         alignSize = Runtime.getAlignSize(field, size);
293       } else if (Runtime.isStructType(field)) {
294         if (field[1] === '0') {
295           // this is [0 x something]. When inside another structure like here, it must be at the end,
296           // and it adds no size
297           // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
298           size = 0;
299           if (Types.types[field]) {
300             alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
301           } else {
302             alignSize = type.alignSize || QUANTUM_SIZE;
303           }
304         } else {
305           size = Types.types[field].flatSize;
306           alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
307         }
308       } else if (field[0] == 'b') {
309         // bN, large number field, like a [N x i8]
310         size = field.substr(1)|0;
311         alignSize = 1;
312       } else if (field[0] === '<') {
313         // vector type
314         size = alignSize = Types.types[field].flatSize; // fully aligned
315       } else if (field[0] === 'i') {
316         // illegal integer field, that could not be legalized because it is an internal structure field
317         // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
318         size = alignSize = parseInt(field.substr(1))/8;
319         assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
320       } else {
321         assert(false, 'invalid type for calculateStructAlignment');
322       }
323       if (type.packed) alignSize = 1;
324       type.alignSize = Math.max(type.alignSize, alignSize);
325       var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
326       type.flatSize = curr + size;
327       if (prev >= 0) {
328         diffs.push(curr-prev);
329       }
330       prev = curr;
331       return curr;
332     });
333     if (type.name_ && type.name_[0] === '[') {
334       // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
335       // allocating a potentially huge array for [999999 x i8] etc.
336       type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
337     }
338     type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
339     if (diffs.length == 0) {
340       type.flatFactor = type.flatSize;
341     } else if (Runtime.dedup(diffs).length == 1) {
342       type.flatFactor = diffs[0];
343     }
344     type.needsFlattening = (type.flatFactor != 1);
345     return type.flatIndexes;
346   },
347   generateStructInfo: function (struct, typeName, offset) {
348     var type, alignment;
349     if (typeName) {
350       offset = offset || 0;
351       type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
352       if (!type) return null;
353       if (type.fields.length != struct.length) {
354         printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
355         return null;
356       }
357       alignment = type.flatIndexes;
358     } else {
359       var type = { fields: struct.map(function(item) { return item[0] }) };
360       alignment = Runtime.calculateStructAlignment(type);
361     }
362     var ret = {
363       __size__: type.flatSize
364     };
365     if (typeName) {
366       struct.forEach(function(item, i) {
367         if (typeof item === 'string') {
368           ret[item] = alignment[i] + offset;
369         } else {
370           // embedded struct
371           var key;
372           for (var k in item) key = k;
373           ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
374         }
375       });
376     } else {
377       struct.forEach(function(item, i) {
378         ret[item[1]] = alignment[i];
379       });
380     }
381     return ret;
382   },
383   dynCall: function (sig, ptr, args) {
384     if (args && args.length) {
385       if (!args.splice) args = Array.prototype.slice.call(args);
386       args.splice(0, 0, ptr);
387       return Module['dynCall_' + sig].apply(null, args);
388     } else {
389       return Module['dynCall_' + sig].call(null, ptr);
390     }
391   },
392   functionPointers: [],
393   addFunction: function (func) {
394     for (var i = 0; i < Runtime.functionPointers.length; i++) {
395       if (!Runtime.functionPointers[i]) {
396         Runtime.functionPointers[i] = func;
397         return 2*(1 + i);
398       }
399     }
400     throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
401   },
402   removeFunction: function (index) {
403     Runtime.functionPointers[(index-2)/2] = null;
404   },
405   getAsmConst: function (code, numArgs) {
406     // code is a constant string on the heap, so we can cache these
407     if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
408     var func = Runtime.asmConstCache[code];
409     if (func) return func;
410     var args = [];
411     for (var i = 0; i < numArgs; i++) {
412       args.push(String.fromCharCode(36) + i); // $0, $1 etc
413     }
414     code = Pointer_stringify(code);
415     if (code[0] === '"') {
416       // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
417       if (code.indexOf('"', 1) === code.length-1) {
418         code = code.substr(1, code.length-2);
419       } else {
420         // something invalid happened, e.g. EM_ASM("..code($0)..", input)
421         abort('invalid EM_ASM input |' + code + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
422       }
423     }
424     return Runtime.asmConstCache[code] = eval('(function(' + args.join(',') + '){ ' + code + ' })'); // new Function does not allow upvars in node
425   },
426   warnOnce: function (text) {
427     if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
428     if (!Runtime.warnOnce.shown[text]) {
429       Runtime.warnOnce.shown[text] = 1;
430       Module.printErr(text);
431     }
432   },
433   funcWrappers: {},
434   getFuncWrapper: function (func, sig) {
435     assert(sig);
436     if (!Runtime.funcWrappers[func]) {
437       Runtime.funcWrappers[func] = function dynCall_wrapper() {
438         return Runtime.dynCall(sig, func, arguments);
439       };
440     }
441     return Runtime.funcWrappers[func];
442   },
443   UTF8Processor: function () {
444     var buffer = [];
445     var needed = 0;
446     this.processCChar = function (code) {
447       code = code & 0xFF;
448
449       if (buffer.length == 0) {
450         if ((code & 0x80) == 0x00) {        // 0xxxxxxx
451           return String.fromCharCode(code);
452         }
453         buffer.push(code);
454         if ((code & 0xE0) == 0xC0) {        // 110xxxxx
455           needed = 1;
456         } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
457           needed = 2;
458         } else {                            // 11110xxx
459           needed = 3;
460         }
461         return '';
462       }
463
464       if (needed) {
465         buffer.push(code);
466         needed--;
467         if (needed > 0) return '';
468       }
469
470       var c1 = buffer[0];
471       var c2 = buffer[1];
472       var c3 = buffer[2];
473       var c4 = buffer[3];
474       var ret;
475       if (buffer.length == 2) {
476         ret = String.fromCharCode(((c1 & 0x1F) << 6)  | (c2 & 0x3F));
477       } else if (buffer.length == 3) {
478         ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6)  | (c3 & 0x3F));
479       } else {
480         // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
481         var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
482                         ((c3 & 0x3F) << 6)  | (c4 & 0x3F);
483         ret = String.fromCharCode(
484           Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
485           (codePoint - 0x10000) % 0x400 + 0xDC00);
486       }
487       buffer.length = 0;
488       return ret;
489     }
490     this.processJSString = function processJSString(string) {
491       string = unescape(encodeURIComponent(string));
492       var ret = [];
493       for (var i = 0; i < string.length; i++) {
494         ret.push(string.charCodeAt(i));
495       }
496       return ret;
497     }
498   },
499   getCompilerSetting: function (name) {
500     throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
501   },
502   stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
503   staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
504   dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
505   alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
506   makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
507   GLOBAL_BASE: 8,
508   QUANTUM_SIZE: 4,
509   __dummy__: 0
510 }
511
512
513 Module['Runtime'] = Runtime;
514
515
516
517
518
519
520
521
522
523 //========================================
524 // Runtime essentials
525 //========================================
526
527 var __THREW__ = 0; // Used in checking for thrown exceptions.
528
529 var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
530 var EXITSTATUS = 0;
531
532 var undef = 0;
533 // tempInt is used for 32-bit signed values or smaller. tempBigInt is used
534 // for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
535 var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
536 var tempI64, tempI64b;
537 var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
538
539 function assert(condition, text) {
540   if (!condition) {
541     abort('Assertion failed: ' + text);
542   }
543 }
544
545 var globalScope = this;
546
547 // C calling interface. A convenient way to call C functions (in C files, or
548 // defined with extern "C").
549 //
550 // Note: LLVM optimizations can inline and remove functions, after which you will not be
551 //       able to call them. Closure can also do so. To avoid that, add your function to
552 //       the exports using something like
553 //
554 //         -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
555 //
556 // @param ident      The name of the C function (note that C++ functions will be name-mangled - use extern "C")
557 // @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
558 //                   'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
559 // @param argTypes   An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,
560 //                   except that 'array' is not possible (there is no way for us to know the length of the array)
561 // @param args       An array of the arguments to the function, as native JS values (as in returnType)
562 //                   Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
563 // @return           The return value, as a native JS value (as in returnType)
564 function ccall(ident, returnType, argTypes, args) {
565   return ccallFunc(getCFunc(ident), returnType, argTypes, args);
566 }
567 Module["ccall"] = ccall;
568
569 // Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
570 function getCFunc(ident) {
571   try {
572     var func = Module['_' + ident]; // closure exported function
573     if (!func) func = eval('_' + ident); // explicit lookup
574   } catch(e) {
575   }
576   assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
577   return func;
578 }
579
580 // Internal function that does a C call using a function, not an identifier
581 function ccallFunc(func, returnType, argTypes, args) {
582   var stack = 0;
583   function toC(value, type) {
584     if (type == 'string') {
585       if (value === null || value === undefined || value === 0) return 0; // null string
586       value = intArrayFromString(value);
587       type = 'array';
588     }
589     if (type == 'array') {
590       if (!stack) stack = Runtime.stackSave();
591       var ret = Runtime.stackAlloc(value.length);
592       writeArrayToMemory(value, ret);
593       return ret;
594     }
595     return value;
596   }
597   function fromC(value, type) {
598     if (type == 'string') {
599       return Pointer_stringify(value);
600     }
601     assert(type != 'array');
602     return value;
603   }
604   var i = 0;
605   var cArgs = args ? args.map(function(arg) {
606     return toC(arg, argTypes[i++]);
607   }) : [];
608   var ret = fromC(func.apply(null, cArgs), returnType);
609   if (stack) Runtime.stackRestore(stack);
610   return ret;
611 }
612
613 // Returns a native JS wrapper for a C function. This is similar to ccall, but
614 // returns a function you can call repeatedly in a normal way. For example:
615 //
616 //   var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
617 //   alert(my_function(5, 22));
618 //   alert(my_function(99, 12));
619 //
620 function cwrap(ident, returnType, argTypes) {
621   var func = getCFunc(ident);
622   return function() {
623     return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
624   }
625 }
626 Module["cwrap"] = cwrap;
627
628 // Sets a value in memory in a dynamic way at run-time. Uses the
629 // type data. This is the same as makeSetValue, except that
630 // makeSetValue is done at compile-time and generates the needed
631 // code then, whereas this function picks the right code at
632 // run-time.
633 // Note that setValue and getValue only do *aligned* writes and reads!
634 // Note that ccall uses JS types as for defining types, while setValue and
635 // getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
636 function setValue(ptr, value, type, noSafe) {
637   type = type || 'i8';
638   if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
639     switch(type) {
640       case 'i1': HEAP8[(ptr)]=value; break;
641       case 'i8': HEAP8[(ptr)]=value; break;
642       case 'i16': HEAP16[((ptr)>>1)]=value; break;
643       case 'i32': HEAP32[((ptr)>>2)]=value; break;
644       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;
645       case 'float': HEAPF32[((ptr)>>2)]=value; break;
646       case 'double': HEAPF64[((ptr)>>3)]=value; break;
647       default: abort('invalid type for setValue: ' + type);
648     }
649 }
650 Module['setValue'] = setValue;
651
652 // Parallel to setValue.
653 function getValue(ptr, type, noSafe) {
654   type = type || 'i8';
655   if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
656     switch(type) {
657       case 'i1': return HEAP8[(ptr)];
658       case 'i8': return HEAP8[(ptr)];
659       case 'i16': return HEAP16[((ptr)>>1)];
660       case 'i32': return HEAP32[((ptr)>>2)];
661       case 'i64': return HEAP32[((ptr)>>2)];
662       case 'float': return HEAPF32[((ptr)>>2)];
663       case 'double': return HEAPF64[((ptr)>>3)];
664       default: abort('invalid type for setValue: ' + type);
665     }
666   return null;
667 }
668 Module['getValue'] = getValue;
669
670 var ALLOC_NORMAL = 0; // Tries to use _malloc()
671 var ALLOC_STACK = 1; // Lives for the duration of the current function call
672 var ALLOC_STATIC = 2; // Cannot be freed
673 var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
674 var ALLOC_NONE = 4; // Do not allocate
675 Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
676 Module['ALLOC_STACK'] = ALLOC_STACK;
677 Module['ALLOC_STATIC'] = ALLOC_STATIC;
678 Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
679 Module['ALLOC_NONE'] = ALLOC_NONE;
680
681 // allocate(): This is for internal use. You can use it yourself as well, but the interface
682 //             is a little tricky (see docs right below). The reason is that it is optimized
683 //             for multiple syntaxes to save space in generated code. So you should
684 //             normally not use allocate(), and instead allocate memory using _malloc(),
685 //             initialize it with setValue(), and so forth.
686 // @slab: An array of data, or a number. If a number, then the size of the block to allocate,
687 //        in *bytes* (note that this is sometimes confusing: the next parameter does not
688 //        affect this!)
689 // @types: Either an array of types, one for each byte (or 0 if no type at that position),
690 //         or a single type which is used for the entire block. This only matters if there
691 //         is initial data - if @slab is a number, then this does not matter at all and is
692 //         ignored.
693 // @allocator: How to allocate memory, see ALLOC_*
694 function allocate(slab, types, allocator, ptr) {
695   var zeroinit, size;
696   if (typeof slab === 'number') {
697     zeroinit = true;
698     size = slab;
699   } else {
700     zeroinit = false;
701     size = slab.length;
702   }
703
704   var singleType = typeof types === 'string' ? types : null;
705
706   var ret;
707   if (allocator == ALLOC_NONE) {
708     ret = ptr;
709   } else {
710     ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
711   }
712
713   if (zeroinit) {
714     var ptr = ret, stop;
715     assert((ret & 3) == 0);
716     stop = ret + (size & ~3);
717     for (; ptr < stop; ptr += 4) {
718       HEAP32[((ptr)>>2)]=0;
719     }
720     stop = ret + size;
721     while (ptr < stop) {
722       HEAP8[((ptr++)|0)]=0;
723     }
724     return ret;
725   }
726
727   if (singleType === 'i8') {
728     if (slab.subarray || slab.slice) {
729       HEAPU8.set(slab, ret);
730     } else {
731       HEAPU8.set(new Uint8Array(slab), ret);
732     }
733     return ret;
734   }
735
736   var i = 0, type, typeSize, previousType;
737   while (i < size) {
738     var curr = slab[i];
739
740     if (typeof curr === 'function') {
741       curr = Runtime.getFunctionIndex(curr);
742     }
743
744     type = singleType || types[i];
745     if (type === 0) {
746       i++;
747       continue;
748     }
749
750     if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
751
752     setValue(ret+i, curr, type);
753
754     // no need to look up size unless type changes, so cache it
755     if (previousType !== type) {
756       typeSize = Runtime.getNativeTypeSize(type);
757       previousType = type;
758     }
759     i += typeSize;
760   }
761
762   return ret;
763 }
764 Module['allocate'] = allocate;
765
766 function Pointer_stringify(ptr, /* optional */ length) {
767   // TODO: use TextDecoder
768   // Find the length, and check for UTF while doing so
769   var hasUtf = false;
770   var t;
771   var i = 0;
772   while (1) {
773     t = HEAPU8[(((ptr)+(i))|0)];
774     if (t >= 128) hasUtf = true;
775     else if (t == 0 && !length) break;
776     i++;
777     if (length && i == length) break;
778   }
779   if (!length) length = i;
780
781   var ret = '';
782
783   if (!hasUtf) {
784     var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
785     var curr;
786     while (length > 0) {
787       curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
788       ret = ret ? ret + curr : curr;
789       ptr += MAX_CHUNK;
790       length -= MAX_CHUNK;
791     }
792     return ret;
793   }
794
795   var utf8 = new Runtime.UTF8Processor();
796   for (i = 0; i < length; i++) {
797     t = HEAPU8[(((ptr)+(i))|0)];
798     ret += utf8.processCChar(t);
799   }
800   return ret;
801 }
802 Module['Pointer_stringify'] = Pointer_stringify;
803
804 // Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
805 // a copy of that string as a Javascript String object.
806 function UTF16ToString(ptr) {
807   var i = 0;
808
809   var str = '';
810   while (1) {
811     var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
812     if (codeUnit == 0)
813       return str;
814     ++i;
815     // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
816     str += String.fromCharCode(codeUnit);
817   }
818 }
819 Module['UTF16ToString'] = UTF16ToString;
820
821 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
822 // null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
823 function stringToUTF16(str, outPtr) {
824   for(var i = 0; i < str.length; ++i) {
825     // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
826     var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
827     HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
828   }
829   // Null-terminate the pointer to the HEAP.
830   HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
831 }
832 Module['stringToUTF16'] = stringToUTF16;
833
834 // Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
835 // a copy of that string as a Javascript String object.
836 function UTF32ToString(ptr) {
837   var i = 0;
838
839   var str = '';
840   while (1) {
841     var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
842     if (utf32 == 0)
843       return str;
844     ++i;
845     // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
846     if (utf32 >= 0x10000) {
847       var ch = utf32 - 0x10000;
848       str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
849     } else {
850       str += String.fromCharCode(utf32);
851     }
852   }
853 }
854 Module['UTF32ToString'] = UTF32ToString;
855
856 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
857 // null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
858 // but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
859 function stringToUTF32(str, outPtr) {
860   var iChar = 0;
861   for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
862     // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
863     var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
864     if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
865       var trailSurrogate = str.charCodeAt(++iCodeUnit);
866       codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
867     }
868     HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
869     ++iChar;
870   }
871   // Null-terminate the pointer to the HEAP.
872   HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
873 }
874 Module['stringToUTF32'] = stringToUTF32;
875
876 function demangle(func) {
877   var i = 3;
878   // params, etc.
879   var basicTypes = {
880     'v': 'void',
881     'b': 'bool',
882     'c': 'char',
883     's': 'short',
884     'i': 'int',
885     'l': 'long',
886     'f': 'float',
887     'd': 'double',
888     'w': 'wchar_t',
889     'a': 'signed char',
890     'h': 'unsigned char',
891     't': 'unsigned short',
892     'j': 'unsigned int',
893     'm': 'unsigned long',
894     'x': 'long long',
895     'y': 'unsigned long long',
896     'z': '...'
897   };
898   var subs = [];
899   var first = true;
900   function dump(x) {
901     //return;
902     if (x) Module.print(x);
903     Module.print(func);
904     var pre = '';
905     for (var a = 0; a < i; a++) pre += ' ';
906     Module.print (pre + '^');
907   }
908   function parseNested() {
909     i++;
910     if (func[i] === 'K') i++; // ignore const
911     var parts = [];
912     while (func[i] !== 'E') {
913       if (func[i] === 'S') { // substitution
914         i++;
915         var next = func.indexOf('_', i);
916         var num = func.substring(i, next) || 0;
917         parts.push(subs[num] || '?');
918         i = next+1;
919         continue;
920       }
921       if (func[i] === 'C') { // constructor
922         parts.push(parts[parts.length-1]);
923         i += 2;
924         continue;
925       }
926       var size = parseInt(func.substr(i));
927       var pre = size.toString().length;
928       if (!size || !pre) { i--; break; } // counter i++ below us
929       var curr = func.substr(i + pre, size);
930       parts.push(curr);
931       subs.push(curr);
932       i += pre + size;
933     }
934     i++; // skip E
935     return parts;
936   }
937   function parse(rawList, limit, allowVoid) { // main parser
938     limit = limit || Infinity;
939     var ret = '', list = [];
940     function flushList() {
941       return '(' + list.join(', ') + ')';
942     }
943     var name;
944     if (func[i] === 'N') {
945       // namespaced N-E
946       name = parseNested().join('::');
947       limit--;
948       if (limit === 0) return rawList ? [name] : name;
949     } else {
950       // not namespaced
951       if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
952       var size = parseInt(func.substr(i));
953       if (size) {
954         var pre = size.toString().length;
955         name = func.substr(i + pre, size);
956         i += pre + size;
957       }
958     }
959     first = false;
960     if (func[i] === 'I') {
961       i++;
962       var iList = parse(true);
963       var iRet = parse(true, 1, true);
964       ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
965     } else {
966       ret = name;
967     }
968     paramLoop: while (i < func.length && limit-- > 0) {
969       //dump('paramLoop');
970       var c = func[i++];
971       if (c in basicTypes) {
972         list.push(basicTypes[c]);
973       } else {
974         switch (c) {
975           case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
976           case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
977           case 'L': { // literal
978             i++; // skip basic type
979             var end = func.indexOf('E', i);
980             var size = end - i;
981             list.push(func.substr(i, size));
982             i += size + 2; // size + 'EE'
983             break;
984           }
985           case 'A': { // array
986             var size = parseInt(func.substr(i));
987             i += size.toString().length;
988             if (func[i] !== '_') throw '?';
989             i++; // skip _
990             list.push(parse(true, 1, true)[0] + ' [' + size + ']');
991             break;
992           }
993           case 'E': break paramLoop;
994           default: ret += '?' + c; break paramLoop;
995         }
996       }
997     }
998     if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
999     return rawList ? list : ret + flushList();
1000   }
1001   try {
1002     // Special-case the entry point, since its name differs from other name mangling.
1003     if (func == 'Object._main' || func == '_main') {
1004       return 'main()';
1005     }
1006     if (typeof func === 'number') func = Pointer_stringify(func);
1007     if (func[0] !== '_') return func;
1008     if (func[1] !== '_') return func; // C function
1009     if (func[2] !== 'Z') return func;
1010     switch (func[3]) {
1011       case 'n': return 'operator new()';
1012       case 'd': return 'operator delete()';
1013     }
1014     return parse();
1015   } catch(e) {
1016     return func;
1017   }
1018 }
1019
1020 function demangleAll(text) {
1021   return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
1022 }
1023
1024 function stackTrace() {
1025   var stack = new Error().stack;
1026   return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
1027 }
1028
1029 // Memory management
1030
1031 var PAGE_SIZE = 4096;
1032 function alignMemoryPage(x) {
1033   return (x+4095)&-4096;
1034 }
1035
1036 var HEAP;
1037 var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
1038
1039 var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
1040 var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
1041 var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
1042
1043 function enlargeMemory() {
1044   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 ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
1045 }
1046
1047 var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
1048 var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 16777216;
1049 var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
1050
1051 var totalMemory = 4096;
1052 while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
1053   if (totalMemory < 16*1024*1024) {
1054     totalMemory *= 2;
1055   } else {
1056     totalMemory += 16*1024*1024
1057   }
1058 }
1059 if (totalMemory !== TOTAL_MEMORY) {
1060   Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
1061   TOTAL_MEMORY = totalMemory;
1062 }
1063
1064 // Initialize the runtime's memory
1065 // check for full engine support (use string 'subarray' to avoid closure compiler confusion)
1066 assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
1067        'JS engine does not provide full typed array support');
1068
1069 var buffer = new ArrayBuffer(TOTAL_MEMORY);
1070 HEAP8 = new Int8Array(buffer);
1071 HEAP16 = new Int16Array(buffer);
1072 HEAP32 = new Int32Array(buffer);
1073 HEAPU8 = new Uint8Array(buffer);
1074 HEAPU16 = new Uint16Array(buffer);
1075 HEAPU32 = new Uint32Array(buffer);
1076 HEAPF32 = new Float32Array(buffer);
1077 HEAPF64 = new Float64Array(buffer);
1078
1079 // Endianness check (note: assumes compiler arch was little-endian)
1080 HEAP32[0] = 255;
1081 assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
1082
1083 Module['HEAP'] = HEAP;
1084 Module['HEAP8'] = HEAP8;
1085 Module['HEAP16'] = HEAP16;
1086 Module['HEAP32'] = HEAP32;
1087 Module['HEAPU8'] = HEAPU8;
1088 Module['HEAPU16'] = HEAPU16;
1089 Module['HEAPU32'] = HEAPU32;
1090 Module['HEAPF32'] = HEAPF32;
1091 Module['HEAPF64'] = HEAPF64;
1092
1093 function callRuntimeCallbacks(callbacks) {
1094   while(callbacks.length > 0) {
1095     var callback = callbacks.shift();
1096     if (typeof callback == 'function') {
1097       callback();
1098       continue;
1099     }
1100     var func = callback.func;
1101     if (typeof func === 'number') {
1102       if (callback.arg === undefined) {
1103         Runtime.dynCall('v', func);
1104       } else {
1105         Runtime.dynCall('vi', func, [callback.arg]);
1106       }
1107     } else {
1108       func(callback.arg === undefined ? null : callback.arg);
1109     }
1110   }
1111 }
1112
1113 var __ATPRERUN__  = []; // functions called before the runtime is initialized
1114 var __ATINIT__    = []; // functions called during startup
1115 var __ATMAIN__    = []; // functions called when main() is to be run
1116 var __ATEXIT__    = []; // functions called during shutdown
1117 var __ATPOSTRUN__ = []; // functions called after the runtime has exited
1118
1119 var runtimeInitialized = false;
1120
1121 function preRun() {
1122   // compatibility - merge in anything from Module['preRun'] at this time
1123   if (Module['preRun']) {
1124     if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
1125     while (Module['preRun'].length) {
1126       addOnPreRun(Module['preRun'].shift());
1127     }
1128   }
1129   callRuntimeCallbacks(__ATPRERUN__);
1130 }
1131
1132 function ensureInitRuntime() {
1133   if (runtimeInitialized) return;
1134   runtimeInitialized = true;
1135   callRuntimeCallbacks(__ATINIT__);
1136 }
1137
1138 function preMain() {
1139   callRuntimeCallbacks(__ATMAIN__);
1140 }
1141
1142 function exitRuntime() {
1143   callRuntimeCallbacks(__ATEXIT__);
1144 }
1145
1146 function postRun() {
1147   // compatibility - merge in anything from Module['postRun'] at this time
1148   if (Module['postRun']) {
1149     if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
1150     while (Module['postRun'].length) {
1151       addOnPostRun(Module['postRun'].shift());
1152     }
1153   }
1154   callRuntimeCallbacks(__ATPOSTRUN__);
1155 }
1156
1157 function addOnPreRun(cb) {
1158   __ATPRERUN__.unshift(cb);
1159 }
1160 Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
1161
1162 function addOnInit(cb) {
1163   __ATINIT__.unshift(cb);
1164 }
1165 Module['addOnInit'] = Module.addOnInit = addOnInit;
1166
1167 function addOnPreMain(cb) {
1168   __ATMAIN__.unshift(cb);
1169 }
1170 Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
1171
1172 function addOnExit(cb) {
1173   __ATEXIT__.unshift(cb);
1174 }
1175 Module['addOnExit'] = Module.addOnExit = addOnExit;
1176
1177 function addOnPostRun(cb) {
1178   __ATPOSTRUN__.unshift(cb);
1179 }
1180 Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
1181
1182 // Tools
1183
1184 // This processes a JS string into a C-line array of numbers, 0-terminated.
1185 // For LLVM-originating strings, see parser.js:parseLLVMString function
1186 function intArrayFromString(stringy, dontAddNull, length /* optional */) {
1187   var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
1188   if (length) {
1189     ret.length = length;
1190   }
1191   if (!dontAddNull) {
1192     ret.push(0);
1193   }
1194   return ret;
1195 }
1196 Module['intArrayFromString'] = intArrayFromString;
1197
1198 function intArrayToString(array) {
1199   var ret = [];
1200   for (var i = 0; i < array.length; i++) {
1201     var chr = array[i];
1202     if (chr > 0xFF) {
1203       chr &= 0xFF;
1204     }
1205     ret.push(String.fromCharCode(chr));
1206   }
1207   return ret.join('');
1208 }
1209 Module['intArrayToString'] = intArrayToString;
1210
1211 // Write a Javascript array to somewhere in the heap
1212 function writeStringToMemory(string, buffer, dontAddNull) {
1213   var array = intArrayFromString(string, dontAddNull);
1214   var i = 0;
1215   while (i < array.length) {
1216     var chr = array[i];
1217     HEAP8[(((buffer)+(i))|0)]=chr;
1218     i = i + 1;
1219   }
1220 }
1221 Module['writeStringToMemory'] = writeStringToMemory;
1222
1223 function writeArrayToMemory(array, buffer) {
1224   for (var i = 0; i < array.length; i++) {
1225     HEAP8[(((buffer)+(i))|0)]=array[i];
1226   }
1227 }
1228 Module['writeArrayToMemory'] = writeArrayToMemory;
1229
1230 function writeAsciiToMemory(str, buffer, dontAddNull) {
1231   for (var i = 0; i < str.length; i++) {
1232     HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
1233   }
1234   if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
1235 }
1236 Module['writeAsciiToMemory'] = writeAsciiToMemory;
1237
1238 function unSign(value, bits, ignore) {
1239   if (value >= 0) {
1240     return value;
1241   }
1242   return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
1243                     : Math.pow(2, bits)         + value;
1244 }
1245 function reSign(value, bits, ignore) {
1246   if (value <= 0) {
1247     return value;
1248   }
1249   var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
1250                         : Math.pow(2, bits-1);
1251   if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
1252                                                        // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
1253                                                        // TODO: In i64 mode 1, resign the two parts separately and safely
1254     value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
1255   }
1256   return value;
1257 }
1258
1259 // check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
1260 if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
1261   var ah  = a >>> 16;
1262   var al = a & 0xffff;
1263   var bh  = b >>> 16;
1264   var bl = b & 0xffff;
1265   return (al*bl + ((ah*bl + al*bh) << 16))|0;
1266 };
1267 Math.imul = Math['imul'];
1268
1269
1270 var Math_abs = Math.abs;
1271 var Math_cos = Math.cos;
1272 var Math_sin = Math.sin;
1273 var Math_tan = Math.tan;
1274 var Math_acos = Math.acos;
1275 var Math_asin = Math.asin;
1276 var Math_atan = Math.atan;
1277 var Math_atan2 = Math.atan2;
1278 var Math_exp = Math.exp;
1279 var Math_log = Math.log;
1280 var Math_sqrt = Math.sqrt;
1281 var Math_ceil = Math.ceil;
1282 var Math_floor = Math.floor;
1283 var Math_pow = Math.pow;
1284 var Math_imul = Math.imul;
1285 var Math_fround = Math.fround;
1286 var Math_min = Math.min;
1287
1288 // A counter of dependencies for calling run(). If we need to
1289 // do asynchronous work before running, increment this and
1290 // decrement it. Incrementing must happen in a place like
1291 // PRE_RUN_ADDITIONS (used by emcc to add file preloading).
1292 // Note that you can add dependencies in preRun, even though
1293 // it happens right before run - run will be postponed until
1294 // the dependencies are met.
1295 var runDependencies = 0;
1296 var runDependencyWatcher = null;
1297 var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
1298
1299 function addRunDependency(id) {
1300   runDependencies++;
1301   if (Module['monitorRunDependencies']) {
1302     Module['monitorRunDependencies'](runDependencies);
1303   }
1304 }
1305 Module['addRunDependency'] = addRunDependency;
1306 function removeRunDependency(id) {
1307   runDependencies--;
1308   if (Module['monitorRunDependencies']) {
1309     Module['monitorRunDependencies'](runDependencies);
1310   }
1311   if (runDependencies == 0) {
1312     if (runDependencyWatcher !== null) {
1313       clearInterval(runDependencyWatcher);
1314       runDependencyWatcher = null;
1315     }
1316     if (dependenciesFulfilled) {
1317       var callback = dependenciesFulfilled;
1318       dependenciesFulfilled = null;
1319       callback(); // can add another dependenciesFulfilled
1320     }
1321   }
1322 }
1323 Module['removeRunDependency'] = removeRunDependency;
1324
1325 Module["preloadedImages"] = {}; // maps url to image data
1326 Module["preloadedAudios"] = {}; // maps url to audio data
1327
1328
1329 var memoryInitializer = null;
1330
1331 // === Body ===
1332 var __ZTVN10__cxxabiv117__class_type_infoE = 15392;
1333 var __ZTVN10__cxxabiv120__si_class_type_infoE = 15432;
1334
1335
1336
1337
1338 STATIC_BASE = 8;
1339
1340 STATICTOP = STATIC_BASE + Runtime.alignMemory(16259);
1341 /* global initializers */ __ATINIT__.push({ func: function() { __GLOBAL__I_a() } }, { func: function() { __GLOBAL__I_a18() } });
1342
1343
1344 /* memory initializer */ allocate([], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
1345 /* memory initializer */ allocate([144,14,0,0,1,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,3,0,0,0,2,0,0,0,78,83,116,51,95,95,49,49,49,95,95,115,116,100,111,117,116,98,117,102,73,119,69,69,0,0,0,0,0,0,0,0,80,60,0,0,112,14,0,0,192,20,0,0,0,0,0,0,0,0,0,0,248,14,0,0,3,0,0,0,4,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,5,0,0,0,2,0,0,0,2,0,0,0,6,0,0,0,7,0,0,0,3,0,0,0,4,0,0,0,4,0,0,0,78,83,116,51,95,95,49,49,48,95,95,115,116,100,105,110,98,117,102,73,119,69,69,0,80,60,0,0,224,14,0,0,192,20,0,0,0,0,0,0,117,110,115,117,112,112,111,114,116,101,100,32,108,111,99,97,108,101,32,102,111,114,32,115,116,97,110,100,97,114,100,32,105,110,112,117,116,0,0,0,0,0,0,0,144,15,0,0,5,0,0,0,6,0,0,0,3,0,0,0,5,0,0,0,2,0,0,0,2,0,0,0,8,0,0,0,9,0,0,0,6,0,0,0,10,0,0,0,11,0,0,0,5,0,0,0,7,0,0,0,6,0,0,0,78,83,116,51,95,95,49,49,49,95,95,115,116,100,111,117,116,98,117,102,73,99,69,69,0,0,0,0,0,0,0,0,80,60,0,0,112,15,0,0,128,20,0,0,0,0,0,0,0,0,0,0,248,15,0,0,7,0,0,0,8,0,0,0,4,0,0,0,5,0,0,0,2,0,0,0,2,0,0,0,12,0,0,0,9,0,0,0,6,0,0,0,13,0,0,0,14,0,0,0,7,0,0,0,8,0,0,0,8,0,0,0,78,83,116,51,95,95,49,49,48,95,95,115,116,100,105,110,98,117,102,73,99,69,69,0,80,60,0,0,224,15,0,0,128,20,0,0,0,0,0,0,78,83,116,51,95,95,49,49,52,95,95,115,104,97,114,101,100,95,99,111,117,110,116,69,0,0,0,0,0,0,0,0,40,60,0,0,8,16,0,0,0,0,0,0,112,16,0,0,9,0,0,0,10,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,216,16,0,0,11,0,0,0,12,0,0,0,16,0,0,0,0,0,0,0,83,116,49,49,108,111,103,105,99,95,101,114,114,111,114,0,80,60,0,0,96,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,16,0,0,9,0,0,0,13,0,0,0,15,0,0,0,0,0,0,0,83,116,49,50,108,101,110,103,116,104,95,101,114,114,111,114,0,0,0,0,0,0,0,0,80,60,0,0,152,16,0,0,112,16,0,0,0,0,0,0,83,116,49,51,114,117,110,116,105,109,101,95,101,114,114,111,114,0,0,0,0,0,0,0,80,60,0,0,192,16,0,0,0,0,0,0,0,0,0,0,58,32,0,0,0,0,0,0,0,0,0,0,32,17,0,0,14,0,0,0,15,0,0,0,16,0,0,0,0,0,0,0,78,83,116,51,95,95,49,49,50,115,121,115,116,101,109,95,101,114,114,111,114,69,0,0,80,60,0,0,8,17,0,0,216,16,0,0,0,0,0,0,78,83,116,51,95,95,49,49,52,101,114,114,111,114,95,99,97,116,101,103,111,114,121,69,0,0,0,0,0,0,0,0,40,60,0,0,48,17,0,0,78,83,116,51,95,95,49,49,50,95,95,100,111,95,109,101,115,115,97,103,101,69,0,0,80,60,0,0,88,17,0,0,80,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,97,115,105,99,95,115,116,114,105,110,103,0,0,0,0,0,0,0,0,128,20,0,0,16,0,0,0,17,0,0,0,5,0,0,0,5,0,0,0,2,0,0,0,2,0,0,0,12,0,0,0,9,0,0,0,6,0,0,0,10,0,0,0,11,0,0,0,5,0,0,0,8,0,0,0,8,0,0,0,0,0,0,0,192,20,0,0,18,0,0,0,19,0,0,0,6,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,5,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,1,0,0,0,4,0,0,0,4,0,0,0,8,0,0,0,0,0,0,0,248,20,0,0,20,0,0,0,21,0,0,0,248,255,255,255,248,255,255,255,248,20,0,0,22,0,0,0,23,0,0,0,8,0,0,0,0,0,0,0,64,21,0,0,24,0,0,0,25,0,0,0,248,255,255,255,248,255,255,255,64,21,0,0,26,0,0,0,27,0,0,0,4,0,0,0,0,0,0,0,136,21,0,0,28,0,0,0,29,0,0,0,252,255,255,255,252,255,255,255,136,21,0,0,30,0,0,0,31,0,0,0,4,0,0,0,0,0,0,0,208,21,0,0,32,0,0,0,33,0,0,0,252,255,255,255,252,255,255,255,208,21,0,0,34,0,0,0,35,0,0,0,105,111,115,116,114,101,97,109,0,0,0,0,0,0,0,0,117,110,115,112,101,99,105,102,105,101,100,32,105,111,115,116,114,101,97,109,95,99,97,116,101,103,111,114,121,32,101,114,114,111,114,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,19,0,0,36,0,0,0,37,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,192,19,0,0,38,0,0,0,39,0,0,0,105,111,115,95,98,97,115,101,58,58,99,108,101,97,114,0,78,83,116,51,95,95,49,56,105,111,115,95,98,97,115,101,55,102,97,105,108,117,114,101,69,0,0,0,0,0,0,0,80,60,0,0,120,19,0,0,32,17,0,0,0,0,0,0,78,83,116,51,95,95,49,56,105,111,115,95,98,97,115,101,69,0,0,0,0,0,0,0,40,60,0,0,168,19,0,0,78,83,116,51,95,95,49,57,98,97,115,105,99,95,105,111,115,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,0,0,0,0,0,0,0,80,60,0,0,200,19,0,0,192,19,0,0,0,0,0,0,78,83,116,51,95,95,49,57,98,97,115,105,99,95,105,111,115,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,0,0,0,0,0,0,0,80,60,0,0,8,20,0,0,192,19,0,0,0,0,0,0,78,83,116,51,95,95,49,49,53,98,97,115,105,99,95,115,116,114,101,97,109,98,117,102,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,0,0,0,0,0,0,0,0,40,60,0,0,72,20,0,0,78,83,116,51,95,95,49,49,53,98,97,115,105,99,95,115,116,114,101,97,109,98,117,102,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,0,0,0,0,0,0,0,0,40,60,0,0,136,20,0,0,78,83,116,51,95,95,49,49,51,98,97,115,105,99,95,105,115,116,114,101,97,109,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,0,0,176,60,0,0,200,20,0,0,0,0,0,0,1,0,0,0,248,19,0,0,3,244,255,255,78,83,116,51,95,95,49,49,51,98,97,115,105,99,95,105,115,116,114,101,97,109,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,0,0,176,60,0,0,16,21,0,0,0,0,0,0,1,0,0,0,56,20,0,0,3,244,255,255,78,83,116,51,95,95,49,49,51,98,97,115,105,99,95,111,115,116,114,101,97,109,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,0,0,176,60,0,0,88,21,0,0,0,0,0,0,1,0,0,0,248,19,0,0,3,244,255,255,78,83,116,51,95,95,49,49,51,98,97,115,105,99,95,111,115,116,114,101,97,109,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,0,0,176,60,0,0,160,21,0,0,0,0,0,0,1,0,0,0,56,20,0,0,3,244,255,255,0,0,0,0,48,22,0,0,40,0,0,0,41,0,0,0,17,0,0,0,1,0,0,0,9,0,0,0,10,0,0,0,2,0,0,0,0,0,0,0,78,83,116,51,95,95,49,49,57,95,95,105,111,115,116,114,101,97,109,95,99,97,116,101,103,111,114,121,69,0,0,0,80,60,0,0,16,22,0,0,112,17,0,0,0,0,0,0,0,0,0,0,88,36,0,0,42,0,0,0,43,0,0,0,44,0,0,0,1,0,0,0,3,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,36,0,0,45,0,0,0,46,0,0,0,44,0,0,0,2,0,0,0,4,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,41,0,0,47,0,0,0,48,0,0,0,44,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,65,66,67,68,69,70,120,88,43,45,112,80,105,73,110,78,0,0,0,0,0,0,0,0,37,112,0,0,0,0,0,0,0,0,0,0,200,41,0,0,49,0,0,0,50,0,0,0,44,0,0,0,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,16,0,0,0,17,0,0,0,18,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,42,0,0,51,0,0,0,52,0,0,0,44,0,0,0,3,0,0,0,4,0,0,0,23,0,0,0,5,0,0,0,24,0,0,0,1,0,0,0,2,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,43,0,0,53,0,0,0,54,0,0,0,44,0,0,0,7,0,0,0,8,0,0,0,25,0,0,0,9,0,0,0,26,0,0,0,3,0,0,0,4,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,0,0,0,0,0,0,0,37,112,0,0,0,0,0,0,0,0,0,0,72,38,0,0,55,0,0,0,56,0,0,0,44,0,0,0,18,0,0,0,27,0,0,0,28,0,0,0,29,0,0,0,30,0,0,0,31,0,0,0,1,0,0,0,248,255,255,255,72,38,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,23,0,0,0,24,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,72,58,37,77,58,37,83,37,109,47,37,100,47,37,121,37,89,45,37,109,45,37,100,37,73,58,37,77,58,37,83,32,37,112,0,0,0,0,0,37,72,58,37,77,0,0,0,37,72,58,37,77,58,37,83,0,0,0,0,232,38,0,0,57,0,0,0,58,0,0,0,44,0,0,0,26,0,0,0,32,0,0,0,33,0,0,0,34,0,0,0,35,0,0,0,36,0,0,0,2,0,0,0,248,255,255,255,232,38,0,0,27,0,0,0,28,0,0,0,29,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,0,0,0,72,0,0,0,58,0,0,0,37,0,0,0,77,0,0,0,58,0,0,0,37,0,0,0,83,0,0,0,37,0,0,0,109,0,0,0,47,0,0,0,37,0,0,0,100,0,0,0,47,0,0,0,37,0,0,0,121,0,0,0,37,0,0,0,89,0,0,0,45,0,0,0,37,0,0,0,109,0,0,0,45,0,0,0,37,0,0,0,100,0,0,0,37,0,0,0,73,0,0,0,58,0,0,0,37,0,0,0,77,0,0,0,58,0,0,0,37,0,0,0,83,0,0,0,32,0,0,0,37,0,0,0,112,0,0,0,0,0,0,0,37,0,0,0,72,0,0,0,58,0,0,0,37,0,0,0,77,0,0,0,0,0,0,0,37,0,0,0,72,0,0,0,58,0,0,0,37,0,0,0,77,0,0,0,58,0,0,0,37,0,0,0,83,0,0,0,0,0,0,0,120,39,0,0,59,0,0,0,60,0,0,0,44,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,39,0,0,61,0,0,0,62,0,0,0,44,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,208,36,0,0,63,0,0,0,64,0,0,0,44,0,0,0,34,0,0,0,35,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,36,0,0,0,11,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,37,0,0,65,0,0,0,66,0,0,0,44,0,0,0,37,0,0,0,38,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,16,0,0,0,39,0,0,0,17,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,37,0,0,67,0,0,0,68,0,0,0,44,0,0,0,40,0,0,0,41,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,42,0,0,0,23,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,144,37,0,0,69,0,0,0,70,0,0,0,44,0,0,0,43,0,0,0,44,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,28,0,0,0,45,0,0,0,29,0,0,0,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,43,0,0,71,0,0,0,72,0,0,0,44,0,0,0,3,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,49,50,51,52,53,54,55,56,57,0,0,0,0,0,0,37,76,102,0,0,0,0,0,109,111,110,101,121,95,103,101,116,32,101,114,114,111,114,0,0,0,0,0,64,44,0,0,73,0,0,0,74,0,0,0,44,0,0,0,5,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,49,50,51,52,53,54,55,56,57,0,0,0,0,0,0,0,0,0,0,208,44,0,0,75,0,0,0,76,0,0,0,44,0,0,0,1,0,0,0,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,46,48,76,102,0,0,0,0,0,0,0,96,45,0,0,77,0,0,0,78,0,0,0,44,0,0,0,2,0,0,0,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56,40,0,0,79,0,0,0,80,0,0,0,44,0,0,0,13,0,0,0,11,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,40,0,0,81,0,0,0,82,0,0,0,44,0,0,0,14,0,0,0,12,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,118,101,99,116,111,114,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,67,0,0,0,0,0,0,0,0,0,0,0,48,36,0,0,83,0,0,0,84,0,0,0,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,33,0,0,85,0,0,0,86,0,0,0,44,0,0,0,9,0,0,0,15,0,0,0,10,0,0,0,16,0,0,0,11,0,0,0,1,0,0,0,17,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,232,33,0,0,87,0,0,0,88,0,0,0,44,0,0,0,1,0,0,0,2,0,0,0,4,0,0,0,46,0,0,0,47,0,0,0,5,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,35,0,0,89,0,0,0,90,0,0,0,44,0,0,0,49,0,0,0,50,0,0,0,33,0,0,0,34,0,0,0,35,0,0,0,0,0,0,0,8,36,0,0,91,0,0,0,92,0,0,0,44,0,0,0,51,0,0,0,52,0,0,0,36,0,0,0,37,0,0,0,38,0,0,0,116,114,117,101,0,0,0,0,116,0,0,0,114,0,0,0,117,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,102,97,108,115,101,0,0,0,102,0,0,0,97,0,0,0,108,0,0,0,115,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,109,47,37,100,47,37,121,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,0,0,0,109,0,0,0,47,0,0,0,37,0,0,0,100,0,0,0,47,0,0,0,37,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,72,58,37,77,58,37,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,0,0,0,72,0,0,0,58,0,0,0,37,0,0,0,77,0,0,0,58,0,0,0,37,0,0,0,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,97,32,37,98,32,37,100,32,37,72,58,37,77,58,37,83,32,37,89,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,0,0,0,97,0,0,0,32,0,0,0,37,0,0,0,98,0,0,0,32,0,0,0,37,0,0,0,100,0,0,0,32,0,0,0,37,0,0,0,72,0,0,0,58,0,0,0,37,0,0,0,77,0,0,0,58,0,0,0,37,0,0,0,83,0,0,0,32,0,0,0,37,0,0,0,89,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,73,58,37,77,58,37,83,32,37,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,0,0,0,73,0,0,0,58,0,0,0,37,0,0,0,77,0,0,0,58,0,0,0,37,0,0,0,83,0,0,0,32,0,0,0,37,0,0,0,112,0,0,0,0,0,0,0,108,111,99,97,108,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,0,0,0,0,0,0,0,64,32,0,0,93,0,0,0,94,0,0,0,44,0,0,0,0,0,0,0,78,83,116,51,95,95,49,54,108,111,99,97,108,101,53,102,97,99,101,116,69,0,0,0,80,60,0,0,40,32,0,0,40,16,0,0,0,0,0,0,0,0,0,0,208,32,0,0,93,0,0,0,95,0,0,0,44,0,0,0,18,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,12,0,0,0,19,0,0,0,13,0,0,0,20,0,0,0,14,0,0,0,5,0,0,0,21,0,0,0,6,0,0,0,0,0,0,0,78,83,116,51,95,95,49,53,99,116,121,112,101,73,119,69,69,0,0,0,0,0,0,0,78,83,116,51,95,95,49,49,48,99,116,121,112,101,95,98,97,115,101,69,0,0,0,0,40,60,0,0,176,32,0,0,176,60,0,0,152,32,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,200,32,0,0,2,0,0,0,78,83,116,51,95,95,49,53,99,116,121,112,101,73,99,69,69,0,0,0,0,0,0,0,176,60,0,0,240,32,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,200,32,0,0,2,0,0,0,0,0,0,0,160,33,0,0,93,0,0,0,96,0,0,0,44,0,0,0,3,0,0,0,4,0,0,0,7,0,0,0,53,0,0,0,54,0,0,0,8,0,0,0,55,0,0,0,78,83,116,51,95,95,49,55,99,111,100,101,99,118,116,73,99,99,49,49,95,95,109,98,115,116,97,116,101,95,116,69,69,0,0,0,0,0,0,0,78,83,116,51,95,95,49,49,50,99,111,100,101,99,118,116,95,98,97,115,101,69,0,0,40,60,0,0,128,33,0,0,176,60,0,0,88,33,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,152,33,0,0,2,0,0,0,78,83,116,51,95,95,49,55,99,111,100,101,99,118,116,73,119,99,49,49,95,95,109,98,115,116,97,116,101,95,116,69,69,0,0,0,0,0,0,0,176,60,0,0,192,33,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,152,33,0,0,2,0,0,0,0,0,0,0,96,34,0,0,93,0,0,0,97,0,0,0,44,0,0,0,5,0,0,0,6,0,0,0,9,0,0,0,56,0,0,0,57,0,0,0,10,0,0,0,58,0,0,0,78,83,116,51,95,95,49,55,99,111,100,101,99,118,116,73,68,115,99,49,49,95,95,109,98,115,116,97,116,101,95,116,69,69,0,0,0,0,0,0,176,60,0,0,56,34,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,152,33,0,0,2,0,0,0,0,0,0,0,216,34,0,0,93,0,0,0,98,0,0,0,44,0,0,0,7,0,0,0,8,0,0,0,11,0,0,0,59,0,0,0,60,0,0,0,12,0,0,0,61,0,0,0,78,83,116,51,95,95,49,55,99,111,100,101,99,118,116,73,68,105,99,49,49,95,95,109,98,115,116,97,116,101,95,116,69,69,0,0,0,0,0,0,176,60,0,0,176,34,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,152,33,0,0,2,0,0,0,0,0,0,0,80,35,0,0,93,0,0,0,99,0,0,0,44,0,0,0,7,0,0,0,8,0,0,0,11,0,0,0,59,0,0,0,60,0,0,0,12,0,0,0,61,0,0,0,78,83,116,51,95,95,49,49,54,95,95,110,97,114,114,111,119,95,116,111,95,117,116,102,56,73,76,106,51,50,69,69,69,0,0,0,0,0,0,0,80,60,0,0,40,35,0,0,216,34,0,0,0,0,0,0,0,0,0,0,184,35,0,0,93,0,0,0,100,0,0,0,44,0,0,0,7,0,0,0,8,0,0,0,11,0,0,0,59,0,0,0,60,0,0,0,12,0,0,0,61,0,0,0,78,83,116,51,95,95,49,49,55,95,95,119,105,100,101,110,95,102,114,111,109,95,117,116,102,56,73,76,106,51,50,69,69,69,0,0,0,0,0,0,80,60,0,0,144,35,0,0,216,34,0,0,0,0,0,0,78,83,116,51,95,95,49,56,110,117,109,112,117,110,99,116,73,99,69,69,0,0,0,0,80,60,0,0,200,35,0,0,64,32,0,0,0,0,0,0,78,83,116,51,95,95,49,56,110,117,109,112,117,110,99,116,73,119,69,69,0,0,0,0,80,60,0,0,240,35,0,0,64,32,0,0,0,0,0,0,78,83,116,51,95,95,49,54,108,111,99,97,108,101,53,95,95,105,109,112,69,0,0,0,80,60,0,0,24,36,0,0,64,32,0,0,0,0,0,0,78,83,116,51,95,95,49,55,99,111,108,108,97,116,101,73,99,69,69,0,0,0,0,0,80,60,0,0,64,36,0,0,64,32,0,0,0,0,0,0,78,83,116,51,95,95,49,55,99,111,108,108,97,116,101,73,119,69,69,0,0,0,0,0,80,60,0,0,104,36,0,0,64,32,0,0,0,0,0,0,78,83,116,51,95,95,49,49,48,109,111,110,101,121,112,117,110,99,116,73,99,76,98,48,69,69,69,0,0,0,0,0,78,83,116,51,95,95,49,49,48,109,111,110,101,121,95,98,97,115,101,69,0,0,0,0,40,60,0,0,176,36,0,0,176,60,0,0,144,36,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,200,36,0,0,2,0,0,0,78,83,116,51,95,95,49,49,48,109,111,110,101,121,112,117,110,99,116,73,99,76,98,49,69,69,69,0,0,0,0,0,176,60,0,0,240,36,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,200,36,0,0,2,0,0,0,78,83,116,51,95,95,49,49,48,109,111,110,101,121,112,117,110,99,116,73,119,76,98,48,69,69,69,0,0,0,0,0,176,60,0,0,48,37,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,200,36,0,0,2,0,0,0,78,83,116,51,95,95,49,49,48,109,111,110,101,121,112,117,110,99,116,73,119,76,98,49,69,69,69,0,0,0,0,0,176,60,0,0,112,37,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,200,36,0,0,2,0,0,0,78,83,116,51,95,95,49,56,116,105,109,101,95,103,101,116,73,99,78,83,95,49,57,105,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,69,69,0,0,0,0,78,83,116,51,95,95,49,57,116,105,109,101,95,98,97,115,101,69,0,0,0,0,0,0,40,60,0,0,248,37,0,0,78,83,116,51,95,95,49,50,48,95,95,116,105,109,101,95,103,101,116,95,99,95,115,116,111,114,97,103,101,73,99,69,69,0,0,0,0,0,0,0,40,60,0,0,24,38,0,0,176,60,0,0,176,37,0,0,0,0,0,0,3,0,0,0,64,32,0,0,2,0,0,0,16,38,0,0,2,0,0,0,64,38,0,0,0,8,0,0,78,83,116,51,95,95,49,56,116,105,109,101,95,103,101,116,73,119,78,83,95,49,57,105,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,69,69,0,0,0,0,78,83,116,51,95,95,49,50,48,95,95,116,105,109,101,95,103,101,116,95,99,95,115,116,111,114,97,103,101,73,119,69,69,0,0,0,0,0,0,0,40,60,0,0,184,38,0,0,176,60,0,0,112,38,0,0,0,0,0,0,3,0,0,0,64,32,0,0,2,0,0,0,16,38,0,0,2,0,0,0,224,38,0,0,0,8,0,0,78,83,116,51,95,95,49,56,116,105,109,101,95,112,117,116,73,99,78,83,95,49,57,111,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,69,69,0,0,0,0,78,83,116,51,95,95,49,49,48,95,95,116,105,109,101,95,112,117,116,69,0,0,0,0,40,60,0,0,88,39,0,0,176,60,0,0,16,39,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,112,39,0,0,0,8,0,0,78,83,116,51,95,95,49,56,116,105,109,101,95,112,117,116,73,119,78,83,95,49,57,111,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,69,69,0,0,0,0,176,60,0,0,152,39,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,112,39,0,0,0,8,0,0,78,83,116,51,95,95,49,56,109,101,115,115,97,103,101,115,73,99,69,69,0,0,0,0,78,83,116,51,95,95,49,49,51,109,101,115,115,97,103,101,115,95,98,97,115,101,69,0,40,60,0,0,24,40,0,0,176,60,0,0,0,40,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,48,40,0,0,2,0,0,0,78,83,116,51,95,95,49,56,109,101,115,115,97,103,101,115,73,119,69,69,0,0,0,0,176,60,0,0,88,40,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,48,40,0,0,2,0,0,0,78,83,116,51,95,95,49,55,110,117,109,95,103,101,116,73,99,78,83,95,49,57,105,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,69,69,0,0,0,0,0,78,83,116,51,95,95,49,57,95,95,110,117,109,95,103,101,116,73,99,69,69,0,0,0,78,83,116,51,95,95,49,49,52,95,95,110,117,109,95,103,101,116,95,98,97,115,101,69,0,0,0,0,0,0,0,0,40,60,0,0,240,40,0,0,176,60,0,0,216,40,0,0,0,0,0,0,1,0,0,0,16,41,0,0,0,0,0,0,176,60,0,0,144,40,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,24,41,0,0,0,0,0,0,78,83,116,51,95,95,49,55,110,117,109,95,103,101,116,73,119,78,83,95,49,57,105,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,69,69,0,0,0,0,0,78,83,116,51,95,95,49,57,95,95,110,117,109,95,103,101,116,73,119,69,69,0,0,0,176,60,0,0,152,41,0,0,0,0,0,0,1,0,0,0,16,41,0,0,0,0,0,0,176,60,0,0,80,41,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,176,41,0,0,0,0,0,0,78,83,116,51,95,95,49,55,110,117,109,95,112,117,116,73,99,78,83,95,49,57,111,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,69,69,0,0,0,0,0,78,83,116,51,95,95,49,57,95,95,110,117,109,95,112,117,116,73,99,69,69,0,0,0,78,83,116,51,95,95,49,49,52,95,95,110,117,109,95,112,117,116,95,98,97,115,101,69,0,0,0,0,0,0,0,0,40,60,0,0,72,42,0,0,176,60,0,0,48,42,0,0,0,0,0,0,1,0,0,0,104,42,0,0,0,0,0,0,176,60,0,0,232,41,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,112,42,0,0,0,0,0,0,78,83,116,51,95,95,49,55,110,117,109,95,112,117,116,73,119,78,83,95,49,57,111,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,69,69,0,0,0,0,0,78,83,116,51,95,95,49,57,95,95,110,117,109,95,112,117,116,73,119,69,69,0,0,0,176,60,0,0,240,42,0,0,0,0,0,0,1,0,0,0,104,42,0,0,0,0,0,0,176,60,0,0,168,42,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,8,43,0,0,0,0,0,0,78,83,116,51,95,95,49,57,109,111,110,101,121,95,103,101,116,73,99,78,83,95,49,57,105,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,69,69,0,0,0,78,83,116,51,95,95,49,49,49,95,95,109,111,110,101,121,95,103,101,116,73,99,69,69,0,0,0,0,0,0,0,0,40,60,0,0,136,43,0,0,176,60,0,0,64,43,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,168,43,0,0,0,0,0,0,78,83,116,51,95,95,49,57,109,111,110,101,121,95,103,101,116,73,119,78,83,95,49,57,105,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,69,69,0,0,0,78,83,116,51,95,95,49,49,49,95,95,109,111,110,101,121,95,103,101,116,73,119,69,69,0,0,0,0,0,0,0,0,40,60,0,0,24,44,0,0,176,60,0,0,208,43,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,56,44,0,0,0,0,0,0,78,83,116,51,95,95,49,57,109,111,110,101,121,95,112,117,116,73,99,78,83,95,49,57,111,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,99,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,99,69,69,69,69,69,69,0,0,0,78,83,116,51,95,95,49,49,49,95,95,109,111,110,101,121,95,112,117,116,73,99,69,69,0,0,0,0,0,0,0,0,40,60,0,0,168,44,0,0,176,60,0,0,96,44,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,200,44,0,0,0,0,0,0,78,83,116,51,95,95,49,57,109,111,110,101,121,95,112,117,116,73,119,78,83,95,49,57,111,115,116,114,101,97,109,98,117,102,95,105,116,101,114,97,116,111,114,73,119,78,83,95,49,49,99,104,97,114,95,116,114,97,105,116,115,73,119,69,69,69,69,69,69,0,0,0,78,83,116,51,95,95,49,49,49,95,95,109,111,110,101,121,95,112,117,116,73,119,69,69,0,0,0,0,0,0,0,0,40,60,0,0,56,45,0,0,176,60,0,0,240,44,0,0,0,0,0,0,2,0,0,0,64,32,0,0,2,0,0,0,88,45,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,0,0,0,77,0,0,0,0,0,0,0,0,0,0,0,80,0,0,0,77,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65,77,0,0,0,0,0,0,80,77,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,74,0,0,0,97,0,0,0,110,0,0,0,117,0,0,0,97,0,0,0,114,0,0,0,121,0,0,0,0,0,0,0,70,0,0,0,101,0,0,0,98,0,0,0,114,0,0,0,117,0,0,0,97,0,0,0,114,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,77,0,0,0,97,0,0,0,114,0,0,0,99,0,0,0,104,0,0,0,0,0,0,0,65,0,0,0,112,0,0,0,114,0,0,0,105,0,0,0,108,0,0,0,0,0,0,0,74,0,0,0,117,0,0,0,110,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,74,0,0,0,117,0,0,0,108,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,65,0,0,0,117,0,0,0,103,0,0,0,117,0,0,0,115,0,0,0,116,0,0,0,0,0,0,0,0,0,0,0,83,0,0,0,101,0,0,0,112,0,0,0,116,0,0,0,101,0,0,0,109,0,0,0,98,0,0,0,101,0,0,0,114,0,0,0,0,0,0,0,79,0,0,0,99,0,0,0,116,0,0,0,111,0,0,0,98,0,0,0,101,0,0,0,114,0,0,0,0,0,0,0,78,0,0,0,111,0,0,0,118,0,0,0,101,0,0,0,109,0,0,0,98,0,0,0,101,0,0,0,114,0,0,0,0,0,0,0,0,0,0,0,68,0,0,0,101,0,0,0,99,0,0,0,101,0,0,0,109,0,0,0,98,0,0,0,101,0,0,0,114,0,0,0,0,0,0,0,0,0,0,0,74,0,0,0,97,0,0,0,110,0,0,0,0,0,0,0,70,0,0,0,101,0,0,0,98,0,0,0,0,0,0,0,77,0,0,0,97,0,0,0,114,0,0,0,0,0,0,0,65,0,0,0,112,0,0,0,114,0,0,0,0,0,0,0,77,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,74,0,0,0,117,0,0,0,110,0,0,0,0,0,0,0,74,0,0,0,117,0,0,0,108,0,0,0,0,0,0,0,65,0,0,0,117,0,0,0,103,0,0,0,0,0,0,0,83,0,0,0,101,0,0,0,112,0,0,0,0,0,0,0,79,0,0,0,99,0,0,0,116,0,0,0,0,0,0,0,78,0,0,0,111,0,0,0,118,0,0,0,0,0,0,0,68,0,0,0,101,0,0,0,99], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE+3628);
1346 /* memory initializer */ allocate([74,97,110,117,97,114,121,0,70,101,98,114,117,97,114,121,0,0,0,0,0,0,0,0,77,97,114,99,104,0,0,0,65,112,114,105,108,0,0,0,77,97,121,0,0,0,0,0,74,117,110,101,0,0,0,0,74,117,108,121,0,0,0,0,65,117,103,117,115,116,0,0,83,101,112,116,101,109,98,101,114,0,0,0,0,0,0,0,79,99,116,111,98,101,114,0,78,111,118,101,109,98,101,114,0,0,0,0,0,0,0,0,68,101,99,101,109,98,101,114,0,0,0,0,0,0,0,0,74,97,110,0,0,0,0,0,70,101,98,0,0,0,0,0,77,97,114,0,0,0,0,0,65,112,114,0,0,0,0,0,74,117,110,0,0,0,0,0,74,117,108,0,0,0,0,0,65,117,103,0,0,0,0,0,83,101,112,0,0,0,0,0,79,99,116,0,0,0,0,0,78,111,118,0,0,0,0,0,68,101,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,83,0,0,0,117,0,0,0,110,0,0,0,100,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,77,0,0,0,111,0,0,0,110,0,0,0,100,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,84,0,0,0,117,0,0,0,101,0,0,0,115,0,0,0,100,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,87,0,0,0,101,0,0,0,100,0,0,0,110,0,0,0,101,0,0,0,115,0,0,0,100,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,84,0,0,0,104,0,0,0,117,0,0,0,114,0,0,0,115,0,0,0,100,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,70,0,0,0,114,0,0,0,105,0,0,0,100,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,83,0,0,0,97,0,0,0,116,0,0,0,117,0,0,0,114,0,0,0,100,0,0,0,97,0,0,0,121,0,0,0,0,0,0,0,0,0,0,0,83,0,0,0,117,0,0,0,110,0,0,0,0,0,0,0,77,0,0,0,111,0,0,0,110,0,0,0,0,0,0,0,84,0,0,0,117,0,0,0,101,0,0,0,0,0,0,0,87,0,0,0,101,0,0,0,100,0,0,0,0,0,0,0,84,0,0,0,104,0,0,0,117,0,0,0,0,0,0,0,70,0,0,0,114,0,0,0,105,0,0,0,0,0,0,0,83,0,0,0,97,0,0,0,116,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,83,117,110,100,97,121,0,0,77,111,110,100,97,121,0,0,84,117,101,115,100,97,121,0,87,101,100,110,101,115,100,97,121,0,0,0,0,0,0,0,84,104,117,114,115,100,97,121,0,0,0,0,0,0,0,0,70,114,105,100,97,121,0,0,83,97,116,117,114,100,97,121,0,0,0,0,0,0,0,0,83,117,110,0,0,0,0,0,77,111,110,0,0,0,0,0,84,117,101,0,0,0,0,0,87,101,100,0,0,0,0,0,84,104,117,0,0,0,0,0,70,114,105,0,0,0,0,0,83,97,116,0,0,0,0,0,2,0,0,192,3,0,0,192,4,0,0,192,5,0,0,192,6,0,0,192,7,0,0,192,8,0,0,192,9,0,0,192,10,0,0,192,11,0,0,192,12,0,0,192,13,0,0,192,14,0,0,192,15,0,0,192,16,0,0,192,17,0,0,192,18,0,0,192,19,0,0,192,20,0,0,192,21,0,0,192,22,0,0,192,23,0,0,192,24,0,0,192,25,0,0,192,26,0,0,192,27,0,0,192,28,0,0,192,29,0,0,192,30,0,0,192,31,0,0,192,0,0,0,179,1,0,0,195,2,0,0,195,3,0,0,195,4,0,0,195,5,0,0,195,6,0,0,195,7,0,0,195,8,0,0,195,9,0,0,195,10,0,0,195,11,0,0,195,12,0,0,195,13,0,0,211,14,0,0,195,15,0,0,195,0,0,12,187,1,0,12,195,2,0,12,195,3,0,12,195,4,0,12,211,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,59,0,0,101,0,0,0,102,0,0,0,62,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,99,97,115,116,0,0,0,83,116,57,116,121,112,101,95,105,110,102,111,0,0,0,0,40,60,0,0,120,59,0,0,83,116,56,98,97,100,95,99,97,115,116,0,0,0,0,0,80,60,0,0,144,59,0,0,0,0,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,80,60,0,0,176,59,0,0,136,59,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,80,60,0,0,232,59,0,0,216,59,0,0,0,0,0,0,0,0,0,0,16,60,0,0,103,0,0,0,104,0,0,0,105,0,0,0,106,0,0,0,22,0,0,0,13,0,0,0,1,0,0,0,5,0,0,0,0,0,0,0,152,60,0,0,103,0,0,0,107,0,0,0,105,0,0,0,106,0,0,0,22,0,0,0,14,0,0,0,2,0,0,0,6,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,80,60,0,0,112,60,0,0,16,60,0,0,0,0,0,0,0,0,0,0,248,60,0,0,103,0,0,0,108,0,0,0,105,0,0,0,106,0,0,0,22,0,0,0,15,0,0,0,3,0,0,0,7,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,49,95,95,118,109,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,80,60,0,0,208,60,0,0,16,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56,63,0,0,109,0,0,0,110,0,0,0,63,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,0,83,116,57,98,97,100,95,97,108,108,111,99,0,0,0,0,80,60,0,0,40,63,0,0,0,0,0,0,0,0,0,0,105,110,102,105,110,105,116,121,0,0,0,0,0,0,0,0,110,97,110,0,0,0,0,0,95,112,137,0,255,9,47,15,10,0,0,0,100,0,0,0,232,3,0,0,16,39,0,0,160,134,1,0,64,66,15,0,128,150,152,0,0,225,245,5], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE+13888);
1347
1348
1349
1350
1351 var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
1352
1353 assert(tempDoublePtr % 8 == 0);
1354
1355 function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
1356
1357   HEAP8[tempDoublePtr] = HEAP8[ptr];
1358
1359   HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
1360
1361   HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
1362
1363   HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
1364
1365 }
1366
1367 function copyTempDouble(ptr) {
1368
1369   HEAP8[tempDoublePtr] = HEAP8[ptr];
1370
1371   HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
1372
1373   HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
1374
1375   HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
1376
1377   HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
1378
1379   HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
1380
1381   HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
1382
1383   HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
1384
1385 }
1386
1387
1388   
1389   function _atexit(func, arg) {
1390       __ATEXIT__.unshift({ func: func, arg: arg });
1391     }var ___cxa_atexit=_atexit;
1392
1393   function _llvm_lifetime_end() {}
1394
1395   
1396    
1397   Module["_memset"] = _memset;var _llvm_memset_p0i8_i32=_memset;
1398
1399    
1400   Module["_i64Subtract"] = _i64Subtract;
1401
1402    
1403   Module["_i64Add"] = _i64Add;
1404
1405   
1406   function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
1407       return !!__ZSt18uncaught_exceptionv.uncaught_exception;
1408     }
1409   
1410   
1411   
1412   function ___cxa_is_number_type(type) {
1413       var isNumber = false;
1414       try { if (type == __ZTIi) isNumber = true } catch(e){}
1415       try { if (type == __ZTIj) isNumber = true } catch(e){}
1416       try { if (type == __ZTIl) isNumber = true } catch(e){}
1417       try { if (type == __ZTIm) isNumber = true } catch(e){}
1418       try { if (type == __ZTIx) isNumber = true } catch(e){}
1419       try { if (type == __ZTIy) isNumber = true } catch(e){}
1420       try { if (type == __ZTIf) isNumber = true } catch(e){}
1421       try { if (type == __ZTId) isNumber = true } catch(e){}
1422       try { if (type == __ZTIe) isNumber = true } catch(e){}
1423       try { if (type == __ZTIc) isNumber = true } catch(e){}
1424       try { if (type == __ZTIa) isNumber = true } catch(e){}
1425       try { if (type == __ZTIh) isNumber = true } catch(e){}
1426       try { if (type == __ZTIs) isNumber = true } catch(e){}
1427       try { if (type == __ZTIt) isNumber = true } catch(e){}
1428       return isNumber;
1429     }function ___cxa_does_inherit(definiteType, possibilityType, possibility) {
1430       if (possibility == 0) return false;
1431       if (possibilityType == 0 || possibilityType == definiteType)
1432         return true;
1433       var possibility_type_info;
1434       if (___cxa_is_number_type(possibilityType)) {
1435         possibility_type_info = possibilityType;
1436       } else {
1437         var possibility_type_infoAddr = HEAP32[((possibilityType)>>2)] - 8;
1438         possibility_type_info = HEAP32[((possibility_type_infoAddr)>>2)];
1439       }
1440       switch (possibility_type_info) {
1441       case 0: // possibility is a pointer
1442         // See if definite type is a pointer
1443         var definite_type_infoAddr = HEAP32[((definiteType)>>2)] - 8;
1444         var definite_type_info = HEAP32[((definite_type_infoAddr)>>2)];
1445         if (definite_type_info == 0) {
1446           // Also a pointer; compare base types of pointers
1447           var defPointerBaseAddr = definiteType+8;
1448           var defPointerBaseType = HEAP32[((defPointerBaseAddr)>>2)];
1449           var possPointerBaseAddr = possibilityType+8;
1450           var possPointerBaseType = HEAP32[((possPointerBaseAddr)>>2)];
1451           return ___cxa_does_inherit(defPointerBaseType, possPointerBaseType, possibility);
1452         } else
1453           return false; // one pointer and one non-pointer
1454       case 1: // class with no base class
1455         return false;
1456       case 2: // class with base class
1457         var parentTypeAddr = possibilityType + 8;
1458         var parentType = HEAP32[((parentTypeAddr)>>2)];
1459         return ___cxa_does_inherit(definiteType, parentType, possibility);
1460       default:
1461         return false; // some unencountered type
1462       }
1463     }
1464   
1465   
1466   
1467   var ___cxa_last_thrown_exception=0;function ___resumeException(ptr) {
1468       if (!___cxa_last_thrown_exception) { ___cxa_last_thrown_exception = ptr; }
1469       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.";
1470     }
1471   
1472   var ___cxa_exception_header_size=8;function ___cxa_find_matching_catch(thrown, throwntype) {
1473       if (thrown == -1) thrown = ___cxa_last_thrown_exception;
1474       header = thrown - ___cxa_exception_header_size;
1475       if (throwntype == -1) throwntype = HEAP32[((header)>>2)];
1476       var typeArray = Array.prototype.slice.call(arguments, 2);
1477   
1478       // If throwntype is a pointer, this means a pointer has been
1479       // thrown. When a pointer is thrown, actually what's thrown
1480       // is a pointer to the pointer. We'll dereference it.
1481       if (throwntype != 0 && !___cxa_is_number_type(throwntype)) {
1482         var throwntypeInfoAddr= HEAP32[((throwntype)>>2)] - 8;
1483         var throwntypeInfo= HEAP32[((throwntypeInfoAddr)>>2)];
1484         if (throwntypeInfo == 0)
1485           thrown = HEAP32[((thrown)>>2)];
1486       }
1487       // The different catch blocks are denoted by different types.
1488       // Due to inheritance, those types may not precisely match the
1489       // type of the thrown object. Find one which matches, and
1490       // return the type of the catch block which should be called.
1491       for (var i = 0; i < typeArray.length; i++) {
1492         if (___cxa_does_inherit(typeArray[i], throwntype, thrown))
1493           return ((asm["setTempRet0"](typeArray[i]),thrown)|0);
1494       }
1495       // Shouldn't happen unless we have bogus data in typeArray
1496       // or encounter a type for which emscripten doesn't have suitable
1497       // typeinfo defined. Best-efforts match just in case.
1498       return ((asm["setTempRet0"](throwntype),thrown)|0);
1499     }function ___cxa_throw(ptr, type, destructor) {
1500       if (!___cxa_throw.initialized) {
1501         try {
1502           HEAP32[((__ZTVN10__cxxabiv119__pointer_type_infoE)>>2)]=0; // Workaround for libcxxabi integration bug
1503         } catch(e){}
1504         try {
1505           HEAP32[((__ZTVN10__cxxabiv117__class_type_infoE)>>2)]=1; // Workaround for libcxxabi integration bug
1506         } catch(e){}
1507         try {
1508           HEAP32[((__ZTVN10__cxxabiv120__si_class_type_infoE)>>2)]=2; // Workaround for libcxxabi integration bug
1509         } catch(e){}
1510         ___cxa_throw.initialized = true;
1511       }
1512       var header = ptr - ___cxa_exception_header_size;
1513       HEAP32[((header)>>2)]=type;
1514       HEAP32[(((header)+(4))>>2)]=destructor;
1515       ___cxa_last_thrown_exception = ptr;
1516       if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
1517         __ZSt18uncaught_exceptionv.uncaught_exception = 1;
1518       } else {
1519         __ZSt18uncaught_exceptionv.uncaught_exception++;
1520       }
1521       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.";
1522     }
1523
1524   function _pthread_mutex_lock() {}
1525
1526   
1527   
1528   var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
1529   
1530   var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can   access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
1531   
1532   
1533   var ___errno_state=0;function ___setErrNo(value) {
1534       // For convenient setting and returning of errno.
1535       HEAP32[((___errno_state)>>2)]=value;
1536       return value;
1537     }
1538   
1539   var PATH={splitPath:function (filename) {
1540         var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
1541         return splitPathRe.exec(filename).slice(1);
1542       },normalizeArray:function (parts, allowAboveRoot) {
1543         // if the path tries to go above the root, `up` ends up > 0
1544         var up = 0;
1545         for (var i = parts.length - 1; i >= 0; i--) {
1546           var last = parts[i];
1547           if (last === '.') {
1548             parts.splice(i, 1);
1549           } else if (last === '..') {
1550             parts.splice(i, 1);
1551             up++;
1552           } else if (up) {
1553             parts.splice(i, 1);
1554             up--;
1555           }
1556         }
1557         // if the path is allowed to go above the root, restore leading ..s
1558         if (allowAboveRoot) {
1559           for (; up--; up) {
1560             parts.unshift('..');
1561           }
1562         }
1563         return parts;
1564       },normalize:function (path) {
1565         var isAbsolute = path.charAt(0) === '/',
1566             trailingSlash = path.substr(-1) === '/';
1567         // Normalize the path
1568         path = PATH.normalizeArray(path.split('/').filter(function(p) {
1569           return !!p;
1570         }), !isAbsolute).join('/');
1571         if (!path && !isAbsolute) {
1572           path = '.';
1573         }
1574         if (path && trailingSlash) {
1575           path += '/';
1576         }
1577         return (isAbsolute ? '/' : '') + path;
1578       },dirname:function (path) {
1579         var result = PATH.splitPath(path),
1580             root = result[0],
1581             dir = result[1];
1582         if (!root && !dir) {
1583           // No dirname whatsoever
1584           return '.';
1585         }
1586         if (dir) {
1587           // It has a dirname, strip trailing slash
1588           dir = dir.substr(0, dir.length - 1);
1589         }
1590         return root + dir;
1591       },basename:function (path) {
1592         // EMSCRIPTEN return '/'' for '/', not an empty string
1593         if (path === '/') return '/';
1594         var lastSlash = path.lastIndexOf('/');
1595         if (lastSlash === -1) return path;
1596         return path.substr(lastSlash+1);
1597       },extname:function (path) {
1598         return PATH.splitPath(path)[3];
1599       },join:function () {
1600         var paths = Array.prototype.slice.call(arguments, 0);
1601         return PATH.normalize(paths.join('/'));
1602       },join2:function (l, r) {
1603         return PATH.normalize(l + '/' + r);
1604       },resolve:function () {
1605         var resolvedPath = '',
1606           resolvedAbsolute = false;
1607         for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1608           var path = (i >= 0) ? arguments[i] : FS.cwd();
1609           // Skip empty and invalid entries
1610           if (typeof path !== 'string') {
1611             throw new TypeError('Arguments to path.resolve must be strings');
1612           } else if (!path) {
1613             continue;
1614           }
1615           resolvedPath = path + '/' + resolvedPath;
1616           resolvedAbsolute = path.charAt(0) === '/';
1617         }
1618         // At this point the path should be resolved to a full absolute path, but
1619         // handle relative paths to be safe (might happen when process.cwd() fails)
1620         resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
1621           return !!p;
1622         }), !resolvedAbsolute).join('/');
1623         return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
1624       },relative:function (from, to) {
1625         from = PATH.resolve(from).substr(1);
1626         to = PATH.resolve(to).substr(1);
1627         function trim(arr) {
1628           var start = 0;
1629           for (; start < arr.length; start++) {
1630             if (arr[start] !== '') break;
1631           }
1632           var end = arr.length - 1;
1633           for (; end >= 0; end--) {
1634             if (arr[end] !== '') break;
1635           }
1636           if (start > end) return [];
1637           return arr.slice(start, end - start + 1);
1638         }
1639         var fromParts = trim(from.split('/'));
1640         var toParts = trim(to.split('/'));
1641         var length = Math.min(fromParts.length, toParts.length);
1642         var samePartsLength = length;
1643         for (var i = 0; i < length; i++) {
1644           if (fromParts[i] !== toParts[i]) {
1645             samePartsLength = i;
1646             break;
1647           }
1648         }
1649         var outputParts = [];
1650         for (var i = samePartsLength; i < fromParts.length; i++) {
1651           outputParts.push('..');
1652         }
1653         outputParts = outputParts.concat(toParts.slice(samePartsLength));
1654         return outputParts.join('/');
1655       }};
1656   
1657   var TTY={ttys:[],init:function () {
1658         // https://github.com/kripken/emscripten/pull/1555
1659         // if (ENVIRONMENT_IS_NODE) {
1660         //   // currently, FS.init does not distinguish if process.stdin is a file or TTY
1661         //   // device, it always assumes it's a TTY device. because of this, we're forcing
1662         //   // process.stdin to UTF8 encoding to at least make stdin reading compatible
1663         //   // with text files until FS.init can be refactored.
1664         //   process['stdin']['setEncoding']('utf8');
1665         // }
1666       },shutdown:function () {
1667         // https://github.com/kripken/emscripten/pull/1555
1668         // if (ENVIRONMENT_IS_NODE) {
1669         //   // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
1670         //   // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
1671         //   // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
1672         //   // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
1673         //   // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
1674         //   process['stdin']['pause']();
1675         // }
1676       },register:function (dev, ops) {
1677         TTY.ttys[dev] = { input: [], output: [], ops: ops };
1678         FS.registerDevice(dev, TTY.stream_ops);
1679       },stream_ops:{open:function (stream) {
1680           var tty = TTY.ttys[stream.node.rdev];
1681           if (!tty) {
1682             throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
1683           }
1684           stream.tty = tty;
1685           stream.seekable = false;
1686         },close:function (stream) {
1687           // flush any pending line data
1688           if (stream.tty.output.length) {
1689             stream.tty.ops.put_char(stream.tty, 10);
1690           }
1691         },read:function (stream, buffer, offset, length, pos /* ignored */) {
1692           if (!stream.tty || !stream.tty.ops.get_char) {
1693             throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
1694           }
1695           var bytesRead = 0;
1696           for (var i = 0; i < length; i++) {
1697             var result;
1698             try {
1699               result = stream.tty.ops.get_char(stream.tty);
1700             } catch (e) {
1701               throw new FS.ErrnoError(ERRNO_CODES.EIO);
1702             }
1703             if (result === undefined && bytesRead === 0) {
1704               throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
1705             }
1706             if (result === null || result === undefined) break;
1707             bytesRead++;
1708             buffer[offset+i] = result;
1709           }
1710           if (bytesRead) {
1711             stream.node.timestamp = Date.now();
1712           }
1713           return bytesRead;
1714         },write:function (stream, buffer, offset, length, pos) {
1715           if (!stream.tty || !stream.tty.ops.put_char) {
1716             throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
1717           }
1718           for (var i = 0; i < length; i++) {
1719             try {
1720               stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
1721             } catch (e) {
1722               throw new FS.ErrnoError(ERRNO_CODES.EIO);
1723             }
1724           }
1725           if (length) {
1726             stream.node.timestamp = Date.now();
1727           }
1728           return i;
1729         }},default_tty_ops:{get_char:function (tty) {
1730           if (!tty.input.length) {
1731             var result = null;
1732             if (ENVIRONMENT_IS_NODE) {
1733               result = process['stdin']['read']();
1734               if (!result) {
1735                 if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
1736                   return null;  // EOF
1737                 }
1738                 return undefined;  // no data available
1739               }
1740             } else if (typeof window != 'undefined' &&
1741               typeof window.prompt == 'function') {
1742               // Browser.
1743               result = window.prompt('Input: ');  // returns null on cancel
1744               if (result !== null) {
1745                 result += '\n';
1746               }
1747             } else if (typeof readline == 'function') {
1748               // Command line.
1749               result = readline();
1750               if (result !== null) {
1751                 result += '\n';
1752               }
1753             }
1754             if (!result) {
1755               return null;
1756             }
1757             tty.input = intArrayFromString(result, true);
1758           }
1759           return tty.input.shift();
1760         },put_char:function (tty, val) {
1761           if (val === null || val === 10) {
1762             Module['print'](tty.output.join(''));
1763             tty.output = [];
1764           } else {
1765             tty.output.push(TTY.utf8.processCChar(val));
1766           }
1767         }},default_tty1_ops:{put_char:function (tty, val) {
1768           if (val === null || val === 10) {
1769             Module['printErr'](tty.output.join(''));
1770             tty.output = [];
1771           } else {
1772             tty.output.push(TTY.utf8.processCChar(val));
1773           }
1774         }}};
1775   
1776   var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
1777         return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
1778       },createNode:function (parent, name, mode, dev) {
1779         if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
1780           // no supported
1781           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
1782         }
1783         if (!MEMFS.ops_table) {
1784           MEMFS.ops_table = {
1785             dir: {
1786               node: {
1787                 getattr: MEMFS.node_ops.getattr,
1788                 setattr: MEMFS.node_ops.setattr,
1789                 lookup: MEMFS.node_ops.lookup,
1790                 mknod: MEMFS.node_ops.mknod,
1791                 rename: MEMFS.node_ops.rename,
1792                 unlink: MEMFS.node_ops.unlink,
1793                 rmdir: MEMFS.node_ops.rmdir,
1794                 readdir: MEMFS.node_ops.readdir,
1795                 symlink: MEMFS.node_ops.symlink
1796               },
1797               stream: {
1798                 llseek: MEMFS.stream_ops.llseek
1799               }
1800             },
1801             file: {
1802               node: {
1803                 getattr: MEMFS.node_ops.getattr,
1804                 setattr: MEMFS.node_ops.setattr
1805               },
1806               stream: {
1807                 llseek: MEMFS.stream_ops.llseek,
1808                 read: MEMFS.stream_ops.read,
1809                 write: MEMFS.stream_ops.write,
1810                 allocate: MEMFS.stream_ops.allocate,
1811                 mmap: MEMFS.stream_ops.mmap
1812               }
1813             },
1814             link: {
1815               node: {
1816                 getattr: MEMFS.node_ops.getattr,
1817                 setattr: MEMFS.node_ops.setattr,
1818                 readlink: MEMFS.node_ops.readlink
1819               },
1820               stream: {}
1821             },
1822             chrdev: {
1823               node: {
1824                 getattr: MEMFS.node_ops.getattr,
1825                 setattr: MEMFS.node_ops.setattr
1826               },
1827               stream: FS.chrdev_stream_ops
1828             },
1829           };
1830         }
1831         var node = FS.createNode(parent, name, mode, dev);
1832         if (FS.isDir(node.mode)) {
1833           node.node_ops = MEMFS.ops_table.dir.node;
1834           node.stream_ops = MEMFS.ops_table.dir.stream;
1835           node.contents = {};
1836         } else if (FS.isFile(node.mode)) {
1837           node.node_ops = MEMFS.ops_table.file.node;
1838           node.stream_ops = MEMFS.ops_table.file.stream;
1839           node.contents = [];
1840           node.contentMode = MEMFS.CONTENT_FLEXIBLE;
1841         } else if (FS.isLink(node.mode)) {
1842           node.node_ops = MEMFS.ops_table.link.node;
1843           node.stream_ops = MEMFS.ops_table.link.stream;
1844         } else if (FS.isChrdev(node.mode)) {
1845           node.node_ops = MEMFS.ops_table.chrdev.node;
1846           node.stream_ops = MEMFS.ops_table.chrdev.stream;
1847         }
1848         node.timestamp = Date.now();
1849         // add the new node to the parent
1850         if (parent) {
1851           parent.contents[name] = node;
1852         }
1853         return node;
1854       },ensureFlexible:function (node) {
1855         if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
1856           var contents = node.contents;
1857           node.contents = Array.prototype.slice.call(contents);
1858           node.contentMode = MEMFS.CONTENT_FLEXIBLE;
1859         }
1860       },node_ops:{getattr:function (node) {
1861           var attr = {};
1862           // device numbers reuse inode numbers.
1863           attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
1864           attr.ino = node.id;
1865           attr.mode = node.mode;
1866           attr.nlink = 1;
1867           attr.uid = 0;
1868           attr.gid = 0;
1869           attr.rdev = node.rdev;
1870           if (FS.isDir(node.mode)) {
1871             attr.size = 4096;
1872           } else if (FS.isFile(node.mode)) {
1873             attr.size = node.contents.length;
1874           } else if (FS.isLink(node.mode)) {
1875             attr.size = node.link.length;
1876           } else {
1877             attr.size = 0;
1878           }
1879           attr.atime = new Date(node.timestamp);
1880           attr.mtime = new Date(node.timestamp);
1881           attr.ctime = new Date(node.timestamp);
1882           // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
1883           //       but this is not required by the standard.
1884           attr.blksize = 4096;
1885           attr.blocks = Math.ceil(attr.size / attr.blksize);
1886           return attr;
1887         },setattr:function (node, attr) {
1888           if (attr.mode !== undefined) {
1889             node.mode = attr.mode;
1890           }
1891           if (attr.timestamp !== undefined) {
1892             node.timestamp = attr.timestamp;
1893           }
1894           if (attr.size !== undefined) {
1895             MEMFS.ensureFlexible(node);
1896             var contents = node.contents;
1897             if (attr.size < contents.length) contents.length = attr.size;
1898             else while (attr.size > contents.length) contents.push(0);
1899           }
1900         },lookup:function (parent, name) {
1901           throw FS.genericErrors[ERRNO_CODES.ENOENT];
1902         },mknod:function (parent, name, mode, dev) {
1903           return MEMFS.createNode(parent, name, mode, dev);
1904         },rename:function (old_node, new_dir, new_name) {
1905           // if we're overwriting a directory at new_name, make sure it's empty.
1906           if (FS.isDir(old_node.mode)) {
1907             var new_node;
1908             try {
1909               new_node = FS.lookupNode(new_dir, new_name);
1910             } catch (e) {
1911             }
1912             if (new_node) {
1913               for (var i in new_node.contents) {
1914                 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
1915               }
1916             }
1917           }
1918           // do the internal rewiring
1919           delete old_node.parent.contents[old_node.name];
1920           old_node.name = new_name;
1921           new_dir.contents[new_name] = old_node;
1922           old_node.parent = new_dir;
1923         },unlink:function (parent, name) {
1924           delete parent.contents[name];
1925         },rmdir:function (parent, name) {
1926           var node = FS.lookupNode(parent, name);
1927           for (var i in node.contents) {
1928             throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
1929           }
1930           delete parent.contents[name];
1931         },readdir:function (node) {
1932           var entries = ['.', '..']
1933           for (var key in node.contents) {
1934             if (!node.contents.hasOwnProperty(key)) {
1935               continue;
1936             }
1937             entries.push(key);
1938           }
1939           return entries;
1940         },symlink:function (parent, newname, oldpath) {
1941           var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
1942           node.link = oldpath;
1943           return node;
1944         },readlink:function (node) {
1945           if (!FS.isLink(node.mode)) {
1946             throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
1947           }
1948           return node.link;
1949         }},stream_ops:{read:function (stream, buffer, offset, length, position) {
1950           var contents = stream.node.contents;
1951           if (position >= contents.length)
1952             return 0;
1953           var size = Math.min(contents.length - position, length);
1954           assert(size >= 0);
1955           if (size > 8 && contents.subarray) { // non-trivial, and typed array
1956             buffer.set(contents.subarray(position, position + size), offset);
1957           } else
1958           {
1959             for (var i = 0; i < size; i++) {
1960               buffer[offset + i] = contents[position + i];
1961             }
1962           }
1963           return size;
1964         },write:function (stream, buffer, offset, length, position, canOwn) {
1965           var node = stream.node;
1966           node.timestamp = Date.now();
1967           var contents = node.contents;
1968           if (length && contents.length === 0 && position === 0 && buffer.subarray) {
1969             // just replace it with the new data
1970             if (canOwn && offset === 0) {
1971               node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
1972               node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
1973             } else {
1974               node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
1975               node.contentMode = MEMFS.CONTENT_FIXED;
1976             }
1977             return length;
1978           }
1979           MEMFS.ensureFlexible(node);
1980           var contents = node.contents;
1981           while (contents.length < position) contents.push(0);
1982           for (var i = 0; i < length; i++) {
1983             contents[position + i] = buffer[offset + i];
1984           }
1985           return length;
1986         },llseek:function (stream, offset, whence) {
1987           var position = offset;
1988           if (whence === 1) {  // SEEK_CUR.
1989             position += stream.position;
1990           } else if (whence === 2) {  // SEEK_END.
1991             if (FS.isFile(stream.node.mode)) {
1992               position += stream.node.contents.length;
1993             }
1994           }
1995           if (position < 0) {
1996             throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
1997           }
1998           stream.ungotten = [];
1999           stream.position = position;
2000           return position;
2001         },allocate:function (stream, offset, length) {
2002           MEMFS.ensureFlexible(stream.node);
2003           var contents = stream.node.contents;
2004           var limit = offset + length;
2005           while (limit > contents.length) contents.push(0);
2006         },mmap:function (stream, buffer, offset, length, position, prot, flags) {
2007           if (!FS.isFile(stream.node.mode)) {
2008             throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
2009           }
2010           var ptr;
2011           var allocated;
2012           var contents = stream.node.contents;
2013           // Only make a new copy when MAP_PRIVATE is specified.
2014           if ( !(flags & 2) &&
2015                 (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
2016             // We can't emulate MAP_SHARED when the file is not backed by the buffer
2017             // we're mapping to (e.g. the HEAP buffer).
2018             allocated = false;
2019             ptr = contents.byteOffset;
2020           } else {
2021             // Try to avoid unnecessary slices.
2022             if (position > 0 || position + length < contents.length) {
2023               if (contents.subarray) {
2024                 contents = contents.subarray(position, position + length);
2025               } else {
2026                 contents = Array.prototype.slice.call(contents, position, position + length);
2027               }
2028             }
2029             allocated = true;
2030             ptr = _malloc(length);
2031             if (!ptr) {
2032               throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
2033             }
2034             buffer.set(contents, ptr);
2035           }
2036           return { ptr: ptr, allocated: allocated };
2037         }}};
2038   
2039   var IDBFS={dbs:{},indexedDB:function () {
2040         return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
2041       },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
2042         // reuse all of the core MEMFS functionality
2043         return MEMFS.mount.apply(null, arguments);
2044       },syncfs:function (mount, populate, callback) {
2045         IDBFS.getLocalSet(mount, function(err, local) {
2046           if (err) return callback(err);
2047   
2048           IDBFS.getRemoteSet(mount, function(err, remote) {
2049             if (err) return callback(err);
2050   
2051             var src = populate ? remote : local;
2052             var dst = populate ? local : remote;
2053   
2054             IDBFS.reconcile(src, dst, callback);
2055           });
2056         });
2057       },getDB:function (name, callback) {
2058         // check the cache first
2059         var db = IDBFS.dbs[name];
2060         if (db) {
2061           return callback(null, db);
2062         }
2063   
2064         var req;
2065         try {
2066           req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
2067         } catch (e) {
2068           return callback(e);
2069         }
2070         req.onupgradeneeded = function(e) {
2071           var db = e.target.result;
2072           var transaction = e.target.transaction;
2073   
2074           var fileStore;
2075   
2076           if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
2077             fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
2078           } else {
2079             fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
2080           }
2081   
2082           fileStore.createIndex('timestamp', 'timestamp', { unique: false });
2083         };
2084         req.onsuccess = function() {
2085           db = req.result;
2086   
2087           // add to the cache
2088           IDBFS.dbs[name] = db;
2089           callback(null, db);
2090         };
2091         req.onerror = function() {
2092           callback(this.error);
2093         };
2094       },getLocalSet:function (mount, callback) {
2095         var entries = {};
2096   
2097         function isRealDir(p) {
2098           return p !== '.' && p !== '..';
2099         };
2100         function toAbsolute(root) {
2101           return function(p) {
2102             return PATH.join2(root, p);
2103           }
2104         };
2105   
2106         var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
2107   
2108         while (check.length) {
2109           var path = check.pop();
2110           var stat;
2111   
2112           try {
2113             stat = FS.stat(path);
2114           } catch (e) {
2115             return callback(e);
2116           }
2117   
2118           if (FS.isDir(stat.mode)) {
2119             check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
2120           }
2121   
2122           entries[path] = { timestamp: stat.mtime };
2123         }
2124   
2125         return callback(null, { type: 'local', entries: entries });
2126       },getRemoteSet:function (mount, callback) {
2127         var entries = {};
2128   
2129         IDBFS.getDB(mount.mountpoint, function(err, db) {
2130           if (err) return callback(err);
2131   
2132           var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
2133           transaction.onerror = function() { callback(this.error); };
2134   
2135           var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
2136           var index = store.index('timestamp');
2137   
2138           index.openKeyCursor().onsuccess = function(event) {
2139             var cursor = event.target.result;
2140   
2141             if (!cursor) {
2142               return callback(null, { type: 'remote', db: db, entries: entries });
2143             }
2144   
2145             entries[cursor.primaryKey] = { timestamp: cursor.key };
2146   
2147             cursor.continue();
2148           };
2149         });
2150       },loadLocalEntry:function (path, callback) {
2151         var stat, node;
2152   
2153         try {
2154           var lookup = FS.lookupPath(path);
2155           node = lookup.node;
2156           stat = FS.stat(path);
2157         } catch (e) {
2158           return callback(e);
2159         }
2160   
2161         if (FS.isDir(stat.mode)) {
2162           return callback(null, { timestamp: stat.mtime, mode: stat.mode });
2163         } else if (FS.isFile(stat.mode)) {
2164           return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
2165         } else {
2166           return callback(new Error('node type not supported'));
2167         }
2168       },storeLocalEntry:function (path, entry, callback) {
2169         try {
2170           if (FS.isDir(entry.mode)) {
2171             FS.mkdir(path, entry.mode);
2172           } else if (FS.isFile(entry.mode)) {
2173             FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
2174           } else {
2175             return callback(new Error('node type not supported'));
2176           }
2177   
2178           FS.utime(path, entry.timestamp, entry.timestamp);
2179         } catch (e) {
2180           return callback(e);
2181         }
2182   
2183         callback(null);
2184       },removeLocalEntry:function (path, callback) {
2185         try {
2186           var lookup = FS.lookupPath(path);
2187           var stat = FS.stat(path);
2188   
2189           if (FS.isDir(stat.mode)) {
2190             FS.rmdir(path);
2191           } else if (FS.isFile(stat.mode)) {
2192             FS.unlink(path);
2193           }
2194         } catch (e) {
2195           return callback(e);
2196         }
2197   
2198         callback(null);
2199       },loadRemoteEntry:function (store, path, callback) {
2200         var req = store.get(path);
2201         req.onsuccess = function(event) { callback(null, event.target.result); };
2202         req.onerror = function() { callback(this.error); };
2203       },storeRemoteEntry:function (store, path, entry, callback) {
2204         var req = store.put(entry, path);
2205         req.onsuccess = function() { callback(null); };
2206         req.onerror = function() { callback(this.error); };
2207       },removeRemoteEntry:function (store, path, callback) {
2208         var req = store.delete(path);
2209         req.onsuccess = function() { callback(null); };
2210         req.onerror = function() { callback(this.error); };
2211       },reconcile:function (src, dst, callback) {
2212         var total = 0;
2213   
2214         var create = [];
2215         Object.keys(src.entries).forEach(function (key) {
2216           var e = src.entries[key];
2217           var e2 = dst.entries[key];
2218           if (!e2 || e.timestamp > e2.timestamp) {
2219             create.push(key);
2220             total++;
2221           }
2222         });
2223   
2224         var remove = [];
2225         Object.keys(dst.entries).forEach(function (key) {
2226           var e = dst.entries[key];
2227           var e2 = src.entries[key];
2228           if (!e2) {
2229             remove.push(key);
2230             total++;
2231           }
2232         });
2233   
2234         if (!total) {
2235           return callback(null);
2236         }
2237   
2238         var errored = false;
2239         var completed = 0;
2240         var db = src.type === 'remote' ? src.db : dst.db;
2241         var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
2242         var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
2243   
2244         function done(err) {
2245           if (err) {
2246             if (!done.errored) {
2247               done.errored = true;
2248               return callback(err);
2249             }
2250             return;
2251           }
2252           if (++completed >= total) {
2253             return callback(null);
2254           }
2255         };
2256   
2257         transaction.onerror = function() { done(this.error); };
2258   
2259         // sort paths in ascending order so directory entries are created
2260         // before the files inside them
2261         create.sort().forEach(function (path) {
2262           if (dst.type === 'local') {
2263             IDBFS.loadRemoteEntry(store, path, function (err, entry) {
2264               if (err) return done(err);
2265               IDBFS.storeLocalEntry(path, entry, done);
2266             });
2267           } else {
2268             IDBFS.loadLocalEntry(path, function (err, entry) {
2269               if (err) return done(err);
2270               IDBFS.storeRemoteEntry(store, path, entry, done);
2271             });
2272           }
2273         });
2274   
2275         // sort paths in descending order so files are deleted before their
2276         // parent directories
2277         remove.sort().reverse().forEach(function(path) {
2278           if (dst.type === 'local') {
2279             IDBFS.removeLocalEntry(path, done);
2280           } else {
2281             IDBFS.removeRemoteEntry(store, path, done);
2282           }
2283         });
2284       }};
2285   
2286   var NODEFS={isWindows:false,staticInit:function () {
2287         NODEFS.isWindows = !!process.platform.match(/^win/);
2288       },mount:function (mount) {
2289         assert(ENVIRONMENT_IS_NODE);
2290         return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
2291       },createNode:function (parent, name, mode, dev) {
2292         if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
2293           throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2294         }
2295         var node = FS.createNode(parent, name, mode);
2296         node.node_ops = NODEFS.node_ops;
2297         node.stream_ops = NODEFS.stream_ops;
2298         return node;
2299       },getMode:function (path) {
2300         var stat;
2301         try {
2302           stat = fs.lstatSync(path);
2303           if (NODEFS.isWindows) {
2304             // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so 
2305             // propagate write bits to execute bits.
2306             stat.mode = stat.mode | ((stat.mode & 146) >> 1);
2307           }
2308         } catch (e) {
2309           if (!e.code) throw e;
2310           throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2311         }
2312         return stat.mode;
2313       },realPath:function (node) {
2314         var parts = [];
2315         while (node.parent !== node) {
2316           parts.push(node.name);
2317           node = node.parent;
2318         }
2319         parts.push(node.mount.opts.root);
2320         parts.reverse();
2321         return PATH.join.apply(null, parts);
2322       },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
2323         if (flags in NODEFS.flagsToPermissionStringMap) {
2324           return NODEFS.flagsToPermissionStringMap[flags];
2325         } else {
2326           return flags;
2327         }
2328       },node_ops:{getattr:function (node) {
2329           var path = NODEFS.realPath(node);
2330           var stat;
2331           try {
2332             stat = fs.lstatSync(path);
2333           } catch (e) {
2334             if (!e.code) throw e;
2335             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2336           }
2337           // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
2338           // See http://support.microsoft.com/kb/140365
2339           if (NODEFS.isWindows && !stat.blksize) {
2340             stat.blksize = 4096;
2341           }
2342           if (NODEFS.isWindows && !stat.blocks) {
2343             stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
2344           }
2345           return {
2346             dev: stat.dev,
2347             ino: stat.ino,
2348             mode: stat.mode,
2349             nlink: stat.nlink,
2350             uid: stat.uid,
2351             gid: stat.gid,
2352             rdev: stat.rdev,
2353             size: stat.size,
2354             atime: stat.atime,
2355             mtime: stat.mtime,
2356             ctime: stat.ctime,
2357             blksize: stat.blksize,
2358             blocks: stat.blocks
2359           };
2360         },setattr:function (node, attr) {
2361           var path = NODEFS.realPath(node);
2362           try {
2363             if (attr.mode !== undefined) {
2364               fs.chmodSync(path, attr.mode);
2365               // update the common node structure mode as well
2366               node.mode = attr.mode;
2367             }
2368             if (attr.timestamp !== undefined) {
2369               var date = new Date(attr.timestamp);
2370               fs.utimesSync(path, date, date);
2371             }
2372             if (attr.size !== undefined) {
2373               fs.truncateSync(path, attr.size);
2374             }
2375           } catch (e) {
2376             if (!e.code) throw e;
2377             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2378           }
2379         },lookup:function (parent, name) {
2380           var path = PATH.join2(NODEFS.realPath(parent), name);
2381           var mode = NODEFS.getMode(path);
2382           return NODEFS.createNode(parent, name, mode);
2383         },mknod:function (parent, name, mode, dev) {
2384           var node = NODEFS.createNode(parent, name, mode, dev);
2385           // create the backing node for this in the fs root as well
2386           var path = NODEFS.realPath(node);
2387           try {
2388             if (FS.isDir(node.mode)) {
2389               fs.mkdirSync(path, node.mode);
2390             } else {
2391               fs.writeFileSync(path, '', { mode: node.mode });
2392             }
2393           } catch (e) {
2394             if (!e.code) throw e;
2395             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2396           }
2397           return node;
2398         },rename:function (oldNode, newDir, newName) {
2399           var oldPath = NODEFS.realPath(oldNode);
2400           var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
2401           try {
2402             fs.renameSync(oldPath, newPath);
2403           } catch (e) {
2404             if (!e.code) throw e;
2405             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2406           }
2407         },unlink:function (parent, name) {
2408           var path = PATH.join2(NODEFS.realPath(parent), name);
2409           try {
2410             fs.unlinkSync(path);
2411           } catch (e) {
2412             if (!e.code) throw e;
2413             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2414           }
2415         },rmdir:function (parent, name) {
2416           var path = PATH.join2(NODEFS.realPath(parent), name);
2417           try {
2418             fs.rmdirSync(path);
2419           } catch (e) {
2420             if (!e.code) throw e;
2421             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2422           }
2423         },readdir:function (node) {
2424           var path = NODEFS.realPath(node);
2425           try {
2426             return fs.readdirSync(path);
2427           } catch (e) {
2428             if (!e.code) throw e;
2429             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2430           }
2431         },symlink:function (parent, newName, oldPath) {
2432           var newPath = PATH.join2(NODEFS.realPath(parent), newName);
2433           try {
2434             fs.symlinkSync(oldPath, newPath);
2435           } catch (e) {
2436             if (!e.code) throw e;
2437             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2438           }
2439         },readlink:function (node) {
2440           var path = NODEFS.realPath(node);
2441           try {
2442             return fs.readlinkSync(path);
2443           } catch (e) {
2444             if (!e.code) throw e;
2445             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2446           }
2447         }},stream_ops:{open:function (stream) {
2448           var path = NODEFS.realPath(stream.node);
2449           try {
2450             if (FS.isFile(stream.node.mode)) {
2451               stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
2452             }
2453           } catch (e) {
2454             if (!e.code) throw e;
2455             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2456           }
2457         },close:function (stream) {
2458           try {
2459             if (FS.isFile(stream.node.mode) && stream.nfd) {
2460               fs.closeSync(stream.nfd);
2461             }
2462           } catch (e) {
2463             if (!e.code) throw e;
2464             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2465           }
2466         },read:function (stream, buffer, offset, length, position) {
2467           // FIXME this is terrible.
2468           var nbuffer = new Buffer(length);
2469           var res;
2470           try {
2471             res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
2472           } catch (e) {
2473             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2474           }
2475           if (res > 0) {
2476             for (var i = 0; i < res; i++) {
2477               buffer[offset + i] = nbuffer[i];
2478             }
2479           }
2480           return res;
2481         },write:function (stream, buffer, offset, length, position) {
2482           // FIXME this is terrible.
2483           var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
2484           var res;
2485           try {
2486             res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
2487           } catch (e) {
2488             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2489           }
2490           return res;
2491         },llseek:function (stream, offset, whence) {
2492           var position = offset;
2493           if (whence === 1) {  // SEEK_CUR.
2494             position += stream.position;
2495           } else if (whence === 2) {  // SEEK_END.
2496             if (FS.isFile(stream.node.mode)) {
2497               try {
2498                 var stat = fs.fstatSync(stream.nfd);
2499                 position += stat.size;
2500               } catch (e) {
2501                 throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2502               }
2503             }
2504           }
2505   
2506           if (position < 0) {
2507             throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2508           }
2509   
2510           stream.position = position;
2511           return position;
2512         }}};
2513   
2514   var _stdin=allocate(1, "i32*", ALLOC_STATIC);
2515   
2516   var _stdout=allocate(1, "i32*", ALLOC_STATIC);
2517   
2518   var _stderr=allocate(1, "i32*", ALLOC_STATIC);var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
2519         if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
2520         return ___setErrNo(e.errno);
2521       },lookupPath:function (path, opts) {
2522         path = PATH.resolve(FS.cwd(), path);
2523         opts = opts || {};
2524   
2525         var defaults = {
2526           follow_mount: true,
2527           recurse_count: 0
2528         };
2529         for (var key in defaults) {
2530           if (opts[key] === undefined) {
2531             opts[key] = defaults[key];
2532           }
2533         }
2534   
2535         if (opts.recurse_count > 8) {  // max recursive lookup of 8
2536           throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
2537         }
2538   
2539         // split the path
2540         var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
2541           return !!p;
2542         }), false);
2543   
2544         // start at the root
2545         var current = FS.root;
2546         var current_path = '/';
2547   
2548         for (var i = 0; i < parts.length; i++) {
2549           var islast = (i === parts.length-1);
2550           if (islast && opts.parent) {
2551             // stop resolving
2552             break;
2553           }
2554   
2555           current = FS.lookupNode(current, parts[i]);
2556           current_path = PATH.join2(current_path, parts[i]);
2557   
2558           // jump to the mount's root node if this is a mountpoint
2559           if (FS.isMountpoint(current)) {
2560             if (!islast || (islast && opts.follow_mount)) {
2561               current = current.mounted.root;
2562             }
2563           }
2564   
2565           // by default, lookupPath will not follow a symlink if it is the final path component.
2566           // setting opts.follow = true will override this behavior.
2567           if (!islast || opts.follow) {
2568             var count = 0;
2569             while (FS.isLink(current.mode)) {
2570               var link = FS.readlink(current_path);
2571               current_path = PATH.resolve(PATH.dirname(current_path), link);
2572               
2573               var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
2574               current = lookup.node;
2575   
2576               if (count++ > 40) {  // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
2577                 throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
2578               }
2579             }
2580           }
2581         }
2582   
2583         return { path: current_path, node: current };
2584       },getPath:function (node) {
2585         var path;
2586         while (true) {
2587           if (FS.isRoot(node)) {
2588             var mount = node.mount.mountpoint;
2589             if (!path) return mount;
2590             return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
2591           }
2592           path = path ? node.name + '/' + path : node.name;
2593           node = node.parent;
2594         }
2595       },hashName:function (parentid, name) {
2596         var hash = 0;
2597   
2598   
2599         for (var i = 0; i < name.length; i++) {
2600           hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
2601         }
2602         return ((parentid + hash) >>> 0) % FS.nameTable.length;
2603       },hashAddNode:function (node) {
2604         var hash = FS.hashName(node.parent.id, node.name);
2605         node.name_next = FS.nameTable[hash];
2606         FS.nameTable[hash] = node;
2607       },hashRemoveNode:function (node) {
2608         var hash = FS.hashName(node.parent.id, node.name);
2609         if (FS.nameTable[hash] === node) {
2610           FS.nameTable[hash] = node.name_next;
2611         } else {
2612           var current = FS.nameTable[hash];
2613           while (current) {
2614             if (current.name_next === node) {
2615               current.name_next = node.name_next;
2616               break;
2617             }
2618             current = current.name_next;
2619           }
2620         }
2621       },lookupNode:function (parent, name) {
2622         var err = FS.mayLookup(parent);
2623         if (err) {
2624           throw new FS.ErrnoError(err);
2625         }
2626         var hash = FS.hashName(parent.id, name);
2627         for (var node = FS.nameTable[hash]; node; node = node.name_next) {
2628           var nodeName = node.name;
2629           if (node.parent.id === parent.id && nodeName === name) {
2630             return node;
2631           }
2632         }
2633         // if we failed to find it in the cache, call into the VFS
2634         return FS.lookup(parent, name);
2635       },createNode:function (parent, name, mode, rdev) {
2636         if (!FS.FSNode) {
2637           FS.FSNode = function(parent, name, mode, rdev) {
2638             if (!parent) {
2639               parent = this;  // root node sets parent to itself
2640             }
2641             this.parent = parent;
2642             this.mount = parent.mount;
2643             this.mounted = null;
2644             this.id = FS.nextInode++;
2645             this.name = name;
2646             this.mode = mode;
2647             this.node_ops = {};
2648             this.stream_ops = {};
2649             this.rdev = rdev;
2650           };
2651   
2652           FS.FSNode.prototype = {};
2653   
2654           // compatibility
2655           var readMode = 292 | 73;
2656           var writeMode = 146;
2657   
2658           // NOTE we must use Object.defineProperties instead of individual calls to
2659           // Object.defineProperty in order to make closure compiler happy
2660           Object.defineProperties(FS.FSNode.prototype, {
2661             read: {
2662               get: function() { return (this.mode & readMode) === readMode; },
2663               set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
2664             },
2665             write: {
2666               get: function() { return (this.mode & writeMode) === writeMode; },
2667               set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
2668             },
2669             isFolder: {
2670               get: function() { return FS.isDir(this.mode); },
2671             },
2672             isDevice: {
2673               get: function() { return FS.isChrdev(this.mode); },
2674             },
2675           });
2676         }
2677   
2678         var node = new FS.FSNode(parent, name, mode, rdev);
2679   
2680         FS.hashAddNode(node);
2681   
2682         return node;
2683       },destroyNode:function (node) {
2684         FS.hashRemoveNode(node);
2685       },isRoot:function (node) {
2686         return node === node.parent;
2687       },isMountpoint:function (node) {
2688         return !!node.mounted;
2689       },isFile:function (mode) {
2690         return (mode & 61440) === 32768;
2691       },isDir:function (mode) {
2692         return (mode & 61440) === 16384;
2693       },isLink:function (mode) {
2694         return (mode & 61440) === 40960;
2695       },isChrdev:function (mode) {
2696         return (mode & 61440) === 8192;
2697       },isBlkdev:function (mode) {
2698         return (mode & 61440) === 24576;
2699       },isFIFO:function (mode) {
2700         return (mode & 61440) === 4096;
2701       },isSocket:function (mode) {
2702         return (mode & 49152) === 49152;
2703       },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
2704         var flags = FS.flagModes[str];
2705         if (typeof flags === 'undefined') {
2706           throw new Error('Unknown file open mode: ' + str);
2707         }
2708         return flags;
2709       },flagsToPermissionString:function (flag) {
2710         var accmode = flag & 2097155;
2711         var perms = ['r', 'w', 'rw'][accmode];
2712         if ((flag & 512)) {
2713           perms += 'w';
2714         }
2715         return perms;
2716       },nodePermissions:function (node, perms) {
2717         if (FS.ignorePermissions) {
2718           return 0;
2719         }
2720         // return 0 if any user, group or owner bits are set.
2721         if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
2722           return ERRNO_CODES.EACCES;
2723         } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
2724           return ERRNO_CODES.EACCES;
2725         } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
2726           return ERRNO_CODES.EACCES;
2727         }
2728         return 0;
2729       },mayLookup:function (dir) {
2730         return FS.nodePermissions(dir, 'x');
2731       },mayCreate:function (dir, name) {
2732         try {
2733           var node = FS.lookupNode(dir, name);
2734           return ERRNO_CODES.EEXIST;
2735         } catch (e) {
2736         }
2737         return FS.nodePermissions(dir, 'wx');
2738       },mayDelete:function (dir, name, isdir) {
2739         var node;
2740         try {
2741           node = FS.lookupNode(dir, name);
2742         } catch (e) {
2743           return e.errno;
2744         }
2745         var err = FS.nodePermissions(dir, 'wx');
2746         if (err) {
2747           return err;
2748         }
2749         if (isdir) {
2750           if (!FS.isDir(node.mode)) {
2751             return ERRNO_CODES.ENOTDIR;
2752           }
2753           if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
2754             return ERRNO_CODES.EBUSY;
2755           }
2756         } else {
2757           if (FS.isDir(node.mode)) {
2758             return ERRNO_CODES.EISDIR;
2759           }
2760         }
2761         return 0;
2762       },mayOpen:function (node, flags) {
2763         if (!node) {
2764           return ERRNO_CODES.ENOENT;
2765         }
2766         if (FS.isLink(node.mode)) {
2767           return ERRNO_CODES.ELOOP;
2768         } else if (FS.isDir(node.mode)) {
2769           if ((flags & 2097155) !== 0 ||  // opening for write
2770               (flags & 512)) {
2771             return ERRNO_CODES.EISDIR;
2772           }
2773         }
2774         return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
2775       },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
2776         fd_start = fd_start || 0;
2777         fd_end = fd_end || FS.MAX_OPEN_FDS;
2778         for (var fd = fd_start; fd <= fd_end; fd++) {
2779           if (!FS.streams[fd]) {
2780             return fd;
2781           }
2782         }
2783         throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
2784       },getStream:function (fd) {
2785         return FS.streams[fd];
2786       },createStream:function (stream, fd_start, fd_end) {
2787         if (!FS.FSStream) {
2788           FS.FSStream = function(){};
2789           FS.FSStream.prototype = {};
2790           // compatibility
2791           Object.defineProperties(FS.FSStream.prototype, {
2792             object: {
2793               get: function() { return this.node; },
2794               set: function(val) { this.node = val; }
2795             },
2796             isRead: {
2797               get: function() { return (this.flags & 2097155) !== 1; }
2798             },
2799             isWrite: {
2800               get: function() { return (this.flags & 2097155) !== 0; }
2801             },
2802             isAppend: {
2803               get: function() { return (this.flags & 1024); }
2804             }
2805           });
2806         }
2807         if (stream.__proto__) {
2808           // reuse the object
2809           stream.__proto__ = FS.FSStream.prototype;
2810         } else {
2811           var newStream = new FS.FSStream();
2812           for (var p in stream) {
2813             newStream[p] = stream[p];
2814           }
2815           stream = newStream;
2816         }
2817         var fd = FS.nextfd(fd_start, fd_end);
2818         stream.fd = fd;
2819         FS.streams[fd] = stream;
2820         return stream;
2821       },closeStream:function (fd) {
2822         FS.streams[fd] = null;
2823       },getStreamFromPtr:function (ptr) {
2824         return FS.streams[ptr - 1];
2825       },getPtrForStream:function (stream) {
2826         return stream ? stream.fd + 1 : 0;
2827       },chrdev_stream_ops:{open:function (stream) {
2828           var device = FS.getDevice(stream.node.rdev);
2829           // override node's stream ops with the device's
2830           stream.stream_ops = device.stream_ops;
2831           // forward the open call
2832           if (stream.stream_ops.open) {
2833             stream.stream_ops.open(stream);
2834           }
2835         },llseek:function () {
2836           throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
2837         }},major:function (dev) {
2838         return ((dev) >> 8);
2839       },minor:function (dev) {
2840         return ((dev) & 0xff);
2841       },makedev:function (ma, mi) {
2842         return ((ma) << 8 | (mi));
2843       },registerDevice:function (dev, ops) {
2844         FS.devices[dev] = { stream_ops: ops };
2845       },getDevice:function (dev) {
2846         return FS.devices[dev];
2847       },getMounts:function (mount) {
2848         var mounts = [];
2849         var check = [mount];
2850   
2851         while (check.length) {
2852           var m = check.pop();
2853   
2854           mounts.push(m);
2855   
2856           check.push.apply(check, m.mounts);
2857         }
2858   
2859         return mounts;
2860       },syncfs:function (populate, callback) {
2861         if (typeof(populate) === 'function') {
2862           callback = populate;
2863           populate = false;
2864         }
2865   
2866         var mounts = FS.getMounts(FS.root.mount);
2867         var completed = 0;
2868   
2869         function done(err) {
2870           if (err) {
2871             if (!done.errored) {
2872               done.errored = true;
2873               return callback(err);
2874             }
2875             return;
2876           }
2877           if (++completed >= mounts.length) {
2878             callback(null);
2879           }
2880         };
2881   
2882         // sync all mounts
2883         mounts.forEach(function (mount) {
2884           if (!mount.type.syncfs) {
2885             return done(null);
2886           }
2887           mount.type.syncfs(mount, populate, done);
2888         });
2889       },mount:function (type, opts, mountpoint) {
2890         var root = mountpoint === '/';
2891         var pseudo = !mountpoint;
2892         var node;
2893   
2894         if (root && FS.root) {
2895           throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
2896         } else if (!root && !pseudo) {
2897           var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
2898   
2899           mountpoint = lookup.path;  // use the absolute path
2900           node = lookup.node;
2901   
2902           if (FS.isMountpoint(node)) {
2903             throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
2904           }
2905   
2906           if (!FS.isDir(node.mode)) {
2907             throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
2908           }
2909         }
2910   
2911         var mount = {
2912           type: type,
2913           opts: opts,
2914           mountpoint: mountpoint,
2915           mounts: []
2916         };
2917   
2918         // create a root node for the fs
2919         var mountRoot = type.mount(mount);
2920         mountRoot.mount = mount;
2921         mount.root = mountRoot;
2922   
2923         if (root) {
2924           FS.root = mountRoot;
2925         } else if (node) {
2926           // set as a mountpoint
2927           node.mounted = mount;
2928   
2929           // add the new mount to the current mount's children
2930           if (node.mount) {
2931             node.mount.mounts.push(mount);
2932           }
2933         }
2934   
2935         return mountRoot;
2936       },unmount:function (mountpoint) {
2937         var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
2938   
2939         if (!FS.isMountpoint(lookup.node)) {
2940           throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2941         }
2942   
2943         // destroy the nodes for this mount, and all its child mounts
2944         var node = lookup.node;
2945         var mount = node.mounted;
2946         var mounts = FS.getMounts(mount);
2947   
2948         Object.keys(FS.nameTable).forEach(function (hash) {
2949           var current = FS.nameTable[hash];
2950   
2951           while (current) {
2952             var next = current.name_next;
2953   
2954             if (mounts.indexOf(current.mount) !== -1) {
2955               FS.destroyNode(current);
2956             }
2957   
2958             current = next;
2959           }
2960         });
2961   
2962         // no longer a mountpoint
2963         node.mounted = null;
2964   
2965         // remove this mount from the child mounts
2966         var idx = node.mount.mounts.indexOf(mount);
2967         assert(idx !== -1);
2968         node.mount.mounts.splice(idx, 1);
2969       },lookup:function (parent, name) {
2970         return parent.node_ops.lookup(parent, name);
2971       },mknod:function (path, mode, dev) {
2972         var lookup = FS.lookupPath(path, { parent: true });
2973         var parent = lookup.node;
2974         var name = PATH.basename(path);
2975         var err = FS.mayCreate(parent, name);
2976         if (err) {
2977           throw new FS.ErrnoError(err);
2978         }
2979         if (!parent.node_ops.mknod) {
2980           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
2981         }
2982         return parent.node_ops.mknod(parent, name, mode, dev);
2983       },create:function (path, mode) {
2984         mode = mode !== undefined ? mode : 438 /* 0666 */;
2985         mode &= 4095;
2986         mode |= 32768;
2987         return FS.mknod(path, mode, 0);
2988       },mkdir:function (path, mode) {
2989         mode = mode !== undefined ? mode : 511 /* 0777 */;
2990         mode &= 511 | 512;
2991         mode |= 16384;
2992         return FS.mknod(path, mode, 0);
2993       },mkdev:function (path, mode, dev) {
2994         if (typeof(dev) === 'undefined') {
2995           dev = mode;
2996           mode = 438 /* 0666 */;
2997         }
2998         mode |= 8192;
2999         return FS.mknod(path, mode, dev);
3000       },symlink:function (oldpath, newpath) {
3001         var lookup = FS.lookupPath(newpath, { parent: true });
3002         var parent = lookup.node;
3003         var newname = PATH.basename(newpath);
3004         var err = FS.mayCreate(parent, newname);
3005         if (err) {
3006           throw new FS.ErrnoError(err);
3007         }
3008         if (!parent.node_ops.symlink) {
3009           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
3010         }
3011         return parent.node_ops.symlink(parent, newname, oldpath);
3012       },rename:function (old_path, new_path) {
3013         var old_dirname = PATH.dirname(old_path);
3014         var new_dirname = PATH.dirname(new_path);
3015         var old_name = PATH.basename(old_path);
3016         var new_name = PATH.basename(new_path);
3017         // parents must exist
3018         var lookup, old_dir, new_dir;
3019         try {
3020           lookup = FS.lookupPath(old_path, { parent: true });
3021           old_dir = lookup.node;
3022           lookup = FS.lookupPath(new_path, { parent: true });
3023           new_dir = lookup.node;
3024         } catch (e) {
3025           throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
3026         }
3027         // need to be part of the same mount
3028         if (old_dir.mount !== new_dir.mount) {
3029           throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
3030         }
3031         // source must exist
3032         var old_node = FS.lookupNode(old_dir, old_name);
3033         // old path should not be an ancestor of the new path
3034         var relative = PATH.relative(old_path, new_dirname);
3035         if (relative.charAt(0) !== '.') {
3036           throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
3037         }
3038         // new path should not be an ancestor of the old path
3039         relative = PATH.relative(new_path, old_dirname);
3040         if (relative.charAt(0) !== '.') {
3041           throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
3042         }
3043         // see if the new path already exists
3044         var new_node;
3045         try {
3046           new_node = FS.lookupNode(new_dir, new_name);
3047         } catch (e) {
3048           // not fatal
3049         }
3050         // early out if nothing needs to change
3051         if (old_node === new_node) {
3052           return;
3053         }
3054         // we'll need to delete the old entry
3055         var isdir = FS.isDir(old_node.mode);
3056         var err = FS.mayDelete(old_dir, old_name, isdir);
3057         if (err) {
3058           throw new FS.ErrnoError(err);
3059         }
3060         // need delete permissions if we'll be overwriting.
3061         // need create permissions if new doesn't already exist.
3062         err = new_node ?
3063           FS.mayDelete(new_dir, new_name, isdir) :
3064           FS.mayCreate(new_dir, new_name);
3065         if (err) {
3066           throw new FS.ErrnoError(err);
3067         }
3068         if (!old_dir.node_ops.rename) {
3069           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
3070         }
3071         if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
3072           throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
3073         }
3074         // if we are going to change the parent, check write permissions
3075         if (new_dir !== old_dir) {
3076           err = FS.nodePermissions(old_dir, 'w');
3077           if (err) {
3078             throw new FS.ErrnoError(err);
3079           }
3080         }
3081         // remove the node from the lookup hash
3082         FS.hashRemoveNode(old_node);
3083         // do the underlying fs rename
3084         try {
3085           old_dir.node_ops.rename(old_node, new_dir, new_name);
3086         } catch (e) {
3087           throw e;
3088         } finally {
3089           // add the node back to the hash (in case node_ops.rename
3090           // changed its name)
3091           FS.hashAddNode(old_node);
3092         }
3093       },rmdir:funct