PageRenderTime 174ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 3ms

/test/mjsunit/asm/embenchen/box2d.js

http://v8.googlecode.com/
JavaScript | 14505 lines | 13559 code | 442 blank | 504 comment | 3027 complexity | 53213d4326b9917ba5e1cc8be4d22d93 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. // Copyright 2014 the V8 project authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. var EXPECTED_OUTPUT =
  5. /frame averages: .+ \+- .+, range: .+ to .+ \n/;
  6. var Module = {
  7. arguments: [1],
  8. print: function(x) {Module.printBuffer += x + '\n';},
  9. preRun: [function() {Module.printBuffer = ''}],
  10. postRun: [function() {
  11. assertTrue(EXPECTED_OUTPUT.test(Module.printBuffer));
  12. }],
  13. };
  14. // The Module object: Our interface to the outside world. We import
  15. // and export values on it, and do the work to get that through
  16. // closure compiler if necessary. There are various ways Module can be used:
  17. // 1. Not defined. We create it here
  18. // 2. A function parameter, function(Module) { ..generated code.. }
  19. // 3. pre-run appended it, var Module = {}; ..generated code..
  20. // 4. External script tag defines var Module.
  21. // We need to do an eval in order to handle the closure compiler
  22. // case, where this code here is minified but Module was defined
  23. // elsewhere (e.g. case 4 above). We also need to check if Module
  24. // already exists (e.g. case 3 above).
  25. // Note that if you want to run closure, and also to use Module
  26. // after the generated code, you will need to define var Module = {};
  27. // before the code. Then that object will be used in the code, and you
  28. // can continue to use Module afterwards as well.
  29. var Module;
  30. if (!Module) Module = (typeof Module !== 'undefined' ? Module : null) || {};
  31. // Sometimes an existing Module object exists with properties
  32. // meant to overwrite the default module functionality. Here
  33. // we collect those properties and reapply _after_ we configure
  34. // the current environment's defaults to avoid having to be so
  35. // defensive during initialization.
  36. var moduleOverrides = {};
  37. for (var key in Module) {
  38. if (Module.hasOwnProperty(key)) {
  39. moduleOverrides[key] = Module[key];
  40. }
  41. }
  42. // The environment setup code below is customized to use Module.
  43. // *** Environment setup code ***
  44. var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';
  45. var ENVIRONMENT_IS_WEB = typeof window === 'object';
  46. var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
  47. var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
  48. if (ENVIRONMENT_IS_NODE) {
  49. // Expose functionality in the same simple way that the shells work
  50. // Note that we pollute the global namespace here, otherwise we break in node
  51. if (!Module['print']) Module['print'] = function print(x) {
  52. process['stdout'].write(x + '\n');
  53. };
  54. if (!Module['printErr']) Module['printErr'] = function printErr(x) {
  55. process['stderr'].write(x + '\n');
  56. };
  57. var nodeFS = require('fs');
  58. var nodePath = require('path');
  59. Module['read'] = function read(filename, binary) {
  60. filename = nodePath['normalize'](filename);
  61. var ret = nodeFS['readFileSync'](filename);
  62. // The path is absolute if the normalized version is the same as the resolved.
  63. if (!ret && filename != nodePath['resolve'](filename)) {
  64. filename = path.join(__dirname, '..', 'src', filename);
  65. ret = nodeFS['readFileSync'](filename);
  66. }
  67. if (ret && !binary) ret = ret.toString();
  68. return ret;
  69. };
  70. Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
  71. Module['load'] = function load(f) {
  72. globalEval(read(f));
  73. };
  74. Module['arguments'] = process['argv'].slice(2);
  75. module['exports'] = Module;
  76. }
  77. else if (ENVIRONMENT_IS_SHELL) {
  78. if (!Module['print']) Module['print'] = print;
  79. if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm
  80. if (typeof read != 'undefined') {
  81. Module['read'] = read;
  82. } else {
  83. Module['read'] = function read() { throw 'no read() available (jsc?)' };
  84. }
  85. Module['readBinary'] = function readBinary(f) {
  86. return read(f, 'binary');
  87. };
  88. if (typeof scriptArgs != 'undefined') {
  89. Module['arguments'] = scriptArgs;
  90. } else if (typeof arguments != 'undefined') {
  91. Module['arguments'] = arguments;
  92. }
  93. this['Module'] = Module;
  94. eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
  95. }
  96. else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
  97. Module['read'] = function read(url) {
  98. var xhr = new XMLHttpRequest();
  99. xhr.open('GET', url, false);
  100. xhr.send(null);
  101. return xhr.responseText;
  102. };
  103. if (typeof arguments != 'undefined') {
  104. Module['arguments'] = arguments;
  105. }
  106. if (typeof console !== 'undefined') {
  107. if (!Module['print']) Module['print'] = function print(x) {
  108. console.log(x);
  109. };
  110. if (!Module['printErr']) Module['printErr'] = function printErr(x) {
  111. console.log(x);
  112. };
  113. } else {
  114. // Probably a worker, and without console.log. We can do very little here...
  115. var TRY_USE_DUMP = false;
  116. if (!Module['print']) Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) {
  117. dump(x);
  118. }) : (function(x) {
  119. // self.postMessage(x); // enable this if you want stdout to be sent as messages
  120. }));
  121. }
  122. if (ENVIRONMENT_IS_WEB) {
  123. window['Module'] = Module;
  124. } else {
  125. Module['load'] = importScripts;
  126. }
  127. }
  128. else {
  129. // Unreachable because SHELL is dependant on the others
  130. throw 'Unknown runtime environment. Where are we?';
  131. }
  132. function globalEval(x) {
  133. eval.call(null, x);
  134. }
  135. if (!Module['load'] == 'undefined' && Module['read']) {
  136. Module['load'] = function load(f) {
  137. globalEval(Module['read'](f));
  138. };
  139. }
  140. if (!Module['print']) {
  141. Module['print'] = function(){};
  142. }
  143. if (!Module['printErr']) {
  144. Module['printErr'] = Module['print'];
  145. }
  146. if (!Module['arguments']) {
  147. Module['arguments'] = [];
  148. }
  149. // *** Environment setup code ***
  150. // Closure helpers
  151. Module.print = Module['print'];
  152. Module.printErr = Module['printErr'];
  153. // Callbacks
  154. Module['preRun'] = [];
  155. Module['postRun'] = [];
  156. // Merge back in the overrides
  157. for (var key in moduleOverrides) {
  158. if (moduleOverrides.hasOwnProperty(key)) {
  159. Module[key] = moduleOverrides[key];
  160. }
  161. }
  162. // === Auto-generated preamble library stuff ===
  163. //========================================
  164. // Runtime code shared with compiler
  165. //========================================
  166. var Runtime = {
  167. stackSave: function () {
  168. return STACKTOP;
  169. },
  170. stackRestore: function (stackTop) {
  171. STACKTOP = stackTop;
  172. },
  173. forceAlign: function (target, quantum) {
  174. quantum = quantum || 4;
  175. if (quantum == 1) return target;
  176. if (isNumber(target) && isNumber(quantum)) {
  177. return Math.ceil(target/quantum)*quantum;
  178. } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {
  179. return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')';
  180. }
  181. return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
  182. },
  183. isNumberType: function (type) {
  184. return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
  185. },
  186. isPointerType: function isPointerType(type) {
  187. return type[type.length-1] == '*';
  188. },
  189. isStructType: function isStructType(type) {
  190. if (isPointerType(type)) return false;
  191. if (isArrayType(type)) return true;
  192. if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
  193. // See comment in isStructPointerType()
  194. return type[0] == '%';
  195. },
  196. INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
  197. FLOAT_TYPES: {"float":0,"double":0},
  198. or64: function (x, y) {
  199. var l = (x | 0) | (y | 0);
  200. var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
  201. return l + h;
  202. },
  203. and64: function (x, y) {
  204. var l = (x | 0) & (y | 0);
  205. var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
  206. return l + h;
  207. },
  208. xor64: function (x, y) {
  209. var l = (x | 0) ^ (y | 0);
  210. var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
  211. return l + h;
  212. },
  213. getNativeTypeSize: function (type) {
  214. switch (type) {
  215. case 'i1': case 'i8': return 1;
  216. case 'i16': return 2;
  217. case 'i32': return 4;
  218. case 'i64': return 8;
  219. case 'float': return 4;
  220. case 'double': return 8;
  221. default: {
  222. if (type[type.length-1] === '*') {
  223. return Runtime.QUANTUM_SIZE; // A pointer
  224. } else if (type[0] === 'i') {
  225. var bits = parseInt(type.substr(1));
  226. assert(bits % 8 === 0);
  227. return bits/8;
  228. } else {
  229. return 0;
  230. }
  231. }
  232. }
  233. },
  234. getNativeFieldSize: function (type) {
  235. return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
  236. },
  237. dedup: function dedup(items, ident) {
  238. var seen = {};
  239. if (ident) {
  240. return items.filter(function(item) {
  241. if (seen[item[ident]]) return false;
  242. seen[item[ident]] = true;
  243. return true;
  244. });
  245. } else {
  246. return items.filter(function(item) {
  247. if (seen[item]) return false;
  248. seen[item] = true;
  249. return true;
  250. });
  251. }
  252. },
  253. set: function set() {
  254. var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
  255. var ret = {};
  256. for (var i = 0; i < args.length; i++) {
  257. ret[args[i]] = 0;
  258. }
  259. return ret;
  260. },
  261. STACK_ALIGN: 8,
  262. getAlignSize: function (type, size, vararg) {
  263. // we align i64s and doubles on 64-bit boundaries, unlike x86
  264. if (!vararg && (type == 'i64' || type == 'double')) return 8;
  265. if (!type) return Math.min(size, 8); // align structures internally to 64 bits
  266. return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
  267. },
  268. calculateStructAlignment: function calculateStructAlignment(type) {
  269. type.flatSize = 0;
  270. type.alignSize = 0;
  271. var diffs = [];
  272. var prev = -1;
  273. var index = 0;
  274. type.flatIndexes = type.fields.map(function(field) {
  275. index++;
  276. var size, alignSize;
  277. if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
  278. size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
  279. alignSize = Runtime.getAlignSize(field, size);
  280. } else if (Runtime.isStructType(field)) {
  281. if (field[1] === '0') {
  282. // this is [0 x something]. When inside another structure like here, it must be at the end,
  283. // and it adds no size
  284. // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');
  285. size = 0;
  286. if (Types.types[field]) {
  287. alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
  288. } else {
  289. alignSize = type.alignSize || QUANTUM_SIZE;
  290. }
  291. } else {
  292. size = Types.types[field].flatSize;
  293. alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);
  294. }
  295. } else if (field[0] == 'b') {
  296. // bN, large number field, like a [N x i8]
  297. size = field.substr(1)|0;
  298. alignSize = 1;
  299. } else if (field[0] === '<') {
  300. // vector type
  301. size = alignSize = Types.types[field].flatSize; // fully aligned
  302. } else if (field[0] === 'i') {
  303. // illegal integer field, that could not be legalized because it is an internal structure field
  304. // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
  305. size = alignSize = parseInt(field.substr(1))/8;
  306. assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
  307. } else {
  308. assert(false, 'invalid type for calculateStructAlignment');
  309. }
  310. if (type.packed) alignSize = 1;
  311. type.alignSize = Math.max(type.alignSize, alignSize);
  312. var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
  313. type.flatSize = curr + size;
  314. if (prev >= 0) {
  315. diffs.push(curr-prev);
  316. }
  317. prev = curr;
  318. return curr;
  319. });
  320. if (type.name_ && type.name_[0] === '[') {
  321. // arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
  322. // allocating a potentially huge array for [999999 x i8] etc.
  323. type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
  324. }
  325. type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
  326. if (diffs.length == 0) {
  327. type.flatFactor = type.flatSize;
  328. } else if (Runtime.dedup(diffs).length == 1) {
  329. type.flatFactor = diffs[0];
  330. }
  331. type.needsFlattening = (type.flatFactor != 1);
  332. return type.flatIndexes;
  333. },
  334. generateStructInfo: function (struct, typeName, offset) {
  335. var type, alignment;
  336. if (typeName) {
  337. offset = offset || 0;
  338. type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
  339. if (!type) return null;
  340. if (type.fields.length != struct.length) {
  341. printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');
  342. return null;
  343. }
  344. alignment = type.flatIndexes;
  345. } else {
  346. var type = { fields: struct.map(function(item) { return item[0] }) };
  347. alignment = Runtime.calculateStructAlignment(type);
  348. }
  349. var ret = {
  350. __size__: type.flatSize
  351. };
  352. if (typeName) {
  353. struct.forEach(function(item, i) {
  354. if (typeof item === 'string') {
  355. ret[item] = alignment[i] + offset;
  356. } else {
  357. // embedded struct
  358. var key;
  359. for (var k in item) key = k;
  360. ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
  361. }
  362. });
  363. } else {
  364. struct.forEach(function(item, i) {
  365. ret[item[1]] = alignment[i];
  366. });
  367. }
  368. return ret;
  369. },
  370. dynCall: function (sig, ptr, args) {
  371. if (args && args.length) {
  372. if (!args.splice) args = Array.prototype.slice.call(args);
  373. args.splice(0, 0, ptr);
  374. return Module['dynCall_' + sig].apply(null, args);
  375. } else {
  376. return Module['dynCall_' + sig].call(null, ptr);
  377. }
  378. },
  379. functionPointers: [],
  380. addFunction: function (func) {
  381. for (var i = 0; i < Runtime.functionPointers.length; i++) {
  382. if (!Runtime.functionPointers[i]) {
  383. Runtime.functionPointers[i] = func;
  384. return 2*(1 + i);
  385. }
  386. }
  387. throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';
  388. },
  389. removeFunction: function (index) {
  390. Runtime.functionPointers[(index-2)/2] = null;
  391. },
  392. getAsmConst: function (code, numArgs) {
  393. // code is a constant string on the heap, so we can cache these
  394. if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
  395. var func = Runtime.asmConstCache[code];
  396. if (func) return func;
  397. var args = [];
  398. for (var i = 0; i < numArgs; i++) {
  399. args.push(String.fromCharCode(36) + i); // $0, $1 etc
  400. }
  401. var source = Pointer_stringify(code);
  402. if (source[0] === '"') {
  403. // tolerate EM_ASM("..code..") even though EM_ASM(..code..) is correct
  404. if (source.indexOf('"', 1) === source.length-1) {
  405. source = source.substr(1, source.length-2);
  406. } else {
  407. // something invalid happened, e.g. EM_ASM("..code($0)..", input)
  408. abort('invalid EM_ASM input |' + source + '|. Please use EM_ASM(..code..) (no quotes) or EM_ASM({ ..code($0).. }, input) (to input values)');
  409. }
  410. }
  411. try {
  412. var evalled = eval('(function(' + args.join(',') + '){ ' + source + ' })'); // new Function does not allow upvars in node
  413. } catch(e) {
  414. Module.printErr('error in executing inline EM_ASM code: ' + e + ' on: \n\n' + source + '\n\nwith args |' + args + '| (make sure to use the right one out of EM_ASM, EM_ASM_ARGS, etc.)');
  415. throw e;
  416. }
  417. return Runtime.asmConstCache[code] = evalled;
  418. },
  419. warnOnce: function (text) {
  420. if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
  421. if (!Runtime.warnOnce.shown[text]) {
  422. Runtime.warnOnce.shown[text] = 1;
  423. Module.printErr(text);
  424. }
  425. },
  426. funcWrappers: {},
  427. getFuncWrapper: function (func, sig) {
  428. assert(sig);
  429. if (!Runtime.funcWrappers[func]) {
  430. Runtime.funcWrappers[func] = function dynCall_wrapper() {
  431. return Runtime.dynCall(sig, func, arguments);
  432. };
  433. }
  434. return Runtime.funcWrappers[func];
  435. },
  436. UTF8Processor: function () {
  437. var buffer = [];
  438. var needed = 0;
  439. this.processCChar = function (code) {
  440. code = code & 0xFF;
  441. if (buffer.length == 0) {
  442. if ((code & 0x80) == 0x00) { // 0xxxxxxx
  443. return String.fromCharCode(code);
  444. }
  445. buffer.push(code);
  446. if ((code & 0xE0) == 0xC0) { // 110xxxxx
  447. needed = 1;
  448. } else if ((code & 0xF0) == 0xE0) { // 1110xxxx
  449. needed = 2;
  450. } else { // 11110xxx
  451. needed = 3;
  452. }
  453. return '';
  454. }
  455. if (needed) {
  456. buffer.push(code);
  457. needed--;
  458. if (needed > 0) return '';
  459. }
  460. var c1 = buffer[0];
  461. var c2 = buffer[1];
  462. var c3 = buffer[2];
  463. var c4 = buffer[3];
  464. var ret;
  465. if (buffer.length == 2) {
  466. ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));
  467. } else if (buffer.length == 3) {
  468. ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
  469. } else {
  470. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  471. var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |
  472. ((c3 & 0x3F) << 6) | (c4 & 0x3F);
  473. ret = String.fromCharCode(
  474. Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,
  475. (codePoint - 0x10000) % 0x400 + 0xDC00);
  476. }
  477. buffer.length = 0;
  478. return ret;
  479. }
  480. this.processJSString = function processJSString(string) {
  481. /* TODO: use TextEncoder when present,
  482. var encoder = new TextEncoder();
  483. encoder['encoding'] = "utf-8";
  484. var utf8Array = encoder['encode'](aMsg.data);
  485. */
  486. string = unescape(encodeURIComponent(string));
  487. var ret = [];
  488. for (var i = 0; i < string.length; i++) {
  489. ret.push(string.charCodeAt(i));
  490. }
  491. return ret;
  492. }
  493. },
  494. getCompilerSetting: function (name) {
  495. throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work';
  496. },
  497. stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = (((STACKTOP)+7)&-8); return ret; },
  498. staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = (((STATICTOP)+7)&-8); return ret; },
  499. dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = (((DYNAMICTOP)+7)&-8); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
  500. alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },
  501. makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+((low>>>0)))+((+((high>>>0)))*(+4294967296))) : ((+((low>>>0)))+((+((high|0)))*(+4294967296)))); return ret; },
  502. GLOBAL_BASE: 8,
  503. QUANTUM_SIZE: 4,
  504. __dummy__: 0
  505. }
  506. Module['Runtime'] = Runtime;
  507. //========================================
  508. // Runtime essentials
  509. //========================================
  510. var __THREW__ = 0; // Used in checking for thrown exceptions.
  511. var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()
  512. var EXITSTATUS = 0;
  513. var undef = 0;
  514. // tempInt is used for 32-bit signed values or smaller. tempBigInt is used
  515. // for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
  516. var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
  517. var tempI64, tempI64b;
  518. var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
  519. function assert(condition, text) {
  520. if (!condition) {
  521. abort('Assertion failed: ' + text);
  522. }
  523. }
  524. var globalScope = this;
  525. // C calling interface. A convenient way to call C functions (in C files, or
  526. // defined with extern "C").
  527. //
  528. // Note: LLVM optimizations can inline and remove functions, after which you will not be
  529. // able to call them. Closure can also do so. To avoid that, add your function to
  530. // the exports using something like
  531. //
  532. // -s EXPORTED_FUNCTIONS='["_main", "_myfunc"]'
  533. //
  534. // @param ident The name of the C function (note that C++ functions will be name-mangled - use extern "C")
  535. // @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and
  536. // 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).
  537. // @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,
  538. // except that 'array' is not possible (there is no way for us to know the length of the array)
  539. // @param args An array of the arguments to the function, as native JS values (as in returnType)
  540. // Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).
  541. // @return The return value, as a native JS value (as in returnType)
  542. function ccall(ident, returnType, argTypes, args) {
  543. return ccallFunc(getCFunc(ident), returnType, argTypes, args);
  544. }
  545. Module["ccall"] = ccall;
  546. // Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
  547. function getCFunc(ident) {
  548. try {
  549. var func = Module['_' + ident]; // closure exported function
  550. if (!func) func = eval('_' + ident); // explicit lookup
  551. } catch(e) {
  552. }
  553. assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
  554. return func;
  555. }
  556. // Internal function that does a C call using a function, not an identifier
  557. function ccallFunc(func, returnType, argTypes, args) {
  558. var stack = 0;
  559. function toC(value, type) {
  560. if (type == 'string') {
  561. if (value === null || value === undefined || value === 0) return 0; // null string
  562. value = intArrayFromString(value);
  563. type = 'array';
  564. }
  565. if (type == 'array') {
  566. if (!stack) stack = Runtime.stackSave();
  567. var ret = Runtime.stackAlloc(value.length);
  568. writeArrayToMemory(value, ret);
  569. return ret;
  570. }
  571. return value;
  572. }
  573. function fromC(value, type) {
  574. if (type == 'string') {
  575. return Pointer_stringify(value);
  576. }
  577. assert(type != 'array');
  578. return value;
  579. }
  580. var i = 0;
  581. var cArgs = args ? args.map(function(arg) {
  582. return toC(arg, argTypes[i++]);
  583. }) : [];
  584. var ret = fromC(func.apply(null, cArgs), returnType);
  585. if (stack) Runtime.stackRestore(stack);
  586. return ret;
  587. }
  588. // Returns a native JS wrapper for a C function. This is similar to ccall, but
  589. // returns a function you can call repeatedly in a normal way. For example:
  590. //
  591. // var my_function = cwrap('my_c_function', 'number', ['number', 'number']);
  592. // alert(my_function(5, 22));
  593. // alert(my_function(99, 12));
  594. //
  595. function cwrap(ident, returnType, argTypes) {
  596. var func = getCFunc(ident);
  597. return function() {
  598. return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));
  599. }
  600. }
  601. Module["cwrap"] = cwrap;
  602. // Sets a value in memory in a dynamic way at run-time. Uses the
  603. // type data. This is the same as makeSetValue, except that
  604. // makeSetValue is done at compile-time and generates the needed
  605. // code then, whereas this function picks the right code at
  606. // run-time.
  607. // Note that setValue and getValue only do *aligned* writes and reads!
  608. // Note that ccall uses JS types as for defining types, while setValue and
  609. // getValue need LLVM types ('i8', 'i32') - this is a lower-level operation
  610. function setValue(ptr, value, type, noSafe) {
  611. type = type || 'i8';
  612. if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
  613. switch(type) {
  614. case 'i1': HEAP8[(ptr)]=value; break;
  615. case 'i8': HEAP8[(ptr)]=value; break;
  616. case 'i16': HEAP16[((ptr)>>1)]=value; break;
  617. case 'i32': HEAP32[((ptr)>>2)]=value; break;
  618. case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math_abs(tempDouble))) >= (+1) ? (tempDouble > (+0) ? ((Math_min((+(Math_floor((tempDouble)/(+4294967296)))), (+4294967295)))|0)>>>0 : (~~((+(Math_ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+4294967296))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;
  619. case 'float': HEAPF32[((ptr)>>2)]=value; break;
  620. case 'double': HEAPF64[((ptr)>>3)]=value; break;
  621. default: abort('invalid type for setValue: ' + type);
  622. }
  623. }
  624. Module['setValue'] = setValue;
  625. // Parallel to setValue.
  626. function getValue(ptr, type, noSafe) {
  627. type = type || 'i8';
  628. if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
  629. switch(type) {
  630. case 'i1': return HEAP8[(ptr)];
  631. case 'i8': return HEAP8[(ptr)];
  632. case 'i16': return HEAP16[((ptr)>>1)];
  633. case 'i32': return HEAP32[((ptr)>>2)];
  634. case 'i64': return HEAP32[((ptr)>>2)];
  635. case 'float': return HEAPF32[((ptr)>>2)];
  636. case 'double': return HEAPF64[((ptr)>>3)];
  637. default: abort('invalid type for setValue: ' + type);
  638. }
  639. return null;
  640. }
  641. Module['getValue'] = getValue;
  642. var ALLOC_NORMAL = 0; // Tries to use _malloc()
  643. var ALLOC_STACK = 1; // Lives for the duration of the current function call
  644. var ALLOC_STATIC = 2; // Cannot be freed
  645. var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk
  646. var ALLOC_NONE = 4; // Do not allocate
  647. Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
  648. Module['ALLOC_STACK'] = ALLOC_STACK;
  649. Module['ALLOC_STATIC'] = ALLOC_STATIC;
  650. Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;
  651. Module['ALLOC_NONE'] = ALLOC_NONE;
  652. // allocate(): This is for internal use. You can use it yourself as well, but the interface
  653. // is a little tricky (see docs right below). The reason is that it is optimized
  654. // for multiple syntaxes to save space in generated code. So you should
  655. // normally not use allocate(), and instead allocate memory using _malloc(),
  656. // initialize it with setValue(), and so forth.
  657. // @slab: An array of data, or a number. If a number, then the size of the block to allocate,
  658. // in *bytes* (note that this is sometimes confusing: the next parameter does not
  659. // affect this!)
  660. // @types: Either an array of types, one for each byte (or 0 if no type at that position),
  661. // or a single type which is used for the entire block. This only matters if there
  662. // is initial data - if @slab is a number, then this does not matter at all and is
  663. // ignored.
  664. // @allocator: How to allocate memory, see ALLOC_*
  665. function allocate(slab, types, allocator, ptr) {
  666. var zeroinit, size;
  667. if (typeof slab === 'number') {
  668. zeroinit = true;
  669. size = slab;
  670. } else {
  671. zeroinit = false;
  672. size = slab.length;
  673. }
  674. var singleType = typeof types === 'string' ? types : null;
  675. var ret;
  676. if (allocator == ALLOC_NONE) {
  677. ret = ptr;
  678. } else {
  679. ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
  680. }
  681. if (zeroinit) {
  682. var ptr = ret, stop;
  683. assert((ret & 3) == 0);
  684. stop = ret + (size & ~3);
  685. for (; ptr < stop; ptr += 4) {
  686. HEAP32[((ptr)>>2)]=0;
  687. }
  688. stop = ret + size;
  689. while (ptr < stop) {
  690. HEAP8[((ptr++)|0)]=0;
  691. }
  692. return ret;
  693. }
  694. if (singleType === 'i8') {
  695. if (slab.subarray || slab.slice) {
  696. HEAPU8.set(slab, ret);
  697. } else {
  698. HEAPU8.set(new Uint8Array(slab), ret);
  699. }
  700. return ret;
  701. }
  702. var i = 0, type, typeSize, previousType;
  703. while (i < size) {
  704. var curr = slab[i];
  705. if (typeof curr === 'function') {
  706. curr = Runtime.getFunctionIndex(curr);
  707. }
  708. type = singleType || types[i];
  709. if (type === 0) {
  710. i++;
  711. continue;
  712. }
  713. if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
  714. setValue(ret+i, curr, type);
  715. // no need to look up size unless type changes, so cache it
  716. if (previousType !== type) {
  717. typeSize = Runtime.getNativeTypeSize(type);
  718. previousType = type;
  719. }
  720. i += typeSize;
  721. }
  722. return ret;
  723. }
  724. Module['allocate'] = allocate;
  725. function Pointer_stringify(ptr, /* optional */ length) {
  726. // TODO: use TextDecoder
  727. // Find the length, and check for UTF while doing so
  728. var hasUtf = false;
  729. var t;
  730. var i = 0;
  731. while (1) {
  732. t = HEAPU8[(((ptr)+(i))|0)];
  733. if (t >= 128) hasUtf = true;
  734. else if (t == 0 && !length) break;
  735. i++;
  736. if (length && i == length) break;
  737. }
  738. if (!length) length = i;
  739. var ret = '';
  740. if (!hasUtf) {
  741. var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack
  742. var curr;
  743. while (length > 0) {
  744. curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));
  745. ret = ret ? ret + curr : curr;
  746. ptr += MAX_CHUNK;
  747. length -= MAX_CHUNK;
  748. }
  749. return ret;
  750. }
  751. var utf8 = new Runtime.UTF8Processor();
  752. for (i = 0; i < length; i++) {
  753. t = HEAPU8[(((ptr)+(i))|0)];
  754. ret += utf8.processCChar(t);
  755. }
  756. return ret;
  757. }
  758. Module['Pointer_stringify'] = Pointer_stringify;
  759. // Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns
  760. // a copy of that string as a Javascript String object.
  761. function UTF16ToString(ptr) {
  762. var i = 0;
  763. var str = '';
  764. while (1) {
  765. var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
  766. if (codeUnit == 0)
  767. return str;
  768. ++i;
  769. // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.
  770. str += String.fromCharCode(codeUnit);
  771. }
  772. }
  773. Module['UTF16ToString'] = UTF16ToString;
  774. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  775. // null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
  776. function stringToUTF16(str, outPtr) {
  777. for(var i = 0; i < str.length; ++i) {
  778. // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
  779. var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
  780. HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit;
  781. }
  782. // Null-terminate the pointer to the HEAP.
  783. HEAP16[(((outPtr)+(str.length*2))>>1)]=0;
  784. }
  785. Module['stringToUTF16'] = stringToUTF16;
  786. // Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns
  787. // a copy of that string as a Javascript String object.
  788. function UTF32ToString(ptr) {
  789. var i = 0;
  790. var str = '';
  791. while (1) {
  792. var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
  793. if (utf32 == 0)
  794. return str;
  795. ++i;
  796. // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
  797. if (utf32 >= 0x10000) {
  798. var ch = utf32 - 0x10000;
  799. str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
  800. } else {
  801. str += String.fromCharCode(utf32);
  802. }
  803. }
  804. }
  805. Module['UTF32ToString'] = UTF32ToString;
  806. // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
  807. // null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
  808. // but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
  809. function stringToUTF32(str, outPtr) {
  810. var iChar = 0;
  811. for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {
  812. // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
  813. var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate
  814. if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
  815. var trailSurrogate = str.charCodeAt(++iCodeUnit);
  816. codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
  817. }
  818. HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit;
  819. ++iChar;
  820. }
  821. // Null-terminate the pointer to the HEAP.
  822. HEAP32[(((outPtr)+(iChar*4))>>2)]=0;
  823. }
  824. Module['stringToUTF32'] = stringToUTF32;
  825. function demangle(func) {
  826. var i = 3;
  827. // params, etc.
  828. var basicTypes = {
  829. 'v': 'void',
  830. 'b': 'bool',
  831. 'c': 'char',
  832. 's': 'short',
  833. 'i': 'int',
  834. 'l': 'long',
  835. 'f': 'float',
  836. 'd': 'double',
  837. 'w': 'wchar_t',
  838. 'a': 'signed char',
  839. 'h': 'unsigned char',
  840. 't': 'unsigned short',
  841. 'j': 'unsigned int',
  842. 'm': 'unsigned long',
  843. 'x': 'long long',
  844. 'y': 'unsigned long long',
  845. 'z': '...'
  846. };
  847. var subs = [];
  848. var first = true;
  849. function dump(x) {
  850. //return;
  851. if (x) Module.print(x);
  852. Module.print(func);
  853. var pre = '';
  854. for (var a = 0; a < i; a++) pre += ' ';
  855. Module.print (pre + '^');
  856. }
  857. function parseNested() {
  858. i++;
  859. if (func[i] === 'K') i++; // ignore const
  860. var parts = [];
  861. while (func[i] !== 'E') {
  862. if (func[i] === 'S') { // substitution
  863. i++;
  864. var next = func.indexOf('_', i);
  865. var num = func.substring(i, next) || 0;
  866. parts.push(subs[num] || '?');
  867. i = next+1;
  868. continue;
  869. }
  870. if (func[i] === 'C') { // constructor
  871. parts.push(parts[parts.length-1]);
  872. i += 2;
  873. continue;
  874. }
  875. var size = parseInt(func.substr(i));
  876. var pre = size.toString().length;
  877. if (!size || !pre) { i--; break; } // counter i++ below us
  878. var curr = func.substr(i + pre, size);
  879. parts.push(curr);
  880. subs.push(curr);
  881. i += pre + size;
  882. }
  883. i++; // skip E
  884. return parts;
  885. }
  886. function parse(rawList, limit, allowVoid) { // main parser
  887. limit = limit || Infinity;
  888. var ret = '', list = [];
  889. function flushList() {
  890. return '(' + list.join(', ') + ')';
  891. }
  892. var name;
  893. if (func[i] === 'N') {
  894. // namespaced N-E
  895. name = parseNested().join('::');
  896. limit--;
  897. if (limit === 0) return rawList ? [name] : name;
  898. } else {
  899. // not namespaced
  900. if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
  901. var size = parseInt(func.substr(i));
  902. if (size) {
  903. var pre = size.toString().length;
  904. name = func.substr(i + pre, size);
  905. i += pre + size;
  906. }
  907. }
  908. first = false;
  909. if (func[i] === 'I') {
  910. i++;
  911. var iList = parse(true);
  912. var iRet = parse(true, 1, true);
  913. ret += iRet[0] + ' ' + name + '<' + iList.join(', ') + '>';
  914. } else {
  915. ret = name;
  916. }
  917. paramLoop: while (i < func.length && limit-- > 0) {
  918. //dump('paramLoop');
  919. var c = func[i++];
  920. if (c in basicTypes) {
  921. list.push(basicTypes[c]);
  922. } else {
  923. switch (c) {
  924. case 'P': list.push(parse(true, 1, true)[0] + '*'); break; // pointer
  925. case 'R': list.push(parse(true, 1, true)[0] + '&'); break; // reference
  926. case 'L': { // literal
  927. i++; // skip basic type
  928. var end = func.indexOf('E', i);
  929. var size = end - i;
  930. list.push(func.substr(i, size));
  931. i += size + 2; // size + 'EE'
  932. break;
  933. }
  934. case 'A': { // array
  935. var size = parseInt(func.substr(i));
  936. i += size.toString().length;
  937. if (func[i] !== '_') throw '?';
  938. i++; // skip _
  939. list.push(parse(true, 1, true)[0] + ' [' + size + ']');
  940. break;
  941. }
  942. case 'E': break paramLoop;
  943. default: ret += '?' + c; break paramLoop;
  944. }
  945. }
  946. }
  947. if (!allowVoid && list.length === 1 && list[0] === 'void') list = []; // avoid (void)
  948. if (rawList) {
  949. if (ret) {
  950. list.push(ret + '?');
  951. }
  952. return list;
  953. } else {
  954. return ret + flushList();
  955. }
  956. }
  957. try {
  958. // Special-case the entry point, since its name differs from other name mangling.
  959. if (func == 'Object._main' || func == '_main') {
  960. return 'main()';
  961. }
  962. if (typeof func === 'number') func = Pointer_stringify(func);
  963. if (func[0] !== '_') return func;
  964. if (func[1] !== '_') return func; // C function
  965. if (func[2] !== 'Z') return func;
  966. switch (func[3]) {
  967. case 'n': return 'operator new()';
  968. case 'd': return 'operator delete()';
  969. }
  970. return parse();
  971. } catch(e) {
  972. return func;
  973. }
  974. }
  975. function demangleAll(text) {
  976. return text.replace(/__Z[\w\d_]+/g, function(x) { var y = demangle(x); return x === y ? x : (x + ' [' + y + ']') });
  977. }
  978. function stackTrace() {
  979. var stack = new Error().stack;
  980. return stack ? demangleAll(stack) : '(no stack trace available)'; // Stack trace is not available at least on IE10 and Safari 6.
  981. }
  982. // Memory management
  983. var PAGE_SIZE = 4096;
  984. function alignMemoryPage(x) {
  985. return (x+4095)&-4096;
  986. }
  987. var HEAP;
  988. var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
  989. var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area
  990. var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area
  991. var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk
  992. function enlargeMemory() {
  993. abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
  994. }
  995. var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;
  996. var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 134217728;
  997. var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
  998. var totalMemory = 4096;
  999. while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
  1000. if (totalMemory < 16*1024*1024) {
  1001. totalMemory *= 2;
  1002. } else {
  1003. totalMemory += 16*1024*1024
  1004. }
  1005. }
  1006. if (totalMemory !== TOTAL_MEMORY) {
  1007. Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
  1008. TOTAL_MEMORY = totalMemory;
  1009. }
  1010. // Initialize the runtime's memory
  1011. // check for full engine support (use string 'subarray' to avoid closure compiler confusion)
  1012. assert(typeof Int32Array !== 'undefined' && typeof Float64Array !== 'undefined' && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
  1013. 'JS engine does not provide full typed array support');
  1014. var buffer = new ArrayBuffer(TOTAL_MEMORY);
  1015. HEAP8 = new Int8Array(buffer);
  1016. HEAP16 = new Int16Array(buffer);
  1017. HEAP32 = new Int32Array(buffer);
  1018. HEAPU8 = new Uint8Array(buffer);
  1019. HEAPU16 = new Uint16Array(buffer);
  1020. HEAPU32 = new Uint32Array(buffer);
  1021. HEAPF32 = new Float32Array(buffer);
  1022. HEAPF64 = new Float64Array(buffer);
  1023. // Endianness check (note: assumes compiler arch was little-endian)
  1024. HEAP32[0] = 255;
  1025. assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
  1026. Module['HEAP'] = HEAP;
  1027. Module['HEAP8'] = HEAP8;
  1028. Module['HEAP16'] = HEAP16;
  1029. Module['HEAP32'] = HEAP32;
  1030. Module['HEAPU8'] = HEAPU8;
  1031. Module['HEAPU16'] = HEAPU16;
  1032. Module['HEAPU32'] = HEAPU32;
  1033. Module['HEAPF32'] = HEAPF32;
  1034. Module['HEAPF64'] = HEAPF64;
  1035. function callRuntimeCallbacks(callbacks) {
  1036. while(callbacks.length > 0) {
  1037. var callback = callbacks.shift();
  1038. if (typeof callback == 'function') {
  1039. callback();
  1040. continue;
  1041. }
  1042. var func = callback.func;
  1043. if (typeof func === 'number') {
  1044. if (callback.arg === undefined) {
  1045. Runtime.dynCall('v', func);
  1046. } else {
  1047. Runtime.dynCall('vi', func, [callback.arg]);
  1048. }
  1049. } else {
  1050. func(callback.arg === undefined ? null : callback.arg);
  1051. }
  1052. }
  1053. }
  1054. var __ATPRERUN__ = []; // functions called before the runtime is initialized
  1055. var __ATINIT__ = []; // functions called during startup
  1056. var __ATMAIN__ = []; // functions called when main() is to be run
  1057. var __ATEXIT__ = []; // functions called during shutdown
  1058. var __ATPOSTRUN__ = []; // functions called after the runtime has exited
  1059. var runtimeInitialized = false;
  1060. function preRun() {
  1061. // compatibility - merge in anything from Module['preRun'] at this time
  1062. if (Module['preRun']) {
  1063. if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
  1064. while (Module['preRun'].length) {
  1065. addOnPreRun(Module['preRun'].shift());
  1066. }
  1067. }
  1068. callRuntimeCallbacks(__ATPRERUN__);
  1069. }
  1070. function ensureInitRuntime() {
  1071. if (runtimeInitialized) return;
  1072. runtimeInitialized = true;
  1073. callRuntimeCallbacks(__ATINIT__);
  1074. }
  1075. function preMain() {
  1076. callRuntimeCallbacks(__ATMAIN__);
  1077. }
  1078. function exitRuntime() {
  1079. callRuntimeCallbacks(__ATEXIT__);
  1080. }
  1081. function postRun() {
  1082. // compatibility - merge in anything from Module['postRun'] at this time
  1083. if (Module['postRun']) {
  1084. if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
  1085. while (Module['postRun'].length) {
  1086. addOnPostRun(Module['postRun'].shift());
  1087. }
  1088. }
  1089. callRuntimeCallbacks(__ATPOSTRUN__);
  1090. }
  1091. function addOnPreRun(cb) {
  1092. __ATPRERUN__.unshift(cb);
  1093. }
  1094. Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;
  1095. function addOnInit(cb) {
  1096. __ATINIT__.unshift(cb);
  1097. }
  1098. Module['addOnInit'] = Module.addOnInit = addOnInit;
  1099. function addOnPreMain(cb) {
  1100. __ATMAIN__.unshift(cb);
  1101. }
  1102. Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;
  1103. function addOnExit(cb) {
  1104. __ATEXIT__.unshift(cb);
  1105. }
  1106. Module['addOnExit'] = Module.addOnExit = addOnExit;
  1107. function addOnPostRun(cb) {
  1108. __ATPOSTRUN__.unshift(cb);
  1109. }
  1110. Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;
  1111. // Tools
  1112. // This processes a JS string into a C-line array of numbers, 0-terminated.
  1113. // For LLVM-originating strings, see parser.js:parseLLVMString function
  1114. function intArrayFromString(stringy, dontAddNull, length /* optional */) {
  1115. var ret = (new Runtime.UTF8Processor()).processJSString(stringy);
  1116. if (length) {
  1117. ret.length = length;
  1118. }
  1119. if (!dontAddNull) {
  1120. ret.push(0);
  1121. }
  1122. return ret;
  1123. }
  1124. Module['intArrayFromString'] = intArrayFromString;
  1125. function intArrayToString(array) {
  1126. var ret = [];
  1127. for (var i = 0; i < array.length; i++) {
  1128. var chr = array[i];
  1129. if (chr > 0xFF) {
  1130. chr &= 0xFF;
  1131. }
  1132. ret.push(String.fromCharCode(chr));
  1133. }
  1134. return ret.join('');
  1135. }
  1136. Module['intArrayToString'] = intArrayToString;
  1137. // Write a Javascript array to somewhere in the heap
  1138. function writeStringToMemory(string, buffer, dontAddNull) {
  1139. var array = intArrayFromString(string, dontAddNull);
  1140. var i = 0;
  1141. while (i < array.length) {
  1142. var chr = array[i];
  1143. HEAP8[(((buffer)+(i))|0)]=chr;
  1144. i = i + 1;
  1145. }
  1146. }
  1147. Module['writeStringToMemory'] = writeStringToMemory;
  1148. function writeArrayToMemory(array, buffer) {
  1149. for (var i = 0; i < array.length; i++) {
  1150. HEAP8[(((buffer)+(i))|0)]=array[i];
  1151. }
  1152. }
  1153. Module['writeArrayToMemory'] = writeArrayToMemory;
  1154. function writeAsciiToMemory(str, buffer, dontAddNull) {
  1155. for (var i = 0; i < str.length; i++) {
  1156. HEAP8[(((buffer)+(i))|0)]=str.charCodeAt(i);
  1157. }
  1158. if (!dontAddNull) HEAP8[(((buffer)+(str.length))|0)]=0;
  1159. }
  1160. Module['writeAsciiToMemory'] = writeAsciiToMemory;
  1161. function unSign(value, bits, ignore) {
  1162. if (value >= 0) {
  1163. return value;
  1164. }
  1165. 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
  1166. : Math.pow(2, bits) + value;
  1167. }
  1168. function reSign(value, bits, ignore) {
  1169. if (value <= 0) {
  1170. return value;
  1171. }
  1172. var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
  1173. : Math.pow(2, bits-1);
  1174. 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
  1175. // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
  1176. // TODO: In i64 mode 1, resign the two parts separately and safely
  1177. value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
  1178. }
  1179. return value;
  1180. }
  1181. // check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
  1182. if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
  1183. var ah = a >>> 16;
  1184. var al = a & 0xffff;
  1185. var bh = b >>> 16;
  1186. var bl = b & 0xffff;
  1187. return (al*bl + ((ah*bl + al*bh) << 16))|0;
  1188. };
  1189. Math.imul = Math['imul'];
  1190. var Math_abs = Math.abs;
  1191. var Math_cos = Math.cos;
  1192. var Math_sin = Math.sin;
  1193. var Math_tan = Math.tan;
  1194. var Math_acos = Math.acos;
  1195. var Math_asin = Math.asin;
  1196. var Math_atan = Math.atan;
  1197. var Math_atan2 = Math.atan2;
  1198. var Math_exp = Math.exp;
  1199. var Math_log = Math.log;
  1200. var Math_sqrt = Math.sqrt;
  1201. var Math_ceil = Math.ceil;
  1202. var Math_floor = Math.floor;
  1203. var Math_pow = Math.pow;
  1204. var Math_imul = Math.imul;
  1205. var Math_fround = Math.fround;
  1206. var Math_min = Math.min;
  1207. // A counter of dependencies for calling run(). If we need to
  1208. // do asynchronous work before running, increment this and
  1209. // decrement it. Incrementing must happen in a place like
  1210. // PRE_RUN_ADDITIONS (used by emcc to add file preloading).
  1211. // Note that you can add dependencies in preRun, even though
  1212. // it happens right before run - run will be postponed until
  1213. // the dependencies are met.
  1214. var runDependencies = 0;
  1215. var runDependencyWatcher = null;
  1216. var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
  1217. function addRunDependency(id) {
  1218. runDependencies++;
  1219. if (Module['monitorRunDependencies']) {
  1220. Module['monitorRunDependencies'](runDependencies);
  1221. }
  1222. }
  1223. Module['addRunDependency'] = addRunDependency;
  1224. function removeRunDependency(id) {
  1225. runDependencies--;
  1226. if (Module['monitorRunDependencies']) {
  1227. Module['monitorRunDependencies'](runDependencies);
  1228. }
  1229. if (runDependencies == 0) {
  1230. if (runDependencyWatcher !== null) {
  1231. clearInterval(runDependencyWatcher);
  1232. runDependencyWatcher = null;
  1233. }
  1234. if (dependenciesFulfilled) {
  1235. var callback = dependenciesFulfilled;
  1236. dependenciesFulfilled = null;
  1237. callback(); // can add another dependenciesFulfilled
  1238. }
  1239. }
  1240. }
  1241. Module['removeRunDependency'] = removeRunDependency;
  1242. Module["preloadedImages"] = {}; // maps url to image data
  1243. Module["preloadedAudios"] = {}; // maps url to audio data
  1244. var memoryInitializer = null;
  1245. // === Body ===
  1246. var __ZTVN10__cxxabiv117__class_type_infoE = 7024;
  1247. var __ZTVN10__cxxabiv120__si_class_type_infoE = 7064;
  1248. STATIC_BASE = 8;
  1249. STATICTOP = STATIC_BASE + Runtime.alignMemory(7731);
  1250. /* global initializers */ __ATINIT__.push();
  1251. /* memory initializer */ allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,232,118,72,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,114,114,111,114,58,32,37,100,92,110,0,0,0,0,0,102,114,97,109,101,32,97,118,101,114,97,103,101,115,58,32,37,46,51,102,32,43,45,32,37,46,51,102,44,32,114,97,110,103,101,58,32,37,46,51,102,32,116,111,32,37,46,51,102,32,10,0,0,0,0,0,105,102,32,40,77,111,100,117,108,101,46,114,101,112,111,114,116,67,111,109,112,108,101,116,105,111,110,41,32,77,111,100,117,108,101,46,114,101,112,111,114,116,67,111,109,112,108,101,116,105,111,110,40,41,0,0,114,101,115,112,111,110,115,105,118,101,32,109,97,105,110,32,108,111,111,112,0,0,0,0,0,0,0,0,56,1,0,0,1,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,49,49,98,50,69,100,103,101,83,104,97,112,101,0,0,0,55,98,50,83,104,97,112,101,0,0,0,0,0,0,0,0,120,27,0,0,32,1,0,0,160,27,0,0,16,1,0,0,48,1,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,80,111,108,121,103,111,110,83,104,97,112,101,46,99,112,112,0,0,0,0,0,0,0,48,46,48,102,32,60,61,32,108,111,119,101,114,32,38,38,32,108,111,119,101,114,32,60,61,32,105,110,112,117,116,46,109,97,120,70,114,97,99,116,105,111,110,0,0,0,0,0,82,97,121,67,97,115,116,0,109,95,118,101,114,116,101,120,67,111,117,110,116,32,62,61,32,51,0,0,0,0,0,0,67,111,109,112,117,116,101,77,97,115,115,0,0,0,0,0,97,114,101,97,32,62,32,49,46,49,57,50,48,57,50,57,48,101,45,48,55,70,0,0,0,0,0,0,48,2,0,0,3,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,49,52,98,50,80,111,108,121,103,111,110,83,104,97,112,101,0,0,0,0,0,0,0,0,160,27,0,0,24,2,0,0,48,1,0,0,0,0,0,0,16,0,0,0,32,0,0,0,64,0,0,0,96,0,0,0,128,0,0,0,160,0,0,0,192,0,0,0,224,0,0,0,0,1,0,0,64,1,0,0,128,1,0,0,192,1,0,0,0,2,0,0,128,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,106,32,60,32,98,50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,0,0,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,46,99,112,112,0,0,0,0,0,0,0,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,0,0,0,0,0,0,0,0,48,32,60,32,115,105,122,101,0,0,0,0,0,0,0,0,65,108,108,111,99,97,116,101,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,98,50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,98,108,111,99,107,67,111,117,110,116,32,42,32,98,108,111,99,107,83,105,122,101,32,60,61,32,98,50,95,99,104,117,110,107,83,105,122,101,0,0,70,114,101,101,0,0,0,0,98,100,45,62,112,111,115,105,116,105,111,110,46,73,115,86,97,108,105,100,40,41,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,66,111,100,121,46,99,112,112,0,0,0,0,0,0,0,98,50,66,111,100,121,0,0,98,100,45,62,108,105,110,101,97,114,86,101,108,111,99,105,116,121,46,73,115,86,97,108,105,100,40,41,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,108,101,41,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,86,101,108,111,99,105,116,121,41,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,108,105,110,101,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,108,105,110,101,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,109,95,119,111,114,108,100,45,62,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,67,114,101,97,116,101,70,105,120,116,117,114,101,0,0,0,109,95,116,121,112,101,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,0,0,82,101,115,101,116,77,97,115,115,68,97,116,97,0,0,0,109,95,73,32,62,32,48,46,48,102,0,0,0,0,0,0,0,10,0,0,0,0,0,0,240,7,0,0,0,0,0,0,48,32,60,61,32,112,114,111,120,121,73,100,32,38,38,32,112,114,111,120,121,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,46,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,121,110,97,109,105,99,84,114,101,101,46,104,0,0,0,0,0,0,0,71,101,116,85,115,101,114,68,97,116,97,0,0,0,0,0,71,101,116,70,97,116,65,65,66,66,0,0,0,0,0,0,0,0,0,0,32,8,0,0,5,0,0,0,6,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,49,55,98,50,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,0,0,0,0,0,120,27,0,0,8,8,0,0,109,95,112,114,111,120,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,70,105,120,116,117,114,101,46,99,112,112,0,0,0,0,67,114,101,97,116,101,80,114,111,120,105,101,115,0,0,0,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,87,111,114,108,100,46,99,112,112,0,0,0,0,0,0,67,114,101,97,116,101,66,111,100,121,0,0,0,0,0,0,98,45,62,73,115,65,99,116,105,118,101,40,41,32,61,61,32,116,114,117,101,0,0,0,83,111,108,118,101,0,0,0,115,116,97,99,107,67,111,117,110,116,32,60,32,115,116,97,99,107,83,105,122,101,0,0,116,121,112,101,65,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,32,124,124,32,116,121,112,101,66,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,83,111,108,118,101,84,79,73,0,0,0,0,0,0,0,0,97,108,112,104,97,48,32,60,32,49,46,48,102,0,0,0,46,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,77,97,116,104,46,104,0,65,100,118,97,110,99,101,0,109,95,106,111,105,110,116,67,111,117,110,116,32,60,32,109,95,106,111,105,110,116,67,97,112,97,99,105,116,121,0,0,46,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,73,115,108,97,110,100,46,104,0,0,0,0,0,65,100,100,0,0,0,0,0,109,95,99,111,110,116,97,99,116,67,111,117,110,116,32,60,32,109,95,99,111,110,116,97,99,116,67,97,112,97,99,105,116,121,0,0,0,0,0,0,109,95,98,111,100,121,67,111,117,110,116,32,60,32,109,95,98,111,100,121,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,40,10,0,0,7,0,0,0,8,0,0,0,3,0,0,0,0,0,0,0,49,53,98,50,67,111,110,116,97,99,116,70,105,108,116,101,114,0,0,0,0,0,0,0,120,27,0,0,16,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,99,104,97,105,110,45,62,109,95,99,111,117,110,116,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,99,112,112,0,0,83,101,116,0,0,0,0,0,102,97,108,115,101,0,0,0,98,50,68,105,115,116,97,110,99,101,0,0,0,0,0,0,71,101,116,77,101,116,114,105,99,0,0,0,0,0,0,0,71,101,116,87,105,116,110,101,115,115,80,111,105,110,116,115,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,0,0,0,46,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,104,0,0,71,101,116,86,101,114,116,101,120,0,0,0,0,0,0,0,71,101,116,67,108,111,115,101,115,116,80,111,105,110,116,0,99,97,99,104,101,45,62,99,111,117,110,116,32,60,61,32,51,0,0,0,0,0,0,0,82,101,97,100,67,97,99,104,101,0,0,0,0,0,0,0,109,95,110,111,100,101,67,111,117,110,116,32,61,61,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,121,110,97,109,105,99,84,114,101,101,46,99,112,112,0,0,0,0,0,0,0,65,108,108,111,99,97,116,101,78,111,100,101,0,0,0,0,48,32,60,61,32,110,111,100,101,73,100,32,38,38,32,110,111,100,101,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,70,114,101,101,78,111,100,101,0,0,0,0,0,0,0,0,48,32,60,32,109,95,110,111,100,101,67,111,117,110,116,0,48,32,60,61,32,112,114,111,120,121,73,100,32,38,38,32,112,114,111,120,121,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,109,95,110,111,100,101,115,91,112,114,111,120,121,73,100,93,46,73,115,76,101,97,102,40,41,0,0,0,0,0,0,0,77,111,118,101,80,114,111,120,121,0,0,0,0,0,0,0,99,104,105,108,100,49,32,33,61,32,40,45,49,41,0,0,73,110,115,101,114,116,76,101,97,102,0,0,0,0,0,0,99,104,105,108,100,50,32,33,61,32,40,45,49,41,0,0,105,65,32,33,61,32,40,45,49,41,0,0,0,0,0,0,66,97,108,97,110,99,101,0,48,32,60,61,32,105,66,32,38,38,32,105,66,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,67,32,38,38,32,105,67,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,70,32,38,38,32,105,70,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,71,32,38,38,32,105,71,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,109,95,110,111,100,101,115,91,67,45,62,112,97,114,101,110,116,93,46,99,104,105,108,100,50,32,61,61,32,105,65,0,48,32,60,61,32,105,68,32,38,38,32,105,68,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,48,32,60,61,32,105,69,32,38,38,32,105,69,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,109,95,110,111,100,101,115,91,66,45,62,112,97,114,101,110,116,93,46,99,104,105,108,100,50,32,61,61,32,105,65,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,97,114,103,101,116,32,62,32,116,111,108,101,114,97,110,99,101,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,84,105,109,101,79,102,73,109,112,97,99,116,46,99,112,112,0,0,0,0,0,0,98,50,84,105,109,101,79,102,73,109,112,97,99,116,0,0,102,97,108,115,101,0,0,0,69,118,97,108,117,97,116,101,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,0,0,0,46,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,104,0,0,71,101,116,86,101,114,116,101,120,0,0,0,0,0,0,0,70,105,110,100,77,105,110,83,101,112,97,114,97,116,105,111,110,0,0,0,0,0,0,0,48,32,60,32,99,111,117,110,116,32,38,38,32,99,111,117,110,116,32,60,32,51,0,0,73,110,105,116,105,97,108,105,122,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,95,105,110,100,101,120,32,61,61,32,48,0,0,0,0,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,46,99,112,112,0,0,0,0,0,0,0,126,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,60,32,98,50,95,109,97,120,83,116,97,99,107,69,110,116,114,105,101,115,0,0,0,0,0,0,0,65,108,108,111,99,97,116,101,0,0,0,0,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,70,114,101,101,0,0,0,0,112,32,61,61,32,101,110,116,114,121,45,62,100,97,116,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,32,60,61,32,116,121,112,101,49,32,38,38,32,116,121,112,101,49,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,46,99,112,112,0,0,0,48,32,60,61,32,116,121,112,101,50,32,38,38,32,116,121,112,101,50,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,67,114,101,97,116,101,0,0,115,95,105,110,105,116,105,97,108,105,122,101,100,32,61,61,32,116,114,117,101,0,0,0,68,101,115,116,114,111,121,0,48,32,60,61,32,116,121,112,101,65,32,38,38,32,116,121,112,101,66,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,0,0,0,0,120,17,0,0,1,0,0,0,9,0,0,0,10,0,0,0,0,0,0,0,57,98,50,67,111,110,116,97,99,116,0,0,0,0,0,0,120,27,0,0,104,17,0,0,0,0,0,0,104,18,0,0,3,0,0,0,11,0,0,0,12,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,101,100,103,101,0,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,50,50,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,160,27,0,0,72,18,0,0,120,17,0,0,0,0,0,0,0,0,0,0,96,19,0,0,4,0,0,0,13,0,0,0,14,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,101,100,103,101,0,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,50,51,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,160,27,0,0,64,19,0,0,120,17,0,0,0,0,0,0,0,0,0,0,96,20,0,0,5,0,0,0,15,0,0,0,16,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,50,53,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,160,27,0,0,64,20,0,0,120,17,0,0,0,0,0,0,0,0,0,0,72,21,0,0,6,0,0,0,17,0,0,0,18,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,49,54,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,160,27,0,0,48,21,0,0,120,17,0,0,0,0,0,0,116,111,105,73,110,100,101,120,65,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,73,115,108,97,110,100,46,99,112,112,0,0,0,0,0,83,111,108,118,101,84,79,73,0,0,0,0,0,0,0,0,116,111,105,73,110,100,101,120,66,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,100,101,110,32,62,32,48,46,48,102,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,69,100,103,101,46,99,112,112,0,0,0,0,0,0,0,98,50,67,111,108,108,105,100,101,69,100,103,101,65,110,100,67,105,114,99,108,101,0,0,48,32,60,61,32,101,100,103,101,49,32,38,38,32,101,100,103,101,49,32,60,32,112,111,108,121,49,45,62,109,95,118,101,114,116,101,120,67,111,117,110,116,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,80,111,108,121,103,111,110,46,99,112,112,0,0,0,0,98,50,70,105,110,100,73,110,99,105,100,101,110,116,69,100,103,101,0,0,0,0,0,0,98,50,69,100,103,101,83,101,112,97,114,97,116,105,111,110,0,0,0,0,0,0,0,0,0,0,0,0,120,23,0,0,7,0,0,0,19,0,0,0,20,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,104,97,105,110,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,50,51,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,160,27,0,0,88,23,0,0,120,17,0,0,0,0,0,0,0,0,0,0,120,24,0,0,8,0,0,0,21,0,0,0,22,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,104,97,105,110,0,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,50,52,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,160,27,0,0,88,24,0,0,120,17,0,0,0,0,0,0,0,0,0,0,88,25,0,0,9,0,0,0,23,0,0,0,24,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,49,53,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,160,27,0,0,64,25,0,0,120,17,0,0,0,0,0,0,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,46,99,112,112,0,0,0,0,0,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,0,109,97,110,105,102,111,108,100,45,62,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,73,110,105,116,105,97,108,105,122,101,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,0,0,0,112,111,105,110,116,67,111,117,110,116,32,61,61,32,49,32,124,124,32,112,111,105,110,116,67,111,117,110,116,32,61,61,32,50,0,0,0,0,0,0,83,111,108,118,101,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,0,0,0,0,0,0,0,0,97,46,120,32,62,61,32,48,46,48,102,32,38,38,32,97,46,121,32,62,61,32,48,46,48,102,0,0,0,0,0,0,112,99,45,62,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,73,110,105,116,105,97,108,105,122,101,0,0,0,0,0,0,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,67,104,97,105,110,83,104,97,112,101,46,99,112,112,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,32,45,32,49,0,0,0,0,0,0,0,71,101,116,67,104,105,108,100,69,100,103,101,0,0,0,0,83,116,57,116,121,112,101,95,105,110,102,111,0,0,0,0,120,27,0,0,232,26,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,160,27,0,0,0,27,0,0,248,26,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,160,27,0,0,56,27,0,0,40,27,0,0,0,0,0,0,0,0,0,0,96,27,0,0,25,0,0,0,26,0,0,0,27,0,0,0,28,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,10,0,0,0,0,0,0,0,232,27,0,0,25,0,0,0,29,0,0,0,27,0,0,0,28,0,0,0,4,0,0,0,2,0,0,0,2,0,0,0,11,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,160,27,0,0,192,27,0,0,96,27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,30,0,0,30,0,0,0,31,0,0,0,3,0,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,0,83,116,57,98,97,100,95,97,108,108,111,99,0,0,0,0,160,27,0,0,24,30,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE);
  1252. var tempDoublePtr = Runtime.alignMemory(allocate(12, "i8", ALLOC_STATIC), 8);
  1253. assert(tempDoublePtr % 8 == 0);
  1254. function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much
  1255. HEAP8[tempDoublePtr] = HEAP8[ptr];
  1256. HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
  1257. HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
  1258. HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
  1259. }
  1260. function copyTempDouble(ptr) {
  1261. HEAP8[tempDoublePtr] = HEAP8[ptr];
  1262. HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
  1263. HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
  1264. HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
  1265. HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
  1266. HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
  1267. HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
  1268. HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
  1269. }
  1270. function _emscripten_set_main_loop(func, fps, simulateInfiniteLoop, arg) {
  1271. Module['noExitRuntime'] = true;
  1272. Browser.mainLoop.runner = function Browser_mainLoop_runner() {
  1273. if (ABORT) return;
  1274. if (Browser.mainLoop.queue.length > 0) {
  1275. var start = Date.now();
  1276. var blocker = Browser.mainLoop.queue.shift();
  1277. blocker.func(blocker.arg);
  1278. if (Browser.mainLoop.remainingBlockers) {
  1279. var remaining = Browser.mainLoop.remainingBlockers;
  1280. var next = remaining%1 == 0 ? remaining-1 : Math.floor(remaining);
  1281. if (blocker.counted) {
  1282. Browser.mainLoop.remainingBlockers = next;
  1283. } else {
  1284. // not counted, but move the progress along a tiny bit
  1285. next = next + 0.5; // do not steal all the next one's progress
  1286. Browser.mainLoop.remainingBlockers = (8*remaining + next)/9;
  1287. }
  1288. }
  1289. console.log('main loop blocker "' + blocker.name + '" took ' + (Date.now() - start) + ' ms'); //, left: ' + Browser.mainLoop.remainingBlockers);
  1290. Browser.mainLoop.updateStatus();
  1291. setTimeout(Browser.mainLoop.runner, 0);
  1292. return;
  1293. }
  1294. if (Browser.mainLoop.shouldPause) {
  1295. // catch pauses from non-main loop sources
  1296. Browser.mainLoop.paused = true;
  1297. Browser.mainLoop.shouldPause = false;
  1298. return;
  1299. }
  1300. // Signal GL rendering layer that processing of a new frame is about to start. This helps it optimize
  1301. // VBO double-buffering and reduce GPU stalls.
  1302. if (Browser.mainLoop.method === 'timeout' && Module.ctx) {
  1303. Module.printErr('Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!');
  1304. Browser.mainLoop.method = ''; // just warn once per call to set main loop
  1305. }
  1306. if (Module['preMainLoop']) {
  1307. Module['preMainLoop']();
  1308. }
  1309. try {
  1310. if (typeof arg !== 'undefined') {
  1311. Runtime.dynCall('vi', func, [arg]);
  1312. } else {
  1313. Runtime.dynCall('v', func);
  1314. }
  1315. } catch (e) {
  1316. if (e instanceof ExitStatus) {
  1317. return;
  1318. } else {
  1319. if (e && typeof e === 'object' && e.stack) Module.printErr('exception thrown: ' + [e, e.stack]);
  1320. throw e;
  1321. }
  1322. }
  1323. if (Module['postMainLoop']) {
  1324. Module['postMainLoop']();
  1325. }
  1326. if (Browser.mainLoop.shouldPause) {
  1327. // catch pauses from the main loop itself
  1328. Browser.mainLoop.paused = true;
  1329. Browser.mainLoop.shouldPause = false;
  1330. return;
  1331. }
  1332. Browser.mainLoop.scheduler();
  1333. }
  1334. if (fps && fps > 0) {
  1335. Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() {
  1336. setTimeout(Browser.mainLoop.runner, 1000/fps); // doing this each time means that on exception, we stop
  1337. };
  1338. Browser.mainLoop.method = 'timeout';
  1339. } else {
  1340. Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() {
  1341. Browser.requestAnimationFrame(Browser.mainLoop.runner);
  1342. };
  1343. Browser.mainLoop.method = 'rAF';
  1344. }
  1345. Browser.mainLoop.scheduler();
  1346. if (simulateInfiniteLoop) {
  1347. throw 'SimulateInfiniteLoop';
  1348. }
  1349. }
  1350. var _cosf=Math_cos;
  1351. function ___cxa_pure_virtual() {
  1352. ABORT = true;
  1353. throw 'Pure virtual function called!';
  1354. }
  1355. function _time(ptr) {
  1356. var ret = Math.floor(Date.now()/1000);
  1357. if (ptr) {
  1358. HEAP32[((ptr)>>2)]=ret;
  1359. }
  1360. return ret;
  1361. }
  1362. function ___assert_fail(condition, filename, line, func) {
  1363. ABORT = true;
  1364. throw 'Assertion failed: ' + Pointer_stringify(condition) + ', at: ' + [filename ? Pointer_stringify(filename) : 'unknown filename', line, func ? Pointer_stringify(func) : 'unknown function'] + ' at ' + stackTrace();
  1365. }
  1366. function __ZSt18uncaught_exceptionv() { // std::uncaught_exception()
  1367. return !!__ZSt18uncaught_exceptionv.uncaught_exception;
  1368. }
  1369. function ___cxa_is_number_type(type) {
  1370. var isNumber = false;
  1371. try { if (type == __ZTIi) isNumber = true } catch(e){}
  1372. try { if (type == __ZTIj) isNumber = true } catch(e){}
  1373. try { if (type == __ZTIl) isNumber = true } catch(e){}
  1374. try { if (type == __ZTIm) isNumber = true } catch(e){}
  1375. try { if (type == __ZTIx) isNumber = true } catch(e){}
  1376. try { if (type == __ZTIy) isNumber = true } catch(e){}
  1377. try { if (type == __ZTIf) isNumber = true } catch(e){}
  1378. try { if (type == __ZTId) isNumber = true } catch(e){}
  1379. try { if (type == __ZTIe) isNumber = true } catch(e){}
  1380. try { if (type == __ZTIc) isNumber = true } catch(e){}
  1381. try { if (type == __ZTIa) isNumber = true } catch(e){}
  1382. try { if (type == __ZTIh) isNumber = true } catch(e){}
  1383. try { if (type == __ZTIs) isNumber = true } catch(e){}
  1384. try { if (type == __ZTIt) isNumber = true } catch(e){}
  1385. return isNumber;
  1386. }function ___cxa_does_inherit(definiteType, possibilityType, possibility) {
  1387. if (possibility == 0) return false;
  1388. if (possibilityType == 0 || possibilityType == definiteType)
  1389. return true;
  1390. var possibility_type_info;
  1391. if (___cxa_is_number_type(possibilityType)) {
  1392. possibility_type_info = possibilityType;
  1393. } else {
  1394. var possibility_type_infoAddr = HEAP32[((possibilityType)>>2)] - 8;
  1395. possibility_type_info = HEAP32[((possibility_type_infoAddr)>>2)];
  1396. }
  1397. switch (possibility_type_info) {
  1398. case 0: // possibility is a pointer
  1399. // See if definite type is a pointer
  1400. var definite_type_infoAddr = HEAP32[((definiteType)>>2)] - 8;
  1401. var definite_type_info = HEAP32[((definite_type_infoAddr)>>2)];
  1402. if (definite_type_info == 0) {
  1403. // Also a pointer; compare base types of pointers
  1404. var defPointerBaseAddr = definiteType+8;
  1405. var defPointerBaseType = HEAP32[((defPointerBaseAddr)>>2)];
  1406. var possPointerBaseAddr = possibilityType+8;
  1407. var possPointerBaseType = HEAP32[((possPointerBaseAddr)>>2)];
  1408. return ___cxa_does_inherit(defPointerBaseType, possPointerBaseType, possibility);
  1409. } else
  1410. return false; // one pointer and one non-pointer
  1411. case 1: // class with no base class
  1412. return false;
  1413. case 2: // class with base class
  1414. var parentTypeAddr = possibilityType + 8;
  1415. var parentType = HEAP32[((parentTypeAddr)>>2)];
  1416. return ___cxa_does_inherit(definiteType, parentType, possibility);
  1417. default:
  1418. return false; // some unencountered type
  1419. }
  1420. }
  1421. var ___cxa_last_thrown_exception=0;function ___resumeException(ptr) {
  1422. if (!___cxa_last_thrown_exception) { ___cxa_last_thrown_exception = ptr; }
  1423. throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
  1424. }
  1425. var ___cxa_exception_header_size=8;function ___cxa_find_matching_catch(thrown, throwntype) {
  1426. if (thrown == -1) thrown = ___cxa_last_thrown_exception;
  1427. header = thrown - ___cxa_exception_header_size;
  1428. if (throwntype == -1) throwntype = HEAP32[((header)>>2)];
  1429. var typeArray = Array.prototype.slice.call(arguments, 2);
  1430. // If throwntype is a pointer, this means a pointer has been
  1431. // thrown. When a pointer is thrown, actually what's thrown
  1432. // is a pointer to the pointer. We'll dereference it.
  1433. if (throwntype != 0 && !___cxa_is_number_type(throwntype)) {
  1434. var throwntypeInfoAddr= HEAP32[((throwntype)>>2)] - 8;
  1435. var throwntypeInfo= HEAP32[((throwntypeInfoAddr)>>2)];
  1436. if (throwntypeInfo == 0)
  1437. thrown = HEAP32[((thrown)>>2)];
  1438. }
  1439. // The different catch blocks are denoted by different types.
  1440. // Due to inheritance, those types may not precisely match the
  1441. // type of the thrown object. Find one which matches, and
  1442. // return the type of the catch block which should be called.
  1443. for (var i = 0; i < typeArray.length; i++) {
  1444. if (___cxa_does_inherit(typeArray[i], throwntype, thrown))
  1445. return ((asm["setTempRet0"](typeArray[i]),thrown)|0);
  1446. }
  1447. // Shouldn't happen unless we have bogus data in typeArray
  1448. // or encounter a type for which emscripten doesn't have suitable
  1449. // typeinfo defined. Best-efforts match just in case.
  1450. return ((asm["setTempRet0"](throwntype),thrown)|0);
  1451. }function ___cxa_throw(ptr, type, destructor) {
  1452. if (!___cxa_throw.initialized) {
  1453. try {
  1454. HEAP32[((__ZTVN10__cxxabiv119__pointer_type_infoE)>>2)]=0; // Workaround for libcxxabi integration bug
  1455. } catch(e){}
  1456. try {
  1457. HEAP32[((__ZTVN10__cxxabiv117__class_type_infoE)>>2)]=1; // Workaround for libcxxabi integration bug
  1458. } catch(e){}
  1459. try {
  1460. HEAP32[((__ZTVN10__cxxabiv120__si_class_type_infoE)>>2)]=2; // Workaround for libcxxabi integration bug
  1461. } catch(e){}
  1462. ___cxa_throw.initialized = true;
  1463. }
  1464. var header = ptr - ___cxa_exception_header_size;
  1465. HEAP32[((header)>>2)]=type;
  1466. HEAP32[(((header)+(4))>>2)]=destructor;
  1467. ___cxa_last_thrown_exception = ptr;
  1468. if (!("uncaught_exception" in __ZSt18uncaught_exceptionv)) {
  1469. __ZSt18uncaught_exceptionv.uncaught_exception = 1;
  1470. } else {
  1471. __ZSt18uncaught_exceptionv.uncaught_exception++;
  1472. }
  1473. throw ptr + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.";
  1474. }
  1475. Module["_memset"] = _memset;
  1476. function __exit(status) {
  1477. // void _exit(int status);
  1478. // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html
  1479. Module['exit'](status);
  1480. }function _exit(status) {
  1481. __exit(status);
  1482. }function __ZSt9terminatev() {
  1483. _exit(-1234);
  1484. }
  1485. function _abort() {
  1486. Module['abort']();
  1487. }
  1488. var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};
  1489. var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};
  1490. var ___errno_state=0;function ___setErrNo(value) {
  1491. // For convenient setting and returning of errno.
  1492. HEAP32[((___errno_state)>>2)]=value;
  1493. return value;
  1494. }
  1495. var PATH={splitPath:function (filename) {
  1496. var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  1497. return splitPathRe.exec(filename).slice(1);
  1498. },normalizeArray:function (parts, allowAboveRoot) {
  1499. // if the path tries to go above the root, `up` ends up > 0
  1500. var up = 0;
  1501. for (var i = parts.length - 1; i >= 0; i--) {
  1502. var last = parts[i];
  1503. if (last === '.') {
  1504. parts.splice(i, 1);
  1505. } else if (last === '..') {
  1506. parts.splice(i, 1);
  1507. up++;
  1508. } else if (up) {
  1509. parts.splice(i, 1);
  1510. up--;
  1511. }
  1512. }
  1513. // if the path is allowed to go above the root, restore leading ..s
  1514. if (allowAboveRoot) {
  1515. for (; up--; up) {
  1516. parts.unshift('..');
  1517. }
  1518. }
  1519. return parts;
  1520. },normalize:function (path) {
  1521. var isAbsolute = path.charAt(0) === '/',
  1522. trailingSlash = path.substr(-1) === '/';
  1523. // Normalize the path
  1524. path = PATH.normalizeArray(path.split('/').filter(function(p) {
  1525. return !!p;
  1526. }), !isAbsolute).join('/');
  1527. if (!path && !isAbsolute) {
  1528. path = '.';
  1529. }
  1530. if (path && trailingSlash) {
  1531. path += '/';
  1532. }
  1533. return (isAbsolute ? '/' : '') + path;
  1534. },dirname:function (path) {
  1535. var result = PATH.splitPath(path),
  1536. root = result[0],
  1537. dir = result[1];
  1538. if (!root && !dir) {
  1539. // No dirname whatsoever
  1540. return '.';
  1541. }
  1542. if (dir) {
  1543. // It has a dirname, strip trailing slash
  1544. dir = dir.substr(0, dir.length - 1);
  1545. }
  1546. return root + dir;
  1547. },basename:function (path) {
  1548. // EMSCRIPTEN return '/'' for '/', not an empty string
  1549. if (path === '/') return '/';
  1550. var lastSlash = path.lastIndexOf('/');
  1551. if (lastSlash === -1) return path;
  1552. return path.substr(lastSlash+1);
  1553. },extname:function (path) {
  1554. return PATH.splitPath(path)[3];
  1555. },join:function () {
  1556. var paths = Array.prototype.slice.call(arguments, 0);
  1557. return PATH.normalize(paths.join('/'));
  1558. },join2:function (l, r) {
  1559. return PATH.normalize(l + '/' + r);
  1560. },resolve:function () {
  1561. var resolvedPath = '',
  1562. resolvedAbsolute = false;
  1563. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  1564. var path = (i >= 0) ? arguments[i] : FS.cwd();
  1565. // Skip empty and invalid entries
  1566. if (typeof path !== 'string') {
  1567. throw new TypeError('Arguments to path.resolve must be strings');
  1568. } else if (!path) {
  1569. continue;
  1570. }
  1571. resolvedPath = path + '/' + resolvedPath;
  1572. resolvedAbsolute = path.charAt(0) === '/';
  1573. }
  1574. // At this point the path should be resolved to a full absolute path, but
  1575. // handle relative paths to be safe (might happen when process.cwd() fails)
  1576. resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {
  1577. return !!p;
  1578. }), !resolvedAbsolute).join('/');
  1579. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  1580. },relative:function (from, to) {
  1581. from = PATH.resolve(from).substr(1);
  1582. to = PATH.resolve(to).substr(1);
  1583. function trim(arr) {
  1584. var start = 0;
  1585. for (; start < arr.length; start++) {
  1586. if (arr[start] !== '') break;
  1587. }
  1588. var end = arr.length - 1;
  1589. for (; end >= 0; end--) {
  1590. if (arr[end] !== '') break;
  1591. }
  1592. if (start > end) return [];
  1593. return arr.slice(start, end - start + 1);
  1594. }
  1595. var fromParts = trim(from.split('/'));
  1596. var toParts = trim(to.split('/'));
  1597. var length = Math.min(fromParts.length, toParts.length);
  1598. var samePartsLength = length;
  1599. for (var i = 0; i < length; i++) {
  1600. if (fromParts[i] !== toParts[i]) {
  1601. samePartsLength = i;
  1602. break;
  1603. }
  1604. }
  1605. var outputParts = [];
  1606. for (var i = samePartsLength; i < fromParts.length; i++) {
  1607. outputParts.push('..');
  1608. }
  1609. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  1610. return outputParts.join('/');
  1611. }};
  1612. var TTY={ttys:[],init:function () {
  1613. // https://github.com/kripken/emscripten/pull/1555
  1614. // if (ENVIRONMENT_IS_NODE) {
  1615. // // currently, FS.init does not distinguish if process.stdin is a file or TTY
  1616. // // device, it always assumes it's a TTY device. because of this, we're forcing
  1617. // // process.stdin to UTF8 encoding to at least make stdin reading compatible
  1618. // // with text files until FS.init can be refactored.
  1619. // process['stdin']['setEncoding']('utf8');
  1620. // }
  1621. },shutdown:function () {
  1622. // https://github.com/kripken/emscripten/pull/1555
  1623. // if (ENVIRONMENT_IS_NODE) {
  1624. // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?
  1625. // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation
  1626. // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?
  1627. // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle
  1628. // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call
  1629. // process['stdin']['pause']();
  1630. // }
  1631. },register:function (dev, ops) {
  1632. TTY.ttys[dev] = { input: [], output: [], ops: ops };
  1633. FS.registerDevice(dev, TTY.stream_ops);
  1634. },stream_ops:{open:function (stream) {
  1635. var tty = TTY.ttys[stream.node.rdev];
  1636. if (!tty) {
  1637. throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
  1638. }
  1639. stream.tty = tty;
  1640. stream.seekable = false;
  1641. },close:function (stream) {
  1642. // flush any pending line data
  1643. if (stream.tty.output.length) {
  1644. stream.tty.ops.put_char(stream.tty, 10);
  1645. }
  1646. },read:function (stream, buffer, offset, length, pos /* ignored */) {
  1647. if (!stream.tty || !stream.tty.ops.get_char) {
  1648. throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
  1649. }
  1650. var bytesRead = 0;
  1651. for (var i = 0; i < length; i++) {
  1652. var result;
  1653. try {
  1654. result = stream.tty.ops.get_char(stream.tty);
  1655. } catch (e) {
  1656. throw new FS.ErrnoError(ERRNO_CODES.EIO);
  1657. }
  1658. if (result === undefined && bytesRead === 0) {
  1659. throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
  1660. }
  1661. if (result === null || result === undefined) break;
  1662. bytesRead++;
  1663. buffer[offset+i] = result;
  1664. }
  1665. if (bytesRead) {
  1666. stream.node.timestamp = Date.now();
  1667. }
  1668. return bytesRead;
  1669. },write:function (stream, buffer, offset, length, pos) {
  1670. if (!stream.tty || !stream.tty.ops.put_char) {
  1671. throw new FS.ErrnoError(ERRNO_CODES.ENXIO);
  1672. }
  1673. for (var i = 0; i < length; i++) {
  1674. try {
  1675. stream.tty.ops.put_char(stream.tty, buffer[offset+i]);
  1676. } catch (e) {
  1677. throw new FS.ErrnoError(ERRNO_CODES.EIO);
  1678. }
  1679. }
  1680. if (length) {
  1681. stream.node.timestamp = Date.now();
  1682. }
  1683. return i;
  1684. }},default_tty_ops:{get_char:function (tty) {
  1685. if (!tty.input.length) {
  1686. var result = null;
  1687. if (ENVIRONMENT_IS_NODE) {
  1688. result = process['stdin']['read']();
  1689. if (!result) {
  1690. if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {
  1691. return null; // EOF
  1692. }
  1693. return undefined; // no data available
  1694. }
  1695. } else if (typeof window != 'undefined' &&
  1696. typeof window.prompt == 'function') {
  1697. // Browser.
  1698. result = window.prompt('Input: '); // returns null on cancel
  1699. if (result !== null) {
  1700. result += '\n';
  1701. }
  1702. } else if (typeof readline == 'function') {
  1703. // Command line.
  1704. result = readline();
  1705. if (result !== null) {
  1706. result += '\n';
  1707. }
  1708. }
  1709. if (!result) {
  1710. return null;
  1711. }
  1712. tty.input = intArrayFromString(result, true);
  1713. }
  1714. return tty.input.shift();
  1715. },put_char:function (tty, val) {
  1716. if (val === null || val === 10) {
  1717. Module['print'](tty.output.join(''));
  1718. tty.output = [];
  1719. } else {
  1720. tty.output.push(TTY.utf8.processCChar(val));
  1721. }
  1722. }},default_tty1_ops:{put_char:function (tty, val) {
  1723. if (val === null || val === 10) {
  1724. Module['printErr'](tty.output.join(''));
  1725. tty.output = [];
  1726. } else {
  1727. tty.output.push(TTY.utf8.processCChar(val));
  1728. }
  1729. }}};
  1730. var MEMFS={ops_table:null,CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,mount:function (mount) {
  1731. return MEMFS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
  1732. },createNode:function (parent, name, mode, dev) {
  1733. if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
  1734. // no supported
  1735. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  1736. }
  1737. if (!MEMFS.ops_table) {
  1738. MEMFS.ops_table = {
  1739. dir: {
  1740. node: {
  1741. getattr: MEMFS.node_ops.getattr,
  1742. setattr: MEMFS.node_ops.setattr,
  1743. lookup: MEMFS.node_ops.lookup,
  1744. mknod: MEMFS.node_ops.mknod,
  1745. rename: MEMFS.node_ops.rename,
  1746. unlink: MEMFS.node_ops.unlink,
  1747. rmdir: MEMFS.node_ops.rmdir,
  1748. readdir: MEMFS.node_ops.readdir,
  1749. symlink: MEMFS.node_ops.symlink
  1750. },
  1751. stream: {
  1752. llseek: MEMFS.stream_ops.llseek
  1753. }
  1754. },
  1755. file: {
  1756. node: {
  1757. getattr: MEMFS.node_ops.getattr,
  1758. setattr: MEMFS.node_ops.setattr
  1759. },
  1760. stream: {
  1761. llseek: MEMFS.stream_ops.llseek,
  1762. read: MEMFS.stream_ops.read,
  1763. write: MEMFS.stream_ops.write,
  1764. allocate: MEMFS.stream_ops.allocate,
  1765. mmap: MEMFS.stream_ops.mmap
  1766. }
  1767. },
  1768. link: {
  1769. node: {
  1770. getattr: MEMFS.node_ops.getattr,
  1771. setattr: MEMFS.node_ops.setattr,
  1772. readlink: MEMFS.node_ops.readlink
  1773. },
  1774. stream: {}
  1775. },
  1776. chrdev: {
  1777. node: {
  1778. getattr: MEMFS.node_ops.getattr,
  1779. setattr: MEMFS.node_ops.setattr
  1780. },
  1781. stream: FS.chrdev_stream_ops
  1782. },
  1783. };
  1784. }
  1785. var node = FS.createNode(parent, name, mode, dev);
  1786. if (FS.isDir(node.mode)) {
  1787. node.node_ops = MEMFS.ops_table.dir.node;
  1788. node.stream_ops = MEMFS.ops_table.dir.stream;
  1789. node.contents = {};
  1790. } else if (FS.isFile(node.mode)) {
  1791. node.node_ops = MEMFS.ops_table.file.node;
  1792. node.stream_ops = MEMFS.ops_table.file.stream;
  1793. node.contents = [];
  1794. node.contentMode = MEMFS.CONTENT_FLEXIBLE;
  1795. } else if (FS.isLink(node.mode)) {
  1796. node.node_ops = MEMFS.ops_table.link.node;
  1797. node.stream_ops = MEMFS.ops_table.link.stream;
  1798. } else if (FS.isChrdev(node.mode)) {
  1799. node.node_ops = MEMFS.ops_table.chrdev.node;
  1800. node.stream_ops = MEMFS.ops_table.chrdev.stream;
  1801. }
  1802. node.timestamp = Date.now();
  1803. // add the new node to the parent
  1804. if (parent) {
  1805. parent.contents[name] = node;
  1806. }
  1807. return node;
  1808. },ensureFlexible:function (node) {
  1809. if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {
  1810. var contents = node.contents;
  1811. node.contents = Array.prototype.slice.call(contents);
  1812. node.contentMode = MEMFS.CONTENT_FLEXIBLE;
  1813. }
  1814. },node_ops:{getattr:function (node) {
  1815. var attr = {};
  1816. // device numbers reuse inode numbers.
  1817. attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
  1818. attr.ino = node.id;
  1819. attr.mode = node.mode;
  1820. attr.nlink = 1;
  1821. attr.uid = 0;
  1822. attr.gid = 0;
  1823. attr.rdev = node.rdev;
  1824. if (FS.isDir(node.mode)) {
  1825. attr.size = 4096;
  1826. } else if (FS.isFile(node.mode)) {
  1827. attr.size = node.contents.length;
  1828. } else if (FS.isLink(node.mode)) {
  1829. attr.size = node.link.length;
  1830. } else {
  1831. attr.size = 0;
  1832. }
  1833. attr.atime = new Date(node.timestamp);
  1834. attr.mtime = new Date(node.timestamp);
  1835. attr.ctime = new Date(node.timestamp);
  1836. // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),
  1837. // but this is not required by the standard.
  1838. attr.blksize = 4096;
  1839. attr.blocks = Math.ceil(attr.size / attr.blksize);
  1840. return attr;
  1841. },setattr:function (node, attr) {
  1842. if (attr.mode !== undefined) {
  1843. node.mode = attr.mode;
  1844. }
  1845. if (attr.timestamp !== undefined) {
  1846. node.timestamp = attr.timestamp;
  1847. }
  1848. if (attr.size !== undefined) {
  1849. MEMFS.ensureFlexible(node);
  1850. var contents = node.contents;
  1851. if (attr.size < contents.length) contents.length = attr.size;
  1852. else while (attr.size > contents.length) contents.push(0);
  1853. }
  1854. },lookup:function (parent, name) {
  1855. throw FS.genericErrors[ERRNO_CODES.ENOENT];
  1856. },mknod:function (parent, name, mode, dev) {
  1857. return MEMFS.createNode(parent, name, mode, dev);
  1858. },rename:function (old_node, new_dir, new_name) {
  1859. // if we're overwriting a directory at new_name, make sure it's empty.
  1860. if (FS.isDir(old_node.mode)) {
  1861. var new_node;
  1862. try {
  1863. new_node = FS.lookupNode(new_dir, new_name);
  1864. } catch (e) {
  1865. }
  1866. if (new_node) {
  1867. for (var i in new_node.contents) {
  1868. throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
  1869. }
  1870. }
  1871. }
  1872. // do the internal rewiring
  1873. delete old_node.parent.contents[old_node.name];
  1874. old_node.name = new_name;
  1875. new_dir.contents[new_name] = old_node;
  1876. old_node.parent = new_dir;
  1877. },unlink:function (parent, name) {
  1878. delete parent.contents[name];
  1879. },rmdir:function (parent, name) {
  1880. var node = FS.lookupNode(parent, name);
  1881. for (var i in node.contents) {
  1882. throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
  1883. }
  1884. delete parent.contents[name];
  1885. },readdir:function (node) {
  1886. var entries = ['.', '..']
  1887. for (var key in node.contents) {
  1888. if (!node.contents.hasOwnProperty(key)) {
  1889. continue;
  1890. }
  1891. entries.push(key);
  1892. }
  1893. return entries;
  1894. },symlink:function (parent, newname, oldpath) {
  1895. var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | 40960, 0);
  1896. node.link = oldpath;
  1897. return node;
  1898. },readlink:function (node) {
  1899. if (!FS.isLink(node.mode)) {
  1900. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  1901. }
  1902. return node.link;
  1903. }},stream_ops:{read:function (stream, buffer, offset, length, position) {
  1904. var contents = stream.node.contents;
  1905. if (position >= contents.length)
  1906. return 0;
  1907. var size = Math.min(contents.length - position, length);
  1908. assert(size >= 0);
  1909. if (size > 8 && contents.subarray) { // non-trivial, and typed array
  1910. buffer.set(contents.subarray(position, position + size), offset);
  1911. } else
  1912. {
  1913. for (var i = 0; i < size; i++) {
  1914. buffer[offset + i] = contents[position + i];
  1915. }
  1916. }
  1917. return size;
  1918. },write:function (stream, buffer, offset, length, position, canOwn) {
  1919. var node = stream.node;
  1920. node.timestamp = Date.now();
  1921. var contents = node.contents;
  1922. if (length && contents.length === 0 && position === 0 && buffer.subarray) {
  1923. // just replace it with the new data
  1924. if (canOwn && offset === 0) {
  1925. node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source.
  1926. node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED;
  1927. } else {
  1928. node.contents = new Uint8Array(buffer.subarray(offset, offset+length));
  1929. node.contentMode = MEMFS.CONTENT_FIXED;
  1930. }
  1931. return length;
  1932. }
  1933. MEMFS.ensureFlexible(node);
  1934. var contents = node.contents;
  1935. while (contents.length < position) contents.push(0);
  1936. for (var i = 0; i < length; i++) {
  1937. contents[position + i] = buffer[offset + i];
  1938. }
  1939. return length;
  1940. },llseek:function (stream, offset, whence) {
  1941. var position = offset;
  1942. if (whence === 1) { // SEEK_CUR.
  1943. position += stream.position;
  1944. } else if (whence === 2) { // SEEK_END.
  1945. if (FS.isFile(stream.node.mode)) {
  1946. position += stream.node.contents.length;
  1947. }
  1948. }
  1949. if (position < 0) {
  1950. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  1951. }
  1952. stream.ungotten = [];
  1953. stream.position = position;
  1954. return position;
  1955. },allocate:function (stream, offset, length) {
  1956. MEMFS.ensureFlexible(stream.node);
  1957. var contents = stream.node.contents;
  1958. var limit = offset + length;
  1959. while (limit > contents.length) contents.push(0);
  1960. },mmap:function (stream, buffer, offset, length, position, prot, flags) {
  1961. if (!FS.isFile(stream.node.mode)) {
  1962. throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
  1963. }
  1964. var ptr;
  1965. var allocated;
  1966. var contents = stream.node.contents;
  1967. // Only make a new copy when MAP_PRIVATE is specified.
  1968. if ( !(flags & 2) &&
  1969. (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {
  1970. // We can't emulate MAP_SHARED when the file is not backed by the buffer
  1971. // we're mapping to (e.g. the HEAP buffer).
  1972. allocated = false;
  1973. ptr = contents.byteOffset;
  1974. } else {
  1975. // Try to avoid unnecessary slices.
  1976. if (position > 0 || position + length < contents.length) {
  1977. if (contents.subarray) {
  1978. contents = contents.subarray(position, position + length);
  1979. } else {
  1980. contents = Array.prototype.slice.call(contents, position, position + length);
  1981. }
  1982. }
  1983. allocated = true;
  1984. ptr = _malloc(length);
  1985. if (!ptr) {
  1986. throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);
  1987. }
  1988. buffer.set(contents, ptr);
  1989. }
  1990. return { ptr: ptr, allocated: allocated };
  1991. }}};
  1992. var IDBFS={dbs:{},indexedDB:function () {
  1993. return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
  1994. },DB_VERSION:21,DB_STORE_NAME:"FILE_DATA",mount:function (mount) {
  1995. // reuse all of the core MEMFS functionality
  1996. return MEMFS.mount.apply(null, arguments);
  1997. },syncfs:function (mount, populate, callback) {
  1998. IDBFS.getLocalSet(mount, function(err, local) {
  1999. if (err) return callback(err);
  2000. IDBFS.getRemoteSet(mount, function(err, remote) {
  2001. if (err) return callback(err);
  2002. var src = populate ? remote : local;
  2003. var dst = populate ? local : remote;
  2004. IDBFS.reconcile(src, dst, callback);
  2005. });
  2006. });
  2007. },getDB:function (name, callback) {
  2008. // check the cache first
  2009. var db = IDBFS.dbs[name];
  2010. if (db) {
  2011. return callback(null, db);
  2012. }
  2013. var req;
  2014. try {
  2015. req = IDBFS.indexedDB().open(name, IDBFS.DB_VERSION);
  2016. } catch (e) {
  2017. return callback(e);
  2018. }
  2019. req.onupgradeneeded = function(e) {
  2020. var db = e.target.result;
  2021. var transaction = e.target.transaction;
  2022. var fileStore;
  2023. if (db.objectStoreNames.contains(IDBFS.DB_STORE_NAME)) {
  2024. fileStore = transaction.objectStore(IDBFS.DB_STORE_NAME);
  2025. } else {
  2026. fileStore = db.createObjectStore(IDBFS.DB_STORE_NAME);
  2027. }
  2028. fileStore.createIndex('timestamp', 'timestamp', { unique: false });
  2029. };
  2030. req.onsuccess = function() {
  2031. db = req.result;
  2032. // add to the cache
  2033. IDBFS.dbs[name] = db;
  2034. callback(null, db);
  2035. };
  2036. req.onerror = function() {
  2037. callback(this.error);
  2038. };
  2039. },getLocalSet:function (mount, callback) {
  2040. var entries = {};
  2041. function isRealDir(p) {
  2042. return p !== '.' && p !== '..';
  2043. };
  2044. function toAbsolute(root) {
  2045. return function(p) {
  2046. return PATH.join2(root, p);
  2047. }
  2048. };
  2049. var check = FS.readdir(mount.mountpoint).filter(isRealDir).map(toAbsolute(mount.mountpoint));
  2050. while (check.length) {
  2051. var path = check.pop();
  2052. var stat;
  2053. try {
  2054. stat = FS.stat(path);
  2055. } catch (e) {
  2056. return callback(e);
  2057. }
  2058. if (FS.isDir(stat.mode)) {
  2059. check.push.apply(check, FS.readdir(path).filter(isRealDir).map(toAbsolute(path)));
  2060. }
  2061. entries[path] = { timestamp: stat.mtime };
  2062. }
  2063. return callback(null, { type: 'local', entries: entries });
  2064. },getRemoteSet:function (mount, callback) {
  2065. var entries = {};
  2066. IDBFS.getDB(mount.mountpoint, function(err, db) {
  2067. if (err) return callback(err);
  2068. var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly');
  2069. transaction.onerror = function() { callback(this.error); };
  2070. var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
  2071. var index = store.index('timestamp');
  2072. index.openKeyCursor().onsuccess = function(event) {
  2073. var cursor = event.target.result;
  2074. if (!cursor) {
  2075. return callback(null, { type: 'remote', db: db, entries: entries });
  2076. }
  2077. entries[cursor.primaryKey] = { timestamp: cursor.key };
  2078. cursor.continue();
  2079. };
  2080. });
  2081. },loadLocalEntry:function (path, callback) {
  2082. var stat, node;
  2083. try {
  2084. var lookup = FS.lookupPath(path);
  2085. node = lookup.node;
  2086. stat = FS.stat(path);
  2087. } catch (e) {
  2088. return callback(e);
  2089. }
  2090. if (FS.isDir(stat.mode)) {
  2091. return callback(null, { timestamp: stat.mtime, mode: stat.mode });
  2092. } else if (FS.isFile(stat.mode)) {
  2093. return callback(null, { timestamp: stat.mtime, mode: stat.mode, contents: node.contents });
  2094. } else {
  2095. return callback(new Error('node type not supported'));
  2096. }
  2097. },storeLocalEntry:function (path, entry, callback) {
  2098. try {
  2099. if (FS.isDir(entry.mode)) {
  2100. FS.mkdir(path, entry.mode);
  2101. } else if (FS.isFile(entry.mode)) {
  2102. FS.writeFile(path, entry.contents, { encoding: 'binary', canOwn: true });
  2103. } else {
  2104. return callback(new Error('node type not supported'));
  2105. }
  2106. FS.utime(path, entry.timestamp, entry.timestamp);
  2107. } catch (e) {
  2108. return callback(e);
  2109. }
  2110. callback(null);
  2111. },removeLocalEntry:function (path, callback) {
  2112. try {
  2113. var lookup = FS.lookupPath(path);
  2114. var stat = FS.stat(path);
  2115. if (FS.isDir(stat.mode)) {
  2116. FS.rmdir(path);
  2117. } else if (FS.isFile(stat.mode)) {
  2118. FS.unlink(path);
  2119. }
  2120. } catch (e) {
  2121. return callback(e);
  2122. }
  2123. callback(null);
  2124. },loadRemoteEntry:function (store, path, callback) {
  2125. var req = store.get(path);
  2126. req.onsuccess = function(event) { callback(null, event.target.result); };
  2127. req.onerror = function() { callback(this.error); };
  2128. },storeRemoteEntry:function (store, path, entry, callback) {
  2129. var req = store.put(entry, path);
  2130. req.onsuccess = function() { callback(null); };
  2131. req.onerror = function() { callback(this.error); };
  2132. },removeRemoteEntry:function (store, path, callback) {
  2133. var req = store.delete(path);
  2134. req.onsuccess = function() { callback(null); };
  2135. req.onerror = function() { callback(this.error); };
  2136. },reconcile:function (src, dst, callback) {
  2137. var total = 0;
  2138. var create = [];
  2139. Object.keys(src.entries).forEach(function (key) {
  2140. var e = src.entries[key];
  2141. var e2 = dst.entries[key];
  2142. if (!e2 || e.timestamp > e2.timestamp) {
  2143. create.push(key);
  2144. total++;
  2145. }
  2146. });
  2147. var remove = [];
  2148. Object.keys(dst.entries).forEach(function (key) {
  2149. var e = dst.entries[key];
  2150. var e2 = src.entries[key];
  2151. if (!e2) {
  2152. remove.push(key);
  2153. total++;
  2154. }
  2155. });
  2156. if (!total) {
  2157. return callback(null);
  2158. }
  2159. var errored = false;
  2160. var completed = 0;
  2161. var db = src.type === 'remote' ? src.db : dst.db;
  2162. var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite');
  2163. var store = transaction.objectStore(IDBFS.DB_STORE_NAME);
  2164. function done(err) {
  2165. if (err) {
  2166. if (!done.errored) {
  2167. done.errored = true;
  2168. return callback(err);
  2169. }
  2170. return;
  2171. }
  2172. if (++completed >= total) {
  2173. return callback(null);
  2174. }
  2175. };
  2176. transaction.onerror = function() { done(this.error); };
  2177. // sort paths in ascending order so directory entries are created
  2178. // before the files inside them
  2179. create.sort().forEach(function (path) {
  2180. if (dst.type === 'local') {
  2181. IDBFS.loadRemoteEntry(store, path, function (err, entry) {
  2182. if (err) return done(err);
  2183. IDBFS.storeLocalEntry(path, entry, done);
  2184. });
  2185. } else {
  2186. IDBFS.loadLocalEntry(path, function (err, entry) {
  2187. if (err) return done(err);
  2188. IDBFS.storeRemoteEntry(store, path, entry, done);
  2189. });
  2190. }
  2191. });
  2192. // sort paths in descending order so files are deleted before their
  2193. // parent directories
  2194. remove.sort().reverse().forEach(function(path) {
  2195. if (dst.type === 'local') {
  2196. IDBFS.removeLocalEntry(path, done);
  2197. } else {
  2198. IDBFS.removeRemoteEntry(store, path, done);
  2199. }
  2200. });
  2201. }};
  2202. var NODEFS={isWindows:false,staticInit:function () {
  2203. NODEFS.isWindows = !!process.platform.match(/^win/);
  2204. },mount:function (mount) {
  2205. assert(ENVIRONMENT_IS_NODE);
  2206. return NODEFS.createNode(null, '/', NODEFS.getMode(mount.opts.root), 0);
  2207. },createNode:function (parent, name, mode, dev) {
  2208. if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
  2209. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  2210. }
  2211. var node = FS.createNode(parent, name, mode);
  2212. node.node_ops = NODEFS.node_ops;
  2213. node.stream_ops = NODEFS.stream_ops;
  2214. return node;
  2215. },getMode:function (path) {
  2216. var stat;
  2217. try {
  2218. stat = fs.lstatSync(path);
  2219. if (NODEFS.isWindows) {
  2220. // On Windows, directories return permission bits 'rw-rw-rw-', even though they have 'rwxrwxrwx', so
  2221. // propagate write bits to execute bits.
  2222. stat.mode = stat.mode | ((stat.mode & 146) >> 1);
  2223. }
  2224. } catch (e) {
  2225. if (!e.code) throw e;
  2226. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2227. }
  2228. return stat.mode;
  2229. },realPath:function (node) {
  2230. var parts = [];
  2231. while (node.parent !== node) {
  2232. parts.push(node.name);
  2233. node = node.parent;
  2234. }
  2235. parts.push(node.mount.opts.root);
  2236. parts.reverse();
  2237. return PATH.join.apply(null, parts);
  2238. },flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:function (flags) {
  2239. if (flags in NODEFS.flagsToPermissionStringMap) {
  2240. return NODEFS.flagsToPermissionStringMap[flags];
  2241. } else {
  2242. return flags;
  2243. }
  2244. },node_ops:{getattr:function (node) {
  2245. var path = NODEFS.realPath(node);
  2246. var stat;
  2247. try {
  2248. stat = fs.lstatSync(path);
  2249. } catch (e) {
  2250. if (!e.code) throw e;
  2251. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2252. }
  2253. // node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake them with default blksize of 4096.
  2254. // See http://support.microsoft.com/kb/140365
  2255. if (NODEFS.isWindows && !stat.blksize) {
  2256. stat.blksize = 4096;
  2257. }
  2258. if (NODEFS.isWindows && !stat.blocks) {
  2259. stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
  2260. }
  2261. return {
  2262. dev: stat.dev,
  2263. ino: stat.ino,
  2264. mode: stat.mode,
  2265. nlink: stat.nlink,
  2266. uid: stat.uid,
  2267. gid: stat.gid,
  2268. rdev: stat.rdev,
  2269. size: stat.size,
  2270. atime: stat.atime,
  2271. mtime: stat.mtime,
  2272. ctime: stat.ctime,
  2273. blksize: stat.blksize,
  2274. blocks: stat.blocks
  2275. };
  2276. },setattr:function (node, attr) {
  2277. var path = NODEFS.realPath(node);
  2278. try {
  2279. if (attr.mode !== undefined) {
  2280. fs.chmodSync(path, attr.mode);
  2281. // update the common node structure mode as well
  2282. node.mode = attr.mode;
  2283. }
  2284. if (attr.timestamp !== undefined) {
  2285. var date = new Date(attr.timestamp);
  2286. fs.utimesSync(path, date, date);
  2287. }
  2288. if (attr.size !== undefined) {
  2289. fs.truncateSync(path, attr.size);
  2290. }
  2291. } catch (e) {
  2292. if (!e.code) throw e;
  2293. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2294. }
  2295. },lookup:function (parent, name) {
  2296. var path = PATH.join2(NODEFS.realPath(parent), name);
  2297. var mode = NODEFS.getMode(path);
  2298. return NODEFS.createNode(parent, name, mode);
  2299. },mknod:function (parent, name, mode, dev) {
  2300. var node = NODEFS.createNode(parent, name, mode, dev);
  2301. // create the backing node for this in the fs root as well
  2302. var path = NODEFS.realPath(node);
  2303. try {
  2304. if (FS.isDir(node.mode)) {
  2305. fs.mkdirSync(path, node.mode);
  2306. } else {
  2307. fs.writeFileSync(path, '', { mode: node.mode });
  2308. }
  2309. } catch (e) {
  2310. if (!e.code) throw e;
  2311. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2312. }
  2313. return node;
  2314. },rename:function (oldNode, newDir, newName) {
  2315. var oldPath = NODEFS.realPath(oldNode);
  2316. var newPath = PATH.join2(NODEFS.realPath(newDir), newName);
  2317. try {
  2318. fs.renameSync(oldPath, newPath);
  2319. } catch (e) {
  2320. if (!e.code) throw e;
  2321. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2322. }
  2323. },unlink:function (parent, name) {
  2324. var path = PATH.join2(NODEFS.realPath(parent), name);
  2325. try {
  2326. fs.unlinkSync(path);
  2327. } catch (e) {
  2328. if (!e.code) throw e;
  2329. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2330. }
  2331. },rmdir:function (parent, name) {
  2332. var path = PATH.join2(NODEFS.realPath(parent), name);
  2333. try {
  2334. fs.rmdirSync(path);
  2335. } catch (e) {
  2336. if (!e.code) throw e;
  2337. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2338. }
  2339. },readdir:function (node) {
  2340. var path = NODEFS.realPath(node);
  2341. try {
  2342. return fs.readdirSync(path);
  2343. } catch (e) {
  2344. if (!e.code) throw e;
  2345. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2346. }
  2347. },symlink:function (parent, newName, oldPath) {
  2348. var newPath = PATH.join2(NODEFS.realPath(parent), newName);
  2349. try {
  2350. fs.symlinkSync(oldPath, newPath);
  2351. } catch (e) {
  2352. if (!e.code) throw e;
  2353. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2354. }
  2355. },readlink:function (node) {
  2356. var path = NODEFS.realPath(node);
  2357. try {
  2358. return fs.readlinkSync(path);
  2359. } catch (e) {
  2360. if (!e.code) throw e;
  2361. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2362. }
  2363. }},stream_ops:{open:function (stream) {
  2364. var path = NODEFS.realPath(stream.node);
  2365. try {
  2366. if (FS.isFile(stream.node.mode)) {
  2367. stream.nfd = fs.openSync(path, NODEFS.flagsToPermissionString(stream.flags));
  2368. }
  2369. } catch (e) {
  2370. if (!e.code) throw e;
  2371. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2372. }
  2373. },close:function (stream) {
  2374. try {
  2375. if (FS.isFile(stream.node.mode) && stream.nfd) {
  2376. fs.closeSync(stream.nfd);
  2377. }
  2378. } catch (e) {
  2379. if (!e.code) throw e;
  2380. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2381. }
  2382. },read:function (stream, buffer, offset, length, position) {
  2383. // FIXME this is terrible.
  2384. var nbuffer = new Buffer(length);
  2385. var res;
  2386. try {
  2387. res = fs.readSync(stream.nfd, nbuffer, 0, length, position);
  2388. } catch (e) {
  2389. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2390. }
  2391. if (res > 0) {
  2392. for (var i = 0; i < res; i++) {
  2393. buffer[offset + i] = nbuffer[i];
  2394. }
  2395. }
  2396. return res;
  2397. },write:function (stream, buffer, offset, length, position) {
  2398. // FIXME this is terrible.
  2399. var nbuffer = new Buffer(buffer.subarray(offset, offset + length));
  2400. var res;
  2401. try {
  2402. res = fs.writeSync(stream.nfd, nbuffer, 0, length, position);
  2403. } catch (e) {
  2404. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2405. }
  2406. return res;
  2407. },llseek:function (stream, offset, whence) {
  2408. var position = offset;
  2409. if (whence === 1) { // SEEK_CUR.
  2410. position += stream.position;
  2411. } else if (whence === 2) { // SEEK_END.
  2412. if (FS.isFile(stream.node.mode)) {
  2413. try {
  2414. var stat = fs.fstatSync(stream.nfd);
  2415. position += stat.size;
  2416. } catch (e) {
  2417. throw new FS.ErrnoError(ERRNO_CODES[e.code]);
  2418. }
  2419. }
  2420. }
  2421. if (position < 0) {
  2422. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  2423. }
  2424. stream.position = position;
  2425. return position;
  2426. }}};
  2427. var _stdin=allocate(1, "i32*", ALLOC_STATIC);
  2428. var _stdout=allocate(1, "i32*", ALLOC_STATIC);
  2429. var _stderr=allocate(1, "i32*", ALLOC_STATIC);
  2430. function _fflush(stream) {
  2431. // int fflush(FILE *stream);
  2432. // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html
  2433. // we don't currently perform any user-space buffering of data
  2434. }var FS={root:null,mounts:[],devices:[null],streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},handleFSError:function (e) {
  2435. if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
  2436. return ___setErrNo(e.errno);
  2437. },lookupPath:function (path, opts) {
  2438. path = PATH.resolve(FS.cwd(), path);
  2439. opts = opts || {};
  2440. var defaults = {
  2441. follow_mount: true,
  2442. recurse_count: 0
  2443. };
  2444. for (var key in defaults) {
  2445. if (opts[key] === undefined) {
  2446. opts[key] = defaults[key];
  2447. }
  2448. }
  2449. if (opts.recurse_count > 8) { // max recursive lookup of 8
  2450. throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
  2451. }
  2452. // split the path
  2453. var parts = PATH.normalizeArray(path.split('/').filter(function(p) {
  2454. return !!p;
  2455. }), false);
  2456. // start at the root
  2457. var current = FS.root;
  2458. var current_path = '/';
  2459. for (var i = 0; i < parts.length; i++) {
  2460. var islast = (i === parts.length-1);
  2461. if (islast && opts.parent) {
  2462. // stop resolving
  2463. break;
  2464. }
  2465. current = FS.lookupNode(current, parts[i]);
  2466. current_path = PATH.join2(current_path, parts[i]);
  2467. // jump to the mount's root node if this is a mountpoint
  2468. if (FS.isMountpoint(current)) {
  2469. if (!islast || (islast && opts.follow_mount)) {
  2470. current = current.mounted.root;
  2471. }
  2472. }
  2473. // by default, lookupPath will not follow a symlink if it is the final path component.
  2474. // setting opts.follow = true will override this behavior.
  2475. if (!islast || opts.follow) {
  2476. var count = 0;
  2477. while (FS.isLink(current.mode)) {
  2478. var link = FS.readlink(current_path);
  2479. current_path = PATH.resolve(PATH.dirname(current_path), link);
  2480. var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });
  2481. current = lookup.node;
  2482. if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
  2483. throw new FS.ErrnoError(ERRNO_CODES.ELOOP);
  2484. }
  2485. }
  2486. }
  2487. }
  2488. return { path: current_path, node: current };
  2489. },getPath:function (node) {
  2490. var path;
  2491. while (true) {
  2492. if (FS.isRoot(node)) {
  2493. var mount = node.mount.mountpoint;
  2494. if (!path) return mount;
  2495. return mount[mount.length-1] !== '/' ? mount + '/' + path : mount + path;
  2496. }
  2497. path = path ? node.name + '/' + path : node.name;
  2498. node = node.parent;
  2499. }
  2500. },hashName:function (parentid, name) {
  2501. var hash = 0;
  2502. for (var i = 0; i < name.length; i++) {
  2503. hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
  2504. }
  2505. return ((parentid + hash) >>> 0) % FS.nameTable.length;
  2506. },hashAddNode:function (node) {
  2507. var hash = FS.hashName(node.parent.id, node.name);
  2508. node.name_next = FS.nameTable[hash];
  2509. FS.nameTable[hash] = node;
  2510. },hashRemoveNode:function (node) {
  2511. var hash = FS.hashName(node.parent.id, node.name);
  2512. if (FS.nameTable[hash] === node) {
  2513. FS.nameTable[hash] = node.name_next;
  2514. } else {
  2515. var current = FS.nameTable[hash];
  2516. while (current) {
  2517. if (current.name_next === node) {
  2518. current.name_next = node.name_next;
  2519. break;
  2520. }
  2521. current = current.name_next;
  2522. }
  2523. }
  2524. },lookupNode:function (parent, name) {
  2525. var err = FS.mayLookup(parent);
  2526. if (err) {
  2527. throw new FS.ErrnoError(err);
  2528. }
  2529. var hash = FS.hashName(parent.id, name);
  2530. for (var node = FS.nameTable[hash]; node; node = node.name_next) {
  2531. var nodeName = node.name;
  2532. if (node.parent.id === parent.id && nodeName === name) {
  2533. return node;
  2534. }
  2535. }
  2536. // if we failed to find it in the cache, call into the VFS
  2537. return FS.lookup(parent, name);
  2538. },createNode:function (parent, name, mode, rdev) {
  2539. if (!FS.FSNode) {
  2540. FS.FSNode = function(parent, name, mode, rdev) {
  2541. if (!parent) {
  2542. parent = this; // root node sets parent to itself
  2543. }
  2544. this.parent = parent;
  2545. this.mount = parent.mount;
  2546. this.mounted = null;
  2547. this.id = FS.nextInode++;
  2548. this.name = name;
  2549. this.mode = mode;
  2550. this.node_ops = {};
  2551. this.stream_ops = {};
  2552. this.rdev = rdev;
  2553. };
  2554. FS.FSNode.prototype = {};
  2555. // compatibility
  2556. var readMode = 292 | 73;
  2557. var writeMode = 146;
  2558. // NOTE we must use Object.defineProperties instead of individual calls to
  2559. // Object.defineProperty in order to make closure compiler happy
  2560. Object.defineProperties(FS.FSNode.prototype, {
  2561. read: {
  2562. get: function() { return (this.mode & readMode) === readMode; },
  2563. set: function(val) { val ? this.mode |= readMode : this.mode &= ~readMode; }
  2564. },
  2565. write: {
  2566. get: function() { return (this.mode & writeMode) === writeMode; },
  2567. set: function(val) { val ? this.mode |= writeMode : this.mode &= ~writeMode; }
  2568. },
  2569. isFolder: {
  2570. get: function() { return FS.isDir(this.mode); },
  2571. },
  2572. isDevice: {
  2573. get: function() { return FS.isChrdev(this.mode); },
  2574. },
  2575. });
  2576. }
  2577. var node = new FS.FSNode(parent, name, mode, rdev);
  2578. FS.hashAddNode(node);
  2579. return node;
  2580. },destroyNode:function (node) {
  2581. FS.hashRemoveNode(node);
  2582. },isRoot:function (node) {
  2583. return node === node.parent;
  2584. },isMountpoint:function (node) {
  2585. return !!node.mounted;
  2586. },isFile:function (mode) {
  2587. return (mode & 61440) === 32768;
  2588. },isDir:function (mode) {
  2589. return (mode & 61440) === 16384;
  2590. },isLink:function (mode) {
  2591. return (mode & 61440) === 40960;
  2592. },isChrdev:function (mode) {
  2593. return (mode & 61440) === 8192;
  2594. },isBlkdev:function (mode) {
  2595. return (mode & 61440) === 24576;
  2596. },isFIFO:function (mode) {
  2597. return (mode & 61440) === 4096;
  2598. },isSocket:function (mode) {
  2599. return (mode & 49152) === 49152;
  2600. },flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:function (str) {
  2601. var flags = FS.flagModes[str];
  2602. if (typeof flags === 'undefined') {
  2603. throw new Error('Unknown file open mode: ' + str);
  2604. }
  2605. return flags;
  2606. },flagsToPermissionString:function (flag) {
  2607. var accmode = flag & 2097155;
  2608. var perms = ['r', 'w', 'rw'][accmode];
  2609. if ((flag & 512)) {
  2610. perms += 'w';
  2611. }
  2612. return perms;
  2613. },nodePermissions:function (node, perms) {
  2614. if (FS.ignorePermissions) {
  2615. return 0;
  2616. }
  2617. // return 0 if any user, group or owner bits are set.
  2618. if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {
  2619. return ERRNO_CODES.EACCES;
  2620. } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {
  2621. return ERRNO_CODES.EACCES;
  2622. } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {
  2623. return ERRNO_CODES.EACCES;
  2624. }
  2625. return 0;
  2626. },mayLookup:function (dir) {
  2627. return FS.nodePermissions(dir, 'x');
  2628. },mayCreate:function (dir, name) {
  2629. try {
  2630. var node = FS.lookupNode(dir, name);
  2631. return ERRNO_CODES.EEXIST;
  2632. } catch (e) {
  2633. }
  2634. return FS.nodePermissions(dir, 'wx');
  2635. },mayDelete:function (dir, name, isdir) {
  2636. var node;
  2637. try {
  2638. node = FS.lookupNode(dir, name);
  2639. } catch (e) {
  2640. return e.errno;
  2641. }
  2642. var err = FS.nodePermissions(dir, 'wx');
  2643. if (err) {
  2644. return err;
  2645. }
  2646. if (isdir) {
  2647. if (!FS.isDir(node.mode)) {
  2648. return ERRNO_CODES.ENOTDIR;
  2649. }
  2650. if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
  2651. return ERRNO_CODES.EBUSY;
  2652. }
  2653. } else {
  2654. if (FS.isDir(node.mode)) {
  2655. return ERRNO_CODES.EISDIR;
  2656. }
  2657. }
  2658. return 0;
  2659. },mayOpen:function (node, flags) {
  2660. if (!node) {
  2661. return ERRNO_CODES.ENOENT;
  2662. }
  2663. if (FS.isLink(node.mode)) {
  2664. return ERRNO_CODES.ELOOP;
  2665. } else if (FS.isDir(node.mode)) {
  2666. if ((flags & 2097155) !== 0 || // opening for write
  2667. (flags & 512)) {
  2668. return ERRNO_CODES.EISDIR;
  2669. }
  2670. }
  2671. return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
  2672. },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {
  2673. fd_start = fd_start || 0;
  2674. fd_end = fd_end || FS.MAX_OPEN_FDS;
  2675. for (var fd = fd_start; fd <= fd_end; fd++) {
  2676. if (!FS.streams[fd]) {
  2677. return fd;
  2678. }
  2679. }
  2680. throw new FS.ErrnoError(ERRNO_CODES.EMFILE);
  2681. },getStream:function (fd) {
  2682. return FS.streams[fd];
  2683. },createStream:function (stream, fd_start, fd_end) {
  2684. if (!FS.FSStream) {
  2685. FS.FSStream = function(){};
  2686. FS.FSStream.prototype = {};
  2687. // compatibility
  2688. Object.defineProperties(FS.FSStream.prototype, {
  2689. object: {
  2690. get: function() { return this.node; },
  2691. set: function(val) { this.node = val; }
  2692. },
  2693. isRead: {
  2694. get: function() { return (this.flags & 2097155) !== 1; }
  2695. },
  2696. isWrite: {
  2697. get: function() { return (this.flags & 2097155) !== 0; }
  2698. },
  2699. isAppend: {
  2700. get: function() { return (this.flags & 1024); }
  2701. }
  2702. });
  2703. }
  2704. if (0) {
  2705. // reuse the object
  2706. stream.__proto__ = FS.FSStream.prototype;
  2707. } else {
  2708. var newStream = new FS.FSStream();
  2709. for (var p in stream) {
  2710. newStream[p] = stream[p];
  2711. }
  2712. stream = newStream;
  2713. }
  2714. var fd = FS.nextfd(fd_start, fd_end);
  2715. stream.fd = fd;
  2716. FS.streams[fd] = stream;
  2717. return stream;
  2718. },closeStream:function (fd) {
  2719. FS.streams[fd] = null;
  2720. },getStreamFromPtr:function (ptr) {
  2721. return FS.streams[ptr - 1];
  2722. },getPtrForStream:function (stream) {
  2723. return stream ? stream.fd + 1 : 0;
  2724. },chrdev_stream_ops:{open:function (stream) {
  2725. var device = FS.getDevice(stream.node.rdev);
  2726. // override node's stream ops with the device's
  2727. stream.stream_ops = device.stream_ops;
  2728. // forward the open call
  2729. if (stream.stream_ops.open) {
  2730. stream.stream_ops.open(stream);
  2731. }
  2732. },llseek:function () {
  2733. throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
  2734. }},major:function (dev) {
  2735. return ((dev) >> 8);
  2736. },minor:function (dev) {
  2737. return ((dev) & 0xff);
  2738. },makedev:function (ma, mi) {
  2739. return ((ma) << 8 | (mi));
  2740. },registerDevice:function (dev, ops) {
  2741. FS.devices[dev] = { stream_ops: ops };
  2742. },getDevice:function (dev) {
  2743. return FS.devices[dev];
  2744. },getMounts:function (mount) {
  2745. var mounts = [];
  2746. var check = [mount];
  2747. while (check.length) {
  2748. var m = check.pop();
  2749. mounts.push(m);
  2750. check.push.apply(check, m.mounts);
  2751. }
  2752. return mounts;
  2753. },syncfs:function (populate, callback) {
  2754. if (typeof(populate) === 'function') {
  2755. callback = populate;
  2756. populate = false;
  2757. }
  2758. var mounts = FS.getMounts(FS.root.mount);
  2759. var completed = 0;
  2760. function done(err) {
  2761. if (err) {
  2762. if (!done.errored) {
  2763. done.errored = true;
  2764. return callback(err);
  2765. }
  2766. return;
  2767. }
  2768. if (++completed >= mounts.length) {
  2769. callback(null);
  2770. }
  2771. };
  2772. // sync all mounts
  2773. mounts.forEach(function (mount) {
  2774. if (!mount.type.syncfs) {
  2775. return done(null);
  2776. }
  2777. mount.type.syncfs(mount, populate, done);
  2778. });
  2779. },mount:function (type, opts, mountpoint) {
  2780. var root = mountpoint === '/';
  2781. var pseudo = !mountpoint;
  2782. var node;
  2783. if (root && FS.root) {
  2784. throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
  2785. } else if (!root && !pseudo) {
  2786. var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
  2787. mountpoint = lookup.path; // use the absolute path
  2788. node = lookup.node;
  2789. if (FS.isMountpoint(node)) {
  2790. throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
  2791. }
  2792. if (!FS.isDir(node.mode)) {
  2793. throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
  2794. }
  2795. }
  2796. var mount = {
  2797. type: type,
  2798. opts: opts,
  2799. mountpoint: mountpoint,
  2800. mounts: []
  2801. };
  2802. // create a root node for the fs
  2803. var mountRoot = type.mount(mount);
  2804. mountRoot.mount = mount;
  2805. mount.root = mountRoot;
  2806. if (root) {
  2807. FS.root = mountRoot;
  2808. } else if (node) {
  2809. // set as a mountpoint
  2810. node.mounted = mount;
  2811. // add the new mount to the current mount's children
  2812. if (node.mount) {
  2813. node.mount.mounts.push(mount);
  2814. }
  2815. }
  2816. return mountRoot;
  2817. },unmount:function (mountpoint) {
  2818. var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
  2819. if (!FS.isMountpoint(lookup.node)) {
  2820. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  2821. }
  2822. // destroy the nodes for this mount, and all its child mounts
  2823. var node = lookup.node;
  2824. var mount = node.mounted;
  2825. var mounts = FS.getMounts(mount);
  2826. Object.keys(FS.nameTable).forEach(function (hash) {
  2827. var current = FS.nameTable[hash];
  2828. while (current) {
  2829. var next = current.name_next;
  2830. if (mounts.indexOf(current.mount) !== -1) {
  2831. FS.destroyNode(current);
  2832. }
  2833. current = next;
  2834. }
  2835. });
  2836. // no longer a mountpoint
  2837. node.mounted = null;
  2838. // remove this mount from the child mounts
  2839. var idx = node.mount.mounts.indexOf(mount);
  2840. assert(idx !== -1);
  2841. node.mount.mounts.splice(idx, 1);
  2842. },lookup:function (parent, name) {
  2843. return parent.node_ops.lookup(parent, name);
  2844. },mknod:function (path, mode, dev) {
  2845. var lookup = FS.lookupPath(path, { parent: true });
  2846. var parent = lookup.node;
  2847. var name = PATH.basename(path);
  2848. var err = FS.mayCreate(parent, name);
  2849. if (err) {
  2850. throw new FS.ErrnoError(err);
  2851. }
  2852. if (!parent.node_ops.mknod) {
  2853. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  2854. }
  2855. return parent.node_ops.mknod(parent, name, mode, dev);
  2856. },create:function (path, mode) {
  2857. mode = mode !== undefined ? mode : 438 /* 0666 */;
  2858. mode &= 4095;
  2859. mode |= 32768;
  2860. return FS.mknod(path, mode, 0);
  2861. },mkdir:function (path, mode) {
  2862. mode = mode !== undefined ? mode : 511 /* 0777 */;
  2863. mode &= 511 | 512;
  2864. mode |= 16384;
  2865. return FS.mknod(path, mode, 0);
  2866. },mkdev:function (path, mode, dev) {
  2867. if (typeof(dev) === 'undefined') {
  2868. dev = mode;
  2869. mode = 438 /* 0666 */;
  2870. }
  2871. mode |= 8192;
  2872. return FS.mknod(path, mode, dev);
  2873. },symlink:function (oldpath, newpath) {
  2874. var lookup = FS.lookupPath(newpath, { parent: true });
  2875. var parent = lookup.node;
  2876. var newname = PATH.basename(newpath);
  2877. var err = FS.mayCreate(parent, newname);
  2878. if (err) {
  2879. throw new FS.ErrnoError(err);
  2880. }
  2881. if (!parent.node_ops.symlink) {
  2882. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  2883. }
  2884. return parent.node_ops.symlink(parent, newname, oldpath);
  2885. },rename:function (old_path, new_path) {
  2886. var old_dirname = PATH.dirname(old_path);
  2887. var new_dirname = PATH.dirname(new_path);
  2888. var old_name = PATH.basename(old_path);
  2889. var new_name = PATH.basename(new_path);
  2890. // parents must exist
  2891. var lookup, old_dir, new_dir;
  2892. try {
  2893. lookup = FS.lookupPath(old_path, { parent: true });
  2894. old_dir = lookup.node;
  2895. lookup = FS.lookupPath(new_path, { parent: true });
  2896. new_dir = lookup.node;
  2897. } catch (e) {
  2898. throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
  2899. }
  2900. // need to be part of the same mount
  2901. if (old_dir.mount !== new_dir.mount) {
  2902. throw new FS.ErrnoError(ERRNO_CODES.EXDEV);
  2903. }
  2904. // source must exist
  2905. var old_node = FS.lookupNode(old_dir, old_name);
  2906. // old path should not be an ancestor of the new path
  2907. var relative = PATH.relative(old_path, new_dirname);
  2908. if (relative.charAt(0) !== '.') {
  2909. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  2910. }
  2911. // new path should not be an ancestor of the old path
  2912. relative = PATH.relative(new_path, old_dirname);
  2913. if (relative.charAt(0) !== '.') {
  2914. throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);
  2915. }
  2916. // see if the new path already exists
  2917. var new_node;
  2918. try {
  2919. new_node = FS.lookupNode(new_dir, new_name);
  2920. } catch (e) {
  2921. // not fatal
  2922. }
  2923. // early out if nothing needs to change
  2924. if (old_node === new_node) {
  2925. return;
  2926. }
  2927. // we'll need to delete the old entry
  2928. var isdir = FS.isDir(old_node.mode);
  2929. var err = FS.mayDelete(old_dir, old_name, isdir);
  2930. if (err) {
  2931. throw new FS.ErrnoError(err);
  2932. }
  2933. // need delete permissions if we'll be overwriting.
  2934. // need create permissions if new doesn't already exist.
  2935. err = new_node ?
  2936. FS.mayDelete(new_dir, new_name, isdir) :
  2937. FS.mayCreate(new_dir, new_name);
  2938. if (err) {
  2939. throw new FS.ErrnoError(err);
  2940. }
  2941. if (!old_dir.node_ops.rename) {
  2942. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  2943. }
  2944. if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
  2945. throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
  2946. }
  2947. // if we are going to change the parent, check write permissions
  2948. if (new_dir !== old_dir) {
  2949. err = FS.nodePermissions(old_dir, 'w');
  2950. if (err) {
  2951. throw new FS.ErrnoError(err);
  2952. }
  2953. }
  2954. // remove the node from the lookup hash
  2955. FS.hashRemoveNode(old_node);
  2956. // do the underlying fs rename
  2957. try {
  2958. old_dir.node_ops.rename(old_node, new_dir, new_name);
  2959. } catch (e) {
  2960. throw e;
  2961. } finally {
  2962. // add the node back to the hash (in case node_ops.rename
  2963. // changed its name)
  2964. FS.hashAddNode(old_node);
  2965. }
  2966. },rmdir:function (path) {
  2967. var lookup = FS.lookupPath(path, { parent: true });
  2968. var parent = lookup.node;
  2969. var name = PATH.basename(path);
  2970. var node = FS.lookupNode(parent, name);
  2971. var err = FS.mayDelete(parent, name, true);
  2972. if (err) {
  2973. throw new FS.ErrnoError(err);
  2974. }
  2975. if (!parent.node_ops.rmdir) {
  2976. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  2977. }
  2978. if (FS.isMountpoint(node)) {
  2979. throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
  2980. }
  2981. parent.node_ops.rmdir(parent, name);
  2982. FS.destroyNode(node);
  2983. },readdir:function (path) {
  2984. var lookup = FS.lookupPath(path, { follow: true });
  2985. var node = lookup.node;
  2986. if (!node.node_ops.readdir) {
  2987. throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
  2988. }
  2989. return node.node_ops.readdir(node);
  2990. },unlink:function (path) {
  2991. var lookup = FS.lookupPath(path, { parent: true });
  2992. var parent = lookup.node;
  2993. var name = PATH.basename(path);
  2994. var node = FS.lookupNode(parent, name);
  2995. var err = FS.mayDelete(parent, name, false);
  2996. if (err) {
  2997. // POSIX says unlink should set EPERM, not EISDIR
  2998. if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;
  2999. throw new FS.ErrnoError(err);
  3000. }
  3001. if (!parent.node_ops.unlink) {
  3002. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  3003. }
  3004. if (FS.isMountpoint(node)) {
  3005. throw new FS.ErrnoError(ERRNO_CODES.EBUSY);
  3006. }
  3007. parent.node_ops.unlink(parent, name);
  3008. FS.destroyNode(node);
  3009. },readlink:function (path) {
  3010. var lookup = FS.lookupPath(path);
  3011. var link = lookup.node;
  3012. if (!link.node_ops.readlink) {
  3013. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3014. }
  3015. return link.node_ops.readlink(link);
  3016. },stat:function (path, dontFollow) {
  3017. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  3018. var node = lookup.node;
  3019. if (!node.node_ops.getattr) {
  3020. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  3021. }
  3022. return node.node_ops.getattr(node);
  3023. },lstat:function (path) {
  3024. return FS.stat(path, true);
  3025. },chmod:function (path, mode, dontFollow) {
  3026. var node;
  3027. if (typeof path === 'string') {
  3028. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  3029. node = lookup.node;
  3030. } else {
  3031. node = path;
  3032. }
  3033. if (!node.node_ops.setattr) {
  3034. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  3035. }
  3036. node.node_ops.setattr(node, {
  3037. mode: (mode & 4095) | (node.mode & ~4095),
  3038. timestamp: Date.now()
  3039. });
  3040. },lchmod:function (path, mode) {
  3041. FS.chmod(path, mode, true);
  3042. },fchmod:function (fd, mode) {
  3043. var stream = FS.getStream(fd);
  3044. if (!stream) {
  3045. throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  3046. }
  3047. FS.chmod(stream.node, mode);
  3048. },chown:function (path, uid, gid, dontFollow) {
  3049. var node;
  3050. if (typeof path === 'string') {
  3051. var lookup = FS.lookupPath(path, { follow: !dontFollow });
  3052. node = lookup.node;
  3053. } else {
  3054. node = path;
  3055. }
  3056. if (!node.node_ops.setattr) {
  3057. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  3058. }
  3059. node.node_ops.setattr(node, {
  3060. timestamp: Date.now()
  3061. // we ignore the uid / gid for now
  3062. });
  3063. },lchown:function (path, uid, gid) {
  3064. FS.chown(path, uid, gid, true);
  3065. },fchown:function (fd, uid, gid) {
  3066. var stream = FS.getStream(fd);
  3067. if (!stream) {
  3068. throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  3069. }
  3070. FS.chown(stream.node, uid, gid);
  3071. },truncate:function (path, len) {
  3072. if (len < 0) {
  3073. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3074. }
  3075. var node;
  3076. if (typeof path === 'string') {
  3077. var lookup = FS.lookupPath(path, { follow: true });
  3078. node = lookup.node;
  3079. } else {
  3080. node = path;
  3081. }
  3082. if (!node.node_ops.setattr) {
  3083. throw new FS.ErrnoError(ERRNO_CODES.EPERM);
  3084. }
  3085. if (FS.isDir(node.mode)) {
  3086. throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
  3087. }
  3088. if (!FS.isFile(node.mode)) {
  3089. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3090. }
  3091. var err = FS.nodePermissions(node, 'w');
  3092. if (err) {
  3093. throw new FS.ErrnoError(err);
  3094. }
  3095. node.node_ops.setattr(node, {
  3096. size: len,
  3097. timestamp: Date.now()
  3098. });
  3099. },ftruncate:function (fd, len) {
  3100. var stream = FS.getStream(fd);
  3101. if (!stream) {
  3102. throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  3103. }
  3104. if ((stream.flags & 2097155) === 0) {
  3105. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3106. }
  3107. FS.truncate(stream.node, len);
  3108. },utime:function (path, atime, mtime) {
  3109. var lookup = FS.lookupPath(path, { follow: true });
  3110. var node = lookup.node;
  3111. node.node_ops.setattr(node, {
  3112. timestamp: Math.max(atime, mtime)
  3113. });
  3114. },open:function (path, flags, mode, fd_start, fd_end) {
  3115. flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
  3116. mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
  3117. if ((flags & 64)) {
  3118. mode = (mode & 4095) | 32768;
  3119. } else {
  3120. mode = 0;
  3121. }
  3122. var node;
  3123. if (typeof path === 'object') {
  3124. node = path;
  3125. } else {
  3126. path = PATH.normalize(path);
  3127. try {
  3128. var lookup = FS.lookupPath(path, {
  3129. follow: !(flags & 131072)
  3130. });
  3131. node = lookup.node;
  3132. } catch (e) {
  3133. // ignore
  3134. }
  3135. }
  3136. // perhaps we need to create the node
  3137. if ((flags & 64)) {
  3138. if (node) {
  3139. // if O_CREAT and O_EXCL are set, error out if the node already exists
  3140. if ((flags & 128)) {
  3141. throw new FS.ErrnoError(ERRNO_CODES.EEXIST);
  3142. }
  3143. } else {
  3144. // node doesn't exist, try to create it
  3145. node = FS.mknod(path, mode, 0);
  3146. }
  3147. }
  3148. if (!node) {
  3149. throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
  3150. }
  3151. // can't truncate a device
  3152. if (FS.isChrdev(node.mode)) {
  3153. flags &= ~512;
  3154. }
  3155. // check permissions
  3156. var err = FS.mayOpen(node, flags);
  3157. if (err) {
  3158. throw new FS.ErrnoError(err);
  3159. }
  3160. // do truncation if necessary
  3161. if ((flags & 512)) {
  3162. FS.truncate(node, 0);
  3163. }
  3164. // we've already handled these, don't pass down to the underlying vfs
  3165. flags &= ~(128 | 512);
  3166. // register the stream with the filesystem
  3167. var stream = FS.createStream({
  3168. node: node,
  3169. path: FS.getPath(node), // we want the absolute path to the node
  3170. flags: flags,
  3171. seekable: true,
  3172. position: 0,
  3173. stream_ops: node.stream_ops,
  3174. // used by the file family libc calls (fopen, fwrite, ferror, etc.)
  3175. ungotten: [],
  3176. error: false
  3177. }, fd_start, fd_end);
  3178. // call the new stream's open function
  3179. if (stream.stream_ops.open) {
  3180. stream.stream_ops.open(stream);
  3181. }
  3182. if (Module['logReadFiles'] && !(flags & 1)) {
  3183. if (!FS.readFiles) FS.readFiles = {};
  3184. if (!(path in FS.readFiles)) {
  3185. FS.readFiles[path] = 1;
  3186. Module['printErr']('read file: ' + path);
  3187. }
  3188. }
  3189. return stream;
  3190. },close:function (stream) {
  3191. try {
  3192. if (stream.stream_ops.close) {
  3193. stream.stream_ops.close(stream);
  3194. }
  3195. } catch (e) {
  3196. throw e;
  3197. } finally {
  3198. FS.closeStream(stream.fd);
  3199. }
  3200. },llseek:function (stream, offset, whence) {
  3201. if (!stream.seekable || !stream.stream_ops.llseek) {
  3202. throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
  3203. }
  3204. return stream.stream_ops.llseek(stream, offset, whence);
  3205. },read:function (stream, buffer, offset, length, position) {
  3206. if (length < 0 || position < 0) {
  3207. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3208. }
  3209. if ((stream.flags & 2097155) === 1) {
  3210. throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  3211. }
  3212. if (FS.isDir(stream.node.mode)) {
  3213. throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
  3214. }
  3215. if (!stream.stream_ops.read) {
  3216. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3217. }
  3218. var seeking = true;
  3219. if (typeof position === 'undefined') {
  3220. position = stream.position;
  3221. seeking = false;
  3222. } else if (!stream.seekable) {
  3223. throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
  3224. }
  3225. var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);
  3226. if (!seeking) stream.position += bytesRead;
  3227. return bytesRead;
  3228. },write:function (stream, buffer, offset, length, position, canOwn) {
  3229. if (length < 0 || position < 0) {
  3230. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3231. }
  3232. if ((stream.flags & 2097155) === 0) {
  3233. throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  3234. }
  3235. if (FS.isDir(stream.node.mode)) {
  3236. throw new FS.ErrnoError(ERRNO_CODES.EISDIR);
  3237. }
  3238. if (!stream.stream_ops.write) {
  3239. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3240. }
  3241. var seeking = true;
  3242. if (typeof position === 'undefined') {
  3243. position = stream.position;
  3244. seeking = false;
  3245. } else if (!stream.seekable) {
  3246. throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);
  3247. }
  3248. if (stream.flags & 1024) {
  3249. // seek to the end before writing in append mode
  3250. FS.llseek(stream, 0, 2);
  3251. }
  3252. var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);
  3253. if (!seeking) stream.position += bytesWritten;
  3254. return bytesWritten;
  3255. },allocate:function (stream, offset, length) {
  3256. if (offset < 0 || length <= 0) {
  3257. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  3258. }
  3259. if ((stream.flags & 2097155) === 0) {
  3260. throw new FS.ErrnoError(ERRNO_CODES.EBADF);
  3261. }
  3262. if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {
  3263. throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
  3264. }
  3265. if (!stream.stream_ops.allocate) {
  3266. throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
  3267. }
  3268. stream.stream_ops.allocate(stream, offset, length);
  3269. },mmap:function (stream, buffer, offset, length, position, prot, flags) {
  3270. // TODO if PROT is PROT_WRITE, make sure we have write access
  3271. if ((stream.flags & 2097155) === 1) {
  3272. throw new FS.ErrnoError(ERRNO_CODES.EACCES);
  3273. }
  3274. if (!stream.stream_ops.mmap) {
  3275. throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
  3276. }
  3277. return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
  3278. },ioctl:function (stream, cmd, arg) {
  3279. if (!stream.stream_ops.ioctl) {
  3280. throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);
  3281. }
  3282. return stream.stream_ops.ioctl(stream, cmd, arg);
  3283. },readFile:function (path, opts) {
  3284. opts = opts || {};
  3285. opts.flags = opts.flags || 'r';
  3286. opts.encoding = opts.encoding || 'binary';
  3287. if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
  3288. throw new Error('Invalid encoding type "' + opts.encoding + '"');
  3289. }
  3290. var ret;
  3291. var stream = FS.open(path, opts.flags);
  3292. var stat = FS.stat(path);
  3293. var length = stat.size;
  3294. var buf = new Uint8Array(length);
  3295. FS.read(stream, buf, 0, length, 0);
  3296. if (opts.encoding === 'utf8') {
  3297. ret = '';
  3298. var utf8 = new Runtime.UTF8Processor();
  3299. for (var i = 0; i < length; i++) {
  3300. ret += utf8.processCChar(buf[i]);
  3301. }
  3302. } else if (opts.encoding === 'binary') {
  3303. ret = buf;
  3304. }
  3305. FS.close(stream);
  3306. return ret;
  3307. },writeFile:function (path, data, opts) {
  3308. opts = opts || {};
  3309. opts.flags = opts.flags || 'w';
  3310. opts.encoding = opts.encoding || 'utf8';
  3311. if (opts.encoding !== 'utf8' && opts.encoding !== 'binary') {
  3312. throw new Error('Invalid encoding type "' + opts.encoding + '"');
  3313. }
  3314. var stream = FS.open(path, opts.flags, opts.mode);
  3315. if (opts.encoding === 'utf8') {
  3316. var utf8 = new Runtime.UTF8Processor();
  3317. var buf = new Uint8Array(utf8.processJSString(data));
  3318. FS.write(stream, buf, 0, buf.length, 0, opts.canOwn);
  3319. } else if (opts.encoding === 'binary') {
  3320. FS.write(stream, data, 0, data.length, 0, opts.canOwn);
  3321. }
  3322. FS.close(stream);
  3323. },cwd:function () {
  3324. return FS.currentPath;
  3325. },chdir:function (path) {
  3326. var lookup = FS.lookupPath(path, { follow: true });
  3327. if (!FS.isDir(lookup.node.mode)) {
  3328. throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);
  3329. }
  3330. var err = FS.nodePermissions(lookup.node, 'x');
  3331. if (err) {
  3332. throw new FS.ErrnoError(err);
  3333. }
  3334. FS.currentPath = lookup.path;
  3335. },createDefaultDirectories:function () {
  3336. FS.mkdir('/tmp');
  3337. },createDefaultDevices:function () {
  3338. // create /dev
  3339. FS.mkdir('/dev');
  3340. // setup /dev/null
  3341. FS.registerDevice(FS.makedev(1, 3), {
  3342. read: function() { return 0; },
  3343. write: function() { return 0; }
  3344. });
  3345. FS.mkdev('/dev/null', FS.makedev(1, 3));
  3346. // setup /dev/tty and /dev/tty1
  3347. // stderr needs to print output using Module['printErr']
  3348. // so we register a second tty just for it.
  3349. TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
  3350. TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
  3351. FS.mkdev('/dev/tty', FS.makedev(5, 0));
  3352. FS.mkdev('/dev/tty1', FS.makedev(6, 0));
  3353. // we're not going to emulate the actual shm device,
  3354. // just create the tmp dirs that reside in it commonly
  3355. FS.mkdir('/dev/shm');
  3356. FS.mkdir('/dev/shm/tmp');
  3357. },createStandardStreams:function () {
  3358. // TODO deprecate the old functionality of a single
  3359. // input / output callback and that utilizes FS.createDevice
  3360. // and instead require a unique set of stream ops
  3361. // by default, we symlink the standard streams to the
  3362. // default tty devices. however, if the standard streams
  3363. // have been overwritten we create a unique device for
  3364. // them instead.
  3365. if (Module['stdin']) {
  3366. FS.createDevice('/dev', 'stdin', Module['stdin']);
  3367. } else {
  3368. FS.symlink('/dev/tty', '/dev/stdin');
  3369. }
  3370. if (Module['stdout']) {
  3371. FS.createDevice('/dev', 'stdout', null, Module['stdout']);
  3372. } else {
  3373. FS.symlink('/dev/tty', '/dev/stdout');
  3374. }
  3375. if (Module['stderr']) {
  3376. FS.createDevice('/dev', 'stderr', null, Module['stderr']);
  3377. } else {
  3378. FS.symlink('/dev/tty1', '/dev/stderr');
  3379. }
  3380. // open default streams for the stdin, stdout and stderr devices
  3381. var stdin = FS.open('/dev/stdin', 'r');
  3382. HEAP32[((_stdin)>>2)]=FS.getPtrForStream(stdin);
  3383. assert(stdin.fd === 0, 'invalid handle for stdin (' + stdin.fd + ')');
  3384. var stdout = FS.open('/dev/stdout', 'w');
  3385. HEAP32[((_stdout)>>2)]=FS.getPtrForStream(stdout);
  3386. assert(stdout.fd === 1, 'invalid handle for stdout (' + stdout.fd + ')');
  3387. var stderr = FS.open('/dev/stderr', 'w');
  3388. HEAP32[((_stderr)>>2)]=FS.getPtrForStream(stderr);
  3389. assert(stderr.fd === 2, 'invalid handle for stderr (' + stderr.fd + ')');
  3390. },ensureErrnoError:function () {
  3391. if (FS.ErrnoError) return;
  3392. FS.ErrnoError = function ErrnoError(errno) {
  3393. this.errno = errno;
  3394. for (var key in ERRNO_CODES) {
  3395. if (ERRNO_CODES[key] === errno) {
  3396. this.code = key;
  3397. break;
  3398. }
  3399. }
  3400. this.message = ERRNO_MESSAGES[errno];
  3401. };
  3402. FS.ErrnoError.prototype = new Error();
  3403. FS.ErrnoError.prototype.constructor = FS.ErrnoError;
  3404. // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
  3405. [ERRNO_CODES.ENOENT].forEach(function(code) {
  3406. FS.genericErrors[code] = new FS.ErrnoError(code);
  3407. FS.genericErrors[code].stack = '<generic error, no stack>';
  3408. });
  3409. },staticInit:function () {
  3410. FS.ensureErrnoError();
  3411. FS.nameTable = new Array(4096);
  3412. FS.mount(MEMFS, {}, '/');
  3413. FS.createDefaultDirectories();
  3414. FS.createDefaultDevices();
  3415. },init:function (input, output, error) {
  3416. 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)');
  3417. FS.init.initialized = true;
  3418. FS.ensureErrnoError();
  3419. // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
  3420. Module['stdin'] = input || Module['stdin'];
  3421. Module['stdout'] = output || Module['stdout'];
  3422. Module['stderr'] = error || Module['stderr'];
  3423. FS.createStandardStreams();
  3424. },quit:function () {
  3425. FS.init.initialized = false;
  3426. for (var i = 0; i < FS.streams.length; i++) {
  3427. var stream = FS.streams[i];
  3428. if (!stream) {
  3429. continue;
  3430. }
  3431. FS.close(stream);
  3432. }
  3433. },getMode:function (canRead, canWrite) {
  3434. var mode = 0;
  3435. if (canRead) mode |= 292 | 73;
  3436. if (canWrite) mode |= 146;
  3437. return mode;
  3438. },joinPath:function (parts, forceRelative) {
  3439. var path = PATH.join.apply(null, parts);
  3440. if (forceRelative && path[0] == '/') path = path.substr(1);
  3441. return path;
  3442. },absolutePath:function (relative, base) {
  3443. return PATH.resolve(base, relative);
  3444. },standardizePath:function (path) {
  3445. return PATH.normalize(path);
  3446. },findObject:function (path, dontResolveLastLink) {
  3447. var ret = FS.analyzePath(path, dontResolveLastLink);
  3448. if (ret.exists) {
  3449. return ret.object;
  3450. } else {
  3451. ___setErrNo(ret.error);
  3452. return null;
  3453. }
  3454. },analyzePath:function (path, dontResolveLastLink) {
  3455. // operate from within the context of the symlink's target
  3456. try {
  3457. var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
  3458. path = lookup.path;
  3459. } catch (e) {
  3460. }
  3461. var ret = {
  3462. isRoot: false, exists: false, error: 0, name: null, path: null, object: null,
  3463. parentExists: false, parentPath: null, parentObject: null
  3464. };
  3465. try {
  3466. var lookup = FS.lookupPath(path, { parent: true });
  3467. ret.parentExists = true;
  3468. ret.parentPath = lookup.path;
  3469. ret.parentObject = lookup.node;
  3470. ret.name = PATH.basename(path);
  3471. lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
  3472. ret.exists = true;
  3473. ret.path = lookup.path;
  3474. ret.object = lookup.node;
  3475. ret.name = lookup.node.name;
  3476. ret.isRoot = lookup.path === '/';
  3477. } catch (e) {
  3478. ret.error = e.errno;
  3479. };
  3480. return ret;
  3481. },createFolder:function (parent, name, canRead, canWrite) {
  3482. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3483. var mode = FS.getMode(canRead, canWrite);
  3484. return FS.mkdir(path, mode);
  3485. },createPath:function (parent, path, canRead, canWrite) {
  3486. parent = typeof parent === 'string' ? parent : FS.getPath(parent);
  3487. var parts = path.split('/').reverse();
  3488. while (parts.length) {
  3489. var part = parts.pop();
  3490. if (!part) continue;
  3491. var current = PATH.join2(parent, part);
  3492. try {
  3493. FS.mkdir(current);
  3494. } catch (e) {
  3495. // ignore EEXIST
  3496. }
  3497. parent = current;
  3498. }
  3499. return current;
  3500. },createFile:function (parent, name, properties, canRead, canWrite) {
  3501. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3502. var mode = FS.getMode(canRead, canWrite);
  3503. return FS.create(path, mode);
  3504. },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {
  3505. var path = name ? PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;
  3506. var mode = FS.getMode(canRead, canWrite);
  3507. var node = FS.create(path, mode);
  3508. if (data) {
  3509. if (typeof data === 'string') {
  3510. var arr = new Array(data.length);
  3511. for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);
  3512. data = arr;
  3513. }
  3514. // make sure we can write to the file
  3515. FS.chmod(node, mode | 146);
  3516. var stream = FS.open(node, 'w');
  3517. FS.write(stream, data, 0, data.length, 0, canOwn);
  3518. FS.close(stream);
  3519. FS.chmod(node, mode);
  3520. }
  3521. return node;
  3522. },createDevice:function (parent, name, input, output) {
  3523. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3524. var mode = FS.getMode(!!input, !!output);
  3525. if (!FS.createDevice.major) FS.createDevice.major = 64;
  3526. var dev = FS.makedev(FS.createDevice.major++, 0);
  3527. // Create a fake device that a set of stream ops to emulate
  3528. // the old behavior.
  3529. FS.registerDevice(dev, {
  3530. open: function(stream) {
  3531. stream.seekable = false;
  3532. },
  3533. close: function(stream) {
  3534. // flush any pending line data
  3535. if (output && output.buffer && output.buffer.length) {
  3536. output(10);
  3537. }
  3538. },
  3539. read: function(stream, buffer, offset, length, pos /* ignored */) {
  3540. var bytesRead = 0;
  3541. for (var i = 0; i < length; i++) {
  3542. var result;
  3543. try {
  3544. result = input();
  3545. } catch (e) {
  3546. throw new FS.ErrnoError(ERRNO_CODES.EIO);
  3547. }
  3548. if (result === undefined && bytesRead === 0) {
  3549. throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
  3550. }
  3551. if (result === null || result === undefined) break;
  3552. bytesRead++;
  3553. buffer[offset+i] = result;
  3554. }
  3555. if (bytesRead) {
  3556. stream.node.timestamp = Date.now();
  3557. }
  3558. return bytesRead;
  3559. },
  3560. write: function(stream, buffer, offset, length, pos) {
  3561. for (var i = 0; i < length; i++) {
  3562. try {
  3563. output(buffer[offset+i]);
  3564. } catch (e) {
  3565. throw new FS.ErrnoError(ERRNO_CODES.EIO);
  3566. }
  3567. }
  3568. if (length) {
  3569. stream.node.timestamp = Date.now();
  3570. }
  3571. return i;
  3572. }
  3573. });
  3574. return FS.mkdev(path, mode, dev);
  3575. },createLink:function (parent, name, target, canRead, canWrite) {
  3576. var path = PATH.join2(typeof parent === 'string' ? parent : FS.getPath(parent), name);
  3577. return FS.symlink(target, path);
  3578. },forceLoadFile:function (obj) {
  3579. if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
  3580. var success = true;
  3581. if (typeof XMLHttpRequest !== 'undefined') {
  3582. 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.");
  3583. } else if (Module['read']) {
  3584. // Command-line.
  3585. try {
  3586. // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as
  3587. // read() will try to parse UTF8.
  3588. obj.contents = intArrayFromString(Module['read'](obj.url), true);
  3589. } catch (e) {
  3590. success = false;
  3591. }
  3592. } else {
  3593. throw new Error('Cannot load without read() or XMLHttpRequest.');
  3594. }
  3595. if (!success) ___setErrNo(ERRNO_CODES.EIO);
  3596. return success;
  3597. },createLazyFile:function (parent, name, url, canRead, canWrite) {
  3598. // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.
  3599. function LazyUint8Array() {
  3600. this.lengthKnown = false;
  3601. this.chunks = []; // Loaded chunks. Index is the chunk number
  3602. }
  3603. LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) {
  3604. if (idx > this.length-1 || idx < 0) {
  3605. return undefined;
  3606. }
  3607. var chunkOffset = idx % this.chunkSize;
  3608. var chunkNum = Math.floor(idx / this.chunkSize);
  3609. return this.getter(chunkNum)[chunkOffset];
  3610. }
  3611. LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) {
  3612. this.getter = getter;
  3613. }
  3614. LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() {
  3615. // Find length
  3616. var xhr = new XMLHttpRequest();
  3617. xhr.open('HEAD', url, false);
  3618. xhr.send(null);
  3619. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3620. var datalength = Number(xhr.getResponseHeader("Content-length"));
  3621. var header;
  3622. var hasByteServing = (header = xhr.getResponseHeader("Accept-Ranges")) && header === "bytes";
  3623. var chunkSize = 1024*1024; // Chunk size in bytes
  3624. if (!hasByteServing) chunkSize = datalength;
  3625. // Function to get a range from the remote URL.
  3626. var doXHR = (function(from, to) {
  3627. if (from > to) throw new Error("invalid range (" + from + ", " + to + ") or no bytes requested!");
  3628. if (to > datalength-1) throw new Error("only " + datalength + " bytes available! programmer error!");
  3629. // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
  3630. var xhr = new XMLHttpRequest();
  3631. xhr.open('GET', url, false);
  3632. if (datalength !== chunkSize) xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
  3633. // Some hints to the browser that we want binary data.
  3634. if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
  3635. if (xhr.overrideMimeType) {
  3636. xhr.overrideMimeType('text/plain; charset=x-user-defined');
  3637. }
  3638. xhr.send(null);
  3639. if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
  3640. if (xhr.response !== undefined) {
  3641. return new Uint8Array(xhr.response || []);
  3642. } else {
  3643. return intArrayFromString(xhr.responseText || '', true);
  3644. }
  3645. });
  3646. var lazyArray = this;
  3647. lazyArray.setDataGetter(function(chunkNum) {
  3648. var start = chunkNum * chunkSize;
  3649. var end = (chunkNum+1) * chunkSize - 1; // including this byte
  3650. end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
  3651. if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
  3652. lazyArray.chunks[chunkNum] = doXHR(start, end);
  3653. }
  3654. if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
  3655. return lazyArray.chunks[chunkNum];
  3656. });
  3657. this._length = datalength;
  3658. this._chunkSize = chunkSize;
  3659. this.lengthKnown = true;
  3660. }
  3661. if (typeof XMLHttpRequest !== 'undefined') {
  3662. if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';
  3663. var lazyArray = new LazyUint8Array();
  3664. Object.defineProperty(lazyArray, "length", {
  3665. get: function() {
  3666. if(!this.lengthKnown) {
  3667. this.cacheLength();
  3668. }
  3669. return this._length;
  3670. }
  3671. });
  3672. Object.defineProperty(lazyArray, "chunkSize", {
  3673. get: function() {
  3674. if(!this.lengthKnown) {
  3675. this.cacheLength();
  3676. }
  3677. return this._chunkSize;
  3678. }
  3679. });
  3680. var properties = { isDevice: false, contents: lazyArray };
  3681. } else {
  3682. var properties = { isDevice: false, url: url };
  3683. }
  3684. var node = FS.createFile(parent, name, properties, canRead, canWrite);
  3685. // This is a total hack, but I want to get this lazy file code out of the
  3686. // core of MEMFS. If we want to keep this lazy file concept I feel it should
  3687. // be its own thin LAZYFS proxying calls to MEMFS.
  3688. if (properties.contents) {
  3689. node.contents = properties.contents;
  3690. } else if (properties.url) {
  3691. node.contents = null;
  3692. node.url = properties.url;
  3693. }
  3694. // override each stream op with one that tries to force load the lazy file first
  3695. var stream_ops = {};
  3696. var keys = Object.keys(node.stream_ops);
  3697. keys.forEach(function(key) {
  3698. var fn = node.stream_ops[key];
  3699. stream_ops[key] = function forceLoadLazyFile() {
  3700. if (!FS.forceLoadFile(node)) {
  3701. throw new FS.ErrnoError(ERRNO_CODES.EIO);
  3702. }
  3703. return fn.apply(null, arguments);
  3704. };
  3705. });
  3706. // use a custom read function
  3707. stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) {
  3708. if (!FS.forceLoadFile(node)) {
  3709. throw new FS.ErrnoError(ERRNO_CODES.EIO);
  3710. }
  3711. var contents = stream.node.contents;
  3712. if (position >= contents.length)
  3713. return 0;
  3714. var size = Math.min(contents.length - position, length);
  3715. assert(size >= 0);
  3716. if (contents.slice) { // normal array
  3717. for (var i = 0; i < size; i++) {
  3718. buffer[offset + i] = contents[position + i];
  3719. }
  3720. } else {
  3721. for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
  3722. buffer[offset + i] = contents.get(position + i);
  3723. }
  3724. }
  3725. return size;
  3726. };
  3727. node.stream_ops = stream_ops;
  3728. return node;
  3729. },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {
  3730. Browser.init();
  3731. // TODO we should allow people to just pass in a complete filename instead
  3732. // of parent and name being that we just join them anyways
  3733. var fullname = name ? PATH.resolve(PATH.join2(parent, name)) : parent;
  3734. function processData(byteArray) {
  3735. function finish(byteArray) {
  3736. if (!dontCreateFile) {
  3737. FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
  3738. }
  3739. if (onload) onload();
  3740. removeRunDependency('cp ' + fullname);
  3741. }
  3742. var handled = false;
  3743. Module['preloadPlugins'].forEach(function(plugin) {
  3744. if (handled) return;
  3745. if (plugin['canHandle'](fullname)) {
  3746. plugin['handle'](byteArray, fullname, finish, function() {
  3747. if (onerror) onerror();
  3748. removeRunDependency('cp ' + fullname);
  3749. });
  3750. handled = true;
  3751. }
  3752. });
  3753. if (!handled) finish(byteArray);
  3754. }
  3755. addRunDependency('cp ' + fullname);
  3756. if (typeof url == 'string') {
  3757. Browser.asyncLoad(url, function(byteArray) {
  3758. processData(byteArray);
  3759. }, onerror);
  3760. } else {
  3761. processData(url);
  3762. }
  3763. },indexedDB:function () {
  3764. return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
  3765. },DB_NAME:function () {
  3766. return 'EM_FS_' + window.location.pathname;
  3767. },DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function (paths, onload, onerror) {
  3768. onload = onload || function(){};
  3769. onerror = onerror || function(){};
  3770. var indexedDB = FS.indexedDB();
  3771. try {
  3772. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
  3773. } catch (e) {
  3774. return onerror(e);
  3775. }
  3776. openRequest.onupgradeneeded = function openRequest_onupgradeneeded() {
  3777. console.log('creating db');
  3778. var db = openRequest.result;
  3779. db.createObjectStore(FS.DB_STORE_NAME);
  3780. };
  3781. openRequest.onsuccess = function openRequest_onsuccess() {
  3782. var db = openRequest.result;
  3783. var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');
  3784. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3785. var ok = 0, fail = 0, total = paths.length;
  3786. function finish() {
  3787. if (fail == 0) onload(); else onerror();
  3788. }
  3789. paths.forEach(function(path) {
  3790. var putRequest = files.put(FS.analyzePath(path).object.contents, path);
  3791. putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() };
  3792. putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() };
  3793. });
  3794. transaction.onerror = onerror;
  3795. };
  3796. openRequest.onerror = onerror;
  3797. },loadFilesFromDB:function (paths, onload, onerror) {
  3798. onload = onload || function(){};
  3799. onerror = onerror || function(){};
  3800. var indexedDB = FS.indexedDB();
  3801. try {
  3802. var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);
  3803. } catch (e) {
  3804. return onerror(e);
  3805. }
  3806. openRequest.onupgradeneeded = onerror; // no database to load from
  3807. openRequest.onsuccess = function openRequest_onsuccess() {
  3808. var db = openRequest.result;
  3809. try {
  3810. var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');
  3811. } catch(e) {
  3812. onerror(e);
  3813. return;
  3814. }
  3815. var files = transaction.objectStore(FS.DB_STORE_NAME);
  3816. var ok = 0, fail = 0, total = paths.length;
  3817. function finish() {
  3818. if (fail == 0) onload(); else onerror();
  3819. }
  3820. paths.forEach(function(path) {
  3821. var getRequest = files.get(path);
  3822. getRequest.onsuccess = function getRequest_onsuccess() {
  3823. if (FS.analyzePath(path).exists) {
  3824. FS.unlink(path);
  3825. }
  3826. FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);
  3827. ok++;
  3828. if (ok + fail == total) finish();
  3829. };
  3830. getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() };
  3831. });
  3832. transaction.onerror = onerror;
  3833. };
  3834. openRequest.onerror = onerror;
  3835. }};
  3836. function _mkport() { throw 'TODO' }var SOCKFS={mount:function (mount) {
  3837. return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
  3838. },createSocket:function (family, type, protocol) {
  3839. var streaming = type == 1;
  3840. if (protocol) {
  3841. assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp
  3842. }
  3843. // create our internal socket structure
  3844. var sock = {
  3845. family: family,
  3846. type: type,
  3847. protocol: protocol,
  3848. server: null,
  3849. peers: {},
  3850. pending: [],
  3851. recv_queue: [],
  3852. sock_ops: SOCKFS.websocket_sock_ops
  3853. };
  3854. // create the filesystem node to store the socket structure
  3855. var name = SOCKFS.nextname();
  3856. var node = FS.createNode(SOCKFS.root, name, 49152, 0);
  3857. node.sock = sock;
  3858. // and the wrapping stream that enables library functions such
  3859. // as read and write to indirectly interact with the socket
  3860. var stream = FS.createStream({
  3861. path: name,
  3862. node: node,
  3863. flags: FS.modeStringToFlags('r+'),
  3864. seekable: false,
  3865. stream_ops: SOCKFS.stream_ops
  3866. });
  3867. // map the new stream to the socket structure (sockets have a 1:1
  3868. // relationship with a stream)
  3869. sock.stream = stream;
  3870. return sock;
  3871. },getSocket:function (fd) {
  3872. var stream = FS.getStream(fd);
  3873. if (!stream || !FS.isSocket(stream.node.mode)) {
  3874. return null;
  3875. }
  3876. return stream.node.sock;
  3877. },stream_ops:{poll:function (stream) {
  3878. var sock = stream.node.sock;
  3879. return sock.sock_ops.poll(sock);
  3880. },ioctl:function (stream, request, varargs) {
  3881. var sock = stream.node.sock;
  3882. return sock.sock_ops.ioctl(sock, request, varargs);
  3883. },read:function (stream, buffer, offset, length, position /* ignored */) {
  3884. var sock = stream.node.sock;
  3885. var msg = sock.sock_ops.recvmsg(sock, length);
  3886. if (!msg) {
  3887. // socket is closed
  3888. return 0;
  3889. }
  3890. buffer.set(msg.buffer, offset);
  3891. return msg.buffer.length;
  3892. },write:function (stream, buffer, offset, length, position /* ignored */) {
  3893. var sock = stream.node.sock;
  3894. return sock.sock_ops.sendmsg(sock, buffer, offset, length);
  3895. },close:function (stream) {
  3896. var sock = stream.node.sock;
  3897. sock.sock_ops.close(sock);
  3898. }},nextname:function () {
  3899. if (!SOCKFS.nextname.current) {
  3900. SOCKFS.nextname.current = 0;
  3901. }
  3902. return 'socket[' + (SOCKFS.nextname.current++) + ']';
  3903. },websocket_sock_ops:{createPeer:function (sock, addr, port) {
  3904. var ws;
  3905. if (typeof addr === 'object') {
  3906. ws = addr;
  3907. addr = null;
  3908. port = null;
  3909. }
  3910. if (ws) {
  3911. // for sockets that've already connected (e.g. we're the server)
  3912. // we can inspect the _socket property for the address
  3913. if (ws._socket) {
  3914. addr = ws._socket.remoteAddress;
  3915. port = ws._socket.remotePort;
  3916. }
  3917. // if we're just now initializing a connection to the remote,
  3918. // inspect the url property
  3919. else {
  3920. var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
  3921. if (!result) {
  3922. throw new Error('WebSocket URL must be in the format ws(s)://address:port');
  3923. }
  3924. addr = result[1];
  3925. port = parseInt(result[2], 10);
  3926. }
  3927. } else {
  3928. // create the actual websocket object and connect
  3929. try {
  3930. // runtimeConfig gets set to true if WebSocket runtime configuration is available.
  3931. var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
  3932. // The default value is 'ws://' the replace is needed because the compiler replaces "//" comments with '#'
  3933. // comments without checking context, so we'd end up with ws:#, the replace swaps the "#" for "//" again.
  3934. var url = 'ws:#'.replace('#', '//');
  3935. if (runtimeConfig) {
  3936. if ('string' === typeof Module['websocket']['url']) {
  3937. url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
  3938. }
  3939. }
  3940. if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
  3941. url = url + addr + ':' + port;
  3942. }
  3943. // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
  3944. var subProtocols = 'binary'; // The default value is 'binary'
  3945. if (runtimeConfig) {
  3946. if ('string' === typeof Module['websocket']['subprotocol']) {
  3947. subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
  3948. }
  3949. }
  3950. // The regex trims the string (removes spaces at the beginning and end, then splits the string by
  3951. // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
  3952. subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
  3953. // The node ws library API for specifying optional subprotocol is slightly different than the browser's.
  3954. var opts = ENVIRONMENT_IS_NODE ? {'protocol': subProtocols.toString()} : subProtocols;
  3955. // If node we use the ws library.
  3956. var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket'];
  3957. ws = new WebSocket(url, opts);
  3958. ws.binaryType = 'arraybuffer';
  3959. } catch (e) {
  3960. throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);
  3961. }
  3962. }
  3963. var peer = {
  3964. addr: addr,
  3965. port: port,
  3966. socket: ws,
  3967. dgram_send_queue: []
  3968. };
  3969. SOCKFS.websocket_sock_ops.addPeer(sock, peer);
  3970. SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
  3971. // if this is a bound dgram socket, send the port number first to allow
  3972. // us to override the ephemeral port reported to us by remotePort on the
  3973. // remote end.
  3974. if (sock.type === 2 && typeof sock.sport !== 'undefined') {
  3975. peer.dgram_send_queue.push(new Uint8Array([
  3976. 255, 255, 255, 255,
  3977. 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
  3978. ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
  3979. ]));
  3980. }
  3981. return peer;
  3982. },getPeer:function (sock, addr, port) {
  3983. return sock.peers[addr + ':' + port];
  3984. },addPeer:function (sock, peer) {
  3985. sock.peers[peer.addr + ':' + peer.port] = peer;
  3986. },removePeer:function (sock, peer) {
  3987. delete sock.peers[peer.addr + ':' + peer.port];
  3988. },handlePeerEvents:function (sock, peer) {
  3989. var first = true;
  3990. var handleOpen = function () {
  3991. try {
  3992. var queued = peer.dgram_send_queue.shift();
  3993. while (queued) {
  3994. peer.socket.send(queued);
  3995. queued = peer.dgram_send_queue.shift();
  3996. }
  3997. } catch (e) {
  3998. // not much we can do here in the way of proper error handling as we've already
  3999. // lied and said this data was sent. shut it down.
  4000. peer.socket.close();
  4001. }
  4002. };
  4003. function handleMessage(data) {
  4004. assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer
  4005. data = new Uint8Array(data); // make a typed array view on the array buffer
  4006. // if this is the port message, override the peer's port with it
  4007. var wasfirst = first;
  4008. first = false;
  4009. if (wasfirst &&
  4010. data.length === 10 &&
  4011. data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
  4012. data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
  4013. // update the peer's port and it's key in the peer map
  4014. var newport = ((data[8] << 8) | data[9]);
  4015. SOCKFS.websocket_sock_ops.removePeer(sock, peer);
  4016. peer.port = newport;
  4017. SOCKFS.websocket_sock_ops.addPeer(sock, peer);
  4018. return;
  4019. }
  4020. sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
  4021. };
  4022. if (ENVIRONMENT_IS_NODE) {
  4023. peer.socket.on('open', handleOpen);
  4024. peer.socket.on('message', function(data, flags) {
  4025. if (!flags.binary) {
  4026. return;
  4027. }
  4028. handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
  4029. });
  4030. peer.socket.on('error', function() {
  4031. // don't throw
  4032. });
  4033. } else {
  4034. peer.socket.onopen = handleOpen;
  4035. peer.socket.onmessage = function peer_socket_onmessage(event) {
  4036. handleMessage(event.data);
  4037. };
  4038. }
  4039. },poll:function (sock) {
  4040. if (sock.type === 1 && sock.server) {
  4041. // listen sockets should only say they're available for reading
  4042. // if there are pending clients.
  4043. return sock.pending.length ? (64 | 1) : 0;
  4044. }
  4045. var mask = 0;
  4046. var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
  4047. SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
  4048. null;
  4049. if (sock.recv_queue.length ||
  4050. !dest || // connection-less sockets are always ready to read
  4051. (dest && dest.socket.readyState === dest.socket.CLOSING) ||
  4052. (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
  4053. mask |= (64 | 1);
  4054. }
  4055. if (!dest || // connection-less sockets are always ready to write
  4056. (dest && dest.socket.readyState === dest.socket.OPEN)) {
  4057. mask |= 4;
  4058. }
  4059. if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
  4060. (dest && dest.socket.readyState === dest.socket.CLOSED)) {
  4061. mask |= 16;
  4062. }
  4063. return mask;
  4064. },ioctl:function (sock, request, arg) {
  4065. switch (request) {
  4066. case 21531:
  4067. var bytes = 0;
  4068. if (sock.recv_queue.length) {
  4069. bytes = sock.recv_queue[0].data.length;
  4070. }
  4071. HEAP32[((arg)>>2)]=bytes;
  4072. return 0;
  4073. default:
  4074. return ERRNO_CODES.EINVAL;
  4075. }
  4076. },close:function (sock) {
  4077. // if we've spawned a listen server, close it
  4078. if (sock.server) {
  4079. try {
  4080. sock.server.close();
  4081. } catch (e) {
  4082. }
  4083. sock.server = null;
  4084. }
  4085. // close any peer connections
  4086. var peers = Object.keys(sock.peers);
  4087. for (var i = 0; i < peers.length; i++) {
  4088. var peer = sock.peers[peers[i]];
  4089. try {
  4090. peer.socket.close();
  4091. } catch (e) {
  4092. }
  4093. SOCKFS.websocket_sock_ops.removePeer(sock, peer);
  4094. }
  4095. return 0;
  4096. },bind:function (sock, addr, port) {
  4097. if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {
  4098. throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound
  4099. }
  4100. sock.saddr = addr;
  4101. sock.sport = port || _mkport();
  4102. // in order to emulate dgram sockets, we need to launch a listen server when
  4103. // binding on a connection-less socket
  4104. // note: this is only required on the server side
  4105. if (sock.type === 2) {
  4106. // close the existing server if it exists
  4107. if (sock.server) {
  4108. sock.server.close();
  4109. sock.server = null;
  4110. }
  4111. // swallow error operation not supported error that occurs when binding in the
  4112. // browser where this isn't supported
  4113. try {
  4114. sock.sock_ops.listen(sock, 0);
  4115. } catch (e) {
  4116. if (!(e instanceof FS.ErrnoError)) throw e;
  4117. if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;
  4118. }
  4119. }
  4120. },connect:function (sock, addr, port) {
  4121. if (sock.server) {
  4122. throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);
  4123. }
  4124. // TODO autobind
  4125. // if (!sock.addr && sock.type == 2) {
  4126. // }
  4127. // early out if we're already connected / in the middle of connecting
  4128. if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {
  4129. var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
  4130. if (dest) {
  4131. if (dest.socket.readyState === dest.socket.CONNECTING) {
  4132. throw new FS.ErrnoError(ERRNO_CODES.EALREADY);
  4133. } else {
  4134. throw new FS.ErrnoError(ERRNO_CODES.EISCONN);
  4135. }
  4136. }
  4137. }
  4138. // add the socket to our peer list and set our
  4139. // destination address / port to match
  4140. var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
  4141. sock.daddr = peer.addr;
  4142. sock.dport = peer.port;
  4143. // always "fail" in non-blocking mode
  4144. throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);
  4145. },listen:function (sock, backlog) {
  4146. if (!ENVIRONMENT_IS_NODE) {
  4147. throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);
  4148. }
  4149. if (sock.server) {
  4150. throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening
  4151. }
  4152. var WebSocketServer = require('ws').Server;
  4153. var host = sock.saddr;
  4154. sock.server = new WebSocketServer({
  4155. host: host,
  4156. port: sock.sport
  4157. // TODO support backlog
  4158. });
  4159. sock.server.on('connection', function(ws) {
  4160. if (sock.type === 1) {
  4161. var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
  4162. // create a peer on the new socket
  4163. var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
  4164. newsock.daddr = peer.addr;
  4165. newsock.dport = peer.port;
  4166. // push to queue for accept to pick up
  4167. sock.pending.push(newsock);
  4168. } else {
  4169. // create a peer on the listen socket so calling sendto
  4170. // with the listen socket and an address will resolve
  4171. // to the correct client
  4172. SOCKFS.websocket_sock_ops.createPeer(sock, ws);
  4173. }
  4174. });
  4175. sock.server.on('closed', function() {
  4176. sock.server = null;
  4177. });
  4178. sock.server.on('error', function() {
  4179. // don't throw
  4180. });
  4181. },accept:function (listensock) {
  4182. if (!listensock.server) {
  4183. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  4184. }
  4185. var newsock = listensock.pending.shift();
  4186. newsock.stream.flags = listensock.stream.flags;
  4187. return newsock;
  4188. },getname:function (sock, peer) {
  4189. var addr, port;
  4190. if (peer) {
  4191. if (sock.daddr === undefined || sock.dport === undefined) {
  4192. throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
  4193. }
  4194. addr = sock.daddr;
  4195. port = sock.dport;
  4196. } else {
  4197. // TODO saddr and sport will be set for bind()'d UDP sockets, but what
  4198. // should we be returning for TCP sockets that've been connect()'d?
  4199. addr = sock.saddr || 0;
  4200. port = sock.sport || 0;
  4201. }
  4202. return { addr: addr, port: port };
  4203. },sendmsg:function (sock, buffer, offset, length, addr, port) {
  4204. if (sock.type === 2) {
  4205. // connection-less sockets will honor the message address,
  4206. // and otherwise fall back to the bound destination address
  4207. if (addr === undefined || port === undefined) {
  4208. addr = sock.daddr;
  4209. port = sock.dport;
  4210. }
  4211. // if there was no address to fall back to, error out
  4212. if (addr === undefined || port === undefined) {
  4213. throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);
  4214. }
  4215. } else {
  4216. // connection-based sockets will only use the bound
  4217. addr = sock.daddr;
  4218. port = sock.dport;
  4219. }
  4220. // find the peer for the destination address
  4221. var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
  4222. // early out if not connected with a connection-based socket
  4223. if (sock.type === 1) {
  4224. if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
  4225. throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
  4226. } else if (dest.socket.readyState === dest.socket.CONNECTING) {
  4227. throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
  4228. }
  4229. }
  4230. // create a copy of the incoming data to send, as the WebSocket API
  4231. // doesn't work entirely with an ArrayBufferView, it'll just send
  4232. // the entire underlying buffer
  4233. var data;
  4234. if (buffer instanceof Array || buffer instanceof ArrayBuffer) {
  4235. data = buffer.slice(offset, offset + length);
  4236. } else { // ArrayBufferView
  4237. data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);
  4238. }
  4239. // if we're emulating a connection-less dgram socket and don't have
  4240. // a cached connection, queue the buffer to send upon connect and
  4241. // lie, saying the data was sent now.
  4242. if (sock.type === 2) {
  4243. if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
  4244. // if we're not connected, open a new connection
  4245. if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
  4246. dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
  4247. }
  4248. dest.dgram_send_queue.push(data);
  4249. return length;
  4250. }
  4251. }
  4252. try {
  4253. // send the actual data
  4254. dest.socket.send(data);
  4255. return length;
  4256. } catch (e) {
  4257. throw new FS.ErrnoError(ERRNO_CODES.EINVAL);
  4258. }
  4259. },recvmsg:function (sock, length) {
  4260. // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
  4261. if (sock.type === 1 && sock.server) {
  4262. // tcp servers should not be recv()'ing on the listen socket
  4263. throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
  4264. }
  4265. var queued = sock.recv_queue.shift();
  4266. if (!queued) {
  4267. if (sock.type === 1) {
  4268. var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
  4269. if (!dest) {
  4270. // if we have a destination address but are not connected, error out
  4271. throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);
  4272. }
  4273. else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
  4274. // return null if the socket has closed
  4275. return null;
  4276. }
  4277. else {
  4278. // else, our socket is in a valid state but truly has nothing available
  4279. throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
  4280. }
  4281. } else {
  4282. throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);
  4283. }
  4284. }
  4285. // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
  4286. // requeued TCP data it'll be an ArrayBufferView
  4287. var queuedLength = queued.data.byteLength || queued.data.length;
  4288. var queuedOffset = queued.data.byteOffset || 0;
  4289. var queuedBuffer = queued.data.buffer || queued.data;
  4290. var bytesRead = Math.min(length, queuedLength);
  4291. var res = {
  4292. buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
  4293. addr: queued.addr,
  4294. port: queued.port
  4295. };
  4296. // push back any unread data for TCP connections
  4297. if (sock.type === 1 && bytesRead < queuedLength) {
  4298. var bytesRemaining = queuedLength - bytesRead;
  4299. queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
  4300. sock.recv_queue.unshift(queued);
  4301. }
  4302. return res;
  4303. }}};function _send(fd, buf, len, flags) {
  4304. var sock = SOCKFS.getSocket(fd);
  4305. if (!sock) {
  4306. ___setErrNo(ERRNO_CODES.EBADF);
  4307. return -1;
  4308. }
  4309. // TODO honor flags
  4310. return _write(fd, buf, len);
  4311. }
  4312. function _pwrite(fildes, buf, nbyte, offset) {
  4313. // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
  4314. // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
  4315. var stream = FS.getStream(fildes);
  4316. if (!stream) {
  4317. ___setErrNo(ERRNO_CODES.EBADF);
  4318. return -1;
  4319. }
  4320. try {
  4321. var slab = HEAP8;
  4322. return FS.write(stream, slab, buf, nbyte, offset);
  4323. } catch (e) {
  4324. FS.handleFSError(e);
  4325. return -1;
  4326. }
  4327. }function _write(fildes, buf, nbyte) {
  4328. // ssize_t write(int fildes, const void *buf, size_t nbyte);
  4329. // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html
  4330. var stream = FS.getStream(fildes);
  4331. if (!stream) {
  4332. ___setErrNo(ERRNO_CODES.EBADF);
  4333. return -1;
  4334. }
  4335. try {
  4336. var slab = HEAP8;
  4337. return FS.write(stream, slab, buf, nbyte);
  4338. } catch (e) {
  4339. FS.handleFSError(e);
  4340. return -1;
  4341. }
  4342. }
  4343. function _fileno(stream) {
  4344. // int fileno(FILE *stream);
  4345. // http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
  4346. stream = FS.getStreamFromPtr(stream);
  4347. if (!stream) return -1;
  4348. return stream.fd;
  4349. }function _fwrite(ptr, size, nitems, stream) {
  4350. // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
  4351. // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html
  4352. var bytesToWrite = nitems * size;
  4353. if (bytesToWrite == 0) return 0;
  4354. var fd = _fileno(stream);
  4355. var bytesWritten = _write(fd, ptr, bytesToWrite);
  4356. if (bytesWritten == -1) {
  4357. var streamObj = FS.getStreamFromPtr(stream);
  4358. if (streamObj) streamObj.error = true;
  4359. return 0;
  4360. } else {
  4361. return Math.floor(bytesWritten / size);
  4362. }
  4363. }
  4364. Module["_strlen"] = _strlen;
  4365. function __reallyNegative(x) {
  4366. return x < 0 || (x === 0 && (1/x) === -Infinity);
  4367. }function __formatString(format, varargs) {
  4368. var textIndex = format;
  4369. var argIndex = 0;
  4370. function getNextArg(type) {
  4371. // NOTE: Explicitly ignoring type safety. Otherwise this fails:
  4372. // int x = 4; printf("%c\n", (char)x);
  4373. var ret;
  4374. if (type === 'double') {
  4375. ret = HEAPF64[(((varargs)+(argIndex))>>3)];
  4376. } else if (type == 'i64') {
  4377. ret = [HEAP32[(((varargs)+(argIndex))>>2)],
  4378. HEAP32[(((varargs)+(argIndex+4))>>2)]];
  4379. } else {
  4380. type = 'i32'; // varargs are always i32, i64, or double
  4381. ret = HEAP32[(((varargs)+(argIndex))>>2)];
  4382. }
  4383. argIndex += Runtime.getNativeFieldSize(type);
  4384. return ret;
  4385. }
  4386. var ret = [];
  4387. var curr, next, currArg;
  4388. while(1) {
  4389. var startTextIndex = textIndex;
  4390. curr = HEAP8[(textIndex)];
  4391. if (curr === 0) break;
  4392. next = HEAP8[((textIndex+1)|0)];
  4393. if (curr == 37) {
  4394. // Handle flags.
  4395. var flagAlwaysSigned = false;
  4396. var flagLeftAlign = false;
  4397. var flagAlternative = false;
  4398. var flagZeroPad = false;
  4399. var flagPadSign = false;
  4400. flagsLoop: while (1) {
  4401. switch (next) {
  4402. case 43:
  4403. flagAlwaysSigned = true;
  4404. break;
  4405. case 45:
  4406. flagLeftAlign = true;
  4407. break;
  4408. case 35:
  4409. flagAlternative = true;
  4410. break;
  4411. case 48:
  4412. if (flagZeroPad) {
  4413. break flagsLoop;
  4414. } else {
  4415. flagZeroPad = true;
  4416. break;
  4417. }
  4418. case 32:
  4419. flagPadSign = true;
  4420. break;
  4421. default:
  4422. break flagsLoop;
  4423. }
  4424. textIndex++;
  4425. next = HEAP8[((textIndex+1)|0)];
  4426. }
  4427. // Handle width.
  4428. var width = 0;
  4429. if (next == 42) {
  4430. width = getNextArg('i32');
  4431. textIndex++;
  4432. next = HEAP8[((textIndex+1)|0)];
  4433. } else {
  4434. while (next >= 48 && next <= 57) {
  4435. width = width * 10 + (next - 48);
  4436. textIndex++;
  4437. next = HEAP8[((textIndex+1)|0)];
  4438. }
  4439. }
  4440. // Handle precision.
  4441. var precisionSet = false, precision = -1;
  4442. if (next == 46) {
  4443. precision = 0;
  4444. precisionSet = true;
  4445. textIndex++;
  4446. next = HEAP8[((textIndex+1)|0)];
  4447. if (next == 42) {
  4448. precision = getNextArg('i32');
  4449. textIndex++;
  4450. } else {
  4451. while(1) {
  4452. var precisionChr = HEAP8[((textIndex+1)|0)];
  4453. if (precisionChr < 48 ||
  4454. precisionChr > 57) break;
  4455. precision = precision * 10 + (precisionChr - 48);
  4456. textIndex++;
  4457. }
  4458. }
  4459. next = HEAP8[((textIndex+1)|0)];
  4460. }
  4461. if (precision < 0) {
  4462. precision = 6; // Standard default.
  4463. precisionSet = false;
  4464. }
  4465. // Handle integer sizes. WARNING: These assume a 32-bit architecture!
  4466. var argSize;
  4467. switch (String.fromCharCode(next)) {
  4468. case 'h':
  4469. var nextNext = HEAP8[((textIndex+2)|0)];
  4470. if (nextNext == 104) {
  4471. textIndex++;
  4472. argSize = 1; // char (actually i32 in varargs)
  4473. } else {
  4474. argSize = 2; // short (actually i32 in varargs)
  4475. }
  4476. break;
  4477. case 'l':
  4478. var nextNext = HEAP8[((textIndex+2)|0)];
  4479. if (nextNext == 108) {
  4480. textIndex++;
  4481. argSize = 8; // long long
  4482. } else {
  4483. argSize = 4; // long
  4484. }
  4485. break;
  4486. case 'L': // long long
  4487. case 'q': // int64_t
  4488. case 'j': // intmax_t
  4489. argSize = 8;
  4490. break;
  4491. case 'z': // size_t
  4492. case 't': // ptrdiff_t
  4493. case 'I': // signed ptrdiff_t or unsigned size_t
  4494. argSize = 4;
  4495. break;
  4496. default:
  4497. argSize = null;
  4498. }
  4499. if (argSize) textIndex++;
  4500. next = HEAP8[((textIndex+1)|0)];
  4501. // Handle type specifier.
  4502. switch (String.fromCharCode(next)) {
  4503. case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {
  4504. // Integer.
  4505. var signed = next == 100 || next == 105;
  4506. argSize = argSize || 4;
  4507. var currArg = getNextArg('i' + (argSize * 8));
  4508. var argText;
  4509. // Flatten i64-1 [low, high] into a (slightly rounded) double
  4510. if (argSize == 8) {
  4511. currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);
  4512. }
  4513. // Truncate to requested size.
  4514. if (argSize <= 4) {
  4515. var limit = Math.pow(256, argSize) - 1;
  4516. currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);
  4517. }
  4518. // Format the number.
  4519. var currAbsArg = Math.abs(currArg);
  4520. var prefix = '';
  4521. if (next == 100 || next == 105) {
  4522. argText = reSign(currArg, 8 * argSize, 1).toString(10);
  4523. } else if (next == 117) {
  4524. argText = unSign(currArg, 8 * argSize, 1).toString(10);
  4525. currArg = Math.abs(currArg);
  4526. } else if (next == 111) {
  4527. argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
  4528. } else if (next == 120 || next == 88) {
  4529. prefix = (flagAlternative && currArg != 0) ? '0x' : '';
  4530. if (currArg < 0) {
  4531. // Represent negative numbers in hex as 2's complement.
  4532. currArg = -currArg;
  4533. argText = (currAbsArg - 1).toString(16);
  4534. var buffer = [];
  4535. for (var i = 0; i < argText.length; i++) {
  4536. buffer.push((0xF - parseInt(argText[i], 16)).toString(16));
  4537. }
  4538. argText = buffer.join('');
  4539. while (argText.length < argSize * 2) argText = 'f' + argText;
  4540. } else {
  4541. argText = currAbsArg.toString(16);
  4542. }
  4543. if (next == 88) {
  4544. prefix = prefix.toUpperCase();
  4545. argText = argText.toUpperCase();
  4546. }
  4547. } else if (next == 112) {
  4548. if (currAbsArg === 0) {
  4549. argText = '(nil)';
  4550. } else {
  4551. prefix = '0x';
  4552. argText = currAbsArg.toString(16);
  4553. }
  4554. }
  4555. if (precisionSet) {
  4556. while (argText.length < precision) {
  4557. argText = '0' + argText;
  4558. }
  4559. }
  4560. // Add sign if needed
  4561. if (currArg >= 0) {
  4562. if (flagAlwaysSigned) {
  4563. prefix = '+' + prefix;
  4564. } else if (flagPadSign) {
  4565. prefix = ' ' + prefix;
  4566. }
  4567. }
  4568. // Move sign to prefix so we zero-pad after the sign
  4569. if (argText.charAt(0) == '-') {
  4570. prefix = '-' + prefix;
  4571. argText = argText.substr(1);
  4572. }
  4573. // Add padding.
  4574. while (prefix.length + argText.length < width) {
  4575. if (flagLeftAlign) {
  4576. argText += ' ';
  4577. } else {
  4578. if (flagZeroPad) {
  4579. argText = '0' + argText;
  4580. } else {
  4581. prefix = ' ' + prefix;
  4582. }
  4583. }
  4584. }
  4585. // Insert the result into the buffer.
  4586. argText = prefix + argText;
  4587. argText.split('').forEach(function(chr) {
  4588. ret.push(chr.charCodeAt(0));
  4589. });
  4590. break;
  4591. }
  4592. case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {
  4593. // Float.
  4594. var currArg = getNextArg('double');
  4595. var argText;
  4596. if (isNaN(currArg)) {
  4597. argText = 'nan';
  4598. flagZeroPad = false;
  4599. } else if (!isFinite(currArg)) {
  4600. argText = (currArg < 0 ? '-' : '') + 'inf';
  4601. flagZeroPad = false;
  4602. } else {
  4603. var isGeneral = false;
  4604. var effectivePrecision = Math.min(precision, 20);
  4605. // Convert g/G to f/F or e/E, as per:
  4606. // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html
  4607. if (next == 103 || next == 71) {
  4608. isGeneral = true;
  4609. precision = precision || 1;
  4610. var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);
  4611. if (precision > exponent && exponent >= -4) {
  4612. next = ((next == 103) ? 'f' : 'F').charCodeAt(0);
  4613. precision -= exponent + 1;
  4614. } else {
  4615. next = ((next == 103) ? 'e' : 'E').charCodeAt(0);
  4616. precision--;
  4617. }
  4618. effectivePrecision = Math.min(precision, 20);
  4619. }
  4620. if (next == 101 || next == 69) {
  4621. argText = currArg.toExponential(effectivePrecision);
  4622. // Make sure the exponent has at least 2 digits.
  4623. if (/[eE][-+]\d$/.test(argText)) {
  4624. argText = argText.slice(0, -1) + '0' + argText.slice(-1);
  4625. }
  4626. } else if (next == 102 || next == 70) {
  4627. argText = currArg.toFixed(effectivePrecision);
  4628. if (currArg === 0 && __reallyNegative(currArg)) {
  4629. argText = '-' + argText;
  4630. }
  4631. }
  4632. var parts = argText.split('e');
  4633. if (isGeneral && !flagAlternative) {
  4634. // Discard trailing zeros and periods.
  4635. while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&
  4636. (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {
  4637. parts[0] = parts[0].slice(0, -1);
  4638. }
  4639. } else {
  4640. // Make sure we have a period in alternative mode.
  4641. if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';
  4642. // Zero pad until required precision.
  4643. while (precision > effectivePrecision++) parts[0] += '0';
  4644. }
  4645. argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');
  4646. // Capitalize 'E' if needed.
  4647. if (next == 69) argText = argText.toUpperCase();
  4648. // Add sign.
  4649. if (currArg >= 0) {
  4650. if (flagAlwaysSigned) {
  4651. argText = '+' + argText;
  4652. } else if (flagPadSign) {
  4653. argText = ' ' + argText;
  4654. }
  4655. }
  4656. }
  4657. // Add padding.
  4658. while (argText.length < width) {
  4659. if (flagLeftAlign) {
  4660. argText += ' ';
  4661. } else {
  4662. if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {
  4663. argText = argText[0] + '0' + argText.slice(1);
  4664. } else {
  4665. argText = (flagZeroPad ? '0' : ' ') + argText;
  4666. }
  4667. }
  4668. }
  4669. // Adjust case.
  4670. if (next < 97) argText = argText.toUpperCase();
  4671. // Insert the result into the buffer.
  4672. argText.split('').forEach(function(chr) {
  4673. ret.push(chr.charCodeAt(0));
  4674. });
  4675. break;
  4676. }
  4677. case 's': {
  4678. // String.
  4679. var arg = getNextArg('i8*');
  4680. var argLength = arg ? _strlen(arg) : '(null)'.length;
  4681. if (precisionSet) argLength = Math.min(argLength, precision);
  4682. if (!flagLeftAlign) {
  4683. while (argLength < width--) {
  4684. ret.push(32);
  4685. }
  4686. }
  4687. if (arg) {
  4688. for (var i = 0; i < argLength; i++) {
  4689. ret.push(HEAPU8[((arg++)|0)]);
  4690. }
  4691. } else {
  4692. ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));
  4693. }
  4694. if (flagLeftAlign) {
  4695. while (argLength < width--) {
  4696. ret.push(32);
  4697. }
  4698. }
  4699. break;
  4700. }
  4701. case 'c': {
  4702. // Character.
  4703. if (flagLeftAlign) ret.push(getNextArg('i8'));
  4704. while (--width > 0) {
  4705. ret.push(32);
  4706. }
  4707. if (!flagLeftAlign) ret.push(getNextArg('i8'));
  4708. break;
  4709. }
  4710. case 'n': {
  4711. // Write the length written so far to the next parameter.
  4712. var ptr = getNextArg('i32*');
  4713. HEAP32[((ptr)>>2)]=ret.length;
  4714. break;
  4715. }
  4716. case '%': {
  4717. // Literal percent sign.
  4718. ret.push(curr);
  4719. break;
  4720. }
  4721. default: {
  4722. // Unknown specifiers remain untouched.
  4723. for (var i = startTextIndex; i < textIndex + 2; i++) {
  4724. ret.push(HEAP8[(i)]);
  4725. }
  4726. }
  4727. }
  4728. textIndex += 2;
  4729. // TODO: Support a/A (hex float) and m (last error) specifiers.
  4730. // TODO: Support %1${specifier} for arg selection.
  4731. } else {
  4732. ret.push(curr);
  4733. textIndex += 1;
  4734. }
  4735. }
  4736. return ret;
  4737. }function _fprintf(stream, format, varargs) {
  4738. // int fprintf(FILE *restrict stream, const char *restrict format, ...);
  4739. // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
  4740. var result = __formatString(format, varargs);
  4741. var stack = Runtime.stackSave();
  4742. var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);
  4743. Runtime.stackRestore(stack);
  4744. return ret;
  4745. }function _printf(format, varargs) {
  4746. // int printf(const char *restrict format, ...);
  4747. // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html
  4748. var stdout = HEAP32[((_stdout)>>2)];
  4749. return _fprintf(stdout, format, varargs);
  4750. }
  4751. var _sinf=Math_sin;
  4752. var _sqrtf=Math_sqrt;
  4753. var _floorf=Math_floor;
  4754. function _fputs(s, stream) {
  4755. // int fputs(const char *restrict s, FILE *restrict stream);
  4756. // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html
  4757. var fd = _fileno(stream);
  4758. return _write(fd, s, _strlen(s));
  4759. }
  4760. function _fputc(c, stream) {
  4761. // int fputc(int c, FILE *stream);
  4762. // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html
  4763. var chr = unSign(c & 0xFF);
  4764. HEAP8[((_fputc.ret)|0)]=chr;
  4765. var fd = _fileno(stream);
  4766. var ret = _write(fd, _fputc.ret, 1);
  4767. if (ret == -1) {
  4768. var streamObj = FS.getStreamFromPtr(stream);
  4769. if (streamObj) streamObj.error = true;
  4770. return -1;
  4771. } else {
  4772. return chr;
  4773. }
  4774. }function _puts(s) {
  4775. // int puts(const char *s);
  4776. // http://pubs.opengroup.org/onlinepubs/000095399/functions/puts.html
  4777. // NOTE: puts() always writes an extra newline.
  4778. var stdout = HEAP32[((_stdout)>>2)];
  4779. var ret = _fputs(s, stdout);
  4780. if (ret < 0) {
  4781. return ret;
  4782. } else {
  4783. var newlineRet = _fputc(10, stdout);
  4784. return (newlineRet < 0) ? -1 : ret + 1;
  4785. }
  4786. }
  4787. function _clock() {
  4788. if (_clock.start === undefined) _clock.start = Date.now();
  4789. return Math.floor((Date.now() - _clock.start) * (1000000/1000));
  4790. }
  4791. var ___cxa_caught_exceptions=[];function ___cxa_begin_catch(ptr) {
  4792. __ZSt18uncaught_exceptionv.uncaught_exception--;
  4793. ___cxa_caught_exceptions.push(___cxa_last_thrown_exception);
  4794. return ptr;
  4795. }
  4796. function ___errno_location() {
  4797. return ___errno_state;
  4798. }
  4799. function _emscripten_memcpy_big(dest, src, num) {
  4800. HEAPU8.set(HEAPU8.subarray(src, src+num), dest);
  4801. return dest;
  4802. }
  4803. Module["_memcpy"] = _memcpy;
  4804. function __ZNSt9exceptionD2Ev() {}
  4805. var Browser={mainLoop:{scheduler:null,method:"",shouldPause:false,paused:false,queue:[],pause:function () {
  4806. Browser.mainLoop.shouldPause = true;
  4807. },resume:function () {
  4808. if (Browser.mainLoop.paused) {
  4809. Browser.mainLoop.paused = false;
  4810. Browser.mainLoop.scheduler();
  4811. }
  4812. Browser.mainLoop.shouldPause = false;
  4813. },updateStatus:function () {
  4814. if (Module['setStatus']) {
  4815. var message = Module['statusMessage'] || 'Please wait...';
  4816. var remaining = Browser.mainLoop.remainingBlockers;
  4817. var expected = Browser.mainLoop.expectedBlockers;
  4818. if (remaining) {
  4819. if (remaining < expected) {
  4820. Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');
  4821. } else {
  4822. Module['setStatus'](message);
  4823. }
  4824. } else {
  4825. Module['setStatus']('');
  4826. }
  4827. }
  4828. }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {
  4829. if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers
  4830. if (Browser.initted || ENVIRONMENT_IS_WORKER) return;
  4831. Browser.initted = true;
  4832. try {
  4833. new Blob();
  4834. Browser.hasBlobConstructor = true;
  4835. } catch(e) {
  4836. Browser.hasBlobConstructor = false;
  4837. console.log("warning: no blob constructor, cannot create blobs with mimetypes");
  4838. }
  4839. Browser.BlobBuilder = typeof MozBlobBuilder != "undefined" ? MozBlobBuilder : (typeof WebKitBlobBuilder != "undefined" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log("warning: no BlobBuilder") : null));
  4840. Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
  4841. if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {
  4842. console.log("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
  4843. Module.noImageDecoding = true;
  4844. }
  4845. // Support for plugins that can process preloaded files. You can add more of these to
  4846. // your app by creating and appending to Module.preloadPlugins.
  4847. //
  4848. // Each plugin is asked if it can handle a file based on the file's name. If it can,
  4849. // it is given the file's raw data. When it is done, it calls a callback with the file's
  4850. // (possibly modified) data. For example, a plugin might decompress a file, or it
  4851. // might create some side data structure for use later (like an Image element, etc.).
  4852. var imagePlugin = {};
  4853. imagePlugin['canHandle'] = function imagePlugin_canHandle(name) {
  4854. return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name);
  4855. };
  4856. imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) {
  4857. var b = null;
  4858. if (Browser.hasBlobConstructor) {
  4859. try {
  4860. b = new Blob([byteArray], { type: Browser.getMimetype(name) });
  4861. if (b.size !== byteArray.length) { // Safari bug #118630
  4862. // Safari's Blob can only take an ArrayBuffer
  4863. b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
  4864. }
  4865. } catch(e) {
  4866. Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');
  4867. }
  4868. }
  4869. if (!b) {
  4870. var bb = new Browser.BlobBuilder();
  4871. bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range
  4872. b = bb.getBlob();
  4873. }
  4874. var url = Browser.URLObject.createObjectURL(b);
  4875. var img = new Image();
  4876. img.onload = function img_onload() {
  4877. assert(img.complete, 'Image ' + name + ' could not be decoded');
  4878. var canvas = document.createElement('canvas');
  4879. canvas.width = img.width;
  4880. canvas.height = img.height;
  4881. var ctx = canvas.getContext('2d');
  4882. ctx.drawImage(img, 0, 0);
  4883. Module["preloadedImages"][name] = canvas;
  4884. Browser.URLObject.revokeObjectURL(url);
  4885. if (onload) onload(byteArray);
  4886. };
  4887. img.onerror = function img_onerror(event) {
  4888. console.log('Image ' + url + ' could not be decoded');
  4889. if (onerror) onerror();
  4890. };
  4891. img.src = url;
  4892. };
  4893. Module['preloadPlugins'].push(imagePlugin);
  4894. var audioPlugin = {};
  4895. audioPlugin['canHandle'] = function audioPlugin_canHandle(name) {
  4896. return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };
  4897. };
  4898. audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) {
  4899. var done = false;
  4900. function finish(audio) {
  4901. if (done) return;
  4902. done = true;
  4903. Module["preloadedAudios"][name] = audio;
  4904. if (onload) onload(byteArray);
  4905. }
  4906. function fail() {
  4907. if (done) return;
  4908. done = true;
  4909. Module["preloadedAudios"][name] = new Audio(); // empty shim
  4910. if (onerror) onerror();
  4911. }
  4912. if (Browser.hasBlobConstructor) {
  4913. try {
  4914. var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
  4915. } catch(e) {
  4916. return fail();
  4917. }
  4918. var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
  4919. var audio = new Audio();
  4920. audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926
  4921. audio.onerror = function audio_onerror(event) {
  4922. if (done) return;
  4923. console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');
  4924. function encode64(data) {
  4925. var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  4926. var PAD = '=';
  4927. var ret = '';
  4928. var leftchar = 0;
  4929. var leftbits = 0;
  4930. for (var i = 0; i < data.length; i++) {
  4931. leftchar = (leftchar << 8) | data[i];
  4932. leftbits += 8;
  4933. while (leftbits >= 6) {
  4934. var curr = (leftchar >> (leftbits-6)) & 0x3f;
  4935. leftbits -= 6;
  4936. ret += BASE[curr];
  4937. }
  4938. }
  4939. if (leftbits == 2) {
  4940. ret += BASE[(leftchar&3) << 4];
  4941. ret += PAD + PAD;
  4942. } else if (leftbits == 4) {
  4943. ret += BASE[(leftchar&0xf) << 2];
  4944. ret += PAD;
  4945. }
  4946. return ret;
  4947. }
  4948. audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);
  4949. finish(audio); // we don't wait for confirmation this worked - but it's worth trying
  4950. };
  4951. audio.src = url;
  4952. // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror
  4953. Browser.safeSetTimeout(function() {
  4954. finish(audio); // try to use it even though it is not necessarily ready to play
  4955. }, 10000);
  4956. } else {
  4957. return fail();
  4958. }
  4959. };
  4960. Module['preloadPlugins'].push(audioPlugin);
  4961. // Canvas event setup
  4962. var canvas = Module['canvas'];
  4963. // forced aspect ratio can be enabled by defining 'forcedAspectRatio' on Module
  4964. // Module['forcedAspectRatio'] = 4 / 3;
  4965. canvas.requestPointerLock = canvas['requestPointerLock'] ||
  4966. canvas['mozRequestPointerLock'] ||
  4967. canvas['webkitRequestPointerLock'] ||
  4968. canvas['msRequestPointerLock'] ||
  4969. function(){};
  4970. canvas.exitPointerLock = document['exitPointerLock'] ||
  4971. document['mozExitPointerLock'] ||
  4972. document['webkitExitPointerLock'] ||
  4973. document['msExitPointerLock'] ||
  4974. function(){}; // no-op if function does not exist
  4975. canvas.exitPointerLock = canvas.exitPointerLock.bind(document);
  4976. function pointerLockChange() {
  4977. Browser.pointerLock = document['pointerLockElement'] === canvas ||
  4978. document['mozPointerLockElement'] === canvas ||
  4979. document['webkitPointerLockElement'] === canvas ||
  4980. document['msPointerLockElement'] === canvas;
  4981. }
  4982. document.addEventListener('pointerlockchange', pointerLockChange, false);
  4983. document.addEventListener('mozpointerlockchange', pointerLockChange, false);
  4984. document.addEventListener('webkitpointerlockchange', pointerLockChange, false);
  4985. document.addEventListener('mspointerlockchange', pointerLockChange, false);
  4986. if (Module['elementPointerLock']) {
  4987. canvas.addEventListener("click", function(ev) {
  4988. if (!Browser.pointerLock && canvas.requestPointerLock) {
  4989. canvas.requestPointerLock();
  4990. ev.preventDefault();
  4991. }
  4992. }, false);
  4993. }
  4994. },createContext:function (canvas, useWebGL, setInModule, webGLContextAttributes) {
  4995. var ctx;
  4996. var errorInfo = '?';
  4997. function onContextCreationError(event) {
  4998. errorInfo = event.statusMessage || errorInfo;
  4999. }
  5000. try {
  5001. if (useWebGL) {
  5002. var contextAttributes = {
  5003. antialias: false,
  5004. alpha: false
  5005. };
  5006. if (webGLContextAttributes) {
  5007. for (var attribute in webGLContextAttributes) {
  5008. contextAttributes[attribute] = webGLContextAttributes[attribute];
  5009. }
  5010. }
  5011. canvas.addEventListener('webglcontextcreationerror', onContextCreationError, false);
  5012. try {
  5013. ['experimental-webgl', 'webgl'].some(function(webglId) {
  5014. return ctx = canvas.getContext(webglId, contextAttributes);
  5015. });
  5016. } finally {
  5017. canvas.removeEventListener('webglcontextcreationerror', onContextCreationError, false);
  5018. }
  5019. } else {
  5020. ctx = canvas.getContext('2d');
  5021. }
  5022. if (!ctx) throw ':(';
  5023. } catch (e) {
  5024. Module.print('Could not create canvas: ' + [errorInfo, e]);
  5025. return null;
  5026. }
  5027. if (useWebGL) {
  5028. // Set the background of the WebGL canvas to black
  5029. canvas.style.backgroundColor = "black";
  5030. // Warn on context loss
  5031. canvas.addEventListener('webglcontextlost', function(event) {
  5032. alert('WebGL context lost. You will need to reload the page.');
  5033. }, false);
  5034. }
  5035. if (setInModule) {
  5036. GLctx = Module.ctx = ctx;
  5037. Module.useWebGL = useWebGL;
  5038. Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
  5039. Browser.init();
  5040. }
  5041. return ctx;
  5042. },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {
  5043. Browser.lockPointer = lockPointer;
  5044. Browser.resizeCanvas = resizeCanvas;
  5045. if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;
  5046. if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;
  5047. var canvas = Module['canvas'];
  5048. function fullScreenChange() {
  5049. Browser.isFullScreen = false;
  5050. var canvasContainer = canvas.parentNode;
  5051. if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
  5052. document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
  5053. document['fullScreenElement'] || document['fullscreenElement'] ||
  5054. document['msFullScreenElement'] || document['msFullscreenElement'] ||
  5055. document['webkitCurrentFullScreenElement']) === canvasContainer) {
  5056. canvas.cancelFullScreen = document['cancelFullScreen'] ||
  5057. document['mozCancelFullScreen'] ||
  5058. document['webkitCancelFullScreen'] ||
  5059. document['msExitFullscreen'] ||
  5060. document['exitFullscreen'] ||
  5061. function() {};
  5062. canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);
  5063. if (Browser.lockPointer) canvas.requestPointerLock();
  5064. Browser.isFullScreen = true;
  5065. if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();
  5066. } else {
  5067. // remove the full screen specific parent of the canvas again to restore the HTML structure from before going full screen
  5068. canvasContainer.parentNode.insertBefore(canvas, canvasContainer);
  5069. canvasContainer.parentNode.removeChild(canvasContainer);
  5070. if (Browser.resizeCanvas) Browser.setWindowedCanvasSize();
  5071. }
  5072. if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);
  5073. Browser.updateCanvasDimensions(canvas);
  5074. }
  5075. if (!Browser.fullScreenHandlersInstalled) {
  5076. Browser.fullScreenHandlersInstalled = true;
  5077. document.addEventListener('fullscreenchange', fullScreenChange, false);
  5078. document.addEventListener('mozfullscreenchange', fullScreenChange, false);
  5079. document.addEventListener('webkitfullscreenchange', fullScreenChange, false);
  5080. document.addEventListener('MSFullscreenChange', fullScreenChange, false);
  5081. }
  5082. // create a new parent to ensure the canvas has no siblings. this allows browsers to optimize full screen performance when its parent is the full screen root
  5083. var canvasContainer = document.createElement("div");
  5084. canvas.parentNode.insertBefore(canvasContainer, canvas);
  5085. canvasContainer.appendChild(canvas);
  5086. // use parent of canvas as full screen root to allow aspect ratio correction (Firefox stretches the root to screen size)
  5087. canvasContainer.requestFullScreen = canvasContainer['requestFullScreen'] ||
  5088. canvasContainer['mozRequestFullScreen'] ||
  5089. canvasContainer['msRequestFullscreen'] ||
  5090. (canvasContainer['webkitRequestFullScreen'] ? function() { canvasContainer['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);
  5091. canvasContainer.requestFullScreen();
  5092. },requestAnimationFrame:function requestAnimationFrame(func) {
  5093. if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
  5094. setTimeout(func, 1000/60);
  5095. } else {
  5096. if (!window.requestAnimationFrame) {
  5097. window.requestAnimationFrame = window['requestAnimationFrame'] ||
  5098. window['mozRequestAnimationFrame'] ||
  5099. window['webkitRequestAnimationFrame'] ||
  5100. window['msRequestAnimationFrame'] ||
  5101. window['oRequestAnimationFrame'] ||
  5102. window['setTimeout'];
  5103. }
  5104. window.requestAnimationFrame(func);
  5105. }
  5106. },safeCallback:function (func) {
  5107. return function() {
  5108. if (!ABORT) return func.apply(null, arguments);
  5109. };
  5110. },safeRequestAnimationFrame:function (func) {
  5111. return Browser.requestAnimationFrame(function() {
  5112. if (!ABORT) func();
  5113. });
  5114. },safeSetTimeout:function (func, timeout) {
  5115. return setTimeout(function() {
  5116. if (!ABORT) func();
  5117. }, timeout);
  5118. },safeSetInterval:function (func, timeout) {
  5119. return setInterval(function() {
  5120. if (!ABORT) func();
  5121. }, timeout);
  5122. },getMimetype:function (name) {
  5123. return {
  5124. 'jpg': 'image/jpeg',
  5125. 'jpeg': 'image/jpeg',
  5126. 'png': 'image/png',
  5127. 'bmp': 'image/bmp',
  5128. 'ogg': 'audio/ogg',
  5129. 'wav': 'audio/wav',
  5130. 'mp3': 'audio/mpeg'
  5131. }[name.substr(name.lastIndexOf('.')+1)];
  5132. },getUserMedia:function (func) {
  5133. if(!window.getUserMedia) {
  5134. window.getUserMedia = navigator['getUserMedia'] ||
  5135. navigator['mozGetUserMedia'];
  5136. }
  5137. window.getUserMedia(func);
  5138. },getMovementX:function (event) {
  5139. return event['movementX'] ||
  5140. event['mozMovementX'] ||
  5141. event['webkitMovementX'] ||
  5142. 0;
  5143. },getMovementY:function (event) {
  5144. return event['movementY'] ||
  5145. event['mozMovementY'] ||
  5146. event['webkitMovementY'] ||
  5147. 0;
  5148. },getMouseWheelDelta:function (event) {
  5149. return Math.max(-1, Math.min(1, event.type === 'DOMMouseScroll' ? event.detail : -event.wheelDelta));
  5150. },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup
  5151. if (Browser.pointerLock) {
  5152. // When the pointer is locked, calculate the coordinates
  5153. // based on the movement of the mouse.
  5154. // Workaround for Firefox bug 764498
  5155. if (event.type != 'mousemove' &&
  5156. ('mozMovementX' in event)) {
  5157. Browser.mouseMovementX = Browser.mouseMovementY = 0;
  5158. } else {
  5159. Browser.mouseMovementX = Browser.getMovementX(event);
  5160. Browser.mouseMovementY = Browser.getMovementY(event);
  5161. }
  5162. // check if SDL is available
  5163. if (typeof SDL != "undefined") {
  5164. Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
  5165. Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
  5166. } else {
  5167. // just add the mouse delta to the current absolut mouse position
  5168. // FIXME: ideally this should be clamped against the canvas size and zero
  5169. Browser.mouseX += Browser.mouseMovementX;
  5170. Browser.mouseY += Browser.mouseMovementY;
  5171. }
  5172. } else {
  5173. // Otherwise, calculate the movement based on the changes
  5174. // in the coordinates.
  5175. var rect = Module["canvas"].getBoundingClientRect();
  5176. var x, y;
  5177. // Neither .scrollX or .pageXOffset are defined in a spec, but
  5178. // we prefer .scrollX because it is currently in a spec draft.
  5179. // (see: http://www.w3.org/TR/2013/WD-cssom-view-20131217/)
  5180. var scrollX = ((typeof window.scrollX !== 'undefined') ? window.scrollX : window.pageXOffset);
  5181. var scrollY = ((typeof window.scrollY !== 'undefined') ? window.scrollY : window.pageYOffset);
  5182. if (event.type == 'touchstart' ||
  5183. event.type == 'touchend' ||
  5184. event.type == 'touchmove') {
  5185. var t = event.touches.item(0);
  5186. if (t) {
  5187. x = t.pageX - (scrollX + rect.left);
  5188. y = t.pageY - (scrollY + rect.top);
  5189. } else {
  5190. return;
  5191. }
  5192. } else {
  5193. x = event.pageX - (scrollX + rect.left);
  5194. y = event.pageY - (scrollY + rect.top);
  5195. }
  5196. // the canvas might be CSS-scaled compared to its backbuffer;
  5197. // SDL-using content will want mouse coordinates in terms
  5198. // of backbuffer units.
  5199. var cw = Module["canvas"].width;
  5200. var ch = Module["canvas"].height;
  5201. x = x * (cw / rect.width);
  5202. y = y * (ch / rect.height);
  5203. Browser.mouseMovementX = x - Browser.mouseX;
  5204. Browser.mouseMovementY = y - Browser.mouseY;
  5205. Browser.mouseX = x;
  5206. Browser.mouseY = y;
  5207. }
  5208. },xhrLoad:function (url, onload, onerror) {
  5209. var xhr = new XMLHttpRequest();
  5210. xhr.open('GET', url, true);
  5211. xhr.responseType = 'arraybuffer';
  5212. xhr.onload = function xhr_onload() {
  5213. if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
  5214. onload(xhr.response);
  5215. } else {
  5216. onerror();
  5217. }
  5218. };
  5219. xhr.onerror = onerror;
  5220. xhr.send(null);
  5221. },asyncLoad:function (url, onload, onerror, noRunDep) {
  5222. Browser.xhrLoad(url, function(arrayBuffer) {
  5223. assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
  5224. onload(new Uint8Array(arrayBuffer));
  5225. if (!noRunDep) removeRunDependency('al ' + url);
  5226. }, function(event) {
  5227. if (onerror) {
  5228. onerror();
  5229. } else {
  5230. throw 'Loading data file "' + url + '" failed.';
  5231. }
  5232. });
  5233. if (!noRunDep) addRunDependency('al ' + url);
  5234. },resizeListeners:[],updateResizeListeners:function () {
  5235. var canvas = Module['canvas'];
  5236. Browser.resizeListeners.forEach(function(listener) {
  5237. listener(canvas.width, canvas.height);
  5238. });
  5239. },setCanvasSize:function (width, height, noUpdates) {
  5240. var canvas = Module['canvas'];
  5241. Browser.updateCanvasDimensions(canvas, width, height);
  5242. if (!noUpdates) Browser.updateResizeListeners();
  5243. },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {
  5244. // check if SDL is available
  5245. if (typeof SDL != "undefined") {
  5246. var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
  5247. flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
  5248. HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
  5249. }
  5250. Browser.updateResizeListeners();
  5251. },setWindowedCanvasSize:function () {
  5252. // check if SDL is available
  5253. if (typeof SDL != "undefined") {
  5254. var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];
  5255. flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
  5256. HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags
  5257. }
  5258. Browser.updateResizeListeners();
  5259. },updateCanvasDimensions:function (canvas, wNative, hNative) {
  5260. if (wNative && hNative) {
  5261. canvas.widthNative = wNative;
  5262. canvas.heightNative = hNative;
  5263. } else {
  5264. wNative = canvas.widthNative;
  5265. hNative = canvas.heightNative;
  5266. }
  5267. var w = wNative;
  5268. var h = hNative;
  5269. if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
  5270. if (w/h < Module['forcedAspectRatio']) {
  5271. w = Math.round(h * Module['forcedAspectRatio']);
  5272. } else {
  5273. h = Math.round(w / Module['forcedAspectRatio']);
  5274. }
  5275. }
  5276. if (((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||
  5277. document['mozFullScreenElement'] || document['mozFullscreenElement'] ||
  5278. document['fullScreenElement'] || document['fullscreenElement'] ||
  5279. document['msFullScreenElement'] || document['msFullscreenElement'] ||
  5280. document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
  5281. var factor = Math.min(screen.width / w, screen.height / h);
  5282. w = Math.round(w * factor);
  5283. h = Math.round(h * factor);
  5284. }
  5285. if (Browser.resizeCanvas) {
  5286. if (canvas.width != w) canvas.width = w;
  5287. if (canvas.height != h) canvas.height = h;
  5288. if (typeof canvas.style != 'undefined') {
  5289. canvas.style.removeProperty( "width");
  5290. canvas.style.removeProperty("height");
  5291. }
  5292. } else {
  5293. if (canvas.width != wNative) canvas.width = wNative;
  5294. if (canvas.height != hNative) canvas.height = hNative;
  5295. if (typeof canvas.style != 'undefined') {
  5296. if (w != wNative || h != hNative) {
  5297. canvas.style.setProperty( "width", w + "px", "important");
  5298. canvas.style.setProperty("height", h + "px", "important");
  5299. } else {
  5300. canvas.style.removeProperty( "width");
  5301. canvas.style.removeProperty("height");
  5302. }
  5303. }
  5304. }
  5305. }};
  5306. function _sbrk(bytes) {
  5307. // Implement a Linux-like 'memory area' for our 'process'.
  5308. // Changes the size of the memory area by |bytes|; returns the
  5309. // address of the previous top ('break') of the memory area
  5310. // We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
  5311. var self = _sbrk;
  5312. if (!self.called) {
  5313. DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
  5314. self.called = true;
  5315. assert(Runtime.dynamicAlloc);
  5316. self.alloc = Runtime.dynamicAlloc;
  5317. Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
  5318. }
  5319. var ret = DYNAMICTOP;
  5320. if (bytes != 0) self.alloc(bytes);
  5321. return ret; // Previous break location.
  5322. }
  5323. function _sysconf(name) {
  5324. // long sysconf(int name);
  5325. // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html
  5326. switch(name) {
  5327. case 30: return PAGE_SIZE;
  5328. case 132:
  5329. case 133:
  5330. case 12:
  5331. case 137:
  5332. case 138:
  5333. case 15:
  5334. case 235:
  5335. case 16:
  5336. case 17:
  5337. case 18:
  5338. case 19:
  5339. case 20:
  5340. case 149:
  5341. case 13:
  5342. case 10:
  5343. case 236:
  5344. case 153:
  5345. case 9:
  5346. case 21:
  5347. case 22:
  5348. case 159:
  5349. case 154:
  5350. case 14:
  5351. case 77:
  5352. case 78:
  5353. case 139:
  5354. case 80:
  5355. case 81:
  5356. case 79:
  5357. case 82:
  5358. case 68:
  5359. case 67:
  5360. case 164:
  5361. case 11:
  5362. case 29:
  5363. case 47:
  5364. case 48:
  5365. case 95:
  5366. case 52:
  5367. case 51:
  5368. case 46:
  5369. return 200809;
  5370. case 27:
  5371. case 246:
  5372. case 127:
  5373. case 128:
  5374. case 23:
  5375. case 24:
  5376. case 160:
  5377. case 161:
  5378. case 181:
  5379. case 182:
  5380. case 242:
  5381. case 183:
  5382. case 184:
  5383. case 243:
  5384. case 244:
  5385. case 245:
  5386. case 165:
  5387. case 178:
  5388. case 179:
  5389. case 49:
  5390. case 50:
  5391. case 168:
  5392. case 169:
  5393. case 175:
  5394. case 170:
  5395. case 171:
  5396. case 172:
  5397. case 97:
  5398. case 76:
  5399. case 32:
  5400. case 173:
  5401. case 35:
  5402. return -1;
  5403. case 176:
  5404. case 177:
  5405. case 7:
  5406. case 155:
  5407. case 8:
  5408. case 157:
  5409. case 125:
  5410. case 126:
  5411. case 92:
  5412. case 93:
  5413. case 129:
  5414. case 130:
  5415. case 131:
  5416. case 94:
  5417. case 91:
  5418. return 1;
  5419. case 74:
  5420. case 60:
  5421. case 69:
  5422. case 70:
  5423. case 4:
  5424. return 1024;
  5425. case 31:
  5426. case 42:
  5427. case 72:
  5428. return 32;
  5429. case 87:
  5430. case 26:
  5431. case 33:
  5432. return 2147483647;
  5433. case 34:
  5434. case 1:
  5435. return 47839;
  5436. case 38:
  5437. case 36:
  5438. return 99;
  5439. case 43:
  5440. case 37:
  5441. return 2048;
  5442. case 0: return 2097152;
  5443. case 3: return 65536;
  5444. case 28: return 32768;
  5445. case 44: return 32767;
  5446. case 75: return 16384;
  5447. case 39: return 1000;
  5448. case 89: return 700;
  5449. case 71: return 256;
  5450. case 40: return 255;
  5451. case 2: return 100;
  5452. case 180: return 64;
  5453. case 25: return 20;
  5454. case 5: return 16;
  5455. case 6: return 6;
  5456. case 73: return 4;
  5457. case 84: return 1;
  5458. }
  5459. ___setErrNo(ERRNO_CODES.EINVAL);
  5460. return -1;
  5461. }
  5462. function _emscripten_run_script(ptr) {
  5463. eval(Pointer_stringify(ptr));
  5464. }
  5465. function _malloc(bytes) {
  5466. /* Over-allocate to make sure it is byte-aligned by 8.
  5467. * This will leak memory, but this is only the dummy
  5468. * implementation (replaced by dlmalloc normally) so
  5469. * not an issue.
  5470. */
  5471. var ptr = Runtime.dynamicAlloc(bytes + 8);
  5472. return (ptr+8) & 0xFFFFFFF8;
  5473. }
  5474. Module["_malloc"] = _malloc;function ___cxa_allocate_exception(size) {
  5475. var ptr = _malloc(size + ___cxa_exception_header_size);
  5476. return ptr + ___cxa_exception_header_size;
  5477. }
  5478. function _emscripten_cancel_main_loop() {
  5479. Browser.mainLoop.scheduler = null;
  5480. Browser.mainLoop.shouldPause = true;
  5481. }
  5482. var __ZTISt9exception=allocate([allocate([1,0,0,0,0,0,0], "i8", ALLOC_STATIC)+8, 0], "i32", ALLOC_STATIC);
  5483. FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module["noFSInit"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module["FS_createFolder"] = FS.createFolder;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createLink"] = FS.createLink;Module["FS_createDevice"] = FS.createDevice;
  5484. ___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;
  5485. __ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();
  5486. if (ENVIRONMENT_IS_NODE) { var fs = require("fs"); NODEFS.staticInit(); }
  5487. __ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });
  5488. _fputc.ret = allocate([0], "i8", ALLOC_STATIC);
  5489. Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };
  5490. Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };
  5491. Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };
  5492. Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };
  5493. Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
  5494. Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }
  5495. STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);
  5496. staticSealed = true; // seal the static portion of memory
  5497. STACK_MAX = STACK_BASE + 5242880;
  5498. DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);
  5499. assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");
  5500. var Math_min = Math.min;
  5501. function invoke_iiii(index,a1,a2,a3) {
  5502. try {
  5503. return Module["dynCall_iiii"](index,a1,a2,a3);
  5504. } catch(e) {
  5505. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5506. asm["setThrew"](1, 0);
  5507. }
  5508. }
  5509. function invoke_viiiii(index,a1,a2,a3,a4,a5) {
  5510. try {
  5511. Module["dynCall_viiiii"](index,a1,a2,a3,a4,a5);
  5512. } catch(e) {
  5513. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5514. asm["setThrew"](1, 0);
  5515. }
  5516. }
  5517. function invoke_vi(index,a1) {
  5518. try {
  5519. Module["dynCall_vi"](index,a1);
  5520. } catch(e) {
  5521. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5522. asm["setThrew"](1, 0);
  5523. }
  5524. }
  5525. function invoke_vii(index,a1,a2) {
  5526. try {
  5527. Module["dynCall_vii"](index,a1,a2);
  5528. } catch(e) {
  5529. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5530. asm["setThrew"](1, 0);
  5531. }
  5532. }
  5533. function invoke_ii(index,a1) {
  5534. try {
  5535. return Module["dynCall_ii"](index,a1);
  5536. } catch(e) {
  5537. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5538. asm["setThrew"](1, 0);
  5539. }
  5540. }
  5541. function invoke_viii(index,a1,a2,a3) {
  5542. try {
  5543. Module["dynCall_viii"](index,a1,a2,a3);
  5544. } catch(e) {
  5545. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5546. asm["setThrew"](1, 0);
  5547. }
  5548. }
  5549. function invoke_v(index) {
  5550. try {
  5551. Module["dynCall_v"](index);
  5552. } catch(e) {
  5553. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5554. asm["setThrew"](1, 0);
  5555. }
  5556. }
  5557. function invoke_viid(index,a1,a2,a3) {
  5558. try {
  5559. Module["dynCall_viid"](index,a1,a2,a3);
  5560. } catch(e) {
  5561. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5562. asm["setThrew"](1, 0);
  5563. }
  5564. }
  5565. function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6) {
  5566. try {
  5567. Module["dynCall_viiiiii"](index,a1,a2,a3,a4,a5,a6);
  5568. } catch(e) {
  5569. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5570. asm["setThrew"](1, 0);
  5571. }
  5572. }
  5573. function invoke_iii(index,a1,a2) {
  5574. try {
  5575. return Module["dynCall_iii"](index,a1,a2);
  5576. } catch(e) {
  5577. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5578. asm["setThrew"](1, 0);
  5579. }
  5580. }
  5581. function invoke_iiiiii(index,a1,a2,a3,a4,a5) {
  5582. try {
  5583. return Module["dynCall_iiiiii"](index,a1,a2,a3,a4,a5);
  5584. } catch(e) {
  5585. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5586. asm["setThrew"](1, 0);
  5587. }
  5588. }
  5589. function invoke_viiii(index,a1,a2,a3,a4) {
  5590. try {
  5591. Module["dynCall_viiii"](index,a1,a2,a3,a4);
  5592. } catch(e) {
  5593. if (typeof e !== 'number' && e !== 'longjmp') throw e;
  5594. asm["setThrew"](1, 0);
  5595. }
  5596. }
  5597. function asmPrintInt(x, y) {
  5598. Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);
  5599. }
  5600. function asmPrintFloat(x, y) {
  5601. Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);
  5602. }
  5603. // EMSCRIPTEN_START_ASM
  5604. var asm = (function(global, env, buffer) {
  5605. 'use asm';
  5606. var HEAP8 = new global.Int8Array(buffer);
  5607. var HEAP16 = new global.Int16Array(buffer);
  5608. var HEAP32 = new global.Int32Array(buffer);
  5609. var HEAPU8 = new global.Uint8Array(buffer);
  5610. var HEAPU16 = new global.Uint16Array(buffer);
  5611. var HEAPU32 = new global.Uint32Array(buffer);
  5612. var HEAPF32 = new global.Float32Array(buffer);
  5613. var HEAPF64 = new global.Float64Array(buffer);
  5614. var STACKTOP=env.STACKTOP|0;
  5615. var STACK_MAX=env.STACK_MAX|0;
  5616. var tempDoublePtr=env.tempDoublePtr|0;
  5617. var ABORT=env.ABORT|0;
  5618. var __ZTISt9exception=env.__ZTISt9exception|0;
  5619. var __THREW__ = 0;
  5620. var threwValue = 0;
  5621. var setjmpId = 0;
  5622. var undef = 0;
  5623. var nan = +env.NaN, inf = +env.Infinity;
  5624. var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0;
  5625. var tempRet0 = 0;
  5626. var tempRet1 = 0;
  5627. var tempRet2 = 0;
  5628. var tempRet3 = 0;
  5629. var tempRet4 = 0;
  5630. var tempRet5 = 0;
  5631. var tempRet6 = 0;
  5632. var tempRet7 = 0;
  5633. var tempRet8 = 0;
  5634. var tempRet9 = 0;
  5635. var Math_floor=global.Math.floor;
  5636. var Math_abs=global.Math.abs;
  5637. var Math_sqrt=global.Math.sqrt;
  5638. var Math_pow=global.Math.pow;
  5639. var Math_cos=global.Math.cos;
  5640. var Math_sin=global.Math.sin;
  5641. var Math_tan=global.Math.tan;
  5642. var Math_acos=global.Math.acos;
  5643. var Math_asin=global.Math.asin;
  5644. var Math_atan=global.Math.atan;
  5645. var Math_atan2=global.Math.atan2;
  5646. var Math_exp=global.Math.exp;
  5647. var Math_log=global.Math.log;
  5648. var Math_ceil=global.Math.ceil;
  5649. var Math_imul=global.Math.imul;
  5650. var abort=env.abort;
  5651. var assert=env.assert;
  5652. var asmPrintInt=env.asmPrintInt;
  5653. var asmPrintFloat=env.asmPrintFloat;
  5654. var Math_min=env.min;
  5655. var invoke_iiii=env.invoke_iiii;
  5656. var invoke_viiiii=env.invoke_viiiii;
  5657. var invoke_vi=env.invoke_vi;
  5658. var invoke_vii=env.invoke_vii;
  5659. var invoke_ii=env.invoke_ii;
  5660. var invoke_viii=env.invoke_viii;
  5661. var invoke_v=env.invoke_v;
  5662. var invoke_viid=env.invoke_viid;
  5663. var invoke_viiiiii=env.invoke_viiiiii;
  5664. var invoke_iii=env.invoke_iii;
  5665. var invoke_iiiiii=env.invoke_iiiiii;
  5666. var invoke_viiii=env.invoke_viiii;
  5667. var ___cxa_throw=env.___cxa_throw;
  5668. var _emscripten_run_script=env._emscripten_run_script;
  5669. var _cosf=env._cosf;
  5670. var _send=env._send;
  5671. var __ZSt9terminatev=env.__ZSt9terminatev;
  5672. var __reallyNegative=env.__reallyNegative;
  5673. var ___cxa_is_number_type=env.___cxa_is_number_type;
  5674. var ___assert_fail=env.___assert_fail;
  5675. var ___cxa_allocate_exception=env.___cxa_allocate_exception;
  5676. var ___cxa_find_matching_catch=env.___cxa_find_matching_catch;
  5677. var _fflush=env._fflush;
  5678. var _pwrite=env._pwrite;
  5679. var ___setErrNo=env.___setErrNo;
  5680. var _sbrk=env._sbrk;
  5681. var ___cxa_begin_catch=env.___cxa_begin_catch;
  5682. var _sinf=env._sinf;
  5683. var _fileno=env._fileno;
  5684. var ___resumeException=env.___resumeException;
  5685. var __ZSt18uncaught_exceptionv=env.__ZSt18uncaught_exceptionv;
  5686. var _sysconf=env._sysconf;
  5687. var _clock=env._clock;
  5688. var _emscripten_memcpy_big=env._emscripten_memcpy_big;
  5689. var _puts=env._puts;
  5690. var _mkport=env._mkport;
  5691. var _floorf=env._floorf;
  5692. var _sqrtf=env._sqrtf;
  5693. var _write=env._write;
  5694. var _emscripten_set_main_loop=env._emscripten_set_main_loop;
  5695. var ___errno_location=env.___errno_location;
  5696. var __ZNSt9exceptionD2Ev=env.__ZNSt9exceptionD2Ev;
  5697. var _printf=env._printf;
  5698. var ___cxa_does_inherit=env.___cxa_does_inherit;
  5699. var __exit=env.__exit;
  5700. var _fputc=env._fputc;
  5701. var _abort=env._abort;
  5702. var _fwrite=env._fwrite;
  5703. var _time=env._time;
  5704. var _fprintf=env._fprintf;
  5705. var _emscripten_cancel_main_loop=env._emscripten_cancel_main_loop;
  5706. var __formatString=env.__formatString;
  5707. var _fputs=env._fputs;
  5708. var _exit=env._exit;
  5709. var ___cxa_pure_virtual=env.___cxa_pure_virtual;
  5710. var tempFloat = 0.0;
  5711. // EMSCRIPTEN_START_FUNCS
  5712. function _malloc(i12) {
  5713. i12 = i12 | 0;
  5714. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0;
  5715. i1 = STACKTOP;
  5716. do {
  5717. if (i12 >>> 0 < 245) {
  5718. if (i12 >>> 0 < 11) {
  5719. i12 = 16;
  5720. } else {
  5721. i12 = i12 + 11 & -8;
  5722. }
  5723. i20 = i12 >>> 3;
  5724. i18 = HEAP32[1790] | 0;
  5725. i21 = i18 >>> i20;
  5726. if ((i21 & 3 | 0) != 0) {
  5727. i6 = (i21 & 1 ^ 1) + i20 | 0;
  5728. i5 = i6 << 1;
  5729. i3 = 7200 + (i5 << 2) | 0;
  5730. i5 = 7200 + (i5 + 2 << 2) | 0;
  5731. i7 = HEAP32[i5 >> 2] | 0;
  5732. i2 = i7 + 8 | 0;
  5733. i4 = HEAP32[i2 >> 2] | 0;
  5734. do {
  5735. if ((i3 | 0) != (i4 | 0)) {
  5736. if (i4 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  5737. _abort();
  5738. }
  5739. i8 = i4 + 12 | 0;
  5740. if ((HEAP32[i8 >> 2] | 0) == (i7 | 0)) {
  5741. HEAP32[i8 >> 2] = i3;
  5742. HEAP32[i5 >> 2] = i4;
  5743. break;
  5744. } else {
  5745. _abort();
  5746. }
  5747. } else {
  5748. HEAP32[1790] = i18 & ~(1 << i6);
  5749. }
  5750. } while (0);
  5751. i32 = i6 << 3;
  5752. HEAP32[i7 + 4 >> 2] = i32 | 3;
  5753. i32 = i7 + (i32 | 4) | 0;
  5754. HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
  5755. i32 = i2;
  5756. STACKTOP = i1;
  5757. return i32 | 0;
  5758. }
  5759. if (i12 >>> 0 > (HEAP32[7168 >> 2] | 0) >>> 0) {
  5760. if ((i21 | 0) != 0) {
  5761. i7 = 2 << i20;
  5762. i7 = i21 << i20 & (i7 | 0 - i7);
  5763. i7 = (i7 & 0 - i7) + -1 | 0;
  5764. i2 = i7 >>> 12 & 16;
  5765. i7 = i7 >>> i2;
  5766. i6 = i7 >>> 5 & 8;
  5767. i7 = i7 >>> i6;
  5768. i5 = i7 >>> 2 & 4;
  5769. i7 = i7 >>> i5;
  5770. i4 = i7 >>> 1 & 2;
  5771. i7 = i7 >>> i4;
  5772. i3 = i7 >>> 1 & 1;
  5773. i3 = (i6 | i2 | i5 | i4 | i3) + (i7 >>> i3) | 0;
  5774. i7 = i3 << 1;
  5775. i4 = 7200 + (i7 << 2) | 0;
  5776. i7 = 7200 + (i7 + 2 << 2) | 0;
  5777. i5 = HEAP32[i7 >> 2] | 0;
  5778. i2 = i5 + 8 | 0;
  5779. i6 = HEAP32[i2 >> 2] | 0;
  5780. do {
  5781. if ((i4 | 0) != (i6 | 0)) {
  5782. if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  5783. _abort();
  5784. }
  5785. i8 = i6 + 12 | 0;
  5786. if ((HEAP32[i8 >> 2] | 0) == (i5 | 0)) {
  5787. HEAP32[i8 >> 2] = i4;
  5788. HEAP32[i7 >> 2] = i6;
  5789. break;
  5790. } else {
  5791. _abort();
  5792. }
  5793. } else {
  5794. HEAP32[1790] = i18 & ~(1 << i3);
  5795. }
  5796. } while (0);
  5797. i6 = i3 << 3;
  5798. i4 = i6 - i12 | 0;
  5799. HEAP32[i5 + 4 >> 2] = i12 | 3;
  5800. i3 = i5 + i12 | 0;
  5801. HEAP32[i5 + (i12 | 4) >> 2] = i4 | 1;
  5802. HEAP32[i5 + i6 >> 2] = i4;
  5803. i6 = HEAP32[7168 >> 2] | 0;
  5804. if ((i6 | 0) != 0) {
  5805. i5 = HEAP32[7180 >> 2] | 0;
  5806. i8 = i6 >>> 3;
  5807. i9 = i8 << 1;
  5808. i6 = 7200 + (i9 << 2) | 0;
  5809. i7 = HEAP32[1790] | 0;
  5810. i8 = 1 << i8;
  5811. if ((i7 & i8 | 0) != 0) {
  5812. i7 = 7200 + (i9 + 2 << 2) | 0;
  5813. i8 = HEAP32[i7 >> 2] | 0;
  5814. if (i8 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  5815. _abort();
  5816. } else {
  5817. i28 = i7;
  5818. i27 = i8;
  5819. }
  5820. } else {
  5821. HEAP32[1790] = i7 | i8;
  5822. i28 = 7200 + (i9 + 2 << 2) | 0;
  5823. i27 = i6;
  5824. }
  5825. HEAP32[i28 >> 2] = i5;
  5826. HEAP32[i27 + 12 >> 2] = i5;
  5827. HEAP32[i5 + 8 >> 2] = i27;
  5828. HEAP32[i5 + 12 >> 2] = i6;
  5829. }
  5830. HEAP32[7168 >> 2] = i4;
  5831. HEAP32[7180 >> 2] = i3;
  5832. i32 = i2;
  5833. STACKTOP = i1;
  5834. return i32 | 0;
  5835. }
  5836. i18 = HEAP32[7164 >> 2] | 0;
  5837. if ((i18 | 0) != 0) {
  5838. i2 = (i18 & 0 - i18) + -1 | 0;
  5839. i31 = i2 >>> 12 & 16;
  5840. i2 = i2 >>> i31;
  5841. i30 = i2 >>> 5 & 8;
  5842. i2 = i2 >>> i30;
  5843. i32 = i2 >>> 2 & 4;
  5844. i2 = i2 >>> i32;
  5845. i6 = i2 >>> 1 & 2;
  5846. i2 = i2 >>> i6;
  5847. i3 = i2 >>> 1 & 1;
  5848. i3 = HEAP32[7464 + ((i30 | i31 | i32 | i6 | i3) + (i2 >>> i3) << 2) >> 2] | 0;
  5849. i2 = (HEAP32[i3 + 4 >> 2] & -8) - i12 | 0;
  5850. i6 = i3;
  5851. while (1) {
  5852. i5 = HEAP32[i6 + 16 >> 2] | 0;
  5853. if ((i5 | 0) == 0) {
  5854. i5 = HEAP32[i6 + 20 >> 2] | 0;
  5855. if ((i5 | 0) == 0) {
  5856. break;
  5857. }
  5858. }
  5859. i6 = (HEAP32[i5 + 4 >> 2] & -8) - i12 | 0;
  5860. i4 = i6 >>> 0 < i2 >>> 0;
  5861. i2 = i4 ? i6 : i2;
  5862. i6 = i5;
  5863. i3 = i4 ? i5 : i3;
  5864. }
  5865. i6 = HEAP32[7176 >> 2] | 0;
  5866. if (i3 >>> 0 < i6 >>> 0) {
  5867. _abort();
  5868. }
  5869. i4 = i3 + i12 | 0;
  5870. if (!(i3 >>> 0 < i4 >>> 0)) {
  5871. _abort();
  5872. }
  5873. i5 = HEAP32[i3 + 24 >> 2] | 0;
  5874. i7 = HEAP32[i3 + 12 >> 2] | 0;
  5875. do {
  5876. if ((i7 | 0) == (i3 | 0)) {
  5877. i8 = i3 + 20 | 0;
  5878. i7 = HEAP32[i8 >> 2] | 0;
  5879. if ((i7 | 0) == 0) {
  5880. i8 = i3 + 16 | 0;
  5881. i7 = HEAP32[i8 >> 2] | 0;
  5882. if ((i7 | 0) == 0) {
  5883. i26 = 0;
  5884. break;
  5885. }
  5886. }
  5887. while (1) {
  5888. i10 = i7 + 20 | 0;
  5889. i9 = HEAP32[i10 >> 2] | 0;
  5890. if ((i9 | 0) != 0) {
  5891. i7 = i9;
  5892. i8 = i10;
  5893. continue;
  5894. }
  5895. i10 = i7 + 16 | 0;
  5896. i9 = HEAP32[i10 >> 2] | 0;
  5897. if ((i9 | 0) == 0) {
  5898. break;
  5899. } else {
  5900. i7 = i9;
  5901. i8 = i10;
  5902. }
  5903. }
  5904. if (i8 >>> 0 < i6 >>> 0) {
  5905. _abort();
  5906. } else {
  5907. HEAP32[i8 >> 2] = 0;
  5908. i26 = i7;
  5909. break;
  5910. }
  5911. } else {
  5912. i8 = HEAP32[i3 + 8 >> 2] | 0;
  5913. if (i8 >>> 0 < i6 >>> 0) {
  5914. _abort();
  5915. }
  5916. i6 = i8 + 12 | 0;
  5917. if ((HEAP32[i6 >> 2] | 0) != (i3 | 0)) {
  5918. _abort();
  5919. }
  5920. i9 = i7 + 8 | 0;
  5921. if ((HEAP32[i9 >> 2] | 0) == (i3 | 0)) {
  5922. HEAP32[i6 >> 2] = i7;
  5923. HEAP32[i9 >> 2] = i8;
  5924. i26 = i7;
  5925. break;
  5926. } else {
  5927. _abort();
  5928. }
  5929. }
  5930. } while (0);
  5931. do {
  5932. if ((i5 | 0) != 0) {
  5933. i7 = HEAP32[i3 + 28 >> 2] | 0;
  5934. i6 = 7464 + (i7 << 2) | 0;
  5935. if ((i3 | 0) == (HEAP32[i6 >> 2] | 0)) {
  5936. HEAP32[i6 >> 2] = i26;
  5937. if ((i26 | 0) == 0) {
  5938. HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i7);
  5939. break;
  5940. }
  5941. } else {
  5942. if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  5943. _abort();
  5944. }
  5945. i6 = i5 + 16 | 0;
  5946. if ((HEAP32[i6 >> 2] | 0) == (i3 | 0)) {
  5947. HEAP32[i6 >> 2] = i26;
  5948. } else {
  5949. HEAP32[i5 + 20 >> 2] = i26;
  5950. }
  5951. if ((i26 | 0) == 0) {
  5952. break;
  5953. }
  5954. }
  5955. if (i26 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  5956. _abort();
  5957. }
  5958. HEAP32[i26 + 24 >> 2] = i5;
  5959. i5 = HEAP32[i3 + 16 >> 2] | 0;
  5960. do {
  5961. if ((i5 | 0) != 0) {
  5962. if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  5963. _abort();
  5964. } else {
  5965. HEAP32[i26 + 16 >> 2] = i5;
  5966. HEAP32[i5 + 24 >> 2] = i26;
  5967. break;
  5968. }
  5969. }
  5970. } while (0);
  5971. i5 = HEAP32[i3 + 20 >> 2] | 0;
  5972. if ((i5 | 0) != 0) {
  5973. if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  5974. _abort();
  5975. } else {
  5976. HEAP32[i26 + 20 >> 2] = i5;
  5977. HEAP32[i5 + 24 >> 2] = i26;
  5978. break;
  5979. }
  5980. }
  5981. }
  5982. } while (0);
  5983. if (i2 >>> 0 < 16) {
  5984. i32 = i2 + i12 | 0;
  5985. HEAP32[i3 + 4 >> 2] = i32 | 3;
  5986. i32 = i3 + (i32 + 4) | 0;
  5987. HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
  5988. } else {
  5989. HEAP32[i3 + 4 >> 2] = i12 | 3;
  5990. HEAP32[i3 + (i12 | 4) >> 2] = i2 | 1;
  5991. HEAP32[i3 + (i2 + i12) >> 2] = i2;
  5992. i6 = HEAP32[7168 >> 2] | 0;
  5993. if ((i6 | 0) != 0) {
  5994. i5 = HEAP32[7180 >> 2] | 0;
  5995. i8 = i6 >>> 3;
  5996. i9 = i8 << 1;
  5997. i6 = 7200 + (i9 << 2) | 0;
  5998. i7 = HEAP32[1790] | 0;
  5999. i8 = 1 << i8;
  6000. if ((i7 & i8 | 0) != 0) {
  6001. i7 = 7200 + (i9 + 2 << 2) | 0;
  6002. i8 = HEAP32[i7 >> 2] | 0;
  6003. if (i8 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6004. _abort();
  6005. } else {
  6006. i25 = i7;
  6007. i24 = i8;
  6008. }
  6009. } else {
  6010. HEAP32[1790] = i7 | i8;
  6011. i25 = 7200 + (i9 + 2 << 2) | 0;
  6012. i24 = i6;
  6013. }
  6014. HEAP32[i25 >> 2] = i5;
  6015. HEAP32[i24 + 12 >> 2] = i5;
  6016. HEAP32[i5 + 8 >> 2] = i24;
  6017. HEAP32[i5 + 12 >> 2] = i6;
  6018. }
  6019. HEAP32[7168 >> 2] = i2;
  6020. HEAP32[7180 >> 2] = i4;
  6021. }
  6022. i32 = i3 + 8 | 0;
  6023. STACKTOP = i1;
  6024. return i32 | 0;
  6025. }
  6026. }
  6027. } else {
  6028. if (!(i12 >>> 0 > 4294967231)) {
  6029. i24 = i12 + 11 | 0;
  6030. i12 = i24 & -8;
  6031. i26 = HEAP32[7164 >> 2] | 0;
  6032. if ((i26 | 0) != 0) {
  6033. i25 = 0 - i12 | 0;
  6034. i24 = i24 >>> 8;
  6035. if ((i24 | 0) != 0) {
  6036. if (i12 >>> 0 > 16777215) {
  6037. i27 = 31;
  6038. } else {
  6039. i31 = (i24 + 1048320 | 0) >>> 16 & 8;
  6040. i32 = i24 << i31;
  6041. i30 = (i32 + 520192 | 0) >>> 16 & 4;
  6042. i32 = i32 << i30;
  6043. i27 = (i32 + 245760 | 0) >>> 16 & 2;
  6044. i27 = 14 - (i30 | i31 | i27) + (i32 << i27 >>> 15) | 0;
  6045. i27 = i12 >>> (i27 + 7 | 0) & 1 | i27 << 1;
  6046. }
  6047. } else {
  6048. i27 = 0;
  6049. }
  6050. i30 = HEAP32[7464 + (i27 << 2) >> 2] | 0;
  6051. L126 : do {
  6052. if ((i30 | 0) == 0) {
  6053. i29 = 0;
  6054. i24 = 0;
  6055. } else {
  6056. if ((i27 | 0) == 31) {
  6057. i24 = 0;
  6058. } else {
  6059. i24 = 25 - (i27 >>> 1) | 0;
  6060. }
  6061. i29 = 0;
  6062. i28 = i12 << i24;
  6063. i24 = 0;
  6064. while (1) {
  6065. i32 = HEAP32[i30 + 4 >> 2] & -8;
  6066. i31 = i32 - i12 | 0;
  6067. if (i31 >>> 0 < i25 >>> 0) {
  6068. if ((i32 | 0) == (i12 | 0)) {
  6069. i25 = i31;
  6070. i29 = i30;
  6071. i24 = i30;
  6072. break L126;
  6073. } else {
  6074. i25 = i31;
  6075. i24 = i30;
  6076. }
  6077. }
  6078. i31 = HEAP32[i30 + 20 >> 2] | 0;
  6079. i30 = HEAP32[i30 + (i28 >>> 31 << 2) + 16 >> 2] | 0;
  6080. i29 = (i31 | 0) == 0 | (i31 | 0) == (i30 | 0) ? i29 : i31;
  6081. if ((i30 | 0) == 0) {
  6082. break;
  6083. } else {
  6084. i28 = i28 << 1;
  6085. }
  6086. }
  6087. }
  6088. } while (0);
  6089. if ((i29 | 0) == 0 & (i24 | 0) == 0) {
  6090. i32 = 2 << i27;
  6091. i26 = i26 & (i32 | 0 - i32);
  6092. if ((i26 | 0) == 0) {
  6093. break;
  6094. }
  6095. i32 = (i26 & 0 - i26) + -1 | 0;
  6096. i28 = i32 >>> 12 & 16;
  6097. i32 = i32 >>> i28;
  6098. i27 = i32 >>> 5 & 8;
  6099. i32 = i32 >>> i27;
  6100. i30 = i32 >>> 2 & 4;
  6101. i32 = i32 >>> i30;
  6102. i31 = i32 >>> 1 & 2;
  6103. i32 = i32 >>> i31;
  6104. i29 = i32 >>> 1 & 1;
  6105. i29 = HEAP32[7464 + ((i27 | i28 | i30 | i31 | i29) + (i32 >>> i29) << 2) >> 2] | 0;
  6106. }
  6107. if ((i29 | 0) != 0) {
  6108. while (1) {
  6109. i27 = (HEAP32[i29 + 4 >> 2] & -8) - i12 | 0;
  6110. i26 = i27 >>> 0 < i25 >>> 0;
  6111. i25 = i26 ? i27 : i25;
  6112. i24 = i26 ? i29 : i24;
  6113. i26 = HEAP32[i29 + 16 >> 2] | 0;
  6114. if ((i26 | 0) != 0) {
  6115. i29 = i26;
  6116. continue;
  6117. }
  6118. i29 = HEAP32[i29 + 20 >> 2] | 0;
  6119. if ((i29 | 0) == 0) {
  6120. break;
  6121. }
  6122. }
  6123. }
  6124. if ((i24 | 0) != 0 ? i25 >>> 0 < ((HEAP32[7168 >> 2] | 0) - i12 | 0) >>> 0 : 0) {
  6125. i4 = HEAP32[7176 >> 2] | 0;
  6126. if (i24 >>> 0 < i4 >>> 0) {
  6127. _abort();
  6128. }
  6129. i2 = i24 + i12 | 0;
  6130. if (!(i24 >>> 0 < i2 >>> 0)) {
  6131. _abort();
  6132. }
  6133. i3 = HEAP32[i24 + 24 >> 2] | 0;
  6134. i6 = HEAP32[i24 + 12 >> 2] | 0;
  6135. do {
  6136. if ((i6 | 0) == (i24 | 0)) {
  6137. i6 = i24 + 20 | 0;
  6138. i5 = HEAP32[i6 >> 2] | 0;
  6139. if ((i5 | 0) == 0) {
  6140. i6 = i24 + 16 | 0;
  6141. i5 = HEAP32[i6 >> 2] | 0;
  6142. if ((i5 | 0) == 0) {
  6143. i22 = 0;
  6144. break;
  6145. }
  6146. }
  6147. while (1) {
  6148. i8 = i5 + 20 | 0;
  6149. i7 = HEAP32[i8 >> 2] | 0;
  6150. if ((i7 | 0) != 0) {
  6151. i5 = i7;
  6152. i6 = i8;
  6153. continue;
  6154. }
  6155. i7 = i5 + 16 | 0;
  6156. i8 = HEAP32[i7 >> 2] | 0;
  6157. if ((i8 | 0) == 0) {
  6158. break;
  6159. } else {
  6160. i5 = i8;
  6161. i6 = i7;
  6162. }
  6163. }
  6164. if (i6 >>> 0 < i4 >>> 0) {
  6165. _abort();
  6166. } else {
  6167. HEAP32[i6 >> 2] = 0;
  6168. i22 = i5;
  6169. break;
  6170. }
  6171. } else {
  6172. i5 = HEAP32[i24 + 8 >> 2] | 0;
  6173. if (i5 >>> 0 < i4 >>> 0) {
  6174. _abort();
  6175. }
  6176. i7 = i5 + 12 | 0;
  6177. if ((HEAP32[i7 >> 2] | 0) != (i24 | 0)) {
  6178. _abort();
  6179. }
  6180. i4 = i6 + 8 | 0;
  6181. if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
  6182. HEAP32[i7 >> 2] = i6;
  6183. HEAP32[i4 >> 2] = i5;
  6184. i22 = i6;
  6185. break;
  6186. } else {
  6187. _abort();
  6188. }
  6189. }
  6190. } while (0);
  6191. do {
  6192. if ((i3 | 0) != 0) {
  6193. i4 = HEAP32[i24 + 28 >> 2] | 0;
  6194. i5 = 7464 + (i4 << 2) | 0;
  6195. if ((i24 | 0) == (HEAP32[i5 >> 2] | 0)) {
  6196. HEAP32[i5 >> 2] = i22;
  6197. if ((i22 | 0) == 0) {
  6198. HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i4);
  6199. break;
  6200. }
  6201. } else {
  6202. if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6203. _abort();
  6204. }
  6205. i4 = i3 + 16 | 0;
  6206. if ((HEAP32[i4 >> 2] | 0) == (i24 | 0)) {
  6207. HEAP32[i4 >> 2] = i22;
  6208. } else {
  6209. HEAP32[i3 + 20 >> 2] = i22;
  6210. }
  6211. if ((i22 | 0) == 0) {
  6212. break;
  6213. }
  6214. }
  6215. if (i22 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6216. _abort();
  6217. }
  6218. HEAP32[i22 + 24 >> 2] = i3;
  6219. i3 = HEAP32[i24 + 16 >> 2] | 0;
  6220. do {
  6221. if ((i3 | 0) != 0) {
  6222. if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6223. _abort();
  6224. } else {
  6225. HEAP32[i22 + 16 >> 2] = i3;
  6226. HEAP32[i3 + 24 >> 2] = i22;
  6227. break;
  6228. }
  6229. }
  6230. } while (0);
  6231. i3 = HEAP32[i24 + 20 >> 2] | 0;
  6232. if ((i3 | 0) != 0) {
  6233. if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6234. _abort();
  6235. } else {
  6236. HEAP32[i22 + 20 >> 2] = i3;
  6237. HEAP32[i3 + 24 >> 2] = i22;
  6238. break;
  6239. }
  6240. }
  6241. }
  6242. } while (0);
  6243. L204 : do {
  6244. if (!(i25 >>> 0 < 16)) {
  6245. HEAP32[i24 + 4 >> 2] = i12 | 3;
  6246. HEAP32[i24 + (i12 | 4) >> 2] = i25 | 1;
  6247. HEAP32[i24 + (i25 + i12) >> 2] = i25;
  6248. i4 = i25 >>> 3;
  6249. if (i25 >>> 0 < 256) {
  6250. i6 = i4 << 1;
  6251. i3 = 7200 + (i6 << 2) | 0;
  6252. i5 = HEAP32[1790] | 0;
  6253. i4 = 1 << i4;
  6254. if ((i5 & i4 | 0) != 0) {
  6255. i5 = 7200 + (i6 + 2 << 2) | 0;
  6256. i4 = HEAP32[i5 >> 2] | 0;
  6257. if (i4 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6258. _abort();
  6259. } else {
  6260. i21 = i5;
  6261. i20 = i4;
  6262. }
  6263. } else {
  6264. HEAP32[1790] = i5 | i4;
  6265. i21 = 7200 + (i6 + 2 << 2) | 0;
  6266. i20 = i3;
  6267. }
  6268. HEAP32[i21 >> 2] = i2;
  6269. HEAP32[i20 + 12 >> 2] = i2;
  6270. HEAP32[i24 + (i12 + 8) >> 2] = i20;
  6271. HEAP32[i24 + (i12 + 12) >> 2] = i3;
  6272. break;
  6273. }
  6274. i3 = i25 >>> 8;
  6275. if ((i3 | 0) != 0) {
  6276. if (i25 >>> 0 > 16777215) {
  6277. i3 = 31;
  6278. } else {
  6279. i31 = (i3 + 1048320 | 0) >>> 16 & 8;
  6280. i32 = i3 << i31;
  6281. i30 = (i32 + 520192 | 0) >>> 16 & 4;
  6282. i32 = i32 << i30;
  6283. i3 = (i32 + 245760 | 0) >>> 16 & 2;
  6284. i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
  6285. i3 = i25 >>> (i3 + 7 | 0) & 1 | i3 << 1;
  6286. }
  6287. } else {
  6288. i3 = 0;
  6289. }
  6290. i6 = 7464 + (i3 << 2) | 0;
  6291. HEAP32[i24 + (i12 + 28) >> 2] = i3;
  6292. HEAP32[i24 + (i12 + 20) >> 2] = 0;
  6293. HEAP32[i24 + (i12 + 16) >> 2] = 0;
  6294. i4 = HEAP32[7164 >> 2] | 0;
  6295. i5 = 1 << i3;
  6296. if ((i4 & i5 | 0) == 0) {
  6297. HEAP32[7164 >> 2] = i4 | i5;
  6298. HEAP32[i6 >> 2] = i2;
  6299. HEAP32[i24 + (i12 + 24) >> 2] = i6;
  6300. HEAP32[i24 + (i12 + 12) >> 2] = i2;
  6301. HEAP32[i24 + (i12 + 8) >> 2] = i2;
  6302. break;
  6303. }
  6304. i4 = HEAP32[i6 >> 2] | 0;
  6305. if ((i3 | 0) == 31) {
  6306. i3 = 0;
  6307. } else {
  6308. i3 = 25 - (i3 >>> 1) | 0;
  6309. }
  6310. L225 : do {
  6311. if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i25 | 0)) {
  6312. i3 = i25 << i3;
  6313. while (1) {
  6314. i6 = i4 + (i3 >>> 31 << 2) + 16 | 0;
  6315. i5 = HEAP32[i6 >> 2] | 0;
  6316. if ((i5 | 0) == 0) {
  6317. break;
  6318. }
  6319. if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i25 | 0)) {
  6320. i18 = i5;
  6321. break L225;
  6322. } else {
  6323. i3 = i3 << 1;
  6324. i4 = i5;
  6325. }
  6326. }
  6327. if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6328. _abort();
  6329. } else {
  6330. HEAP32[i6 >> 2] = i2;
  6331. HEAP32[i24 + (i12 + 24) >> 2] = i4;
  6332. HEAP32[i24 + (i12 + 12) >> 2] = i2;
  6333. HEAP32[i24 + (i12 + 8) >> 2] = i2;
  6334. break L204;
  6335. }
  6336. } else {
  6337. i18 = i4;
  6338. }
  6339. } while (0);
  6340. i4 = i18 + 8 | 0;
  6341. i3 = HEAP32[i4 >> 2] | 0;
  6342. i5 = HEAP32[7176 >> 2] | 0;
  6343. if (i18 >>> 0 < i5 >>> 0) {
  6344. _abort();
  6345. }
  6346. if (i3 >>> 0 < i5 >>> 0) {
  6347. _abort();
  6348. } else {
  6349. HEAP32[i3 + 12 >> 2] = i2;
  6350. HEAP32[i4 >> 2] = i2;
  6351. HEAP32[i24 + (i12 + 8) >> 2] = i3;
  6352. HEAP32[i24 + (i12 + 12) >> 2] = i18;
  6353. HEAP32[i24 + (i12 + 24) >> 2] = 0;
  6354. break;
  6355. }
  6356. } else {
  6357. i32 = i25 + i12 | 0;
  6358. HEAP32[i24 + 4 >> 2] = i32 | 3;
  6359. i32 = i24 + (i32 + 4) | 0;
  6360. HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
  6361. }
  6362. } while (0);
  6363. i32 = i24 + 8 | 0;
  6364. STACKTOP = i1;
  6365. return i32 | 0;
  6366. }
  6367. }
  6368. } else {
  6369. i12 = -1;
  6370. }
  6371. }
  6372. } while (0);
  6373. i18 = HEAP32[7168 >> 2] | 0;
  6374. if (!(i12 >>> 0 > i18 >>> 0)) {
  6375. i3 = i18 - i12 | 0;
  6376. i2 = HEAP32[7180 >> 2] | 0;
  6377. if (i3 >>> 0 > 15) {
  6378. HEAP32[7180 >> 2] = i2 + i12;
  6379. HEAP32[7168 >> 2] = i3;
  6380. HEAP32[i2 + (i12 + 4) >> 2] = i3 | 1;
  6381. HEAP32[i2 + i18 >> 2] = i3;
  6382. HEAP32[i2 + 4 >> 2] = i12 | 3;
  6383. } else {
  6384. HEAP32[7168 >> 2] = 0;
  6385. HEAP32[7180 >> 2] = 0;
  6386. HEAP32[i2 + 4 >> 2] = i18 | 3;
  6387. i32 = i2 + (i18 + 4) | 0;
  6388. HEAP32[i32 >> 2] = HEAP32[i32 >> 2] | 1;
  6389. }
  6390. i32 = i2 + 8 | 0;
  6391. STACKTOP = i1;
  6392. return i32 | 0;
  6393. }
  6394. i18 = HEAP32[7172 >> 2] | 0;
  6395. if (i12 >>> 0 < i18 >>> 0) {
  6396. i31 = i18 - i12 | 0;
  6397. HEAP32[7172 >> 2] = i31;
  6398. i32 = HEAP32[7184 >> 2] | 0;
  6399. HEAP32[7184 >> 2] = i32 + i12;
  6400. HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
  6401. HEAP32[i32 + 4 >> 2] = i12 | 3;
  6402. i32 = i32 + 8 | 0;
  6403. STACKTOP = i1;
  6404. return i32 | 0;
  6405. }
  6406. do {
  6407. if ((HEAP32[1908] | 0) == 0) {
  6408. i18 = _sysconf(30) | 0;
  6409. if ((i18 + -1 & i18 | 0) == 0) {
  6410. HEAP32[7640 >> 2] = i18;
  6411. HEAP32[7636 >> 2] = i18;
  6412. HEAP32[7644 >> 2] = -1;
  6413. HEAP32[7648 >> 2] = -1;
  6414. HEAP32[7652 >> 2] = 0;
  6415. HEAP32[7604 >> 2] = 0;
  6416. HEAP32[1908] = (_time(0) | 0) & -16 ^ 1431655768;
  6417. break;
  6418. } else {
  6419. _abort();
  6420. }
  6421. }
  6422. } while (0);
  6423. i20 = i12 + 48 | 0;
  6424. i25 = HEAP32[7640 >> 2] | 0;
  6425. i21 = i12 + 47 | 0;
  6426. i22 = i25 + i21 | 0;
  6427. i25 = 0 - i25 | 0;
  6428. i18 = i22 & i25;
  6429. if (!(i18 >>> 0 > i12 >>> 0)) {
  6430. i32 = 0;
  6431. STACKTOP = i1;
  6432. return i32 | 0;
  6433. }
  6434. i24 = HEAP32[7600 >> 2] | 0;
  6435. if ((i24 | 0) != 0 ? (i31 = HEAP32[7592 >> 2] | 0, i32 = i31 + i18 | 0, i32 >>> 0 <= i31 >>> 0 | i32 >>> 0 > i24 >>> 0) : 0) {
  6436. i32 = 0;
  6437. STACKTOP = i1;
  6438. return i32 | 0;
  6439. }
  6440. L269 : do {
  6441. if ((HEAP32[7604 >> 2] & 4 | 0) == 0) {
  6442. i26 = HEAP32[7184 >> 2] | 0;
  6443. L271 : do {
  6444. if ((i26 | 0) != 0) {
  6445. i24 = 7608 | 0;
  6446. while (1) {
  6447. i27 = HEAP32[i24 >> 2] | 0;
  6448. if (!(i27 >>> 0 > i26 >>> 0) ? (i23 = i24 + 4 | 0, (i27 + (HEAP32[i23 >> 2] | 0) | 0) >>> 0 > i26 >>> 0) : 0) {
  6449. break;
  6450. }
  6451. i24 = HEAP32[i24 + 8 >> 2] | 0;
  6452. if ((i24 | 0) == 0) {
  6453. i13 = 182;
  6454. break L271;
  6455. }
  6456. }
  6457. if ((i24 | 0) != 0) {
  6458. i25 = i22 - (HEAP32[7172 >> 2] | 0) & i25;
  6459. if (i25 >>> 0 < 2147483647) {
  6460. i13 = _sbrk(i25 | 0) | 0;
  6461. i26 = (i13 | 0) == ((HEAP32[i24 >> 2] | 0) + (HEAP32[i23 >> 2] | 0) | 0);
  6462. i22 = i13;
  6463. i24 = i25;
  6464. i23 = i26 ? i13 : -1;
  6465. i25 = i26 ? i25 : 0;
  6466. i13 = 191;
  6467. } else {
  6468. i25 = 0;
  6469. }
  6470. } else {
  6471. i13 = 182;
  6472. }
  6473. } else {
  6474. i13 = 182;
  6475. }
  6476. } while (0);
  6477. do {
  6478. if ((i13 | 0) == 182) {
  6479. i23 = _sbrk(0) | 0;
  6480. if ((i23 | 0) != (-1 | 0)) {
  6481. i24 = i23;
  6482. i22 = HEAP32[7636 >> 2] | 0;
  6483. i25 = i22 + -1 | 0;
  6484. if ((i25 & i24 | 0) == 0) {
  6485. i25 = i18;
  6486. } else {
  6487. i25 = i18 - i24 + (i25 + i24 & 0 - i22) | 0;
  6488. }
  6489. i24 = HEAP32[7592 >> 2] | 0;
  6490. i26 = i24 + i25 | 0;
  6491. if (i25 >>> 0 > i12 >>> 0 & i25 >>> 0 < 2147483647) {
  6492. i22 = HEAP32[7600 >> 2] | 0;
  6493. if ((i22 | 0) != 0 ? i26 >>> 0 <= i24 >>> 0 | i26 >>> 0 > i22 >>> 0 : 0) {
  6494. i25 = 0;
  6495. break;
  6496. }
  6497. i22 = _sbrk(i25 | 0) | 0;
  6498. i13 = (i22 | 0) == (i23 | 0);
  6499. i24 = i25;
  6500. i23 = i13 ? i23 : -1;
  6501. i25 = i13 ? i25 : 0;
  6502. i13 = 191;
  6503. } else {
  6504. i25 = 0;
  6505. }
  6506. } else {
  6507. i25 = 0;
  6508. }
  6509. }
  6510. } while (0);
  6511. L291 : do {
  6512. if ((i13 | 0) == 191) {
  6513. i13 = 0 - i24 | 0;
  6514. if ((i23 | 0) != (-1 | 0)) {
  6515. i17 = i23;
  6516. i14 = i25;
  6517. i13 = 202;
  6518. break L269;
  6519. }
  6520. do {
  6521. if ((i22 | 0) != (-1 | 0) & i24 >>> 0 < 2147483647 & i24 >>> 0 < i20 >>> 0 ? (i19 = HEAP32[7640 >> 2] | 0, i19 = i21 - i24 + i19 & 0 - i19, i19 >>> 0 < 2147483647) : 0) {
  6522. if ((_sbrk(i19 | 0) | 0) == (-1 | 0)) {
  6523. _sbrk(i13 | 0) | 0;
  6524. break L291;
  6525. } else {
  6526. i24 = i19 + i24 | 0;
  6527. break;
  6528. }
  6529. }
  6530. } while (0);
  6531. if ((i22 | 0) != (-1 | 0)) {
  6532. i17 = i22;
  6533. i14 = i24;
  6534. i13 = 202;
  6535. break L269;
  6536. }
  6537. }
  6538. } while (0);
  6539. HEAP32[7604 >> 2] = HEAP32[7604 >> 2] | 4;
  6540. i13 = 199;
  6541. } else {
  6542. i25 = 0;
  6543. i13 = 199;
  6544. }
  6545. } while (0);
  6546. if ((((i13 | 0) == 199 ? i18 >>> 0 < 2147483647 : 0) ? (i17 = _sbrk(i18 | 0) | 0, i16 = _sbrk(0) | 0, (i16 | 0) != (-1 | 0) & (i17 | 0) != (-1 | 0) & i17 >>> 0 < i16 >>> 0) : 0) ? (i15 = i16 - i17 | 0, i14 = i15 >>> 0 > (i12 + 40 | 0) >>> 0, i14) : 0) {
  6547. i14 = i14 ? i15 : i25;
  6548. i13 = 202;
  6549. }
  6550. if ((i13 | 0) == 202) {
  6551. i15 = (HEAP32[7592 >> 2] | 0) + i14 | 0;
  6552. HEAP32[7592 >> 2] = i15;
  6553. if (i15 >>> 0 > (HEAP32[7596 >> 2] | 0) >>> 0) {
  6554. HEAP32[7596 >> 2] = i15;
  6555. }
  6556. i15 = HEAP32[7184 >> 2] | 0;
  6557. L311 : do {
  6558. if ((i15 | 0) != 0) {
  6559. i21 = 7608 | 0;
  6560. while (1) {
  6561. i16 = HEAP32[i21 >> 2] | 0;
  6562. i19 = i21 + 4 | 0;
  6563. i20 = HEAP32[i19 >> 2] | 0;
  6564. if ((i17 | 0) == (i16 + i20 | 0)) {
  6565. i13 = 214;
  6566. break;
  6567. }
  6568. i18 = HEAP32[i21 + 8 >> 2] | 0;
  6569. if ((i18 | 0) == 0) {
  6570. break;
  6571. } else {
  6572. i21 = i18;
  6573. }
  6574. }
  6575. if (((i13 | 0) == 214 ? (HEAP32[i21 + 12 >> 2] & 8 | 0) == 0 : 0) ? i15 >>> 0 >= i16 >>> 0 & i15 >>> 0 < i17 >>> 0 : 0) {
  6576. HEAP32[i19 >> 2] = i20 + i14;
  6577. i2 = (HEAP32[7172 >> 2] | 0) + i14 | 0;
  6578. i3 = i15 + 8 | 0;
  6579. if ((i3 & 7 | 0) == 0) {
  6580. i3 = 0;
  6581. } else {
  6582. i3 = 0 - i3 & 7;
  6583. }
  6584. i32 = i2 - i3 | 0;
  6585. HEAP32[7184 >> 2] = i15 + i3;
  6586. HEAP32[7172 >> 2] = i32;
  6587. HEAP32[i15 + (i3 + 4) >> 2] = i32 | 1;
  6588. HEAP32[i15 + (i2 + 4) >> 2] = 40;
  6589. HEAP32[7188 >> 2] = HEAP32[7648 >> 2];
  6590. break;
  6591. }
  6592. if (i17 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6593. HEAP32[7176 >> 2] = i17;
  6594. }
  6595. i19 = i17 + i14 | 0;
  6596. i16 = 7608 | 0;
  6597. while (1) {
  6598. if ((HEAP32[i16 >> 2] | 0) == (i19 | 0)) {
  6599. i13 = 224;
  6600. break;
  6601. }
  6602. i18 = HEAP32[i16 + 8 >> 2] | 0;
  6603. if ((i18 | 0) == 0) {
  6604. break;
  6605. } else {
  6606. i16 = i18;
  6607. }
  6608. }
  6609. if ((i13 | 0) == 224 ? (HEAP32[i16 + 12 >> 2] & 8 | 0) == 0 : 0) {
  6610. HEAP32[i16 >> 2] = i17;
  6611. i6 = i16 + 4 | 0;
  6612. HEAP32[i6 >> 2] = (HEAP32[i6 >> 2] | 0) + i14;
  6613. i6 = i17 + 8 | 0;
  6614. if ((i6 & 7 | 0) == 0) {
  6615. i6 = 0;
  6616. } else {
  6617. i6 = 0 - i6 & 7;
  6618. }
  6619. i7 = i17 + (i14 + 8) | 0;
  6620. if ((i7 & 7 | 0) == 0) {
  6621. i13 = 0;
  6622. } else {
  6623. i13 = 0 - i7 & 7;
  6624. }
  6625. i15 = i17 + (i13 + i14) | 0;
  6626. i8 = i6 + i12 | 0;
  6627. i7 = i17 + i8 | 0;
  6628. i10 = i15 - (i17 + i6) - i12 | 0;
  6629. HEAP32[i17 + (i6 + 4) >> 2] = i12 | 3;
  6630. L348 : do {
  6631. if ((i15 | 0) != (HEAP32[7184 >> 2] | 0)) {
  6632. if ((i15 | 0) == (HEAP32[7180 >> 2] | 0)) {
  6633. i32 = (HEAP32[7168 >> 2] | 0) + i10 | 0;
  6634. HEAP32[7168 >> 2] = i32;
  6635. HEAP32[7180 >> 2] = i7;
  6636. HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
  6637. HEAP32[i17 + (i32 + i8) >> 2] = i32;
  6638. break;
  6639. }
  6640. i12 = i14 + 4 | 0;
  6641. i18 = HEAP32[i17 + (i12 + i13) >> 2] | 0;
  6642. if ((i18 & 3 | 0) == 1) {
  6643. i11 = i18 & -8;
  6644. i16 = i18 >>> 3;
  6645. do {
  6646. if (!(i18 >>> 0 < 256)) {
  6647. i9 = HEAP32[i17 + ((i13 | 24) + i14) >> 2] | 0;
  6648. i19 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
  6649. do {
  6650. if ((i19 | 0) == (i15 | 0)) {
  6651. i19 = i13 | 16;
  6652. i18 = i17 + (i12 + i19) | 0;
  6653. i16 = HEAP32[i18 >> 2] | 0;
  6654. if ((i16 | 0) == 0) {
  6655. i18 = i17 + (i19 + i14) | 0;
  6656. i16 = HEAP32[i18 >> 2] | 0;
  6657. if ((i16 | 0) == 0) {
  6658. i5 = 0;
  6659. break;
  6660. }
  6661. }
  6662. while (1) {
  6663. i20 = i16 + 20 | 0;
  6664. i19 = HEAP32[i20 >> 2] | 0;
  6665. if ((i19 | 0) != 0) {
  6666. i16 = i19;
  6667. i18 = i20;
  6668. continue;
  6669. }
  6670. i19 = i16 + 16 | 0;
  6671. i20 = HEAP32[i19 >> 2] | 0;
  6672. if ((i20 | 0) == 0) {
  6673. break;
  6674. } else {
  6675. i16 = i20;
  6676. i18 = i19;
  6677. }
  6678. }
  6679. if (i18 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6680. _abort();
  6681. } else {
  6682. HEAP32[i18 >> 2] = 0;
  6683. i5 = i16;
  6684. break;
  6685. }
  6686. } else {
  6687. i18 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
  6688. if (i18 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6689. _abort();
  6690. }
  6691. i16 = i18 + 12 | 0;
  6692. if ((HEAP32[i16 >> 2] | 0) != (i15 | 0)) {
  6693. _abort();
  6694. }
  6695. i20 = i19 + 8 | 0;
  6696. if ((HEAP32[i20 >> 2] | 0) == (i15 | 0)) {
  6697. HEAP32[i16 >> 2] = i19;
  6698. HEAP32[i20 >> 2] = i18;
  6699. i5 = i19;
  6700. break;
  6701. } else {
  6702. _abort();
  6703. }
  6704. }
  6705. } while (0);
  6706. if ((i9 | 0) != 0) {
  6707. i16 = HEAP32[i17 + (i14 + 28 + i13) >> 2] | 0;
  6708. i18 = 7464 + (i16 << 2) | 0;
  6709. if ((i15 | 0) == (HEAP32[i18 >> 2] | 0)) {
  6710. HEAP32[i18 >> 2] = i5;
  6711. if ((i5 | 0) == 0) {
  6712. HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i16);
  6713. break;
  6714. }
  6715. } else {
  6716. if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6717. _abort();
  6718. }
  6719. i16 = i9 + 16 | 0;
  6720. if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
  6721. HEAP32[i16 >> 2] = i5;
  6722. } else {
  6723. HEAP32[i9 + 20 >> 2] = i5;
  6724. }
  6725. if ((i5 | 0) == 0) {
  6726. break;
  6727. }
  6728. }
  6729. if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6730. _abort();
  6731. }
  6732. HEAP32[i5 + 24 >> 2] = i9;
  6733. i15 = i13 | 16;
  6734. i9 = HEAP32[i17 + (i15 + i14) >> 2] | 0;
  6735. do {
  6736. if ((i9 | 0) != 0) {
  6737. if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6738. _abort();
  6739. } else {
  6740. HEAP32[i5 + 16 >> 2] = i9;
  6741. HEAP32[i9 + 24 >> 2] = i5;
  6742. break;
  6743. }
  6744. }
  6745. } while (0);
  6746. i9 = HEAP32[i17 + (i12 + i15) >> 2] | 0;
  6747. if ((i9 | 0) != 0) {
  6748. if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6749. _abort();
  6750. } else {
  6751. HEAP32[i5 + 20 >> 2] = i9;
  6752. HEAP32[i9 + 24 >> 2] = i5;
  6753. break;
  6754. }
  6755. }
  6756. }
  6757. } else {
  6758. i5 = HEAP32[i17 + ((i13 | 8) + i14) >> 2] | 0;
  6759. i12 = HEAP32[i17 + (i14 + 12 + i13) >> 2] | 0;
  6760. i18 = 7200 + (i16 << 1 << 2) | 0;
  6761. if ((i5 | 0) != (i18 | 0)) {
  6762. if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6763. _abort();
  6764. }
  6765. if ((HEAP32[i5 + 12 >> 2] | 0) != (i15 | 0)) {
  6766. _abort();
  6767. }
  6768. }
  6769. if ((i12 | 0) == (i5 | 0)) {
  6770. HEAP32[1790] = HEAP32[1790] & ~(1 << i16);
  6771. break;
  6772. }
  6773. if ((i12 | 0) != (i18 | 0)) {
  6774. if (i12 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6775. _abort();
  6776. }
  6777. i16 = i12 + 8 | 0;
  6778. if ((HEAP32[i16 >> 2] | 0) == (i15 | 0)) {
  6779. i9 = i16;
  6780. } else {
  6781. _abort();
  6782. }
  6783. } else {
  6784. i9 = i12 + 8 | 0;
  6785. }
  6786. HEAP32[i5 + 12 >> 2] = i12;
  6787. HEAP32[i9 >> 2] = i5;
  6788. }
  6789. } while (0);
  6790. i15 = i17 + ((i11 | i13) + i14) | 0;
  6791. i10 = i11 + i10 | 0;
  6792. }
  6793. i5 = i15 + 4 | 0;
  6794. HEAP32[i5 >> 2] = HEAP32[i5 >> 2] & -2;
  6795. HEAP32[i17 + (i8 + 4) >> 2] = i10 | 1;
  6796. HEAP32[i17 + (i10 + i8) >> 2] = i10;
  6797. i5 = i10 >>> 3;
  6798. if (i10 >>> 0 < 256) {
  6799. i10 = i5 << 1;
  6800. i2 = 7200 + (i10 << 2) | 0;
  6801. i9 = HEAP32[1790] | 0;
  6802. i5 = 1 << i5;
  6803. if ((i9 & i5 | 0) != 0) {
  6804. i9 = 7200 + (i10 + 2 << 2) | 0;
  6805. i5 = HEAP32[i9 >> 2] | 0;
  6806. if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6807. _abort();
  6808. } else {
  6809. i3 = i9;
  6810. i4 = i5;
  6811. }
  6812. } else {
  6813. HEAP32[1790] = i9 | i5;
  6814. i3 = 7200 + (i10 + 2 << 2) | 0;
  6815. i4 = i2;
  6816. }
  6817. HEAP32[i3 >> 2] = i7;
  6818. HEAP32[i4 + 12 >> 2] = i7;
  6819. HEAP32[i17 + (i8 + 8) >> 2] = i4;
  6820. HEAP32[i17 + (i8 + 12) >> 2] = i2;
  6821. break;
  6822. }
  6823. i3 = i10 >>> 8;
  6824. if ((i3 | 0) != 0) {
  6825. if (i10 >>> 0 > 16777215) {
  6826. i3 = 31;
  6827. } else {
  6828. i31 = (i3 + 1048320 | 0) >>> 16 & 8;
  6829. i32 = i3 << i31;
  6830. i30 = (i32 + 520192 | 0) >>> 16 & 4;
  6831. i32 = i32 << i30;
  6832. i3 = (i32 + 245760 | 0) >>> 16 & 2;
  6833. i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
  6834. i3 = i10 >>> (i3 + 7 | 0) & 1 | i3 << 1;
  6835. }
  6836. } else {
  6837. i3 = 0;
  6838. }
  6839. i4 = 7464 + (i3 << 2) | 0;
  6840. HEAP32[i17 + (i8 + 28) >> 2] = i3;
  6841. HEAP32[i17 + (i8 + 20) >> 2] = 0;
  6842. HEAP32[i17 + (i8 + 16) >> 2] = 0;
  6843. i9 = HEAP32[7164 >> 2] | 0;
  6844. i5 = 1 << i3;
  6845. if ((i9 & i5 | 0) == 0) {
  6846. HEAP32[7164 >> 2] = i9 | i5;
  6847. HEAP32[i4 >> 2] = i7;
  6848. HEAP32[i17 + (i8 + 24) >> 2] = i4;
  6849. HEAP32[i17 + (i8 + 12) >> 2] = i7;
  6850. HEAP32[i17 + (i8 + 8) >> 2] = i7;
  6851. break;
  6852. }
  6853. i4 = HEAP32[i4 >> 2] | 0;
  6854. if ((i3 | 0) == 31) {
  6855. i3 = 0;
  6856. } else {
  6857. i3 = 25 - (i3 >>> 1) | 0;
  6858. }
  6859. L444 : do {
  6860. if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i10 | 0)) {
  6861. i3 = i10 << i3;
  6862. while (1) {
  6863. i5 = i4 + (i3 >>> 31 << 2) + 16 | 0;
  6864. i9 = HEAP32[i5 >> 2] | 0;
  6865. if ((i9 | 0) == 0) {
  6866. break;
  6867. }
  6868. if ((HEAP32[i9 + 4 >> 2] & -8 | 0) == (i10 | 0)) {
  6869. i2 = i9;
  6870. break L444;
  6871. } else {
  6872. i3 = i3 << 1;
  6873. i4 = i9;
  6874. }
  6875. }
  6876. if (i5 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6877. _abort();
  6878. } else {
  6879. HEAP32[i5 >> 2] = i7;
  6880. HEAP32[i17 + (i8 + 24) >> 2] = i4;
  6881. HEAP32[i17 + (i8 + 12) >> 2] = i7;
  6882. HEAP32[i17 + (i8 + 8) >> 2] = i7;
  6883. break L348;
  6884. }
  6885. } else {
  6886. i2 = i4;
  6887. }
  6888. } while (0);
  6889. i4 = i2 + 8 | 0;
  6890. i3 = HEAP32[i4 >> 2] | 0;
  6891. i5 = HEAP32[7176 >> 2] | 0;
  6892. if (i2 >>> 0 < i5 >>> 0) {
  6893. _abort();
  6894. }
  6895. if (i3 >>> 0 < i5 >>> 0) {
  6896. _abort();
  6897. } else {
  6898. HEAP32[i3 + 12 >> 2] = i7;
  6899. HEAP32[i4 >> 2] = i7;
  6900. HEAP32[i17 + (i8 + 8) >> 2] = i3;
  6901. HEAP32[i17 + (i8 + 12) >> 2] = i2;
  6902. HEAP32[i17 + (i8 + 24) >> 2] = 0;
  6903. break;
  6904. }
  6905. } else {
  6906. i32 = (HEAP32[7172 >> 2] | 0) + i10 | 0;
  6907. HEAP32[7172 >> 2] = i32;
  6908. HEAP32[7184 >> 2] = i7;
  6909. HEAP32[i17 + (i8 + 4) >> 2] = i32 | 1;
  6910. }
  6911. } while (0);
  6912. i32 = i17 + (i6 | 8) | 0;
  6913. STACKTOP = i1;
  6914. return i32 | 0;
  6915. }
  6916. i3 = 7608 | 0;
  6917. while (1) {
  6918. i2 = HEAP32[i3 >> 2] | 0;
  6919. if (!(i2 >>> 0 > i15 >>> 0) ? (i11 = HEAP32[i3 + 4 >> 2] | 0, i10 = i2 + i11 | 0, i10 >>> 0 > i15 >>> 0) : 0) {
  6920. break;
  6921. }
  6922. i3 = HEAP32[i3 + 8 >> 2] | 0;
  6923. }
  6924. i3 = i2 + (i11 + -39) | 0;
  6925. if ((i3 & 7 | 0) == 0) {
  6926. i3 = 0;
  6927. } else {
  6928. i3 = 0 - i3 & 7;
  6929. }
  6930. i2 = i2 + (i11 + -47 + i3) | 0;
  6931. i2 = i2 >>> 0 < (i15 + 16 | 0) >>> 0 ? i15 : i2;
  6932. i3 = i2 + 8 | 0;
  6933. i4 = i17 + 8 | 0;
  6934. if ((i4 & 7 | 0) == 0) {
  6935. i4 = 0;
  6936. } else {
  6937. i4 = 0 - i4 & 7;
  6938. }
  6939. i32 = i14 + -40 - i4 | 0;
  6940. HEAP32[7184 >> 2] = i17 + i4;
  6941. HEAP32[7172 >> 2] = i32;
  6942. HEAP32[i17 + (i4 + 4) >> 2] = i32 | 1;
  6943. HEAP32[i17 + (i14 + -36) >> 2] = 40;
  6944. HEAP32[7188 >> 2] = HEAP32[7648 >> 2];
  6945. HEAP32[i2 + 4 >> 2] = 27;
  6946. HEAP32[i3 + 0 >> 2] = HEAP32[7608 >> 2];
  6947. HEAP32[i3 + 4 >> 2] = HEAP32[7612 >> 2];
  6948. HEAP32[i3 + 8 >> 2] = HEAP32[7616 >> 2];
  6949. HEAP32[i3 + 12 >> 2] = HEAP32[7620 >> 2];
  6950. HEAP32[7608 >> 2] = i17;
  6951. HEAP32[7612 >> 2] = i14;
  6952. HEAP32[7620 >> 2] = 0;
  6953. HEAP32[7616 >> 2] = i3;
  6954. i4 = i2 + 28 | 0;
  6955. HEAP32[i4 >> 2] = 7;
  6956. if ((i2 + 32 | 0) >>> 0 < i10 >>> 0) {
  6957. while (1) {
  6958. i3 = i4 + 4 | 0;
  6959. HEAP32[i3 >> 2] = 7;
  6960. if ((i4 + 8 | 0) >>> 0 < i10 >>> 0) {
  6961. i4 = i3;
  6962. } else {
  6963. break;
  6964. }
  6965. }
  6966. }
  6967. if ((i2 | 0) != (i15 | 0)) {
  6968. i2 = i2 - i15 | 0;
  6969. i3 = i15 + (i2 + 4) | 0;
  6970. HEAP32[i3 >> 2] = HEAP32[i3 >> 2] & -2;
  6971. HEAP32[i15 + 4 >> 2] = i2 | 1;
  6972. HEAP32[i15 + i2 >> 2] = i2;
  6973. i3 = i2 >>> 3;
  6974. if (i2 >>> 0 < 256) {
  6975. i4 = i3 << 1;
  6976. i2 = 7200 + (i4 << 2) | 0;
  6977. i5 = HEAP32[1790] | 0;
  6978. i3 = 1 << i3;
  6979. if ((i5 & i3 | 0) != 0) {
  6980. i4 = 7200 + (i4 + 2 << 2) | 0;
  6981. i3 = HEAP32[i4 >> 2] | 0;
  6982. if (i3 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  6983. _abort();
  6984. } else {
  6985. i7 = i4;
  6986. i8 = i3;
  6987. }
  6988. } else {
  6989. HEAP32[1790] = i5 | i3;
  6990. i7 = 7200 + (i4 + 2 << 2) | 0;
  6991. i8 = i2;
  6992. }
  6993. HEAP32[i7 >> 2] = i15;
  6994. HEAP32[i8 + 12 >> 2] = i15;
  6995. HEAP32[i15 + 8 >> 2] = i8;
  6996. HEAP32[i15 + 12 >> 2] = i2;
  6997. break;
  6998. }
  6999. i3 = i2 >>> 8;
  7000. if ((i3 | 0) != 0) {
  7001. if (i2 >>> 0 > 16777215) {
  7002. i3 = 31;
  7003. } else {
  7004. i31 = (i3 + 1048320 | 0) >>> 16 & 8;
  7005. i32 = i3 << i31;
  7006. i30 = (i32 + 520192 | 0) >>> 16 & 4;
  7007. i32 = i32 << i30;
  7008. i3 = (i32 + 245760 | 0) >>> 16 & 2;
  7009. i3 = 14 - (i30 | i31 | i3) + (i32 << i3 >>> 15) | 0;
  7010. i3 = i2 >>> (i3 + 7 | 0) & 1 | i3 << 1;
  7011. }
  7012. } else {
  7013. i3 = 0;
  7014. }
  7015. i7 = 7464 + (i3 << 2) | 0;
  7016. HEAP32[i15 + 28 >> 2] = i3;
  7017. HEAP32[i15 + 20 >> 2] = 0;
  7018. HEAP32[i15 + 16 >> 2] = 0;
  7019. i4 = HEAP32[7164 >> 2] | 0;
  7020. i5 = 1 << i3;
  7021. if ((i4 & i5 | 0) == 0) {
  7022. HEAP32[7164 >> 2] = i4 | i5;
  7023. HEAP32[i7 >> 2] = i15;
  7024. HEAP32[i15 + 24 >> 2] = i7;
  7025. HEAP32[i15 + 12 >> 2] = i15;
  7026. HEAP32[i15 + 8 >> 2] = i15;
  7027. break;
  7028. }
  7029. i4 = HEAP32[i7 >> 2] | 0;
  7030. if ((i3 | 0) == 31) {
  7031. i3 = 0;
  7032. } else {
  7033. i3 = 25 - (i3 >>> 1) | 0;
  7034. }
  7035. L499 : do {
  7036. if ((HEAP32[i4 + 4 >> 2] & -8 | 0) != (i2 | 0)) {
  7037. i3 = i2 << i3;
  7038. while (1) {
  7039. i7 = i4 + (i3 >>> 31 << 2) + 16 | 0;
  7040. i5 = HEAP32[i7 >> 2] | 0;
  7041. if ((i5 | 0) == 0) {
  7042. break;
  7043. }
  7044. if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i2 | 0)) {
  7045. i6 = i5;
  7046. break L499;
  7047. } else {
  7048. i3 = i3 << 1;
  7049. i4 = i5;
  7050. }
  7051. }
  7052. if (i7 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  7053. _abort();
  7054. } else {
  7055. HEAP32[i7 >> 2] = i15;
  7056. HEAP32[i15 + 24 >> 2] = i4;
  7057. HEAP32[i15 + 12 >> 2] = i15;
  7058. HEAP32[i15 + 8 >> 2] = i15;
  7059. break L311;
  7060. }
  7061. } else {
  7062. i6 = i4;
  7063. }
  7064. } while (0);
  7065. i4 = i6 + 8 | 0;
  7066. i3 = HEAP32[i4 >> 2] | 0;
  7067. i2 = HEAP32[7176 >> 2] | 0;
  7068. if (i6 >>> 0 < i2 >>> 0) {
  7069. _abort();
  7070. }
  7071. if (i3 >>> 0 < i2 >>> 0) {
  7072. _abort();
  7073. } else {
  7074. HEAP32[i3 + 12 >> 2] = i15;
  7075. HEAP32[i4 >> 2] = i15;
  7076. HEAP32[i15 + 8 >> 2] = i3;
  7077. HEAP32[i15 + 12 >> 2] = i6;
  7078. HEAP32[i15 + 24 >> 2] = 0;
  7079. break;
  7080. }
  7081. }
  7082. } else {
  7083. i32 = HEAP32[7176 >> 2] | 0;
  7084. if ((i32 | 0) == 0 | i17 >>> 0 < i32 >>> 0) {
  7085. HEAP32[7176 >> 2] = i17;
  7086. }
  7087. HEAP32[7608 >> 2] = i17;
  7088. HEAP32[7612 >> 2] = i14;
  7089. HEAP32[7620 >> 2] = 0;
  7090. HEAP32[7196 >> 2] = HEAP32[1908];
  7091. HEAP32[7192 >> 2] = -1;
  7092. i2 = 0;
  7093. do {
  7094. i32 = i2 << 1;
  7095. i31 = 7200 + (i32 << 2) | 0;
  7096. HEAP32[7200 + (i32 + 3 << 2) >> 2] = i31;
  7097. HEAP32[7200 + (i32 + 2 << 2) >> 2] = i31;
  7098. i2 = i2 + 1 | 0;
  7099. } while ((i2 | 0) != 32);
  7100. i2 = i17 + 8 | 0;
  7101. if ((i2 & 7 | 0) == 0) {
  7102. i2 = 0;
  7103. } else {
  7104. i2 = 0 - i2 & 7;
  7105. }
  7106. i32 = i14 + -40 - i2 | 0;
  7107. HEAP32[7184 >> 2] = i17 + i2;
  7108. HEAP32[7172 >> 2] = i32;
  7109. HEAP32[i17 + (i2 + 4) >> 2] = i32 | 1;
  7110. HEAP32[i17 + (i14 + -36) >> 2] = 40;
  7111. HEAP32[7188 >> 2] = HEAP32[7648 >> 2];
  7112. }
  7113. } while (0);
  7114. i2 = HEAP32[7172 >> 2] | 0;
  7115. if (i2 >>> 0 > i12 >>> 0) {
  7116. i31 = i2 - i12 | 0;
  7117. HEAP32[7172 >> 2] = i31;
  7118. i32 = HEAP32[7184 >> 2] | 0;
  7119. HEAP32[7184 >> 2] = i32 + i12;
  7120. HEAP32[i32 + (i12 + 4) >> 2] = i31 | 1;
  7121. HEAP32[i32 + 4 >> 2] = i12 | 3;
  7122. i32 = i32 + 8 | 0;
  7123. STACKTOP = i1;
  7124. return i32 | 0;
  7125. }
  7126. }
  7127. HEAP32[(___errno_location() | 0) >> 2] = 12;
  7128. i32 = 0;
  7129. STACKTOP = i1;
  7130. return i32 | 0;
  7131. }
  7132. function __ZN12b2EPCollider7CollideEP10b2ManifoldPK11b2EdgeShapeRK11b2TransformPK14b2PolygonShapeS7_(i12, i2, i16, i5, i8, i6) {
  7133. i12 = i12 | 0;
  7134. i2 = i2 | 0;
  7135. i16 = i16 | 0;
  7136. i5 = i5 | 0;
  7137. i8 = i8 | 0;
  7138. i6 = i6 | 0;
  7139. var i1 = 0, i3 = 0, i4 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i13 = 0, i14 = 0, i15 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, i29 = 0, d30 = 0.0, d31 = 0.0, d32 = 0.0, d33 = 0.0, i34 = 0, i35 = 0, d36 = 0.0, d37 = 0.0, i38 = 0, d39 = 0.0, i40 = 0, i41 = 0;
  7140. i1 = STACKTOP;
  7141. STACKTOP = STACKTOP + 144 | 0;
  7142. i18 = i1 + 128 | 0;
  7143. i11 = i1 + 24 | 0;
  7144. i9 = i1 + 72 | 0;
  7145. i10 = i1 + 48 | 0;
  7146. i3 = i1;
  7147. i4 = i12 + 132 | 0;
  7148. d28 = +HEAPF32[i5 + 12 >> 2];
  7149. d37 = +HEAPF32[i6 + 8 >> 2];
  7150. d23 = +HEAPF32[i5 + 8 >> 2];
  7151. d27 = +HEAPF32[i6 + 12 >> 2];
  7152. d22 = d28 * d37 - d23 * d27;
  7153. d27 = d37 * d23 + d28 * d27;
  7154. d37 = +d22;
  7155. d26 = +d27;
  7156. d25 = +HEAPF32[i6 >> 2] - +HEAPF32[i5 >> 2];
  7157. d36 = +HEAPF32[i6 + 4 >> 2] - +HEAPF32[i5 + 4 >> 2];
  7158. d24 = d28 * d25 + d23 * d36;
  7159. d25 = d28 * d36 - d23 * d25;
  7160. d23 = +d24;
  7161. d36 = +d25;
  7162. i5 = i4;
  7163. HEAPF32[i5 >> 2] = d23;
  7164. HEAPF32[i5 + 4 >> 2] = d36;
  7165. i5 = i12 + 140 | 0;
  7166. HEAPF32[i5 >> 2] = d37;
  7167. HEAPF32[i5 + 4 >> 2] = d26;
  7168. i5 = i12 + 144 | 0;
  7169. d26 = +HEAPF32[i8 + 12 >> 2];
  7170. i7 = i12 + 140 | 0;
  7171. d37 = +HEAPF32[i8 + 16 >> 2];
  7172. d24 = d24 + (d27 * d26 - d22 * d37);
  7173. i6 = i12 + 136 | 0;
  7174. d25 = d26 * d22 + d27 * d37 + d25;
  7175. d37 = +d24;
  7176. d27 = +d25;
  7177. i34 = i12 + 148 | 0;
  7178. HEAPF32[i34 >> 2] = d37;
  7179. HEAPF32[i34 + 4 >> 2] = d27;
  7180. i34 = i16 + 28 | 0;
  7181. i29 = HEAP32[i34 >> 2] | 0;
  7182. i34 = HEAP32[i34 + 4 >> 2] | 0;
  7183. i14 = i12 + 156 | 0;
  7184. HEAP32[i14 >> 2] = i29;
  7185. HEAP32[i14 + 4 >> 2] = i34;
  7186. i14 = i12 + 164 | 0;
  7187. i17 = i16 + 12 | 0;
  7188. i40 = HEAP32[i17 >> 2] | 0;
  7189. i17 = HEAP32[i17 + 4 >> 2] | 0;
  7190. i13 = i14;
  7191. HEAP32[i13 >> 2] = i40;
  7192. HEAP32[i13 + 4 >> 2] = i17;
  7193. i13 = i12 + 172 | 0;
  7194. i20 = i16 + 20 | 0;
  7195. i41 = HEAP32[i20 >> 2] | 0;
  7196. i20 = HEAP32[i20 + 4 >> 2] | 0;
  7197. i38 = i13;
  7198. HEAP32[i38 >> 2] = i41;
  7199. HEAP32[i38 + 4 >> 2] = i20;
  7200. i38 = i16 + 36 | 0;
  7201. i35 = HEAP32[i38 >> 2] | 0;
  7202. i38 = HEAP32[i38 + 4 >> 2] | 0;
  7203. i19 = i12 + 180 | 0;
  7204. HEAP32[i19 >> 2] = i35;
  7205. HEAP32[i19 + 4 >> 2] = i38;
  7206. i19 = (HEAP8[i16 + 44 | 0] | 0) != 0;
  7207. i21 = (HEAP8[i16 + 45 | 0] | 0) != 0;
  7208. d27 = (HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
  7209. d37 = (HEAP32[tempDoublePtr >> 2] = i40, +HEAPF32[tempDoublePtr >> 2]);
  7210. d22 = d27 - d37;
  7211. d26 = (HEAP32[tempDoublePtr >> 2] = i20, +HEAPF32[tempDoublePtr >> 2]);
  7212. i20 = i12 + 168 | 0;
  7213. d36 = (HEAP32[tempDoublePtr >> 2] = i17, +HEAPF32[tempDoublePtr >> 2]);
  7214. d23 = d26 - d36;
  7215. d28 = +Math_sqrt(+(d22 * d22 + d23 * d23));
  7216. d33 = (HEAP32[tempDoublePtr >> 2] = i29, +HEAPF32[tempDoublePtr >> 2]);
  7217. d32 = (HEAP32[tempDoublePtr >> 2] = i34, +HEAPF32[tempDoublePtr >> 2]);
  7218. d31 = (HEAP32[tempDoublePtr >> 2] = i35, +HEAPF32[tempDoublePtr >> 2]);
  7219. d30 = (HEAP32[tempDoublePtr >> 2] = i38, +HEAPF32[tempDoublePtr >> 2]);
  7220. if (!(d28 < 1.1920928955078125e-7)) {
  7221. d39 = 1.0 / d28;
  7222. d22 = d22 * d39;
  7223. d23 = d23 * d39;
  7224. }
  7225. i16 = i12 + 196 | 0;
  7226. d28 = -d22;
  7227. HEAPF32[i16 >> 2] = d23;
  7228. i17 = i12 + 200 | 0;
  7229. HEAPF32[i17 >> 2] = d28;
  7230. d28 = (d24 - d37) * d23 + (d25 - d36) * d28;
  7231. if (i19) {
  7232. d37 = d37 - d33;
  7233. d36 = d36 - d32;
  7234. d39 = +Math_sqrt(+(d37 * d37 + d36 * d36));
  7235. if (!(d39 < 1.1920928955078125e-7)) {
  7236. d39 = 1.0 / d39;
  7237. d37 = d37 * d39;
  7238. d36 = d36 * d39;
  7239. }
  7240. d39 = -d37;
  7241. HEAPF32[i12 + 188 >> 2] = d36;
  7242. HEAPF32[i12 + 192 >> 2] = d39;
  7243. i29 = d23 * d37 - d22 * d36 >= 0.0;
  7244. d32 = (d24 - d33) * d36 + (d25 - d32) * d39;
  7245. } else {
  7246. i29 = 0;
  7247. d32 = 0.0;
  7248. }
  7249. L10 : do {
  7250. if (!i21) {
  7251. if (!i19) {
  7252. i41 = d28 >= 0.0;
  7253. HEAP8[i12 + 248 | 0] = i41 & 1;
  7254. i19 = i12 + 212 | 0;
  7255. if (i41) {
  7256. i15 = 64;
  7257. break;
  7258. } else {
  7259. i15 = 65;
  7260. break;
  7261. }
  7262. }
  7263. i19 = d32 >= 0.0;
  7264. if (i29) {
  7265. if (!i19) {
  7266. i41 = d28 >= 0.0;
  7267. HEAP8[i12 + 248 | 0] = i41 & 1;
  7268. i19 = i12 + 212 | 0;
  7269. if (!i41) {
  7270. d37 = +-d23;
  7271. d39 = +d22;
  7272. i38 = i19;
  7273. HEAPF32[i38 >> 2] = d37;
  7274. HEAPF32[i38 + 4 >> 2] = d39;
  7275. i38 = i16;
  7276. i40 = HEAP32[i38 >> 2] | 0;
  7277. i38 = HEAP32[i38 + 4 >> 2] | 0;
  7278. i41 = i12 + 228 | 0;
  7279. HEAP32[i41 >> 2] = i40;
  7280. HEAP32[i41 + 4 >> 2] = i38;
  7281. i41 = i12 + 236 | 0;
  7282. HEAPF32[i41 >> 2] = -(HEAP32[tempDoublePtr >> 2] = i40, +HEAPF32[tempDoublePtr >> 2]);
  7283. HEAPF32[i41 + 4 >> 2] = d39;
  7284. break;
  7285. }
  7286. } else {
  7287. HEAP8[i12 + 248 | 0] = 1;
  7288. i19 = i12 + 212 | 0;
  7289. }
  7290. i41 = i16;
  7291. i40 = HEAP32[i41 + 4 >> 2] | 0;
  7292. i38 = i19;
  7293. HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
  7294. HEAP32[i38 + 4 >> 2] = i40;
  7295. i38 = i12 + 188 | 0;
  7296. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7297. i41 = i12 + 228 | 0;
  7298. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7299. HEAP32[i41 + 4 >> 2] = i40;
  7300. d37 = +-+HEAPF32[i16 >> 2];
  7301. d39 = +-+HEAPF32[i17 >> 2];
  7302. i41 = i12 + 236 | 0;
  7303. HEAPF32[i41 >> 2] = d37;
  7304. HEAPF32[i41 + 4 >> 2] = d39;
  7305. break;
  7306. } else {
  7307. if (i19) {
  7308. i41 = d28 >= 0.0;
  7309. HEAP8[i12 + 248 | 0] = i41 & 1;
  7310. i19 = i12 + 212 | 0;
  7311. if (i41) {
  7312. i38 = i16;
  7313. i41 = HEAP32[i38 >> 2] | 0;
  7314. i38 = HEAP32[i38 + 4 >> 2] | 0;
  7315. i40 = i19;
  7316. HEAP32[i40 >> 2] = i41;
  7317. HEAP32[i40 + 4 >> 2] = i38;
  7318. i40 = i12 + 228 | 0;
  7319. HEAP32[i40 >> 2] = i41;
  7320. HEAP32[i40 + 4 >> 2] = i38;
  7321. d37 = +-(HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
  7322. d39 = +d22;
  7323. i41 = i12 + 236 | 0;
  7324. HEAPF32[i41 >> 2] = d37;
  7325. HEAPF32[i41 + 4 >> 2] = d39;
  7326. break;
  7327. }
  7328. } else {
  7329. HEAP8[i12 + 248 | 0] = 0;
  7330. i19 = i12 + 212 | 0;
  7331. }
  7332. d39 = +-d23;
  7333. d37 = +d22;
  7334. i38 = i19;
  7335. HEAPF32[i38 >> 2] = d39;
  7336. HEAPF32[i38 + 4 >> 2] = d37;
  7337. i38 = i16;
  7338. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7339. i41 = i12 + 228 | 0;
  7340. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7341. HEAP32[i41 + 4 >> 2] = i40;
  7342. d37 = +-+HEAPF32[i12 + 188 >> 2];
  7343. d39 = +-+HEAPF32[i12 + 192 >> 2];
  7344. i41 = i12 + 236 | 0;
  7345. HEAPF32[i41 >> 2] = d37;
  7346. HEAPF32[i41 + 4 >> 2] = d39;
  7347. break;
  7348. }
  7349. } else {
  7350. d33 = d31 - d27;
  7351. d31 = d30 - d26;
  7352. d30 = +Math_sqrt(+(d33 * d33 + d31 * d31));
  7353. if (d30 < 1.1920928955078125e-7) {
  7354. d30 = d33;
  7355. } else {
  7356. d39 = 1.0 / d30;
  7357. d30 = d33 * d39;
  7358. d31 = d31 * d39;
  7359. }
  7360. d39 = -d30;
  7361. i34 = i12 + 204 | 0;
  7362. HEAPF32[i34 >> 2] = d31;
  7363. i35 = i12 + 208 | 0;
  7364. HEAPF32[i35 >> 2] = d39;
  7365. i38 = d22 * d31 - d23 * d30 > 0.0;
  7366. d24 = (d24 - d27) * d31 + (d25 - d26) * d39;
  7367. if (!i19) {
  7368. i19 = d28 >= 0.0;
  7369. if (!i21) {
  7370. HEAP8[i12 + 248 | 0] = i19 & 1;
  7371. i15 = i12 + 212 | 0;
  7372. if (i19) {
  7373. i19 = i15;
  7374. i15 = 64;
  7375. break;
  7376. } else {
  7377. i19 = i15;
  7378. i15 = 65;
  7379. break;
  7380. }
  7381. }
  7382. if (i38) {
  7383. if (!i19) {
  7384. i41 = d24 >= 0.0;
  7385. HEAP8[i12 + 248 | 0] = i41 & 1;
  7386. i19 = i12 + 212 | 0;
  7387. if (!i41) {
  7388. d37 = +-d23;
  7389. d39 = +d22;
  7390. i38 = i19;
  7391. HEAPF32[i38 >> 2] = d37;
  7392. HEAPF32[i38 + 4 >> 2] = d39;
  7393. i38 = i12 + 228 | 0;
  7394. HEAPF32[i38 >> 2] = d37;
  7395. HEAPF32[i38 + 4 >> 2] = d39;
  7396. i38 = i16;
  7397. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7398. i41 = i12 + 236 | 0;
  7399. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7400. HEAP32[i41 + 4 >> 2] = i40;
  7401. break;
  7402. }
  7403. } else {
  7404. HEAP8[i12 + 248 | 0] = 1;
  7405. i19 = i12 + 212 | 0;
  7406. }
  7407. i41 = i16;
  7408. i40 = HEAP32[i41 + 4 >> 2] | 0;
  7409. i38 = i19;
  7410. HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
  7411. HEAP32[i38 + 4 >> 2] = i40;
  7412. d37 = +-+HEAPF32[i16 >> 2];
  7413. d39 = +-+HEAPF32[i17 >> 2];
  7414. i38 = i12 + 228 | 0;
  7415. HEAPF32[i38 >> 2] = d37;
  7416. HEAPF32[i38 + 4 >> 2] = d39;
  7417. i38 = i12 + 204 | 0;
  7418. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7419. i41 = i12 + 236 | 0;
  7420. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7421. HEAP32[i41 + 4 >> 2] = i40;
  7422. break;
  7423. } else {
  7424. if (i19) {
  7425. i41 = d24 >= 0.0;
  7426. HEAP8[i12 + 248 | 0] = i41 & 1;
  7427. i19 = i12 + 212 | 0;
  7428. if (i41) {
  7429. i40 = i16;
  7430. i38 = HEAP32[i40 >> 2] | 0;
  7431. i40 = HEAP32[i40 + 4 >> 2] | 0;
  7432. i41 = i19;
  7433. HEAP32[i41 >> 2] = i38;
  7434. HEAP32[i41 + 4 >> 2] = i40;
  7435. d37 = +-(HEAP32[tempDoublePtr >> 2] = i38, +HEAPF32[tempDoublePtr >> 2]);
  7436. d39 = +d22;
  7437. i41 = i12 + 228 | 0;
  7438. HEAPF32[i41 >> 2] = d37;
  7439. HEAPF32[i41 + 4 >> 2] = d39;
  7440. i41 = i12 + 236 | 0;
  7441. HEAP32[i41 >> 2] = i38;
  7442. HEAP32[i41 + 4 >> 2] = i40;
  7443. break;
  7444. }
  7445. } else {
  7446. HEAP8[i12 + 248 | 0] = 0;
  7447. i19 = i12 + 212 | 0;
  7448. }
  7449. d39 = +-d23;
  7450. d37 = +d22;
  7451. i38 = i19;
  7452. HEAPF32[i38 >> 2] = d39;
  7453. HEAPF32[i38 + 4 >> 2] = d37;
  7454. d37 = +-+HEAPF32[i12 + 204 >> 2];
  7455. d39 = +-+HEAPF32[i12 + 208 >> 2];
  7456. i38 = i12 + 228 | 0;
  7457. HEAPF32[i38 >> 2] = d37;
  7458. HEAPF32[i38 + 4 >> 2] = d39;
  7459. i38 = i16;
  7460. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7461. i41 = i12 + 236 | 0;
  7462. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7463. HEAP32[i41 + 4 >> 2] = i40;
  7464. break;
  7465. }
  7466. }
  7467. if (i29 & i38) {
  7468. if (!(d32 >= 0.0) & !(d28 >= 0.0)) {
  7469. i41 = d24 >= 0.0;
  7470. HEAP8[i12 + 248 | 0] = i41 & 1;
  7471. i19 = i12 + 212 | 0;
  7472. if (!i41) {
  7473. d37 = +-d23;
  7474. d39 = +d22;
  7475. i41 = i19;
  7476. HEAPF32[i41 >> 2] = d37;
  7477. HEAPF32[i41 + 4 >> 2] = d39;
  7478. i41 = i12 + 228 | 0;
  7479. HEAPF32[i41 >> 2] = d37;
  7480. HEAPF32[i41 + 4 >> 2] = d39;
  7481. i41 = i12 + 236 | 0;
  7482. HEAPF32[i41 >> 2] = d37;
  7483. HEAPF32[i41 + 4 >> 2] = d39;
  7484. break;
  7485. }
  7486. } else {
  7487. HEAP8[i12 + 248 | 0] = 1;
  7488. i19 = i12 + 212 | 0;
  7489. }
  7490. i38 = i16;
  7491. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7492. i41 = i19;
  7493. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7494. HEAP32[i41 + 4 >> 2] = i40;
  7495. i41 = i12 + 188 | 0;
  7496. i40 = HEAP32[i41 + 4 >> 2] | 0;
  7497. i38 = i12 + 228 | 0;
  7498. HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
  7499. HEAP32[i38 + 4 >> 2] = i40;
  7500. i38 = i12 + 204 | 0;
  7501. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7502. i41 = i12 + 236 | 0;
  7503. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7504. HEAP32[i41 + 4 >> 2] = i40;
  7505. break;
  7506. }
  7507. if (i29) {
  7508. do {
  7509. if (!(d32 >= 0.0)) {
  7510. if (d28 >= 0.0) {
  7511. i41 = d24 >= 0.0;
  7512. HEAP8[i12 + 248 | 0] = i41 & 1;
  7513. i19 = i12 + 212 | 0;
  7514. if (i41) {
  7515. break;
  7516. }
  7517. } else {
  7518. HEAP8[i12 + 248 | 0] = 0;
  7519. i19 = i12 + 212 | 0;
  7520. }
  7521. d37 = +-d23;
  7522. d39 = +d22;
  7523. i41 = i19;
  7524. HEAPF32[i41 >> 2] = d37;
  7525. HEAPF32[i41 + 4 >> 2] = d39;
  7526. d39 = +-+HEAPF32[i34 >> 2];
  7527. d37 = +-+HEAPF32[i35 >> 2];
  7528. i41 = i12 + 228 | 0;
  7529. HEAPF32[i41 >> 2] = d39;
  7530. HEAPF32[i41 + 4 >> 2] = d37;
  7531. d37 = +-+HEAPF32[i16 >> 2];
  7532. d39 = +-+HEAPF32[i17 >> 2];
  7533. i41 = i12 + 236 | 0;
  7534. HEAPF32[i41 >> 2] = d37;
  7535. HEAPF32[i41 + 4 >> 2] = d39;
  7536. break L10;
  7537. } else {
  7538. HEAP8[i12 + 248 | 0] = 1;
  7539. i19 = i12 + 212 | 0;
  7540. }
  7541. } while (0);
  7542. i38 = i16;
  7543. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7544. i41 = i19;
  7545. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7546. HEAP32[i41 + 4 >> 2] = i40;
  7547. i41 = i12 + 188 | 0;
  7548. i40 = HEAP32[i41 + 4 >> 2] | 0;
  7549. i38 = i12 + 228 | 0;
  7550. HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
  7551. HEAP32[i38 + 4 >> 2] = i40;
  7552. i38 = i16;
  7553. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7554. i41 = i12 + 236 | 0;
  7555. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7556. HEAP32[i41 + 4 >> 2] = i40;
  7557. break;
  7558. }
  7559. if (!i38) {
  7560. if (!(!(d32 >= 0.0) | !(d28 >= 0.0))) {
  7561. i41 = d24 >= 0.0;
  7562. HEAP8[i12 + 248 | 0] = i41 & 1;
  7563. i19 = i12 + 212 | 0;
  7564. if (i41) {
  7565. i40 = i16;
  7566. i38 = HEAP32[i40 >> 2] | 0;
  7567. i40 = HEAP32[i40 + 4 >> 2] | 0;
  7568. i41 = i19;
  7569. HEAP32[i41 >> 2] = i38;
  7570. HEAP32[i41 + 4 >> 2] = i40;
  7571. i41 = i12 + 228 | 0;
  7572. HEAP32[i41 >> 2] = i38;
  7573. HEAP32[i41 + 4 >> 2] = i40;
  7574. i41 = i12 + 236 | 0;
  7575. HEAP32[i41 >> 2] = i38;
  7576. HEAP32[i41 + 4 >> 2] = i40;
  7577. break;
  7578. }
  7579. } else {
  7580. HEAP8[i12 + 248 | 0] = 0;
  7581. i19 = i12 + 212 | 0;
  7582. }
  7583. d37 = +-d23;
  7584. d39 = +d22;
  7585. i41 = i19;
  7586. HEAPF32[i41 >> 2] = d37;
  7587. HEAPF32[i41 + 4 >> 2] = d39;
  7588. d39 = +-+HEAPF32[i34 >> 2];
  7589. d37 = +-+HEAPF32[i35 >> 2];
  7590. i41 = i12 + 228 | 0;
  7591. HEAPF32[i41 >> 2] = d39;
  7592. HEAPF32[i41 + 4 >> 2] = d37;
  7593. d37 = +-+HEAPF32[i12 + 188 >> 2];
  7594. d39 = +-+HEAPF32[i12 + 192 >> 2];
  7595. i41 = i12 + 236 | 0;
  7596. HEAPF32[i41 >> 2] = d37;
  7597. HEAPF32[i41 + 4 >> 2] = d39;
  7598. break;
  7599. }
  7600. do {
  7601. if (!(d24 >= 0.0)) {
  7602. if (d32 >= 0.0) {
  7603. i41 = d28 >= 0.0;
  7604. HEAP8[i12 + 248 | 0] = i41 & 1;
  7605. i19 = i12 + 212 | 0;
  7606. if (i41) {
  7607. break;
  7608. }
  7609. } else {
  7610. HEAP8[i12 + 248 | 0] = 0;
  7611. i19 = i12 + 212 | 0;
  7612. }
  7613. d37 = +-d23;
  7614. d39 = +d22;
  7615. i41 = i19;
  7616. HEAPF32[i41 >> 2] = d37;
  7617. HEAPF32[i41 + 4 >> 2] = d39;
  7618. d39 = +-+HEAPF32[i16 >> 2];
  7619. d37 = +-+HEAPF32[i17 >> 2];
  7620. i41 = i12 + 228 | 0;
  7621. HEAPF32[i41 >> 2] = d39;
  7622. HEAPF32[i41 + 4 >> 2] = d37;
  7623. d37 = +-+HEAPF32[i12 + 188 >> 2];
  7624. d39 = +-+HEAPF32[i12 + 192 >> 2];
  7625. i41 = i12 + 236 | 0;
  7626. HEAPF32[i41 >> 2] = d37;
  7627. HEAPF32[i41 + 4 >> 2] = d39;
  7628. break L10;
  7629. } else {
  7630. HEAP8[i12 + 248 | 0] = 1;
  7631. i19 = i12 + 212 | 0;
  7632. }
  7633. } while (0);
  7634. i38 = i16;
  7635. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7636. i41 = i19;
  7637. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7638. HEAP32[i41 + 4 >> 2] = i40;
  7639. i41 = i16;
  7640. i40 = HEAP32[i41 + 4 >> 2] | 0;
  7641. i38 = i12 + 228 | 0;
  7642. HEAP32[i38 >> 2] = HEAP32[i41 >> 2];
  7643. HEAP32[i38 + 4 >> 2] = i40;
  7644. i38 = i12 + 204 | 0;
  7645. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7646. i41 = i12 + 236 | 0;
  7647. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  7648. HEAP32[i41 + 4 >> 2] = i40;
  7649. }
  7650. } while (0);
  7651. if ((i15 | 0) == 64) {
  7652. i38 = i16;
  7653. i41 = HEAP32[i38 >> 2] | 0;
  7654. i38 = HEAP32[i38 + 4 >> 2] | 0;
  7655. i40 = i19;
  7656. HEAP32[i40 >> 2] = i41;
  7657. HEAP32[i40 + 4 >> 2] = i38;
  7658. d37 = +-(HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
  7659. d39 = +d22;
  7660. i41 = i12 + 228 | 0;
  7661. HEAPF32[i41 >> 2] = d37;
  7662. HEAPF32[i41 + 4 >> 2] = d39;
  7663. i41 = i12 + 236 | 0;
  7664. HEAPF32[i41 >> 2] = d37;
  7665. HEAPF32[i41 + 4 >> 2] = d39;
  7666. } else if ((i15 | 0) == 65) {
  7667. d37 = +-d23;
  7668. d39 = +d22;
  7669. i40 = i19;
  7670. HEAPF32[i40 >> 2] = d37;
  7671. HEAPF32[i40 + 4 >> 2] = d39;
  7672. i40 = i16;
  7673. i38 = HEAP32[i40 >> 2] | 0;
  7674. i40 = HEAP32[i40 + 4 >> 2] | 0;
  7675. i41 = i12 + 228 | 0;
  7676. HEAP32[i41 >> 2] = i38;
  7677. HEAP32[i41 + 4 >> 2] = i40;
  7678. i41 = i12 + 236 | 0;
  7679. HEAP32[i41 >> 2] = i38;
  7680. HEAP32[i41 + 4 >> 2] = i40;
  7681. }
  7682. i21 = i8 + 148 | 0;
  7683. i34 = i12 + 128 | 0;
  7684. HEAP32[i34 >> 2] = HEAP32[i21 >> 2];
  7685. if ((HEAP32[i21 >> 2] | 0) > 0) {
  7686. i19 = 0;
  7687. do {
  7688. d33 = +HEAPF32[i5 >> 2];
  7689. d37 = +HEAPF32[i8 + (i19 << 3) + 20 >> 2];
  7690. d39 = +HEAPF32[i7 >> 2];
  7691. d36 = +HEAPF32[i8 + (i19 << 3) + 24 >> 2];
  7692. d32 = +(+HEAPF32[i4 >> 2] + (d33 * d37 - d39 * d36));
  7693. d36 = +(d37 * d39 + d33 * d36 + +HEAPF32[i6 >> 2]);
  7694. i41 = i12 + (i19 << 3) | 0;
  7695. HEAPF32[i41 >> 2] = d32;
  7696. HEAPF32[i41 + 4 >> 2] = d36;
  7697. d36 = +HEAPF32[i5 >> 2];
  7698. d32 = +HEAPF32[i8 + (i19 << 3) + 84 >> 2];
  7699. d33 = +HEAPF32[i7 >> 2];
  7700. d39 = +HEAPF32[i8 + (i19 << 3) + 88 >> 2];
  7701. d37 = +(d36 * d32 - d33 * d39);
  7702. d39 = +(d32 * d33 + d36 * d39);
  7703. i41 = i12 + (i19 << 3) + 64 | 0;
  7704. HEAPF32[i41 >> 2] = d37;
  7705. HEAPF32[i41 + 4 >> 2] = d39;
  7706. i19 = i19 + 1 | 0;
  7707. } while ((i19 | 0) < (HEAP32[i21 >> 2] | 0));
  7708. }
  7709. i21 = i12 + 244 | 0;
  7710. HEAPF32[i21 >> 2] = .019999999552965164;
  7711. i19 = i2 + 60 | 0;
  7712. HEAP32[i19 >> 2] = 0;
  7713. i29 = i12 + 248 | 0;
  7714. i35 = HEAP32[i34 >> 2] | 0;
  7715. if ((i35 | 0) <= 0) {
  7716. STACKTOP = i1;
  7717. return;
  7718. }
  7719. d23 = +HEAPF32[i12 + 164 >> 2];
  7720. d26 = +HEAPF32[i20 >> 2];
  7721. d24 = +HEAPF32[i12 + 212 >> 2];
  7722. d27 = +HEAPF32[i12 + 216 >> 2];
  7723. d22 = 3.4028234663852886e+38;
  7724. i20 = 0;
  7725. do {
  7726. d25 = d24 * (+HEAPF32[i12 + (i20 << 3) >> 2] - d23) + d27 * (+HEAPF32[i12 + (i20 << 3) + 4 >> 2] - d26);
  7727. d22 = d25 < d22 ? d25 : d22;
  7728. i20 = i20 + 1 | 0;
  7729. } while ((i20 | 0) != (i35 | 0));
  7730. if (d22 > .019999999552965164) {
  7731. STACKTOP = i1;
  7732. return;
  7733. }
  7734. __ZN12b2EPCollider24ComputePolygonSeparationEv(i18, i12);
  7735. i20 = HEAP32[i18 >> 2] | 0;
  7736. if ((i20 | 0) != 0) {
  7737. d23 = +HEAPF32[i18 + 8 >> 2];
  7738. if (d23 > +HEAPF32[i21 >> 2]) {
  7739. STACKTOP = i1;
  7740. return;
  7741. }
  7742. if (d23 > d22 * .9800000190734863 + .0010000000474974513) {
  7743. i18 = HEAP32[i18 + 4 >> 2] | 0;
  7744. i35 = i2 + 56 | 0;
  7745. if ((i20 | 0) == 1) {
  7746. i18 = i11;
  7747. i15 = 77;
  7748. } else {
  7749. HEAP32[i35 >> 2] = 2;
  7750. i40 = i14;
  7751. i41 = HEAP32[i40 + 4 >> 2] | 0;
  7752. i38 = i11;
  7753. HEAP32[i38 >> 2] = HEAP32[i40 >> 2];
  7754. HEAP32[i38 + 4 >> 2] = i41;
  7755. i38 = i11 + 8 | 0;
  7756. HEAP8[i38] = 0;
  7757. i41 = i18 & 255;
  7758. HEAP8[i38 + 1 | 0] = i41;
  7759. HEAP8[i38 + 2 | 0] = 0;
  7760. HEAP8[i38 + 3 | 0] = 1;
  7761. i38 = i13;
  7762. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7763. i13 = i11 + 12 | 0;
  7764. HEAP32[i13 >> 2] = HEAP32[i38 >> 2];
  7765. HEAP32[i13 + 4 >> 2] = i40;
  7766. i13 = i11 + 20 | 0;
  7767. HEAP8[i13] = 0;
  7768. HEAP8[i13 + 1 | 0] = i41;
  7769. HEAP8[i13 + 2 | 0] = 0;
  7770. HEAP8[i13 + 3 | 0] = 1;
  7771. HEAP32[i9 >> 2] = i18;
  7772. i13 = i18 + 1 | 0;
  7773. i16 = (i13 | 0) < (HEAP32[i34 >> 2] | 0) ? i13 : 0;
  7774. HEAP32[i9 + 4 >> 2] = i16;
  7775. i17 = i12 + (i18 << 3) | 0;
  7776. i13 = HEAP32[i17 >> 2] | 0;
  7777. i17 = HEAP32[i17 + 4 >> 2] | 0;
  7778. i29 = i9 + 8 | 0;
  7779. HEAP32[i29 >> 2] = i13;
  7780. HEAP32[i29 + 4 >> 2] = i17;
  7781. i16 = i12 + (i16 << 3) | 0;
  7782. i29 = HEAP32[i16 >> 2] | 0;
  7783. i16 = HEAP32[i16 + 4 >> 2] | 0;
  7784. i20 = i9 + 16 | 0;
  7785. HEAP32[i20 >> 2] = i29;
  7786. HEAP32[i20 + 4 >> 2] = i16;
  7787. i20 = i12 + (i18 << 3) + 64 | 0;
  7788. i12 = HEAP32[i20 >> 2] | 0;
  7789. i20 = HEAP32[i20 + 4 >> 2] | 0;
  7790. i14 = i9 + 24 | 0;
  7791. HEAP32[i14 >> 2] = i12;
  7792. HEAP32[i14 + 4 >> 2] = i20;
  7793. i14 = 0;
  7794. }
  7795. } else {
  7796. i15 = 75;
  7797. }
  7798. } else {
  7799. i15 = 75;
  7800. }
  7801. if ((i15 | 0) == 75) {
  7802. i18 = i11;
  7803. i35 = i2 + 56 | 0;
  7804. i15 = 77;
  7805. }
  7806. do {
  7807. if ((i15 | 0) == 77) {
  7808. HEAP32[i35 >> 2] = 1;
  7809. i15 = HEAP32[i34 >> 2] | 0;
  7810. if ((i15 | 0) > 1) {
  7811. d23 = +HEAPF32[i12 + 216 >> 2];
  7812. d22 = +HEAPF32[i12 + 212 >> 2];
  7813. i34 = 0;
  7814. d24 = d22 * +HEAPF32[i12 + 64 >> 2] + d23 * +HEAPF32[i12 + 68 >> 2];
  7815. i35 = 1;
  7816. while (1) {
  7817. d25 = d22 * +HEAPF32[i12 + (i35 << 3) + 64 >> 2] + d23 * +HEAPF32[i12 + (i35 << 3) + 68 >> 2];
  7818. i20 = d25 < d24;
  7819. i34 = i20 ? i35 : i34;
  7820. i35 = i35 + 1 | 0;
  7821. if ((i35 | 0) < (i15 | 0)) {
  7822. d24 = i20 ? d25 : d24;
  7823. } else {
  7824. break;
  7825. }
  7826. }
  7827. } else {
  7828. i34 = 0;
  7829. }
  7830. i20 = i34 + 1 | 0;
  7831. i40 = (i20 | 0) < (i15 | 0) ? i20 : 0;
  7832. i41 = i12 + (i34 << 3) | 0;
  7833. i38 = HEAP32[i41 + 4 >> 2] | 0;
  7834. i35 = i11;
  7835. HEAP32[i35 >> 2] = HEAP32[i41 >> 2];
  7836. HEAP32[i35 + 4 >> 2] = i38;
  7837. i35 = i11 + 8 | 0;
  7838. HEAP8[i35] = 0;
  7839. HEAP8[i35 + 1 | 0] = i34;
  7840. HEAP8[i35 + 2 | 0] = 1;
  7841. HEAP8[i35 + 3 | 0] = 0;
  7842. i35 = i12 + (i40 << 3) | 0;
  7843. i38 = HEAP32[i35 + 4 >> 2] | 0;
  7844. i41 = i11 + 12 | 0;
  7845. HEAP32[i41 >> 2] = HEAP32[i35 >> 2];
  7846. HEAP32[i41 + 4 >> 2] = i38;
  7847. i41 = i11 + 20 | 0;
  7848. HEAP8[i41] = 0;
  7849. HEAP8[i41 + 1 | 0] = i40;
  7850. HEAP8[i41 + 2 | 0] = 1;
  7851. HEAP8[i41 + 3 | 0] = 0;
  7852. if ((HEAP8[i29] | 0) == 0) {
  7853. HEAP32[i9 >> 2] = 1;
  7854. HEAP32[i9 + 4 >> 2] = 0;
  7855. i11 = i13;
  7856. i13 = HEAP32[i11 >> 2] | 0;
  7857. i11 = HEAP32[i11 + 4 >> 2] | 0;
  7858. i29 = i9 + 8 | 0;
  7859. HEAP32[i29 >> 2] = i13;
  7860. HEAP32[i29 + 4 >> 2] = i11;
  7861. i29 = HEAP32[i14 >> 2] | 0;
  7862. i14 = HEAP32[i14 + 4 >> 2] | 0;
  7863. i12 = i9 + 16 | 0;
  7864. HEAP32[i12 >> 2] = i29;
  7865. HEAP32[i12 + 4 >> 2] = i14;
  7866. i12 = (HEAPF32[tempDoublePtr >> 2] = -+HEAPF32[i16 >> 2], HEAP32[tempDoublePtr >> 2] | 0);
  7867. i20 = (HEAPF32[tempDoublePtr >> 2] = -+HEAPF32[i17 >> 2], HEAP32[tempDoublePtr >> 2] | 0);
  7868. i16 = i9 + 24 | 0;
  7869. HEAP32[i16 >> 2] = i12;
  7870. HEAP32[i16 + 4 >> 2] = i20;
  7871. i16 = i14;
  7872. i17 = i11;
  7873. i11 = i18;
  7874. i18 = 1;
  7875. i14 = 1;
  7876. break;
  7877. } else {
  7878. HEAP32[i9 >> 2] = 0;
  7879. HEAP32[i9 + 4 >> 2] = 1;
  7880. i17 = i14;
  7881. i11 = HEAP32[i17 >> 2] | 0;
  7882. i17 = HEAP32[i17 + 4 >> 2] | 0;
  7883. i29 = i9 + 8 | 0;
  7884. HEAP32[i29 >> 2] = i11;
  7885. HEAP32[i29 + 4 >> 2] = i17;
  7886. i29 = HEAP32[i13 >> 2] | 0;
  7887. i13 = HEAP32[i13 + 4 >> 2] | 0;
  7888. i20 = i9 + 16 | 0;
  7889. HEAP32[i20 >> 2] = i29;
  7890. HEAP32[i20 + 4 >> 2] = i13;
  7891. i20 = i16;
  7892. i12 = HEAP32[i20 >> 2] | 0;
  7893. i20 = HEAP32[i20 + 4 >> 2] | 0;
  7894. i16 = i9 + 24 | 0;
  7895. HEAP32[i16 >> 2] = i12;
  7896. HEAP32[i16 + 4 >> 2] = i20;
  7897. i16 = i13;
  7898. i13 = i11;
  7899. i11 = i18;
  7900. i18 = 0;
  7901. i14 = 1;
  7902. break;
  7903. }
  7904. }
  7905. } while (0);
  7906. d30 = (HEAP32[tempDoublePtr >> 2] = i20, +HEAPF32[tempDoublePtr >> 2]);
  7907. d39 = (HEAP32[tempDoublePtr >> 2] = i12, +HEAPF32[tempDoublePtr >> 2]);
  7908. d31 = (HEAP32[tempDoublePtr >> 2] = i13, +HEAPF32[tempDoublePtr >> 2]);
  7909. d32 = (HEAP32[tempDoublePtr >> 2] = i17, +HEAPF32[tempDoublePtr >> 2]);
  7910. d33 = (HEAP32[tempDoublePtr >> 2] = i29, +HEAPF32[tempDoublePtr >> 2]);
  7911. d37 = (HEAP32[tempDoublePtr >> 2] = i16, +HEAPF32[tempDoublePtr >> 2]);
  7912. i41 = i9 + 32 | 0;
  7913. i16 = i9 + 24 | 0;
  7914. i13 = i9 + 28 | 0;
  7915. d39 = -d39;
  7916. HEAPF32[i41 >> 2] = d30;
  7917. HEAPF32[i9 + 36 >> 2] = d39;
  7918. i20 = i9 + 44 | 0;
  7919. d36 = -d30;
  7920. i17 = i20;
  7921. HEAPF32[i17 >> 2] = d36;
  7922. HEAP32[i17 + 4 >> 2] = i12;
  7923. i17 = i9 + 8 | 0;
  7924. i15 = i9 + 12 | 0;
  7925. d39 = d30 * d31 + d32 * d39;
  7926. HEAPF32[i9 + 40 >> 2] = d39;
  7927. i29 = i9 + 52 | 0;
  7928. HEAPF32[i29 >> 2] = d33 * d36 + (HEAP32[tempDoublePtr >> 2] = i12, +HEAPF32[tempDoublePtr >> 2]) * d37;
  7929. if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i10, i11, i41, d39, i18) | 0) < 2) {
  7930. STACKTOP = i1;
  7931. return;
  7932. }
  7933. if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i3, i10, i20, +HEAPF32[i29 >> 2], HEAP32[i9 + 4 >> 2] | 0) | 0) < 2) {
  7934. STACKTOP = i1;
  7935. return;
  7936. }
  7937. i10 = i2 + 40 | 0;
  7938. if (i14) {
  7939. i40 = i16;
  7940. i41 = HEAP32[i40 >> 2] | 0;
  7941. i40 = HEAP32[i40 + 4 >> 2] | 0;
  7942. i35 = i10;
  7943. HEAP32[i35 >> 2] = i41;
  7944. HEAP32[i35 + 4 >> 2] = i40;
  7945. i35 = i17;
  7946. i40 = HEAP32[i35 >> 2] | 0;
  7947. i35 = HEAP32[i35 + 4 >> 2] | 0;
  7948. i38 = i2 + 48 | 0;
  7949. HEAP32[i38 >> 2] = i40;
  7950. HEAP32[i38 + 4 >> 2] = i35;
  7951. d23 = (HEAP32[tempDoublePtr >> 2] = i40, +HEAPF32[tempDoublePtr >> 2]);
  7952. d22 = (HEAP32[tempDoublePtr >> 2] = i41, +HEAPF32[tempDoublePtr >> 2]);
  7953. d24 = +HEAPF32[i15 >> 2];
  7954. d25 = +HEAPF32[i13 >> 2];
  7955. d28 = +HEAPF32[i3 >> 2];
  7956. d27 = +HEAPF32[i3 + 4 >> 2];
  7957. d26 = +HEAPF32[i21 >> 2];
  7958. if (!((d28 - d23) * d22 + (d27 - d24) * d25 <= d26)) {
  7959. d28 = d26;
  7960. i8 = 0;
  7961. } else {
  7962. d37 = d28 - +HEAPF32[i4 >> 2];
  7963. d36 = d27 - +HEAPF32[i6 >> 2];
  7964. d33 = +HEAPF32[i5 >> 2];
  7965. d28 = +HEAPF32[i7 >> 2];
  7966. d39 = +(d37 * d33 + d36 * d28);
  7967. d28 = +(d33 * d36 - d37 * d28);
  7968. i8 = i2;
  7969. HEAPF32[i8 >> 2] = d39;
  7970. HEAPF32[i8 + 4 >> 2] = d28;
  7971. HEAP32[i2 + 16 >> 2] = HEAP32[i3 + 8 >> 2];
  7972. d28 = +HEAPF32[i21 >> 2];
  7973. i8 = 1;
  7974. }
  7975. d26 = +HEAPF32[i3 + 12 >> 2];
  7976. d27 = +HEAPF32[i3 + 16 >> 2];
  7977. if ((d26 - d23) * d22 + (d27 - d24) * d25 <= d28) {
  7978. d36 = d26 - +HEAPF32[i4 >> 2];
  7979. d33 = d27 - +HEAPF32[i6 >> 2];
  7980. d32 = +HEAPF32[i5 >> 2];
  7981. d39 = +HEAPF32[i7 >> 2];
  7982. d37 = +(d36 * d32 + d33 * d39);
  7983. d39 = +(d32 * d33 - d36 * d39);
  7984. i41 = i2 + (i8 * 20 | 0) | 0;
  7985. HEAPF32[i41 >> 2] = d37;
  7986. HEAPF32[i41 + 4 >> 2] = d39;
  7987. HEAP32[i2 + (i8 * 20 | 0) + 16 >> 2] = HEAP32[i3 + 20 >> 2];
  7988. i8 = i8 + 1 | 0;
  7989. }
  7990. } else {
  7991. i38 = HEAP32[i9 >> 2] | 0;
  7992. i35 = i8 + (i38 << 3) + 84 | 0;
  7993. i41 = HEAP32[i35 + 4 >> 2] | 0;
  7994. i40 = i10;
  7995. HEAP32[i40 >> 2] = HEAP32[i35 >> 2];
  7996. HEAP32[i40 + 4 >> 2] = i41;
  7997. i38 = i8 + (i38 << 3) + 20 | 0;
  7998. i40 = HEAP32[i38 + 4 >> 2] | 0;
  7999. i41 = i2 + 48 | 0;
  8000. HEAP32[i41 >> 2] = HEAP32[i38 >> 2];
  8001. HEAP32[i41 + 4 >> 2] = i40;
  8002. d22 = +HEAPF32[i17 >> 2];
  8003. d23 = +HEAPF32[i16 >> 2];
  8004. d24 = +HEAPF32[i15 >> 2];
  8005. d25 = +HEAPF32[i13 >> 2];
  8006. d26 = +HEAPF32[i21 >> 2];
  8007. if (!((+HEAPF32[i3 >> 2] - d22) * d23 + (+HEAPF32[i3 + 4 >> 2] - d24) * d25 <= d26)) {
  8008. i8 = 0;
  8009. } else {
  8010. i40 = i3;
  8011. i8 = HEAP32[i40 + 4 >> 2] | 0;
  8012. i41 = i2;
  8013. HEAP32[i41 >> 2] = HEAP32[i40 >> 2];
  8014. HEAP32[i41 + 4 >> 2] = i8;
  8015. i41 = i3 + 8 | 0;
  8016. i8 = i2 + 16 | 0;
  8017. HEAP8[i8 + 2 | 0] = HEAP8[i41 + 3 | 0] | 0;
  8018. HEAP8[i8 + 3 | 0] = HEAP8[i41 + 2 | 0] | 0;
  8019. HEAP8[i8] = HEAP8[i41 + 1 | 0] | 0;
  8020. HEAP8[i8 + 1 | 0] = HEAP8[i41] | 0;
  8021. d26 = +HEAPF32[i21 >> 2];
  8022. i8 = 1;
  8023. }
  8024. i4 = i3 + 12 | 0;
  8025. if ((+HEAPF32[i4 >> 2] - d22) * d23 + (+HEAPF32[i3 + 16 >> 2] - d24) * d25 <= d26) {
  8026. i38 = i4;
  8027. i41 = HEAP32[i38 + 4 >> 2] | 0;
  8028. i40 = i2 + (i8 * 20 | 0) | 0;
  8029. HEAP32[i40 >> 2] = HEAP32[i38 >> 2];
  8030. HEAP32[i40 + 4 >> 2] = i41;
  8031. i40 = i3 + 20 | 0;
  8032. i41 = i2 + (i8 * 20 | 0) + 16 | 0;
  8033. HEAP8[i41 + 2 | 0] = HEAP8[i40 + 3 | 0] | 0;
  8034. HEAP8[i41 + 3 | 0] = HEAP8[i40 + 2 | 0] | 0;
  8035. HEAP8[i41] = HEAP8[i40 + 1 | 0] | 0;
  8036. HEAP8[i41 + 1 | 0] = HEAP8[i40] | 0;
  8037. i8 = i8 + 1 | 0;
  8038. }
  8039. }
  8040. HEAP32[i19 >> 2] = i8;
  8041. STACKTOP = i1;
  8042. return;
  8043. }
  8044. function __ZN7b2World8SolveTOIERK10b2TimeStep(i30, i11) {
  8045. i30 = i30 | 0;
  8046. i11 = i11 | 0;
  8047. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, i38 = 0, i39 = 0, i40 = 0, i41 = 0, d42 = 0.0, i43 = 0, i44 = 0, i45 = 0, i46 = 0, i47 = 0, i48 = 0, i49 = 0, i50 = 0, i51 = 0, i52 = 0, i53 = 0, i54 = 0, i55 = 0, i56 = 0, i57 = 0, i58 = 0, i59 = 0, i60 = 0, i61 = 0, i62 = 0, i63 = 0, i64 = 0, i65 = 0, i66 = 0, d67 = 0.0, d68 = 0.0, d69 = 0.0, d70 = 0.0, d71 = 0.0, d72 = 0.0;
  8048. i1 = STACKTOP;
  8049. STACKTOP = STACKTOP + 336 | 0;
  8050. i3 = i1 + 284 | 0;
  8051. i6 = i1 + 152 | 0;
  8052. i5 = i1 + 144 | 0;
  8053. i4 = i1 + 108 | 0;
  8054. i8 = i1 + 72 | 0;
  8055. i7 = i1 + 64 | 0;
  8056. i14 = i1 + 24 | 0;
  8057. i9 = i1;
  8058. i10 = i30 + 102872 | 0;
  8059. i13 = i30 + 102944 | 0;
  8060. __ZN8b2IslandC2EiiiP16b2StackAllocatorP17b2ContactListener(i3, 64, 32, 0, i30 + 68 | 0, HEAP32[i13 >> 2] | 0);
  8061. i2 = i30 + 102995 | 0;
  8062. if ((HEAP8[i2] | 0) != 0) {
  8063. i15 = HEAP32[i30 + 102952 >> 2] | 0;
  8064. if ((i15 | 0) != 0) {
  8065. do {
  8066. i66 = i15 + 4 | 0;
  8067. HEAP16[i66 >> 1] = HEAP16[i66 >> 1] & 65534;
  8068. HEAPF32[i15 + 60 >> 2] = 0.0;
  8069. i15 = HEAP32[i15 + 96 >> 2] | 0;
  8070. } while ((i15 | 0) != 0);
  8071. }
  8072. i15 = i30 + 102932 | 0;
  8073. i16 = HEAP32[i15 >> 2] | 0;
  8074. if ((i16 | 0) != 0) {
  8075. do {
  8076. i66 = i16 + 4 | 0;
  8077. HEAP32[i66 >> 2] = HEAP32[i66 >> 2] & -34;
  8078. HEAP32[i16 + 128 >> 2] = 0;
  8079. HEAPF32[i16 + 132 >> 2] = 1.0;
  8080. i16 = HEAP32[i16 + 12 >> 2] | 0;
  8081. } while ((i16 | 0) != 0);
  8082. }
  8083. } else {
  8084. i15 = i30 + 102932 | 0;
  8085. }
  8086. i25 = i3 + 28 | 0;
  8087. i26 = i3 + 36 | 0;
  8088. i27 = i3 + 32 | 0;
  8089. i28 = i3 + 40 | 0;
  8090. i29 = i3 + 8 | 0;
  8091. i24 = i3 + 44 | 0;
  8092. i23 = i3 + 12 | 0;
  8093. i22 = i7 + 4 | 0;
  8094. i21 = i9 + 4 | 0;
  8095. i20 = i9 + 8 | 0;
  8096. i19 = i9 + 16 | 0;
  8097. i18 = i11 + 12 | 0;
  8098. i17 = i9 + 12 | 0;
  8099. i16 = i9 + 20 | 0;
  8100. i39 = i30 + 102994 | 0;
  8101. i37 = i6 + 16 | 0;
  8102. i36 = i6 + 20 | 0;
  8103. i35 = i6 + 24 | 0;
  8104. i34 = i6 + 44 | 0;
  8105. i33 = i6 + 48 | 0;
  8106. i32 = i6 + 52 | 0;
  8107. i41 = i6 + 28 | 0;
  8108. i31 = i6 + 56 | 0;
  8109. i40 = i6 + 92 | 0;
  8110. i30 = i6 + 128 | 0;
  8111. i38 = i5 + 4 | 0;
  8112. L11 : while (1) {
  8113. i47 = HEAP32[i15 >> 2] | 0;
  8114. if ((i47 | 0) == 0) {
  8115. i4 = 36;
  8116. break;
  8117. } else {
  8118. d42 = 1.0;
  8119. i44 = 0;
  8120. }
  8121. do {
  8122. i48 = i47 + 4 | 0;
  8123. i43 = HEAP32[i48 >> 2] | 0;
  8124. do {
  8125. if ((i43 & 4 | 0) != 0 ? (HEAP32[i47 + 128 >> 2] | 0) <= 8 : 0) {
  8126. if ((i43 & 32 | 0) == 0) {
  8127. i43 = HEAP32[i47 + 48 >> 2] | 0;
  8128. i45 = HEAP32[i47 + 52 >> 2] | 0;
  8129. if ((HEAP8[i43 + 38 | 0] | 0) != 0) {
  8130. break;
  8131. }
  8132. if ((HEAP8[i45 + 38 | 0] | 0) != 0) {
  8133. break;
  8134. }
  8135. i46 = HEAP32[i43 + 8 >> 2] | 0;
  8136. i50 = HEAP32[i45 + 8 >> 2] | 0;
  8137. i53 = HEAP32[i46 >> 2] | 0;
  8138. i52 = HEAP32[i50 >> 2] | 0;
  8139. if (!((i53 | 0) == 2 | (i52 | 0) == 2)) {
  8140. i4 = 16;
  8141. break L11;
  8142. }
  8143. i51 = HEAP16[i46 + 4 >> 1] | 0;
  8144. i49 = HEAP16[i50 + 4 >> 1] | 0;
  8145. if (!((i51 & 2) != 0 & (i53 | 0) != 0 | (i49 & 2) != 0 & (i52 | 0) != 0)) {
  8146. break;
  8147. }
  8148. if (!((i51 & 8) != 0 | (i53 | 0) != 2 | ((i49 & 8) != 0 | (i52 | 0) != 2))) {
  8149. break;
  8150. }
  8151. i51 = i46 + 28 | 0;
  8152. i52 = i46 + 60 | 0;
  8153. d68 = +HEAPF32[i52 >> 2];
  8154. i49 = i50 + 28 | 0;
  8155. i53 = i50 + 60 | 0;
  8156. d67 = +HEAPF32[i53 >> 2];
  8157. if (!(d68 < d67)) {
  8158. if (d67 < d68) {
  8159. if (!(d67 < 1.0)) {
  8160. i4 = 25;
  8161. break L11;
  8162. }
  8163. d67 = (d68 - d67) / (1.0 - d67);
  8164. i66 = i50 + 36 | 0;
  8165. d69 = 1.0 - d67;
  8166. d71 = +(+HEAPF32[i66 >> 2] * d69 + d67 * +HEAPF32[i50 + 44 >> 2]);
  8167. d70 = +(d69 * +HEAPF32[i50 + 40 >> 2] + d67 * +HEAPF32[i50 + 48 >> 2]);
  8168. HEAPF32[i66 >> 2] = d71;
  8169. HEAPF32[i66 + 4 >> 2] = d70;
  8170. i66 = i50 + 52 | 0;
  8171. HEAPF32[i66 >> 2] = d69 * +HEAPF32[i66 >> 2] + d67 * +HEAPF32[i50 + 56 >> 2];
  8172. HEAPF32[i53 >> 2] = d68;
  8173. d67 = d68;
  8174. } else {
  8175. d67 = d68;
  8176. }
  8177. } else {
  8178. if (!(d68 < 1.0)) {
  8179. i4 = 21;
  8180. break L11;
  8181. }
  8182. d71 = (d67 - d68) / (1.0 - d68);
  8183. i66 = i46 + 36 | 0;
  8184. d70 = 1.0 - d71;
  8185. d68 = +(+HEAPF32[i66 >> 2] * d70 + d71 * +HEAPF32[i46 + 44 >> 2]);
  8186. d69 = +(d70 * +HEAPF32[i46 + 40 >> 2] + d71 * +HEAPF32[i46 + 48 >> 2]);
  8187. HEAPF32[i66 >> 2] = d68;
  8188. HEAPF32[i66 + 4 >> 2] = d69;
  8189. i66 = i46 + 52 | 0;
  8190. HEAPF32[i66 >> 2] = d70 * +HEAPF32[i66 >> 2] + d71 * +HEAPF32[i46 + 56 >> 2];
  8191. HEAPF32[i52 >> 2] = d67;
  8192. }
  8193. if (!(d67 < 1.0)) {
  8194. i4 = 28;
  8195. break L11;
  8196. }
  8197. i66 = HEAP32[i47 + 56 >> 2] | 0;
  8198. i46 = HEAP32[i47 + 60 >> 2] | 0;
  8199. HEAP32[i37 >> 2] = 0;
  8200. HEAP32[i36 >> 2] = 0;
  8201. HEAPF32[i35 >> 2] = 0.0;
  8202. HEAP32[i34 >> 2] = 0;
  8203. HEAP32[i33 >> 2] = 0;
  8204. HEAPF32[i32 >> 2] = 0.0;
  8205. __ZN15b2DistanceProxy3SetEPK7b2Shapei(i6, HEAP32[i43 + 12 >> 2] | 0, i66);
  8206. __ZN15b2DistanceProxy3SetEPK7b2Shapei(i41, HEAP32[i45 + 12 >> 2] | 0, i46);
  8207. i43 = i31 + 0 | 0;
  8208. i45 = i51 + 0 | 0;
  8209. i46 = i43 + 36 | 0;
  8210. do {
  8211. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8212. i43 = i43 + 4 | 0;
  8213. i45 = i45 + 4 | 0;
  8214. } while ((i43 | 0) < (i46 | 0));
  8215. i43 = i40 + 0 | 0;
  8216. i45 = i49 + 0 | 0;
  8217. i46 = i43 + 36 | 0;
  8218. do {
  8219. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8220. i43 = i43 + 4 | 0;
  8221. i45 = i45 + 4 | 0;
  8222. } while ((i43 | 0) < (i46 | 0));
  8223. HEAPF32[i30 >> 2] = 1.0;
  8224. __Z14b2TimeOfImpactP11b2TOIOutputPK10b2TOIInput(i5, i6);
  8225. if ((HEAP32[i5 >> 2] | 0) == 3) {
  8226. d67 = d67 + (1.0 - d67) * +HEAPF32[i38 >> 2];
  8227. d67 = d67 < 1.0 ? d67 : 1.0;
  8228. } else {
  8229. d67 = 1.0;
  8230. }
  8231. HEAPF32[i47 + 132 >> 2] = d67;
  8232. HEAP32[i48 >> 2] = HEAP32[i48 >> 2] | 32;
  8233. } else {
  8234. d67 = +HEAPF32[i47 + 132 >> 2];
  8235. }
  8236. if (d67 < d42) {
  8237. d42 = d67;
  8238. i44 = i47;
  8239. }
  8240. }
  8241. } while (0);
  8242. i47 = HEAP32[i47 + 12 >> 2] | 0;
  8243. } while ((i47 | 0) != 0);
  8244. if ((i44 | 0) == 0 | d42 > .9999988079071045) {
  8245. i4 = 36;
  8246. break;
  8247. }
  8248. i47 = HEAP32[(HEAP32[i44 + 48 >> 2] | 0) + 8 >> 2] | 0;
  8249. i48 = HEAP32[(HEAP32[i44 + 52 >> 2] | 0) + 8 >> 2] | 0;
  8250. i49 = i47 + 28 | 0;
  8251. i43 = i4 + 0 | 0;
  8252. i45 = i49 + 0 | 0;
  8253. i46 = i43 + 36 | 0;
  8254. do {
  8255. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8256. i43 = i43 + 4 | 0;
  8257. i45 = i45 + 4 | 0;
  8258. } while ((i43 | 0) < (i46 | 0));
  8259. i50 = i48 + 28 | 0;
  8260. i43 = i8 + 0 | 0;
  8261. i45 = i50 + 0 | 0;
  8262. i46 = i43 + 36 | 0;
  8263. do {
  8264. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8265. i43 = i43 + 4 | 0;
  8266. i45 = i45 + 4 | 0;
  8267. } while ((i43 | 0) < (i46 | 0));
  8268. i43 = i47 + 60 | 0;
  8269. d67 = +HEAPF32[i43 >> 2];
  8270. if (!(d67 < 1.0)) {
  8271. i4 = 38;
  8272. break;
  8273. }
  8274. d70 = (d42 - d67) / (1.0 - d67);
  8275. i57 = i47 + 36 | 0;
  8276. d67 = 1.0 - d70;
  8277. i52 = i47 + 44 | 0;
  8278. i53 = i47 + 48 | 0;
  8279. d71 = +HEAPF32[i57 >> 2] * d67 + d70 * +HEAPF32[i52 >> 2];
  8280. d72 = d67 * +HEAPF32[i47 + 40 >> 2] + d70 * +HEAPF32[i53 >> 2];
  8281. d69 = +d71;
  8282. d68 = +d72;
  8283. HEAPF32[i57 >> 2] = d69;
  8284. HEAPF32[i57 + 4 >> 2] = d68;
  8285. i57 = i47 + 52 | 0;
  8286. i51 = i47 + 56 | 0;
  8287. d70 = d67 * +HEAPF32[i57 >> 2] + d70 * +HEAPF32[i51 >> 2];
  8288. HEAPF32[i57 >> 2] = d70;
  8289. HEAPF32[i43 >> 2] = d42;
  8290. i57 = i47 + 44 | 0;
  8291. HEAPF32[i57 >> 2] = d69;
  8292. HEAPF32[i57 + 4 >> 2] = d68;
  8293. HEAPF32[i51 >> 2] = d70;
  8294. d68 = +Math_sin(+d70);
  8295. i57 = i47 + 20 | 0;
  8296. HEAPF32[i57 >> 2] = d68;
  8297. d70 = +Math_cos(+d70);
  8298. i56 = i47 + 24 | 0;
  8299. HEAPF32[i56 >> 2] = d70;
  8300. i58 = i47 + 12 | 0;
  8301. i55 = i47 + 28 | 0;
  8302. d69 = +HEAPF32[i55 >> 2];
  8303. i54 = i47 + 32 | 0;
  8304. d67 = +HEAPF32[i54 >> 2];
  8305. d71 = +(d71 - (d70 * d69 - d68 * d67));
  8306. d67 = +(d72 - (d68 * d69 + d70 * d67));
  8307. i43 = i58;
  8308. HEAPF32[i43 >> 2] = d71;
  8309. HEAPF32[i43 + 4 >> 2] = d67;
  8310. i43 = i48 + 60 | 0;
  8311. d67 = +HEAPF32[i43 >> 2];
  8312. if (!(d67 < 1.0)) {
  8313. i4 = 40;
  8314. break;
  8315. }
  8316. d70 = (d42 - d67) / (1.0 - d67);
  8317. i64 = i48 + 36 | 0;
  8318. d72 = 1.0 - d70;
  8319. i61 = i48 + 44 | 0;
  8320. i60 = i48 + 48 | 0;
  8321. d71 = +HEAPF32[i64 >> 2] * d72 + d70 * +HEAPF32[i61 >> 2];
  8322. d67 = d72 * +HEAPF32[i48 + 40 >> 2] + d70 * +HEAPF32[i60 >> 2];
  8323. d69 = +d71;
  8324. d68 = +d67;
  8325. HEAPF32[i64 >> 2] = d69;
  8326. HEAPF32[i64 + 4 >> 2] = d68;
  8327. i64 = i48 + 52 | 0;
  8328. i59 = i48 + 56 | 0;
  8329. d70 = d72 * +HEAPF32[i64 >> 2] + d70 * +HEAPF32[i59 >> 2];
  8330. HEAPF32[i64 >> 2] = d70;
  8331. HEAPF32[i43 >> 2] = d42;
  8332. i64 = i48 + 44 | 0;
  8333. HEAPF32[i64 >> 2] = d69;
  8334. HEAPF32[i64 + 4 >> 2] = d68;
  8335. HEAPF32[i59 >> 2] = d70;
  8336. d68 = +Math_sin(+d70);
  8337. i64 = i48 + 20 | 0;
  8338. HEAPF32[i64 >> 2] = d68;
  8339. d70 = +Math_cos(+d70);
  8340. i63 = i48 + 24 | 0;
  8341. HEAPF32[i63 >> 2] = d70;
  8342. i65 = i48 + 12 | 0;
  8343. i62 = i48 + 28 | 0;
  8344. d69 = +HEAPF32[i62 >> 2];
  8345. i66 = i48 + 32 | 0;
  8346. d72 = +HEAPF32[i66 >> 2];
  8347. d71 = +(d71 - (d70 * d69 - d68 * d72));
  8348. d72 = +(d67 - (d68 * d69 + d70 * d72));
  8349. i43 = i65;
  8350. HEAPF32[i43 >> 2] = d71;
  8351. HEAPF32[i43 + 4 >> 2] = d72;
  8352. __ZN9b2Contact6UpdateEP17b2ContactListener(i44, HEAP32[i13 >> 2] | 0);
  8353. i43 = i44 + 4 | 0;
  8354. i45 = HEAP32[i43 >> 2] | 0;
  8355. HEAP32[i43 >> 2] = i45 & -33;
  8356. i46 = i44 + 128 | 0;
  8357. HEAP32[i46 >> 2] = (HEAP32[i46 >> 2] | 0) + 1;
  8358. if ((i45 & 6 | 0) != 6) {
  8359. HEAP32[i43 >> 2] = i45 & -37;
  8360. i43 = i49 + 0 | 0;
  8361. i45 = i4 + 0 | 0;
  8362. i46 = i43 + 36 | 0;
  8363. do {
  8364. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8365. i43 = i43 + 4 | 0;
  8366. i45 = i45 + 4 | 0;
  8367. } while ((i43 | 0) < (i46 | 0));
  8368. i43 = i50 + 0 | 0;
  8369. i45 = i8 + 0 | 0;
  8370. i46 = i43 + 36 | 0;
  8371. do {
  8372. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8373. i43 = i43 + 4 | 0;
  8374. i45 = i45 + 4 | 0;
  8375. } while ((i43 | 0) < (i46 | 0));
  8376. d69 = +HEAPF32[i51 >> 2];
  8377. d71 = +Math_sin(+d69);
  8378. HEAPF32[i57 >> 2] = d71;
  8379. d69 = +Math_cos(+d69);
  8380. HEAPF32[i56 >> 2] = d69;
  8381. d72 = +HEAPF32[i55 >> 2];
  8382. d70 = +HEAPF32[i54 >> 2];
  8383. d68 = +(+HEAPF32[i52 >> 2] - (d69 * d72 - d71 * d70));
  8384. d70 = +(+HEAPF32[i53 >> 2] - (d71 * d72 + d69 * d70));
  8385. HEAPF32[i58 >> 2] = d68;
  8386. HEAPF32[i58 + 4 >> 2] = d70;
  8387. d70 = +HEAPF32[i59 >> 2];
  8388. d68 = +Math_sin(+d70);
  8389. HEAPF32[i64 >> 2] = d68;
  8390. d70 = +Math_cos(+d70);
  8391. HEAPF32[i63 >> 2] = d70;
  8392. d69 = +HEAPF32[i62 >> 2];
  8393. d72 = +HEAPF32[i66 >> 2];
  8394. d71 = +(+HEAPF32[i61 >> 2] - (d70 * d69 - d68 * d72));
  8395. d72 = +(+HEAPF32[i60 >> 2] - (d68 * d69 + d70 * d72));
  8396. i66 = i65;
  8397. HEAPF32[i66 >> 2] = d71;
  8398. HEAPF32[i66 + 4 >> 2] = d72;
  8399. continue;
  8400. }
  8401. i45 = i47 + 4 | 0;
  8402. i46 = HEAPU16[i45 >> 1] | 0;
  8403. if ((i46 & 2 | 0) == 0) {
  8404. HEAP16[i45 >> 1] = i46 | 2;
  8405. HEAPF32[i47 + 144 >> 2] = 0.0;
  8406. }
  8407. i46 = i48 + 4 | 0;
  8408. i49 = HEAPU16[i46 >> 1] | 0;
  8409. if ((i49 & 2 | 0) == 0) {
  8410. HEAP16[i46 >> 1] = i49 | 2;
  8411. HEAPF32[i48 + 144 >> 2] = 0.0;
  8412. }
  8413. HEAP32[i25 >> 2] = 0;
  8414. HEAP32[i26 >> 2] = 0;
  8415. HEAP32[i27 >> 2] = 0;
  8416. if ((HEAP32[i28 >> 2] | 0) <= 0) {
  8417. i4 = 48;
  8418. break;
  8419. }
  8420. i49 = i47 + 8 | 0;
  8421. HEAP32[i49 >> 2] = 0;
  8422. i51 = HEAP32[i25 >> 2] | 0;
  8423. HEAP32[(HEAP32[i29 >> 2] | 0) + (i51 << 2) >> 2] = i47;
  8424. i51 = i51 + 1 | 0;
  8425. HEAP32[i25 >> 2] = i51;
  8426. if ((i51 | 0) >= (HEAP32[i28 >> 2] | 0)) {
  8427. i4 = 50;
  8428. break;
  8429. }
  8430. i50 = i48 + 8 | 0;
  8431. HEAP32[i50 >> 2] = i51;
  8432. i51 = HEAP32[i25 >> 2] | 0;
  8433. HEAP32[(HEAP32[i29 >> 2] | 0) + (i51 << 2) >> 2] = i48;
  8434. HEAP32[i25 >> 2] = i51 + 1;
  8435. i51 = HEAP32[i26 >> 2] | 0;
  8436. if ((i51 | 0) >= (HEAP32[i24 >> 2] | 0)) {
  8437. i4 = 52;
  8438. break;
  8439. }
  8440. HEAP32[i26 >> 2] = i51 + 1;
  8441. HEAP32[(HEAP32[i23 >> 2] | 0) + (i51 << 2) >> 2] = i44;
  8442. HEAP16[i45 >> 1] = HEAPU16[i45 >> 1] | 1;
  8443. HEAP16[i46 >> 1] = HEAPU16[i46 >> 1] | 1;
  8444. HEAP32[i43 >> 2] = HEAP32[i43 >> 2] | 1;
  8445. HEAP32[i7 >> 2] = i47;
  8446. HEAP32[i22 >> 2] = i48;
  8447. i44 = 1;
  8448. while (1) {
  8449. L58 : do {
  8450. if ((HEAP32[i47 >> 2] | 0) == 2 ? (i12 = HEAP32[i47 + 112 >> 2] | 0, (i12 | 0) != 0) : 0) {
  8451. i47 = i47 + 4 | 0;
  8452. i51 = i12;
  8453. do {
  8454. if ((HEAP32[i25 >> 2] | 0) == (HEAP32[i28 >> 2] | 0)) {
  8455. break L58;
  8456. }
  8457. if ((HEAP32[i26 >> 2] | 0) == (HEAP32[i24 >> 2] | 0)) {
  8458. break L58;
  8459. }
  8460. i52 = HEAP32[i51 + 4 >> 2] | 0;
  8461. i53 = i52 + 4 | 0;
  8462. do {
  8463. if ((HEAP32[i53 >> 2] & 1 | 0) == 0) {
  8464. i48 = HEAP32[i51 >> 2] | 0;
  8465. if (((HEAP32[i48 >> 2] | 0) == 2 ? (HEAP16[i47 >> 1] & 8) == 0 : 0) ? (HEAP16[i48 + 4 >> 1] & 8) == 0 : 0) {
  8466. break;
  8467. }
  8468. if ((HEAP8[(HEAP32[i52 + 48 >> 2] | 0) + 38 | 0] | 0) == 0 ? (HEAP8[(HEAP32[i52 + 52 >> 2] | 0) + 38 | 0] | 0) == 0 : 0) {
  8469. i54 = i48 + 28 | 0;
  8470. i43 = i14 + 0 | 0;
  8471. i45 = i54 + 0 | 0;
  8472. i46 = i43 + 36 | 0;
  8473. do {
  8474. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8475. i43 = i43 + 4 | 0;
  8476. i45 = i45 + 4 | 0;
  8477. } while ((i43 | 0) < (i46 | 0));
  8478. i43 = i48 + 4 | 0;
  8479. if ((HEAP16[i43 >> 1] & 1) == 0) {
  8480. i45 = i48 + 60 | 0;
  8481. d67 = +HEAPF32[i45 >> 2];
  8482. if (!(d67 < 1.0)) {
  8483. i4 = 67;
  8484. break L11;
  8485. }
  8486. d70 = (d42 - d67) / (1.0 - d67);
  8487. i65 = i48 + 36 | 0;
  8488. d72 = 1.0 - d70;
  8489. d71 = +HEAPF32[i65 >> 2] * d72 + d70 * +HEAPF32[i48 + 44 >> 2];
  8490. d67 = d72 * +HEAPF32[i48 + 40 >> 2] + d70 * +HEAPF32[i48 + 48 >> 2];
  8491. d69 = +d71;
  8492. d68 = +d67;
  8493. HEAPF32[i65 >> 2] = d69;
  8494. HEAPF32[i65 + 4 >> 2] = d68;
  8495. i65 = i48 + 52 | 0;
  8496. i66 = i48 + 56 | 0;
  8497. d70 = d72 * +HEAPF32[i65 >> 2] + d70 * +HEAPF32[i66 >> 2];
  8498. HEAPF32[i65 >> 2] = d70;
  8499. HEAPF32[i45 >> 2] = d42;
  8500. i65 = i48 + 44 | 0;
  8501. HEAPF32[i65 >> 2] = d69;
  8502. HEAPF32[i65 + 4 >> 2] = d68;
  8503. HEAPF32[i66 >> 2] = d70;
  8504. d68 = +Math_sin(+d70);
  8505. HEAPF32[i48 + 20 >> 2] = d68;
  8506. d70 = +Math_cos(+d70);
  8507. HEAPF32[i48 + 24 >> 2] = d70;
  8508. d69 = +HEAPF32[i48 + 28 >> 2];
  8509. d72 = +HEAPF32[i48 + 32 >> 2];
  8510. d71 = +(d71 - (d70 * d69 - d68 * d72));
  8511. d72 = +(d67 - (d68 * d69 + d70 * d72));
  8512. i66 = i48 + 12 | 0;
  8513. HEAPF32[i66 >> 2] = d71;
  8514. HEAPF32[i66 + 4 >> 2] = d72;
  8515. }
  8516. __ZN9b2Contact6UpdateEP17b2ContactListener(i52, HEAP32[i13 >> 2] | 0);
  8517. i45 = HEAP32[i53 >> 2] | 0;
  8518. if ((i45 & 4 | 0) == 0) {
  8519. i43 = i54 + 0 | 0;
  8520. i45 = i14 + 0 | 0;
  8521. i46 = i43 + 36 | 0;
  8522. do {
  8523. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8524. i43 = i43 + 4 | 0;
  8525. i45 = i45 + 4 | 0;
  8526. } while ((i43 | 0) < (i46 | 0));
  8527. d70 = +HEAPF32[i48 + 56 >> 2];
  8528. d68 = +Math_sin(+d70);
  8529. HEAPF32[i48 + 20 >> 2] = d68;
  8530. d70 = +Math_cos(+d70);
  8531. HEAPF32[i48 + 24 >> 2] = d70;
  8532. d69 = +HEAPF32[i48 + 28 >> 2];
  8533. d72 = +HEAPF32[i48 + 32 >> 2];
  8534. d71 = +(+HEAPF32[i48 + 44 >> 2] - (d70 * d69 - d68 * d72));
  8535. d72 = +(+HEAPF32[i48 + 48 >> 2] - (d68 * d69 + d70 * d72));
  8536. i66 = i48 + 12 | 0;
  8537. HEAPF32[i66 >> 2] = d71;
  8538. HEAPF32[i66 + 4 >> 2] = d72;
  8539. break;
  8540. }
  8541. if ((i45 & 2 | 0) == 0) {
  8542. i43 = i54 + 0 | 0;
  8543. i45 = i14 + 0 | 0;
  8544. i46 = i43 + 36 | 0;
  8545. do {
  8546. HEAP32[i43 >> 2] = HEAP32[i45 >> 2];
  8547. i43 = i43 + 4 | 0;
  8548. i45 = i45 + 4 | 0;
  8549. } while ((i43 | 0) < (i46 | 0));
  8550. d70 = +HEAPF32[i48 + 56 >> 2];
  8551. d68 = +Math_sin(+d70);
  8552. HEAPF32[i48 + 20 >> 2] = d68;
  8553. d70 = +Math_cos(+d70);
  8554. HEAPF32[i48 + 24 >> 2] = d70;
  8555. d69 = +HEAPF32[i48 + 28 >> 2];
  8556. d72 = +HEAPF32[i48 + 32 >> 2];
  8557. d71 = +(+HEAPF32[i48 + 44 >> 2] - (d70 * d69 - d68 * d72));
  8558. d72 = +(+HEAPF32[i48 + 48 >> 2] - (d68 * d69 + d70 * d72));
  8559. i66 = i48 + 12 | 0;
  8560. HEAPF32[i66 >> 2] = d71;
  8561. HEAPF32[i66 + 4 >> 2] = d72;
  8562. break;
  8563. }
  8564. HEAP32[i53 >> 2] = i45 | 1;
  8565. i45 = HEAP32[i26 >> 2] | 0;
  8566. if ((i45 | 0) >= (HEAP32[i24 >> 2] | 0)) {
  8567. i4 = 74;
  8568. break L11;
  8569. }
  8570. HEAP32[i26 >> 2] = i45 + 1;
  8571. HEAP32[(HEAP32[i23 >> 2] | 0) + (i45 << 2) >> 2] = i52;
  8572. i45 = HEAPU16[i43 >> 1] | 0;
  8573. if ((i45 & 1 | 0) == 0) {
  8574. HEAP16[i43 >> 1] = i45 | 1;
  8575. if ((HEAP32[i48 >> 2] | 0) != 0 ? (i45 & 2 | 0) == 0 : 0) {
  8576. HEAP16[i43 >> 1] = i45 | 3;
  8577. HEAPF32[i48 + 144 >> 2] = 0.0;
  8578. }
  8579. i43 = HEAP32[i25 >> 2] | 0;
  8580. if ((i43 | 0) >= (HEAP32[i28 >> 2] | 0)) {
  8581. i4 = 80;
  8582. break L11;
  8583. }
  8584. HEAP32[i48 + 8 >> 2] = i43;
  8585. i66 = HEAP32[i25 >> 2] | 0;
  8586. HEAP32[(HEAP32[i29 >> 2] | 0) + (i66 << 2) >> 2] = i48;
  8587. HEAP32[i25 >> 2] = i66 + 1;
  8588. }
  8589. }
  8590. }
  8591. } while (0);
  8592. i51 = HEAP32[i51 + 12 >> 2] | 0;
  8593. } while ((i51 | 0) != 0);
  8594. }
  8595. } while (0);
  8596. if ((i44 | 0) >= 2) {
  8597. break;
  8598. }
  8599. i47 = HEAP32[i7 + (i44 << 2) >> 2] | 0;
  8600. i44 = i44 + 1 | 0;
  8601. }
  8602. d72 = (1.0 - d42) * +HEAPF32[i11 >> 2];
  8603. HEAPF32[i9 >> 2] = d72;
  8604. HEAPF32[i21 >> 2] = 1.0 / d72;
  8605. HEAPF32[i20 >> 2] = 1.0;
  8606. HEAP32[i19 >> 2] = 20;
  8607. HEAP32[i17 >> 2] = HEAP32[i18 >> 2];
  8608. HEAP8[i16] = 0;
  8609. __ZN8b2Island8SolveTOIERK10b2TimeStepii(i3, i9, HEAP32[i49 >> 2] | 0, HEAP32[i50 >> 2] | 0);
  8610. i44 = HEAP32[i25 >> 2] | 0;
  8611. if ((i44 | 0) > 0) {
  8612. i43 = 0;
  8613. do {
  8614. i45 = HEAP32[(HEAP32[i29 >> 2] | 0) + (i43 << 2) >> 2] | 0;
  8615. i66 = i45 + 4 | 0;
  8616. HEAP16[i66 >> 1] = HEAP16[i66 >> 1] & 65534;
  8617. if ((HEAP32[i45 >> 2] | 0) == 2) {
  8618. __ZN6b2Body19SynchronizeFixturesEv(i45);
  8619. i44 = HEAP32[i45 + 112 >> 2] | 0;
  8620. if ((i44 | 0) != 0) {
  8621. do {
  8622. i66 = (HEAP32[i44 + 4 >> 2] | 0) + 4 | 0;
  8623. HEAP32[i66 >> 2] = HEAP32[i66 >> 2] & -34;
  8624. i44 = HEAP32[i44 + 12 >> 2] | 0;
  8625. } while ((i44 | 0) != 0);
  8626. }
  8627. i44 = HEAP32[i25 >> 2] | 0;
  8628. }
  8629. i43 = i43 + 1 | 0;
  8630. } while ((i43 | 0) < (i44 | 0));
  8631. }
  8632. __ZN16b2ContactManager15FindNewContactsEv(i10);
  8633. if ((HEAP8[i39] | 0) != 0) {
  8634. i4 = 92;
  8635. break;
  8636. }
  8637. }
  8638. if ((i4 | 0) == 16) {
  8639. ___assert_fail(2288, 2184, 641, 2344);
  8640. } else if ((i4 | 0) == 21) {
  8641. ___assert_fail(2360, 2376, 723, 2400);
  8642. } else if ((i4 | 0) == 25) {
  8643. ___assert_fail(2360, 2376, 723, 2400);
  8644. } else if ((i4 | 0) == 28) {
  8645. ___assert_fail(2360, 2184, 676, 2344);
  8646. } else if ((i4 | 0) == 36) {
  8647. HEAP8[i2] = 1;
  8648. __ZN8b2IslandD2Ev(i3);
  8649. STACKTOP = i1;
  8650. return;
  8651. } else if ((i4 | 0) == 38) {
  8652. ___assert_fail(2360, 2376, 723, 2400);
  8653. } else if ((i4 | 0) == 40) {
  8654. ___assert_fail(2360, 2376, 723, 2400);
  8655. } else if ((i4 | 0) == 48) {
  8656. ___assert_fail(2520, 2440, 54, 2472);
  8657. } else if ((i4 | 0) == 50) {
  8658. ___assert_fail(2520, 2440, 54, 2472);
  8659. } else if ((i4 | 0) == 52) {
  8660. ___assert_fail(2480, 2440, 62, 2472);
  8661. } else if ((i4 | 0) == 67) {
  8662. ___assert_fail(2360, 2376, 723, 2400);
  8663. } else if ((i4 | 0) == 74) {
  8664. ___assert_fail(2480, 2440, 62, 2472);
  8665. } else if ((i4 | 0) == 80) {
  8666. ___assert_fail(2520, 2440, 54, 2472);
  8667. } else if ((i4 | 0) == 92) {
  8668. HEAP8[i2] = 0;
  8669. __ZN8b2IslandD2Ev(i3);
  8670. STACKTOP = i1;
  8671. return;
  8672. }
  8673. }
  8674. function __ZNSt3__16__sortIRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i5, i8, i1) {
  8675. i5 = i5 | 0;
  8676. i8 = i8 | 0;
  8677. i1 = i1 | 0;
  8678. var i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0;
  8679. i3 = STACKTOP;
  8680. STACKTOP = STACKTOP + 16 | 0;
  8681. i2 = i3;
  8682. L1 : while (1) {
  8683. i7 = i8;
  8684. i4 = i8 + -12 | 0;
  8685. L3 : while (1) {
  8686. i9 = i5;
  8687. i11 = i7 - i9 | 0;
  8688. switch ((i11 | 0) / 12 | 0 | 0) {
  8689. case 4:
  8690. {
  8691. i6 = 14;
  8692. break L1;
  8693. }
  8694. case 2:
  8695. {
  8696. i6 = 4;
  8697. break L1;
  8698. }
  8699. case 3:
  8700. {
  8701. i6 = 6;
  8702. break L1;
  8703. }
  8704. case 5:
  8705. {
  8706. i6 = 15;
  8707. break L1;
  8708. }
  8709. case 1:
  8710. case 0:
  8711. {
  8712. i6 = 67;
  8713. break L1;
  8714. }
  8715. default:
  8716. {}
  8717. }
  8718. if ((i11 | 0) < 372) {
  8719. i6 = 21;
  8720. break L1;
  8721. }
  8722. i12 = (i11 | 0) / 24 | 0;
  8723. i10 = i5 + (i12 * 12 | 0) | 0;
  8724. do {
  8725. if ((i11 | 0) > 11988) {
  8726. i14 = (i11 | 0) / 48 | 0;
  8727. i11 = i5 + (i14 * 12 | 0) | 0;
  8728. i14 = i5 + ((i14 + i12 | 0) * 12 | 0) | 0;
  8729. i12 = __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i5, i11, i10, i14, i1) | 0;
  8730. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i14) | 0) {
  8731. HEAP32[i2 + 0 >> 2] = HEAP32[i14 + 0 >> 2];
  8732. HEAP32[i2 + 4 >> 2] = HEAP32[i14 + 4 >> 2];
  8733. HEAP32[i2 + 8 >> 2] = HEAP32[i14 + 8 >> 2];
  8734. HEAP32[i14 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  8735. HEAP32[i14 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  8736. HEAP32[i14 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  8737. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8738. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8739. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8740. i13 = i12 + 1 | 0;
  8741. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i14, i10) | 0) {
  8742. HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8743. HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8744. HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8745. HEAP32[i10 + 0 >> 2] = HEAP32[i14 + 0 >> 2];
  8746. HEAP32[i10 + 4 >> 2] = HEAP32[i14 + 4 >> 2];
  8747. HEAP32[i10 + 8 >> 2] = HEAP32[i14 + 8 >> 2];
  8748. HEAP32[i14 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8749. HEAP32[i14 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8750. HEAP32[i14 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8751. i13 = i12 + 2 | 0;
  8752. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i11) | 0) {
  8753. HEAP32[i2 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
  8754. HEAP32[i2 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
  8755. HEAP32[i2 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
  8756. HEAP32[i11 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8757. HEAP32[i11 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8758. HEAP32[i11 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8759. HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8760. HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8761. HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8762. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i11, i5) | 0) {
  8763. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  8764. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  8765. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  8766. HEAP32[i5 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
  8767. HEAP32[i5 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
  8768. HEAP32[i5 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
  8769. HEAP32[i11 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8770. HEAP32[i11 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8771. HEAP32[i11 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8772. i12 = i12 + 4 | 0;
  8773. } else {
  8774. i12 = i12 + 3 | 0;
  8775. }
  8776. } else {
  8777. i12 = i13;
  8778. }
  8779. } else {
  8780. i12 = i13;
  8781. }
  8782. }
  8783. } else {
  8784. i15 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i5) | 0;
  8785. i11 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i10) | 0;
  8786. if (!i15) {
  8787. if (!i11) {
  8788. i12 = 0;
  8789. break;
  8790. }
  8791. HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8792. HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8793. HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8794. HEAP32[i10 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  8795. HEAP32[i10 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  8796. HEAP32[i10 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  8797. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8798. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8799. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8800. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i5) | 0)) {
  8801. i12 = 1;
  8802. break;
  8803. }
  8804. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  8805. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  8806. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  8807. HEAP32[i5 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8808. HEAP32[i5 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8809. HEAP32[i5 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8810. HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8811. HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8812. HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8813. i12 = 2;
  8814. break;
  8815. }
  8816. if (i11) {
  8817. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  8818. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  8819. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  8820. HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  8821. HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  8822. HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  8823. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8824. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8825. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8826. i12 = 1;
  8827. break;
  8828. }
  8829. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  8830. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  8831. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  8832. HEAP32[i5 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8833. HEAP32[i5 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8834. HEAP32[i5 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8835. HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8836. HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8837. HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8838. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i10) | 0) {
  8839. HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8840. HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8841. HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8842. HEAP32[i10 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  8843. HEAP32[i10 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  8844. HEAP32[i10 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  8845. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8846. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8847. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8848. i12 = 2;
  8849. } else {
  8850. i12 = 1;
  8851. }
  8852. }
  8853. } while (0);
  8854. do {
  8855. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i10) | 0) {
  8856. i13 = i4;
  8857. } else {
  8858. i13 = i4;
  8859. while (1) {
  8860. i13 = i13 + -12 | 0;
  8861. if ((i5 | 0) == (i13 | 0)) {
  8862. break;
  8863. }
  8864. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i13, i10) | 0) {
  8865. i6 = 50;
  8866. break;
  8867. }
  8868. }
  8869. if ((i6 | 0) == 50) {
  8870. i6 = 0;
  8871. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  8872. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  8873. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  8874. HEAP32[i5 + 0 >> 2] = HEAP32[i13 + 0 >> 2];
  8875. HEAP32[i5 + 4 >> 2] = HEAP32[i13 + 4 >> 2];
  8876. HEAP32[i5 + 8 >> 2] = HEAP32[i13 + 8 >> 2];
  8877. HEAP32[i13 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8878. HEAP32[i13 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8879. HEAP32[i13 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8880. i12 = i12 + 1 | 0;
  8881. break;
  8882. }
  8883. i10 = i5 + 12 | 0;
  8884. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i4) | 0)) {
  8885. if ((i10 | 0) == (i4 | 0)) {
  8886. i6 = 67;
  8887. break L1;
  8888. }
  8889. while (1) {
  8890. i9 = i10 + 12 | 0;
  8891. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i10) | 0) {
  8892. break;
  8893. }
  8894. if ((i9 | 0) == (i4 | 0)) {
  8895. i6 = 67;
  8896. break L1;
  8897. } else {
  8898. i10 = i9;
  8899. }
  8900. }
  8901. HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8902. HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8903. HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8904. HEAP32[i10 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  8905. HEAP32[i10 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  8906. HEAP32[i10 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  8907. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8908. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8909. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8910. i10 = i9;
  8911. }
  8912. if ((i10 | 0) == (i4 | 0)) {
  8913. i6 = 67;
  8914. break L1;
  8915. } else {
  8916. i9 = i4;
  8917. }
  8918. while (1) {
  8919. while (1) {
  8920. i11 = i10 + 12 | 0;
  8921. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i10) | 0) {
  8922. break;
  8923. } else {
  8924. i10 = i11;
  8925. }
  8926. }
  8927. do {
  8928. i9 = i9 + -12 | 0;
  8929. } while (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i9) | 0);
  8930. if (!(i10 >>> 0 < i9 >>> 0)) {
  8931. i5 = i10;
  8932. continue L3;
  8933. }
  8934. HEAP32[i2 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8935. HEAP32[i2 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8936. HEAP32[i2 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8937. HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
  8938. HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
  8939. HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
  8940. HEAP32[i9 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8941. HEAP32[i9 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8942. HEAP32[i9 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8943. i10 = i11;
  8944. }
  8945. }
  8946. } while (0);
  8947. i11 = i5 + 12 | 0;
  8948. L47 : do {
  8949. if (i11 >>> 0 < i13 >>> 0) {
  8950. while (1) {
  8951. i15 = i11;
  8952. while (1) {
  8953. i11 = i15 + 12 | 0;
  8954. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i15, i10) | 0) {
  8955. i15 = i11;
  8956. } else {
  8957. i14 = i13;
  8958. break;
  8959. }
  8960. }
  8961. do {
  8962. i14 = i14 + -12 | 0;
  8963. } while (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i14, i10) | 0));
  8964. if (i15 >>> 0 > i14 >>> 0) {
  8965. i11 = i15;
  8966. break L47;
  8967. }
  8968. HEAP32[i2 + 0 >> 2] = HEAP32[i15 + 0 >> 2];
  8969. HEAP32[i2 + 4 >> 2] = HEAP32[i15 + 4 >> 2];
  8970. HEAP32[i2 + 8 >> 2] = HEAP32[i15 + 8 >> 2];
  8971. HEAP32[i15 + 0 >> 2] = HEAP32[i14 + 0 >> 2];
  8972. HEAP32[i15 + 4 >> 2] = HEAP32[i14 + 4 >> 2];
  8973. HEAP32[i15 + 8 >> 2] = HEAP32[i14 + 8 >> 2];
  8974. HEAP32[i14 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8975. HEAP32[i14 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8976. HEAP32[i14 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8977. i13 = i14;
  8978. i10 = (i10 | 0) == (i15 | 0) ? i14 : i10;
  8979. i12 = i12 + 1 | 0;
  8980. }
  8981. }
  8982. } while (0);
  8983. if ((i11 | 0) != (i10 | 0) ? FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i10, i11) | 0 : 0) {
  8984. HEAP32[i2 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
  8985. HEAP32[i2 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
  8986. HEAP32[i2 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
  8987. HEAP32[i11 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  8988. HEAP32[i11 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  8989. HEAP32[i11 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  8990. HEAP32[i10 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  8991. HEAP32[i10 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  8992. HEAP32[i10 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  8993. i12 = i12 + 1 | 0;
  8994. }
  8995. if ((i12 | 0) == 0) {
  8996. i12 = __ZNSt3__127__insertion_sort_incompleteIRPFbRK6b2PairS3_EPS1_EEbT0_S8_T_(i5, i11, i1) | 0;
  8997. i10 = i11 + 12 | 0;
  8998. if (__ZNSt3__127__insertion_sort_incompleteIRPFbRK6b2PairS3_EPS1_EEbT0_S8_T_(i10, i8, i1) | 0) {
  8999. i6 = 62;
  9000. break;
  9001. }
  9002. if (i12) {
  9003. i5 = i10;
  9004. continue;
  9005. }
  9006. }
  9007. i15 = i11;
  9008. if ((i15 - i9 | 0) >= (i7 - i15 | 0)) {
  9009. i6 = 66;
  9010. break;
  9011. }
  9012. __ZNSt3__16__sortIRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i5, i11, i1);
  9013. i5 = i11 + 12 | 0;
  9014. }
  9015. if ((i6 | 0) == 62) {
  9016. i6 = 0;
  9017. if (i12) {
  9018. i6 = 67;
  9019. break;
  9020. } else {
  9021. i8 = i11;
  9022. continue;
  9023. }
  9024. } else if ((i6 | 0) == 66) {
  9025. i6 = 0;
  9026. __ZNSt3__16__sortIRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i11 + 12 | 0, i8, i1);
  9027. i8 = i11;
  9028. continue;
  9029. }
  9030. }
  9031. if ((i6 | 0) == 4) {
  9032. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i5) | 0)) {
  9033. STACKTOP = i3;
  9034. return;
  9035. }
  9036. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9037. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9038. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9039. HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9040. HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9041. HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9042. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9043. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9044. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9045. STACKTOP = i3;
  9046. return;
  9047. } else if ((i6 | 0) == 6) {
  9048. i6 = i5 + 12 | 0;
  9049. i15 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i6, i5) | 0;
  9050. i7 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i6) | 0;
  9051. if (!i15) {
  9052. if (!i7) {
  9053. STACKTOP = i3;
  9054. return;
  9055. }
  9056. HEAP32[i2 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9057. HEAP32[i2 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9058. HEAP32[i2 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9059. HEAP32[i6 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9060. HEAP32[i6 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9061. HEAP32[i6 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9062. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9063. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9064. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9065. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i6, i5) | 0)) {
  9066. STACKTOP = i3;
  9067. return;
  9068. }
  9069. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9070. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9071. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9072. HEAP32[i5 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9073. HEAP32[i5 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9074. HEAP32[i5 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9075. HEAP32[i6 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9076. HEAP32[i6 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9077. HEAP32[i6 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9078. STACKTOP = i3;
  9079. return;
  9080. }
  9081. if (i7) {
  9082. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9083. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9084. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9085. HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9086. HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9087. HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9088. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9089. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9090. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9091. STACKTOP = i3;
  9092. return;
  9093. }
  9094. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9095. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9096. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9097. HEAP32[i5 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9098. HEAP32[i5 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9099. HEAP32[i5 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9100. HEAP32[i6 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9101. HEAP32[i6 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9102. HEAP32[i6 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9103. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i6) | 0)) {
  9104. STACKTOP = i3;
  9105. return;
  9106. }
  9107. HEAP32[i2 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9108. HEAP32[i2 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9109. HEAP32[i2 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9110. HEAP32[i6 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9111. HEAP32[i6 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9112. HEAP32[i6 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9113. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9114. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9115. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9116. STACKTOP = i3;
  9117. return;
  9118. } else if ((i6 | 0) == 14) {
  9119. __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i5, i5 + 12 | 0, i5 + 24 | 0, i4, i1) | 0;
  9120. STACKTOP = i3;
  9121. return;
  9122. } else if ((i6 | 0) == 15) {
  9123. i6 = i5 + 12 | 0;
  9124. i7 = i5 + 24 | 0;
  9125. i8 = i5 + 36 | 0;
  9126. __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i5, i6, i7, i8, i1) | 0;
  9127. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i8) | 0)) {
  9128. STACKTOP = i3;
  9129. return;
  9130. }
  9131. HEAP32[i2 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
  9132. HEAP32[i2 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
  9133. HEAP32[i2 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
  9134. HEAP32[i8 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9135. HEAP32[i8 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9136. HEAP32[i8 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9137. HEAP32[i4 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9138. HEAP32[i4 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9139. HEAP32[i4 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9140. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i8, i7) | 0)) {
  9141. STACKTOP = i3;
  9142. return;
  9143. }
  9144. HEAP32[i2 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9145. HEAP32[i2 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9146. HEAP32[i2 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9147. HEAP32[i7 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
  9148. HEAP32[i7 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
  9149. HEAP32[i7 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
  9150. HEAP32[i8 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9151. HEAP32[i8 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9152. HEAP32[i8 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9153. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0)) {
  9154. STACKTOP = i3;
  9155. return;
  9156. }
  9157. HEAP32[i2 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9158. HEAP32[i2 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9159. HEAP32[i2 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9160. HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9161. HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9162. HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9163. HEAP32[i7 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9164. HEAP32[i7 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9165. HEAP32[i7 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9166. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i6, i5) | 0)) {
  9167. STACKTOP = i3;
  9168. return;
  9169. }
  9170. HEAP32[i2 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9171. HEAP32[i2 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9172. HEAP32[i2 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9173. HEAP32[i5 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9174. HEAP32[i5 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9175. HEAP32[i5 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9176. HEAP32[i6 + 0 >> 2] = HEAP32[i2 + 0 >> 2];
  9177. HEAP32[i6 + 4 >> 2] = HEAP32[i2 + 4 >> 2];
  9178. HEAP32[i6 + 8 >> 2] = HEAP32[i2 + 8 >> 2];
  9179. STACKTOP = i3;
  9180. return;
  9181. } else if ((i6 | 0) == 21) {
  9182. __ZNSt3__118__insertion_sort_3IRPFbRK6b2PairS3_EPS1_EEvT0_S8_T_(i5, i8, i1);
  9183. STACKTOP = i3;
  9184. return;
  9185. } else if ((i6 | 0) == 67) {
  9186. STACKTOP = i3;
  9187. return;
  9188. }
  9189. }
  9190. function _free(i7) {
  9191. i7 = i7 | 0;
  9192. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0;
  9193. i1 = STACKTOP;
  9194. if ((i7 | 0) == 0) {
  9195. STACKTOP = i1;
  9196. return;
  9197. }
  9198. i15 = i7 + -8 | 0;
  9199. i16 = HEAP32[7176 >> 2] | 0;
  9200. if (i15 >>> 0 < i16 >>> 0) {
  9201. _abort();
  9202. }
  9203. i13 = HEAP32[i7 + -4 >> 2] | 0;
  9204. i12 = i13 & 3;
  9205. if ((i12 | 0) == 1) {
  9206. _abort();
  9207. }
  9208. i8 = i13 & -8;
  9209. i6 = i7 + (i8 + -8) | 0;
  9210. do {
  9211. if ((i13 & 1 | 0) == 0) {
  9212. i19 = HEAP32[i15 >> 2] | 0;
  9213. if ((i12 | 0) == 0) {
  9214. STACKTOP = i1;
  9215. return;
  9216. }
  9217. i15 = -8 - i19 | 0;
  9218. i13 = i7 + i15 | 0;
  9219. i12 = i19 + i8 | 0;
  9220. if (i13 >>> 0 < i16 >>> 0) {
  9221. _abort();
  9222. }
  9223. if ((i13 | 0) == (HEAP32[7180 >> 2] | 0)) {
  9224. i2 = i7 + (i8 + -4) | 0;
  9225. if ((HEAP32[i2 >> 2] & 3 | 0) != 3) {
  9226. i2 = i13;
  9227. i11 = i12;
  9228. break;
  9229. }
  9230. HEAP32[7168 >> 2] = i12;
  9231. HEAP32[i2 >> 2] = HEAP32[i2 >> 2] & -2;
  9232. HEAP32[i7 + (i15 + 4) >> 2] = i12 | 1;
  9233. HEAP32[i6 >> 2] = i12;
  9234. STACKTOP = i1;
  9235. return;
  9236. }
  9237. i18 = i19 >>> 3;
  9238. if (i19 >>> 0 < 256) {
  9239. i2 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
  9240. i11 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
  9241. i14 = 7200 + (i18 << 1 << 2) | 0;
  9242. if ((i2 | 0) != (i14 | 0)) {
  9243. if (i2 >>> 0 < i16 >>> 0) {
  9244. _abort();
  9245. }
  9246. if ((HEAP32[i2 + 12 >> 2] | 0) != (i13 | 0)) {
  9247. _abort();
  9248. }
  9249. }
  9250. if ((i11 | 0) == (i2 | 0)) {
  9251. HEAP32[1790] = HEAP32[1790] & ~(1 << i18);
  9252. i2 = i13;
  9253. i11 = i12;
  9254. break;
  9255. }
  9256. if ((i11 | 0) != (i14 | 0)) {
  9257. if (i11 >>> 0 < i16 >>> 0) {
  9258. _abort();
  9259. }
  9260. i14 = i11 + 8 | 0;
  9261. if ((HEAP32[i14 >> 2] | 0) == (i13 | 0)) {
  9262. i17 = i14;
  9263. } else {
  9264. _abort();
  9265. }
  9266. } else {
  9267. i17 = i11 + 8 | 0;
  9268. }
  9269. HEAP32[i2 + 12 >> 2] = i11;
  9270. HEAP32[i17 >> 2] = i2;
  9271. i2 = i13;
  9272. i11 = i12;
  9273. break;
  9274. }
  9275. i17 = HEAP32[i7 + (i15 + 24) >> 2] | 0;
  9276. i18 = HEAP32[i7 + (i15 + 12) >> 2] | 0;
  9277. do {
  9278. if ((i18 | 0) == (i13 | 0)) {
  9279. i19 = i7 + (i15 + 20) | 0;
  9280. i18 = HEAP32[i19 >> 2] | 0;
  9281. if ((i18 | 0) == 0) {
  9282. i19 = i7 + (i15 + 16) | 0;
  9283. i18 = HEAP32[i19 >> 2] | 0;
  9284. if ((i18 | 0) == 0) {
  9285. i14 = 0;
  9286. break;
  9287. }
  9288. }
  9289. while (1) {
  9290. i21 = i18 + 20 | 0;
  9291. i20 = HEAP32[i21 >> 2] | 0;
  9292. if ((i20 | 0) != 0) {
  9293. i18 = i20;
  9294. i19 = i21;
  9295. continue;
  9296. }
  9297. i20 = i18 + 16 | 0;
  9298. i21 = HEAP32[i20 >> 2] | 0;
  9299. if ((i21 | 0) == 0) {
  9300. break;
  9301. } else {
  9302. i18 = i21;
  9303. i19 = i20;
  9304. }
  9305. }
  9306. if (i19 >>> 0 < i16 >>> 0) {
  9307. _abort();
  9308. } else {
  9309. HEAP32[i19 >> 2] = 0;
  9310. i14 = i18;
  9311. break;
  9312. }
  9313. } else {
  9314. i19 = HEAP32[i7 + (i15 + 8) >> 2] | 0;
  9315. if (i19 >>> 0 < i16 >>> 0) {
  9316. _abort();
  9317. }
  9318. i16 = i19 + 12 | 0;
  9319. if ((HEAP32[i16 >> 2] | 0) != (i13 | 0)) {
  9320. _abort();
  9321. }
  9322. i20 = i18 + 8 | 0;
  9323. if ((HEAP32[i20 >> 2] | 0) == (i13 | 0)) {
  9324. HEAP32[i16 >> 2] = i18;
  9325. HEAP32[i20 >> 2] = i19;
  9326. i14 = i18;
  9327. break;
  9328. } else {
  9329. _abort();
  9330. }
  9331. }
  9332. } while (0);
  9333. if ((i17 | 0) != 0) {
  9334. i18 = HEAP32[i7 + (i15 + 28) >> 2] | 0;
  9335. i16 = 7464 + (i18 << 2) | 0;
  9336. if ((i13 | 0) == (HEAP32[i16 >> 2] | 0)) {
  9337. HEAP32[i16 >> 2] = i14;
  9338. if ((i14 | 0) == 0) {
  9339. HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i18);
  9340. i2 = i13;
  9341. i11 = i12;
  9342. break;
  9343. }
  9344. } else {
  9345. if (i17 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9346. _abort();
  9347. }
  9348. i16 = i17 + 16 | 0;
  9349. if ((HEAP32[i16 >> 2] | 0) == (i13 | 0)) {
  9350. HEAP32[i16 >> 2] = i14;
  9351. } else {
  9352. HEAP32[i17 + 20 >> 2] = i14;
  9353. }
  9354. if ((i14 | 0) == 0) {
  9355. i2 = i13;
  9356. i11 = i12;
  9357. break;
  9358. }
  9359. }
  9360. if (i14 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9361. _abort();
  9362. }
  9363. HEAP32[i14 + 24 >> 2] = i17;
  9364. i16 = HEAP32[i7 + (i15 + 16) >> 2] | 0;
  9365. do {
  9366. if ((i16 | 0) != 0) {
  9367. if (i16 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9368. _abort();
  9369. } else {
  9370. HEAP32[i14 + 16 >> 2] = i16;
  9371. HEAP32[i16 + 24 >> 2] = i14;
  9372. break;
  9373. }
  9374. }
  9375. } while (0);
  9376. i15 = HEAP32[i7 + (i15 + 20) >> 2] | 0;
  9377. if ((i15 | 0) != 0) {
  9378. if (i15 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9379. _abort();
  9380. } else {
  9381. HEAP32[i14 + 20 >> 2] = i15;
  9382. HEAP32[i15 + 24 >> 2] = i14;
  9383. i2 = i13;
  9384. i11 = i12;
  9385. break;
  9386. }
  9387. } else {
  9388. i2 = i13;
  9389. i11 = i12;
  9390. }
  9391. } else {
  9392. i2 = i13;
  9393. i11 = i12;
  9394. }
  9395. } else {
  9396. i2 = i15;
  9397. i11 = i8;
  9398. }
  9399. } while (0);
  9400. if (!(i2 >>> 0 < i6 >>> 0)) {
  9401. _abort();
  9402. }
  9403. i12 = i7 + (i8 + -4) | 0;
  9404. i13 = HEAP32[i12 >> 2] | 0;
  9405. if ((i13 & 1 | 0) == 0) {
  9406. _abort();
  9407. }
  9408. if ((i13 & 2 | 0) == 0) {
  9409. if ((i6 | 0) == (HEAP32[7184 >> 2] | 0)) {
  9410. i21 = (HEAP32[7172 >> 2] | 0) + i11 | 0;
  9411. HEAP32[7172 >> 2] = i21;
  9412. HEAP32[7184 >> 2] = i2;
  9413. HEAP32[i2 + 4 >> 2] = i21 | 1;
  9414. if ((i2 | 0) != (HEAP32[7180 >> 2] | 0)) {
  9415. STACKTOP = i1;
  9416. return;
  9417. }
  9418. HEAP32[7180 >> 2] = 0;
  9419. HEAP32[7168 >> 2] = 0;
  9420. STACKTOP = i1;
  9421. return;
  9422. }
  9423. if ((i6 | 0) == (HEAP32[7180 >> 2] | 0)) {
  9424. i21 = (HEAP32[7168 >> 2] | 0) + i11 | 0;
  9425. HEAP32[7168 >> 2] = i21;
  9426. HEAP32[7180 >> 2] = i2;
  9427. HEAP32[i2 + 4 >> 2] = i21 | 1;
  9428. HEAP32[i2 + i21 >> 2] = i21;
  9429. STACKTOP = i1;
  9430. return;
  9431. }
  9432. i11 = (i13 & -8) + i11 | 0;
  9433. i12 = i13 >>> 3;
  9434. do {
  9435. if (!(i13 >>> 0 < 256)) {
  9436. i10 = HEAP32[i7 + (i8 + 16) >> 2] | 0;
  9437. i15 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
  9438. do {
  9439. if ((i15 | 0) == (i6 | 0)) {
  9440. i13 = i7 + (i8 + 12) | 0;
  9441. i12 = HEAP32[i13 >> 2] | 0;
  9442. if ((i12 | 0) == 0) {
  9443. i13 = i7 + (i8 + 8) | 0;
  9444. i12 = HEAP32[i13 >> 2] | 0;
  9445. if ((i12 | 0) == 0) {
  9446. i9 = 0;
  9447. break;
  9448. }
  9449. }
  9450. while (1) {
  9451. i14 = i12 + 20 | 0;
  9452. i15 = HEAP32[i14 >> 2] | 0;
  9453. if ((i15 | 0) != 0) {
  9454. i12 = i15;
  9455. i13 = i14;
  9456. continue;
  9457. }
  9458. i14 = i12 + 16 | 0;
  9459. i15 = HEAP32[i14 >> 2] | 0;
  9460. if ((i15 | 0) == 0) {
  9461. break;
  9462. } else {
  9463. i12 = i15;
  9464. i13 = i14;
  9465. }
  9466. }
  9467. if (i13 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9468. _abort();
  9469. } else {
  9470. HEAP32[i13 >> 2] = 0;
  9471. i9 = i12;
  9472. break;
  9473. }
  9474. } else {
  9475. i13 = HEAP32[i7 + i8 >> 2] | 0;
  9476. if (i13 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9477. _abort();
  9478. }
  9479. i14 = i13 + 12 | 0;
  9480. if ((HEAP32[i14 >> 2] | 0) != (i6 | 0)) {
  9481. _abort();
  9482. }
  9483. i12 = i15 + 8 | 0;
  9484. if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
  9485. HEAP32[i14 >> 2] = i15;
  9486. HEAP32[i12 >> 2] = i13;
  9487. i9 = i15;
  9488. break;
  9489. } else {
  9490. _abort();
  9491. }
  9492. }
  9493. } while (0);
  9494. if ((i10 | 0) != 0) {
  9495. i12 = HEAP32[i7 + (i8 + 20) >> 2] | 0;
  9496. i13 = 7464 + (i12 << 2) | 0;
  9497. if ((i6 | 0) == (HEAP32[i13 >> 2] | 0)) {
  9498. HEAP32[i13 >> 2] = i9;
  9499. if ((i9 | 0) == 0) {
  9500. HEAP32[7164 >> 2] = HEAP32[7164 >> 2] & ~(1 << i12);
  9501. break;
  9502. }
  9503. } else {
  9504. if (i10 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9505. _abort();
  9506. }
  9507. i12 = i10 + 16 | 0;
  9508. if ((HEAP32[i12 >> 2] | 0) == (i6 | 0)) {
  9509. HEAP32[i12 >> 2] = i9;
  9510. } else {
  9511. HEAP32[i10 + 20 >> 2] = i9;
  9512. }
  9513. if ((i9 | 0) == 0) {
  9514. break;
  9515. }
  9516. }
  9517. if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9518. _abort();
  9519. }
  9520. HEAP32[i9 + 24 >> 2] = i10;
  9521. i6 = HEAP32[i7 + (i8 + 8) >> 2] | 0;
  9522. do {
  9523. if ((i6 | 0) != 0) {
  9524. if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9525. _abort();
  9526. } else {
  9527. HEAP32[i9 + 16 >> 2] = i6;
  9528. HEAP32[i6 + 24 >> 2] = i9;
  9529. break;
  9530. }
  9531. }
  9532. } while (0);
  9533. i6 = HEAP32[i7 + (i8 + 12) >> 2] | 0;
  9534. if ((i6 | 0) != 0) {
  9535. if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9536. _abort();
  9537. } else {
  9538. HEAP32[i9 + 20 >> 2] = i6;
  9539. HEAP32[i6 + 24 >> 2] = i9;
  9540. break;
  9541. }
  9542. }
  9543. }
  9544. } else {
  9545. i9 = HEAP32[i7 + i8 >> 2] | 0;
  9546. i7 = HEAP32[i7 + (i8 | 4) >> 2] | 0;
  9547. i8 = 7200 + (i12 << 1 << 2) | 0;
  9548. if ((i9 | 0) != (i8 | 0)) {
  9549. if (i9 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9550. _abort();
  9551. }
  9552. if ((HEAP32[i9 + 12 >> 2] | 0) != (i6 | 0)) {
  9553. _abort();
  9554. }
  9555. }
  9556. if ((i7 | 0) == (i9 | 0)) {
  9557. HEAP32[1790] = HEAP32[1790] & ~(1 << i12);
  9558. break;
  9559. }
  9560. if ((i7 | 0) != (i8 | 0)) {
  9561. if (i7 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9562. _abort();
  9563. }
  9564. i8 = i7 + 8 | 0;
  9565. if ((HEAP32[i8 >> 2] | 0) == (i6 | 0)) {
  9566. i10 = i8;
  9567. } else {
  9568. _abort();
  9569. }
  9570. } else {
  9571. i10 = i7 + 8 | 0;
  9572. }
  9573. HEAP32[i9 + 12 >> 2] = i7;
  9574. HEAP32[i10 >> 2] = i9;
  9575. }
  9576. } while (0);
  9577. HEAP32[i2 + 4 >> 2] = i11 | 1;
  9578. HEAP32[i2 + i11 >> 2] = i11;
  9579. if ((i2 | 0) == (HEAP32[7180 >> 2] | 0)) {
  9580. HEAP32[7168 >> 2] = i11;
  9581. STACKTOP = i1;
  9582. return;
  9583. }
  9584. } else {
  9585. HEAP32[i12 >> 2] = i13 & -2;
  9586. HEAP32[i2 + 4 >> 2] = i11 | 1;
  9587. HEAP32[i2 + i11 >> 2] = i11;
  9588. }
  9589. i6 = i11 >>> 3;
  9590. if (i11 >>> 0 < 256) {
  9591. i7 = i6 << 1;
  9592. i3 = 7200 + (i7 << 2) | 0;
  9593. i8 = HEAP32[1790] | 0;
  9594. i6 = 1 << i6;
  9595. if ((i8 & i6 | 0) != 0) {
  9596. i6 = 7200 + (i7 + 2 << 2) | 0;
  9597. i7 = HEAP32[i6 >> 2] | 0;
  9598. if (i7 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9599. _abort();
  9600. } else {
  9601. i4 = i6;
  9602. i5 = i7;
  9603. }
  9604. } else {
  9605. HEAP32[1790] = i8 | i6;
  9606. i4 = 7200 + (i7 + 2 << 2) | 0;
  9607. i5 = i3;
  9608. }
  9609. HEAP32[i4 >> 2] = i2;
  9610. HEAP32[i5 + 12 >> 2] = i2;
  9611. HEAP32[i2 + 8 >> 2] = i5;
  9612. HEAP32[i2 + 12 >> 2] = i3;
  9613. STACKTOP = i1;
  9614. return;
  9615. }
  9616. i4 = i11 >>> 8;
  9617. if ((i4 | 0) != 0) {
  9618. if (i11 >>> 0 > 16777215) {
  9619. i4 = 31;
  9620. } else {
  9621. i20 = (i4 + 1048320 | 0) >>> 16 & 8;
  9622. i21 = i4 << i20;
  9623. i19 = (i21 + 520192 | 0) >>> 16 & 4;
  9624. i21 = i21 << i19;
  9625. i4 = (i21 + 245760 | 0) >>> 16 & 2;
  9626. i4 = 14 - (i19 | i20 | i4) + (i21 << i4 >>> 15) | 0;
  9627. i4 = i11 >>> (i4 + 7 | 0) & 1 | i4 << 1;
  9628. }
  9629. } else {
  9630. i4 = 0;
  9631. }
  9632. i5 = 7464 + (i4 << 2) | 0;
  9633. HEAP32[i2 + 28 >> 2] = i4;
  9634. HEAP32[i2 + 20 >> 2] = 0;
  9635. HEAP32[i2 + 16 >> 2] = 0;
  9636. i7 = HEAP32[7164 >> 2] | 0;
  9637. i6 = 1 << i4;
  9638. L199 : do {
  9639. if ((i7 & i6 | 0) != 0) {
  9640. i5 = HEAP32[i5 >> 2] | 0;
  9641. if ((i4 | 0) == 31) {
  9642. i4 = 0;
  9643. } else {
  9644. i4 = 25 - (i4 >>> 1) | 0;
  9645. }
  9646. L204 : do {
  9647. if ((HEAP32[i5 + 4 >> 2] & -8 | 0) != (i11 | 0)) {
  9648. i4 = i11 << i4;
  9649. i7 = i5;
  9650. while (1) {
  9651. i6 = i7 + (i4 >>> 31 << 2) + 16 | 0;
  9652. i5 = HEAP32[i6 >> 2] | 0;
  9653. if ((i5 | 0) == 0) {
  9654. break;
  9655. }
  9656. if ((HEAP32[i5 + 4 >> 2] & -8 | 0) == (i11 | 0)) {
  9657. i3 = i5;
  9658. break L204;
  9659. } else {
  9660. i4 = i4 << 1;
  9661. i7 = i5;
  9662. }
  9663. }
  9664. if (i6 >>> 0 < (HEAP32[7176 >> 2] | 0) >>> 0) {
  9665. _abort();
  9666. } else {
  9667. HEAP32[i6 >> 2] = i2;
  9668. HEAP32[i2 + 24 >> 2] = i7;
  9669. HEAP32[i2 + 12 >> 2] = i2;
  9670. HEAP32[i2 + 8 >> 2] = i2;
  9671. break L199;
  9672. }
  9673. } else {
  9674. i3 = i5;
  9675. }
  9676. } while (0);
  9677. i5 = i3 + 8 | 0;
  9678. i4 = HEAP32[i5 >> 2] | 0;
  9679. i6 = HEAP32[7176 >> 2] | 0;
  9680. if (i3 >>> 0 < i6 >>> 0) {
  9681. _abort();
  9682. }
  9683. if (i4 >>> 0 < i6 >>> 0) {
  9684. _abort();
  9685. } else {
  9686. HEAP32[i4 + 12 >> 2] = i2;
  9687. HEAP32[i5 >> 2] = i2;
  9688. HEAP32[i2 + 8 >> 2] = i4;
  9689. HEAP32[i2 + 12 >> 2] = i3;
  9690. HEAP32[i2 + 24 >> 2] = 0;
  9691. break;
  9692. }
  9693. } else {
  9694. HEAP32[7164 >> 2] = i7 | i6;
  9695. HEAP32[i5 >> 2] = i2;
  9696. HEAP32[i2 + 24 >> 2] = i5;
  9697. HEAP32[i2 + 12 >> 2] = i2;
  9698. HEAP32[i2 + 8 >> 2] = i2;
  9699. }
  9700. } while (0);
  9701. i21 = (HEAP32[7192 >> 2] | 0) + -1 | 0;
  9702. HEAP32[7192 >> 2] = i21;
  9703. if ((i21 | 0) == 0) {
  9704. i2 = 7616 | 0;
  9705. } else {
  9706. STACKTOP = i1;
  9707. return;
  9708. }
  9709. while (1) {
  9710. i2 = HEAP32[i2 >> 2] | 0;
  9711. if ((i2 | 0) == 0) {
  9712. break;
  9713. } else {
  9714. i2 = i2 + 8 | 0;
  9715. }
  9716. }
  9717. HEAP32[7192 >> 2] = -1;
  9718. STACKTOP = i1;
  9719. return;
  9720. }
  9721. function __ZNSt3__127__insertion_sort_incompleteIRPFbRK6b2PairS3_EPS1_EEbT0_S8_T_(i3, i4, i2) {
  9722. i3 = i3 | 0;
  9723. i4 = i4 | 0;
  9724. i2 = i2 | 0;
  9725. var i1 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0;
  9726. i1 = STACKTOP;
  9727. STACKTOP = STACKTOP + 32 | 0;
  9728. i7 = i1 + 12 | 0;
  9729. i6 = i1;
  9730. switch ((i4 - i3 | 0) / 12 | 0 | 0) {
  9731. case 5:
  9732. {
  9733. i6 = i3 + 12 | 0;
  9734. i8 = i3 + 24 | 0;
  9735. i5 = i3 + 36 | 0;
  9736. i4 = i4 + -12 | 0;
  9737. __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i3, i6, i8, i5, i2) | 0;
  9738. if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i5) | 0)) {
  9739. i10 = 1;
  9740. STACKTOP = i1;
  9741. return i10 | 0;
  9742. }
  9743. HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9744. HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9745. HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9746. HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9747. HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9748. HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9749. HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9750. HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9751. HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9752. if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i5, i8) | 0)) {
  9753. i10 = 1;
  9754. STACKTOP = i1;
  9755. return i10 | 0;
  9756. }
  9757. HEAP32[i7 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
  9758. HEAP32[i7 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
  9759. HEAP32[i7 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
  9760. HEAP32[i8 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9761. HEAP32[i8 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9762. HEAP32[i8 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9763. HEAP32[i5 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9764. HEAP32[i5 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9765. HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9766. if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i8, i6) | 0)) {
  9767. i10 = 1;
  9768. STACKTOP = i1;
  9769. return i10 | 0;
  9770. }
  9771. HEAP32[i7 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9772. HEAP32[i7 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9773. HEAP32[i7 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9774. HEAP32[i6 + 0 >> 2] = HEAP32[i8 + 0 >> 2];
  9775. HEAP32[i6 + 4 >> 2] = HEAP32[i8 + 4 >> 2];
  9776. HEAP32[i6 + 8 >> 2] = HEAP32[i8 + 8 >> 2];
  9777. HEAP32[i8 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9778. HEAP32[i8 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9779. HEAP32[i8 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9780. if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i6, i3) | 0)) {
  9781. i10 = 1;
  9782. STACKTOP = i1;
  9783. return i10 | 0;
  9784. }
  9785. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9786. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9787. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9788. HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  9789. HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  9790. HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  9791. HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9792. HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9793. HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9794. i10 = 1;
  9795. STACKTOP = i1;
  9796. return i10 | 0;
  9797. }
  9798. case 4:
  9799. {
  9800. __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i3, i3 + 12 | 0, i3 + 24 | 0, i4 + -12 | 0, i2) | 0;
  9801. i10 = 1;
  9802. STACKTOP = i1;
  9803. return i10 | 0;
  9804. }
  9805. case 3:
  9806. {
  9807. i5 = i3 + 12 | 0;
  9808. i4 = i4 + -12 | 0;
  9809. i10 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i5, i3) | 0;
  9810. i6 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i5) | 0;
  9811. if (!i10) {
  9812. if (!i6) {
  9813. i10 = 1;
  9814. STACKTOP = i1;
  9815. return i10 | 0;
  9816. }
  9817. HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9818. HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9819. HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9820. HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9821. HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9822. HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9823. HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9824. HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9825. HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9826. if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i5, i3) | 0)) {
  9827. i10 = 1;
  9828. STACKTOP = i1;
  9829. return i10 | 0;
  9830. }
  9831. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9832. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9833. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9834. HEAP32[i3 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9835. HEAP32[i3 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9836. HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9837. HEAP32[i5 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9838. HEAP32[i5 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9839. HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9840. i10 = 1;
  9841. STACKTOP = i1;
  9842. return i10 | 0;
  9843. }
  9844. if (i6) {
  9845. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9846. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9847. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9848. HEAP32[i3 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9849. HEAP32[i3 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9850. HEAP32[i3 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9851. HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9852. HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9853. HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9854. i10 = 1;
  9855. STACKTOP = i1;
  9856. return i10 | 0;
  9857. }
  9858. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9859. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9860. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9861. HEAP32[i3 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9862. HEAP32[i3 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9863. HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9864. HEAP32[i5 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9865. HEAP32[i5 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9866. HEAP32[i5 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9867. if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i5) | 0)) {
  9868. i10 = 1;
  9869. STACKTOP = i1;
  9870. return i10 | 0;
  9871. }
  9872. HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  9873. HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  9874. HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  9875. HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9876. HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9877. HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9878. HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9879. HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9880. HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9881. i10 = 1;
  9882. STACKTOP = i1;
  9883. return i10 | 0;
  9884. }
  9885. case 2:
  9886. {
  9887. i4 = i4 + -12 | 0;
  9888. if (!(FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i4, i3) | 0)) {
  9889. i10 = 1;
  9890. STACKTOP = i1;
  9891. return i10 | 0;
  9892. }
  9893. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9894. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9895. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9896. HEAP32[i3 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  9897. HEAP32[i3 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  9898. HEAP32[i3 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  9899. HEAP32[i4 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9900. HEAP32[i4 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9901. HEAP32[i4 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9902. i10 = 1;
  9903. STACKTOP = i1;
  9904. return i10 | 0;
  9905. }
  9906. case 1:
  9907. case 0:
  9908. {
  9909. i10 = 1;
  9910. STACKTOP = i1;
  9911. return i10 | 0;
  9912. }
  9913. default:
  9914. {
  9915. i9 = i3 + 24 | 0;
  9916. i10 = i3 + 12 | 0;
  9917. i11 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i10, i3) | 0;
  9918. i8 = FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i9, i10) | 0;
  9919. do {
  9920. if (i11) {
  9921. if (i8) {
  9922. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9923. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9924. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9925. HEAP32[i3 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
  9926. HEAP32[i3 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
  9927. HEAP32[i3 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
  9928. HEAP32[i9 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9929. HEAP32[i9 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9930. HEAP32[i9 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9931. break;
  9932. }
  9933. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9934. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9935. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9936. HEAP32[i3 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  9937. HEAP32[i3 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  9938. HEAP32[i3 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  9939. HEAP32[i10 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9940. HEAP32[i10 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9941. HEAP32[i10 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9942. if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i9, i10) | 0) {
  9943. HEAP32[i7 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  9944. HEAP32[i7 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  9945. HEAP32[i7 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  9946. HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
  9947. HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
  9948. HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
  9949. HEAP32[i9 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9950. HEAP32[i9 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9951. HEAP32[i9 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9952. }
  9953. } else {
  9954. if (i8) {
  9955. HEAP32[i7 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  9956. HEAP32[i7 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  9957. HEAP32[i7 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  9958. HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
  9959. HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
  9960. HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
  9961. HEAP32[i9 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9962. HEAP32[i9 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9963. HEAP32[i9 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9964. if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i10, i3) | 0) {
  9965. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  9966. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  9967. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  9968. HEAP32[i3 + 0 >> 2] = HEAP32[i10 + 0 >> 2];
  9969. HEAP32[i3 + 4 >> 2] = HEAP32[i10 + 4 >> 2];
  9970. HEAP32[i3 + 8 >> 2] = HEAP32[i10 + 8 >> 2];
  9971. HEAP32[i10 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9972. HEAP32[i10 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9973. HEAP32[i10 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9974. }
  9975. }
  9976. }
  9977. } while (0);
  9978. i7 = i3 + 36 | 0;
  9979. if ((i7 | 0) == (i4 | 0)) {
  9980. i11 = 1;
  9981. STACKTOP = i1;
  9982. return i11 | 0;
  9983. }
  9984. i8 = 0;
  9985. while (1) {
  9986. if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i7, i9) | 0) {
  9987. HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  9988. HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  9989. HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  9990. i10 = i7;
  9991. while (1) {
  9992. HEAP32[i10 + 0 >> 2] = HEAP32[i9 + 0 >> 2];
  9993. HEAP32[i10 + 4 >> 2] = HEAP32[i9 + 4 >> 2];
  9994. HEAP32[i10 + 8 >> 2] = HEAP32[i9 + 8 >> 2];
  9995. if ((i9 | 0) == (i3 | 0)) {
  9996. break;
  9997. }
  9998. i10 = i9 + -12 | 0;
  9999. if (FUNCTION_TABLE_iii[HEAP32[i2 >> 2] & 3](i6, i10) | 0) {
  10000. i11 = i9;
  10001. i9 = i10;
  10002. i10 = i11;
  10003. } else {
  10004. break;
  10005. }
  10006. }
  10007. HEAP32[i9 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  10008. HEAP32[i9 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  10009. HEAP32[i9 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  10010. i8 = i8 + 1 | 0;
  10011. if ((i8 | 0) == 8) {
  10012. break;
  10013. }
  10014. }
  10015. i9 = i7 + 12 | 0;
  10016. if ((i9 | 0) == (i4 | 0)) {
  10017. i2 = 1;
  10018. i5 = 35;
  10019. break;
  10020. } else {
  10021. i11 = i7;
  10022. i7 = i9;
  10023. i9 = i11;
  10024. }
  10025. }
  10026. if ((i5 | 0) == 35) {
  10027. STACKTOP = i1;
  10028. return i2 | 0;
  10029. }
  10030. i11 = (i7 + 12 | 0) == (i4 | 0);
  10031. STACKTOP = i1;
  10032. return i11 | 0;
  10033. }
  10034. }
  10035. return 0;
  10036. }
  10037. function __ZN13b2DynamicTree7BalanceEi(i11, i6) {
  10038. i11 = i11 | 0;
  10039. i6 = i6 | 0;
  10040. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, d19 = 0.0, i20 = 0, i21 = 0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0;
  10041. i1 = STACKTOP;
  10042. if ((i6 | 0) == -1) {
  10043. ___assert_fail(3216, 2944, 382, 3232);
  10044. }
  10045. i5 = HEAP32[i11 + 4 >> 2] | 0;
  10046. i13 = i5 + (i6 * 36 | 0) | 0;
  10047. i18 = i5 + (i6 * 36 | 0) + 24 | 0;
  10048. i8 = HEAP32[i18 >> 2] | 0;
  10049. if ((i8 | 0) == -1) {
  10050. i21 = i6;
  10051. STACKTOP = i1;
  10052. return i21 | 0;
  10053. }
  10054. i2 = i5 + (i6 * 36 | 0) + 32 | 0;
  10055. if ((HEAP32[i2 >> 2] | 0) < 2) {
  10056. i21 = i6;
  10057. STACKTOP = i1;
  10058. return i21 | 0;
  10059. }
  10060. i20 = i5 + (i6 * 36 | 0) + 28 | 0;
  10061. i7 = HEAP32[i20 >> 2] | 0;
  10062. if (!((i8 | 0) > -1)) {
  10063. ___assert_fail(3240, 2944, 392, 3232);
  10064. }
  10065. i12 = HEAP32[i11 + 12 >> 2] | 0;
  10066. if ((i8 | 0) >= (i12 | 0)) {
  10067. ___assert_fail(3240, 2944, 392, 3232);
  10068. }
  10069. if (!((i7 | 0) > -1 & (i7 | 0) < (i12 | 0))) {
  10070. ___assert_fail(3272, 2944, 393, 3232);
  10071. }
  10072. i9 = i5 + (i8 * 36 | 0) | 0;
  10073. i10 = i5 + (i7 * 36 | 0) | 0;
  10074. i3 = i5 + (i7 * 36 | 0) + 32 | 0;
  10075. i4 = i5 + (i8 * 36 | 0) + 32 | 0;
  10076. i14 = (HEAP32[i3 >> 2] | 0) - (HEAP32[i4 >> 2] | 0) | 0;
  10077. if ((i14 | 0) > 1) {
  10078. i21 = i5 + (i7 * 36 | 0) + 24 | 0;
  10079. i14 = HEAP32[i21 >> 2] | 0;
  10080. i18 = i5 + (i7 * 36 | 0) + 28 | 0;
  10081. i15 = HEAP32[i18 >> 2] | 0;
  10082. i16 = i5 + (i14 * 36 | 0) | 0;
  10083. i17 = i5 + (i15 * 36 | 0) | 0;
  10084. if (!((i14 | 0) > -1 & (i14 | 0) < (i12 | 0))) {
  10085. ___assert_fail(3304, 2944, 407, 3232);
  10086. }
  10087. if (!((i15 | 0) > -1 & (i15 | 0) < (i12 | 0))) {
  10088. ___assert_fail(3336, 2944, 408, 3232);
  10089. }
  10090. HEAP32[i21 >> 2] = i6;
  10091. i21 = i5 + (i6 * 36 | 0) + 20 | 0;
  10092. i12 = i5 + (i7 * 36 | 0) + 20 | 0;
  10093. HEAP32[i12 >> 2] = HEAP32[i21 >> 2];
  10094. HEAP32[i21 >> 2] = i7;
  10095. i12 = HEAP32[i12 >> 2] | 0;
  10096. do {
  10097. if (!((i12 | 0) == -1)) {
  10098. i11 = i5 + (i12 * 36 | 0) + 24 | 0;
  10099. if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
  10100. HEAP32[i11 >> 2] = i7;
  10101. break;
  10102. }
  10103. i11 = i5 + (i12 * 36 | 0) + 28 | 0;
  10104. if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
  10105. HEAP32[i11 >> 2] = i7;
  10106. break;
  10107. } else {
  10108. ___assert_fail(3368, 2944, 424, 3232);
  10109. }
  10110. } else {
  10111. HEAP32[i11 >> 2] = i7;
  10112. }
  10113. } while (0);
  10114. i11 = i5 + (i14 * 36 | 0) + 32 | 0;
  10115. i12 = i5 + (i15 * 36 | 0) + 32 | 0;
  10116. if ((HEAP32[i11 >> 2] | 0) > (HEAP32[i12 >> 2] | 0)) {
  10117. HEAP32[i18 >> 2] = i14;
  10118. HEAP32[i20 >> 2] = i15;
  10119. HEAP32[i5 + (i15 * 36 | 0) + 20 >> 2] = i6;
  10120. d19 = +HEAPF32[i9 >> 2];
  10121. d22 = +HEAPF32[i17 >> 2];
  10122. d19 = d19 < d22 ? d19 : d22;
  10123. d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 4 >> 2];
  10124. d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
  10125. d24 = +d19;
  10126. d23 = +(d23 < d22 ? d23 : d22);
  10127. i21 = i13;
  10128. HEAPF32[i21 >> 2] = d24;
  10129. HEAPF32[i21 + 4 >> 2] = d23;
  10130. d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 8 >> 2];
  10131. d24 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
  10132. d22 = +HEAPF32[i5 + (i8 * 36 | 0) + 12 >> 2];
  10133. d25 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
  10134. d23 = +(d23 > d24 ? d23 : d24);
  10135. d24 = +(d22 > d25 ? d22 : d25);
  10136. i21 = i5 + (i6 * 36 | 0) + 8 | 0;
  10137. HEAPF32[i21 >> 2] = d23;
  10138. HEAPF32[i21 + 4 >> 2] = d24;
  10139. d24 = +HEAPF32[i16 >> 2];
  10140. d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
  10141. d23 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
  10142. d19 = +(d19 < d24 ? d19 : d24);
  10143. d22 = +(d22 < d23 ? d22 : d23);
  10144. i21 = i10;
  10145. HEAPF32[i21 >> 2] = d19;
  10146. HEAPF32[i21 + 4 >> 2] = d22;
  10147. d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
  10148. d19 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
  10149. d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
  10150. d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
  10151. d19 = +(d22 > d19 ? d22 : d19);
  10152. d25 = +(d23 > d24 ? d23 : d24);
  10153. i5 = i5 + (i7 * 36 | 0) + 8 | 0;
  10154. HEAPF32[i5 >> 2] = d19;
  10155. HEAPF32[i5 + 4 >> 2] = d25;
  10156. i4 = HEAP32[i4 >> 2] | 0;
  10157. i5 = HEAP32[i12 >> 2] | 0;
  10158. i4 = ((i4 | 0) > (i5 | 0) ? i4 : i5) + 1 | 0;
  10159. HEAP32[i2 >> 2] = i4;
  10160. i2 = HEAP32[i11 >> 2] | 0;
  10161. i2 = (i4 | 0) > (i2 | 0) ? i4 : i2;
  10162. } else {
  10163. HEAP32[i18 >> 2] = i15;
  10164. HEAP32[i20 >> 2] = i14;
  10165. HEAP32[i5 + (i14 * 36 | 0) + 20 >> 2] = i6;
  10166. d19 = +HEAPF32[i9 >> 2];
  10167. d22 = +HEAPF32[i16 >> 2];
  10168. d19 = d19 < d22 ? d19 : d22;
  10169. d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 4 >> 2];
  10170. d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
  10171. d22 = +d19;
  10172. d23 = +(d23 < d24 ? d23 : d24);
  10173. i21 = i13;
  10174. HEAPF32[i21 >> 2] = d22;
  10175. HEAPF32[i21 + 4 >> 2] = d23;
  10176. d23 = +HEAPF32[i5 + (i8 * 36 | 0) + 8 >> 2];
  10177. d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
  10178. d22 = +HEAPF32[i5 + (i8 * 36 | 0) + 12 >> 2];
  10179. d25 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
  10180. d23 = +(d23 > d24 ? d23 : d24);
  10181. d24 = +(d22 > d25 ? d22 : d25);
  10182. i21 = i5 + (i6 * 36 | 0) + 8 | 0;
  10183. HEAPF32[i21 >> 2] = d23;
  10184. HEAPF32[i21 + 4 >> 2] = d24;
  10185. d24 = +HEAPF32[i17 >> 2];
  10186. d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
  10187. d23 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
  10188. d19 = +(d19 < d24 ? d19 : d24);
  10189. d23 = +(d22 < d23 ? d22 : d23);
  10190. i21 = i10;
  10191. HEAPF32[i21 >> 2] = d19;
  10192. HEAPF32[i21 + 4 >> 2] = d23;
  10193. d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
  10194. d19 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
  10195. d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
  10196. d24 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
  10197. d19 = +(d23 > d19 ? d23 : d19);
  10198. d25 = +(d22 > d24 ? d22 : d24);
  10199. i5 = i5 + (i7 * 36 | 0) + 8 | 0;
  10200. HEAPF32[i5 >> 2] = d19;
  10201. HEAPF32[i5 + 4 >> 2] = d25;
  10202. i4 = HEAP32[i4 >> 2] | 0;
  10203. i5 = HEAP32[i11 >> 2] | 0;
  10204. i4 = ((i4 | 0) > (i5 | 0) ? i4 : i5) + 1 | 0;
  10205. HEAP32[i2 >> 2] = i4;
  10206. i2 = HEAP32[i12 >> 2] | 0;
  10207. i2 = (i4 | 0) > (i2 | 0) ? i4 : i2;
  10208. }
  10209. HEAP32[i3 >> 2] = i2 + 1;
  10210. i21 = i7;
  10211. STACKTOP = i1;
  10212. return i21 | 0;
  10213. }
  10214. if (!((i14 | 0) < -1)) {
  10215. i21 = i6;
  10216. STACKTOP = i1;
  10217. return i21 | 0;
  10218. }
  10219. i21 = i5 + (i8 * 36 | 0) + 24 | 0;
  10220. i14 = HEAP32[i21 >> 2] | 0;
  10221. i20 = i5 + (i8 * 36 | 0) + 28 | 0;
  10222. i15 = HEAP32[i20 >> 2] | 0;
  10223. i17 = i5 + (i14 * 36 | 0) | 0;
  10224. i16 = i5 + (i15 * 36 | 0) | 0;
  10225. if (!((i14 | 0) > -1 & (i14 | 0) < (i12 | 0))) {
  10226. ___assert_fail(3400, 2944, 467, 3232);
  10227. }
  10228. if (!((i15 | 0) > -1 & (i15 | 0) < (i12 | 0))) {
  10229. ___assert_fail(3432, 2944, 468, 3232);
  10230. }
  10231. HEAP32[i21 >> 2] = i6;
  10232. i21 = i5 + (i6 * 36 | 0) + 20 | 0;
  10233. i12 = i5 + (i8 * 36 | 0) + 20 | 0;
  10234. HEAP32[i12 >> 2] = HEAP32[i21 >> 2];
  10235. HEAP32[i21 >> 2] = i8;
  10236. i12 = HEAP32[i12 >> 2] | 0;
  10237. do {
  10238. if (!((i12 | 0) == -1)) {
  10239. i11 = i5 + (i12 * 36 | 0) + 24 | 0;
  10240. if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
  10241. HEAP32[i11 >> 2] = i8;
  10242. break;
  10243. }
  10244. i11 = i5 + (i12 * 36 | 0) + 28 | 0;
  10245. if ((HEAP32[i11 >> 2] | 0) == (i6 | 0)) {
  10246. HEAP32[i11 >> 2] = i8;
  10247. break;
  10248. } else {
  10249. ___assert_fail(3464, 2944, 484, 3232);
  10250. }
  10251. } else {
  10252. HEAP32[i11 >> 2] = i8;
  10253. }
  10254. } while (0);
  10255. i12 = i5 + (i14 * 36 | 0) + 32 | 0;
  10256. i11 = i5 + (i15 * 36 | 0) + 32 | 0;
  10257. if ((HEAP32[i12 >> 2] | 0) > (HEAP32[i11 >> 2] | 0)) {
  10258. HEAP32[i20 >> 2] = i14;
  10259. HEAP32[i18 >> 2] = i15;
  10260. HEAP32[i5 + (i15 * 36 | 0) + 20 >> 2] = i6;
  10261. d19 = +HEAPF32[i10 >> 2];
  10262. d22 = +HEAPF32[i16 >> 2];
  10263. d19 = d19 < d22 ? d19 : d22;
  10264. d23 = +HEAPF32[i5 + (i7 * 36 | 0) + 4 >> 2];
  10265. d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
  10266. d24 = +d19;
  10267. d23 = +(d23 < d22 ? d23 : d22);
  10268. i21 = i13;
  10269. HEAPF32[i21 >> 2] = d24;
  10270. HEAPF32[i21 + 4 >> 2] = d23;
  10271. d23 = +HEAPF32[i5 + (i7 * 36 | 0) + 8 >> 2];
  10272. d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
  10273. d24 = +HEAPF32[i5 + (i7 * 36 | 0) + 12 >> 2];
  10274. d25 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
  10275. d22 = +(d23 > d22 ? d23 : d22);
  10276. d24 = +(d24 > d25 ? d24 : d25);
  10277. i21 = i5 + (i6 * 36 | 0) + 8 | 0;
  10278. HEAPF32[i21 >> 2] = d22;
  10279. HEAPF32[i21 + 4 >> 2] = d24;
  10280. d24 = +HEAPF32[i17 >> 2];
  10281. d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
  10282. d22 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
  10283. d19 = +(d19 < d24 ? d19 : d24);
  10284. d22 = +(d23 < d22 ? d23 : d22);
  10285. i21 = i9;
  10286. HEAPF32[i21 >> 2] = d19;
  10287. HEAPF32[i21 + 4 >> 2] = d22;
  10288. d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
  10289. d23 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
  10290. d19 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
  10291. d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
  10292. d22 = +(d22 > d23 ? d22 : d23);
  10293. d25 = +(d19 > d24 ? d19 : d24);
  10294. i5 = i5 + (i8 * 36 | 0) + 8 | 0;
  10295. HEAPF32[i5 >> 2] = d22;
  10296. HEAPF32[i5 + 4 >> 2] = d25;
  10297. i3 = HEAP32[i3 >> 2] | 0;
  10298. i5 = HEAP32[i11 >> 2] | 0;
  10299. i3 = ((i3 | 0) > (i5 | 0) ? i3 : i5) + 1 | 0;
  10300. HEAP32[i2 >> 2] = i3;
  10301. i2 = HEAP32[i12 >> 2] | 0;
  10302. i2 = (i3 | 0) > (i2 | 0) ? i3 : i2;
  10303. } else {
  10304. HEAP32[i20 >> 2] = i15;
  10305. HEAP32[i18 >> 2] = i14;
  10306. HEAP32[i5 + (i14 * 36 | 0) + 20 >> 2] = i6;
  10307. d19 = +HEAPF32[i10 >> 2];
  10308. d22 = +HEAPF32[i17 >> 2];
  10309. d19 = d19 < d22 ? d19 : d22;
  10310. d23 = +HEAPF32[i5 + (i7 * 36 | 0) + 4 >> 2];
  10311. d24 = +HEAPF32[i5 + (i14 * 36 | 0) + 4 >> 2];
  10312. d22 = +d19;
  10313. d24 = +(d23 < d24 ? d23 : d24);
  10314. i21 = i13;
  10315. HEAPF32[i21 >> 2] = d22;
  10316. HEAPF32[i21 + 4 >> 2] = d24;
  10317. d24 = +HEAPF32[i5 + (i7 * 36 | 0) + 8 >> 2];
  10318. d23 = +HEAPF32[i5 + (i14 * 36 | 0) + 8 >> 2];
  10319. d22 = +HEAPF32[i5 + (i7 * 36 | 0) + 12 >> 2];
  10320. d25 = +HEAPF32[i5 + (i14 * 36 | 0) + 12 >> 2];
  10321. d23 = +(d24 > d23 ? d24 : d23);
  10322. d24 = +(d22 > d25 ? d22 : d25);
  10323. i21 = i5 + (i6 * 36 | 0) + 8 | 0;
  10324. HEAPF32[i21 >> 2] = d23;
  10325. HEAPF32[i21 + 4 >> 2] = d24;
  10326. d24 = +HEAPF32[i16 >> 2];
  10327. d23 = +HEAPF32[i5 + (i6 * 36 | 0) + 4 >> 2];
  10328. d22 = +HEAPF32[i5 + (i15 * 36 | 0) + 4 >> 2];
  10329. d19 = +(d19 < d24 ? d19 : d24);
  10330. d22 = +(d23 < d22 ? d23 : d22);
  10331. i21 = i9;
  10332. HEAPF32[i21 >> 2] = d19;
  10333. HEAPF32[i21 + 4 >> 2] = d22;
  10334. d22 = +HEAPF32[i5 + (i6 * 36 | 0) + 8 >> 2];
  10335. d23 = +HEAPF32[i5 + (i15 * 36 | 0) + 8 >> 2];
  10336. d19 = +HEAPF32[i5 + (i6 * 36 | 0) + 12 >> 2];
  10337. d24 = +HEAPF32[i5 + (i15 * 36 | 0) + 12 >> 2];
  10338. d22 = +(d22 > d23 ? d22 : d23);
  10339. d25 = +(d19 > d24 ? d19 : d24);
  10340. i5 = i5 + (i8 * 36 | 0) + 8 | 0;
  10341. HEAPF32[i5 >> 2] = d22;
  10342. HEAPF32[i5 + 4 >> 2] = d25;
  10343. i3 = HEAP32[i3 >> 2] | 0;
  10344. i5 = HEAP32[i12 >> 2] | 0;
  10345. i3 = ((i3 | 0) > (i5 | 0) ? i3 : i5) + 1 | 0;
  10346. HEAP32[i2 >> 2] = i3;
  10347. i2 = HEAP32[i11 >> 2] | 0;
  10348. i2 = (i3 | 0) > (i2 | 0) ? i3 : i2;
  10349. }
  10350. HEAP32[i4 >> 2] = i2 + 1;
  10351. i21 = i8;
  10352. STACKTOP = i1;
  10353. return i21 | 0;
  10354. }
  10355. function __Z10b2DistanceP16b2DistanceOutputP14b2SimplexCachePK15b2DistanceInput(i2, i5, i3) {
  10356. i2 = i2 | 0;
  10357. i5 = i5 | 0;
  10358. i3 = i3 | 0;
  10359. var i1 = 0, i4 = 0, i6 = 0, d7 = 0.0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0, d22 = 0.0, i23 = 0, d24 = 0.0, d25 = 0.0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, d36 = 0.0, d37 = 0.0, d38 = 0.0, i39 = 0, i40 = 0, i41 = 0, i42 = 0, d43 = 0.0, d44 = 0.0, d45 = 0.0, i46 = 0;
  10360. i1 = STACKTOP;
  10361. STACKTOP = STACKTOP + 176 | 0;
  10362. i11 = i1 + 152 | 0;
  10363. i10 = i1 + 136 | 0;
  10364. i4 = i1 + 24 | 0;
  10365. i14 = i1 + 12 | 0;
  10366. i15 = i1;
  10367. HEAP32[652] = (HEAP32[652] | 0) + 1;
  10368. i9 = i3 + 28 | 0;
  10369. i31 = i3 + 56 | 0;
  10370. HEAP32[i11 + 0 >> 2] = HEAP32[i31 + 0 >> 2];
  10371. HEAP32[i11 + 4 >> 2] = HEAP32[i31 + 4 >> 2];
  10372. HEAP32[i11 + 8 >> 2] = HEAP32[i31 + 8 >> 2];
  10373. HEAP32[i11 + 12 >> 2] = HEAP32[i31 + 12 >> 2];
  10374. i31 = i3 + 72 | 0;
  10375. HEAP32[i10 + 0 >> 2] = HEAP32[i31 + 0 >> 2];
  10376. HEAP32[i10 + 4 >> 2] = HEAP32[i31 + 4 >> 2];
  10377. HEAP32[i10 + 8 >> 2] = HEAP32[i31 + 8 >> 2];
  10378. HEAP32[i10 + 12 >> 2] = HEAP32[i31 + 12 >> 2];
  10379. __ZN9b2Simplex9ReadCacheEPK14b2SimplexCachePK15b2DistanceProxyRK11b2TransformS5_S8_(i4, i5, i3, i11, i9, i10);
  10380. i9 = i4 + 108 | 0;
  10381. i31 = HEAP32[i9 >> 2] | 0;
  10382. if ((i31 | 0) == 3 | (i31 | 0) == 2 | (i31 | 0) == 1) {
  10383. i8 = i4 + 16 | 0;
  10384. i6 = i4 + 20 | 0;
  10385. d17 = +HEAPF32[i11 + 12 >> 2];
  10386. d18 = +HEAPF32[i11 + 8 >> 2];
  10387. i13 = i3 + 16 | 0;
  10388. i12 = i3 + 20 | 0;
  10389. d16 = +HEAPF32[i11 >> 2];
  10390. d21 = +HEAPF32[i11 + 4 >> 2];
  10391. d19 = +HEAPF32[i10 + 12 >> 2];
  10392. d22 = +HEAPF32[i10 + 8 >> 2];
  10393. i23 = i3 + 44 | 0;
  10394. i20 = i3 + 48 | 0;
  10395. d24 = +HEAPF32[i10 >> 2];
  10396. d25 = +HEAPF32[i10 + 4 >> 2];
  10397. i11 = i4 + 52 | 0;
  10398. i10 = i4 + 56 | 0;
  10399. i30 = i4 + 16 | 0;
  10400. i27 = i4 + 36 | 0;
  10401. i26 = i4 + 52 | 0;
  10402. i29 = i4 + 24 | 0;
  10403. i28 = i4 + 60 | 0;
  10404. i33 = 0;
  10405. L3 : while (1) {
  10406. i32 = (i31 | 0) > 0;
  10407. if (i32) {
  10408. i34 = 0;
  10409. do {
  10410. HEAP32[i14 + (i34 << 2) >> 2] = HEAP32[i4 + (i34 * 36 | 0) + 28 >> 2];
  10411. HEAP32[i15 + (i34 << 2) >> 2] = HEAP32[i4 + (i34 * 36 | 0) + 32 >> 2];
  10412. i34 = i34 + 1 | 0;
  10413. } while ((i34 | 0) != (i31 | 0));
  10414. }
  10415. do {
  10416. if ((i31 | 0) == 2) {
  10417. i46 = i30;
  10418. d45 = +HEAPF32[i46 >> 2];
  10419. d36 = +HEAPF32[i46 + 4 >> 2];
  10420. i46 = i26;
  10421. d38 = +HEAPF32[i46 >> 2];
  10422. d37 = +HEAPF32[i46 + 4 >> 2];
  10423. d43 = d38 - d45;
  10424. d44 = d37 - d36;
  10425. d36 = d45 * d43 + d36 * d44;
  10426. if (d36 >= -0.0) {
  10427. HEAPF32[i29 >> 2] = 1.0;
  10428. HEAP32[i9 >> 2] = 1;
  10429. i35 = 17;
  10430. break;
  10431. }
  10432. d37 = d38 * d43 + d37 * d44;
  10433. if (!(d37 <= 0.0)) {
  10434. d45 = 1.0 / (d37 - d36);
  10435. HEAPF32[i29 >> 2] = d37 * d45;
  10436. HEAPF32[i28 >> 2] = -(d36 * d45);
  10437. HEAP32[i9 >> 2] = 2;
  10438. i35 = 18;
  10439. break;
  10440. } else {
  10441. HEAPF32[i28 >> 2] = 1.0;
  10442. HEAP32[i9 >> 2] = 1;
  10443. i34 = i4 + 0 | 0;
  10444. i39 = i27 + 0 | 0;
  10445. i35 = i34 + 36 | 0;
  10446. do {
  10447. HEAP32[i34 >> 2] = HEAP32[i39 >> 2];
  10448. i34 = i34 + 4 | 0;
  10449. i39 = i39 + 4 | 0;
  10450. } while ((i34 | 0) < (i35 | 0));
  10451. i35 = 17;
  10452. break;
  10453. }
  10454. } else if ((i31 | 0) == 3) {
  10455. __ZN9b2Simplex6Solve3Ev(i4);
  10456. i34 = HEAP32[i9 >> 2] | 0;
  10457. if ((i34 | 0) == 1) {
  10458. i35 = 17;
  10459. } else if ((i34 | 0) == 0) {
  10460. i35 = 15;
  10461. break L3;
  10462. } else if ((i34 | 0) == 2) {
  10463. i35 = 18;
  10464. } else if ((i34 | 0) == 3) {
  10465. i35 = 42;
  10466. break L3;
  10467. } else {
  10468. i35 = 16;
  10469. break L3;
  10470. }
  10471. } else if ((i31 | 0) == 1) {
  10472. i35 = 17;
  10473. } else {
  10474. i35 = 13;
  10475. break L3;
  10476. }
  10477. } while (0);
  10478. do {
  10479. if ((i35 | 0) == 17) {
  10480. d36 = -+HEAPF32[i8 >> 2];
  10481. d37 = -+HEAPF32[i6 >> 2];
  10482. i34 = 1;
  10483. } else if ((i35 | 0) == 18) {
  10484. d44 = +HEAPF32[i8 >> 2];
  10485. d37 = +HEAPF32[i11 >> 2] - d44;
  10486. d45 = +HEAPF32[i6 >> 2];
  10487. d36 = +HEAPF32[i10 >> 2] - d45;
  10488. if (d44 * d36 - d37 * d45 > 0.0) {
  10489. d36 = -d36;
  10490. i34 = 2;
  10491. break;
  10492. } else {
  10493. d37 = -d37;
  10494. i34 = 2;
  10495. break;
  10496. }
  10497. }
  10498. } while (0);
  10499. if (d37 * d37 + d36 * d36 < 1.4210854715202004e-14) {
  10500. i35 = 42;
  10501. break;
  10502. }
  10503. i39 = i4 + (i34 * 36 | 0) | 0;
  10504. d44 = -d36;
  10505. d45 = -d37;
  10506. d43 = d17 * d44 + d18 * d45;
  10507. d44 = d17 * d45 - d18 * d44;
  10508. i40 = HEAP32[i13 >> 2] | 0;
  10509. i41 = HEAP32[i12 >> 2] | 0;
  10510. if ((i41 | 0) > 1) {
  10511. i42 = 0;
  10512. d45 = d44 * +HEAPF32[i40 + 4 >> 2] + d43 * +HEAPF32[i40 >> 2];
  10513. i46 = 1;
  10514. while (1) {
  10515. d38 = d43 * +HEAPF32[i40 + (i46 << 3) >> 2] + d44 * +HEAPF32[i40 + (i46 << 3) + 4 >> 2];
  10516. i35 = d38 > d45;
  10517. i42 = i35 ? i46 : i42;
  10518. i46 = i46 + 1 | 0;
  10519. if ((i46 | 0) == (i41 | 0)) {
  10520. break;
  10521. } else {
  10522. d45 = i35 ? d38 : d45;
  10523. }
  10524. }
  10525. i35 = i4 + (i34 * 36 | 0) + 28 | 0;
  10526. HEAP32[i35 >> 2] = i42;
  10527. if (!((i42 | 0) > -1)) {
  10528. i35 = 28;
  10529. break;
  10530. }
  10531. } else {
  10532. i35 = i4 + (i34 * 36 | 0) + 28 | 0;
  10533. HEAP32[i35 >> 2] = 0;
  10534. i42 = 0;
  10535. }
  10536. if ((i41 | 0) <= (i42 | 0)) {
  10537. i35 = 28;
  10538. break;
  10539. }
  10540. d45 = +HEAPF32[i40 + (i42 << 3) >> 2];
  10541. d43 = +HEAPF32[i40 + (i42 << 3) + 4 >> 2];
  10542. d38 = d16 + (d17 * d45 - d18 * d43);
  10543. d44 = +d38;
  10544. d43 = +(d45 * d18 + d17 * d43 + d21);
  10545. i40 = i39;
  10546. HEAPF32[i40 >> 2] = d44;
  10547. HEAPF32[i40 + 4 >> 2] = d43;
  10548. d43 = d36 * d19 + d37 * d22;
  10549. d44 = d37 * d19 - d36 * d22;
  10550. i40 = HEAP32[i23 >> 2] | 0;
  10551. i39 = HEAP32[i20 >> 2] | 0;
  10552. if ((i39 | 0) > 1) {
  10553. i41 = 0;
  10554. d37 = d44 * +HEAPF32[i40 + 4 >> 2] + d43 * +HEAPF32[i40 >> 2];
  10555. i42 = 1;
  10556. while (1) {
  10557. d36 = d43 * +HEAPF32[i40 + (i42 << 3) >> 2] + d44 * +HEAPF32[i40 + (i42 << 3) + 4 >> 2];
  10558. i46 = d36 > d37;
  10559. i41 = i46 ? i42 : i41;
  10560. i42 = i42 + 1 | 0;
  10561. if ((i42 | 0) == (i39 | 0)) {
  10562. break;
  10563. } else {
  10564. d37 = i46 ? d36 : d37;
  10565. }
  10566. }
  10567. i42 = i4 + (i34 * 36 | 0) + 32 | 0;
  10568. HEAP32[i42 >> 2] = i41;
  10569. if (!((i41 | 0) > -1)) {
  10570. i35 = 35;
  10571. break;
  10572. }
  10573. } else {
  10574. i42 = i4 + (i34 * 36 | 0) + 32 | 0;
  10575. HEAP32[i42 >> 2] = 0;
  10576. i41 = 0;
  10577. }
  10578. if ((i39 | 0) <= (i41 | 0)) {
  10579. i35 = 35;
  10580. break;
  10581. }
  10582. d37 = +HEAPF32[i40 + (i41 << 3) >> 2];
  10583. d45 = +HEAPF32[i40 + (i41 << 3) + 4 >> 2];
  10584. d44 = d24 + (d19 * d37 - d22 * d45);
  10585. d43 = +d44;
  10586. d45 = +(d37 * d22 + d19 * d45 + d25);
  10587. i46 = i4 + (i34 * 36 | 0) + 8 | 0;
  10588. HEAPF32[i46 >> 2] = d43;
  10589. HEAPF32[i46 + 4 >> 2] = d45;
  10590. d44 = +(d44 - d38);
  10591. d45 = +(+HEAPF32[i4 + (i34 * 36 | 0) + 12 >> 2] - +HEAPF32[i4 + (i34 * 36 | 0) + 4 >> 2]);
  10592. i46 = i4 + (i34 * 36 | 0) + 16 | 0;
  10593. HEAPF32[i46 >> 2] = d44;
  10594. HEAPF32[i46 + 4 >> 2] = d45;
  10595. i33 = i33 + 1 | 0;
  10596. HEAP32[654] = (HEAP32[654] | 0) + 1;
  10597. if (i32) {
  10598. i34 = HEAP32[i35 >> 2] | 0;
  10599. i32 = 0;
  10600. do {
  10601. if ((i34 | 0) == (HEAP32[i14 + (i32 << 2) >> 2] | 0) ? (HEAP32[i42 >> 2] | 0) == (HEAP32[i15 + (i32 << 2) >> 2] | 0) : 0) {
  10602. i35 = 42;
  10603. break L3;
  10604. }
  10605. i32 = i32 + 1 | 0;
  10606. } while ((i32 | 0) < (i31 | 0));
  10607. }
  10608. i31 = (HEAP32[i9 >> 2] | 0) + 1 | 0;
  10609. HEAP32[i9 >> 2] = i31;
  10610. if ((i33 | 0) >= 20) {
  10611. i35 = 42;
  10612. break;
  10613. }
  10614. }
  10615. if ((i35 | 0) == 13) {
  10616. ___assert_fail(2712, 2672, 498, 2720);
  10617. } else if ((i35 | 0) == 15) {
  10618. ___assert_fail(2712, 2672, 194, 2856);
  10619. } else if ((i35 | 0) == 16) {
  10620. ___assert_fail(2712, 2672, 207, 2856);
  10621. } else if ((i35 | 0) == 28) {
  10622. ___assert_fail(2776, 2808, 103, 2840);
  10623. } else if ((i35 | 0) == 35) {
  10624. ___assert_fail(2776, 2808, 103, 2840);
  10625. } else if ((i35 | 0) == 42) {
  10626. i12 = HEAP32[656] | 0;
  10627. HEAP32[656] = (i12 | 0) > (i33 | 0) ? i12 : i33;
  10628. i14 = i2 + 8 | 0;
  10629. __ZNK9b2Simplex16GetWitnessPointsEP6b2Vec2S1_(i4, i2, i14);
  10630. d44 = +HEAPF32[i2 >> 2] - +HEAPF32[i14 >> 2];
  10631. i13 = i2 + 4 | 0;
  10632. i12 = i2 + 12 | 0;
  10633. d45 = +HEAPF32[i13 >> 2] - +HEAPF32[i12 >> 2];
  10634. i15 = i2 + 16 | 0;
  10635. HEAPF32[i15 >> 2] = +Math_sqrt(+(d44 * d44 + d45 * d45));
  10636. HEAP32[i2 + 20 >> 2] = i33;
  10637. i9 = HEAP32[i9 >> 2] | 0;
  10638. if ((i9 | 0) == 2) {
  10639. d45 = +HEAPF32[i8 >> 2] - +HEAPF32[i11 >> 2];
  10640. d7 = +HEAPF32[i6 >> 2] - +HEAPF32[i10 >> 2];
  10641. d7 = +Math_sqrt(+(d45 * d45 + d7 * d7));
  10642. } else if ((i9 | 0) == 3) {
  10643. d7 = +HEAPF32[i8 >> 2];
  10644. d45 = +HEAPF32[i6 >> 2];
  10645. d7 = (+HEAPF32[i11 >> 2] - d7) * (+HEAPF32[i4 + 92 >> 2] - d45) - (+HEAPF32[i10 >> 2] - d45) * (+HEAPF32[i4 + 88 >> 2] - d7);
  10646. } else if ((i9 | 0) == 1) {
  10647. d7 = 0.0;
  10648. } else if ((i9 | 0) == 0) {
  10649. ___assert_fail(2712, 2672, 246, 2736);
  10650. } else {
  10651. ___assert_fail(2712, 2672, 259, 2736);
  10652. }
  10653. HEAPF32[i5 >> 2] = d7;
  10654. HEAP16[i5 + 4 >> 1] = i9;
  10655. i6 = 0;
  10656. do {
  10657. HEAP8[i5 + i6 + 6 | 0] = HEAP32[i4 + (i6 * 36 | 0) + 28 >> 2];
  10658. HEAP8[i5 + i6 + 9 | 0] = HEAP32[i4 + (i6 * 36 | 0) + 32 >> 2];
  10659. i6 = i6 + 1 | 0;
  10660. } while ((i6 | 0) < (i9 | 0));
  10661. if ((HEAP8[i3 + 88 | 0] | 0) == 0) {
  10662. STACKTOP = i1;
  10663. return;
  10664. }
  10665. d7 = +HEAPF32[i3 + 24 >> 2];
  10666. d16 = +HEAPF32[i3 + 52 >> 2];
  10667. d18 = +HEAPF32[i15 >> 2];
  10668. d17 = d7 + d16;
  10669. if (!(d18 > d17 & d18 > 1.1920928955078125e-7)) {
  10670. d44 = +((+HEAPF32[i2 >> 2] + +HEAPF32[i14 >> 2]) * .5);
  10671. d45 = +((+HEAPF32[i13 >> 2] + +HEAPF32[i12 >> 2]) * .5);
  10672. i46 = i2;
  10673. HEAPF32[i46 >> 2] = d44;
  10674. HEAPF32[i46 + 4 >> 2] = d45;
  10675. i46 = i14;
  10676. HEAPF32[i46 >> 2] = d44;
  10677. HEAPF32[i46 + 4 >> 2] = d45;
  10678. HEAPF32[i15 >> 2] = 0.0;
  10679. STACKTOP = i1;
  10680. return;
  10681. }
  10682. HEAPF32[i15 >> 2] = d18 - d17;
  10683. d18 = +HEAPF32[i14 >> 2];
  10684. d21 = +HEAPF32[i2 >> 2];
  10685. d24 = d18 - d21;
  10686. d17 = +HEAPF32[i12 >> 2];
  10687. d19 = +HEAPF32[i13 >> 2];
  10688. d22 = d17 - d19;
  10689. d25 = +Math_sqrt(+(d24 * d24 + d22 * d22));
  10690. if (!(d25 < 1.1920928955078125e-7)) {
  10691. d45 = 1.0 / d25;
  10692. d24 = d24 * d45;
  10693. d22 = d22 * d45;
  10694. }
  10695. HEAPF32[i2 >> 2] = d7 * d24 + d21;
  10696. HEAPF32[i13 >> 2] = d7 * d22 + d19;
  10697. HEAPF32[i14 >> 2] = d18 - d16 * d24;
  10698. HEAPF32[i12 >> 2] = d17 - d16 * d22;
  10699. STACKTOP = i1;
  10700. return;
  10701. }
  10702. } else if ((i31 | 0) == 0) {
  10703. ___assert_fail(2712, 2672, 194, 2856);
  10704. } else {
  10705. ___assert_fail(2712, 2672, 207, 2856);
  10706. }
  10707. }
  10708. function __ZN8b2Island5SolveEP9b2ProfileRK10b2TimeStepRK6b2Vec2b(i4, i8, i11, i17, i7) {
  10709. i4 = i4 | 0;
  10710. i8 = i8 | 0;
  10711. i11 = i11 | 0;
  10712. i17 = i17 | 0;
  10713. i7 = i7 | 0;
  10714. var i1 = 0, i2 = 0, i3 = 0, d5 = 0.0, i6 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i18 = 0, i19 = 0, i20 = 0, d21 = 0.0, i22 = 0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, i30 = 0;
  10715. i3 = STACKTOP;
  10716. STACKTOP = STACKTOP + 160 | 0;
  10717. i6 = i3 + 128 | 0;
  10718. i9 = i3 + 148 | 0;
  10719. i10 = i3 + 96 | 0;
  10720. i16 = i3 + 52 | 0;
  10721. i2 = i3;
  10722. __ZN7b2TimerC2Ev(i9);
  10723. d5 = +HEAPF32[i11 >> 2];
  10724. i1 = i4 + 28 | 0;
  10725. if ((HEAP32[i1 >> 2] | 0) > 0) {
  10726. i13 = i4 + 8 | 0;
  10727. i12 = i17 + 4 | 0;
  10728. i15 = i4 + 20 | 0;
  10729. i14 = i4 + 24 | 0;
  10730. i19 = 0;
  10731. do {
  10732. i22 = HEAP32[(HEAP32[i13 >> 2] | 0) + (i19 << 2) >> 2] | 0;
  10733. i18 = i22 + 44 | 0;
  10734. i20 = HEAP32[i18 >> 2] | 0;
  10735. i18 = HEAP32[i18 + 4 >> 2] | 0;
  10736. d21 = +HEAPF32[i22 + 56 >> 2];
  10737. i30 = i22 + 64 | 0;
  10738. d27 = +HEAPF32[i30 >> 2];
  10739. d24 = +HEAPF32[i30 + 4 >> 2];
  10740. d23 = +HEAPF32[i22 + 72 >> 2];
  10741. i30 = i22 + 36 | 0;
  10742. HEAP32[i30 >> 2] = i20;
  10743. HEAP32[i30 + 4 >> 2] = i18;
  10744. HEAPF32[i22 + 52 >> 2] = d21;
  10745. if ((HEAP32[i22 >> 2] | 0) == 2) {
  10746. d25 = +HEAPF32[i22 + 140 >> 2];
  10747. d26 = +HEAPF32[i22 + 120 >> 2];
  10748. d28 = 1.0 - d5 * +HEAPF32[i22 + 132 >> 2];
  10749. d28 = d28 < 1.0 ? d28 : 1.0;
  10750. d28 = d28 < 0.0 ? 0.0 : d28;
  10751. d29 = 1.0 - d5 * +HEAPF32[i22 + 136 >> 2];
  10752. d29 = d29 < 1.0 ? d29 : 1.0;
  10753. d27 = (d27 + d5 * (d25 * +HEAPF32[i17 >> 2] + d26 * +HEAPF32[i22 + 76 >> 2])) * d28;
  10754. d24 = (d24 + d5 * (d25 * +HEAPF32[i12 >> 2] + d26 * +HEAPF32[i22 + 80 >> 2])) * d28;
  10755. d23 = (d23 + d5 * +HEAPF32[i22 + 128 >> 2] * +HEAPF32[i22 + 84 >> 2]) * (d29 < 0.0 ? 0.0 : d29);
  10756. }
  10757. i30 = (HEAP32[i15 >> 2] | 0) + (i19 * 12 | 0) | 0;
  10758. HEAP32[i30 >> 2] = i20;
  10759. HEAP32[i30 + 4 >> 2] = i18;
  10760. HEAPF32[(HEAP32[i15 >> 2] | 0) + (i19 * 12 | 0) + 8 >> 2] = d21;
  10761. d28 = +d27;
  10762. d29 = +d24;
  10763. i30 = (HEAP32[i14 >> 2] | 0) + (i19 * 12 | 0) | 0;
  10764. HEAPF32[i30 >> 2] = d28;
  10765. HEAPF32[i30 + 4 >> 2] = d29;
  10766. HEAPF32[(HEAP32[i14 >> 2] | 0) + (i19 * 12 | 0) + 8 >> 2] = d23;
  10767. i19 = i19 + 1 | 0;
  10768. } while ((i19 | 0) < (HEAP32[i1 >> 2] | 0));
  10769. } else {
  10770. i14 = i4 + 24 | 0;
  10771. i15 = i4 + 20 | 0;
  10772. }
  10773. HEAP32[i10 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
  10774. HEAP32[i10 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
  10775. HEAP32[i10 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
  10776. HEAP32[i10 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
  10777. HEAP32[i10 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
  10778. HEAP32[i10 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
  10779. i22 = HEAP32[i15 >> 2] | 0;
  10780. HEAP32[i10 + 24 >> 2] = i22;
  10781. i30 = HEAP32[i14 >> 2] | 0;
  10782. HEAP32[i10 + 28 >> 2] = i30;
  10783. HEAP32[i16 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
  10784. HEAP32[i16 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
  10785. HEAP32[i16 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
  10786. HEAP32[i16 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
  10787. HEAP32[i16 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
  10788. HEAP32[i16 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
  10789. i13 = i4 + 12 | 0;
  10790. HEAP32[i16 + 24 >> 2] = HEAP32[i13 >> 2];
  10791. i12 = i4 + 36 | 0;
  10792. HEAP32[i16 + 28 >> 2] = HEAP32[i12 >> 2];
  10793. HEAP32[i16 + 32 >> 2] = i22;
  10794. HEAP32[i16 + 36 >> 2] = i30;
  10795. HEAP32[i16 + 40 >> 2] = HEAP32[i4 >> 2];
  10796. __ZN15b2ContactSolverC2EP18b2ContactSolverDef(i2, i16);
  10797. __ZN15b2ContactSolver29InitializeVelocityConstraintsEv(i2);
  10798. if ((HEAP8[i11 + 20 | 0] | 0) != 0) {
  10799. __ZN15b2ContactSolver9WarmStartEv(i2);
  10800. }
  10801. i16 = i4 + 32 | 0;
  10802. if ((HEAP32[i16 >> 2] | 0) > 0) {
  10803. i18 = i4 + 16 | 0;
  10804. i17 = 0;
  10805. do {
  10806. i30 = HEAP32[(HEAP32[i18 >> 2] | 0) + (i17 << 2) >> 2] | 0;
  10807. FUNCTION_TABLE_vii[HEAP32[(HEAP32[i30 >> 2] | 0) + 28 >> 2] & 15](i30, i10);
  10808. i17 = i17 + 1 | 0;
  10809. } while ((i17 | 0) < (HEAP32[i16 >> 2] | 0));
  10810. }
  10811. HEAPF32[i8 + 12 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i9);
  10812. i17 = i11 + 12 | 0;
  10813. if ((HEAP32[i17 >> 2] | 0) > 0) {
  10814. i20 = i4 + 16 | 0;
  10815. i19 = 0;
  10816. do {
  10817. if ((HEAP32[i16 >> 2] | 0) > 0) {
  10818. i18 = 0;
  10819. do {
  10820. i30 = HEAP32[(HEAP32[i20 >> 2] | 0) + (i18 << 2) >> 2] | 0;
  10821. FUNCTION_TABLE_vii[HEAP32[(HEAP32[i30 >> 2] | 0) + 32 >> 2] & 15](i30, i10);
  10822. i18 = i18 + 1 | 0;
  10823. } while ((i18 | 0) < (HEAP32[i16 >> 2] | 0));
  10824. }
  10825. __ZN15b2ContactSolver24SolveVelocityConstraintsEv(i2);
  10826. i19 = i19 + 1 | 0;
  10827. } while ((i19 | 0) < (HEAP32[i17 >> 2] | 0));
  10828. }
  10829. __ZN15b2ContactSolver13StoreImpulsesEv(i2);
  10830. HEAPF32[i8 + 16 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i9);
  10831. if ((HEAP32[i1 >> 2] | 0) > 0) {
  10832. i19 = HEAP32[i14 >> 2] | 0;
  10833. i18 = 0;
  10834. do {
  10835. i30 = HEAP32[i15 >> 2] | 0;
  10836. i17 = i30 + (i18 * 12 | 0) | 0;
  10837. i22 = i17;
  10838. d23 = +HEAPF32[i22 >> 2];
  10839. d21 = +HEAPF32[i22 + 4 >> 2];
  10840. d24 = +HEAPF32[i30 + (i18 * 12 | 0) + 8 >> 2];
  10841. i30 = i19 + (i18 * 12 | 0) | 0;
  10842. d26 = +HEAPF32[i30 >> 2];
  10843. d27 = +HEAPF32[i30 + 4 >> 2];
  10844. d25 = +HEAPF32[i19 + (i18 * 12 | 0) + 8 >> 2];
  10845. d29 = d5 * d26;
  10846. d28 = d5 * d27;
  10847. d28 = d29 * d29 + d28 * d28;
  10848. if (d28 > 4.0) {
  10849. d29 = 2.0 / +Math_sqrt(+d28);
  10850. d26 = d26 * d29;
  10851. d27 = d27 * d29;
  10852. }
  10853. d28 = d5 * d25;
  10854. if (d28 * d28 > 2.4674012660980225) {
  10855. if (!(d28 > 0.0)) {
  10856. d28 = -d28;
  10857. }
  10858. d25 = d25 * (1.5707963705062866 / d28);
  10859. }
  10860. d29 = +(d23 + d5 * d26);
  10861. d28 = +(d21 + d5 * d27);
  10862. i19 = i17;
  10863. HEAPF32[i19 >> 2] = d29;
  10864. HEAPF32[i19 + 4 >> 2] = d28;
  10865. HEAPF32[(HEAP32[i15 >> 2] | 0) + (i18 * 12 | 0) + 8 >> 2] = d24 + d5 * d25;
  10866. d28 = +d26;
  10867. d29 = +d27;
  10868. i19 = (HEAP32[i14 >> 2] | 0) + (i18 * 12 | 0) | 0;
  10869. HEAPF32[i19 >> 2] = d28;
  10870. HEAPF32[i19 + 4 >> 2] = d29;
  10871. i19 = HEAP32[i14 >> 2] | 0;
  10872. HEAPF32[i19 + (i18 * 12 | 0) + 8 >> 2] = d25;
  10873. i18 = i18 + 1 | 0;
  10874. } while ((i18 | 0) < (HEAP32[i1 >> 2] | 0));
  10875. }
  10876. i11 = i11 + 16 | 0;
  10877. L41 : do {
  10878. if ((HEAP32[i11 >> 2] | 0) > 0) {
  10879. i17 = i4 + 16 | 0;
  10880. i19 = 0;
  10881. while (1) {
  10882. i18 = __ZN15b2ContactSolver24SolvePositionConstraintsEv(i2) | 0;
  10883. if ((HEAP32[i16 >> 2] | 0) > 0) {
  10884. i20 = 0;
  10885. i22 = 1;
  10886. do {
  10887. i30 = HEAP32[(HEAP32[i17 >> 2] | 0) + (i20 << 2) >> 2] | 0;
  10888. i22 = i22 & (FUNCTION_TABLE_iii[HEAP32[(HEAP32[i30 >> 2] | 0) + 36 >> 2] & 3](i30, i10) | 0);
  10889. i20 = i20 + 1 | 0;
  10890. } while ((i20 | 0) < (HEAP32[i16 >> 2] | 0));
  10891. } else {
  10892. i22 = 1;
  10893. }
  10894. i19 = i19 + 1 | 0;
  10895. if (i18 & i22) {
  10896. i10 = 0;
  10897. break L41;
  10898. }
  10899. if ((i19 | 0) >= (HEAP32[i11 >> 2] | 0)) {
  10900. i10 = 1;
  10901. break;
  10902. }
  10903. }
  10904. } else {
  10905. i10 = 1;
  10906. }
  10907. } while (0);
  10908. if ((HEAP32[i1 >> 2] | 0) > 0) {
  10909. i11 = i4 + 8 | 0;
  10910. i16 = 0;
  10911. do {
  10912. i30 = HEAP32[(HEAP32[i11 >> 2] | 0) + (i16 << 2) >> 2] | 0;
  10913. i22 = (HEAP32[i15 >> 2] | 0) + (i16 * 12 | 0) | 0;
  10914. i20 = HEAP32[i22 >> 2] | 0;
  10915. i22 = HEAP32[i22 + 4 >> 2] | 0;
  10916. i17 = i30 + 44 | 0;
  10917. HEAP32[i17 >> 2] = i20;
  10918. HEAP32[i17 + 4 >> 2] = i22;
  10919. d27 = +HEAPF32[(HEAP32[i15 >> 2] | 0) + (i16 * 12 | 0) + 8 >> 2];
  10920. HEAPF32[i30 + 56 >> 2] = d27;
  10921. i17 = (HEAP32[i14 >> 2] | 0) + (i16 * 12 | 0) | 0;
  10922. i18 = HEAP32[i17 + 4 >> 2] | 0;
  10923. i19 = i30 + 64 | 0;
  10924. HEAP32[i19 >> 2] = HEAP32[i17 >> 2];
  10925. HEAP32[i19 + 4 >> 2] = i18;
  10926. HEAPF32[i30 + 72 >> 2] = +HEAPF32[(HEAP32[i14 >> 2] | 0) + (i16 * 12 | 0) + 8 >> 2];
  10927. d25 = +Math_sin(+d27);
  10928. HEAPF32[i30 + 20 >> 2] = d25;
  10929. d27 = +Math_cos(+d27);
  10930. HEAPF32[i30 + 24 >> 2] = d27;
  10931. d26 = +HEAPF32[i30 + 28 >> 2];
  10932. d29 = +HEAPF32[i30 + 32 >> 2];
  10933. d28 = (HEAP32[tempDoublePtr >> 2] = i20, +HEAPF32[tempDoublePtr >> 2]) - (d27 * d26 - d25 * d29);
  10934. d29 = (HEAP32[tempDoublePtr >> 2] = i22, +HEAPF32[tempDoublePtr >> 2]) - (d25 * d26 + d27 * d29);
  10935. d28 = +d28;
  10936. d29 = +d29;
  10937. i30 = i30 + 12 | 0;
  10938. HEAPF32[i30 >> 2] = d28;
  10939. HEAPF32[i30 + 4 >> 2] = d29;
  10940. i16 = i16 + 1 | 0;
  10941. } while ((i16 | 0) < (HEAP32[i1 >> 2] | 0));
  10942. }
  10943. HEAPF32[i8 + 20 >> 2] = +__ZNK7b2Timer15GetMillisecondsEv(i9);
  10944. i9 = HEAP32[i2 + 40 >> 2] | 0;
  10945. i8 = i4 + 4 | 0;
  10946. if ((HEAP32[i8 >> 2] | 0) != 0 ? (HEAP32[i12 >> 2] | 0) > 0 : 0) {
  10947. i11 = i6 + 16 | 0;
  10948. i14 = 0;
  10949. do {
  10950. i15 = HEAP32[(HEAP32[i13 >> 2] | 0) + (i14 << 2) >> 2] | 0;
  10951. i16 = HEAP32[i9 + (i14 * 152 | 0) + 144 >> 2] | 0;
  10952. HEAP32[i11 >> 2] = i16;
  10953. if ((i16 | 0) > 0) {
  10954. i17 = 0;
  10955. do {
  10956. HEAPF32[i6 + (i17 << 2) >> 2] = +HEAPF32[i9 + (i14 * 152 | 0) + (i17 * 36 | 0) + 16 >> 2];
  10957. HEAPF32[i6 + (i17 << 2) + 8 >> 2] = +HEAPF32[i9 + (i14 * 152 | 0) + (i17 * 36 | 0) + 20 >> 2];
  10958. i17 = i17 + 1 | 0;
  10959. } while ((i17 | 0) != (i16 | 0));
  10960. }
  10961. i30 = HEAP32[i8 >> 2] | 0;
  10962. FUNCTION_TABLE_viii[HEAP32[(HEAP32[i30 >> 2] | 0) + 20 >> 2] & 3](i30, i15, i6);
  10963. i14 = i14 + 1 | 0;
  10964. } while ((i14 | 0) < (HEAP32[i12 >> 2] | 0));
  10965. }
  10966. if (!i7) {
  10967. __ZN15b2ContactSolverD2Ev(i2);
  10968. STACKTOP = i3;
  10969. return;
  10970. }
  10971. i7 = HEAP32[i1 >> 2] | 0;
  10972. i6 = (i7 | 0) > 0;
  10973. if (i6) {
  10974. i8 = HEAP32[i4 + 8 >> 2] | 0;
  10975. i9 = 0;
  10976. d21 = 3.4028234663852886e+38;
  10977. do {
  10978. i11 = HEAP32[i8 + (i9 << 2) >> 2] | 0;
  10979. do {
  10980. if ((HEAP32[i11 >> 2] | 0) != 0) {
  10981. if ((!((HEAP16[i11 + 4 >> 1] & 4) == 0) ? (d29 = +HEAPF32[i11 + 72 >> 2], !(d29 * d29 > .001218469929881394)) : 0) ? (d28 = +HEAPF32[i11 + 64 >> 2], d29 = +HEAPF32[i11 + 68 >> 2], !(d28 * d28 + d29 * d29 > 9999999747378752.0e-20)) : 0) {
  10982. i30 = i11 + 144 | 0;
  10983. d23 = d5 + +HEAPF32[i30 >> 2];
  10984. HEAPF32[i30 >> 2] = d23;
  10985. d21 = d21 < d23 ? d21 : d23;
  10986. break;
  10987. }
  10988. HEAPF32[i11 + 144 >> 2] = 0.0;
  10989. d21 = 0.0;
  10990. }
  10991. } while (0);
  10992. i9 = i9 + 1 | 0;
  10993. } while ((i9 | 0) < (i7 | 0));
  10994. } else {
  10995. d21 = 3.4028234663852886e+38;
  10996. }
  10997. if (!(d21 >= .5) | i10 | i6 ^ 1) {
  10998. __ZN15b2ContactSolverD2Ev(i2);
  10999. STACKTOP = i3;
  11000. return;
  11001. }
  11002. i4 = i4 + 8 | 0;
  11003. i6 = 0;
  11004. do {
  11005. i30 = HEAP32[(HEAP32[i4 >> 2] | 0) + (i6 << 2) >> 2] | 0;
  11006. i22 = i30 + 4 | 0;
  11007. HEAP16[i22 >> 1] = HEAP16[i22 >> 1] & 65533;
  11008. HEAPF32[i30 + 144 >> 2] = 0.0;
  11009. i30 = i30 + 64 | 0;
  11010. HEAP32[i30 + 0 >> 2] = 0;
  11011. HEAP32[i30 + 4 >> 2] = 0;
  11012. HEAP32[i30 + 8 >> 2] = 0;
  11013. HEAP32[i30 + 12 >> 2] = 0;
  11014. HEAP32[i30 + 16 >> 2] = 0;
  11015. HEAP32[i30 + 20 >> 2] = 0;
  11016. i6 = i6 + 1 | 0;
  11017. } while ((i6 | 0) < (HEAP32[i1 >> 2] | 0));
  11018. __ZN15b2ContactSolverD2Ev(i2);
  11019. STACKTOP = i3;
  11020. return;
  11021. }
  11022. function __ZN15b2ContactSolver24SolveVelocityConstraintsEv(i4) {
  11023. i4 = i4 | 0;
  11024. var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, d9 = 0.0, d10 = 0.0, d11 = 0.0, d12 = 0.0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, i19 = 0, d20 = 0.0, d21 = 0.0, i22 = 0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, i32 = 0, i33 = 0, d34 = 0.0, d35 = 0.0, d36 = 0.0, d37 = 0.0, d38 = 0.0, d39 = 0.0, d40 = 0.0, i41 = 0, i42 = 0, d43 = 0.0, d44 = 0.0;
  11025. i1 = STACKTOP;
  11026. i2 = i4 + 48 | 0;
  11027. if ((HEAP32[i2 >> 2] | 0) <= 0) {
  11028. STACKTOP = i1;
  11029. return;
  11030. }
  11031. i3 = i4 + 40 | 0;
  11032. i4 = i4 + 28 | 0;
  11033. i42 = HEAP32[i4 >> 2] | 0;
  11034. i5 = 0;
  11035. L4 : while (1) {
  11036. i19 = HEAP32[i3 >> 2] | 0;
  11037. i22 = i19 + (i5 * 152 | 0) | 0;
  11038. i8 = HEAP32[i19 + (i5 * 152 | 0) + 112 >> 2] | 0;
  11039. i6 = HEAP32[i19 + (i5 * 152 | 0) + 116 >> 2] | 0;
  11040. d12 = +HEAPF32[i19 + (i5 * 152 | 0) + 120 >> 2];
  11041. d10 = +HEAPF32[i19 + (i5 * 152 | 0) + 128 >> 2];
  11042. d11 = +HEAPF32[i19 + (i5 * 152 | 0) + 124 >> 2];
  11043. d9 = +HEAPF32[i19 + (i5 * 152 | 0) + 132 >> 2];
  11044. i32 = i19 + (i5 * 152 | 0) + 144 | 0;
  11045. i33 = HEAP32[i32 >> 2] | 0;
  11046. i7 = i42 + (i8 * 12 | 0) | 0;
  11047. i41 = i7;
  11048. d21 = +HEAPF32[i41 >> 2];
  11049. d20 = +HEAPF32[i41 + 4 >> 2];
  11050. i41 = i42 + (i6 * 12 | 0) | 0;
  11051. d14 = +HEAPF32[i41 >> 2];
  11052. d13 = +HEAPF32[i41 + 4 >> 2];
  11053. i41 = i19 + (i5 * 152 | 0) + 72 | 0;
  11054. d17 = +HEAPF32[i41 >> 2];
  11055. d16 = +HEAPF32[i41 + 4 >> 2];
  11056. d23 = -d17;
  11057. d24 = +HEAPF32[i19 + (i5 * 152 | 0) + 136 >> 2];
  11058. if ((i33 + -1 | 0) >>> 0 < 2) {
  11059. i41 = 0;
  11060. d18 = +HEAPF32[i42 + (i8 * 12 | 0) + 8 >> 2];
  11061. d15 = +HEAPF32[i42 + (i6 * 12 | 0) + 8 >> 2];
  11062. } else {
  11063. i2 = 4;
  11064. break;
  11065. }
  11066. do {
  11067. d30 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 12 >> 2];
  11068. d25 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 8 >> 2];
  11069. d26 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 4 >> 2];
  11070. d27 = +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) >> 2];
  11071. d34 = d24 * +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 16 >> 2];
  11072. i42 = i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 20 | 0;
  11073. d28 = +HEAPF32[i42 >> 2];
  11074. d31 = d28 - +HEAPF32[i19 + (i5 * 152 | 0) + (i41 * 36 | 0) + 28 >> 2] * (d16 * (d14 - d15 * d30 - d21 + d18 * d26) + (d13 + d15 * d25 - d20 - d18 * d27) * d23);
  11075. d29 = -d34;
  11076. d31 = d31 < d34 ? d31 : d34;
  11077. d40 = d31 < d29 ? d29 : d31;
  11078. d39 = d40 - d28;
  11079. HEAPF32[i42 >> 2] = d40;
  11080. d40 = d16 * d39;
  11081. d39 = d39 * d23;
  11082. d21 = d21 - d12 * d40;
  11083. d20 = d20 - d12 * d39;
  11084. d18 = d18 - d10 * (d27 * d39 - d26 * d40);
  11085. d14 = d14 + d11 * d40;
  11086. d13 = d13 + d11 * d39;
  11087. d15 = d15 + d9 * (d25 * d39 - d30 * d40);
  11088. i41 = i41 + 1 | 0;
  11089. } while ((i41 | 0) != (i33 | 0));
  11090. do {
  11091. if ((HEAP32[i32 >> 2] | 0) != 1) {
  11092. i32 = i19 + (i5 * 152 | 0) + 16 | 0;
  11093. d31 = +HEAPF32[i32 >> 2];
  11094. i33 = i19 + (i5 * 152 | 0) + 52 | 0;
  11095. d34 = +HEAPF32[i33 >> 2];
  11096. if (!(d31 >= 0.0) | !(d34 >= 0.0)) {
  11097. i2 = 9;
  11098. break L4;
  11099. }
  11100. d23 = +HEAPF32[i19 + (i5 * 152 | 0) + 12 >> 2];
  11101. d24 = +HEAPF32[i19 + (i5 * 152 | 0) + 8 >> 2];
  11102. d26 = +HEAPF32[i19 + (i5 * 152 | 0) + 4 >> 2];
  11103. d30 = +HEAPF32[i22 >> 2];
  11104. d27 = +HEAPF32[i19 + (i5 * 152 | 0) + 48 >> 2];
  11105. d25 = +HEAPF32[i19 + (i5 * 152 | 0) + 44 >> 2];
  11106. d28 = +HEAPF32[i19 + (i5 * 152 | 0) + 40 >> 2];
  11107. d29 = +HEAPF32[i19 + (i5 * 152 | 0) + 36 >> 2];
  11108. d37 = +HEAPF32[i19 + (i5 * 152 | 0) + 104 >> 2];
  11109. d38 = +HEAPF32[i19 + (i5 * 152 | 0) + 100 >> 2];
  11110. d35 = d17 * (d14 - d15 * d23 - d21 + d18 * d26) + d16 * (d13 + d15 * d24 - d20 - d18 * d30) - +HEAPF32[i19 + (i5 * 152 | 0) + 32 >> 2] - (d31 * +HEAPF32[i19 + (i5 * 152 | 0) + 96 >> 2] + d34 * d37);
  11111. d36 = d17 * (d14 - d15 * d27 - d21 + d18 * d28) + d16 * (d13 + d15 * d25 - d20 - d18 * d29) - +HEAPF32[i19 + (i5 * 152 | 0) + 68 >> 2] - (d31 * d38 + d34 * +HEAPF32[i19 + (i5 * 152 | 0) + 108 >> 2]);
  11112. d44 = +HEAPF32[i19 + (i5 * 152 | 0) + 80 >> 2] * d35 + +HEAPF32[i19 + (i5 * 152 | 0) + 88 >> 2] * d36;
  11113. d43 = d35 * +HEAPF32[i19 + (i5 * 152 | 0) + 84 >> 2] + d36 * +HEAPF32[i19 + (i5 * 152 | 0) + 92 >> 2];
  11114. d40 = -d44;
  11115. d39 = -d43;
  11116. if (!(!(d44 <= -0.0) | !(d43 <= -0.0))) {
  11117. d37 = d40 - d31;
  11118. d43 = d39 - d34;
  11119. d38 = d17 * d37;
  11120. d37 = d16 * d37;
  11121. d44 = d17 * d43;
  11122. d43 = d16 * d43;
  11123. d35 = d38 + d44;
  11124. d36 = d37 + d43;
  11125. HEAPF32[i32 >> 2] = d40;
  11126. HEAPF32[i33 >> 2] = d39;
  11127. d21 = d21 - d12 * d35;
  11128. d20 = d20 - d12 * d36;
  11129. d14 = d14 + d11 * d35;
  11130. d13 = d13 + d11 * d36;
  11131. d18 = d18 - d10 * (d30 * d37 - d26 * d38 + (d29 * d43 - d28 * d44));
  11132. d15 = d15 + d9 * (d24 * d37 - d23 * d38 + (d25 * d43 - d27 * d44));
  11133. break;
  11134. }
  11135. d44 = d35 * +HEAPF32[i19 + (i5 * 152 | 0) + 24 >> 2];
  11136. d39 = -d44;
  11137. if (d44 <= -0.0 ? d36 + d38 * d39 >= 0.0 : 0) {
  11138. d38 = d39 - d31;
  11139. d43 = 0.0 - d34;
  11140. d40 = d17 * d38;
  11141. d38 = d16 * d38;
  11142. d44 = d17 * d43;
  11143. d43 = d16 * d43;
  11144. d36 = d44 + d40;
  11145. d37 = d43 + d38;
  11146. HEAPF32[i32 >> 2] = d39;
  11147. HEAPF32[i33 >> 2] = 0.0;
  11148. d21 = d21 - d12 * d36;
  11149. d20 = d20 - d12 * d37;
  11150. d14 = d14 + d11 * d36;
  11151. d13 = d13 + d11 * d37;
  11152. d18 = d18 - d10 * (d38 * d30 - d40 * d26 + (d43 * d29 - d44 * d28));
  11153. d15 = d15 + d9 * (d38 * d24 - d40 * d23 + (d43 * d25 - d44 * d27));
  11154. break;
  11155. }
  11156. d44 = d36 * +HEAPF32[i19 + (i5 * 152 | 0) + 60 >> 2];
  11157. d38 = -d44;
  11158. if (d44 <= -0.0 ? d35 + d37 * d38 >= 0.0 : 0) {
  11159. d39 = 0.0 - d31;
  11160. d43 = d38 - d34;
  11161. d40 = d17 * d39;
  11162. d39 = d16 * d39;
  11163. d44 = d17 * d43;
  11164. d43 = d16 * d43;
  11165. d36 = d40 + d44;
  11166. d37 = d39 + d43;
  11167. HEAPF32[i32 >> 2] = 0.0;
  11168. HEAPF32[i33 >> 2] = d38;
  11169. d21 = d21 - d12 * d36;
  11170. d20 = d20 - d12 * d37;
  11171. d14 = d14 + d11 * d36;
  11172. d13 = d13 + d11 * d37;
  11173. d18 = d18 - d10 * (d39 * d30 - d40 * d26 + (d43 * d29 - d44 * d28));
  11174. d15 = d15 + d9 * (d39 * d24 - d40 * d23 + (d43 * d25 - d44 * d27));
  11175. break;
  11176. }
  11177. if (!(!(d35 >= 0.0) | !(d36 >= 0.0))) {
  11178. d39 = 0.0 - d31;
  11179. d43 = 0.0 - d34;
  11180. d40 = d17 * d39;
  11181. d39 = d16 * d39;
  11182. d44 = d17 * d43;
  11183. d43 = d16 * d43;
  11184. d37 = d40 + d44;
  11185. d38 = d39 + d43;
  11186. HEAPF32[i32 >> 2] = 0.0;
  11187. HEAPF32[i33 >> 2] = 0.0;
  11188. d21 = d21 - d12 * d37;
  11189. d20 = d20 - d12 * d38;
  11190. d14 = d14 + d11 * d37;
  11191. d13 = d13 + d11 * d38;
  11192. d18 = d18 - d10 * (d39 * d30 - d40 * d26 + (d43 * d29 - d44 * d28));
  11193. d15 = d15 + d9 * (d39 * d24 - d40 * d23 + (d43 * d25 - d44 * d27));
  11194. }
  11195. } else {
  11196. d23 = +HEAPF32[i19 + (i5 * 152 | 0) + 12 >> 2];
  11197. d24 = +HEAPF32[i19 + (i5 * 152 | 0) + 8 >> 2];
  11198. d25 = +HEAPF32[i19 + (i5 * 152 | 0) + 4 >> 2];
  11199. d26 = +HEAPF32[i22 >> 2];
  11200. i22 = i19 + (i5 * 152 | 0) + 16 | 0;
  11201. d27 = +HEAPF32[i22 >> 2];
  11202. d28 = d27 - +HEAPF32[i19 + (i5 * 152 | 0) + 24 >> 2] * (d17 * (d14 - d15 * d23 - d21 + d18 * d25) + d16 * (d13 + d15 * d24 - d20 - d18 * d26) - +HEAPF32[i19 + (i5 * 152 | 0) + 32 >> 2]);
  11203. d44 = d28 > 0.0 ? d28 : 0.0;
  11204. d43 = d44 - d27;
  11205. HEAPF32[i22 >> 2] = d44;
  11206. d44 = d17 * d43;
  11207. d43 = d16 * d43;
  11208. d21 = d21 - d12 * d44;
  11209. d20 = d20 - d12 * d43;
  11210. d14 = d14 + d11 * d44;
  11211. d13 = d13 + d11 * d43;
  11212. d18 = d18 - d10 * (d26 * d43 - d25 * d44);
  11213. d15 = d15 + d9 * (d24 * d43 - d23 * d44);
  11214. }
  11215. } while (0);
  11216. d44 = +d21;
  11217. d43 = +d20;
  11218. i42 = i7;
  11219. HEAPF32[i42 >> 2] = d44;
  11220. HEAPF32[i42 + 4 >> 2] = d43;
  11221. i42 = HEAP32[i4 >> 2] | 0;
  11222. HEAPF32[i42 + (i8 * 12 | 0) + 8 >> 2] = d18;
  11223. d43 = +d14;
  11224. d44 = +d13;
  11225. i42 = i42 + (i6 * 12 | 0) | 0;
  11226. HEAPF32[i42 >> 2] = d43;
  11227. HEAPF32[i42 + 4 >> 2] = d44;
  11228. i42 = HEAP32[i4 >> 2] | 0;
  11229. HEAPF32[i42 + (i6 * 12 | 0) + 8 >> 2] = d15;
  11230. i5 = i5 + 1 | 0;
  11231. if ((i5 | 0) >= (HEAP32[i2 >> 2] | 0)) {
  11232. i2 = 21;
  11233. break;
  11234. }
  11235. }
  11236. if ((i2 | 0) == 4) {
  11237. ___assert_fail(6648, 6520, 311, 6688);
  11238. } else if ((i2 | 0) == 9) {
  11239. ___assert_fail(6720, 6520, 406, 6688);
  11240. } else if ((i2 | 0) == 21) {
  11241. STACKTOP = i1;
  11242. return;
  11243. }
  11244. }
  11245. function __Z14b2TimeOfImpactP11b2TOIOutputPK10b2TOIInput(i3, i11) {
  11246. i3 = i3 | 0;
  11247. i11 = i11 | 0;
  11248. var i1 = 0, i2 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i12 = 0, i13 = 0, d14 = 0.0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, d28 = 0.0, i29 = 0, d30 = 0.0, d31 = 0.0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, i38 = 0, i39 = 0, d40 = 0.0, i41 = 0, d42 = 0.0, d43 = 0.0, i44 = 0, i45 = 0, d46 = 0.0, i47 = 0, d48 = 0.0, d49 = 0.0, d50 = 0.0, d51 = 0.0, i52 = 0, d53 = 0.0, d54 = 0.0, d55 = 0.0, d56 = 0.0;
  11249. i1 = STACKTOP;
  11250. STACKTOP = STACKTOP + 320 | 0;
  11251. i12 = i1 + 276 | 0;
  11252. i10 = i1 + 240 | 0;
  11253. i13 = i1 + 228 | 0;
  11254. i5 = i1 + 136 | 0;
  11255. i7 = i1 + 112 | 0;
  11256. i8 = i1 + 8 | 0;
  11257. i9 = i1 + 4 | 0;
  11258. i4 = i1;
  11259. HEAP32[874] = (HEAP32[874] | 0) + 1;
  11260. HEAP32[i3 >> 2] = 0;
  11261. i19 = i11 + 128 | 0;
  11262. i2 = i3 + 4 | 0;
  11263. HEAPF32[i2 >> 2] = +HEAPF32[i19 >> 2];
  11264. i6 = i11 + 28 | 0;
  11265. i16 = i12 + 0 | 0;
  11266. i15 = i11 + 56 | 0;
  11267. i17 = i16 + 36 | 0;
  11268. do {
  11269. HEAP32[i16 >> 2] = HEAP32[i15 >> 2];
  11270. i16 = i16 + 4 | 0;
  11271. i15 = i15 + 4 | 0;
  11272. } while ((i16 | 0) < (i17 | 0));
  11273. i16 = i10 + 0 | 0;
  11274. i15 = i11 + 92 | 0;
  11275. i17 = i16 + 36 | 0;
  11276. do {
  11277. HEAP32[i16 >> 2] = HEAP32[i15 >> 2];
  11278. i16 = i16 + 4 | 0;
  11279. i15 = i15 + 4 | 0;
  11280. } while ((i16 | 0) < (i17 | 0));
  11281. i15 = i12 + 24 | 0;
  11282. d42 = +HEAPF32[i15 >> 2];
  11283. d43 = +Math_floor(+(d42 / 6.2831854820251465)) * 6.2831854820251465;
  11284. d42 = d42 - d43;
  11285. HEAPF32[i15 >> 2] = d42;
  11286. i16 = i12 + 28 | 0;
  11287. d43 = +HEAPF32[i16 >> 2] - d43;
  11288. HEAPF32[i16 >> 2] = d43;
  11289. i17 = i10 + 24 | 0;
  11290. d46 = +HEAPF32[i17 >> 2];
  11291. d40 = +Math_floor(+(d46 / 6.2831854820251465)) * 6.2831854820251465;
  11292. d46 = d46 - d40;
  11293. HEAPF32[i17 >> 2] = d46;
  11294. i18 = i10 + 28 | 0;
  11295. d40 = +HEAPF32[i18 >> 2] - d40;
  11296. HEAPF32[i18 >> 2] = d40;
  11297. d14 = +HEAPF32[i19 >> 2];
  11298. d28 = +HEAPF32[i11 + 24 >> 2] + +HEAPF32[i11 + 52 >> 2] + -.014999999664723873;
  11299. d28 = d28 < .004999999888241291 ? .004999999888241291 : d28;
  11300. if (!(d28 > .0012499999720603228)) {
  11301. ___assert_fail(3536, 3560, 280, 3600);
  11302. }
  11303. HEAP16[i13 + 4 >> 1] = 0;
  11304. HEAP32[i5 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
  11305. HEAP32[i5 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
  11306. HEAP32[i5 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
  11307. HEAP32[i5 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
  11308. HEAP32[i5 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
  11309. HEAP32[i5 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
  11310. HEAP32[i5 + 24 >> 2] = HEAP32[i11 + 24 >> 2];
  11311. i38 = i5 + 28 | 0;
  11312. HEAP32[i38 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  11313. HEAP32[i38 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  11314. HEAP32[i38 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  11315. HEAP32[i38 + 12 >> 2] = HEAP32[i6 + 12 >> 2];
  11316. HEAP32[i38 + 16 >> 2] = HEAP32[i6 + 16 >> 2];
  11317. HEAP32[i38 + 20 >> 2] = HEAP32[i6 + 20 >> 2];
  11318. HEAP32[i38 + 24 >> 2] = HEAP32[i6 + 24 >> 2];
  11319. HEAP8[i5 + 88 | 0] = 0;
  11320. i38 = i12 + 8 | 0;
  11321. i27 = i12 + 12 | 0;
  11322. i29 = i12 + 16 | 0;
  11323. i22 = i12 + 20 | 0;
  11324. i32 = i12 + 4 | 0;
  11325. i34 = i10 + 8 | 0;
  11326. i36 = i10 + 12 | 0;
  11327. i35 = i10 + 16 | 0;
  11328. i37 = i10 + 20 | 0;
  11329. i33 = i10 + 4 | 0;
  11330. i26 = i5 + 56 | 0;
  11331. i25 = i5 + 64 | 0;
  11332. i24 = i5 + 68 | 0;
  11333. i23 = i5 + 72 | 0;
  11334. i20 = i5 + 80 | 0;
  11335. i19 = i5 + 84 | 0;
  11336. i21 = i7 + 16 | 0;
  11337. d30 = d28 + .0012499999720603228;
  11338. d31 = d28 + -.0012499999720603228;
  11339. d48 = d40;
  11340. i39 = 0;
  11341. d40 = 0.0;
  11342. L4 : while (1) {
  11343. d56 = 1.0 - d40;
  11344. d49 = d56 * d42 + d40 * d43;
  11345. d43 = +Math_sin(+d49);
  11346. d49 = +Math_cos(+d49);
  11347. d55 = +HEAPF32[i12 >> 2];
  11348. d54 = +HEAPF32[i32 >> 2];
  11349. d42 = d56 * d46 + d40 * d48;
  11350. d53 = +Math_sin(+d42);
  11351. d42 = +Math_cos(+d42);
  11352. d46 = +HEAPF32[i10 >> 2];
  11353. d51 = +HEAPF32[i33 >> 2];
  11354. d50 = d56 * +HEAPF32[i34 >> 2] + d40 * +HEAPF32[i35 >> 2] - (d42 * d46 - d53 * d51);
  11355. d51 = d56 * +HEAPF32[i36 >> 2] + d40 * +HEAPF32[i37 >> 2] - (d53 * d46 + d42 * d51);
  11356. d46 = +(d56 * +HEAPF32[i38 >> 2] + d40 * +HEAPF32[i29 >> 2] - (d49 * d55 - d43 * d54));
  11357. d48 = +(d56 * +HEAPF32[i27 >> 2] + d40 * +HEAPF32[i22 >> 2] - (d43 * d55 + d49 * d54));
  11358. i52 = i26;
  11359. HEAPF32[i52 >> 2] = d46;
  11360. HEAPF32[i52 + 4 >> 2] = d48;
  11361. HEAPF32[i25 >> 2] = d43;
  11362. HEAPF32[i24 >> 2] = d49;
  11363. d50 = +d50;
  11364. d51 = +d51;
  11365. i52 = i23;
  11366. HEAPF32[i52 >> 2] = d50;
  11367. HEAPF32[i52 + 4 >> 2] = d51;
  11368. HEAPF32[i20 >> 2] = d53;
  11369. HEAPF32[i19 >> 2] = d42;
  11370. __Z10b2DistanceP16b2DistanceOutputP14b2SimplexCachePK15b2DistanceInput(i7, i13, i5);
  11371. d42 = +HEAPF32[i21 >> 2];
  11372. if (d42 <= 0.0) {
  11373. i4 = 5;
  11374. break;
  11375. }
  11376. if (d42 < d30) {
  11377. i4 = 7;
  11378. break;
  11379. }
  11380. +__ZN20b2SeparationFunction10InitializeEPK14b2SimplexCachePK15b2DistanceProxyRK7b2SweepS5_S8_f(i8, i13, i11, i12, i6, i10, d40);
  11381. i41 = 0;
  11382. d42 = d14;
  11383. do {
  11384. d50 = +__ZNK20b2SeparationFunction17FindMinSeparationEPiS0_f(i8, i9, i4, d42);
  11385. if (d50 > d30) {
  11386. i4 = 10;
  11387. break L4;
  11388. }
  11389. if (d50 > d31) {
  11390. d40 = d42;
  11391. break;
  11392. }
  11393. i45 = HEAP32[i9 >> 2] | 0;
  11394. i44 = HEAP32[i4 >> 2] | 0;
  11395. d48 = +__ZNK20b2SeparationFunction8EvaluateEiif(i8, i45, i44, d40);
  11396. if (d48 < d31) {
  11397. i4 = 13;
  11398. break L4;
  11399. }
  11400. if (!(d48 <= d30)) {
  11401. d43 = d40;
  11402. d46 = d42;
  11403. i47 = 0;
  11404. } else {
  11405. i4 = 15;
  11406. break L4;
  11407. }
  11408. while (1) {
  11409. if ((i47 & 1 | 0) == 0) {
  11410. d49 = (d43 + d46) * .5;
  11411. } else {
  11412. d49 = d43 + (d28 - d48) * (d46 - d43) / (d50 - d48);
  11413. }
  11414. d51 = +__ZNK20b2SeparationFunction8EvaluateEiif(i8, i45, i44, d49);
  11415. d53 = d51 - d28;
  11416. if (!(d53 > 0.0)) {
  11417. d53 = -d53;
  11418. }
  11419. if (d53 < .0012499999720603228) {
  11420. d42 = d49;
  11421. break;
  11422. }
  11423. i52 = d51 > d28;
  11424. i47 = i47 + 1 | 0;
  11425. HEAP32[880] = (HEAP32[880] | 0) + 1;
  11426. if ((i47 | 0) == 50) {
  11427. i47 = 50;
  11428. break;
  11429. } else {
  11430. d43 = i52 ? d49 : d43;
  11431. d46 = i52 ? d46 : d49;
  11432. d48 = i52 ? d51 : d48;
  11433. d50 = i52 ? d50 : d51;
  11434. }
  11435. }
  11436. i44 = HEAP32[882] | 0;
  11437. HEAP32[882] = (i44 | 0) > (i47 | 0) ? i44 : i47;
  11438. i41 = i41 + 1 | 0;
  11439. } while ((i41 | 0) != 8);
  11440. i39 = i39 + 1 | 0;
  11441. HEAP32[876] = (HEAP32[876] | 0) + 1;
  11442. if ((i39 | 0) == 20) {
  11443. i4 = 27;
  11444. break;
  11445. }
  11446. d42 = +HEAPF32[i15 >> 2];
  11447. d43 = +HEAPF32[i16 >> 2];
  11448. d46 = +HEAPF32[i17 >> 2];
  11449. d48 = +HEAPF32[i18 >> 2];
  11450. }
  11451. if ((i4 | 0) == 5) {
  11452. HEAP32[i3 >> 2] = 2;
  11453. HEAPF32[i2 >> 2] = 0.0;
  11454. i2 = HEAP32[878] | 0;
  11455. i52 = (i2 | 0) > (i39 | 0);
  11456. i52 = i52 ? i2 : i39;
  11457. HEAP32[878] = i52;
  11458. STACKTOP = i1;
  11459. return;
  11460. } else if ((i4 | 0) == 7) {
  11461. HEAP32[i3 >> 2] = 3;
  11462. HEAPF32[i2 >> 2] = d40;
  11463. i2 = HEAP32[878] | 0;
  11464. i52 = (i2 | 0) > (i39 | 0);
  11465. i52 = i52 ? i2 : i39;
  11466. HEAP32[878] = i52;
  11467. STACKTOP = i1;
  11468. return;
  11469. } else if ((i4 | 0) == 10) {
  11470. HEAP32[i3 >> 2] = 4;
  11471. HEAPF32[i2 >> 2] = d14;
  11472. } else if ((i4 | 0) == 13) {
  11473. HEAP32[i3 >> 2] = 1;
  11474. HEAPF32[i2 >> 2] = d40;
  11475. } else if ((i4 | 0) == 15) {
  11476. HEAP32[i3 >> 2] = 3;
  11477. HEAPF32[i2 >> 2] = d40;
  11478. } else if ((i4 | 0) == 27) {
  11479. HEAP32[i3 >> 2] = 1;
  11480. HEAPF32[i2 >> 2] = d40;
  11481. i39 = 20;
  11482. i2 = HEAP32[878] | 0;
  11483. i52 = (i2 | 0) > (i39 | 0);
  11484. i52 = i52 ? i2 : i39;
  11485. HEAP32[878] = i52;
  11486. STACKTOP = i1;
  11487. return;
  11488. }
  11489. HEAP32[876] = (HEAP32[876] | 0) + 1;
  11490. i39 = i39 + 1 | 0;
  11491. i2 = HEAP32[878] | 0;
  11492. i52 = (i2 | 0) > (i39 | 0);
  11493. i52 = i52 ? i2 : i39;
  11494. HEAP32[878] = i52;
  11495. STACKTOP = i1;
  11496. return;
  11497. }
  11498. function __ZN7b2World5SolveERK10b2TimeStep(i5, i15) {
  11499. i5 = i5 | 0;
  11500. i15 = i15 | 0;
  11501. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, i26 = 0, i27 = 0, i28 = 0, i29 = 0, i30 = 0, i31 = 0, i32 = 0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, i38 = 0, d39 = 0.0;
  11502. i3 = STACKTOP;
  11503. STACKTOP = STACKTOP + 96 | 0;
  11504. i4 = i3 + 32 | 0;
  11505. i9 = i3;
  11506. i2 = i3 + 84 | 0;
  11507. i11 = i5 + 103008 | 0;
  11508. HEAPF32[i11 >> 2] = 0.0;
  11509. i14 = i5 + 103012 | 0;
  11510. HEAPF32[i14 >> 2] = 0.0;
  11511. i8 = i5 + 103016 | 0;
  11512. HEAPF32[i8 >> 2] = 0.0;
  11513. i16 = i5 + 102960 | 0;
  11514. i1 = i5 + 102872 | 0;
  11515. i6 = i5 + 68 | 0;
  11516. __ZN8b2IslandC2EiiiP16b2StackAllocatorP17b2ContactListener(i4, HEAP32[i16 >> 2] | 0, HEAP32[i5 + 102936 >> 2] | 0, HEAP32[i5 + 102964 >> 2] | 0, i6, HEAP32[i5 + 102944 >> 2] | 0);
  11517. i7 = i5 + 102952 | 0;
  11518. i17 = HEAP32[i7 >> 2] | 0;
  11519. if ((i17 | 0) != 0) {
  11520. do {
  11521. i38 = i17 + 4 | 0;
  11522. HEAP16[i38 >> 1] = HEAP16[i38 >> 1] & 65534;
  11523. i17 = HEAP32[i17 + 96 >> 2] | 0;
  11524. } while ((i17 | 0) != 0);
  11525. }
  11526. i17 = HEAP32[i5 + 102932 >> 2] | 0;
  11527. if ((i17 | 0) != 0) {
  11528. do {
  11529. i38 = i17 + 4 | 0;
  11530. HEAP32[i38 >> 2] = HEAP32[i38 >> 2] & -2;
  11531. i17 = HEAP32[i17 + 12 >> 2] | 0;
  11532. } while ((i17 | 0) != 0);
  11533. }
  11534. i17 = HEAP32[i5 + 102956 >> 2] | 0;
  11535. if ((i17 | 0) != 0) {
  11536. do {
  11537. HEAP8[i17 + 60 | 0] = 0;
  11538. i17 = HEAP32[i17 + 12 >> 2] | 0;
  11539. } while ((i17 | 0) != 0);
  11540. }
  11541. i24 = HEAP32[i16 >> 2] | 0;
  11542. i16 = __ZN16b2StackAllocator8AllocateEi(i6, i24 << 2) | 0;
  11543. i32 = HEAP32[i7 >> 2] | 0;
  11544. L13 : do {
  11545. if ((i32 | 0) != 0) {
  11546. i18 = i4 + 28 | 0;
  11547. i30 = i4 + 36 | 0;
  11548. i27 = i4 + 32 | 0;
  11549. i17 = i4 + 40 | 0;
  11550. i23 = i4 + 8 | 0;
  11551. i29 = i4 + 48 | 0;
  11552. i28 = i4 + 16 | 0;
  11553. i26 = i4 + 44 | 0;
  11554. i31 = i4 + 12 | 0;
  11555. i25 = i5 + 102968 | 0;
  11556. i22 = i5 + 102976 | 0;
  11557. i21 = i9 + 12 | 0;
  11558. i20 = i9 + 16 | 0;
  11559. i19 = i9 + 20 | 0;
  11560. L15 : while (1) {
  11561. i33 = i32 + 4 | 0;
  11562. i34 = HEAP16[i33 >> 1] | 0;
  11563. if ((i34 & 35) == 34 ? (HEAP32[i32 >> 2] | 0) != 0 : 0) {
  11564. HEAP32[i18 >> 2] = 0;
  11565. HEAP32[i30 >> 2] = 0;
  11566. HEAP32[i27 >> 2] = 0;
  11567. HEAP32[i16 >> 2] = i32;
  11568. HEAP16[i33 >> 1] = i34 & 65535 | 1;
  11569. i35 = 1;
  11570. do {
  11571. i35 = i35 + -1 | 0;
  11572. i33 = HEAP32[i16 + (i35 << 2) >> 2] | 0;
  11573. i34 = i33 + 4 | 0;
  11574. i36 = HEAP16[i34 >> 1] | 0;
  11575. if ((i36 & 32) == 0) {
  11576. i8 = 13;
  11577. break L15;
  11578. }
  11579. i37 = HEAP32[i18 >> 2] | 0;
  11580. if ((i37 | 0) >= (HEAP32[i17 >> 2] | 0)) {
  11581. i8 = 15;
  11582. break L15;
  11583. }
  11584. HEAP32[i33 + 8 >> 2] = i37;
  11585. i38 = HEAP32[i18 >> 2] | 0;
  11586. HEAP32[(HEAP32[i23 >> 2] | 0) + (i38 << 2) >> 2] = i33;
  11587. HEAP32[i18 >> 2] = i38 + 1;
  11588. i36 = i36 & 65535;
  11589. if ((i36 & 2 | 0) == 0) {
  11590. HEAP16[i34 >> 1] = i36 | 2;
  11591. HEAPF32[i33 + 144 >> 2] = 0.0;
  11592. }
  11593. if ((HEAP32[i33 >> 2] | 0) != 0) {
  11594. i34 = HEAP32[i33 + 112 >> 2] | 0;
  11595. if ((i34 | 0) != 0) {
  11596. do {
  11597. i38 = HEAP32[i34 + 4 >> 2] | 0;
  11598. i36 = i38 + 4 | 0;
  11599. if (((HEAP32[i36 >> 2] & 7 | 0) == 6 ? (HEAP8[(HEAP32[i38 + 48 >> 2] | 0) + 38 | 0] | 0) == 0 : 0) ? (HEAP8[(HEAP32[i38 + 52 >> 2] | 0) + 38 | 0] | 0) == 0 : 0) {
  11600. i37 = HEAP32[i30 >> 2] | 0;
  11601. if ((i37 | 0) >= (HEAP32[i26 >> 2] | 0)) {
  11602. i8 = 25;
  11603. break L15;
  11604. }
  11605. HEAP32[i30 >> 2] = i37 + 1;
  11606. HEAP32[(HEAP32[i31 >> 2] | 0) + (i37 << 2) >> 2] = i38;
  11607. HEAP32[i36 >> 2] = HEAP32[i36 >> 2] | 1;
  11608. i38 = HEAP32[i34 >> 2] | 0;
  11609. i36 = i38 + 4 | 0;
  11610. i37 = HEAP16[i36 >> 1] | 0;
  11611. if ((i37 & 1) == 0) {
  11612. if ((i35 | 0) >= (i24 | 0)) {
  11613. i8 = 28;
  11614. break L15;
  11615. }
  11616. HEAP32[i16 + (i35 << 2) >> 2] = i38;
  11617. HEAP16[i36 >> 1] = i37 & 65535 | 1;
  11618. i35 = i35 + 1 | 0;
  11619. }
  11620. }
  11621. i34 = HEAP32[i34 + 12 >> 2] | 0;
  11622. } while ((i34 | 0) != 0);
  11623. }
  11624. i33 = HEAP32[i33 + 108 >> 2] | 0;
  11625. if ((i33 | 0) != 0) {
  11626. do {
  11627. i37 = i33 + 4 | 0;
  11628. i36 = HEAP32[i37 >> 2] | 0;
  11629. if ((HEAP8[i36 + 60 | 0] | 0) == 0 ? (i10 = HEAP32[i33 >> 2] | 0, i13 = i10 + 4 | 0, i12 = HEAP16[i13 >> 1] | 0, !((i12 & 32) == 0)) : 0) {
  11630. i34 = HEAP32[i27 >> 2] | 0;
  11631. if ((i34 | 0) >= (HEAP32[i29 >> 2] | 0)) {
  11632. i8 = 35;
  11633. break L15;
  11634. }
  11635. HEAP32[i27 >> 2] = i34 + 1;
  11636. HEAP32[(HEAP32[i28 >> 2] | 0) + (i34 << 2) >> 2] = i36;
  11637. HEAP8[(HEAP32[i37 >> 2] | 0) + 60 | 0] = 1;
  11638. if ((i12 & 1) == 0) {
  11639. if ((i35 | 0) >= (i24 | 0)) {
  11640. i8 = 38;
  11641. break L15;
  11642. }
  11643. HEAP32[i16 + (i35 << 2) >> 2] = i10;
  11644. HEAP16[i13 >> 1] = i12 & 65535 | 1;
  11645. i35 = i35 + 1 | 0;
  11646. }
  11647. }
  11648. i33 = HEAP32[i33 + 12 >> 2] | 0;
  11649. } while ((i33 | 0) != 0);
  11650. }
  11651. }
  11652. } while ((i35 | 0) > 0);
  11653. __ZN8b2Island5SolveEP9b2ProfileRK10b2TimeStepRK6b2Vec2b(i4, i9, i15, i25, (HEAP8[i22] | 0) != 0);
  11654. HEAPF32[i11 >> 2] = +HEAPF32[i21 >> 2] + +HEAPF32[i11 >> 2];
  11655. HEAPF32[i14 >> 2] = +HEAPF32[i20 >> 2] + +HEAPF32[i14 >> 2];
  11656. HEAPF32[i8 >> 2] = +HEAPF32[i19 >> 2] + +HEAPF32[i8 >> 2];
  11657. i35 = HEAP32[i18 >> 2] | 0;
  11658. if ((i35 | 0) > 0) {
  11659. i33 = HEAP32[i23 >> 2] | 0;
  11660. i36 = 0;
  11661. do {
  11662. i34 = HEAP32[i33 + (i36 << 2) >> 2] | 0;
  11663. if ((HEAP32[i34 >> 2] | 0) == 0) {
  11664. i38 = i34 + 4 | 0;
  11665. HEAP16[i38 >> 1] = HEAP16[i38 >> 1] & 65534;
  11666. }
  11667. i36 = i36 + 1 | 0;
  11668. } while ((i36 | 0) < (i35 | 0));
  11669. }
  11670. }
  11671. i32 = HEAP32[i32 + 96 >> 2] | 0;
  11672. if ((i32 | 0) == 0) {
  11673. break L13;
  11674. }
  11675. }
  11676. if ((i8 | 0) == 13) {
  11677. ___assert_fail(2232, 2184, 445, 2256);
  11678. } else if ((i8 | 0) == 15) {
  11679. ___assert_fail(2520, 2440, 54, 2472);
  11680. } else if ((i8 | 0) == 25) {
  11681. ___assert_fail(2480, 2440, 62, 2472);
  11682. } else if ((i8 | 0) == 28) {
  11683. ___assert_fail(2264, 2184, 495, 2256);
  11684. } else if ((i8 | 0) == 35) {
  11685. ___assert_fail(2408, 2440, 68, 2472);
  11686. } else if ((i8 | 0) == 38) {
  11687. ___assert_fail(2264, 2184, 524, 2256);
  11688. }
  11689. }
  11690. } while (0);
  11691. __ZN16b2StackAllocator4FreeEPv(i6, i16);
  11692. __ZN7b2TimerC2Ev(i2);
  11693. i6 = HEAP32[i7 >> 2] | 0;
  11694. if ((i6 | 0) == 0) {
  11695. __ZN16b2ContactManager15FindNewContactsEv(i1);
  11696. d39 = +__ZNK7b2Timer15GetMillisecondsEv(i2);
  11697. i38 = i5 + 103020 | 0;
  11698. HEAPF32[i38 >> 2] = d39;
  11699. __ZN8b2IslandD2Ev(i4);
  11700. STACKTOP = i3;
  11701. return;
  11702. }
  11703. do {
  11704. if (!((HEAP16[i6 + 4 >> 1] & 1) == 0) ? (HEAP32[i6 >> 2] | 0) != 0 : 0) {
  11705. __ZN6b2Body19SynchronizeFixturesEv(i6);
  11706. }
  11707. i6 = HEAP32[i6 + 96 >> 2] | 0;
  11708. } while ((i6 | 0) != 0);
  11709. __ZN16b2ContactManager15FindNewContactsEv(i1);
  11710. d39 = +__ZNK7b2Timer15GetMillisecondsEv(i2);
  11711. i38 = i5 + 103020 | 0;
  11712. HEAPF32[i38 >> 2] = d39;
  11713. __ZN8b2IslandD2Ev(i4);
  11714. STACKTOP = i3;
  11715. return;
  11716. }
  11717. function __ZN15b2ContactSolver29InitializeVelocityConstraintsEv(i10) {
  11718. i10 = i10 | 0;
  11719. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, i31 = 0, d32 = 0.0, i33 = 0, i34 = 0, i35 = 0, i36 = 0, i37 = 0, d38 = 0.0, d39 = 0.0, d40 = 0.0, d41 = 0.0, i42 = 0, d43 = 0.0, d44 = 0.0, d45 = 0.0, d46 = 0.0, d47 = 0.0, d48 = 0.0, i49 = 0, i50 = 0;
  11720. i1 = STACKTOP;
  11721. STACKTOP = STACKTOP + 64 | 0;
  11722. i8 = i1 + 40 | 0;
  11723. i3 = i1 + 24 | 0;
  11724. i5 = i1;
  11725. i4 = i10 + 48 | 0;
  11726. if ((HEAP32[i4 >> 2] | 0) <= 0) {
  11727. STACKTOP = i1;
  11728. return;
  11729. }
  11730. i9 = i10 + 40 | 0;
  11731. i2 = i10 + 36 | 0;
  11732. i7 = i10 + 44 | 0;
  11733. i6 = i10 + 24 | 0;
  11734. i13 = i10 + 28 | 0;
  11735. i14 = i8 + 8 | 0;
  11736. i12 = i8 + 12 | 0;
  11737. i11 = i3 + 8 | 0;
  11738. i10 = i3 + 12 | 0;
  11739. i16 = 0;
  11740. while (1) {
  11741. i15 = HEAP32[i9 >> 2] | 0;
  11742. i33 = HEAP32[i2 >> 2] | 0;
  11743. i31 = HEAP32[(HEAP32[i7 >> 2] | 0) + (HEAP32[i15 + (i16 * 152 | 0) + 148 >> 2] << 2) >> 2] | 0;
  11744. i35 = HEAP32[i15 + (i16 * 152 | 0) + 112 >> 2] | 0;
  11745. i42 = HEAP32[i15 + (i16 * 152 | 0) + 116 >> 2] | 0;
  11746. d30 = +HEAPF32[i15 + (i16 * 152 | 0) + 120 >> 2];
  11747. d24 = +HEAPF32[i15 + (i16 * 152 | 0) + 124 >> 2];
  11748. d17 = +HEAPF32[i15 + (i16 * 152 | 0) + 128 >> 2];
  11749. d18 = +HEAPF32[i15 + (i16 * 152 | 0) + 132 >> 2];
  11750. i36 = i33 + (i16 * 88 | 0) + 48 | 0;
  11751. d39 = +HEAPF32[i36 >> 2];
  11752. d40 = +HEAPF32[i36 + 4 >> 2];
  11753. i36 = i33 + (i16 * 88 | 0) + 56 | 0;
  11754. d41 = +HEAPF32[i36 >> 2];
  11755. d43 = +HEAPF32[i36 + 4 >> 2];
  11756. i36 = HEAP32[i6 >> 2] | 0;
  11757. i37 = i36 + (i35 * 12 | 0) | 0;
  11758. d26 = +HEAPF32[i37 >> 2];
  11759. d27 = +HEAPF32[i37 + 4 >> 2];
  11760. d32 = +HEAPF32[i36 + (i35 * 12 | 0) + 8 >> 2];
  11761. i37 = HEAP32[i13 >> 2] | 0;
  11762. i34 = i37 + (i35 * 12 | 0) | 0;
  11763. d22 = +HEAPF32[i34 >> 2];
  11764. d25 = +HEAPF32[i34 + 4 >> 2];
  11765. d23 = +HEAPF32[i37 + (i35 * 12 | 0) + 8 >> 2];
  11766. i35 = i36 + (i42 * 12 | 0) | 0;
  11767. d28 = +HEAPF32[i35 >> 2];
  11768. d29 = +HEAPF32[i35 + 4 >> 2];
  11769. d38 = +HEAPF32[i36 + (i42 * 12 | 0) + 8 >> 2];
  11770. i36 = i37 + (i42 * 12 | 0) | 0;
  11771. d20 = +HEAPF32[i36 >> 2];
  11772. d19 = +HEAPF32[i36 + 4 >> 2];
  11773. d21 = +HEAPF32[i37 + (i42 * 12 | 0) + 8 >> 2];
  11774. if ((HEAP32[i31 + 124 >> 2] | 0) <= 0) {
  11775. i2 = 4;
  11776. break;
  11777. }
  11778. d44 = +HEAPF32[i33 + (i16 * 88 | 0) + 80 >> 2];
  11779. d45 = +HEAPF32[i33 + (i16 * 88 | 0) + 76 >> 2];
  11780. d47 = +Math_sin(+d32);
  11781. HEAPF32[i14 >> 2] = d47;
  11782. d48 = +Math_cos(+d32);
  11783. HEAPF32[i12 >> 2] = d48;
  11784. d32 = +Math_sin(+d38);
  11785. HEAPF32[i11 >> 2] = d32;
  11786. d38 = +Math_cos(+d38);
  11787. HEAPF32[i10 >> 2] = d38;
  11788. d46 = +(d26 - (d39 * d48 - d40 * d47));
  11789. d40 = +(d27 - (d40 * d48 + d39 * d47));
  11790. i37 = i8;
  11791. HEAPF32[i37 >> 2] = d46;
  11792. HEAPF32[i37 + 4 >> 2] = d40;
  11793. d40 = +(d28 - (d41 * d38 - d43 * d32));
  11794. d43 = +(d29 - (d43 * d38 + d41 * d32));
  11795. i37 = i3;
  11796. HEAPF32[i37 >> 2] = d40;
  11797. HEAPF32[i37 + 4 >> 2] = d43;
  11798. __ZN15b2WorldManifold10InitializeEPK10b2ManifoldRK11b2TransformfS5_f(i5, i31 + 64 | 0, i8, d45, i3, d44);
  11799. i37 = i15 + (i16 * 152 | 0) + 72 | 0;
  11800. i42 = i5;
  11801. i33 = HEAP32[i42 + 4 >> 2] | 0;
  11802. i31 = i37;
  11803. HEAP32[i31 >> 2] = HEAP32[i42 >> 2];
  11804. HEAP32[i31 + 4 >> 2] = i33;
  11805. i31 = i15 + (i16 * 152 | 0) + 144 | 0;
  11806. i33 = HEAP32[i31 >> 2] | 0;
  11807. do {
  11808. if ((i33 | 0) > 0) {
  11809. i36 = i15 + (i16 * 152 | 0) + 76 | 0;
  11810. d32 = d30 + d24;
  11811. i35 = i15 + (i16 * 152 | 0) + 140 | 0;
  11812. i34 = 0;
  11813. do {
  11814. i49 = i5 + (i34 << 3) + 8 | 0;
  11815. d41 = +HEAPF32[i49 >> 2] - d26;
  11816. i42 = i5 + (i34 << 3) + 12 | 0;
  11817. d39 = +d41;
  11818. d40 = +(+HEAPF32[i42 >> 2] - d27);
  11819. i50 = i15 + (i16 * 152 | 0) + (i34 * 36 | 0) | 0;
  11820. HEAPF32[i50 >> 2] = d39;
  11821. HEAPF32[i50 + 4 >> 2] = d40;
  11822. d40 = +HEAPF32[i49 >> 2] - d28;
  11823. d39 = +d40;
  11824. d47 = +(+HEAPF32[i42 >> 2] - d29);
  11825. i42 = i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 8 | 0;
  11826. HEAPF32[i42 >> 2] = d39;
  11827. HEAPF32[i42 + 4 >> 2] = d47;
  11828. d47 = +HEAPF32[i36 >> 2];
  11829. d39 = +HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 4 >> 2];
  11830. d43 = +HEAPF32[i37 >> 2];
  11831. d48 = d41 * d47 - d39 * d43;
  11832. d38 = +HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 12 >> 2];
  11833. d43 = d47 * d40 - d43 * d38;
  11834. d43 = d32 + d48 * d17 * d48 + d43 * d18 * d43;
  11835. if (d43 > 0.0) {
  11836. d43 = 1.0 / d43;
  11837. } else {
  11838. d43 = 0.0;
  11839. }
  11840. HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 24 >> 2] = d43;
  11841. d43 = +HEAPF32[i36 >> 2];
  11842. d47 = -+HEAPF32[i37 >> 2];
  11843. d48 = d41 * d47 - d43 * d39;
  11844. d43 = d40 * d47 - d43 * d38;
  11845. d43 = d32 + d48 * d17 * d48 + d43 * d18 * d43;
  11846. if (d43 > 0.0) {
  11847. d43 = 1.0 / d43;
  11848. } else {
  11849. d43 = 0.0;
  11850. }
  11851. HEAPF32[i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 28 >> 2] = d43;
  11852. i42 = i15 + (i16 * 152 | 0) + (i34 * 36 | 0) + 32 | 0;
  11853. HEAPF32[i42 >> 2] = 0.0;
  11854. d38 = +HEAPF32[i37 >> 2] * (d20 - d21 * d38 - d22 + d23 * d39) + +HEAPF32[i36 >> 2] * (d19 + d21 * d40 - d25 - d23 * d41);
  11855. if (d38 < -1.0) {
  11856. HEAPF32[i42 >> 2] = -(d38 * +HEAPF32[i35 >> 2]);
  11857. }
  11858. i34 = i34 + 1 | 0;
  11859. } while ((i34 | 0) != (i33 | 0));
  11860. if ((HEAP32[i31 >> 2] | 0) == 2) {
  11861. d45 = +HEAPF32[i15 + (i16 * 152 | 0) + 76 >> 2];
  11862. d20 = +HEAPF32[i37 >> 2];
  11863. d44 = +HEAPF32[i15 + (i16 * 152 | 0) >> 2] * d45 - +HEAPF32[i15 + (i16 * 152 | 0) + 4 >> 2] * d20;
  11864. d19 = d45 * +HEAPF32[i15 + (i16 * 152 | 0) + 8 >> 2] - d20 * +HEAPF32[i15 + (i16 * 152 | 0) + 12 >> 2];
  11865. d47 = d45 * +HEAPF32[i15 + (i16 * 152 | 0) + 36 >> 2] - d20 * +HEAPF32[i15 + (i16 * 152 | 0) + 40 >> 2];
  11866. d20 = d45 * +HEAPF32[i15 + (i16 * 152 | 0) + 44 >> 2] - d20 * +HEAPF32[i15 + (i16 * 152 | 0) + 48 >> 2];
  11867. d45 = d30 + d24;
  11868. d46 = d17 * d44;
  11869. d48 = d18 * d19;
  11870. d19 = d45 + d44 * d46 + d19 * d48;
  11871. d18 = d45 + d47 * d17 * d47 + d20 * d18 * d20;
  11872. d17 = d45 + d46 * d47 + d48 * d20;
  11873. d20 = d19 * d18 - d17 * d17;
  11874. if (!(d19 * d19 < d20 * 1.0e3)) {
  11875. HEAP32[i31 >> 2] = 1;
  11876. break;
  11877. }
  11878. HEAPF32[i15 + (i16 * 152 | 0) + 96 >> 2] = d19;
  11879. HEAPF32[i15 + (i16 * 152 | 0) + 100 >> 2] = d17;
  11880. HEAPF32[i15 + (i16 * 152 | 0) + 104 >> 2] = d17;
  11881. HEAPF32[i15 + (i16 * 152 | 0) + 108 >> 2] = d18;
  11882. if (d20 != 0.0) {
  11883. d20 = 1.0 / d20;
  11884. }
  11885. d48 = -(d20 * d17);
  11886. HEAPF32[i15 + (i16 * 152 | 0) + 80 >> 2] = d18 * d20;
  11887. HEAPF32[i15 + (i16 * 152 | 0) + 84 >> 2] = d48;
  11888. HEAPF32[i15 + (i16 * 152 | 0) + 88 >> 2] = d48;
  11889. HEAPF32[i15 + (i16 * 152 | 0) + 92 >> 2] = d19 * d20;
  11890. }
  11891. }
  11892. } while (0);
  11893. i16 = i16 + 1 | 0;
  11894. if ((i16 | 0) >= (HEAP32[i4 >> 2] | 0)) {
  11895. i2 = 21;
  11896. break;
  11897. }
  11898. }
  11899. if ((i2 | 0) == 4) {
  11900. ___assert_fail(6584, 6520, 168, 6616);
  11901. } else if ((i2 | 0) == 21) {
  11902. STACKTOP = i1;
  11903. return;
  11904. }
  11905. }
  11906. function __Z17b2CollidePolygonsP10b2ManifoldPK14b2PolygonShapeRK11b2TransformS3_S6_(i5, i27, i28, i24, i14) {
  11907. i5 = i5 | 0;
  11908. i27 = i27 | 0;
  11909. i28 = i28 | 0;
  11910. i24 = i24 | 0;
  11911. i14 = i14 | 0;
  11912. var i1 = 0, i2 = 0, d3 = 0.0, i4 = 0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d9 = 0.0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, d15 = 0.0, d16 = 0.0, i17 = 0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0, d22 = 0.0, d23 = 0.0, d25 = 0.0, d26 = 0.0, d29 = 0.0, d30 = 0.0, i31 = 0, d32 = 0.0, i33 = 0, i34 = 0, d35 = 0.0, d36 = 0.0, d37 = 0.0, d38 = 0.0;
  11913. i1 = STACKTOP;
  11914. STACKTOP = STACKTOP + 96 | 0;
  11915. i17 = i1 + 92 | 0;
  11916. i20 = i1 + 88 | 0;
  11917. i13 = i1;
  11918. i11 = i1 + 80 | 0;
  11919. i12 = i1 + 56 | 0;
  11920. i4 = i1 + 32 | 0;
  11921. i10 = i1 + 24 | 0;
  11922. i2 = i5 + 60 | 0;
  11923. HEAP32[i2 >> 2] = 0;
  11924. d3 = +HEAPF32[i27 + 8 >> 2] + +HEAPF32[i24 + 8 >> 2];
  11925. HEAP32[i17 >> 2] = 0;
  11926. d7 = +__ZL19b2FindMaxSeparationPiPK14b2PolygonShapeRK11b2TransformS2_S5_(i17, i27, i28, i24, i14);
  11927. if (d7 > d3) {
  11928. STACKTOP = i1;
  11929. return;
  11930. }
  11931. HEAP32[i20 >> 2] = 0;
  11932. d6 = +__ZL19b2FindMaxSeparationPiPK14b2PolygonShapeRK11b2TransformS2_S5_(i20, i24, i14, i27, i28);
  11933. if (d6 > d3) {
  11934. STACKTOP = i1;
  11935. return;
  11936. }
  11937. if (d6 > d7 * .9800000190734863 + .0010000000474974513) {
  11938. d18 = +HEAPF32[i14 >> 2];
  11939. d19 = +HEAPF32[i14 + 4 >> 2];
  11940. d15 = +HEAPF32[i14 + 8 >> 2];
  11941. d16 = +HEAPF32[i14 + 12 >> 2];
  11942. d9 = +HEAPF32[i28 >> 2];
  11943. d6 = +HEAPF32[i28 + 4 >> 2];
  11944. d7 = +HEAPF32[i28 + 8 >> 2];
  11945. d8 = +HEAPF32[i28 + 12 >> 2];
  11946. i17 = HEAP32[i20 >> 2] | 0;
  11947. HEAP32[i5 + 56 >> 2] = 2;
  11948. i14 = 1;
  11949. i20 = i24;
  11950. } else {
  11951. d18 = +HEAPF32[i28 >> 2];
  11952. d19 = +HEAPF32[i28 + 4 >> 2];
  11953. d15 = +HEAPF32[i28 + 8 >> 2];
  11954. d16 = +HEAPF32[i28 + 12 >> 2];
  11955. d9 = +HEAPF32[i14 >> 2];
  11956. d6 = +HEAPF32[i14 + 4 >> 2];
  11957. d7 = +HEAPF32[i14 + 8 >> 2];
  11958. d8 = +HEAPF32[i14 + 12 >> 2];
  11959. i17 = HEAP32[i17 >> 2] | 0;
  11960. HEAP32[i5 + 56 >> 2] = 1;
  11961. i14 = 0;
  11962. i20 = i27;
  11963. i27 = i24;
  11964. }
  11965. i28 = HEAP32[i27 + 148 >> 2] | 0;
  11966. if (!((i17 | 0) > -1)) {
  11967. ___assert_fail(5640, 5688, 151, 5728);
  11968. }
  11969. i24 = HEAP32[i20 + 148 >> 2] | 0;
  11970. if ((i24 | 0) <= (i17 | 0)) {
  11971. ___assert_fail(5640, 5688, 151, 5728);
  11972. }
  11973. d21 = +HEAPF32[i20 + (i17 << 3) + 84 >> 2];
  11974. d36 = +HEAPF32[i20 + (i17 << 3) + 88 >> 2];
  11975. d22 = d16 * d21 - d15 * d36;
  11976. d36 = d15 * d21 + d16 * d36;
  11977. d21 = d8 * d22 + d7 * d36;
  11978. d22 = d8 * d36 - d7 * d22;
  11979. if ((i28 | 0) > 0) {
  11980. i33 = 0;
  11981. i34 = 0;
  11982. d23 = 3.4028234663852886e+38;
  11983. while (1) {
  11984. d25 = d21 * +HEAPF32[i27 + (i33 << 3) + 84 >> 2] + d22 * +HEAPF32[i27 + (i33 << 3) + 88 >> 2];
  11985. i31 = d25 < d23;
  11986. i34 = i31 ? i33 : i34;
  11987. i33 = i33 + 1 | 0;
  11988. if ((i33 | 0) == (i28 | 0)) {
  11989. break;
  11990. } else {
  11991. d23 = i31 ? d25 : d23;
  11992. }
  11993. }
  11994. } else {
  11995. i34 = 0;
  11996. }
  11997. i31 = i34 + 1 | 0;
  11998. i33 = (i31 | 0) < (i28 | 0) ? i31 : 0;
  11999. d35 = +HEAPF32[i27 + (i34 << 3) + 20 >> 2];
  12000. d32 = +HEAPF32[i27 + (i34 << 3) + 24 >> 2];
  12001. d36 = +(d9 + (d8 * d35 - d7 * d32));
  12002. d32 = +(d6 + (d7 * d35 + d8 * d32));
  12003. i31 = i13;
  12004. HEAPF32[i31 >> 2] = d36;
  12005. HEAPF32[i31 + 4 >> 2] = d32;
  12006. i31 = i17 & 255;
  12007. i28 = i13 + 8 | 0;
  12008. HEAP8[i28] = i31;
  12009. HEAP8[i28 + 1 | 0] = i34;
  12010. HEAP8[i28 + 2 | 0] = 1;
  12011. HEAP8[i28 + 3 | 0] = 0;
  12012. d32 = +HEAPF32[i27 + (i33 << 3) + 20 >> 2];
  12013. d36 = +HEAPF32[i27 + (i33 << 3) + 24 >> 2];
  12014. d35 = +(d9 + (d8 * d32 - d7 * d36));
  12015. d36 = +(d6 + (d7 * d32 + d8 * d36));
  12016. i27 = i13 + 12 | 0;
  12017. HEAPF32[i27 >> 2] = d35;
  12018. HEAPF32[i27 + 4 >> 2] = d36;
  12019. i27 = i13 + 20 | 0;
  12020. HEAP8[i27] = i31;
  12021. HEAP8[i27 + 1 | 0] = i33;
  12022. HEAP8[i27 + 2 | 0] = 1;
  12023. HEAP8[i27 + 3 | 0] = 0;
  12024. i27 = i17 + 1 | 0;
  12025. i24 = (i27 | 0) < (i24 | 0) ? i27 : 0;
  12026. i34 = i20 + (i17 << 3) + 20 | 0;
  12027. d26 = +HEAPF32[i34 >> 2];
  12028. d25 = +HEAPF32[i34 + 4 >> 2];
  12029. i34 = i20 + (i24 << 3) + 20 | 0;
  12030. d30 = +HEAPF32[i34 >> 2];
  12031. d29 = +HEAPF32[i34 + 4 >> 2];
  12032. d32 = d30 - d26;
  12033. d35 = d29 - d25;
  12034. d21 = +Math_sqrt(+(d32 * d32 + d35 * d35));
  12035. if (!(d21 < 1.1920928955078125e-7)) {
  12036. d36 = 1.0 / d21;
  12037. d32 = d32 * d36;
  12038. d35 = d35 * d36;
  12039. }
  12040. d36 = d16 * d32 - d15 * d35;
  12041. d21 = d16 * d35 + d15 * d32;
  12042. HEAPF32[i11 >> 2] = d36;
  12043. HEAPF32[i11 + 4 >> 2] = d21;
  12044. d22 = -d36;
  12045. d38 = d18 + (d16 * d26 - d15 * d25);
  12046. d37 = d19 + (d15 * d26 + d16 * d25);
  12047. d23 = d38 * d21 + d37 * d22;
  12048. HEAPF32[i10 >> 2] = d22;
  12049. HEAPF32[i10 + 4 >> 2] = -d21;
  12050. if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i12, i13, i10, d3 - (d38 * d36 + d37 * d21), i17) | 0) < 2) {
  12051. STACKTOP = i1;
  12052. return;
  12053. }
  12054. if ((__Z19b2ClipSegmentToLineP12b2ClipVertexPKS_RK6b2Vec2fi(i4, i12, i11, d3 + ((d18 + (d16 * d30 - d15 * d29)) * d36 + (d19 + (d15 * d30 + d16 * d29)) * d21), i24) | 0) < 2) {
  12055. STACKTOP = i1;
  12056. return;
  12057. }
  12058. d16 = +d35;
  12059. d15 = +-d32;
  12060. i10 = i5 + 40 | 0;
  12061. HEAPF32[i10 >> 2] = d16;
  12062. HEAPF32[i10 + 4 >> 2] = d15;
  12063. d15 = +((d26 + d30) * .5);
  12064. d16 = +((d25 + d29) * .5);
  12065. i10 = i5 + 48 | 0;
  12066. HEAPF32[i10 >> 2] = d15;
  12067. HEAPF32[i10 + 4 >> 2] = d16;
  12068. d16 = +HEAPF32[i4 >> 2];
  12069. d15 = +HEAPF32[i4 + 4 >> 2];
  12070. i10 = !(d21 * d16 + d15 * d22 - d23 <= d3);
  12071. if (i14 << 24 >> 24 == 0) {
  12072. if (i10) {
  12073. i10 = 0;
  12074. } else {
  12075. d38 = d16 - d9;
  12076. d36 = d15 - d6;
  12077. d37 = +(d8 * d38 + d7 * d36);
  12078. d38 = +(d8 * d36 - d7 * d38);
  12079. i10 = i5;
  12080. HEAPF32[i10 >> 2] = d37;
  12081. HEAPF32[i10 + 4 >> 2] = d38;
  12082. HEAP32[i5 + 16 >> 2] = HEAP32[i4 + 8 >> 2];
  12083. i10 = 1;
  12084. }
  12085. d16 = +HEAPF32[i4 + 12 >> 2];
  12086. d15 = +HEAPF32[i4 + 16 >> 2];
  12087. if (d21 * d16 + d15 * d22 - d23 <= d3) {
  12088. d38 = d16 - d9;
  12089. d36 = d15 - d6;
  12090. d37 = +(d8 * d38 + d7 * d36);
  12091. d38 = +(d8 * d36 - d7 * d38);
  12092. i34 = i5 + (i10 * 20 | 0) | 0;
  12093. HEAPF32[i34 >> 2] = d37;
  12094. HEAPF32[i34 + 4 >> 2] = d38;
  12095. HEAP32[i5 + (i10 * 20 | 0) + 16 >> 2] = HEAP32[i4 + 20 >> 2];
  12096. i10 = i10 + 1 | 0;
  12097. }
  12098. } else {
  12099. if (i10) {
  12100. i10 = 0;
  12101. } else {
  12102. d38 = d16 - d9;
  12103. d36 = d15 - d6;
  12104. d37 = +(d8 * d38 + d7 * d36);
  12105. d38 = +(d8 * d36 - d7 * d38);
  12106. i10 = i5;
  12107. HEAPF32[i10 >> 2] = d37;
  12108. HEAPF32[i10 + 4 >> 2] = d38;
  12109. i10 = i5 + 16 | 0;
  12110. i34 = HEAP32[i4 + 8 >> 2] | 0;
  12111. HEAP32[i10 >> 2] = i34;
  12112. HEAP8[i10] = i34 >>> 8;
  12113. HEAP8[i10 + 1 | 0] = i34;
  12114. HEAP8[i10 + 2 | 0] = i34 >>> 24;
  12115. HEAP8[i10 + 3 | 0] = i34 >>> 16;
  12116. i10 = 1;
  12117. }
  12118. d16 = +HEAPF32[i4 + 12 >> 2];
  12119. d15 = +HEAPF32[i4 + 16 >> 2];
  12120. if (d21 * d16 + d15 * d22 - d23 <= d3) {
  12121. d38 = d16 - d9;
  12122. d36 = d15 - d6;
  12123. d37 = +(d8 * d38 + d7 * d36);
  12124. d38 = +(d8 * d36 - d7 * d38);
  12125. i34 = i5 + (i10 * 20 | 0) | 0;
  12126. HEAPF32[i34 >> 2] = d37;
  12127. HEAPF32[i34 + 4 >> 2] = d38;
  12128. i34 = i5 + (i10 * 20 | 0) + 16 | 0;
  12129. i33 = HEAP32[i4 + 20 >> 2] | 0;
  12130. HEAP32[i34 >> 2] = i33;
  12131. HEAP8[i34] = i33 >>> 8;
  12132. HEAP8[i34 + 1 | 0] = i33;
  12133. HEAP8[i34 + 2 | 0] = i33 >>> 24;
  12134. HEAP8[i34 + 3 | 0] = i33 >>> 16;
  12135. i10 = i10 + 1 | 0;
  12136. }
  12137. }
  12138. HEAP32[i2 >> 2] = i10;
  12139. STACKTOP = i1;
  12140. return;
  12141. }
  12142. function __ZN8b2Island8SolveTOIERK10b2TimeStepii(i4, i11, i15, i18) {
  12143. i4 = i4 | 0;
  12144. i11 = i11 | 0;
  12145. i15 = i15 | 0;
  12146. i18 = i18 | 0;
  12147. var i1 = 0, i2 = 0, i3 = 0, i5 = 0, i6 = 0, i7 = 0, i8 = 0, i9 = 0, i10 = 0, d12 = 0.0, d13 = 0.0, d14 = 0.0, d16 = 0.0, d17 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, i22 = 0, i23 = 0, i24 = 0, i25 = 0, d26 = 0.0;
  12148. i1 = STACKTOP;
  12149. STACKTOP = STACKTOP + 128 | 0;
  12150. i2 = i1 + 96 | 0;
  12151. i10 = i1 + 52 | 0;
  12152. i3 = i1;
  12153. i6 = i4 + 28 | 0;
  12154. i5 = HEAP32[i6 >> 2] | 0;
  12155. if ((i5 | 0) <= (i15 | 0)) {
  12156. ___assert_fail(5464, 5488, 386, 5520);
  12157. }
  12158. if ((i5 | 0) <= (i18 | 0)) {
  12159. ___assert_fail(5536, 5488, 387, 5520);
  12160. }
  12161. if ((i5 | 0) > 0) {
  12162. i9 = i4 + 8 | 0;
  12163. i8 = i4 + 20 | 0;
  12164. i7 = i4 + 24 | 0;
  12165. i22 = 0;
  12166. while (1) {
  12167. i23 = HEAP32[(HEAP32[i9 >> 2] | 0) + (i22 << 2) >> 2] | 0;
  12168. i5 = i23 + 44 | 0;
  12169. i24 = HEAP32[i5 + 4 >> 2] | 0;
  12170. i25 = (HEAP32[i8 >> 2] | 0) + (i22 * 12 | 0) | 0;
  12171. HEAP32[i25 >> 2] = HEAP32[i5 >> 2];
  12172. HEAP32[i25 + 4 >> 2] = i24;
  12173. HEAPF32[(HEAP32[i8 >> 2] | 0) + (i22 * 12 | 0) + 8 >> 2] = +HEAPF32[i23 + 56 >> 2];
  12174. i25 = i23 + 64 | 0;
  12175. i24 = HEAP32[i25 + 4 >> 2] | 0;
  12176. i5 = (HEAP32[i7 >> 2] | 0) + (i22 * 12 | 0) | 0;
  12177. HEAP32[i5 >> 2] = HEAP32[i25 >> 2];
  12178. HEAP32[i5 + 4 >> 2] = i24;
  12179. i5 = HEAP32[i7 >> 2] | 0;
  12180. HEAPF32[i5 + (i22 * 12 | 0) + 8 >> 2] = +HEAPF32[i23 + 72 >> 2];
  12181. i22 = i22 + 1 | 0;
  12182. if ((i22 | 0) >= (HEAP32[i6 >> 2] | 0)) {
  12183. i22 = i5;
  12184. break;
  12185. }
  12186. }
  12187. } else {
  12188. i8 = i4 + 20 | 0;
  12189. i22 = HEAP32[i4 + 24 >> 2] | 0;
  12190. }
  12191. i5 = i4 + 12 | 0;
  12192. HEAP32[i10 + 24 >> 2] = HEAP32[i5 >> 2];
  12193. i7 = i4 + 36 | 0;
  12194. HEAP32[i10 + 28 >> 2] = HEAP32[i7 >> 2];
  12195. HEAP32[i10 + 40 >> 2] = HEAP32[i4 >> 2];
  12196. HEAP32[i10 + 0 >> 2] = HEAP32[i11 + 0 >> 2];
  12197. HEAP32[i10 + 4 >> 2] = HEAP32[i11 + 4 >> 2];
  12198. HEAP32[i10 + 8 >> 2] = HEAP32[i11 + 8 >> 2];
  12199. HEAP32[i10 + 12 >> 2] = HEAP32[i11 + 12 >> 2];
  12200. HEAP32[i10 + 16 >> 2] = HEAP32[i11 + 16 >> 2];
  12201. HEAP32[i10 + 20 >> 2] = HEAP32[i11 + 20 >> 2];
  12202. HEAP32[i10 + 32 >> 2] = HEAP32[i8 >> 2];
  12203. i9 = i4 + 24 | 0;
  12204. HEAP32[i10 + 36 >> 2] = i22;
  12205. __ZN15b2ContactSolverC2EP18b2ContactSolverDef(i3, i10);
  12206. i10 = i11 + 16 | 0;
  12207. L13 : do {
  12208. if ((HEAP32[i10 >> 2] | 0) > 0) {
  12209. i22 = 0;
  12210. do {
  12211. i22 = i22 + 1 | 0;
  12212. if (__ZN15b2ContactSolver27SolveTOIPositionConstraintsEii(i3, i15, i18) | 0) {
  12213. break L13;
  12214. }
  12215. } while ((i22 | 0) < (HEAP32[i10 >> 2] | 0));
  12216. }
  12217. } while (0);
  12218. i10 = i4 + 8 | 0;
  12219. i24 = (HEAP32[i8 >> 2] | 0) + (i15 * 12 | 0) | 0;
  12220. i25 = HEAP32[i24 + 4 >> 2] | 0;
  12221. i23 = (HEAP32[(HEAP32[i10 >> 2] | 0) + (i15 << 2) >> 2] | 0) + 36 | 0;
  12222. HEAP32[i23 >> 2] = HEAP32[i24 >> 2];
  12223. HEAP32[i23 + 4 >> 2] = i25;
  12224. i23 = HEAP32[i8 >> 2] | 0;
  12225. i25 = HEAP32[i10 >> 2] | 0;
  12226. HEAPF32[(HEAP32[i25 + (i15 << 2) >> 2] | 0) + 52 >> 2] = +HEAPF32[i23 + (i15 * 12 | 0) + 8 >> 2];
  12227. i23 = i23 + (i18 * 12 | 0) | 0;
  12228. i24 = HEAP32[i23 + 4 >> 2] | 0;
  12229. i25 = (HEAP32[i25 + (i18 << 2) >> 2] | 0) + 36 | 0;
  12230. HEAP32[i25 >> 2] = HEAP32[i23 >> 2];
  12231. HEAP32[i25 + 4 >> 2] = i24;
  12232. HEAPF32[(HEAP32[(HEAP32[i10 >> 2] | 0) + (i18 << 2) >> 2] | 0) + 52 >> 2] = +HEAPF32[(HEAP32[i8 >> 2] | 0) + (i18 * 12 | 0) + 8 >> 2];
  12233. __ZN15b2ContactSolver29InitializeVelocityConstraintsEv(i3);
  12234. i18 = i11 + 12 | 0;
  12235. if ((HEAP32[i18 >> 2] | 0) > 0) {
  12236. i15 = 0;
  12237. do {
  12238. __ZN15b2ContactSolver24SolveVelocityConstraintsEv(i3);
  12239. i15 = i15 + 1 | 0;
  12240. } while ((i15 | 0) < (HEAP32[i18 >> 2] | 0));
  12241. }
  12242. d16 = +HEAPF32[i11 >> 2];
  12243. if ((HEAP32[i6 >> 2] | 0) > 0) {
  12244. i15 = 0;
  12245. do {
  12246. i25 = HEAP32[i8 >> 2] | 0;
  12247. i11 = i25 + (i15 * 12 | 0) | 0;
  12248. i24 = i11;
  12249. d12 = +HEAPF32[i24 >> 2];
  12250. d14 = +HEAPF32[i24 + 4 >> 2];
  12251. d13 = +HEAPF32[i25 + (i15 * 12 | 0) + 8 >> 2];
  12252. i25 = HEAP32[i9 >> 2] | 0;
  12253. i24 = i25 + (i15 * 12 | 0) | 0;
  12254. d19 = +HEAPF32[i24 >> 2];
  12255. d20 = +HEAPF32[i24 + 4 >> 2];
  12256. d17 = +HEAPF32[i25 + (i15 * 12 | 0) + 8 >> 2];
  12257. d26 = d16 * d19;
  12258. d21 = d16 * d20;
  12259. d21 = d26 * d26 + d21 * d21;
  12260. if (d21 > 4.0) {
  12261. d26 = 2.0 / +Math_sqrt(+d21);
  12262. d19 = d19 * d26;
  12263. d20 = d20 * d26;
  12264. }
  12265. d21 = d16 * d17;
  12266. if (d21 * d21 > 2.4674012660980225) {
  12267. if (!(d21 > 0.0)) {
  12268. d21 = -d21;
  12269. }
  12270. d17 = d17 * (1.5707963705062866 / d21);
  12271. }
  12272. d21 = d12 + d16 * d19;
  12273. d14 = d14 + d16 * d20;
  12274. d26 = d13 + d16 * d17;
  12275. d12 = +d21;
  12276. d13 = +d14;
  12277. i25 = i11;
  12278. HEAPF32[i25 >> 2] = d12;
  12279. HEAPF32[i25 + 4 >> 2] = d13;
  12280. HEAPF32[(HEAP32[i8 >> 2] | 0) + (i15 * 12 | 0) + 8 >> 2] = d26;
  12281. d19 = +d19;
  12282. d20 = +d20;
  12283. i25 = (HEAP32[i9 >> 2] | 0) + (i15 * 12 | 0) | 0;
  12284. HEAPF32[i25 >> 2] = d19;
  12285. HEAPF32[i25 + 4 >> 2] = d20;
  12286. HEAPF32[(HEAP32[i9 >> 2] | 0) + (i15 * 12 | 0) + 8 >> 2] = d17;
  12287. i25 = HEAP32[(HEAP32[i10 >> 2] | 0) + (i15 << 2) >> 2] | 0;
  12288. i24 = i25 + 44 | 0;
  12289. HEAPF32[i24 >> 2] = d12;
  12290. HEAPF32[i24 + 4 >> 2] = d13;
  12291. HEAPF32[i25 + 56 >> 2] = d26;
  12292. i24 = i25 + 64 | 0;
  12293. HEAPF32[i24 >> 2] = d19;
  12294. HEAPF32[i24 + 4 >> 2] = d20;
  12295. HEAPF32[i25 + 72 >> 2] = d17;
  12296. d17 = +Math_sin(+d26);
  12297. HEAPF32[i25 + 20 >> 2] = d17;
  12298. d20 = +Math_cos(+d26);
  12299. HEAPF32[i25 + 24 >> 2] = d20;
  12300. d19 = +HEAPF32[i25 + 28 >> 2];
  12301. d26 = +HEAPF32[i25 + 32 >> 2];
  12302. d21 = +(d21 - (d20 * d19 - d17 * d26));
  12303. d26 = +(d14 - (d17 * d19 + d20 * d26));
  12304. i25 = i25 + 12 | 0;
  12305. HEAPF32[i25 >> 2] = d21;
  12306. HEAPF32[i25 + 4 >> 2] = d26;
  12307. i15 = i15 + 1 | 0;
  12308. } while ((i15 | 0) < (HEAP32[i6 >> 2] | 0));
  12309. }
  12310. i6 = HEAP32[i3 + 40 >> 2] | 0;
  12311. i4 = i4 + 4 | 0;
  12312. if ((HEAP32[i4 >> 2] | 0) == 0) {
  12313. __ZN15b2ContactSolverD2Ev(i3);
  12314. STACKTOP = i1;
  12315. return;
  12316. }
  12317. if ((HEAP32[i7 >> 2] | 0) <= 0) {
  12318. __ZN15b2ContactSolverD2Ev(i3);
  12319. STACKTOP = i1;
  12320. return;
  12321. }
  12322. i8 = i2 + 16 | 0;
  12323. i9 = 0;
  12324. do {
  12325. i10 = HEAP32[(HEAP32[i5 >> 2] | 0) + (i9 << 2) >> 2] | 0;
  12326. i11 = HEAP32[i6 + (i9 * 152 | 0) + 144 >> 2] | 0;
  12327. HEAP32[i8 >> 2] = i11;
  12328. if ((i11 | 0) > 0) {
  12329. i15 = 0;
  12330. do {
  12331. HEAPF32[i2 + (i15 << 2) >> 2] = +HEAPF32[i6 + (i9 * 152 | 0) + (i15 * 36 | 0) + 16 >> 2];
  12332. HEAPF32[i2 + (i15 << 2) + 8 >> 2] = +HEAPF32[i6 + (i9 * 152 | 0) + (i15 * 36 | 0) + 20 >> 2];
  12333. i15 = i15 + 1 | 0;
  12334. } while ((i15 | 0) != (i11 | 0));
  12335. }
  12336. i25 = HEAP32[i4 >> 2] | 0;
  12337. FUNCTION_TABLE_viii[HEAP32[(HEAP32[i25 >> 2] | 0) + 20 >> 2] & 3](i25, i10, i2);
  12338. i9 = i9 + 1 | 0;
  12339. } while ((i9 | 0) < (HEAP32[i7 >> 2] | 0));
  12340. __ZN15b2ContactSolverD2Ev(i3);
  12341. STACKTOP = i1;
  12342. return;
  12343. }
  12344. function __ZN20b2SeparationFunction10InitializeEPK14b2SimplexCachePK15b2DistanceProxyRK7b2SweepS5_S8_f(i2, i11, i13, i21, i12, i24, d9) {
  12345. i2 = i2 | 0;
  12346. i11 = i11 | 0;
  12347. i13 = i13 | 0;
  12348. i21 = i21 | 0;
  12349. i12 = i12 | 0;
  12350. i24 = i24 | 0;
  12351. d9 = +d9;
  12352. var i1 = 0, d3 = 0.0, d4 = 0.0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d10 = 0.0, i14 = 0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d22 = 0.0, i23 = 0, i25 = 0, i26 = 0, i27 = 0, d28 = 0.0, d29 = 0.0;
  12353. i1 = STACKTOP;
  12354. HEAP32[i2 >> 2] = i13;
  12355. HEAP32[i2 + 4 >> 2] = i12;
  12356. i14 = HEAP16[i11 + 4 >> 1] | 0;
  12357. if (!(i14 << 16 >> 16 != 0 & (i14 & 65535) < 3)) {
  12358. ___assert_fail(3744, 3560, 50, 3768);
  12359. }
  12360. i23 = i2 + 8 | 0;
  12361. i25 = i23 + 0 | 0;
  12362. i27 = i21 + 0 | 0;
  12363. i26 = i25 + 36 | 0;
  12364. do {
  12365. HEAP32[i25 >> 2] = HEAP32[i27 >> 2];
  12366. i25 = i25 + 4 | 0;
  12367. i27 = i27 + 4 | 0;
  12368. } while ((i25 | 0) < (i26 | 0));
  12369. i21 = i2 + 44 | 0;
  12370. i25 = i21 + 0 | 0;
  12371. i27 = i24 + 0 | 0;
  12372. i26 = i25 + 36 | 0;
  12373. do {
  12374. HEAP32[i25 >> 2] = HEAP32[i27 >> 2];
  12375. i25 = i25 + 4 | 0;
  12376. i27 = i27 + 4 | 0;
  12377. } while ((i25 | 0) < (i26 | 0));
  12378. d19 = 1.0 - d9;
  12379. d4 = d19 * +HEAPF32[i2 + 32 >> 2] + +HEAPF32[i2 + 36 >> 2] * d9;
  12380. d3 = +Math_sin(+d4);
  12381. d4 = +Math_cos(+d4);
  12382. d7 = +HEAPF32[i23 >> 2];
  12383. d5 = +HEAPF32[i2 + 12 >> 2];
  12384. d8 = d19 * +HEAPF32[i2 + 16 >> 2] + +HEAPF32[i2 + 24 >> 2] * d9 - (d4 * d7 - d3 * d5);
  12385. d5 = d19 * +HEAPF32[i2 + 20 >> 2] + +HEAPF32[i2 + 28 >> 2] * d9 - (d3 * d7 + d4 * d5);
  12386. d7 = d19 * +HEAPF32[i2 + 68 >> 2] + +HEAPF32[i2 + 72 >> 2] * d9;
  12387. d6 = +Math_sin(+d7);
  12388. d7 = +Math_cos(+d7);
  12389. d20 = +HEAPF32[i21 >> 2];
  12390. d22 = +HEAPF32[i2 + 48 >> 2];
  12391. d10 = d19 * +HEAPF32[i2 + 52 >> 2] + +HEAPF32[i2 + 60 >> 2] * d9 - (d7 * d20 - d6 * d22);
  12392. d9 = d19 * +HEAPF32[i2 + 56 >> 2] + +HEAPF32[i2 + 64 >> 2] * d9 - (d6 * d20 + d7 * d22);
  12393. if (i14 << 16 >> 16 == 1) {
  12394. HEAP32[i2 + 80 >> 2] = 0;
  12395. i14 = HEAPU8[i11 + 6 | 0] | 0;
  12396. if ((HEAP32[i13 + 20 >> 2] | 0) <= (i14 | 0)) {
  12397. ___assert_fail(3640, 3672, 103, 3704);
  12398. }
  12399. i27 = (HEAP32[i13 + 16 >> 2] | 0) + (i14 << 3) | 0;
  12400. d15 = +HEAPF32[i27 >> 2];
  12401. d16 = +HEAPF32[i27 + 4 >> 2];
  12402. i11 = HEAPU8[i11 + 9 | 0] | 0;
  12403. if ((HEAP32[i12 + 20 >> 2] | 0) <= (i11 | 0)) {
  12404. ___assert_fail(3640, 3672, 103, 3704);
  12405. }
  12406. i11 = (HEAP32[i12 + 16 >> 2] | 0) + (i11 << 3) | 0;
  12407. d20 = +HEAPF32[i11 >> 2];
  12408. d22 = +HEAPF32[i11 + 4 >> 2];
  12409. i11 = i2 + 92 | 0;
  12410. d8 = d10 + (d7 * d20 - d6 * d22) - (d8 + (d4 * d15 - d3 * d16));
  12411. d4 = d9 + (d6 * d20 + d7 * d22) - (d5 + (d3 * d15 + d4 * d16));
  12412. d22 = +d8;
  12413. d3 = +d4;
  12414. i27 = i11;
  12415. HEAPF32[i27 >> 2] = d22;
  12416. HEAPF32[i27 + 4 >> 2] = d3;
  12417. d3 = +Math_sqrt(+(d8 * d8 + d4 * d4));
  12418. if (d3 < 1.1920928955078125e-7) {
  12419. d22 = 0.0;
  12420. STACKTOP = i1;
  12421. return +d22;
  12422. }
  12423. d22 = 1.0 / d3;
  12424. HEAPF32[i11 >> 2] = d8 * d22;
  12425. HEAPF32[i2 + 96 >> 2] = d4 * d22;
  12426. d22 = d3;
  12427. STACKTOP = i1;
  12428. return +d22;
  12429. }
  12430. i14 = i11 + 6 | 0;
  12431. i21 = i11 + 7 | 0;
  12432. i23 = i2 + 80 | 0;
  12433. if ((HEAP8[i14] | 0) == (HEAP8[i21] | 0)) {
  12434. HEAP32[i23 >> 2] = 2;
  12435. i23 = HEAPU8[i11 + 9 | 0] | 0;
  12436. i21 = HEAP32[i12 + 20 >> 2] | 0;
  12437. if ((i21 | 0) <= (i23 | 0)) {
  12438. ___assert_fail(3640, 3672, 103, 3704);
  12439. }
  12440. i12 = HEAP32[i12 + 16 >> 2] | 0;
  12441. i27 = i12 + (i23 << 3) | 0;
  12442. d16 = +HEAPF32[i27 >> 2];
  12443. d15 = +HEAPF32[i27 + 4 >> 2];
  12444. i11 = HEAPU8[i11 + 10 | 0] | 0;
  12445. if ((i21 | 0) <= (i11 | 0)) {
  12446. ___assert_fail(3640, 3672, 103, 3704);
  12447. }
  12448. i11 = i12 + (i11 << 3) | 0;
  12449. d20 = +HEAPF32[i11 >> 2];
  12450. d18 = +HEAPF32[i11 + 4 >> 2];
  12451. i11 = i2 + 92 | 0;
  12452. d22 = d20 - d16;
  12453. d19 = d18 - d15;
  12454. d17 = -d22;
  12455. d29 = +d19;
  12456. d28 = +d17;
  12457. i27 = i11;
  12458. HEAPF32[i27 >> 2] = d29;
  12459. HEAPF32[i27 + 4 >> 2] = d28;
  12460. d22 = +Math_sqrt(+(d19 * d19 + d22 * d22));
  12461. if (!(d22 < 1.1920928955078125e-7)) {
  12462. d29 = 1.0 / d22;
  12463. d19 = d19 * d29;
  12464. HEAPF32[i11 >> 2] = d19;
  12465. d17 = d29 * d17;
  12466. HEAPF32[i2 + 96 >> 2] = d17;
  12467. }
  12468. d16 = (d16 + d20) * .5;
  12469. d15 = (d15 + d18) * .5;
  12470. d28 = +d16;
  12471. d29 = +d15;
  12472. i2 = i2 + 84 | 0;
  12473. HEAPF32[i2 >> 2] = d28;
  12474. HEAPF32[i2 + 4 >> 2] = d29;
  12475. i2 = HEAPU8[i14] | 0;
  12476. if ((HEAP32[i13 + 20 >> 2] | 0) <= (i2 | 0)) {
  12477. ___assert_fail(3640, 3672, 103, 3704);
  12478. }
  12479. i27 = (HEAP32[i13 + 16 >> 2] | 0) + (i2 << 3) | 0;
  12480. d28 = +HEAPF32[i27 >> 2];
  12481. d29 = +HEAPF32[i27 + 4 >> 2];
  12482. d3 = (d7 * d19 - d6 * d17) * (d8 + (d4 * d28 - d3 * d29) - (d10 + (d7 * d16 - d6 * d15))) + (d6 * d19 + d7 * d17) * (d5 + (d3 * d28 + d4 * d29) - (d9 + (d6 * d16 + d7 * d15)));
  12483. if (!(d3 < 0.0)) {
  12484. d29 = d3;
  12485. STACKTOP = i1;
  12486. return +d29;
  12487. }
  12488. d28 = +-d19;
  12489. d29 = +-d17;
  12490. i27 = i11;
  12491. HEAPF32[i27 >> 2] = d28;
  12492. HEAPF32[i27 + 4 >> 2] = d29;
  12493. d29 = -d3;
  12494. STACKTOP = i1;
  12495. return +d29;
  12496. } else {
  12497. HEAP32[i23 >> 2] = 1;
  12498. i23 = HEAPU8[i14] | 0;
  12499. i14 = HEAP32[i13 + 20 >> 2] | 0;
  12500. if ((i14 | 0) <= (i23 | 0)) {
  12501. ___assert_fail(3640, 3672, 103, 3704);
  12502. }
  12503. i13 = HEAP32[i13 + 16 >> 2] | 0;
  12504. i27 = i13 + (i23 << 3) | 0;
  12505. d16 = +HEAPF32[i27 >> 2];
  12506. d15 = +HEAPF32[i27 + 4 >> 2];
  12507. i21 = HEAPU8[i21] | 0;
  12508. if ((i14 | 0) <= (i21 | 0)) {
  12509. ___assert_fail(3640, 3672, 103, 3704);
  12510. }
  12511. i13 = i13 + (i21 << 3) | 0;
  12512. d20 = +HEAPF32[i13 >> 2];
  12513. d18 = +HEAPF32[i13 + 4 >> 2];
  12514. i13 = i2 + 92 | 0;
  12515. d22 = d20 - d16;
  12516. d19 = d18 - d15;
  12517. d17 = -d22;
  12518. d28 = +d19;
  12519. d29 = +d17;
  12520. i27 = i13;
  12521. HEAPF32[i27 >> 2] = d28;
  12522. HEAPF32[i27 + 4 >> 2] = d29;
  12523. d22 = +Math_sqrt(+(d19 * d19 + d22 * d22));
  12524. if (!(d22 < 1.1920928955078125e-7)) {
  12525. d29 = 1.0 / d22;
  12526. d19 = d19 * d29;
  12527. HEAPF32[i13 >> 2] = d19;
  12528. d17 = d29 * d17;
  12529. HEAPF32[i2 + 96 >> 2] = d17;
  12530. }
  12531. d16 = (d16 + d20) * .5;
  12532. d15 = (d15 + d18) * .5;
  12533. d28 = +d16;
  12534. d29 = +d15;
  12535. i2 = i2 + 84 | 0;
  12536. HEAPF32[i2 >> 2] = d28;
  12537. HEAPF32[i2 + 4 >> 2] = d29;
  12538. i2 = HEAPU8[i11 + 9 | 0] | 0;
  12539. if ((HEAP32[i12 + 20 >> 2] | 0) <= (i2 | 0)) {
  12540. ___assert_fail(3640, 3672, 103, 3704);
  12541. }
  12542. i27 = (HEAP32[i12 + 16 >> 2] | 0) + (i2 << 3) | 0;
  12543. d28 = +HEAPF32[i27 >> 2];
  12544. d29 = +HEAPF32[i27 + 4 >> 2];
  12545. d3 = (d4 * d19 - d3 * d17) * (d10 + (d7 * d28 - d6 * d29) - (d8 + (d4 * d16 - d3 * d15))) + (d3 * d19 + d4 * d17) * (d9 + (d6 * d28 + d7 * d29) - (d5 + (d3 * d16 + d4 * d15)));
  12546. if (!(d3 < 0.0)) {
  12547. d29 = d3;
  12548. STACKTOP = i1;
  12549. return +d29;
  12550. }
  12551. d28 = +-d19;
  12552. d29 = +-d17;
  12553. i27 = i13;
  12554. HEAPF32[i27 >> 2] = d28;
  12555. HEAPF32[i27 + 4 >> 2] = d29;
  12556. d29 = -d3;
  12557. STACKTOP = i1;
  12558. return +d29;
  12559. }
  12560. return 0.0;
  12561. }
  12562. function __ZNK20b2SeparationFunction17FindMinSeparationEPiS0_f(i12, i10, i9, d5) {
  12563. i12 = i12 | 0;
  12564. i10 = i10 | 0;
  12565. i9 = i9 | 0;
  12566. d5 = +d5;
  12567. var i1 = 0, d2 = 0.0, d3 = 0.0, d4 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, d11 = 0.0, d13 = 0.0, d14 = 0.0, i15 = 0, i16 = 0, d17 = 0.0, d18 = 0.0, i19 = 0, d20 = 0.0, d21 = 0.0, i22 = 0, d23 = 0.0, d24 = 0.0, i25 = 0, i26 = 0, i27 = 0;
  12568. i1 = STACKTOP;
  12569. d21 = 1.0 - d5;
  12570. d6 = d21 * +HEAPF32[i12 + 32 >> 2] + +HEAPF32[i12 + 36 >> 2] * d5;
  12571. d7 = +Math_sin(+d6);
  12572. d6 = +Math_cos(+d6);
  12573. d3 = +HEAPF32[i12 + 8 >> 2];
  12574. d8 = +HEAPF32[i12 + 12 >> 2];
  12575. d11 = d21 * +HEAPF32[i12 + 16 >> 2] + +HEAPF32[i12 + 24 >> 2] * d5 - (d6 * d3 - d7 * d8);
  12576. d8 = d21 * +HEAPF32[i12 + 20 >> 2] + +HEAPF32[i12 + 28 >> 2] * d5 - (d7 * d3 + d6 * d8);
  12577. d3 = d21 * +HEAPF32[i12 + 68 >> 2] + +HEAPF32[i12 + 72 >> 2] * d5;
  12578. d2 = +Math_sin(+d3);
  12579. d3 = +Math_cos(+d3);
  12580. d23 = +HEAPF32[i12 + 44 >> 2];
  12581. d24 = +HEAPF32[i12 + 48 >> 2];
  12582. d4 = d21 * +HEAPF32[i12 + 52 >> 2] + +HEAPF32[i12 + 60 >> 2] * d5 - (d3 * d23 - d2 * d24);
  12583. d5 = d21 * +HEAPF32[i12 + 56 >> 2] + +HEAPF32[i12 + 64 >> 2] * d5 - (d2 * d23 + d3 * d24);
  12584. i19 = HEAP32[i12 + 80 >> 2] | 0;
  12585. if ((i19 | 0) == 1) {
  12586. d23 = +HEAPF32[i12 + 92 >> 2];
  12587. d14 = +HEAPF32[i12 + 96 >> 2];
  12588. d13 = d6 * d23 - d7 * d14;
  12589. d14 = d7 * d23 + d6 * d14;
  12590. d23 = +HEAPF32[i12 + 84 >> 2];
  12591. d24 = +HEAPF32[i12 + 88 >> 2];
  12592. d11 = d11 + (d6 * d23 - d7 * d24);
  12593. d6 = d8 + (d7 * d23 + d6 * d24);
  12594. d7 = -d13;
  12595. d24 = -d14;
  12596. d8 = d3 * d7 + d2 * d24;
  12597. d7 = d3 * d24 - d2 * d7;
  12598. HEAP32[i10 >> 2] = -1;
  12599. i25 = i12 + 4 | 0;
  12600. i22 = HEAP32[i25 >> 2] | 0;
  12601. i19 = HEAP32[i22 + 16 >> 2] | 0;
  12602. i22 = HEAP32[i22 + 20 >> 2] | 0;
  12603. if ((i22 | 0) > 1) {
  12604. i10 = 0;
  12605. d18 = d7 * +HEAPF32[i19 + 4 >> 2] + d8 * +HEAPF32[i19 >> 2];
  12606. i12 = 1;
  12607. while (1) {
  12608. d17 = d8 * +HEAPF32[i19 + (i12 << 3) >> 2] + d7 * +HEAPF32[i19 + (i12 << 3) + 4 >> 2];
  12609. i16 = d17 > d18;
  12610. i10 = i16 ? i12 : i10;
  12611. i12 = i12 + 1 | 0;
  12612. if ((i12 | 0) == (i22 | 0)) {
  12613. break;
  12614. } else {
  12615. d18 = i16 ? d17 : d18;
  12616. }
  12617. }
  12618. HEAP32[i9 >> 2] = i10;
  12619. if ((i10 | 0) > -1) {
  12620. i15 = i10;
  12621. } else {
  12622. ___assert_fail(3640, 3672, 103, 3704);
  12623. }
  12624. } else {
  12625. HEAP32[i9 >> 2] = 0;
  12626. i15 = 0;
  12627. }
  12628. i9 = HEAP32[i25 >> 2] | 0;
  12629. if ((HEAP32[i9 + 20 >> 2] | 0) <= (i15 | 0)) {
  12630. ___assert_fail(3640, 3672, 103, 3704);
  12631. }
  12632. i27 = (HEAP32[i9 + 16 >> 2] | 0) + (i15 << 3) | 0;
  12633. d23 = +HEAPF32[i27 >> 2];
  12634. d24 = +HEAPF32[i27 + 4 >> 2];
  12635. d24 = d13 * (d4 + (d3 * d23 - d2 * d24) - d11) + d14 * (d5 + (d2 * d23 + d3 * d24) - d6);
  12636. STACKTOP = i1;
  12637. return +d24;
  12638. } else if ((i19 | 0) == 0) {
  12639. d13 = +HEAPF32[i12 + 92 >> 2];
  12640. d14 = +HEAPF32[i12 + 96 >> 2];
  12641. d21 = d6 * d13 + d7 * d14;
  12642. d24 = d6 * d14 - d7 * d13;
  12643. d17 = -d13;
  12644. d23 = -d14;
  12645. d18 = d3 * d17 + d2 * d23;
  12646. d17 = d3 * d23 - d2 * d17;
  12647. i15 = HEAP32[i12 >> 2] | 0;
  12648. i16 = HEAP32[i15 + 16 >> 2] | 0;
  12649. i15 = i15 + 20 | 0;
  12650. i19 = HEAP32[i15 >> 2] | 0;
  12651. if ((i19 | 0) > 1) {
  12652. i25 = 0;
  12653. d23 = d24 * +HEAPF32[i16 + 4 >> 2] + d21 * +HEAPF32[i16 >> 2];
  12654. i26 = 1;
  12655. while (1) {
  12656. d20 = d21 * +HEAPF32[i16 + (i26 << 3) >> 2] + d24 * +HEAPF32[i16 + (i26 << 3) + 4 >> 2];
  12657. i22 = d20 > d23;
  12658. i25 = i22 ? i26 : i25;
  12659. i26 = i26 + 1 | 0;
  12660. if ((i26 | 0) == (i19 | 0)) {
  12661. break;
  12662. } else {
  12663. d23 = i22 ? d20 : d23;
  12664. }
  12665. }
  12666. } else {
  12667. i25 = 0;
  12668. }
  12669. HEAP32[i10 >> 2] = i25;
  12670. i19 = HEAP32[i12 + 4 >> 2] | 0;
  12671. i12 = HEAP32[i19 + 16 >> 2] | 0;
  12672. i19 = i19 + 20 | 0;
  12673. i25 = HEAP32[i19 >> 2] | 0;
  12674. if ((i25 | 0) > 1) {
  12675. i27 = 0;
  12676. d20 = d17 * +HEAPF32[i12 + 4 >> 2] + d18 * +HEAPF32[i12 >> 2];
  12677. i26 = 1;
  12678. while (1) {
  12679. d21 = d18 * +HEAPF32[i12 + (i26 << 3) >> 2] + d17 * +HEAPF32[i12 + (i26 << 3) + 4 >> 2];
  12680. i22 = d21 > d20;
  12681. i27 = i22 ? i26 : i27;
  12682. i26 = i26 + 1 | 0;
  12683. if ((i26 | 0) == (i25 | 0)) {
  12684. break;
  12685. } else {
  12686. d20 = i22 ? d21 : d20;
  12687. }
  12688. }
  12689. } else {
  12690. i27 = 0;
  12691. }
  12692. HEAP32[i9 >> 2] = i27;
  12693. i9 = HEAP32[i10 >> 2] | 0;
  12694. if (!((i9 | 0) > -1)) {
  12695. ___assert_fail(3640, 3672, 103, 3704);
  12696. }
  12697. if ((HEAP32[i15 >> 2] | 0) <= (i9 | 0)) {
  12698. ___assert_fail(3640, 3672, 103, 3704);
  12699. }
  12700. i26 = i16 + (i9 << 3) | 0;
  12701. d18 = +HEAPF32[i26 >> 2];
  12702. d17 = +HEAPF32[i26 + 4 >> 2];
  12703. if (!((i27 | 0) > -1)) {
  12704. ___assert_fail(3640, 3672, 103, 3704);
  12705. }
  12706. if ((HEAP32[i19 >> 2] | 0) <= (i27 | 0)) {
  12707. ___assert_fail(3640, 3672, 103, 3704);
  12708. }
  12709. i27 = i12 + (i27 << 3) | 0;
  12710. d23 = +HEAPF32[i27 >> 2];
  12711. d24 = +HEAPF32[i27 + 4 >> 2];
  12712. d24 = d13 * (d4 + (d3 * d23 - d2 * d24) - (d11 + (d6 * d18 - d7 * d17))) + d14 * (d5 + (d2 * d23 + d3 * d24) - (d8 + (d7 * d18 + d6 * d17)));
  12713. STACKTOP = i1;
  12714. return +d24;
  12715. } else if ((i19 | 0) == 2) {
  12716. d23 = +HEAPF32[i12 + 92 >> 2];
  12717. d13 = +HEAPF32[i12 + 96 >> 2];
  12718. d14 = d3 * d23 - d2 * d13;
  12719. d13 = d2 * d23 + d3 * d13;
  12720. d23 = +HEAPF32[i12 + 84 >> 2];
  12721. d24 = +HEAPF32[i12 + 88 >> 2];
  12722. d4 = d4 + (d3 * d23 - d2 * d24);
  12723. d2 = d5 + (d2 * d23 + d3 * d24);
  12724. d3 = -d14;
  12725. d24 = -d13;
  12726. d5 = d6 * d3 + d7 * d24;
  12727. d3 = d6 * d24 - d7 * d3;
  12728. HEAP32[i9 >> 2] = -1;
  12729. i22 = HEAP32[i12 >> 2] | 0;
  12730. i15 = HEAP32[i22 + 16 >> 2] | 0;
  12731. i22 = HEAP32[i22 + 20 >> 2] | 0;
  12732. if ((i22 | 0) > 1) {
  12733. i9 = 0;
  12734. d17 = d3 * +HEAPF32[i15 + 4 >> 2] + d5 * +HEAPF32[i15 >> 2];
  12735. i19 = 1;
  12736. while (1) {
  12737. d18 = d5 * +HEAPF32[i15 + (i19 << 3) >> 2] + d3 * +HEAPF32[i15 + (i19 << 3) + 4 >> 2];
  12738. i25 = d18 > d17;
  12739. i9 = i25 ? i19 : i9;
  12740. i19 = i19 + 1 | 0;
  12741. if ((i19 | 0) == (i22 | 0)) {
  12742. break;
  12743. } else {
  12744. d17 = i25 ? d18 : d17;
  12745. }
  12746. }
  12747. HEAP32[i10 >> 2] = i9;
  12748. if ((i9 | 0) > -1) {
  12749. i16 = i9;
  12750. } else {
  12751. ___assert_fail(3640, 3672, 103, 3704);
  12752. }
  12753. } else {
  12754. HEAP32[i10 >> 2] = 0;
  12755. i16 = 0;
  12756. }
  12757. i9 = HEAP32[i12 >> 2] | 0;
  12758. if ((HEAP32[i9 + 20 >> 2] | 0) <= (i16 | 0)) {
  12759. ___assert_fail(3640, 3672, 103, 3704);
  12760. }
  12761. i27 = (HEAP32[i9 + 16 >> 2] | 0) + (i16 << 3) | 0;
  12762. d23 = +HEAPF32[i27 >> 2];
  12763. d24 = +HEAPF32[i27 + 4 >> 2];
  12764. d24 = d14 * (d11 + (d6 * d23 - d7 * d24) - d4) + d13 * (d8 + (d7 * d23 + d6 * d24) - d2);
  12765. STACKTOP = i1;
  12766. return +d24;
  12767. } else {
  12768. ___assert_fail(3616, 3560, 183, 3720);
  12769. }
  12770. return 0.0;
  12771. }
  12772. function __ZN13b2DynamicTree10InsertLeafEi(i3, i4) {
  12773. i3 = i3 | 0;
  12774. i4 = i4 | 0;
  12775. var i1 = 0, i2 = 0, d5 = 0.0, d6 = 0.0, d7 = 0.0, d8 = 0.0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, d13 = 0.0, d14 = 0.0, d15 = 0.0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, d22 = 0.0, d23 = 0.0, i24 = 0;
  12776. i1 = STACKTOP;
  12777. i11 = i3 + 24 | 0;
  12778. HEAP32[i11 >> 2] = (HEAP32[i11 >> 2] | 0) + 1;
  12779. i11 = HEAP32[i3 >> 2] | 0;
  12780. if ((i11 | 0) == -1) {
  12781. HEAP32[i3 >> 2] = i4;
  12782. HEAP32[(HEAP32[i3 + 4 >> 2] | 0) + (i4 * 36 | 0) + 20 >> 2] = -1;
  12783. STACKTOP = i1;
  12784. return;
  12785. }
  12786. i2 = i3 + 4 | 0;
  12787. i9 = HEAP32[i2 >> 2] | 0;
  12788. d8 = +HEAPF32[i9 + (i4 * 36 | 0) >> 2];
  12789. d7 = +HEAPF32[i9 + (i4 * 36 | 0) + 4 >> 2];
  12790. d6 = +HEAPF32[i9 + (i4 * 36 | 0) + 8 >> 2];
  12791. d5 = +HEAPF32[i9 + (i4 * 36 | 0) + 12 >> 2];
  12792. i10 = HEAP32[i9 + (i11 * 36 | 0) + 24 >> 2] | 0;
  12793. L5 : do {
  12794. if (!((i10 | 0) == -1)) {
  12795. do {
  12796. i12 = HEAP32[i9 + (i11 * 36 | 0) + 28 >> 2] | 0;
  12797. d14 = +HEAPF32[i9 + (i11 * 36 | 0) + 8 >> 2];
  12798. d15 = +HEAPF32[i9 + (i11 * 36 | 0) >> 2];
  12799. d17 = +HEAPF32[i9 + (i11 * 36 | 0) + 12 >> 2];
  12800. d16 = +HEAPF32[i9 + (i11 * 36 | 0) + 4 >> 2];
  12801. d21 = ((d14 > d6 ? d14 : d6) - (d15 < d8 ? d15 : d8) + ((d17 > d5 ? d17 : d5) - (d16 < d7 ? d16 : d7))) * 2.0;
  12802. d13 = d21 * 2.0;
  12803. d14 = (d21 - (d14 - d15 + (d17 - d16)) * 2.0) * 2.0;
  12804. d21 = +HEAPF32[i9 + (i10 * 36 | 0) >> 2];
  12805. d16 = d8 < d21 ? d8 : d21;
  12806. d17 = +HEAPF32[i9 + (i10 * 36 | 0) + 4 >> 2];
  12807. d18 = d7 < d17 ? d7 : d17;
  12808. d19 = +HEAPF32[i9 + (i10 * 36 | 0) + 8 >> 2];
  12809. d20 = d6 > d19 ? d6 : d19;
  12810. d15 = +HEAPF32[i9 + (i10 * 36 | 0) + 12 >> 2];
  12811. d22 = d5 > d15 ? d5 : d15;
  12812. if ((HEAP32[i9 + (i10 * 36 | 0) + 24 >> 2] | 0) == -1) {
  12813. d15 = (d20 - d16 + (d22 - d18)) * 2.0;
  12814. } else {
  12815. d15 = (d20 - d16 + (d22 - d18)) * 2.0 - (d19 - d21 + (d15 - d17)) * 2.0;
  12816. }
  12817. d15 = d14 + d15;
  12818. d17 = +HEAPF32[i9 + (i12 * 36 | 0) >> 2];
  12819. d18 = d8 < d17 ? d8 : d17;
  12820. d23 = +HEAPF32[i9 + (i12 * 36 | 0) + 4 >> 2];
  12821. d22 = d7 < d23 ? d7 : d23;
  12822. d21 = +HEAPF32[i9 + (i12 * 36 | 0) + 8 >> 2];
  12823. d20 = d6 > d21 ? d6 : d21;
  12824. d19 = +HEAPF32[i9 + (i12 * 36 | 0) + 12 >> 2];
  12825. d16 = d5 > d19 ? d5 : d19;
  12826. if ((HEAP32[i9 + (i12 * 36 | 0) + 24 >> 2] | 0) == -1) {
  12827. d16 = (d20 - d18 + (d16 - d22)) * 2.0;
  12828. } else {
  12829. d16 = (d20 - d18 + (d16 - d22)) * 2.0 - (d21 - d17 + (d19 - d23)) * 2.0;
  12830. }
  12831. d14 = d14 + d16;
  12832. if (d13 < d15 & d13 < d14) {
  12833. break L5;
  12834. }
  12835. i11 = d15 < d14 ? i10 : i12;
  12836. i10 = HEAP32[i9 + (i11 * 36 | 0) + 24 >> 2] | 0;
  12837. } while (!((i10 | 0) == -1));
  12838. }
  12839. } while (0);
  12840. i9 = HEAP32[i9 + (i11 * 36 | 0) + 20 >> 2] | 0;
  12841. i10 = __ZN13b2DynamicTree12AllocateNodeEv(i3) | 0;
  12842. i12 = HEAP32[i2 >> 2] | 0;
  12843. HEAP32[i12 + (i10 * 36 | 0) + 20 >> 2] = i9;
  12844. HEAP32[i12 + (i10 * 36 | 0) + 16 >> 2] = 0;
  12845. i12 = HEAP32[i2 >> 2] | 0;
  12846. d14 = +HEAPF32[i12 + (i11 * 36 | 0) >> 2];
  12847. d13 = +HEAPF32[i12 + (i11 * 36 | 0) + 4 >> 2];
  12848. d8 = +(d8 < d14 ? d8 : d14);
  12849. d7 = +(d7 < d13 ? d7 : d13);
  12850. i24 = i12 + (i10 * 36 | 0) | 0;
  12851. HEAPF32[i24 >> 2] = d8;
  12852. HEAPF32[i24 + 4 >> 2] = d7;
  12853. d8 = +HEAPF32[i12 + (i11 * 36 | 0) + 8 >> 2];
  12854. d7 = +HEAPF32[i12 + (i11 * 36 | 0) + 12 >> 2];
  12855. d6 = +(d6 > d8 ? d6 : d8);
  12856. d23 = +(d5 > d7 ? d5 : d7);
  12857. i12 = i12 + (i10 * 36 | 0) + 8 | 0;
  12858. HEAPF32[i12 >> 2] = d6;
  12859. HEAPF32[i12 + 4 >> 2] = d23;
  12860. i12 = HEAP32[i2 >> 2] | 0;
  12861. HEAP32[i12 + (i10 * 36 | 0) + 32 >> 2] = (HEAP32[i12 + (i11 * 36 | 0) + 32 >> 2] | 0) + 1;
  12862. if ((i9 | 0) == -1) {
  12863. HEAP32[i12 + (i10 * 36 | 0) + 24 >> 2] = i11;
  12864. HEAP32[i12 + (i10 * 36 | 0) + 28 >> 2] = i4;
  12865. HEAP32[i12 + (i11 * 36 | 0) + 20 >> 2] = i10;
  12866. i24 = i12 + (i4 * 36 | 0) + 20 | 0;
  12867. HEAP32[i24 >> 2] = i10;
  12868. HEAP32[i3 >> 2] = i10;
  12869. i10 = HEAP32[i24 >> 2] | 0;
  12870. } else {
  12871. i24 = i12 + (i9 * 36 | 0) + 24 | 0;
  12872. if ((HEAP32[i24 >> 2] | 0) == (i11 | 0)) {
  12873. HEAP32[i24 >> 2] = i10;
  12874. } else {
  12875. HEAP32[i12 + (i9 * 36 | 0) + 28 >> 2] = i10;
  12876. }
  12877. HEAP32[i12 + (i10 * 36 | 0) + 24 >> 2] = i11;
  12878. HEAP32[i12 + (i10 * 36 | 0) + 28 >> 2] = i4;
  12879. HEAP32[i12 + (i11 * 36 | 0) + 20 >> 2] = i10;
  12880. HEAP32[i12 + (i4 * 36 | 0) + 20 >> 2] = i10;
  12881. }
  12882. if ((i10 | 0) == -1) {
  12883. STACKTOP = i1;
  12884. return;
  12885. }
  12886. while (1) {
  12887. i9 = __ZN13b2DynamicTree7BalanceEi(i3, i10) | 0;
  12888. i4 = HEAP32[i2 >> 2] | 0;
  12889. i11 = HEAP32[i4 + (i9 * 36 | 0) + 24 >> 2] | 0;
  12890. i10 = HEAP32[i4 + (i9 * 36 | 0) + 28 >> 2] | 0;
  12891. if ((i11 | 0) == -1) {
  12892. i2 = 20;
  12893. break;
  12894. }
  12895. if ((i10 | 0) == -1) {
  12896. i2 = 22;
  12897. break;
  12898. }
  12899. i12 = HEAP32[i4 + (i11 * 36 | 0) + 32 >> 2] | 0;
  12900. i24 = HEAP32[i4 + (i10 * 36 | 0) + 32 >> 2] | 0;
  12901. HEAP32[i4 + (i9 * 36 | 0) + 32 >> 2] = ((i12 | 0) > (i24 | 0) ? i12 : i24) + 1;
  12902. d7 = +HEAPF32[i4 + (i11 * 36 | 0) >> 2];
  12903. d8 = +HEAPF32[i4 + (i10 * 36 | 0) >> 2];
  12904. d5 = +HEAPF32[i4 + (i11 * 36 | 0) + 4 >> 2];
  12905. d6 = +HEAPF32[i4 + (i10 * 36 | 0) + 4 >> 2];
  12906. d7 = +(d7 < d8 ? d7 : d8);
  12907. d5 = +(d5 < d6 ? d5 : d6);
  12908. i24 = i4 + (i9 * 36 | 0) | 0;
  12909. HEAPF32[i24 >> 2] = d7;
  12910. HEAPF32[i24 + 4 >> 2] = d5;
  12911. d5 = +HEAPF32[i4 + (i11 * 36 | 0) + 8 >> 2];
  12912. d6 = +HEAPF32[i4 + (i10 * 36 | 0) + 8 >> 2];
  12913. d7 = +HEAPF32[i4 + (i11 * 36 | 0) + 12 >> 2];
  12914. d8 = +HEAPF32[i4 + (i10 * 36 | 0) + 12 >> 2];
  12915. d5 = +(d5 > d6 ? d5 : d6);
  12916. d23 = +(d7 > d8 ? d7 : d8);
  12917. i10 = i4 + (i9 * 36 | 0) + 8 | 0;
  12918. HEAPF32[i10 >> 2] = d5;
  12919. HEAPF32[i10 + 4 >> 2] = d23;
  12920. i10 = HEAP32[(HEAP32[i2 >> 2] | 0) + (i9 * 36 | 0) + 20 >> 2] | 0;
  12921. if ((i10 | 0) == -1) {
  12922. i2 = 24;
  12923. break;
  12924. }
  12925. }
  12926. if ((i2 | 0) == 20) {
  12927. ___assert_fail(3168, 2944, 307, 3184);
  12928. } else if ((i2 | 0) == 22) {
  12929. ___assert_fail(3200, 2944, 308, 3184);
  12930. } else if ((i2 | 0) == 24) {
  12931. STACKTOP = i1;
  12932. return;
  12933. }
  12934. }
  12935. function __ZN15b2ContactSolverC2EP18b2ContactSolverDef(i7, i5) {
  12936. i7 = i7 | 0;
  12937. i5 = i5 | 0;
  12938. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, d15 = 0.0, d16 = 0.0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0;
  12939. i1 = STACKTOP;
  12940. HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  12941. HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  12942. HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  12943. HEAP32[i7 + 12 >> 2] = HEAP32[i5 + 12 >> 2];
  12944. HEAP32[i7 + 16 >> 2] = HEAP32[i5 + 16 >> 2];
  12945. HEAP32[i7 + 20 >> 2] = HEAP32[i5 + 20 >> 2];
  12946. i14 = HEAP32[i5 + 40 >> 2] | 0;
  12947. i9 = i7 + 32 | 0;
  12948. HEAP32[i9 >> 2] = i14;
  12949. i2 = HEAP32[i5 + 28 >> 2] | 0;
  12950. i4 = i7 + 48 | 0;
  12951. HEAP32[i4 >> 2] = i2;
  12952. i3 = i7 + 36 | 0;
  12953. HEAP32[i3 >> 2] = __ZN16b2StackAllocator8AllocateEi(i14, i2 * 88 | 0) | 0;
  12954. i2 = i7 + 40 | 0;
  12955. HEAP32[i2 >> 2] = __ZN16b2StackAllocator8AllocateEi(HEAP32[i9 >> 2] | 0, (HEAP32[i4 >> 2] | 0) * 152 | 0) | 0;
  12956. HEAP32[i7 + 24 >> 2] = HEAP32[i5 + 32 >> 2];
  12957. HEAP32[i7 + 28 >> 2] = HEAP32[i5 + 36 >> 2];
  12958. i9 = HEAP32[i5 + 24 >> 2] | 0;
  12959. i5 = i7 + 44 | 0;
  12960. HEAP32[i5 >> 2] = i9;
  12961. if ((HEAP32[i4 >> 2] | 0) <= 0) {
  12962. STACKTOP = i1;
  12963. return;
  12964. }
  12965. i6 = i7 + 20 | 0;
  12966. i7 = i7 + 8 | 0;
  12967. i8 = 0;
  12968. while (1) {
  12969. i10 = HEAP32[i9 + (i8 << 2) >> 2] | 0;
  12970. i11 = HEAP32[i10 + 48 >> 2] | 0;
  12971. i12 = HEAP32[i10 + 52 >> 2] | 0;
  12972. i14 = HEAP32[i11 + 8 >> 2] | 0;
  12973. i13 = HEAP32[i12 + 8 >> 2] | 0;
  12974. i9 = HEAP32[i10 + 124 >> 2] | 0;
  12975. if ((i9 | 0) <= 0) {
  12976. i2 = 4;
  12977. break;
  12978. }
  12979. d15 = +HEAPF32[(HEAP32[i12 + 12 >> 2] | 0) + 8 >> 2];
  12980. d16 = +HEAPF32[(HEAP32[i11 + 12 >> 2] | 0) + 8 >> 2];
  12981. i12 = HEAP32[i2 >> 2] | 0;
  12982. HEAPF32[i12 + (i8 * 152 | 0) + 136 >> 2] = +HEAPF32[i10 + 136 >> 2];
  12983. HEAPF32[i12 + (i8 * 152 | 0) + 140 >> 2] = +HEAPF32[i10 + 140 >> 2];
  12984. i22 = i14 + 8 | 0;
  12985. HEAP32[i12 + (i8 * 152 | 0) + 112 >> 2] = HEAP32[i22 >> 2];
  12986. i21 = i13 + 8 | 0;
  12987. HEAP32[i12 + (i8 * 152 | 0) + 116 >> 2] = HEAP32[i21 >> 2];
  12988. i19 = i14 + 120 | 0;
  12989. HEAPF32[i12 + (i8 * 152 | 0) + 120 >> 2] = +HEAPF32[i19 >> 2];
  12990. i20 = i13 + 120 | 0;
  12991. HEAPF32[i12 + (i8 * 152 | 0) + 124 >> 2] = +HEAPF32[i20 >> 2];
  12992. i18 = i14 + 128 | 0;
  12993. HEAPF32[i12 + (i8 * 152 | 0) + 128 >> 2] = +HEAPF32[i18 >> 2];
  12994. i17 = i13 + 128 | 0;
  12995. HEAPF32[i12 + (i8 * 152 | 0) + 132 >> 2] = +HEAPF32[i17 >> 2];
  12996. HEAP32[i12 + (i8 * 152 | 0) + 148 >> 2] = i8;
  12997. HEAP32[i12 + (i8 * 152 | 0) + 144 >> 2] = i9;
  12998. i11 = i12 + (i8 * 152 | 0) + 80 | 0;
  12999. HEAP32[i11 + 0 >> 2] = 0;
  13000. HEAP32[i11 + 4 >> 2] = 0;
  13001. HEAP32[i11 + 8 >> 2] = 0;
  13002. HEAP32[i11 + 12 >> 2] = 0;
  13003. HEAP32[i11 + 16 >> 2] = 0;
  13004. HEAP32[i11 + 20 >> 2] = 0;
  13005. HEAP32[i11 + 24 >> 2] = 0;
  13006. HEAP32[i11 + 28 >> 2] = 0;
  13007. i11 = HEAP32[i3 >> 2] | 0;
  13008. HEAP32[i11 + (i8 * 88 | 0) + 32 >> 2] = HEAP32[i22 >> 2];
  13009. HEAP32[i11 + (i8 * 88 | 0) + 36 >> 2] = HEAP32[i21 >> 2];
  13010. HEAPF32[i11 + (i8 * 88 | 0) + 40 >> 2] = +HEAPF32[i19 >> 2];
  13011. HEAPF32[i11 + (i8 * 88 | 0) + 44 >> 2] = +HEAPF32[i20 >> 2];
  13012. i20 = i14 + 28 | 0;
  13013. i14 = HEAP32[i20 + 4 >> 2] | 0;
  13014. i19 = i11 + (i8 * 88 | 0) + 48 | 0;
  13015. HEAP32[i19 >> 2] = HEAP32[i20 >> 2];
  13016. HEAP32[i19 + 4 >> 2] = i14;
  13017. i19 = i13 + 28 | 0;
  13018. i14 = HEAP32[i19 + 4 >> 2] | 0;
  13019. i13 = i11 + (i8 * 88 | 0) + 56 | 0;
  13020. HEAP32[i13 >> 2] = HEAP32[i19 >> 2];
  13021. HEAP32[i13 + 4 >> 2] = i14;
  13022. HEAPF32[i11 + (i8 * 88 | 0) + 64 >> 2] = +HEAPF32[i18 >> 2];
  13023. HEAPF32[i11 + (i8 * 88 | 0) + 68 >> 2] = +HEAPF32[i17 >> 2];
  13024. i13 = i10 + 104 | 0;
  13025. i14 = HEAP32[i13 + 4 >> 2] | 0;
  13026. i17 = i11 + (i8 * 88 | 0) + 16 | 0;
  13027. HEAP32[i17 >> 2] = HEAP32[i13 >> 2];
  13028. HEAP32[i17 + 4 >> 2] = i14;
  13029. i17 = i10 + 112 | 0;
  13030. i14 = HEAP32[i17 + 4 >> 2] | 0;
  13031. i13 = i11 + (i8 * 88 | 0) + 24 | 0;
  13032. HEAP32[i13 >> 2] = HEAP32[i17 >> 2];
  13033. HEAP32[i13 + 4 >> 2] = i14;
  13034. HEAP32[i11 + (i8 * 88 | 0) + 84 >> 2] = i9;
  13035. HEAPF32[i11 + (i8 * 88 | 0) + 76 >> 2] = d16;
  13036. HEAPF32[i11 + (i8 * 88 | 0) + 80 >> 2] = d15;
  13037. HEAP32[i11 + (i8 * 88 | 0) + 72 >> 2] = HEAP32[i10 + 120 >> 2];
  13038. i13 = 0;
  13039. do {
  13040. i14 = i10 + (i13 * 20 | 0) + 64 | 0;
  13041. if ((HEAP8[i6] | 0) == 0) {
  13042. HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 16 >> 2] = 0.0;
  13043. HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 20 >> 2] = 0.0;
  13044. } else {
  13045. HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 16 >> 2] = +HEAPF32[i7 >> 2] * +HEAPF32[i10 + (i13 * 20 | 0) + 72 >> 2];
  13046. HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 20 >> 2] = +HEAPF32[i7 >> 2] * +HEAPF32[i10 + (i13 * 20 | 0) + 76 >> 2];
  13047. }
  13048. i20 = i12 + (i8 * 152 | 0) + (i13 * 36 | 0) | 0;
  13049. HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 24 >> 2] = 0.0;
  13050. HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 28 >> 2] = 0.0;
  13051. HEAPF32[i12 + (i8 * 152 | 0) + (i13 * 36 | 0) + 32 >> 2] = 0.0;
  13052. i22 = i11 + (i8 * 88 | 0) + (i13 << 3) | 0;
  13053. HEAP32[i20 + 0 >> 2] = 0;
  13054. HEAP32[i20 + 4 >> 2] = 0;
  13055. HEAP32[i20 + 8 >> 2] = 0;
  13056. HEAP32[i20 + 12 >> 2] = 0;
  13057. i20 = i14;
  13058. i21 = HEAP32[i20 + 4 >> 2] | 0;
  13059. HEAP32[i22 >> 2] = HEAP32[i20 >> 2];
  13060. HEAP32[i22 + 4 >> 2] = i21;
  13061. i13 = i13 + 1 | 0;
  13062. } while ((i13 | 0) != (i9 | 0));
  13063. i8 = i8 + 1 | 0;
  13064. if ((i8 | 0) >= (HEAP32[i4 >> 2] | 0)) {
  13065. i2 = 12;
  13066. break;
  13067. }
  13068. i9 = HEAP32[i5 >> 2] | 0;
  13069. }
  13070. if ((i2 | 0) == 4) {
  13071. ___assert_fail(6504, 6520, 71, 6568);
  13072. } else if ((i2 | 0) == 12) {
  13073. STACKTOP = i1;
  13074. return;
  13075. }
  13076. }
  13077. function __Z25b2CollidePolygonAndCircleP10b2ManifoldPK14b2PolygonShapeRK11b2TransformPK13b2CircleShapeS6_(i1, i4, i11, i9, i10) {
  13078. i1 = i1 | 0;
  13079. i4 = i4 | 0;
  13080. i11 = i11 | 0;
  13081. i9 = i9 | 0;
  13082. i10 = i10 | 0;
  13083. var i2 = 0, i3 = 0, i5 = 0, d6 = 0.0, d7 = 0.0, d8 = 0.0, i12 = 0, d13 = 0.0, d14 = 0.0, i15 = 0, d16 = 0.0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, d21 = 0.0, i22 = 0;
  13084. i3 = STACKTOP;
  13085. i5 = i1 + 60 | 0;
  13086. HEAP32[i5 >> 2] = 0;
  13087. i2 = i9 + 12 | 0;
  13088. d20 = +HEAPF32[i10 + 12 >> 2];
  13089. d7 = +HEAPF32[i2 >> 2];
  13090. d6 = +HEAPF32[i10 + 8 >> 2];
  13091. d21 = +HEAPF32[i9 + 16 >> 2];
  13092. d8 = +HEAPF32[i10 >> 2] + (d20 * d7 - d6 * d21) - +HEAPF32[i11 >> 2];
  13093. d21 = d7 * d6 + d20 * d21 + +HEAPF32[i10 + 4 >> 2] - +HEAPF32[i11 + 4 >> 2];
  13094. d20 = +HEAPF32[i11 + 12 >> 2];
  13095. d6 = +HEAPF32[i11 + 8 >> 2];
  13096. d7 = d8 * d20 + d21 * d6;
  13097. d6 = d20 * d21 - d8 * d6;
  13098. d8 = +HEAPF32[i4 + 8 >> 2] + +HEAPF32[i9 + 8 >> 2];
  13099. i12 = HEAP32[i4 + 148 >> 2] | 0;
  13100. do {
  13101. if ((i12 | 0) > 0) {
  13102. i10 = 0;
  13103. i9 = 0;
  13104. d13 = -3.4028234663852886e+38;
  13105. while (1) {
  13106. d14 = (d7 - +HEAPF32[i4 + (i10 << 3) + 20 >> 2]) * +HEAPF32[i4 + (i10 << 3) + 84 >> 2] + (d6 - +HEAPF32[i4 + (i10 << 3) + 24 >> 2]) * +HEAPF32[i4 + (i10 << 3) + 88 >> 2];
  13107. if (d14 > d8) {
  13108. i10 = 19;
  13109. break;
  13110. }
  13111. i11 = d14 > d13;
  13112. d13 = i11 ? d14 : d13;
  13113. i9 = i11 ? i10 : i9;
  13114. i10 = i10 + 1 | 0;
  13115. if ((i10 | 0) >= (i12 | 0)) {
  13116. i10 = 4;
  13117. break;
  13118. }
  13119. }
  13120. if ((i10 | 0) == 4) {
  13121. i22 = d13 < 1.1920928955078125e-7;
  13122. break;
  13123. } else if ((i10 | 0) == 19) {
  13124. STACKTOP = i3;
  13125. return;
  13126. }
  13127. } else {
  13128. i9 = 0;
  13129. i22 = 1;
  13130. }
  13131. } while (0);
  13132. i15 = i9 + 1 | 0;
  13133. i11 = i4 + (i9 << 3) + 20 | 0;
  13134. i10 = HEAP32[i11 >> 2] | 0;
  13135. i11 = HEAP32[i11 + 4 >> 2] | 0;
  13136. d14 = (HEAP32[tempDoublePtr >> 2] = i10, +HEAPF32[tempDoublePtr >> 2]);
  13137. d13 = (HEAP32[tempDoublePtr >> 2] = i11, +HEAPF32[tempDoublePtr >> 2]);
  13138. i12 = i4 + (((i15 | 0) < (i12 | 0) ? i15 : 0) << 3) + 20 | 0;
  13139. i15 = HEAP32[i12 >> 2] | 0;
  13140. i12 = HEAP32[i12 + 4 >> 2] | 0;
  13141. d21 = (HEAP32[tempDoublePtr >> 2] = i15, +HEAPF32[tempDoublePtr >> 2]);
  13142. d18 = (HEAP32[tempDoublePtr >> 2] = i12, +HEAPF32[tempDoublePtr >> 2]);
  13143. if (i22) {
  13144. HEAP32[i5 >> 2] = 1;
  13145. HEAP32[i1 + 56 >> 2] = 1;
  13146. i22 = i4 + (i9 << 3) + 84 | 0;
  13147. i15 = HEAP32[i22 + 4 >> 2] | 0;
  13148. i12 = i1 + 40 | 0;
  13149. HEAP32[i12 >> 2] = HEAP32[i22 >> 2];
  13150. HEAP32[i12 + 4 >> 2] = i15;
  13151. d20 = +((d14 + d21) * .5);
  13152. d21 = +((d13 + d18) * .5);
  13153. i12 = i1 + 48 | 0;
  13154. HEAPF32[i12 >> 2] = d20;
  13155. HEAPF32[i12 + 4 >> 2] = d21;
  13156. i12 = i2;
  13157. i15 = HEAP32[i12 + 4 >> 2] | 0;
  13158. i22 = i1;
  13159. HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
  13160. HEAP32[i22 + 4 >> 2] = i15;
  13161. HEAP32[i1 + 16 >> 2] = 0;
  13162. STACKTOP = i3;
  13163. return;
  13164. }
  13165. d16 = d7 - d14;
  13166. d20 = d6 - d13;
  13167. d19 = d7 - d21;
  13168. d17 = d6 - d18;
  13169. if (d16 * (d21 - d14) + d20 * (d18 - d13) <= 0.0) {
  13170. if (d16 * d16 + d20 * d20 > d8 * d8) {
  13171. STACKTOP = i3;
  13172. return;
  13173. }
  13174. HEAP32[i5 >> 2] = 1;
  13175. HEAP32[i1 + 56 >> 2] = 1;
  13176. i4 = i1 + 40 | 0;
  13177. d21 = +d16;
  13178. d6 = +d20;
  13179. i22 = i4;
  13180. HEAPF32[i22 >> 2] = d21;
  13181. HEAPF32[i22 + 4 >> 2] = d6;
  13182. d6 = +Math_sqrt(+(d16 * d16 + d20 * d20));
  13183. if (!(d6 < 1.1920928955078125e-7)) {
  13184. d21 = 1.0 / d6;
  13185. HEAPF32[i4 >> 2] = d16 * d21;
  13186. HEAPF32[i1 + 44 >> 2] = d20 * d21;
  13187. }
  13188. i12 = i1 + 48 | 0;
  13189. HEAP32[i12 >> 2] = i10;
  13190. HEAP32[i12 + 4 >> 2] = i11;
  13191. i12 = i2;
  13192. i15 = HEAP32[i12 + 4 >> 2] | 0;
  13193. i22 = i1;
  13194. HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
  13195. HEAP32[i22 + 4 >> 2] = i15;
  13196. HEAP32[i1 + 16 >> 2] = 0;
  13197. STACKTOP = i3;
  13198. return;
  13199. }
  13200. if (!(d19 * (d14 - d21) + d17 * (d13 - d18) <= 0.0)) {
  13201. d14 = (d14 + d21) * .5;
  13202. d13 = (d13 + d18) * .5;
  13203. i10 = i4 + (i9 << 3) + 84 | 0;
  13204. if ((d7 - d14) * +HEAPF32[i10 >> 2] + (d6 - d13) * +HEAPF32[i4 + (i9 << 3) + 88 >> 2] > d8) {
  13205. STACKTOP = i3;
  13206. return;
  13207. }
  13208. HEAP32[i5 >> 2] = 1;
  13209. HEAP32[i1 + 56 >> 2] = 1;
  13210. i22 = i10;
  13211. i15 = HEAP32[i22 + 4 >> 2] | 0;
  13212. i12 = i1 + 40 | 0;
  13213. HEAP32[i12 >> 2] = HEAP32[i22 >> 2];
  13214. HEAP32[i12 + 4 >> 2] = i15;
  13215. d20 = +d14;
  13216. d21 = +d13;
  13217. i12 = i1 + 48 | 0;
  13218. HEAPF32[i12 >> 2] = d20;
  13219. HEAPF32[i12 + 4 >> 2] = d21;
  13220. i12 = i2;
  13221. i15 = HEAP32[i12 + 4 >> 2] | 0;
  13222. i22 = i1;
  13223. HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
  13224. HEAP32[i22 + 4 >> 2] = i15;
  13225. HEAP32[i1 + 16 >> 2] = 0;
  13226. STACKTOP = i3;
  13227. return;
  13228. }
  13229. if (d19 * d19 + d17 * d17 > d8 * d8) {
  13230. STACKTOP = i3;
  13231. return;
  13232. }
  13233. HEAP32[i5 >> 2] = 1;
  13234. HEAP32[i1 + 56 >> 2] = 1;
  13235. i4 = i1 + 40 | 0;
  13236. d21 = +d19;
  13237. d6 = +d17;
  13238. i22 = i4;
  13239. HEAPF32[i22 >> 2] = d21;
  13240. HEAPF32[i22 + 4 >> 2] = d6;
  13241. d6 = +Math_sqrt(+(d19 * d19 + d17 * d17));
  13242. if (!(d6 < 1.1920928955078125e-7)) {
  13243. d21 = 1.0 / d6;
  13244. HEAPF32[i4 >> 2] = d19 * d21;
  13245. HEAPF32[i1 + 44 >> 2] = d17 * d21;
  13246. }
  13247. i22 = i1 + 48 | 0;
  13248. HEAP32[i22 >> 2] = i15;
  13249. HEAP32[i22 + 4 >> 2] = i12;
  13250. i12 = i2;
  13251. i15 = HEAP32[i12 + 4 >> 2] | 0;
  13252. i22 = i1;
  13253. HEAP32[i22 >> 2] = HEAP32[i12 >> 2];
  13254. HEAP32[i22 + 4 >> 2] = i15;
  13255. HEAP32[i1 + 16 >> 2] = 0;
  13256. STACKTOP = i3;
  13257. return;
  13258. }
  13259. function __ZN15b2WorldManifold10InitializeEPK10b2ManifoldRK11b2TransformfS5_f(i1, i5, i7, d4, i8, d3) {
  13260. i1 = i1 | 0;
  13261. i5 = i5 | 0;
  13262. i7 = i7 | 0;
  13263. d4 = +d4;
  13264. i8 = i8 | 0;
  13265. d3 = +d3;
  13266. var i2 = 0, i6 = 0, d9 = 0.0, d10 = 0.0, i11 = 0, i12 = 0, i13 = 0, d14 = 0.0, d15 = 0.0, i16 = 0, d17 = 0.0, d18 = 0.0, d19 = 0.0, i20 = 0, d21 = 0.0, d22 = 0.0;
  13267. i2 = STACKTOP;
  13268. i6 = i5 + 60 | 0;
  13269. if ((HEAP32[i6 >> 2] | 0) == 0) {
  13270. STACKTOP = i2;
  13271. return;
  13272. }
  13273. i11 = HEAP32[i5 + 56 >> 2] | 0;
  13274. if ((i11 | 0) == 2) {
  13275. i13 = i8 + 12 | 0;
  13276. d17 = +HEAPF32[i13 >> 2];
  13277. d18 = +HEAPF32[i5 + 40 >> 2];
  13278. i16 = i8 + 8 | 0;
  13279. d19 = +HEAPF32[i16 >> 2];
  13280. d15 = +HEAPF32[i5 + 44 >> 2];
  13281. d14 = d17 * d18 - d19 * d15;
  13282. d15 = d18 * d19 + d17 * d15;
  13283. d17 = +d14;
  13284. d19 = +d15;
  13285. i12 = i1;
  13286. HEAPF32[i12 >> 2] = d17;
  13287. HEAPF32[i12 + 4 >> 2] = d19;
  13288. d19 = +HEAPF32[i13 >> 2];
  13289. d17 = +HEAPF32[i5 + 48 >> 2];
  13290. d18 = +HEAPF32[i16 >> 2];
  13291. d10 = +HEAPF32[i5 + 52 >> 2];
  13292. d9 = +HEAPF32[i8 >> 2] + (d19 * d17 - d18 * d10);
  13293. d10 = d17 * d18 + d19 * d10 + +HEAPF32[i8 + 4 >> 2];
  13294. if ((HEAP32[i6 >> 2] | 0) > 0) {
  13295. i8 = i7 + 12 | 0;
  13296. i11 = i7 + 8 | 0;
  13297. i12 = i7 + 4 | 0;
  13298. i13 = i1 + 4 | 0;
  13299. i16 = 0;
  13300. do {
  13301. d18 = +HEAPF32[i8 >> 2];
  13302. d22 = +HEAPF32[i5 + (i16 * 20 | 0) >> 2];
  13303. d21 = +HEAPF32[i11 >> 2];
  13304. d17 = +HEAPF32[i5 + (i16 * 20 | 0) + 4 >> 2];
  13305. d19 = +HEAPF32[i7 >> 2] + (d18 * d22 - d21 * d17);
  13306. d17 = d22 * d21 + d18 * d17 + +HEAPF32[i12 >> 2];
  13307. d18 = d3 - (d14 * (d19 - d9) + (d17 - d10) * d15);
  13308. d19 = +((d19 - d14 * d4 + (d19 + d14 * d18)) * .5);
  13309. d14 = +((d17 - d15 * d4 + (d17 + d15 * d18)) * .5);
  13310. i20 = i1 + (i16 << 3) + 8 | 0;
  13311. HEAPF32[i20 >> 2] = d19;
  13312. HEAPF32[i20 + 4 >> 2] = d14;
  13313. i16 = i16 + 1 | 0;
  13314. d14 = +HEAPF32[i1 >> 2];
  13315. d15 = +HEAPF32[i13 >> 2];
  13316. } while ((i16 | 0) < (HEAP32[i6 >> 2] | 0));
  13317. }
  13318. d21 = +-d14;
  13319. d22 = +-d15;
  13320. i20 = i1;
  13321. HEAPF32[i20 >> 2] = d21;
  13322. HEAPF32[i20 + 4 >> 2] = d22;
  13323. STACKTOP = i2;
  13324. return;
  13325. } else if ((i11 | 0) == 1) {
  13326. i16 = i7 + 12 | 0;
  13327. d19 = +HEAPF32[i16 >> 2];
  13328. d21 = +HEAPF32[i5 + 40 >> 2];
  13329. i20 = i7 + 8 | 0;
  13330. d22 = +HEAPF32[i20 >> 2];
  13331. d15 = +HEAPF32[i5 + 44 >> 2];
  13332. d14 = d19 * d21 - d22 * d15;
  13333. d15 = d21 * d22 + d19 * d15;
  13334. d19 = +d14;
  13335. d22 = +d15;
  13336. i13 = i1;
  13337. HEAPF32[i13 >> 2] = d19;
  13338. HEAPF32[i13 + 4 >> 2] = d22;
  13339. d22 = +HEAPF32[i16 >> 2];
  13340. d19 = +HEAPF32[i5 + 48 >> 2];
  13341. d21 = +HEAPF32[i20 >> 2];
  13342. d10 = +HEAPF32[i5 + 52 >> 2];
  13343. d9 = +HEAPF32[i7 >> 2] + (d22 * d19 - d21 * d10);
  13344. d10 = d19 * d21 + d22 * d10 + +HEAPF32[i7 + 4 >> 2];
  13345. if ((HEAP32[i6 >> 2] | 0) <= 0) {
  13346. STACKTOP = i2;
  13347. return;
  13348. }
  13349. i12 = i8 + 12 | 0;
  13350. i11 = i8 + 8 | 0;
  13351. i7 = i8 + 4 | 0;
  13352. i13 = i1 + 4 | 0;
  13353. i16 = 0;
  13354. while (1) {
  13355. d22 = +HEAPF32[i12 >> 2];
  13356. d17 = +HEAPF32[i5 + (i16 * 20 | 0) >> 2];
  13357. d18 = +HEAPF32[i11 >> 2];
  13358. d19 = +HEAPF32[i5 + (i16 * 20 | 0) + 4 >> 2];
  13359. d21 = +HEAPF32[i8 >> 2] + (d22 * d17 - d18 * d19);
  13360. d19 = d17 * d18 + d22 * d19 + +HEAPF32[i7 >> 2];
  13361. d22 = d4 - (d14 * (d21 - d9) + (d19 - d10) * d15);
  13362. d21 = +((d21 - d14 * d3 + (d21 + d14 * d22)) * .5);
  13363. d22 = +((d19 - d15 * d3 + (d19 + d15 * d22)) * .5);
  13364. i20 = i1 + (i16 << 3) + 8 | 0;
  13365. HEAPF32[i20 >> 2] = d21;
  13366. HEAPF32[i20 + 4 >> 2] = d22;
  13367. i16 = i16 + 1 | 0;
  13368. if ((i16 | 0) >= (HEAP32[i6 >> 2] | 0)) {
  13369. break;
  13370. }
  13371. d14 = +HEAPF32[i1 >> 2];
  13372. d15 = +HEAPF32[i13 >> 2];
  13373. }
  13374. STACKTOP = i2;
  13375. return;
  13376. } else if ((i11 | 0) == 0) {
  13377. HEAPF32[i1 >> 2] = 1.0;
  13378. i6 = i1 + 4 | 0;
  13379. HEAPF32[i6 >> 2] = 0.0;
  13380. d21 = +HEAPF32[i7 + 12 >> 2];
  13381. d22 = +HEAPF32[i5 + 48 >> 2];
  13382. d19 = +HEAPF32[i7 + 8 >> 2];
  13383. d10 = +HEAPF32[i5 + 52 >> 2];
  13384. d9 = +HEAPF32[i7 >> 2] + (d21 * d22 - d19 * d10);
  13385. d10 = d22 * d19 + d21 * d10 + +HEAPF32[i7 + 4 >> 2];
  13386. d21 = +HEAPF32[i8 + 12 >> 2];
  13387. d19 = +HEAPF32[i5 >> 2];
  13388. d22 = +HEAPF32[i8 + 8 >> 2];
  13389. d15 = +HEAPF32[i5 + 4 >> 2];
  13390. d14 = +HEAPF32[i8 >> 2] + (d21 * d19 - d22 * d15);
  13391. d15 = d19 * d22 + d21 * d15 + +HEAPF32[i8 + 4 >> 2];
  13392. d21 = d9 - d14;
  13393. d22 = d10 - d15;
  13394. if (d21 * d21 + d22 * d22 > 1.4210854715202004e-14) {
  13395. d19 = d14 - d9;
  13396. d17 = d15 - d10;
  13397. d22 = +d19;
  13398. d18 = +d17;
  13399. i20 = i1;
  13400. HEAPF32[i20 >> 2] = d22;
  13401. HEAPF32[i20 + 4 >> 2] = d18;
  13402. d18 = +Math_sqrt(+(d19 * d19 + d17 * d17));
  13403. if (!(d18 < 1.1920928955078125e-7)) {
  13404. d22 = 1.0 / d18;
  13405. d19 = d19 * d22;
  13406. HEAPF32[i1 >> 2] = d19;
  13407. d17 = d17 * d22;
  13408. HEAPF32[i6 >> 2] = d17;
  13409. }
  13410. } else {
  13411. d19 = 1.0;
  13412. d17 = 0.0;
  13413. }
  13414. d21 = +((d9 + d19 * d4 + (d14 - d19 * d3)) * .5);
  13415. d22 = +((d10 + d17 * d4 + (d15 - d17 * d3)) * .5);
  13416. i20 = i1 + 8 | 0;
  13417. HEAPF32[i20 >> 2] = d21;
  13418. HEAPF32[i20 + 4 >> 2] = d22;
  13419. STACKTOP = i2;
  13420. return;
  13421. } else {
  13422. STACKTOP = i2;
  13423. return;
  13424. }
  13425. }
  13426. function _main(i3, i2) {
  13427. i3 = i3 | 0;
  13428. i2 = i2 | 0;
  13429. var i1 = 0, i4 = 0, i5 = 0, d6 = 0.0, d7 = 0.0, i8 = 0, i9 = 0, d10 = 0.0, d11 = 0.0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, d22 = 0.0, d23 = 0.0;
  13430. i1 = STACKTOP;
  13431. STACKTOP = STACKTOP + 240 | 0;
  13432. i5 = i1;
  13433. i12 = i1 + 224 | 0;
  13434. i4 = i1 + 168 | 0;
  13435. i9 = i1 + 160 | 0;
  13436. i8 = i1 + 152 | 0;
  13437. L1 : do {
  13438. if ((i3 | 0) > 1) {
  13439. i14 = HEAP8[HEAP32[i2 + 4 >> 2] | 0] | 0;
  13440. switch (i14 | 0) {
  13441. case 49:
  13442. {
  13443. HEAP32[2] = 5;
  13444. HEAP32[4] = 35;
  13445. i15 = 35;
  13446. i14 = 5;
  13447. break L1;
  13448. }
  13449. case 50:
  13450. {
  13451. HEAP32[2] = 32;
  13452. HEAP32[4] = 161;
  13453. i15 = 161;
  13454. i14 = 32;
  13455. break L1;
  13456. }
  13457. case 51:
  13458. {
  13459. i13 = 5;
  13460. break L1;
  13461. }
  13462. case 52:
  13463. {
  13464. HEAP32[2] = 320;
  13465. HEAP32[4] = 2331;
  13466. i15 = 2331;
  13467. i14 = 320;
  13468. break L1;
  13469. }
  13470. case 53:
  13471. {
  13472. HEAP32[2] = 640;
  13473. HEAP32[4] = 5661;
  13474. i15 = 5661;
  13475. i14 = 640;
  13476. break L1;
  13477. }
  13478. case 48:
  13479. {
  13480. i20 = 0;
  13481. STACKTOP = i1;
  13482. return i20 | 0;
  13483. }
  13484. default:
  13485. {
  13486. HEAP32[i5 >> 2] = i14 + -48;
  13487. _printf(80, i5 | 0) | 0;
  13488. i20 = -1;
  13489. STACKTOP = i1;
  13490. return i20 | 0;
  13491. }
  13492. }
  13493. } else {
  13494. i13 = 5;
  13495. }
  13496. } while (0);
  13497. if ((i13 | 0) == 5) {
  13498. HEAP32[2] = 64;
  13499. HEAP32[4] = 333;
  13500. i15 = 333;
  13501. i14 = 64;
  13502. }
  13503. i13 = i15 + i14 | 0;
  13504. HEAP32[4] = i13;
  13505. HEAP32[2] = 0;
  13506. HEAP32[8] = __Znaj(i13 >>> 0 > 1073741823 ? -1 : i13 << 2) | 0;
  13507. HEAPF32[i12 >> 2] = 0.0;
  13508. HEAPF32[i12 + 4 >> 2] = -10.0;
  13509. i15 = __Znwj(103028) | 0;
  13510. __ZN7b2WorldC2ERK6b2Vec2(i15, i12);
  13511. HEAP32[6] = i15;
  13512. __ZN7b2World16SetAllowSleepingEb(i15, 0);
  13513. HEAP32[i5 + 44 >> 2] = 0;
  13514. i15 = i5 + 4 | 0;
  13515. i14 = i5 + 36 | 0;
  13516. HEAP32[i15 + 0 >> 2] = 0;
  13517. HEAP32[i15 + 4 >> 2] = 0;
  13518. HEAP32[i15 + 8 >> 2] = 0;
  13519. HEAP32[i15 + 12 >> 2] = 0;
  13520. HEAP32[i15 + 16 >> 2] = 0;
  13521. HEAP32[i15 + 20 >> 2] = 0;
  13522. HEAP32[i15 + 24 >> 2] = 0;
  13523. HEAP32[i15 + 28 >> 2] = 0;
  13524. HEAP8[i14] = 1;
  13525. HEAP8[i5 + 37 | 0] = 1;
  13526. HEAP8[i5 + 38 | 0] = 0;
  13527. HEAP8[i5 + 39 | 0] = 0;
  13528. HEAP32[i5 >> 2] = 0;
  13529. HEAP8[i5 + 40 | 0] = 1;
  13530. HEAPF32[i5 + 48 >> 2] = 1.0;
  13531. i14 = __ZN7b2World10CreateBodyEPK9b2BodyDef(HEAP32[6] | 0, i5) | 0;
  13532. HEAP32[i4 >> 2] = 240;
  13533. HEAP32[i4 + 4 >> 2] = 1;
  13534. HEAPF32[i4 + 8 >> 2] = .009999999776482582;
  13535. i15 = i4 + 28 | 0;
  13536. HEAP32[i15 + 0 >> 2] = 0;
  13537. HEAP32[i15 + 4 >> 2] = 0;
  13538. HEAP32[i15 + 8 >> 2] = 0;
  13539. HEAP32[i15 + 12 >> 2] = 0;
  13540. HEAP16[i15 + 16 >> 1] = 0;
  13541. HEAPF32[i9 >> 2] = -40.0;
  13542. HEAPF32[i9 + 4 >> 2] = 0.0;
  13543. HEAPF32[i8 >> 2] = 40.0;
  13544. HEAPF32[i8 + 4 >> 2] = 0.0;
  13545. __ZN11b2EdgeShape3SetERK6b2Vec2S2_(i4, i9, i8);
  13546. __ZN6b2Body13CreateFixtureEPK7b2Shapef(i14, i4, 0.0) | 0;
  13547. HEAP32[i5 >> 2] = 504;
  13548. HEAP32[i5 + 4 >> 2] = 2;
  13549. HEAPF32[i5 + 8 >> 2] = .009999999776482582;
  13550. HEAP32[i5 + 148 >> 2] = 0;
  13551. HEAPF32[i5 + 12 >> 2] = 0.0;
  13552. HEAPF32[i5 + 16 >> 2] = 0.0;
  13553. __ZN14b2PolygonShape8SetAsBoxEff(i5, .5, .5);
  13554. i14 = i4 + 44 | 0;
  13555. i15 = i4 + 4 | 0;
  13556. i8 = i4 + 36 | 0;
  13557. i17 = i4 + 37 | 0;
  13558. i18 = i4 + 38 | 0;
  13559. i19 = i4 + 39 | 0;
  13560. i20 = i4 + 40 | 0;
  13561. i13 = i4 + 48 | 0;
  13562. i12 = i4 + 4 | 0;
  13563. d11 = -7.0;
  13564. d10 = .75;
  13565. i9 = 0;
  13566. while (1) {
  13567. d7 = d11;
  13568. d6 = d10;
  13569. i16 = i9;
  13570. while (1) {
  13571. HEAP32[i14 >> 2] = 0;
  13572. HEAP32[i15 + 0 >> 2] = 0;
  13573. HEAP32[i15 + 4 >> 2] = 0;
  13574. HEAP32[i15 + 8 >> 2] = 0;
  13575. HEAP32[i15 + 12 >> 2] = 0;
  13576. HEAP32[i15 + 16 >> 2] = 0;
  13577. HEAP32[i15 + 20 >> 2] = 0;
  13578. HEAP32[i15 + 24 >> 2] = 0;
  13579. HEAP32[i15 + 28 >> 2] = 0;
  13580. HEAP8[i8] = 1;
  13581. HEAP8[i17] = 1;
  13582. HEAP8[i18] = 0;
  13583. HEAP8[i19] = 0;
  13584. HEAP8[i20] = 1;
  13585. HEAPF32[i13 >> 2] = 1.0;
  13586. HEAP32[i4 >> 2] = 2;
  13587. d23 = +d7;
  13588. d22 = +d6;
  13589. i21 = i12;
  13590. HEAPF32[i21 >> 2] = d23;
  13591. HEAPF32[i21 + 4 >> 2] = d22;
  13592. i21 = __ZN7b2World10CreateBodyEPK9b2BodyDef(HEAP32[6] | 0, i4) | 0;
  13593. __ZN6b2Body13CreateFixtureEPK7b2Shapef(i21, i5, 5.0) | 0;
  13594. HEAP32[14] = i21;
  13595. i16 = i16 + 1 | 0;
  13596. if ((i16 | 0) >= 40) {
  13597. break;
  13598. } else {
  13599. d7 = d7 + 1.125;
  13600. d6 = d6 + 0.0;
  13601. }
  13602. }
  13603. i9 = i9 + 1 | 0;
  13604. if ((i9 | 0) >= 40) {
  13605. break;
  13606. } else {
  13607. d11 = d11 + .5625;
  13608. d10 = d10 + 1.0;
  13609. }
  13610. }
  13611. if ((HEAP32[2] | 0) > 0) {
  13612. i4 = 0;
  13613. do {
  13614. __ZN7b2World4StepEfii(HEAP32[6] | 0, .01666666753590107, 3, 3);
  13615. i4 = i4 + 1 | 0;
  13616. } while ((i4 | 0) < (HEAP32[2] | 0));
  13617. }
  13618. if ((i3 | 0) > 2) {
  13619. i21 = (HEAP8[HEAP32[i2 + 8 >> 2] | 0] | 0) + -48 | 0;
  13620. HEAP32[18] = i21;
  13621. if ((i21 | 0) != 0) {
  13622. _puts(208) | 0;
  13623. _emscripten_set_main_loop(2, 60, 1);
  13624. i21 = 0;
  13625. STACKTOP = i1;
  13626. return i21 | 0;
  13627. }
  13628. } else {
  13629. HEAP32[18] = 0;
  13630. }
  13631. while (1) {
  13632. __Z4iterv();
  13633. if ((HEAP32[16] | 0) > (HEAP32[4] | 0)) {
  13634. i2 = 0;
  13635. break;
  13636. }
  13637. }
  13638. STACKTOP = i1;
  13639. return i2 | 0;
  13640. }
  13641. function __ZN9b2Simplex9ReadCacheEPK14b2SimplexCachePK15b2DistanceProxyRK11b2TransformS5_S8_(i2, i11, i10, i4, i3, i5) {
  13642. i2 = i2 | 0;
  13643. i11 = i11 | 0;
  13644. i10 = i10 | 0;
  13645. i4 = i4 | 0;
  13646. i3 = i3 | 0;
  13647. i5 = i5 | 0;
  13648. var i1 = 0, i6 = 0, i7 = 0, d8 = 0.0, i9 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, i21 = 0, i22 = 0, i23 = 0, d24 = 0.0, d25 = 0.0, i26 = 0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, d32 = 0.0;
  13649. i1 = STACKTOP;
  13650. i13 = HEAP16[i11 + 4 >> 1] | 0;
  13651. if (!((i13 & 65535) < 4)) {
  13652. ___assert_fail(2872, 2672, 102, 2896);
  13653. }
  13654. i12 = i13 & 65535;
  13655. i6 = i2 + 108 | 0;
  13656. HEAP32[i6 >> 2] = i12;
  13657. L4 : do {
  13658. if (!(i13 << 16 >> 16 == 0)) {
  13659. i17 = i10 + 20 | 0;
  13660. i21 = i10 + 16 | 0;
  13661. i13 = i3 + 20 | 0;
  13662. i14 = i3 + 16 | 0;
  13663. i15 = i4 + 12 | 0;
  13664. i16 = i4 + 8 | 0;
  13665. i12 = i4 + 4 | 0;
  13666. i18 = i5 + 12 | 0;
  13667. i19 = i5 + 8 | 0;
  13668. i20 = i5 + 4 | 0;
  13669. i22 = 0;
  13670. while (1) {
  13671. i26 = HEAPU8[i11 + i22 + 6 | 0] | 0;
  13672. HEAP32[i2 + (i22 * 36 | 0) + 28 >> 2] = i26;
  13673. i23 = HEAPU8[i11 + i22 + 9 | 0] | 0;
  13674. HEAP32[i2 + (i22 * 36 | 0) + 32 >> 2] = i23;
  13675. if ((HEAP32[i17 >> 2] | 0) <= (i26 | 0)) {
  13676. i9 = 6;
  13677. break;
  13678. }
  13679. i26 = (HEAP32[i21 >> 2] | 0) + (i26 << 3) | 0;
  13680. d25 = +HEAPF32[i26 >> 2];
  13681. d24 = +HEAPF32[i26 + 4 >> 2];
  13682. if ((HEAP32[i13 >> 2] | 0) <= (i23 | 0)) {
  13683. i9 = 8;
  13684. break;
  13685. }
  13686. i23 = (HEAP32[i14 >> 2] | 0) + (i23 << 3) | 0;
  13687. d29 = +HEAPF32[i23 >> 2];
  13688. d31 = +HEAPF32[i23 + 4 >> 2];
  13689. d32 = +HEAPF32[i15 >> 2];
  13690. d30 = +HEAPF32[i16 >> 2];
  13691. d27 = +HEAPF32[i4 >> 2] + (d25 * d32 - d24 * d30);
  13692. d28 = +d27;
  13693. d30 = +(d24 * d32 + d25 * d30 + +HEAPF32[i12 >> 2]);
  13694. i23 = i2 + (i22 * 36 | 0) | 0;
  13695. HEAPF32[i23 >> 2] = d28;
  13696. HEAPF32[i23 + 4 >> 2] = d30;
  13697. d30 = +HEAPF32[i18 >> 2];
  13698. d25 = +HEAPF32[i19 >> 2];
  13699. d24 = +HEAPF32[i5 >> 2] + (d29 * d30 - d31 * d25);
  13700. d28 = +d24;
  13701. d25 = +(d31 * d30 + d29 * d25 + +HEAPF32[i20 >> 2]);
  13702. i23 = i2 + (i22 * 36 | 0) + 8 | 0;
  13703. HEAPF32[i23 >> 2] = d28;
  13704. HEAPF32[i23 + 4 >> 2] = d25;
  13705. d24 = +(d24 - d27);
  13706. d25 = +(+HEAPF32[i2 + (i22 * 36 | 0) + 12 >> 2] - +HEAPF32[i2 + (i22 * 36 | 0) + 4 >> 2]);
  13707. i23 = i2 + (i22 * 36 | 0) + 16 | 0;
  13708. HEAPF32[i23 >> 2] = d24;
  13709. HEAPF32[i23 + 4 >> 2] = d25;
  13710. HEAPF32[i2 + (i22 * 36 | 0) + 24 >> 2] = 0.0;
  13711. i22 = i22 + 1 | 0;
  13712. i23 = HEAP32[i6 >> 2] | 0;
  13713. if ((i22 | 0) >= (i23 | 0)) {
  13714. i7 = i23;
  13715. break L4;
  13716. }
  13717. }
  13718. if ((i9 | 0) == 6) {
  13719. ___assert_fail(2776, 2808, 103, 2840);
  13720. } else if ((i9 | 0) == 8) {
  13721. ___assert_fail(2776, 2808, 103, 2840);
  13722. }
  13723. } else {
  13724. i7 = i12;
  13725. }
  13726. } while (0);
  13727. do {
  13728. if ((i7 | 0) > 1) {
  13729. d24 = +HEAPF32[i11 >> 2];
  13730. if ((i7 | 0) == 2) {
  13731. d32 = +HEAPF32[i2 + 16 >> 2] - +HEAPF32[i2 + 52 >> 2];
  13732. d8 = +HEAPF32[i2 + 20 >> 2] - +HEAPF32[i2 + 56 >> 2];
  13733. d8 = +Math_sqrt(+(d32 * d32 + d8 * d8));
  13734. } else if ((i7 | 0) == 3) {
  13735. d8 = +HEAPF32[i2 + 16 >> 2];
  13736. d32 = +HEAPF32[i2 + 20 >> 2];
  13737. d8 = (+HEAPF32[i2 + 52 >> 2] - d8) * (+HEAPF32[i2 + 92 >> 2] - d32) - (+HEAPF32[i2 + 56 >> 2] - d32) * (+HEAPF32[i2 + 88 >> 2] - d8);
  13738. } else {
  13739. ___assert_fail(2712, 2672, 259, 2736);
  13740. }
  13741. if (!(d8 < d24 * .5) ? !(d24 * 2.0 < d8 | d8 < 1.1920928955078125e-7) : 0) {
  13742. i9 = 18;
  13743. break;
  13744. }
  13745. HEAP32[i6 >> 2] = 0;
  13746. } else {
  13747. i9 = 18;
  13748. }
  13749. } while (0);
  13750. if ((i9 | 0) == 18 ? (i7 | 0) != 0 : 0) {
  13751. STACKTOP = i1;
  13752. return;
  13753. }
  13754. HEAP32[i2 + 28 >> 2] = 0;
  13755. HEAP32[i2 + 32 >> 2] = 0;
  13756. if ((HEAP32[i10 + 20 >> 2] | 0) <= 0) {
  13757. ___assert_fail(2776, 2808, 103, 2840);
  13758. }
  13759. i26 = HEAP32[i10 + 16 >> 2] | 0;
  13760. d8 = +HEAPF32[i26 >> 2];
  13761. d24 = +HEAPF32[i26 + 4 >> 2];
  13762. if ((HEAP32[i3 + 20 >> 2] | 0) <= 0) {
  13763. ___assert_fail(2776, 2808, 103, 2840);
  13764. }
  13765. i26 = HEAP32[i3 + 16 >> 2] | 0;
  13766. d27 = +HEAPF32[i26 >> 2];
  13767. d25 = +HEAPF32[i26 + 4 >> 2];
  13768. d30 = +HEAPF32[i4 + 12 >> 2];
  13769. d32 = +HEAPF32[i4 + 8 >> 2];
  13770. d31 = +HEAPF32[i4 >> 2] + (d8 * d30 - d24 * d32);
  13771. d32 = d24 * d30 + d8 * d32 + +HEAPF32[i4 + 4 >> 2];
  13772. d30 = +d31;
  13773. d28 = +d32;
  13774. i26 = i2;
  13775. HEAPF32[i26 >> 2] = d30;
  13776. HEAPF32[i26 + 4 >> 2] = d28;
  13777. d28 = +HEAPF32[i5 + 12 >> 2];
  13778. d30 = +HEAPF32[i5 + 8 >> 2];
  13779. d29 = +HEAPF32[i5 >> 2] + (d27 * d28 - d25 * d30);
  13780. d30 = d25 * d28 + d27 * d30 + +HEAPF32[i5 + 4 >> 2];
  13781. d27 = +d29;
  13782. d28 = +d30;
  13783. i26 = i2 + 8 | 0;
  13784. HEAPF32[i26 >> 2] = d27;
  13785. HEAPF32[i26 + 4 >> 2] = d28;
  13786. d31 = +(d29 - d31);
  13787. d32 = +(d30 - d32);
  13788. i26 = i2 + 16 | 0;
  13789. HEAPF32[i26 >> 2] = d31;
  13790. HEAPF32[i26 + 4 >> 2] = d32;
  13791. HEAP32[i6 >> 2] = 1;
  13792. STACKTOP = i1;
  13793. return;
  13794. }
  13795. function __ZNSt3__17__sort4IRPFbRK6b2PairS3_EPS1_EEjT0_S8_S8_S8_T_(i6, i7, i5, i4, i1) {
  13796. i6 = i6 | 0;
  13797. i7 = i7 | 0;
  13798. i5 = i5 | 0;
  13799. i4 = i4 | 0;
  13800. i1 = i1 | 0;
  13801. var i2 = 0, i3 = 0, i8 = 0, i9 = 0;
  13802. i2 = STACKTOP;
  13803. STACKTOP = STACKTOP + 16 | 0;
  13804. i3 = i2;
  13805. i9 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0;
  13806. i8 = FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i7) | 0;
  13807. do {
  13808. if (i9) {
  13809. if (i8) {
  13810. HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  13811. HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  13812. HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  13813. HEAP32[i6 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  13814. HEAP32[i6 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  13815. HEAP32[i6 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  13816. HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13817. HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13818. HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13819. i8 = 1;
  13820. break;
  13821. }
  13822. HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  13823. HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  13824. HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  13825. HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  13826. HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  13827. HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  13828. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13829. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13830. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13831. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i7) | 0) {
  13832. HEAP32[i3 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  13833. HEAP32[i3 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  13834. HEAP32[i3 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  13835. HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  13836. HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  13837. HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  13838. HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13839. HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13840. HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13841. i8 = 2;
  13842. } else {
  13843. i8 = 1;
  13844. }
  13845. } else {
  13846. if (i8) {
  13847. HEAP32[i3 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  13848. HEAP32[i3 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  13849. HEAP32[i3 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  13850. HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  13851. HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  13852. HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  13853. HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13854. HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13855. HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13856. if (FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0) {
  13857. HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  13858. HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  13859. HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  13860. HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  13861. HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  13862. HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  13863. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13864. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13865. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13866. i8 = 2;
  13867. } else {
  13868. i8 = 1;
  13869. }
  13870. } else {
  13871. i8 = 0;
  13872. }
  13873. }
  13874. } while (0);
  13875. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i4, i5) | 0)) {
  13876. i9 = i8;
  13877. STACKTOP = i2;
  13878. return i9 | 0;
  13879. }
  13880. HEAP32[i3 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  13881. HEAP32[i3 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  13882. HEAP32[i3 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  13883. HEAP32[i5 + 0 >> 2] = HEAP32[i4 + 0 >> 2];
  13884. HEAP32[i5 + 4 >> 2] = HEAP32[i4 + 4 >> 2];
  13885. HEAP32[i5 + 8 >> 2] = HEAP32[i4 + 8 >> 2];
  13886. HEAP32[i4 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13887. HEAP32[i4 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13888. HEAP32[i4 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13889. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i5, i7) | 0)) {
  13890. i9 = i8 + 1 | 0;
  13891. STACKTOP = i2;
  13892. return i9 | 0;
  13893. }
  13894. HEAP32[i3 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  13895. HEAP32[i3 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  13896. HEAP32[i3 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  13897. HEAP32[i7 + 0 >> 2] = HEAP32[i5 + 0 >> 2];
  13898. HEAP32[i7 + 4 >> 2] = HEAP32[i5 + 4 >> 2];
  13899. HEAP32[i7 + 8 >> 2] = HEAP32[i5 + 8 >> 2];
  13900. HEAP32[i5 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13901. HEAP32[i5 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13902. HEAP32[i5 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13903. if (!(FUNCTION_TABLE_iii[HEAP32[i1 >> 2] & 3](i7, i6) | 0)) {
  13904. i9 = i8 + 2 | 0;
  13905. STACKTOP = i2;
  13906. return i9 | 0;
  13907. }
  13908. HEAP32[i3 + 0 >> 2] = HEAP32[i6 + 0 >> 2];
  13909. HEAP32[i3 + 4 >> 2] = HEAP32[i6 + 4 >> 2];
  13910. HEAP32[i3 + 8 >> 2] = HEAP32[i6 + 8 >> 2];
  13911. HEAP32[i6 + 0 >> 2] = HEAP32[i7 + 0 >> 2];
  13912. HEAP32[i6 + 4 >> 2] = HEAP32[i7 + 4 >> 2];
  13913. HEAP32[i6 + 8 >> 2] = HEAP32[i7 + 8 >> 2];
  13914. HEAP32[i7 + 0 >> 2] = HEAP32[i3 + 0 >> 2];
  13915. HEAP32[i7 + 4 >> 2] = HEAP32[i3 + 4 >> 2];
  13916. HEAP32[i7 + 8 >> 2] = HEAP32[i3 + 8 >> 2];
  13917. i9 = i8 + 3 | 0;
  13918. STACKTOP = i2;
  13919. return i9 | 0;
  13920. }
  13921. function __ZN15b2ContactSolver27SolveTOIPositionConstraintsEii(i9, i2, i5) {
  13922. i9 = i9 | 0;
  13923. i2 = i2 | 0;
  13924. i5 = i5 | 0;
  13925. var i1 = 0, i3 = 0, i4 = 0, i6 = 0, i7 = 0, i8 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, i17 = 0, i18 = 0, i19 = 0, i20 = 0, d21 = 0.0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, d26 = 0.0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, d32 = 0.0, d33 = 0.0, d34 = 0.0, d35 = 0.0, d36 = 0.0, i37 = 0, d38 = 0.0, d39 = 0.0, d40 = 0.0, d41 = 0.0, d42 = 0.0, d43 = 0.0, d44 = 0.0, d45 = 0.0, i46 = 0, d47 = 0.0;
  13926. i1 = STACKTOP;
  13927. STACKTOP = STACKTOP + 64 | 0;
  13928. i8 = i1 + 40 | 0;
  13929. i3 = i1 + 24 | 0;
  13930. i4 = i1;
  13931. i6 = i9 + 48 | 0;
  13932. if ((HEAP32[i6 >> 2] | 0) <= 0) {
  13933. d45 = 0.0;
  13934. i37 = d45 >= -.007499999832361937;
  13935. STACKTOP = i1;
  13936. return i37 | 0;
  13937. }
  13938. i7 = i9 + 36 | 0;
  13939. i14 = i9 + 24 | 0;
  13940. i9 = i8 + 8 | 0;
  13941. i15 = i8 + 12 | 0;
  13942. i10 = i3 + 8 | 0;
  13943. i11 = i3 + 12 | 0;
  13944. i12 = i4 + 8 | 0;
  13945. i13 = i4 + 16 | 0;
  13946. i16 = 0;
  13947. d34 = 0.0;
  13948. do {
  13949. i37 = HEAP32[i7 >> 2] | 0;
  13950. i19 = i37 + (i16 * 88 | 0) | 0;
  13951. i17 = HEAP32[i37 + (i16 * 88 | 0) + 32 >> 2] | 0;
  13952. i18 = HEAP32[i37 + (i16 * 88 | 0) + 36 >> 2] | 0;
  13953. i20 = i37 + (i16 * 88 | 0) + 48 | 0;
  13954. d21 = +HEAPF32[i20 >> 2];
  13955. d22 = +HEAPF32[i20 + 4 >> 2];
  13956. i20 = i37 + (i16 * 88 | 0) + 56 | 0;
  13957. d23 = +HEAPF32[i20 >> 2];
  13958. d24 = +HEAPF32[i20 + 4 >> 2];
  13959. i20 = HEAP32[i37 + (i16 * 88 | 0) + 84 >> 2] | 0;
  13960. if ((i17 | 0) == (i2 | 0) | (i17 | 0) == (i5 | 0)) {
  13961. d26 = +HEAPF32[i37 + (i16 * 88 | 0) + 64 >> 2];
  13962. d27 = +HEAPF32[i37 + (i16 * 88 | 0) + 40 >> 2];
  13963. } else {
  13964. d26 = 0.0;
  13965. d27 = 0.0;
  13966. }
  13967. d25 = +HEAPF32[i37 + (i16 * 88 | 0) + 44 >> 2];
  13968. d28 = +HEAPF32[i37 + (i16 * 88 | 0) + 68 >> 2];
  13969. i37 = HEAP32[i14 >> 2] | 0;
  13970. i46 = i37 + (i17 * 12 | 0) | 0;
  13971. d33 = +HEAPF32[i46 >> 2];
  13972. d35 = +HEAPF32[i46 + 4 >> 2];
  13973. d29 = +HEAPF32[i37 + (i17 * 12 | 0) + 8 >> 2];
  13974. i46 = i37 + (i18 * 12 | 0) | 0;
  13975. d32 = +HEAPF32[i46 >> 2];
  13976. d36 = +HEAPF32[i46 + 4 >> 2];
  13977. d31 = +HEAPF32[i37 + (i18 * 12 | 0) + 8 >> 2];
  13978. if ((i20 | 0) > 0) {
  13979. d30 = d27 + d25;
  13980. i37 = 0;
  13981. do {
  13982. d38 = +Math_sin(+d29);
  13983. HEAPF32[i9 >> 2] = d38;
  13984. d44 = +Math_cos(+d29);
  13985. HEAPF32[i15 >> 2] = d44;
  13986. d43 = +Math_sin(+d31);
  13987. HEAPF32[i10 >> 2] = d43;
  13988. d41 = +Math_cos(+d31);
  13989. HEAPF32[i11 >> 2] = d41;
  13990. d40 = +(d33 - (d21 * d44 - d22 * d38));
  13991. d38 = +(d35 - (d22 * d44 + d21 * d38));
  13992. i46 = i8;
  13993. HEAPF32[i46 >> 2] = d40;
  13994. HEAPF32[i46 + 4 >> 2] = d38;
  13995. d38 = +(d32 - (d23 * d41 - d24 * d43));
  13996. d43 = +(d36 - (d24 * d41 + d23 * d43));
  13997. i46 = i3;
  13998. HEAPF32[i46 >> 2] = d38;
  13999. HEAPF32[i46 + 4 >> 2] = d43;
  14000. __ZN24b2PositionSolverManifold10InitializeEP27b2ContactPositionConstraintRK11b2TransformS4_i(i4, i19, i8, i3, i37);
  14001. i46 = i4;
  14002. d43 = +HEAPF32[i46 >> 2];
  14003. d38 = +HEAPF32[i46 + 4 >> 2];
  14004. i46 = i12;
  14005. d41 = +HEAPF32[i46 >> 2];
  14006. d40 = +HEAPF32[i46 + 4 >> 2];
  14007. d44 = +HEAPF32[i13 >> 2];
  14008. d39 = d41 - d33;
  14009. d42 = d40 - d35;
  14010. d41 = d41 - d32;
  14011. d40 = d40 - d36;
  14012. d34 = d34 < d44 ? d34 : d44;
  14013. d44 = (d44 + .004999999888241291) * .75;
  14014. d44 = d44 < 0.0 ? d44 : 0.0;
  14015. d45 = d38 * d39 - d43 * d42;
  14016. d47 = d38 * d41 - d43 * d40;
  14017. d45 = d47 * d28 * d47 + (d30 + d45 * d26 * d45);
  14018. if (d45 > 0.0) {
  14019. d44 = -(d44 < -.20000000298023224 ? -.20000000298023224 : d44) / d45;
  14020. } else {
  14021. d44 = 0.0;
  14022. }
  14023. d47 = d43 * d44;
  14024. d45 = d38 * d44;
  14025. d33 = d33 - d27 * d47;
  14026. d35 = d35 - d27 * d45;
  14027. d29 = d29 - d26 * (d39 * d45 - d42 * d47);
  14028. d32 = d32 + d25 * d47;
  14029. d36 = d36 + d25 * d45;
  14030. d31 = d31 + d28 * (d41 * d45 - d40 * d47);
  14031. i37 = i37 + 1 | 0;
  14032. } while ((i37 | 0) != (i20 | 0));
  14033. i37 = HEAP32[i14 >> 2] | 0;
  14034. }
  14035. d47 = +d33;
  14036. d45 = +d35;
  14037. i46 = i37 + (i17 * 12 | 0) | 0;
  14038. HEAPF32[i46 >> 2] = d47;
  14039. HEAPF32[i46 + 4 >> 2] = d45;
  14040. i46 = HEAP32[i14 >> 2] | 0;
  14041. HEAPF32[i46 + (i17 * 12 | 0) + 8 >> 2] = d29;
  14042. d45 = +d32;
  14043. d47 = +d36;
  14044. i46 = i46 + (i18 * 12 | 0) | 0;
  14045. HEAPF32[i46 >> 2] = d45;
  14046. HEAPF32[i46 + 4 >> 2] = d47;
  14047. HEAPF32[(HEAP32[i14 >> 2] | 0) + (i18 * 12 | 0) + 8 >> 2] = d31;
  14048. i16 = i16 + 1 | 0;
  14049. } while ((i16 | 0) < (HEAP32[i6 >> 2] | 0));
  14050. i46 = d34 >= -.007499999832361937;
  14051. STACKTOP = i1;
  14052. return i46 | 0;
  14053. }
  14054. function __ZN15b2ContactSolver24SolvePositionConstraintsEv(i7) {
  14055. i7 = i7 | 0;
  14056. var i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0, i8 = 0, i9 = 0, i10 = 0, i11 = 0, i12 = 0, i13 = 0, i14 = 0, i15 = 0, i16 = 0, d17 = 0.0, d18 = 0.0, d19 = 0.0, d20 = 0.0, i21 = 0, d22 = 0.0, d23 = 0.0, d24 = 0.0, d25 = 0.0, i26 = 0, d27 = 0.0, d28 = 0.0, d29 = 0.0, d30 = 0.0, d31 = 0.0, d32 = 0.0, d33 = 0.0, d34 = 0.0, i35 = 0, d36 = 0.0, d37 = 0.0, d38 = 0.0, d39 = 0.0, d40 = 0.0, d41 = 0.0, d42 = 0.0, d43 = 0.0, i44 = 0, d45 = 0.0;
  14057. i1 = STACKTOP;
  14058. STACKTOP = STACKTOP + 64 | 0;
  14059. i4 = i1 + 40 | 0;
  14060. i5 = i1 + 24 | 0;
  14061. i3 = i1;
  14062. i2 = i7 + 48 | 0;
  14063. if ((HE