shithub: h264bsd

Download patch

ref: 675f1a771edf57accbfaf9c9a369b7053792b22e
parent: 3cc5bb12d6f8e833bad40ad49444d3fcda5d0b6f
author: Chris Jarabek <[email protected]>
date: Thu Jan 23 11:14:55 EST 2014

Fixed errors when generating dist file.  Added more inline docs.  Improved code style in a few places.

--- a/js/Gruntfile.js
+++ b/js/Gruntfile.js
@@ -1,26 +1,16 @@
 module.exports = function(grunt) {
-
-  // Project configuration.
   grunt.initConfig({
 
-    //Doesn't seem to work atm.  Clobbers global vars needed in test script.
     uglify: {
+      options: {
+            mangle: false
+      },      
       minlibs: {
-        options: {
-            mangle: false,
-        },
         files: {
           'dist/h264bsd.min.js': ['h264bsd_asm.js',' sylvester.js', 'glUtils.js', 'util.js', 'canvas.js', 'h264bsd.js']
         }
       }
     },   
-
-    concat: {
-      pack: {
-        src: ['h264bsd_asm.js',' sylvester.js', 'glUtils.js', 'util.js', 'canvas.js', 'h264bsd.js'],
-        dest: 'dist/h264bsd.min.js'
-      }
-    },
    
     //grunt-clean
     clean: {
@@ -37,5 +27,5 @@
     
 
   // Default task.
-  grunt.registerTask('default', ['clean', 'concat']);
+  grunt.registerTask('default', ['clean', 'uglify']);
 };
--- a/js/dist/h264bsd.min.js
+++ b/js/dist/h264bsd.min.js
@@ -1,5507 +1,11 @@
-// Note: For maximum-speed code, see "Optimizing Code" on the Emscripten wiki, https://github.com/kripken/emscripten/wiki/Optimizing-Code
-// Note: Some Emscripten settings may limit the speed of the generated code.
-// The Module object: Our interface to the outside world. We import
-// and export values on it, and do the work to get that through
-// closure compiler if necessary. There are various ways Module can be used:
-// 1. Not defined. We create it here
-// 2. A function parameter, function(Module) { ..generated code.. }
-// 3. pre-run appended it, var Module = {}; ..generated code..
-// 4. External script tag defines var Module.
-// We need to do an eval in order to handle the closure compiler
-// case, where this code here is minified but Module was defined
-// elsewhere (e.g. case 4 above). We also need to check if Module
-// already exists (e.g. case 3 above).
-// Note that if you want to run closure, and also to use Module
-// after the generated code, you will need to define   var Module = {};
-// before the code. Then that object will be used in the code, and you
-// can continue to use Module afterwards as well.
-var Module;
-if (!Module) Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');
-// Sometimes an existing Module object exists with properties
-// meant to overwrite the default module functionality. Here
-// we collect those properties and reapply _after_ we configure
-// the current environment's defaults to avoid having to be so
-// defensive during initialization.
-var moduleOverrides = {};
-for (var key in Module) {
-  if (Module.hasOwnProperty(key)) {
-    moduleOverrides[key] = Module[key];
-  }
-}
-// The environment setup code below is customized to use Module.
-// *** Environment setup code ***
-var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
-var ENVIRONMENT_IS_WEB = typeof window === 'object';
-var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
-var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
-if (ENVIRONMENT_IS_NODE) {
-  // Expose functionality in the same simple way that the shells work
-  // Note that we pollute the global namespace here, otherwise we break in node
-  Module['print'] = function print(x) {
-    process['stdout'].write(x + '\n');
-  };
-  Module['printErr'] = function printErr(x) {
-    process['stderr'].write(x + '\n');
-  };
-  var nodeFS = require('fs');
-  var nodePath = require('path');
-  Module['read'] = function read(filename, binary) {
-    filename = nodePath['normalize'](filename);
-    var ret = nodeFS['readFileSync'](filename);
-    // The path is absolute if the normalized version is the same as the resolved.
-    if (!ret && filename != nodePath['resolve'](filename)) {
-      filename = path.join(__dirname, '..', 'src', filename);
-      ret = nodeFS['readFileSync'](filename);
-    }
-    if (ret && !binary) ret = ret.toString();
-    return ret;
-  };
-  Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
-  Module['load'] = function load(f) {
-    globalEval(read(f));
-  };
-  Module['arguments'] = process['argv'].slice(2);
-  module['exports'] = Module;
-}
-else if (ENVIRONMENT_IS_SHELL) {
-  Module['print'] = print;
-  if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
-  if (typeof read != 'undefined') {
-    Module['read'] = read;
-  } else {
-    Module['read'] = function read() { throw 'no read() available (jsc?)' };
-  }
-  Module['readBinary'] = function readBinary(f) {
-    return read(f, 'binary');
-  };
-  if (typeof scriptArgs != 'undefined') {
-    Module['arguments'] = scriptArgs;
-  } else if (typeof arguments != 'undefined') {
-    Module['arguments'] = arguments;
-  }
-  this['Module'] = Module;
-  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)
-}
-else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
-  Module['read'] = function read(url) {
-    var xhr = new XMLHttpRequest();
-    xhr.open('GET', url, false);
-    xhr.send(null);
-    return xhr.responseText;
-  };
-  if (typeof arguments != 'undefined') {
-    Module['arguments'] = arguments;
-  }
-  if (typeof console !== 'undefined') {
-    Module['print'] = function print(x) {
-      console.log(x);
-    };
-    Module['printErr'] = function printErr(x) {
-      console.log(x);
-    };
-  } else {
-    // Probably a worker, and without console.log. We can do very little here...
-    var TRY_USE_DUMP = false;
-    Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
-      dump(x);
-    }) : (function(x) {
-      // self.postMessage(x); // enable this if you want stdout to be sent as messages
-    }));
-  }
-  if (ENVIRONMENT_IS_WEB) {
-    this['Module'] = Module;
-  } else {
-    Module['load'] = importScripts;
-  }
-}
-else {
-  // Unreachable because SHELL is dependant on the others
-  throw 'Unknown runtime environment. Where are we?';
-}
-function globalEval(x) {
-  eval.call(null, x);
-}
-if (!Module['load'] == 'undefined' && Module['read']) {
-  Module['load'] = function load(f) {
-    globalEval(Module['read'](f));
-  };
-}
-if (!Module['print']) {
-  Module['print'] = function(){};
-}
-if (!Module['printErr']) {
-  Module['printErr'] = Module['print'];
-}
-if (!Module['arguments']) {
-  Module['arguments'] = [];
-}
-// *** Environment setup code ***
-// Closure helpers
-Module.print = Module['print'];
-Module.printErr = Module['printErr'];
-// Callbacks
-Module['preRun'] = [];
-Module['postRun'] = [];
-// Merge back in the overrides
-for (var key in moduleOverrides) {
-  if (moduleOverrides.hasOwnProperty(key)) {
-    Module[key] = moduleOverrides[key];
-  }
-}
-// === Auto-generated preamble library stuff ===
-//========================================
-// Runtime code shared with compiler
-//========================================
-var Runtime = {
-  stackSave: function () {
-    return STACKTOP;
-  },
-  stackRestore: function (stackTop) {
-    STACKTOP = stackTop;
-  },
-  forceAlign: function (target, quantum) {
-    quantum = quantum || 4;
-    if (quantum == 1) return target;
-    if (isNumber(target) && isNumber(quantum)) {
-      return Math.ceil(target/quantum)*quantum;
-    } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
-      return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
-    }
-    return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
-  },
-  isNumberType: function (type) {
-    return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
-  },
-  isPointerType: function isPointerType(type) {
-  return type[type.length-1] == '*';
-},
-  isStructType: function isStructType(type) {
-  if (isPointerType(type)) return false;
-  if (isArrayType(type)) return true;
-  if (/<?{ ?[^}]* ?}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
-  // See comment in isStructPointerType()
-  return type[0] == '%';
-},
-  INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
-  FLOAT_TYPES: {"float":0,"double":0},
-  or64: function (x, y) {
-    var l = (x | 0) | (y | 0);
-    var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
-    return l + h;
-  },
-  and64: function (x, y) {
-    var l = (x | 0) & (y | 0);
-    var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
-    return l + h;
-  },
-  xor64: function (x, y) {
-    var l = (x | 0) ^ (y | 0);
-    var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
-    return l + h;
-  },
-  getNativeTypeSize: function (type) {
-    switch (type) {
-      case 'i1': case 'i8': return 1;
-      case 'i16': return 2;
-      case 'i32': return 4;
-      case 'i64': return 8;
-      case 'float': return 4;
-      case 'double': return 8;
-      default: {
-        if (type[type.length-1] === '*') {
-          return Runtime.QUANTUM_SIZE; // A pointer
-        } else if (type[0] === 'i') {
-          var bits = parseInt(type.substr(1));
-          assert(bits % 8 === 0);
-          return bits/8;
-        } else {
-          return 0;
-        }
-      }
-    }
-  },
-  getNativeFieldSize: function (type) {
-    return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
-  },
-  dedup: function dedup(items, ident) {
-  var seen = {};
-  if (ident) {
-    return items.filter(function(item) {
-      if (seen[item[ident]]) return false;
-      seen[item[ident]] = true;
-      return true;
-    });
-  } else {
-    return items.filter(function(item) {
-      if (seen[item]) return false;
-      seen[item] = true;
-      return true;
-    });
-  }
-},
-  set: function set() {
-  var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
-  var ret = {};
-  for (var i = 0; i < args.length; i++) {
-    ret[args[i]] = 0;
-  }
-  return ret;
-},
-  STACK_ALIGN: 8,
-  getAlignSize: function (type, size, vararg) {
-    // we align i64s and doubles on 64-bit boundaries, unlike x86
-    if (vararg) return 8;
-    if (!vararg && (type == 'i64' || type == 'double')) return 8;
-    if (!type) return Math.min(size, 8); // align structures internally to 64 bits
-    return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
-  },
-  calculateStructAlignment: function calculateStructAlignment(type) {
-    type.flatSize = 0;
-    type.alignSize = 0;
-    var diffs = [];
-    var prev = -1;
-    var index = 0;
-    type.flatIndexes = type.fields.map(function(field) {
-      index++;
-      var size, alignSize;
-      if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
-        size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
-        alignSize = Runtime.getAlignSize(field, size);
-      } else if (Runtime.isStructType(field)) {
-        if (field[1] === '0') {
-          // this is [0 x something]. When inside another structure like here, it must be at the end,
-          // and it adds no size
-          // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
-          size = 0;
-          if (Types.types[field]) {
-            alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
-          } else {
-            alignSize = type.alignSize || QUANTUM_SIZE;
-          }
-        } else {
-          size = Types.types[field].flatSize;
-          alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
-        }
-      } else if (field[0] == 'b') {
-        // bN, large number field, like a [N x i8]
-        size = field.substr(1)|0;
-        alignSize = 1;
-      } else if (field[0] === '<') {
-        // vector type
-        size = alignSize = Types.types[field].flatSize; // fully aligned
-      } else if (field[0] === 'i') {
-        // illegal integer field, that could not be legalized because it is an internal structure field
-        // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
-        size = alignSize = parseInt(field.substr(1))/8;
-        assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
-      } else {
-        assert(false, 'invalid type for calculateStructAlignment');
-      }
-      if (type.packed) alignSize = 1;
-      type.alignSize = Math.max(type.alignSize, alignSize);
-      var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
-      type.flatSize = curr + size;
-      if (prev >= 0) {
-        diffs.push(curr-prev);
-      }
-      prev = curr;
-      return curr;
-    });
-    if (type.name_ && type.name_[0] === '[') {
-      // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
-      // allocating a potentially huge array for [999999 x i8] etc.
-      type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
-    }
-    type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
-    if (diffs.length == 0) {
-      type.flatFactor = type.flatSize;
-    } else if (Runtime.dedup(diffs).length == 1) {
-      type.flatFactor = diffs[0];
-    }
-    type.needsFlattening = (type.flatFactor != 1);
-    return type.flatIndexes;
-  },
-  generateStructInfo: function (struct, typeName, offset) {
-    var type, alignment;
-    if (typeName) {
-      offset = offset || 0;
-      type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
-      if (!type) return null;
-      if (type.fields.length != struct.length) {
-        printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
-        return null;
-      }
-      alignment = type.flatIndexes;
-    } else {
-      var type = { fields: struct.map(function(item) { return item[0] }) };
-      alignment = Runtime.calculateStructAlignment(type);
-    }
-    var ret = {
-      __size__: type.flatSize
-    };
-    if (typeName) {
-      struct.forEach(function(item, i) {
-        if (typeof item === 'string') {
-          ret[item] = alignment[i] + offset;
-        } else {
-          // embedded struct
-          var key;
-          for (var k in item) key = k;
-          ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
-        }
-      });
-    } else {
-      struct.forEach(function(item, i) {
-        ret[item[1]] = alignment[i];
-      });
-    }
-    return ret;
-  },
-  dynCall: function (sig, ptr, args) {
-    if (args && args.length) {
-      if (!args.splice) args = Array.prototype.slice.call(args);
-      args.splice(0, 0, ptr);
-      return Module['dynCall_' + sig].apply(null, args);
-    } else {
-      return Module['dynCall_' + sig].call(null, ptr);
-    }
-  },
-  functionPointers: [],
-  addFunction: function (func) {
-    for (var i = 0; i < Runtime.functionPointers.length; i++) {
-      if (!Runtime.functionPointers[i]) {
-        Runtime.functionPointers[i] = func;
-        return 2*(1 + i);
-      }
-    }
-    throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
-  },
-  removeFunction: function (index) {
-    Runtime.functionPointers[(index-2)/2] = null;
-  },
-  getAsmConst: function (code, numArgs) {
-    // code is a constant string on the heap, so we can cache these
-    if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
-    var func = Runtime.asmConstCache[code];
-    if (func) return func;
-    var args = [];
-    for (var i = 0; i < numArgs; i++) {
-      args.push(String.fromCharCode(36) + i); // $0, $1 etc
-    }
-    return Runtime.asmConstCache[code] = eval('(function(' + args.join(',') + '){ ' + Pointer_stringify(code) + ' })'); // new Function does not allow upvars in node
-  },
-  warnOnce: function (text) {
-    if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
-    if (!Runtime.warnOnce.shown[text]) {
-      Runtime.warnOnce.shown[text] = 1;
-      Module.printErr(text);
-    }
-  },
-  funcWrappers: {},
-  getFuncWrapper: function (func, sig) {
-    assert(sig);
-    if (!Runtime.funcWrappers[func]) {
-      Runtime.funcWrappers[func] = function dynCall_wrapper() {
-        return Runtime.dynCall(sig, func, arguments);
-      };
-    }
-    return Runtime.funcWrappers[func];
-  },
-  UTF8Processor: function () {
-    var buffer = [];
-    var needed = 0;
-    this.processCChar = function (code) {
-      code = code & 0xFF;
-      if (buffer.length == 0) {
-        if ((code & 0x80) == 0x00) {        // 0xxxxxxx
-          return String.fromCharCode(code);
-        }
-        buffer.push(code);
-        if ((code & 0xE0) == 0xC0) {        // 110xxxxx
-          needed = 1;
-        } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
-          needed = 2;
-        } else {                            // 11110xxx
-          needed = 3;
-        }
-        return '';
-      }
-      if (needed) {
-        buffer.push(code);
-        needed--;
-        if (needed > 0) return '';
-      }
-      var c1 = buffer[0];
-      var c2 = buffer[1];
-      var c3 = buffer[2];
-      var c4 = buffer[3];
-      var ret;
-      if (buffer.length == 2) {
-        ret = String.fromCharCode(((c1 & 0x1F) << 6)  | (c2 & 0x3F));
-      } else if (buffer.length == 3) {
-        ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6)  | (c3 & 0x3F));
-      } else {
-        // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
-        var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
-                        ((c3 & 0x3F) << 6)  | (c4 & 0x3F);
-        ret = String.fromCharCode(
-          Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
-          (codePoint - 0x10000) % 0x400 + 0xDC00);
-      }
-      buffer.length = 0;
-      return ret;
-    }
-    this.processJSString = function processJSString(string) {
-      string = unescape(encodeURIComponent(string));
-      var ret = [];
-      for (var i = 0; i < string.length; i++) {
-        ret.push(string.charCodeAt(i));
-      }
-      return ret;
-    }
-  },
-  stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
-  staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
-  dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
-  alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
-  makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
-  GLOBAL_BASE: 8,
-  QUANTUM_SIZE: 4,
-  __dummy__: 0
-}
-//========================================
-// Runtime essentials
-//========================================
-var __THREW__ = 0; // Used in checking for thrown exceptions.
-var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
-var EXITSTATUS = 0;
-var undef = 0;
-// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
-// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
-var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
-var tempI64, tempI64b;
-var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
-function assert(condition, text) {
-  if (!condition) {
-    abort('Assertion failed: ' + text);
-  }
-}
-var globalScope = this;
-// C calling interface. A convenient way to call C functions (in C files, or
-// defined with extern "C").
-//
-// Note: LLVM optimizations can inline and remove functions, after which you will not be
-//       able to call them. Closure can also do so. To avoid that, add your function to
-//       the exports using something like
-//
-//         -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
-//
-// @param ident      The name of the C function (note that C++ functions will be name-mangled - use extern "C")
-// @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
-//                   'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
-// @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,
-//                   except that 'array' is not possible (there is no way for us to know the length of the array)
-// @param args       An array of the arguments to the function, as native JS values (as in returnType)
-//                   Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
-// @return           The return value, as a native JS value (as in returnType)
-function ccall(ident, returnType, argTypes, args) {
-  return ccallFunc(getCFunc(ident), returnType, argTypes, args);
-}
-Module["ccall"] = ccall;
-// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
-function getCFunc(ident) {
-  try {
-    var func = Module['_' + ident]; // closure exported function
-    if (!func) func = eval('_' + ident); // explicit lookup
-  } catch(e) {
-  }
-  assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
-  return func;
-}
-// Internal function that does a C call using a function, not an identifier
-function ccallFunc(func, returnType, argTypes, args) {
-  var stack = 0;
-  function toC(value, type) {
-    if (type == 'string') {
-      if (value === null || value === undefined || value === 0) return 0; // null string
-      value = intArrayFromString(value);
-      type = 'array';
-    }
-    if (type == 'array') {
-      if (!stack) stack = Runtime.stackSave();
-      var ret = Runtime.stackAlloc(value.length);
-      writeArrayToMemory(value, ret);
-      return ret;
-    }
-    return value;
-  }
-  function fromC(value, type) {
-    if (type == 'string') {
-      return Pointer_stringify(value);
-    }
-    assert(type != 'array');
-    return value;
-  }
-  var i = 0;
-  var cArgs = args ? args.map(function(arg) {
-    return toC(arg, argTypes[i++]);
-  }) : [];
-  var ret = fromC(func.apply(null, cArgs), returnType);
-  if (stack) Runtime.stackRestore(stack);
-  return ret;
-}
-// Returns a native JS wrapper for a C function. This is similar to ccall, but
-// returns a function you can call repeatedly in a normal way. For example:
-//
-//   var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
-//   alert(my_function(5, 22));
-//   alert(my_function(99, 12));
-//
-function cwrap(ident, returnType, argTypes) {
-  var func = getCFunc(ident);
-  return function() {
-    return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
-  }
-}
-Module["cwrap"] = cwrap;
-// Sets a value in memory in a dynamic way at run-time. Uses the
-// type data. This is the same as makeSetValue, except that
-// makeSetValue is done at compile-time and generates the needed
-// code then, whereas this function picks the right code at
-// run-time.
-// Note that setValue and getValue only do *aligned* writes and reads!
-// Note that ccall uses JS types as for defining types, while setValue and
-// getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
-function setValue(ptr, value, type, noSafe) {
-  type = type || 'i8';
-  if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
-    switch(type) {
-      case 'i1': HEAP8[(ptr)]=value; break;
-      case 'i8': HEAP8[(ptr)]=value; break;
-      case 'i16': HEAP16[((ptr)>>1)]=value; break;
-      case 'i32': HEAP32[((ptr)>>2)]=value; break;
-      case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
-      case 'float': HEAPF32[((ptr)>>2)]=value; break;
-      case 'double': HEAPF64[((ptr)>>3)]=value; break;
-      default: abort('invalid type for setValue: ' + type);
-    }
-}
-Module['setValue'] = setValue;
-// Parallel to setValue.
-function getValue(ptr, type, noSafe) {
-  type = type || 'i8';
-  if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
-    switch(type) {
-      case 'i1': return HEAP8[(ptr)];
-      case 'i8': return HEAP8[(ptr)];
-      case 'i16': return HEAP16[((ptr)>>1)];
-      case 'i32': return HEAP32[((ptr)>>2)];
-      case 'i64': return HEAP32[((ptr)>>2)];
-      case 'float': return HEAPF32[((ptr)>>2)];
-      case 'double': return HEAPF64[((ptr)>>3)];
-      default: abort('invalid type for setValue: ' + type);
-    }
-  return null;
-}
-Module['getValue'] = getValue;
-var ALLOC_NORMAL = 0; // Tries to use _malloc()
-var ALLOC_STACK = 1; // Lives for the duration of the current function call
-var ALLOC_STATIC = 2; // Cannot be freed
-var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
-var ALLOC_NONE = 4; // Do not allocate
-Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
-Module['ALLOC_STACK'] = ALLOC_STACK;
-Module['ALLOC_STATIC'] = ALLOC_STATIC;
-Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
-Module['ALLOC_NONE'] = ALLOC_NONE;
-// allocate(): This is for internal use. You can use it yourself as well, but the interface
-//             is a little tricky (see docs right below). The reason is that it is optimized
-//             for multiple syntaxes to save space in generated code. So you should
-//             normally not use allocate(), and instead allocate memory using _malloc(),
-//             initialize it with setValue(), and so forth.
-// @slab: An array of data, or a number. If a number, then the size of the block to allocate,
-//        in *bytes* (note that this is sometimes confusing: the next parameter does not
-//        affect this!)
-// @types: Either an array of types, one for each byte (or 0 if no type at that position),
-//         or a single type which is used for the entire block. This only matters if there
-//         is initial data - if @slab is a number, then this does not matter at all and is
-//         ignored.
-// @allocator: How to allocate memory, see ALLOC_*
-function allocate(slab, types, allocator, ptr) {
-  var zeroinit, size;
-  if (typeof slab === 'number') {
-    zeroinit = true;
-    size = slab;
-  } else {
-    zeroinit = false;
-    size = slab.length;
-  }
-  var singleType = typeof types === 'string' ? types : null;
-  var ret;
-  if (allocator == ALLOC_NONE) {
-    ret = ptr;
-  } else {
-    ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
-  }
-  if (zeroinit) {
-    var ptr = ret, stop;
-    assert((ret & 3) == 0);
-    stop = ret + (size & ~3);
-    for (; ptr < stop; ptr += 4) {
-      HEAP32[((ptr)>>2)]=0;
-    }
-    stop = ret + size;
-    while (ptr < stop) {
-      HEAP8[((ptr++)|0)]=0;
-    }
-    return ret;
-  }
-  if (singleType === 'i8') {
-    if (slab.subarray || slab.slice) {
-      HEAPU8.set(slab, ret);
-    } else {
-      HEAPU8.set(new Uint8Array(slab), ret);
-    }
-    return ret;
-  }
-  var i = 0, type, typeSize, previousType;
-  while (i < size) {
-    var curr = slab[i];
-    if (typeof curr === 'function') {
-      curr = Runtime.getFunctionIndex(curr);
-    }
-    type = singleType || types[i];
-    if (type === 0) {
-      i++;
-      continue;
-    }
-    if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
-    setValue(ret+i, curr, type);
-    // no need to look up size unless type changes, so cache it
-    if (previousType !== type) {
-      typeSize = Runtime.getNativeTypeSize(type);
-      previousType = type;
-    }
-    i += typeSize;
-  }
-  return ret;
-}
-Module['allocate'] = allocate;
-function Pointer_stringify(ptr, /* optional */ length) {
-  // TODO: use TextDecoder
-  // Find the length, and check for UTF while doing so
-  var hasUtf = false;
-  var t;
-  var i = 0;
-  while (1) {
-    t = HEAPU8[(((ptr)+(i))|0)];
-    if (t >= 128) hasUtf = true;
-    else if (t == 0 && !length) break;
-    i++;
-    if (length && i == length) break;
-  }
-  if (!length) length = i;
-  var ret = '';
-  if (!hasUtf) {
-    var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
-    var curr;
-    while (length > 0) {
-      curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
-      ret = ret ? ret + curr : curr;
-      ptr += MAX_CHUNK;
-      length -= MAX_CHUNK;
-    }
-    return ret;
-  }
-  var utf8 = new Runtime.UTF8Processor();
-  for (i = 0; i < length; i++) {
-    t = HEAPU8[(((ptr)+(i))|0)];
-    ret += utf8.processCChar(t);
-  }
-  return ret;
-}
-Module['Pointer_stringify'] = Pointer_stringify;
-// Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
-// a copy of that string as a Javascript String object.
-function UTF16ToString(ptr) {
-  var i = 0;
-  var str = '';
-  while (1) {
-    var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
-    if (codeUnit == 0)
-      return str;
-    ++i;
-    // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
-    str += String.fromCharCode(codeUnit);
-  }
-}
-Module['UTF16ToString'] = UTF16ToString;
-// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
-// null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
-function stringToUTF16(str, outPtr) {
-  for(var i = 0; i < str.length; ++i) {
-    // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
-    var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
-    HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
-  }
-  // Null-terminate the pointer to the HEAP.
-  HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
-}
-Module['stringToUTF16'] = stringToUTF16;
-// Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
-// a copy of that string as a Javascript String object.
-function UTF32ToString(ptr) {
-  var i = 0;
-  var str = '';
-  while (1) {
-    var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
-    if (utf32 == 0)
-      return str;
-    ++i;
-    // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
-    if (utf32 >= 0x10000) {
-      var ch = utf32 - 0x10000;
-      str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
-    } else {
-      str += String.fromCharCode(utf32);
-    }
-  }
-}
-Module['UTF32ToString'] = UTF32ToString;
-// Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
-// null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
-// 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.
-function stringToUTF32(str, outPtr) {
-  var iChar = 0;
-  for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
-    // 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.
-    var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
-    if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
-      var trailSurrogate = str.charCodeAt(++iCodeUnit);
-      codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
-    }
-    HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
-    ++iChar;
-  }
-  // Null-terminate the pointer to the HEAP.
-  HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
-}
-Module['stringToUTF32'] = stringToUTF32;
-function demangle(func) {
-  try {
-    // Special-case the entry point, since its name differs from other name mangling.
-    if (func == 'Object._main' || func == '_main') {
-      return 'main()';
-    }
-    if (typeof func === 'number') func = Pointer_stringify(func);
-    if (func[0] !== '_') return func;
-    if (func[1] !== '_') return func; // C function
-    if (func[2] !== 'Z') return func;
-    switch (func[3]) {
-      case 'n': return 'operator new()';
-      case 'd': return 'operator delete()';
-    }
-    var i = 3;
-    // params, etc.
-    var basicTypes = {
-      'v': 'void',
-      'b': 'bool',
-      'c': 'char',
-      's': 'short',
-      'i': 'int',
-      'l': 'long',
-      'f': 'float',
-      'd': 'double',
-      'w': 'wchar_t',
-      'a': 'signed char',
-      'h': 'unsigned char',
-      't': 'unsigned short',
-      'j': 'unsigned int',
-      'm': 'unsigned long',
-      'x': 'long long',
-      'y': 'unsigned long long',
-      'z': '...'
-    };
-    function dump(x) {
-      //return;
-      if (x) Module.print(x);
-      Module.print(func);
-      var pre = '';
-      for (var a = 0; a < i; a++) pre += ' ';
-      Module.print (pre + '^');
-    }
-    var subs = [];
-    function parseNested() {
-      i++;
-      if (func[i] === 'K') i++; // ignore const
-      var parts = [];
-      while (func[i] !== 'E') {
-        if (func[i] === 'S') { // substitution
-          i++;
-          var next = func.indexOf('_', i);
-          var num = func.substring(i, next) || 0;
-          parts.push(subs[num] || '?');
-          i = next+1;
-          continue;
-        }
-        if (func[i] === 'C') { // constructor
-          parts.push(parts[parts.length-1]);
-          i += 2;
-          continue;
-        }
-        var size = parseInt(func.substr(i));
-        var pre = size.toString().length;
-        if (!size || !pre) { i--; break; } // counter i++ below us
-        var curr = func.substr(i + pre, size);
-        parts.push(curr);
-        subs.push(curr);
-        i += pre + size;
-      }
-      i++; // skip E
-      return parts;
-    }
-    var first = true;
-    function parse(rawList, limit, allowVoid) { // main parser
-      limit = limit || Infinity;
-      var ret = '', list = [];
-      function flushList() {
-        return '(' + list.join(', ') + ')';
-      }
-      var name;
-      if (func[i] === 'N') {
-        // namespaced N-E
-        name = parseNested().join('::');
-        limit--;
-        if (limit === 0) return rawList ? [name] : name;
-      } else {
-        // not namespaced
-        if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
-        var size = parseInt(func.substr(i));
-        if (size) {
-          var pre = size.toString().length;
-          name = func.substr(i + pre, size);
-          i += pre + size;
-        }
-      }
-      first = false;
-      if (func[i] === 'I') {
-        i++;
-        var iList = parse(true);
-        var iRet = parse(true, 1, true);
-        ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
-      } else {
-        ret = name;
-      }
-      paramLoop: while (i < func.length && limit-- > 0) {
-        //dump('paramLoop');
-        var c = func[i++];
-        if (c in basicTypes) {
-          list.push(basicTypes[c]);
-        } else {
-          switch (c) {
-            case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
-            case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
-            case 'L': { // literal
-              i++; // skip basic type
-              var end = func.indexOf('E', i);
-              var size = end - i;
-              list.push(func.substr(i, size));
-              i += size + 2; // size + 'EE'
-              break;
-            }
-            case 'A': { // array
-              var size = parseInt(func.substr(i));
-              i += size.toString().length;
-              if (func[i] !== '_') throw '?';
-              i++; // skip _
-              list.push(parse(true, 1, true)[0] + ' [' + size + ']');
-              break;
-            }
-            case 'E': break paramLoop;
-            default: ret += '?' + c; break paramLoop;
-          }
-        }
-      }
-      if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
-      return rawList ? list : ret + flushList();
-    }
-    return parse();
-  } catch(e) {
-    return func;
-  }
-}
-function demangleAll(text) {
-  return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
-}
-function stackTrace() {
-  var stack = new Error().stack;
-  return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
-}
-// Memory management
-var PAGE_SIZE = 4096;
-function alignMemoryPage(x) {
-  return (x+4095)&-4096;
-}
-var HEAP;
-var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
-var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
-var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
-var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
-function enlargeMemory() {
-  abort('Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', or (2) set Module.TOTAL_MEMORY before the program runs.');
-}
-var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
-var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 268435456;
-var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
-var totalMemory = 4096;
-while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
-  if (totalMemory < 16*1024*1024) {
-    totalMemory *= 2;
-  } else {
-    totalMemory += 16*1024*1024
-  }
-}
-if (totalMemory !== TOTAL_MEMORY) {
-  Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
-  TOTAL_MEMORY = totalMemory;
-}
-// Initialize the runtime's memory
-// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
-assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
-       'Cannot fallback to non-typed array case: Code is too specialized');
-var buffer = new ArrayBuffer(TOTAL_MEMORY);
-HEAP8 = new Int8Array(buffer);
-HEAP16 = new Int16Array(buffer);
-HEAP32 = new Int32Array(buffer);
-HEAPU8 = new Uint8Array(buffer);
-HEAPU16 = new Uint16Array(buffer);
-HEAPU32 = new Uint32Array(buffer);
-HEAPF32 = new Float32Array(buffer);
-HEAPF64 = new Float64Array(buffer);
-// Endianness check (note: assumes compiler arch was little-endian)
-HEAP32[0] = 255;
-assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
-Module['HEAP'] = HEAP;
-Module['HEAP8'] = HEAP8;
-Module['HEAP16'] = HEAP16;
-Module['HEAP32'] = HEAP32;
-Module['HEAPU8'] = HEAPU8;
-Module['HEAPU16'] = HEAPU16;
-Module['HEAPU32'] = HEAPU32;
-Module['HEAPF32'] = HEAPF32;
-Module['HEAPF64'] = HEAPF64;
-function callRuntimeCallbacks(callbacks) {
-  while(callbacks.length > 0) {
-    var callback = callbacks.shift();
-    if (typeof callback == 'function') {
-      callback();
-      continue;
-    }
-    var func = callback.func;
-    if (typeof func === 'number') {
-      if (callback.arg === undefined) {
-        Runtime.dynCall('v', func);
-      } else {
-        Runtime.dynCall('vi', func, [callback.arg]);
-      }
-    } else {
-      func(callback.arg === undefined ? null : callback.arg);
-    }
-  }
-}
-var __ATPRERUN__  = []; // functions called before the runtime is initialized
-var __ATINIT__    = []; // functions called during startup
-var __ATMAIN__    = []; // functions called when main() is to be run
-var __ATEXIT__    = []; // functions called during shutdown
-var __ATPOSTRUN__ = []; // functions called after the runtime has exited
-var runtimeInitialized = false;
-function preRun() {
-  // compatibility - merge in anything from Module['preRun'] at this time
-  if (Module['preRun']) {
-    if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
-    while (Module['preRun'].length) {
-      addOnPreRun(Module['preRun'].shift());
-    }
-  }
-  callRuntimeCallbacks(__ATPRERUN__);
-}
-function ensureInitRuntime() {
-  if (runtimeInitialized) return;
-  runtimeInitialized = true;
-  callRuntimeCallbacks(__ATINIT__);
-}
-function preMain() {
-  callRuntimeCallbacks(__ATMAIN__);
-}
-function exitRuntime() {
-  callRuntimeCallbacks(__ATEXIT__);
-}
-function postRun() {
-  // compatibility - merge in anything from Module['postRun'] at this time
-  if (Module['postRun']) {
-    if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
-    while (Module['postRun'].length) {
-      addOnPostRun(Module['postRun'].shift());
-    }
-  }
-  callRuntimeCallbacks(__ATPOSTRUN__);
-}
-function addOnPreRun(cb) {
-  __ATPRERUN__.unshift(cb);
-}
-Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
-function addOnInit(cb) {
-  __ATINIT__.unshift(cb);
-}
-Module['addOnInit'] = Module.addOnInit = addOnInit;
-function addOnPreMain(cb) {
-  __ATMAIN__.unshift(cb);
-}
-Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
-function addOnExit(cb) {
-  __ATEXIT__.unshift(cb);
-}
-Module['addOnExit'] = Module.addOnExit = addOnExit;
-function addOnPostRun(cb) {
-  __ATPOSTRUN__.unshift(cb);
-}
-Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
-// Tools
-// This processes a JS string into a C-line array of numbers, 0-terminated.
-// For LLVM-originating strings, see parser.js:parseLLVMString function
-function intArrayFromString(stringy, dontAddNull, length /* optional */) {
-  var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
-  if (length) {
-    ret.length = length;
-  }
-  if (!dontAddNull) {
-    ret.push(0);
-  }
-  return ret;
-}
-Module['intArrayFromString'] = intArrayFromString;
-function intArrayToString(array) {
-  var ret = [];
-  for (var i = 0; i < array.length; i++) {
-    var chr = array[i];
-    if (chr > 0xFF) {
-      chr &= 0xFF;
-    }
-    ret.push(String.fromCharCode(chr));
-  }
-  return ret.join('');
-}
-Module['intArrayToString'] = intArrayToString;
-// Write a Javascript array to somewhere in the heap
-function writeStringToMemory(string, buffer, dontAddNull) {
-  var array = intArrayFromString(string, dontAddNull);
-  var i = 0;
-  while (i < array.length) {
-    var chr = array[i];
-    HEAP8[(((buffer)+(i))|0)]=chr;
-    i = i + 1;
-  }
-}
-Module['writeStringToMemory'] = writeStringToMemory;
-function writeArrayToMemory(array, buffer) {
-  for (var i = 0; i < array.length; i++) {
-    HEAP8[(((buffer)+(i))|0)]=array[i];
-  }
-}
-Module['writeArrayToMemory'] = writeArrayToMemory;
-function writeAsciiToMemory(str, buffer, dontAddNull) {
-  for (var i = 0; i < str.length; i++) {
-    HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
-  }
-  if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
-}
-Module['writeAsciiToMemory'] = writeAsciiToMemory;
-function unSign(value, bits, ignore, sig) {
-  if (value >= 0) {
-    return value;
-  }
-  return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
-                    : Math.pow(2, bits)         + value;
-}
-function reSign(value, bits, ignore, sig) {
-  if (value <= 0) {
-    return value;
-  }
-  var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
-                        : Math.pow(2, bits-1);
-  if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
-                                                       // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
-                                                       // TODO: In i64 mode 1, resign the two parts separately and safely
-    value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
-  }
-  return value;
-}
-if (!Math['imul']) Math['imul'] = function imul(a, b) {
-  var ah  = a >>> 16;
-  var al = a & 0xffff;
-  var bh  = b >>> 16;
-  var bl = b & 0xffff;
-  return (al*bl + ((ah*bl + al*bh) << 16))|0;
-};
-Math.imul = Math['imul'];
-var Math_abs = Math.abs;
-var Math_cos = Math.cos;
-var Math_sin = Math.sin;
-var Math_tan = Math.tan;
-var Math_acos = Math.acos;
-var Math_asin = Math.asin;
-var Math_atan = Math.atan;
-var Math_atan2 = Math.atan2;
-var Math_exp = Math.exp;
-var Math_log = Math.log;
-var Math_sqrt = Math.sqrt;
-var Math_ceil = Math.ceil;
-var Math_floor = Math.floor;
-var Math_pow = Math.pow;
-var Math_imul = Math.imul;
-var Math_fround = Math.fround;
-var Math_min = Math.min;
-// A counter of dependencies for calling run(). If we need to
-// do asynchronous work before running, increment this and
-// decrement it. Incrementing must happen in a place like
-// PRE_RUN_ADDITIONS (used by emcc to add file preloading).
-// Note that you can add dependencies in preRun, even though
-// it happens right before run - run will be postponed until
-// the dependencies are met.
-var runDependencies = 0;
-var runDependencyWatcher = null;
-var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
-function addRunDependency(id) {
-  runDependencies++;
-  if (Module['monitorRunDependencies']) {
-    Module['monitorRunDependencies'](runDependencies);
-  }
-}
-Module['addRunDependency'] = addRunDependency;
-function removeRunDependency(id) {
-  runDependencies--;
-  if (Module['monitorRunDependencies']) {
-    Module['monitorRunDependencies'](runDependencies);
-  }
-  if (runDependencies == 0) {
-    if (runDependencyWatcher !== null) {
-      clearInterval(runDependencyWatcher);
-      runDependencyWatcher = null;
-    }
-    if (dependenciesFulfilled) {
-      var callback = dependenciesFulfilled;
-      dependenciesFulfilled = null;
-      callback(); // can add another dependenciesFulfilled
-    }
-  }
-}
-Module['removeRunDependency'] = removeRunDependency;
-Module["preloadedImages"] = {}; // maps url to image data
-Module["preloadedAudios"] = {}; // maps url to audio data
-var memoryInitializer = null;
-// === Body ===
-STATIC_BASE = 8;
-STATICTOP = STATIC_BASE + 7624;
-/* global initializers */ __ATINIT__.push({ func: function() { runPostSets() } });
-/* memory initializer */ allocate([22,6,117,117,36,36,36,36,83,83,83,83,83,83,83,83,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,134,6,37,37,20,20,20,20,115,115,115,115,115,115,115,115,99,99,99,99,99,99,99,99,51,51,51,51,51,51,51,51,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,150,6,21,21,116,116,116,116,131,131,131,131,131,131,131,131,99,99,99,99,99,99,99,99,67,67,67,67,67,67,67,67,51,51,51,51,51,51,51,51,35,35,35,35,35,35,35,35,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,166,6,21,21,132,132,132,132,147,147,147,147,147,147,147,147,115,115,115,115,115,115,115,115,99,99,99,99,99,99,99,99,83,83,83,83,83,83,83,83,67,67,67,67,67,67,67,67,51,51,51,51,51,51,51,51,35,35,35,35,35,35,35,35,181,149,164,164,132,132,36,36,20,20,4,4,115,115,115,115,99,99,99,99,83,83,83,83,67,67,67,67,51,51,51,51,197,181,165,5,148,148,116,116,52,52,36,36,131,131,131,131,99,99,99,99,83,83,83,83,67,67,67,67,19,19,19,19,214,182,197,197,165,165,149,149,132,132,132,132,84,84,84,84,68,68,68,68,4,4,4,4,115,115,115,115,115,115,115,115,99,99,99,99,99,99,99,99,51,51,51,51,51,51,51,51,35,35,35,35,35,35,35,35,19,19,19,19,19,19,19,19,230,214,198,182,165,165,149,149,132,132,132,132,116,116,116,116,100,100,100,100,84,84,84,84,67,67,67,67,67,67,67,67,51,51,51,51,51,51,51,51,35,35,35,35,35,35,35,35,19,19,19,19,19,19,19,19,3,3,3,3,3,3,3,3,0,249,233,217,200,200,184,184,167,167,167,167,151,151,151,151,134,134,134,134,134,134,134,134,118,118,118,118,118,118,118,118,0,0,101,85,68,68,52,52,35,35,35,35,19,19,19,19,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,18,33,33,0,0,0,0,3,19,50,50,33,33,33,33,4,20,67,67,34,34,34,34,49,49,49,49,49,49,49,49,4,20,35,35,51,51,83,83,65,65,65,65,65,65,65,65,21,5,100,100,35,35,35,35,82,82,82,82,82,82,82,82,66,66,66,66,66,66,66,66,50,50,50,50,50,50,50,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,1,0,0,1,0,0,1,0,0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,2,1,1,2,1,2,3,1,2,3,2,2,3,2,2,4,2,3,4,2,3,4,3,3,5,3,4,6,3,4,6,4,5,7,4,5,8,4,6,9,5,7,10,6,8,11,6,8,13,7,10,14,8,11,16,9,12,18,10,13,20,11,15,23,13,17,25,0,0,0,0,1,0,0,0,2,0,0,0,4,0,0,0,8,0,0,0,16,0,0,0,32,0,0,0,64,0,0,0,128,0,0,0,19,35,67,51,99,83,2,2,83,67,51,35,18,18,2,2,67,51,34,34,18,18,2,2,50,34,18,2,0,0,0,0,34,18,1,1,0,0,0,0,17,1,0,0,0,0,0,0,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,8,8,8,0,0,0,0,0,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,12,0,0,0,13,0,0,0,14,0,0,0,15,0,0,0,10,0,0,0,13,0,0,0,16,0,0,0,11,0,0,0,14,0,0,0,18,0,0,0,13,0,0,0,16,0,0,0,20,0,0,0,14,0,0,0,18,0,0,0,23,0,0,0,16,0,0,0,20,0,0,0,25,0,0,0,18,0,0,0,23,0,0,0,29,0,0,0,0,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,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,23,0,0,0,24,0,0,0,25,0,0,0,26,0,0,0,27,0,0,0,28,0,0,0,29,0,0,0,29,0,0,0,30,0,0,0,31,0,0,0,32,0,0,0,32,0,0,0,33,0,0,0,34,0,0,0,34,0,0,0,35,0,0,0,35,0,0,0,36,0,0,0,36,0,0,0,37,0,0,0,37,0,0,0,37,0,0,0,38,0,0,0,38,0,0,0,38,0,0,0,39,0,0,0,39,0,0,0,39,0,0,0,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
\ No newline at end of file
-var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
-assert(tempDoublePtr % 8 == 0);
-function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
-  HEAP8[tempDoublePtr] = HEAP8[ptr];
-  HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
-  HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
-  HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
-}
-function copyTempDouble(ptr) {
-  HEAP8[tempDoublePtr] = HEAP8[ptr];
-  HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
-  HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
-  HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
-  HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
-  HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
-  HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
-  HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
-}
-  Module["_memset"] = _memset;var _llvm_memset_p0i8_i32=_memset;
-  Module["_memcpy"] = _memcpy;var _llvm_memcpy_p0i8_p0i8_i32=_memcpy;
-  var _llvm_memset_p0i8_i64=_memset;
-  function _llvm_lifetime_start() {}
-  function _llvm_lifetime_end() {}
-  function _abort() {
-      Module['abort']();
-    }
-  var ___errno_state=0;function ___setErrNo(value) {
-      // For convenient setting and returning of errno.
-      HEAP32[((___errno_state)>>2)]=value
-      return value;
-    }function ___errno_location() {
-      return ___errno_state;
-    }
-  function _sbrk(bytes) {
-      // Implement a Linux-like 'memory area' for our 'process'.
-      // Changes the size of the memory area by |bytes|; returns the
-      // address of the previous top ('break') of the memory area
-      // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
-      var self = _sbrk;
-      if (!self.called) {
-        DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
-        self.called = true;
-        assert(Runtime.dynamicAlloc);
-        self.alloc = Runtime.dynamicAlloc;
-        Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
-      }
-      var ret = DYNAMICTOP;
-      if (bytes != 0) self.alloc(bytes);
-      return ret;  // Previous break location.
-    }
-  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};function _sysconf(name) {
-      // long sysconf(int name);
-      // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
-      switch(name) {
-        case 30: return PAGE_SIZE;
-        case 132:
-        case 133:
-        case 12:
-        case 137:
-        case 138:
-        case 15:
-        case 235:
-        case 16:
-        case 17:
-        case 18:
-        case 19:
-        case 20:
-        case 149:
-        case 13:
-        case 10:
-        case 236:
-        case 153:
-        case 9:
-        case 21:
-        case 22:
-        case 159:
-        case 154:
-        case 14:
-        case 77:
-        case 78:
-        case 139:
-        case 80:
-        case 81:
-        case 79:
-        case 82:
-        case 68:
-        case 67:
-        case 164:
-        case 11:
-        case 29:
-        case 47:
-        case 48:
-        case 95:
-        case 52:
-        case 51:
-        case 46:
-          return 200809;
-        case 27:
-        case 246:
-        case 127:
-        case 128:
-        case 23:
-        case 24:
-        case 160:
-        case 161:
-        case 181:
-        case 182:
-        case 242:
-        case 183:
-        case 184:
-        case 243:
-        case 244:
-        case 245:
-        case 165:
-        case 178:
-        case 179:
-        case 49:
-        case 50:
-        case 168:
-        case 169:
-        case 175:
-        case 170:
-        case 171:
-        case 172:
-        case 97:
-        case 76:
-        case 32:
-        case 173:
-        case 35:
-          return -1;
-        case 176:
-        case 177:
-        case 7:
-        case 155:
-        case 8:
-        case 157:
-        case 125:
-        case 126:
-        case 92:
-        case 93:
-        case 129:
-        case 130:
-        case 131:
-        case 94:
-        case 91:
-          return 1;
-        case 74:
-        case 60:
-        case 69:
-        case 70:
-        case 4:
-          return 1024;
-        case 31:
-        case 42:
-        case 72:
-          return 32;
-        case 87:
-        case 26:
-        case 33:
-          return 2147483647;
-        case 34:
-        case 1:
-          return 47839;
-        case 38:
-        case 36:
-          return 99;
-        case 43:
-        case 37:
-          return 2048;
-        case 0: return 2097152;
-        case 3: return 65536;
-        case 28: return 32768;
-        case 44: return 32767;
-        case 75: return 16384;
-        case 39: return 1000;
-        case 89: return 700;
-        case 71: return 256;
-        case 40: return 255;
-        case 2: return 100;
-        case 180: return 64;
-        case 25: return 20;
-        case 5: return 16;
-        case 6: return 6;
-        case 73: return 4;
-        case 84: return 1;
-      }
-      ___setErrNo(ERRNO_CODES.EINVAL);
-      return -1;
-    }
-  function _time(ptr) {
-      var ret = Math.floor(Date.now()/1000);
-      if (ptr) {
-        HEAP32[((ptr)>>2)]=ret
-      }
-      return ret;
-    }
-  Module["_strlen"] = _strlen;
-  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"};
-  var TTY={ttys:[],init:function () {
-        // https://github.com/kripken/emscripten/pull/1555
-        // if (ENVIRONMENT_IS_NODE) {
-        //   // currently, FS.init does not distinguish if process.stdin is a file or TTY
-        //   // device, it always assumes it's a TTY device. because of this, we're forcing
-        //   // process.stdin to UTF8 encoding to at least make stdin reading compatible
-        //   // with text files until FS.init can be refactored.
-        //   process['stdin']['setEncoding']('utf8');
-        // }
-      },shutdown:function () {
-        // https://github.com/kripken/emscripten/pull/1555
-        // if (ENVIRONMENT_IS_NODE) {
-        //   // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
-        //   // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
-        //   // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
-        //   // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
-        //   // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
-        //   process['stdin']['pause']();
-        // }
-      },register:function (dev, ops) {
-        TTY.ttys[dev] = { input: [], output: [], ops: ops };
-        FS.registerDevice(dev, TTY.stream_ops);
-      },stream_ops:{open:function (stream) {
-          var tty = TTY.ttys[stream.node.rdev];
-          if (!tty) {
-            throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
-          }
-          stream.tty = tty;
-          stream.seekable = false;
-        },close:function (stream) {
-          // flush any pending line data
-          if (stream.tty.output.length) {
-            stream.tty.ops.put_char(stream.tty, 10);
-          }
-        },read:function (stream, buffer, offset, length, pos /* ignored */) {
-          if (!stream.tty || !stream.tty.ops.get_char) {
-            throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
-          }
-          var bytesRead = 0;
-          for (var i = 0; i < length; i++) {
-            var result;
-            try {
-              result = stream.tty.ops.get_char(stream.tty);
-            } catch (e) {
-              throw new FS.ErrnoError(ERRNO_CODES.EIO);
-            }
-            if (result === undefined && bytesRead === 0) {
-              throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
-            }
-            if (result === null || result === undefined) break;
-            bytesRead++;
-            buffer[offset+i] = result;
-          }
-          if (bytesRead) {
-            stream.node.timestamp = Date.now();
-          }
-          return bytesRead;
-        },write:function (stream, buffer, offset, length, pos) {
-          if (!stream.tty || !stream.tty.ops.put_char) {
-            throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
-          }
-          for (var i = 0; i < length; i++) {
-            try {
-              stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
-            } catch (e) {
-              throw new FS.ErrnoError(ERRNO_CODES.EIO);
-            }
-          }
-          if (length) {
-            stream.node.timestamp = Date.now();
-          }
-          return i;
-        }},default_tty_ops:{get_char:function (tty) {
-          if (!tty.input.length) {
-            var result = null;
-            if (ENVIRONMENT_IS_NODE) {
-              result = process['stdin']['read']();
-              if (!result) {
-                if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
-                  return null;  // EOF
-                }
-                return undefined;  // no data available
-              }
-            } else if (typeof window != 'undefined' &&
-              typeof window.prompt == 'function') {
-              // Browser.
-              result = window.prompt('Input: ');  // returns null on cancel
-              if (result !== null) {
-                result += '\n';
-              }
-            } else if (typeof readline == 'function') {
-              // Command line.
-              result = readline();
-              if (result !== null) {
-                result += '\n';
-              }
-            }
-            if (!result) {
-              return null;
-            }
-            tty.input = intArrayFromString(result, true);
-          }
-          return tty.input.shift();
-        },put_char:function (tty, val) {
-          if (val === null || val === 10) {
-            Module['print'](tty.output.join(''));
-            tty.output = [];
-          } else {
-            tty.output.push(TTY.utf8.processCChar(val));
-          }
-        }},default_tty1_ops:{put_char:function (tty, val) {
-          if (val === null || val === 10) {
-            Module['printErr'](tty.output.join(''));
-            tty.output = [];
-          } else {
-            tty.output.push(TTY.utf8.processCChar(val));
-          }
-        }}};
-  var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
-        return MEMFS.createNode(null, '/', 16384 | 0777, 0);
-      },createNode:function (parent, name, mode, dev) {
-        if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
-          // no supported
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        if (!MEMFS.ops_table) {
-          MEMFS.ops_table = {
-            dir: {
-              node: {
-                getattr: MEMFS.node_ops.getattr,
-                setattr: MEMFS.node_ops.setattr,
-                lookup: MEMFS.node_ops.lookup,
-                mknod: MEMFS.node_ops.mknod,
-                mknod: MEMFS.node_ops.mknod,
-                rename: MEMFS.node_ops.rename,
-                unlink: MEMFS.node_ops.unlink,
-                rmdir: MEMFS.node_ops.rmdir,
-                readdir: MEMFS.node_ops.readdir,
-                symlink: MEMFS.node_ops.symlink
-              },
-              stream: {
-                llseek: MEMFS.stream_ops.llseek
-              }
-            },
-            file: {
-              node: {
-                getattr: MEMFS.node_ops.getattr,
-                setattr: MEMFS.node_ops.setattr
-              },
-              stream: {
-                llseek: MEMFS.stream_ops.llseek,
-                read: MEMFS.stream_ops.read,
-                write: MEMFS.stream_ops.write,
-                allocate: MEMFS.stream_ops.allocate,
-                mmap: MEMFS.stream_ops.mmap
-              }
-            },
-            link: {
-              node: {
-                getattr: MEMFS.node_ops.getattr,
-                setattr: MEMFS.node_ops.setattr,
-                readlink: MEMFS.node_ops.readlink
-              },
-              stream: {}
-            },
-            chrdev: {
-              node: {
-                getattr: MEMFS.node_ops.getattr,
-                setattr: MEMFS.node_ops.setattr
-              },
-              stream: FS.chrdev_stream_ops
-            },
-          };
-        }
-        var node = FS.createNode(parent, name, mode, dev);
-        if (FS.isDir(node.mode)) {
-          node.node_ops = MEMFS.ops_table.dir.node;
-          node.stream_ops = MEMFS.ops_table.dir.stream;
-          node.contents = {};
-        } else if (FS.isFile(node.mode)) {
-          node.node_ops = MEMFS.ops_table.file.node;
-          node.stream_ops = MEMFS.ops_table.file.stream;
-          node.contents = [];
-          node.contentMode = MEMFS.CONTENT_FLEXIBLE;
-        } else if (FS.isLink(node.mode)) {
-          node.node_ops = MEMFS.ops_table.link.node;
-          node.stream_ops = MEMFS.ops_table.link.stream;
-        } else if (FS.isChrdev(node.mode)) {
-          node.node_ops = MEMFS.ops_table.chrdev.node;
-          node.stream_ops = MEMFS.ops_table.chrdev.stream;
-        }
-        node.timestamp = Date.now();
-        // add the new node to the parent
-        if (parent) {
-          parent.contents[name] = node;
-        }
-        return node;
-      },ensureFlexible:function (node) {
-        if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
-          var contents = node.contents;
-          node.contents = Array.prototype.slice.call(contents);
-          node.contentMode = MEMFS.CONTENT_FLEXIBLE;
-        }
-      },node_ops:{getattr:function (node) {
-          var attr = {};
-          // device numbers reuse inode numbers.
-          attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
-          attr.ino = node.id;
-          attr.mode = node.mode;
-          attr.nlink = 1;
-          attr.uid = 0;
-          attr.gid = 0;
-          attr.rdev = node.rdev;
-          if (FS.isDir(node.mode)) {
-            attr.size = 4096;
-          } else if (FS.isFile(node.mode)) {
-            attr.size = node.contents.length;
-          } else if (FS.isLink(node.mode)) {
-            attr.size = node.link.length;
-          } else {
-            attr.size = 0;
-          }
-          attr.atime = new Date(node.timestamp);
-          attr.mtime = new Date(node.timestamp);
-          attr.ctime = new Date(node.timestamp);
-          // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
-          //       but this is not required by the standard.
-          attr.blksize = 4096;
-          attr.blocks = Math.ceil(attr.size / attr.blksize);
-          return attr;
-        },setattr:function (node, attr) {
-          if (attr.mode !== undefined) {
-            node.mode = attr.mode;
-          }
-          if (attr.timestamp !== undefined) {
-            node.timestamp = attr.timestamp;
-          }
-          if (attr.size !== undefined) {
-            MEMFS.ensureFlexible(node);
-            var contents = node.contents;
-            if (attr.size < contents.length) contents.length = attr.size;
-            else while (attr.size > contents.length) contents.push(0);
-          }
-        },lookup:function (parent, name) {
-          throw FS.genericErrors[ERRNO_CODES.ENOENT];
-        },mknod:function (parent, name, mode, dev) {
-          return MEMFS.createNode(parent, name, mode, dev);
-        },rename:function (old_node, new_dir, new_name) {
-          // if we're overwriting a directory at new_name, make sure it's empty.
-          if (FS.isDir(old_node.mode)) {
-            var new_node;
-            try {
-              new_node = FS.lookupNode(new_dir, new_name);
-            } catch (e) {
-            }
-            if (new_node) {
-              for (var i in new_node.contents) {
-                throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
-              }
-            }
-          }
-          // do the internal rewiring
-          delete old_node.parent.contents[old_node.name];
-          old_node.name = new_name;
-          new_dir.contents[new_name] = old_node;
-          old_node.parent = new_dir;
-        },unlink:function (parent, name) {
-          delete parent.contents[name];
-        },rmdir:function (parent, name) {
-          var node = FS.lookupNode(parent, name);
-          for (var i in node.contents) {
-            throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
-          }
-          delete parent.contents[name];
-        },readdir:function (node) {
-          var entries = ['.', '..']
-          for (var key in node.contents) {
-            if (!node.contents.hasOwnProperty(key)) {
-              continue;
-            }
-            entries.push(key);
-          }
-          return entries;
-        },symlink:function (parent, newname, oldpath) {
-          var node = MEMFS.createNode(parent, newname, 0777 | 40960, 0);
-          node.link = oldpath;
-          return node;
-        },readlink:function (node) {
-          if (!FS.isLink(node.mode)) {
-            throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-          }
-          return node.link;
-        }},stream_ops:{read:function (stream, buffer, offset, length, position) {
-          var contents = stream.node.contents;
-          if (position >= contents.length)
-            return 0;
-          var size = Math.min(contents.length - position, length);
-          assert(size >= 0);
-          if (size > 8 && contents.subarray) { // non-trivial, and typed array
-            buffer.set(contents.subarray(position, position + size), offset);
-          } else
-          {
-            for (var i = 0; i < size; i++) {
-              buffer[offset + i] = contents[position + i];
-            }
-          }
-          return size;
-        },write:function (stream, buffer, offset, length, position, canOwn) {
-          var node = stream.node;
-          node.timestamp = Date.now();
-          var contents = node.contents;
-          if (length && contents.length === 0 && position === 0 && buffer.subarray) {
-            // just replace it with the new data
-            if (canOwn && offset === 0) {
-              node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
-              node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
-            } else {
-              node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
-              node.contentMode = MEMFS.CONTENT_FIXED;
-            }
-            return length;
-          }
-          MEMFS.ensureFlexible(node);
-          var contents = node.contents;
-          while (contents.length < position) contents.push(0);
-          for (var i = 0; i < length; i++) {
-            contents[position + i] = buffer[offset + i];
-          }
-          return length;
-        },llseek:function (stream, offset, whence) {
-          var position = offset;
-          if (whence === 1) {  // SEEK_CUR.
-            position += stream.position;
-          } else if (whence === 2) {  // SEEK_END.
-            if (FS.isFile(stream.node.mode)) {
-              position += stream.node.contents.length;
-            }
-          }
-          if (position < 0) {
-            throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-          }
-          stream.ungotten = [];
-          stream.position = position;
-          return position;
-        },allocate:function (stream, offset, length) {
-          MEMFS.ensureFlexible(stream.node);
-          var contents = stream.node.contents;
-          var limit = offset + length;
-          while (limit > contents.length) contents.push(0);
-        },mmap:function (stream, buffer, offset, length, position, prot, flags) {
-          if (!FS.isFile(stream.node.mode)) {
-            throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
-          }
-          var ptr;
-          var allocated;
-          var contents = stream.node.contents;
-          // Only make a new copy when MAP_PRIVATE is specified.
-          if ( !(flags & 2) &&
-                (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
-            // We can't emulate MAP_SHARED when the file is not backed by the buffer
-            // we're mapping to (e.g. the HEAP buffer).
-            allocated = false;
-            ptr = contents.byteOffset;
-          } else {
-            // Try to avoid unnecessary slices.
-            if (position > 0 || position + length < contents.length) {
-              if (contents.subarray) {
-                contents = contents.subarray(position, position + length);
-              } else {
-                contents = Array.prototype.slice.call(contents, position, position + length);
-              }
-            }
-            allocated = true;
-            ptr = _malloc(length);
-            if (!ptr) {
-              throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
-            }
-            buffer.set(contents, ptr);
-          }
-          return { ptr: ptr, allocated: allocated };
-        }}};
-  var IDBFS={dbs:{},indexedDB:function () {
-        return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
-      },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
-        return MEMFS.mount.apply(null, arguments);
-      },syncfs:function (mount, populate, callback) {
-        IDBFS.getLocalSet(mount, function(err, local) {
-          if (err) return callback(err);
-          IDBFS.getRemoteSet(mount, function(err, remote) {
-            if (err) return callback(err);
-            var src = populate ? remote : local;
-            var dst = populate ? local : remote;
-            IDBFS.reconcile(src, dst, callback);
-          });
-        });
-      },reconcile:function (src, dst, callback) {
-        var total = 0;
-        var create = {};
-        for (var key in src.files) {
-          if (!src.files.hasOwnProperty(key)) continue;
-          var e = src.files[key];
-          var e2 = dst.files[key];
-          if (!e2 || e.timestamp > e2.timestamp) {
-            create[key] = e;
-            total++;
-          }
-        }
-        var remove = {};
-        for (var key in dst.files) {
-          if (!dst.files.hasOwnProperty(key)) continue;
-          var e = dst.files[key];
-          var e2 = src.files[key];
-          if (!e2) {
-            remove[key] = e;
-            total++;
-          }
-        }
-        if (!total) {
-          // early out
-          return callback(null);
-        }
-        var completed = 0;
-        function done(err) {
-          if (err) return callback(err);
-          if (++completed >= total) {
-            return callback(null);
-          }
-        };
-        // create a single transaction to handle and IDB reads / writes we'll need to do
-        var db = src.type === 'remote' ? src.db : dst.db;
-        var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
-        transaction.onerror = function transaction_onerror() { callback(this.error); };
-        var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
-        for (var path in create) {
-          if (!create.hasOwnProperty(path)) continue;
-          var entry = create[path];
-          if (dst.type === 'local') {
-            // save file to local
-            try {
-              if (FS.isDir(entry.mode)) {
-                FS.mkdir(path, entry.mode);
-              } else if (FS.isFile(entry.mode)) {
-                var stream = FS.open(path, 'w+', 0666);
-                FS.write(stream, entry.contents, 0, entry.contents.length, 0, true /* canOwn */);
-                FS.close(stream);
-              }
-              done(null);
-            } catch (e) {
-              return done(e);
-            }
-          } else {
-            // save file to IDB
-            var req = store.put(entry, path);
-            req.onsuccess = function req_onsuccess() { done(null); };
-            req.onerror = function req_onerror() { done(this.error); };
-          }
-        }
-        for (var path in remove) {
-          if (!remove.hasOwnProperty(path)) continue;
-          var entry = remove[path];
-          if (dst.type === 'local') {
-            // delete file from local
-            try {
-              if (FS.isDir(entry.mode)) {
-                // TODO recursive delete?
-                FS.rmdir(path);
-              } else if (FS.isFile(entry.mode)) {
-                FS.unlink(path);
-              }
-              done(null);
-            } catch (e) {
-              return done(e);
-            }
-          } else {
-            // delete file from IDB
-            var req = store.delete(path);
-            req.onsuccess = function req_onsuccess() { done(null); };
-            req.onerror = function req_onerror() { done(this.error); };
-          }
-        }
-      },getLocalSet:function (mount, callback) {
-        var files = {};
-        function isRealDir(p) {
-          return p !== '.' && p !== '..';
-        };
-        function toAbsolute(root) {
-          return function(p) {
-            return PATH.join2(root, p);
-          }
-        };
-        var check = FS.readdir(mount.mountpoint)
-          .filter(isRealDir)
-          .map(toAbsolute(mount.mountpoint));
-        while (check.length) {
-          var path = check.pop();
-          var stat, node;
-          try {
-            var lookup = FS.lookupPath(path);
-            node = lookup.node;
-            stat = FS.stat(path);
-          } catch (e) {
-            return callback(e);
-          }
-          if (FS.isDir(stat.mode)) {
-            check.push.apply(check, FS.readdir(path)
-              .filter(isRealDir)
-              .map(toAbsolute(path)));
-            files[path] = { mode: stat.mode, timestamp: stat.mtime };
-          } else if (FS.isFile(stat.mode)) {
-            files[path] = { contents: node.contents, mode: stat.mode, timestamp: stat.mtime };
-          } else {
-            return callback(new Error('node type not supported'));
-          }
-        }
-        return callback(null, { type: 'local', files: files });
-      },getDB:function (name, callback) {
-        // look it up in the cache
-        var db = IDBFS.dbs[name];
-        if (db) {
-          return callback(null, db);
-        }
-        var req;
-        try {
-          req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
-        } catch (e) {
-          return onerror(e);
-        }
-        req.onupgradeneeded = function req_onupgradeneeded() {
-          db = req.result;
-          db.createObjectStore(IDBFS.DB_STORE_NAME);
-        };
-        req.onsuccess = function req_onsuccess() {
-          db = req.result;
-          // add to the cache
-          IDBFS.dbs[name] = db;
-          callback(null, db);
-        };
-        req.onerror = function req_onerror() {
-          callback(this.error);
-        };
-      },getRemoteSet:function (mount, callback) {
-        var files = {};
-        IDBFS.getDB(mount.mountpoint, function(err, db) {
-          if (err) return callback(err);
-          var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
-          transaction.onerror = function transaction_onerror() { callback(this.error); };
-          var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
-          store.openCursor().onsuccess = function store_openCursor_onsuccess(event) {
-            var cursor = event.target.result;
-            if (!cursor) {
-              return callback(null, { type: 'remote', db: db, files: files });
-            }
-            files[cursor.key] = cursor.value;
-            cursor.continue();
-          };
-        });
-      }};
-  var NODEFS={isWindows:false,staticInit:function () {
-        NODEFS.isWindows = !!process.platform.match(/^win/);
-      },mount:function (mount) {
-        assert(ENVIRONMENT_IS_NODE);
-        return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
-      },createNode:function (parent, name, mode, dev) {
-        if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        var node = FS.createNode(parent, name, mode);
-        node.node_ops = NODEFS.node_ops;
-        node.stream_ops = NODEFS.stream_ops;
-        return node;
-      },getMode:function (path) {
-        var stat;
-        try {
-          stat = fs.lstatSync(path);
-          if (NODEFS.isWindows) {
-            // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so 
-            // propagate write bits to execute bits.
-            stat.mode = stat.mode | ((stat.mode & 146) >> 1);
-          }
-        } catch (e) {
-          if (!e.code) throw e;
-          throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-        }
-        return stat.mode;
-      },realPath:function (node) {
-        var parts = [];
-        while (node.parent !== node) {
-          parts.push(node.name);
-          node = node.parent;
-        }
-        parts.push(node.mount.opts.root);
-        parts.reverse();
-        return PATH.join.apply(null, parts);
-      },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) {
-        if (flags in NODEFS.flagsToPermissionStringMap) {
-          return NODEFS.flagsToPermissionStringMap[flags];
-        } else {
-          return flags;
-        }
-      },node_ops:{getattr:function (node) {
-          var path = NODEFS.realPath(node);
-          var stat;
-          try {
-            stat = fs.lstatSync(path);
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-          // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
-          // See http://support.microsoft.com/kb/140365
-          if (NODEFS.isWindows && !stat.blksize) {
-            stat.blksize = 4096;
-          }
-          if (NODEFS.isWindows && !stat.blocks) {
-            stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
-          }
-          return {
-            dev: stat.dev,
-            ino: stat.ino,
-            mode: stat.mode,
-            nlink: stat.nlink,
-            uid: stat.uid,
-            gid: stat.gid,
-            rdev: stat.rdev,
-            size: stat.size,
-            atime: stat.atime,
-            mtime: stat.mtime,
-            ctime: stat.ctime,
-            blksize: stat.blksize,
-            blocks: stat.blocks
-          };
-        },setattr:function (node, attr) {
-          var path = NODEFS.realPath(node);
-          try {
-            if (attr.mode !== undefined) {
-              fs.chmodSync(path, attr.mode);
-              // update the common node structure mode as well
-              node.mode = attr.mode;
-            }
-            if (attr.timestamp !== undefined) {
-              var date = new Date(attr.timestamp);
-              fs.utimesSync(path, date, date);
-            }
-            if (attr.size !== undefined) {
-              fs.truncateSync(path, attr.size);
-            }
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },lookup:function (parent, name) {
-          var path = PATH.join2(NODEFS.realPath(parent), name);
-          var mode = NODEFS.getMode(path);
-          return NODEFS.createNode(parent, name, mode);
-        },mknod:function (parent, name, mode, dev) {
-          var node = NODEFS.createNode(parent, name, mode, dev);
-          // create the backing node for this in the fs root as well
-          var path = NODEFS.realPath(node);
-          try {
-            if (FS.isDir(node.mode)) {
-              fs.mkdirSync(path, node.mode);
-            } else {
-              fs.writeFileSync(path, '', { mode: node.mode });
-            }
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-          return node;
-        },rename:function (oldNode, newDir, newName) {
-          var oldPath = NODEFS.realPath(oldNode);
-          var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
-          try {
-            fs.renameSync(oldPath, newPath);
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },unlink:function (parent, name) {
-          var path = PATH.join2(NODEFS.realPath(parent), name);
-          try {
-            fs.unlinkSync(path);
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },rmdir:function (parent, name) {
-          var path = PATH.join2(NODEFS.realPath(parent), name);
-          try {
-            fs.rmdirSync(path);
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },readdir:function (node) {
-          var path = NODEFS.realPath(node);
-          try {
-            return fs.readdirSync(path);
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },symlink:function (parent, newName, oldPath) {
-          var newPath = PATH.join2(NODEFS.realPath(parent), newName);
-          try {
-            fs.symlinkSync(oldPath, newPath);
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },readlink:function (node) {
-          var path = NODEFS.realPath(node);
-          try {
-            return fs.readlinkSync(path);
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        }},stream_ops:{open:function (stream) {
-          var path = NODEFS.realPath(stream.node);
-          try {
-            if (FS.isFile(stream.node.mode)) {
-              stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
-            }
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },close:function (stream) {
-          try {
-            if (FS.isFile(stream.node.mode) && stream.nfd) {
-              fs.closeSync(stream.nfd);
-            }
-          } catch (e) {
-            if (!e.code) throw e;
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-        },read:function (stream, buffer, offset, length, position) {
-          // FIXME this is terrible.
-          var nbuffer = new Buffer(length);
-          var res;
-          try {
-            res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
-          } catch (e) {
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-          if (res > 0) {
-            for (var i = 0; i < res; i++) {
-              buffer[offset + i] = nbuffer[i];
-            }
-          }
-          return res;
-        },write:function (stream, buffer, offset, length, position) {
-          // FIXME this is terrible.
-          var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
-          var res;
-          try {
-            res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
-          } catch (e) {
-            throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-          }
-          return res;
-        },llseek:function (stream, offset, whence) {
-          var position = offset;
-          if (whence === 1) {  // SEEK_CUR.
-            position += stream.position;
-          } else if (whence === 2) {  // SEEK_END.
-            if (FS.isFile(stream.node.mode)) {
-              try {
-                var stat = fs.fstatSync(stream.nfd);
-                position += stat.size;
-              } catch (e) {
-                throw new FS.ErrnoError(ERRNO_CODES[e.code]);
-              }
-            }
-          }
-          if (position < 0) {
-            throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-          }
-          stream.position = position;
-          return position;
-        }}};
-  var _stdin=allocate(1, "i32*", ALLOC_STATIC);
-  var _stdout=allocate(1, "i32*", ALLOC_STATIC);
-  var _stderr=allocate(1, "i32*", ALLOC_STATIC);
-  function _fflush(stream) {
-      // int fflush(FILE *stream);
-      // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
-      // we don't currently perform any user-space buffering of data
-    }var FS={root:null,mounts:[],devices:[null],streams:[null],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
-        if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
-        return ___setErrNo(e.errno);
-      },lookupPath:function (path, opts) {
-        path = PATH.resolve(FS.cwd(), path);
-        opts = opts || { recurse_count: 0 };
-        if (opts.recurse_count > 8) {  // max recursive lookup of 8
-          throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
-        }
-        // split the path
-        var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
-          return !!p;
-        }), false);
-        // start at the root
-        var current = FS.root;
-        var current_path = '/';
-        for (var i = 0; i < parts.length; i++) {
-          var islast = (i === parts.length-1);
-          if (islast && opts.parent) {
-            // stop resolving
-            break;
-          }
-          current = FS.lookupNode(current, parts[i]);
-          current_path = PATH.join2(current_path, parts[i]);
-          // jump to the mount's root node if this is a mountpoint
-          if (FS.isMountpoint(current)) {
-            current = current.mount.root;
-          }
-          // follow symlinks
-          // by default, lookupPath will not follow a symlink if it is the final path component.
-          // setting opts.follow = true will override this behavior.
-          if (!islast || opts.follow) {
-            var count = 0;
-            while (FS.isLink(current.mode)) {
-              var link = FS.readlink(current_path);
-              current_path = PATH.resolve(PATH.dirname(current_path), link);
-              var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
-              current = lookup.node;
-              if (count++ > 40) {  // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
-                throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
-              }
-            }
-          }
-        }
-        return { path: current_path, node: current };
-      },getPath:function (node) {
-        var path;
-        while (true) {
-          if (FS.isRoot(node)) {
-            var mount = node.mount.mountpoint;
-            if (!path) return mount;
-            return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
-          }
-          path = path ? node.name + '/' + path : node.name;
-          node = node.parent;
-        }
-      },hashName:function (parentid, name) {
-        var hash = 0;
-        for (var i = 0; i < name.length; i++) {
-          hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
-        }
-        return ((parentid + hash) >>> 0) % FS.nameTable.length;
-      },hashAddNode:function (node) {
-        var hash = FS.hashName(node.parent.id, node.name);
-        node.name_next = FS.nameTable[hash];
-        FS.nameTable[hash] = node;
-      },hashRemoveNode:function (node) {
-        var hash = FS.hashName(node.parent.id, node.name);
-        if (FS.nameTable[hash] === node) {
-          FS.nameTable[hash] = node.name_next;
-        } else {
-          var current = FS.nameTable[hash];
-          while (current) {
-            if (current.name_next === node) {
-              current.name_next = node.name_next;
-              break;
-            }
-            current = current.name_next;
-          }
-        }
-      },lookupNode:function (parent, name) {
-        var err = FS.mayLookup(parent);
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        var hash = FS.hashName(parent.id, name);
-        for (var node = FS.nameTable[hash]; node; node = node.name_next) {
-          var nodeName = node.name;
-          if (node.parent.id === parent.id && nodeName === name) {
-            return node;
-          }
-        }
-        // if we failed to find it in the cache, call into the VFS
-        return FS.lookup(parent, name);
-      },createNode:function (parent, name, mode, rdev) {
-        if (!FS.FSNode) {
-          FS.FSNode = function(parent, name, mode, rdev) {
-            this.id = FS.nextInode++;
-            this.name = name;
-            this.mode = mode;
-            this.node_ops = {};
-            this.stream_ops = {};
-            this.rdev = rdev;
-            this.parent = null;
-            this.mount = null;
-            if (!parent) {
-              parent = this;  // root node sets parent to itself
-            }
-            this.parent = parent;
-            this.mount = parent.mount;
-            FS.hashAddNode(this);
-          };
-          // compatibility
-          var readMode = 292 | 73;
-          var writeMode = 146;
-          FS.FSNode.prototype = {};
-          // NOTE we must use Object.defineProperties instead of individual calls to
-          // Object.defineProperty in order to make closure compiler happy
-          Object.defineProperties(FS.FSNode.prototype, {
-            read: {
-              get: function() { return (this.mode & readMode) === readMode; },
-              set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
-            },
-            write: {
-              get: function() { return (this.mode & writeMode) === writeMode; },
-              set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
-            },
-            isFolder: {
-              get: function() { return FS.isDir(this.mode); },
-            },
-            isDevice: {
-              get: function() { return FS.isChrdev(this.mode); },
-            },
-          });
-        }
-        return new FS.FSNode(parent, name, mode, rdev);
-      },destroyNode:function (node) {
-        FS.hashRemoveNode(node);
-      },isRoot:function (node) {
-        return node === node.parent;
-      },isMountpoint:function (node) {
-        return node.mounted;
-      },isFile:function (mode) {
-        return (mode & 61440) === 32768;
-      },isDir:function (mode) {
-        return (mode & 61440) === 16384;
-      },isLink:function (mode) {
-        return (mode & 61440) === 40960;
-      },isChrdev:function (mode) {
-        return (mode & 61440) === 8192;
-      },isBlkdev:function (mode) {
-        return (mode & 61440) === 24576;
-      },isFIFO:function (mode) {
-        return (mode & 61440) === 4096;
-      },isSocket:function (mode) {
-        return (mode & 49152) === 49152;
-      },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
-        var flags = FS.flagModes[str];
-        if (typeof flags === 'undefined') {
-          throw new Error('Unknown file open mode: ' + str);
-        }
-        return flags;
-      },flagsToPermissionString:function (flag) {
-        var accmode = flag & 2097155;
-        var perms = ['r', 'w', 'rw'][accmode];
-        if ((flag & 512)) {
-          perms += 'w';
-        }
-        return perms;
-      },nodePermissions:function (node, perms) {
-        if (FS.ignorePermissions) {
-          return 0;
-        }
-        // return 0 if any user, group or owner bits are set.
-        if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
-          return ERRNO_CODES.EACCES;
-        } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
-          return ERRNO_CODES.EACCES;
-        } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
-          return ERRNO_CODES.EACCES;
-        }
-        return 0;
-      },mayLookup:function (dir) {
-        return FS.nodePermissions(dir, 'x');
-      },mayCreate:function (dir, name) {
-        try {
-          var node = FS.lookupNode(dir, name);
-          return ERRNO_CODES.EEXIST;
-        } catch (e) {
-        }
-        return FS.nodePermissions(dir, 'wx');
-      },mayDelete:function (dir, name, isdir) {
-        var node;
-        try {
-          node = FS.lookupNode(dir, name);
-        } catch (e) {
-          return e.errno;
-        }
-        var err = FS.nodePermissions(dir, 'wx');
-        if (err) {
-          return err;
-        }
-        if (isdir) {
-          if (!FS.isDir(node.mode)) {
-            return ERRNO_CODES.ENOTDIR;
-          }
-          if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
-            return ERRNO_CODES.EBUSY;
-          }
-        } else {
-          if (FS.isDir(node.mode)) {
-            return ERRNO_CODES.EISDIR;
-          }
-        }
-        return 0;
-      },mayOpen:function (node, flags) {
-        if (!node) {
-          return ERRNO_CODES.ENOENT;
-        }
-        if (FS.isLink(node.mode)) {
-          return ERRNO_CODES.ELOOP;
-        } else if (FS.isDir(node.mode)) {
-          if ((flags & 2097155) !== 0 ||  // opening for write
-              (flags & 512)) {
-            return ERRNO_CODES.EISDIR;
-          }
-        }
-        return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
-      },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
-        fd_start = fd_start || 1;
-        fd_end = fd_end || FS.MAX_OPEN_FDS;
-        for (var fd = fd_start; fd <= fd_end; fd++) {
-          if (!FS.streams[fd]) {
-            return fd;
-          }
-        }
-        throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
-      },getStream:function (fd) {
-        return FS.streams[fd];
-      },createStream:function (stream, fd_start, fd_end) {
-        if (!FS.FSStream) {
-          FS.FSStream = function(){};
-          FS.FSStream.prototype = {};
-          // compatibility
-          Object.defineProperties(FS.FSStream.prototype, {
-            object: {
-              get: function() { return this.node; },
-              set: function(val) { this.node = val; }
-            },
-            isRead: {
-              get: function() { return (this.flags & 2097155) !== 1; }
-            },
-            isWrite: {
-              get: function() { return (this.flags & 2097155) !== 0; }
-            },
-            isAppend: {
-              get: function() { return (this.flags & 1024); }
-            }
-          });
-        }
-        if (stream.__proto__) {
-          // reuse the object
-          stream.__proto__ = FS.FSStream.prototype;
-        } else {
-          var newStream = new FS.FSStream();
-          for (var p in stream) {
-            newStream[p] = stream[p];
-          }
-          stream = newStream;
-        }
-        var fd = FS.nextfd(fd_start, fd_end);
-        stream.fd = fd;
-        FS.streams[fd] = stream;
-        return stream;
-      },closeStream:function (fd) {
-        FS.streams[fd] = null;
-      },chrdev_stream_ops:{open:function (stream) {
-          var device = FS.getDevice(stream.node.rdev);
-          // override node's stream ops with the device's
-          stream.stream_ops = device.stream_ops;
-          // forward the open call
-          if (stream.stream_ops.open) {
-            stream.stream_ops.open(stream);
-          }
-        },llseek:function () {
-          throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
-        }},major:function (dev) {
-        return ((dev) >> 8);
-      },minor:function (dev) {
-        return ((dev) & 0xff);
-      },makedev:function (ma, mi) {
-        return ((ma) << 8 | (mi));
-      },registerDevice:function (dev, ops) {
-        FS.devices[dev] = { stream_ops: ops };
-      },getDevice:function (dev) {
-        return FS.devices[dev];
-      },syncfs:function (populate, callback) {
-        if (typeof(populate) === 'function') {
-          callback = populate;
-          populate = false;
-        }
-        var completed = 0;
-        var total = FS.mounts.length;
-        function done(err) {
-          if (err) {
-            return callback(err);
-          }
-          if (++completed >= total) {
-            callback(null);
-          }
-        };
-        // sync all mounts
-        for (var i = 0; i < FS.mounts.length; i++) {
-          var mount = FS.mounts[i];
-          if (!mount.type.syncfs) {
-            done(null);
-            continue;
-          }
-          mount.type.syncfs(mount, populate, done);
-        }
-      },mount:function (type, opts, mountpoint) {
-        var lookup;
-        if (mountpoint) {
-          lookup = FS.lookupPath(mountpoint, { follow: false });
-          mountpoint = lookup.path;  // use the absolute path
-        }
-        var mount = {
-          type: type,
-          opts: opts,
-          mountpoint: mountpoint,
-          root: null
-        };
-        // create a root node for the fs
-        var root = type.mount(mount);
-        root.mount = mount;
-        mount.root = root;
-        // assign the mount info to the mountpoint's node
-        if (lookup) {
-          lookup.node.mount = mount;
-          lookup.node.mounted = true;
-          // compatibility update FS.root if we mount to /
-          if (mountpoint === '/') {
-            FS.root = mount.root;
-          }
-        }
-        // add to our cached list of mounts
-        FS.mounts.push(mount);
-        return root;
-      },lookup:function (parent, name) {
-        return parent.node_ops.lookup(parent, name);
-      },mknod:function (path, mode, dev) {
-        var lookup = FS.lookupPath(path, { parent: true });
-        var parent = lookup.node;
-        var name = PATH.basename(path);
-        var err = FS.mayCreate(parent, name);
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        if (!parent.node_ops.mknod) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        return parent.node_ops.mknod(parent, name, mode, dev);
-      },create:function (path, mode) {
-        mode = mode !== undefined ? mode : 0666;
-        mode &= 4095;
-        mode |= 32768;
-        return FS.mknod(path, mode, 0);
-      },mkdir:function (path, mode) {
-        mode = mode !== undefined ? mode : 0777;
-        mode &= 511 | 512;
-        mode |= 16384;
-        return FS.mknod(path, mode, 0);
-      },mkdev:function (path, mode, dev) {
-        if (typeof(dev) === 'undefined') {
-          dev = mode;
-          mode = 0666;
-        }
-        mode |= 8192;
-        return FS.mknod(path, mode, dev);
-      },symlink:function (oldpath, newpath) {
-        var lookup = FS.lookupPath(newpath, { parent: true });
-        var parent = lookup.node;
-        var newname = PATH.basename(newpath);
-        var err = FS.mayCreate(parent, newname);
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        if (!parent.node_ops.symlink) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        return parent.node_ops.symlink(parent, newname, oldpath);
-      },rename:function (old_path, new_path) {
-        var old_dirname = PATH.dirname(old_path);
-        var new_dirname = PATH.dirname(new_path);
-        var old_name = PATH.basename(old_path);
-        var new_name = PATH.basename(new_path);
-        // parents must exist
-        var lookup, old_dir, new_dir;
-        try {
-          lookup = FS.lookupPath(old_path, { parent: true });
-          old_dir = lookup.node;
-          lookup = FS.lookupPath(new_path, { parent: true });
-          new_dir = lookup.node;
-        } catch (e) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
-        }
-        // need to be part of the same mount
-        if (old_dir.mount !== new_dir.mount) {
-          throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
-        }
-        // source must exist
-        var old_node = FS.lookupNode(old_dir, old_name);
-        // old path should not be an ancestor of the new path
-        var relative = PATH.relative(old_path, new_dirname);
-        if (relative.charAt(0) !== '.') {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        // new path should not be an ancestor of the old path
-        relative = PATH.relative(new_path, old_dirname);
-        if (relative.charAt(0) !== '.') {
-          throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
-        }
-        // see if the new path already exists
-        var new_node;
-        try {
-          new_node = FS.lookupNode(new_dir, new_name);
-        } catch (e) {
-          // not fatal
-        }
-        // early out if nothing needs to change
-        if (old_node === new_node) {
-          return;
-        }
-        // we'll need to delete the old entry
-        var isdir = FS.isDir(old_node.mode);
-        var err = FS.mayDelete(old_dir, old_name, isdir);
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        // need delete permissions if we'll be overwriting.
-        // need create permissions if new doesn't already exist.
-        err = new_node ?
-          FS.mayDelete(new_dir, new_name, isdir) :
-          FS.mayCreate(new_dir, new_name);
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        if (!old_dir.node_ops.rename) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
-        }
-        // if we are going to change the parent, check write permissions
-        if (new_dir !== old_dir) {
-          err = FS.nodePermissions(old_dir, 'w');
-          if (err) {
-            throw new FS.ErrnoError(err);
-          }
-        }
-        // remove the node from the lookup hash
-        FS.hashRemoveNode(old_node);
-        // do the underlying fs rename
-        try {
-          old_dir.node_ops.rename(old_node, new_dir, new_name);
-        } catch (e) {
-          throw e;
-        } finally {
-          // add the node back to the hash (in case node_ops.rename
-          // changed its name)
-          FS.hashAddNode(old_node);
-        }
-      },rmdir:function (path) {
-        var lookup = FS.lookupPath(path, { parent: true });
-        var parent = lookup.node;
-        var name = PATH.basename(path);
-        var node = FS.lookupNode(parent, name);
-        var err = FS.mayDelete(parent, name, true);
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        if (!parent.node_ops.rmdir) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        if (FS.isMountpoint(node)) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
-        }
-        parent.node_ops.rmdir(parent, name);
-        FS.destroyNode(node);
-      },readdir:function (path) {
-        var lookup = FS.lookupPath(path, { follow: true });
-        var node = lookup.node;
-        if (!node.node_ops.readdir) {
-          throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
-        }
-        return node.node_ops.readdir(node);
-      },unlink:function (path) {
-        var lookup = FS.lookupPath(path, { parent: true });
-        var parent = lookup.node;
-        var name = PATH.basename(path);
-        var node = FS.lookupNode(parent, name);
-        var err = FS.mayDelete(parent, name, false);
-        if (err) {
-          // POSIX says unlink should set EPERM, not EISDIR
-          if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
-          throw new FS.ErrnoError(err);
-        }
-        if (!parent.node_ops.unlink) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        if (FS.isMountpoint(node)) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
-        }
-        parent.node_ops.unlink(parent, name);
-        FS.destroyNode(node);
-      },readlink:function (path) {
-        var lookup = FS.lookupPath(path, { follow: false });
-        var link = lookup.node;
-        if (!link.node_ops.readlink) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        return link.node_ops.readlink(link);
-      },stat:function (path, dontFollow) {
-        var lookup = FS.lookupPath(path, { follow: !dontFollow });
-        var node = lookup.node;
-        if (!node.node_ops.getattr) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        return node.node_ops.getattr(node);
-      },lstat:function (path) {
-        return FS.stat(path, true);
-      },chmod:function (path, mode, dontFollow) {
-        var node;
-        if (typeof path === 'string') {
-          var lookup = FS.lookupPath(path, { follow: !dontFollow });
-          node = lookup.node;
-        } else {
-          node = path;
-        }
-        if (!node.node_ops.setattr) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        node.node_ops.setattr(node, {
-          mode: (mode & 4095) | (node.mode & ~4095),
-          timestamp: Date.now()
-        });
-      },lchmod:function (path, mode) {
-        FS.chmod(path, mode, true);
-      },fchmod:function (fd, mode) {
-        var stream = FS.getStream(fd);
-        if (!stream) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBADF);
-        }
-        FS.chmod(stream.node, mode);
-      },chown:function (path, uid, gid, dontFollow) {
-        var node;
-        if (typeof path === 'string') {
-          var lookup = FS.lookupPath(path, { follow: !dontFollow });
-          node = lookup.node;
-        } else {
-          node = path;
-        }
-        if (!node.node_ops.setattr) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        node.node_ops.setattr(node, {
-          timestamp: Date.now()
-          // we ignore the uid / gid for now
-        });
-      },lchown:function (path, uid, gid) {
-        FS.chown(path, uid, gid, true);
-      },fchown:function (fd, uid, gid) {
-        var stream = FS.getStream(fd);
-        if (!stream) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBADF);
-        }
-        FS.chown(stream.node, uid, gid);
-      },truncate:function (path, len) {
-        if (len < 0) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        var node;
-        if (typeof path === 'string') {
-          var lookup = FS.lookupPath(path, { follow: true });
-          node = lookup.node;
-        } else {
-          node = path;
-        }
-        if (!node.node_ops.setattr) {
-          throw new FS.ErrnoError(ERRNO_CODES.EPERM);
-        }
-        if (FS.isDir(node.mode)) {
-          throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
-        }
-        if (!FS.isFile(node.mode)) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        var err = FS.nodePermissions(node, 'w');
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        node.node_ops.setattr(node, {
-          size: len,
-          timestamp: Date.now()
-        });
-      },ftruncate:function (fd, len) {
-        var stream = FS.getStream(fd);
-        if (!stream) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBADF);
-        }
-        if ((stream.flags & 2097155) === 0) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        FS.truncate(stream.node, len);
-      },utime:function (path, atime, mtime) {
-        var lookup = FS.lookupPath(path, { follow: true });
-        var node = lookup.node;
-        node.node_ops.setattr(node, {
-          timestamp: Math.max(atime, mtime)
-        });
-      },open:function (path, flags, mode, fd_start, fd_end) {
-        flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
-        mode = typeof mode === 'undefined' ? 0666 : mode;
-        if ((flags & 64)) {
-          mode = (mode & 4095) | 32768;
-        } else {
-          mode = 0;
-        }
-        var node;
-        if (typeof path === 'object') {
-          node = path;
-        } else {
-          path = PATH.normalize(path);
-          try {
-            var lookup = FS.lookupPath(path, {
-              follow: !(flags & 131072)
-            });
-            node = lookup.node;
-          } catch (e) {
-            // ignore
-          }
-        }
-        // perhaps we need to create the node
-        if ((flags & 64)) {
-          if (node) {
-            // if O_CREAT and O_EXCL are set, error out if the node already exists
-            if ((flags & 128)) {
-              throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
-            }
-          } else {
-            // node doesn't exist, try to create it
-            node = FS.mknod(path, mode, 0);
-          }
-        }
-        if (!node) {
-          throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
-        }
-        // can't truncate a device
-        if (FS.isChrdev(node.mode)) {
-          flags &= ~512;
-        }
-        // check permissions
-        var err = FS.mayOpen(node, flags);
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        // do truncation if necessary
-        if ((flags & 512)) {
-          FS.truncate(node, 0);
-        }
-        // we've already handled these, don't pass down to the underlying vfs
-        flags &= ~(128 | 512);
-        // register the stream with the filesystem
-        var stream = FS.createStream({
-          node: node,
-          path: FS.getPath(node),  // we want the absolute path to the node
-          flags: flags,
-          seekable: true,
-          position: 0,
-          stream_ops: node.stream_ops,
-          // used by the file family libc calls (fopen, fwrite, ferror, etc.)
-          ungotten: [],
-          error: false
-        }, fd_start, fd_end);
-        // call the new stream's open function
-        if (stream.stream_ops.open) {
-          stream.stream_ops.open(stream);
-        }
-        if (Module['logReadFiles'] && !(flags & 1)) {
-          if (!FS.readFiles) FS.readFiles = {};
-          if (!(path in FS.readFiles)) {
-            FS.readFiles[path] = 1;
-            Module['printErr']('read file: ' + path);
-          }
-        }
-        return stream;
-      },close:function (stream) {
-        try {
-          if (stream.stream_ops.close) {
-            stream.stream_ops.close(stream);
-          }
-        } catch (e) {
-          throw e;
-        } finally {
-          FS.closeStream(stream.fd);
-        }
-      },llseek:function (stream, offset, whence) {
-        if (!stream.seekable || !stream.stream_ops.llseek) {
-          throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
-        }
-        return stream.stream_ops.llseek(stream, offset, whence);
-      },read:function (stream, buffer, offset, length, position) {
-        if (length < 0 || position < 0) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        if ((stream.flags & 2097155) === 1) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBADF);
-        }
-        if (FS.isDir(stream.node.mode)) {
-          throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
-        }
-        if (!stream.stream_ops.read) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        var seeking = true;
-        if (typeof position === 'undefined') {
-          position = stream.position;
-          seeking = false;
-        } else if (!stream.seekable) {
-          throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
-        }
-        var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
-        if (!seeking) stream.position += bytesRead;
-        return bytesRead;
-      },write:function (stream, buffer, offset, length, position, canOwn) {
-        if (length < 0 || position < 0) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        if ((stream.flags & 2097155) === 0) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBADF);
-        }
-        if (FS.isDir(stream.node.mode)) {
-          throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
-        }
-        if (!stream.stream_ops.write) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        var seeking = true;
-        if (typeof position === 'undefined') {
-          position = stream.position;
-          seeking = false;
-        } else if (!stream.seekable) {
-          throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
-        }
-        if (stream.flags & 1024) {
-          // seek to the end before writing in append mode
-          FS.llseek(stream, 0, 2);
-        }
-        var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
-        if (!seeking) stream.position += bytesWritten;
-        return bytesWritten;
-      },allocate:function (stream, offset, length) {
-        if (offset < 0 || length <= 0) {
-          throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
-        }
-        if ((stream.flags & 2097155) === 0) {
-          throw new FS.ErrnoError(ERRNO_CODES.EBADF);
-        }
-        if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
-          throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
-        }
-        if (!stream.stream_ops.allocate) {
-          throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
-        }
-        stream.stream_ops.allocate(stream, offset, length);
-      },mmap:function (stream, buffer, offset, length, position, prot, flags) {
-        // TODO if PROT is PROT_WRITE, make sure we have write access
-        if ((stream.flags & 2097155) === 1) {
-          throw new FS.ErrnoError(ERRNO_CODES.EACCES);
-        }
-        if (!stream.stream_ops.mmap) {
-          throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
-        }
-        return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
-      },ioctl:function (stream, cmd, arg) {
-        if (!stream.stream_ops.ioctl) {
-          throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
-        }
-        return stream.stream_ops.ioctl(stream, cmd, arg);
-      },readFile:function (path, opts) {
-        opts = opts || {};
-        opts.flags = opts.flags || 'r';
-        opts.encoding = opts.encoding || 'binary';
-        var ret;
-        var stream = FS.open(path, opts.flags);
-        var stat = FS.stat(path);
-        var length = stat.size;
-        var buf = new Uint8Array(length);
-        FS.read(stream, buf, 0, length, 0);
-        if (opts.encoding === 'utf8') {
-          ret = '';
-          var utf8 = new Runtime.UTF8Processor();
-          for (var i = 0; i < length; i++) {
-            ret += utf8.processCChar(buf[i]);
-          }
-        } else if (opts.encoding === 'binary') {
-          ret = buf;
-        } else {
-          throw new Error('Invalid encoding type "' + opts.encoding + '"');
-        }
-        FS.close(stream);
-        return ret;
-      },writeFile:function (path, data, opts) {
-        opts = opts || {};
-        opts.flags = opts.flags || 'w';
-        opts.encoding = opts.encoding || 'utf8';
-        var stream = FS.open(path, opts.flags, opts.mode);
-        if (opts.encoding === 'utf8') {
-          var utf8 = new Runtime.UTF8Processor();
-          var buf = new Uint8Array(utf8.processJSString(data));
-          FS.write(stream, buf, 0, buf.length, 0);
-        } else if (opts.encoding === 'binary') {
-          FS.write(stream, data, 0, data.length, 0);
-        } else {
-          throw new Error('Invalid encoding type "' + opts.encoding + '"');
-        }
-        FS.close(stream);
-      },cwd:function () {
-        return FS.currentPath;
-      },chdir:function (path) {
-        var lookup = FS.lookupPath(path, { follow: true });
-        if (!FS.isDir(lookup.node.mode)) {
-          throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
-        }
-        var err = FS.nodePermissions(lookup.node, 'x');
-        if (err) {
-          throw new FS.ErrnoError(err);
-        }
-        FS.currentPath = lookup.path;
-      },createDefaultDirectories:function () {
-        FS.mkdir('/tmp');
-      },createDefaultDevices:function () {
-        // create /dev
-        FS.mkdir('/dev');
-        // setup /dev/null
-        FS.registerDevice(FS.makedev(1, 3), {
-          read: function() { return 0; },
-          write: function() { return 0; }
-        });
-        FS.mkdev('/dev/null', FS.makedev(1, 3));
-        // setup /dev/tty and /dev/tty1
-        // stderr needs to print output using Module['printErr']
-        // so we register a second tty just for it.
-        TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
-        TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
-        FS.mkdev('/dev/tty', FS.makedev(5, 0));
-        FS.mkdev('/dev/tty1', FS.makedev(6, 0));
-        // we're not going to emulate the actual shm device,
-        // just create the tmp dirs that reside in it commonly
-        FS.mkdir('/dev/shm');
-        FS.mkdir('/dev/shm/tmp');
-      },createStandardStreams:function () {
-        // TODO deprecate the old functionality of a single
-        // input / output callback and that utilizes FS.createDevice
-        // and instead require a unique set of stream ops
-        // by default, we symlink the standard streams to the
-        // default tty devices. however, if the standard streams
-        // have been overwritten we create a unique device for
-        // them instead.
-        if (Module['stdin']) {
-          FS.createDevice('/dev', 'stdin', Module['stdin']);
-        } else {
-          FS.symlink('/dev/tty', '/dev/stdin');
-        }
-        if (Module['stdout']) {
-          FS.createDevice('/dev', 'stdout', null, Module['stdout']);
-        } else {
-          FS.symlink('/dev/tty', '/dev/stdout');
-        }
-        if (Module['stderr']) {
-          FS.createDevice('/dev', 'stderr', null, Module['stderr']);
-        } else {
-          FS.symlink('/dev/tty1', '/dev/stderr');
-        }
-        // open default streams for the stdin, stdout and stderr devices
-        var stdin = FS.open('/dev/stdin', 'r');
-        HEAP32[((_stdin)>>2)]=stdin.fd;
-        assert(stdin.fd === 1, 'invalid handle for stdin (' + stdin.fd + ')');
-        var stdout = FS.open('/dev/stdout', 'w');
-        HEAP32[((_stdout)>>2)]=stdout.fd;
-        assert(stdout.fd === 2, 'invalid handle for stdout (' + stdout.fd + ')');
-        var stderr = FS.open('/dev/stderr', 'w');
-        HEAP32[((_stderr)>>2)]=stderr.fd;
-        assert(stderr.fd === 3, 'invalid handle for stderr (' + stderr.fd + ')');
-      },ensureErrnoError:function () {
-        if (FS.ErrnoError) return;
-        FS.ErrnoError = function ErrnoError(errno) {
-          this.errno = errno;
-          for (var key in ERRNO_CODES) {
-            if (ERRNO_CODES[key] === errno) {
-              this.code = key;
-              break;
-            }
-          }
-          this.message = ERRNO_MESSAGES[errno];
-          this.stack = stackTrace();
-        };
-        FS.ErrnoError.prototype = new Error();
-        FS.ErrnoError.prototype.constructor = FS.ErrnoError;
-        // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
-        [ERRNO_CODES.ENOENT].forEach(function(code) {
-          FS.genericErrors[code] = new FS.ErrnoError(code);
-          FS.genericErrors[code].stack = '<generic error, no stack>';
-        });
-      },staticInit:function () {
-        FS.ensureErrnoError();
-        FS.nameTable = new Array(4096);
-        FS.root = FS.createNode(null, '/', 16384 | 0777, 0);
-        FS.mount(MEMFS, {}, '/');
-        FS.createDefaultDirectories();
-        FS.createDefaultDevices();
-      },init:function (input, output, error) {
-        assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');
-        FS.init.initialized = true;
-        FS.ensureErrnoError();
-        // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
-        Module['stdin'] = input || Module['stdin'];
-        Module['stdout'] = output || Module['stdout'];
-        Module['stderr'] = error || Module['stderr'];
-        FS.createStandardStreams();
-      },quit:function () {
-        FS.init.initialized = false;
-        for (var i = 0; i < FS.streams.length; i++) {
-          var stream = FS.streams[i];
-          if (!stream) {
-            continue;
-          }
-          FS.close(stream);
-        }
-      },getMode:function (canRead, canWrite) {
-        var mode = 0;
-        if (canRead) mode |= 292 | 73;
-        if (canWrite) mode |= 146;
-        return mode;
-      },joinPath:function (parts, forceRelative) {
-        var path = PATH.join.apply(null, parts);
-        if (forceRelative && path[0] == '/') path = path.substr(1);
-        return path;
-      },absolutePath:function (relative, base) {
-        return PATH.resolve(base, relative);
-      },standardizePath:function (path) {
-        return PATH.normalize(path);
-      },findObject:function (path, dontResolveLastLink) {
-        var ret = FS.analyzePath(path, dontResolveLastLink);
-        if (ret.exists) {
-          return ret.object;
-        } else {
-          ___setErrNo(ret.error);
-          return null;
-        }
-      },analyzePath:function (path, dontResolveLastLink) {
-        // operate from within the context of the symlink's target
-        try {
-          var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
-          path = lookup.path;
-        } catch (e) {
-        }
-        var ret = {
-          isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
-          parentExists: false, parentPath: null, parentObject: null
-        };
-        try {
-          var lookup = FS.lookupPath(path, { parent: true });
-          ret.parentExists = true;
-          ret.parentPath = lookup.path;
-          ret.parentObject = lookup.node;
-          ret.name = PATH.basename(path);
-          lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
-          ret.exists = true;
-          ret.path = lookup.path;
-          ret.object = lookup.node;
-          ret.name = lookup.node.name;
-          ret.isRoot = lookup.path === '/';
-        } catch (e) {
-          ret.error = e.errno;
-        };
-        return ret;
-      },createFolder:function (parent, name, canRead, canWrite) {
-        var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
-        var mode = FS.getMode(canRead, canWrite);
-        return FS.mkdir(path, mode);
-      },createPath:function (parent, path, canRead, canWrite) {
-        parent = typeof parent === 'string' ? parent : FS.getPath(parent);
-        var parts = path.split('/').reverse();
-        while (parts.length) {
-          var part = parts.pop();
-          if (!part) continue;
-          var current = PATH.join2(parent, part);
-          try {
-            FS.mkdir(current);
-          } catch (e) {
-            // ignore EEXIST
-          }
-          parent = current;
-        }
-        return current;
-      },createFile:function (parent, name, properties, canRead, canWrite) {
-        var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
-        var mode = FS.getMode(canRead, canWrite);
-        return FS.create(path, mode);
-      },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
-        var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
-        var mode = FS.getMode(canRead, canWrite);
-        var node = FS.create(path, mode);
-        if (data) {
-          if (typeof data === 'string') {
-            var arr = new Array(data.length);
-            for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
-            data = arr;
-          }
-          // make sure we can write to the file
-          FS.chmod(node, mode | 146);
-          var stream = FS.open(node, 'w');
-          FS.write(stream, data, 0, data.length, 0, canOwn);
-          FS.close(stream);
-          FS.chmod(node, mode);
-        }
-        return node;
-      },createDevice:function (parent, name, input, output) {
-        var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
-        var mode = FS.getMode(!!input, !!output);
-        if (!FS.createDevice.major) FS.createDevice.major = 64;
-        var dev = FS.makedev(FS.createDevice.major++, 0);
-        // Create a fake device that a set of stream ops to emulate
-        // the old behavior.
-        FS.registerDevice(dev, {
-          open: function(stream) {
-            stream.seekable = false;
-          },
-          close: function(stream) {
-            // flush any pending line data
-            if (output && output.buffer && output.buffer.length) {
-              output(10);
-            }
-          },
-          read: function(stream, buffer, offset, length, pos /* ignored */) {
-            var bytesRead = 0;
-            for (var i = 0; i < length; i++) {
-              var result;
-              try {
-                result = input();
-              } catch (e) {
-                throw new FS.ErrnoError(ERRNO_CODES.EIO);
-              }
-              if (result === undefined && bytesRead === 0) {
-                throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
-              }
-              if (result === null || result === undefined) break;
-              bytesRead++;
-              buffer[offset+i] = result;
-            }
-            if (bytesRead) {
-              stream.node.timestamp = Date.now();
-            }
-            return bytesRead;
-          },
-          write: function(stream, buffer, offset, length, pos) {
-            for (var i = 0; i < length; i++) {
-              try {
-                output(buffer[offset+i]);
-              } catch (e) {
-                throw new FS.ErrnoError(ERRNO_CODES.EIO);
-              }
-            }
-            if (length) {
-              stream.node.timestamp = Date.now();
-            }
-            return i;
-          }
-        });
-        return FS.mkdev(path, mode, dev);
-      },createLink:function (parent, name, target, canRead, canWrite) {
-        var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
-        return FS.symlink(target, path);
-      },forceLoadFile:function (obj) {
-        if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
-        var success = true;
-        if (typeof XMLHttpRequest !== 'undefined') {
-          throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");
-        } else if (Module['read']) {
-          // Command-line.
-          try {
-            // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
-            //          read() will try to parse UTF8.
-            obj.contents = intArrayFromString(Module['read'](obj.url), true);
-          } catch (e) {
-            success = false;
-          }
-        } else {
-          throw new Error('Cannot load without read() or XMLHttpRequest.');
-        }
-        if (!success) ___setErrNo(ERRNO_CODES.EIO);
-        return success;
-      },createLazyFile:function (parent, name, url, canRead, canWrite) {
-        if (typeof XMLHttpRequest !== 'undefined') {
-          if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
-          // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
-          function LazyUint8Array() {
-            this.lengthKnown = false;
-            this.chunks = []; // Loaded chunks. Index is the chunk number
-          }
-          LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
-            if (idx > this.length-1 || idx < 0) {
-              return undefined;
-            }
-            var chunkOffset = idx % this.chunkSize;
-            var chunkNum = Math.floor(idx / this.chunkSize);
-            return this.getter(chunkNum)[chunkOffset];
-          }
-          LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
-            this.getter = getter;
-          }
-          LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
-              // Find length
-              var xhr = new XMLHttpRequest();
-              xhr.open('HEAD', url, false);
-              xhr.send(null);
-              if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
-              var datalength = Number(xhr.getResponseHeader("Content-length"));
-              var header;
-              var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
-              var chunkSize = 1024*1024; // Chunk size in bytes
-              if (!hasByteServing) chunkSize = datalength;
-              // Function to get a range from the remote URL.
-              var doXHR = (function(from, to) {
-                if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
-                if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
-                // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
-                var xhr = new XMLHttpRequest();
-                xhr.open('GET', url, false);
-                if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
-                // Some hints to the browser that we want binary data.
-                if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
-                if (xhr.overrideMimeType) {
-                  xhr.overrideMimeType('text/plain; charset=x-user-defined');
-                }
-                xhr.send(null);
-                if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
-                if (xhr.response !== undefined) {
-                  return new Uint8Array(xhr.response || []);
-                } else {
-                  return intArrayFromString(xhr.responseText || '', true);
-                }
-              });
-              var lazyArray = this;
-              lazyArray.setDataGetter(function(chunkNum) {
-                var start = chunkNum * chunkSize;
-                var end = (chunkNum+1) * chunkSize - 1; // including this byte
-                end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
-                if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
-                  lazyArray.chunks[chunkNum] = doXHR(start, end);
-                }
-                if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
-                return lazyArray.chunks[chunkNum];
-              });
-              this._length = datalength;
-              this._chunkSize = chunkSize;
-              this.lengthKnown = true;
-          }
-          var lazyArray = new LazyUint8Array();
-          Object.defineProperty(lazyArray, "length", {
-              get: function() {
-                  if(!this.lengthKnown) {
-                      this.cacheLength();
-                  }
-                  return this._length;
-              }
-          });
-          Object.defineProperty(lazyArray, "chunkSize", {
-              get: function() {
-                  if(!this.lengthKnown) {
-                      this.cacheLength();
-                  }
-                  return this._chunkSize;
-              }
-          });
-          var properties = { isDevice: false, contents: lazyArray };
-        } else {
-          var properties = { isDevice: false, url: url };
-        }
-        var node = FS.createFile(parent, name, properties, canRead, canWrite);
-        // This is a total hack, but I want to get this lazy file code out of the
-        // core of MEMFS. If we want to keep this lazy file concept I feel it should
-        // be its own thin LAZYFS proxying calls to MEMFS.
-        if (properties.contents) {
-          node.contents = properties.contents;
-        } else if (properties.url) {
-          node.contents = null;
-          node.url = properties.url;
-        }
-        // override each stream op with one that tries to force load the lazy file first
-        var stream_ops = {};
-        var keys = Object.keys(node.stream_ops);
-        keys.forEach(function(key) {
-          var fn = node.stream_ops[key];
-          stream_ops[key] = function forceLoadLazyFile() {
-            if (!FS.forceLoadFile(node)) {
-              throw new FS.ErrnoError(ERRNO_CODES.EIO);
-            }
-            return fn.apply(null, arguments);
-          };
-        });
-        // use a custom read function
-        stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
-          if (!FS.forceLoadFile(node)) {
-            throw new FS.ErrnoError(ERRNO_CODES.EIO);
-          }
-          var contents = stream.node.contents;
-          if (position >= contents.length)
-            return 0;
-          var size = Math.min(contents.length - position, length);
-          assert(size >= 0);
-          if (contents.slice) { // normal array
-            for (var i = 0; i < size; i++) {
-              buffer[offset + i] = contents[position + i];
-            }
-          } else {
-            for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
-              buffer[offset + i] = contents.get(position + i);
-            }
-          }
-          return size;
-        };
-        node.stream_ops = stream_ops;
-        return node;
-      },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
-        Browser.init();
-        // TODO we should allow people to just pass in a complete filename instead
-        // of parent and name being that we just join them anyways
-        var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
-        function processData(byteArray) {
-          function finish(byteArray) {
-            if (!dontCreateFile) {
-              FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
-            }
-            if (onload) onload();
-            removeRunDependency('cp ' + fullname);
-          }
-          var handled = false;
-          Module['preloadPlugins'].forEach(function(plugin) {
-            if (handled) return;
-            if (plugin['canHandle'](fullname)) {
-              plugin['handle'](byteArray, fullname, finish, function() {
-                if (onerror) onerror();
-                removeRunDependency('cp ' + fullname);
-              });
-              handled = true;
-            }
-          });
-          if (!handled) finish(byteArray);
-        }
-        addRunDependency('cp ' + fullname);
-        if (typeof url == 'string') {
-          Browser.asyncLoad(url, function(byteArray) {
-            processData(byteArray);
-          }, onerror);
-        } else {
-          processData(url);
-        }
-      },indexedDB:function () {
-        return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
-      },DB_NAME:function () {
-        return 'EM_FS_' + window.location.pathname;
-      },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
-        onload = onload || function(){};
-        onerror = onerror || function(){};
-        var indexedDB = FS.indexedDB();
-        try {
-          var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
-        } catch (e) {
-          return onerror(e);
-        }
-        openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
-          console.log('creating db');
-          var db = openRequest.result;
-          db.createObjectStore(FS.DB_STORE_NAME);
-        };
-        openRequest.onsuccess = function openRequest_onsuccess() {
-          var db = openRequest.result;
-          var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
-          var files = transaction.objectStore(FS.DB_STORE_NAME);
-          var ok = 0, fail = 0, total = paths.length;
-          function finish() {
-            if (fail == 0) onload(); else onerror();
-          }
-          paths.forEach(function(path) {
-            var putRequest = files.put(FS.analyzePath(path).object.contents, path);
-            putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
-            putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
-          });
-          transaction.onerror = onerror;
-        };
-        openRequest.onerror = onerror;
-      },loadFilesFromDB:function (paths, onload, onerror) {
-        onload = onload || function(){};
-        onerror = onerror || function(){};
-        var indexedDB = FS.indexedDB();
-        try {
-          var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
-        } catch (e) {
-          return onerror(e);
-        }
-        openRequest.onupgradeneeded = onerror; // no database to load from
-        openRequest.onsuccess = function openRequest_onsuccess() {
-          var db = openRequest.result;
-          try {
-            var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
-          } catch(e) {
-            onerror(e);
-            return;
-          }
-          var files = transaction.objectStore(FS.DB_STORE_NAME);
-          var ok = 0, fail = 0, total = paths.length;
-          function finish() {
-            if (fail == 0) onload(); else onerror();
-          }
-          paths.forEach(function(path) {
-            var getRequest = files.get(path);
-            getRequest.onsuccess = function getRequest_onsuccess() {
-              if (FS.analyzePath(path).exists) {
-                FS.unlink(path);
-              }
-              FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
-              ok++;
-              if (ok + fail == total) finish();
-            };
-            getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
-          });
-          transaction.onerror = onerror;
-        };
-        openRequest.onerror = onerror;
-      }};var PATH={splitPath:function (filename) {
-        var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
-        return splitPathRe.exec(filename).slice(1);
-      },normalizeArray:function (parts, allowAboveRoot) {
-        // if the path tries to go above the root, `up` ends up > 0
-        var up = 0;
-        for (var i = parts.length - 1; i >= 0; i--) {
-          var last = parts[i];
-          if (last === '.') {
-            parts.splice(i, 1);
-          } else if (last === '..') {
-            parts.splice(i, 1);
-            up++;
-          } else if (up) {
-            parts.splice(i, 1);
-            up--;
-          }
-        }
-        // if the path is allowed to go above the root, restore leading ..s
-        if (allowAboveRoot) {
-          for (; up--; up) {
-            parts.unshift('..');
-          }
-        }
-        return parts;
-      },normalize:function (path) {
-        var isAbsolute = path.charAt(0) === '/',
-            trailingSlash = path.substr(-1) === '/';
-        // Normalize the path
-        path = PATH.normalizeArray(path.split('/').filter(function(p) {
-          return !!p;
-        }), !isAbsolute).join('/');
-        if (!path && !isAbsolute) {
-          path = '.';
-        }
-        if (path && trailingSlash) {
-          path += '/';
-        }
-        return (isAbsolute ? '/' : '') + path;
-      },dirname:function (path) {
-        var result = PATH.splitPath(path),
-            root = result[0],
-            dir = result[1];
-        if (!root && !dir) {
-          // No dirname whatsoever
-          return '.';
-        }
-        if (dir) {
-          // It has a dirname, strip trailing slash
-          dir = dir.substr(0, dir.length - 1);
-        }
-        return root + dir;
-      },basename:function (path) {
-        // EMSCRIPTEN return '/'' for '/', not an empty string
-        if (path === '/') return '/';
-        var lastSlash = path.lastIndexOf('/');
-        if (lastSlash === -1) return path;
-        return path.substr(lastSlash+1);
-      },extname:function (path) {
-        return PATH.splitPath(path)[3];
-      },join:function () {
-        var paths = Array.prototype.slice.call(arguments, 0);
-        return PATH.normalize(paths.join('/'));
-      },join2:function (l, r) {
-        return PATH.normalize(l + '/' + r);
-      },resolve:function () {
-        var resolvedPath = '',
-          resolvedAbsolute = false;
-        for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
-          var path = (i >= 0) ? arguments[i] : FS.cwd();
-          // Skip empty and invalid entries
-          if (typeof path !== 'string') {
-            throw new TypeError('Arguments to path.resolve must be strings');
-          } else if (!path) {
-            continue;
-          }
-          resolvedPath = path + '/' + resolvedPath;
-          resolvedAbsolute = path.charAt(0) === '/';
-        }
-        // At this point the path should be resolved to a full absolute path, but
-        // handle relative paths to be safe (might happen when process.cwd() fails)
-        resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
-          return !!p;
-        }), !resolvedAbsolute).join('/');
-        return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
-      },relative:function (from, to) {
-        from = PATH.resolve(from).substr(1);
-        to = PATH.resolve(to).substr(1);
-        function trim(arr) {
-          var start = 0;
-          for (; start < arr.length; start++) {
-            if (arr[start] !== '') break;
-          }
-          var end = arr.length - 1;
-          for (; end >= 0; end--) {
-            if (arr[end] !== '') break;
-          }
-          if (start > end) return [];
-          return arr.slice(start, end - start + 1);
-        }
-        var fromParts = trim(from.split('/'));
-        var toParts = trim(to.split('/'));
-        var length = Math.min(fromParts.length, toParts.length);
-        var samePartsLength = length;
-        for (var i = 0; i < length; i++) {
-          if (fromParts[i] !== toParts[i]) {
-            samePartsLength = i;
-            break;
-          }
-        }
-        var outputParts = [];
-        for (var i = samePartsLength; i < fromParts.length; i++) {
-          outputParts.push('..');
-        }
-        outputParts = outputParts.concat(toParts.slice(samePartsLength));
-        return outputParts.join('/');
-      }};var Browser={mainLoop:{scheduler:null,shouldPause:false,paused:false,queue:[],pause:function () {
-          Browser.mainLoop.shouldPause = true;
-        },resume:function () {
-          if (Browser.mainLoop.paused) {
-            Browser.mainLoop.paused = false;
-            Browser.mainLoop.scheduler();
-          }
-          Browser.mainLoop.shouldPause = false;
-        },updateStatus:function () {
-          if (Module['setStatus']) {
-            var message = Module['statusMessage'] || 'Please wait...';
-            var remaining = Browser.mainLoop.remainingBlockers;
-            var expected = Browser.mainLoop.expectedBlockers;
-            if (remaining) {
-              if (remaining < expected) {
-                Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
-              } else {
-                Module['setStatus'](message);
-              }
-            } else {
-              Module['setStatus']('');
-            }
-          }
-        }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
-        if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
-        if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
-        Browser.initted = true;
-        try {
-          new Blob();
-          Browser.hasBlobConstructor = true;
-        } catch(e) {
-          Browser.hasBlobConstructor = false;
-          console.log("warning: no blob constructor, cannot create blobs with mimetypes");
-        }
-        Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
-        Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
-        if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
-          console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
-          Module.noImageDecoding = true;
-        }
-        // Support for plugins that can process preloaded files. You can add more of these to
-        // your app by creating and appending to Module.preloadPlugins.
-        //
-        // Each plugin is asked if it can handle a file based on the file's name. If it can,
-        // it is given the file's raw data. When it is done, it calls a callback with the file's
-        // (possibly modified) data. For example, a plugin might decompress a file, or it
-        // might create some side data structure for use later (like an Image element, etc.).
-        var imagePlugin = {};
-        imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
-          return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
-        };
-        imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
-          var b = null;
-          if (Browser.hasBlobConstructor) {
-            try {
-              b = new Blob([byteArray], { type: Browser.getMimetype(name) });
-              if (b.size !== byteArray.length) { // Safari bug #118630
-                // Safari's Blob can only take an ArrayBuffer
-                b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
-              }
-            } catch(e) {
-              Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
-            }
-          }
-          if (!b) {
-            var bb = new Browser.BlobBuilder();
-            bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
-            b = bb.getBlob();
-          }
-          var url = Browser.URLObject.createObjectURL(b);
-          var img = new Image();
-          img.onload = function img_onload() {
-            assert(img.complete, 'Image ' + name + ' could not be decoded');
-            var canvas = document.createElement('canvas');
-            canvas.width = img.width;
-            canvas.height = img.height;
-            var ctx = canvas.getContext('2d');
-            ctx.drawImage(img, 0, 0);
-            Module["preloadedImages"][name] = canvas;
-            Browser.URLObject.revokeObjectURL(url);
-            if (onload) onload(byteArray);
-          };
-          img.onerror = function img_onerror(event) {
-            console.log('Image ' + url + ' could not be decoded');
-            if (onerror) onerror();
-          };
-          img.src = url;
-        };
-        Module['preloadPlugins'].push(imagePlugin);
-        var audioPlugin = {};
-        audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
-          return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
-        };
-        audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
-          var done = false;
-          function finish(audio) {
-            if (done) return;
-            done = true;
-            Module["preloadedAudios"][name] = audio;
-            if (onload) onload(byteArray);
-          }
-          function fail() {
-            if (done) return;
-            done = true;
-            Module["preloadedAudios"][name] = new Audio(); // empty shim
-            if (onerror) onerror();
-          }
-          if (Browser.hasBlobConstructor) {
-            try {
-              var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
-            } catch(e) {
-              return fail();
-            }
-            var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
-            var audio = new Audio();
-            audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
-            audio.onerror = function audio_onerror(event) {
-              if (done) return;
-              console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
-              function encode64(data) {
-                var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
-                var PAD = '=';
-                var ret = '';
-                var leftchar = 0;
-                var leftbits = 0;
-                for (var i = 0; i < data.length; i++) {
-                  leftchar = (leftchar << 8) | data[i];
-                  leftbits += 8;
-                  while (leftbits >= 6) {
-                    var curr = (leftchar >> (leftbits-6)) & 0x3f;
-                    leftbits -= 6;
-                    ret += BASE[curr];
-                  }
-                }
-                if (leftbits == 2) {
-                  ret += BASE[(leftchar&3) << 4];
-                  ret += PAD + PAD;
-                } else if (leftbits == 4) {
-                  ret += BASE[(leftchar&0xf) << 2];
-                  ret += PAD;
-                }
-                return ret;
-              }
-              audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
-              finish(audio); // we don't wait for confirmation this worked - but it's worth trying
-            };
-            audio.src = url;
-            // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
-            Browser.safeSetTimeout(function() {
-              finish(audio); // try to use it even though it is not necessarily ready to play
-            }, 10000);
-          } else {
-            return fail();
-          }
-        };
-        Module['preloadPlugins'].push(audioPlugin);
-        // Canvas event setup
-        var canvas = Module['canvas'];
-        canvas.requestPointerLock = canvas['requestPointerLock'] ||
-                                    canvas['mozRequestPointerLock'] ||
-                                    canvas['webkitRequestPointerLock'];
-        canvas.exitPointerLock = document['exitPointerLock'] ||
-                                 document['mozExitPointerLock'] ||
-                                 document['webkitExitPointerLock'] ||
-                                 function(){}; // no-op if function does not exist
-        canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
-        function pointerLockChange() {
-          Browser.pointerLock = document['pointerLockElement'] === canvas ||
-                                document['mozPointerLockElement'] === canvas ||
-                                document['webkitPointerLockElement'] === canvas;
-        }
-        document.addEventListener('pointerlockchange', pointerLockChange, false);
-        document.addEventListener('mozpointerlockchange', pointerLockChange, false);
-        document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
-        if (Module['elementPointerLock']) {
-          canvas.addEventListener("click", function(ev) {
-            if (!Browser.pointerLock && canvas.requestPointerLock) {
-              canvas.requestPointerLock();
-              ev.preventDefault();
-            }
-          }, false);
-        }
-      },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
-        var ctx;
-        try {
-          if (useWebGL) {
-            var contextAttributes = {
-              antialias: false,
-              alpha: false
-            };
-            if (webGLContextAttributes) {
-              for (var attribute in webGLContextAttributes) {
-                contextAttributes[attribute] = webGLContextAttributes[attribute];
-              }
-            }
-            var errorInfo = '?';
-            function onContextCreationError(event) {
-              errorInfo = event.statusMessage || errorInfo;
-            }
-            canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
-            try {
-              ['experimental-webgl', 'webgl'].some(function(webglId) {
-                return ctx = canvas.getContext(webglId, contextAttributes);
-              });
-            } finally {
-              canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
-            }
-          } else {
-            ctx = canvas.getContext('2d');
-          }
-          if (!ctx) throw ':(';
-        } catch (e) {
-          Module.print('Could not create canvas: ' + [errorInfo, e]);
-          return null;
-        }
-        if (useWebGL) {
-          // Set the background of the WebGL canvas to black
-          canvas.style.backgroundColor = "black";
-          // Warn on context loss
-          canvas.addEventListener('webglcontextlost', function(event) {
-            alert('WebGL context lost. You will need to reload the page.');
-          }, false);
-        }
-        if (setInModule) {
-          Module.ctx = ctx;
-          Module.useWebGL = useWebGL;
-          Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
-          Browser.init();
-        }
-        return ctx;
-      },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
-        Browser.lockPointer = lockPointer;
-        Browser.resizeCanvas = resizeCanvas;
-        if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
-        if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
-        var canvas = Module['canvas'];
-        function fullScreenChange() {
-          Browser.isFullScreen = false;
-          if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
-               document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
-               document['fullScreenElement'] || document['fullscreenElement']) === canvas) {
-            canvas.cancelFullScreen = document['cancelFullScreen'] ||
-                                      document['mozCancelFullScreen'] ||
-                                      document['webkitCancelFullScreen'];
-            canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
-            if (Browser.lockPointer) canvas.requestPointerLock();
-            Browser.isFullScreen = true;
-            if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
-          } else if (Browser.resizeCanvas){
-            Browser.setWindowedCanvasSize();
-          }
-          if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
-        }
-        if (!Browser.fullScreenHandlersInstalled) {
-          Browser.fullScreenHandlersInstalled = true;
-          document.addEventListener('fullscreenchange', fullScreenChange, false);
-          document.addEventListener('mozfullscreenchange', fullScreenChange, false);
-          document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
-        }
-        canvas.requestFullScreen = canvas['requestFullScreen'] ||
-                                   canvas['mozRequestFullScreen'] ||
-                                   (canvas['webkitRequestFullScreen'] ? function() { canvas['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
-        canvas.requestFullScreen();
-      },requestAnimationFrame:function requestAnimationFrame(func) {
-        if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
-          setTimeout(func, 1000/60);
-        } else {
-          if (!window.requestAnimationFrame) {
-            window.requestAnimationFrame = window['requestAnimationFrame'] ||
-                                           window['mozRequestAnimationFrame'] ||
-                                           window['webkitRequestAnimationFrame'] ||
-                                           window['msRequestAnimationFrame'] ||
-                                           window['oRequestAnimationFrame'] ||
-                                           window['setTimeout'];
-          }
-          window.requestAnimationFrame(func);
-        }
-      },safeCallback:function (func) {
-        return function() {
-          if (!ABORT) return func.apply(null, arguments);
-        };
-      },safeRequestAnimationFrame:function (func) {
-        return Browser.requestAnimationFrame(function() {
-          if (!ABORT) func();
-        });
-      },safeSetTimeout:function (func, timeout) {
-        return setTimeout(function() {
-          if (!ABORT) func();
-        }, timeout);
-      },safeSetInterval:function (func, timeout) {
-        return setInterval(function() {
-          if (!ABORT) func();
-        }, timeout);
-      },getMimetype:function (name) {
-        return {
-          'jpg': 'image/jpeg',
-          'jpeg': 'image/jpeg',
-          'png': 'image/png',
-          'bmp': 'image/bmp',
-          'ogg': 'audio/ogg',
-          'wav': 'audio/wav',
-          'mp3': 'audio/mpeg'
-        }[name.substr(name.lastIndexOf('.')+1)];
-      },getUserMedia:function (func) {
-        if(!window.getUserMedia) {
-          window.getUserMedia = navigator['getUserMedia'] ||
-                                navigator['mozGetUserMedia'];
-        }
-        window.getUserMedia(func);
-      },getMovementX:function (event) {
-        return event['movementX'] ||
-               event['mozMovementX'] ||
-               event['webkitMovementX'] ||
-               0;
-      },getMovementY:function (event) {
-        return event['movementY'] ||
-               event['mozMovementY'] ||
-               event['webkitMovementY'] ||
-               0;
-      },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
-        if (Browser.pointerLock) {
-          // When the pointer is locked, calculate the coordinates
-          // based on the movement of the mouse.
-          // Workaround for Firefox bug 764498
-          if (event.type != 'mousemove' &&
-              ('mozMovementX' in event)) {
-            Browser.mouseMovementX = Browser.mouseMovementY = 0;
-          } else {
-            Browser.mouseMovementX = Browser.getMovementX(event);
-            Browser.mouseMovementY = Browser.getMovementY(event);
-          }
-          // check if SDL is available
-          if (typeof SDL != "undefined") {
-          	Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
-          	Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
-          } else {
-          	// just add the mouse delta to the current absolut mouse position
-          	// FIXME: ideally this should be clamped against the canvas size and zero
-          	Browser.mouseX += Browser.mouseMovementX;
-          	Browser.mouseY += Browser.mouseMovementY;
-          }        
-        } else {
-          // Otherwise, calculate the movement based on the changes
-          // in the coordinates.
-          var rect = Module["canvas"].getBoundingClientRect();
-          var x, y;
-          if (event.type == 'touchstart' ||
-              event.type == 'touchend' ||
-              event.type == 'touchmove') {
-            var t = event.touches.item(0);
-            if (t) {
-              x = t.pageX - (window.scrollX + rect.left);
-              y = t.pageY - (window.scrollY + rect.top);
-            } else {
-              return;
-            }
-          } else {
-            x = event.pageX - (window.scrollX + rect.left);
-            y = event.pageY - (window.scrollY + rect.top);
-          }
-          // the canvas might be CSS-scaled compared to its backbuffer;
-          // SDL-using content will want mouse coordinates in terms
-          // of backbuffer units.
-          var cw = Module["canvas"].width;
-          var ch = Module["canvas"].height;
-          x = x * (cw / rect.width);
-          y = y * (ch / rect.height);
-          Browser.mouseMovementX = x - Browser.mouseX;
-          Browser.mouseMovementY = y - Browser.mouseY;
-          Browser.mouseX = x;
-          Browser.mouseY = y;
-        }
-      },xhrLoad:function (url, onload, onerror) {
-        var xhr = new XMLHttpRequest();
-        xhr.open('GET', url, true);
-        xhr.responseType = 'arraybuffer';
-        xhr.onload = function xhr_onload() {
-          if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
-            onload(xhr.response);
-          } else {
-            onerror();
-          }
-        };
-        xhr.onerror = onerror;
-        xhr.send(null);
-      },asyncLoad:function (url, onload, onerror, noRunDep) {
-        Browser.xhrLoad(url, function(arrayBuffer) {
-          assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
-          onload(new Uint8Array(arrayBuffer));
-          if (!noRunDep) removeRunDependency('al ' + url);
-        }, function(event) {
-          if (onerror) {
-            onerror();
-          } else {
-            throw 'Loading data file "' + url + '" failed.';
-          }
-        });
-        if (!noRunDep) addRunDependency('al ' + url);
-      },resizeListeners:[],updateResizeListeners:function () {
-        var canvas = Module['canvas'];
-        Browser.resizeListeners.forEach(function(listener) {
-          listener(canvas.width, canvas.height);
-        });
-      },setCanvasSize:function (width, height, noUpdates) {
-        var canvas = Module['canvas'];
-        canvas.width = width;
-        canvas.height = height;
-        if (!noUpdates) Browser.updateResizeListeners();
-      },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
-        var canvas = Module['canvas'];
-        this.windowedWidth = canvas.width;
-        this.windowedHeight = canvas.height;
-        canvas.width = screen.width;
-        canvas.height = screen.height;
-        // check if SDL is available   
-        if (typeof SDL != "undefined") {
-        	var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
-        	flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
-        	HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
-        }
-        Browser.updateResizeListeners();
-      },setWindowedCanvasSize:function () {
-        var canvas = Module['canvas'];
-        canvas.width = this.windowedWidth;
-        canvas.height = this.windowedHeight;
-        // check if SDL is available       
-        if (typeof SDL != "undefined") {
-        	var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
-        	flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
-        	HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
-        }
-        Browser.updateResizeListeners();
-      }};
-___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
-Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
-  Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
-  Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
-  Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
-  Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
-  Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
-FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
-__ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
-if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
-STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
-staticSealed = true; // seal the static portion of memory
-STACK_MAX = STACK_BASE + 5242880;
-DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
-assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
-var Math_min = Math.min;
-function invoke_viiiii(index,a1,a2,a3,a4,a5) {
-  try {
-    Module["dynCall_viiiii"](index,a1,a2,a3,a4,a5);
-  } catch(e) {
-    if (typeof e !== 'number' && e !== 'longjmp') throw e;
-    asm["setThrew"](1, 0);
-  }
-}
-function invoke_vi(index,a1) {
-  try {
-    Module["dynCall_vi"](index,a1);
-  } catch(e) {
-    if (typeof e !== 'number' && e !== 'longjmp') throw e;
-    asm["setThrew"](1, 0);
-  }
-}
-function invoke_ii(index,a1) {
-  try {
-    return Module["dynCall_ii"](index,a1);
-  } catch(e) {
-    if (typeof e !== 'number' && e !== 'longjmp') throw e;
-    asm["setThrew"](1, 0);
-  }
-}
-function invoke_v(index) {
-  try {
-    Module["dynCall_v"](index);
-  } catch(e) {
-    if (typeof e !== 'number' && e !== 'longjmp') throw e;
-    asm["setThrew"](1, 0);
-  }
-}
-function invoke_iii(index,a1,a2) {
-  try {
-    return Module["dynCall_iii"](index,a1,a2);
-  } catch(e) {
-    if (typeof e !== 'number' && e !== 'longjmp') throw e;
-    asm["setThrew"](1, 0);
-  }
-}
-function asmPrintInt(x, y) {
-  Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
-}
-function asmPrintFloat(x, y) {
-  Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
-}
-// EMSCRIPTEN_START_ASM
-var asm=(function(global,env,buffer){"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=+env.NaN;var n=+env.Infinity;var o=0;var p=0;var q=0;var r=0;var s=0,t=0,u=0,v=0,w=0.0,x=0,y=0,z=0,A=0.0;var B=0;var C=0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=global.Math.floor;var M=global.Math.abs;var N=global.Math.sqrt;var O=global.Math.pow;var P=global.Math.cos;var Q=global.Math.sin;var R=global.Math.tan;var S=global.Math.acos;var T=global.Math.asin;var U=global.Math.atan;var V=global.Math.atan2;var W=global.Math.exp;var X=global.Math.log;var Y=global.Math.ceil;var Z=global.Math.imul;var _=env.abort;var $=env.assert;var aa=env.asmPrintInt;var ab=env.asmPrintFloat;var ac=env.min;var ad=env.invoke_viiiii;var ae=env.invoke_vi;var af=env.invoke_ii;var ag=env.invoke_v;var ah=env.invoke_iii;var ai=env._llvm_lifetime_end;var aj=env._sysconf;var ak=env._sbrk;var al=env.___setErrNo;var am=env.___errno_location;var an=env._llvm_lifetime_start;var ao=env._abort;var ap=env._time;var aq=env._fflush;var ar=0.0;
-// EMSCRIPTEN_START_FUNCS
-function ax(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+7&-8;return b|0}function ay(){return i|0}function az(a){a=a|0;i=a}function aA(a,b){a=a|0;b=b|0;if((o|0)==0){o=a;p=b}}function aB(b){b=b|0;a[k]=a[b];a[k+1|0]=a[b+1|0];a[k+2|0]=a[b+2|0];a[k+3|0]=a[b+3|0]}function aC(b){b=b|0;a[k]=a[b];a[k+1|0]=a[b+1|0];a[k+2|0]=a[b+2|0];a[k+3|0]=a[b+3|0];a[k+4|0]=a[b+4|0];a[k+5|0]=a[b+5|0];a[k+6|0]=a[b+6|0];a[k+7|0]=a[b+7|0]}function aD(a){a=a|0;B=a}function aE(a){a=a|0;C=a}function aF(a){a=a|0;D=a}function aG(a){a=a|0;E=a}function aH(a){a=a|0;F=a}function aI(a){a=a|0;G=a}function aJ(a){a=a|0;H=a}function aK(a){a=a|0;I=a}function aL(a){a=a|0;J=a}function aM(a){a=a|0;K=a}function aN(){}function aO(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0;L1:do{if(e>>>0>3>>>0){if((a[b]|0)!=0){h=19;break}if((a[b+1|0]|0)!=0){h=19;break}i=a[b+2|0]|0;if((i&255)>>>0>=2>>>0){h=19;break}L6:do{if((e|0)!=3){j=2;k=b+3|0;l=3;m=-3;n=i;while(1){if((n<<24>>24|0)==0){o=j+1|0}else if((n<<24>>24|0)==1){if(j>>>0>1>>>0){p=k;q=0;r=0;s=0;t=l;break}else{o=0}}else{o=0}u=l+1|0;if((u|0)==(e|0)){break L6}v=~l;w=a[k]|0;j=o;k=k+1|0;l=u;m=v;n=w}while(1){n=a[p]|0;k=t+1|0;j=n<<24>>24!=0;x=(j&1^1)+s|0;y=n<<24>>24==3&(x|0)==2?1:r;if(n<<24>>24==1&x>>>0>1>>>0){h=14;break}if(j){z=x>>>0>2>>>0?1:q;A=0}else{z=q;A=x}if((k|0)==(e|0)){h=18;break}else{p=p+1|0;q=z;r=y;s=A;t=k}}if((h|0)==14){k=m+t-x|0;c[f+12>>2]=k;B=q;C=y;D=x-(x>>>0<3>>>0?x:3)|0;E=l;F=k;break L1}else if((h|0)==18){k=m+e-A|0;c[f+12>>2]=k;B=z;C=y;D=A;E=l;F=k;break L1}}}while(0);c[g>>2]=e;G=1;return G|0}else{h=19}}while(0);if((h|0)==19){c[f+12>>2]=e;B=0;C=1;D=0;E=0;F=e}e=b+E|0;b=f|0;c[b>>2]=e;c[f+4>>2]=e;c[f+8>>2]=0;c[f+16>>2]=0;e=f+12|0;c[g>>2]=D+E+F;if((B|0)!=0){G=1;return G|0}if((C|0)==0){G=0;return G|0}C=c[b>>2]|0;b=C;B=C;C=0;F=c[e>>2]|0;L35:while(1){H=B;E=C;D=F;while(1){I=D-1|0;if((D|0)==0){h=31;break L35}J=a[H]|0;if((E|0)!=2){K=E;break}if(J<<24>>24!=3){h=29;break}if((I|0)==0){G=1;h=36;break L35}g=H+1|0;if((d[g]|0)>>>0>3>>>0){G=1;h=37;break L35}else{H=g;E=0;D=I}}if((h|0)==29){h=0;if((J&255)>>>0<3>>>0){G=1;h=38;break}else{K=2}}a[b]=J;b=b+1|0;B=H+1|0;C=J<<24>>24==0?K+1|0:0;F=I}if((h|0)==31){c[e>>2]=b-H+(c[e>>2]|0);G=0;return G|0}else if((h|0)==36){return G|0}else if((h|0)==37){return G|0}else if((h|0)==38){return G|0}return 0}function aP(e,f,g,h){e=e|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0;j=i;i=i+128|0;k=j|0;l=j+64|0;m=cm(e)|0;n=m>>>16;do{if(g>>>0<2>>>0){if((m|0)<0){o=1;break}if(m>>>0>201326591>>>0){p=4016+(m>>>26<<1)|0;q=25;break}if(m>>>0>16777215>>>0){p=3920+(m>>>22<<1)|0;q=25;break}if(m>>>0>2097151>>>0){p=3808+((m>>>18)-8<<1)|0;q=25;break}else{p=3744+(n<<1)|0;q=25;break}}else{if(g>>>0<4>>>0){if((m|0)<0){o=(n&16384|0)!=0?2:2082;break}if(m>>>0>268435455>>>0){p=3680+(m>>>26<<1)|0;q=25;break}if(m>>>0>33554431>>>0){p=3616+(m>>>23<<1)|0;q=25;break}else{p=3360+(m>>>18<<1)|0;q=25;break}}else{if(g>>>0<8>>>0){r=m>>>26;if((r-8|0)>>>0<56>>>0){p=3232+(r<<1)|0;q=25;break}p=2976+(m>>>22<<1)|0;q=25;break}if(g>>>0<17>>>0){p=2848+(m>>>26<<1)|0;q=25;break}r=m>>>29;if((r|0)!=0){p=2832+(r<<1)|0;q=25;break}p=2768+(m>>>24<<1)|0;q=25;break}}}while(0);do{if((q|0)==25){g=b[p>>1]|0;if(g<<16>>16==0){s=1}else{o=g&65535;break}i=j;return s|0}}while(0);p=o&31;g=m<<p;m=32-p|0;n=o>>>11;if(n>>>0>h>>>0){s=1;i=j;return s|0}r=o>>>5&63;do{if((n|0)==0){t=m;u=0}else{if((r|0)==0){v=m;w=g;x=0}else{do{if(m>>>0<r>>>0){if((cn(e,p)|0)==-1){s=1;i=j;return s|0}else{y=32;z=cm(e)|0;break}}else{y=m;z=g}}while(0);A=z>>>((32-r|0)>>>0);B=z<<r;C=1<<r-1;D=0;do{c[k+(D<<2)>>2]=(C&A|0)!=0?-1:1;C=C>>>1;D=D+1|0;}while((C|0)!=0);v=y-r|0;w=B;x=D}C=r>>>0<3>>>0;L55:do{if(x>>>0<n>>>0){A=x;E=o>>>0>22527>>>0&C&1;F=w;G=v;L57:while(1){if(G>>>0<16>>>0){if((cn(e,32-G|0)|0)==-1){s=1;q=130;break}H=32;I=cm(e)|0}else{H=G;I=F
\ No newline at end of file
-// EMSCRIPTEN_END_FUNCS
-var as=[cN,cN,bY,cN,bZ,cN,cN,cN];var at=[cO,cO];var au=[cP,cP];var av=[cQ,cQ];var aw=[cR,cR];return{_h264bsdCroppingParams:a5,_strlen:cH,_h264bsdInit:a_,_h264bsdNextOutputPicture:a1,_h264bsdAlloc:a6,_h264bsdShutdown:a0,_memset:cF,_malloc:cD,_memcpy:cG,_h264bsdPicWidth:a2,_h264bsdFree:a7,_free:cE,_h264bsdCheckValidParamSets:a4,_h264bsdDecode:a$,_h264bsdPicHeight:a3,runPostSets:aN,stackAlloc:ax,stackSave:ay,stackRestore:az,setThrew:aA,setTempRet0:aD,setTempRet1:aE,setTempRet2:aF,setTempRet3:aG,setTempRet4:aH,setTempRet5:aI,setTempRet6:aJ,setTempRet7:aK,setTempRet8:aL,setTempRet9:aM,dynCall_viiiii:cI,dynCall_vi:cJ,dynCall_ii:cK,dynCall_v:cL,dynCall_iii:cM}})
-// EMSCRIPTEN_END_ASM
-({ "Math": Math, "Int8Array": Int8Array, "Int16Array": Int16Array, "Int32Array": Int32Array, "Uint8Array": Uint8Array, "Uint16Array": Uint16Array, "Uint32Array": Uint32Array, "Float32Array": Float32Array, "Float64Array": Float64Array }, { "abort": abort, "assert": assert, "asmPrintInt": asmPrintInt, "asmPrintFloat": asmPrintFloat, "min": Math_min, "invoke_viiiii": invoke_viiiii, "invoke_vi": invoke_vi, "invoke_ii": invoke_ii, "invoke_v": invoke_v, "invoke_iii": invoke_iii, "_llvm_lifetime_end": _llvm_lifetime_end, "_sysconf": _sysconf, "_sbrk": _sbrk, "___setErrNo": ___setErrNo, "___errno_location": ___errno_location, "_llvm_lifetime_start": _llvm_lifetime_start, "_abort": _abort, "_time": _time, "_fflush": _fflush, "STACKTOP": STACKTOP, "STACK_MAX": STACK_MAX, "tempDoublePtr": tempDoublePtr, "ABORT": ABORT, "NaN": NaN, "Infinity": Infinity }, buffer);
-var _h264bsdCroppingParams = Module["_h264bsdCroppingParams"] = asm["_h264bsdCroppingParams"];
-var _strlen = Module["_strlen"] = asm["_strlen"];
-var _h264bsdInit = Module["_h264bsdInit"] = asm["_h264bsdInit"];
-var _h264bsdNextOutputPicture = Module["_h264bsdNextOutputPicture"] = asm["_h264bsdNextOutputPicture"];
-var _h264bsdAlloc = Module["_h264bsdAlloc"] = asm["_h264bsdAlloc"];
-var _h264bsdShutdown = Module["_h264bsdShutdown"] = asm["_h264bsdShutdown"];
-var _memset = Module["_memset"] = asm["_memset"];
-var _malloc = Module["_malloc"] = asm["_malloc"];
-var _memcpy = Module["_memcpy"] = asm["_memcpy"];
-var _h264bsdPicWidth = Module["_h264bsdPicWidth"] = asm["_h264bsdPicWidth"];
-var _h264bsdFree = Module["_h264bsdFree"] = asm["_h264bsdFree"];
-var _free = Module["_free"] = asm["_free"];
-var _h264bsdCheckValidParamSets = Module["_h264bsdCheckValidParamSets"] = asm["_h264bsdCheckValidParamSets"];
-var _h264bsdDecode = Module["_h264bsdDecode"] = asm["_h264bsdDecode"];
-var _h264bsdPicHeight = Module["_h264bsdPicHeight"] = asm["_h264bsdPicHeight"];
-var runPostSets = Module["runPostSets"] = asm["runPostSets"];
-var dynCall_viiiii = Module["dynCall_viiiii"] = asm["dynCall_viiiii"];
-var dynCall_vi = Module["dynCall_vi"] = asm["dynCall_vi"];
-var dynCall_ii = Module["dynCall_ii"] = asm["dynCall_ii"];
-var dynCall_v = Module["dynCall_v"] = asm["dynCall_v"];
-var dynCall_iii = Module["dynCall_iii"] = asm["dynCall_iii"];
-Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };
-Runtime.stackSave = function() { return asm['stackSave']() };
-Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
-// Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included
-var i64Math = null;
-// === Auto-generated postamble setup entry stuff ===
-if (memoryInitializer) {
-  function applyData(data) {
-    HEAPU8.set(data, STATIC_BASE);
-  }
-  if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {
-    applyData(Module['readBinary'](memoryInitializer));
-  } else {
-    addRunDependency('memory initializer');
-    Browser.asyncLoad(memoryInitializer, function(data) {
-      applyData(data);
-      removeRunDependency('memory initializer');
-    }, function(data) {
-      throw 'could not load memory initializer ' + memoryInitializer;
-    });
-  }
-}
-function ExitStatus(status) {
-  this.name = "ExitStatus";
-  this.message = "Program terminated with exit(" + status + ")";
-  this.status = status;
-};
-ExitStatus.prototype = new Error();
-ExitStatus.prototype.constructor = ExitStatus;
-var initialStackTop;
-var preloadStartTime = null;
-var calledMain = false;
-dependenciesFulfilled = function runCaller() {
-  // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
-  if (!Module['calledRun'] && shouldRunNow) run();
-  if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
-}
-Module['callMain'] = Module.callMain = function callMain(args) {
-  assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');
-  assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');
-  args = args || [];
-  if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {
-    Module.printErr('preload time: ' + (Date.now() - preloadStartTime) + ' ms');
-  }
-  ensureInitRuntime();
-  var argc = args.length+1;
-  function pad() {
-    for (var i = 0; i < 4-1; i++) {
-      argv.push(0);
-    }
-  }
-  var argv = [allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL) ];
-  pad();
-  for (var i = 0; i < argc-1; i = i + 1) {
-    argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));
-    pad();
-  }
-  argv.push(0);
-  argv = allocate(argv, 'i32', ALLOC_NORMAL);
-  initialStackTop = STACKTOP;
-  try {
-    var ret = Module['_main'](argc, argv, 0);
-    // if we're not running an evented main loop, it's time to exit
-    if (!Module['noExitRuntime']) {
-      exit(ret);
-    }
-  }
-  catch(e) {
-    if (e instanceof ExitStatus) {
-      // exit() throws this once it's done to make sure execution
-      // has been stopped completely
-      return;
-    } else if (e == 'SimulateInfiniteLoop') {
-      // running an evented main loop, don't immediately exit
-      Module['noExitRuntime'] = true;
-      return;
-    } else {
-      if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
-      throw e;
-    }
-  } finally {
-    calledMain = true;
-  }
-}
-function run(args) {
-  args = args || Module['arguments'];
-  if (preloadStartTime === null) preloadStartTime = Date.now();
-  if (runDependencies > 0) {
-    Module.printErr('run() called, but dependencies remain, so not running');
-    return;
-  }
-  preRun();
-  if (runDependencies > 0) {
-    // a preRun added a dependency, run will be called later
-    return;
-  }
-  function doRun() {
-    ensureInitRuntime();
-    preMain();
-    Module['calledRun'] = true;
-    if (Module['_main'] && shouldRunNow) {
-      Module['callMain'](args);
-    }
-    postRun();
-  }
-  if (Module['setStatus']) {
-    Module['setStatus']('Running...');
-    setTimeout(function() {
-      setTimeout(function() {
-        Module['setStatus']('');
-      }, 1);
-      if (!ABORT) doRun();
-    }, 1);
-  } else {
-    doRun();
-  }
-}
-Module['run'] = Module.run = run;
-function exit(status) {
-  ABORT = true;
-  EXITSTATUS = status;
-  STACKTOP = initialStackTop;
-  // exit the runtime
-  exitRuntime();
-  // TODO We should handle this differently based on environment.
-  // In the browser, the best we can do is throw an exception
-  // to halt execution, but in node we could process.exit and
-  // I'd imagine SM shell would have something equivalent.
-  // This would let us set a proper exit status (which
-  // would be great for checking test exit statuses).
-  // https://github.com/kripken/emscripten/issues/1371
-  // throw an exception to halt the current execution
-  throw new ExitStatus(status);
-}
-Module['exit'] = Module.exit = exit;
-function abort(text) {
-  if (text) {
-    Module.print(text);
-    Module.printErr(text);
-  }
-  ABORT = true;
-  EXITSTATUS = 1;
-  throw 'abort() at ' + stackTrace();
-}
-Module['abort'] = Module.abort = abort;
-// {{PRE_RUN_ADDITIONS}}
-if (Module['preInit']) {
-  if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
-  while (Module['preInit'].length > 0) {
-    Module['preInit'].pop()();
-  }
-}
-// shouldRunNow refers to calling main(), not run().
-var shouldRunNow = true;
-if (Module['noInitialRun']) {
-  shouldRunNow = false;
-}
-run();
-// {{POST_RUN_ADDITIONS}}
-// {{MODULE_ADDITIONS}}
-
-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 17={3i:\'0.1.3\',16:1e-6};l v(){}v.23={e:l(i){8(i<1||i>7.4.q)?w:7.4[i-1]},2R:l(){8 7.4.q},1u:l(){8 F.1x(7.2u(7))},24:l(a){9 n=7.4.q;9 V=a.4||a;o(n!=V.q){8 1L}J{o(F.13(7.4[n-1]-V[n-1])>17.16){8 1L}}H(--n);8 2x},1q:l(){8 v.u(7.4)},1b:l(a){9 b=[];7.28(l(x,i){b.19(a(x,i))});8 v.u(b)},28:l(a){9 n=7.4.q,k=n,i;J{i=k-n;a(7.4[i],i+1)}H(--n)},2q:l(){9 r=7.1u();o(r===0){8 7.1q()}8 7.1b(l(x){8 x/r})},1C:l(a){9 V=a.4||a;9 n=7.4.q,k=n,i;o(n!=V.q){8 w}9 b=0,1D=0,1F=0;7.28(l(x,i){b+=x*V[i-1];1D+=x*x;1F+=V[i-1]*V[i-1]});1D=F.1x(1D);1F=F.1x(1F);o(1D*1F===0){8 w}9 c=b/(1D*1F);o(c<-1){c=-1}o(c>1){c=1}8 F.37(c)},1m:l(a){9 b=7.1C(a);8(b===w)?w:(b<=17.16)},34:l(a){9 b=7.1C(a);8(b===w)?w:(F.13(b-F.1A)<=17.16)},2k:l(a){9 b=7.2u(a);8(b===w)?w:(F.13(b)<=17.16)},2j:l(a){9 V=a.4||a;o(7.4.q!=V.q){8 w}8 7.1b(l(x,i){8 x+V[i-1]})},2C:l(a){9 V=a.4||a;o(7.4.q!=V.q){8 w}8 7.1b(l(x,i){8 x-V[i-1]})},22:l(k){8 7.1b(l(x){8 x*k})},x:l(k){8 7.22(k)},2u:l(a){9 V=a.4||a;9 i,2g=0,n=7.4.q;o(n!=V.q){8 w}J{2g+=7.4[n-1]*V[n-1]}H(--n);8 2g},2f:l(a){9 B=a.4||a;o(7.4.q!=3||B.q!=3){8 w}9 A=7.4;8 v.u([(A[1]*B[2])-(A[2]*B[1]),(A[2]*B[0])-(A[0]*B[2]),(A[0]*B[1])-(A[1]*B[0])])},2A:l(){9 m=0,n=7.4.q,k=n,i;J{i=k-n;o(F.13(7.4[i])>F.13(m)){m=7.4[i]}}H(--n);8 m},2Z:l(x){9 a=w,n=7.4.q,k=n,i;J{i=k-n;o(a===w&&7.4[i]==x){a=i+1}}H(--n);8 a},3g:l(){8 S.2X(7.4)},2d:l(){8 7.1b(l(x){8 F.2d(x)})},2V:l(x){8 7.1b(l(y){8(F.13(y-x)<=17.16)?x:y})},1o:l(a){o(a.K){8 a.1o(7)}9 V=a.4||a;o(V.q!=7.4.q){8 w}9 b=0,2b;7.28(l(x,i){2b=x-V[i-1];b+=2b*2b});8 F.1x(b)},3a:l(a){8 a.1h(7)},2T:l(a){8 a.1h(7)},1V:l(t,a){9 V,R,x,y,z;2S(7.4.q){27 2:V=a.4||a;o(V.q!=2){8 w}R=S.1R(t).4;x=7.4[0]-V[0];y=7.4[1]-V[1];8 v.u([V[0]+R[0][0]*x+R[0][1]*y,V[1]+R[1][0]*x+R[1][1]*y]);1I;27 3:o(!a.U){8 w}9 C=a.1r(7).4;R=S.1R(t,a.U).4;x=7.4[0]-C[0];y=7.4[1]-C[1];z=7.4[2]-C[2];8 v.u([C[0]+R[0][0]*x+R[0][1]*y+R[0][2]*z,C[1]+R[1][0]*x+R[1][1]*y+R[1][2]*z,C[2]+R[2][0]*x+R[2][1]*y+R[2][2]*z]);1I;2P:8 w}},1t:l(a){o(a.K){9 P=7.4.2O();9 C=a.1r(P).4;8 v.u([C[0]+(C[0]-P[0]),C[1]+(C[1]-P[1]),C[2]+(C[2]-(P[2]||0))])}1d{9 Q=a.4||a;o(7.4.q!=Q.q){8 w}8 7.1b(l(x,i){8 Q[i-1]+(Q[i-1]-x)})}},1N:l(){9 V=7.1q();2S(V.4.q){27 3:1I;27 2:V.4.19(0);1I;2P:8 w}8 V},2n:l(){8\'[\'+7.4.2K(\', \')+\']\'},26:l(a){7.4=(a.4||a).2O();8 7}};v.u=l(a){9 V=25 v();8 V.26(a)};v.i=v.u([1,0,0]);v.j=v.u([0,1,0]);v.k=v.u([0,0,1]);v.2J=l(n){9 a=[];J{a.19(F.2F())}H(--n);8 v.u(a)};v.1j=l(n){9 a=[];J{a.19(0)}H(--n);8 v.u(a)};l S(){}S.23={e:l(i,j){o(i<1||i>7.4.q||j<1||j>7.4[0].q){8 w}8 7.4[i-1][j-1]},33:l(i){o(i>7.4.q){8 w}8 v.u(7.4[i-1])},2E:l(j){o(j>7.4[0].q){8 w}9 a=[],n=7.4.q,k=n,i;J{i=k-n;a.19(7.4[i][j-1])}H(--n);8 v.u(a)},2R:l(){8{2D:7.4.q,1p:7.4[0].q}},2D:l(){8 7.4.q},1p:l(){8 7.4[0].q},24:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(7.4.q!=M.q||7.4[0].q!=M[0].q){8 1L}9 b=7.4.q,15=b,i,G,10=7.4[0].q,j;J{i=15-b;G=10;J{j=10-G;o(F.13(7.4[i][j]-M[i][j])>17.16){8 1L}}H(--G)}H(--b);8 2x},1q:l(){8 S.u(7.4)},1b:l(a){9 b=[],12=7.4.q,15=12,i,G,10=7.4[0].q,j;J{i=15-12;G=10;b[i]=[];J{j=10-G;b[i][j]=a(7.4[i][j],i+1,j+1)}H(--G)}H(--12);8 S.u(b)},2i:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}8(7.4.q==M.q&&7.4[0].q==M[0].q)},2j:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(!7.2i(M)){8 w}8 7.1b(l(x,i,j){8 x+M[i-1][j-1]})},2C:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(!7.2i(M)){8 w}8 7.1b(l(x,i,j){8 x-M[i-1][j-1]})},2B:l(a){9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}8(7.4[0].q==M.q)},22:l(a){o(!a.4){8 7.1b(l(x){8 x*a})}9 b=a.1u?2x:1L;9 M=a.4||a;o(1g(M[0][0])==\'1f\'){M=S.u(M).4}o(!7.2B(M)){8 w}9 d=7.4.q,15=d,i,G,10=M[0].q,j;9 e=7.4[0].q,4=[],21,20,c;J{i=15-d;4[i]=[];G=10;J{j=10-G;21=0;20=e;J{c=e-20;21+=7.4[i][c]*M[c][j]}H(--20);4[i][j]=21}H(--G)}H(--d);9 M=S.u(4);8 b?M.2E(1):M},x:l(a){8 7.22(a)},32:l(a,b,c,d){9 e=[],12=c,i,G,j;9 f=7.4.q,1p=7.4
\ No newline at end of file
-// augment Sylvester some
-Matrix.Translation = function (v)
-{
-  if (v.elements.length == 2) {
-    var r = Matrix.I(3);
-    r.elements[2][0] = v.elements[0];
-    r.elements[2][1] = v.elements[1];
-    return r;
-  }
-
-  if (v.elements.length == 3) {
-    var r = Matrix.I(4);
-    r.elements[0][3] = v.elements[0];
-    r.elements[1][3] = v.elements[1];
-    r.elements[2][3] = v.elements[2];
-    return r;
-  }
-
-  throw "Invalid length for Translation";
-}
-
-Matrix.prototype.flatten = function ()
-{
-    var result = [];
-    if (this.elements.length == 0)
-        return [];
-
-
-    for (var j = 0; j < this.elements[0].length; j++)
-        for (var i = 0; i < this.elements.length; i++)
-            result.push(this.elements[i][j]);
-    return result;
-}
-
-Matrix.prototype.ensure4x4 = function()
-{
-    if (this.elements.length == 4 &&
-        this.elements[0].length == 4)
-        return this;
-
-    if (this.elements.length > 4 ||
-        this.elements[0].length > 4)
-        return null;
-
-    for (var i = 0; i < this.elements.length; i++) {
-        for (var j = this.elements[i].length; j < 4; j++) {
-            if (i == j)
-                this.elements[i].push(1);
-            else
-                this.elements[i].push(0);
-        }
-    }
-
-    for (var i = this.elements.length; i < 4; i++) {
-        if (i == 0)
-            this.elements.push([1, 0, 0, 0]);
-        else if (i == 1)
-            this.elements.push([0, 1, 0, 0]);
-        else if (i == 2)
-            this.elements.push([0, 0, 1, 0]);
-        else if (i == 3)
-            this.elements.push([0, 0, 0, 1]);
-    }
-
-    return this;
-};
-
-Matrix.prototype.make3x3 = function()
-{
-    if (this.elements.length != 4 ||
-        this.elements[0].length != 4)
-        return null;
-
-    return Matrix.create([[this.elements[0][0], this.elements[0][1], this.elements[0][2]],
-                          [this.elements[1][0], this.elements[1][1], this.elements[1][2]],
-                          [this.elements[2][0], this.elements[2][1], this.elements[2][2]]]);
-};
-
-Vector.prototype.flatten = function ()
-{
-    return this.elements;
-};
-
-function mht(m) {
-    var s = "";
-    if (m.length == 16) {
-        for (var i = 0; i < 4; i++) {
-            s += "<span style='font-family: monospace'>[" + m[i*4+0].toFixed(4) + "," + m[i*4+1].toFixed(4) + "," + m[i*4+2].toFixed(4) + "," + m[i*4+3].toFixed(4) + "]</span><br>";
-        }
-    } else if (m.length == 9) {
-        for (var i = 0; i < 3; i++) {
-            s += "<span style='font-family: monospace'>[" + m[i*3+0].toFixed(4) + "," + m[i*3+1].toFixed(4) + "," + m[i*3+2].toFixed(4) + "]</font><br>";
-        }
-    } else {
-        return m.toString();
-    }
-    return s;
-}
-
-//
-// gluLookAt
-//
-function makeLookAt(ex, ey, ez,
-                    cx, cy, cz,
-                    ux, uy, uz)
-{
-    var eye = $V([ex, ey, ez]);
-    var center = $V([cx, cy, cz]);
-    var up = $V([ux, uy, uz]);
-
-    var mag;
-
-    var z = eye.subtract(center).toUnitVector();
-    var x = up.cross(z).toUnitVector();
-    var y = z.cross(x).toUnitVector();
-
-    var m = $M([[x.e(1), x.e(2), x.e(3), 0],
-                [y.e(1), y.e(2), y.e(3), 0],
-                [z.e(1), z.e(2), z.e(3), 0],
-                [0, 0, 0, 1]]);
-
-    var t = $M([[1, 0, 0, -ex],
-                [0, 1, 0, -ey],
-                [0, 0, 1, -ez],
-                [0, 0, 0, 1]]);
-    return m.x(t);
-}
-
-//
-// glOrtho
-//
-function makeOrtho(left, right,
-                   bottom, top,
-                   znear, zfar)
-{
-    var tx = -(right+left)/(right-left);
-    var ty = -(top+bottom)/(top-bottom);
-    var tz = -(zfar+znear)/(zfar-znear);
-
-    return $M([[2/(right-left), 0, 0, tx],
-               [0, 2/(top-bottom), 0, ty],
-               [0, 0, -2/(zfar-znear), tz],
-               [0, 0, 0, 1]]);
-}
-
-//
-// gluPerspective
-//
-function makePerspective(fovy, aspect, znear, zfar)
-{
-    var ymax = znear * Math.tan(fovy * Math.PI / 360.0);
-    var ymin = -ymax;
-    var xmin = ymin * aspect;
-    var xmax = ymax * aspect;
-
-    return makeFrustum(xmin, xmax, ymin, ymax, znear, zfar);
-}
-
-//
-// glFrustum
-//
-function makeFrustum(left, right,
-                     bottom, top,
-                     znear, zfar)
-{
-    var X = 2*znear/(right-left);
-    var Y = 2*znear/(top-bottom);
-    var A = (right+left)/(right-left);
-    var B = (top+bottom)/(top-bottom);
-    var C = -(zfar+znear)/(zfar-znear);
-    var D = -2*zfar*znear/(zfar-znear);
-
-    return $M([[X, 0, A, 0],
-               [0, Y, B, 0],
-               [0, 0, C, D],
-               [0, 0, -1, 0]]);
-}
-
-//
-// glOrtho
-//
-function makeOrtho(left, right, bottom, top, znear, zfar)
-{
-    var tx = - (right + left) / (right - left);
-    var ty = - (top + bottom) / (top - bottom);
-    var tz = - (zfar + znear) / (zfar - znear);
-
-    return $M([[2 / (right - left), 0, 0, tx],
-           [0, 2 / (top - bottom), 0, ty],
-           [0, 0, -2 / (zfar - znear), tz],
-           [0, 0, 0, 1]]);
-}
-
-
-'use strict';
-
-function error(message) {
-  console.error(message);
-  console.trace();
-}
-
-function assert(condition, message) {
-  if (!condition) {
-    error(message);
-  }
-}
-
-function isPowerOfTwo(x) {
-  return (x & (x - 1)) == 0;
-}
-
-/**
- * Joins a list of lines using a newline separator, not the fastest
- * thing in the world but good enough for initialization code. 
- */
-function text(lines) {
-  return lines.join("\n");
-}
-
-/**
- * Rounds up to the next highest power of two.
- */
-function nextHighestPowerOfTwo(x) {
-  --x;
-  for (var i = 1; i < 32; i <<= 1) {
-      x = x | x >> i;
-  }
-  return x + 1;
-}
-
-/**
- * Represents a 2-dimensional size value. 
- */
-var Size = (function size() {
-  function constructor(w, h) {
-    this.w = w;
-    this.h = h;
-  }
-  constructor.prototype = {
-    toString: function () {
-      return "(" + this.w + ", " + this.h + ")";
-    },
-    getHalfSize: function() {
-      return new Size(this.w >>> 1, this.h >>> 1);
-    },
-    length: function() {
-      return this.w * this.h;
-    }
-  }
-  return constructor;
-})();
-
-/**
- * Creates a new prototype object derived from another objects prototype along with a list of additional properties.
- *
- * @param base object whose prototype to use as the created prototype object's prototype
- * @param properties additional properties to add to the created prototype object
- */
-function inherit(base, properties) {
-  var prot = Object.create(base.prototype);
-  for (var p in properties) {
-    prot[p] = properties[p];
-  }
-  return prot;
-}
-/*
- * This file wraps several WebGL constructs and provides a simple, single texture based WebGLCanvas as well as a
- * specialized YUVWebGLCanvas that can handle YUV->RGB conversion. 
- */
-
-/**
- * Represents a WebGL shader script.
- */
-var Script = (function script() {
-  function constructor() {}
-  
-  constructor.createFromElementId = function(id) {
-    var script = document.getElementById(id);
-    
-    // Didn't find an element with the specified ID, abort.
-    assert(script , "Could not find shader with ID: " + id);
-    
-    // Walk through the source element's children, building the shader source string.
-    var source = "";
-    var currentChild = script .firstChild;
-    while(currentChild) {
-      if (currentChild.nodeType == 3) {
-        source += currentChild.textContent;
-      }
-      currentChild = currentChild.nextSibling;
-    }
-    
-    var res = new constructor();
-    res.type = script.type;
-    res.source = source;
-    return res;
-  };
-  
-  constructor.createFromSource = function(type, source) {
-    var res = new constructor();
-    res.type = type;
-    res.source = source;
-    return res;
-  }
-  return constructor;
-})();
-
-/**
- * Represents a WebGL shader object and provides a mechanism to load shaders from HTML
- * script tags.
- */
-var Shader = (function shader() {
-  function constructor(gl, script) {
-    
-    // Now figure out what type of shader script we have, based on its MIME type.
-    if (script.type == "x-shader/x-fragment") {
-      this.shader = gl.createShader(gl.FRAGMENT_SHADER);
-    } else if (script.type == "x-shader/x-vertex") {
-      this.shader = gl.createShader(gl.VERTEX_SHADER);
-    } else {
-      error("Unknown shader type: " + script.type);
-      return;
-    }
-    
-    // Send the source to the shader object.
-    gl.shaderSource(this.shader, script.source);
-    
-    // Compile the shader program.
-    gl.compileShader(this.shader);
-    
-    // See if it compiled successfully.
-    if (!gl.getShaderParameter(this.shader, gl.COMPILE_STATUS)) {
-      error("An error occurred compiling the shaders: " + gl.getShaderInfoLog(this.shader));
-      return;
-    }
-  }
-  return constructor;
-})();
-
-var Program = (function () {
-  function constructor(gl) {
-    this.gl = gl;
-    this.program = this.gl.createProgram();
-  }
-  constructor.prototype = {
-    attach: function (shader) {
-      this.gl.attachShader(this.program, shader.shader);
-    }, 
-    link: function () {
-      this.gl.linkProgram(this.program);
-      // If creating the shader program failed, alert.
-      assert(this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS),
-             "Unable to initialize the shader program.");
-    },
-    use: function () {
-      this.gl.useProgram(this.program);
-    },
-    getAttributeLocation: function(name) {
-      return this.gl.getAttribLocation(this.program, name);
-    },
-    setMatrixUniform: function(name, array) {
-      var uniform = this.gl.getUniformLocation(this.program, name);
-      this.gl.uniformMatrix4fv(uniform, false, array);
-    }
-  };
-  return constructor;
-})();
-
-/**
- * Represents a WebGL texture object.
- */
-var Texture = (function texture() {
-  function constructor(gl, size, format) {
-    this.gl = gl;
-    this.size = size;
-    this.texture = gl.createTexture();
-    gl.bindTexture(gl.TEXTURE_2D, this.texture);
-    this.format = format ? format : gl.LUMINANCE; 
-    gl.texImage2D(gl.TEXTURE_2D, 0, this.format, size.w, size.h, 0, this.format, gl.UNSIGNED_BYTE, null);
-    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
-    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
-    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-  }
-  var textureIDs = null;
-  constructor.prototype = {
-    fill: function(textureData, useTexSubImage2D) {
-      var gl = this.gl;
-      assert(textureData.length >= this.size.w * this.size.h, 
-             "Texture size mismatch, data:" + textureData.length + ", texture: " + this.size.w * this.size.h);
-      gl.bindTexture(gl.TEXTURE_2D, this.texture);
-      if (useTexSubImage2D) {
-        gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.size.w , this.size.h, this.format, gl.UNSIGNED_BYTE, textureData);
-      } else {
-        // texImage2D seems to be faster, thus keeping it as the default
-        gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.size.w, this.size.h, 0, this.format, gl.UNSIGNED_BYTE, textureData);
-      }
-    },
-    bind: function(n, program, name) {
-      var gl = this.gl;
-      if (!textureIDs) {
-        textureIDs = [gl.TEXTURE0, gl.TEXTURE1, gl.TEXTURE2];
-      }
-      gl.activeTexture(textureIDs[n]);
-      gl.bindTexture(gl.TEXTURE_2D, this.texture);
-      gl.uniform1i(gl.getUniformLocation(program.program, name), n);
-    }
-  };
-  return constructor; 
-})();
-
-/**
- * Generic WebGL backed canvas that sets up: a quad to paint a texture on, appropriate vertex/fragment shaders,
- * scene parameters and other things. Specialized versions of this class can be created by overriding several 
- * initialization methods.
- * 
- * <code>
- * var canvas = new WebGLCanvas(document.getElementById('canvas'), new Size(512, 512);
- * canvas.texture.fill(data);
- * canvas.drawScene();
- * </code>
- */
-var WebGLCanvas = (function () {
-  
-  var vertexShaderScript = Script.createFromSource("x-shader/x-vertex", text([
-    "attribute vec3 aVertexPosition;",
-    "attribute vec2 aTextureCoord;",
-    "uniform mat4 uMVMatrix;",
-    "uniform mat4 uPMatrix;",
-    "varying highp vec2 vTextureCoord;",
-    "void main(void) {",
-    "  gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);",
-    "  vTextureCoord = aTextureCoord;",
-    "}"
-    ]));
-  
-  var fragmentShaderScript = Script.createFromSource("x-shader/x-fragment", text([
-    "precision highp float;",
-    "varying highp vec2 vTextureCoord;",
-    "uniform sampler2D texture;",
-    "void main(void) {",
-    "  gl_FragColor = texture2D(texture, vTextureCoord);",
-    "}"
-    ]));
-  
-  function constructor(canvas, size, useFrameBuffer) {
-    this.canvas = canvas;
-    this.size = size;
-    this.canvas.width = size.w;
-    this.canvas.height = size.h;
-    
-    this.onInitWebGL();
-    this.onInitShaders();
-    initBuffers.call(this);
-    if (useFrameBuffer) {
-      initFramebuffer.call(this);
-    }
-    this.onInitTextures();
-    initScene.call(this);
-  }
-
-  /**
-   * Initialize a frame buffer so that we can render off-screen.
-   */
-  function initFramebuffer() {
-    var gl = this.gl;
-    
-    // Create framebuffer object and texture.
-    this.framebuffer = gl.createFramebuffer(); 
-    gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
-    this.framebufferTexture = new Texture(this.gl, this.size, gl.RGB);
-
-    // Create and allocate renderbuffer for depth data.
-    var renderbuffer = gl.createRenderbuffer();
-    gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
-    gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, this.size.w, this.size.h);
-
-    // Attach texture and renderbuffer to the framebuffer.
-    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.framebufferTexture.texture, 0);
-    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbuffer);
-  }
-  
-  /**
-   * Initialize vertex and texture coordinate buffers for a plane.
-   */
-  function initBuffers() {
-    var tmp;
-    var gl = this.gl;
-    
-    // Create vertex position buffer.
-    this.quadVPBuffer = gl.createBuffer();
-    gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVPBuffer);
-    tmp = [
-       1.0,  1.0, 0.0,
-      -1.0,  1.0, 0.0, 
-       1.0, -1.0, 0.0, 
-      -1.0, -1.0, 0.0];
-    
-    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(tmp), gl.STATIC_DRAW);
-    this.quadVPBuffer.itemSize = 3;
-    this.quadVPBuffer.numItems = 4;
-    
-    /*
-     +--------------------+ 
-     | -1,1 (1)           | 1,1 (0)
-     |                    |
-     |                    |
-     |                    |
-     |                    |
-     |                    |
-     | -1,-1 (3)          | 1,-1 (2)
-     +--------------------+
-     */
-    
-    var scaleX = 1.0;
-    var scaleY = 1.0;
-    
-    // Create vertex texture coordinate buffer.
-    this.quadVTCBuffer = gl.createBuffer();
-    gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVTCBuffer);
-    tmp = [
-      scaleX, 0.0,
-      0.0, 0.0,
-      scaleX, scaleY,
-      0.0, scaleY,
-    ];
-    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(tmp), gl.STATIC_DRAW);
-  }
-  
-  function mvIdentity() {
-    this.mvMatrix = Matrix.I(4);
-  }
-
-  function mvMultiply(m) {
-    this.mvMatrix = this.mvMatrix.x(m);
-  }
-
-  function mvTranslate(m) {
-    mvMultiply.call(this, Matrix.Translation($V([m[0], m[1], m[2]])).ensure4x4());
-  }
-  
-  function setMatrixUniforms() {
-    this.program.setMatrixUniform("uPMatrix", new Float32Array(this.perspectiveMatrix.flatten()));
-    this.program.setMatrixUniform("uMVMatrix", new Float32Array(this.mvMatrix.flatten()));
-  }
-
-  function initScene() {
-    var gl = this.gl;
-    
-    // Establish the perspective with which we want to view the
-    // scene. Our field of view is 45 degrees, with a width/height
-    // ratio of 640:480, and we only want to see objects between 0.1 units
-    // and 100 units away from the camera.
-    
-    this.perspectiveMatrix = makePerspective(45, 1, 0.1, 100.0);
-    
-    // Set the drawing position to the "identity" point, which is
-    // the center of the scene.
-    mvIdentity.call(this);
-    
-    // Now move the drawing position a bit to where we want to start
-    // drawing the square.
-    mvTranslate.call(this, [0.0, 0.0, -2.4]);
-
-    // Draw the cube by binding the array buffer to the cube's vertices
-    // array, setting attributes, and pushing it to GL.
-    gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVPBuffer);
-    gl.vertexAttribPointer(this.vertexPositionAttribute, 3, gl.FLOAT, false, 0, 0);
-    
-    // Set the texture coordinates attribute for the vertices.
-    
-    gl.bindBuffer(gl.ARRAY_BUFFER, this.quadVTCBuffer);
-    gl.vertexAttribPointer(this.textureCoordAttribute, 2, gl.FLOAT, false, 0, 0);  
-    
-    this.onInitSceneTextures();
-    
-    setMatrixUniforms.call(this);
-    
-    if (this.framebuffer) {
-      console.log("Bound Frame Buffer");
-      gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
-    }
-  }
-  
-  constructor.prototype = {
-    toString: function() {
-      return "WebGLCanvas Size: " + this.size;
-    },
-    checkLastError: function (operation) {
-      var err = this.gl.getError();
-      if (err != this.gl.NO_ERROR) {
-        var name = this.glNames[err];
-        name = (name !== undefined) ? name + "(" + err + ")":
-            ("Unknown WebGL ENUM (0x" + value.toString(16) + ")");
-        if (operation) {
-          console.log("WebGL Error: %s, %s", operation, name);
-        } else {
-          console.log("WebGL Error: %s", name);
-        }
-        console.trace();
-      }
-    },
-    onInitWebGL: function () {
-      try {
-        this.gl = this.canvas.getContext("experimental-webgl");
-      } catch(e) {}
-      
-      if (!this.gl) {
-        error("Unable to initialize WebGL. Your browser may not support it.");
-      }
-      if (this.glNames) {
-        return;
-      }
-      this.glNames = {};
-      for (var propertyName in this.gl) {
-        if (typeof this.gl[propertyName] == 'number') {
-          this.glNames[this.gl[propertyName]] = propertyName;
-        }
-      }
-    },
-    onInitShaders: function() {
-      this.program = new Program(this.gl);
-      this.program.attach(new Shader(this.gl, vertexShaderScript));
-      this.program.attach(new Shader(this.gl, fragmentShaderScript));
-      this.program.link();
-      this.program.use();
-      this.vertexPositionAttribute = this.program.getAttributeLocation("aVertexPosition");
-      this.gl.enableVertexAttribArray(this.vertexPositionAttribute);
-      this.textureCoordAttribute = this.program.getAttributeLocation("aTextureCoord");;
-      this.gl.enableVertexAttribArray(this.textureCoordAttribute);
-    },
-    onInitTextures: function () {
-      var gl = this.gl;
-      this.texture = new Texture(gl, this.size, gl.RGB);
-    },
-    onInitSceneTextures: function () {
-      this.texture.bind(0, this.program, "texture");
-    },
-    drawScene: function() {
-      this.gl.drawArrays(this.gl.TRIANGLE_STRIP, 0, 4);
-    },
-    readPixels: function(buffer) {
-      var gl = this.gl;
-      gl.readPixels(0, 0, this.size.w, this.size.h, gl.RGB, gl.UNSIGNED_BYTE, buffer);
-    }
-  };
-  return constructor;
-})();
-
-var YUVWebGLCanvas = (function () {
-  var vertexShaderScript = Script.createFromSource("x-shader/x-vertex", text([
-    "attribute vec3 aVertexPosition;",
-    "attribute vec2 aTextureCoord;",
-    "uniform mat4 uMVMatrix;",
-    "uniform mat4 uPMatrix;",
-    "varying highp vec2 vTextureCoord;",
-    "void main(void) {",
-    "  gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);",
-    "  vTextureCoord = aTextureCoord;",
-    "}"
-  ]));
-  
-  var fragmentShaderScriptOld = Script.createFromSource("x-shader/x-fragment", text([
-    "precision highp float;",
-    "varying highp vec2 vTextureCoord;",
-    "uniform sampler2D YTexture;",
-    "uniform sampler2D UTexture;",
-    "uniform sampler2D VTexture;",
-    
-    "void main(void) {",
-    "  vec3 YUV = vec3",
-    "  (",
-    "    texture2D(YTexture, vTextureCoord).x * 1.1643828125,   // premultiply Y",
-    "    texture2D(UTexture, vTextureCoord).x,",
-    "    texture2D(VTexture, vTextureCoord).x",
-    "  );",
-    "  gl_FragColor = vec4",
-    "  (",
-    "    YUV.x + 1.59602734375 * YUV.z - 0.87078515625,",
-    "    YUV.x - 0.39176171875 * YUV.y - 0.81296875 * YUV.z + 0.52959375,",
-    "    YUV.x + 2.017234375   * YUV.y - 1.081390625,",
-    "    1",
-    "  );",
-    "}"
-  ]));
-  
-  var fragmentShaderScriptSimple = Script.createFromSource("x-shader/x-fragment", text([
-   "precision highp float;",
-   "varying highp vec2 vTextureCoord;",
-   "uniform sampler2D YTexture;",
-   "uniform sampler2D UTexture;",
-   "uniform sampler2D VTexture;",
-   
-   "void main(void) {",
-   "  gl_FragColor = texture2D(YTexture, vTextureCoord);",
-   "}"
-   ]));
-
-  var fragmentShaderScript = Script.createFromSource("x-shader/x-fragment", text([
-    "precision highp float;",
-    "varying highp vec2 vTextureCoord;",
-    "uniform sampler2D YTexture;",
-    "uniform sampler2D UTexture;",
-    "uniform sampler2D VTexture;",
-    "const mat4 YUV2RGB = mat4",
-    "(",
-    " 1.1643828125, 0, 1.59602734375, -.87078515625,",
-    " 1.1643828125, -.39176171875, -.81296875, .52959375,",
-    " 1.1643828125, 2.017234375, 0, -1.081390625,",
-    " 0, 0, 0, 1",
-    ");",
-  
-    "void main(void) {",
-    " gl_FragColor = vec4( texture2D(YTexture,  vTextureCoord).x, texture2D(UTexture, vTextureCoord).x, texture2D(VTexture, vTextureCoord).x, 1) * YUV2RGB;",
-    "}"
-  ]));
-  
-  
-  function constructor(canvas, size) {
-    WebGLCanvas.call(this, canvas, size);
-  } 
-  
-  constructor.prototype = inherit(WebGLCanvas, {
-    onInitShaders: function() {
-      this.program = new Program(this.gl);
-      this.program.attach(new Shader(this.gl, vertexShaderScript));
-      this.program.attach(new Shader(this.gl, fragmentShaderScript));
-      this.program.link();
-      this.program.use();
-      this.vertexPositionAttribute = this.program.getAttributeLocation("aVertexPosition");
-      this.gl.enableVertexAttribArray(this.vertexPositionAttribute);
-      this.textureCoordAttribute = this.program.getAttributeLocation("aTextureCoord");;
-      this.gl.enableVertexAttribArray(this.textureCoordAttribute);
-    },
-    onInitTextures: function () {
-      this.YTexture = new Texture(this.gl, this.size);
-      this.UTexture = new Texture(this.gl, this.size.getHalfSize());
-      this.VTexture = new Texture(this.gl, this.size.getHalfSize());
-    },
-    onInitSceneTextures: function () {
-      this.YTexture.bind(0, this.program, "YTexture");
-      this.UTexture.bind(1, this.program, "UTexture");
-      this.VTexture.bind(2, this.program, "VTexture");
-    },
-    fillYUVTextures: function(y, u, v) {
-      this.YTexture.fill(y);
-      this.UTexture.fill(u);
-      this.VTexture.fill(v);
-    },
-    toString: function() {
-      return "YUVCanvas Size: " + this.size;
-    }
-  });
-  
-  return constructor;
-})(); 
-
-
-var FilterWebGLCanvas = (function () {
-  var vertexShaderScript = Script.createFromSource("x-shader/x-vertex", text([
-    "attribute vec3 aVertexPosition;",
-    "attribute vec2 aTextureCoord;",
-    "uniform mat4 uMVMatrix;",
-    "uniform mat4 uPMatrix;",
-    "varying highp vec2 vTextureCoord;",
-    "void main(void) {",
-    "  gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);",
-    "  vTextureCoord = aTextureCoord;",
-    "}"
-  ]));
-
-  var fragmentShaderScript = Script.createFromSource("x-shader/x-fragment", text([
-    "precision highp float;",
-    "varying highp vec2 vTextureCoord;",
-    "uniform sampler2D FTexture;",
-    
-    "void main(void) {",
-    " gl_FragColor = texture2D(FTexture,  vTextureCoord);",
-    "}"
-  ]));
-  
-  
-  function constructor(canvas, size, useFrameBuffer) {
-    WebGLCanvas.call(this, canvas, size, useFrameBuffer);
-  } 
-  
-  constructor.prototype = inherit(WebGLCanvas, {
-    onInitShaders: function() {
-      this.program = new Program(this.gl);
-      this.program.attach(new Shader(this.gl, vertexShaderScript));
-      this.program.attach(new Shader(this.gl, fragmentShaderScript));
-      this.program.link();
-      this.program.use();
-      this.vertexPositionAttribute = this.program.getAttributeLocation("aVertexPosition");
-      this.gl.enableVertexAttribArray(this.vertexPositionAttribute);
-      this.textureCoordAttribute = this.program.getAttributeLocation("aTextureCoord");
-      this.gl.enableVertexAttribArray(this.textureCoordAttribute);
-    },
-    onInitTextures: function () {
-      console.log("creatingTextures: size: " + this.size);
-      this.FTexture = new Texture(this.gl, this.size, this.gl.RGB);
-    },
-    onInitSceneTextures: function () {
-      this.FTexture.bind(0, this.program, "FTexture");
-    },
-    process: function(buffer, output) {
-      this.FTexture.fill(buffer);
-      this.drawScene();
-      this.readPixels(output);
-    },
-    toString: function() {
-      return "FilterWebGLCanvas Size: " + this.size;
-    }
-  });
-  
-  return constructor;
-})(); 
-//
-//  Copyright (c) 2013 Sam Leitch. All rights reserved.
-//
-//  Permission is hereby granted, free of charge, to any person obtaining a copy
-//  of this software and associated documentation files (the "Software"), to
-//  deal in the Software without restriction, including without limitation the
-//  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-//  sell copies of the Software, and to permit persons to whom the Software is
-//  furnished to do so, subject to the following conditions:
-//
-//  The above copyright notice and this permission notice shall be included in
-//  all copies or substantial portions of the Software.
-//
-//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-//  IN THE SOFTWARE.
-//
-
-/*
- * This class wraps the details of the h264bsd library.
- */
-function H264Decoder(Module, targetCanvas) {
-	var self = this;	
-	self.Module = Module;
-	self.released = false;
-	self.yuvCanvas = null;
-	self.pStorage = H264Decoder.h264bsdAlloc(self.Module);
-	H264Decoder.h264bsdInit(self.Module, self.pStorage, 0);
-	self.targetCanvas = targetCanvas;
-	self.useWebGL = H264Decoder.detectWebGl();
-};
-
-
-H264Decoder.RDY = 0;
-H264Decoder.PIC_RDY = 1;
-H264Decoder.HDRS_RDY = 2;
-H264Decoder.ERROR = 3;
-H264Decoder.PARAM_SET_ERROR = 4;
-H264Decoder.MEMALLOC_ERROR = 5;
-
-
-
-H264Decoder.prototype.release = function() {
-	var self = this;
-	if(self.released) return;
-
-	self.released = true;
-	H264Decoder.h264bsdShutdown(self.Module, self.pStorage);
-	H264Decoder.h264bsdFree(self.Module, self.pStorage);
-};
-
-H264Decoder.prototype.decode = function(data) {
-	var self = this;
-	if(typeof data === 'undefined' || !(data instanceof ArrayBuffer)) {
-		throw new Error("data must be a ArrayBuffer instance")
-	}
-	
-	data = new Uint8Array(data);
-	
-	var pData = 0; //The offset into the heap when decoding 
-	var pAlloced = 0; //The original pointer to the data buffer (for freeing)
-	var pBytesRead = 0; //Pointer to bytesRead
-	var length = data.byteLength; //The byte-wise length of the data to decode	
-	var bytesRead = 0;  //The number of bytes read from a decode operation
-	var retCode = 0; //Return code from a decode operation
-	var lastPicId = 0; //ID of the last picture decoded
-
-	//Get a pointer into the heap were our decoded bytes will live
-	pData = pAlloced = H264Decoder.malloc(self.Module, length);
-	self.Module.HEAPU8.set(data, pData);
-
-	//get a pointer to where bytesRead will be stored: Uint32 = 4 bytes
-	pBytesRead = H264Decoder.malloc(self.Module, 4);
-
-	//Keep decoding frames while there is still something to decode
-	while(length > 0) {
-
-		retCode = H264Decoder.h264bsdDecode(self.Module, self.pStorage, pData, length, lastPicId, pBytesRead);		
-		bytesRead = self.Module.getValue(pBytesRead, 'i32');
-		console.log('retCode: ', retCode, 'bytesRead: ', bytesRead);
-		switch(retCode){
-			case H264Decoder.PIC_RDY:
-				lastPicId++;
-				var evt = new CustomEvent("pictureReady", {
-					detail: self.getNextOutputPicture()
-				});
-
-				if (self.targetCanvas != null){
-					self.targetCanvas.dispatchEvent(evt);
-				}				
-				break;
-		}
-
-		length = length - bytesRead;		
-		pData = pData + bytesRead;
-	}
-
-	if(pAlloced != 0) {
-		H264Decoder.free(self.Module, pAlloced);
-	}
-	
-	if(pBytesRead != 0) {
-		H264Decoder.free(self.Module, pBytesRead);
-	}
-
-};
-
-H264Decoder.prototype.getNextOutputPicture = function(){
-	var self = this; 
-	var length = self.getYUVLength();
-
-	var pPicId = H264Decoder.malloc(self.Module, 4);
-	var picId = 0;
-
-	var pIsIdrPic = H264Decoder.malloc(self.Module, 4);
-	var isIdrPic = 0;
-
-	var pNumErrMbs = H264Decoder.malloc(self.Module, 4);
-	var numErrMbs = 0;
-
-	var pBytes = H264Decoder.h264bsdNextOutputPicture(self.Module, self.pStorage, pPicId, pIsIdrPic, pNumErrMbs);
-	var bytes = null;
-
-	picId = self.Module.getValue(pPicId, 'i32');	
-	isIdrPic = self.Module.getValue(pIsIdrPic, 'i32');	
-	numErrMbs = self.Module.getValue(pNumErrMbs, 'i32');
-	
-	bytes = new Uint8Array();
-	bytes = self.Module.HEAPU8.subarray(pBytes, (pBytes + length));
-
-    H264Decoder.free(self.Module, pPicId);		
-  	H264Decoder.free(self.Module, pIsIdrPic);
-    H264Decoder.free(self.Module, pNumErrMbs);	
-
-    var ret = {};
-    var croppingInfo = self.getCroppingInfo();
-    if (self.useWebGL){
-		ret = {
-		    encoding: 'YUV',
-		    picture: bytes, 
-		    height: croppingInfo.height, 
-		    width: croppingInfo.width};
-    }else{
-		ret = {
-			encoding: 'RGB',
-		    picture: H264Decoder.convertYUV2RGB(bytes, croppingInfo), 
-		    height: croppingInfo.height, 
-		    width: croppingInfo.width};
-    }
-    
-    return ret; 
-};
-
-
-H264Decoder.prototype.getCroppingInfo = function(){
-	var self = this;
-	var pCroppingFlag = H264Decoder.malloc(self.Module, 4);
-	var pLeftOffset = H264Decoder.malloc(self.Module, 4);
-	var pTopOffset = H264Decoder.malloc(self.Module, 4);
-	var pWidth = H264Decoder.malloc(self.Module, 4);
-	var pHeight = H264Decoder.malloc(self.Module, 4);
-
-	var result = {
-		'width': (H264Decoder.h264bsdPicWidth(self.Module, self.pStorage)*16),
-		'height': (H264Decoder.h264bsdPicHeight(self.Module, self.pStorage)*16),
-		'top': 0,
-		'left': 0
-	};
-
-	H264Decoder.free(self.Module, pCroppingFlag);
-	H264Decoder.free(self.Module, pLeftOffset);
-	H264Decoder.free(self.Module, pTopOffset);
-	H264Decoder.free(self.Module, pWidth);
-	H264Decoder.free(self.Module, pHeight);
-
-	return result;
-};
-
-
-H264Decoder.prototype.getYUVLength = function(){
-	var self = this;
-	var width = H264Decoder.h264bsdPicWidth(self.Module, self.pStorage);
-	var height = H264Decoder.h264bsdPicHeight(self.Module, self.pStorage);
-    return (width * 16 * height * 16) + (2 * width * 16 * height * 8);
-};
-
-//http://www.browserleaks.com/webgl#howto-detect-webgl
-H264Decoder.detectWebGl = function()
-{
-    if (!!window.WebGLRenderingContext) {
-        var canvas = document.createElement("canvas"),
-             names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-3d"],
-           context = false; 
-        for(var i=0;i<4;i++) {
-            try {
-                context = canvas.getContext(names[i]);
-                if (context && typeof context.getParameter == "function") {
-                    // WebGL is enabled                    
-                    return true;
-                }
-            } catch(e) {}
-        } 
-        // WebGL is supported, but disabled
-        return false;
-    }
-    // WebGL not supported
-    return false;
-};
-
-//Excessively pink
-H264Decoder.convertYUV2RGB = function(yuvBytes, croppingInfo){
-	var width = croppingInfo.width - croppingInfo.left;
-	var height = croppingInfo.height - croppingInfo.top;
-
-	var rgbBytes = new Uint8Array();
-
-	var cb = width * height;
-	var cr = cb + ((width * height) / 2);	
-	var numPixels = width * height;
-
-	var dst = 0;
-	var dst_width = 0;
-
-	var k = 0;
-	for (var i = 0; i < numPixels; i += 2)
-	{
-		k += 1;
-
-		var y1 = yuvBytes[i] & 0xff;
-		var y2 = yuvBytes[i + 1] & 0xff;
-		var y3 = yuvBytes[width + i] & 0xff;
-		var y4 = yuvBytes[width + i + 1] & 0xff;
-		
-		var v = yuvBytes[cr + k] & 0xff;
-		var u = yuvBytes[cb + k] & 0xff;
-		
-		v = v - 128;
-		u = u - 128;
-
-		dst = i * 4;
-		dst_width = width*4 + dst;
-
-		// i
-		rgbBytes[dst] = 0xff;
-		rgbBytes[dst + 1] = H264Decoder.clamp((298 * (y1 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst + 2] = H264Decoder.clamp((298 * (y1 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst + 3] = H264Decoder.clamp((298 * y1 + 516*u + 128) >> 8, 255, 0);
-				
-		// i + 1
-		rgbBytes[dst + 4] = 0xff;
-		rgbBytes[dst + 5] = H264Decoder.clamp((298 * (y2 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst + 6] = H264Decoder.clamp((298 * (y2 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst + 7] = H264Decoder.clamp((298 * y2 + 516*u + 128) >> 8, 255, 0);
-		
-		//width
-		rgbBytes[dst_width] = 0xff;
-		rgbBytes[dst_width + 1] = H264Decoder.clamp((298 * (y3 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst_width + 2] = H264Decoder.clamp((298 * (y2 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst_width + 3] = H264Decoder.clamp((298 * y3 + 516*u + 128) >> 8, 255, 0);
-				
-		//width + 1
-		rgbBytes[dst_width + 4] = 0xff;
-		rgbBytes[dst_width + 5] = H264Decoder.clamp((298 * (y4 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst_width + 6] = H264Decoder.clamp((298 * (y4 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst_width + 7] = H264Decoder.clamp((298 * y4 + 516*u + 128) >> 8, 255, 0);
-
-		if (i != 0 && (i+2)%width ==0) {
-			i += width;					
-		} 
-	}
-
-	return rgbBytes;
-};
-
-H264Decoder.clamp = function(num, max, min) {
-  return Math.min(Math.max(num, min), max);
-};
-
-// u32 h264bsdDecode(storage_t *pStorage, u8 *byteStrm, u32 len, u32 picId, u32 *readBytes);
-H264Decoder.h264bsdDecode = function(Module, pStorage, pBytes, len, picId, pBytesRead) {
-	return Module.ccall('h264bsdDecode', Number, 
-		[Number, Number, Number, Number, Number], 
-		[pStorage, pBytes, len, picId, pBytesRead]);
-};
-
-// storage_t* h264bsdAlloc();
-H264Decoder.h264bsdAlloc = function(Module) {
-	return Module.ccall('h264bsdAlloc', Number);
-};
-
-// void h264bsdFree(storage_t *pStorage);
-H264Decoder.h264bsdFree = function(Module, pStorage) {
-	Module.ccall('h264bsdFree', null, [Number], [pStorage]);
-};
-
-// u32 h264bsdInit(storage_t *pStorage, u32 noOutputReordering);
-H264Decoder.h264bsdInit = function(Module, pStorage, noOutputReordering) {
-	return Module.ccall('h264bsdInit', Number, [Number, Number], [pStorage, noOutputReordering]);
-};
-
-//void h264bsdShutdown(storage_t *pStorage);
-H264Decoder.h264bsdShutdown = function(Module, pStorage) {
-	Module.ccall('h264bsdShutdown', null, [Number], [pStorage]);
-};
-
-// u8* h264bsdNextOutputPicture(storage_t *pStorage, u32 *picId, u32 *isIdrPic, u32 *numErrMbs);
-H264Decoder.h264bsdNextOutputPicture = function(Module, pStorage, pPicId, pIsIdrPic, pNumErrMbs) {
-	return Module.ccall('h264bsdNextOutputPicture', 
-		Number, 
-		[Number, Number, Number, Number], 
-		[pStorage, pPicId, pIsIdrPic, pNumErrMbs]);
-};
-
-// u32 h264bsdPicWidth(storage_t *pStorage);
-H264Decoder.h264bsdPicWidth = function(Module, pStorage) {
-	return Module.ccall('h264bsdPicWidth', Number, [Number], [pStorage]);
-};
-
-// u32 h264bsdPicHeight(storage_t *pStorage);
-H264Decoder.h264bsdPicHeight = function(Module, pStorage) {
-	return Module.ccall('h264bsdPicHeight', Number, [Number], [pStorage]);
-};
-
-// void h264bsdCroppingParams(storage_t *pStorage, u32 *croppingFlag, u32 *left, u32 *width, u32 *top, u32 *height);
-H264Decoder.h264bsdCroppingParams = function(Module, pStorage, pCroppingFlag, pLeft, pWidth, pTop, pHeight) {
-	return Module.ccall('h264bsdCroppingParams', 
-		Number, 
-		[Number, Number, Number, Number, Number, Number, Number], 
-		[pStorage, pCroppingFlag, pLeft, pWidth, pTop, pHeight]);
-};
-
-// u32 h264bsdCheckValidParamSets(storage_t *pStorage);
-H264Decoder.h264bsdCheckValidParamSets = function(Module, pStorage){
-	return Module.ccall('h264bsdCheckValidParamSets', Number, [Number], [pStorage]);
-};
-
-// void* malloc(size_t size);
-H264Decoder.malloc = function(Module, size){
-	return Module.ccall('malloc', Number, [Number], [size]);
-};
-
-// void free(void* ptr);
-H264Decoder.free = function(Module, ptr){
-	return Module.ccall('free', null, [Number], [ptr]);
-};
-
-// void* memcpy(void* dest, void* src, size_t size);
-H264Decoder.memcpy = function(Module, length){
-	return Module.ccall('malloc', Number, [Number, Number, Number], [dest, src, size]);
-};
+function globalEval(x){eval.call(null,x)}function assert(condition,text){condition||abort("Assertion failed: "+text)}function ccall(ident,returnType,argTypes,args){return ccallFunc(getCFunc(ident),returnType,argTypes,args)}function getCFunc(ident){try{var func=Module["_"+ident];func||(func=eval("_"+ident))}catch(e){}return assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)"),func}function ccallFunc(func,returnType,argTypes,args){function toC(value,type){if("string"==type){if(null===value||void 0===value||0===value)return 0;value=intArrayFromString(value),type="array"}if("array"==type){stack||(stack=Runtime.stackSave());var ret=Runtime.stackAlloc(value.length);return writeArrayToMemory(value,ret),ret}return value}function fromC(value,type){return"string"==type?Pointer_stringify(value):(assert("array"!=type),value)}var stack=0,i=0,cArgs=args?args.map(function(arg){return toC(arg,argTypes[i++])}):[],ret=fromC(func.apply(null,cArgs),returnType);return stack&&Runtime.stackRestore(stack),ret}function cwrap(ident,returnType,argTypes){var func=getCFunc(ident);return function(){return ccallFunc(func,returnType,argTypes,Array.prototype.slice.call(arguments))}}function setValue(ptr,value,type){switch(type=type||"i8","*"===type.charAt(type.length-1)&&(type="i32"),type){case"i1":HEAP8[ptr]=value;break;case"i8":HEAP8[ptr]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=1?tempDouble>0?(0|Math_min(+Math_floor(tempDouble/4294967296),4294967295))>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}function getValue(ptr,type){switch(type=type||"i8","*"===type.charAt(type.length-1)&&(type="i32"),type){case"i1":return HEAP8[ptr];case"i8":return HEAP8[ptr];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for setValue: "+type)}return null}function allocate(slab,types,allocator,ptr){var zeroinit,size;"number"==typeof slab?(zeroinit=!0,size=slab):(zeroinit=!1,size=slab.length);var ret,singleType="string"==typeof types?types:null;if(ret=allocator==ALLOC_NONE?ptr:[_malloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][void 0===allocator?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length)),zeroinit){var stop,ptr=ret;for(assert(0==(3&ret)),stop=ret+(-4&size);stop>ptr;ptr+=4)HEAP32[ptr>>2]=0;for(stop=ret+size;stop>ptr;)HEAP8[0|ptr++]=0;return ret}if("i8"===singleType)return slab.subarray||slab.slice?HEAPU8.set(slab,ret):HEAPU8.set(new Uint8Array(slab),ret),ret;for(var type,typeSize,previousType,i=0;size>i;){var curr=slab[i];"function"==typeof curr&&(curr=Runtime.getFunctionIndex(curr)),type=singleType||types[i],0!==type?("i64"==type&&(type="i32"),setValue(ret+i,curr,type),previousType!==type&&(typeSize=Runtime.getNativeTypeSize(type),previousType=type),i+=typeSize):i++}return ret}function Pointer_stringify(ptr,length){for(var t,hasUtf=!1,i=0;;){if(t=HEAPU8[ptr+i|0],t>=128)hasUtf=!0;else if(0==t&&!length)break;if(i++,length&&i==length)break}length||(length=i);var ret="";if(!hasUtf){for(var curr,MAX_CHUNK=1024;length>0;)curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK))),ret=ret?ret+curr:curr,ptr+=MAX_CHUNK,length-=MAX_CHUNK;return ret}var utf8=new Runtime.UTF8Processor;for(i=0;length>i;i++)t=HEAPU8[ptr+i|0],ret+=utf8.processCChar(t);return ret}function UTF16ToString(ptr){for(var i=0,str="";;){var codeUnit=HEAP16[ptr+2*i>>1];if(0==codeUnit)return str;++i,str+=String.fromCharCode(codeUnit)}}function stringToUTF16(str,outPtr){for(var i=0;i<str.length;++i){var codeUnit=str.charCodeAt(i);HEAP16[outPtr+2*i>>1]=codeUnit}HEAP16[outPtr+2*str.length>>1]=0}function UTF32ToString(ptr){for(v
\ No newline at end of file
+var tempDoublePtr=Runtime.alignMemory(allocate(12,"i8",ALLOC_STATIC),8);assert(tempDoublePtr%8==0),Module._memset=_memset;var _llvm_memset_p0i8_i32=_memset;Module._memcpy=_memcpy;var _llvm_memcpy_p0i8_p0i8_i32=_memcpy,_llvm_memset_p0i8_i64=_memset,___errno_state=0,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};Module._strlen=_strlen;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 availabl
\ No newline at end of file
+if(err)throw err===ERRNO_CODES.EISDIR&&(err=ERRNO_CODES.EPERM),new FS.ErrnoError(err);if(!parent.node_ops.unlink)throw new FS.ErrnoError(ERRNO_CODES.EPERM);if(FS.isMountpoint(node))throw new FS.ErrnoError(ERRNO_CODES.EBUSY);parent.node_ops.unlink(parent,name),FS.destroyNode(node)},readlink:function(path){var lookup=FS.lookupPath(path,{follow:!1}),link=lookup.node;if(!link.node_ops.readlink)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);return link.node_ops.readlink(link)},stat:function(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow}),node=lookup.node;if(!node.node_ops.getattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);return node.node_ops.getattr(node)},lstat:function(path){return FS.stat(path,!0)},chmod:function(path,mode,dontFollow){var node;if("string"==typeof path){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else node=path;if(!node.node_ops.setattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);node.node_ops.setattr(node,{mode:4095&mode|-4096&node.mode,timestamp:Date.now()})},lchmod:function(path,mode){FS.chmod(path,mode,!0)},fchmod:function(fd,mode){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);FS.chmod(stream.node,mode)},chown:function(path,uid,gid,dontFollow){var node;if("string"==typeof path){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else node=path;if(!node.node_ops.setattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);node.node_ops.setattr(node,{timestamp:Date.now()})},lchown:function(path,uid,gid){FS.chown(path,uid,gid,!0)},fchown:function(fd,uid,gid){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);FS.chown(stream.node,uid,gid)},truncate:function(path,len){if(0>len)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);var node;if("string"==typeof path){var lookup=FS.lookupPath(path,{follow:!0});node=lookup.node}else node=path;if(!node.node_ops.setattr)throw new FS.ErrnoError(ERRNO_CODES.EPERM);if(FS.isDir(node.mode))throw new FS.ErrnoError(ERRNO_CODES.EISDIR);if(!FS.isFile(node.mode))throw new FS.ErrnoError(ERRNO_CODES.EINVAL);var err=FS.nodePermissions(node,"w");if(err)throw new FS.ErrnoError(err);node.node_ops.setattr(node,{size:len,timestamp:Date.now()})},ftruncate:function(fd,len){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(ERRNO_CODES.EBADF);if(0===(2097155&stream.flags))throw new FS.ErrnoError(ERRNO_CODES.EINVAL);FS.truncate(stream.node,len)},utime:function(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:!0}),node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})},open:function(path,flags,mode,fd_start,fd_end){flags="string"==typeof flags?FS.modeStringToFlags(flags):flags,mode="undefined"==typeof mode?438:mode,mode=64&flags?4095&mode|32768:0;var node;if("object"==typeof path)node=path;else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(131072&flags)});node=lookup.node}catch(e){}}if(64&flags)if(node){if(128&flags)throw new FS.ErrnoError(ERRNO_CODES.EEXIST)}else node=FS.mknod(path,mode,0);if(!node)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);FS.isChrdev(node.mode)&&(flags&=-513);var err=FS.mayOpen(node,flags);if(err)throw new FS.ErrnoError(err);512&flags&&FS.truncate(node,0),flags&=-641;var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:!0,position:0,stream_ops:node.stream_ops,ungotten:[],error:!1},fd_start,fd_end);return stream.stream_ops.open&&stream.stream_ops.open(stream),!Module.logReadFiles||1&flags||(FS.readFiles||(FS.readFiles={}),path in FS.readFiles||(FS.readFiles[path]=1,Module.printErr("read file: "+path))),stream},close:function(stream){try{stream.stream_ops.close&&stream.stream_ops.close(stream)}catch(e){throw e}finally{FS.closeStream(stream.fd)}},llseek:function(stream,offset,whence){if(!stream.seekable||!stream.stream_ops.llseek)throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);return stream.stream_ops.llseek(stream,offset,whence)},read:function(stream,buffer,offset,length,position){if(0>length||0>position)throw new FS.ErrnoError(ERRNO_CODES.EINVAL);if(1===(2097155&stream.fla
\ No newline at end of file
+x*=cw/rect.width,y*=ch/rect.height,Browser.mouseMovementX=x-Browser.mouseX,Browser.mouseMovementY=y-Browser.mouseY,Browser.mouseX=x,Browser.mouseY=y}},xhrLoad:function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,!0),xhr.responseType="arraybuffer",xhr.onload=function(){200==xhr.status||0==xhr.status&&xhr.response?onload(xhr.response):onerror()},xhr.onerror=onerror,xhr.send(null)},asyncLoad:function(url,onload,onerror,noRunDep){Browser.xhrLoad(url,function(arrayBuffer){assert(arrayBuffer,'Loading data file "'+url+'" failed (no arrayBuffer).'),onload(new Uint8Array(arrayBuffer)),noRunDep||removeRunDependency("al "+url)},function(){if(!onerror)throw'Loading data file "'+url+'" failed.';onerror()}),noRunDep||addRunDependency("al "+url)},resizeListeners:[],updateResizeListeners:function(){var canvas=Module.canvas;Browser.resizeListeners.forEach(function(listener){listener(canvas.width,canvas.height)})},setCanvasSize:function(width,height,noUpdates){var canvas=Module.canvas;canvas.width=width,canvas.height=height,noUpdates||Browser.updateResizeListeners()},windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function(){var canvas=Module.canvas;if(this.windowedWidth=canvas.width,this.windowedHeight=canvas.height,canvas.width=screen.width,canvas.height=screen.height,"undefined"!=typeof SDL){var flags=HEAPU32[SDL.screen+0*Runtime.QUANTUM_SIZE>>2];flags=8388608|flags,HEAP32[SDL.screen+0*Runtime.QUANTUM_SIZE>>2]=flags}Browser.updateResizeListeners()},setWindowedCanvasSize:function(){var canvas=Module.canvas;if(canvas.width=this.windowedWidth,canvas.height=this.windowedHeight,"undefined"!=typeof SDL){var flags=HEAPU32[SDL.screen+0*Runtime.QUANTUM_SIZE>>2];flags=-8388609&flags,HEAP32[SDL.screen+0*Runtime.QUANTUM_SIZE>>2]=flags}Browser.updateResizeListeners()}};if(___errno_state=Runtime.staticAlloc(4),HEAP32[___errno_state>>2]=0,Module.requestFullScreen=function(lockPointer,resizeCanvas){Browser.requestFullScreen(lockPointer,resizeCanvas)},Module.requestAnimationFrame=function(func){Browser.requestAnimationFrame(func)},Module.setCanvasSize=function(width,height,noUpdates){Browser.setCanvasSize(width,height,noUpdates)},Module.pauseMainLoop=function(){Browser.mainLoop.pause()},Module.resumeMainLoop=function(){Browser.mainLoop.resume()},Module.getUserMedia=function(){Browser.getUserMedia()},FS.staticInit(),__ATINIT__.unshift({func:function(){Module.noFSInit||FS.init.initialized||FS.init()}}),__ATMAIN__.push({func:function(){FS.ignorePermissions=!1}}),__ATEXIT__.push({func:function(){FS.quit()}}),Module.FS_createFolder=FS.createFolder,Module.FS_createPath=FS.createPath,Module.FS_createDataFile=FS.createDataFile,Module.FS_createPreloadedFile=FS.createPreloadedFile,Module.FS_createLazyFile=FS.createLazyFile,Module.FS_createLink=FS.createLink,Module.FS_createDevice=FS.createDevice,__ATINIT__.unshift({func:function(){TTY.init()}}),__ATEXIT__.push({func:function(){TTY.shutdown()}}),TTY.utf8=new Runtime.UTF8Processor,ENVIRONMENT_IS_NODE){var fs=require("fs");NODEFS.staticInit()}STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP),staticSealed=!0,STACK_MAX=STACK_BASE+5242880,DYNAMIC_BASE=DYNAMICTOP=Runtime.alignMemory(STACK_MAX),assert(TOTAL_MEMORY>DYNAMIC_BASE,"TOTAL_MEMORY not big enough for stack");var Math_min=Math.min,asm=function(global,env,buffer){"use asm";function ax(a){a|=0;var b=0;return b=i,i=i+a|0,i=i+7&-8,b|0}function ay(){return i|0}function az(a){a|=0,i=a}function aA(a,b){a|=0,b|=0,(o|0)==0&&(o=a,p=b)}function aD(a){a|=0,B=a}function aE(a){a|=0,C=a}function aF(a){a|=0,D=a}function aG(a){a|=0,E=a}function aH(a){a|=0,F=a}function aI(a){a|=0,G=a}function aJ(a){a|=0,H=a}function aK(a){a|=0,I=a}function aL(a){a|=0,J=a}function aM(a){a|=0,K=a}function aN(){}function aO(b,e,f,g){b|=0,e|=0,f|=0,g|=0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0;L1:do{if(e>>>0>3){if((a[b]|0)!=0){h=19;break}if((a[b+1|0]|0)!=0){h=19;break}if(i=a[b+2|0]|0,(i&255)>>>0>=2){h=19;break}L6:do if((e|0)!=3){for(j=2,k=b+3|0,l=3,m=-3,n=i;;){if((n<<24>>24|0)==0)o=j+1|
\ No newline at end of file
+break}cl=ci-cj|0,ck=((cl|0)<0?-cl|0:cl)>>>0>3|0}else ck=2;while(0);c[z>>2]=ck,cj=aq+50|0,ci=aq+176|0,bB=b[ci>>1]|0,a4=b[b2>>1]|0,cl=aq+178|0,cm=b[cl>>1]|0,cn=b[b5>>1]|0;do if((b[cj>>1]|0)==0){if((b[b3>>1]|0)!=0){co=2;break}if(cp=bB-a4|0,((cp|0)<0?-cp|0:cp)>>>0>3){co=1;break}cp=cm-cn|0,co=((cp|0)<0?-cp|0:cp)>>>0>3|0}else co=2;while(0);c[y>>2]=co,cn=aq+56|0,cm=aq+188|0,a4=b[cm>>1]|0,bB=b[b6>>1]|0,cp=aq+190|0,cq=b[cp>>1]|0,cr=b[b9>>1]|0;do if((b[cn>>1]|0)==0){if((b[b7>>1]|0)!=0){cs=2;break}if(ct=a4-bB|0,((ct|0)<0?-ct|0:ct)>>>0>3){cs=1;break}ct=cq-cr|0,cs=((ct|0)<0?-ct|0:ct)>>>0>3|0}else cs=2;while(0);c[x>>2]=cs,cr=aq+58|0,cq=aq+192|0,bB=b[cq>>1]|0,a4=b[ca>>1]|0,ct=aq+194|0,cu=b[ct>>1]|0,cv=b[cd>>1]|0;do if((b[cr>>1]|0)==0){if((b[cb>>1]|0)!=0){cw=2;break}if(cx=bB-a4|0,((cx|0)<0?-cx|0:cx)>>>0>3){cw=1;break}cx=cu-cv|0,cw=((cx|0)<0?-cx|0:cx)>>>0>3|0}else cw=2;while(0);c[w>>2]=cw,cv=aq+30|0,cu=b[aS>>1]|0,a4=b[aM>>1]|0,bB=b[ba>>1]|0,cx=b[bV>>1]|0;do if((b[cv>>1]|0)==0){if((b[aq+28>>1]|0)!=0){cy=2;break}if(cz=cu-a4|0,((cz|0)<0?-cz|0:cz)>>>0>3){cy=1;break}cz=bB-cx|0,cy=((cz|0)<0?-cz|0:cz)>>>0>3|0}else cy=2;while(0);c[T>>2]=cy,cx=aq+36|0,bB=b[bG>>1]|0,a4=b[aS>>1]|0,cu=b[a_>>1]|0,bV=b[ba>>1]|0;do if((b[cx>>1]|0)==0){if((b[cv>>1]|0)!=0){cA=2;break}if(aM=bB-a4|0,((aM|0)<0?-aM|0:aM)>>>0>3){cA=1;break}if(aM=cu-bV|0,((aM|0)<0?-aM|0:aM)>>>0>3){cA=1;break}cA=(c[aq+120>>2]|0)!=(c[aq+116>>2]|0)|0}else cA=2;while(0);c[S>>2]=cA,bV=b[a2>>1]|0,cu=b[bG>>1]|0,a4=b[bY>>1]|0,bB=b[a_>>1]|0;do if((b[aq+38>>1]|0)==0){if((b[cx>>1]|0)!=0){cB=2;break}if(cv=bV-cu|0,((cv|0)<0?-cv|0:cv)>>>0>3){cB=1;break}cv=a4-bB|0,cB=((cv|0)<0?-cv|0:cv)>>>0>3|0}else cB=2;while(0);c[R>>2]=cB,bB=b[bU>>1]|0,a4=b[bE>>1]|0,cu=b[aO>>1]|0,bV=b[bT>>1]|0;do if((b[bW>>1]|0)==0){if((b[be>>1]|0)!=0){cC=2;break}if(cx=bB-a4|0,((cx|0)<0?-cx|0:cx)>>>0>3){cC=1;break}cx=cu-bV|0,cC=((cx|0)<0?-cx|0:cx)>>>0>3|0}else cC=2;while(0);c[Q>>2]=cC,bV=b[a0>>1]|0,cu=b[bU>>1]|0,a4=b[aL>>1]|0,bB=b[aO>>1]|0;do if((b[aH>>1]|0)==0){if((b[bW>>1]|0)!=0){cD=2;break}if(be=bV-cu|0,((be|0)<0?-be|0:be)>>>0>3){cD=1;break}if(be=a4-bB|0,((be|0)<0?-be|0:be)>>>0>3){cD=1;break}cD=(c[aq+120>>2]|0)!=(c[aq+116>>2]|0)|0}else cD=2;while(0);c[P>>2]=cD,bB=b[aQ>>1]|0,a4=b[a0>>1]|0,cu=b[a6>>1]|0,bV=b[aL>>1]|0;do if((b[a8>>1]|0)==0){if((b[aH>>1]|0)!=0){cE=2;break}if(bW=bB-a4|0,((bW|0)<0?-bW|0:bW)>>>0>3){cE=1;break}bW=cu-bV|0,cE=((bW|0)<0?-bW|0:bW)>>>0>3|0}else cE=2;while(0);c[O>>2]=cE,bV=b[b2>>1]|0,cu=b[bc>>1]|0,a4=b[b5>>1]|0,bB=b[b1>>1]|0;do if((b[b3>>1]|0)==0){if((b[b$>>1]|0)!=0){cF=2;break}if(aH=bV-cu|0,((aH|0)<0?-aH|0:aH)>>>0>3){cF=1;break}aH=a4-bB|0,cF=((aH|0)<0?-aH|0:aH)>>>0>3|0}else cF=2;while(0);c[N>>2]=cF,bB=b[b6>>1]|0,a4=b[b2>>1]|0,cu=b[b9>>1]|0,bV=b[b5>>1]|0;do if((b[b7>>1]|0)==0){if((b[b3>>1]|0)!=0){cG=2;break}if(b$=bB-a4|0,((b$|0)<0?-b$|0:b$)>>>0>3){cG=1;break}if(b$=cu-bV|0,((b$|0)<0?-b$|0:b$)>>>0>3){cG=1;break}cG=(c[aq+128>>2]|0)!=(c[aq+124>>2]|0)|0}else cG=2;while(0);c[M>>2]=cG,bV=b[ca>>1]|0,cu=b[b6>>1]|0,a4=b[cd>>1]|0,bB=b[b9>>1]|0;do if((b[cb>>1]|0)==0){if((b[b7>>1]|0)!=0){cH=2;break}if(b3=bV-cu|0,((b3|0)<0?-b3|0:b3)>>>0>3){cH=1;break}b3=a4-bB|0,cH=((b3|0)<0?-b3|0:b3)>>>0>3|0}else cH=2;while(0);c[L>>2]=cH,bB=b[ci>>1]|0,a4=b[ce>>1]|0,cu=b[cl>>1]|0,bV=b[ch>>1]|0;do if((b[cj>>1]|0)==0){if((b[cf>>1]|0)!=0){cI=2;break}if(b7=bB-a4|0,((b7|0)<0?-b7|0:b7)>>>0>3){cI=1;break}b7=cu-bV|0,cI=((b7|0)<0?-b7|0:b7)>>>0>3|0}else cI=2;while(0);c[K>>2]=cI,bV=b[cm>>1]|0,cu=b[ci>>1]|0,a4=b[cp>>1]|0,bB=b[cl>>1]|0;do if((b[cn>>1]|0)==0){if((b[cj>>1]|0)!=0){cJ=2;break}if(cf=bV-cu|0,((cf|0)<0?-cf|0:cf)>>>0>3){cJ=1;break}if(cf=a4-bB|0,((cf|0)<0?-cf|0:cf)>>>0>3){cJ=1;break}cJ=(c[aq+128>>2]|0)!=(c[aq+124>>2]|0)|0}else cJ=2;while(0);c[J>>2]=cJ,bB=b[cq>>1]|0,a4=b[cm>>1]|0,cu=b[ct>>1]|0,bV=b[cp>>1]|0;do if((b[cr>>1]|0)==0){if((b[cn>>1]|0)!=0){cK=2;break}if(cj=bB-a4|0,((cj|0)<0?-cj|0:cj)>>>0>3){cK=1;break}cj=cu-bV|0,cK=((cj|0)<0?-cj|0:cj)>>>0>3|0}else cK=2;while(0);c[I>>2]=cK;break}aU(aq,e)}while(0);if((aE|0)!=0)break;if((c[H>>2]|0)!=0)break;if((c[G>>2]|0)!=0)break;if((c[F>>2]|0)!=0)break;if((c[E>>2]|0)!=0)break;if((c[D>>2]|0)!=0)break;if((c[C>>2]
\ No newline at end of file
+}if((c[a+(s*40|0)+8>>2]|0)<=(j|0)){t=r;break L8}}if(cG(a+(r*40|0)|0,a+(s*40|0)|0,40)|0,s>>>0<g>>>0){p=s,q=14;break L6}r=s}for(;;){if(r=u-g|0,s=c[a+(r*40|0)+20>>2]|0,(s|0)!=0&(s-1|0)>>>0<2){if(s=c[a+(r*40|0)+8>>2]|0,(s|0)>(j|0)){t=u;break L8}if(v=a+(u*40|0)|0,!((s|0)<(j|0))){x=v;break L6}w=v}else w=a+(u*40|0)|0;if(cG(w|0,a+(r*40|0)|0,40)|0,r>>>0<g>>>0){p=r,q=14;break L6}u=r}}while(0);x=a+(t*40|0)|0}while(0);(q|0)==14&&(q=0,x=a+(p*40|0)|0),o=x,c[o>>2]=k,c[o+4>>2]=l,c[x+8>>2]=j,o=x+12|0,r=c[e+4>>2]|0,c[o>>2]=c[e>>2],c[o+4>>2]=r,c[x+20>>2]=n,c[x+24>>2]=m,r=x+28|0,c[r>>2]=c[f>>2],c[r+4>>2]=c[f+4>>2],c[r+8>>2]=c[f+8>>2],h=h+1|0}while(h>>>0<b>>>0)}g>>>=1}while((g|0)!=0);i=d}function bb(a,b){a|=0,b|=0;var d=0,e=0;do if(b>>>0>16)d=0;else{if(e=c[(c[a+4>>2]|0)+(b<<2)>>2]|0,(e|0)==0){d=0;break}if((c[e+20>>2]|0)>>>0<=1){d=0;break}d=c[e>>2]|0}while(0);return d|0}function bc(a){a|=0;var b=0;return b=(c[a>>2]|0)+((c[a+28>>2]|0)*40|0)|0,c[a+8>>2]=b,c[b>>2]|0}function bd(a,b,d,e,f,g){a|=0,b|=0,d|=0,e|=0,f|=0,g|=0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(c[a+36>>2]=65535,h=e>>>0>1?e:1,c[a+24>>2]=h,e=a+28|0,i=(g|0)==0?d:h,c[e>>2]=i,c[a+32>>2]=f,c[a+56>>2]=g,c[a+44>>2]=0,c[a+40>>2]=0,c[a+48>>2]=0,g=cD(680)|0,f=g,h=a|0,c[h>>2]=f,(g|0)==0)return j=65535,j|0;cF(g|0,0,680)|0;do if((i|0)==-1)k=0;else{for(g=b*384|0|47,d=0,l=f;;){if(c[l+(d*40|0)+4>>2]=cD(g)|0,m=c[h>>2]|0,n=c[m+(d*40|0)+4>>2]|0,(n|0)==0){j=65535,o=11;break}if(c[m+(d*40|0)>>2]=n+(-n&15),n=d+1|0,p=c[e>>2]|0,n>>>0>=(p+1|0)>>>0){o=7;break}d=n,l=c[h>>2]|0}if((o|0)==11)return j|0;if((o|0)==7){k=(p<<4)+16|0;break}}while(0);return p=cD(68)|0,c[a+4>>2]=p,o=cD(k)|0,c[a+12>>2]=o,(p|0)==0|(o|0)==0?(j=65535,j|0):(cF(p|0,0,68)|0,c[a+20>>2]=0,c[a+16>>2]=0,j=0,j|0)}function be(a,b,d,e,f,g){a|=0,b|=0,d|=0,e|=0,f|=0,g|=0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;h=a|0,i=c[h>>2]|0;do if((i|0)==0)j=0;else{if(k=a+28|0,(c[k>>2]|0)==-1){j=i;break}for(l=0,m=i;;){if(cE(c[m+(l*40|0)+4>>2]|0),c[(c[h>>2]|0)+(l*40|0)+4>>2]=0,n=l+1|0,o=c[h>>2]|0,!(n>>>0<((c[k>>2]|0)+1|0)>>>0)){j=o;break}l=n,m=o}}while(0);return cE(j),c[h>>2]=0,h=a+4|0,cE(c[h>>2]|0),c[h>>2]=0,h=a+12|0,cE(c[h>>2]|0),c[h>>2]=0,bd(a,b,d,e,f,g)|0}function bf(a){a|=0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=a|0,d=c[b>>2]|0;do if((d|0)==0)e=0;else{if(f=a+28|0,(c[f>>2]|0)==-1){e=d;break}for(g=0,h=d;;){if(cE(c[h+(g*40|0)+4>>2]|0),c[(c[b>>2]|0)+(g*40|0)+4>>2]=0,i=g+1|0,j=c[b>>2]|0,!(i>>>0<((c[f>>2]|0)+1|0)>>>0)){e=j;break}g=i,h=j}}while(0);cE(e),c[b>>2]=0,b=a+4|0,cE(c[b>>2]|0),c[b>>2]=0,b=a+12|0,cE(c[b>>2]|0),c[b>>2]=0}function bg(a){a|=0;var b=0,d=0,e=0;if(b=a+40|0,(c[b>>2]|0)!=0){d=a|0,e=a+4|0,a=0;do c[(c[e>>2]|0)+(a<<2)>>2]=(c[d>>2]|0)+(a*40|0),a=a+1|0;while(a>>>0<(c[b>>2]|0)>>>0)}}function bh(a,b,d,e){a|=0,b|=0,d|=0,e|=0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;if(f=a+16|0,c[f>>2]=0,c[a+20>>2]=0,(e|0)==0)return g=0,g|0;e=a+48|0,h=c[e>>2]|0,i=(h|0)==(b|0);L4:do if(i)j=37;else{if(k=a+32|0,l=((h+1|0)>>>0)%((c[k>>2]|0)>>>0)|0,(l|0)==(b|0)){j=37;break}m=a+28|0,n=a|0,o=c[(c[n>>2]|0)+((c[m>>2]|0)*40|0)>>2]|0,p=a+40|0,q=a+24|0,r=a+44|0,s=a+56|0,t=a+12|0,u=l;L7:for(;;){if(l=c[p>>2]|0,(l|0)==0)v=0;else for(w=0,x=l;;){if(l=c[n>>2]|0,((c[l+(w*40|0)+20>>2]|0)-1|0)>>>0<2?(y=c[l+(w*40|0)+12>>2]|0,z=y>>>0>u>>>0?y-(c[k>>2]|0)|0:y,c[l+(w*40|0)+8>>2]=z,A=c[p>>2]|0):A=x,l=w+1|0,!(l>>>0<A>>>0)){v=A;break}w=l,x=A}do if(v>>>0>=(c[q>>2]|0)>>>0){if((v|0)==0){g=1,j=51;break L7}for(x=c[n>>2]|0,w=-1,l=0,y=0;;){if(((c[x+(y*40|0)+20>>2]|0)-1|0)>>>0<2?(B=c[x+(y*40|0)+8>>2]|0,C=(B|0)<(l|0)|(w|0)==-1,D=C?B:l,E=C?y:w):(D=l,E=w),C=y+1|0,!(C>>>0<v>>>0))break;w=E,l=D,y=C}if((E|0)<=-1){g=1,j=50;break L7}if(c[x+(E*40|0)+20>>2]=0,c[p>>2]=(c[p>>2]|0)-1,(c[(c[n>>2]|0)+(E*40|0)+24>>2]|0)!=0)break;c[r>>2]=(c[r>>2]|0)-1}while(0);if(y=c[r>>2]|0,l=c[m>>2]|0,y>>>0<l>>>0)F=l;else for(w=l,l=y;;){do if((c[s>>2]|0)==0){for(y=c[n>>2]|0,C=0,B=2147483647,G=0;;){if((c[y+(C*40|0)+24>>2]|0)==0?(H=G,I=B):(J=c[y+(C*40|0)+16>>2]|0,K=(J|0)<(B|0),H=K?y+(C*40|0)|0:G,I=K?J:B),J=C+1|0,J>>>0>w>>>0)brea
\ No newline at end of file
+}function bq(b,e,f,g,h,i){b|=0,e|=0,f|=0,g|=0,h|=0,i|=0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0;j=(i|0)==0,i=0;L1:for(;;){k=bE(i)|0,l=c[k+4>>2]|0,m=bD(b,c[k>>2]|0)|0,k=bI(b,m)|0,(k|0)==0|j?n=k:(o=(bu(c[m>>2]|0)|0)==2,n=o?0:k),k=bF(i)|0,o=c[k+4>>2]|0,p=bD(b,c[k>>2]|0)|0,k=bI(b,p)|0,(k|0)==0|j?q=k:(r=(bu(c[p>>2]|0)|0)==2,q=r?0:k),k=(n|0)!=0,r=(q|0)==0,s=r|k^1,s?t=2:(u=(bu(c[m>>2]|0)|0)==0?d[(l&255)+(m+82)|0]|0:2,v=(bu(c[p>>2]|0)|0)==0?d[(o&255)+(p+82)|0]|0:2,t=u>>>0<v>>>0?u:v),(c[f+12+(i<<2)>>2]|0)==0?(p=c[f+76+(i<<2)>>2]|0,w=(p>>>0>=t>>>0)+p|0):w=t,a[b+82+i|0]=w,p=c[(bG(i)|0)>>2]|0,o=bD(b,p)|0,p=bI(b,o)|0,(p|0)==0|j?x=p:(m=(bu(c[o>>2]|0)|0)==2,x=m?0:p),p=c[(bH(i)|0)>>2]|0,m=bD(b,p)|0,p=bI(b,m)|0,(p|0)==0|j?y=p:(o=(bu(c[m>>2]|0)|0)==2,y=o?0:p),p=c[2640+(i<<2)>>2]|0,o=c[2576+(i<<2)>>2]|0,m=(1285>>>(i>>>0)&1|0)!=0,m?(z=h+o|0,A=h+(o+1)|0,B=h+(o+2)|0,C=h+(o+3)|0):(l=(o<<4)+p|0,z=e+(l-1)|0,A=e+(l+15)|0,B=e+(l+31)|0,C=e+(l+47)|0),l=a[z]|0,D=a[A]|0,E=a[B]|0,F=a[C]|0;do{if((51>>>(i>>>0)&1|0)==0){if(G=o-1|0,H=(G<<4)+p|0,I=a[e+H|0]|0,J=a[e+(H+1)|0]|0,K=a[e+(H+2)|0]|0,L=a[e+(H+3)|0]|0,M=a[e+(H+4)|0]|0,N=a[e+(H+5)|0]|0,O=a[e+(H+6)|0]|0,P=a[e+(H+7)|0]|0,m){Q=h+G|0,R=I,S=J,T=K,U=L,V=M,W=N,X=O,Y=P;break}Q=e+(H-1)|0,R=I,S=J,T=K,U=L,V=M,W=N,X=O,Y=P;break}Q=g+p|0,R=a[g+(p+1)|0]|0,S=a[g+(p+2)|0]|0,T=a[g+(p+3)|0]|0,U=a[g+(p+4)|0]|0,V=a[g+(p+5)|0]|0,W=a[g+(p+6)|0]|0,X=a[g+(p+7)|0]|0,Y=a[g+(p+8)|0]|0}while(0);switch(m=a[Q]|0,w|0){case 0:if(r){_=1,$=52;break L1}P=(T&255)<<16|(U&255)<<24|(S&255)<<8|R&255,aa=P,ab=P,ac=P,ad=P;break;case 1:if(!k){_=1,$=53;break L1}aa=Z(l&255,16843009)|0,ab=Z(D&255,16843009)|0,ac=Z(E&255,16843009)|0,ad=Z(F&255,16843009)|0;break;case 2:do if(s){if(k){ae=((l&255)+2+(D&255)+(E&255)+(F&255)|0)>>>2&255;break}if(r){ae=-128;break}ae=((U&255)+2+(T&255)+(S&255)+(R&255)|0)>>>2&255}else ae=((l&255)+4+(D&255)+(E&255)+(F&255)+(U&255)+(T&255)+(S&255)+(R&255)|0)>>>3&255;while(0);P=Z(ae&255,16843009)|0,aa=P,ab=P,ac=P,ad=P;break;case 3:if(r){_=1,$=54;break L1}P=(x|0)==0,O=S&255,N=T&255,M=N+2|0,L=U&255,K=L+2|0,J=(K+O+(N<<1)|0)>>>2&255,N=(P?U:V)&255,I=(M+(L<<1)+N|0)>>>2&255,L=(P?U:W)&255,H=(K+L+(N<<1)|0)>>>2,K=H&255,G=(P?U:X)&255,af=(N+2+G+(L<<1)|0)>>>2,N=af&255,ag=(P?U:Y)&255,P=(L+2+ag+(G<<1)|0)>>>2,aa=J<<8|H<<24|(M+(R&255)+(O<<1)|0)>>>2&255|I<<16,ab=K<<16|J|af<<24|I<<8,ac=I|K<<8|P<<24|N<<16,ad=(G+2+(ag*3|0)|0)>>>2<<24|K|N<<8|P<<16&16711680;break;case 4:if(s|(y|0)==0){_=1,$=55;break L1}P=R&255,N=m&255,K=l&255,ag=P+2|0,G=(ag+K+(N<<1)|0)>>>2,I=G&255,af=S&255,J=N+2|0,N=((P<<1)+af+J|0)>>>2,P=N&255,O=T&255,M=((af<<1)+O+ag|0)>>>2,ag=D&255,H=(ag+(K<<1)+J|0)>>>2&255,J=E&255,L=(K+2+(ag<<1)+J|0)>>>2&255,aa=M<<16&16711680|((U&255)+2+af+(O<<1)|0)>>>2<<24|I|P<<8,ab=H|M<<24|P<<16|I<<8,ac=N<<24|L|I<<16|H<<8,ad=(ag+2+(J<<1)+(F&255)|0)>>>2&255|L<<8|G<<24|H<<16;break;case 5:if(s|(y|0)==0){_=1,$=56;break L1}H=m&255,G=R&255,L=(G+1+H|0)>>>1&255,J=S&255,ag=(J+2+(G<<1)+H|0)>>>2&255,I=l&255,N=G+2|0,P=(N+I+(H<<1)|0)>>>2&255,M=(J+1+G|0)>>>1&255,G=T&255,O=((J<<1)+G+N|0)>>>2,N=(G+1+J|0)>>>1,af=U&255,K=D&255,aa=N<<16&16711680|(af+1+G|0)>>>1<<24|M<<8|L,ab=O<<16&16711680|(af+2+J+(G<<1)|0)>>>2<<24|P|ag<<8,ac=M<<16|N<<24|(K+2+(I<<1)+H|0)>>>2&255|L<<8,ad=O<<24|(I+2+(E&255)+(K<<1)|0)>>>2&255|ag<<16|P<<8;break;case 6:if(s|(y|0)==0){_=1,$=57;break L1}P=m&255,ag=l&255,K=ag+1|0,I=(K+P|0)>>>1&255,O=D&255,L=((ag<<1)+2+O+P|0)>>>2,H=(K+O|0)>>>1&255,K=E&255,N=ag+2|0,ag=(N+(O<<1)+K|0)>>>2,M=(O+1+K|0)>>>1&255,G=F&255,J=R&255,af=(N+J+(P<<1)|0)>>>2,N=S&255,aa=I|((T&255)+2+(N<<1)+J|0)>>>2<<24|(N+2+(J<<1)+P|0)>>>2<<16&16711680|af<<8&65280,ab=L<<8&65280|H|I<<16|af<<24,ac=M|H<<16|ag<<8&65280|L<<24,ad=ag<<24|M<<16|(K+1+G|0)>>>1&255|(O+2+(K<<1)+G|0)>>>2<<8&65280;break;case 7:if(r){_=1,$=58;break L1}G=(x|0)==0,K=R&255,O=S&255,M=T&255,ag=(M+1+O|0)>>>1&255,L=U&255,H=L+1|0,af=(H+M|0)>>>1&255,I=(G?U:V)&255,P=(H+I|0)>>>1,H=M+2|0,J=L+2|0,N=(J+O+(M<<1)|0)>>>2&255,M=(H+(L<<1)+I|0)>>>2&255,L=(G?U:W)&255,ah=(J+L+(I<<1)|0
\ No newline at end of file
+do if((e|0)<0)n=4;else{if((e+5+j|0)>>>0>g>>>0|(f|0)<0){n=4;break}(k+f|0)>>>0>h>>>0?n=4:(o=b,p=e,q=f,r=g)}while(0);if((n|0)==4&&(n=m,m=j+5|0,bM(b,n,e,f,g,h,m,k,m),o=n,p=0,q=0,r=m),(k|0)==0)return void(i=l);for(m=j>>>2,n=(m|0)==0,h=r-j|0,g=16-j|0,j=m<<2,f=o+(p+5+(Z(q,r)|0))|0,r=k,k=c;;){if(n)s=f,t=k;else{for(c=k+j|0,q=f,p=m,o=d[f-1|0]|0,e=d[f-2|0]|0,b=d[f-3|0]|0,u=d[f-4|0]|0,v=d[f-5|0]|0,w=k;;){if(x=u+o|0,y=d[q]|0,a[w]=a[(v+16-x-(x<<2)+y+((b+e|0)*20|0)>>5)+1808|0]|0,x=y+b|0,z=d[q+1|0]|0,a[w+1|0]=a[(u+16-x-(x<<2)+z+((e+o|0)*20|0)>>5)+1808|0]|0,x=z+e|0,A=d[q+2|0]|0,a[w+2|0]=a[(b+16-x-(x<<2)+A+((y+o|0)*20|0)>>5)+1808|0]|0,x=A+o|0,B=d[q+3|0]|0,a[w+3|0]=a[(e+16-x-(x<<2)+B+((z+y|0)*20|0)>>5)+1808|0]|0,x=p-1|0,(x|0)==0)break;q=q+4|0,p=x,v=o,o=B,e=A,b=z,u=y,w=w+4|0}s=f+j|0,t=c}if(w=r-1|0,(w|0)==0)break;f=s+h|0,r=w,k=t+g|0}i=l}function bS(b,c,e,f,g,h,j,k,l){b|=0,c|=0,e|=0,f|=0,g|=0,h|=0,j|=0,k|=0,l|=0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;m=i,i=i+448|0,n=m|0;do if((e|0)<0)o=4;else{if((e+5+j|0)>>>0>g>>>0|(f|0)<0){o=4;break}(k+f|0)>>>0>h>>>0?o=4:(p=b,q=e,r=f,s=g)}while(0);if((o|0)==4&&(o=n,n=j+5|0,bM(b,o,e,f,g,h,n,k,n),p=o,q=0,r=0,s=n),(k|0)==0)return void(i=m);for(n=j>>>2,o=(n|0)==0,h=s-j|0,g=16-j|0,j=(l|0)!=0,l=n<<2,f=p+(q+5+(Z(r,s)|0))|0,s=k,k=c;;){if(o)t=f,u=k;else{for(c=k+l|0,r=f,q=n,p=k,e=d[f-1|0]|0,b=d[f-2|0]|0,v=d[f-3|0]|0,w=d[f-4|0]|0,x=d[f-5|0]|0;;){if(y=w+e|0,z=d[r]|0,a[p]=((j?b:v)+1+(d[(x+16-y-(y<<2)+z+((v+b|0)*20|0)>>5)+1808|0]|0)|0)>>>1,y=z+v|0,A=d[r+1|0]|0,a[p+1|0]=((j?e:b)+1+(d[(w+16-y-(y<<2)+A+((b+e|0)*20|0)>>5)+1808|0]|0)|0)>>>1,y=A+b|0,B=d[r+2|0]|0,a[p+2|0]=((j?z:e)+1+(d[(v+16-y-(y<<2)+B+((z+e|0)*20|0)>>5)+1808|0]|0)|0)>>>1,y=B+e|0,C=d[r+3|0]|0,a[p+3|0]=((j?A:z)+1+(d[(b+16-y-(y<<2)+C+((A+z|0)*20|0)>>5)+1808|0]|0)|0)>>>1,y=q-1|0,(y|0)==0)break;r=r+4|0,q=y,p=p+4|0,x=e,e=C,b=B,v=A,w=z}t=f+l|0,u=c}if(w=s-1|0,(w|0)==0)break;f=t+h|0,s=w,k=u+g|0}i=m}function bT(b,c,e,f,g,h,j,k,l){b|=0,c|=0,e|=0,f|=0,g|=0,h|=0,j|=0,k|=0,l|=0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0;m=i,i=i+448|0,n=m|0;do if((e|0)<0)o=4;else{if((e+5+j|0)>>>0>g>>>0|(f|0)<0){o=4;break}(f+5+k|0)>>>0>h>>>0?o=4:(p=b,q=e,r=f,s=g)}while(0);if((o|0)==4&&(o=n,n=j+5|0,bM(b,o,e,f,g,h,n,k+5|0,n),p=o,q=0,r=0,s=n),n=(Z(r,s)|0)+q|0,q=(l&1|2)+s+n|0,r=p+q|0,(k|0)==0)return void(i=m);for(o=j>>>2,h=(o|0)==0,g=s-j|0,f=16-j|0,e=o<<2,b=c,c=p+((Z(s,l>>>1&1|2)|0)+5+n)|0,n=k;;){if(h)t=b,u=c;else{for(l=b+e|0,v=b,w=c,x=o,y=d[c-1|0]|0,z=d[c-2|0]|0,A=d[c-3|0]|0,B=d[c-4|0]|0,C=d[c-5|0]|0;;){if(D=B+y|0,E=d[w]|0,a[v]=a[(C+16-D-(D<<2)+E+((A+z|0)*20|0)>>5)+1808|0]|0,D=E+A|0,F=d[w+1|0]|0,a[v+1|0]=a[(B+16-D-(D<<2)+F+((z+y|0)*20|0)>>5)+1808|0]|0,D=F+z|0,G=d[w+2|0]|0,a[v+2|0]=a[(A+16-D-(D<<2)+G+((E+y|0)*20|0)>>5)+1808|0]|0,D=G+y|0,H=d[w+3|0]|0,a[v+3|0]=a[(z+16-D-(D<<2)+H+((F+E|0)*20|0)>>5)+1808|0]|0,D=x-1|0,(D|0)==0)break;v=v+4|0,w=w+4|0,x=D,C=y,y=H,z=G,A=F,B=E}t=l,u=c+e|0}if(B=n-1|0,(B|0)==0)break;b=t+f|0,c=u+g|0,n=B}if(n=k>>>2,(n|0)==0)return void(i=m);for(g=(j|0)==0,u=(s<<2)-j|0,c=64-j|0,b=-s|0,e=b<<1,o=s<<1,h=t+(f-(k<<4))|0,k=r,r=p+(q+(s*5|0))|0,q=n;;){if(g)I=h,J=k,K=r;else{for(n=h+j|0,p=h,f=k,t=r,B=j;;){if(A=d[t+e|0]|0,z=d[t+b|0]|0,y=d[t+s|0]|0,C=d[t]|0,x=y+A|0,w=d[f+o|0]|0,v=p+48|0,a[v]=((d[((d[t+o|0]|0)+16-x-(x<<2)+w+((C+z|0)*20|0)>>5)+1808|0]|0)+1+(d[v]|0)|0)>>>1,v=w+C|0,x=d[f+s|0]|0,E=p+32|0,a[E]=((d[(y+16-v-(v<<2)+x+((z+A|0)*20|0)>>5)+1808|0]|0)+1+(d[E]|0)|0)>>>1,E=d[f]|0,v=x+z|0,y=p+16|0,a[y]=((d[(C+16-v-(v<<2)+E+((w+A|0)*20|0)>>5)+1808|0]|0)+1+(d[y]|0)|0)>>>1,y=E+A|0,a[p]=((d[(z+16-y-(y<<2)+(d[f+b|0]|0)+((x+w|0)*20|0)>>5)+1808|0]|0)+1+(d[p]|0)|0)>>>1,w=B-1|0,(w|0)==0)break;p=p+1|0,f=f+1|0,t=t+1|0,B=w}I=n,J=k+j|0,K=r+j|0}if(B=q-1|0,(B|0)==0)break;h=I+c|0,k=J+u|0,r=K+u|0,q=B}i=m}function bU(b,e,f,g,h,j,k,l){b|=0,e|=0,f|=0,g|=0,h|=0,j|=0,k|=0,l|=0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0;m=i,i=i+1792|0,n=m|0,o=m+448|0;do if((f|0)<0)p=5;else{if((f+5+k|0)>>>0>h>>>0|(g|0)<0){p=5;break}if((g+5+l|0)>>>0>j>>>0){p=5;break}q=b,r=f+5|0,s=g,t=h,
\ No newline at end of file
+if((c[(c[m>>2]|0)+(n<<2)>>2]|0)>>>0>k>>>0){g=1;break}n=n+1|0}return g|0}if((l|0)!=2){if((l-3|0)>>>0<3){if(!((c[f+36>>2]|0)>>>0>k>>>0))break;return g=1,g|0}if((l|0)!=6)break;if(!((c[f+40>>2]|0)>>>0<k>>>0))break;return g=1,g|0}for(n=i-1|0,m=f+24|0,o=f+28|0,p=0;;){if(p>>>0>=n>>>0)break L7;if(q=c[(c[m>>2]|0)+(p<<2)>>2]|0,r=c[(c[o>>2]|0)+(p<<2)>>2]|0,!(q>>>0<=r>>>0&r>>>0<k>>>0)){g=1,s=39;break}if(((q>>>0)%(j>>>0)|0)>>>0>((r>>>0)%(j>>>0)|0)>>>0){g=1,s=38;break}p=p+1|0}if((s|0)==38)return g|0;if((s|0)==39)return g|0}while(0);k=a+4|0,f=c[k>>2]|0;do{if((f|0)!=256){if(i=a+3380|0,(c[i>>2]|0)==0){if((f|0)==(b|0))break;if(j=a+8|0,(h|0)==(c[j>>2]|0)){c[k>>2]=b,c[a+12>>2]=c[e>>2];break}if((d|0)==0)return g=1,g|0;c[k>>2]=b,s=c[e>>2]|0,c[a+12>>2]=s,p=c[s+4>>2]|0,c[j>>2]=p,j=c[a+20+(p<<2)>>2]|0,c[a+16>>2]=j,p=j+52|0,s=j+56|0,c[a+1176>>2]=Z(c[s>>2]|0,c[p>>2]|0)|0,c[a+1340>>2]=c[p>>2],c[a+1344>>2]=c[s>>2],c[i>>2]=1;break}if(c[i>>2]=0,i=a+1212|0,cE(c[i>>2]|0),c[i>>2]=0,s=a+1172|0,cE(c[s>>2]|0),p=c[a+1176>>2]|0,j=p*216|0,o=cD(j)|0,m=o,c[i>>2]=m,i=cD(p<<2)|0,c[s>>2]=i,(o|0)==0|(i|0)==0)return g=65535,g|0;cF(o|0,0,j|0)|0,j=a+16|0,bC(m,c[(c[j>>2]|0)+52>>2]|0,p),p=c[j>>2]|0;L47:do if((c[a+1216>>2]|0)==0){if((c[p+16>>2]|0)==2){t=1;break}do if((c[p+80>>2]|0)!=0){if(j=c[p+84>>2]|0,(c[j+920>>2]|0)==0)break;if((c[j+944>>2]|0)==0){t=1;break L47}}while(0);t=0}else t=1;while(0);if(l=Z(c[p+56>>2]|0,c[p+52>>2]|0)|0,j=be(a+1220|0,l,c[p+88>>2]|0,c[p+44>>2]|0,c[p+12>>2]|0,t)|0,(j|0)==0)break;return g=j,g|0}c[k>>2]=b,s=c[e>>2]|0,c[a+12>>2]=s,j=c[s+4>>2]|0,c[a+8>>2]=j,s=c[a+20+(j<<2)>>2]|0,c[a+16>>2]=s,j=s+52|0,i=s+56|0,c[a+1176>>2]=Z(c[i>>2]|0,c[j>>2]|0)|0,c[a+1340>>2]=c[j>>2],c[a+1344>>2]=c[i>>2],c[a+3380>>2]=1}while(0);return g=0,g|0}function cf(a){a|=0;var b=0,d=0;if(c[a+1196>>2]=0,c[a+1192>>2]=0,b=a+1176|0,(c[b>>2]|0)!=0){d=a+1212|0,a=0;do c[(c[d>>2]|0)+(a*216|0)+4>>2]=0,c[(c[d>>2]|0)+(a*216|0)+196>>2]=0,a=a+1|0;while(a>>>0<(c[b>>2]|0)>>>0)}}function cg(a){return a|=0,(c[a+1188>>2]|0)==0|0}function ch(a){a|=0;var b=0,d=0,e=0,f=0,g=0;do{if((c[a+1404>>2]|0)==0){if((c[a+1196>>2]|0)!=(c[a+1176>>2]|0))break;return b=1,b|0}if(d=c[a+1176>>2]|0,(d|0)==0)return b=1,b|0;e=c[a+1212>>2]|0,f=0,g=0;do g=((c[e+(f*216|0)+196>>2]|0)!=0)+g|0,f=f+1|0;while(f>>>0<d>>>0);if((g|0)!=(d|0))break;return b=1,b|0}while(0);return b=0,b|0}function ci(a,b){a|=0,b|=0;var d=0;d=c[a+16>>2]|0,b2(c[a+1172>>2]|0,c[a+12>>2]|0,b,c[d+52>>2]|0,c[d+56>>2]|0)}function cj(a,b,d,e){a|=0,b|=0,d|=0,e|=0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;if(f=i,i=i+48|0,g=f|0,h=f+8|0,j=f+16|0,k=f+24|0,l=f+32|0,m=f+40|0,c[e>>2]=0,n=b|0,o=c[n>>2]|0,(o-6|0)>>>0<6|(o-13|0)>>>0<6)return c[e>>2]=1,p=0,i=f,p|0;if(!((o|0)==1|(o|0)==5))return p=0,i=f,p|0;if(o=d+1300|0,q=d+1332|0,(c[q>>2]|0)!=0&&(c[e>>2]=1,c[q>>2]=0),q=b4(a,g)|0,(q|0)!=0)return p=q,i=f,p|0;if(q=c[d+148+(c[g>>2]<<2)>>2]|0,(q|0)==0)return p=65520,i=f,p|0;if(g=c[q+4>>2]|0,r=c[d+20+(g<<2)>>2]|0,(r|0)==0)return p=65520,i=f,p|0;s=c[d+8>>2]|0;do if(!((s|0)==32|(g|0)==(s|0))){if((c[n>>2]|0)==5)break;return p=65520,i=f,p|0}while(0);s=c[d+1304>>2]|0,g=c[b+4>>2]|0;do if((s|0)!=(g|0)){if(!((s|0)==0|(g|0)==0))break;c[e>>2]=1}while(0);if(g=o|0,s=(c[n>>2]|0)==5,(c[g>>2]|0)==5?s||(t=17):s&&(t=17),(t|0)==17&&(c[e>>2]=1),t=r+12|0,(b5(a,c[t>>2]|0,h)|0)!=0)return p=1,i=f,p|0;if(s=d+1308|0,u=c[h>>2]|0,(c[s>>2]|0)!=(u|0)&&(c[s>>2]=u,c[e>>2]=1),(c[n>>2]|0)==5){if((b6(a,c[t>>2]|0,5,j)|0)!=0)return p=1,i=f,p|0;do if((c[g>>2]|0)==5){if(t=d+1312|0,u=c[t>>2]|0,s=c[j>>2]|0,(u|0)==(s|0)){v=u,w=t;break}c[e>>2]=1,v=s,w=t}else v=c[j>>2]|0,w=d+1312|0;while(0);c[w>>2]=v}v=c[r+16>>2]|0;do if((v|0)==0){if((b7(a,r,c[n>>2]|0,k)|0)!=0)return p=1,i=f,p|0;if(w=d+1316|0,j=c[k>>2]|0,(c[w>>2]|0)!=(j|0)&&(c[w>>2]=j,c[e>>2]=1),(c[q+8>>2]|0)==0)break;if(j=b8(a,r,c[n>>2]|0,l)|0,(j|0)!=0)return p=j,i=f,p|0;if(j=d+1320|0,w=c[l>>2]|0,(c[j>>2]|0)==(w|0))break;c[j>>2]=w,c[e>>2]=1}else if((v|0)==1){if((c[r+24>>2]|0)!=0)break;if(w=q+8|0,j=m|0,g=b9(a,r,c[n>>2]|0,c[w>>2]|0,j)|0,(g|0)!=0)return p=g,i=f,p|0;if(g=d+1324|0,t=c[j>>2]|0,(c[g>>2]|0)!=(t|0)&&(c[g>>2]=t,c[e>>2]=1),(c[w>>2]
\ No newline at end of file
+}while(0);if(m=7464+(aJ<<2)|0,c[ad+28>>2]=aJ,c[ad+20>>2]=0,c[ad+16>>2]=0,Z=c[1791]|0,Q=1<<aJ,(Z&Q|0)==0){c[1791]=Z|Q,c[m>>2]=K,c[ad+24>>2]=m,c[ad+12>>2]=ad,c[ad+8>>2]=ad;break}for(aK=(aJ|0)==31?0:25-(aJ>>>1)|0,Q=_<<aK,Z=c[m>>2]|0;;){if((c[Z+4>>2]&-8|0)==(_|0))break;if(aL=Z+16+(Q>>>31<<2)|0,m=c[aL>>2]|0,(m|0)==0){T=331;break}Q<<=1,Z=m}if((T|0)==331){if(aL>>>0<(c[1794]|0)>>>0)return ao(),0;c[aL>>2]=K,c[ad+24>>2]=Z,c[ad+12>>2]=ad,c[ad+8>>2]=ad;break}if(Q=Z+8|0,_=c[Q>>2]|0,m=c[1794]|0,Z>>>0<m>>>0)return ao(),0;if(_>>>0<m>>>0)return ao(),0;c[_+12>>2]=K,c[Q>>2]=K,c[ad+8>>2]=_,c[ad+12>>2]=Z,c[ad+24>>2]=0;break}S=c[1794]|0,(S|0)==0|ab>>>0<S>>>0&&(c[1794]=ab),c[1902]=ab,c[1903]=aa,c[1905]=0,c[1799]=c[1784],c[1798]=-1,S=0;do Y=S<<1,ac=7200+(Y<<2)|0,c[7200+(Y+3<<2)>>2]=ac,c[7200+(Y+2<<2)>>2]=ac,S=S+1|0;while(S>>>0<32);S=ab+8|0,ae=(S&7|0)==0?0:-S&7,S=aa-40-ae|0,c[1796]=ab+ae,c[1793]=S,c[ab+(ae+4)>>2]=S|1,c[ab+(aa-36)>>2]=40,c[1797]=c[1788]}while(0);if(ad=c[1793]|0,ad>>>0<=o>>>0)break;return _=ad-o|0,c[1793]=_,ad=c[1796]|0,Q=ad,c[1796]=Q+o,c[Q+(o+4)>>2]=_|1,c[ad+4>>2]=o|3,n=ad+8|0,n|0}while(0);return c[(am()|0)>>2]=12,n=0,n|0}function cE(a){a|=0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;if((a|0)!=0){b=a-8|0,d=b,e=c[1794]|0,b>>>0<e>>>0&&ao(),f=c[a-4>>2]|0,g=f&3,(g|0)==1&&ao(),h=f&-8,i=a+(h-8)|0,j=i;L10:do if((f&1|0)==0){if(k=c[b>>2]|0,(g|0)==0)return;if(l=-8-k|0,m=a+l|0,n=m,o=k+h|0,m>>>0<e>>>0&&ao(),(n|0)==(c[1795]|0)){if(p=a+(h-4)|0,(c[p>>2]&3|0)!=3){q=n,r=o;break}return c[1792]=o,c[p>>2]=c[p>>2]&-2,c[a+(l+4)>>2]=o|1,void(c[i>>2]=o)}if(p=k>>>3,k>>>0<256){k=c[a+(l+8)>>2]|0,s=c[a+(l+12)>>2]|0,t=7200+(p<<1<<2)|0;do if((k|0)!=(t|0)){if(k>>>0<e>>>0&&ao(),(c[k+12>>2]|0)==(n|0))break;ao()}while(0);if((s|0)==(k|0)){c[1790]=c[1790]&~(1<<p),q=n,r=o;break}do if((s|0)==(t|0))u=s+8|0;else{if(s>>>0<e>>>0&&ao(),v=s+8|0,(c[v>>2]|0)==(n|0)){u=v;break}ao()}while(0);c[k+12>>2]=s,c[u>>2]=k,q=n,r=o;break}t=m,p=c[a+(l+24)>>2]|0,v=c[a+(l+12)>>2]|0;do if((v|0)==(t|0)){if(w=a+(l+20)|0,x=c[w>>2]|0,(x|0)==0){if(y=a+(l+16)|0,z=c[y>>2]|0,(z|0)==0){A=0;break}B=z,C=y}else B=x,C=w;for(;;)if(w=B+20|0,x=c[w>>2]|0,(x|0)==0){if(w=B+16|0,x=c[w>>2]|0,(x|0)==0)break;B=x,C=w}else B=x,C=w;if(!(C>>>0<e>>>0)){c[C>>2]=0,A=B;break}ao()}else{if(w=c[a+(l+8)>>2]|0,w>>>0<e>>>0&&ao(),x=w+12|0,(c[x>>2]|0)!=(t|0)&&ao(),y=v+8|0,(c[y>>2]|0)==(t|0)){c[x>>2]=v,c[y>>2]=w,A=v;break}ao()}while(0);if((p|0)==0){q=n,r=o;break}v=a+(l+28)|0,m=7464+(c[v>>2]<<2)|0;do{if((t|0)==(c[m>>2]|0)){if(c[m>>2]=A,(A|0)!=0)break;c[1791]=c[1791]&~(1<<c[v>>2]),q=n,r=o;break L10}if(p>>>0<(c[1794]|0)>>>0&&ao(),k=p+16|0,(c[k>>2]|0)==(t|0)?c[k>>2]=A:c[p+20>>2]=A,(A|0)==0){q=n,r=o;break L10}}while(0);A>>>0<(c[1794]|0)>>>0&&ao(),c[A+24>>2]=p,t=c[a+(l+16)>>2]|0;do if((t|0)!=0){if(!(t>>>0<(c[1794]|0)>>>0)){c[A+16>>2]=t,c[t+24>>2]=A;break}ao()}while(0);if(t=c[a+(l+20)>>2]|0,(t|0)==0){q=n,r=o;break}if(!(t>>>0<(c[1794]|0)>>>0)){c[A+20>>2]=t,c[t+24>>2]=A,q=n,r=o;break}ao()}else q=d,r=h;while(0);d=q,d>>>0>=i>>>0&&ao(),A=a+(h-4)|0,e=c[A>>2]|0,(e&1|0)==0&&ao();do{if((e&2|0)==0){if((j|0)==(c[1796]|0)){if(B=(c[1793]|0)+r|0,c[1793]=B,c[1796]=q,c[q+4>>2]=B|1,(q|0)!=(c[1795]|0))return;return c[1795]=0,void(c[1792]=0)}if((j|0)==(c[1795]|0))return B=(c[1792]|0)+r|0,c[1792]=B,c[1795]=q,c[q+4>>2]=B|1,void(c[d+B>>2]=B);B=(e&-8)+r|0,C=e>>>3;L112:do if(e>>>0<256){u=c[a+h>>2]|0,g=c[a+(h|4)>>2]|0,b=7200+(C<<1<<2)|0;do if((u|0)!=(b|0)){if(u>>>0<(c[1794]|0)>>>0&&ao(),(c[u+12>>2]|0)==(j|0))break;ao()}while(0);if((g|0)==(u|0)){c[1790]=c[1790]&~(1<<C);break}do if((g|0)==(b|0))D=g+8|0;else{if(g>>>0<(c[1794]|0)>>>0&&ao(),f=g+8|0,(c[f>>2]|0)==(j|0)){D=f;break}ao()}while(0);c[u+12>>2]=g,c[D>>2]=u}else{b=i,f=c[a+(h+16)>>2]|0,t=c[a+(h|4)>>2]|0;do if((t|0)==(b|0)){if(p=a+(h+12)|0,v=c[p>>2]|0,(v|0)==0){if(m=a+(h+8)|0,k=c[m>>2]|0,(k|0)==0){E=0;break}F=k,G=m}else F=v,G=p;for(;;)if(p=F+20|0,v=c[p>>2]|0,(v|0)==0){if(p=F+16|0,v=c[p>>2]|0,(v|0)==0)break;F=v,G=p}else F=v,G=p;if(!(G>>>0<(c[1794]|0)>>>0)){c[G>>2]=0,E=F;break}ao()}else{if(p=c[a+h
\ No newline at end of file
+var scaleX=1,scaleY=1;this.quadVTCBuffer=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,this.quadVTCBuffer),tmp=[scaleX,0,0,0,scaleX,scaleY,0,scaleY],gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(tmp),gl.STATIC_DRAW)}function mvIdentity(){this.mvMatrix=Matrix.I(4)}function mvMultiply(m){this.mvMatrix=this.mvMatrix.x(m)}function mvTranslate(m){mvMultiply.call(this,Matrix.Translation($V([m[0],m[1],m[2]])).ensure4x4())}function setMatrixUniforms(){this.program.setMatrixUniform("uPMatrix",new Float32Array(this.perspectiveMatrix.flatten())),this.program.setMatrixUniform("uMVMatrix",new Float32Array(this.mvMatrix.flatten()))}function initScene(){var gl=this.gl;this.perspectiveMatrix=makePerspective(45,1,.1,100),mvIdentity.call(this),mvTranslate.call(this,[0,0,-2.4]),gl.bindBuffer(gl.ARRAY_BUFFER,this.quadVPBuffer),gl.vertexAttribPointer(this.vertexPositionAttribute,3,gl.FLOAT,!1,0,0),gl.bindBuffer(gl.ARRAY_BUFFER,this.quadVTCBuffer),gl.vertexAttribPointer(this.textureCoordAttribute,2,gl.FLOAT,!1,0,0),this.onInitSceneTextures(),setMatrixUniforms.call(this),this.framebuffer&&(console.log("Bound Frame Buffer"),gl.bindFramebuffer(gl.FRAMEBUFFER,this.framebuffer))}var vertexShaderScript=Script.createFromSource("x-shader/x-vertex",text(["attribute vec3 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat4 uMVMatrix;","uniform mat4 uPMatrix;","varying highp vec2 vTextureCoord;","void main(void) {","  gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);","  vTextureCoord = aTextureCoord;","}"])),fragmentShaderScript=Script.createFromSource("x-shader/x-fragment",text(["precision highp float;","varying highp vec2 vTextureCoord;","uniform sampler2D texture;","void main(void) {","  gl_FragColor = texture2D(texture, vTextureCoord);","}"]));return constructor.prototype={toString:function(){return"WebGLCanvas Size: "+this.size},checkLastError:function(operation){var err=this.gl.getError();if(err!=this.gl.NO_ERROR){var name=this.glNames[err];name=void 0!==name?name+"("+err+")":"Unknown WebGL ENUM (0x"+value.toString(16)+")",operation?console.log("WebGL Error: %s, %s",operation,name):console.log("WebGL Error: %s",name),console.trace()}},onInitWebGL:function(){try{this.gl=this.canvas.getContext("experimental-webgl")}catch(e){}if(this.gl||error("Unable to initialize WebGL. Your browser may not support it."),!this.glNames){this.glNames={};for(var propertyName in this.gl)"number"==typeof this.gl[propertyName]&&(this.glNames[this.gl[propertyName]]=propertyName)}},onInitShaders:function(){this.program=new Program(this.gl),this.program.attach(new Shader(this.gl,vertexShaderScript)),this.program.attach(new Shader(this.gl,fragmentShaderScript)),this.program.link(),this.program.use(),this.vertexPositionAttribute=this.program.getAttributeLocation("aVertexPosition"),this.gl.enableVertexAttribArray(this.vertexPositionAttribute),this.textureCoordAttribute=this.program.getAttributeLocation("aTextureCoord"),this.gl.enableVertexAttribArray(this.textureCoordAttribute)},onInitTextures:function(){var gl=this.gl;this.texture=new Texture(gl,this.size,gl.RGB)},onInitSceneTextures:function(){this.texture.bind(0,this.program,"texture")},drawScene:function(){this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)},readPixels:function(buffer){var gl=this.gl;gl.readPixels(0,0,this.size.w,this.size.h,gl.RGB,gl.UNSIGNED_BYTE,buffer)}},constructor}(),YUVWebGLCanvas=function(){function constructor(canvas,size){WebGLCanvas.call(this,canvas,size)}var vertexShaderScript=Script.createFromSource("x-shader/x-vertex",text(["attribute vec3 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat4 uMVMatrix;","uniform mat4 uPMatrix;","varying highp vec2 vTextureCoord;","void main(void) {","  gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);","  vTextureCoord = aTextureCoord;","}"])),fragmentShaderScript=(Script.createFromSource("x-shader/x-fragment",text(["precision highp float;","varying highp vec2 vTextureCoord;","uniform sampler2D YTexture;","uniform sampler2D UTexture;","uniform sampler2D VTexture;","void main(void) {","  vec3 YUV = vec3","  (
\ No newline at end of file
--- a/js/h264bsd.js
+++ b/js/h264bsd.js
@@ -22,19 +22,28 @@
 
 /*
  * This class wraps the details of the h264bsd library.
+ * Module object is an Emscripten module provided globally by h264bsd_asm.js
+ * targetElement element is an HTML element that will emit events that should 
+ * be listened for when H264 images are ready to be displayed
+ * forceRGB boolean Says whether the YUV->RGB decoding should be used (even 
+ * in the presence of the WebGL canvas)
  */
-function H264Decoder(Module, targetCanvas, forceRGB) {
+function H264Decoder(Module, targetElement, forceRGB) {
 	var self = this;	
 	self.Module = Module;
 	self.released = false;
 	self.yuvCanvas = null;
-	self.pStorage = H264Decoder.h264bsdAlloc(self.Module);
-	H264Decoder.h264bsdInit(self.Module, self.pStorage, 0);
-	self.targetCanvas = targetCanvas;	
+	self.pStorage = H264Decoder.h264bsdAlloc_(self.Module);
+	H264Decoder.h264bsdInit_(self.Module, self.pStorage, 0);
+	self.targetElement = targetElement;	
+
+	//If we are using RGB
 	if (forceRGB){
 		self.useWebGL = false;
 		self.precision = 32768;
-		self.co_y = Math.floor((1.165 * self.precision) + 0.5);
+
+		//Calculate all of the YUV->RGB coefficients 
+		self.co_y = Math.floor((1.164 * self.precision) + 0.5);
 		self.co_rv = Math.floor((1.596 * self.precision) + 0.5);
 		self.co_gu = Math.floor((0.391 * self.precision) + 0.5);
 		self.co_gv = Math.floor((0.813 * self.precision) + 0.5);
@@ -70,7 +79,8 @@
 			self.coefficients_bu[i] = self.co_bu * (i - 128);
 		}
 	}else{
-		self.useWebGL = H264Decoder.detectWebGl();	
+		//Check if we can use WebGL (as this dictates the output pipline)
+		self.useWebGL = H264Decoder.detectWebGl_();	
 	}	
 };
 
@@ -81,15 +91,17 @@
 H264Decoder.PARAM_SET_ERROR = 4;
 H264Decoder.MEMALLOC_ERROR = 5;
 
+//Clean up memory used by the decoder
 H264Decoder.prototype.release = function() {
 	var self = this;
 	if(self.released) return;
 
 	self.released = true;
-	H264Decoder.h264bsdShutdown(self.Module, self.pStorage);
-	H264Decoder.h264bsdFree(self.Module, self.pStorage);
+	H264Decoder.h264bsdShutdown_(self.Module, self.pStorage);
+	H264Decoder.h264bsdFree_(self.Module, self.pStorage);
 };
 
+//Takes an array buffer of bytes and returns a UInt8Array of the decoded bytes
 H264Decoder.prototype.decode = function(data) {
 	var self = this;
 	if(typeof data === 'undefined' || !(data instanceof ArrayBuffer)) {
@@ -107,16 +119,16 @@
 	var lastPicId = 0; //ID of the last picture decoded
 
 	//Get a pointer into the heap were our decoded bytes will live
-	pData = pAlloced = H264Decoder.malloc(self.Module, length);
+	pData = pAlloced = H264Decoder.malloc_(self.Module, length);
 	self.Module.HEAPU8.set(data, pData);
 
 	//get a pointer to where bytesRead will be stored: Uint32 = 4 bytes
-	pBytesRead = H264Decoder.malloc(self.Module, 4);
+	pBytesRead = H264Decoder.malloc_(self.Module, 4);
 
 	//Keep decoding frames while there is still something to decode
 	while(length > 0) {
 
-		retCode = H264Decoder.h264bsdDecode(self.Module, self.pStorage, pData, length, lastPicId, pBytesRead);		
+		retCode = H264Decoder.h264bsdDecode_(self.Module, self.pStorage, pData, length, lastPicId, pBytesRead);		
 		bytesRead = self.Module.getValue(pBytesRead, 'i32');
 		switch(retCode){
 			case H264Decoder.PIC_RDY:
@@ -125,8 +137,9 @@
 					detail: self.getNextOutputPicture()
 				});
 
-				if (self.targetCanvas != null){
-					self.targetCanvas.dispatchEvent(evt);
+				if (self.targetElement != null){
+					//Raise the event on the displaying canvas element
+					self.targetElement.dispatchEvent(evt);
 				}				
 				break;
 		}
@@ -136,11 +149,11 @@
 	}
 
 	if(pAlloced != 0) {
-		H264Decoder.free(self.Module, pAlloced);
+		H264Decoder.free_(self.Module, pAlloced);
 	}
 	
 	if(pBytesRead != 0) {
-		H264Decoder.free(self.Module, pBytesRead);
+		H264Decoder.free_(self.Module, pBytesRead);
 	}
 
 };
@@ -147,33 +160,35 @@
 
 H264Decoder.prototype.getNextOutputPicture = function(){
 	var self = this; 
-	var length = self.getYUVLength();
+	var length = H264Decoder.getYUVLength_(self.Module, self.pStorage);
 
-	var pPicId = H264Decoder.malloc(self.Module, 4);
+	var pPicId = H264Decoder.malloc_(self.Module, 4);
 	var picId = 0;
 
-	var pIsIdrPic = H264Decoder.malloc(self.Module, 4);
+	var pIsIdrPic = H264Decoder.malloc_(self.Module, 4);
 	var isIdrPic = 0;
 
-	var pNumErrMbs = H264Decoder.malloc(self.Module, 4);
+	var pNumErrMbs = H264Decoder.malloc_(self.Module, 4);
 	var numErrMbs = 0;
 
-	var pBytes = H264Decoder.h264bsdNextOutputPicture(self.Module, self.pStorage, pPicId, pIsIdrPic, pNumErrMbs);
+	var pBytes = H264Decoder.h264bsdNextOutputPicture_(self.Module, self.pStorage, pPicId, pIsIdrPic, pNumErrMbs);
 	var bytes = null;
 
+	//We don't really use these
 	picId = self.Module.getValue(pPicId, 'i32');	
 	isIdrPic = self.Module.getValue(pIsIdrPic, 'i32');	
 	numErrMbs = self.Module.getValue(pNumErrMbs, 'i32');
-	
-	bytes = new Uint8Array();
+		
 	bytes = self.Module.HEAPU8.subarray(pBytes, (pBytes + length));
 
-    H264Decoder.free(self.Module, pPicId);		
-  	H264Decoder.free(self.Module, pIsIdrPic);
-    H264Decoder.free(self.Module, pNumErrMbs);	
+    H264Decoder.free_(self.Module, pPicId);		
+  	H264Decoder.free_(self.Module, pIsIdrPic);
+    H264Decoder.free_(self.Module, pNumErrMbs);	
 
     var ret = {};
-    var croppingInfo = self.getCroppingInfo();
+    var croppingInfo = H264Decoder.getCroppingInfo_(self.Module, self.pStorage);
+
+    //Return bytes according to the requested format
     if (self.useWebGL){
 		ret = {
 		    encoding: 'YUV',
@@ -183,7 +198,7 @@
     }else{
 		ret = {
 			encoding: 'RGB',
-		    picture: H264Decoder.convertYUV2RGB(bytes, croppingInfo), 
+		    picture: H264Decoder.convertYUV2RGB_(bytes, croppingInfo, self), 
 		    height: croppingInfo.height, 
 		    width: croppingInfo.width};
     }
@@ -192,40 +207,25 @@
 };
 
 
-H264Decoder.prototype.getCroppingInfo = function(){
+H264Decoder.getCroppingInfo_ = function(Module, pStorage){
 	var self = this;
-	var pCroppingFlag = H264Decoder.malloc(self.Module, 4);
-	var pLeftOffset = H264Decoder.malloc(self.Module, 4);
-	var pTopOffset = H264Decoder.malloc(self.Module, 4);
-	var pWidth = H264Decoder.malloc(self.Module, 4);
-	var pHeight = H264Decoder.malloc(self.Module, 4);
-
 	var result = {
-		'width': (H264Decoder.h264bsdPicWidth(self.Module, self.pStorage)*16),
-		'height': (H264Decoder.h264bsdPicHeight(self.Module, self.pStorage)*16),
+		'width': (H264Decoder.h264bsdPicWidth_(Module, pStorage)*16),
+		'height': (H264Decoder.h264bsdPicHeight_(Module, pStorage)*16),
 		'top': 0,
 		'left': 0
 	};
-
-	H264Decoder.free(self.Module, pCroppingFlag);
-	H264Decoder.free(self.Module, pLeftOffset);
-	H264Decoder.free(self.Module, pTopOffset);
-	H264Decoder.free(self.Module, pWidth);
-	H264Decoder.free(self.Module, pHeight);
-
 	return result;
 };
 
-
-H264Decoder.prototype.getYUVLength = function(){
-	var self = this;
-	var width = H264Decoder.h264bsdPicWidth(self.Module, self.pStorage);
-	var height = H264Decoder.h264bsdPicHeight(self.Module, self.pStorage);
+H264Decoder.getYUVLength_ = function(Module, pStorage){	
+	var width = H264Decoder.h264bsdPicWidth_(Module, pStorage);
+	var height = H264Decoder.h264bsdPicHeight_(Module, pStorage);
     return (width * 16 * height * 16) + (2 * width * 16 * height * 8);
 };
 
 //http://www.browserleaks.com/webgl#howto-detect-webgl
-H264Decoder.detectWebGl = function()
+H264Decoder.detectWebGl_ = function()
 {
     if (!!window.WebGLRenderingContext) {
         var canvas = document.createElement("canvas"),
@@ -247,77 +247,53 @@
     return false;
 };
 
-//Excessively pink
-H264Decoder.convertYUV2RGB = function(yuvBytes, croppingInfo){
+//If WebGL Canvas is not availble, this will convert an array of yuv bytes into an array of rgb bytes
+H264Decoder.convertYUV2RGB_ = function(yuvBytes, croppingInfo, exCtx){
 	var width = croppingInfo.width - croppingInfo.left;
 	var height = croppingInfo.height - croppingInfo.top;
+	var rgbBytes = new Uint8ClampedArray(4 * height * width);
 
-	var rgbBytes = new Uint8Array(4 * height * width);
+	var lumaSize = width * height;
+	var chromaSize = lumaSize >> 2;
+	
+	var planeY_off = 0;
+	var planeU_off = lumaSize;
+	var planeV_off = lumaSize + chromaSize;
 
-	var cb = width * height;
-	var cr = cb + ((width * height) / 2);	
-	var numPixels = width * height;
+	var stride_Y_h_off;
+	var stride_UV_h_off;
+	var stride_RGBA_off;
+	for (var h=0;h<height;h++) {
+		stride_Y_h_off = (width)*h;
+		stride_UV_h_off = (width>>1)*(h>>1);
+		stride_RGBA_off = (width<<2)*h;
+		for (var w=0; w<width; w++) {
+			var Y = yuvBytes[planeY_off+ w+stride_Y_h_off];
+			stride_UV_off = (w>>1)+stride_UV_h_off;
+			var U = (yuvBytes[planeU_off+ stride_UV_off]);
+			var V = (yuvBytes[planeV_off+ stride_UV_off]);
+			
+			var R = exCtx.coefficients_y[Y] + exCtx.coefficients_rv[V];
+			var G = exCtx.coefficients_y[Y] - exCtx.coefficients_gu[U] - exCtx.coefficients_gv[V];
+			var B = exCtx.coefficients_y[Y] + exCtx.coefficients_bu[U];
 
-	var dst = 0;
-	var dst_width = 0;
+			R = R >> 15; // div by 32768
+			G = G >> 15;
+			B = B >> 15;
 
-	var k = 0;
-	for (var i = 0; i < numPixels; i += 2)
-	{
-		k += 1;
-
-		var y1 = yuvBytes[i];// & 0xff;
-		var y2 = yuvBytes[i + 1];// & 0xff;
-		var y3 = yuvBytes[width + i];// & 0xff;
-		var y4 = yuvBytes[width + i + 1];// & 0xff;
-		
-		var v = yuvBytes[cr + k];// & 0xff;
-		var u = yuvBytes[cb + k];// & 0xff;
-		
-		v = v - 128;
-		u = u - 128;
-
-		dst = i * 4;
-		dst_width = width*4 + dst;
-
-		// i
-		rgbBytes[dst] = 0xff;
-		rgbBytes[dst + 1] = H264Decoder.clamp((298 * (y1 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst + 2] = H264Decoder.clamp((298 * (y1 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst + 3] = H264Decoder.clamp((298 * y1 + 516*u + 128) >> 8, 255, 0);
-				
-		// i + 1
-		rgbBytes[dst + 4] = 0xff;
-		rgbBytes[dst + 5] = H264Decoder.clamp((298 * (y2 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst + 6] = H264Decoder.clamp((298 * (y2 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst + 7] = H264Decoder.clamp((298 * y2 + 516*u + 128) >> 8, 255, 0);
-		
-		//width
-		rgbBytes[dst_width] = 0xff;
-		rgbBytes[dst_width + 1] = H264Decoder.clamp((298 * (y3 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst_width + 2] = H264Decoder.clamp((298 * (y2 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst_width + 3] = H264Decoder.clamp((298 * y3 + 516*u + 128) >> 8, 255, 0);
-				
-		//width + 1
-		rgbBytes[dst_width + 4] = 0xff;
-		rgbBytes[dst_width + 5] = H264Decoder.clamp((298 * (y4 - 16) + 409 * v + 128) >> 8, 255, 0);
-		rgbBytes[dst_width + 6] = H264Decoder.clamp((298 * (y4 - 16) - 100 * u - 208 *v + 128) >> 8, 255,0);
-		rgbBytes[dst_width + 7] = H264Decoder.clamp((298 * y4 + 516*u + 128) >> 8, 255, 0);
-
-		if (i != 0 && (i+2)%width ==0) {
-			i += width;					
-		} 
+			var outputData_pos = (w<<2)+stride_RGBA_off;
+			rgbBytes[0+outputData_pos] = R;
+			rgbBytes[1+outputData_pos] = G;
+			rgbBytes[2+outputData_pos] = B;
+			rgbBytes[3+outputData_pos] = 255;
+		}			
 	}
 
 	return rgbBytes;
 };
 
-H264Decoder.clamp = function(num, max, min) {
-  return Math.min(Math.max(num, min), max);
-};
-
 // u32 h264bsdDecode(storage_t *pStorage, u8 *byteStrm, u32 len, u32 picId, u32 *readBytes);
-H264Decoder.h264bsdDecode = function(Module, pStorage, pBytes, len, picId, pBytesRead) {
+H264Decoder.h264bsdDecode_ = function(Module, pStorage, pBytes, len, picId, pBytesRead) {
 	return Module.ccall('h264bsdDecode', Number, 
 		[Number, Number, Number, Number, Number], 
 		[pStorage, pBytes, len, picId, pBytesRead]);
@@ -324,27 +300,27 @@
 };
 
 // storage_t* h264bsdAlloc();
-H264Decoder.h264bsdAlloc = function(Module) {
+H264Decoder.h264bsdAlloc_ = function(Module) {
 	return Module.ccall('h264bsdAlloc', Number);
 };
 
 // void h264bsdFree(storage_t *pStorage);
-H264Decoder.h264bsdFree = function(Module, pStorage) {
+H264Decoder.h264bsdFree_ = function(Module, pStorage) {
 	Module.ccall('h264bsdFree', null, [Number], [pStorage]);
 };
 
 // u32 h264bsdInit(storage_t *pStorage, u32 noOutputReordering);
-H264Decoder.h264bsdInit = function(Module, pStorage, noOutputReordering) {
+H264Decoder.h264bsdInit_ = function(Module, pStorage, noOutputReordering) {
 	return Module.ccall('h264bsdInit', Number, [Number, Number], [pStorage, noOutputReordering]);
 };
 
 //void h264bsdShutdown(storage_t *pStorage);
-H264Decoder.h264bsdShutdown = function(Module, pStorage) {
+H264Decoder.h264bsdShutdown_ = function(Module, pStorage) {
 	Module.ccall('h264bsdShutdown', null, [Number], [pStorage]);
 };
 
 // u8* h264bsdNextOutputPicture(storage_t *pStorage, u32 *picId, u32 *isIdrPic, u32 *numErrMbs);
-H264Decoder.h264bsdNextOutputPicture = function(Module, pStorage, pPicId, pIsIdrPic, pNumErrMbs) {
+H264Decoder.h264bsdNextOutputPicture_ = function(Module, pStorage, pPicId, pIsIdrPic, pNumErrMbs) {
 	return Module.ccall('h264bsdNextOutputPicture', 
 		Number, 
 		[Number, Number, Number, Number], 
@@ -352,17 +328,17 @@
 };
 
 // u32 h264bsdPicWidth(storage_t *pStorage);
-H264Decoder.h264bsdPicWidth = function(Module, pStorage) {
+H264Decoder.h264bsdPicWidth_ = function(Module, pStorage) {
 	return Module.ccall('h264bsdPicWidth', Number, [Number], [pStorage]);
 };
 
 // u32 h264bsdPicHeight(storage_t *pStorage);
-H264Decoder.h264bsdPicHeight = function(Module, pStorage) {
+H264Decoder.h264bsdPicHeight_ = function(Module, pStorage) {
 	return Module.ccall('h264bsdPicHeight', Number, [Number], [pStorage]);
 };
 
 // void h264bsdCroppingParams(storage_t *pStorage, u32 *croppingFlag, u32 *left, u32 *width, u32 *top, u32 *height);
-H264Decoder.h264bsdCroppingParams = function(Module, pStorage, pCroppingFlag, pLeft, pWidth, pTop, pHeight) {
+H264Decoder.h264bsdCroppingParams_ = function(Module, pStorage, pCroppingFlag, pLeft, pWidth, pTop, pHeight) {
 	return Module.ccall('h264bsdCroppingParams', 
 		Number, 
 		[Number, Number, Number, Number, Number, Number, Number], 
@@ -370,21 +346,21 @@
 };
 
 // u32 h264bsdCheckValidParamSets(storage_t *pStorage);
-H264Decoder.h264bsdCheckValidParamSets = function(Module, pStorage){
+H264Decoder.h264bsdCheckValidParamSets_ = function(Module, pStorage){
 	return Module.ccall('h264bsdCheckValidParamSets', Number, [Number], [pStorage]);
 };
 
 // void* malloc(size_t size);
-H264Decoder.malloc = function(Module, size){
+H264Decoder.malloc_ = function(Module, size){
 	return Module.ccall('malloc', Number, [Number], [size]);
 };
 
 // void free(void* ptr);
-H264Decoder.free = function(Module, ptr){
+H264Decoder.free_ = function(Module, ptr){
 	return Module.ccall('free', null, [Number], [ptr]);
 };
 
 // void* memcpy(void* dest, void* src, size_t size);
-H264Decoder.memcpy = function(Module, length){
+H264Decoder.memcpy_ = function(Module, length){
 	return Module.ccall('malloc', Number, [Number, Number, Number], [dest, src, size]);
 };
--- a/js/util.js
+++ b/js/util.js
@@ -1,5 +1,3 @@
-'use strict';
-
 function error(message) {
   console.error(message);
   console.trace();
--- a/test/h264bsd.html
+++ b/test/h264bsd.html
@@ -6,8 +6,10 @@
 </head>
 <body>
     <input type="file" id="file" name="file" /><br/>
+
+    <!--This is where we will display decoded frames-->
     <canvas id="canvas" width="640" height="480" style="border:solid;"></canvas>
-    <h264decoder id="h264decoder"><h264decoder>
+
     <script src="../js/h264bsd_asm.js"></script>
     <script src="../js/sylvester.js"></script>
     <script src="../js/glUtils.js"></script>
@@ -14,12 +16,17 @@
     <script src="../js/util.js"></script>
     <script src="../js/canvas.js"></script>    
     <script src="../js/h264bsd.js"></script>
-    <!--<script src="../js/dist/h264bsd.min.js"></script>-->
-    <script type="text/javascript">
-    	var canvas = document.getElementById('canvas');    	
-    	var d = new H264Decoder(Module, canvas, true);
-    	canvas.addEventListener("pictureReady", function(e){
+       
+    <!--<script src="../js/dist/h264bsd.min.js"></script>--> 
 
+    <script type="text/javascript">        	
+    	var canvas = document.getElementById('canvas');    	    	
+    	
+    	//Create / init the decoder
+    	var d = new H264Decoder(Module, canvas, false);
+
+    	//The element we passed into the H264Decoder constructor (canvas), will emit 'pictureReady' events
+    	canvas.addEventListener("pictureReady", function(e){
 			if (e.detail.picture == null){
 				return;
 			}			
@@ -28,6 +35,8 @@
 			var width = e.detail.width;
 			var height = e.detail.height;
 
+			//The picture will be encoded as YUV or RGB depending on 1) the 3rd param of the H264Decoder constructor,
+			//2) Support for the WebGL canvas in the browser.
 			if (e.detail.encoding === 'YUV'){
 				var wgc = new YUVWebGLCanvas(canvas, new Size(width, height));
 				var lumaSize = width * height;
@@ -49,10 +58,12 @@
 				}
 				console.log(out);
 
-				canvas.height = height;
+				canvas.height = height;				
 				canvas.width = width;
+
 				canvas.style.height = height;
 				canvas.style.width = width;
+
 				var oc = canvas.getContext('2d');
 				oc.putImageData(imageData, 0,0);
 			}
@@ -59,6 +70,7 @@
 
     	});
 
+		//Use the FileReader to get the bytes into the decoder
 		function handleFileSelect(evt) {
 		    var f = evt.target.files[0]; // FileList object