Add JetStream to PerformanceTests
[WebKit-https.git] / PerformanceTests / JetStream / simple / bigfib.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'] || 134217728;
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 = 13216;
1333 var __ZTVN10__cxxabiv120__si_class_type_infoE = 13256;
1334
1335
1336
1337
1338 STATIC_BASE = 8;
1339
1340 STATICTOP = STATIC_BASE + Runtime.alignMemory(14083);
1341 /* global initializers */ __ATINIT__.push({ func: function() { __GLOBAL__I_a() } });
1342
1343
1344 /* memory initializer */ allocate([70,105,98,32,91,0,0,0,93,32,61,32,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,97,108,108,0,0,0,0,0,116,104,0,0,0,0,0,0,115,111,109,101,0,0,0,0,114,97,110,100,0,0,0,0,56,0,0,0,0,0,0,0,184,0,0,0,1,0,0,0,2,0,0,0,200,255,255,255,200,255,255,255,184,0,0,0,3,0,0,0,4,0,0,0,78,83,116,51,95,95,49,49,57,98,97,115,105,99,95,111,115,116,114,105,110,103,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,78,83,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,0,0,0,208,51,0,0,112,0,0,0,8,13,0,0,0,0,0,0,56,0,0,0,0,0,0,0,8,13,0,0,5,0,0,0,6,0,0,0,200,255,255,255,200,255,255,255,8,13,0,0,7,0,0,0,8,0,0,0,0,0,0,0,120,1,0,0,9,0,0,0,10,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,53,98,97,115,105,99,95,115,116,114,105,110,103,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,78,83,95,57,97,108,108,111,99,97,116,111,114,73,99,69,69,69,69,0,0,0,0,0,0,0,208,51,0,0,48,1,0,0,0,12], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
1345 /* memory initializer */ allocate([16,6,0,0,11,0,0,0,12,0,0,0,2,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,5,0,0,0,6,0,0,0,5,0,0,0,7,0,0,0,8,0,0,0,3,0,0,0,6,0,0,0,4,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,208,51,0,0,240,5,0,0,64,12,0,0,0,0,0,0,0,0,0,0,120,6,0,0,13,0,0,0,14,0,0,0,3,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,9,0,0,0,6,0,0,0,5,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,48,95,95,115,116,100,105,110,98,117,102,73,119,69,69,0,208,51,0,0,96,6,0,0,64,12,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,16,7,0,0,15,0,0,0,16,0,0,0,4,0,0,0,1,0,0,0,3,0,0,0,3,0,0,0,12,0,0,0,2,0,0,0,2,0,0,0,13,0,0,0,4,0,0,0,7,0,0,0,8,0,0,0,8,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,208,51,0,0,240,6,0,0,0,12,0,0,0,0,0,0,0,0,0,0,120,7,0,0,17,0,0,0,18,0,0,0,5,0,0,0,1,0,0,0,3,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,14,0,0,0,15,0,0,0,9,0,0,0,3,0,0,0,10,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,208,51,0,0,96,7,0,0,0,12,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,168,51,0,0,136,7,0,0,0,0,0,0,240,7,0,0,19,0,0,0,20,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,88,8,0,0,21,0,0,0,22,0,0,0,17,0,0,0,0,0,0,0,83,116,49,49,108,111,103,105,99,95,101,114,114,111,114,0,208,51,0,0,224,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,8,0,0,19,0,0,0,23,0,0,0,16,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,208,51,0,0,24,8,0,0,240,7,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,208,51,0,0,64,8,0,0,0,0,0,0,0,0,0,0,58,32,0,0,0,0,0,0,0,0,0,0,160,8,0,0,24,0,0,0,25,0,0,0,17,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,208,51,0,0,136,8,0,0,88,8,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,168,51,0,0,176,8,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,208,51,0,0,216,8,0,0,208,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,12,0,0,26,0,0,0,27,0,0,0,1,0,0,0,1,0,0,0,3,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,13,0,0,0,4,0,0,0,7,0,0,0,3,0,0,0,10,0,0,0,0,0,0,0,64,12,0,0,28,0,0,0,29,0,0,0,6,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,9,0,0,0,6,0,0,0,5,0,0,0,7,0,0,0,8,0,0,0,3,0,0,0,7,0,0,0,6,0,0,0,8,0,0,0,0,0,0,0,120,12,0,0,30,0,0,0,31,0,0,0,248,255,255,255,248,255,255,255,120,12,0,0,32,0,0,0,33,0,0,0,8,0,0,0,0,0,0,0,192,12,0,0,34,0,0,0,35,0,0,0,248,255,255,255,248,255,255,255,192,12,0,0,36,0,0,0,37,0,0,0,4,0,0,0,0,0,0,0,8,13,0,0,5,0,0,0,6,0,0,0,252,255,255,255,252,255,255,255,8,13,0,0,7,0,0,0,8,0,0,0,4,0,0,0,0,0,0,0,80,13,0,0,38,0,0,0,39,0,0,0,252,255,255,255,252,255,255,255,80,13,0,0,40,0,0,0,41,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,24,11,0,0,42,0,0,0,43,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,64,11,0,0,44,0,0,0,45,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,208,51,0,0,248,10,0,0,160,8,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,168,51,0,0,40,11,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,208,51,0,0,72,11,0,0,64,11,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,208,51,0,0,136,11,0,0,64,11,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,168,51,0,0,200,11,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,168,51,0,0,8,12,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,48,52,0,0,72,12,0,0,0,0,0,0,1,0,0,0,120,11,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,48,52,0,0,144,12,0,0,0,0,0,0,1,0,0,0,184,11,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,48,52,0,0,216,12,0,0,0,0,0,0,1,0,0,0,120,11,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,48,52,0,0,32,13,0,0,0,0,0,0,1,0,0,0,184,11,0,0,3,244,255,255,0,0,0,0,176,13,0,0,46,0,0,0,47,0,0,0,18,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,208,51,0,0,144,13,0,0,240,8,0,0,0,0,0,0,0,0,0,0,216,27,0,0,48,0,0,0,49,0,0,0,50,0,0,0,1,0,0,0,4,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,51,0,0,0,52,0,0,0,50,0,0,0,2,0,0,0,5,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,32,0,0,53,0,0,0,54,0,0,0,50,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,72,33,0,0,55,0,0,0,56,0,0,0,50,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,8,34,0,0,57,0,0,0,58,0,0,0,50,0,0,0,4,0,0,0,5,0,0,0,23,0,0,0,6,0,0,0,24,0,0,0,1,0,0,0,2,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,34,0,0,59,0,0,0,60,0,0,0,50,0,0,0,8,0,0,0,9,0,0,0,25,0,0,0,10,0,0,0,26,0,0,0,3,0,0,0,4,0,0,0,11,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,200,29,0,0,61,0,0,0,62,0,0,0,50,0,0,0,19,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,200,29,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,26,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,104,30,0,0,63,0,0,0,64,0,0,0,50,0,0,0,27,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,104,30,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,34,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,248,30,0,0,65,0,0,0,66,0,0,0,50,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,31,0,0,67,0,0,0,68,0,0,0,50,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,28,0,0,69,0,0,0,70,0,0,0,50,0,0,0,35,0,0,0,36,0,0,0,7,0,0,0,8,0,0,0,9,0,0,0,10,0,0,0,37,0,0,0,11,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,144,28,0,0,71,0,0,0,72,0,0,0,50,0,0,0,38,0,0,0,39,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,16,0,0,0,40,0,0,0,17,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,208,28,0,0,73,0,0,0,74,0,0,0,50,0,0,0,41,0,0,0,42,0,0,0,19,0,0,0,20,0,0,0,21,0,0,0,22,0,0,0,43,0,0,0,23,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,29,0,0,75,0,0,0,76,0,0,0,50,0,0,0,44,0,0,0,45,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,28,0,0,0,46,0,0,0,29,0,0,0,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,35,0,0,77,0,0,0,78,0,0,0,50,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,192,35,0,0,79,0,0,0,80,0,0,0,50,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,80,36,0,0,81,0,0,0,82,0,0,0,50,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,224,36,0,0,83,0,0,0,84,0,0,0,50,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,184,31,0,0,85,0,0,0,86,0,0,0,50,0,0,0,13,0,0,0,12,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,31,0,0,87,0,0,0,88,0,0,0,50,0,0,0,14,0,0,0,13,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,176,27,0,0,89,0,0,0,90,0,0,0,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,24,0,0,91,0,0,0,92,0,0,0,50,0,0,0,11,0,0,0,15,0,0,0,12,0,0,0,16,0,0,0,13,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,104,25,0,0,93,0,0,0,94,0,0,0,50,0,0,0,1,0,0,0,2,0,0,0,4,0,0,0,47,0,0,0,48,0,0,0,5,0,0,0,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,27,0,0,95,0,0,0,96,0,0,0,50,0,0,0,50,0,0,0,51,0,0,0,33,0,0,0,34,0,0,0,35,0,0,0,0,0,0,0,136,27,0,0,97,0,0,0,98,0,0,0,50,0,0,0,52,0,0,0,53,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,192,23,0,0,99,0,0,0,100,0,0,0,50,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,208,51,0,0,168,23,0,0,168,7,0,0,0,0,0,0,0,0,0,0,80,24,0,0,99,0,0,0,101,0,0,0,50,0,0,0,18,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,14,0,0,0,19,0,0,0,15,0,0,0,20,0,0,0,16,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,168,51,0,0,48,24,0,0,48,52,0,0,24,24,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,72,24,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,48,52,0,0,112,24,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,72,24,0,0,2,0,0,0,0,0,0,0,32,25,0,0,99,0,0,0,102,0,0,0,50,0,0,0,3,0,0,0,4,0,0,0,7,0,0,0,54,0,0,0,55,0,0,0,8,0,0,0,56,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,168,51,0,0,0,25,0,0,48,52,0,0,216,24,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,24,25,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,48,52,0,0,64,25,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,24,25,0,0,2,0,0,0,0,0,0,0,224,25,0,0,99,0,0,0,103,0,0,0,50,0,0,0,5,0,0,0,6,0,0,0,9,0,0,0,57,0,0,0,58,0,0,0,10,0,0,0,59,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,48,52,0,0,184,25,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,24,25,0,0,2,0,0,0,0,0,0,0,88,26,0,0,99,0,0,0,104,0,0,0,50,0,0,0,7,0,0,0,8,0,0,0,11,0,0,0,60,0,0,0,61,0,0,0,12,0,0,0,62,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,48,52,0,0,48,26,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,24,25,0,0,2,0,0,0,0,0,0,0,208,26,0,0,99,0,0,0,105,0,0,0,50,0,0,0,7,0,0,0,8,0,0,0,11,0,0,0,60,0,0,0,61,0,0,0,12,0,0,0,62,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,208,51,0,0,168,26,0,0,88,26,0,0,0,0,0,0,0,0,0,0,56,27,0,0,99,0,0,0,106,0,0,0,50,0,0,0,7,0,0,0,8,0,0,0,11,0,0,0,60,0,0,0,61,0,0,0,12,0,0,0,62,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,208,51,0,0,16,27,0,0,88,26,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,208,51,0,0,72,27,0,0,192,23,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,208,51,0,0,112,27,0,0,192,23,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,208,51,0,0,152,27,0,0,192,23,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,208,51,0,0,192,27,0,0,192,23,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,208,51,0,0,232,27,0,0,192,23,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,168,51,0,0,48,28,0,0,48,52,0,0,16,28,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,72,28,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,48,52,0,0,112,28,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,72,28,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,48,52,0,0,176,28,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,72,28,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,48,52,0,0,240,28,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,72,28,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,168,51,0,0,120,29,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,168,51,0,0,152,29,0,0,48,52,0,0,48,29,0,0,0,0,0,0,3,0,0,0,192,23,0,0,2,0,0,0,144,29,0,0,2,0,0,0,192,29,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,168,51,0,0,56,30,0,0,48,52,0,0,240,29,0,0,0,0,0,0,3,0,0,0,192,23,0,0,2,0,0,0,144,29,0,0,2,0,0,0,96,30,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,168,51,0,0,216,30,0,0,48,52,0,0,144,30,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,240,30,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,48,52,0,0,24,31,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,240,30,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,168,51,0,0,152,31,0,0,48,52,0,0,128,31,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,176,31,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,48,52,0,0,216,31,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,176,31,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,168,51,0,0,112,32,0,0,48,52,0,0,88,32,0,0,0,0,0,0,1,0,0,0,144,32,0,0,0,0,0,0,48,52,0,0,16,32,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,152,32,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,48,52,0,0,24,33,0,0,0,0,0,0,1,0,0,0,144,32,0,0,0,0,0,0,48,52,0,0,208,32,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,48,33,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,168,51,0,0,200,33,0,0,48,52,0,0,176,33,0,0,0,0,0,0,1,0,0,0,232,33,0,0,0,0,0,0,48,52,0,0,104,33,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,240,33,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,48,52,0,0,112,34,0,0,0,0,0,0,1,0,0,0,232,33,0,0,0,0,0,0,48,52,0,0,40,34,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,136,34,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,168,51,0,0,8,35,0,0,48,52,0,0,192,34,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,40,35,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,168,51,0,0,152,35,0,0,48,52,0,0,80,35,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,184,35,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,168,51,0,0,40,36,0,0,48,52,0,0,224,35,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,72,36,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,168,51,0,0,184,36,0,0,48,52,0,0,112,36,0,0,0,0,0,0,2,0,0,0,192,23,0,0,2,0,0,0,216,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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+1452);
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,32,51,0,0,107,0,0,0,108,0,0,0,63,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,168,51,0,0,248,50,0,0,83,116,56,98,97,100,95,99,97,115,116,0,0,0,0,0,208,51,0,0,16,51,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,208,51,0,0,48,51,0,0,8,51,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,208,51,0,0,104,51,0,0,88,51,0,0,0,0,0,0,0,0,0,0,144,51,0,0,109,0,0,0,110,0,0,0,111,0,0,0,112,0,0,0,22,0,0,0,14,0,0,0,1,0,0,0,6,0,0,0,0,0,0,0,24,52,0,0,109,0,0,0,113,0,0,0,111,0,0,0,112,0,0,0,22,0,0,0,15,0,0,0,2,0,0,0,7,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,208,51,0,0,240,51,0,0,144,51,0,0,0,0,0,0,0,0,0,0,120,52,0,0,109,0,0,0,114,0,0,0,111,0,0,0,112,0,0,0,22,0,0,0,16,0,0,0,3,0,0,0,8,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,208,51,0,0,80,52,0,0,144,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,54,0,0,115,0,0,0,116,0,0,0,64,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,208,51,0,0,168,54,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+11712);
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   function _llvm_lifetime_end() {}
1389
1390   
1391    
1392   Module["_rand_r"] = _rand_r;
1393   
1394   var ___rand_seed=allocate([0x0273459b, 0, 0, 0], "i32", ALLOC_STATIC); 
1395   Module["_rand"] = _rand;
1396
1397   
1398    
1399   Module["_memset"] = _memset;var _llvm_memset_p0i8_i32=_memset;
1400
1401    
1402   Module["_i64Subtract"] = _i64Subtract;
1403
1404    
1405   Module["_i64Add"] = _i64Add;
1406
1407   
1408   function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
1409       return !!__ZSt18uncaught_exceptionv.uncaught_exception;
1410     }
1411   
1412   
1413   
1414   function ___cxa_is_number_type(type) {
1415       var isNumber = false;
1416       try { if (type == __ZTIi) isNumber = true } catch(e){}
1417       try { if (type == __ZTIj) isNumber = true } catch(e){}
1418       try { if (type == __ZTIl) isNumber = true } catch(e){}
1419       try { if (type == __ZTIm) isNumber = true } catch(e){}
1420       try { if (type == __ZTIx) isNumber = true } catch(e){}
1421       try { if (type == __ZTIy) isNumber = true } catch(e){}
1422       try { if (type == __ZTIf) isNumber = true } catch(e){}
1423       try { if (type == __ZTId) isNumber = true } catch(e){}
1424       try { if (type == __ZTIe) isNumber = true } catch(e){}
1425       try { if (type == __ZTIc) isNumber = true } catch(e){}
1426       try { if (type == __ZTIa) isNumber = true } catch(e){}
1427       try { if (type == __ZTIh) isNumber = true } catch(e){}
1428       try { if (type == __ZTIs) isNumber = true } catch(e){}
1429       try { if (type == __ZTIt) isNumber = true } catch(e){}
1430       return isNumber;
1431     }function ___cxa_does_inherit(definiteType, possibilityType, possibility) {
1432       if (possibility == 0) return false;
1433       if (possibilityType == 0 || possibilityType == definiteType)
1434         return true;
1435       var possibility_type_info;
1436       if (___cxa_is_number_type(possibilityType)) {
1437         possibility_type_info = possibilityType;
1438       } else {
1439         var possibility_type_infoAddr = HEAP32[((possibilityType)>>2)] - 8;
1440         possibility_type_info = HEAP32[((possibility_type_infoAddr)>>2)];
1441       }
1442       switch (possibility_type_info) {
1443       case 0: // possibility is a pointer
1444         // See if definite type is a pointer
1445         var definite_type_infoAddr = HEAP32[((definiteType)>>2)] - 8;
1446         var definite_type_info = HEAP32[((definite_type_infoAddr)>>2)];
1447         if (definite_type_info == 0) {
1448           // Also a pointer; compare base types of pointers
1449           var defPointerBaseAddr = definiteType+8;
1450           var defPointerBaseType = HEAP32[((defPointerBaseAddr)>>2)];
1451           var possPointerBaseAddr = possibilityType+8;
1452           var possPointerBaseType = HEAP32[((possPointerBaseAddr)>>2)];
1453           return ___cxa_does_inherit(defPointerBaseType, possPointerBaseType, possibility);
1454         } else
1455           return false; // one pointer and one non-pointer
1456       case 1: // class with no base class
1457         return false;
1458       case 2: // class with base class
1459         var parentTypeAddr = possibilityType + 8;
1460         var parentType = HEAP32[((parentTypeAddr)>>2)];
1461         return ___cxa_does_inherit(definiteType, parentType, possibility);
1462       default:
1463         return false; // some unencountered type
1464       }
1465     }
1466   
1467   
1468   
1469   var ___cxa_last_thrown_exception=0;function ___resumeException(ptr) {
1470       if (!___cxa_last_thrown_exception) { ___cxa_last_thrown_exception = ptr; }
1471       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.";
1472     }
1473   
1474   var ___cxa_exception_header_size=8;function ___cxa_find_matching_catch(thrown, throwntype) {
1475       if (thrown == -1) thrown = ___cxa_last_thrown_exception;
1476       header = thrown - ___cxa_exception_header_size;
1477       if (throwntype == -1) throwntype = HEAP32[((header)>>2)];
1478       var typeArray = Array.prototype.slice.call(arguments, 2);
1479   
1480       // If throwntype is a pointer, this means a pointer has been
1481       // thrown. When a pointer is thrown, actually what's thrown
1482       // is a pointer to the pointer. We'll dereference it.
1483       if (throwntype != 0 && !___cxa_is_number_type(throwntype)) {
1484         var throwntypeInfoAddr= HEAP32[((throwntype)>>2)] - 8;
1485         var throwntypeInfo= HEAP32[((throwntypeInfoAddr)>>2)];
1486         if (throwntypeInfo == 0)
1487           thrown = HEAP32[((thrown)>>2)];
1488       }
1489       // The different catch blocks are denoted by different types.
1490       // Due to inheritance, those types may not precisely match the
1491       // type of the thrown object. Find one which matches, and
1492       // return the type of the catch block which should be called.
1493       for (var i = 0; i < typeArray.length; i++) {
1494         if (___cxa_does_inherit(typeArray[i], throwntype, thrown))
1495           return ((asm["setTempRet0"](typeArray[i]),thrown)|0);
1496       }
1497       // Shouldn't happen unless we have bogus data in typeArray
1498       // or encounter a type for which emscripten doesn't have suitable
1499       // typeinfo defined. Best-efforts match just in case.
1500       return ((asm["setTempRet0"](throwntype),thrown)|0);
1501     }function ___cxa_throw(ptr, type, destructor) {
1502       if (!___cxa_throw.initialized) {
1503         try {
1504           HEAP32[((__ZTVN10__cxxabiv119__pointer_type_infoE)>>2)]=0; // Workaround for libcxxabi integration bug
1505         } catch(e){}
1506         try {
1507           HEAP32[((__ZTVN10__cxxabiv117__class_type_infoE)>>2)]=1; // Workaround for libcxxabi integration bug
1508         } catch(e){}
1509         try {
1510           HEAP32[((__ZTVN10__cxxabiv120__si_class_type_infoE)>>2)]=2; // Workaround for libcxxabi integration bug
1511         } catch(e){}
1512         ___cxa_throw.initialized = true;
1513       }
1514       var header = ptr - ___cxa_exception_header_size;
1515       HEAP32[((header)>>2)]=type;
1516       HEAP32[(((header)+(4))>>2)]=destructor;
1517       ___cxa_last_thrown_exception = ptr;
1518       if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
1519         __ZSt18uncaught_exceptionv.uncaught_exception = 1;
1520       } else {
1521         __ZSt18uncaught_exceptionv.uncaught_exception++;
1522       }
1523       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.";
1524     }
1525
1526   function _pthread_mutex_lock() {}
1527
1528   
1529   
1530   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};
1531   
1532   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"};
1533   
1534   
1535   var ___errno_state=0;function ___setErrNo(value) {
1536       // For convenient setting and returning of errno.
1537       HEAP32[((___errno_state)>>2)]=value;
1538       return value;
1539     }
1540   
1541   var PATH={splitPath:function (filename) {
1542         var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
1543         return splitPathRe.exec(filename).slice(1);
1544       },normalizeArray:function (parts, allowAboveRoot) {
1545         // if the path tries to go above the root, `up` ends up > 0
1546         var up = 0;
1547         for (var i = parts.length - 1; i >= 0; i--) {
1548           var last = parts[i];
1549           if (last === '.') {
1550             parts.splice(i, 1);
1551           } else if (last === '..') {
1552             parts.splice(i, 1);
1553             up++;
1554           } else if (up) {
1555             parts.splice(i, 1);
1556             up--;
1557           }
1558         }
1559         // if the path is allowed to go above the root, restore leading ..s
1560         if (allowAboveRoot) {
1561           for (; up--; up) {
1562             parts.unshift('..');
1563           }
1564         }
1565         return parts;
1566       },normalize:function (path) {
1567         var isAbsolute = path.charAt(0) === '/',
1568             trailingSlash = path.substr(-1) === '/';
1569         // Normalize the path
1570         path = PATH.normalizeArray(path.split('/').filter(function(p) {
1571           return !!p;
1572         }), !isAbsolute).join('/');
1573         if (!path && !isAbsolute) {
1574           path = '.';
1575         }
1576         if (path && trailingSlash) {
1577           path += '/';
1578         }
1579         return (isAbsolute ? '/' : '') + path;
1580       },dirname:function (path) {
1581         var result = PATH.splitPath(path),
1582             root = result[0],
1583             dir = result[1];
1584         if (!root && !dir) {
1585           // No dirname whatsoever
1586           return '.';
1587         }
1588         if (dir) {
1589           // It has a dirname, strip trailing slash
1590           dir = dir.substr(0, dir.length - 1);
1591         }
1592         return root + dir;
1593       },basename:function (path) {
1594         // EMSCRIPTEN return '/'' for '/', not an empty string
1595         if (path === '/') return '/';
1596         var lastSlash = path.lastIndexOf('/');
1597         if (lastSlash === -1) return path;
1598         return path.substr(lastSlash+1);
1599       },extname:function (path) {
1600         return PATH.splitPath(path)[3];
1601       },join:function () {
1602         var paths = Array.prototype.slice.call(arguments, 0);
1603         return PATH.normalize(paths.join('/'));
1604       },join2:function (l, r) {
1605         return PATH.normalize(l + '/' + r);
1606       },resolve:function () {
1607         var resolvedPath = '',
1608           resolvedAbsolute = false;
1609         for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1610           var path = (i >= 0) ? arguments[i] : FS.cwd();
1611           // Skip empty and invalid entries
1612           if (typeof path !== 'string') {
1613             throw new TypeError('Arguments to path.resolve must be strings');
1614           } else if (!path) {
1615             continue;
1616           }
1617           resolvedPath = path + '/' + resolvedPath;
1618           resolvedAbsolute = path.charAt(0) === '/';
1619         }
1620         // At this point the path should be resolved to a full absolute path, but
1621         // handle relative paths to be safe (might happen when process.cwd() fails)
1622         resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
1623           return !!p;
1624         }), !resolvedAbsolute).join('/');
1625         return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
1626       },relative:function (from, to) {
1627         from = PATH.resolve(from).substr(1);
1628         to = PATH.resolve(to).substr(1);
1629         function trim(arr) {
1630           var start = 0;
1631           for (; start < arr.length; start++) {
1632             if (arr[start] !== '') break;
1633           }
1634           var end = arr.length - 1;
1635           for (; end >= 0; end--) {
1636             if (arr[end] !== '') break;
1637           }
1638           if (start > end) return [];
1639           return arr.slice(start, end - start + 1);
1640         }
1641         var fromParts = trim(from.split('/'));
1642         var toParts = trim(to.split('/'));
1643         var length = Math.min(fromParts.length, toParts.length);
1644         var samePartsLength = length;
1645         for (var i = 0; i < length; i++) {
1646           if (fromParts[i] !== toParts[i]) {
1647             samePartsLength = i;
1648             break;
1649           }
1650         }
1651         var outputParts = [];
1652         for (var i = samePartsLength; i < fromParts.length; i++) {
1653           outputParts.push('..');
1654         }
1655         outputParts = outputParts.concat(toParts.slice(samePartsLength));
1656         return outputParts.join('/');
1657       }};
1658   
1659   var TTY={ttys:[],init:function () {
1660         // https://github.com/kripken/emscripten/pull/1555
1661         // if (ENVIRONMENT_IS_NODE) {
1662         //   // currently, FS.init does not distinguish if process.stdin is a file or TTY
1663         //   // device, it always assumes it's a TTY device. because of this, we're forcing
1664         //   // process.stdin to UTF8 encoding to at least make stdin reading compatible
1665         //   // with text files until FS.init can be refactored.
1666         //   process['stdin']['setEncoding']('utf8');
1667         // }
1668       },shutdown:function () {
1669         // https://github.com/kripken/emscripten/pull/1555
1670         // if (ENVIRONMENT_IS_NODE) {
1671         //   // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
1672         //   // 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
1673         //   // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
1674         //   // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
1675         //   // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
1676         //   process['stdin']['pause']();
1677         // }
1678       },register:function (dev, ops) {
1679         TTY.ttys[dev] = { input: [], output: [], ops: ops };
1680         FS.registerDevice(dev, TTY.stream_ops);
1681       },stream_ops:{open:function (stream) {
1682           var tty = TTY.ttys[stream.node.rdev];
1683           if (!tty) {
1684             throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
1685           }
1686           stream.tty = tty;
1687           stream.seekable = false;
1688         },close:function (stream) {
1689           // flush any pending line data
1690           if (stream.tty.output.length) {
1691             stream.tty.ops.put_char(stream.tty, 10);
1692           }
1693         },read:function (stream, buffer, offset, length, pos /* ignored */) {
1694           if (!stream.tty || !stream.tty.ops.get_char) {
1695             throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
1696           }
1697           var bytesRead = 0;
1698           for (var i = 0; i < length; i++) {
1699             var result;
1700             try {
1701               result = stream.tty.ops.get_char(stream.tty);
1702             } catch (e) {
1703               throw new FS.ErrnoError(ERRNO_CODES.EIO);
1704             }
1705             if (result === undefined && bytesRead === 0) {
1706               throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
1707             }
1708             if (result === null || result === undefined) break;
1709             bytesRead++;
1710             buffer[offset+i] = result;
1711           }
1712           if (bytesRead) {
1713             stream.node.timestamp = Date.now();
1714           }
1715           return bytesRead;
1716         },write:function (stream, buffer, offset, length, pos) {
1717           if (!stream.tty || !stream.tty.ops.put_char) {
1718             throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
1719           }
1720           for (var i = 0; i < length; i++) {
1721             try {
1722               stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
1723             } catch (e) {
1724               throw new FS.ErrnoError(ERRNO_CODES.EIO);
1725             }
1726           }
1727           if (length) {
1728             stream.node.timestamp = Date.now();
1729           }
1730           return i;
1731         }},default_tty_ops:{get_char:function (tty) {
1732           if (!tty.input.length) {
1733             var result = null;
1734             if (ENVIRONMENT_IS_NODE) {
1735               result = process['stdin']['read']();
1736               if (!result) {
1737                 if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
1738                   return null;  // EOF
1739                 }
1740                 return undefined;  // no data available
1741               }
1742             } else if (typeof window != 'undefined' &&
1743               typeof window.prompt == 'function') {
1744               // Browser.
1745               result = window.prompt('Input: ');  // returns null on cancel
1746               if (result !== null) {
1747                 result += '\n';
1748               }
1749             } else if (typeof readline == 'function') {
1750               // Command line.
1751               result = readline();
1752               if (result !== null) {
1753                 result += '\n';
1754               }
1755             }
1756             if (!result) {
1757               return null;
1758             }
1759             tty.input = intArrayFromString(result, true);
1760           }
1761           return tty.input.shift();
1762         },put_char:function (tty, val) {
1763           if (val === null || val === 10) {
1764             Module['print'](tty.output.join(''));
1765             tty.output = [];
1766           } else {
1767             tty.output.push(TTY.utf8.processCChar(val));
1768           }
1769         }},default_tty1_ops:{put_char:function (tty, val) {
1770           if (val === null || val === 10) {
1771             Module['printErr'](tty.output.join(''));
1772             tty.output = [];
1773           } else {
1774             tty.output.push(TTY.utf8.processCChar(val));
1775           }
1776         }}};
1777   
1778   var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
1779         return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
1780       },createNode:function (parent, name, mode, dev) {
1781         if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
1782           // no supported
1783           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
1784         }
1785         if (!MEMFS.ops_table) {
1786           MEMFS.ops_table = {
1787             dir: {
1788               node: {
1789                 getattr: MEMFS.node_ops.getattr,
1790                 setattr: MEMFS.node_ops.setattr,
1791                 lookup: MEMFS.node_ops.lookup,
1792                 mknod: MEMFS.node_ops.mknod,
1793                 rename: MEMFS.node_ops.rename,
1794                 unlink: MEMFS.node_ops.unlink,
1795                 rmdir: MEMFS.node_ops.rmdir,
1796                 readdir: MEMFS.node_ops.readdir,
1797                 symlink: MEMFS.node_ops.symlink
1798               },
1799               stream: {
1800                 llseek: MEMFS.stream_ops.llseek
1801               }
1802             },
1803             file: {
1804               node: {
1805                 getattr: MEMFS.node_ops.getattr,
1806                 setattr: MEMFS.node_ops.setattr
1807               },
1808               stream: {
1809                 llseek: MEMFS.stream_ops.llseek,
1810                 read: MEMFS.stream_ops.read,
1811                 write: MEMFS.stream_ops.write,
1812                 allocate: MEMFS.stream_ops.allocate,
1813                 mmap: MEMFS.stream_ops.mmap
1814               }
1815             },
1816             link: {
1817               node: {
1818                 getattr: MEMFS.node_ops.getattr,
1819                 setattr: MEMFS.node_ops.setattr,
1820                 readlink: MEMFS.node_ops.readlink
1821               },
1822               stream: {}
1823             },
1824             chrdev: {
1825               node: {
1826                 getattr: MEMFS.node_ops.getattr,
1827                 setattr: MEMFS.node_ops.setattr
1828               },
1829               stream: FS.chrdev_stream_ops
1830             },
1831           };
1832         }
1833         var node = FS.createNode(parent, name, mode, dev);
1834         if (FS.isDir(node.mode)) {
1835           node.node_ops = MEMFS.ops_table.dir.node;
1836           node.stream_ops = MEMFS.ops_table.dir.stream;
1837           node.contents = {};
1838         } else if (FS.isFile(node.mode)) {
1839           node.node_ops = MEMFS.ops_table.file.node;
1840           node.stream_ops = MEMFS.ops_table.file.stream;
1841           node.contents = [];
1842           node.contentMode = MEMFS.CONTENT_FLEXIBLE;
1843         } else if (FS.isLink(node.mode)) {
1844           node.node_ops = MEMFS.ops_table.link.node;
1845           node.stream_ops = MEMFS.ops_table.link.stream;
1846         } else if (FS.isChrdev(node.mode)) {
1847           node.node_ops = MEMFS.ops_table.chrdev.node;
1848           node.stream_ops = MEMFS.ops_table.chrdev.stream;
1849         }
1850         node.timestamp = Date.now();
1851         // add the new node to the parent
1852         if (parent) {
1853           parent.contents[name] = node;
1854         }
1855         return node;
1856       },ensureFlexible:function (node) {
1857         if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
1858           var contents = node.contents;
1859           node.contents = Array.prototype.slice.call(contents);
1860           node.contentMode = MEMFS.CONTENT_FLEXIBLE;
1861         }
1862       },node_ops:{getattr:function (node) {
1863           var attr = {};
1864           // device numbers reuse inode numbers.
1865           attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
1866           attr.ino = node.id;
1867           attr.mode = node.mode;
1868           attr.nlink = 1;
1869           attr.uid = 0;
1870           attr.gid = 0;
1871           attr.rdev = node.rdev;
1872           if (FS.isDir(node.mode)) {
1873             attr.size = 4096;
1874           } else if (FS.isFile(node.mode)) {
1875             attr.size = node.contents.length;
1876           } else if (FS.isLink(node.mode)) {
1877             attr.size = node.link.length;
1878           } else {
1879             attr.size = 0;
1880           }
1881           attr.atime = new Date(node.timestamp);
1882           attr.mtime = new Date(node.timestamp);
1883           attr.ctime = new Date(node.timestamp);
1884           // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
1885           //       but this is not required by the standard.
1886           attr.blksize = 4096;
1887           attr.blocks = Math.ceil(attr.size / attr.blksize);
1888           return attr;
1889         },setattr:function (node, attr) {
1890           if (attr.mode !== undefined) {
1891             node.mode = attr.mode;
1892           }
1893           if (attr.timestamp !== undefined) {
1894             node.timestamp = attr.timestamp;
1895           }
1896           if (attr.size !== undefined) {
1897             MEMFS.ensureFlexible(node);
1898             var contents = node.contents;
1899             if (attr.size < contents.length) contents.length = attr.size;
1900             else while (attr.size > contents.length) contents.push(0);
1901           }
1902         },lookup:function (parent, name) {
1903           throw FS.genericErrors[ERRNO_CODES.ENOENT];
1904         },mknod:function (parent, name, mode, dev) {
1905           return MEMFS.createNode(parent, name, mode, dev);
1906         },rename:function (old_node, new_dir, new_name) {
1907           // if we're overwriting a directory at new_name, make sure it's empty.
1908           if (FS.isDir(old_node.mode)) {
1909             var new_node;
1910             try {
1911               new_node = FS.lookupNode(new_dir, new_name);
1912             } catch (e) {
1913             }
1914             if (new_node) {
1915               for (var i in new_node.contents) {
1916                 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
1917               }
1918             }
1919           }
1920           // do the internal rewiring
1921           delete old_node.parent.contents[old_node.name];
1922           old_node.name = new_name;
1923           new_dir.contents[new_name] = old_node;
1924           old_node.parent = new_dir;
1925         },unlink:function (parent, name) {
1926           delete parent.contents[name];
1927         },rmdir:function (parent, name) {
1928           var node = FS.lookupNode(parent, name);
1929           for (var i in node.contents) {
1930             throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
1931           }
1932           delete parent.contents[name];
1933         },readdir:function (node) {
1934           var entries = ['.', '..']
1935           for (var key in node.contents) {
1936             if (!node.contents.hasOwnProperty(key)) {
1937               continue;
1938             }
1939             entries.push(key);
1940           }
1941           return entries;
1942         },symlink:function (parent, newname, oldpath) {
1943           var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
1944           node.link = oldpath;
1945           return node;
1946         },readlink:function (node) {
1947           if (!FS.isLink(node.mode)) {
1948             throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
1949           }
1950           return node.link;
1951         }},stream_ops:{read:function (stream, buffer, offset, length, position) {
1952           var contents = stream.node.contents;
1953           if (position >= contents.length)
1954             return 0;
1955           var size = Math.min(contents.length - position, length);
1956           assert(size >= 0);
1957           if (size > 8 && contents.subarray) { // non-trivial, and typed array
1958             buffer.set(contents.subarray(position, position + size), offset);
1959           } else
1960           {
1961             for (var i = 0; i < size; i++) {
1962               buffer[offset + i] = contents[position + i];
1963             }
1964           }
1965           return size;
1966         },write:function (stream, buffer, offset, length, position, canOwn) {
1967           var node = stream.node;
1968           node.timestamp = Date.now();
1969           var contents = node.contents;
1970           if (length && contents.length === 0 && position === 0 && buffer.subarray) {
1971             // just replace it with the new data
1972             if (canOwn && offset === 0) {
1973               node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
1974               node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
1975             } else {
1976               node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
1977               node.contentMode = MEMFS.CONTENT_FIXED;
1978             }
1979             return length;
1980           }
1981           MEMFS.ensureFlexible(node);
1982           var contents = node.contents;
1983           while (contents.length < position) contents.push(0);
1984           for (var i = 0; i < length; i++) {
1985             contents[position + i] = buffer[offset + i];
1986           }
1987           return length;
1988         },llseek:function (stream, offset, whence) {
1989           var position = offset;
1990           if (whence === 1) {  // SEEK_CUR.
1991             position += stream.position;
1992           } else if (whence === 2) {  // SEEK_END.
1993             if (FS.isFile(stream.node.mode)) {
1994               position += stream.node.contents.length;
1995             }
1996           }
1997           if (position < 0) {
1998             throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
1999           }
2000           stream.ungotten = [];
2001           stream.position = position;
2002           return position;
2003         },allocate:function (stream, offset, length) {
2004           MEMFS.ensureFlexible(stream.node);
2005           var contents = stream.node.contents;
2006           var limit = offset + length;
2007           while (limit > contents.length) contents.push(0);
2008         },mmap:function (stream, buffer, offset, length, position, prot, flags) {
2009           if (!FS.isFile(stream.node.mode)) {
2010             throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
2011           }
2012           var ptr;
2013           var allocated;
2014           var contents = stream.node.contents;
2015           // Only make a new copy when MAP_PRIVATE is specified.
2016           if ( !(flags & 2) &&
2017                 (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
2018             // We can't emulate MAP_SHARED when the file is not backed by the buffer
2019             // we're mapping to (e.g. the HEAP buffer).
2020             allocated = false;
2021             ptr = contents.byteOffset;
2022           } else {
2023             // Try to avoid unnecessary slices.
2024             if (position > 0 || position + length < contents.length) {
2025               if (contents.subarray) {
2026                 contents = contents.subarray(position, position + length);
2027               } else {
2028                 contents = Array.prototype.slice.call(contents, position, position + length);
2029               }
2030             }
2031             allocated = true;
2032             ptr = _malloc(length);
2033             if (!ptr) {
2034               throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
2035             }
2036             buffer.set(contents, ptr);
2037           }
2038           return { ptr: ptr, allocated: allocated };
2039         }}};
2040   
2041   var IDBFS={dbs:{},indexedDB:function () {
2042         return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
2043       },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
2044         // reuse all of the core MEMFS functionality
2045         return MEMFS.mount.apply(null, arguments);
2046       },syncfs:function (mount, populate, callback) {
2047         IDBFS.getLocalSet(mount, function(err, local) {
2048           if (err) return callback(err);
2049   
2050           IDBFS.getRemoteSet(mount, function(err, remote) {
2051             if (err) return callback(err);
2052   
2053             var src = populate ? remote : local;
2054             var dst = populate ? local : remote;
2055   
2056             IDBFS.reconcile(src, dst, callback);
2057           });
2058         });
2059       },getDB:function (name, callback) {
2060         // check the cache first
2061         var db = IDBFS.dbs[name];
2062         if (db) {
2063           return callback(null, db);
2064         }
2065   
2066         var req;
2067         try {
2068           req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
2069         } catch (e) {
2070           return callback(e);
2071         }
2072         req.onupgradeneeded = function(e) {
2073           var db = e.target.result;
2074           var transaction = e.target.transaction;
2075   
2076           var fileStore;
2077   
2078           if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
2079             fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
2080           } else {
2081             fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
2082           }
2083   
2084           fileStore.createIndex('timestamp', 'timestamp', { unique: false });
2085         };
2086         req.onsuccess = function() {
2087           db = req.result;
2088   
2089           // add to the cache
2090           IDBFS.dbs[name] = db;
2091           callback(null, db);
2092         };
2093         req.onerror = function() {
2094           callback(this.error);
2095         };
2096       },getLocalSet:function (mount, callback) {
2097         var entries = {};
2098   
2099         function isRealDir(p) {
2100           return p !== '.' && p !== '..';
2101         };
2102         function toAbsolute(root) {
2103           return function(p) {
2104             return PATH.join2(root, p);
2105           }
2106         };
2107   
2108         var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
2109   
2110         while (check.length) {
2111           var path = check.pop();
2112           var stat;
2113   
2114           try {
2115             stat = FS.stat(path);
2116           } catch (e) {
2117             return callback(e);
2118           }
2119   
2120           if (FS.isDir(stat.mode)) {
2121             check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
2122           }
2123   
2124           entries[path] = { timestamp: stat.mtime };
2125         }
2126   
2127         return callback(null, { type: 'local', entries: entries });
2128       },getRemoteSet:function (mount, callback) {
2129         var entries = {};
2130   
2131         IDBFS.getDB(mount.mountpoint, function(err, db) {
2132           if (err) return callback(err);
2133   
2134           var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
2135           transaction.onerror = function() { callback(this.error); };
2136   
2137           var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
2138           var index = store.index('timestamp');
2139   
2140           index.openKeyCursor().onsuccess = function(event) {
2141             var cursor = event.target.result;
2142   
2143             if (!cursor) {
2144               return callback(null, { type: 'remote', db: db, entries: entries });
2145             }
2146   
2147             entries[cursor.primaryKey] = { timestamp: cursor.key };
2148   
2149             cursor.continue();
2150           };
2151         });
2152       },loadLocalEntry:function (path, callback) {
2153         var stat, node;
2154   
2155         try {
2156           var lookup = FS.lookupPath(path);
2157           node = lookup.node;
2158           stat = FS.stat(path);
2159         } catch (e) {
2160           return callback(e);
2161         }
2162   
2163         if (FS.isDir(stat.mode)) {
2164           return callback(null, { timestamp: stat.mtime, mode: stat.mode });
2165         } else if (FS.isFile(stat.mode)) {
2166           return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
2167         } else {
2168           return callback(new Error('node type not supported'));
2169         }
2170       },storeLocalEntry:function (path, entry, callback) {
2171         try {
2172           if (FS.isDir(entry.mode)) {
2173             FS.mkdir(path, entry.mode);
2174           } else if (FS.isFile(entry.mode)) {
2175             FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
2176           } else {
2177             return callback(new Error('node type not supported'));
2178           }
2179   
2180           FS.utime(path, entry.timestamp, entry.timestamp);
2181         } catch (e) {
2182           return callback(e);
2183         }
2184   
2185         callback(null);
2186       },removeLocalEntry:function (path, callback) {
2187         try {
2188           var lookup = FS.lookupPath(path);
2189           var stat = FS.stat(path);
2190   
2191           if (FS.isDir(stat.mode)) {
2192             FS.rmdir(path);
2193           } else if (FS.isFile(stat.mode)) {
2194             FS.unlink(path);
2195           }
2196         } catch (e) {
2197           return callback(e);
2198         }
2199   
2200         callback(null);
2201       },loadRemoteEntry:function (store, path, callback) {
2202         var req = store.get(path);
2203         req.onsuccess = function(event) { callback(null, event.target.result); };
2204         req.onerror = function() { callback(this.error); };
2205       },storeRemoteEntry:function (store, path, entry, callback) {
2206         var req = store.put(entry, path);
2207         req.onsuccess = function() { callback(null); };
2208         req.onerror = function() { callback(this.error); };
2209       },removeRemoteEntry:function (store, path, callback) {
2210         var req = store.delete(path);
2211         req.onsuccess = function() { callback(null); };
2212         req.onerror = function() { callback(this.error); };
2213       },reconcile:function (src, dst, callback) {
2214         var total = 0;
2215   
2216         var create = [];
2217         Object.keys(src.entries).forEach(function (key) {
2218           var e = src.entries[key];
2219           var e2 = dst.entries[key];
2220           if (!e2 || e.timestamp > e2.timestamp) {
2221             create.push(key);
2222             total++;
2223           }
2224         });
2225   
2226         var remove = [];
2227         Object.keys(dst.entries).forEach(function (key) {
2228           var e = dst.entries[key];
2229           var e2 = src.entries[key];
2230           if (!e2) {
2231             remove.push(key);
2232             total++;
2233           }
2234         });
2235   
2236         if (!total) {
2237           return callback(null);
2238         }
2239   
2240         var errored = false;
2241         var completed = 0;
2242         var db = src.type === 'remote' ? src.db : dst.db;
2243         var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
2244         var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
2245   
2246         function done(err) {
2247           if (err) {
2248             if (!done.errored) {
2249               done.errored = true;
2250               return callback(err);
2251             }
2252             return;
2253           }
2254           if (++completed >= total) {
2255             return callback(null);
2256           }
2257         };
2258   
2259         transaction.onerror = function() { done(this.error); };
2260   
2261         // sort paths in ascending order so directory entries are created
2262         // before the files inside them
2263         create.sort().forEach(function (path) {
2264           if (dst.type === 'local') {
2265             IDBFS.loadRemoteEntry(store, path, function (err, entry) {
2266               if (err) return done(err);
2267               IDBFS.storeLocalEntry(path, entry, done);
2268             });
2269           } else {
2270             IDBFS.loadLocalEntry(path, function (err, entry) {
2271               if (err) return done(err);
2272               IDBFS.storeRemoteEntry(store, path, entry, done);
2273             });
2274           }
2275         });
2276   
2277         // sort paths in descending order so files are deleted before their
2278         // parent directories
2279         remove.sort().reverse().forEach(function(path) {
2280           if (dst.type === 'local') {
2281             IDBFS.removeLocalEntry(path, done);
2282           } else {
2283             IDBFS.removeRemoteEntry(store, path, done);
2284           }
2285         });
2286       }};
2287   
2288   var NODEFS={isWindows:false,staticInit:function () {
2289         NODEFS.isWindows = !!process.platform.match(/^win/);
2290       },mount:function (mount) {
2291         assert(ENVIRONMENT_IS_NODE);
2292         return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
2293       },createNode:function (parent, name, mode, dev) {
2294         if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
2295           throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2296         }
2297         var node = FS.createNode(parent, name, mode);
2298         node.node_ops = NODEFS.node_ops;
2299         node.stream_ops = NODEFS.stream_ops;
2300         return node;
2301       },getMode:function (path) {
2302         var stat;
2303         try {
2304           stat = fs.lstatSync(path);
2305           if (NODEFS.isWindows) {
2306             // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so 
2307             // propagate write bits to execute bits.
2308             stat.mode = stat.mode | ((stat.mode & 146) >> 1);
2309           }
2310         } catch (e) {
2311           if (!e.code) throw e;
2312           throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2313         }
2314         return stat.mode;
2315       },realPath:function (node) {
2316         var parts = [];
2317         while (node.parent !== node) {
2318           parts.push(node.name);
2319           node = node.parent;
2320         }
2321         parts.push(node.mount.opts.root);
2322         parts.reverse();
2323         return PATH.join.apply(null, parts);
2324       },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) {
2325         if (flags in NODEFS.flagsToPermissionStringMap) {
2326           return NODEFS.flagsToPermissionStringMap[flags];
2327         } else {
2328           return flags;
2329         }
2330       },node_ops:{getattr:function (node) {
2331           var path = NODEFS.realPath(node);
2332           var stat;
2333           try {
2334             stat = fs.lstatSync(path);
2335           } catch (e) {
2336             if (!e.code) throw e;
2337             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2338           }
2339           // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
2340           // See http://support.microsoft.com/kb/140365
2341           if (NODEFS.isWindows && !stat.blksize) {
2342             stat.blksize = 4096;
2343           }
2344           if (NODEFS.isWindows && !stat.blocks) {
2345             stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
2346           }
2347           return {
2348             dev: stat.dev,
2349             ino: stat.ino,
2350             mode: stat.mode,
2351             nlink: stat.nlink,
2352             uid: stat.uid,
2353             gid: stat.gid,
2354             rdev: stat.rdev,
2355             size: stat.size,
2356             atime: stat.atime,
2357             mtime: stat.mtime,
2358             ctime: stat.ctime,
2359             blksize: stat.blksize,
2360             blocks: stat.blocks
2361           };
2362         },setattr:function (node, attr) {
2363           var path = NODEFS.realPath(node);
2364           try {
2365             if (attr.mode !== undefined) {
2366               fs.chmodSync(path, attr.mode);
2367               // update the common node structure mode as well
2368               node.mode = attr.mode;
2369             }
2370             if (attr.timestamp !== undefined) {
2371               var date = new Date(attr.timestamp);
2372               fs.utimesSync(path, date, date);
2373             }
2374             if (attr.size !== undefined) {
2375               fs.truncateSync(path, attr.size);
2376             }
2377           } catch (e) {
2378             if (!e.code) throw e;
2379             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2380           }
2381         },lookup:function (parent, name) {
2382           var path = PATH.join2(NODEFS.realPath(parent), name);
2383           var mode = NODEFS.getMode(path);
2384           return NODEFS.createNode(parent, name, mode);
2385         },mknod:function (parent, name, mode, dev) {
2386           var node = NODEFS.createNode(parent, name, mode, dev);
2387           // create the backing node for this in the fs root as well
2388           var path = NODEFS.realPath(node);
2389           try {
2390             if (FS.isDir(node.mode)) {
2391               fs.mkdirSync(path, node.mode);
2392             } else {
2393               fs.writeFileSync(path, '', { mode: node.mode });
2394             }
2395           } catch (e) {
2396             if (!e.code) throw e;
2397             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2398           }
2399           return node;
2400         },rename:function (oldNode, newDir, newName) {
2401           var oldPath = NODEFS.realPath(oldNode);
2402           var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
2403           try {
2404             fs.renameSync(oldPath, newPath);
2405           } catch (e) {
2406             if (!e.code) throw e;
2407             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2408           }
2409         },unlink:function (parent, name) {
2410           var path = PATH.join2(NODEFS.realPath(parent), name);
2411           try {
2412             fs.unlinkSync(path);
2413           } catch (e) {
2414             if (!e.code) throw e;
2415             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2416           }
2417         },rmdir:function (parent, name) {
2418           var path = PATH.join2(NODEFS.realPath(parent), name);
2419           try {
2420             fs.rmdirSync(path);
2421           } catch (e) {
2422             if (!e.code) throw e;
2423             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2424           }
2425         },readdir:function (node) {
2426           var path = NODEFS.realPath(node);
2427           try {
2428             return fs.readdirSync(path);
2429           } catch (e) {
2430             if (!e.code) throw e;
2431             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2432           }
2433         },symlink:function (parent, newName, oldPath) {
2434           var newPath = PATH.join2(NODEFS.realPath(parent), newName);
2435           try {
2436             fs.symlinkSync(oldPath, newPath);
2437           } catch (e) {
2438             if (!e.code) throw e;
2439             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2440           }
2441         },readlink:function (node) {
2442           var path = NODEFS.realPath(node);
2443           try {
2444             return fs.readlinkSync(path);
2445           } catch (e) {
2446             if (!e.code) throw e;
2447             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2448           }
2449         }},stream_ops:{open:function (stream) {
2450           var path = NODEFS.realPath(stream.node);
2451           try {
2452             if (FS.isFile(stream.node.mode)) {
2453               stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
2454             }
2455           } catch (e) {
2456             if (!e.code) throw e;
2457             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2458           }
2459         },close:function (stream) {
2460           try {
2461             if (FS.isFile(stream.node.mode) && stream.nfd) {
2462               fs.closeSync(stream.nfd);
2463             }
2464           } catch (e) {
2465             if (!e.code) throw e;
2466             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2467           }
2468         },read:function (stream, buffer, offset, length, position) {
2469           // FIXME this is terrible.
2470           var nbuffer = new Buffer(length);
2471           var res;
2472           try {
2473             res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
2474           } catch (e) {
2475             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2476           }
2477           if (res > 0) {
2478             for (var i = 0; i < res; i++) {
2479               buffer[offset + i] = nbuffer[i];
2480             }
2481           }
2482           return res;
2483         },write:function (stream, buffer, offset, length, position) {
2484           // FIXME this is terrible.
2485           var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
2486           var res;
2487           try {
2488             res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
2489           } catch (e) {
2490             throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2491           }
2492           return res;
2493         },llseek:function (stream, offset, whence) {
2494           var position = offset;
2495           if (whence === 1) {  // SEEK_CUR.
2496             position += stream.position;
2497           } else if (whence === 2) {  // SEEK_END.
2498             if (FS.isFile(stream.node.mode)) {
2499               try {
2500                 var stat = fs.fstatSync(stream.nfd);
2501                 position += stat.size;
2502               } catch (e) {
2503                 throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2504               }
2505             }
2506           }
2507   
2508           if (position < 0) {
2509             throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2510           }
2511   
2512           stream.position = position;
2513           return position;
2514         }}};
2515   
2516   var _stdin=allocate(1, "i32*", ALLOC_STATIC);
2517   
2518   var _stdout=allocate(1, "i32*", ALLOC_STATIC);
2519   
2520   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) {
2521         if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
2522         return ___setErrNo(e.errno);
2523       },lookupPath:function (path, opts) {
2524         path = PATH.resolve(FS.cwd(), path);
2525         opts = opts || {};
2526   
2527         var defaults = {
2528           follow_mount: true,
2529           recurse_count: 0
2530         };
2531         for (var key in defaults) {
2532           if (opts[key] === undefined) {
2533             opts[key] = defaults[key];
2534           }
2535         }
2536   
2537         if (opts.recurse_count > 8) {  // max recursive lookup of 8
2538           throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
2539         }
2540   
2541         // split the path
2542         var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
2543           return !!p;
2544         }), false);
2545   
2546         // start at the root
2547         var current = FS.root;
2548         var current_path = '/';
2549   
2550         for (var i = 0; i < parts.length; i++) {
2551           var islast = (i === parts.length-1);
2552           if (islast && opts.parent) {
2553             // stop resolving
2554             break;
2555           }
2556   
2557           current = FS.lookupNode(current, parts[i]);
2558           current_path = PATH.join2(current_path, parts[i]);
2559   
2560           // jump to the mount's root node if this is a mountpoint
2561           if (FS.isMountpoint(current)) {
2562             if (!islast || (islast && opts.follow_mount)) {
2563               current = current.mounted.root;
2564             }
2565           }
2566   
2567           // by default, lookupPath will not follow a symlink if it is the final path component.
2568           // setting opts.follow = true will override this behavior.
2569           if (!islast || opts.follow) {
2570             var count = 0;
2571             while (FS.isLink(current.mode)) {
2572               var link = FS.readlink(current_path);
2573               current_path = PATH.resolve(PATH.dirname(current_path), link);
2574               
2575               var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
2576               current = lookup.node;
2577   
2578               if (count++ > 40) {  // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
2579                 throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
2580               }
2581             }
2582           }
2583         }
2584   
2585         return { path: current_path, node: current };
2586       },getPath:function (node) {
2587         var path;
2588         while (true) {
2589           if (FS.isRoot(node)) {
2590             var mount = node.mount.mountpoint;
2591             if (!path) return mount;
2592             return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
2593           }
2594           path = path ? node.name + '/' + path : node.name;
2595           node = node.parent;
2596         }
2597       },hashName:function (parentid, name) {
2598         var hash = 0;
2599   
2600   
2601         for (var i = 0; i < name.length; i++) {
2602           hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
2603         }
2604         return ((parentid + hash) >>> 0) % FS.nameTable.length;
2605       },hashAddNode:function (node) {
2606         var hash = FS.hashName(node.parent.id, node.name);
2607         node.name_next = FS.nameTable[hash];
2608         FS.nameTable[hash] = node;
2609       },hashRemoveNode:function (node) {
2610         var hash = FS.hashName(node.parent.id, node.name);
2611         if (FS.nameTable[hash] === node) {
2612           FS.nameTable[hash] = node.name_next;
2613         } else {
2614           var current = FS.nameTable[hash];
2615           while (current) {
2616             if (current.name_next === node) {
2617               current.name_next = node.name_next;
2618               break;
2619             }
2620             current = current.name_next;
2621           }
2622         }
2623       },lookupNode:function (parent, name) {
2624         var err = FS.mayLookup(parent);
2625         if (err) {
2626           throw new FS.ErrnoError(err);
2627         }
2628         var hash = FS.hashName(parent.id, name);
2629         for (var node = FS.nameTable[hash]; node; node = node.name_next) {
2630           var nodeName = node.name;
2631           if (node.parent.id === parent.id && nodeName === name) {
2632             return node;
2633           }
2634         }
2635         // if we failed to find it in the cache, call into the VFS
2636         return FS.lookup(parent, name);
2637       },createNode:function (parent, name, mode, rdev) {
2638         if (!FS.FSNode) {
2639           FS.FSNode = function(parent, name, mode, rdev) {
2640             if (!parent) {
2641               parent = this;  // root node sets parent to itself
2642             }
2643             this.parent = parent;
2644             this.mount = parent.mount;
2645             this.mounted = null;
2646             this.id = FS.nextInode++;
2647             this.name = name;
2648             this.mode = mode;
2649             this.node_ops = {};
2650             this.stream_ops = {};
2651             this.rdev = rdev;
2652           };
2653   
2654           FS.FSNode.prototype = {};
2655   
2656           // compatibility
2657           var readMode = 292 | 73;
2658           var writeMode = 146;
2659   
2660           // NOTE we must use Object.defineProperties instead of individual calls to
2661           // Object.defineProperty in order to make closure compiler happy
2662           Object.defineProperties(FS.FSNode.prototype, {
2663             read: {
2664               get: function() { return (this.mode & readMode) === readMode; },
2665               set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
2666             },
2667             write: {
2668               get: function() { return (this.mode & writeMode) === writeMode; },
2669               set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
2670             },
2671             isFolder: {
2672               get: function() { return FS.isDir(this.mode); },
2673             },
2674             isDevice: {
2675               get: function() { return FS.isChrdev(this.mode); },
2676             },
2677           });
2678         }
2679   
2680         var node = new FS.FSNode(parent, name, mode, rdev);
2681   
2682         FS.hashAddNode(node);
2683   
2684         return node;
2685       },destroyNode:function (node) {
2686         FS.hashRemoveNode(node);
2687       },isRoot:function (node) {
2688         return node === node.parent;
2689       },isMountpoint:function (node) {
2690         return !!node.mounted;
2691       },isFile:function (mode) {
2692         return (mode & 61440) === 32768;
2693       },isDir:function (mode) {
2694         return (mode & 61440) === 16384;
2695       },isLink:function (mode) {
2696         return (mode & 61440) === 40960;
2697       },isChrdev:function (mode) {
2698         return (mode & 61440) === 8192;
2699       },isBlkdev:function (mode) {
2700         return (mode & 61440) === 24576;
2701       },isFIFO:function (mode) {
2702         return (mode & 61440) === 4096;
2703       },isSocket:function (mode) {
2704         return (mode & 49152) === 49152;
2705       },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) {
2706         var flags = FS.flagModes[str];
2707         if (typeof flags === 'undefined') {
2708           throw new Error('Unknown file open mode: ' + str);
2709         }
2710         return flags;
2711       },flagsToPermissionString:function (flag) {
2712         var accmode = flag & 2097155;
2713         var perms = ['r', 'w', 'rw'][accmode];
2714         if ((flag & 512)) {
2715           perms += 'w';
2716         }
2717         return perms;
2718       },nodePermissions:function (node, perms) {
2719         if (FS.ignorePermissions) {
2720           return 0;
2721         }
2722         // return 0 if any user, group or owner bits are set.
2723         if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
2724           return ERRNO_CODES.EACCES;
2725         } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
2726           return ERRNO_CODES.EACCES;
2727         } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
2728           return ERRNO_CODES.EACCES;
2729         }
2730         return 0;
2731       },mayLookup:function (dir) {
2732         return FS.nodePermissions(dir, 'x');
2733       },mayCreate:function (dir, name) {
2734         try {
2735           var node = FS.lookupNode(dir, name);
2736           return ERRNO_CODES.EEXIST;
2737         } catch (e) {
2738         }
2739         return FS.nodePermissions(dir, 'wx');
2740       },mayDelete:function (dir, name, isdir) {
2741         var node;
2742         try {
2743           node = FS.lookupNode(dir, name);
2744         } catch (e) {
2745           return e.errno;
2746         }
2747         var err = FS.nodePermissions(dir, 'wx');
2748         if (err) {
2749           return err;
2750         }
2751         if (isdir) {
2752           if (!FS.isDir(node.mode)) {
2753             return ERRNO_CODES.ENOTDIR;
2754           }
2755           if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
2756             return ERRNO_CODES.EBUSY;
2757           }
2758         } else {
2759           if (FS.isDir(node.mode)) {
2760             return ERRNO_CODES.EISDIR;
2761           }
2762         }
2763         return 0;
2764       },mayOpen:function (node, flags) {
2765         if (!node) {
2766           return ERRNO_CODES.ENOENT;
2767         }
2768         if (FS.isLink(node.mode)) {
2769           return ERRNO_CODES.ELOOP;
2770         } else if (FS.isDir(node.mode)) {
2771           if ((flags & 2097155) !== 0 ||  // opening for write
2772               (flags & 512)) {
2773             return ERRNO_CODES.EISDIR;
2774           }
2775         }
2776         return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
2777       },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
2778         fd_start = fd_start || 0;
2779         fd_end = fd_end || FS.MAX_OPEN_FDS;
2780         for (var fd = fd_start; fd <= fd_end; fd++) {
2781           if (!FS.streams[fd]) {
2782             return fd;
2783           }
2784         }
2785         throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
2786       },getStream:function (fd) {
2787         return FS.streams[fd];
2788       },createStream:function (stream, fd_start, fd_end) {
2789         if (!FS.FSStream) {
2790           FS.FSStream = function(){};
2791           FS.FSStream.prototype = {};
2792           // compatibility
2793           Object.defineProperties(FS.FSStream.prototype, {
2794             object: {
2795               get: function() { return this.node; },
2796               set: function(val) { this.node = val; }
2797             },
2798             isRead: {
2799               get: function() { return (this.flags & 2097155) !== 1; }
2800             },
2801             isWrite: {
2802               get: function() { return (this.flags & 2097155) !== 0; }
2803             },
2804             isAppend: {
2805               get: function() { return (this.flags & 1024); }
2806             }
2807           });
2808         }
2809         if (stream.__proto__) {
2810           // reuse the object
2811           stream.__proto__ = FS.FSStream.prototype;
2812         } else {
2813           var newStream = new FS.FSStream();
2814           for (var p in stream) {
2815             newStream[p] = stream[p];
2816           }
2817           stream = newStream;
2818         }
2819         var fd = FS.nextfd(fd_start, fd_end);
2820         stream.fd = fd;
2821         FS.streams[fd] = stream;
2822         return stream;
2823       },closeStream:function (fd) {
2824         FS.streams[fd] = null;
2825       },getStreamFromPtr:function (ptr) {
2826         return FS.streams[ptr - 1];
2827       },getPtrForStream:function (stream) {
2828         return stream ? stream.fd + 1 : 0;
2829       },chrdev_stream_ops:{open:function (stream) {
2830           var device = FS.getDevice(stream.node.rdev);
2831           // override node's stream ops with the device's
2832           stream.stream_ops = device.stream_ops;
2833           // forward the open call
2834           if (stream.stream_ops.open) {
2835             stream.stream_ops.open(stream);
2836           }
2837         },llseek:function () {
2838           throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
2839         }},major:function (dev) {
2840         return ((dev) >> 8);
2841       },minor:function (dev) {
2842         return ((dev) & 0xff);
2843       },makedev:function (ma, mi) {
2844         return ((ma) << 8 | (mi));
2845       },registerDevice:function (dev, ops) {
2846         FS.devices[dev] = { stream_ops: ops };
2847       },getDevice:function (dev) {
2848         return FS.devices[dev];
2849       },getMounts:function (mount) {
2850         var mounts = [];
2851         var check = [mount];
2852   
2853         while (check.length) {
2854           var m = check.pop();
2855   
2856           mounts.push(m);
2857   
2858           check.push.apply(check, m.mounts);
2859         }
2860   
2861         return mounts;
2862       },syncfs:function (populate, callback) {
2863         if (typeof(populate) === 'function') {
2864           callback = populate;
2865           populate = false;
2866         }
2867   
2868         var mounts = FS.getMounts(FS.root.mount);
2869         var completed = 0;
2870   
2871         function done(err) {
2872           if (err) {
2873             if (!done.errored) {
2874               done.errored = true;
2875               return callback(err);
2876             }
2877             return;
2878           }
2879           if (++completed >= mounts.length) {
2880             callback(null);
2881           }
2882         };
2883   
2884         // sync all mounts
2885         mounts.forEach(function (mount) {
2886           if (!mount.type.syncfs) {
2887             return done(null);
2888           }
2889           mount.type.syncfs(mount, populate, done);
2890         });
2891       },mount:function (type, opts, mountpoint) {
2892         var root = mountpoint === '/';
2893         var pseudo = !mountpoint;
2894         var node;
2895   
2896         if (root && FS.root) {
2897           throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
2898         } else if (!root && !pseudo) {
2899           var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
2900   
2901           mountpoint = lookup.path;  // use the absolute path
2902           node = lookup.node;
2903   
2904           if (FS.isMountpoint(node)) {
2905             throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
2906           }
2907   
2908           if (!FS.isDir(node.mode)) {
2909             throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
2910           }
2911         }
2912   
2913         var mount = {
2914           type: type,
2915           opts: opts,
2916           mountpoint: mountpoint,
2917           mounts: []
2918         };
2919   
2920         // create a root node for the fs
2921         var mountRoot = type.mount(mount);
2922         mountRoot.mount = mount;
2923         mount.root = mountRoot;
2924   
2925         if (root) {
2926           FS.root = mountRoot;
2927         } else if (node) {
2928           // set as a mountpoint
2929           node.mounted = mount;
2930   
2931           // add the new mount to the current mount's children
2932           if (node.mount) {
2933             node.mount.mounts.push(mount);
2934           }
2935         }
2936   
2937         return mountRoot;
2938       },unmount:function (mountpoint) {
2939         var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
2940   
2941         if (!FS.isMountpoint(lookup.node)) {
2942           throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
2943         }
2944   
2945         // destroy the nodes for this mount, and all its child mounts
2946         var node = lookup.node;
2947         var mount = node.mounted;
2948         var mounts = FS.getMounts(mount);
2949   
2950         Object.keys(FS.nameTable).forEach(function (hash) {
2951           var current = FS.nameTable[hash];
2952   
2953           while (current) {
2954             var next = current.name_next;
2955   
2956             if (mounts.indexOf(current.mount) !== -1) {
2957               FS.destroyNode(current);
2958             }
2959   
2960             current = next;
2961           }
2962         });
2963   
2964         // no longer a mountpoint
2965         node.mounted = null;
2966   
2967         // remove this mount from the child mounts
2968         var idx = node.mount.mounts.indexOf(mount);
2969         assert(idx !== -1);
2970         node.mount.mounts.splice(idx, 1);
2971       },lookup:function (parent, name) {
2972         return parent.node_ops.lookup(parent, name);
2973       },mknod:function (path, mode, dev) {
2974         var lookup = FS.lookupPath(path, { parent: true });
2975         var parent = lookup.node;
2976         var name = PATH.basename(path);
2977         var err = FS.mayCreate(parent, name);
2978         if (err) {
2979           throw new FS.ErrnoError(err);
2980         }
2981         if (!parent.node_ops.mknod) {
2982           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
2983         }
2984         return parent.node_ops.mknod(parent, name, mode, dev);
2985       },create:function (path, mode) {
2986         mode = mode !== undefined ? mode : 438 /* 0666 */;
2987         mode &= 4095;
2988         mode |= 32768;
2989         return FS.mknod(path, mode, 0);
2990       },mkdir:function (path, mode) {
2991         mode = mode !== undefined ? mode : 511 /* 0777 */;
2992         mode &= 511 | 512;
2993         mode |= 16384;
2994         return FS.mknod(path, mode, 0);
2995       },mkdev:function (path, mode, dev) {
2996         if (typeof(dev) === 'undefined') {
2997           dev = mode;
2998           mode = 438 /* 0666 */;
2999         }
3000         mode |= 8192;
3001         return FS.mknod(path, mode, dev);
3002       },symlink:function (oldpath, newpath) {
3003         var lookup = FS.lookupPath(newpath, { parent: true });
3004         var parent = lookup.node;
3005         var newname = PATH.basename(newpath);
3006         var err = FS.mayCreate(parent, newname);
3007         if (err) {
3008           throw new FS.ErrnoError(err);
3009         }
3010         if (!parent.node_ops.symlink) {
3011           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
3012         }
3013         return parent.node_ops.symlink(parent, newname, oldpath);
3014       },rename:function (old_path, new_path) {
3015         var old_dirname = PATH.dirname(old_path);
3016         var new_dirname = PATH.dirname(new_path);
3017         var old_name = PATH.basename(old_path);
3018         var new_name = PATH.basename(new_path);
3019         // parents must exist
3020         var lookup, old_dir, new_dir;
3021         try {
3022           lookup = FS.lookupPath(old_path, { parent: true });
3023           old_dir = lookup.node;
3024           lookup = FS.lookupPath(new_path, { parent: true });
3025           new_dir = lookup.node;
3026         } catch (e) {
3027           throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
3028         }
3029         // need to be part of the same mount
3030         if (old_dir.mount !== new_dir.mount) {
3031           throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
3032         }
3033         // source must exist
3034         var old_node = FS.lookupNode(old_dir, old_name);
3035         // old path should not be an ancestor of the new path
3036         var relative = PATH.relative(old_path, new_dirname);
3037         if (relative.charAt(0) !== '.') {
3038           throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
3039         }
3040         // new path should not be an ancestor of the old path
3041         relative = PATH.relative(new_path, old_dirname);
3042         if (relative.charAt(0) !== '.') {
3043           throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
3044         }
3045         // see if the new path already exists
3046         var new_node;
3047         try {
3048           new_node = FS.lookupNode(new_dir, new_name);
3049         } catch (e) {
3050           // not fatal
3051         }
3052         // early out if nothing needs to change
3053         if (old_node === new_node) {
3054           return;
3055         }
3056         // we'll need to delete the old entry
3057         var isdir = FS.isDir(old_node.mode);
3058         var err = FS.mayDelete(old_dir, old_name, isdir);
3059         if (err) {
3060           throw new FS.ErrnoError(err);
3061         }
3062         // need delete permissions if we'll be overwriting.
3063         // need create permissions if new doesn't already exist.
3064         err = new_node ?
3065           FS.mayDelete(new_dir, new_name, isdir) :
3066           FS.mayCreate(new_dir, new_name);
3067         if (err) {
3068           throw new FS.ErrnoError(err);
3069         }
3070         if (!old_dir.node_ops.rename) {
3071           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
3072         }
3073         if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
3074           throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
3075         }
3076         // if we are going to change the parent, check write permissions
3077         if (new_dir !== old_dir) {
3078           err = FS.nodePermissions(old_dir, 'w');
3079           if (err) {
3080             throw new FS.ErrnoError(err);
3081           }
3082         }
3083         // remove the node from the lookup hash
3084         FS.hashRemoveNode(old_node);
3085         // do the underlying fs rename
3086         try {
3087           old_dir.node_ops.rename(old_node, new_dir, new_name);
3088         } catch (e) {
3089           throw e;
3090         } finally {
3091           // add the node back to the hash (in case node_ops.rename
3092           // changed its name)
3093           FS.hashAddNode(old_node);
3094         }
3095       },rmdir:function (path) {
3096         var lookup = FS.lookupPath(path, { parent: true });
3097         var parent = lookup.node;
3098         var name = PATH.basename(path);
3099         var node = FS.lookupNode(parent, name);
3100         var err = FS.mayDelete(parent, name, true);
3101         if (err) {
3102           throw new FS.ErrnoError(err);
3103         }
3104         if (!parent.node_ops.rmdir) {
3105           throw new FS.ErrnoError(ERRNO_CODES.EPERM);
3106         }
3107         if (FS.isMountpoint(node)) {
3108           throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
3109         }
3110         parent.node_ops.rmdir(parent, name);
3111         FS.destroyNode(node);
3112       },readdir:function (path) {
3113         var lookup = FS.lookupPath(path, { follow: true });
3114         var node = lookup.node;
3115         if (!node.node_ops.readdir) {
3116           throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
3117         }
3118         return node.node_ops.readdir(node);
311