1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
|
//====================================================================================
// Auto-generated code. Original source + changes are
// sphere flake bvh raytracer (c) 2005, thierry berger-perrin <tbptbp@gmail.com>
// (c) 2010, azakai (Emscripten)
// this code is released under the GNU Public License.
//
// Optimized using Closure Compiler
//====================================================================================
// === Auto-generated preamble library stuff ===
function __globalConstructor__() {
}
var __THREW__ = false; // Used in checking for thrown exceptions.
var __ATEXIT__ = [];
function assert(condition, text) {
if (!condition) {
var text = "Assertion failed: " + text;
print(text + ':\n' + (new Error).stack);
throw "Assertion: " + text;
}
}
function Pointer_niceify(ptr) {
return { slab: HEAP, pos: ptr };
}
// Creates a pointer for a certain slab and a certain address in that slab.
// If just a slab is given, will allocate room for it and copy it there. In
// other words, do whatever is necessary in order to return a pointer, that
// points to the slab (and possibly position) we are given.
ALLOC_NORMAL = 0; // Tries to use _malloc()
ALLOC_STACK = 1; // Lives for the duration of the current function call
ALLOC_STATIC = 2; // Cannot be freed
function Pointer_make(slab, pos, allocator) {
pos = pos ? pos : 0;
if (slab === HEAP) return pos;
// Flatten out - needed for global consts/vars
function flatten(slab) {
if (!slab || slab.length === undefined || typeof slab === 'function') return [slab];
return slab.map(flatten).reduce(function(a,b) { return a.concat(b) }, []);
}
var slab = flatten(slab);
// Finalize
var ret = [_malloc, stackAlloc, staticAlloc][allocator ? allocator : ALLOC_STATIC](Math.max(slab.length - pos, 1));
for (var i = 0; i < slab.length - pos; i++) {
HEAP[ret + i] = slab[pos + i];
}
return ret;
}
function Pointer_stringify(ptr) {
ptr = Pointer_niceify(ptr);
var ret = "";
var i = 0;
var t;
while (1) {
// if ((ptr.pos + i) >= ptr.slab.length) { return "<< Invalid read: " + (ptr.pos+i) + " : " + ptr.slab.length + " >>"; } else {}
if ((ptr.pos+i) >= ptr.slab.length) { break; } else {}
t = String.fromCharCode(ptr.slab[ptr.pos + i]);
if (t == "\0") { break; } else {}
ret += t;
i += 1;
}
return ret;
}
// Memory management
PAGE_SIZE = 4096;
function alignMemoryPage(x) {
return Math.ceil(x/PAGE_SIZE)*PAGE_SIZE;
}
// If we don't have malloc/free implemented, use a simple implementation.
if (!this._malloc) {
_malloc = staticAlloc;
_free = function() { }; // leak!
}
// Mangled "new"s... need a heuristic for autogeneration...
__Znwj = _malloc; // llvm-gcc
__Znaj = _malloc; // llvm-gcc
__Znam = _malloc; // clang
__Znwm = _malloc; // clang
// Mangled "delete"s... need a heuristic for autogeneration...
__ZdlPv = _free; // llvm-gcc
__ZdaPv = _free; // llvm-gcc
function __initializeRuntime__() {
HEAP = intArrayFromString('(null)'); // So printing %s of NULL gives '(null)'
// Also this ensures we leave 0 as an invalid address, 'NULL'
STACK_STACK = [];
STACK_ROOT = STACKTOP = alignMemoryPage(10);
if (!this['TOTAL_STACK']) TOTAL_STACK = 64*1024*100; // Reserved room for stack
STACK_MAX = STACK_ROOT + TOTAL_STACK;
STATICTOP = alignMemoryPage(STACK_MAX);
}
// stdio.h
// C-style: we work on ints on the HEAP.
function __formatString() {
var textIndex = arguments[0];
var argIndex = 1;
var ret = [];
var curr = -1;
while (curr != 0) {
curr = HEAP[textIndex];
next = HEAP[textIndex+1];
if (curr == '%'.charCodeAt(0) && ['d', 'u', 'f', '.'].indexOf(String.fromCharCode(next)) != -1) {
var argText = String(arguments[argIndex]);
// Handle very very simply formatting, namely only %.Xf
if (next == '.'.charCodeAt(0)) {
var limit = parseInt(String.fromCharCode(HEAP[textIndex+2]));
var dotIndex = argText.indexOf('.');
if (dotIndex == -1) {
dotIndex = argText.length;
argText += '.';
}
argText += '00000000000'; // padding
argText = argText.substr(0, dotIndex+1+limit);
textIndex += 2;
} else if (next == 'u'.charCodeAt(0)) {
argText = String(unSign(arguments[argIndex], 32));
}
argText.split('').forEach(function(chr) {
ret.push(chr.charCodeAt(0));
});
argIndex += 1;
textIndex += 2;
} else if (curr == '%'.charCodeAt(0) && next == 's'.charCodeAt(0)) {
ret = ret.concat(String_copy(arguments[argIndex]));
argIndex += 1;
textIndex += 2;
} else {
ret.push(curr);
textIndex += 1;
}
}
return Pointer_make(ret, 0, ALLOC_STACK); // NB: Stored on the stack
}
// Copies a list of num items on the HEAP into a
// a normal JavaScript array of numbers
function Array_copy(ptr, num) {
// XXX hardcoded ptr impl
return HEAP.slice(ptr, ptr+num);
}
// Copies a C-style string, terminated by a zero, from the HEAP into
// a normal JavaScript array of numbers
function String_copy(ptr, addZero) {
// XXX hardcoded ptr impl
return Array_copy(ptr, _strlen(ptr)).concat(addZero ? [0] : []);
}
// stdlib.h
// Get a pointer, return int value of the string it points to
function _atoi(s) {
return Math.floor(Number(Pointer_stringify(s)));
}
function _llvm_memcpy_i32(dest, src, num, idunno) {
// XXX hardcoded ptr impl
for (var i = 0; i < num; i++) {
HEAP[dest + i] = HEAP[src + i];
}
// dest = Pointer_niceify(dest);
// src = Pointer_niceify(src);
// dest.slab = src.slab.slice(src.pos);
}
_llvm_memcpy_i64 = _llvm_memcpy_i32;
// Tools
PRINTBUFFER = '';
function __print__(text) {
// We print only when we see a '\n', as console JS engines always add
// one anyhow.
PRINTBUFFER = PRINTBUFFER + text;
var endIndex;
while ((endIndex = PRINTBUFFER.indexOf('\n')) != -1) {
print(PRINTBUFFER.substr(0, endIndex));
PRINTBUFFER = PRINTBUFFER.substr(endIndex + 1);
}
}
function jrint(label, obj) { // XXX manual debugging
if (!obj) {
obj = label;
label = '';
} else
label = label + ' : ';
print(label + JSON.stringify(obj));
}
// This processes a 'normal' string into a C-line array of numbers.
// For LLVM-originating strings, see parser.js:parseLLVMString function
function intArrayFromString(stringy) {
var ret = [];
var t;
var i = 0;
while (i < stringy.length) {
ret.push(stringy.charCodeAt(i));
i = i + 1;
}
ret.push(0);
return ret;
}
// Converts a value we have as signed, into an unsigned value. For
// example, -1 in int32 would be a very large number as unsigned.
function unSign(value, bits) {
if (value >= 0) return value;
return 2*Math.abs(1 << (bits-1)) + value;
}
// === Body ===
function stackAlloc(size) { var ret = STACKTOP; STACKTOP += size; return ret; }
function staticAlloc(size) { var ret = STATICTOP; STATICTOP += size; return ret; }
var _0___FLATTENER = [0,1];
var _struct__1__pthread_mutex_s___FLATTENER = [0,1,2,3,4,5];
var _struct_SDL_BlitMap___FLATTENER = [];
var _struct_SDL_Color___FLATTENER = [0,1,2,3];
var _struct_SDL_Palette___FLATTENER = [0,1];
var _struct_SDL_PixelFormat___FLATTENER = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
var _struct_SDL_Rect___FLATTENER = [0,1,2,3];
var _struct_SDL_Surface___FLATTENER = [0,1,2,3,4,5,6,7,8,12,13,14,15,16];
var _struct___pthread_slist_t___FLATTENER = [0];
var _struct_basis_t___FLATTENER = [0,3,6];
var _struct_hit_t___FLATTENER = [0,3];
var _struct_node_t___FLATTENER = [0,4,8];
var _struct_private_hwdata___FLATTENER = [];
var _struct_ray_t___FLATTENER = [0,3];
var _struct_sphere_t___FLATTENER = [0,3];
var __struct_std__ios_base__Init____FLATTENER = [0];
var _struct_v_t___FLATTENER = [0,1,2];
var _union__0__45___FLATTENER = [0];
var _union_pthread_attr_t___FLATTENER = [0,1];
var _union_pthread_mutex_t___FLATTENER = [0];
var _union_pthread_mutexattr_t___FLATTENER = [0];
this.__defineGetter__("_screen", function() { delete _screen; _screen = Pointer_make([0], 0, ALLOC_STATIC); return _screen });
this.__defineGetter__("__ZStL8__ioinit", function() { delete __ZStL8__ioinit; __ZStL8__ioinit = Pointer_make([0], 0, ALLOC_STATIC); return __ZStL8__ioinit });
var ___dso_handle = 0; /* external value? */
this.__defineGetter__("__ZL5light", function() { delete __ZL5light; __ZL5light = Pointer_make([0,0,0], 0, ALLOC_STATIC); return __ZL5light });
this.__defineGetter__("__ZL4pool", function() { delete __ZL4pool; __ZL4pool = Pointer_make([0], 0, ALLOC_STATIC); return __ZL4pool });
this.__defineGetter__("__ZL3end", function() { delete __ZL3end; __ZL3end = Pointer_make([0], 0, ALLOC_STATIC); return __ZL3end });
this.__defineGetter__("__ZL4grid", function() { delete __ZL4grid; __ZL4grid = Pointer_make([ [-1.000000e+00, -0.3333333333333333], [0.3333333333333333, -1.000000e+00], [-0.3333333333333333, 1.000000e+00], [1.000000e+00, 0.3333333333333333] ], 0, ALLOC_STATIC); return __ZL4grid });
__globalConstructor__ = function() {
__GLOBAL__I_screen();
}
_sqrt = function (x) { return Math.sqrt(x) }
__ZNSt8ios_base4InitC1Ev = function () {
// need valid 'file descriptors'
__ZSt4cout = 1;
__ZSt4cerr = 2;
}
___cxa_atexit = function (func) {
__ATEXIT__.push(func);
}
__ZNSt8ios_base4InitD1Ev = function () {
// need valid 'file descriptors'
__ZSt4cout = 1;
__ZSt4cerr = 2;
}
_cos = function (x) { return Math.cos(x) }
_sin = function (x) { return Math.sin(x) }
_SDL_LockSurface = function (surf) {
var surfData = SDL_SURFACES[surf];
surfData.image = surfData.ctx.getImageData(0, 0, surfData.width, surfData.height);
// Copy pixel data to somewhere accessible to 'C/C++'
var num = surfData.image.data.length;
for (var i = 0; i < num; i++) {
HEAP[surfData.buffer+i] = surfData.image.data[i];
}
// Mark in C/C++-accessible SDL structure
// SDL_Surface has the following fields: Uint32 flags, SDL_PixelFormat *format; int w, h; Uint16 pitch; void *pixels; ...
// So we have fields all of the same size, and 5 of them before us.
HEAP[surf + 5*1] = surfData.buffer;
}
_SDL_UnlockSurface = function (surf) {
var surfData = SDL_SURFACES[surf];
// Copy pixel data to image
var num = surfData.image.data.length;
for (var i = 0; i < num; i++) {
surfData.image.data[i] = HEAP[surfData.buffer+i];
}
for (var i = 0; i < num/4; i++) {
surfData.image.data[i*4+3] = 255; // opacity, as canvases blend alpha
}
// Copy to canvas
surfData.ctx.putImageData(surfData.image, 0, 0);
// Cleanup
surfData.image = null;
}
_SDL_Flip = function (surf) {
// We actually do this in Unlock...
}
// stub for _atoi
// stub for __Znaj
_SDL_Init = function (what) {
SDL_SURFACES = {};
return 1;
}
_SDL_SetVideoMode = function (width, height, depth, flags, canvas) {
// ^^^^^^ a 'canvas' parameter is added here; supply a canvas from JS there
var surf = _malloc(14*1); // SDL_Surface has 14 fields of quantum size
SDL_SURFACES[surf] = {
width: width,
height: height,
canvas: canvas,
ctx: canvas.getContext('2d'),
surf: surf,
buffer: _malloc(width*height*4),
};
return surf;
}
_SDL_Delay = function (delay) {
// No can do... unless you were a generator...
}
_SDL_Quit = function () {
return 1;
}
// stub for i32
// stub for i8_
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
// stub for i32
function __GLOBAL__I_screen() {
STACK_STACK.push(STACKTOP);
var __label__;
__Z41__static_initialization_and_destruction_0ii(1, 65535);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZnwjPv(_unnamed_arg, ___p) {
STACK_STACK.push(STACKTOP);
var __label__;
var _unnamed_arg_addr;
var ___p_addr = STACKTOP; STACKTOP += 1;
var _retval = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
_unnamed_arg_addr = _unnamed_arg;
HEAP[___p_addr] = ___p;
var _1 = HEAP[___p_addr];
HEAP[_0] = _1;
var _2 = HEAP[_0];
HEAP[_0] = _2;
var _3 = HEAP[_0];
HEAP[_retval] = _3;
__label__ = 0; /* _return */
var _retval1 = HEAP[_retval];
STACKTOP = STACK_STACK.pop();
return _retval1;
}
function __ZN3v_tC1Ev(_this) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK3v_tplERKS_(_agg_result, _this, _v) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
var _0 = HEAP[_this_addr];
var _2 = HEAP[0 + _0+2*1];
var _3 = HEAP[_v_addr];
var _5 = HEAP[0 + _3+2*1];
var _6 = _2 + _5;
var _7 = HEAP[_this_addr];
var _9 = HEAP[0 + _7+1*1];
var _10 = HEAP[_v_addr];
var _12 = HEAP[0 + _10+1*1];
var _13 = _9 + _12;
var _14 = HEAP[_this_addr];
var _16 = HEAP[0 + _14+0*1];
var _17 = HEAP[_v_addr];
var _19 = HEAP[0 + _17+0*1];
var _20 = _16 + _19;
__ZN3v_tC1Eddd(_agg_result, _20, _13, _6);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK3v_tmiERKS_(_agg_result, _this, _v) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
var _0 = HEAP[_this_addr];
var _2 = HEAP[0 + _0+2*1];
var _3 = HEAP[_v_addr];
var _5 = HEAP[0 + _3+2*1];
var _6 = _2 - _5;
var _7 = HEAP[_this_addr];
var _9 = HEAP[0 + _7+1*1];
var _10 = HEAP[_v_addr];
var _12 = HEAP[0 + _10+1*1];
var _13 = _9 - _12;
var _14 = HEAP[_this_addr];
var _16 = HEAP[0 + _14+0*1];
var _17 = HEAP[_v_addr];
var _19 = HEAP[0 + _17+0*1];
var _20 = _16 - _19;
__ZN3v_tC1Eddd(_agg_result, _20, _13, _6);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK3v_tngEv(_agg_result, _this) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
var _0 = HEAP[_this_addr];
var _2 = HEAP[0 + _0+2*1];
var _3 = -0.000000e+00 - _2;
var _4 = HEAP[_this_addr];
var _6 = HEAP[0 + _4+1*1];
var _7 = -0.000000e+00 - _6;
var _8 = HEAP[_this_addr];
var _10 = HEAP[0 + _8+0*1];
var _11 = -0.000000e+00 - _10;
__ZN3v_tC1Eddd(_agg_result, _11, _7, _3);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK3v_tmlEd(_agg_result, _this, _d) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _d_addr;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
_d_addr = _d;
var _0 = HEAP[_this_addr];
var _2 = HEAP[0 + _0+2*1];
var _3 = _d_addr;
var _4 = _2 * _3;
var _5 = HEAP[_this_addr];
var _7 = HEAP[0 + _5+1*1];
var _8 = _d_addr;
var _9 = _7 * _8;
var _10 = HEAP[_this_addr];
var _12 = HEAP[0 + _10+0*1];
var _13 = _d_addr;
var _14 = _12 * _13;
__ZN3v_tC1Eddd(_agg_result, _14, _9, _4);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK3v_t5crossERKS_(_agg_result, _this, _v) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
var _0 = HEAP[_this_addr];
var _2 = HEAP[0 + _0+0*1];
var _3 = HEAP[_v_addr];
var _5 = HEAP[0 + _3+1*1];
var _6 = _2 * _5;
var _7 = HEAP[_this_addr];
var _9 = HEAP[0 + _7+1*1];
var _10 = HEAP[_v_addr];
var _12 = HEAP[0 + _10+0*1];
var _13 = _9 * _12;
var _14 = _6 - _13;
var _15 = HEAP[_this_addr];
var _17 = HEAP[0 + _15+2*1];
var _18 = HEAP[_v_addr];
var _20 = HEAP[0 + _18+0*1];
var _21 = _17 * _20;
var _22 = HEAP[_this_addr];
var _24 = HEAP[0 + _22+0*1];
var _25 = HEAP[_v_addr];
var _27 = HEAP[0 + _25+2*1];
var _28 = _24 * _27;
var _29 = _21 - _28;
var _30 = HEAP[_this_addr];
var _32 = HEAP[0 + _30+1*1];
var _33 = HEAP[_v_addr];
var _35 = HEAP[0 + _33+2*1];
var _36 = _32 * _35;
var _37 = HEAP[_this_addr];
var _39 = HEAP[0 + _37+2*1];
var _40 = HEAP[_v_addr];
var _42 = HEAP[0 + _40+1*1];
var _43 = _39 * _42;
var _44 = _36 - _43;
__ZN3v_tC1Eddd(_agg_result, _44, _29, _14);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK3v_t3dotERKS_(_this, _v) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var _retval;
var _0;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
var _1 = HEAP[_this_addr];
var _3 = HEAP[0 + _1+0*1];
var _4 = HEAP[_v_addr];
var _6 = HEAP[0 + _4+0*1];
var _7 = _3 * _6;
var _8 = HEAP[_this_addr];
var _10 = HEAP[0 + _8+1*1];
var _11 = HEAP[_v_addr];
var _13 = HEAP[0 + _11+1*1];
var _14 = _10 * _13;
var _15 = _7 + _14;
var _16 = HEAP[_this_addr];
var _18 = HEAP[0 + _16+2*1];
var _19 = HEAP[_v_addr];
var _21 = HEAP[0 + _19+2*1];
var _22 = _18 * _21;
_0 = _15 + _22;
_retval = _0;
__label__ = 0; /* _return */
var _retval1 = _retval;
STACKTOP = STACK_STACK.pop();
return _retval1;
}
function __ZSt3maxIdERKT_S2_S2_(___a, ___b) {
STACK_STACK.push(STACKTOP);
var __label__;
var ___a_addr = STACKTOP; STACKTOP += 1;
var ___b_addr = STACKTOP; STACKTOP += 1;
var _retval = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[___a_addr] = ___a;
HEAP[___b_addr] = ___b;
var _1 = HEAP[___a_addr];
var _2 = HEAP[_1];
var _3 = HEAP[___b_addr];
var _4 = HEAP[_3];
var _5 = 0+(_2 < _4);
if (_5) { __label__ = 1; /* _bb */ } else { __label__ = 2; /* _bb1 */ }
_bb: do {
if (__label__ == 1) {
var _6 = HEAP[___b_addr];
HEAP[_0] = _6;
__label__ = 3; /* _bb2 */ break _bb;
}
else if (__label__ == 2) {
var _7 = HEAP[___a_addr];
HEAP[_0] = _7;
__label__ = 3; /* _bb2 */ break _bb;
}
} while(0);
var _8 = HEAP[_0];
HEAP[_retval] = _8;
__label__ = 0; /* _return */
var _retval3 = HEAP[_retval];
STACKTOP = STACK_STACK.pop();
return _retval3;
}
function __ZSt3maxIiERKT_S2_S2_(___a, ___b) {
STACK_STACK.push(STACKTOP);
var __label__;
var ___a_addr = STACKTOP; STACKTOP += 1;
var ___b_addr = STACKTOP; STACKTOP += 1;
var _retval = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[___a_addr] = ___a;
HEAP[___b_addr] = ___b;
var _1 = HEAP[___a_addr];
var _2 = HEAP[_1];
var _3 = HEAP[___b_addr];
var _4 = HEAP[_3];
var _5 = 0+(_2 < _4);
if (_5) { __label__ = 1; /* _bb */ } else { __label__ = 2; /* _bb1 */ }
_bb: do {
if (__label__ == 1) {
var _6 = HEAP[___b_addr];
HEAP[_0] = _6;
__label__ = 3; /* _bb2 */ break _bb;
}
else if (__label__ == 2) {
var _7 = HEAP[___a_addr];
HEAP[_0] = _7;
__label__ = 3; /* _bb2 */ break _bb;
}
} while(0);
var _8 = HEAP[_0];
HEAP[_retval] = _8;
__label__ = 0; /* _return */
var _retval3 = HEAP[_retval];
STACKTOP = STACK_STACK.pop();
return _retval3;
}
function ___tcf_0(_unnamed_arg) {
STACK_STACK.push(STACKTOP);
var __label__;
var _unnamed_arg_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_unnamed_arg_addr] = _unnamed_arg;
__ZNSt8ios_base4InitD1Ev(__ZStL8__ioinit);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN3v_tC1Eddd(_this, _a, _b, _c) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _a_addr;
var _b_addr;
var _c_addr;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
_a_addr = _a;
_b_addr = _b;
_c_addr = _c;
var _0 = HEAP[_this_addr];
var _1 = _0+0*1;
HEAP[_1] = _a_addr;
var _3 = HEAP[_this_addr];
var _4 = _3+1*1;
HEAP[_4] = _b_addr;
var _6 = HEAP[_this_addr];
var _7 = _6+2*1;
HEAP[_7] = _c_addr;
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN5ray_tC1ERK3v_t(_this, _v) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
var _0 = HEAP[_this_addr];
var _1 = _0+0*3;
var _2 = HEAP[_v_addr];
var _3 = _1+0*1;
var _5 = HEAP[0 + _2+0*1];
HEAP[_3] = _5;
var _6 = _1+1*1;
var _8 = HEAP[0 + _2+1*1];
HEAP[_6] = _8;
var _9 = _1+2*1;
var _11 = HEAP[0 + _2+2*1];
HEAP[_9] = _11;
var _12 = HEAP[_this_addr];
var _13 = _12+1*3;
__ZN3v_tC1Ev(_13);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN5ray_tC1ERK3v_tS2_(_this, _v, _w) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var _w_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
HEAP[_w_addr] = _w;
var _0 = HEAP[_this_addr];
var _1 = _0+0*3;
var _2 = HEAP[_v_addr];
var _3 = _1+0*1;
var _5 = HEAP[0 + _2+0*1];
HEAP[_3] = _5;
var _6 = _1+1*1;
var _8 = HEAP[0 + _2+1*1];
HEAP[_6] = _8;
var _9 = _1+2*1;
var _11 = HEAP[0 + _2+2*1];
HEAP[_9] = _11;
var _12 = HEAP[_this_addr];
var _13 = _12+1*3;
var _14 = HEAP[_w_addr];
var _15 = _13+0*1;
var _17 = HEAP[0 + _14+0*1];
HEAP[_15] = _17;
var _18 = _13+1*1;
var _20 = HEAP[0 + _14+1*1];
HEAP[_18] = _20;
var _21 = _13+2*1;
var _23 = HEAP[0 + _14+2*1];
HEAP[_21] = _23;
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN5hit_tC1Ev(_this) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
var _0 = HEAP[_this_addr];
var _1 = _0+_struct_hit_t___FLATTENER[0];
__ZN3v_tC1Eddd(_1, 0.000000e+00, 0.000000e+00, 0.000000e+00);
var _2 = HEAP[_this_addr];
var _3 = _2+_struct_hit_t___FLATTENER[1];
HEAP[_3] = Infinity;
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN8sphere_tC1Ev(_this) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
var _0 = HEAP[_this_addr];
var _1 = _0+_struct_hit_t___FLATTENER[0];
__ZN3v_tC1Ev(_1);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN8sphere_tC1ERK3v_td(_this, _v, _d) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var _d_addr;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
_d_addr = _d;
var _0 = HEAP[_this_addr];
var _1 = _0+_struct_hit_t___FLATTENER[0];
var _2 = HEAP[_v_addr];
var _3 = _1+0*1;
var _5 = HEAP[0 + _2+0*1];
HEAP[_3] = _5;
var _6 = _1+1*1;
var _8 = HEAP[0 + _2+1*1];
HEAP[_6] = _8;
var _9 = _1+2*1;
var _11 = HEAP[0 + _2+2*1];
HEAP[_9] = _11;
var _12 = HEAP[_this_addr];
var _13 = _12+_struct_hit_t___FLATTENER[1];
HEAP[_13] = _d_addr;
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK8sphere_t10get_normalERK3v_t(_agg_result, _this, _v) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 3;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
var _1 = HEAP[_this_addr];
var _3 = HEAP[0 + _1+_struct_hit_t___FLATTENER[1]];
var _4 = 1.000000e+00 / _3;
var _5 = HEAP[_this_addr];
var _6 = _5+_struct_hit_t___FLATTENER[0];
var _7 = HEAP[_v_addr];
__ZNK3v_tmiERKS_(_0, _7, _6);
__ZNK3v_tmlEd(_agg_result, _0, _4);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN6node_tC1Ev(_this) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
var _0 = HEAP[_this_addr];
var _1 = _0+_struct_node_t___FLATTENER[0];
__ZN8sphere_tC1Ev(_1);
var _2 = HEAP[_this_addr];
var _3 = _2+_struct_node_t___FLATTENER[1];
__ZN8sphere_tC1Ev(_3);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN6node_tC1ERK8sphere_tS2_l(_this, _b, _l, _jump) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _b_addr = STACKTOP; STACKTOP += 1;
var _l_addr = STACKTOP; STACKTOP += 1;
var _jump_addr;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_b_addr] = _b;
HEAP[_l_addr] = _l;
_jump_addr = _jump;
var _0 = HEAP[_this_addr];
var _1 = _0+_struct_node_t___FLATTENER[0];
var _2 = HEAP[_b_addr];
var _3 = _1+_struct_hit_t___FLATTENER[0];
var _4 = _2+_struct_hit_t___FLATTENER[0];
var _5 = _3+0*1;
var _7 = HEAP[0 + _4+0*1];
HEAP[_5] = _7;
var _8 = _3+1*1;
var _10 = HEAP[0 + _4+1*1];
HEAP[_8] = _10;
var _11 = _3+2*1;
var _13 = HEAP[0 + _4+2*1];
HEAP[_11] = _13;
var _14 = _1+_struct_hit_t___FLATTENER[1];
var _16 = HEAP[0 + _2+_struct_hit_t___FLATTENER[1]];
HEAP[_14] = _16;
var _17 = HEAP[_this_addr];
var _18 = _17+_struct_node_t___FLATTENER[1];
var _19 = HEAP[_l_addr];
var _20 = _18+_struct_hit_t___FLATTENER[0];
var _21 = _19+_struct_hit_t___FLATTENER[0];
var _22 = _20+0*1;
var _24 = HEAP[0 + _21+0*1];
HEAP[_22] = _24;
var _25 = _20+1*1;
var _27 = HEAP[0 + _21+1*1];
HEAP[_25] = _27;
var _28 = _20+2*1;
var _30 = HEAP[0 + _21+2*1];
HEAP[_28] = _30;
var _31 = _18+_struct_hit_t___FLATTENER[1];
var _33 = HEAP[0 + _19+_struct_hit_t___FLATTENER[1]];
HEAP[_31] = _33;
var _34 = HEAP[_this_addr];
var _35 = _34+_struct_node_t___FLATTENER[2];
HEAP[_35] = _jump_addr;
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN7basis_tC1ERK3v_t(_this, _v) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _v_addr = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 3;
var _n = STACKTOP; STACKTOP += 3;
var _memtmp = STACKTOP; STACKTOP += 3;
var _memtmp12 = STACKTOP; STACKTOP += 3;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_v_addr] = _v;
var _1 = HEAP[_this_addr];
var _2 = _1+0*3;
__ZN3v_tC1Ev(_2);
var _3 = HEAP[_this_addr];
var _4 = _3+1*3;
__ZN3v_tC1Ev(_4);
var _5 = HEAP[_this_addr];
var _6 = _5+2*3;
__ZN3v_tC1Ev(_6);
var _7 = HEAP[_v_addr];
__ZNK3v_t4normEv(_n, _7);
var _9 = HEAP[0 + _n+0*1];
var _11 = HEAP[0 + _n+0*1];
var _12 = _9 * _11;
var _13 = 0+(_12 != 1.000000e+00);
var _14 = _13;
var _16 = HEAP[0 + _n+1*1];
var _18 = HEAP[0 + _n+1*1];
var _19 = _16 * _18;
var _20 = 0+(_19 != 1.000000e+00);
var _21 = _20;
var _toBool = 0+(_14 != 0);
var _toBool1 = 0+(_21 != 0);
var _22 = _toBool & _toBool1;
var _23 = _22;
var _24 = _23;
var _26 = HEAP[0 + _n+2*1];
var _28 = HEAP[0 + _n+2*1];
var _29 = _26 * _28;
var _30 = 0+(_29 != 1.000000e+00);
var _31 = _30;
var _32 = _24 & _31;
var _33 = 0+(_32 != 0);
if (_33) { __label__ = 1; /* _bb */ } else { __label__ = 4; /* _bb10 */ }
_bb: do {
if (__label__ == 1) {
var _34 = HEAP[_this_addr];
var _35 = _34+1*3;
var _36 = _35+0*1;
var _38 = HEAP[0 + _n+0*1];
HEAP[_36] = _38;
var _39 = _35+1*1;
var _41 = HEAP[0 + _n+1*1];
HEAP[_39] = _41;
var _42 = _35+2*1;
var _44 = HEAP[0 + _n+2*1];
HEAP[_42] = _44;
var _46 = HEAP[0 + _n+1*1];
var _48 = HEAP[0 + _n+1*1];
var _49 = _46 * _48;
var _51 = HEAP[0 + _n+0*1];
var _53 = HEAP[0 + _n+0*1];
var _54 = _51 * _53;
var _55 = 0+(_49 > _54);
if (_55) { __label__ = 3; /* _bb2 */ } else { __label__ = 5; /* _bb6 */ }
_bb2: do {
if (__label__ == 3) {
var _57 = HEAP[0 + _n+1*1];
var _59 = HEAP[0 + _n+1*1];
var _60 = _57 * _59;
var _62 = HEAP[0 + _n+2*1];
var _64 = HEAP[0 + _n+2*1];
var _65 = _62 * _64;
var _66 = 0+(_60 > _65);
if (_66) { __label__ = 6; /* _bb3 */ } else { __label__ = 7; /* _bb4 */ }
_bb3: do {
if (__label__ == 6) {
var _67 = HEAP[_this_addr];
var _68 = _67+1*3;
var _70 = HEAP[0 + _68+1*1];
var _71 = -0.000000e+00 - _70;
var _72 = HEAP[_this_addr];
var _73 = _72+1*3;
var _74 = _73+1*1;
HEAP[_74] = _71;
__label__ = 8; /* _bb5 */ break _bb3;
}
else if (__label__ == 7) {
var _75 = HEAP[_this_addr];
var _76 = _75+1*3;
var _78 = HEAP[0 + _76+2*1];
var _79 = -0.000000e+00 - _78;
var _80 = HEAP[_this_addr];
var _81 = _80+1*3;
var _82 = _81+2*1;
HEAP[_82] = _79;
__label__ = 8; /* _bb5 */ break _bb3;
}
} while(0);
__label__ = 9; /* _bb9 */ break _bb2;
}
else if (__label__ == 5) {
var _84 = HEAP[0 + _n+2*1];
var _86 = HEAP[0 + _n+2*1];
var _87 = _84 * _86;
var _89 = HEAP[0 + _n+0*1];
var _91 = HEAP[0 + _n+0*1];
var _92 = _89 * _91;
var _93 = 0+(_87 > _92);
if (_93) { __label__ = 10; /* _bb7 */ } else { __label__ = 11; /* _bb8 */ }
_bb7: do {
if (__label__ == 10) {
var _94 = HEAP[_this_addr];
var _95 = _94+1*3;
var _97 = HEAP[0 + _95+2*1];
var _98 = -0.000000e+00 - _97;
var _99 = HEAP[_this_addr];
var _100 = _99+1*3;
var _101 = _100+2*1;
HEAP[_101] = _98;
__label__ = 9; /* _bb9 */ break _bb2;
}
else if (__label__ == 11) {
var _102 = HEAP[_this_addr];
var _103 = _102+1*3;
var _105 = HEAP[0 + _103+0*1];
var _106 = -0.000000e+00 - _105;
var _107 = HEAP[_this_addr];
var _108 = _107+1*3;
var _109 = _108+0*1;
HEAP[_109] = _106;
__label__ = 9; /* _bb9 */ break _bb2;
}
} while(0);
}
} while(0);
__label__ = 12; /* _bb11 */ break _bb;
}
else if (__label__ == 4) {
var _111 = HEAP[0 + _n+1*1];
var _113 = HEAP[0 + _n+0*1];
var _115 = HEAP[0 + _n+2*1];
__ZN3v_tC1Eddd(_0, _115, _113, _111);
var _116 = HEAP[_this_addr];
var _117 = _116+1*3;
var _118 = _117+0*1;
var _120 = HEAP[0 + _0+0*1];
HEAP[_118] = _120;
var _121 = _117+1*1;
var _123 = HEAP[0 + _0+1*1];
HEAP[_121] = _123;
var _124 = _117+2*1;
var _126 = HEAP[0 + _0+2*1];
HEAP[_124] = _126;
__label__ = 12; /* _bb11 */ break _bb;
}
} while(0);
var _127 = HEAP[_this_addr];
var _128 = _127+0*3;
var _129 = _128+0*1;
var _131 = HEAP[0 + _n+0*1];
HEAP[_129] = _131;
var _132 = _128+1*1;
var _134 = HEAP[0 + _n+1*1];
HEAP[_132] = _134;
var _135 = _128+2*1;
var _137 = HEAP[0 + _n+2*1];
HEAP[_135] = _137;
var _138 = HEAP[_this_addr];
var _139 = _138+1*3;
var _140 = HEAP[_this_addr];
var _141 = _140+0*3;
var _142 = HEAP[_this_addr];
var _143 = _142+2*3;
__ZNK3v_t5crossERKS_(_memtmp, _141, _139);
var _144 = _143+0*1;
var _146 = HEAP[0 + _memtmp+0*1];
HEAP[_144] = _146;
var _147 = _143+1*1;
var _149 = HEAP[0 + _memtmp+1*1];
HEAP[_147] = _149;
var _150 = _143+2*1;
var _152 = HEAP[0 + _memtmp+2*1];
HEAP[_150] = _152;
var _153 = HEAP[_this_addr];
var _154 = _153+2*3;
var _155 = HEAP[_this_addr];
var _156 = _155+0*3;
var _157 = HEAP[_this_addr];
var _158 = _157+1*3;
__ZNK3v_t5crossERKS_(_memtmp12, _156, _154);
var _159 = _158+0*1;
var _161 = HEAP[0 + _memtmp12+0*1];
HEAP[_159] = _161;
var _162 = _158+1*1;
var _164 = HEAP[0 + _memtmp12+1*1];
HEAP[_162] = _164;
var _165 = _158+2*1;
var _167 = HEAP[0 + _memtmp12+2*1];
HEAP[_165] = _167;
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK3v_t6magsqrEv(_this) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _retval;
var _0;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
var _1 = HEAP[_this_addr];
var _2 = HEAP[_this_addr];
_0 = __ZNK3v_t3dotERKS_(_1, _2);
_retval = _0;
__label__ = 0; /* _return */
var _retval1 = _retval;
STACKTOP = STACK_STACK.pop();
return _retval1;
}
function __ZNK3v_t4normEv(_agg_result, _this) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
var _0 = HEAP[_this_addr];
var _1 = __ZNK3v_t6magsqrEv(_0);
var _2 = _sqrt(_1);
var _3 = 1.000000e+00 / _2;
var _4 = HEAP[_this_addr];
__ZNK3v_tmlEd(_agg_result, _4, _3);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __Z41__static_initialization_and_destruction_0ii(___initialize_p, ___priority) {
STACK_STACK.push(STACKTOP);
var __label__;
var ___initialize_p_addr;
var ___priority_addr;
var _0 = STACKTOP; STACKTOP += 3;
var __alloca_point_ = 0;
___initialize_p_addr = ___initialize_p;
___priority_addr = ___priority;
var _1 = ___initialize_p_addr;
var _2 = 0+(_1 == 1);
if (_2) { __label__ = 1; /* _bb */ } else { __label__ = 3; /* _bb2 */ }
_bb: do {
if (__label__ == 1) {
var _3 = ___priority_addr;
var _4 = 0+(_3 == 65535);
if (_4) { __label__ = 2; /* _bb1 */ } else { __label__ = 3; /* _bb2 */ break _bb; }
__ZNSt8ios_base4InitC1Ev(__ZStL8__ioinit);
var _5 = ___cxa_atexit(___tcf_0, 0, ___dso_handle);
__ZN3v_tC1Eddd(_0, -5.000000e-01, -6.500000e-01, 9.000000e-01);
__ZNK3v_t4normEv(__ZL5light, _0);
__label__ = 3; /* _bb2 */ break _bb;
}
} while(0);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZNK8sphere_t9intersectERK5ray_t(_this, _ray) {
STACK_STACK.push(STACKTOP);
var __label__;
var _this_addr = STACKTOP; STACKTOP += 1;
var _ray_addr = STACKTOP; STACKTOP += 1;
var _retval;
var _iftmp_88;
var _0;
var _v = STACKTOP; STACKTOP += 3;
var _b;
var _disc;
var _d;
var _t2;
var _t1;
var __alloca_point_ = 0;
HEAP[_this_addr] = _this;
HEAP[_ray_addr] = _ray;
var _1 = HEAP[_ray_addr];
var _2 = _1+0*3;
var _3 = HEAP[_this_addr];
var _4 = _3+_struct_hit_t___FLATTENER[0];
__ZNK3v_tmiERKS_(_v, _4, _2);
var _5 = HEAP[_ray_addr];
var _6 = _5+1*3;
_b = __ZNK3v_t3dotERKS_(_6, _v);
var _8 = _b;
var _9 = _b;
var _10 = _8 * _9;
var _11 = __ZNK3v_t6magsqrEv(_v);
var _12 = _10 - _11;
var _13 = HEAP[_this_addr];
var _15 = HEAP[0 + _13+_struct_hit_t___FLATTENER[1]];
var _16 = HEAP[_this_addr];
var _18 = HEAP[0 + _16+_struct_hit_t___FLATTENER[1]];
var _19 = _15 * _18;
_disc = _12 + _19;
var _21 = _disc;
var _22 = 0+(_21 < 0.000000e+00);
if (_22) { __label__ = 1; /* _bb */ } else { __label__ = 2; /* _bb1 */ }
_bb: do {
if (__label__ == 1) {
_0 = Infinity;
__label__ = 10; /* _bb7 */ break _bb;
}
else if (__label__ == 2) {
_d = _sqrt(_disc);
var _25 = _b;
var _26 = _d;
_t2 = _25 + _26;
var _28 = _b;
var _29 = _d;
_t1 = _28 - _29;
var _31 = _t2;
var _32 = 0+(_31 < 0.000000e+00);
if (_32) { __label__ = 3; /* _bb2 */ } else { __label__ = 6; /* _bb3 */ }
_bb2: do {
if (__label__ == 3) {
_0 = Infinity;
__label__ = 10; /* _bb7 */ break _bb;
}
else if (__label__ == 6) {
var _33 = _t1;
var _34 = 0+(_33 > 0.000000e+00);
if (_34) { __label__ = 7; /* _bb4 */ } else { __label__ = 8; /* _bb5 */ }
_bb4: do {
if (__label__ == 7) {
_iftmp_88 = _t1;
__label__ = 5; /* _bb6 */ break _bb4;
}
else if (__label__ == 8) {
_iftmp_88 = _t2;
__label__ = 5; /* _bb6 */ break _bb4;
}
} while(0);
_0 = _iftmp_88;
__label__ = 10; /* _bb7 */ break _bb;
}
} while(0);
}
} while(0);
_retval = _0;
__label__ = 0; /* _return */
var _retval8 = _retval;
STACKTOP = STACK_STACK.pop();
return _retval8;
}
function __ZN6node_t9intersectILb0EEEvRK5ray_tR5hit_t(_ray, _hit) {
STACK_STACK.push(STACKTOP);
var __label__;
var _ray_addr = STACKTOP; STACKTOP += 1;
var _hit_addr = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 3;
var _1 = STACKTOP; STACKTOP += 3;
var _retval_114;
var _p = STACKTOP; STACKTOP += 1;
var _t;
var _memtmp = STACKTOP; STACKTOP += 3;
var __alloca_point_ = 0;
HEAP[_ray_addr] = _ray;
HEAP[_hit_addr] = _hit;
var _2 = HEAP[__ZL4pool];
HEAP[_p] = _2;
__label__ = 8; /* _bb5 */
_bb5: while(1) { // _bb5
var _50 = HEAP[__ZL3end];
var _51 = HEAP[_p];
var _52 = 0+(_51 < _50);
if (_52) { __label__ = 1; /* _bb */ } else { __label__ = 5; /* _bb6 */ break _bb5; }
var _3 = HEAP[_p];
var _4 = _3+_struct_node_t___FLATTENER[0];
var _5 = HEAP[_ray_addr];
var _6 = __ZNK8sphere_t9intersectERK5ray_t(_4, _5);
var _7 = HEAP[_hit_addr];
var _9 = HEAP[0 + _7+_struct_hit_t___FLATTENER[1]];
var _10 = 0+(_6 >= _9);
_retval_114 = _10;
var _12 = _retval_114;
var _toBool = 0+(_12 != 0);
if (_toBool) { __label__ = 2; /* _bb1 */ } else { __label__ = 3; /* _bb2 */ }
_bb1: do {
if (__label__ == 2) {
var _13 = HEAP[_p];
var _15 = HEAP[0 + _13+_struct_node_t___FLATTENER[2]];
var _16 = HEAP[_p];
var _17 = _16+9*_15;
HEAP[_p] = _17;
__label__ = 8; /* _bb5 */ continue _bb5;
}
else if (__label__ == 3) {
var _18 = HEAP[_p];
var _19 = _18+_struct_node_t___FLATTENER[1];
var _20 = HEAP[_ray_addr];
_t = __ZNK8sphere_t9intersectERK5ray_t(_19, _20);
var _22 = HEAP[_hit_addr];
var _24 = HEAP[0 + _22+_struct_hit_t___FLATTENER[1]];
var _25 = _t;
var _26 = 0+(_24 > _25);
if (_26) { __label__ = 6; /* _bb3 */ } else { __label__ = 7; /* _bb4 */ }
_bb3: do {
if (__label__ == 6) {
var _27 = HEAP[_hit_addr];
var _28 = _27+_struct_hit_t___FLATTENER[1];
HEAP[_28] = _t;
var _30 = HEAP[_ray_addr];
var _31 = _30+1*3;
__ZNK3v_tmlEd(_0, _31, _t);
var _33 = HEAP[_ray_addr];
var _34 = _33+0*3;
__ZNK3v_tplERKS_(_1, _34, _0);
var _35 = HEAP[_p];
var _36 = _35+_struct_node_t___FLATTENER[1];
var _37 = HEAP[_hit_addr];
var _38 = _37+_struct_hit_t___FLATTENER[0];
__ZNK8sphere_t10get_normalERK3v_t(_memtmp, _36, _1);
var _39 = _38+0*1;
var _41 = HEAP[0 + _memtmp+0*1];
HEAP[_39] = _41;
var _42 = _38+1*1;
var _44 = HEAP[0 + _memtmp+1*1];
HEAP[_42] = _44;
var _45 = _38+2*1;
var _47 = HEAP[0 + _memtmp+2*1];
HEAP[_45] = _47;
__label__ = 7; /* _bb4 */ break _bb3;
}
} while(0);
var _48 = HEAP[_p];
var _49 = _48+9*1;
HEAP[_p] = _49;
__label__ = 8; /* _bb5 */ continue _bb5;
}
} while(0);
}
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZN6node_t9intersectILb1EEEvRK5ray_tR5hit_t(_ray, _hit) {
STACK_STACK.push(STACKTOP);
var __label__;
var _ray_addr = STACKTOP; STACKTOP += 1;
var _hit_addr = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 3;
var _1 = STACKTOP; STACKTOP += 3;
var _retval_116;
var _p = STACKTOP; STACKTOP += 1;
var _t;
var __alloca_point_ = 0;
HEAP[_ray_addr] = _ray;
HEAP[_hit_addr] = _hit;
var _2 = HEAP[__ZL4pool];
HEAP[_p] = _2;
__label__ = 8; /* _bb5 */
_bb5: while(1) { // _bb5
var _32 = HEAP[__ZL3end];
var _33 = HEAP[_p];
var _34 = 0+(_33 < _32);
if (_34) { __label__ = 1; /* _bb */ } else { __label__ = 5; /* _bb6 */ break _bb5; }
var _3 = HEAP[_p];
var _4 = _3+_struct_node_t___FLATTENER[0];
var _5 = HEAP[_ray_addr];
var _6 = __ZNK8sphere_t9intersectERK5ray_t(_4, _5);
var _7 = HEAP[_hit_addr];
var _9 = HEAP[0 + _7+_struct_hit_t___FLATTENER[1]];
var _10 = 0+(_6 >= _9);
_retval_116 = _10;
var _12 = _retval_116;
var _toBool = 0+(_12 != 0);
if (_toBool) { __label__ = 2; /* _bb1 */ } else { __label__ = 3; /* _bb2 */ }
_bb1: do {
if (__label__ == 2) {
var _13 = HEAP[_p];
var _15 = HEAP[0 + _13+_struct_node_t___FLATTENER[2]];
var _16 = HEAP[_p];
var _17 = _16+9*_15;
HEAP[_p] = _17;
__label__ = 8; /* _bb5 */ continue _bb5;
}
else if (__label__ == 3) {
var _18 = HEAP[_p];
var _19 = _18+_struct_node_t___FLATTENER[1];
var _20 = HEAP[_ray_addr];
_t = __ZNK8sphere_t9intersectERK5ray_t(_19, _20);
var _22 = HEAP[_hit_addr];
var _24 = HEAP[0 + _22+_struct_hit_t___FLATTENER[1]];
var _25 = _t;
var _26 = 0+(_24 > _25);
if (_26) { __label__ = 6; /* _bb3 */ break _bb5; } else { __label__ = 7; /* _bb4 */ }
var _30 = HEAP[_p];
var _31 = _30+9*1;
HEAP[_p] = _31;
__label__ = 8; /* _bb5 */ continue _bb5;
}
} while(0);
}
_bb3: do {
if (__label__ == 6) {
var _27 = HEAP[_hit_addr];
var _28 = _27+_struct_hit_t___FLATTENER[1];
HEAP[_28] = _t;
__label__ = 5; /* _bb6 */ break _bb3;
}
} while(0);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function __ZL9ray_tracePK6node_tRK5ray_t(_scene, _ray) {
STACK_STACK.push(STACKTOP);
var __label__;
var _scene_addr = STACKTOP; STACKTOP += 1;
var _ray_addr = STACKTOP; STACKTOP += 1;
var _retval;
var _iftmp_90;
var _0 = STACKTOP; STACKTOP += 3;
var _1 = STACKTOP; STACKTOP += 3;
var _2 = STACKTOP; STACKTOP += 3;
var _3 = STACKTOP; STACKTOP += 3;
var _4 = STACKTOP; STACKTOP += 3;
var _5;
var _iftmp_89;
var _hit = STACKTOP; STACKTOP += 4;
var _diffuse;
var _sray = STACKTOP; STACKTOP += 6;
var _shit = STACKTOP; STACKTOP += 4;
var __alloca_point_ = 0;
HEAP[_scene_addr] = _scene;
HEAP[_ray_addr] = _ray;
__ZN5hit_tC1Ev(_hit);
var _6 = HEAP[_ray_addr];
__ZN6node_t9intersectILb0EEEvRK5ray_tR5hit_t(_6, _hit);
var _8 = HEAP[0 + _hit+_struct_hit_t___FLATTENER[1]];
var _9 = 0+(_8 != Infinity);
if (_9) { __label__ = 1; /* _bb */ } else { __label__ = 2; /* _bb1 */ }
_bb: do {
if (__label__ == 1) {
var _10 = _hit+_struct_hit_t___FLATTENER[0];
var _11 = __ZNK3v_t3dotERKS_(_10, __ZL5light);
_iftmp_89 = -0.000000e+00 - _11;
__label__ = 3; /* _bb2 */ break _bb;
}
else if (__label__ == 2) {
_iftmp_89 = 0.000000e+00;
__label__ = 3; /* _bb2 */ break _bb;
}
} while(0);
_diffuse = _iftmp_89;
var _14 = _diffuse;
var _15 = 0+(_14 <= 0.000000e+00);
if (_15) { __label__ = 6; /* _bb3 */ } else { __label__ = 7; /* _bb4 */ }
_bb3: do {
if (__label__ == 6) {
_5 = 0.000000e+00;
__label__ = 11; /* _bb8 */ break _bb3;
}
else if (__label__ == 7) {
__ZNK3v_tngEv(_4, __ZL5light);
var _16 = _hit+_struct_hit_t___FLATTENER[0];
__ZNK3v_tmlEd(_2, _16, 1.000000e-12);
var _18 = HEAP[0 + _hit+_struct_hit_t___FLATTENER[1]];
var _19 = HEAP[_ray_addr];
var _20 = _19+1*3;
__ZNK3v_tmlEd(_0, _20, _18);
var _21 = HEAP[_ray_addr];
var _22 = _21+0*3;
__ZNK3v_tplERKS_(_1, _22, _0);
__ZNK3v_tplERKS_(_3, _1, _2);
__ZN5ray_tC1ERK3v_tS2_(_sray, _3, _4);
__ZN5hit_tC1Ev(_shit);
__ZN6node_t9intersectILb1EEEvRK5ray_tR5hit_t(_sray, _shit);
var _24 = HEAP[0 + _shit+_struct_hit_t___FLATTENER[1]];
var _25 = 0+(_24 == Infinity);
if (_25) { __label__ = 8; /* _bb5 */ } else { __label__ = 5; /* _bb6 */ }
_bb5: do {
if (__label__ == 8) {
_iftmp_90 = _diffuse;
__label__ = 10; /* _bb7 */ break _bb5;
}
else if (__label__ == 5) {
_iftmp_90 = 0.000000e+00;
__label__ = 10; /* _bb7 */ break _bb5;
}
} while(0);
_5 = _iftmp_90;
__label__ = 11; /* _bb8 */ break _bb3;
}
} while(0);
_retval = _5;
__label__ = 0; /* _return */
var _retval9 = _retval;
STACKTOP = STACK_STACK.pop();
return _retval9;
}
function __ZL6createP6node_tii3v_tS1_d(_n, _lvl, _dist, _c, _d, _r) {
STACK_STACK.push(STACKTOP);
var __label__;
var _n_addr = STACKTOP; STACKTOP += 1;
var _lvl_addr;
var _dist_addr;
var _r_addr;
var _retval = STACKTOP; STACKTOP += 1;
var _0 = STACKTOP; STACKTOP += 3;
var _1 = STACKTOP; STACKTOP += 3;
var _2 = STACKTOP; STACKTOP += 3;
var _3 = STACKTOP; STACKTOP += 3;
var _4 = STACKTOP; STACKTOP += 3;
var _5 = STACKTOP; STACKTOP += 3;
var _6 = STACKTOP; STACKTOP += 3;
var _7 = STACKTOP; STACKTOP += 3;
var _8 = STACKTOP; STACKTOP += 3;
var _9 = STACKTOP; STACKTOP += 3;
var _10 = STACKTOP; STACKTOP += 3;
var _11 = STACKTOP; STACKTOP += 3;
var _12 = STACKTOP; STACKTOP += 3;
var _13 = STACKTOP; STACKTOP += 3;
var _14 = STACKTOP; STACKTOP += 1;
var _15 = STACKTOP; STACKTOP += 1;
var _16 = STACKTOP; STACKTOP += 1;
var _iftmp_104;
var _iftmp_103 = STACKTOP; STACKTOP += 1;
var _17 = STACKTOP; STACKTOP += 1;
var _18 = STACKTOP; STACKTOP += 4;
var _19 = STACKTOP; STACKTOP += 1;
var _20 = STACKTOP; STACKTOP += 4;
var _21 = STACKTOP; STACKTOP += 1;
var _b = STACKTOP; STACKTOP += 9;
var _nr;
var _daL;
var _daU;
var _a;
var _i;
var _ndir = STACKTOP; STACKTOP += 3;
var _i11;
var _ndir13 = STACKTOP; STACKTOP += 3;
var __alloca_point_ = 0;
HEAP[_n_addr] = _n;
_lvl_addr = _lvl;
_dist_addr = _dist;
_r_addr = _r;
var _22 = _r_addr;
var _23 = _22 * 2.000000e+00;
__ZN8sphere_tC1ERK3v_td(_20, _c, _23);
HEAP[_21] = _20;
__ZN8sphere_tC1ERK3v_td(_18, _c, _r_addr);
HEAP[_19] = _18;
var _25 = HEAP[_n_addr];
var _27 = __ZnwjPv(68, _25);
HEAP[_17] = _27;
var _29 = HEAP[_17];
var _30 = 0+(_29 != 0);
if (_30) { __label__ = 1; /* _bb */ } else { __label__ = 7; /* _bb4 */ }
_bb: do {
if (__label__ == 1) {
var _31 = _lvl_addr;
var _32 = 0+(_31 > 1);
if (_32) { __label__ = 2; /* _bb1 */ } else { __label__ = 3; /* _bb2 */ }
_bb1: do {
if (__label__ == 2) {
_iftmp_104 = _dist_addr;
__label__ = 6; /* _bb3 */ break _bb1;
}
else if (__label__ == 3) {
_iftmp_104 = 1;
__label__ = 6; /* _bb3 */ break _bb1;
}
} while(0);
var _34 = HEAP[_17];
var _35 = HEAP[_21];
var _36 = HEAP[_19];
__ZN6node_tC1ERK8sphere_tS2_l(_34, _35, _36, _iftmp_104);
var _38 = HEAP[_17];
HEAP[_iftmp_103] = _38;
__label__ = 8; /* _bb5 */ break _bb;
}
else if (__label__ == 7) {
var _39 = HEAP[_17];
HEAP[_iftmp_103] = _39;
__label__ = 8; /* _bb5 */ break _bb;
}
} while(0);
var _40 = HEAP[_iftmp_103];
var _41 = _40+9*1;
HEAP[_n_addr] = _41;
var _42 = _lvl_addr;
var _43 = 0+(_42 <= 1);
if (_43) { __label__ = 5; /* _bb6 */ } else { __label__ = 10; /* _bb7 */ }
_bb6: do {
if (__label__ == 5) {
var _44 = HEAP[_n_addr];
HEAP[_16] = _44;
__label__ = 13; /* _bb16 */ break _bb6;
}
else if (__label__ == 10) {
HEAP[_15] = 1;
var _45 = _dist_addr;
var _46 = _45 - 9;
var _47 = Math.floor(_46 / 9);
HEAP[_14] = _47;
var _48 = __ZSt3maxIiERKT_S2_S2_(_14, _15);
_dist_addr = HEAP[_48];
__ZN7basis_tC1ERK3v_t(_b, _d);
var _50 = _r_addr;
_nr = _50 / 3.000000e+00;
_daL = 1.0471975511965976;
_daU = 2.0943951023931953;
_a = 0.000000e+00;
_i = 0;
__label__ = 9; /* _bb9 */
_bb9: while(1) { // _bb9
var _71 = _i;
var _72 = 0+(_71 <= 5);
if (_72) { __label__ = 11; /* _bb8 */ } else { __label__ = 4; /* _bb10 */ break _bb9; }
var _53 = _cos(_a);
var _54 = _b+2*3;
__ZNK3v_tmlEd(_12, _54, _53);
var _56 = _sin(_a);
var _57 = _b+1*3;
__ZNK3v_tmlEd(_10, _57, _56);
__ZNK3v_tmlEd(_9, _d, -2.000000e-01);
__ZNK3v_tplERKS_(_11, _9, _10);
__ZNK3v_tplERKS_(_13, _11, _12);
__ZNK3v_t4normEv(_ndir, _13);
var _58 = _r_addr;
var _59 = _nr;
var _60 = _58 + _59;
__ZNK3v_tmlEd(_7, _ndir, _60);
__ZNK3v_tplERKS_(_8, _c, _7);
var _61 = _lvl_addr;
var _62 = _61 - 1;
var _63 = HEAP[_n_addr];
var _66 = __ZL6createP6node_tii3v_tS1_d(_63, _62, _dist_addr, _8, _ndir, _nr);
HEAP[_n_addr] = _66;
var _67 = _a;
_a = _67 + 1.0471975511965976;
var _69 = _i;
_i = _69 + 1;
__label__ = 9; /* _bb9 */ continue _bb9;
}
var _73 = _a;
_a = _73 - 0.3490658503988659;
_i11 = 0;
__label__ = 14; /* _bb14 */
_bb14: while(1) { // _bb14
var _94 = _i11;
var _95 = 0+(_94 <= 2);
if (_95) { __label__ = 15; /* _bb12 */ } else { __label__ = 16; /* _bb15 */ break _bb14; }
var _76 = _cos(_a);
var _77 = _b+2*3;
__ZNK3v_tmlEd(_5, _77, _76);
var _79 = _sin(_a);
var _80 = _b+1*3;
__ZNK3v_tmlEd(_3, _80, _79);
__ZNK3v_tmlEd(_2, _d, 6.000000e-01);
__ZNK3v_tplERKS_(_4, _2, _3);
__ZNK3v_tplERKS_(_6, _4, _5);
__ZNK3v_t4normEv(_ndir13, _6);
var _81 = _r_addr;
var _82 = _nr;
var _83 = _81 + _82;
__ZNK3v_tmlEd(_0, _ndir13, _83);
__ZNK3v_tplERKS_(_1, _c, _0);
var _84 = _lvl_addr;
var _85 = _84 - 1;
var _86 = HEAP[_n_addr];
var _89 = __ZL6createP6node_tii3v_tS1_d(_86, _85, _dist_addr, _1, _ndir13, _nr);
HEAP[_n_addr] = _89;
var _90 = _a;
_a = _90 + 2.0943951023931953;
var _92 = _i11;
_i11 = _92 + 1;
__label__ = 14; /* _bb14 */ continue _bb14;
}
var _96 = HEAP[_n_addr];
HEAP[_16] = _96;
__label__ = 13; /* _bb16 */ break _bb6;
}
} while(0);
var _97 = HEAP[_16];
HEAP[_retval] = _97;
__label__ = 0; /* _return */
var _retval17 = HEAP[_retval];
STACKTOP = STACK_STACK.pop();
return _retval17;
}
function __ZL10trace_lineiii(_width, _height, _y) {
STACK_STACK.push(STACKTOP);
var __label__;
var _width_addr;
var _height_addr;
var _y_addr;
var _0 = STACKTOP; STACKTOP += 3;
var _1 = STACKTOP; STACKTOP += 3;
var _2;
var _3 = STACKTOP; STACKTOP += 1;
var _4 = STACKTOP; STACKTOP += 1;
var _retval_91 = STACKTOP; STACKTOP += 1;
var _5 = STACKTOP; STACKTOP += 3;
var _w = STACKTOP; STACKTOP += 1;
var _h = STACKTOP; STACKTOP += 1;
var _rcp;
var _scale;
var _ray = STACKTOP; STACKTOP += 6;
var _rgss = STACKTOP; STACKTOP += 12;
var _scan = STACKTOP; STACKTOP += 3;
var _i;
var _j;
var _g;
var _idx;
var _memtmp = STACKTOP; STACKTOP += 3;
var _k;
var __alloca_point_ = 0;
_width_addr = _width;
_height_addr = _height;
_y_addr = _y;
var _6 = _width_addr;
var _7 = _6;
HEAP[_w] = _7;
var _8 = _height_addr;
var _9 = _8;
HEAP[_h] = _9;
_rcp = 5.000000e-01;
_scale = 6.400000e+01;
__ZN3v_tC1Eddd(_5, 0.000000e+00, 0.000000e+00, -4.500000e+00);
__ZN5ray_tC1ERK3v_t(_ray, _5);
var _10 = _rgss+0*3;
HEAP[_4] = _10;
var _11 = HEAP[_4];
HEAP[_3] = _11;
_2 = 3;
__label__ = 2; /* _bb1 */
_bb1: while(1) { // _bb1
var _17 = _2;
var _18 = 0+(_17 != -1);
if (_18) { __label__ = 1; /* _bb */ } else { __label__ = 3; /* _bb2 */ break _bb1; }
var _12 = HEAP[_3];
__ZN3v_tC1Ev(_12);
var _13 = HEAP[_3];
var _14 = _13+3*1;
HEAP[_3] = _14;
var _15 = _2;
_2 = _15 - 1;
__label__ = 2; /* _bb1 */ continue _bb1;
}
var _19 = HEAP[_4];
HEAP[_retval_91] = _19;
_i = 0;
__label__ = 7; /* _bb4 */
_bb4: while(1) { // _bb4
var _49 = _i;
var _50 = 0+(_49 <= 3);
if (_50) { __label__ = 6; /* _bb3 */ } else { __label__ = 8; /* _bb5 */ break _bb4; }
var _20 = _i;
var _22 = __ZL4grid+_i*2;
var _24 = HEAP[0 + _22+1*1];
var _25 = _24 * 5.000000e-01;
var _26 = HEAP[_h];
var _27 = _26 / -2.000000e+00;
var _28 = _25 + _27;
var _30 = __ZL4grid+_i*2;
var _32 = HEAP[0 + _30+0*1];
var _33 = _32 * 5.000000e-01;
var _34 = HEAP[_w];
var _35 = _34 / -2.000000e+00;
var _36 = _33 + _35;
__ZN3v_tC1Eddd(_1, _36, _28, 0.000000e+00);
var _37 = _rgss+_20*3;
var _38 = _37+0*1;
var _40 = HEAP[0 + _1+0*1];
HEAP[_38] = _40;
var _41 = _37+1*1;
var _43 = HEAP[0 + _1+1*1];
HEAP[_41] = _43;
var _44 = _37+2*1;
var _46 = HEAP[0 + _1+2*1];
HEAP[_44] = _46;
var _47 = _i;
_i = _47 + 1;
__label__ = 7; /* _bb4 */ continue _bb4;
}
var _51 = __ZSt3maxIdERKT_S2_S2_(_w, _h);
var _52 = HEAP[_51];
var _53 = _y_addr;
var _54 = _53;
__ZN3v_tC1Eddd(_scan, 0.000000e+00, _54, _52);
var _55 = HEAP[_screen];
var _56 = _SDL_LockSurface(_55);
_j = _width_addr;
__label__ = 14; /* _bb14 */
_bb14: while(1) { // _bb14
var _112 = _j;
var _113 = 0+(_112 != 0);
if (_113) { __label__ = 5; /* _bb6 */ } else { __label__ = 16; /* _bb15 */ break _bb14; }
_g = 0.000000e+00;
_idx = 0;
__label__ = 11; /* _bb8 */
_bb8: while(1) { // _bb8
var _76 = _idx;
var _77 = 0+(_76 <= 3);
if (_77) { __label__ = 10; /* _bb7 */ } else { __label__ = 9; /* _bb9 */ break _bb8; }
var _59 = _rgss+_idx*3;
__ZNK3v_tplERKS_(_0, _scan, _59);
var _60 = _ray+1*3;
__ZNK3v_t4normEv(_memtmp, _0);
var _61 = _60+0*1;
var _63 = HEAP[0 + _memtmp+0*1];
HEAP[_61] = _63;
var _64 = _60+1*1;
var _66 = HEAP[0 + _memtmp+1*1];
HEAP[_64] = _66;
var _67 = _60+2*1;
var _69 = HEAP[0 + _memtmp+2*1];
HEAP[_67] = _69;
var _70 = HEAP[__ZL4pool];
var _71 = __ZL9ray_tracePK6node_tRK5ray_t(_70, _ray);
var _72 = _g;
_g = _71 + _72;
var _74 = _idx;
_idx = _74 + 1;
__label__ = 11; /* _bb8 */ continue _bb8;
}
_k = 0;
__label__ = 15; /* _bb12 */
_bb12: while(1) { // _bb12
var _104 = _k;
var _105 = 0+(_104 <= 2);
if (_105) { __label__ = 12; /* _bb11 */ } else { __label__ = 17; /* _bb13 */ break _bb12; }
var _78 = HEAP[_screen];
var _80 = HEAP[0 + _78+_struct_SDL_Surface___FLATTENER[5]];
var _81 = _width_addr;
var _82 = _81;
var _84 = HEAP[0 + _scan+1*1];
var _85 = _82 - _84;
var _86 = _width_addr;
var _87 = _86;
var _88 = _85 * _87;
var _89 = _88 * 4.000000e+00;
var _91 = HEAP[0 + _scan+0*1];
var _92 = _91 * 4.000000e+00;
var _93 = _89 + _92;
var _94 = Math.floor(_93);
var _95 = _80+1*_94;
var _96 = _g;
var _97 = _96 * 6.400000e+01;
var _98 = Math.floor(_97);
var _99 = _98;
var _101 = _95+1*_k;
HEAP[_101] = _99;
var _102 = _k;
_k = _102 + 1;
__label__ = 15; /* _bb12 */ continue _bb12;
}
var _107 = HEAP[0 + _scan+0*1];
var _108 = _107 + 1.000000e+00;
var _109 = _scan+0*1;
HEAP[_109] = _108;
var _110 = _j;
_j = _110 - 1;
__label__ = 14; /* _bb14 */ continue _bb14;
}
var _114 = HEAP[_screen];
_SDL_UnlockSurface(_114);
var _115 = HEAP[_screen];
var _116 = _SDL_Flip(_115);
__label__ = 0; /* _return */
STACKTOP = STACK_STACK.pop();
return;
}
function _main(_argc, _argv) {
STACK_STACK.push(STACKTOP);
var __label__;
var _argc_addr;
var _argv_addr = STACKTOP; STACKTOP += 1;
var _retval;
var _0;
var _1 = STACKTOP; STACKTOP += 3;
var _2 = STACKTOP; STACKTOP += 3;
var _3 = STACKTOP; STACKTOP += 3;
var _4;
var _5 = STACKTOP; STACKTOP += 1;
var _6 = STACKTOP; STACKTOP += 1;
var _retval_108 = STACKTOP; STACKTOP += 1;
var _count_107;
var _7 = STACKTOP; STACKTOP += 1;
var _retval_106;
var _8 = STACKTOP; STACKTOP += 1;
var _9 = STACKTOP; STACKTOP += 1;
var _iftmp_105;
var _lvl;
var _count;
var _dec;
var _y;
var __alloca_point_ = 0;
_argc_addr = _argc;
HEAP[_argv_addr] = _argv;
var _10 = _argc_addr;
var _11 = 0+(_10 == 2);
if (_11) { __label__ = 1; /* _bb */ } else { __label__ = 2; /* _bb1 */ }
_bb: do {
if (__label__ == 1) {
HEAP[_9] = 2;
var _12 = HEAP[_argv_addr];
var _14 = HEAP[0 + _12+1*1];
var _15 = _atoi(_14);
HEAP[_8] = _15;
var _16 = __ZSt3maxIiERKT_S2_S2_(_8, _9);
_iftmp_105 = HEAP[_16];
__label__ = 3; /* _bb2 */ break _bb;
}
else if (__label__ == 2) {
_iftmp_105 = 6;
__label__ = 3; /* _bb2 */ break _bb;
}
} while(0);
_lvl = _iftmp_105;
_count = 9;
_dec = _lvl;
__label__ = 7; /* _bb4 */
_bb4: while(1) { // _bb4
var _23 = _dec;
_dec = _23 - 1;
var _25 = _dec;
var _26 = 0+(_25 > 1);
_retval_106 = _26;
var _28 = _retval_106;
var _toBool = 0+(_28 != 0);
if (_toBool) { __label__ = 6; /* _bb3 */ } else { __label__ = 8; /* _bb5 */ break _bb4; }
var _20 = _count;
var _21 = _20 + 1;
_count = _21 * 9;
__label__ = 7; /* _bb4 */ continue _bb4;
}
var _29 = _count;
_count = _29 + 1;
_count_107 = _count;
var _32 = _count_107;
var _33 = _32 * 68;
var _34 = __Znaj(_33);
HEAP[_7] = _34;
var _36 = HEAP[_7];
HEAP[_6] = _36;
var _38 = HEAP[_6];
HEAP[_5] = _38;
var _39 = _count_107;
_4 = _39 - 1;
__label__ = 10; /* _bb7 */
_bb7: while(1) { // _bb7
var _46 = _4;
var _47 = 0+(_46 != -1);
if (_47) { __label__ = 5; /* _bb6 */ } else { __label__ = 11; /* _bb8 */ break _bb7; }
var _41 = HEAP[_5];
__ZN6node_tC1Ev(_41);
var _42 = HEAP[_5];
var _43 = _42+9*1;
HEAP[_5] = _43;
var _44 = _4;
_4 = _44 - 1;
__label__ = 10; /* _bb7 */ continue _bb7;
}
var _48 = HEAP[_6];
HEAP[_retval_108] = _48;
var _49 = HEAP[_retval_108];
var _50 = _49;
var _51 = HEAP[_7];
HEAP[__ZL4pool] = _51;
var _53 = HEAP[__ZL4pool];
var _55 = _53+9*_count;
HEAP[__ZL3end] = _55;
__ZN3v_tC1Eddd(_2, 2.500000e-01, 1.000000e+00, -5.000000e-01);
__ZNK3v_t4normEv(_3, _2);
__ZN3v_tC1Eddd(_1, 0.000000e+00, 0.000000e+00, 0.000000e+00);
var _56 = HEAP[__ZL4pool];
var _59 = __ZL6createP6node_tii3v_tS1_d(_56, _lvl, _count, _1, _3, 1.000000e+00);
return; // XXX
var _60 = _SDL_Init(32);
var _61 = _SDL_SetVideoMode(512, 512, 32, 0);
HEAP[_screen] = _61;
_y = 511;
__label__ = 4; /* _bb10 */
_bb10: while(1) { // _bb10
var _65 = _y;
var _66 = 0+(_65 >= 0);
if (_66) { __label__ = 9; /* _bb9 */ } else { __label__ = 12; /* _bb11 */ break _bb10; }
__ZL10trace_lineiii(512, 512, _y);
var _63 = _y;
_y = _63 - 1;
__label__ = 4; /* _bb10 */ continue _bb10;
}
_SDL_Delay(20000);
_SDL_Quit();
_0 = 0;
_retval = _0;
__label__ = 0; /* _return */
var _retval12 = _retval;
STACKTOP = STACK_STACK.pop();
return _retval12;
}
// === Auto-generated postamble setup entry stuff ===
function run(args) {
__initializeRuntime__();
var argc = args.length+1;
function pad() {
for (var i = 0; i < 1-1; i++) {
argv.push(0);
}
}
var argv = [Pointer_make(intArrayFromString("/bin/this.program"), null) ];
pad();
for (var i = 0; i < argc-1; i = i + 1) {
argv.push(Pointer_make(intArrayFromString(args[i]), null));
pad();
}
argv = Pointer_make(argv, null);
__globalConstructor__();
_main(argc, argv);
while( __ATEXIT__.length > 0) {
__ATEXIT__.pop()();
}
}
|