Skip to content

Instantly share code, notes, and snippets.

@charltoons
Last active December 15, 2015 09:49
Show Gist options
  • Save charltoons/5240824 to your computer and use it in GitHub Desktop.
Save charltoons/5240824 to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Emscripten-Generated Code</title>
<style>
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
textarea.emscripten { font-family: monospace; width: 80%; }
div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid black; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; }
</style>
</head>
<body>
<hr/>
<div class="emscripten" id="status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<div class="emscripten_border">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
</div>
<hr/>
<div class="emscripten">
<input type="checkbox" id="resize">Resize canvas
<input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer
&nbsp;&nbsp;&nbsp;
<input type="button" value="Fullscreen" onclick="Module.requestFullScreen(document.getElementById('pointerLock').checked,
document.getElementById('resize').checked)">
</div>
<hr/>
<textarea class="emscripten" id="output" rows="8"></textarea>
<hr>
<script type='text/javascript'>
// connect to canvas
var Module = {
preRun: [],
postRun: [],
print: (function() {
var element = document.getElementById('output');
element.value = ''; // clear browser cache
return function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
element.value += text + "\n";
element.scrollTop = 99999; // focus on bottom
};
})(),
printErr: function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
console.log(text);
}
},
canvas: document.getElementById('canvas'),
setStatus: function(text) {
if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
</script>
<script type='text/javascript'>
// Note: Some Emscripten settings will significantly limit the speed of the generated code.
// Note: Some Emscripten settings may limit the speed of the generated code.
try {
this['Module'] = Module;
} catch(e) {
this['Module'] = Module = {};
}
// 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(x) {
process['stdout'].write(x + '\n');
};
Module['printErr'] = function(x) {
process['stderr'].write(x + '\n');
};
var nodeFS = require('fs');
var nodePath = require('path');
Module['read'] = function(filename) {
filename = nodePath['normalize'](filename);
var ret = nodeFS['readFileSync'](filename).toString();
// 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).toString();
}
return ret;
};
Module['load'] = function(f) {
globalEval(read(f));
};
if (!Module['arguments']) {
Module['arguments'] = process['argv'].slice(2);
}
}
if (ENVIRONMENT_IS_SHELL) {
Module['print'] = print;
if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
// Polyfill over SpiderMonkey/V8 differences
if (typeof read != 'undefined') {
Module['read'] = read;
} else {
Module['read'] = function(f) { snarf(f) };
}
if (!Module['arguments']) {
if (typeof scriptArgs != 'undefined') {
Module['arguments'] = scriptArgs;
} else if (typeof arguments != 'undefined') {
Module['arguments'] = arguments;
}
}
}
if (ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER) {
if (!Module['print']) {
Module['print'] = function(x) {
console.log(x);
};
}
if (!Module['printErr']) {
Module['printErr'] = function(x) {
console.log(x);
};
}
}
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
Module['read'] = function(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send(null);
return xhr.responseText;
};
if (!Module['arguments']) {
if (typeof arguments != 'undefined') {
Module['arguments'] = arguments;
}
}
}
if (ENVIRONMENT_IS_WORKER) {
// We can do very little here...
var TRY_USE_DUMP = false;
if (!Module['print']) {
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
}));
}
Module['load'] = importScripts;
}
if (!ENVIRONMENT_IS_WORKER && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_SHELL) {
// 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(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
if (!Module['preRun']) Module['preRun'] = [];
if (!Module['postRun']) Module['postRun'] = [];
// === 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)) {
var logg = log2(quantum);
return '((((' +target + ')+' + (quantum-1) + ')>>' + logg + ')<<' + logg + ')';
}
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 (/^\[\d+\ x\ (.*)\]/.test(type)) return true; // [15 x ?] blocks. Like structs
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, quantumSize) {
if (Runtime.QUANTUM_SIZE == 1) return 1;
var size = {
'%i1': 1,
'%i8': 1,
'%i16': 2,
'%i32': 4,
'%i64': 8,
"%float": 4,
"%double": 8
}['%'+type]; // add '%' since float and double confuse Closure compiler as keys, and also spidermonkey as a compiler will remove 's from '_i8' etc
if (!size) {
if (type.charAt(type.length-1) == '*') {
size = Runtime.QUANTUM_SIZE; // A pointer
} else if (type[0] == 'i') {
var bits = parseInt(type.substr(1));
assert(bits % 8 == 0);
size = bits/8;
}
}
return size;
},
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;
},
calculateStructAlignment: function calculateStructAlignment(type) {
type.flatSize = 0;
type.alignSize = 0;
var diffs = [];
var prev = -1;
type.flatIndexes = type.fields.map(function(field) {
var size, alignSize;
if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
alignSize = size;
} else if (Runtime.isStructType(field)) {
size = Types.types[field].flatSize;
alignSize = 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 {
throw 'Unclear type in struct: ' + field + ', in ' + type.name_ + ' :: ' + dump(Types.types[type.name_]);
}
alignSize = type.packed ? 1 : Math.min(alignSize, Runtime.QUANTUM_SIZE);
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;
});
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) {
assert(args.length == sig.length-1);
return FUNCTION_TABLE[ptr].apply(null, args);
} else {
assert(sig.length == 1);
return FUNCTION_TABLE[ptr]();
}
},
addFunction: function (func, sig) {
//assert(sig); // TODO: support asm
var table = FUNCTION_TABLE; // TODO: support asm
var ret = table.length;
table.push(func);
table.push(0);
return ret;
},
removeFunction: function (index) {
var table = FUNCTION_TABLE; // TODO: support asm
table[index] = null;
},
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() {
Runtime.dynCall(sig, func, arguments);
};
}
return Runtime.funcWrappers[func];
},
UTF8Processor: function () {
var buffer = [];
var needed = 0;
this.processCChar = function (code) {
code = code & 0xff;
if (needed) {
buffer.push(code);
needed--;
}
if (buffer.length == 0) {
if (code < 128) return String.fromCharCode(code);
buffer.push(code);
if (code > 191 && code < 224) {
needed = 1;
} else {
needed = 2;
}
return '';
}
if (needed > 0) return '';
var c1 = buffer[0];
var c2 = buffer[1];
var c3 = buffer[2];
var ret;
if (c1 > 191 && c1 < 224) {
ret = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
} else {
ret = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
}
buffer.length = 0;
return ret;
}
this.processJSString = function(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)+3)>>2)<<2);assert((STACKTOP|0) < (STACK_MAX|0)); return ret; },
staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = ((((STATICTOP)+3)>>2)<<2); if (STATICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 4))*(quantum ? quantum : 4); return ret; },
makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? (((low)>>>(0))+(((high)>>>(0))*4294967296)) : (((low)>>>(0))+(((high)|(0))*4294967296))); return ret; },
QUANTUM_SIZE: 4,
__dummy__: 0
}
//========================================
// Runtime essentials
//========================================
var __THREW__ = 0; // Used in checking for thrown exceptions.
var setjmpId = 1; // Used in setjmp/longjmp
var setjmpLabels = {};
var ABORT = false;
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;
var tempI64, tempI64b;
var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
function abort(text) {
Module.print(text + ':\n' + (new Error).stack);
ABORT = true;
throw "Assertion: " + text;
}
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).
// @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 = globalScope['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
if (!stack) stack = Runtime.stackSave();
var ret = Runtime.stackAlloc(value.length+1);
writeStringToMemory(value, ret);
return ret;
} else 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,Math.min(Math.floor((value)/4294967296), 4294967295)>>>0],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
case 'float': HEAPF32[((ptr)>>2)]=value; break;
case 'double': (HEAPF64[(tempDoublePtr)>>3]=value,HEAP32[((ptr)>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[(((ptr)+(4))>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]); 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 (HEAP32[((tempDoublePtr)>>2)]=HEAP32[((ptr)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[(((ptr)+(4))>>2)],HEAPF64[(tempDoublePtr)>>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_NONE = 3; // Do not allocate
Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
Module['ALLOC_STACK'] = ALLOC_STACK;
Module['ALLOC_STATIC'] = ALLOC_STATIC;
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][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') {
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;
}
assert(type, 'Must know what type to store in allocate!');
if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
setValue(ret+i, curr, type);
// no need to look up size unless type changes, so cache it
if (previousType !== type) {
typeSize = Runtime.getNativeTypeSize(type);
previousType = type;
}
i += typeSize;
}
return ret;
}
Module['allocate'] = allocate;
function Pointer_stringify(ptr, /* optional */ length) {
// 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++) {
assert(ptr + i < TOTAL_MEMORY);
t = HEAPU8[(((ptr)+(i))|0)];
ret += utf8.processCChar(t);
}
return ret;
}
Module['Pointer_stringify'] = Pointer_stringify;
// Memory management
var PAGE_SIZE = 4096;
function alignMemoryPage(x) {
return ((x+4095)>>12)<<12;
}
var HEAP;
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
var STACK_ROOT, STACKTOP, STACK_MAX;
var STATICTOP;
function enlargeMemory() {
abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
}
var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 16777216;
var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
// Initialize the runtime's memory
// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
assert(!!Int32Array && !!Float64Array && !!(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;
STACK_ROOT = STACKTOP = Runtime.alignMemory(1);
STACK_MAX = TOTAL_STACK; // we lose a little stack here, but TOTAL_STACK is nice and round so use that as the max
var tempDoublePtr = Runtime.alignMemory(allocate(12, 'i8', ALLOC_STACK), 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];
}
STATICTOP = STACK_MAX;
assert(STATICTOP < TOTAL_MEMORY); // Stack must fit in TOTAL_MEMORY; allocations from here on may enlarge TOTAL_MEMORY
var nullString = allocate(intArrayFromString('(null)'), 'i8', ALLOC_STACK);
function callRuntimeCallbacks(callbacks) {
while(callbacks.length > 0) {
var callback = callbacks.shift();
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 __ATINIT__ = []; // functions called during startup
var __ATMAIN__ = []; // functions called when main() is to be run
var __ATEXIT__ = []; // functions called during shutdown
function initRuntime() {
callRuntimeCallbacks(__ATINIT__);
}
function preMain() {
callRuntimeCallbacks(__ATMAIN__);
}
function exitRuntime() {
callRuntimeCallbacks(__ATEXIT__);
}
// 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) {
assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
chr &= 0xFF;
}
ret.push(String.fromCharCode(chr));
}
return ret.join('');
}
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 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(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;
};
// 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 runDependencyTracking = {};
var calledRun = false;
var runDependencyWatcher = null;
function addRunDependency(id) {
runDependencies++;
if (Module['monitorRunDependencies']) {
Module['monitorRunDependencies'](runDependencies);
}
if (id) {
assert(!runDependencyTracking[id]);
runDependencyTracking[id] = 1;
if (runDependencyWatcher === null && typeof setInterval !== 'undefined') {
// Check for missing dependencies every few seconds
runDependencyWatcher = setInterval(function() {
var shown = false;
for (var dep in runDependencyTracking) {
if (!shown) {
shown = true;
Module.printErr('still waiting on run dependencies:');
}
Module.printErr('dependency: ' + dep);
}
if (shown) {
Module.printErr('(end of list)');
}
}, 6000);
}
} else {
Module.printErr('warning: run dependency added without ID');
}
}
Module['addRunDependency'] = addRunDependency;
function removeRunDependency(id) {
runDependencies--;
if (Module['monitorRunDependencies']) {
Module['monitorRunDependencies'](runDependencies);
}
if (id) {
assert(runDependencyTracking[id]);
delete runDependencyTracking[id];
} else {
Module.printErr('warning: run dependency removed without ID');
}
if (runDependencies == 0) {
if (runDependencyWatcher !== null) {
clearInterval(runDependencyWatcher);
runDependencyWatcher = null;
}
// If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
if (!calledRun && shouldRunNow) run();
}
}
Module['removeRunDependency'] = removeRunDependency;
Module["preloadedImages"] = {}; // maps url to image data
Module["preloadedAudios"] = {}; // maps url to audio data
// === Body ===
assert(STATICTOP == STACK_MAX); assert(STACK_MAX == TOTAL_STACK);
STATICTOP += 1832;
assert(STATICTOP < TOTAL_MEMORY);
allocate([0,0,160,65,0,0,240,65,0,0,0,0], "i8", ALLOC_NONE, 5242880);
allocate([97,116,116,114,105,98,117,116,101,32,118,101,99,51,32,112,111,115,105,116,105,111,110,59,10,97,116,116,114,105,98,117,116,101,32,118,101,99,51,32,110,111,114,109,97,108,59,10,10,117,110,105,102,111,114,109,32,109,97,116,52,32,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,109,97,116,52,32,78,111,114,109,97,108,77,97,116,114,105,120,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,76,105,103,104,116,83,111,117,114,99,101,80,111,115,105,116,105,111,110,59,10,117,110,105,102,111,114,109,32,118,101,99,52,32,77,97,116,101,114,105,97,108,67,111,108,111,114,59,10,10,118,97,114,121,105,110,103,32,118,101,99,52,32,67,111,108,111,114,59,10,10,118,111,105,100,32,109,97,105,110,40,118,111,105,100,41,10,123,10,32,32,32,32,47,47,32,84,114,97,110,115,102,111,114,109,32,116,104,101,32,110,111,114,109,97,108,32,116,111,32,101,121,101,32,99,111,111,114,100,105,110,97,116,101,115,10,32,32,32,32,118,101,99,51,32,78,32,61,32,110,111,114,109,97,108,105,122,101,40,118,101,99,51,40,78,111,114,109,97,108,77,97,116,114,105,120,32,42,32,118,101,99,52,40,110,111,114,109,97,108,44,32,49,46,48,41,41,41,59,10,10,32,32,32,32,47,47,32,84,104,101,32,76,105,103,104,116,83,111,117,114,99,101,80,111,115,105,116,105,111,110,32,105,115,32,97,99,116,117,97,108,108,121,32,105,116,115,32,100,105,114,101,99,116,105,111,110,32,102,111,114,32,100,105,114,101,99,116,105,111,110,97,108,32,108,105,103,104,116,10,32,32,32,32,118,101,99,51,32,76,32,61,32,110,111,114,109,97,108,105,122,101,40,76,105,103,104,116,83,111,117,114,99,101,80,111,115,105,116,105,111,110,46,120,121,122,41,59,10,10,32,32,32,32,47,47,32,77,117,108,116,105,112,108,121,32,116,104,101,32,100,105,102,102,117,115,101,32,118,97,108,117,101,32,98,121,32,116,104,101,32,118,101,114,116,101,120,32,99,111,108,111,114,32,40,119,104,105,99,104,32,105,115,32,102,105,120,101,100,32,105,110,32,116,104,105,115,32,99,97,115,101,41,10,32,32,32,32,47,47,32,116,111,32,103,101,116,32,116,104,101,32,97,99,116,117,97,108,32,99,111,108,111,114,32,116,104,97,116,32,119,101,32,119,105,108,108,32,117,115,101,32,116,111,32,100,114,97,119,32,116,104,105,115,32,118,101,114,116,101,120,32,119,105,116,104,10,32,32,32,32,102,108,111,97,116,32,100,105,102,102,117,115,101,32,61,32,109,97,120,40,100,111,116,40,78,44,32,76,41,44,32,48,46,48,41,59,10,32,32,32,32,67,111,108,111,114,32,61,32,100,105,102,102,117,115,101,32,42,32,77,97,116,101,114,105,97,108,67,111,108,111,114,59,10,10,32,32,32,32,47,47,32,84,114,97,110,115,102,111,114,109,32,116,104,101,32,112,111,115,105,116,105,111,110,32,116,111,32,99,108,105,112,32,99,111,111,114,100,105,110,97,116,101,115,10,32,32,32,32,103,108,95,80,111,115,105,116,105,111,110,32,61,32,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,32,42,32,118,101,99,52,40,112,111,115,105,116,105,111,110,44,32,49,46,48,41,59,10,125,0] /* attribute vec3 posit */, "i8", ALLOC_NONE, 5242892);
allocate(24, "i8", ALLOC_NONE, 5243708);
allocate([0,0,0,0,0,0,240,191], "i8", ALLOC_NONE, 5243732);
allocate([0,0,0,0,0,0,240,191], "i8", ALLOC_NONE, 5243740);
allocate(4, "i8", ALLOC_NONE, 5243748);
allocate([205,204,76,63,205,204,204,61,0,0,0,0,0,0,128,63], "i8", ALLOC_NONE, 5243752);
allocate([0,0,0,0,205,204,76,63,205,204,76,62,0,0,128,63], "i8", ALLOC_NONE, 5243768);
allocate([205,204,76,62,205,204,76,62,0,0,128,63,0,0,128,63], "i8", ALLOC_NONE, 5243784);
allocate(4, "i8", ALLOC_NONE, 5243800);
allocate(4, "i8", ALLOC_NONE, 5243804);
allocate(4, "i8", ALLOC_NONE, 5243808);
allocate([35,105,102,100,101,102,32,71,76,95,69,83,10,112,114,101,99,105,115,105,111,110,32,109,101,100,105,117,109,112,32,102,108,111,97,116,59,10,35,101,110,100,105,102,10,118,97,114,121,105,110,103,32,118,101,99,52,32,67,111,108,111,114,59,10,10,118,111,105,100,32,109,97,105,110,40,118,111,105,100,41,10,123,10,32,32,32,32,103,108,95,70,114,97,103,67,111,108,111,114,32,61,32,67,111,108,111,114,59,10,125,0] /* #ifdef GL_ES\0Apreci */, "i8", ALLOC_NONE, 5243812);
allocate(4, "i8", ALLOC_NONE, 5243924);
allocate([77,97,116,101,114,105,97,108,67,111,108,111,114,0] /* MaterialColor\00 */, "i8", ALLOC_NONE, 5243928);
allocate([76,105,103,104,116,83,111,117,114,99,101,80,111,115,105,116,105,111,110,0] /* LightSourcePosition\ */, "i8", ALLOC_NONE, 5243944);
allocate([78,111,114,109,97,108,77,97,116,114,105,120,0] /* NormalMatrix\00 */, "i8", ALLOC_NONE, 5243964);
allocate([77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,0] /* ModelViewProjectionM */, "i8", ALLOC_NONE, 5243980);
allocate([105,110,102,111,58,32,37,115,10,0] /* info: %s\0A\00 */, "i8", ALLOC_NONE, 5244008);
allocate([110,111,114,109,97,108,0] /* normal\00 */, "i8", ALLOC_NONE, 5244020);
allocate([112,111,115,105,116,105,111,110,0] /* position\00 */, "i8", ALLOC_NONE, 5244028);
allocate([102,114,97,103,109,101,110,116,32,115,104,97,100,101,114,32,105,110,102,111,58,32,37,115,10,0] /* fragment shader info */, "i8", ALLOC_NONE, 5244040);
allocate([37,100,32,102,114,97,109,101,115,32,105,110,32,37,51,46,49,102,32,115,101,99,111,110,100,115,32,61,32,37,54,46,51,102,32,70,80,83,10,0] /* %d frames in %3.1f s */, "i8", ALLOC_NONE, 5244068);
allocate([118,101,114,116,101,120,32,115,104,97,100,101,114,32,105,110,102,111,58,32,37,115,10,0] /* vertex shader info: */, "i8", ALLOC_NONE, 5244108);
allocate([101,115,50,103,101,97,114,115,0] /* es2gears\00 */, "i8", ALLOC_NONE, 5244132);
allocate(472, "i8", ALLOC_NONE, 5244144);
allocate(64, "i8", ALLOC_NONE, 5244616);
allocate(4, "i8", ALLOC_NONE, 5244680);
allocate(4, "i8", ALLOC_NONE, 5244684);
allocate(4, "i8", ALLOC_NONE, 5244688);
allocate(4, "i8", ALLOC_NONE, 5244692);
allocate([0,0,160,64,0,0,160,64,0,0,32,65,0,0,128,63], "i8", ALLOC_NONE, 5244696);
function _memcpy(dest, src, num) {
dest = dest|0; src = src|0; num = num|0;
var ret = 0;
ret = dest|0;
if ((dest&3) == (src&3)) {
while (dest & 3) {
if ((num|0) == 0) return ret|0;
HEAP8[(dest)]=HEAP8[(src)];
dest = (dest+1)|0;
src = (src+1)|0;
num = (num-1)|0;
}
while ((num|0) >= 4) {
HEAP32[((dest)>>2)]=HEAP32[((src)>>2)];
dest = (dest+4)|0;
src = (src+4)|0;
num = (num-4)|0;
}
}
while ((num|0) > 0) {
HEAP8[(dest)]=HEAP8[(src)];
dest = (dest+1)|0;
src = (src+1)|0;
num = (num-1)|0;
}
return ret|0;
}var _llvm_memcpy_p0i8_p0i8_i32=_memcpy;
var GLUT={initTime:null,idleFunc:null,displayFunc:null,keyboardFunc:null,keyboardUpFunc:null,specialFunc:null,specialUpFunc:null,reshapeFunc:null,motionFunc:null,passiveMotionFunc:null,mouseFunc:null,lastX:0,lastY:0,buttons:0,modifiers:0,initWindowWidth:256,initWindowHeight:256,windowX:0,windowY:0,windowWidth:0,windowHeight:0,savePosition:function (event) {
/* TODO maybe loop here ala http://www.quirksmode.org/js/findpos.html */
GLUT.lastX = event['clientX'] - Module['canvas'].offsetLeft;
GLUT.lastY = event['clientY'] - Module['canvas'].offsetTop;
},saveModifiers:function (event) {
GLUT.modifiers = 0;
if (event['shiftKey'])
GLUT.modifiers += 1; /* GLUT_ACTIVE_SHIFT */
if (event['ctrlKey'])
GLUT.modifiers += 2; /* GLUT_ACTIVE_CTRL */
if (event['altKey'])
GLUT.modifiers += 4; /* GLUT_ACTIVE_ALT */
},onMousemove:function (event) {
/* Send motion event only if the motion changed, prevents
* spamming our app with uncessary callback call. It does happen in
* Chrome on Windows.
*/
var newX = event['clientX'] - Module['canvas'].offsetLeft;
var newY = event['clientY'] - Module['canvas'].offsetTop;
if (newX == GLUT.lastX && newY == GLUT.lastY)
return;
GLUT.savePosition(event);
if (GLUT.buttons == 0 && event.target == Module["canvas"] && GLUT.passiveMotionFunc) {
event.preventDefault();
GLUT.saveModifiers(event);
Runtime.dynCall('vii', GLUT.passiveMotionFunc, [GLUT.lastX, GLUT.lastY]);
} else if (GLUT.buttons != 0 && GLUT.motionFunc) {
event.preventDefault();
GLUT.saveModifiers(event);
Runtime.dynCall('vii', GLUT.motionFunc, [GLUT.lastX, GLUT.lastY]);
}
},getSpecialKey:function (keycode) {
var key = null;
switch (keycode) {
case 0x70 /*DOM_VK_F1*/: key = 1 /* GLUT_KEY_F1 */; break;
case 0x71 /*DOM_VK_F2*/: key = 2 /* GLUT_KEY_F2 */; break;
case 0x72 /*DOM_VK_F3*/: key = 3 /* GLUT_KEY_F3 */; break;
case 0x73 /*DOM_VK_F4*/: key = 4 /* GLUT_KEY_F4 */; break;
case 0x74 /*DOM_VK_F5*/: key = 5 /* GLUT_KEY_F5 */; break;
case 0x75 /*DOM_VK_F6*/: key = 6 /* GLUT_KEY_F6 */; break;
case 0x76 /*DOM_VK_F7*/: key = 7 /* GLUT_KEY_F7 */; break;
case 0x77 /*DOM_VK_F8*/: key = 8 /* GLUT_KEY_F8 */; break;
case 0x78 /*DOM_VK_F9*/: key = 9 /* GLUT_KEY_F9 */; break;
case 0x79 /*DOM_VK_F10*/: key = 10 /* GLUT_KEY_F10 */; break;
case 0x7a /*DOM_VK_F11*/: key = 11 /* GLUT_KEY_F11 */; break;
case 0x7b /*DOM_VK_F12*/: key = 12 /* GLUT_KEY_F12 */; break;
case 0x25 /*DOM_VK_LEFT*/: key = 100 /* GLUT_KEY_LEFT */; break;
case 0x26 /*DOM_VK_UP*/: key = 101 /* GLUT_KEY_UP */; break;
case 0x27 /*DOM_VK_RIGHT*/: key = 102 /* GLUT_KEY_RIGHT */; break;
case 0x28 /*DOM_VK_DOWN*/: key = 103 /* GLUT_KEY_DOWN */; break;
case 0x21 /*DOM_VK_PAGE_UP*/: key = 104 /* GLUT_KEY_PAGE_UP */; break;
case 0x22 /*DOM_VK_PAGE_DOWN*/: key = 105 /* GLUT_KEY_PAGE_DOWN */; break;
case 0x24 /*DOM_VK_HOME*/: key = 106 /* GLUT_KEY_HOME */; break;
case 0x23 /*DOM_VK_END*/: key = 107 /* GLUT_KEY_END */; break;
case 0x2d /*DOM_VK_INSERT*/: key = 108 /* GLUT_KEY_INSERT */; break;
case 16 /*DOM_VK_SHIFT*/:
case 0x05 /*DOM_VK_LEFT_SHIFT*/:
key = 112 /* GLUT_KEY_SHIFT_L */;
break;
case 0x06 /*DOM_VK_RIGHT_SHIFT*/:
key = 113 /* GLUT_KEY_SHIFT_R */;
break;
case 17 /*DOM_VK_CONTROL*/:
case 0x03 /*DOM_VK_LEFT_CONTROL*/:
key = 114 /* GLUT_KEY_CONTROL_L */;
break;
case 0x04 /*DOM_VK_RIGHT_CONTROL*/:
key = 115 /* GLUT_KEY_CONTROL_R */;
break;
case 18 /*DOM_VK_ALT*/:
case 0x02 /*DOM_VK_LEFT_ALT*/:
key = 116 /* GLUT_KEY_ALT_L */;
break;
case 0x01 /*DOM_VK_RIGHT_ALT*/:
key = 117 /* GLUT_KEY_ALT_R */;
break;
};
return key;
},getASCIIKey:function (event) {
if (event['ctrlKey'] || event['altKey'] || event['metaKey']) return null;
var keycode = event['keyCode'];
/* The exact list is soooo hard to find in a canonical place! */
if (48 <= keycode && keycode <= 57)
return keycode; // numeric TODO handle shift?
if (65 <= keycode && keycode <= 90)
return event['shiftKey'] ? keycode : keycode + 32;
if (106 <= keycode && keycode <= 111)
return keycode - 106 + 42; // *,+-./ TODO handle shift?
switch (keycode) {
case 27: // escape
case 32: // space
case 61: // equal
return keycode;
}
var s = event['shiftKey'];
switch (keycode) {
case 186: return s ? 58 : 59; // colon / semi-colon
case 187: return s ? 43 : 61; // add / equal (these two may be wrong)
case 188: return s ? 60 : 44; // less-than / comma
case 189: return s ? 95 : 45; // dash
case 190: return s ? 62 : 46; // greater-than / period
case 191: return s ? 63 : 47; // forward slash
case 219: return s ? 123 : 91; // open bracket
case 220: return s ? 124 : 47; // back slash
case 221: return s ? 125 : 93; // close braket
case 222: return s ? 34 : 39; // single quote
}
return null;
},onKeydown:function (event) {
if (GLUT.specialFunc || GLUT.keyboardFunc) {
var key = GLUT.getSpecialKey(event['keyCode']);
if (key !== null) {
if( GLUT.specialFunc ) {
event.preventDefault();
GLUT.saveModifiers(event);
Runtime.dynCall('viii', GLUT.specialFunc, [key, GLUT.lastX, GLUT.lastY]);
}
}
else
{
key = GLUT.getASCIIKey(event);
if( key !== null && GLUT.keyboardFunc ) {
event.preventDefault();
GLUT.saveModifiers(event);
Runtime.dynCall('viii', GLUT.keyboardFunc, [key, GLUT.lastX, GLUT.lastY]);
}
}
}
},onKeyup:function (event) {
if (GLUT.specialUpFunc || GLUT.keyboardUpFunc) {
var key = GLUT.getSpecialKey(event['keyCode']);
if (key !== null) {
if(GLUT.specialUpFunc) {
event.preventDefault ();
GLUT.saveModifiers(event);
Runtime.dynCall('viii', GLUT.specialUpFunc, [key, GLUT.lastX, GLUT.lastY]);
}
}
else
{
key = GLUT.getASCIIKey(event);
if( key !== null && GLUT.keyboardUpFunc ) {
event.preventDefault ();
GLUT.saveModifiers(event);
Runtime.dynCall('viii', GLUT.keyboardUpFunc, [key, GLUT.lastX, GLUT.lastY]);
}
}
}
},onMouseButtonDown:function (event){
GLUT.savePosition(event);
GLUT.buttons |= (1 << event['button']);
if(event.target == Module["canvas"] && GLUT.mouseFunc){
try {
event.target.setCapture();
} catch (e) {}
event.preventDefault();
GLUT.saveModifiers(event);
Runtime.dynCall('viiii', GLUT.mouseFunc, [event['button'], 0/*GLUT_DOWN*/, GLUT.lastX, GLUT.lastY]);
}
},onMouseButtonUp:function (event){
GLUT.savePosition(event);
GLUT.buttons &= ~(1 << event['button']);
if(GLUT.mouseFunc) {
event.preventDefault();
GLUT.saveModifiers(event);
Runtime.dynCall('viiii', GLUT.mouseFunc, [event['button'], 1/*GLUT_UP*/, GLUT.lastX, GLUT.lastY]);
}
},onFullScreenEventChange:function (event){
var width;
var height;
if (document["fullScreen"] || document["mozFullScreen"] || document["webkitIsFullScreen"]) {
width = screen["width"];
height = screen["height"];
} else {
width = GLUT.windowWidth;
height = GLUT.windowHeight;
// TODO set position
document.removeEventListener('fullscreenchange', GLUT.onFullScreenEventChange, true);
document.removeEventListener('mozfullscreenchange', GLUT.onFullScreenEventChange, true);
document.removeEventListener('webkitfullscreenchange', GLUT.onFullScreenEventChange, true);
}
Browser.setCanvasSize(width, height);
/* Can't call _glutReshapeWindow as that requests cancelling fullscreen. */
if (GLUT.reshapeFunc) {
// console.log("GLUT.reshapeFunc (from FS): " + width + ", " + height);
Runtime.dynCall('vii', GLUT.reshapeFunc, [width, height]);
}
_glutPostRedisplay();
},requestFullScreen:function () {
var RFS = Module["canvas"]['requestFullscreen'] ||
Module["canvas"]['requestFullScreen'] ||
Module["canvas"]['mozRequestFullScreen'] ||
Module["canvas"]['webkitRequestFullScreen'] ||
(function() {});
RFS.apply(Module["canvas"], []);
},cancelFullScreen:function () {
var CFS = document['exitFullscreen'] ||
document['cancelFullScreen'] ||
document['mozCancelFullScreen'] ||
document['webkitCancelFullScreen'] ||
(function() {});
CFS.apply(document, []);
}};function _glutInit(argcp, argv) {
// Ignore arguments
GLUT.initTime = Date.now();
window.addEventListener("keydown", GLUT.onKeydown, true);
window.addEventListener("keyup", GLUT.onKeyup, true);
window.addEventListener("mousemove", GLUT.onMousemove, true);
window.addEventListener("mousedown", GLUT.onMouseButtonDown, true);
window.addEventListener("mouseup", GLUT.onMouseButtonUp, true);
__ATEXIT__.push({ func: function() {
window.removeEventListener("keydown", GLUT.onKeydown, true);
window.removeEventListener("keyup", GLUT.onKeyup, true);
window.removeEventListener("mousemove", GLUT.onMousemove, true);
window.removeEventListener("mousedown", GLUT.onMouseButtonDown, true);
window.removeEventListener("mouseup", GLUT.onMouseButtonUp, true);
Module["canvas"].width = Module["canvas"].height = 1;
} });
}
function _glutInitWindowSize(width, height) {
Browser.setCanvasSize( GLUT.initWindowWidth = width,
GLUT.initWindowHeight = height );
}
function _glutInitDisplayMode(mode) {}
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 (Browser.initted) 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) : console.log("warning: cannot create object URLs");
// 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.).
function getMimetype(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(-3)];
return ret;
}
if (!Module["preloadPlugins"]) Module["preloadPlugins"] = [];
var imagePlugin = {};
imagePlugin['canHandle'] = function(name) {
return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/.exec(name);
};
imagePlugin['handle'] = function(byteArray, name, onload, onerror) {
var b = null;
if (Browser.hasBlobConstructor) {
try {
b = new Blob([byteArray], { type: 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);
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
var img = new Image();
img.onload = function() {
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(event) {
console.log('Image ' + url + ' could not be decoded');
if (onerror) onerror();
};
img.src = url;
};
Module['preloadPlugins'].push(imagePlugin);
var audioPlugin = {};
audioPlugin['canHandle'] = function(name) {
return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
};
audioPlugin['handle'] = function(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: getMimetype(name) });
} catch(e) {
return fail();
}
var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
var audio = new Audio();
audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
audio.onerror = function(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
setTimeout(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'];
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) {
var ctx;
try {
if (useWebGL) {
ctx = canvas.getContext('experimental-webgl', {
alpha: false
});
} else {
ctx = canvas.getContext('2d');
}
if (!ctx) throw ':(';
} catch (e) {
Module.print('Could not create canvas - ' + 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) {
this.lockPointer = lockPointer;
this.resizeCanvas = resizeCanvas;
if (typeof this.lockPointer === 'undefined') this.lockPointer = true;
if (typeof this.resizeCanvas === 'undefined') this.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 (!this.fullScreenHandlersInstalled) {
this.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 (func) {
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = window['requestAnimationFrame'] ||
window['mozRequestAnimationFrame'] ||
window['webkitRequestAnimationFrame'] ||
window['msRequestAnimationFrame'] ||
window['oRequestAnimationFrame'] ||
window['setTimeout'];
}
window.requestAnimationFrame(func);
},getMovementX:function (event) {
return event['movementX'] ||
event['mozMovementX'] ||
event['webkitMovementX'] ||
0;
},getMovementY:function (event) {
return event['movementY'] ||
event['mozMovementY'] ||
event['webkitMovementY'] ||
0;
},xhrLoad:function (url, onload, onerror) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
if (xhr.status == 200) {
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;
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;
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();
}};function _glutCreateWindow(name) {
Module.ctx = Browser.createContext(Module['canvas'], true, true);
return 1;
}
function _glutIdleFunc(func) {
var callback = function() {
if (GLUT.idleFunc) {
Runtime.dynCall('v', GLUT.idleFunc);
window.setTimeout(callback, 0);
}
}
if (!GLUT.idleFunc)
window.setTimeout(callback, 0);
GLUT.idleFunc = func;
}
function _glutReshapeFunc(func) {
GLUT.reshapeFunc = func;
}
function _glutDisplayFunc(func) {
GLUT.displayFunc = func;
}
function _glutSpecialFunc(func) {
GLUT.specialFunc = func;
}
function _glutPostRedisplay() {
if (GLUT.displayFunc) {
Browser.requestAnimationFrame(function() {
Runtime.dynCall('v', GLUT.displayFunc);
});
}
}function _glutReshapeWindow(width, height) {
GLUT.cancelFullScreen();
// console.log("glutReshapeWindow: " + width + ", " + height);
Browser.setCanvasSize(width, height);
if (GLUT.reshapeFunc) {
// console.log("GLUT.reshapeFunc: " + width + ", " + height);
Runtime.dynCall('vii', GLUT.reshapeFunc, [width, height]);
}
_glutPostRedisplay();
}function _glutMainLoop() {
_glutReshapeWindow(Module['canvas'].width, Module['canvas'].height);
_glutPostRedisplay();
throw 'SimulateInfiniteLoop';
}
var GL={counter:1,buffers:[],programs:[],framebuffers:[],renderbuffers:[],textures:[],uniforms:[],shaders:[],currArrayBuffer:0,currElementArrayBuffer:0,byteSizeByTypeRoot:5120,byteSizeByType:[1,1,2,2,4,4,4,2,3,4,8],uniformTable:{},packAlignment:4,unpackAlignment:4,init:function () {
Browser.moduleContextCreatedCallbacks.push(GL.initExtensions);
},getNewId:function (table) {
var ret = GL.counter++;
for (var i = table.length; i < ret; i++) {
table[i] = null;
}
return ret;
},MINI_TEMP_BUFFER_SIZE:16,miniTempBuffer:null,miniTempBufferViews:[0],MAX_TEMP_BUFFER_SIZE:2097152,tempBufferIndexLookup:null,tempVertexBuffers:null,tempIndexBuffers:null,tempQuadIndexBuffer:null,generateTempBuffers:function (quads) {
this.tempBufferIndexLookup = new Uint8Array(this.MAX_TEMP_BUFFER_SIZE+1);
this.tempVertexBuffers = [];
this.tempIndexBuffers = [];
var last = -1, curr = -1;
var size = 1;
for (var i = 0; i <= this.MAX_TEMP_BUFFER_SIZE; i++) {
if (i > size) {
size <<= 1;
}
if (size != last) {
curr++;
this.tempVertexBuffers[curr] = Module.ctx.createBuffer();
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, this.tempVertexBuffers[curr]);
Module.ctx.bufferData(Module.ctx.ARRAY_BUFFER, size, Module.ctx.DYNAMIC_DRAW);
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, null);
this.tempIndexBuffers[curr] = Module.ctx.createBuffer();
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.tempIndexBuffers[curr]);
Module.ctx.bufferData(Module.ctx.ELEMENT_ARRAY_BUFFER, size, Module.ctx.DYNAMIC_DRAW);
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, null);
last = size;
}
this.tempBufferIndexLookup[i] = curr;
}
if (quads) {
// GL_QUAD indexes can be precalculated
this.tempQuadIndexBuffer = Module.ctx.createBuffer();
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, this.tempQuadIndexBuffer);
var numIndexes = this.MAX_TEMP_BUFFER_SIZE >> 1;
var quadIndexes = new Uint16Array(numIndexes);
var i = 0, v = 0;
while (1) {
quadIndexes[i++] = v;
if (i >= numIndexes) break;
quadIndexes[i++] = v+1;
if (i >= numIndexes) break;
quadIndexes[i++] = v+2;
if (i >= numIndexes) break;
quadIndexes[i++] = v;
if (i >= numIndexes) break;
quadIndexes[i++] = v+2;
if (i >= numIndexes) break;
quadIndexes[i++] = v+3;
if (i >= numIndexes) break;
v += 4;
}
Module.ctx.bufferData(Module.ctx.ELEMENT_ARRAY_BUFFER, quadIndexes, Module.ctx.STATIC_DRAW);
Module.ctx.bindBuffer(Module.ctx.ELEMENT_ARRAY_BUFFER, null);
}
},scan:function (table, object) {
for (var item in table) {
if (table[item] == object) return item;
}
return 0;
},findToken:function (source, token) {
function isIdentChar(ch) {
if (ch >= 48 && ch <= 57) // 0-9
return true;
if (ch >= 65 && ch <= 90) // A-Z
return true;
if (ch >= 97 && ch <= 122) // a-z
return true;
return false;
}
var i = -1;
do {
i = source.indexOf(token, i + 1);
if (i < 0) {
break;
}
if (i > 0 && isIdentChar(source[i - 1])) {
continue;
}
i += token.length;
if (i < source.length - 1 && isIdentChar(source[i + 1])) {
continue;
}
return true;
} while (true);
return false;
},getSource:function (shader, count, string, length) {
var source = '';
for (var i = 0; i < count; ++i) {
var frag;
if (length) {
var len = HEAP32[(((length)+(i*4))>>2)];
if (len < 0) {
frag = Pointer_stringify(HEAP32[(((string)+(i*4))>>2)]);
} else {
frag = Pointer_stringify(HEAP32[(((string)+(i*4))>>2)], len);
}
} else {
frag = Pointer_stringify(HEAP32[(((string)+(i*4))>>2)]);
}
source += frag;
}
// Let's see if we need to enable the standard derivatives extension
type = Module.ctx.getShaderParameter(GL.shaders[shader], 0x8B4F /* GL_SHADER_TYPE */);
if (type == 0x8B30 /* GL_FRAGMENT_SHADER */) {
if (GL.findToken(source, "dFdx") ||
GL.findToken(source, "dFdy") ||
GL.findToken(source, "fwidth")) {
source = "#extension GL_OES_standard_derivatives : enable\n" + source;
var extension = Module.ctx.getExtension("OES_standard_derivatives");
}
}
return source;
},computeImageSize:function (width, height, sizePerPixel, alignment) {
function roundedToNextMultipleOf(x, y) {
return Math.floor((x + y - 1) / y) * y
}
var plainRowSize = width * sizePerPixel;
var alignedRowSize = roundedToNextMultipleOf(plainRowSize, alignment);
return (height <= 0) ? 0 :
((height - 1) * alignedRowSize + plainRowSize);
},getTexPixelData:function (type, format, width, height, pixels, internalFormat) {
var sizePerPixel;
switch (type) {
case 0x1401 /* GL_UNSIGNED_BYTE */:
switch (format) {
case 0x1906 /* GL_ALPHA */:
case 0x1909 /* GL_LUMINANCE */:
sizePerPixel = 1;
break;
case 0x1907 /* GL_RGB */:
sizePerPixel = 3;
break;
case 0x1908 /* GL_RGBA */:
sizePerPixel = 4;
break;
case 0x190A /* GL_LUMINANCE_ALPHA */:
sizePerPixel = 2;
break;
default:
throw 'Invalid format (' + format + ')';
}
break;
case 0x8363 /* GL_UNSIGNED_SHORT_5_6_5 */:
case 0x8033 /* GL_UNSIGNED_SHORT_4_4_4_4 */:
case 0x8034 /* GL_UNSIGNED_SHORT_5_5_5_1 */:
sizePerPixel = 2;
break;
case 0x1406 /* GL_FLOAT */:
assert(GL.floatExt, 'Must have OES_texture_float to use float textures');
switch (format) {
case 0x1907 /* GL_RGB */:
sizePerPixel = 3*4;
break;
case 0x1908 /* GL_RGBA */:
sizePerPixel = 4*4;
break;
default:
throw 'Invalid format (' + format + ')';
}
internalFormat = Module.ctx.RGBA;
break;
default:
throw 'Invalid type (' + type + ')';
}
var bytes = GL.computeImageSize(width, height, sizePerPixel, GL.unpackAlignment);
if (type == 0x1401 /* GL_UNSIGNED_BYTE */) {
pixels = HEAPU8.subarray((pixels),(pixels+bytes));
} else if (type == 0x1406 /* GL_FLOAT */) {
pixels = HEAPF32.subarray((pixels)>>2,(pixels+bytes)>>2);
} else {
pixels = HEAPU16.subarray((pixels)>>1,(pixels+bytes)>>1);
}
return {
pixels: pixels,
internalFormat: internalFormat
}
},initExtensions:function () {
if (GL.initExtensions.done) return;
GL.initExtensions.done = true;
if (!Module.useWebGL) return; // an app might link both gl and 2d backends
GL.miniTempBuffer = new Float32Array(GL.MINI_TEMP_BUFFER_SIZE);
for (var i = 0; i < GL.MINI_TEMP_BUFFER_SIZE; i++) {
GL.miniTempBufferViews[i] = GL.miniTempBuffer.subarray(0, i+1);
}
GL.maxVertexAttribs = Module.ctx.getParameter(Module.ctx.MAX_VERTEX_ATTRIBS);
GL.compressionExt = Module.ctx.getExtension('WEBGL_compressed_texture_s3tc') ||
Module.ctx.getExtension('MOZ_WEBGL_compressed_texture_s3tc') ||
Module.ctx.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
GL.anisotropicExt = Module.ctx.getExtension('EXT_texture_filter_anisotropic') ||
Module.ctx.getExtension('MOZ_EXT_texture_filter_anisotropic') ||
Module.ctx.getExtension('WEBKIT_EXT_texture_filter_anisotropic');
GL.floatExt = Module.ctx.getExtension('OES_texture_float');
}};function _glEnable(x0) { Module.ctx.enable(x0) }
function _glCreateShader(shaderType) {
var id = GL.getNewId(GL.shaders);
GL.shaders[id] = Module.ctx.createShader(shaderType);
return id;
}
function _glShaderSource(shader, count, string, length) {
var source = GL.getSource(shader, count, string, length);
Module.ctx.shaderSource(GL.shaders[shader], source);
}
function _glCompileShader(shader) {
Module.ctx.compileShader(GL.shaders[shader]);
}
function _glGetShaderInfoLog(shader, maxLength, length, infoLog) {
var log = Module.ctx.getShaderInfoLog(GL.shaders[shader]);
// Work around a bug in Chromium which causes getShaderInfoLog to return null
if (!log) {
log = "";
}
log = log.substr(0, maxLength - 1);
writeStringToMemory(log, infoLog);
if (length) {
HEAP32[((length)>>2)]=log.length
}
}
var ERRNO_CODES={E2BIG:7,EACCES:13,EADDRINUSE:98,EADDRNOTAVAIL:99,EAFNOSUPPORT:97,EAGAIN:11,EALREADY:114,EBADF:9,EBADMSG:74,EBUSY:16,ECANCELED:125,ECHILD:10,ECONNABORTED:103,ECONNREFUSED:111,ECONNRESET:104,EDEADLK:35,EDESTADDRREQ:89,EDOM:33,EDQUOT:122,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:113,EIDRM:43,EILSEQ:84,EINPROGRESS:115,EINTR:4,EINVAL:22,EIO:5,EISCONN:106,EISDIR:21,ELOOP:40,EMFILE:24,EMLINK:31,EMSGSIZE:90,EMULTIHOP:72,ENAMETOOLONG:36,ENETDOWN:100,ENETRESET:102,ENETUNREACH:101,ENFILE:23,ENOBUFS:105,ENODATA:61,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:37,ENOLINK:67,ENOMEM:12,ENOMSG:42,ENOPROTOOPT:92,ENOSPC:28,ENOSR:63,ENOSTR:60,ENOSYS:38,ENOTCONN:107,ENOTDIR:20,ENOTEMPTY:39,ENOTRECOVERABLE:131,ENOTSOCK:88,ENOTSUP:95,ENOTTY:25,ENXIO:6,EOVERFLOW:75,EOWNERDEAD:130,EPERM:1,EPIPE:32,EPROTO:71,EPROTONOSUPPORT:93,EPROTOTYPE:91,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:116,ETIME:62,ETIMEDOUT:110,ETXTBSY:26,EWOULDBLOCK:11,EXDEV:18};
function ___setErrNo(value) {
// For convenient setting and returning of errno.
if (!___setErrNo.ret) ___setErrNo.ret = allocate([0], 'i32', ALLOC_STATIC);
HEAP32[((___setErrNo.ret)>>2)]=value
return value;
}
var _stdin=allocate(1, "i32*", ALLOC_STACK);
var _stdout=allocate(1, "i32*", ALLOC_STACK);
var _stderr=allocate(1, "i32*", ALLOC_STACK);
var __impure_ptr=allocate(1, "i32*", ALLOC_STACK);var FS={currentPath:"/",nextInode:2,streams:[null],checkStreams:function () {
for (var i in FS.streams) if (FS.streams.hasOwnProperty(i)) assert(i >= 0 && i < FS.streams.length); // no keys not in dense span
for (var i = 0; i < FS.streams.length; i++) assert(typeof FS.streams[i] == 'object'); // no non-null holes in dense span
},ignorePermissions:true,joinPath:function (parts, forceRelative) {
var ret = parts[0];
for (var i = 1; i < parts.length; i++) {
if (ret[ret.length-1] != '/') ret += '/';
ret += parts[i];
}
if (forceRelative && ret[0] == '/') ret = ret.substr(1);
return ret;
},absolutePath:function (relative, base) {
if (typeof relative !== 'string') return null;
if (base === undefined) base = FS.currentPath;
if (relative && relative[0] == '/') base = '';
var full = base + '/' + relative;
var parts = full.split('/').reverse();
var absolute = [''];
while (parts.length) {
var part = parts.pop();
if (part == '' || part == '.') {
// Nothing.
} else if (part == '..') {
if (absolute.length > 1) absolute.pop();
} else {
absolute.push(part);
}
}
return absolute.length == 1 ? '/' : absolute.join('/');
},analyzePath:function (path, dontResolveLastLink, linksVisited) {
var ret = {
isRoot: false,
exists: false,
error: 0,
name: null,
path: null,
object: null,
parentExists: false,
parentPath: null,
parentObject: null
};
path = FS.absolutePath(path);
if (path == '/') {
ret.isRoot = true;
ret.exists = ret.parentExists = true;
ret.name = '/';
ret.path = ret.parentPath = '/';
ret.object = ret.parentObject = FS.root;
} else if (path !== null) {
linksVisited = linksVisited || 0;
path = path.slice(1).split('/');
var current = FS.root;
var traversed = [''];
while (path.length) {
if (path.length == 1 && current.isFolder) {
ret.parentExists = true;
ret.parentPath = traversed.length == 1 ? '/' : traversed.join('/');
ret.parentObject = current;
ret.name = path[0];
}
var target = path.shift();
if (!current.isFolder) {
ret.error = ERRNO_CODES.ENOTDIR;
break;
} else if (!current.read) {
ret.error = ERRNO_CODES.EACCES;
break;
} else if (!current.contents.hasOwnProperty(target)) {
ret.error = ERRNO_CODES.ENOENT;
break;
}
current = current.contents[target];
if (current.link && !(dontResolveLastLink && path.length == 0)) {
if (linksVisited > 40) { // Usual Linux SYMLOOP_MAX.
ret.error = ERRNO_CODES.ELOOP;
break;
}
var link = FS.absolutePath(current.link, traversed.join('/'));
ret = FS.analyzePath([link].concat(path).join('/'),
dontResolveLastLink, linksVisited + 1);
return ret;
}
traversed.push(target);
if (path.length == 0) {
ret.exists = true;
ret.path = traversed.join('/');
ret.object = current;
}
}
}
return ret;
},findObject:function (path, dontResolveLastLink) {
FS.ensureRoot();
var ret = FS.analyzePath(path, dontResolveLastLink);
if (ret.exists) {
return ret.object;
} else {
___setErrNo(ret.error);
return null;
}
},createObject:function (parent, name, properties, canRead, canWrite) {
if (!parent) parent = '/';
if (typeof parent === 'string') parent = FS.findObject(parent);
if (!parent) {
___setErrNo(ERRNO_CODES.EACCES);
throw new Error('Parent path must exist.');
}
if (!parent.isFolder) {
___setErrNo(ERRNO_CODES.ENOTDIR);
throw new Error('Parent must be a folder.');
}
if (!parent.write && !FS.ignorePermissions) {
___setErrNo(ERRNO_CODES.EACCES);
throw new Error('Parent folder must be writeable.');
}
if (!name || name == '.' || name == '..') {
___setErrNo(ERRNO_CODES.ENOENT);
throw new Error('Name must not be empty.');
}
if (parent.contents.hasOwnProperty(name)) {
___setErrNo(ERRNO_CODES.EEXIST);
throw new Error("Can't overwrite object.");
}
parent.contents[name] = {
read: canRead === undefined ? true : canRead,
write: canWrite === undefined ? false : canWrite,
timestamp: Date.now(),
inodeNumber: FS.nextInode++
};
for (var key in properties) {
if (properties.hasOwnProperty(key)) {
parent.contents[name][key] = properties[key];
}
}
return parent.contents[name];
},createFolder:function (parent, name, canRead, canWrite) {
var properties = {isFolder: true, isDevice: false, contents: {}};
return FS.createObject(parent, name, properties, canRead, canWrite);
},createPath:function (parent, path, canRead, canWrite) {
var current = FS.findObject(parent);
if (current === null) throw new Error('Invalid parent.');
path = path.split('/').reverse();
while (path.length) {
var part = path.pop();
if (!part) continue;
if (!current.contents.hasOwnProperty(part)) {
FS.createFolder(current, part, canRead, canWrite);
}
current = current.contents[part];
}
return current;
},createFile:function (parent, name, properties, canRead, canWrite) {
properties.isFolder = false;
return FS.createObject(parent, name, properties, canRead, canWrite);
},createDataFile:function (parent, name, data, canRead, canWrite) {
if (typeof data === 'string') {
var dataArray = new Array(data.length);
for (var i = 0, len = data.length; i < len; ++i) dataArray[i] = data.charCodeAt(i);
data = dataArray;
}
var properties = {
isDevice: false,
contents: data.subarray ? data.subarray(0) : data // as an optimization, create a new array wrapper (not buffer) here, to help JS engines understand this object
};
return FS.createFile(parent, name, properties, canRead, canWrite);
},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.
var LazyUint8Array = function(chunkSize, length) {
this.length = length;
this.chunkSize = chunkSize;
this.chunks = []; // Loaded chunks. Index is the chunk number
}
LazyUint8Array.prototype.get = function(idx) {
if (idx > this.length-1 || idx < 0) {
return undefined;
}
var chunkOffset = idx % chunkSize;
var chunkNum = Math.floor(idx / chunkSize);
return this.getter(chunkNum)[chunkOffset];
}
LazyUint8Array.prototype.setDataGetter = function(getter) {
this.getter = getter;
}
// 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 = new LazyUint8Array(chunkSize, datalength);
lazyArray.setDataGetter(function(chunkNum) {
var start = chunkNum * lazyArray.chunkSize;
var end = (chunkNum+1) * lazyArray.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];
});
var properties = { isDevice: false, contents: lazyArray };
} else {
var properties = { isDevice: false, url: url };
}
return FS.createFile(parent, name, properties, canRead, canWrite);
},createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile) {
Browser.init();
var fullname = FS.joinPath([parent, name], true);
function processData(byteArray) {
function finish(byteArray) {
if (!dontCreateFile) {
FS.createDataFile(parent, name, byteArray, canRead, canWrite);
}
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);
}
},createLink:function (parent, name, target, canRead, canWrite) {
var properties = {isDevice: false, link: target};
return FS.createFile(parent, name, properties, canRead, canWrite);
},createDevice:function (parent, name, input, output) {
if (!(input || output)) {
throw new Error('A device must have at least one callback defined.');
}
var ops = {isDevice: true, input: input, output: output};
return FS.createFile(parent, name, ops, Boolean(input), Boolean(output));
},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;
},ensureRoot:function () {
if (FS.root) return;
// The main file system tree. All the contents are inside this.
FS.root = {
read: true,
write: true,
isFolder: true,
isDevice: false,
timestamp: Date.now(),
inodeNumber: 1,
contents: {}
};
},init:function (input, output, error) {
// Make sure we initialize only once.
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.ensureRoot();
// Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
input = input || Module['stdin'];
output = output || Module['stdout'];
error = error || Module['stderr'];
// Default handlers.
var stdinOverridden = true, stdoutOverridden = true, stderrOverridden = true;
if (!input) {
stdinOverridden = false;
input = function() {
if (!input.cache || !input.cache.length) {
var result;
if (typeof window != 'undefined' &&
typeof window.prompt == 'function') {
// Browser.
result = window.prompt('Input: ');
if (result === null) result = String.fromCharCode(0); // cancel ==> EOF
} else if (typeof readline == 'function') {
// Command line.
result = readline();
}
if (!result) result = '';
input.cache = intArrayFromString(result + '\n', true);
}
return input.cache.shift();
};
}
var utf8 = new Runtime.UTF8Processor();
function simpleOutput(val) {
if (val === null || val === 10) {
output.printer(output.buffer.join(''));
output.buffer = [];
} else {
output.buffer.push(utf8.processCChar(val));
}
}
if (!output) {
stdoutOverridden = false;
output = simpleOutput;
}
if (!output.printer) output.printer = Module['print'];
if (!output.buffer) output.buffer = [];
if (!error) {
stderrOverridden = false;
error = simpleOutput;
}
if (!error.printer) error.printer = Module['print'];
if (!error.buffer) error.buffer = [];
// Create the temporary folder, if not already created
try {
FS.createFolder('/', 'tmp', true, true);
} catch(e) {}
// Create the I/O devices.
var devFolder = FS.createFolder('/', 'dev', true, true);
var stdin = FS.createDevice(devFolder, 'stdin', input);
var stdout = FS.createDevice(devFolder, 'stdout', null, output);
var stderr = FS.createDevice(devFolder, 'stderr', null, error);
FS.createDevice(devFolder, 'tty', input, output);
// Create default streams.
FS.streams[1] = {
path: '/dev/stdin',
object: stdin,
position: 0,
isRead: true,
isWrite: false,
isAppend: false,
isTerminal: !stdinOverridden,
error: false,
eof: false,
ungotten: []
};
FS.streams[2] = {
path: '/dev/stdout',
object: stdout,
position: 0,
isRead: false,
isWrite: true,
isAppend: false,
isTerminal: !stdoutOverridden,
error: false,
eof: false,
ungotten: []
};
FS.streams[3] = {
path: '/dev/stderr',
object: stderr,
position: 0,
isRead: false,
isWrite: true,
isAppend: false,
isTerminal: !stderrOverridden,
error: false,
eof: false,
ungotten: []
};
assert(Math.max(_stdin, _stdout, _stderr) < 128); // make sure these are low, we flatten arrays with these
HEAP32[((_stdin)>>2)]=1;
HEAP32[((_stdout)>>2)]=2;
HEAP32[((_stderr)>>2)]=3;
// Other system paths
FS.createPath('/', 'dev/shm/tmp', true, true); // temp files
// Newlib initialization
for (var i = FS.streams.length; i < Math.max(_stdin, _stdout, _stderr) + 4; i++) {
FS.streams[i] = null; // Make sure to keep FS.streams dense
}
FS.streams[_stdin] = FS.streams[1];
FS.streams[_stdout] = FS.streams[2];
FS.streams[_stderr] = FS.streams[3];
FS.checkStreams();
assert(FS.streams.length < 1024); // at this early stage, we should not have a large set of file descriptors - just a few
allocate([ allocate(
[0, 0, 0, 0, _stdin, 0, 0, 0, _stdout, 0, 0, 0, _stderr, 0, 0, 0],
'void*', ALLOC_STATIC) ], 'void*', ALLOC_NONE, __impure_ptr);
},quit:function () {
if (!FS.init.initialized) return;
// Flush any partially-printed lines in stdout and stderr. Careful, they may have been closed
if (FS.streams[2] && FS.streams[2].object.output.buffer.length > 0) FS.streams[2].object.output(10);
if (FS.streams[3] && FS.streams[3].object.output.buffer.length > 0) FS.streams[3].object.output(10);
},standardizePath:function (path) {
if (path.substr(0, 2) == './') path = path.substr(2);
return path;
},deleteFile:function (path) {
path = FS.analyzePath(path);
if (!path.parentExists || !path.exists) {
throw 'Invalid path ' + path;
}
delete path.parentObject.contents[path.name];
}};
function _pwrite(fildes, buf, nbyte, offset) {
// ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
var stream = FS.streams[fildes];
if (!stream || stream.object.isDevice) {
___setErrNo(ERRNO_CODES.EBADF);
return -1;
} else if (!stream.isWrite) {
___setErrNo(ERRNO_CODES.EACCES);
return -1;
} else if (stream.object.isFolder) {
___setErrNo(ERRNO_CODES.EISDIR);
return -1;
} else if (nbyte < 0 || offset < 0) {
___setErrNo(ERRNO_CODES.EINVAL);
return -1;
} else {
var contents = stream.object.contents;
while (contents.length < offset) contents.push(0);
for (var i = 0; i < nbyte; i++) {
contents[offset + i] = HEAPU8[(((buf)+(i))|0)];
}
stream.object.timestamp = Date.now();
return i;
}
}function _write(fildes, buf, nbyte) {
// ssize_t write(int fildes, const void *buf, size_t nbyte);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
var stream = FS.streams[fildes];
if (!stream) {
___setErrNo(ERRNO_CODES.EBADF);
return -1;
} else if (!stream.isWrite) {
___setErrNo(ERRNO_CODES.EACCES);
return -1;
} else if (nbyte < 0) {
___setErrNo(ERRNO_CODES.EINVAL);
return -1;
} else {
if (stream.object.isDevice) {
if (stream.object.output) {
for (var i = 0; i < nbyte; i++) {
try {
stream.object.output(HEAP8[(((buf)+(i))|0)]);
} catch (e) {
___setErrNo(ERRNO_CODES.EIO);
return -1;
}
}
stream.object.timestamp = Date.now();
return i;
} else {
___setErrNo(ERRNO_CODES.ENXIO);
return -1;
}
} else {
var bytesWritten = _pwrite(fildes, buf, nbyte, stream.position);
if (bytesWritten != -1) stream.position += bytesWritten;
return bytesWritten;
}
}
}function _fwrite(ptr, size, nitems, stream) {
// size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
var bytesToWrite = nitems * size;
if (bytesToWrite == 0) return 0;
var bytesWritten = _write(stream, ptr, bytesToWrite);
if (bytesWritten == -1) {
if (FS.streams[stream]) FS.streams[stream].error = true;
return 0;
} else {
return Math.floor(bytesWritten / size);
}
}
function _strlen(ptr) {
ptr = ptr|0;
var curr = 0;
curr = ptr;
while (HEAP8[(curr)]|0 != 0) {
curr = (curr + 1)|0;
}
return (curr - ptr)|0;
}
function __reallyNegative(x) {
return x < 0 || (x === 0 && (1/x) === -Infinity);
}function __formatString(format, varargs) {
var textIndex = format;
var argIndex = 0;
function getNextArg(type) {
// NOTE: Explicitly ignoring type safety. Otherwise this fails:
// int x = 4; printf("%c\n", (char)x);
var ret;
if (type === 'double') {
ret = (HEAP32[((tempDoublePtr)>>2)]=HEAP32[(((varargs)+(argIndex))>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[(((varargs)+((argIndex)+(4)))>>2)],HEAPF64[(tempDoublePtr)>>3]);
} else if (type == 'i64') {
ret = [HEAP32[(((varargs)+(argIndex))>>2)],
HEAP32[(((varargs)+(argIndex+4))>>2)]];
} else {
type = 'i32'; // varargs are always i32, i64, or double
ret = HEAP32[(((varargs)+(argIndex))>>2)];
}
argIndex += Runtime.getNativeFieldSize(type);
return ret;
}
var ret = [];
var curr, next, currArg;
while(1) {
var startTextIndex = textIndex;
curr = HEAP8[(textIndex)];
if (curr === 0) break;
next = HEAP8[((textIndex+1)|0)];
if (curr == 37) {
// Handle flags.
var flagAlwaysSigned = false;
var flagLeftAlign = false;
var flagAlternative = false;
var flagZeroPad = false;
flagsLoop: while (1) {
switch (next) {
case 43:
flagAlwaysSigned = true;
break;
case 45:
flagLeftAlign = true;
break;
case 35:
flagAlternative = true;
break;
case 48:
if (flagZeroPad) {
break flagsLoop;
} else {
flagZeroPad = true;
break;
}
default:
break flagsLoop;
}
textIndex++;
next = HEAP8[((textIndex+1)|0)];
}
// Handle width.
var width = 0;
if (next == 42) {
width = getNextArg('i32');
textIndex++;
next = HEAP8[((textIndex+1)|0)];
} else {
while (next >= 48 && next <= 57) {
width = width * 10 + (next - 48);
textIndex++;
next = HEAP8[((textIndex+1)|0)];
}
}
// Handle precision.
var precisionSet = false;
if (next == 46) {
var precision = 0;
precisionSet = true;
textIndex++;
next = HEAP8[((textIndex+1)|0)];
if (next == 42) {
precision = getNextArg('i32');
textIndex++;
} else {
while(1) {
var precisionChr = HEAP8[((textIndex+1)|0)];
if (precisionChr < 48 ||
precisionChr > 57) break;
precision = precision * 10 + (precisionChr - 48);
textIndex++;
}
}
next = HEAP8[((textIndex+1)|0)];
} else {
var precision = 6; // Standard default.
}
// Handle integer sizes. WARNING: These assume a 32-bit architecture!
var argSize;
switch (String.fromCharCode(next)) {
case 'h':
var nextNext = HEAP8[((textIndex+2)|0)];
if (nextNext == 104) {
textIndex++;
argSize = 1; // char (actually i32 in varargs)
} else {
argSize = 2; // short (actually i32 in varargs)
}
break;
case 'l':
var nextNext = HEAP8[((textIndex+2)|0)];
if (nextNext == 108) {
textIndex++;
argSize = 8; // long long
} else {
argSize = 4; // long
}
break;
case 'L': // long long
case 'q': // int64_t
case 'j': // intmax_t
argSize = 8;
break;
case 'z': // size_t
case 't': // ptrdiff_t
case 'I': // signed ptrdiff_t or unsigned size_t
argSize = 4;
break;
default:
argSize = null;
}
if (argSize) textIndex++;
next = HEAP8[((textIndex+1)|0)];
// Handle type specifier.
switch (String.fromCharCode(next)) {
case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
// Integer.
var signed = next == 100 || next == 105;
argSize = argSize || 4;
var currArg = getNextArg('i' + (argSize * 8));
var origArg = currArg;
var argText;
// Flatten i64-1 [low, high] into a (slightly rounded) double
if (argSize == 8) {
currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
}
// Truncate to requested size.
if (argSize <= 4) {
var limit = Math.pow(256, argSize) - 1;
currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
}
// Format the number.
var currAbsArg = Math.abs(currArg);
var prefix = '';
if (next == 100 || next == 105) {
if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], null); else
argText = reSign(currArg, 8 * argSize, 1).toString(10);
} else if (next == 117) {
if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], true); else
argText = unSign(currArg, 8 * argSize, 1).toString(10);
currArg = Math.abs(currArg);
} else if (next == 111) {
argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
} else if (next == 120 || next == 88) {
prefix = flagAlternative ? '0x' : '';
if (argSize == 8 && i64Math) {
if (origArg[1]) {
argText = (origArg[1]>>>0).toString(16);
var lower = (origArg[0]>>>0).toString(16);
while (lower.length < 8) lower = '0' + lower;
argText += lower;
} else {
argText = (origArg[0]>>>0).toString(16);
}
} else
if (currArg < 0) {
// Represent negative numbers in hex as 2's complement.
currArg = -currArg;
argText = (currAbsArg - 1).toString(16);
var buffer = [];
for (var i = 0; i < argText.length; i++) {
buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
}
argText = buffer.join('');
while (argText.length < argSize * 2) argText = 'f' + argText;
} else {
argText = currAbsArg.toString(16);
}
if (next == 88) {
prefix = prefix.toUpperCase();
argText = argText.toUpperCase();
}
} else if (next == 112) {
if (currAbsArg === 0) {
argText = '(nil)';
} else {
prefix = '0x';
argText = currAbsArg.toString(16);
}
}
if (precisionSet) {
while (argText.length < precision) {
argText = '0' + argText;
}
}
// Add sign if needed
if (flagAlwaysSigned) {
if (currArg < 0) {
prefix = '-' + prefix;
} else {
prefix = '+' + prefix;
}
}
// Add padding.
while (prefix.length + argText.length < width) {
if (flagLeftAlign) {
argText += ' ';
} else {
if (flagZeroPad) {
argText = '0' + argText;
} else {
prefix = ' ' + prefix;
}
}
}
// Insert the result into the buffer.
argText = prefix + argText;
argText.split('').forEach(function(chr) {
ret.push(chr.charCodeAt(0));
});
break;
}
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
// Float.
var currArg = getNextArg('double');
var argText;
if (isNaN(currArg)) {
argText = 'nan';
flagZeroPad = false;
} else if (!isFinite(currArg)) {
argText = (currArg < 0 ? '-' : '') + 'inf';
flagZeroPad = false;
} else {
var isGeneral = false;
var effectivePrecision = Math.min(precision, 20);
// Convert g/G to f/F or e/E, as per:
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
if (next == 103 || next == 71) {
isGeneral = true;
precision = precision || 1;
var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
if (precision > exponent && exponent >= -4) {
next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
precision -= exponent + 1;
} else {
next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
precision--;
}
effectivePrecision = Math.min(precision, 20);
}
if (next == 101 || next == 69) {
argText = currArg.toExponential(effectivePrecision);
// Make sure the exponent has at least 2 digits.
if (/[eE][-+]\d$/.test(argText)) {
argText = argText.slice(0, -1) + '0' + argText.slice(-1);
}
} else if (next == 102 || next == 70) {
argText = currArg.toFixed(effectivePrecision);
if (currArg === 0 && __reallyNegative(currArg)) {
argText = '-' + argText;
}
}
var parts = argText.split('e');
if (isGeneral && !flagAlternative) {
// Discard trailing zeros and periods.
while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
(parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
parts[0] = parts[0].slice(0, -1);
}
} else {
// Make sure we have a period in alternative mode.
if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
// Zero pad until required precision.
while (precision > effectivePrecision++) parts[0] += '0';
}
argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
// Capitalize 'E' if needed.
if (next == 69) argText = argText.toUpperCase();
// Add sign.
if (flagAlwaysSigned && currArg >= 0) {
argText = '+' + argText;
}
}
// Add padding.
while (argText.length < width) {
if (flagLeftAlign) {
argText += ' ';
} else {
if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
argText = argText[0] + '0' + argText.slice(1);
} else {
argText = (flagZeroPad ? '0' : ' ') + argText;
}
}
}
// Adjust case.
if (next < 97) argText = argText.toUpperCase();
// Insert the result into the buffer.
argText.split('').forEach(function(chr) {
ret.push(chr.charCodeAt(0));
});
break;
}
case 's': {
// String.
var arg = getNextArg('i8*') || nullString;
var argLength = _strlen(arg);
if (precisionSet) argLength = Math.min(argLength, precision);
if (!flagLeftAlign) {
while (argLength < width--) {
ret.push(32);
}
}
for (var i = 0; i < argLength; i++) {
ret.push(HEAPU8[((arg++)|0)]);
}
if (flagLeftAlign) {
while (argLength < width--) {
ret.push(32);
}
}
break;
}
case 'c': {
// Character.
if (flagLeftAlign) ret.push(getNextArg('i8'));
while (--width > 0) {
ret.push(32);
}
if (!flagLeftAlign) ret.push(getNextArg('i8'));
break;
}
case 'n': {
// Write the length written so far to the next parameter.
var ptr = getNextArg('i32*');
HEAP32[((ptr)>>2)]=ret.length
break;
}
case '%': {
// Literal percent sign.
ret.push(curr);
break;
}
default: {
// Unknown specifiers remain untouched.
for (var i = startTextIndex; i < textIndex + 2; i++) {
ret.push(HEAP8[(i)]);
}
}
}
textIndex += 2;
// TODO: Support a/A (hex float) and m (last error) specifiers.
// TODO: Support %1${specifier} for arg selection.
} else {
ret.push(curr);
textIndex += 1;
}
}
return ret;
}function _fprintf(stream, format, varargs) {
// int fprintf(FILE *restrict stream, const char *restrict format, ...);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
var result = __formatString(format, varargs);
var stack = Runtime.stackSave();
var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
Runtime.stackRestore(stack);
return ret;
}function _printf(format, varargs) {
// int printf(const char *restrict format, ...);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
var stdout = HEAP32[((_stdout)>>2)];
return _fprintf(stdout, format, varargs);
}
function _glCreateProgram() {
var id = GL.getNewId(GL.programs);
GL.programs[id] = Module.ctx.createProgram();
return id;
}
function _glAttachShader(program, shader) {
Module.ctx.attachShader(GL.programs[program],
GL.shaders[shader]);
}
function _glBindAttribLocation(program, index, name) {
name = Pointer_stringify(name);
Module.ctx.bindAttribLocation(GL.programs[program], index, name);
}
function _glLinkProgram(program) {
Module.ctx.linkProgram(GL.programs[program]);
GL.uniformTable[program] = {}; // uniforms no longer keep the same names after linking
}
function _glGetProgramInfoLog(program, maxLength, length, infoLog) {
var log = Module.ctx.getProgramInfoLog(GL.programs[program]);
// Work around a bug in Chromium which causes getProgramInfoLog to return null
if (!log) {
log = "";
}
log = log.substr(0, maxLength - 1);
writeStringToMemory(log, infoLog);
if (length) {
HEAP32[((length)>>2)]=log.length
}
}
function _glUseProgram(program) {
Module.ctx.useProgram(program ? GL.programs[program] : null);
}
function _glGetUniformLocation(program, name) {
name = Pointer_stringify(name);
var ptable = GL.uniformTable[program];
if (!ptable) ptable = GL.uniformTable[program] = {};
var id = ptable[name];
if (id) return id;
var loc = Module.ctx.getUniformLocation(GL.programs[program], name);
if (!loc) return -1;
id = GL.getNewId(GL.uniforms);
GL.uniforms[id] = loc;
ptable[name] = id;
return id;
}
function _glUniform4fv(location, count, value) {
location = GL.uniforms[location];
var view;
if (count == 1) {
// avoid allocation for the common case of uploading one uniform
view = GL.miniTempBufferViews[3];
view[0] = HEAPF32[((value)>>2)];
view[1] = HEAPF32[(((value)+(4))>>2)];
view[2] = HEAPF32[(((value)+(8))>>2)];
view[3] = HEAPF32[(((value)+(12))>>2)];
} else {
view = HEAPF32.subarray((value)>>2,(value+count*16)>>2);
}
Module.ctx.uniform4fv(location, view);
}
function _glGenBuffers(n, buffers) {
for (var i = 0; i < n; i++) {
var id = GL.getNewId(GL.buffers);
GL.buffers[id] = Module.ctx.createBuffer();
HEAP32[(((buffers)+(i*4))>>2)]=id;
}
}
function _glBindBuffer(target, buffer) {
if (target == Module.ctx.ARRAY_BUFFER) {
GL.currArrayBuffer = buffer;
} else if (target == Module.ctx.ELEMENT_ARRAY_BUFFER) {
GL.currElementArrayBuffer = buffer;
}
Module.ctx.bindBuffer(target, buffer ? GL.buffers[buffer] : null);
}
function _glBufferData(target, size, data, usage) {
Module.ctx.bufferData(target, HEAPU8.subarray(data, data+size), usage);
}
function _glutFullScreen() {
GLUT.windowX = 0; // TODO
GLUT.windowY = 0; // TODO
GLUT.windowWidth = Module['canvas'].width;
GLUT.windowHeight = Module['canvas'].height;
document.addEventListener('fullscreenchange', GLUT.onFullScreenEventChange, true);
document.addEventListener('mozfullscreenchange', GLUT.onFullScreenEventChange, true);
document.addEventListener('webkitfullscreenchange', GLUT.onFullScreenEventChange, true);
GLUT.requestFullScreen();
}
function _glClearColor(x0, x1, x2, x3) { Module.ctx.clearColor(x0, x1, x2, x3) }
function _glClear(x0) { Module.ctx.clear(x0) }
function _glutSwapBuffers() {}
function _glUniformMatrix4fv(location, count, transpose, value) {
location = GL.uniforms[location];
var view;
if (count == 1) {
// avoid allocation for the common case of uploading one uniform matrix
view = GL.miniTempBufferViews[15];
for (var i = 0; i < 16; i++) {
view[i] = HEAPF32[(((value)+(i*4))>>2)];
}
} else {
view = HEAPF32.subarray((value)>>2,(value+count*64)>>2);
}
Module.ctx.uniformMatrix4fv(location, transpose, view);
}
function _glVertexAttribPointer(index, size, type, normalized, stride, ptr) {
Module.ctx.vertexAttribPointer(index, size, type, normalized, stride, ptr);
}
function _glEnableVertexAttribArray(index) {
Module.ctx.enableVertexAttribArray(index);
}
function _glDrawArrays(mode, first, count) {
Module.ctx.drawArrays(mode, first, count);
}
function _glDisableVertexAttribArray(index) {
Module.ctx.disableVertexAttribArray(index);
}
var ___div_t_struct_layout={__size__:8,quot:0,rem:4};function _div(divt, numer, denom) {
var quot = Math.floor(numer / denom);
var rem = numer - quot * denom;
var offset = ___div_t_struct_layout.rem;
HEAP32[((divt)>>2)]=quot;
HEAP32[(((divt)+(offset))>>2)]=rem;
return divt;
}
function _glViewport(x0, x1, x2, x3) { Module.ctx.viewport(x0, x1, x2, x3) }
function _glutGet(type) {
switch (type) {
case 100: /* GLUT_WINDOW_X */
return 0; /* TODO */
case 101: /* GLUT_WINDOW_Y */
return 0; /* TODO */
case 102: /* GLUT_WINDOW_WIDTH */
return Module['canvas'].width;
case 103: /* GLUT_WINDOW_HEIGHT */
return Module['canvas'].height;
case 500: /* GLUT_INIT_WINDOW_X */
return 0; /* TODO */
case 501: /* GLUT_INIT_WINDOW_Y */
return 0; /* TODO */
case 502: /* GLUT_INIT_WINDOW_WIDTH */
return GLUT.initWindowWidth;
case 503: /* GLUT_INIT_WINDOW_HEIGHT */
return GLUT.initWindowHeight;
case 700: /* GLUT_ELAPSED_TIME */
var now = Date.now();
return now - GLUT.initTime;
default:
throw "glutGet(" + type + ") not implemented yet";
}
}
var _sin=Math.sin;
var _cos=Math.cos;
function _memset(ptr, value, num) {
ptr = ptr|0; value = value|0; num = num|0;
var stop = 0, value4 = 0, stop4 = 0, unaligned = 0;
stop = (ptr + num)|0;
if ((num|0) >= 20) {
// This is unaligned, but quite large, so work hard to get to aligned settings
value = value & 0xff;
unaligned = ptr & 3;
value4 = value | (value << 8) | (value << 16) | (value << 24);
stop4 = stop & ~3;
if (unaligned) {
unaligned = (ptr + 4 - unaligned)|0;
while ((ptr|0) < (unaligned|0)) { // no need to check for stop, since we have large num
HEAP8[(ptr)]=value;
ptr = (ptr+1)|0;
}
}
while ((ptr|0) < (stop4|0)) {
HEAP32[((ptr)>>2)]=value4;
ptr = (ptr+4)|0;
}
}
while ((ptr|0) < (stop|0)) {
HEAP8[(ptr)]=value;
ptr = (ptr+1)|0;
}
}var _llvm_memset_p0i8_i32=_memset;
function _abort() {
ABORT = true;
throw 'abort() at ' + (new Error().stack);
}
function ___errno_location() {
return ___setErrNo.ret;
}var ___errno=___errno_location;
function _sysconf(name) {
// long sysconf(int name);
// http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
switch(name) {
case 8: return PAGE_SIZE;
case 54:
case 56:
case 21:
case 61:
case 63:
case 22:
case 67:
case 23:
case 24:
case 25:
case 26:
case 27:
case 69:
case 28:
case 101:
case 70:
case 71:
case 29:
case 30:
case 199:
case 75:
case 76:
case 32:
case 43:
case 44:
case 80:
case 46:
case 47:
case 45:
case 48:
case 49:
case 42:
case 82:
case 33:
case 7:
case 108:
case 109:
case 107:
case 112:
case 119:
case 121:
return 200809;
case 13:
case 104:
case 94:
case 95:
case 34:
case 35:
case 77:
case 81:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
case 91:
case 94:
case 95:
case 110:
case 111:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 120:
case 40:
case 16:
case 79:
case 19:
return -1;
case 92:
case 93:
case 5:
case 72:
case 6:
case 74:
case 92:
case 93:
case 96:
case 97:
case 98:
case 99:
case 102:
case 103:
case 105:
return 1;
case 38:
case 66:
case 50:
case 51:
case 4:
return 1024;
case 15:
case 64:
case 41:
return 32;
case 55:
case 37:
case 17:
return 2147483647;
case 18:
case 1:
return 47839;
case 59:
case 57:
return 99;
case 68:
case 58:
return 2048;
case 0: return 2097152;
case 3: return 65536;
case 14: return 32768;
case 73: return 32767;
case 39: return 16384;
case 60: return 1000;
case 106: return 700;
case 52: return 256;
case 62: return 255;
case 2: return 100;
case 65: return 64;
case 36: return 20;
case 100: return 16;
case 20: return 6;
case 53: return 4;
case 10: 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;
}
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 need to make sure no one else allocates unfreeable memory!
// We must control this entirely. So we don't even need to do
// unfreeable allocations - the HEAP is ours, from STATICTOP up.
// TODO: We could in theory slice off the top of the HEAP when
// sbrk gets a negative increment in |bytes|...
var self = _sbrk;
if (!self.called) {
STATICTOP = alignMemoryPage(STATICTOP); // make sure we start out aligned
self.called = true;
_sbrk.DYNAMIC_START = STATICTOP;
}
var ret = STATICTOP;
if (bytes != 0) Runtime.staticAlloc(bytes);
return ret; // Previous break location.
}
function _free(){}
Module["requestFullScreen"] = function(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
Module["requestAnimationFrame"] = function(func) { Browser.requestAnimationFrame(func) };
Module["pauseMainLoop"] = function() { Browser.mainLoop.pause() };
Module["resumeMainLoop"] = function() { Browser.mainLoop.resume() };
GL.init()
__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;
___setErrNo(0);
var FUNCTION_TABLE = [0,0,_gears_reshape,0,_gears_draw,0,_gears_idle,0,_gears_special,0];
// EMSCRIPTEN_START_FUNCS
function _perspective($m, $fovy, $aspect, $zNear, $zFar) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 80)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $4;
var $5;
var $tmp=__stackBase__;
var $sine=(__stackBase__)+(64);
var $cosine=(__stackBase__)+(72);
var $cotangent;
var $deltaZ;
var $radians;
$1=$m;
$2=$fovy;
$3=$aspect;
$4=$zNear;
$5=$zFar;
var $6=(($tmp)|0);
_identity($6);
var $7=$2;
var $8=($7)/(2);
var $9=$8;
var $10=($9)*(3.141592653589793);
var $11=($10)/(180);
var $12=$11;
$radians=$12;
var $13=$5;
var $14=$4;
var $15=($13)-($14);
var $16=$15;
$deltaZ=$16;
var $17=$radians;
var $18=$17;
__sincos($18, $sine, $cosine);
var $19=$deltaZ;
var $20=$19 == 0;
if ($20) { label = 5; break; } else { label = 3; break; }
case 3:
var $22=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($sine)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($sine)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $23=$22 == 0;
if ($23) { label = 5; break; } else { label = 4; break; }
case 4:
var $25=$3;
var $26=$25 == 0;
if ($26) { label = 5; break; } else { label = 6; break; }
case 5:
label = 7; break;
case 6:
var $29=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($cosine)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($cosine)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $30=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($sine)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($sine)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $31=($29)/($30);
$cotangent=$31;
var $32=$cotangent;
var $33=$3;
var $34=$33;
var $35=($32)/($34);
var $36=$35;
var $37=(($tmp)|0);
HEAPF32[(($37)>>2)]=$36;
var $38=$cotangent;
var $39=$38;
var $40=(($tmp+20)|0);
HEAPF32[(($40)>>2)]=$39;
var $41=$5;
var $42=$4;
var $43=($41)+($42);
var $44=(-$43);
var $45=$44;
var $46=$deltaZ;
var $47=($45)/($46);
var $48=$47;
var $49=(($tmp+40)|0);
HEAPF32[(($49)>>2)]=$48;
var $50=(($tmp+44)|0);
HEAPF32[(($50)>>2)]=-1;
var $51=$4;
var $52=($51)*(-2);
var $53=$5;
var $54=($52)*($53);
var $55=$54;
var $56=$deltaZ;
var $57=($55)/($56);
var $58=$57;
var $59=(($tmp+56)|0);
HEAPF32[(($59)>>2)]=$58;
var $60=(($tmp+60)|0);
HEAPF32[(($60)>>2)]=0;
var $61=$1;
var $62=$61;
var $63=$tmp;
assert(64 % 1 === 0);_memcpy($62, $63, 64);
label = 7; break;
case 7:
STACKTOP = __stackBase__;
return;
default: assert(0, "bad label: " + label);
}
}
function _identity($m) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 64)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $1;
var $t=__stackBase__;
$1=$m;
var $2=$t;
_memset($2, 0, 64);
var $3=$2;
var $4=(($3)|0);
HEAPF32[(($4)>>2)]=1;
var $5=(($3+20)|0);
HEAPF32[(($5)>>2)]=1;
var $6=(($3+40)|0);
HEAPF32[(($6)>>2)]=1;
var $7=(($3+60)|0);
HEAPF32[(($7)>>2)]=1;
var $8=$1;
var $9=$8;
var $10=$t;
assert(64 % 1 === 0);_memcpy($9, $10, 64);
STACKTOP = __stackBase__;
return;
}
function __sincos($a, $s, $c) {
var label = 0;
var $1;
var $2;
var $3;
$1=$a;
$2=$s;
$3=$c;
var $4=$1;
var $5=Math.sin($4);
var $6=$2;
(HEAPF64[(tempDoublePtr)>>3]=$5,HEAP32[(($6)>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((($6)+(4))>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]);
var $7=$1;
var $8=Math.cos($7);
var $9=$3;
(HEAPF64[(tempDoublePtr)>>3]=$8,HEAP32[(($9)>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((($9)+(4))>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]);
return;
}
function _main($argc, $argv) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 4)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $1;
var $2=__stackBase__;
var $3;
$1=0;
HEAP32[(($2)>>2)]=$argc;
$3=$argv;
var $4=$3;
_glutInit($2, $4);
_glutInitWindowSize(300, 300);
_glutInitDisplayMode(18);
var $5=_glutCreateWindow(((5244132)|0));
_glutIdleFunc(6);
_glutReshapeFunc(2);
_glutDisplayFunc(4);
_glutSpecialFunc(8);
_gears_init();
_glutMainLoop();
STACKTOP = __stackBase__;
return 0;
}
Module["_main"] = _main;
function _gears_idle() {
var label = 0;
var __stackBase__ = STACKTOP; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
label = 2;
while(1) switch(label) {
case 2:
var $dt;
var $t;
var $seconds;
var $fps;
var $1=_glutGet(700);
var $2=(($1)|(0));
var $3=($2)/(1000);
$t=$3;
var $4=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[((5243732)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((5243736)>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $5=$4 < 0;
if ($5) { label = 3; break; } else { label = 4; break; }
case 3:
var $7=$t;
(HEAPF64[(tempDoublePtr)>>3]=$7,HEAP32[((5243732)>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((5243736)>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]);
label = 4; break;
case 4:
var $9=$t;
var $10=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[((5243732)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((5243736)>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $11=($9)-($10);
$dt=$11;
var $12=$t;
(HEAPF64[(tempDoublePtr)>>3]=$12,HEAP32[((5243732)>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((5243736)>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]);
var $13=$dt;
var $14=($13)*(70);
var $15=HEAPF32[((5243924)>>2)];
var $16=$15;
var $17=($16)+($14);
var $18=$17;
HEAPF32[((5243924)>>2)]=$18;
var $19=HEAPF32[((5243924)>>2)];
var $20=$19;
var $21=$20 > 3600;
if ($21) { label = 5; break; } else { label = 6; break; }
case 5:
var $23=HEAPF32[((5243924)>>2)];
var $24=$23;
var $25=($24)-(3600);
var $26=$25;
HEAPF32[((5243924)>>2)]=$26;
label = 6; break;
case 6:
_glutPostRedisplay();
var $28=HEAP32[((5243748)>>2)];
var $29=((($28)+(1))|0);
HEAP32[((5243748)>>2)]=$29;
var $30=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[((5243740)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((5243744)>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $31=$30 < 0;
if ($31) { label = 7; break; } else { label = 8; break; }
case 7:
var $33=$t;
(HEAPF64[(tempDoublePtr)>>3]=$33,HEAP32[((5243740)>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((5243744)>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]);
label = 8; break;
case 8:
var $35=$t;
var $36=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[((5243740)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((5243744)>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $37=($35)-($36);
var $38=$37 >= 5;
if ($38) { label = 9; break; } else { label = 10; break; }
case 9:
var $40=$t;
var $41=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[((5243740)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((5243744)>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $42=($40)-($41);
var $43=$42;
$seconds=$43;
var $44=HEAP32[((5243748)>>2)];
var $45=(($44)|(0));
var $46=$seconds;
var $47=($45)/($46);
$fps=$47;
var $48=HEAP32[((5243748)>>2)];
var $49=$seconds;
var $50=$49;
var $51=$fps;
var $52=$51;
var $53=_printf(((5244068)|0), (tempInt=STACKTOP,STACKTOP = (STACKTOP + 20)|0,assert((STACKTOP|0) < (STACK_MAX|0)),HEAP32[((tempInt)>>2)]=$48,(HEAPF64[(tempDoublePtr)>>3]=$50,HEAP32[(((tempInt)+(4))>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((((tempInt)+(4))+(4))>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]),(HEAPF64[(tempDoublePtr)>>3]=$52,HEAP32[(((tempInt)+(12))>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((((tempInt)+(12))+(4))>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]),tempInt));
var $54=$t;
(HEAPF64[(tempDoublePtr)>>3]=$54,HEAP32[((5243740)>>2)]=HEAP32[((tempDoublePtr)>>2)],HEAP32[((5243744)>>2)]=HEAP32[(((tempDoublePtr)+(4))>>2)]);
HEAP32[((5243748)>>2)]=0;
label = 10; break;
case 10:
STACKTOP = __stackBase__;
return;
default: assert(0, "bad label: " + label);
}
}
function _gears_reshape($width, $height) {
var label = 0;
var $1;
var $2;
$1=$width;
$2=$height;
var $3=$1;
var $4=(($3)|(0));
var $5=$2;
var $6=(($5)|(0));
var $7=($4)/($6);
_perspective(((5244616)|0), 60, $7, 1, 1024);
var $8=$1;
var $9=$2;
_glViewport(0, 0, $8, $9);
return;
}
function _gears_draw() {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 64)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $transform=__stackBase__;
var $1=(($transform)|0);
_identity($1);
_glClearColor(0, 0, 0, 0);
_glClear(16640);
var $2=(($transform)|0);
_translate($2, 0, 0, -20);
var $3=(($transform)|0);
var $4=HEAPF32[((((5242880)|0))>>2)];
var $5=$4;
var $6=($5)*(6.283185307179586);
var $7=($6)/(360);
var $8=$7;
_rotate($3, $8, 1, 0, 0);
var $9=(($transform)|0);
var $10=HEAPF32[((((5242884)|0))>>2)];
var $11=$10;
var $12=($11)*(6.283185307179586);
var $13=($12)/(360);
var $14=$13;
_rotate($9, $14, 0, 1, 0);
var $15=(($transform)|0);
var $16=HEAPF32[((((5242888)|0))>>2)];
var $17=$16;
var $18=($17)*(6.283185307179586);
var $19=($18)/(360);
var $20=$19;
_rotate($15, $20, 0, 0, 1);
var $21=HEAP32[((5243808)>>2)];
var $22=(($transform)|0);
var $23=HEAPF32[((5243924)>>2)];
_draw_gear($21, $22, -3, -2, $23, ((5243752)|0));
var $24=HEAP32[((5243804)>>2)];
var $25=(($transform)|0);
var $26=HEAPF32[((5243924)>>2)];
var $27=($26)*(-2);
var $28=$27;
var $29=($28)-(9);
var $30=$29;
_draw_gear($24, $25, 3.0999999046325684, -2, $30, ((5243768)|0));
var $31=HEAP32[((5243800)>>2)];
var $32=(($transform)|0);
var $33=HEAPF32[((5243924)>>2)];
var $34=($33)*(-2);
var $35=$34;
var $36=($35)-(25);
var $37=$36;
_draw_gear($31, $32, -3.0999999046325684, 4.199999809265137, $37, ((5243784)|0));
STACKTOP = __stackBase__;
return;
}
function _gears_special($special, $crap, $morecrap) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
$1=$special;
$2=$crap;
$3=$morecrap;
var $4=$1;
if ((($4)|(0))==100) {
label = 3; break;
}
else if ((($4)|(0))==102) {
label = 4; break;
}
else if ((($4)|(0))==101) {
label = 5; break;
}
else if ((($4)|(0))==103) {
label = 6; break;
}
else if ((($4)|(0))==11) {
label = 7; break;
}
else {
label = 8; break;
}
case 3:
var $6=HEAPF32[((((5242884)|0))>>2)];
var $7=$6;
var $8=($7)+(5);
var $9=$8;
HEAPF32[((((5242884)|0))>>2)]=$9;
label = 8; break;
case 4:
var $11=HEAPF32[((((5242884)|0))>>2)];
var $12=$11;
var $13=($12)-(5);
var $14=$13;
HEAPF32[((((5242884)|0))>>2)]=$14;
label = 8; break;
case 5:
var $16=HEAPF32[((((5242880)|0))>>2)];
var $17=$16;
var $18=($17)+(5);
var $19=$18;
HEAPF32[((((5242880)|0))>>2)]=$19;
label = 8; break;
case 6:
var $21=HEAPF32[((((5242880)|0))>>2)];
var $22=$21;
var $23=($22)-(5);
var $24=$23;
HEAPF32[((((5242880)|0))>>2)]=$24;
label = 8; break;
case 7:
_glutFullScreen();
label = 8; break;
case 8:
return;
default: assert(0, "bad label: " + label);
}
}
function _gears_init() {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 516)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $v;
var $f;
var $program;
var $p=__stackBase__;
var $msg=(__stackBase__)+(4);
_glEnable(2884);
_glEnable(2929);
HEAP32[(($p)>>2)]=((5242892)|0);
var $1=_glCreateShader(35633);
$v=$1;
var $2=$v;
_glShaderSource($2, 1, $p, 0);
var $3=$v;
_glCompileShader($3);
var $4=$v;
var $5=(($msg)|0);
_glGetShaderInfoLog($4, 512, 0, $5);
var $6=(($msg)|0);
var $7=_printf(((5244108)|0), (tempInt=STACKTOP,STACKTOP = (STACKTOP + 4)|0,assert((STACKTOP|0) < (STACK_MAX|0)),HEAP32[((tempInt)>>2)]=$6,tempInt));
HEAP32[(($p)>>2)]=((5243812)|0);
var $8=_glCreateShader(35632);
$f=$8;
var $9=$f;
_glShaderSource($9, 1, $p, 0);
var $10=$f;
_glCompileShader($10);
var $11=$f;
var $12=(($msg)|0);
_glGetShaderInfoLog($11, 512, 0, $12);
var $13=(($msg)|0);
var $14=_printf(((5244040)|0), (tempInt=STACKTOP,STACKTOP = (STACKTOP + 4)|0,assert((STACKTOP|0) < (STACK_MAX|0)),HEAP32[((tempInt)>>2)]=$13,tempInt));
var $15=_glCreateProgram();
$program=$15;
var $16=$program;
var $17=$v;
_glAttachShader($16, $17);
var $18=$program;
var $19=$f;
_glAttachShader($18, $19);
var $20=$program;
_glBindAttribLocation($20, 0, ((5244028)|0));
var $21=$program;
_glBindAttribLocation($21, 1, ((5244020)|0));
var $22=$program;
_glLinkProgram($22);
var $23=$program;
var $24=(($msg)|0);
_glGetProgramInfoLog($23, 512, 0, $24);
var $25=(($msg)|0);
var $26=_printf(((5244008)|0), (tempInt=STACKTOP,STACKTOP = (STACKTOP + 4)|0,assert((STACKTOP|0) < (STACK_MAX|0)),HEAP32[((tempInt)>>2)]=$25,tempInt));
var $27=$program;
_glUseProgram($27);
var $28=$program;
var $29=_glGetUniformLocation($28, ((5243980)|0));
HEAP32[((5244684)>>2)]=$29;
var $30=$program;
var $31=_glGetUniformLocation($30, ((5243964)|0));
HEAP32[((5244680)>>2)]=$31;
var $32=$program;
var $33=_glGetUniformLocation($32, ((5243944)|0));
HEAP32[((5244692)>>2)]=$33;
var $34=$program;
var $35=_glGetUniformLocation($34, ((5243928)|0));
HEAP32[((5244688)>>2)]=$35;
var $36=HEAP32[((5244692)>>2)];
_glUniform4fv($36, 1, ((5244696)|0));
var $37=_create_gear(1, 4, 1, 20, 0.699999988079071);
HEAP32[((5243808)>>2)]=$37;
var $38=_create_gear(0.5, 2, 2, 10, 0.699999988079071);
HEAP32[((5243804)>>2)]=$38;
var $39=_create_gear(1.2999999523162842, 2, 0.5, 10, 0.699999988079071);
HEAP32[((5243800)>>2)]=$39;
STACKTOP = __stackBase__;
return;
}
function _create_gear($inner_radius, $outer_radius, $width, $teeth, $tooth_depth) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 148)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $4;
var $5;
var $6;
var $r0;
var $r1;
var $r2;
var $da;
var $v;
var $gear;
var $s=__stackBase__;
var $c=(__stackBase__)+(40);
var $normal=(__stackBase__)+(80);
var $cur_strip;
var $i;
var $p=(__stackBase__)+(92);
var $_tmp;
var $_tmp1;
var $_tmp2;
var $_tmp3;
var $_tmp4;
var $_tmp5;
var $_tmp6;
$2=$inner_radius;
$3=$outer_radius;
$4=$width;
$5=$teeth;
$6=$tooth_depth;
$cur_strip=0;
var $7=_malloc(20);
var $8=$7;
$gear=$8;
var $9=$gear;
var $10=(($9)|(0))==0;
if ($10) { label = 3; break; } else { label = 4; break; }
case 3:
$1=0;
label = 61; break;
case 4:
var $13=$2;
$r0=$13;
var $14=$3;
var $15=$14;
var $16=$6;
var $17=$16;
var $18=($17)/(2);
var $19=($15)-($18);
var $20=$19;
$r1=$20;
var $21=$3;
var $22=$21;
var $23=$6;
var $24=$23;
var $25=($24)/(2);
var $26=($22)+($25);
var $27=$26;
$r2=$27;
var $28=$5;
var $29=(($28)|(0));
var $30=(6.283185307179586)/($29);
var $31=($30)/(4);
var $32=$31;
$da=$32;
var $33=$5;
var $34=((($33)*(7))&-1);
var $35=$gear;
var $36=(($35+12)|0);
HEAP32[(($36)>>2)]=$34;
var $37=$gear;
var $38=(($37+12)|0);
var $39=HEAP32[(($38)>>2)];
var $40=_calloc($39, 8);
var $41=$40;
var $42=$gear;
var $43=(($42+8)|0);
HEAP32[(($43)>>2)]=$41;
var $44=$5;
var $45=((($44)*(34))&-1);
var $46=_calloc($45, 24);
var $47=$46;
var $48=$gear;
var $49=(($48)|0);
HEAP32[(($49)>>2)]=$47;
var $50=$gear;
var $51=(($50)|0);
var $52=HEAP32[(($51)>>2)];
$v=$52;
$i=0;
label = 5; break;
case 5:
var $54=$i;
var $55=$5;
var $56=(($54)|(0)) < (($55)|(0));
if ($56) { label = 6; break; } else { label = 60; break; }
case 6:
var $58=$i;
var $59=(($58)|(0));
var $60=($59)*(2);
var $61=($60)*(3.141592653589793);
var $62=$5;
var $63=(($62)|(0));
var $64=($61)/($63);
var $65=(($s)|0);
var $66=(($c)|0);
__sincos($64, $65, $66);
var $67=$i;
var $68=(($67)|(0));
var $69=($68)*(2);
var $70=($69)*(3.141592653589793);
var $71=$5;
var $72=(($71)|(0));
var $73=($70)/($72);
var $74=$da;
var $75=$74;
var $76=($73)+($75);
var $77=(($s+8)|0);
var $78=(($c+8)|0);
__sincos($76, $77, $78);
var $79=$i;
var $80=(($79)|(0));
var $81=($80)*(2);
var $82=($81)*(3.141592653589793);
var $83=$5;
var $84=(($83)|(0));
var $85=($82)/($84);
var $86=$da;
var $87=($86)*(2);
var $88=$87;
var $89=($85)+($88);
var $90=(($s+16)|0);
var $91=(($c+16)|0);
__sincos($89, $90, $91);
var $92=$i;
var $93=(($92)|(0));
var $94=($93)*(2);
var $95=($94)*(3.141592653589793);
var $96=$5;
var $97=(($96)|(0));
var $98=($95)/($97);
var $99=$da;
var $100=($99)*(3);
var $101=$100;
var $102=($98)+($101);
var $103=(($s+24)|0);
var $104=(($c+24)|0);
__sincos($102, $103, $104);
var $105=$i;
var $106=(($105)|(0));
var $107=($106)*(2);
var $108=($107)*(3.141592653589793);
var $109=$5;
var $110=(($109)|(0));
var $111=($108)/($110);
var $112=$da;
var $113=($112)*(4);
var $114=$113;
var $115=($111)+($114);
var $116=(($s+32)|0);
var $117=(($c+32)|0);
__sincos($115, $116, $117);
var $118=(($p)|0);
var $119=(($118)|0);
var $120=$r2;
var $121=$120;
var $122=(($c+8)|0);
var $123=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($122)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($122)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $124=($121)*($123);
var $125=$124;
HEAPF32[(($119)>>2)]=$125;
var $126=(($118+4)|0);
var $127=$r2;
var $128=$127;
var $129=(($s+8)|0);
var $130=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($129)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($129)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $131=($128)*($130);
var $132=$131;
HEAPF32[(($126)>>2)]=$132;
var $133=(($118+8)|0);
var $134=(($133)|0);
var $135=$r2;
var $136=$135;
var $137=(($c+16)|0);
var $138=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($137)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($137)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $139=($136)*($138);
var $140=$139;
HEAPF32[(($134)>>2)]=$140;
var $141=(($133+4)|0);
var $142=$r2;
var $143=$142;
var $144=(($s+16)|0);
var $145=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($144)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($144)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $146=($143)*($145);
var $147=$146;
HEAPF32[(($141)>>2)]=$147;
var $148=(($133+8)|0);
var $149=(($148)|0);
var $150=$r1;
var $151=$150;
var $152=(($c)|0);
var $153=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($152)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($152)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $154=($151)*($153);
var $155=$154;
HEAPF32[(($149)>>2)]=$155;
var $156=(($148+4)|0);
var $157=$r1;
var $158=$157;
var $159=(($s)|0);
var $160=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($159)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($159)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $161=($158)*($160);
var $162=$161;
HEAPF32[(($156)>>2)]=$162;
var $163=(($148+8)|0);
var $164=(($163)|0);
var $165=$r1;
var $166=$165;
var $167=(($c+24)|0);
var $168=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($167)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($167)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $169=($166)*($168);
var $170=$169;
HEAPF32[(($164)>>2)]=$170;
var $171=(($163+4)|0);
var $172=$r1;
var $173=$172;
var $174=(($s+24)|0);
var $175=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($174)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($174)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $176=($173)*($175);
var $177=$176;
HEAPF32[(($171)>>2)]=$177;
var $178=(($163+8)|0);
var $179=(($178)|0);
var $180=$r0;
var $181=$180;
var $182=(($c)|0);
var $183=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($182)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($182)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $184=($181)*($183);
var $185=$184;
HEAPF32[(($179)>>2)]=$185;
var $186=(($178+4)|0);
var $187=$r0;
var $188=$187;
var $189=(($s)|0);
var $190=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($189)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($189)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $191=($188)*($190);
var $192=$191;
HEAPF32[(($186)>>2)]=$192;
var $193=(($178+8)|0);
var $194=(($193)|0);
var $195=$r1;
var $196=$195;
var $197=(($c+32)|0);
var $198=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($197)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($197)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $199=($196)*($198);
var $200=$199;
HEAPF32[(($194)>>2)]=$200;
var $201=(($193+4)|0);
var $202=$r1;
var $203=$202;
var $204=(($s+32)|0);
var $205=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($204)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($204)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $206=($203)*($205);
var $207=$206;
HEAPF32[(($201)>>2)]=$207;
var $208=(($193+8)|0);
var $209=(($208)|0);
var $210=$r0;
var $211=$210;
var $212=(($c+32)|0);
var $213=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($212)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($212)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $214=($211)*($213);
var $215=$214;
HEAPF32[(($209)>>2)]=$215;
var $216=(($208+4)|0);
var $217=$r0;
var $218=$217;
var $219=(($s+32)|0);
var $220=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($219)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($219)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $221=($218)*($220);
var $222=$221;
HEAPF32[(($216)>>2)]=$222;
label = 7; break;
case 7:
var $224=$v;
var $225=$gear;
var $226=(($225)|0);
var $227=HEAP32[(($226)>>2)];
var $228=$224;
var $229=$227;
var $230=((($228)-($229))|0);
var $231=((((($230)|(0)))/(24))&-1);
var $232=$cur_strip;
var $233=$gear;
var $234=(($233+8)|0);
var $235=HEAP32[(($234)>>2)];
var $236=(($235+($232<<3))|0);
var $237=(($236)|0);
HEAP32[(($237)>>2)]=$231;
label = 8; break;
case 8:
label = 9; break;
case 9:
var $240=(($normal)|0);
HEAPF32[(($240)>>2)]=0;
var $241=(($normal+4)|0);
HEAPF32[(($241)>>2)]=0;
var $242=(($normal+8)|0);
HEAPF32[(($242)>>2)]=1;
label = 10; break;
case 10:
var $244=$v;
var $245=(($p)|0);
var $246=(($245)|0);
var $247=HEAPF32[(($246)>>2)];
var $248=(($p)|0);
var $249=(($248+4)|0);
var $250=HEAPF32[(($249)>>2)];
var $251=$4;
var $252=$251;
var $253=$252;
var $254=($253)*(0.5);
var $255=$254;
var $256=(($normal)|0);
var $257=_vert($244, $247, $250, $255, $256);
$v=$257;
var $258=$v;
var $259=(($p+8)|0);
var $260=(($259)|0);
var $261=HEAPF32[(($260)>>2)];
var $262=(($p+8)|0);
var $263=(($262+4)|0);
var $264=HEAPF32[(($263)>>2)];
var $265=$4;
var $266=$265;
var $267=$266;
var $268=($267)*(0.5);
var $269=$268;
var $270=(($normal)|0);
var $271=_vert($258, $261, $264, $269, $270);
$v=$271;
var $272=$v;
var $273=(($p+16)|0);
var $274=(($273)|0);
var $275=HEAPF32[(($274)>>2)];
var $276=(($p+16)|0);
var $277=(($276+4)|0);
var $278=HEAPF32[(($277)>>2)];
var $279=$4;
var $280=$279;
var $281=$280;
var $282=($281)*(0.5);
var $283=$282;
var $284=(($normal)|0);
var $285=_vert($272, $275, $278, $283, $284);
$v=$285;
var $286=$v;
var $287=(($p+24)|0);
var $288=(($287)|0);
var $289=HEAPF32[(($288)>>2)];
var $290=(($p+24)|0);
var $291=(($290+4)|0);
var $292=HEAPF32[(($291)>>2)];
var $293=$4;
var $294=$293;
var $295=$294;
var $296=($295)*(0.5);
var $297=$296;
var $298=(($normal)|0);
var $299=_vert($286, $289, $292, $297, $298);
$v=$299;
var $300=$v;
var $301=(($p+32)|0);
var $302=(($301)|0);
var $303=HEAPF32[(($302)>>2)];
var $304=(($p+32)|0);
var $305=(($304+4)|0);
var $306=HEAPF32[(($305)>>2)];
var $307=$4;
var $308=$307;
var $309=$308;
var $310=($309)*(0.5);
var $311=$310;
var $312=(($normal)|0);
var $313=_vert($300, $303, $306, $311, $312);
$v=$313;
var $314=$v;
var $315=(($p+40)|0);
var $316=(($315)|0);
var $317=HEAPF32[(($316)>>2)];
var $318=(($p+40)|0);
var $319=(($318+4)|0);
var $320=HEAPF32[(($319)>>2)];
var $321=$4;
var $322=$321;
var $323=$322;
var $324=($323)*(0.5);
var $325=$324;
var $326=(($normal)|0);
var $327=_vert($314, $317, $320, $325, $326);
$v=$327;
var $328=$v;
var $329=(($p+48)|0);
var $330=(($329)|0);
var $331=HEAPF32[(($330)>>2)];
var $332=(($p+48)|0);
var $333=(($332+4)|0);
var $334=HEAPF32[(($333)>>2)];
var $335=$4;
var $336=$335;
var $337=$336;
var $338=($337)*(0.5);
var $339=$338;
var $340=(($normal)|0);
var $341=_vert($328, $331, $334, $339, $340);
$v=$341;
label = 11; break;
case 11:
var $343=$v;
var $344=$gear;
var $345=(($344)|0);
var $346=HEAP32[(($345)>>2)];
var $347=$343;
var $348=$346;
var $349=((($347)-($348))|0);
var $350=((((($349)|(0)))/(24))&-1);
$_tmp=$350;
var $351=$_tmp;
var $352=$cur_strip;
var $353=$gear;
var $354=(($353+8)|0);
var $355=HEAP32[(($354)>>2)];
var $356=(($355+($352<<3))|0);
var $357=(($356)|0);
var $358=HEAP32[(($357)>>2)];
var $359=((($351)-($358))|0);
var $360=$cur_strip;
var $361=$gear;
var $362=(($361+8)|0);
var $363=HEAP32[(($362)>>2)];
var $364=(($363+($360<<3))|0);
var $365=(($364+4)|0);
HEAP32[(($365)>>2)]=$359;
var $366=$cur_strip;
var $367=((($366)+(1))|0);
$cur_strip=$367;
label = 12; break;
case 12:
label = 13; break;
case 13:
var $370=$v;
var $371=$gear;
var $372=(($371)|0);
var $373=HEAP32[(($372)>>2)];
var $374=$370;
var $375=$373;
var $376=((($374)-($375))|0);
var $377=((((($376)|(0)))/(24))&-1);
var $378=$cur_strip;
var $379=$gear;
var $380=(($379+8)|0);
var $381=HEAP32[(($380)>>2)];
var $382=(($381+($378<<3))|0);
var $383=(($382)|0);
HEAP32[(($383)>>2)]=$377;
label = 14; break;
case 14:
label = 15; break;
case 15:
label = 16; break;
case 16:
var $387=(($p+32)|0);
var $388=(($387+4)|0);
var $389=HEAPF32[(($388)>>2)];
var $390=(($p+48)|0);
var $391=(($390+4)|0);
var $392=HEAPF32[(($391)>>2)];
var $393=($389)-($392);
var $394=(($normal)|0);
HEAPF32[(($394)>>2)]=$393;
var $395=(($p+32)|0);
var $396=(($395)|0);
var $397=HEAPF32[(($396)>>2)];
var $398=(($p+48)|0);
var $399=(($398)|0);
var $400=HEAPF32[(($399)>>2)];
var $401=($397)-($400);
var $402=(-$401);
var $403=(($normal+4)|0);
HEAPF32[(($403)>>2)]=$402;
var $404=(($normal+8)|0);
HEAPF32[(($404)>>2)]=0;
label = 17; break;
case 17:
var $406=$v;
var $407=(($p+32)|0);
var $408=(($407)|0);
var $409=HEAPF32[(($408)>>2)];
var $410=(($p+32)|0);
var $411=(($410+4)|0);
var $412=HEAPF32[(($411)>>2)];
var $413=$4;
var $414=($413)*(-1);
var $415=$414;
var $416=($415)*(0.5);
var $417=$416;
var $418=(($normal)|0);
var $419=_vert($406, $409, $412, $417, $418);
$v=$419;
var $420=$v;
var $421=(($p+32)|0);
var $422=(($421)|0);
var $423=HEAPF32[(($422)>>2)];
var $424=(($p+32)|0);
var $425=(($424+4)|0);
var $426=HEAPF32[(($425)>>2)];
var $427=$4;
var $428=$427;
var $429=$428;
var $430=($429)*(0.5);
var $431=$430;
var $432=(($normal)|0);
var $433=_vert($420, $423, $426, $431, $432);
$v=$433;
var $434=$v;
var $435=(($p+48)|0);
var $436=(($435)|0);
var $437=HEAPF32[(($436)>>2)];
var $438=(($p+48)|0);
var $439=(($438+4)|0);
var $440=HEAPF32[(($439)>>2)];
var $441=$4;
var $442=($441)*(-1);
var $443=$442;
var $444=($443)*(0.5);
var $445=$444;
var $446=(($normal)|0);
var $447=_vert($434, $437, $440, $445, $446);
$v=$447;
var $448=$v;
var $449=(($p+48)|0);
var $450=(($449)|0);
var $451=HEAPF32[(($450)>>2)];
var $452=(($p+48)|0);
var $453=(($452+4)|0);
var $454=HEAPF32[(($453)>>2)];
var $455=$4;
var $456=$455;
var $457=$456;
var $458=($457)*(0.5);
var $459=$458;
var $460=(($normal)|0);
var $461=_vert($448, $451, $454, $459, $460);
$v=$461;
label = 18; break;
case 18:
label = 19; break;
case 19:
var $464=$v;
var $465=$gear;
var $466=(($465)|0);
var $467=HEAP32[(($466)>>2)];
var $468=$464;
var $469=$467;
var $470=((($468)-($469))|0);
var $471=((((($470)|(0)))/(24))&-1);
$_tmp1=$471;
var $472=$_tmp1;
var $473=$cur_strip;
var $474=$gear;
var $475=(($474+8)|0);
var $476=HEAP32[(($475)>>2)];
var $477=(($476+($473<<3))|0);
var $478=(($477)|0);
var $479=HEAP32[(($478)>>2)];
var $480=((($472)-($479))|0);
var $481=$cur_strip;
var $482=$gear;
var $483=(($482+8)|0);
var $484=HEAP32[(($483)>>2)];
var $485=(($484+($481<<3))|0);
var $486=(($485+4)|0);
HEAP32[(($486)>>2)]=$480;
var $487=$cur_strip;
var $488=((($487)+(1))|0);
$cur_strip=$488;
label = 20; break;
case 20:
label = 21; break;
case 21:
var $491=$v;
var $492=$gear;
var $493=(($492)|0);
var $494=HEAP32[(($493)>>2)];
var $495=$491;
var $496=$494;
var $497=((($495)-($496))|0);
var $498=((((($497)|(0)))/(24))&-1);
var $499=$cur_strip;
var $500=$gear;
var $501=(($500+8)|0);
var $502=HEAP32[(($501)>>2)];
var $503=(($502+($499<<3))|0);
var $504=(($503)|0);
HEAP32[(($504)>>2)]=$498;
label = 22; break;
case 22:
label = 23; break;
case 23:
var $507=(($normal)|0);
HEAPF32[(($507)>>2)]=0;
var $508=(($normal+4)|0);
HEAPF32[(($508)>>2)]=0;
var $509=(($normal+8)|0);
HEAPF32[(($509)>>2)]=-1;
label = 24; break;
case 24:
var $511=$v;
var $512=(($p+48)|0);
var $513=(($512)|0);
var $514=HEAPF32[(($513)>>2)];
var $515=(($p+48)|0);
var $516=(($515+4)|0);
var $517=HEAPF32[(($516)>>2)];
var $518=$4;
var $519=($518)*(-1);
var $520=$519;
var $521=($520)*(0.5);
var $522=$521;
var $523=(($normal)|0);
var $524=_vert($511, $514, $517, $522, $523);
$v=$524;
var $525=$v;
var $526=(($p+40)|0);
var $527=(($526)|0);
var $528=HEAPF32[(($527)>>2)];
var $529=(($p+40)|0);
var $530=(($529+4)|0);
var $531=HEAPF32[(($530)>>2)];
var $532=$4;
var $533=($532)*(-1);
var $534=$533;
var $535=($534)*(0.5);
var $536=$535;
var $537=(($normal)|0);
var $538=_vert($525, $528, $531, $536, $537);
$v=$538;
var $539=$v;
var $540=(($p+32)|0);
var $541=(($540)|0);
var $542=HEAPF32[(($541)>>2)];
var $543=(($p+32)|0);
var $544=(($543+4)|0);
var $545=HEAPF32[(($544)>>2)];
var $546=$4;
var $547=($546)*(-1);
var $548=$547;
var $549=($548)*(0.5);
var $550=$549;
var $551=(($normal)|0);
var $552=_vert($539, $542, $545, $550, $551);
$v=$552;
var $553=$v;
var $554=(($p+24)|0);
var $555=(($554)|0);
var $556=HEAPF32[(($555)>>2)];
var $557=(($p+24)|0);
var $558=(($557+4)|0);
var $559=HEAPF32[(($558)>>2)];
var $560=$4;
var $561=($560)*(-1);
var $562=$561;
var $563=($562)*(0.5);
var $564=$563;
var $565=(($normal)|0);
var $566=_vert($553, $556, $559, $564, $565);
$v=$566;
var $567=$v;
var $568=(($p+16)|0);
var $569=(($568)|0);
var $570=HEAPF32[(($569)>>2)];
var $571=(($p+16)|0);
var $572=(($571+4)|0);
var $573=HEAPF32[(($572)>>2)];
var $574=$4;
var $575=($574)*(-1);
var $576=$575;
var $577=($576)*(0.5);
var $578=$577;
var $579=(($normal)|0);
var $580=_vert($567, $570, $573, $578, $579);
$v=$580;
var $581=$v;
var $582=(($p+8)|0);
var $583=(($582)|0);
var $584=HEAPF32[(($583)>>2)];
var $585=(($p+8)|0);
var $586=(($585+4)|0);
var $587=HEAPF32[(($586)>>2)];
var $588=$4;
var $589=($588)*(-1);
var $590=$589;
var $591=($590)*(0.5);
var $592=$591;
var $593=(($normal)|0);
var $594=_vert($581, $584, $587, $592, $593);
$v=$594;
var $595=$v;
var $596=(($p)|0);
var $597=(($596)|0);
var $598=HEAPF32[(($597)>>2)];
var $599=(($p)|0);
var $600=(($599+4)|0);
var $601=HEAPF32[(($600)>>2)];
var $602=$4;
var $603=($602)*(-1);
var $604=$603;
var $605=($604)*(0.5);
var $606=$605;
var $607=(($normal)|0);
var $608=_vert($595, $598, $601, $606, $607);
$v=$608;
label = 25; break;
case 25:
var $610=$v;
var $611=$gear;
var $612=(($611)|0);
var $613=HEAP32[(($612)>>2)];
var $614=$610;
var $615=$613;
var $616=((($614)-($615))|0);
var $617=((((($616)|(0)))/(24))&-1);
$_tmp2=$617;
var $618=$_tmp2;
var $619=$cur_strip;
var $620=$gear;
var $621=(($620+8)|0);
var $622=HEAP32[(($621)>>2)];
var $623=(($622+($619<<3))|0);
var $624=(($623)|0);
var $625=HEAP32[(($624)>>2)];
var $626=((($618)-($625))|0);
var $627=$cur_strip;
var $628=$gear;
var $629=(($628+8)|0);
var $630=HEAP32[(($629)>>2)];
var $631=(($630+($627<<3))|0);
var $632=(($631+4)|0);
HEAP32[(($632)>>2)]=$626;
var $633=$cur_strip;
var $634=((($633)+(1))|0);
$cur_strip=$634;
label = 26; break;
case 26:
label = 27; break;
case 27:
var $637=$v;
var $638=$gear;
var $639=(($638)|0);
var $640=HEAP32[(($639)>>2)];
var $641=$637;
var $642=$640;
var $643=((($641)-($642))|0);
var $644=((((($643)|(0)))/(24))&-1);
var $645=$cur_strip;
var $646=$gear;
var $647=(($646+8)|0);
var $648=HEAP32[(($647)>>2)];
var $649=(($648+($645<<3))|0);
var $650=(($649)|0);
HEAP32[(($650)>>2)]=$644;
label = 28; break;
case 28:
label = 29; break;
case 29:
label = 30; break;
case 30:
var $654=(($p)|0);
var $655=(($654+4)|0);
var $656=HEAPF32[(($655)>>2)];
var $657=(($p+16)|0);
var $658=(($657+4)|0);
var $659=HEAPF32[(($658)>>2)];
var $660=($656)-($659);
var $661=(($normal)|0);
HEAPF32[(($661)>>2)]=$660;
var $662=(($p)|0);
var $663=(($662)|0);
var $664=HEAPF32[(($663)>>2)];
var $665=(($p+16)|0);
var $666=(($665)|0);
var $667=HEAPF32[(($666)>>2)];
var $668=($664)-($667);
var $669=(-$668);
var $670=(($normal+4)|0);
HEAPF32[(($670)>>2)]=$669;
var $671=(($normal+8)|0);
HEAPF32[(($671)>>2)]=0;
label = 31; break;
case 31:
var $673=$v;
var $674=(($p)|0);
var $675=(($674)|0);
var $676=HEAPF32[(($675)>>2)];
var $677=(($p)|0);
var $678=(($677+4)|0);
var $679=HEAPF32[(($678)>>2)];
var $680=$4;
var $681=($680)*(-1);
var $682=$681;
var $683=($682)*(0.5);
var $684=$683;
var $685=(($normal)|0);
var $686=_vert($673, $676, $679, $684, $685);
$v=$686;
var $687=$v;
var $688=(($p)|0);
var $689=(($688)|0);
var $690=HEAPF32[(($689)>>2)];
var $691=(($p)|0);
var $692=(($691+4)|0);
var $693=HEAPF32[(($692)>>2)];
var $694=$4;
var $695=$694;
var $696=$695;
var $697=($696)*(0.5);
var $698=$697;
var $699=(($normal)|0);
var $700=_vert($687, $690, $693, $698, $699);
$v=$700;
var $701=$v;
var $702=(($p+16)|0);
var $703=(($702)|0);
var $704=HEAPF32[(($703)>>2)];
var $705=(($p+16)|0);
var $706=(($705+4)|0);
var $707=HEAPF32[(($706)>>2)];
var $708=$4;
var $709=($708)*(-1);
var $710=$709;
var $711=($710)*(0.5);
var $712=$711;
var $713=(($normal)|0);
var $714=_vert($701, $704, $707, $712, $713);
$v=$714;
var $715=$v;
var $716=(($p+16)|0);
var $717=(($716)|0);
var $718=HEAPF32[(($717)>>2)];
var $719=(($p+16)|0);
var $720=(($719+4)|0);
var $721=HEAPF32[(($720)>>2)];
var $722=$4;
var $723=$722;
var $724=$723;
var $725=($724)*(0.5);
var $726=$725;
var $727=(($normal)|0);
var $728=_vert($715, $718, $721, $726, $727);
$v=$728;
label = 32; break;
case 32:
label = 33; break;
case 33:
var $731=$v;
var $732=$gear;
var $733=(($732)|0);
var $734=HEAP32[(($733)>>2)];
var $735=$731;
var $736=$734;
var $737=((($735)-($736))|0);
var $738=((((($737)|(0)))/(24))&-1);
$_tmp3=$738;
var $739=$_tmp3;
var $740=$cur_strip;
var $741=$gear;
var $742=(($741+8)|0);
var $743=HEAP32[(($742)>>2)];
var $744=(($743+($740<<3))|0);
var $745=(($744)|0);
var $746=HEAP32[(($745)>>2)];
var $747=((($739)-($746))|0);
var $748=$cur_strip;
var $749=$gear;
var $750=(($749+8)|0);
var $751=HEAP32[(($750)>>2)];
var $752=(($751+($748<<3))|0);
var $753=(($752+4)|0);
HEAP32[(($753)>>2)]=$747;
var $754=$cur_strip;
var $755=((($754)+(1))|0);
$cur_strip=$755;
label = 34; break;
case 34:
label = 35; break;
case 35:
var $758=$v;
var $759=$gear;
var $760=(($759)|0);
var $761=HEAP32[(($760)>>2)];
var $762=$758;
var $763=$761;
var $764=((($762)-($763))|0);
var $765=((((($764)|(0)))/(24))&-1);
var $766=$cur_strip;
var $767=$gear;
var $768=(($767+8)|0);
var $769=HEAP32[(($768)>>2)];
var $770=(($769+($766<<3))|0);
var $771=(($770)|0);
HEAP32[(($771)>>2)]=$765;
label = 36; break;
case 36:
label = 37; break;
case 37:
label = 38; break;
case 38:
var $775=(($p+8)|0);
var $776=(($775+4)|0);
var $777=HEAPF32[(($776)>>2)];
var $778=(($p)|0);
var $779=(($778+4)|0);
var $780=HEAPF32[(($779)>>2)];
var $781=($777)-($780);
var $782=(($normal)|0);
HEAPF32[(($782)>>2)]=$781;
var $783=(($p+8)|0);
var $784=(($783)|0);
var $785=HEAPF32[(($784)>>2)];
var $786=(($p)|0);
var $787=(($786)|0);
var $788=HEAPF32[(($787)>>2)];
var $789=($785)-($788);
var $790=(-$789);
var $791=(($normal+4)|0);
HEAPF32[(($791)>>2)]=$790;
var $792=(($normal+8)|0);
HEAPF32[(($792)>>2)]=0;
label = 39; break;
case 39:
var $794=$v;
var $795=(($p+8)|0);
var $796=(($795)|0);
var $797=HEAPF32[(($796)>>2)];
var $798=(($p+8)|0);
var $799=(($798+4)|0);
var $800=HEAPF32[(($799)>>2)];
var $801=$4;
var $802=($801)*(-1);
var $803=$802;
var $804=($803)*(0.5);
var $805=$804;
var $806=(($normal)|0);
var $807=_vert($794, $797, $800, $805, $806);
$v=$807;
var $808=$v;
var $809=(($p+8)|0);
var $810=(($809)|0);
var $811=HEAPF32[(($810)>>2)];
var $812=(($p+8)|0);
var $813=(($812+4)|0);
var $814=HEAPF32[(($813)>>2)];
var $815=$4;
var $816=$815;
var $817=$816;
var $818=($817)*(0.5);
var $819=$818;
var $820=(($normal)|0);
var $821=_vert($808, $811, $814, $819, $820);
$v=$821;
var $822=$v;
var $823=(($p)|0);
var $824=(($823)|0);
var $825=HEAPF32[(($824)>>2)];
var $826=(($p)|0);
var $827=(($826+4)|0);
var $828=HEAPF32[(($827)>>2)];
var $829=$4;
var $830=($829)*(-1);
var $831=$830;
var $832=($831)*(0.5);
var $833=$832;
var $834=(($normal)|0);
var $835=_vert($822, $825, $828, $833, $834);
$v=$835;
var $836=$v;
var $837=(($p)|0);
var $838=(($837)|0);
var $839=HEAPF32[(($838)>>2)];
var $840=(($p)|0);
var $841=(($840+4)|0);
var $842=HEAPF32[(($841)>>2)];
var $843=$4;
var $844=$843;
var $845=$844;
var $846=($845)*(0.5);
var $847=$846;
var $848=(($normal)|0);
var $849=_vert($836, $839, $842, $847, $848);
$v=$849;
label = 40; break;
case 40:
label = 41; break;
case 41:
var $852=$v;
var $853=$gear;
var $854=(($853)|0);
var $855=HEAP32[(($854)>>2)];
var $856=$852;
var $857=$855;
var $858=((($856)-($857))|0);
var $859=((((($858)|(0)))/(24))&-1);
$_tmp4=$859;
var $860=$_tmp4;
var $861=$cur_strip;
var $862=$gear;
var $863=(($862+8)|0);
var $864=HEAP32[(($863)>>2)];
var $865=(($864+($861<<3))|0);
var $866=(($865)|0);
var $867=HEAP32[(($866)>>2)];
var $868=((($860)-($867))|0);
var $869=$cur_strip;
var $870=$gear;
var $871=(($870+8)|0);
var $872=HEAP32[(($871)>>2)];
var $873=(($872+($869<<3))|0);
var $874=(($873+4)|0);
HEAP32[(($874)>>2)]=$868;
var $875=$cur_strip;
var $876=((($875)+(1))|0);
$cur_strip=$876;
label = 42; break;
case 42:
label = 43; break;
case 43:
var $879=$v;
var $880=$gear;
var $881=(($880)|0);
var $882=HEAP32[(($881)>>2)];
var $883=$879;
var $884=$882;
var $885=((($883)-($884))|0);
var $886=((((($885)|(0)))/(24))&-1);
var $887=$cur_strip;
var $888=$gear;
var $889=(($888+8)|0);
var $890=HEAP32[(($889)>>2)];
var $891=(($890+($887<<3))|0);
var $892=(($891)|0);
HEAP32[(($892)>>2)]=$886;
label = 44; break;
case 44:
label = 45; break;
case 45:
label = 46; break;
case 46:
var $896=(($p+24)|0);
var $897=(($896+4)|0);
var $898=HEAPF32[(($897)>>2)];
var $899=(($p+8)|0);
var $900=(($899+4)|0);
var $901=HEAPF32[(($900)>>2)];
var $902=($898)-($901);
var $903=(($normal)|0);
HEAPF32[(($903)>>2)]=$902;
var $904=(($p+24)|0);
var $905=(($904)|0);
var $906=HEAPF32[(($905)>>2)];
var $907=(($p+8)|0);
var $908=(($907)|0);
var $909=HEAPF32[(($908)>>2)];
var $910=($906)-($909);
var $911=(-$910);
var $912=(($normal+4)|0);
HEAPF32[(($912)>>2)]=$911;
var $913=(($normal+8)|0);
HEAPF32[(($913)>>2)]=0;
label = 47; break;
case 47:
var $915=$v;
var $916=(($p+24)|0);
var $917=(($916)|0);
var $918=HEAPF32[(($917)>>2)];
var $919=(($p+24)|0);
var $920=(($919+4)|0);
var $921=HEAPF32[(($920)>>2)];
var $922=$4;
var $923=($922)*(-1);
var $924=$923;
var $925=($924)*(0.5);
var $926=$925;
var $927=(($normal)|0);
var $928=_vert($915, $918, $921, $926, $927);
$v=$928;
var $929=$v;
var $930=(($p+24)|0);
var $931=(($930)|0);
var $932=HEAPF32[(($931)>>2)];
var $933=(($p+24)|0);
var $934=(($933+4)|0);
var $935=HEAPF32[(($934)>>2)];
var $936=$4;
var $937=$936;
var $938=$937;
var $939=($938)*(0.5);
var $940=$939;
var $941=(($normal)|0);
var $942=_vert($929, $932, $935, $940, $941);
$v=$942;
var $943=$v;
var $944=(($p+8)|0);
var $945=(($944)|0);
var $946=HEAPF32[(($945)>>2)];
var $947=(($p+8)|0);
var $948=(($947+4)|0);
var $949=HEAPF32[(($948)>>2)];
var $950=$4;
var $951=($950)*(-1);
var $952=$951;
var $953=($952)*(0.5);
var $954=$953;
var $955=(($normal)|0);
var $956=_vert($943, $946, $949, $954, $955);
$v=$956;
var $957=$v;
var $958=(($p+8)|0);
var $959=(($958)|0);
var $960=HEAPF32[(($959)>>2)];
var $961=(($p+8)|0);
var $962=(($961+4)|0);
var $963=HEAPF32[(($962)>>2)];
var $964=$4;
var $965=$964;
var $966=$965;
var $967=($966)*(0.5);
var $968=$967;
var $969=(($normal)|0);
var $970=_vert($957, $960, $963, $968, $969);
$v=$970;
label = 48; break;
case 48:
label = 49; break;
case 49:
var $973=$v;
var $974=$gear;
var $975=(($974)|0);
var $976=HEAP32[(($975)>>2)];
var $977=$973;
var $978=$976;
var $979=((($977)-($978))|0);
var $980=((((($979)|(0)))/(24))&-1);
$_tmp5=$980;
var $981=$_tmp5;
var $982=$cur_strip;
var $983=$gear;
var $984=(($983+8)|0);
var $985=HEAP32[(($984)>>2)];
var $986=(($985+($982<<3))|0);
var $987=(($986)|0);
var $988=HEAP32[(($987)>>2)];
var $989=((($981)-($988))|0);
var $990=$cur_strip;
var $991=$gear;
var $992=(($991+8)|0);
var $993=HEAP32[(($992)>>2)];
var $994=(($993+($990<<3))|0);
var $995=(($994+4)|0);
HEAP32[(($995)>>2)]=$989;
var $996=$cur_strip;
var $997=((($996)+(1))|0);
$cur_strip=$997;
label = 50; break;
case 50:
label = 51; break;
case 51:
var $1000=$v;
var $1001=$gear;
var $1002=(($1001)|0);
var $1003=HEAP32[(($1002)>>2)];
var $1004=$1000;
var $1005=$1003;
var $1006=((($1004)-($1005))|0);
var $1007=((((($1006)|(0)))/(24))&-1);
var $1008=$cur_strip;
var $1009=$gear;
var $1010=(($1009+8)|0);
var $1011=HEAP32[(($1010)>>2)];
var $1012=(($1011+($1008<<3))|0);
var $1013=(($1012)|0);
HEAP32[(($1013)>>2)]=$1007;
label = 52; break;
case 52:
label = 53; break;
case 53:
label = 54; break;
case 54:
var $1017=(($p+40)|0);
var $1018=(($1017+4)|0);
var $1019=HEAPF32[(($1018)>>2)];
var $1020=(($p+24)|0);
var $1021=(($1020+4)|0);
var $1022=HEAPF32[(($1021)>>2)];
var $1023=($1019)-($1022);
var $1024=(($normal)|0);
HEAPF32[(($1024)>>2)]=$1023;
var $1025=(($p+40)|0);
var $1026=(($1025)|0);
var $1027=HEAPF32[(($1026)>>2)];
var $1028=(($p+24)|0);
var $1029=(($1028)|0);
var $1030=HEAPF32[(($1029)>>2)];
var $1031=($1027)-($1030);
var $1032=(-$1031);
var $1033=(($normal+4)|0);
HEAPF32[(($1033)>>2)]=$1032;
var $1034=(($normal+8)|0);
HEAPF32[(($1034)>>2)]=0;
label = 55; break;
case 55:
var $1036=$v;
var $1037=(($p+40)|0);
var $1038=(($1037)|0);
var $1039=HEAPF32[(($1038)>>2)];
var $1040=(($p+40)|0);
var $1041=(($1040+4)|0);
var $1042=HEAPF32[(($1041)>>2)];
var $1043=$4;
var $1044=($1043)*(-1);
var $1045=$1044;
var $1046=($1045)*(0.5);
var $1047=$1046;
var $1048=(($normal)|0);
var $1049=_vert($1036, $1039, $1042, $1047, $1048);
$v=$1049;
var $1050=$v;
var $1051=(($p+40)|0);
var $1052=(($1051)|0);
var $1053=HEAPF32[(($1052)>>2)];
var $1054=(($p+40)|0);
var $1055=(($1054+4)|0);
var $1056=HEAPF32[(($1055)>>2)];
var $1057=$4;
var $1058=$1057;
var $1059=$1058;
var $1060=($1059)*(0.5);
var $1061=$1060;
var $1062=(($normal)|0);
var $1063=_vert($1050, $1053, $1056, $1061, $1062);
$v=$1063;
var $1064=$v;
var $1065=(($p+24)|0);
var $1066=(($1065)|0);
var $1067=HEAPF32[(($1066)>>2)];
var $1068=(($p+24)|0);
var $1069=(($1068+4)|0);
var $1070=HEAPF32[(($1069)>>2)];
var $1071=$4;
var $1072=($1071)*(-1);
var $1073=$1072;
var $1074=($1073)*(0.5);
var $1075=$1074;
var $1076=(($normal)|0);
var $1077=_vert($1064, $1067, $1070, $1075, $1076);
$v=$1077;
var $1078=$v;
var $1079=(($p+24)|0);
var $1080=(($1079)|0);
var $1081=HEAPF32[(($1080)>>2)];
var $1082=(($p+24)|0);
var $1083=(($1082+4)|0);
var $1084=HEAPF32[(($1083)>>2)];
var $1085=$4;
var $1086=$1085;
var $1087=$1086;
var $1088=($1087)*(0.5);
var $1089=$1088;
var $1090=(($normal)|0);
var $1091=_vert($1078, $1081, $1084, $1089, $1090);
$v=$1091;
label = 56; break;
case 56:
label = 57; break;
case 57:
var $1094=$v;
var $1095=$gear;
var $1096=(($1095)|0);
var $1097=HEAP32[(($1096)>>2)];
var $1098=$1094;
var $1099=$1097;
var $1100=((($1098)-($1099))|0);
var $1101=((((($1100)|(0)))/(24))&-1);
$_tmp6=$1101;
var $1102=$_tmp6;
var $1103=$cur_strip;
var $1104=$gear;
var $1105=(($1104+8)|0);
var $1106=HEAP32[(($1105)>>2)];
var $1107=(($1106+($1103<<3))|0);
var $1108=(($1107)|0);
var $1109=HEAP32[(($1108)>>2)];
var $1110=((($1102)-($1109))|0);
var $1111=$cur_strip;
var $1112=$gear;
var $1113=(($1112+8)|0);
var $1114=HEAP32[(($1113)>>2)];
var $1115=(($1114+($1111<<3))|0);
var $1116=(($1115+4)|0);
HEAP32[(($1116)>>2)]=$1110;
var $1117=$cur_strip;
var $1118=((($1117)+(1))|0);
$cur_strip=$1118;
label = 58; break;
case 58:
label = 59; break;
case 59:
var $1121=$i;
var $1122=((($1121)+(1))|0);
$i=$1122;
label = 5; break;
case 60:
var $1124=$v;
var $1125=$gear;
var $1126=(($1125)|0);
var $1127=HEAP32[(($1126)>>2)];
var $1128=$1124;
var $1129=$1127;
var $1130=((($1128)-($1129))|0);
var $1131=((((($1130)|(0)))/(24))&-1);
var $1132=$gear;
var $1133=(($1132+4)|0);
HEAP32[(($1133)>>2)]=$1131;
var $1134=$gear;
var $1135=(($1134+16)|0);
_glGenBuffers(1, $1135);
var $1136=$gear;
var $1137=(($1136+16)|0);
var $1138=HEAP32[(($1137)>>2)];
_glBindBuffer(34962, $1138);
var $1139=$gear;
var $1140=(($1139+4)|0);
var $1141=HEAP32[(($1140)>>2)];
var $1142=((($1141)*(24))&-1);
var $1143=$gear;
var $1144=(($1143)|0);
var $1145=HEAP32[(($1144)>>2)];
var $1146=$1145;
_glBufferData(34962, $1142, $1146, 35044);
var $1147=$gear;
$1=$1147;
label = 61; break;
case 61:
var $1149=$1;
STACKTOP = __stackBase__;
return $1149;
default: assert(0, "bad label: " + label);
}
}
function _vert($v, $x, $y, $z, $n) {
var label = 0;
var $1;
var $2;
var $3;
var $4;
var $5;
$1=$v;
$2=$x;
$3=$y;
$4=$z;
$5=$n;
var $6=$2;
var $7=$1;
var $8=(($7)|0);
var $9=(($8)|0);
HEAPF32[(($9)>>2)]=$6;
var $10=$3;
var $11=$1;
var $12=(($11)|0);
var $13=(($12+4)|0);
HEAPF32[(($13)>>2)]=$10;
var $14=$4;
var $15=$1;
var $16=(($15)|0);
var $17=(($16+8)|0);
HEAPF32[(($17)>>2)]=$14;
var $18=$5;
var $19=(($18)|0);
var $20=HEAPF32[(($19)>>2)];
var $21=$1;
var $22=(($21)|0);
var $23=(($22+12)|0);
HEAPF32[(($23)>>2)]=$20;
var $24=$5;
var $25=(($24+4)|0);
var $26=HEAPF32[(($25)>>2)];
var $27=$1;
var $28=(($27)|0);
var $29=(($28+16)|0);
HEAPF32[(($29)>>2)]=$26;
var $30=$5;
var $31=(($30+8)|0);
var $32=HEAPF32[(($31)>>2)];
var $33=$1;
var $34=(($33)|0);
var $35=(($34+20)|0);
HEAPF32[(($35)>>2)]=$32;
var $36=$1;
var $37=(($36+24)|0);
return $37;
}
function _translate($m, $x, $y, $z) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 64)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $1;
var $2;
var $3;
var $4;
var $t=__stackBase__;
$1=$m;
$2=$x;
$3=$y;
$4=$z;
var $5=(($t)|0);
HEAPF32[(($5)>>2)]=1;
var $6=(($5+4)|0);
HEAPF32[(($6)>>2)]=0;
var $7=(($6+4)|0);
HEAPF32[(($7)>>2)]=0;
var $8=(($7+4)|0);
HEAPF32[(($8)>>2)]=0;
var $9=(($8+4)|0);
HEAPF32[(($9)>>2)]=0;
var $10=(($9+4)|0);
HEAPF32[(($10)>>2)]=1;
var $11=(($10+4)|0);
HEAPF32[(($11)>>2)]=0;
var $12=(($11+4)|0);
HEAPF32[(($12)>>2)]=0;
var $13=(($12+4)|0);
HEAPF32[(($13)>>2)]=0;
var $14=(($13+4)|0);
HEAPF32[(($14)>>2)]=0;
var $15=(($14+4)|0);
HEAPF32[(($15)>>2)]=1;
var $16=(($15+4)|0);
HEAPF32[(($16)>>2)]=0;
var $17=(($16+4)|0);
var $18=$2;
HEAPF32[(($17)>>2)]=$18;
var $19=(($17+4)|0);
var $20=$3;
HEAPF32[(($19)>>2)]=$20;
var $21=(($19+4)|0);
var $22=$4;
HEAPF32[(($21)>>2)]=$22;
var $23=(($21+4)|0);
HEAPF32[(($23)>>2)]=1;
var $24=$1;
var $25=(($t)|0);
_multiply($24, $25);
STACKTOP = __stackBase__;
return;
}
function _rotate($m, $angle, $x, $y, $z) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 80)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $1;
var $2;
var $3;
var $4;
var $5;
var $s=__stackBase__;
var $c=(__stackBase__)+(8);
var $r=(__stackBase__)+(16);
$1=$m;
$2=$angle;
$3=$x;
$4=$y;
$5=$z;
var $6=$2;
var $7=$6;
__sincos($7, $s, $c);
var $8=(($r)|0);
var $9=$3;
var $10=$3;
var $11=($9)*($10);
var $12=$11;
var $13=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $14=(1)-($13);
var $15=($12)*($14);
var $16=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $17=($15)+($16);
var $18=$17;
HEAPF32[(($8)>>2)]=$18;
var $19=(($8+4)|0);
var $20=$4;
var $21=$3;
var $22=($20)*($21);
var $23=$22;
var $24=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $25=(1)-($24);
var $26=($23)*($25);
var $27=$5;
var $28=$27;
var $29=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($s)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($s)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $30=($28)*($29);
var $31=($26)+($30);
var $32=$31;
HEAPF32[(($19)>>2)]=$32;
var $33=(($19+4)|0);
var $34=$3;
var $35=$5;
var $36=($34)*($35);
var $37=$36;
var $38=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $39=(1)-($38);
var $40=($37)*($39);
var $41=$4;
var $42=$41;
var $43=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($s)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($s)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $44=($42)*($43);
var $45=($40)-($44);
var $46=$45;
HEAPF32[(($33)>>2)]=$46;
var $47=(($33+4)|0);
HEAPF32[(($47)>>2)]=0;
var $48=(($47+4)|0);
var $49=$3;
var $50=$4;
var $51=($49)*($50);
var $52=$51;
var $53=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $54=(1)-($53);
var $55=($52)*($54);
var $56=$5;
var $57=$56;
var $58=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($s)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($s)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $59=($57)*($58);
var $60=($55)-($59);
var $61=$60;
HEAPF32[(($48)>>2)]=$61;
var $62=(($48+4)|0);
var $63=$4;
var $64=$4;
var $65=($63)*($64);
var $66=$65;
var $67=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $68=(1)-($67);
var $69=($66)*($68);
var $70=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $71=($69)+($70);
var $72=$71;
HEAPF32[(($62)>>2)]=$72;
var $73=(($62+4)|0);
var $74=$4;
var $75=$5;
var $76=($74)*($75);
var $77=$76;
var $78=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $79=(1)-($78);
var $80=($77)*($79);
var $81=$3;
var $82=$81;
var $83=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($s)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($s)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $84=($82)*($83);
var $85=($80)+($84);
var $86=$85;
HEAPF32[(($73)>>2)]=$86;
var $87=(($73+4)|0);
HEAPF32[(($87)>>2)]=0;
var $88=(($87+4)|0);
var $89=$3;
var $90=$5;
var $91=($89)*($90);
var $92=$91;
var $93=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $94=(1)-($93);
var $95=($92)*($94);
var $96=$4;
var $97=$96;
var $98=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($s)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($s)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $99=($97)*($98);
var $100=($95)+($99);
var $101=$100;
HEAPF32[(($88)>>2)]=$101;
var $102=(($88+4)|0);
var $103=$4;
var $104=$5;
var $105=($103)*($104);
var $106=$105;
var $107=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $108=(1)-($107);
var $109=($106)*($108);
var $110=$3;
var $111=$110;
var $112=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($s)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($s)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $113=($111)*($112);
var $114=($109)-($113);
var $115=$114;
HEAPF32[(($102)>>2)]=$115;
var $116=(($102+4)|0);
var $117=$5;
var $118=$5;
var $119=($117)*($118);
var $120=$119;
var $121=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $122=(1)-($121);
var $123=($120)*($122);
var $124=(HEAP32[((tempDoublePtr)>>2)]=HEAP32[(($c)>>2)],HEAP32[(((tempDoublePtr)+(4))>>2)]=HEAP32[((($c)+(4))>>2)],HEAPF64[(tempDoublePtr)>>3]);
var $125=($123)+($124);
var $126=$125;
HEAPF32[(($116)>>2)]=$126;
var $127=(($116+4)|0);
HEAPF32[(($127)>>2)]=0;
var $128=(($127+4)|0);
HEAPF32[(($128)>>2)]=0;
var $129=(($128+4)|0);
HEAPF32[(($129)>>2)]=0;
var $130=(($129+4)|0);
HEAPF32[(($130)>>2)]=0;
var $131=(($130+4)|0);
HEAPF32[(($131)>>2)]=1;
var $132=$1;
var $133=(($r)|0);
_multiply($132, $133);
STACKTOP = __stackBase__;
return;
}
function _draw_gear($gear, $transform, $x, $y, $angle, $color) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 192)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $4;
var $5;
var $6;
var $model_view=__stackBase__;
var $normal_matrix=(__stackBase__)+(64);
var $model_view_projection=(__stackBase__)+(128);
var $n;
$1=$gear;
$2=$transform;
$3=$x;
$4=$y;
$5=$angle;
$6=$color;
var $7=$model_view;
var $8=$2;
var $9=$8;
assert(64 % 1 === 0);_memcpy($7, $9, 64);
var $10=(($model_view)|0);
var $11=$3;
var $12=$4;
_translate($10, $11, $12, 0);
var $13=(($model_view)|0);
var $14=$5;
var $15=$14;
var $16=($15)*(6.283185307179586);
var $17=($16)/(360);
var $18=$17;
_rotate($13, $18, 0, 0, 1);
var $19=$model_view_projection;
assert(64 % 1 === 0);_memcpy($19, 5244616, 64);
var $20=(($model_view_projection)|0);
var $21=(($model_view)|0);
_multiply($20, $21);
var $22=HEAP32[((5244684)>>2)];
var $23=(($model_view_projection)|0);
_glUniformMatrix4fv($22, 1, 0, $23);
var $24=$normal_matrix;
var $25=$model_view;
assert(64 % 1 === 0);_memcpy($24, $25, 64);
var $26=(($normal_matrix)|0);
_invert($26);
var $27=(($normal_matrix)|0);
_transpose($27);
var $28=HEAP32[((5244680)>>2)];
var $29=(($normal_matrix)|0);
_glUniformMatrix4fv($28, 1, 0, $29);
var $30=HEAP32[((5244688)>>2)];
var $31=$6;
_glUniform4fv($30, 1, $31);
var $32=$1;
var $33=(($32+16)|0);
var $34=HEAP32[(($33)>>2)];
_glBindBuffer(34962, $34);
_glVertexAttribPointer(0, 3, 5126, 0, 24, 0);
_glVertexAttribPointer(1, 3, 5126, 0, 24, (((12)|0)));
_glEnableVertexAttribArray(0);
_glEnableVertexAttribArray(1);
$n=0;
label = 3; break;
case 3:
var $36=$n;
var $37=$1;
var $38=(($37+12)|0);
var $39=HEAP32[(($38)>>2)];
var $40=(($36)|(0)) < (($39)|(0));
if ($40) { label = 4; break; } else { label = 6; break; }
case 4:
var $42=$n;
var $43=$1;
var $44=(($43+8)|0);
var $45=HEAP32[(($44)>>2)];
var $46=(($45+($42<<3))|0);
var $47=(($46)|0);
var $48=HEAP32[(($47)>>2)];
var $49=$n;
var $50=$1;
var $51=(($50+8)|0);
var $52=HEAP32[(($51)>>2)];
var $53=(($52+($49<<3))|0);
var $54=(($53+4)|0);
var $55=HEAP32[(($54)>>2)];
_glDrawArrays(5, $48, $55);
label = 5; break;
case 5:
var $57=$n;
var $58=((($57)+(1))|0);
$n=$58;
label = 3; break;
case 6:
_glDisableVertexAttribArray(1);
_glDisableVertexAttribArray(0);
STACKTOP = __stackBase__;
return;
default: assert(0, "bad label: " + label);
}
}
function _multiply($m, $n) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 80)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $tmp=__stackBase__;
var $row;
var $column;
var $d=(__stackBase__)+(64);
var $i;
var $j;
var $3=(__stackBase__)+(72);
$1=$m;
$2=$n;
$i=0;
label = 3; break;
case 3:
var $5=$i;
var $6=(($5)|(0)) < 16;
if ($6) { label = 4; break; } else { label = 10; break; }
case 4:
var $8=$i;
var $9=(($tmp+($8<<2))|0);
HEAPF32[(($9)>>2)]=0;
var $10=$i;
_div($3, $10, 4);
var $11=$d;
var $12=$3;
assert(8 % 1 === 0);HEAP32[(($11)>>2)]=HEAP32[(($12)>>2)];HEAP32[((($11)+(4))>>2)]=HEAP32[((($12)+(4))>>2)];
var $13=$2;
var $14=(($d)|0);
var $15=HEAP32[(($14)>>2)];
var $16=($15<<2);
var $17=(($13+($16<<2))|0);
$row=$17;
var $18=$1;
var $19=(($d+4)|0);
var $20=HEAP32[(($19)>>2)];
var $21=(($18+($20<<2))|0);
$column=$21;
$j=0;
label = 5; break;
case 5:
var $23=$j;
var $24=(($23)|(0)) < 4;
if ($24) { label = 6; break; } else { label = 8; break; }
case 6:
var $26=$j;
var $27=$row;
var $28=(($27+($26<<2))|0);
var $29=HEAPF32[(($28)>>2)];
var $30=$j;
var $31=($30<<2);
var $32=$column;
var $33=(($32+($31<<2))|0);
var $34=HEAPF32[(($33)>>2)];
var $35=($29)*($34);
var $36=$i;
var $37=(($tmp+($36<<2))|0);
var $38=HEAPF32[(($37)>>2)];
var $39=($38)+($35);
HEAPF32[(($37)>>2)]=$39;
label = 7; break;
case 7:
var $41=$j;
var $42=((($41)+(1))|0);
$j=$42;
label = 5; break;
case 8:
label = 9; break;
case 9:
var $45=$i;
var $46=((($45)+(1))|0);
$i=$46;
label = 3; break;
case 10:
var $48=$1;
var $49=$48;
var $50=$tmp;
assert(64 % 1 === 0);_memcpy($49, $50, 64);
STACKTOP = __stackBase__;
return;
default: assert(0, "bad label: " + label);
}
}
function _invert($m) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 64)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $1;
var $t=__stackBase__;
$1=$m;
var $2=(($t)|0);
_identity($2);
var $3=$1;
var $4=(($3+48)|0);
var $5=HEAPF32[(($4)>>2)];
var $6=(-$5);
var $7=(($t+48)|0);
HEAPF32[(($7)>>2)]=$6;
var $8=$1;
var $9=(($8+52)|0);
var $10=HEAPF32[(($9)>>2)];
var $11=(-$10);
var $12=(($t+52)|0);
HEAPF32[(($12)>>2)]=$11;
var $13=$1;
var $14=(($13+56)|0);
var $15=HEAPF32[(($14)>>2)];
var $16=(-$15);
var $17=(($t+56)|0);
HEAPF32[(($17)>>2)]=$16;
var $18=$1;
var $19=(($18+56)|0);
HEAPF32[(($19)>>2)]=0;
var $20=$1;
var $21=(($20+52)|0);
HEAPF32[(($21)>>2)]=0;
var $22=$1;
var $23=(($22+48)|0);
HEAPF32[(($23)>>2)]=0;
var $24=$1;
_transpose($24);
var $25=$1;
var $26=(($t)|0);
_multiply($25, $26);
STACKTOP = __stackBase__;
return;
}
function _transpose($m) {
var label = 0;
var __stackBase__ = STACKTOP; STACKTOP = (STACKTOP + 64)|0; assert(!(STACKTOP&3)); assert((STACKTOP|0) < (STACK_MAX|0));
var $1;
var $t=__stackBase__;
$1=$m;
var $2=(($t)|0);
var $3=$1;
var $4=(($3)|0);
var $5=HEAPF32[(($4)>>2)];
HEAPF32[(($2)>>2)]=$5;
var $6=(($2+4)|0);
var $7=$1;
var $8=(($7+16)|0);
var $9=HEAPF32[(($8)>>2)];
HEAPF32[(($6)>>2)]=$9;
var $10=(($6+4)|0);
var $11=$1;
var $12=(($11+32)|0);
var $13=HEAPF32[(($12)>>2)];
HEAPF32[(($10)>>2)]=$13;
var $14=(($10+4)|0);
var $15=$1;
var $16=(($15+48)|0);
var $17=HEAPF32[(($16)>>2)];
HEAPF32[(($14)>>2)]=$17;
var $18=(($14+4)|0);
var $19=$1;
var $20=(($19+4)|0);
var $21=HEAPF32[(($20)>>2)];
HEAPF32[(($18)>>2)]=$21;
var $22=(($18+4)|0);
var $23=$1;
var $24=(($23+20)|0);
var $25=HEAPF32[(($24)>>2)];
HEAPF32[(($22)>>2)]=$25;
var $26=(($22+4)|0);
var $27=$1;
var $28=(($27+36)|0);
var $29=HEAPF32[(($28)>>2)];
HEAPF32[(($26)>>2)]=$29;
var $30=(($26+4)|0);
var $31=$1;
var $32=(($31+52)|0);
var $33=HEAPF32[(($32)>>2)];
HEAPF32[(($30)>>2)]=$33;
var $34=(($30+4)|0);
var $35=$1;
var $36=(($35+8)|0);
var $37=HEAPF32[(($36)>>2)];
HEAPF32[(($34)>>2)]=$37;
var $38=(($34+4)|0);
var $39=$1;
var $40=(($39+24)|0);
var $41=HEAPF32[(($40)>>2)];
HEAPF32[(($38)>>2)]=$41;
var $42=(($38+4)|0);
var $43=$1;
var $44=(($43+40)|0);
var $45=HEAPF32[(($44)>>2)];
HEAPF32[(($42)>>2)]=$45;
var $46=(($42+4)|0);
var $47=$1;
var $48=(($47+56)|0);
var $49=HEAPF32[(($48)>>2)];
HEAPF32[(($46)>>2)]=$49;
var $50=(($46+4)|0);
var $51=$1;
var $52=(($51+12)|0);
var $53=HEAPF32[(($52)>>2)];
HEAPF32[(($50)>>2)]=$53;
var $54=(($50+4)|0);
var $55=$1;
var $56=(($55+28)|0);
var $57=HEAPF32[(($56)>>2)];
HEAPF32[(($54)>>2)]=$57;
var $58=(($54+4)|0);
var $59=$1;
var $60=(($59+44)|0);
var $61=HEAPF32[(($60)>>2)];
HEAPF32[(($58)>>2)]=$61;
var $62=(($58+4)|0);
var $63=$1;
var $64=(($63+60)|0);
var $65=HEAPF32[(($64)>>2)];
HEAPF32[(($62)>>2)]=$65;
var $66=$1;
var $67=$66;
var $68=$t;
assert(64 % 1 === 0);_memcpy($67, $68, 64);
STACKTOP = __stackBase__;
return;
}
function _malloc($bytes) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $mem;
var $nb;
var $idx;
var $smallbits;
var $b;
var $p;
var $F;
var $b1;
var $p2;
var $r;
var $rsize;
var $i;
var $leftbits;
var $leastbit;
var $Y;
var $K;
var $N;
var $F3;
var $DVS;
var $DV;
var $I;
var $B;
var $F4;
var $rsize5;
var $p6;
var $r7;
var $dvs;
var $rsize8;
var $p9;
var $r10;
$1=$bytes;
var $2=$1;
var $3=(($2)>>>(0)) <= 244;
if ($3) { label = 3; break; } else { label = 42; break; }
case 3:
var $5=$1;
var $6=(($5)>>>(0)) < 11;
if ($6) { label = 4; break; } else { label = 5; break; }
case 4:
var $14 = 16;label = 6; break;
case 5:
var $9=$1;
var $10=((($9)+(4))|0);
var $11=((($10)+(7))|0);
var $12=$11 & -8;
var $14 = $12;label = 6; break;
case 6:
var $14;
$nb=$14;
var $15=$nb;
var $16=$15 >>> 3;
$idx=$16;
var $17=HEAP32[((((5244144)|0))>>2)];
var $18=$idx;
var $19=$17 >>> (($18)>>>(0));
$smallbits=$19;
var $20=$smallbits;
var $21=$20 & 3;
var $22=(($21)|(0))!=0;
if ($22) { label = 7; break; } else { label = 16; break; }
case 7:
var $24=$smallbits;
var $25=$24 ^ -1;
var $26=$25 & 1;
var $27=$idx;
var $28=((($27)+($26))|0);
$idx=$28;
var $29=$idx;
var $30=$29 << 1;
var $31=((((5244184)|0)+($30<<2))|0);
var $32=$31;
var $33=$32;
$b=$33;
var $34=$b;
var $35=(($34+8)|0);
var $36=HEAP32[(($35)>>2)];
$p=$36;
var $37=$p;
var $38=(($37+8)|0);
var $39=HEAP32[(($38)>>2)];
$F=$39;
var $40=$b;
var $41=$F;
var $42=(($40)|(0))==(($41)|(0));
if ($42) { label = 8; break; } else { label = 9; break; }
case 8:
var $44=$idx;
var $45=1 << $44;
var $46=$45 ^ -1;
var $47=HEAP32[((((5244144)|0))>>2)];
var $48=$47 & $46;
HEAP32[((((5244144)|0))>>2)]=$48;
label = 15; break;
case 9:
var $50=$F;
var $51=$50;
var $52=HEAP32[((((5244160)|0))>>2)];
var $53=(($51)>>>(0)) >= (($52)>>>(0));
if ($53) { label = 10; break; } else { var $61 = 0;label = 11; break; }
case 10:
var $55=$F;
var $56=(($55+12)|0);
var $57=HEAP32[(($56)>>2)];
var $58=$p;
var $59=(($57)|(0))==(($58)|(0));
var $61 = $59;label = 11; break;
case 11:
var $61;
var $62=(($61)&(1));
var $63=($62);
var $64=(($63)|(0))!=0;
if ($64) { label = 12; break; } else { label = 13; break; }
case 12:
var $66=$b;
var $67=$F;
var $68=(($67+12)|0);
HEAP32[(($68)>>2)]=$66;
var $69=$F;
var $70=$b;
var $71=(($70+8)|0);
HEAP32[(($71)>>2)]=$69;
label = 14; break;
case 13:
_abort();
throw "Reached an unreachable!"
case 14:
label = 15; break;
case 15:
var $75=$idx;
var $76=$75 << 3;
var $77=$76 | 1;
var $78=$77 | 2;
var $79=$p;
var $80=(($79+4)|0);
HEAP32[(($80)>>2)]=$78;
var $81=$p;
var $82=$81;
var $83=$idx;
var $84=$83 << 3;
var $85=(($82+$84)|0);
var $86=$85;
var $87=(($86+4)|0);
var $88=HEAP32[(($87)>>2)];
var $89=$88 | 1;
HEAP32[(($87)>>2)]=$89;
var $90=$p;
var $91=$90;
var $92=(($91+8)|0);
$mem=$92;
label = 58; break;
case 16:
var $94=$nb;
var $95=HEAP32[((((5244152)|0))>>2)];
var $96=(($94)>>>(0)) > (($95)>>>(0));
if ($96) { label = 17; break; } else { label = 40; break; }
case 17:
var $98=$smallbits;
var $99=(($98)|(0))!=0;
if ($99) { label = 18; break; } else { label = 35; break; }
case 18:
var $101=$smallbits;
var $102=$idx;
var $103=$101 << $102;
var $104=$idx;
var $105=1 << $104;
var $106=$105 << 1;
var $107=$idx;
var $108=1 << $107;
var $109=$108 << 1;
var $110=(((-$109))|0);
var $111=$106 | $110;
var $112=$103 & $111;
$leftbits=$112;
var $113=$leftbits;
var $114=$leftbits;
var $115=(((-$114))|0);
var $116=$113 & $115;
$leastbit=$116;
var $117=$leastbit;
var $118=((($117)-(1))|0);
$Y=$118;
var $119=$Y;
var $120=$119 >>> 12;
var $121=$120 & 16;
$K=$121;
var $122=$K;
$N=$122;
var $123=$K;
var $124=$Y;
var $125=$124 >>> (($123)>>>(0));
$Y=$125;
var $126=$Y;
var $127=$126 >>> 5;
var $128=$127 & 8;
$K=$128;
var $129=$N;
var $130=((($129)+($128))|0);
$N=$130;
var $131=$K;
var $132=$Y;
var $133=$132 >>> (($131)>>>(0));
$Y=$133;
var $134=$Y;
var $135=$134 >>> 2;
var $136=$135 & 4;
$K=$136;
var $137=$N;
var $138=((($137)+($136))|0);
$N=$138;
var $139=$K;
var $140=$Y;
var $141=$140 >>> (($139)>>>(0));
$Y=$141;
var $142=$Y;
var $143=$142 >>> 1;
var $144=$143 & 2;
$K=$144;
var $145=$N;
var $146=((($145)+($144))|0);
$N=$146;
var $147=$K;
var $148=$Y;
var $149=$148 >>> (($147)>>>(0));
$Y=$149;
var $150=$Y;
var $151=$150 >>> 1;
var $152=$151 & 1;
$K=$152;
var $153=$N;
var $154=((($153)+($152))|0);
$N=$154;
var $155=$K;
var $156=$Y;
var $157=$156 >>> (($155)>>>(0));
$Y=$157;
var $158=$N;
var $159=$Y;
var $160=((($158)+($159))|0);
$i=$160;
var $161=$i;
var $162=$161 << 1;
var $163=((((5244184)|0)+($162<<2))|0);
var $164=$163;
var $165=$164;
$b1=$165;
var $166=$b1;
var $167=(($166+8)|0);
var $168=HEAP32[(($167)>>2)];
$p2=$168;
var $169=$p2;
var $170=(($169+8)|0);
var $171=HEAP32[(($170)>>2)];
$F3=$171;
var $172=$b1;
var $173=$F3;
var $174=(($172)|(0))==(($173)|(0));
if ($174) { label = 19; break; } else { label = 20; break; }
case 19:
var $176=$i;
var $177=1 << $176;
var $178=$177 ^ -1;
var $179=HEAP32[((((5244144)|0))>>2)];
var $180=$179 & $178;
HEAP32[((((5244144)|0))>>2)]=$180;
label = 26; break;
case 20:
var $182=$F3;
var $183=$182;
var $184=HEAP32[((((5244160)|0))>>2)];
var $185=(($183)>>>(0)) >= (($184)>>>(0));
if ($185) { label = 21; break; } else { var $193 = 0;label = 22; break; }
case 21:
var $187=$F3;
var $188=(($187+12)|0);
var $189=HEAP32[(($188)>>2)];
var $190=$p2;
var $191=(($189)|(0))==(($190)|(0));
var $193 = $191;label = 22; break;
case 22:
var $193;
var $194=(($193)&(1));
var $195=($194);
var $196=(($195)|(0))!=0;
if ($196) { label = 23; break; } else { label = 24; break; }
case 23:
var $198=$b1;
var $199=$F3;
var $200=(($199+12)|0);
HEAP32[(($200)>>2)]=$198;
var $201=$F3;
var $202=$b1;
var $203=(($202+8)|0);
HEAP32[(($203)>>2)]=$201;
label = 25; break;
case 24:
_abort();
throw "Reached an unreachable!"
case 25:
label = 26; break;
case 26:
var $207=$i;
var $208=$207 << 3;
var $209=$nb;
var $210=((($208)-($209))|0);
$rsize=$210;
var $211=$nb;
var $212=$211 | 1;
var $213=$212 | 2;
var $214=$p2;
var $215=(($214+4)|0);
HEAP32[(($215)>>2)]=$213;
var $216=$p2;
var $217=$216;
var $218=$nb;
var $219=(($217+$218)|0);
var $220=$219;
$r=$220;
var $221=$rsize;
var $222=$221 | 1;
var $223=$r;
var $224=(($223+4)|0);
HEAP32[(($224)>>2)]=$222;
var $225=$rsize;
var $226=$r;
var $227=$226;
var $228=$rsize;
var $229=(($227+$228)|0);
var $230=$229;
var $231=(($230)|0);
HEAP32[(($231)>>2)]=$225;
var $232=HEAP32[((((5244152)|0))>>2)];
$DVS=$232;
var $233=$DVS;
var $234=(($233)|(0))!=0;
if ($234) { label = 27; break; } else { label = 34; break; }
case 27:
var $236=HEAP32[((((5244164)|0))>>2)];
$DV=$236;
var $237=$DVS;
var $238=$237 >>> 3;
$I=$238;
var $239=$I;
var $240=$239 << 1;
var $241=((((5244184)|0)+($240<<2))|0);
var $242=$241;
var $243=$242;
$B=$243;
var $244=$B;
$F4=$244;
var $245=HEAP32[((((5244144)|0))>>2)];
var $246=$I;
var $247=1 << $246;
var $248=$245 & $247;
var $249=(($248)|(0))!=0;
if ($249) { label = 29; break; } else { label = 28; break; }
case 28:
var $251=$I;
var $252=1 << $251;
var $253=HEAP32[((((5244144)|0))>>2)];
var $254=$253 | $252;
HEAP32[((((5244144)|0))>>2)]=$254;
label = 33; break;
case 29:
var $256=$B;
var $257=(($256+8)|0);
var $258=HEAP32[(($257)>>2)];
var $259=$258;
var $260=HEAP32[((((5244160)|0))>>2)];
var $261=(($259)>>>(0)) >= (($260)>>>(0));
var $262=(($261)&(1));
var $263=($262);
var $264=(($263)|(0))!=0;
if ($264) { label = 30; break; } else { label = 31; break; }
case 30:
var $266=$B;
var $267=(($266+8)|0);
var $268=HEAP32[(($267)>>2)];
$F4=$268;
label = 32; break;
case 31:
_abort();
throw "Reached an unreachable!"
case 32:
label = 33; break;
case 33:
var $272=$DV;
var $273=$B;
var $274=(($273+8)|0);
HEAP32[(($274)>>2)]=$272;
var $275=$DV;
var $276=$F4;
var $277=(($276+12)|0);
HEAP32[(($277)>>2)]=$275;
var $278=$F4;
var $279=$DV;
var $280=(($279+8)|0);
HEAP32[(($280)>>2)]=$278;
var $281=$B;
var $282=$DV;
var $283=(($282+12)|0);
HEAP32[(($283)>>2)]=$281;
label = 34; break;
case 34:
var $285=$rsize;
HEAP32[((((5244152)|0))>>2)]=$285;
var $286=$r;
HEAP32[((((5244164)|0))>>2)]=$286;
var $287=$p2;
var $288=$287;
var $289=(($288+8)|0);
$mem=$289;
label = 58; break;
case 35:
var $291=HEAP32[((((5244148)|0))>>2)];
var $292=(($291)|(0))!=0;
if ($292) { label = 36; break; } else { label = 38; break; }
case 36:
var $294=$nb;
var $295=_tmalloc_small(5244144, $294);
$mem=$295;
var $296=(($295)|(0))!=0;
if ($296) { label = 37; break; } else { label = 38; break; }
case 37:
label = 58; break;
case 38:
label = 39; break;
case 39:
label = 40; break;
case 40:
label = 41; break;
case 41:
label = 49; break;
case 42:
var $303=$1;
var $304=(($303)>>>(0)) >= 4294967232;
if ($304) { label = 43; break; } else { label = 44; break; }
case 43:
$nb=-1;
label = 48; break;
case 44:
var $307=$1;
var $308=((($307)+(4))|0);
var $309=((($308)+(7))|0);
var $310=$309 & -8;
$nb=$310;
var $311=HEAP32[((((5244148)|0))>>2)];
var $312=(($311)|(0))!=0;
if ($312) { label = 45; break; } else { label = 47; break; }
case 45:
var $314=$nb;
var $315=_tmalloc_large(5244144, $314);
$mem=$315;
var $316=(($315)|(0))!=0;
if ($316) { label = 46; break; } else { label = 47; break; }
case 46:
label = 58; break;
case 47:
label = 48; break;
case 48:
label = 49; break;
case 49:
var $321=$nb;
var $322=HEAP32[((((5244152)|0))>>2)];
var $323=(($321)>>>(0)) <= (($322)>>>(0));
if ($323) { label = 50; break; } else { label = 54; break; }
case 50:
var $325=HEAP32[((((5244152)|0))>>2)];
var $326=$nb;
var $327=((($325)-($326))|0);
$rsize5=$327;
var $328=HEAP32[((((5244164)|0))>>2)];
$p6=$328;
var $329=$rsize5;
var $330=(($329)>>>(0)) >= 16;
if ($330) { label = 51; break; } else { label = 52; break; }
case 51:
var $332=$p6;
var $333=$332;
var $334=$nb;
var $335=(($333+$334)|0);
var $336=$335;
HEAP32[((((5244164)|0))>>2)]=$336;
$r7=$336;
var $337=$rsize5;
HEAP32[((((5244152)|0))>>2)]=$337;
var $338=$rsize5;
var $339=$338 | 1;
var $340=$r7;
var $341=(($340+4)|0);
HEAP32[(($341)>>2)]=$339;
var $342=$rsize5;
var $343=$r7;
var $344=$343;
var $345=$rsize5;
var $346=(($344+$345)|0);
var $347=$346;
var $348=(($347)|0);
HEAP32[(($348)>>2)]=$342;
var $349=$nb;
var $350=$349 | 1;
var $351=$350 | 2;
var $352=$p6;
var $353=(($352+4)|0);
HEAP32[(($353)>>2)]=$351;
label = 53; break;
case 52:
var $355=HEAP32[((((5244152)|0))>>2)];
$dvs=$355;
HEAP32[((((5244152)|0))>>2)]=0;
HEAP32[((((5244164)|0))>>2)]=0;
var $356=$dvs;
var $357=$356 | 1;
var $358=$357 | 2;
var $359=$p6;
var $360=(($359+4)|0);
HEAP32[(($360)>>2)]=$358;
var $361=$p6;
var $362=$361;
var $363=$dvs;
var $364=(($362+$363)|0);
var $365=$364;
var $366=(($365+4)|0);
var $367=HEAP32[(($366)>>2)];
var $368=$367 | 1;
HEAP32[(($366)>>2)]=$368;
label = 53; break;
case 53:
var $370=$p6;
var $371=$370;
var $372=(($371+8)|0);
$mem=$372;
label = 58; break;
case 54:
var $374=$nb;
var $375=HEAP32[((((5244156)|0))>>2)];
var $376=(($374)>>>(0)) < (($375)>>>(0));
if ($376) { label = 55; break; } else { label = 56; break; }
case 55:
var $378=$nb;
var $379=HEAP32[((((5244156)|0))>>2)];
var $380=((($379)-($378))|0);
HEAP32[((((5244156)|0))>>2)]=$380;
$rsize8=$380;
var $381=HEAP32[((((5244168)|0))>>2)];
$p9=$381;
var $382=$p9;
var $383=$382;
var $384=$nb;
var $385=(($383+$384)|0);
var $386=$385;
HEAP32[((((5244168)|0))>>2)]=$386;
$r10=$386;
var $387=$rsize8;
var $388=$387 | 1;
var $389=$r10;
var $390=(($389+4)|0);
HEAP32[(($390)>>2)]=$388;
var $391=$nb;
var $392=$391 | 1;
var $393=$392 | 2;
var $394=$p9;
var $395=(($394+4)|0);
HEAP32[(($395)>>2)]=$393;
var $396=$p9;
var $397=$396;
var $398=(($397+8)|0);
$mem=$398;
label = 58; break;
case 56:
label = 57; break;
case 57:
var $401=$nb;
var $402=_sys_alloc(5244144, $401);
$mem=$402;
label = 58; break;
case 58:
var $404=$mem;
return $404;
default: assert(0, "bad label: " + label);
}
}
function _tmalloc_small($m, $nb) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $t;
var $v;
var $rsize;
var $i;
var $leastbit;
var $Y;
var $K;
var $N;
var $trem;
var $r;
var $XP;
var $R;
var $F;
var $RP;
var $CP;
var $H;
var $C0;
var $C1;
var $DVS;
var $DV;
var $I;
var $B;
var $F1;
$1=$m;
$2=$nb;
var $3=$1;
var $4=(($3+4)|0);
var $5=HEAP32[(($4)>>2)];
var $6=$1;
var $7=(($6+4)|0);
var $8=HEAP32[(($7)>>2)];
var $9=(((-$8))|0);
var $10=$5 & $9;
$leastbit=$10;
var $11=$leastbit;
var $12=((($11)-(1))|0);
$Y=$12;
var $13=$Y;
var $14=$13 >>> 12;
var $15=$14 & 16;
$K=$15;
var $16=$K;
$N=$16;
var $17=$K;
var $18=$Y;
var $19=$18 >>> (($17)>>>(0));
$Y=$19;
var $20=$Y;
var $21=$20 >>> 5;
var $22=$21 & 8;
$K=$22;
var $23=$N;
var $24=((($23)+($22))|0);
$N=$24;
var $25=$K;
var $26=$Y;
var $27=$26 >>> (($25)>>>(0));
$Y=$27;
var $28=$Y;
var $29=$28 >>> 2;
var $30=$29 & 4;
$K=$30;
var $31=$N;
var $32=((($31)+($30))|0);
$N=$32;
var $33=$K;
var $34=$Y;
var $35=$34 >>> (($33)>>>(0));
$Y=$35;
var $36=$Y;
var $37=$36 >>> 1;
var $38=$37 & 2;
$K=$38;
var $39=$N;
var $40=((($39)+($38))|0);
$N=$40;
var $41=$K;
var $42=$Y;
var $43=$42 >>> (($41)>>>(0));
$Y=$43;
var $44=$Y;
var $45=$44 >>> 1;
var $46=$45 & 1;
$K=$46;
var $47=$N;
var $48=((($47)+($46))|0);
$N=$48;
var $49=$K;
var $50=$Y;
var $51=$50 >>> (($49)>>>(0));
$Y=$51;
var $52=$N;
var $53=$Y;
var $54=((($52)+($53))|0);
$i=$54;
var $55=$i;
var $56=$1;
var $57=(($56+304)|0);
var $58=(($57+($55<<2))|0);
var $59=HEAP32[(($58)>>2)];
$t=$59;
$v=$59;
var $60=$t;
var $61=(($60+4)|0);
var $62=HEAP32[(($61)>>2)];
var $63=$62 & -8;
var $64=$2;
var $65=((($63)-($64))|0);
$rsize=$65;
label = 3; break;
case 3:
var $67=$t;
var $68=(($67+16)|0);
var $69=(($68)|0);
var $70=HEAP32[(($69)>>2)];
var $71=(($70)|(0))!=0;
if ($71) { label = 4; break; } else { label = 5; break; }
case 4:
var $73=$t;
var $74=(($73+16)|0);
var $75=(($74)|0);
var $76=HEAP32[(($75)>>2)];
var $83 = $76;label = 6; break;
case 5:
var $78=$t;
var $79=(($78+16)|0);
var $80=(($79+4)|0);
var $81=HEAP32[(($80)>>2)];
var $83 = $81;label = 6; break;
case 6:
var $83;
$t=$83;
var $84=(($83)|(0))!=0;
if ($84) { label = 7; break; } else { label = 10; break; }
case 7:
var $86=$t;
var $87=(($86+4)|0);
var $88=HEAP32[(($87)>>2)];
var $89=$88 & -8;
var $90=$2;
var $91=((($89)-($90))|0);
$trem=$91;
var $92=$trem;
var $93=$rsize;
var $94=(($92)>>>(0)) < (($93)>>>(0));
if ($94) { label = 8; break; } else { label = 9; break; }
case 8:
var $96=$trem;
$rsize=$96;
var $97=$t;
$v=$97;
label = 9; break;
case 9:
label = 3; break;
case 10:
var $100=$v;
var $101=$100;
var $102=$1;
var $103=(($102+16)|0);
var $104=HEAP32[(($103)>>2)];
var $105=(($101)>>>(0)) >= (($104)>>>(0));
var $106=(($105)&(1));
var $107=($106);
var $108=(($107)|(0))!=0;
if ($108) { label = 11; break; } else { label = 73; break; }
case 11:
var $110=$v;
var $111=$110;
var $112=$2;
var $113=(($111+$112)|0);
var $114=$113;
$r=$114;
var $115=$v;
var $116=$115;
var $117=$r;
var $118=$117;
var $119=(($116)>>>(0)) < (($118)>>>(0));
var $120=(($119)&(1));
var $121=($120);
var $122=(($121)|(0))!=0;
if ($122) { label = 12; break; } else { label = 72; break; }
case 12:
var $124=$v;
var $125=(($124+24)|0);
var $126=HEAP32[(($125)>>2)];
$XP=$126;
var $127=$v;
var $128=(($127+12)|0);
var $129=HEAP32[(($128)>>2)];
var $130=$v;
var $131=(($129)|(0))!=(($130)|(0));
if ($131) { label = 13; break; } else { label = 20; break; }
case 13:
var $133=$v;
var $134=(($133+8)|0);
var $135=HEAP32[(($134)>>2)];
$F=$135;
var $136=$v;
var $137=(($136+12)|0);
var $138=HEAP32[(($137)>>2)];
$R=$138;
var $139=$F;
var $140=$139;
var $141=$1;
var $142=(($141+16)|0);
var $143=HEAP32[(($142)>>2)];
var $144=(($140)>>>(0)) >= (($143)>>>(0));
if ($144) { label = 14; break; } else { var $158 = 0;label = 16; break; }
case 14:
var $146=$F;
var $147=(($146+12)|0);
var $148=HEAP32[(($147)>>2)];
var $149=$v;
var $150=(($148)|(0))==(($149)|(0));
if ($150) { label = 15; break; } else { var $158 = 0;label = 16; break; }
case 15:
var $152=$R;
var $153=(($152+8)|0);
var $154=HEAP32[(($153)>>2)];
var $155=$v;
var $156=(($154)|(0))==(($155)|(0));
var $158 = $156;label = 16; break;
case 16:
var $158;
var $159=(($158)&(1));
var $160=($159);
var $161=(($160)|(0))!=0;
if ($161) { label = 17; break; } else { label = 18; break; }
case 17:
var $163=$R;
var $164=$F;
var $165=(($164+12)|0);
HEAP32[(($165)>>2)]=$163;
var $166=$F;
var $167=$R;
var $168=(($167+8)|0);
HEAP32[(($168)>>2)]=$166;
label = 19; break;
case 18:
_abort();
throw "Reached an unreachable!"
case 19:
label = 32; break;
case 20:
var $172=$v;
var $173=(($172+16)|0);
var $174=(($173+4)|0);
$RP=$174;
var $175=HEAP32[(($174)>>2)];
$R=$175;
var $176=(($175)|(0))!=0;
if ($176) { label = 22; break; } else { label = 21; break; }
case 21:
var $178=$v;
var $179=(($178+16)|0);
var $180=(($179)|0);
$RP=$180;
var $181=HEAP32[(($180)>>2)];
$R=$181;
var $182=(($181)|(0))!=0;
if ($182) { label = 22; break; } else { label = 31; break; }
case 22:
label = 23; break;
case 23:
var $185=$R;
var $186=(($185+16)|0);
var $187=(($186+4)|0);
$CP=$187;
var $188=HEAP32[(($187)>>2)];
var $189=(($188)|(0))!=0;
if ($189) { var $197 = 1;label = 25; break; } else { label = 24; break; }
case 24:
var $191=$R;
var $192=(($191+16)|0);
var $193=(($192)|0);
$CP=$193;
var $194=HEAP32[(($193)>>2)];
var $195=(($194)|(0))!=0;
var $197 = $195;label = 25; break;
case 25:
var $197;
if ($197) { label = 26; break; } else { label = 27; break; }
case 26:
var $199=$CP;
$RP=$199;
var $200=HEAP32[(($199)>>2)];
$R=$200;
label = 23; break;
case 27:
var $202=$RP;
var $203=$202;
var $204=$1;
var $205=(($204+16)|0);
var $206=HEAP32[(($205)>>2)];
var $207=(($203)>>>(0)) >= (($206)>>>(0));
var $208=(($207)&(1));
var $209=($208);
var $210=(($209)|(0))!=0;
if ($210) { label = 28; break; } else { label = 29; break; }
case 28:
var $212=$RP;
HEAP32[(($212)>>2)]=0;
label = 30; break;
case 29:
_abort();
throw "Reached an unreachable!"
case 30:
label = 31; break;
case 31:
label = 32; break;
case 32:
var $217=$XP;
var $218=(($217)|(0))!=0;
if ($218) { label = 33; break; } else { label = 60; break; }
case 33:
var $220=$v;
var $221=(($220+28)|0);
var $222=HEAP32[(($221)>>2)];
var $223=$1;
var $224=(($223+304)|0);
var $225=(($224+($222<<2))|0);
$H=$225;
var $226=$v;
var $227=$H;
var $228=HEAP32[(($227)>>2)];
var $229=(($226)|(0))==(($228)|(0));
if ($229) { label = 34; break; } else { label = 37; break; }
case 34:
var $231=$R;
var $232=$H;
HEAP32[(($232)>>2)]=$231;
var $233=(($231)|(0))==0;
if ($233) { label = 35; break; } else { label = 36; break; }
case 35:
var $235=$v;
var $236=(($235+28)|0);
var $237=HEAP32[(($236)>>2)];
var $238=1 << $237;
var $239=$238 ^ -1;
var $240=$1;
var $241=(($240+4)|0);
var $242=HEAP32[(($241)>>2)];
var $243=$242 & $239;
HEAP32[(($241)>>2)]=$243;
label = 36; break;
case 36:
label = 44; break;
case 37:
var $246=$XP;
var $247=$246;
var $248=$1;
var $249=(($248+16)|0);
var $250=HEAP32[(($249)>>2)];
var $251=(($247)>>>(0)) >= (($250)>>>(0));
var $252=(($251)&(1));
var $253=($252);
var $254=(($253)|(0))!=0;
if ($254) { label = 38; break; } else { label = 42; break; }
case 38:
var $256=$XP;
var $257=(($256+16)|0);
var $258=(($257)|0);
var $259=HEAP32[(($258)>>2)];
var $260=$v;
var $261=(($259)|(0))==(($260)|(0));
if ($261) { label = 39; break; } else { label = 40; break; }
case 39:
var $263=$R;
var $264=$XP;
var $265=(($264+16)|0);
var $266=(($265)|0);
HEAP32[(($266)>>2)]=$263;
label = 41; break;
case 40:
var $268=$R;
var $269=$XP;
var $270=(($269+16)|0);
var $271=(($270+4)|0);
HEAP32[(($271)>>2)]=$268;
label = 41; break;
case 41:
label = 43; break;
case 42:
_abort();
throw "Reached an unreachable!"
case 43:
label = 44; break;
case 44:
var $276=$R;
var $277=(($276)|(0))!=0;
if ($277) { label = 45; break; } else { label = 59; break; }
case 45:
var $279=$R;
var $280=$279;
var $281=$1;
var $282=(($281+16)|0);
var $283=HEAP32[(($282)>>2)];
var $284=(($280)>>>(0)) >= (($283)>>>(0));
var $285=(($284)&(1));
var $286=($285);
var $287=(($286)|(0))!=0;
if ($287) { label = 46; break; } else { label = 57; break; }
case 46:
var $289=$XP;
var $290=$R;
var $291=(($290+24)|0);
HEAP32[(($291)>>2)]=$289;
var $292=$v;
var $293=(($292+16)|0);
var $294=(($293)|0);
var $295=HEAP32[(($294)>>2)];
$C0=$295;
var $296=(($295)|(0))!=0;
if ($296) { label = 47; break; } else { label = 51; break; }
case 47:
var $298=$C0;
var $299=$298;
var $300=$1;
var $301=(($300+16)|0);
var $302=HEAP32[(($301)>>2)];
var $303=(($299)>>>(0)) >= (($302)>>>(0));
var $304=(($303)&(1));
var $305=($304);
var $306=(($305)|(0))!=0;
if ($306) { label = 48; break; } else { label = 49; break; }
case 48:
var $308=$C0;
var $309=$R;
var $310=(($309+16)|0);
var $311=(($310)|0);
HEAP32[(($311)>>2)]=$308;
var $312=$R;
var $313=$C0;
var $314=(($313+24)|0);
HEAP32[(($314)>>2)]=$312;
label = 50; break;
case 49:
_abort();
throw "Reached an unreachable!"
case 50:
label = 51; break;
case 51:
var $318=$v;
var $319=(($318+16)|0);
var $320=(($319+4)|0);
var $321=HEAP32[(($320)>>2)];
$C1=$321;
var $322=(($321)|(0))!=0;
if ($322) { label = 52; break; } else { label = 56; break; }
case 52:
var $324=$C1;
var $325=$324;
var $326=$1;
var $327=(($326+16)|0);
var $328=HEAP32[(($327)>>2)];
var $329=(($325)>>>(0)) >= (($328)>>>(0));
var $330=(($329)&(1));
var $331=($330);
var $332=(($331)|(0))!=0;
if ($332) { label = 53; break; } else { label = 54; break; }
case 53:
var $334=$C1;
var $335=$R;
var $336=(($335+16)|0);
var $337=(($336+4)|0);
HEAP32[(($337)>>2)]=$334;
var $338=$R;
var $339=$C1;
var $340=(($339+24)|0);
HEAP32[(($340)>>2)]=$338;
label = 55; break;
case 54:
_abort();
throw "Reached an unreachable!"
case 55:
label = 56; break;
case 56:
label = 58; break;
case 57:
_abort();
throw "Reached an unreachable!"
case 58:
label = 59; break;
case 59:
label = 60; break;
case 60:
var $348=$rsize;
var $349=(($348)>>>(0)) < 16;
if ($349) { label = 61; break; } else { label = 62; break; }
case 61:
var $351=$rsize;
var $352=$2;
var $353=((($351)+($352))|0);
var $354=$353 | 1;
var $355=$354 | 2;
var $356=$v;
var $357=(($356+4)|0);
HEAP32[(($357)>>2)]=$355;
var $358=$v;
var $359=$358;
var $360=$rsize;
var $361=$2;
var $362=((($360)+($361))|0);
var $363=(($359+$362)|0);
var $364=$363;
var $365=(($364+4)|0);
var $366=HEAP32[(($365)>>2)];
var $367=$366 | 1;
HEAP32[(($365)>>2)]=$367;
label = 71; break;
case 62:
var $369=$2;
var $370=$369 | 1;
var $371=$370 | 2;
var $372=$v;
var $373=(($372+4)|0);
HEAP32[(($373)>>2)]=$371;
var $374=$rsize;
var $375=$374 | 1;
var $376=$r;
var $377=(($376+4)|0);
HEAP32[(($377)>>2)]=$375;
var $378=$rsize;
var $379=$r;
var $380=$379;
var $381=$rsize;
var $382=(($380+$381)|0);
var $383=$382;
var $384=(($383)|0);
HEAP32[(($384)>>2)]=$378;
var $385=$1;
var $386=(($385+8)|0);
var $387=HEAP32[(($386)>>2)];
$DVS=$387;
var $388=$DVS;
var $389=(($388)|(0))!=0;
if ($389) { label = 63; break; } else { label = 70; break; }
case 63:
var $391=$1;
var $392=(($391+20)|0);
var $393=HEAP32[(($392)>>2)];
$DV=$393;
var $394=$DVS;
var $395=$394 >>> 3;
$I=$395;
var $396=$I;
var $397=$396 << 1;
var $398=$1;
var $399=(($398+40)|0);
var $400=(($399+($397<<2))|0);
var $401=$400;
var $402=$401;
$B=$402;
var $403=$B;
$F1=$403;
var $404=$1;
var $405=(($404)|0);
var $406=HEAP32[(($405)>>2)];
var $407=$I;
var $408=1 << $407;
var $409=$406 & $408;
var $410=(($409)|(0))!=0;
if ($410) { label = 65; break; } else { label = 64; break; }
case 64:
var $412=$I;
var $413=1 << $412;
var $414=$1;
var $415=(($414)|0);
var $416=HEAP32[(($415)>>2)];
var $417=$416 | $413;
HEAP32[(($415)>>2)]=$417;
label = 69; break;
case 65:
var $419=$B;
var $420=(($419+8)|0);
var $421=HEAP32[(($420)>>2)];
var $422=$421;
var $423=$1;
var $424=(($423+16)|0);
var $425=HEAP32[(($424)>>2)];
var $426=(($422)>>>(0)) >= (($425)>>>(0));
var $427=(($426)&(1));
var $428=($427);
var $429=(($428)|(0))!=0;
if ($429) { label = 66; break; } else { label = 67; break; }
case 66:
var $431=$B;
var $432=(($431+8)|0);
var $433=HEAP32[(($432)>>2)];
$F1=$433;
label = 68; break;
case 67:
_abort();
throw "Reached an unreachable!"
case 68:
label = 69; break;
case 69:
var $437=$DV;
var $438=$B;
var $439=(($438+8)|0);
HEAP32[(($439)>>2)]=$437;
var $440=$DV;
var $441=$F1;
var $442=(($441+12)|0);
HEAP32[(($442)>>2)]=$440;
var $443=$F1;
var $444=$DV;
var $445=(($444+8)|0);
HEAP32[(($445)>>2)]=$443;
var $446=$B;
var $447=$DV;
var $448=(($447+12)|0);
HEAP32[(($448)>>2)]=$446;
label = 70; break;
case 70:
var $450=$rsize;
var $451=$1;
var $452=(($451+8)|0);
HEAP32[(($452)>>2)]=$450;
var $453=$r;
var $454=$1;
var $455=(($454+20)|0);
HEAP32[(($455)>>2)]=$453;
label = 71; break;
case 71:
var $457=$v;
var $458=$457;
var $459=(($458+8)|0);
return $459;
case 72:
label = 73; break;
case 73:
_abort();
throw "Reached an unreachable!"
default: assert(0, "bad label: " + label);
}
}
function _tmalloc_large($m, $nb) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $v;
var $rsize;
var $t;
var $idx;
var $X;
var $Y;
var $N;
var $K;
var $sizebits;
var $rst;
var $rt;
var $trem;
var $leftbits;
var $i;
var $leastbit;
var $Y1;
var $K2;
var $N3;
var $trem4;
var $r;
var $XP;
var $R;
var $F;
var $RP;
var $CP;
var $H;
var $C0;
var $C1;
var $I;
var $B;
var $F5;
var $TP;
var $H6;
var $I7;
var $X8;
var $Y9;
var $N10;
var $K11;
var $T;
var $K12;
var $C;
var $F13;
$2=$m;
$3=$nb;
$v=0;
var $4=$3;
var $5=(((-$4))|0);
$rsize=$5;
var $6=$3;
var $7=$6 >>> 8;
$X=$7;
var $8=$X;
var $9=(($8)|(0))==0;
if ($9) { label = 3; break; } else { label = 4; break; }
case 3:
$idx=0;
label = 8; break;
case 4:
var $12=$X;
var $13=(($12)>>>(0)) > 65535;
if ($13) { label = 5; break; } else { label = 6; break; }
case 5:
$idx=31;
label = 7; break;
case 6:
var $16=$X;
$Y=$16;
var $17=$Y;
var $18=((($17)-(256))|0);
var $19=$18 >>> 16;
var $20=$19 & 8;
$N=$20;
var $21=$N;
var $22=$Y;
var $23=$22 << $21;
$Y=$23;
var $24=((($23)-(4096))|0);
var $25=$24 >>> 16;
var $26=$25 & 4;
$K=$26;
var $27=$K;
var $28=$N;
var $29=((($28)+($27))|0);
$N=$29;
var $30=$K;
var $31=$Y;
var $32=$31 << $30;
$Y=$32;
var $33=((($32)-(16384))|0);
var $34=$33 >>> 16;
var $35=$34 & 2;
$K=$35;
var $36=$N;
var $37=((($36)+($35))|0);
$N=$37;
var $38=$N;
var $39=(((14)-($38))|0);
var $40=$K;
var $41=$Y;
var $42=$41 << $40;
$Y=$42;
var $43=$42 >>> 15;
var $44=((($39)+($43))|0);
$K=$44;
var $45=$K;
var $46=$45 << 1;
var $47=$3;
var $48=$K;
var $49=((($48)+(7))|0);
var $50=$47 >>> (($49)>>>(0));
var $51=$50 & 1;
var $52=((($46)+($51))|0);
$idx=$52;
label = 7; break;
case 7:
label = 8; break;
case 8:
var $55=$idx;
var $56=$2;
var $57=(($56+304)|0);
var $58=(($57+($55<<2))|0);
var $59=HEAP32[(($58)>>2)];
$t=$59;
var $60=(($59)|(0))!=0;
if ($60) { label = 9; break; } else { label = 24; break; }
case 9:
var $62=$3;
var $63=$idx;
var $64=(($63)|(0))==31;
if ($64) { label = 10; break; } else { label = 11; break; }
case 10:
var $73 = 0;label = 12; break;
case 11:
var $67=$idx;
var $68=$67 >>> 1;
var $69=((($68)+(8))|0);
var $70=((($69)-(2))|0);
var $71=(((31)-($70))|0);
var $73 = $71;label = 12; break;
case 12:
var $73;
var $74=$62 << $73;
$sizebits=$74;
$rst=0;
label = 13; break;
case 13:
var $76=$t;
var $77=(($76+4)|0);
var $78=HEAP32[(($77)>>2)];
var $79=$78 & -8;
var $80=$3;
var $81=((($79)-($80))|0);
$trem=$81;
var $82=$trem;
var $83=$rsize;
var $84=(($82)>>>(0)) < (($83)>>>(0));
if ($84) { label = 14; break; } else { label = 17; break; }
case 14:
var $86=$t;
$v=$86;
var $87=$trem;
$rsize=$87;
var $88=(($87)|(0))==0;
if ($88) { label = 15; break; } else { label = 16; break; }
case 15:
label = 23; break;
case 16:
label = 17; break;
case 17:
var $92=$t;
var $93=(($92+16)|0);
var $94=(($93+4)|0);
var $95=HEAP32[(($94)>>2)];
$rt=$95;
var $96=$sizebits;
var $97=$96 >>> 31;
var $98=$97 & 1;
var $99=$t;
var $100=(($99+16)|0);
var $101=(($100+($98<<2))|0);
var $102=HEAP32[(($101)>>2)];
$t=$102;
var $103=$rt;
var $104=(($103)|(0))!=0;
if ($104) { label = 18; break; } else { label = 20; break; }
case 18:
var $106=$rt;
var $107=$t;
var $108=(($106)|(0))!=(($107)|(0));
if ($108) { label = 19; break; } else { label = 20; break; }
case 19:
var $110=$rt;
$rst=$110;
label = 20; break;
case 20:
var $112=$t;
var $113=(($112)|(0))==0;
if ($113) { label = 21; break; } else { label = 22; break; }
case 21:
var $115=$rst;
$t=$115;
label = 23; break;
case 22:
var $117=$sizebits;
var $118=$117 << 1;
$sizebits=$118;
label = 13; break;
case 23:
label = 24; break;
case 24:
var $121=$t;
var $122=(($121)|(0))==0;
if ($122) { label = 25; break; } else { label = 29; break; }
case 25:
var $124=$v;
var $125=(($124)|(0))==0;
if ($125) { label = 26; break; } else { label = 29; break; }
case 26:
var $127=$idx;
var $128=1 << $127;
var $129=$128 << 1;
var $130=$idx;
var $131=1 << $130;
var $132=$131 << 1;
var $133=(((-$132))|0);
var $134=$129 | $133;
var $135=$2;
var $136=(($135+4)|0);
var $137=HEAP32[(($136)>>2)];
var $138=$134 & $137;
$leftbits=$138;
var $139=$leftbits;
var $140=(($139)|(0))!=0;
if ($140) { label = 27; break; } else { label = 28; break; }
case 27:
var $142=$leftbits;
var $143=$leftbits;
var $144=(((-$143))|0);
var $145=$142 & $144;
$leastbit=$145;
var $146=$leastbit;
var $147=((($146)-(1))|0);
$Y1=$147;
var $148=$Y1;
var $149=$148 >>> 12;
var $150=$149 & 16;
$K2=$150;
var $151=$K2;
$N3=$151;
var $152=$K2;
var $153=$Y1;
var $154=$153 >>> (($152)>>>(0));
$Y1=$154;
var $155=$Y1;
var $156=$155 >>> 5;
var $157=$156 & 8;
$K2=$157;
var $158=$N3;
var $159=((($158)+($157))|0);
$N3=$159;
var $160=$K2;
var $161=$Y1;
var $162=$161 >>> (($160)>>>(0));
$Y1=$162;
var $163=$Y1;
var $164=$163 >>> 2;
var $165=$164 & 4;
$K2=$165;
var $166=$N3;
var $167=((($166)+($165))|0);
$N3=$167;
var $168=$K2;
var $169=$Y1;
var $170=$169 >>> (($168)>>>(0));
$Y1=$170;
var $171=$Y1;
var $172=$171 >>> 1;
var $173=$172 & 2;
$K2=$173;
var $174=$N3;
var $175=((($174)+($173))|0);
$N3=$175;
var $176=$K2;
var $177=$Y1;
var $178=$177 >>> (($176)>>>(0));
$Y1=$178;
var $179=$Y1;
var $180=$179 >>> 1;
var $181=$180 & 1;
$K2=$181;
var $182=$N3;
var $183=((($182)+($181))|0);
$N3=$183;
var $184=$K2;
var $185=$Y1;
var $186=$185 >>> (($184)>>>(0));
$Y1=$186;
var $187=$N3;
var $188=$Y1;
var $189=((($187)+($188))|0);
$i=$189;
var $190=$i;
var $191=$2;
var $192=(($191+304)|0);
var $193=(($192+($190<<2))|0);
var $194=HEAP32[(($193)>>2)];
$t=$194;
label = 28; break;
case 28:
label = 29; break;
case 29:
label = 30; break;
case 30:
var $198=$t;
var $199=(($198)|(0))!=0;
if ($199) { label = 31; break; } else { label = 37; break; }
case 31:
var $201=$t;
var $202=(($201+4)|0);
var $203=HEAP32[(($202)>>2)];
var $204=$203 & -8;
var $205=$3;
var $206=((($204)-($205))|0);
$trem4=$206;
var $207=$trem4;
var $208=$rsize;
var $209=(($207)>>>(0)) < (($208)>>>(0));
if ($209) { label = 32; break; } else { label = 33; break; }
case 32:
var $211=$trem4;
$rsize=$211;
var $212=$t;
$v=$212;
label = 33; break;
case 33:
var $214=$t;
var $215=(($214+16)|0);
var $216=(($215)|0);
var $217=HEAP32[(($216)>>2)];
var $218=(($217)|(0))!=0;
if ($218) { label = 34; break; } else { label = 35; break; }
case 34:
var $220=$t;
var $221=(($220+16)|0);
var $222=(($221)|0);
var $223=HEAP32[(($222)>>2)];
var $230 = $223;label = 36; break;
case 35:
var $225=$t;
var $226=(($225+16)|0);
var $227=(($226+4)|0);
var $228=HEAP32[(($227)>>2)];
var $230 = $228;label = 36; break;
case 36:
var $230;
$t=$230;
label = 30; break;
case 37:
var $232=$v;
var $233=(($232)|(0))!=0;
if ($233) { label = 38; break; } else { label = 130; break; }
case 38:
var $235=$rsize;
var $236=$2;
var $237=(($236+8)|0);
var $238=HEAP32[(($237)>>2)];
var $239=$3;
var $240=((($238)-($239))|0);
var $241=(($235)>>>(0)) < (($240)>>>(0));
if ($241) { label = 39; break; } else { label = 130; break; }
case 39:
var $243=$v;
var $244=$243;
var $245=$2;
var $246=(($245+16)|0);
var $247=HEAP32[(($246)>>2)];
var $248=(($244)>>>(0)) >= (($247)>>>(0));
var $249=(($248)&(1));
var $250=($249);
var $251=(($250)|(0))!=0;
if ($251) { label = 40; break; } else { label = 129; break; }
case 40:
var $253=$v;
var $254=$253;
var $255=$3;
var $256=(($254+$255)|0);
var $257=$256;
$r=$257;
var $258=$v;
var $259=$258;
var $260=$r;
var $261=$260;
var $262=(($259)>>>(0)) < (($261)>>>(0));
var $263=(($262)&(1));
var $264=($263);
var $265=(($264)|(0))!=0;
if ($265) { label = 41; break; } else { label = 128; break; }
case 41:
var $267=$v;
var $268=(($267+24)|0);
var $269=HEAP32[(($268)>>2)];
$XP=$269;
var $270=$v;
var $271=(($270+12)|0);
var $272=HEAP32[(($271)>>2)];
var $273=$v;
var $274=(($272)|(0))!=(($273)|(0));
if ($274) { label = 42; break; } else { label = 49; break; }
case 42:
var $276=$v;
var $277=(($276+8)|0);
var $278=HEAP32[(($277)>>2)];
$F=$278;
var $279=$v;
var $280=(($279+12)|0);
var $281=HEAP32[(($280)>>2)];
$R=$281;
var $282=$F;
var $283=$282;
var $284=$2;
var $285=(($284+16)|0);
var $286=HEAP32[(($285)>>2)];
var $287=(($283)>>>(0)) >= (($286)>>>(0));
if ($287) { label = 43; break; } else { var $301 = 0;label = 45; break; }
case 43:
var $289=$F;
var $290=(($289+12)|0);
var $291=HEAP32[(($290)>>2)];
var $292=$v;
var $293=(($291)|(0))==(($292)|(0));
if ($293) { label = 44; break; } else { var $301 = 0;label = 45; break; }
case 44:
var $295=$R;
var $296=(($295+8)|0);
var $297=HEAP32[(($296)>>2)];
var $298=$v;
var $299=(($297)|(0))==(($298)|(0));
var $301 = $299;label = 45; break;
case 45:
var $301;
var $302=(($301)&(1));
var $303=($302);
var $304=(($303)|(0))!=0;
if ($304) { label = 46; break; } else { label = 47; break; }
case 46:
var $306=$R;
var $307=$F;
var $308=(($307+12)|0);
HEAP32[(($308)>>2)]=$306;
var $309=$F;
var $310=$R;
var $311=(($310+8)|0);
HEAP32[(($311)>>2)]=$309;
label = 48; break;
case 47:
_abort();
throw "Reached an unreachable!"
case 48:
label = 61; break;
case 49:
var $315=$v;
var $316=(($315+16)|0);
var $317=(($316+4)|0);
$RP=$317;
var $318=HEAP32[(($317)>>2)];
$R=$318;
var $319=(($318)|(0))!=0;
if ($319) { label = 51; break; } else { label = 50; break; }
case 50:
var $321=$v;
var $322=(($321+16)|0);
var $323=(($322)|0);
$RP=$323;
var $324=HEAP32[(($323)>>2)];
$R=$324;
var $325=(($324)|(0))!=0;
if ($325) { label = 51; break; } else { label = 60; break; }
case 51:
label = 52; break;
case 52:
var $328=$R;
var $329=(($328+16)|0);
var $330=(($329+4)|0);
$CP=$330;
var $331=HEAP32[(($330)>>2)];
var $332=(($331)|(0))!=0;
if ($332) { var $340 = 1;label = 54; break; } else { label = 53; break; }
case 53:
var $334=$R;
var $335=(($334+16)|0);
var $336=(($335)|0);
$CP=$336;
var $337=HEAP32[(($336)>>2)];
var $338=(($337)|(0))!=0;
var $340 = $338;label = 54; break;
case 54:
var $340;
if ($340) { label = 55; break; } else { label = 56; break; }
case 55:
var $342=$CP;
$RP=$342;
var $343=HEAP32[(($342)>>2)];
$R=$343;
label = 52; break;
case 56:
var $345=$RP;
var $346=$345;
var $347=$2;
var $348=(($347+16)|0);
var $349=HEAP32[(($348)>>2)];
var $350=(($346)>>>(0)) >= (($349)>>>(0));
var $351=(($350)&(1));
var $352=($351);
var $353=(($352)|(0))!=0;
if ($353) { label = 57; break; } else { label = 58; break; }
case 57:
var $355=$RP;
HEAP32[(($355)>>2)]=0;
label = 59; break;
case 58:
_abort();
throw "Reached an unreachable!"
case 59:
label = 60; break;
case 60:
label = 61; break;
case 61:
var $360=$XP;
var $361=(($360)|(0))!=0;
if ($361) { label = 62; break; } else { label = 89; break; }
case 62:
var $363=$v;
var $364=(($363+28)|0);
var $365=HEAP32[(($364)>>2)];
var $366=$2;
var $367=(($366+304)|0);
var $368=(($367+($365<<2))|0);
$H=$368;
var $369=$v;
var $370=$H;
var $371=HEAP32[(($370)>>2)];
var $372=(($369)|(0))==(($371)|(0));
if ($372) { label = 63; break; } else { label = 66; break; }
case 63:
var $374=$R;
var $375=$H;
HEAP32[(($375)>>2)]=$374;
var $376=(($374)|(0))==0;
if ($376) { label = 64; break; } else { label = 65; break; }
case 64:
var $378=$v;
var $379=(($378+28)|0);
var $380=HEAP32[(($379)>>2)];
var $381=1 << $380;
var $382=$381 ^ -1;
var $383=$2;
var $384=(($383+4)|0);
var $385=HEAP32[(($384)>>2)];
var $386=$385 & $382;
HEAP32[(($384)>>2)]=$386;
label = 65; break;
case 65:
label = 73; break;
case 66:
var $389=$XP;
var $390=$389;
var $391=$2;
var $392=(($391+16)|0);
var $393=HEAP32[(($392)>>2)];
var $394=(($390)>>>(0)) >= (($393)>>>(0));
var $395=(($394)&(1));
var $396=($395);
var $397=(($396)|(0))!=0;
if ($397) { label = 67; break; } else { label = 71; break; }
case 67:
var $399=$XP;
var $400=(($399+16)|0);
var $401=(($400)|0);
var $402=HEAP32[(($401)>>2)];
var $403=$v;
var $404=(($402)|(0))==(($403)|(0));
if ($404) { label = 68; break; } else { label = 69; break; }
case 68:
var $406=$R;
var $407=$XP;
var $408=(($407+16)|0);
var $409=(($408)|0);
HEAP32[(($409)>>2)]=$406;
label = 70; break;
case 69:
var $411=$R;
var $412=$XP;
var $413=(($412+16)|0);
var $414=(($413+4)|0);
HEAP32[(($414)>>2)]=$411;
label = 70; break;
case 70:
label = 72; break;
case 71:
_abort();
throw "Reached an unreachable!"
case 72:
label = 73; break;
case 73:
var $419=$R;
var $420=(($419)|(0))!=0;
if ($420) { label = 74; break; } else { label = 88; break; }
case 74:
var $422=$R;
var $423=$422;
var $424=$2;
var $425=(($424+16)|0);
var $426=HEAP32[(($425)>>2)];
var $427=(($423)>>>(0)) >= (($426)>>>(0));
var $428=(($427)&(1));
var $429=($428);
var $430=(($429)|(0))!=0;
if ($430) { label = 75; break; } else { label = 86; break; }
case 75:
var $432=$XP;
var $433=$R;
var $434=(($433+24)|0);
HEAP32[(($434)>>2)]=$432;
var $435=$v;
var $436=(($435+16)|0);
var $437=(($436)|0);
var $438=HEAP32[(($437)>>2)];
$C0=$438;
var $439=(($438)|(0))!=0;
if ($439) { label = 76; break; } else { label = 80; break; }
case 76:
var $441=$C0;
var $442=$441;
var $443=$2;
var $444=(($443+16)|0);
var $445=HEAP32[(($444)>>2)];
var $446=(($442)>>>(0)) >= (($445)>>>(0));
var $447=(($446)&(1));
var $448=($447);
var $449=(($448)|(0))!=0;
if ($449) { label = 77; break; } else { label = 78; break; }
case 77:
var $451=$C0;
var $452=$R;
var $453=(($452+16)|0);
var $454=(($453)|0);
HEAP32[(($454)>>2)]=$451;
var $455=$R;
var $456=$C0;
var $457=(($456+24)|0);
HEAP32[(($457)>>2)]=$455;
label = 79; break;
case 78:
_abort();
throw "Reached an unreachable!"
case 79:
label = 80; break;
case 80:
var $461=$v;
var $462=(($461+16)|0);
var $463=(($462+4)|0);
var $464=HEAP32[(($463)>>2)];
$C1=$464;
var $465=(($464)|(0))!=0;
if ($465) { label = 81; break; } else { label = 85; break; }
case 81:
var $467=$C1;
var $468=$467;
var $469=$2;
var $470=(($469+16)|0);
var $471=HEAP32[(($470)>>2)];
var $472=(($468)>>>(0)) >= (($471)>>>(0));
var $473=(($472)&(1));
var $474=($473);
var $475=(($474)|(0))!=0;
if ($475) { label = 82; break; } else { label = 83; break; }
case 82:
var $477=$C1;
var $478=$R;
var $479=(($478+16)|0);
var $480=(($479+4)|0);
HEAP32[(($480)>>2)]=$477;
var $481=$R;
var $482=$C1;
var $483=(($482+24)|0);
HEAP32[(($483)>>2)]=$481;
label = 84; break;
case 83:
_abort();
throw "Reached an unreachable!"
case 84:
label = 85; break;
case 85:
label = 87; break;
case 86:
_abort();
throw "Reached an unreachable!"
case 87:
label = 88; break;
case 88:
label = 89; break;
case 89:
var $491=$rsize;
var $492=(($491)>>>(0)) < 16;
if ($492) { label = 90; break; } else { label = 91; break; }
case 90:
var $494=$rsize;
var $495=$3;
var $496=((($494)+($495))|0);
var $497=$496 | 1;
var $498=$497 | 2;
var $499=$v;
var $500=(($499+4)|0);
HEAP32[(($500)>>2)]=$498;
var $501=$v;
var $502=$501;
var $503=$rsize;
var $504=$3;
var $505=((($503)+($504))|0);
var $506=(($502+$505)|0);
var $507=$506;
var $508=(($507+4)|0);
var $509=HEAP32[(($508)>>2)];
var $510=$509 | 1;
HEAP32[(($508)>>2)]=$510;
label = 127; break;
case 91:
var $512=$3;
var $513=$512 | 1;
var $514=$513 | 2;
var $515=$v;
var $516=(($515+4)|0);
HEAP32[(($516)>>2)]=$514;
var $517=$rsize;
var $518=$517 | 1;
var $519=$r;
var $520=(($519+4)|0);
HEAP32[(($520)>>2)]=$518;
var $521=$rsize;
var $522=$r;
var $523=$522;
var $524=$rsize;
var $525=(($523+$524)|0);
var $526=$525;
var $527=(($526)|0);
HEAP32[(($527)>>2)]=$521;
var $528=$rsize;
var $529=$528 >>> 3;
var $530=(($529)>>>(0)) < 32;
if ($530) { label = 92; break; } else { label = 99; break; }
case 92:
var $532=$rsize;
var $533=$532 >>> 3;
$I=$533;
var $534=$I;
var $535=$534 << 1;
var $536=$2;
var $537=(($536+40)|0);
var $538=(($537+($535<<2))|0);
var $539=$538;
var $540=$539;
$B=$540;
var $541=$B;
$F5=$541;
var $542=$2;
var $543=(($542)|0);
var $544=HEAP32[(($543)>>2)];
var $545=$I;
var $546=1 << $545;
var $547=$544 & $546;
var $548=(($547)|(0))!=0;
if ($548) { label = 94; break; } else { label = 93; break; }
case 93:
var $550=$I;
var $551=1 << $550;
var $552=$2;
var $553=(($552)|0);
var $554=HEAP32[(($553)>>2)];
var $555=$554 | $551;
HEAP32[(($553)>>2)]=$555;
label = 98; break;
case 94:
var $557=$B;
var $558=(($557+8)|0);
var $559=HEAP32[(($558)>>2)];
var $560=$559;
var $561=$2;
var $562=(($561+16)|0);
var $563=HEAP32[(($562)>>2)];
var $564=(($560)>>>(0)) >= (($563)>>>(0));
var $565=(($564)&(1));
var $566=($565);
var $567=(($566)|(0))!=0;
if ($567) { label = 95; break; } else { label = 96; break; }
case 95:
var $569=$B;
var $570=(($569+8)|0);
var $571=HEAP32[(($570)>>2)];
$F5=$571;
label = 97; break;
case 96:
_abort();
throw "Reached an unreachable!"
case 97:
label = 98; break;
case 98:
var $575=$r;
var $576=$B;
var $577=(($576+8)|0);
HEAP32[(($577)>>2)]=$575;
var $578=$r;
var $579=$F5;
var $580=(($579+12)|0);
HEAP32[(($580)>>2)]=$578;
var $581=$F5;
var $582=$r;
var $583=(($582+8)|0);
HEAP32[(($583)>>2)]=$581;
var $584=$B;
var $585=$r;
var $586=(($585+12)|0);
HEAP32[(($586)>>2)]=$584;
label = 126; break;
case 99:
var $588=$r;
var $589=$588;
$TP=$589;
var $590=$rsize;
var $591=$590 >>> 8;
$X8=$591;
var $592=$X8;
var $593=(($592)|(0))==0;
if ($593) { label = 100; break; } else { label = 101; break; }
case 100:
$I7=0;
label = 105; break;
case 101:
var $596=$X8;
var $597=(($596)>>>(0)) > 65535;
if ($597) { label = 102; break; } else { label = 103; break; }
case 102:
$I7=31;
label = 104; break;
case 103:
var $600=$X8;
$Y9=$600;
var $601=$Y9;
var $602=((($601)-(256))|0);
var $603=$602 >>> 16;
var $604=$603 & 8;
$N10=$604;
var $605=$N10;
var $606=$Y9;
var $607=$606 << $605;
$Y9=$607;
var $608=((($607)-(4096))|0);
var $609=$608 >>> 16;
var $610=$609 & 4;
$K11=$610;
var $611=$K11;
var $612=$N10;
var $613=((($612)+($611))|0);
$N10=$613;
var $614=$K11;
var $615=$Y9;
var $616=$615 << $614;
$Y9=$616;
var $617=((($616)-(16384))|0);
var $618=$617 >>> 16;
var $619=$618 & 2;
$K11=$619;
var $620=$N10;
var $621=((($620)+($619))|0);
$N10=$621;
var $622=$N10;
var $623=(((14)-($622))|0);
var $624=$K11;
var $625=$Y9;
var $626=$625 << $624;
$Y9=$626;
var $627=$626 >>> 15;
var $628=((($623)+($627))|0);
$K11=$628;
var $629=$K11;
var $630=$629 << 1;
var $631=$rsize;
var $632=$K11;
var $633=((($632)+(7))|0);
var $634=$631 >>> (($633)>>>(0));
var $635=$634 & 1;
var $636=((($630)+($635))|0);
$I7=$636;
label = 104; break;
case 104:
label = 105; break;
case 105:
var $639=$I7;
var $640=$2;
var $641=(($640+304)|0);
var $642=(($641+($639<<2))|0);
$H6=$642;
var $643=$I7;
var $644=$TP;
var $645=(($644+28)|0);
HEAP32[(($645)>>2)]=$643;
var $646=$TP;
var $647=(($646+16)|0);
var $648=(($647+4)|0);
HEAP32[(($648)>>2)]=0;
var $649=$TP;
var $650=(($649+16)|0);
var $651=(($650)|0);
HEAP32[(($651)>>2)]=0;
var $652=$2;
var $653=(($652+4)|0);
var $654=HEAP32[(($653)>>2)];
var $655=$I7;
var $656=1 << $655;
var $657=$654 & $656;
var $658=(($657)|(0))!=0;
if ($658) { label = 107; break; } else { label = 106; break; }
case 106:
var $660=$I7;
var $661=1 << $660;
var $662=$2;
var $663=(($662+4)|0);
var $664=HEAP32[(($663)>>2)];
var $665=$664 | $661;
HEAP32[(($663)>>2)]=$665;
var $666=$TP;
var $667=$H6;
HEAP32[(($667)>>2)]=$666;
var $668=$H6;
var $669=$668;
var $670=$TP;
var $671=(($670+24)|0);
HEAP32[(($671)>>2)]=$669;
var $672=$TP;
var $673=$TP;
var $674=(($673+12)|0);
HEAP32[(($674)>>2)]=$672;
var $675=$TP;
var $676=(($675+8)|0);
HEAP32[(($676)>>2)]=$672;
label = 125; break;
case 107:
var $678=$H6;
var $679=HEAP32[(($678)>>2)];
$T=$679;
var $680=$rsize;
var $681=$I7;
var $682=(($681)|(0))==31;
if ($682) { label = 108; break; } else { label = 109; break; }
case 108:
var $691 = 0;label = 110; break;
case 109:
var $685=$I7;
var $686=$685 >>> 1;
var $687=((($686)+(8))|0);
var $688=((($687)-(2))|0);
var $689=(((31)-($688))|0);
var $691 = $689;label = 110; break;
case 110:
var $691;
var $692=$680 << $691;
$K12=$692;
label = 111; break;
case 111:
var $694=$T;
var $695=(($694+4)|0);
var $696=HEAP32[(($695)>>2)];
var $697=$696 & -8;
var $698=$rsize;
var $699=(($697)|(0))!=(($698)|(0));
if ($699) { label = 112; break; } else { label = 118; break; }
case 112:
var $701=$K12;
var $702=$701 >>> 31;
var $703=$702 & 1;
var $704=$T;
var $705=(($704+16)|0);
var $706=(($705+($703<<2))|0);
$C=$706;
var $707=$K12;
var $708=$707 << 1;
$K12=$708;
var $709=$C;
var $710=HEAP32[(($709)>>2)];
var $711=(($710)|(0))!=0;
if ($711) { label = 113; break; } else { label = 114; break; }
case 113:
var $713=$C;
var $714=HEAP32[(($713)>>2)];
$T=$714;
label = 117; break;
case 114:
var $716=$C;
var $717=$716;
var $718=$2;
var $719=(($718+16)|0);
var $720=HEAP32[(($719)>>2)];
var $721=(($717)>>>(0)) >= (($720)>>>(0));
var $722=(($721)&(1));
var $723=($722);
var $724=(($723)|(0))!=0;
if ($724) { label = 115; break; } else { label = 116; break; }
case 115:
var $726=$TP;
var $727=$C;
HEAP32[(($727)>>2)]=$726;
var $728=$T;
var $729=$TP;
var $730=(($729+24)|0);
HEAP32[(($730)>>2)]=$728;
var $731=$TP;
var $732=$TP;
var $733=(($732+12)|0);
HEAP32[(($733)>>2)]=$731;
var $734=$TP;
var $735=(($734+8)|0);
HEAP32[(($735)>>2)]=$731;
label = 124; break;
case 116:
_abort();
throw "Reached an unreachable!"
case 117:
label = 123; break;
case 118:
var $739=$T;
var $740=(($739+8)|0);
var $741=HEAP32[(($740)>>2)];
$F13=$741;
var $742=$T;
var $743=$742;
var $744=$2;
var $745=(($744+16)|0);
var $746=HEAP32[(($745)>>2)];
var $747=(($743)>>>(0)) >= (($746)>>>(0));
if ($747) { label = 119; break; } else { var $756 = 0;label = 120; break; }
case 119:
var $749=$F13;
var $750=$749;
var $751=$2;
var $752=(($751+16)|0);
var $753=HEAP32[(($752)>>2)];
var $754=(($750)>>>(0)) >= (($753)>>>(0));
var $756 = $754;label = 120; break;
case 120:
var $756;
var $757=(($756)&(1));
var $758=($757);
var $759=(($758)|(0))!=0;
if ($759) { label = 121; break; } else { label = 122; break; }
case 121:
var $761=$TP;
var $762=$F13;
var $763=(($762+12)|0);
HEAP32[(($763)>>2)]=$761;
var $764=$T;
var $765=(($764+8)|0);
HEAP32[(($765)>>2)]=$761;
var $766=$F13;
var $767=$TP;
var $768=(($767+8)|0);
HEAP32[(($768)>>2)]=$766;
var $769=$T;
var $770=$TP;
var $771=(($770+12)|0);
HEAP32[(($771)>>2)]=$769;
var $772=$TP;
var $773=(($772+24)|0);
HEAP32[(($773)>>2)]=0;
label = 124; break;
case 122:
_abort();
throw "Reached an unreachable!"
case 123:
label = 111; break;
case 124:
label = 125; break;
case 125:
label = 126; break;
case 126:
label = 127; break;
case 127:
var $780=$v;
var $781=$780;
var $782=(($781+8)|0);
$1=$782;
label = 131; break;
case 128:
label = 129; break;
case 129:
_abort();
throw "Reached an unreachable!"
case 130:
$1=0;
label = 131; break;
case 131:
var $787=$1;
return $787;
default: assert(0, "bad label: " + label);
}
}
function _sys_alloc($m, $nb) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $tbase;
var $tsize;
var $mmap_flag;
var $asize;
var $mem;
var $fp;
var $br;
var $ssize;
var $ss;
var $base;
var $fp1;
var $esize;
var $end;
var $br2;
var $end3;
var $ssize4;
var $mn;
var $sp;
var $oldbase;
var $rsize;
var $p;
var $r;
$2=$m;
$3=$nb;
$tbase=-1;
$tsize=0;
$mmap_flag=0;
var $4=HEAP32[((((5243708)|0))>>2)];
var $5=(($4)|(0))!=0;
if ($5) { var $10 = 1;label = 4; break; } else { label = 3; break; }
case 3:
var $7=_init_mparams();
var $8=(($7)|(0))!=0;
var $10 = $8;label = 4; break;
case 4:
var $10;
var $11=(($10)&(1));
var $12=$2;
var $13=(($12+444)|0);
var $14=HEAP32[(($13)>>2)];
var $15=$14 & 0;
var $16=(($15)|(0))!=0;
if ($16) { label = 5; break; } else { label = 10; break; }
case 5:
var $18=$3;
var $19=HEAP32[((((5243720)|0))>>2)];
var $20=(($18)>>>(0)) >= (($19)>>>(0));
if ($20) { label = 6; break; } else { label = 10; break; }
case 6:
var $22=$2;
var $23=(($22+12)|0);
var $24=HEAP32[(($23)>>2)];
var $25=(($24)|(0))!=0;
if ($25) { label = 7; break; } else { label = 10; break; }
case 7:
var $27=$2;
var $28=$3;
var $29=_mmap_alloc($27, $28);
$mem=$29;
var $30=$mem;
var $31=(($30)|(0))!=0;
if ($31) { label = 8; break; } else { label = 9; break; }
case 8:
var $33=$mem;
$1=$33;
label = 104; break;
case 9:
label = 10; break;
case 10:
var $36=$3;
var $37=((($36)+(48))|0);
var $38=HEAP32[((((5243716)|0))>>2)];
var $39=((($38)-(1))|0);
var $40=((($37)+($39))|0);
var $41=HEAP32[((((5243716)|0))>>2)];
var $42=((($41)-(1))|0);
var $43=$42 ^ -1;
var $44=$40 & $43;
$asize=$44;
var $45=$asize;
var $46=$3;
var $47=(($45)>>>(0)) <= (($46)>>>(0));
if ($47) { label = 11; break; } else { label = 12; break; }
case 11:
$1=0;
label = 104; break;
case 12:
var $50=$2;
var $51=(($50+440)|0);
var $52=HEAP32[(($51)>>2)];
var $53=(($52)|(0))!=0;
if ($53) { label = 13; break; } else { label = 17; break; }
case 13:
var $55=$2;
var $56=(($55+432)|0);
var $57=HEAP32[(($56)>>2)];
var $58=$asize;
var $59=((($57)+($58))|0);
$fp=$59;
var $60=$fp;
var $61=$2;
var $62=(($61+432)|0);
var $63=HEAP32[(($62)>>2)];
var $64=(($60)>>>(0)) <= (($63)>>>(0));
if ($64) { label = 15; break; } else { label = 14; break; }
case 14:
var $66=$fp;
var $67=$2;
var $68=(($67+440)|0);
var $69=HEAP32[(($68)>>2)];
var $70=(($66)>>>(0)) > (($69)>>>(0));
if ($70) { label = 15; break; } else { label = 16; break; }
case 15:
$1=0;
label = 104; break;
case 16:
label = 17; break;
case 17:
var $74=$2;
var $75=(($74+444)|0);
var $76=HEAP32[(($75)>>2)];
var $77=$76 & 4;
var $78=(($77)|(0))!=0;
if ($78) { label = 54; break; } else { label = 18; break; }
case 18:
$br=-1;
var $80=$asize;
$ssize=$80;
var $81=$2;
var $82=(($81+24)|0);
var $83=HEAP32[(($82)>>2)];
var $84=(($83)|(0))==0;
if ($84) { label = 19; break; } else { label = 20; break; }
case 19:
var $94 = 0;label = 21; break;
case 20:
var $87=$2;
var $88=$2;
var $89=(($88+24)|0);
var $90=HEAP32[(($89)>>2)];
var $91=$90;
var $92=_segment_holding($87, $91);
var $94 = $92;label = 21; break;
case 21:
var $94;
$ss=$94;
var $95=$ss;
var $96=(($95)|(0))==0;
if ($96) { label = 22; break; } else { label = 34; break; }
case 22:
var $98=_sbrk(0);
$base=$98;
var $99=$base;
var $100=(($99)|(0))!=-1;
if ($100) { label = 23; break; } else { label = 33; break; }
case 23:
var $102=$base;
var $103=$102;
var $104=HEAP32[((((5243712)|0))>>2)];
var $105=((($104)-(1))|0);
var $106=$103 & $105;
var $107=(($106)|(0))==0;
if ($107) { label = 25; break; } else { label = 24; break; }
case 24:
var $109=$base;
var $110=$109;
var $111=HEAP32[((((5243712)|0))>>2)];
var $112=((($111)-(1))|0);
var $113=((($110)+($112))|0);
var $114=HEAP32[((((5243712)|0))>>2)];
var $115=((($114)-(1))|0);
var $116=$115 ^ -1;
var $117=$113 & $116;
var $118=$base;
var $119=$118;
var $120=((($117)-($119))|0);
var $121=$ssize;
var $122=((($121)+($120))|0);
$ssize=$122;
label = 25; break;
case 25:
var $124=$2;
var $125=(($124+432)|0);
var $126=HEAP32[(($125)>>2)];
var $127=$ssize;
var $128=((($126)+($127))|0);
$fp1=$128;
var $129=$ssize;
var $130=$3;
var $131=(($129)>>>(0)) > (($130)>>>(0));
if ($131) { label = 26; break; } else { label = 32; break; }
case 26:
var $133=$ssize;
var $134=(($133)>>>(0)) < 2147483647;
if ($134) { label = 27; break; } else { label = 32; break; }
case 27:
var $136=$2;
var $137=(($136+440)|0);
var $138=HEAP32[(($137)>>2)];
var $139=(($138)|(0))==0;
if ($139) { label = 30; break; } else { label = 28; break; }
case 28:
var $141=$fp1;
var $142=$2;
var $143=(($142+432)|0);
var $144=HEAP32[(($143)>>2)];
var $145=(($141)>>>(0)) > (($144)>>>(0));
if ($145) { label = 29; break; } else { label = 32; break; }
case 29:
var $147=$fp1;
var $148=$2;
var $149=(($148+440)|0);
var $150=HEAP32[(($149)>>2)];
var $151=(($147)>>>(0)) <= (($150)>>>(0));
if ($151) { label = 30; break; } else { label = 32; break; }
case 30:
var $153=$ssize;
var $154=_sbrk($153);
$br=$154;
var $155=$base;
var $156=(($154)|(0))==(($155)|(0));
if ($156) { label = 31; break; } else { label = 32; break; }
case 31:
var $158=$base;
$tbase=$158;
var $159=$ssize;
$tsize=$159;
label = 32; break;
case 32:
label = 33; break;
case 33:
label = 38; break;
case 34:
var $163=$3;
var $164=$2;
var $165=(($164+12)|0);
var $166=HEAP32[(($165)>>2)];
var $167=((($163)-($166))|0);
var $168=((($167)+(48))|0);
var $169=HEAP32[((((5243716)|0))>>2)];
var $170=((($169)-(1))|0);
var $171=((($168)+($170))|0);
var $172=HEAP32[((((5243716)|0))>>2)];
var $173=((($172)-(1))|0);
var $174=$173 ^ -1;
var $175=$171 & $174;
$ssize=$175;
var $176=$ssize;
var $177=(($176)>>>(0)) < 2147483647;
if ($177) { label = 35; break; } else { label = 37; break; }
case 35:
var $179=$ssize;
var $180=_sbrk($179);
$br=$180;
var $181=$ss;
var $182=(($181)|0);
var $183=HEAP32[(($182)>>2)];
var $184=$ss;
var $185=(($184+4)|0);
var $186=HEAP32[(($185)>>2)];
var $187=(($183+$186)|0);
var $188=(($180)|(0))==(($187)|(0));
if ($188) { label = 36; break; } else { label = 37; break; }
case 36:
var $190=$br;
$tbase=$190;
var $191=$ssize;
$tsize=$191;
label = 37; break;
case 37:
label = 38; break;
case 38:
var $194=$tbase;
var $195=(($194)|(0))==-1;
if ($195) { label = 39; break; } else { label = 53; break; }
case 39:
var $197=$br;
var $198=(($197)|(0))!=-1;
if ($198) { label = 40; break; } else { label = 49; break; }
case 40:
var $200=$ssize;
var $201=(($200)>>>(0)) < 2147483647;
if ($201) { label = 41; break; } else { label = 48; break; }
case 41:
var $203=$ssize;
var $204=$3;
var $205=((($204)+(48))|0);
var $206=(($203)>>>(0)) < (($205)>>>(0));
if ($206) { label = 42; break; } else { label = 48; break; }
case 42:
var $208=$3;
var $209=((($208)+(48))|0);
var $210=$ssize;
var $211=((($209)-($210))|0);
var $212=HEAP32[((((5243716)|0))>>2)];
var $213=((($212)-(1))|0);
var $214=((($211)+($213))|0);
var $215=HEAP32[((((5243716)|0))>>2)];
var $216=((($215)-(1))|0);
var $217=$216 ^ -1;
var $218=$214 & $217;
$esize=$218;
var $219=$esize;
var $220=(($219)>>>(0)) < 2147483647;
if ($220) { label = 43; break; } else { label = 47; break; }
case 43:
var $222=$esize;
var $223=_sbrk($222);
$end=$223;
var $224=$end;
var $225=(($224)|(0))!=-1;
if ($225) { label = 44; break; } else { label = 45; break; }
case 44:
var $227=$esize;
var $228=$ssize;
var $229=((($228)+($227))|0);
$ssize=$229;
label = 46; break;
case 45:
var $231=$ssize;
var $232=(((-$231))|0);
var $233=_sbrk($232);
$br=-1;
label = 46; break;
case 46:
label = 47; break;
case 47:
label = 48; break;
case 48:
label = 49; break;
case 49:
var $238=$br;
var $239=(($238)|(0))!=-1;
if ($239) { label = 50; break; } else { label = 51; break; }
case 50:
var $241=$br;
$tbase=$241;
var $242=$ssize;
$tsize=$242;
label = 52; break;
case 51:
var $244=$2;
var $245=(($244+444)|0);
var $246=HEAP32[(($245)>>2)];
var $247=$246 | 4;
HEAP32[(($245)>>2)]=$247;
label = 52; break;
case 52:
label = 53; break;
case 53:
label = 54; break;
case 54:
var $251=$tbase;
var $252=(($251)|(0))==-1;
if ($252) { label = 55; break; } else { label = 64; break; }
case 55:
var $254=$asize;
var $255=(($254)>>>(0)) < 2147483647;
if ($255) { label = 56; break; } else { label = 63; break; }
case 56:
$br2=-1;
$end3=-1;
var $257=$asize;
var $258=_sbrk($257);
$br2=$258;
var $259=_sbrk(0);
$end3=$259;
var $260=$br2;
var $261=(($260)|(0))!=-1;
if ($261) { label = 57; break; } else { label = 62; break; }
case 57:
var $263=$end3;
var $264=(($263)|(0))!=-1;
if ($264) { label = 58; break; } else { label = 62; break; }
case 58:
var $266=$br2;
var $267=$end3;
var $268=(($266)>>>(0)) < (($267)>>>(0));
if ($268) { label = 59; break; } else { label = 62; break; }
case 59:
var $270=$end3;
var $271=$br2;
var $272=$270;
var $273=$271;
var $274=((($272)-($273))|0);
$ssize4=$274;
var $275=$ssize4;
var $276=$3;
var $277=((($276)+(40))|0);
var $278=(($275)>>>(0)) > (($277)>>>(0));
if ($278) { label = 60; break; } else { label = 61; break; }
case 60:
var $280=$br2;
$tbase=$280;
var $281=$ssize4;
$tsize=$281;
label = 61; break;
case 61:
label = 62; break;
case 62:
label = 63; break;
case 63:
label = 64; break;
case 64:
var $286=$tbase;
var $287=(($286)|(0))!=-1;
if ($287) { label = 65; break; } else { label = 103; break; }
case 65:
var $289=$tsize;
var $290=$2;
var $291=(($290+432)|0);
var $292=HEAP32[(($291)>>2)];
var $293=((($292)+($289))|0);
HEAP32[(($291)>>2)]=$293;
var $294=$2;
var $295=(($294+436)|0);
var $296=HEAP32[(($295)>>2)];
var $297=(($293)>>>(0)) > (($296)>>>(0));
if ($297) { label = 66; break; } else { label = 67; break; }
case 66:
var $299=$2;
var $300=(($299+432)|0);
var $301=HEAP32[(($300)>>2)];
var $302=$2;
var $303=(($302+436)|0);
HEAP32[(($303)>>2)]=$301;
label = 67; break;
case 67:
var $305=$2;
var $306=(($305+24)|0);
var $307=HEAP32[(($306)>>2)];
var $308=(($307)|(0))!=0;
if ($308) { label = 75; break; } else { label = 68; break; }
case 68:
var $310=$2;
var $311=(($310+16)|0);
var $312=HEAP32[(($311)>>2)];
var $313=(($312)|(0))==0;
if ($313) { label = 70; break; } else { label = 69; break; }
case 69:
var $315=$tbase;
var $316=$2;
var $317=(($316+16)|0);
var $318=HEAP32[(($317)>>2)];
var $319=(($315)>>>(0)) < (($318)>>>(0));
if ($319) { label = 70; break; } else { label = 71; break; }
case 70:
var $321=$tbase;
var $322=$2;
var $323=(($322+16)|0);
HEAP32[(($323)>>2)]=$321;
label = 71; break;
case 71:
var $325=$tbase;
var $326=$2;
var $327=(($326+448)|0);
var $328=(($327)|0);
HEAP32[(($328)>>2)]=$325;
var $329=$tsize;
var $330=$2;
var $331=(($330+448)|0);
var $332=(($331+4)|0);
HEAP32[(($332)>>2)]=$329;
var $333=$mmap_flag;
var $334=$2;
var $335=(($334+448)|0);
var $336=(($335+12)|0);
HEAP32[(($336)>>2)]=$333;
var $337=HEAP32[((((5243708)|0))>>2)];
var $338=$2;
var $339=(($338+36)|0);
HEAP32[(($339)>>2)]=$337;
var $340=$2;
var $341=(($340+32)|0);
HEAP32[(($341)>>2)]=-1;
var $342=$2;
_init_bins($342);
var $343=$2;
var $344=(($343)|(0))==5244144;
if ($344) { label = 72; break; } else { label = 73; break; }
case 72:
var $346=$2;
var $347=$tbase;
var $348=$347;
var $349=$tsize;
var $350=((($349)-(40))|0);
_init_top($346, $348, $350);
label = 74; break;
case 73:
var $352=$2;
var $353=$352;
var $354=((($353)-(8))|0);
var $355=$354;
var $356=$355;
var $357=$2;
var $358=$357;
var $359=((($358)-(8))|0);
var $360=$359;
var $361=(($360+4)|0);
var $362=HEAP32[(($361)>>2)];
var $363=$362 & -8;
var $364=(($356+$363)|0);
var $365=$364;
$mn=$365;
var $366=$2;
var $367=$mn;
var $368=$tbase;
var $369=$tsize;
var $370=(($368+$369)|0);
var $371=$mn;
var $372=$371;
var $373=$370;
var $374=$372;
var $375=((($373)-($374))|0);
var $376=((($375)-(40))|0);
_init_top($366, $367, $376);
label = 74; break;
case 74:
label = 100; break;
case 75:
var $379=$2;
var $380=(($379+448)|0);
$sp=$380;
label = 76; break;
case 76:
var $382=$sp;
var $383=(($382)|(0))!=0;
if ($383) { label = 77; break; } else { var $395 = 0;label = 78; break; }
case 77:
var $385=$tbase;
var $386=$sp;
var $387=(($386)|0);
var $388=HEAP32[(($387)>>2)];
var $389=$sp;
var $390=(($389+4)|0);
var $391=HEAP32[(($390)>>2)];
var $392=(($388+$391)|0);
var $393=(($385)|(0))!=(($392)|(0));
var $395 = $393;label = 78; break;
case 78:
var $395;
if ($395) { label = 79; break; } else { label = 80; break; }
case 79:
var $397=$sp;
var $398=(($397+8)|0);
var $399=HEAP32[(($398)>>2)];
$sp=$399;
label = 76; break;
case 80:
var $401=$sp;
var $402=(($401)|(0))!=0;
if ($402) { label = 81; break; } else { label = 86; break; }
case 81:
var $404=$sp;
var $405=(($404+12)|0);
var $406=HEAP32[(($405)>>2)];
var $407=$406 & 8;
var $408=(($407)|(0))!=0;
if ($408) { label = 86; break; } else { label = 82; break; }
case 82:
var $410=$sp;
var $411=(($410+12)|0);
var $412=HEAP32[(($411)>>2)];
var $413=$412 & 0;
var $414=$mmap_flag;
var $415=(($413)|(0))==(($414)|(0));
if ($415) { label = 83; break; } else { label = 86; break; }
case 83:
var $417=$2;
var $418=(($417+24)|0);
var $419=HEAP32[(($418)>>2)];
var $420=$419;
var $421=$sp;
var $422=(($421)|0);
var $423=HEAP32[(($422)>>2)];
var $424=(($420)>>>(0)) >= (($423)>>>(0));
if ($424) { label = 84; break; } else { label = 86; break; }
case 84:
var $426=$2;
var $427=(($426+24)|0);
var $428=HEAP32[(($427)>>2)];
var $429=$428;
var $430=$sp;
var $431=(($430)|0);
var $432=HEAP32[(($431)>>2)];
var $433=$sp;
var $434=(($433+4)|0);
var $435=HEAP32[(($434)>>2)];
var $436=(($432+$435)|0);
var $437=(($429)>>>(0)) < (($436)>>>(0));
if ($437) { label = 85; break; } else { label = 86; break; }
case 85:
var $439=$tsize;
var $440=$sp;
var $441=(($440+4)|0);
var $442=HEAP32[(($441)>>2)];
var $443=((($442)+($439))|0);
HEAP32[(($441)>>2)]=$443;
var $444=$2;
var $445=$2;
var $446=(($445+24)|0);
var $447=HEAP32[(($446)>>2)];
var $448=$2;
var $449=(($448+12)|0);
var $450=HEAP32[(($449)>>2)];
var $451=$tsize;
var $452=((($450)+($451))|0);
_init_top($444, $447, $452);
label = 99; break;
case 86:
var $454=$tbase;
var $455=$2;
var $456=(($455+16)|0);
var $457=HEAP32[(($456)>>2)];
var $458=(($454)>>>(0)) < (($457)>>>(0));
if ($458) { label = 87; break; } else { label = 88; break; }
case 87:
var $460=$tbase;
var $461=$2;
var $462=(($461+16)|0);
HEAP32[(($462)>>2)]=$460;
label = 88; break;
case 88:
var $464=$2;
var $465=(($464+448)|0);
$sp=$465;
label = 89; break;
case 89:
var $467=$sp;
var $468=(($467)|(0))!=0;
if ($468) { label = 90; break; } else { var $478 = 0;label = 91; break; }
case 90:
var $470=$sp;
var $471=(($470)|0);
var $472=HEAP32[(($471)>>2)];
var $473=$tbase;
var $474=$tsize;
var $475=(($473+$474)|0);
var $476=(($472)|(0))!=(($475)|(0));
var $478 = $476;label = 91; break;
case 91:
var $478;
if ($478) { label = 92; break; } else { label = 93; break; }
case 92:
var $480=$sp;
var $481=(($480+8)|0);
var $482=HEAP32[(($481)>>2)];
$sp=$482;
label = 89; break;
case 93:
var $484=$sp;
var $485=(($484)|(0))!=0;
if ($485) { label = 94; break; } else { label = 97; break; }
case 94:
var $487=$sp;
var $488=(($487+12)|0);
var $489=HEAP32[(($488)>>2)];
var $490=$489 & 8;
var $491=(($490)|(0))!=0;
if ($491) { label = 97; break; } else { label = 95; break; }
case 95:
var $493=$sp;
var $494=(($493+12)|0);
var $495=HEAP32[(($494)>>2)];
var $496=$495 & 0;
var $497=$mmap_flag;
var $498=(($496)|(0))==(($497)|(0));
if ($498) { label = 96; break; } else { label = 97; break; }
case 96:
var $500=$sp;
var $501=(($500)|0);
var $502=HEAP32[(($501)>>2)];
$oldbase=$502;
var $503=$tbase;
var $504=$sp;
var $505=(($504)|0);
HEAP32[(($505)>>2)]=$503;
var $506=$tsize;
var $507=$sp;
var $508=(($507+4)|0);
var $509=HEAP32[(($508)>>2)];
var $510=((($509)+($506))|0);
HEAP32[(($508)>>2)]=$510;
var $511=$2;
var $512=$tbase;
var $513=$oldbase;
var $514=$3;
var $515=_prepend_alloc($511, $512, $513, $514);
$1=$515;
label = 104; break;
case 97:
var $517=$2;
var $518=$tbase;
var $519=$tsize;
var $520=$mmap_flag;
_add_segment($517, $518, $519, $520);
label = 98; break;
case 98:
label = 99; break;
case 99:
label = 100; break;
case 100:
var $524=$3;
var $525=$2;
var $526=(($525+12)|0);
var $527=HEAP32[(($526)>>2)];
var $528=(($524)>>>(0)) < (($527)>>>(0));
if ($528) { label = 101; break; } else { label = 102; break; }
case 101:
var $530=$3;
var $531=$2;
var $532=(($531+12)|0);
var $533=HEAP32[(($532)>>2)];
var $534=((($533)-($530))|0);
HEAP32[(($532)>>2)]=$534;
$rsize=$534;
var $535=$2;
var $536=(($535+24)|0);
var $537=HEAP32[(($536)>>2)];
$p=$537;
var $538=$p;
var $539=$538;
var $540=$3;
var $541=(($539+$540)|0);
var $542=$541;
var $543=$2;
var $544=(($543+24)|0);
HEAP32[(($544)>>2)]=$542;
$r=$542;
var $545=$rsize;
var $546=$545 | 1;
var $547=$r;
var $548=(($547+4)|0);
HEAP32[(($548)>>2)]=$546;
var $549=$3;
var $550=$549 | 1;
var $551=$550 | 2;
var $552=$p;
var $553=(($552+4)|0);
HEAP32[(($553)>>2)]=$551;
var $554=$p;
var $555=$554;
var $556=(($555+8)|0);
$1=$556;
label = 104; break;
case 102:
label = 103; break;
case 103:
var $559=___errno_location();
HEAP32[(($559)>>2)]=12;
$1=0;
label = 104; break;
case 104:
var $561=$1;
return $561;
default: assert(0, "bad label: " + label);
}
}
function _calloc($n_elements, $elem_size) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $mem;
var $req;
$1=$n_elements;
$2=$elem_size;
$req=0;
var $3=$1;
var $4=(($3)|(0))!=0;
if ($4) { label = 3; break; } else { label = 7; break; }
case 3:
var $6=$1;
var $7=$2;
var $8=Math.imul($6,$7);
$req=$8;
var $9=$1;
var $10=$2;
var $11=$9 | $10;
var $12=$11 & -65536;
var $13=(($12)|(0))!=0;
if ($13) { label = 4; break; } else { label = 6; break; }
case 4:
var $15=$req;
var $16=$1;
var $17=Math.floor(((($15)>>>(0)))/((($16)>>>(0))));
var $18=$2;
var $19=(($17)|(0))!=(($18)|(0));
if ($19) { label = 5; break; } else { label = 6; break; }
case 5:
$req=-1;
label = 6; break;
case 6:
label = 7; break;
case 7:
var $23=$req;
var $24=_malloc($23);
$mem=$24;
var $25=$mem;
var $26=(($25)|(0))!=0;
if ($26) { label = 8; break; } else { label = 10; break; }
case 8:
var $28=$mem;
var $29=((($28)-(8))|0);
var $30=$29;
var $31=(($30+4)|0);
var $32=HEAP32[(($31)>>2)];
var $33=$32 & 3;
var $34=(($33)|(0))==0;
if ($34) { label = 10; break; } else { label = 9; break; }
case 9:
var $36=$mem;
var $37=$req;
_memset($36, 0, $37);
label = 10; break;
case 10:
var $39=$mem;
return $39;
default: assert(0, "bad label: " + label);
}
}
Module["_calloc"] = _calloc;
function _init_mparams() {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $magic;
var $psize;
var $gsize;
var $1=HEAP32[((((5243708)|0))>>2)];
var $2=(($1)|(0))==0;
if ($2) { label = 3; break; } else { label = 7; break; }
case 3:
var $4=_sysconf(8);
$psize=$4;
var $5=$psize;
$gsize=$5;
var $6=$gsize;
var $7=$gsize;
var $8=((($7)-(1))|0);
var $9=$6 & $8;
var $10=(($9)|(0))!=0;
if ($10) { label = 5; break; } else { label = 4; break; }
case 4:
var $12=$psize;
var $13=$psize;
var $14=((($13)-(1))|0);
var $15=$12 & $14;
var $16=(($15)|(0))!=0;
if ($16) { label = 5; break; } else { label = 6; break; }
case 5:
_abort();
throw "Reached an unreachable!"
case 6:
var $19=$gsize;
HEAP32[((((5243716)|0))>>2)]=$19;
var $20=$psize;
HEAP32[((((5243712)|0))>>2)]=$20;
HEAP32[((((5243720)|0))>>2)]=-1;
HEAP32[((((5243724)|0))>>2)]=2097152;
HEAP32[((((5243728)|0))>>2)]=0;
var $21=HEAP32[((((5243728)|0))>>2)];
HEAP32[((((5244588)|0))>>2)]=$21;
var $22=_time(0);
var $23=$22 ^ 1431655765;
$magic=$23;
var $24=$magic;
var $25=$24 | 8;
$magic=$25;
var $26=$magic;
var $27=$26 & -8;
$magic=$27;
var $28=$magic;
HEAP32[((((5243708)|0))>>2)]=$28;
label = 7; break;
case 7:
return 1;
default: assert(0, "bad label: " + label);
}
}
function _segment_holding($m, $addr) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $sp;
$2=$m;
$3=$addr;
var $4=$2;
var $5=(($4+448)|0);
$sp=$5;
label = 3; break;
case 3:
var $7=$3;
var $8=$sp;
var $9=(($8)|0);
var $10=HEAP32[(($9)>>2)];
var $11=(($7)>>>(0)) >= (($10)>>>(0));
if ($11) { label = 4; break; } else { label = 6; break; }
case 4:
var $13=$3;
var $14=$sp;
var $15=(($14)|0);
var $16=HEAP32[(($15)>>2)];
var $17=$sp;
var $18=(($17+4)|0);
var $19=HEAP32[(($18)>>2)];
var $20=(($16+$19)|0);
var $21=(($13)>>>(0)) < (($20)>>>(0));
if ($21) { label = 5; break; } else { label = 6; break; }
case 5:
var $23=$sp;
$1=$23;
label = 9; break;
case 6:
var $25=$sp;
var $26=(($25+8)|0);
var $27=HEAP32[(($26)>>2)];
$sp=$27;
var $28=(($27)|(0))==0;
if ($28) { label = 7; break; } else { label = 8; break; }
case 7:
$1=0;
label = 9; break;
case 8:
label = 3; break;
case 9:
var $32=$1;
return $32;
default: assert(0, "bad label: " + label);
}
}
function _init_top($m, $p, $psize) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $offset;
$1=$m;
$2=$p;
$3=$psize;
var $4=$2;
var $5=$4;
var $6=(($5+8)|0);
var $7=$6;
var $8=$7 & 7;
var $9=(($8)|(0))==0;
if ($9) { label = 3; break; } else { label = 4; break; }
case 3:
var $20 = 0;label = 5; break;
case 4:
var $12=$2;
var $13=$12;
var $14=(($13+8)|0);
var $15=$14;
var $16=$15 & 7;
var $17=(((8)-($16))|0);
var $18=$17 & 7;
var $20 = $18;label = 5; break;
case 5:
var $20;
$offset=$20;
var $21=$2;
var $22=$21;
var $23=$offset;
var $24=(($22+$23)|0);
var $25=$24;
$2=$25;
var $26=$offset;
var $27=$3;
var $28=((($27)-($26))|0);
$3=$28;
var $29=$2;
var $30=$1;
var $31=(($30+24)|0);
HEAP32[(($31)>>2)]=$29;
var $32=$3;
var $33=$1;
var $34=(($33+12)|0);
HEAP32[(($34)>>2)]=$32;
var $35=$3;
var $36=$35 | 1;
var $37=$2;
var $38=(($37+4)|0);
HEAP32[(($38)>>2)]=$36;
var $39=$2;
var $40=$39;
var $41=$3;
var $42=(($40+$41)|0);
var $43=$42;
var $44=(($43+4)|0);
HEAP32[(($44)>>2)]=40;
var $45=HEAP32[((((5243724)|0))>>2)];
var $46=$1;
var $47=(($46+28)|0);
HEAP32[(($47)>>2)]=$45;
return;
default: assert(0, "bad label: " + label);
}
}
function _mmap_alloc($m, $nb) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $mmsize;
var $fp;
var $mm;
var $offset;
var $psize;
var $p;
$2=$m;
$3=$nb;
var $4=$3;
var $5=((($4)+(24))|0);
var $6=((($5)+(7))|0);
var $7=HEAP32[((((5243712)|0))>>2)];
var $8=((($7)-(1))|0);
var $9=((($6)+($8))|0);
var $10=HEAP32[((((5243712)|0))>>2)];
var $11=((($10)-(1))|0);
var $12=$11 ^ -1;
var $13=$9 & $12;
$mmsize=$13;
var $14=$2;
var $15=(($14+440)|0);
var $16=HEAP32[(($15)>>2)];
var $17=(($16)|(0))!=0;
if ($17) { label = 3; break; } else { label = 7; break; }
case 3:
var $19=$2;
var $20=(($19+432)|0);
var $21=HEAP32[(($20)>>2)];
var $22=$mmsize;
var $23=((($21)+($22))|0);
$fp=$23;
var $24=$fp;
var $25=$2;
var $26=(($25+432)|0);
var $27=HEAP32[(($26)>>2)];
var $28=(($24)>>>(0)) <= (($27)>>>(0));
if ($28) { label = 5; break; } else { label = 4; break; }
case 4:
var $30=$fp;
var $31=$2;
var $32=(($31+440)|0);
var $33=HEAP32[(($32)>>2)];
var $34=(($30)>>>(0)) > (($33)>>>(0));
if ($34) { label = 5; break; } else { label = 6; break; }
case 5:
$1=0;
label = 20; break;
case 6:
label = 7; break;
case 7:
var $38=$mmsize;
var $39=$3;
var $40=(($38)>>>(0)) > (($39)>>>(0));
if ($40) { label = 8; break; } else { label = 19; break; }
case 8:
$mm=-1;
var $42=$mm;
var $43=(($42)|(0))!=-1;
if ($43) { label = 9; break; } else { label = 18; break; }
case 9:
var $45=$mm;
var $46=(($45+8)|0);
var $47=$46;
var $48=$47 & 7;
var $49=(($48)|(0))==0;
if ($49) { label = 10; break; } else { label = 11; break; }
case 10:
var $59 = 0;label = 12; break;
case 11:
var $52=$mm;
var $53=(($52+8)|0);
var $54=$53;
var $55=$54 & 7;
var $56=(((8)-($55))|0);
var $57=$56 & 7;
var $59 = $57;label = 12; break;
case 12:
var $59;
$offset=$59;
var $60=$mmsize;
var $61=$offset;
var $62=((($60)-($61))|0);
var $63=((($62)-(16))|0);
$psize=$63;
var $64=$mm;
var $65=$offset;
var $66=(($64+$65)|0);
var $67=$66;
$p=$67;
var $68=$offset;
var $69=$p;
var $70=(($69)|0);
HEAP32[(($70)>>2)]=$68;
var $71=$psize;
var $72=$p;
var $73=(($72+4)|0);
HEAP32[(($73)>>2)]=$71;
var $74=$p;
var $75=$74;
var $76=$psize;
var $77=(($75+$76)|0);
var $78=$77;
var $79=(($78+4)|0);
HEAP32[(($79)>>2)]=7;
var $80=$p;
var $81=$80;
var $82=$psize;
var $83=((($82)+(4))|0);
var $84=(($81+$83)|0);
var $85=$84;
var $86=(($85+4)|0);
HEAP32[(($86)>>2)]=0;
var $87=$2;
var $88=(($87+16)|0);
var $89=HEAP32[(($88)>>2)];
var $90=(($89)|(0))==0;
if ($90) { label = 14; break; } else { label = 13; break; }
case 13:
var $92=$mm;
var $93=$2;
var $94=(($93+16)|0);
var $95=HEAP32[(($94)>>2)];
var $96=(($92)>>>(0)) < (($95)>>>(0));
if ($96) { label = 14; break; } else { label = 15; break; }
case 14:
var $98=$mm;
var $99=$2;
var $100=(($99+16)|0);
HEAP32[(($100)>>2)]=$98;
label = 15; break;
case 15:
var $102=$mmsize;
var $103=$2;
var $104=(($103+432)|0);
var $105=HEAP32[(($104)>>2)];
var $106=((($105)+($102))|0);
HEAP32[(($104)>>2)]=$106;
var $107=$2;
var $108=(($107+436)|0);
var $109=HEAP32[(($108)>>2)];
var $110=(($106)>>>(0)) > (($109)>>>(0));
if ($110) { label = 16; break; } else { label = 17; break; }
case 16:
var $112=$2;
var $113=(($112+432)|0);
var $114=HEAP32[(($113)>>2)];
var $115=$2;
var $116=(($115+436)|0);
HEAP32[(($116)>>2)]=$114;
label = 17; break;
case 17:
var $118=$p;
var $119=$118;
var $120=(($119+8)|0);
$1=$120;
label = 20; break;
case 18:
label = 19; break;
case 19:
$1=0;
label = 20; break;
case 20:
var $124=$1;
return $124;
default: assert(0, "bad label: " + label);
}
}
function _init_bins($m) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $i;
var $bin;
$1=$m;
$i=0;
label = 3; break;
case 3:
var $3=$i;
var $4=(($3)>>>(0)) < 32;
if ($4) { label = 4; break; } else { label = 6; break; }
case 4:
var $6=$i;
var $7=$6 << 1;
var $8=$1;
var $9=(($8+40)|0);
var $10=(($9+($7<<2))|0);
var $11=$10;
var $12=$11;
$bin=$12;
var $13=$bin;
var $14=$bin;
var $15=(($14+12)|0);
HEAP32[(($15)>>2)]=$13;
var $16=$bin;
var $17=(($16+8)|0);
HEAP32[(($17)>>2)]=$13;
label = 5; break;
case 5:
var $19=$i;
var $20=((($19)+(1))|0);
$i=$20;
label = 3; break;
case 6:
return;
default: assert(0, "bad label: " + label);
}
}
function _prepend_alloc($m, $newbase, $oldbase, $nb) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $4;
var $p;
var $oldfirst;
var $psize;
var $q;
var $qsize;
var $tsize;
var $dsize;
var $nsize;
var $F;
var $B;
var $I;
var $TP;
var $XP;
var $R;
var $F1;
var $RP;
var $CP;
var $H;
var $C0;
var $C1;
var $I2;
var $B3;
var $F4;
var $TP5;
var $H6;
var $I7;
var $X;
var $Y;
var $N;
var $K;
var $T;
var $K8;
var $C;
var $F9;
$1=$m;
$2=$newbase;
$3=$oldbase;
$4=$nb;
var $5=$2;
var $6=$2;
var $7=(($6+8)|0);
var $8=$7;
var $9=$8 & 7;
var $10=(($9)|(0))==0;
if ($10) { label = 3; break; } else { label = 4; break; }
case 3:
var $20 = 0;label = 5; break;
case 4:
var $13=$2;
var $14=(($13+8)|0);
var $15=$14;
var $16=$15 & 7;
var $17=(((8)-($16))|0);
var $18=$17 & 7;
var $20 = $18;label = 5; break;
case 5:
var $20;
var $21=(($5+$20)|0);
var $22=$21;
$p=$22;
var $23=$3;
var $24=$3;
var $25=(($24+8)|0);
var $26=$25;
var $27=$26 & 7;
var $28=(($27)|(0))==0;
if ($28) { label = 6; break; } else { label = 7; break; }
case 6:
var $38 = 0;label = 8; break;
case 7:
var $31=$3;
var $32=(($31+8)|0);
var $33=$32;
var $34=$33 & 7;
var $35=(((8)-($34))|0);
var $36=$35 & 7;
var $38 = $36;label = 8; break;
case 8:
var $38;
var $39=(($23+$38)|0);
var $40=$39;
$oldfirst=$40;
var $41=$oldfirst;
var $42=$41;
var $43=$p;
var $44=$43;
var $45=$42;
var $46=$44;
var $47=((($45)-($46))|0);
$psize=$47;
var $48=$p;
var $49=$48;
var $50=$4;
var $51=(($49+$50)|0);
var $52=$51;
$q=$52;
var $53=$psize;
var $54=$4;
var $55=((($53)-($54))|0);
$qsize=$55;
var $56=$4;
var $57=$56 | 1;
var $58=$57 | 2;
var $59=$p;
var $60=(($59+4)|0);
HEAP32[(($60)>>2)]=$58;
var $61=$oldfirst;
var $62=$1;
var $63=(($62+24)|0);
var $64=HEAP32[(($63)>>2)];
var $65=(($61)|(0))==(($64)|(0));
if ($65) { label = 9; break; } else { label = 10; break; }
case 9:
var $67=$qsize;
var $68=$1;
var $69=(($68+12)|0);
var $70=HEAP32[(($69)>>2)];
var $71=((($70)+($67))|0);
HEAP32[(($69)>>2)]=$71;
$tsize=$71;
var $72=$q;
var $73=$1;
var $74=(($73+24)|0);
HEAP32[(($74)>>2)]=$72;
var $75=$tsize;
var $76=$75 | 1;
var $77=$q;
var $78=(($77+4)|0);
HEAP32[(($78)>>2)]=$76;
label = 119; break;
case 10:
var $80=$oldfirst;
var $81=$1;
var $82=(($81+20)|0);
var $83=HEAP32[(($82)>>2)];
var $84=(($80)|(0))==(($83)|(0));
if ($84) { label = 11; break; } else { label = 12; break; }
case 11:
var $86=$qsize;
var $87=$1;
var $88=(($87+8)|0);
var $89=HEAP32[(($88)>>2)];
var $90=((($89)+($86))|0);
HEAP32[(($88)>>2)]=$90;
$dsize=$90;
var $91=$q;
var $92=$1;
var $93=(($92+20)|0);
HEAP32[(($93)>>2)]=$91;
var $94=$dsize;
var $95=$94 | 1;
var $96=$q;
var $97=(($96+4)|0);
HEAP32[(($97)>>2)]=$95;
var $98=$dsize;
var $99=$q;
var $100=$99;
var $101=$dsize;
var $102=(($100+$101)|0);
var $103=$102;
var $104=(($103)|0);
HEAP32[(($104)>>2)]=$98;
label = 118; break;
case 12:
var $106=$oldfirst;
var $107=(($106+4)|0);
var $108=HEAP32[(($107)>>2)];
var $109=$108 & 3;
var $110=(($109)|(0))!=1;
if ($110) { label = 82; break; } else { label = 13; break; }
case 13:
var $112=$oldfirst;
var $113=(($112+4)|0);
var $114=HEAP32[(($113)>>2)];
var $115=$114 & -8;
$nsize=$115;
var $116=$nsize;
var $117=$116 >>> 3;
var $118=(($117)>>>(0)) < 32;
if ($118) { label = 14; break; } else { label = 32; break; }
case 14:
var $120=$oldfirst;
var $121=(($120+8)|0);
var $122=HEAP32[(($121)>>2)];
$F=$122;
var $123=$oldfirst;
var $124=(($123+12)|0);
var $125=HEAP32[(($124)>>2)];
$B=$125;
var $126=$nsize;
var $127=$126 >>> 3;
$I=$127;
var $128=$F;
var $129=$I;
var $130=$129 << 1;
var $131=$1;
var $132=(($131+40)|0);
var $133=(($132+($130<<2))|0);
var $134=$133;
var $135=$134;
var $136=(($128)|(0))==(($135)|(0));
if ($136) { var $153 = 1;label = 18; break; } else { label = 15; break; }
case 15:
var $138=$F;
var $139=$138;
var $140=$1;
var $141=(($140+16)|0);
var $142=HEAP32[(($141)>>2)];
var $143=(($139)>>>(0)) >= (($142)>>>(0));
if ($143) { label = 16; break; } else { var $151 = 0;label = 17; break; }
case 16:
var $145=$F;
var $146=(($145+12)|0);
var $147=HEAP32[(($146)>>2)];
var $148=$oldfirst;
var $149=(($147)|(0))==(($148)|(0));
var $151 = $149;label = 17; break;
case 17:
var $151;
var $153 = $151;label = 18; break;
case 18:
var $153;
var $154=(($153)&(1));
var $155=($154);
var $156=(($155)|(0))!=0;
if ($156) { label = 19; break; } else { label = 30; break; }
case 19:
var $158=$B;
var $159=$F;
var $160=(($158)|(0))==(($159)|(0));
if ($160) { label = 20; break; } else { label = 21; break; }
case 20:
var $162=$I;
var $163=1 << $162;
var $164=$163 ^ -1;
var $165=$1;
var $166=(($165)|0);
var $167=HEAP32[(($166)>>2)];
var $168=$167 & $164;
HEAP32[(($166)>>2)]=$168;
label = 29; break;
case 21:
var $170=$B;
var $171=$I;
var $172=$171 << 1;
var $173=$1;
var $174=(($173+40)|0);
var $175=(($174+($172<<2))|0);
var $176=$175;
var $177=$176;
var $178=(($170)|(0))==(($177)|(0));
if ($178) { var $195 = 1;label = 25; break; } else { label = 22; break; }
case 22:
var $180=$B;
var $181=$180;
var $182=$1;
var $183=(($182+16)|0);
var $184=HEAP32[(($183)>>2)];
var $185=(($181)>>>(0)) >= (($184)>>>(0));
if ($185) { label = 23; break; } else { var $193 = 0;label = 24; break; }
case 23:
var $187=$B;
var $188=(($187+8)|0);
var $189=HEAP32[(($188)>>2)];
var $190=$oldfirst;
var $191=(($189)|(0))==(($190)|(0));
var $193 = $191;label = 24; break;
case 24:
var $193;
var $195 = $193;label = 25; break;
case 25:
var $195;
var $196=(($195)&(1));
var $197=($196);
var $198=(($197)|(0))!=0;
if ($198) { label = 26; break; } else { label = 27; break; }
case 26:
var $200=$B;
var $201=$F;
var $202=(($201+12)|0);
HEAP32[(($202)>>2)]=$200;
var $203=$F;
var $204=$B;
var $205=(($204+8)|0);
HEAP32[(($205)>>2)]=$203;
label = 28; break;
case 27:
_abort();
throw "Reached an unreachable!"
case 28:
label = 29; break;
case 29:
label = 31; break;
case 30:
_abort();
throw "Reached an unreachable!"
case 31:
label = 81; break;
case 32:
var $212=$oldfirst;
var $213=$212;
$TP=$213;
var $214=$TP;
var $215=(($214+24)|0);
var $216=HEAP32[(($215)>>2)];
$XP=$216;
var $217=$TP;
var $218=(($217+12)|0);
var $219=HEAP32[(($218)>>2)];
var $220=$TP;
var $221=(($219)|(0))!=(($220)|(0));
if ($221) { label = 33; break; } else { label = 40; break; }
case 33:
var $223=$TP;
var $224=(($223+8)|0);
var $225=HEAP32[(($224)>>2)];
$F1=$225;
var $226=$TP;
var $227=(($226+12)|0);
var $228=HEAP32[(($227)>>2)];
$R=$228;
var $229=$F1;
var $230=$229;
var $231=$1;
var $232=(($231+16)|0);
var $233=HEAP32[(($232)>>2)];
var $234=(($230)>>>(0)) >= (($233)>>>(0));
if ($234) { label = 34; break; } else { var $248 = 0;label = 36; break; }
case 34:
var $236=$F1;
var $237=(($236+12)|0);
var $238=HEAP32[(($237)>>2)];
var $239=$TP;
var $240=(($238)|(0))==(($239)|(0));
if ($240) { label = 35; break; } else { var $248 = 0;label = 36; break; }
case 35:
var $242=$R;
var $243=(($242+8)|0);
var $244=HEAP32[(($243)>>2)];
var $245=$TP;
var $246=(($244)|(0))==(($245)|(0));
var $248 = $246;label = 36; break;
case 36:
var $248;
var $249=(($248)&(1));
var $250=($249);
var $251=(($250)|(0))!=0;
if ($251) { label = 37; break; } else { label = 38; break; }
case 37:
var $253=$R;
var $254=$F1;
var $255=(($254+12)|0);
HEAP32[(($255)>>2)]=$253;
var $256=$F1;
var $257=$R;
var $258=(($257+8)|0);
HEAP32[(($258)>>2)]=$256;
label = 39; break;
case 38:
_abort();
throw "Reached an unreachable!"
case 39:
label = 52; break;
case 40:
var $262=$TP;
var $263=(($262+16)|0);
var $264=(($263+4)|0);
$RP=$264;
var $265=HEAP32[(($264)>>2)];
$R=$265;
var $266=(($265)|(0))!=0;
if ($266) { label = 42; break; } else { label = 41; break; }
case 41:
var $268=$TP;
var $269=(($268+16)|0);
var $270=(($269)|0);
$RP=$270;
var $271=HEAP32[(($270)>>2)];
$R=$271;
var $272=(($271)|(0))!=0;
if ($272) { label = 42; break; } else { label = 51; break; }
case 42:
label = 43; break;
case 43:
var $275=$R;
var $276=(($275+16)|0);
var $277=(($276+4)|0);
$CP=$277;
var $278=HEAP32[(($277)>>2)];
var $279=(($278)|(0))!=0;
if ($279) { var $287 = 1;label = 45; break; } else { label = 44; break; }
case 44:
var $281=$R;
var $282=(($281+16)|0);
var $283=(($282)|0);
$CP=$283;
var $284=HEAP32[(($283)>>2)];
var $285=(($284)|(0))!=0;
var $287 = $285;label = 45; break;
case 45:
var $287;
if ($287) { label = 46; break; } else { label = 47; break; }
case 46:
var $289=$CP;
$RP=$289;
var $290=HEAP32[(($289)>>2)];
$R=$290;
label = 43; break;
case 47:
var $292=$RP;
var $293=$292;
var $294=$1;
var $295=(($294+16)|0);
var $296=HEAP32[(($295)>>2)];
var $297=(($293)>>>(0)) >= (($296)>>>(0));
var $298=(($297)&(1));
var $299=($298);
var $300=(($299)|(0))!=0;
if ($300) { label = 48; break; } else { label = 49; break; }
case 48:
var $302=$RP;
HEAP32[(($302)>>2)]=0;
label = 50; break;
case 49:
_abort();
throw "Reached an unreachable!"
case 50:
label = 51; break;
case 51:
label = 52; break;
case 52:
var $307=$XP;
var $308=(($307)|(0))!=0;
if ($308) { label = 53; break; } else { label = 80; break; }
case 53:
var $310=$TP;
var $311=(($310+28)|0);
var $312=HEAP32[(($311)>>2)];
var $313=$1;
var $314=(($313+304)|0);
var $315=(($314+($312<<2))|0);
$H=$315;
var $316=$TP;
var $317=$H;
var $318=HEAP32[(($317)>>2)];
var $319=(($316)|(0))==(($318)|(0));
if ($319) { label = 54; break; } else { label = 57; break; }
case 54:
var $321=$R;
var $322=$H;
HEAP32[(($322)>>2)]=$321;
var $323=(($321)|(0))==0;
if ($323) { label = 55; break; } else { label = 56; break; }
case 55:
var $325=$TP;
var $326=(($325+28)|0);
var $327=HEAP32[(($326)>>2)];
var $328=1 << $327;
var $329=$328 ^ -1;
var $330=$1;
var $331=(($330+4)|0);
var $332=HEAP32[(($331)>>2)];
var $333=$332 & $329;
HEAP32[(($331)>>2)]=$333;
label = 56; break;
case 56:
label = 64; break;
case 57:
var $336=$XP;
var $337=$336;
var $338=$1;
var $339=(($338+16)|0);
var $340=HEAP32[(($339)>>2)];
var $341=(($337)>>>(0)) >= (($340)>>>(0));
var $342=(($341)&(1));
var $343=($342);
var $344=(($343)|(0))!=0;
if ($344) { label = 58; break; } else { label = 62; break; }
case 58:
var $346=$XP;
var $347=(($346+16)|0);
var $348=(($347)|0);
var $349=HEAP32[(($348)>>2)];
var $350=$TP;
var $351=(($349)|(0))==(($350)|(0));
if ($351) { label = 59; break; } else { label = 60; break; }
case 59:
var $353=$R;
var $354=$XP;
var $355=(($354+16)|0);
var $356=(($355)|0);
HEAP32[(($356)>>2)]=$353;
label = 61; break;
case 60:
var $358=$R;
var $359=$XP;
var $360=(($359+16)|0);
var $361=(($360+4)|0);
HEAP32[(($361)>>2)]=$358;
label = 61; break;
case 61:
label = 63; break;
case 62:
_abort();
throw "Reached an unreachable!"
case 63:
label = 64; break;
case 64:
var $366=$R;
var $367=(($366)|(0))!=0;
if ($367) { label = 65; break; } else { label = 79; break; }
case 65:
var $369=$R;
var $370=$369;
var $371=$1;
var $372=(($371+16)|0);
var $373=HEAP32[(($372)>>2)];
var $374=(($370)>>>(0)) >= (($373)>>>(0));
var $375=(($374)&(1));
var $376=($375);
var $377=(($376)|(0))!=0;
if ($377) { label = 66; break; } else { label = 77; break; }
case 66:
var $379=$XP;
var $380=$R;
var $381=(($380+24)|0);
HEAP32[(($381)>>2)]=$379;
var $382=$TP;
var $383=(($382+16)|0);
var $384=(($383)|0);
var $385=HEAP32[(($384)>>2)];
$C0=$385;
var $386=(($385)|(0))!=0;
if ($386) { label = 67; break; } else { label = 71; break; }
case 67:
var $388=$C0;
var $389=$388;
var $390=$1;
var $391=(($390+16)|0);
var $392=HEAP32[(($391)>>2)];
var $393=(($389)>>>(0)) >= (($392)>>>(0));
var $394=(($393)&(1));
var $395=($394);
var $396=(($395)|(0))!=0;
if ($396) { label = 68; break; } else { label = 69; break; }
case 68:
var $398=$C0;
var $399=$R;
var $400=(($399+16)|0);
var $401=(($400)|0);
HEAP32[(($401)>>2)]=$398;
var $402=$R;
var $403=$C0;
var $404=(($403+24)|0);
HEAP32[(($404)>>2)]=$402;
label = 70; break;
case 69:
_abort();
throw "Reached an unreachable!"
case 70:
label = 71; break;
case 71:
var $408=$TP;
var $409=(($408+16)|0);
var $410=(($409+4)|0);
var $411=HEAP32[(($410)>>2)];
$C1=$411;
var $412=(($411)|(0))!=0;
if ($412) { label = 72; break; } else { label = 76; break; }
case 72:
var $414=$C1;
var $415=$414;
var $416=$1;
var $417=(($416+16)|0);
var $418=HEAP32[(($417)>>2)];
var $419=(($415)>>>(0)) >= (($418)>>>(0));
var $420=(($419)&(1));
var $421=($420);
var $422=(($421)|(0))!=0;
if ($422) { label = 73; break; } else { label = 74; break; }
case 73:
var $424=$C1;
var $425=$R;
var $426=(($425+16)|0);
var $427=(($426+4)|0);
HEAP32[(($427)>>2)]=$424;
var $428=$R;
var $429=$C1;
var $430=(($429+24)|0);
HEAP32[(($430)>>2)]=$428;
label = 75; break;
case 74:
_abort();
throw "Reached an unreachable!"
case 75:
label = 76; break;
case 76:
label = 78; break;
case 77:
_abort();
throw "Reached an unreachable!"
case 78:
label = 79; break;
case 79:
label = 80; break;
case 80:
label = 81; break;
case 81:
var $439=$oldfirst;
var $440=$439;
var $441=$nsize;
var $442=(($440+$441)|0);
var $443=$442;
$oldfirst=$443;
var $444=$nsize;
var $445=$qsize;
var $446=((($445)+($444))|0);
$qsize=$446;
label = 82; break;
case 82:
var $448=$oldfirst;
var $449=(($448+4)|0);
var $450=HEAP32[(($449)>>2)];
var $451=$450 & -2;
HEAP32[(($449)>>2)]=$451;
var $452=$qsize;
var $453=$452 | 1;
var $454=$q;
var $455=(($454+4)|0);
HEAP32[(($455)>>2)]=$453;
var $456=$qsize;
var $457=$q;
var $458=$457;
var $459=$qsize;
var $460=(($458+$459)|0);
var $461=$460;
var $462=(($461)|0);
HEAP32[(($462)>>2)]=$456;
var $463=$qsize;
var $464=$463 >>> 3;
var $465=(($464)>>>(0)) < 32;
if ($465) { label = 83; break; } else { label = 90; break; }
case 83:
var $467=$qsize;
var $468=$467 >>> 3;
$I2=$468;
var $469=$I2;
var $470=$469 << 1;
var $471=$1;
var $472=(($471+40)|0);
var $473=(($472+($470<<2))|0);
var $474=$473;
var $475=$474;
$B3=$475;
var $476=$B3;
$F4=$476;
var $477=$1;
var $478=(($477)|0);
var $479=HEAP32[(($478)>>2)];
var $480=$I2;
var $481=1 << $480;
var $482=$479 & $481;
var $483=(($482)|(0))!=0;
if ($483) { label = 85; break; } else { label = 84; break; }
case 84:
var $485=$I2;
var $486=1 << $485;
var $487=$1;
var $488=(($487)|0);
var $489=HEAP32[(($488)>>2)];
var $490=$489 | $486;
HEAP32[(($488)>>2)]=$490;
label = 89; break;
case 85:
var $492=$B3;
var $493=(($492+8)|0);
var $494=HEAP32[(($493)>>2)];
var $495=$494;
var $496=$1;
var $497=(($496+16)|0);
var $498=HEAP32[(($497)>>2)];
var $499=(($495)>>>(0)) >= (($498)>>>(0));
var $500=(($499)&(1));
var $501=($500);
var $502=(($501)|(0))!=0;
if ($502) { label = 86; break; } else { label = 87; break; }
case 86:
var $504=$B3;
var $505=(($504+8)|0);
var $506=HEAP32[(($505)>>2)];
$F4=$506;
label = 88; break;
case 87:
_abort();
throw "Reached an unreachable!"
case 88:
label = 89; break;
case 89:
var $510=$q;
var $511=$B3;
var $512=(($511+8)|0);
HEAP32[(($512)>>2)]=$510;
var $513=$q;
var $514=$F4;
var $515=(($514+12)|0);
HEAP32[(($515)>>2)]=$513;
var $516=$F4;
var $517=$q;
var $518=(($517+8)|0);
HEAP32[(($518)>>2)]=$516;
var $519=$B3;
var $520=$q;
var $521=(($520+12)|0);
HEAP32[(($521)>>2)]=$519;
label = 117; break;
case 90:
var $523=$q;
var $524=$523;
$TP5=$524;
var $525=$qsize;
var $526=$525 >>> 8;
$X=$526;
var $527=$X;
var $528=(($527)|(0))==0;
if ($528) { label = 91; break; } else { label = 92; break; }
case 91:
$I7=0;
label = 96; break;
case 92:
var $531=$X;
var $532=(($531)>>>(0)) > 65535;
if ($532) { label = 93; break; } else { label = 94; break; }
case 93:
$I7=31;
label = 95; break;
case 94:
var $535=$X;
$Y=$535;
var $536=$Y;
var $537=((($536)-(256))|0);
var $538=$537 >>> 16;
var $539=$538 & 8;
$N=$539;
var $540=$N;
var $541=$Y;
var $542=$541 << $540;
$Y=$542;
var $543=((($542)-(4096))|0);
var $544=$543 >>> 16;
var $545=$544 & 4;
$K=$545;
var $546=$K;
var $547=$N;
var $548=((($547)+($546))|0);
$N=$548;
var $549=$K;
var $550=$Y;
var $551=$550 << $549;
$Y=$551;
var $552=((($551)-(16384))|0);
var $553=$552 >>> 16;
var $554=$553 & 2;
$K=$554;
var $555=$N;
var $556=((($555)+($554))|0);
$N=$556;
var $557=$N;
var $558=(((14)-($557))|0);
var $559=$K;
var $560=$Y;
var $561=$560 << $559;
$Y=$561;
var $562=$561 >>> 15;
var $563=((($558)+($562))|0);
$K=$563;
var $564=$K;
var $565=$564 << 1;
var $566=$qsize;
var $567=$K;
var $568=((($567)+(7))|0);
var $569=$566 >>> (($568)>>>(0));
var $570=$569 & 1;
var $571=((($565)+($570))|0);
$I7=$571;
label = 95; break;
case 95:
label = 96; break;
case 96:
var $574=$I7;
var $575=$1;
var $576=(($575+304)|0);
var $577=(($576+($574<<2))|0);
$H6=$577;
var $578=$I7;
var $579=$TP5;
var $580=(($579+28)|0);
HEAP32[(($580)>>2)]=$578;
var $581=$TP5;
var $582=(($581+16)|0);
var $583=(($582+4)|0);
HEAP32[(($583)>>2)]=0;
var $584=$TP5;
var $585=(($584+16)|0);
var $586=(($585)|0);
HEAP32[(($586)>>2)]=0;
var $587=$1;
var $588=(($587+4)|0);
var $589=HEAP32[(($588)>>2)];
var $590=$I7;
var $591=1 << $590;
var $592=$589 & $591;
var $593=(($592)|(0))!=0;
if ($593) { label = 98; break; } else { label = 97; break; }
case 97:
var $595=$I7;
var $596=1 << $595;
var $597=$1;
var $598=(($597+4)|0);
var $599=HEAP32[(($598)>>2)];
var $600=$599 | $596;
HEAP32[(($598)>>2)]=$600;
var $601=$TP5;
var $602=$H6;
HEAP32[(($602)>>2)]=$601;
var $603=$H6;
var $604=$603;
var $605=$TP5;
var $606=(($605+24)|0);
HEAP32[(($606)>>2)]=$604;
var $607=$TP5;
var $608=$TP5;
var $609=(($608+12)|0);
HEAP32[(($609)>>2)]=$607;
var $610=$TP5;
var $611=(($610+8)|0);
HEAP32[(($611)>>2)]=$607;
label = 116; break;
case 98:
var $613=$H6;
var $614=HEAP32[(($613)>>2)];
$T=$614;
var $615=$qsize;
var $616=$I7;
var $617=(($616)|(0))==31;
if ($617) { label = 99; break; } else { label = 100; break; }
case 99:
var $626 = 0;label = 101; break;
case 100:
var $620=$I7;
var $621=$620 >>> 1;
var $622=((($621)+(8))|0);
var $623=((($622)-(2))|0);
var $624=(((31)-($623))|0);
var $626 = $624;label = 101; break;
case 101:
var $626;
var $627=$615 << $626;
$K8=$627;
label = 102; break;
case 102:
var $629=$T;
var $630=(($629+4)|0);
var $631=HEAP32[(($630)>>2)];
var $632=$631 & -8;
var $633=$qsize;
var $634=(($632)|(0))!=(($633)|(0));
if ($634) { label = 103; break; } else { label = 109; break; }
case 103:
var $636=$K8;
var $637=$636 >>> 31;
var $638=$637 & 1;
var $639=$T;
var $640=(($639+16)|0);
var $641=(($640+($638<<2))|0);
$C=$641;
var $642=$K8;
var $643=$642 << 1;
$K8=$643;
var $644=$C;
var $645=HEAP32[(($644)>>2)];
var $646=(($645)|(0))!=0;
if ($646) { label = 104; break; } else { label = 105; break; }
case 104:
var $648=$C;
var $649=HEAP32[(($648)>>2)];
$T=$649;
label = 108; break;
case 105:
var $651=$C;
var $652=$651;
var $653=$1;
var $654=(($653+16)|0);
var $655=HEAP32[(($654)>>2)];
var $656=(($652)>>>(0)) >= (($655)>>>(0));
var $657=(($656)&(1));
var $658=($657);
var $659=(($658)|(0))!=0;
if ($659) { label = 106; break; } else { label = 107; break; }
case 106:
var $661=$TP5;
var $662=$C;
HEAP32[(($662)>>2)]=$661;
var $663=$T;
var $664=$TP5;
var $665=(($664+24)|0);
HEAP32[(($665)>>2)]=$663;
var $666=$TP5;
var $667=$TP5;
var $668=(($667+12)|0);
HEAP32[(($668)>>2)]=$666;
var $669=$TP5;
var $670=(($669+8)|0);
HEAP32[(($670)>>2)]=$666;
label = 115; break;
case 107:
_abort();
throw "Reached an unreachable!"
case 108:
label = 114; break;
case 109:
var $674=$T;
var $675=(($674+8)|0);
var $676=HEAP32[(($675)>>2)];
$F9=$676;
var $677=$T;
var $678=$677;
var $679=$1;
var $680=(($679+16)|0);
var $681=HEAP32[(($680)>>2)];
var $682=(($678)>>>(0)) >= (($681)>>>(0));
if ($682) { label = 110; break; } else { var $691 = 0;label = 111; break; }
case 110:
var $684=$F9;
var $685=$684;
var $686=$1;
var $687=(($686+16)|0);
var $688=HEAP32[(($687)>>2)];
var $689=(($685)>>>(0)) >= (($688)>>>(0));
var $691 = $689;label = 111; break;
case 111:
var $691;
var $692=(($691)&(1));
var $693=($692);
var $694=(($693)|(0))!=0;
if ($694) { label = 112; break; } else { label = 113; break; }
case 112:
var $696=$TP5;
var $697=$F9;
var $698=(($697+12)|0);
HEAP32[(($698)>>2)]=$696;
var $699=$T;
var $700=(($699+8)|0);
HEAP32[(($700)>>2)]=$696;
var $701=$F9;
var $702=$TP5;
var $703=(($702+8)|0);
HEAP32[(($703)>>2)]=$701;
var $704=$T;
var $705=$TP5;
var $706=(($705+12)|0);
HEAP32[(($706)>>2)]=$704;
var $707=$TP5;
var $708=(($707+24)|0);
HEAP32[(($708)>>2)]=0;
label = 115; break;
case 113:
_abort();
throw "Reached an unreachable!"
case 114:
label = 102; break;
case 115:
label = 116; break;
case 116:
label = 117; break;
case 117:
label = 118; break;
case 118:
label = 119; break;
case 119:
var $716=$p;
var $717=$716;
var $718=(($717+8)|0);
return $718;
default: assert(0, "bad label: " + label);
}
}
function _add_segment($m, $tbase, $tsize, $mmapped) {
var label = 0;
label = 2;
while(1) switch(label) {
case 2:
var $1;
var $2;
var $3;
var $4;
var $old_top;
var $oldsp;
var $old_end;
var $ssize;
var $rawsp;
var $offset;
var $asp;
var $csp;
var $sp;
var $ss;
var $tnext;
var $p;
var $nfences;
var $nextp;
var $q;
var $psize;
var $tn;
var $I;
var $B;
var $F;
var $TP;
var $H;
var $I1;
var $X;
var $Y;
var $N;
var $K;
var $T;
var $K2;
var $C;
var $F3;
$1=$m;
$2=$tbase;
$3=$tsize;
$4=$mmapped;
var $5=$1;
var $6=(($5+24)|0);
var $7=HEAP32[(($6)>>2)];
var $8=$7;
$old_top=$8;
var $9=$1;
var $10=$old_top;
var $11=_segment_holding($9, $10);
$oldsp=$11;
var $12=$oldsp;
var $13=(($12)|0);
var $14=HEAP32[(($13)>>2)];
var $15=$oldsp;
var $16=(($15+4)|0);
var $17=HEAP32[(($16)>>2)];
var $18=(($14+$17)|0);
$old_end=$18;
$ssize=24;
var $19=$old_end;
var $20=$ssize;
var $21=((($20)+(16))|0);
var $22=((($21)+(7))|0);
var $23=(((-$22))|0);
var $24=(($19+$23)|0);
$rawsp=$24;
var $25=$rawsp;
var $26=(($25+8)|0);
var $27=$26;
var $28=$27 & 7;
var $29=(($28)|(0))==0;
if ($29) { label = 3; break; } else { label = 4; break; }
case 3:
var $39 = 0;label = 5; break;
case 4:
var $32=$rawsp;
var $33=(($32+8)|0);
var $34=$33;
var $35=$34 & 7;
var $36=(((8)-($35))|0);
var $37=$36 & 7;
var $39 = $37;label = 5; break;
case 5:
var $39;
$offset=$39;
var $40=$rawsp;
var $41=$offset;
var $42=(($40+$41)|0);
$asp=$42;
var $43=$asp;
var $44=$old_top;
var $45=(($44+16)|0);
var $46=(($43)>>>(0)) < (($45)>>>(0));
if ($46) { label = 6; break; } else { label = 7; break; }
case 6:
var $48=$old_top;
var $52 = $48;label = 8; break;
case 7:
var $50=$asp;
var $52 = $50;label = 8; break;
case 8:
var $52;
$csp=$52;
var $53=$csp;
var $54=$53;
$sp=$54;
var $55=$sp;
var $56=$55;
var $57=(($56+8)|0);
var $58=$57;
$ss=$58;
var $59=$sp;
var $60=$59;
var $61=$ssize;
var $62=(($60+$61)|0);
var $63=$62;
$tnext=$63;
var $64=$tnext;
$p=$64;
$nfences=0;
var $65=$1;
var $66=$2;
var $67=$66;
var $68=$3;
var $69=((($68)-(40))|0);
_init_top($65, $67, $69);
var $70=$ssize;
var $71=$70 | 1;
var $72=$71 | 2;
var $73=$sp;
var $74=(($73+4)|0);
HEAP32[(($74)>>2)]=$72;
var $75=$ss;
var $76=$1;
var $77=(($76+448)|0);
var $78=$75;
var $79=$77;
assert(16 % 1 === 0);HEAP32[(($78)>>2)]=HEAP32[(($79)>>2)];HEAP32[((($78)+(4))>>2)]=HEAP32[((($79)+(4))>>2)];HEAP32[((($78)+(8))>>2)]=HEAP32[((($79)+(8))>>2)];HEAP32[((($78)+(12))>>2)]=HEAP32[((($79)+(12))>>2)];
var $80=$2;
var $81=$1;
var $82=(($81+448)|0);
var $83=(($82)|0);
HEAP32[(($83)>>2)]=$80;
var $84=$3;
var $85=$1;
var $86=(($85+448)|0);
var $87=(($86+4)|0);
HEAP32[(($87)>>2)]=$84;
var $88=$4;
var $89=$1;
var $90=(($89+448)|0);
var $91=(($90+12)|0);
HEAP32[(($91)>>2)]=$88;
var $92=$ss;
var $93=$1;
var $94=(($93+448)|0);
var $95=(($94+8)|0);
HEAP32[(($95)>>2)]=$92;
label = 9; break;
case 9:
var $97=$p;
var $98=$97;
var $99=(($98+4)|0);
var $100=$99;
$nextp=$100;
var $101=$p;
var $102=(($101+4)|0);
HEAP32[(($102)>>2)]=7;
var $103=$nfences;
var $104=((($103)+(1))|0);
$nfences=$104;
var $105=$nextp;
var $106=(($105+4)|0);
var $107=$106;
var $108=$old_end;
var $109=(($107)>>>(0)) < (($108)>>>(0));
if ($109) { label = 10; break; } else { label = 11; break; }
case 10:
var $111=$nextp;
$p=$111;
label = 12; break;
case 11:
label = 13; break;
case 12:
label = 9; break;
case 13:
var $115=$csp;
var $116=$old_top;
var $117=(($115)|(0))!=(($116)|(0));
if ($117) { label = 14; break; } else { label = 50; break; }
case 14:
var $119=$old_top;
var $120=$119;
$q=$120;
var $121=$csp;
var $122=$old_top;
var $123=$121;
var $124=$122;
var $125=((($123)-($124))|0);
$psize=$125;
var $126=$q;
var $127=$126;
var $128=$psize;
var $129=(($127+$128)|0);
var $130=$129;
$tn=$130;
var $131=$tn;
var $132=(($131+4)|0);
var $133=HEAP32[(($132)>>2)];
var $134=$133 & -2;
HEAP32[(($132)>>2)]=$134;
var $135=$psize;
var $136=$135 | 1;
var $137=$q;
var $138=(($137+4)|0);
HEAP32[(($138)>>2)]=$136;
var $139=$psize;
var $140=$q;
var $141=$140;
var $142=$psize;
var $143=(($141+$142)|0);
var $144=$143;
var $145=(($144)|0);
HEAP32[(($145)>>2)]=$139;
var $146=$psize;
var $147=$146 >>> 3;
var $148=(($147)>>>(0)) < 32;
if ($148) { label = 15; break; } else { label = 22; break; }
case 15:
var $150=$psize;
var $151=$150 >>> 3;
$I=$151;
var $152=$I;
var $153=$152 << 1;
var $154=$1;
var $155=(($154+40)|0);
var $156=(($155+($153<<2))|0);
var $157=$156;
var $158=$157;
$B=$158;
var $159=$B;
$F=$159;
var $160=$1;
var $161=(($160)|0);
var $162=HEAP32[(($161)>>2)];
var $163=$I;
var $164=1 << $163;
var $165=$162 & $164;
var $166=(($165)|(0))!=0;
if ($166) { label = 17; break; } else { label = 16; break; }
case 16:
var $168=$I;
var $169=1 << $168;
var $170=$1;
var $171=(($170)|0);
var $172=HEAP32[(($171)>>2)];
var $173=$172 | $169;
HEAP32[(($171)>>2)]=$173;
label = 21; break;
case 17:
var $175=$B;
var $176=(($175+8)|0);
var $177=HEAP32[(($176)>>2)];
var $178=$177;
var $179=$1;
var $180=(($179+16)|0);
var $181=HEAP32[(($180)>>2)];
var $182=(($178)>>>(0)) >= (($181)>>>(0));
var $183=(($182)&(1));
var $184=($183);
var $185=(($184)|(0))!=0;
if ($185) { label = 18; break; } else { label = 19; break; }
case 18:
var $187=$B;
var $188=(($187+8)|0);
var $189=HEAP32[(($188)>>2)];
$F=$189;
label = 20; break;
case 19:
_abort();
throw "Reached an unreachable!"
case 20:
label = 21; break;
case 21:
var $193=$q;
var $194=$B;
var $195=(($194+8)|0);
HEAP32[(($195)>>2)]=$193;
var $196=$q;
var $197=$F;
var $198=(($197+12)|0);
HEAP32[(($198)>>2)]=$196;
var $199=$F;
var $200=$q;
var $201=(($200+8)|0);
HEAP32[(($201)>>2)]=$199;
var $202=$B;
var $203=$q;
var $204=(($203+12)|0);
HEAP32[(($204)>>2)]=$202;
label = 49; break;
case 22:
var $206=$q;
var $207=$206;
$TP=$207;
var $208=$psize;
var $209=$208 >>> 8;
$X=$209;
var $210=$X;
var $211=(($210)|(0))==0;
if ($211) { label = 23; break; } else { label = 24; break; }
case 23:
$I1=0;
label = 28; break;
case 24:
var $214=$X;
var $215=(($214)>>>(0)) > 65535;
if ($215) { label = 25; break; } else { label = 26; break; }
case 25:
$I1=31;
label = 27; break;
case 26:
var $218=$X;
$Y=$218;
var $219=$Y;
var $220=((($219)-(256))|0);
var $221=$220 >>> 16;
var $222=$221 & 8;
$N=$222;
var $223=$N;
var $224=$Y;
var $225=$224 << $223;
$Y=$225;
var $226=((($225)-(4096))|0);
var $227=$226 >>> 16;
var $228=$227 & 4;
$K=$228;
var $229=$K;
var $230=$N;
var $231=((($230)+($229))|0);
$N=$231;
var $232=$K;
var $233=$Y;
var $234=$233 << $232;
$Y=$234;
var $235=((($234)-(16384))|0);
var $236=$235 >>> 16;
var $237=$236 & 2;
$K=$237;
var $238=$N;
var $239=((($238)+($237))|0);
$N=$239;
var $240=$N;
var $241=(((14)-($240))|0);
var $242=$K;
var $243=$Y;
var $244=$243 << $242;
$Y=$244;
var $245=$244 >>> 15;
var $246=((($241)+($245))|0);
$K=$246;
var $247=$K;
var $248=$247 << 1;
var $249=$psize;
var $250=$K;
var $251=((($250)+(7))|0);
var $252=$249 >>> (($251)>>>(0));
var $253=$252 & 1;
var $254=((($248)+($253))|0);
$I1=$254;
label = 27; break;
case 27:
label = 28; break;
case 28:
var $257=$I1;
var $258=$1;
var $259=(($258+304)|0);
var $260=(($259+($257<<2))|0);
$H=$260;
var $261=$I1;
var $262=$TP;
var $263=(($262+28)|0);
HEAP32[(($263)>>2)]=$261;
var $264=$TP;
var $265=(($264+16)|0);
var $266=(($265+4)|0);
HEAP32[(($266)>>2)]=0;
var $267=$TP;
var $268=(($267+16)|0);
var $269=(($268)|0);
HEAP32[(($269)>>2)]=0;
var $270=$1;
var $271=(($270+4)|0);
var $272=HEAP32[(($271)>>2)];
var $273=$I1;
var $274=1 << $273;
var $275=$272 & $274;
var $276=(($275)|(0))!=0;
if ($276) { label = 30; break; } else { label = 29; break; }
case 29:
var $278=$I1;
var $279=1 << $278;
var $280=$1;
var $281=(($280+4)|0);
var $282=HEAP32[(($281)>>2)];
var $283=$282 | $279;
HEAP32[(($281)>>2)]=$283;
var $284=$TP;
var $285=$H;
HEAP32[(($285)>>2)]=$284;
var $286=$H;
var $287=$286;
var $288=$TP;
var $289=(($288+24)|0);
HEAP32[(($289)>>2)]=$287;
var $290=$TP;
var $291=$TP;
var $292=(($291+12)|0);
HEAP32[(($292)>>2)]=$290;
var $293=$TP;
var $294=(($293+8)|0);
HEAP32[(($294)>>2)]=$290;
label = 48; break;
case 30:
var $296=$H;
var $297=HEAP32[(($296)>>2)];
$T=$297;
var $298=$psize;
var $299=$I1;
var $300=(($299)|(0))==31;
if ($300) { label = 31; break; } else { label = 32; break; }
case 31:
var $309 = 0;label = 33; break;
case 32:
var $303=$I1;
var $304=$303 >>> 1;
var $305=((($304)+(8))|0);
var $306=((($305)-(2))|0);
var $307=(((31)-($306))|0);
var $309 = $307;label = 33; break;
case 33:
var $309;
var $310=$298 << $309;
$K2=$310;
label = 34; break;
case 34:
var $312=$T;
var $313=(($312+4)|0);
var $314=HEAP32[(($313)>>2)];
var $315=$314 & -8;
var $316=$psize;
var $317=(($315)|(0))!=(($316)|(0));
if ($317) { label = 35; break; } else { label = 41; break; }
case 35:
var $319=$K2;
var $320=$319 >>> 31;
var $321=$320 & 1;
var $322=$T;
var $323=(($322+16)|0);
var $324=(($323+($321<<2))|0);
$C=$324;
var $325=$K2;
var $326=$325 << 1;
$K2=$326;
var $327=$C;
var $328=HEAP32[(($327)>>2)];
var $329=(($328)|(0))!=0;
if ($329) { label = 36; break; } else { label = 37; break; }
case 36:
var $331=$C;
var $332=HEAP32[(($331)>>2)];
$T=$332;
label = 40; break;
case 37:
var $334=$C;
var $335=$334;
var $336=$1;
var $337=(($336+16)|0);
var $338=HEAP32[(($337)>>2)];
var $339=(($335)>>>(0)) >= (($338)>>>(0));
var $340=(($339)&(1));
var $341=($340);
var $342=(($341)|(0))!=0;
if ($342) { label = 38; break; } else { label = 39; break; }
case 38:
var $344=$TP;
var $345=$C;
HEAP32[(($345)>>2)]=$344;
var $346=$T;
var $347=$TP;
var $348=(($347+24)|0);
HEAP32[(($348)>>2)]=$346;
var $349=$TP;
var $350=$TP;
var $351=(($350+12)|0);
HEAP32[(($351)>>2)]=$349;
var $352=$TP;
var $353=(($352+8)|0);
HEAP32[(($353)>>2)]=$349;
label = 47; break;
case 39:
_abort();
throw "Reached an unreachable!"
case 40:
label = 46; break;
case 41:
var $357=$T;
var $358=(($357+8)|0);
var $359=HEAP32[(($358)>>2)];
$F3=$359;
var $360=$T;
var $361=$360;
var $362=$1;
var $363=(($362+16)|0);
var $364=HEAP32[(($363)>>2)];
var $365=(($361)>>>(0)) >= (($364)>>>(0));
if ($365) { label = 42; break; } else { var $374 = 0;label = 43; break; }
case 42:
var $367=$F3;
var $368=$367;
var $369=$1;
var $370=(($369+16)|0);
var $371=HEAP32[(($370)>>2)];
var $372=(($368)>>>(0)) >= (($371)>>>(0));
var $374 = $372;label = 43; break;
case 43:
var $374;
var $375=(($374)&(1));
var $376=($375);
var $377=(($376)|(0))!=0;
if ($377) { label = 44; break; } else { label = 45; break; }
case 44:
var $379=$TP;
var $380=$F3;
var $381=(($380+12)|0);
HEAP32[(($381)>>2)]=$379;
var $382=$T;
var $383=(($382+8)|0);
HEAP32[(($383)>>2)]=$379;
var $384=$F3;
var $385=$TP;
var $386=(($385+8)|0);
HEAP32[(($386)>>2)]=$384;
var $387=$T;
var $388=$TP;
var $389=(($388+12)|0);
HEAP32[(($389)>>2)]=$387;
var $390=$TP;
var $391=(($390+24)|0);
HEAP32[(($391)>>2)]=0;
label = 47; break;
case 45:
_abort();
throw "Reached an unreachable!"
case 46:
label = 34; break;
case 47:
label = 48; break;
case 48:
label = 49; break;
case 49:
label = 50; break;
case 50:
return;
default: assert(0, "bad label: " + label);
}
}
// EMSCRIPTEN_END_FUNCS
// EMSCRIPTEN_END_FUNCS
// 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 ===
Module.callMain = function callMain(args) {
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_STATIC) ];
pad();
for (var i = 0; i < argc-1; i = i + 1) {
argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_STATIC));
pad();
}
argv.push(0);
argv = allocate(argv, 'i32', ALLOC_STATIC);
var ret;
var initialStackTop = STACKTOP;
try {
ret = Module['_main'](argc, argv, 0);
}
catch(e) {
if (e.name == 'ExitStatus') {
return e.status;
} else if (e == 'SimulateInfiniteLoop') {
Module['noExitRuntime'] = true;
} else {
throw e;
}
} finally {
STACKTOP = initialStackTop;
}
return ret;
}
function run(args) {
args = args || Module['arguments'];
if (runDependencies > 0) {
Module.printErr('run() called, but dependencies remain, so not running');
return 0;
}
if (Module['preRun']) {
if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
var toRun = Module['preRun'];
Module['preRun'] = [];
for (var i = toRun.length-1; i >= 0; i--) {
toRun[i]();
}
if (runDependencies > 0) {
// a preRun added a dependency, run will be called later
return 0;
}
}
function doRun() {
var ret = 0;
calledRun = true;
if (Module['_main']) {
preMain();
ret = Module.callMain(args);
if (!Module['noExitRuntime']) {
exitRuntime();
}
}
if (Module['postRun']) {
if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
while (Module['postRun'].length > 0) {
Module['postRun'].pop()();
}
}
return ret;
}
if (Module['setStatus']) {
Module['setStatus']('Running...');
setTimeout(function() {
setTimeout(function() {
Module['setStatus']('');
}, 1);
doRun();
}, 1);
return 0;
} else {
return doRun();
}
}
Module['run'] = Module.run = run;
// {{PRE_RUN_ADDITIONS}}
if (Module['preInit']) {
if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
while (Module['preInit'].length > 0) {
Module['preInit'].pop()();
}
}
initRuntime();
var shouldRunNow = true;
if (Module['noInitialRun']) {
shouldRunNow = false;
}
if (shouldRunNow) {
run();
}
// {{POST_RUN_ADDITIONS}}
// {{MODULE_ADDITIONS}}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment