diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rwxr-xr-x | emcc | 9 | ||||
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/library.js | 43 | ||||
-rw-r--r-- | src/preamble.js | 25 | ||||
-rw-r--r-- | src/proxyClient.js | 54 | ||||
-rw-r--r-- | src/runtime.js | 22 | ||||
-rw-r--r-- | src/settings.js | 11 | ||||
-rw-r--r-- | src/utility.js | 6 | ||||
-rw-r--r-- | system/include/emscripten/emscripten.h | 21 | ||||
-rw-r--r-- | tests/cases/boolret_fastcomp.ll | 31 | ||||
-rw-r--r-- | tests/cases/boolret_fastcomp.txt | 2 | ||||
-rw-r--r-- | tests/core/emscripten_get_compiler_setting.c | 11 | ||||
-rw-r--r-- | tests/core/emscripten_get_compiler_setting.out | 2 | ||||
-rw-r--r-- | tests/fuzz/9.c | 1296 | ||||
-rw-r--r-- | tests/fuzz/9.c.txt | 1 | ||||
-rwxr-xr-x | tests/fuzz/csmith_driver.py | 44 | ||||
-rwxr-xr-x | tests/fuzz/test.sh | 3 | ||||
-rw-r--r-- | tests/test_core.py | 13 | ||||
-rw-r--r-- | tools/js-optimizer.js | 27 |
20 files changed, 1552 insertions, 74 deletions
@@ -124,5 +124,4 @@ a license to everyone to use it as detailed in LICENSE.) * jonas echterhoff <jonas@unity3d.com> * Sami Vaarala <sami.vaarala@iki.fi> * Jack A. Arrington <jack@epicpineapple.com> - - +* Richard Janicek <r@janicek.co> @@ -1204,7 +1204,6 @@ try: if fastcomp: shared.Settings.ASM_JS = 1 if opt_level > 0 else 2 - assert shared.Settings.ALLOW_MEMORY_GROWTH == 0, 'memory growth not supported in fastcomp yet' assert shared.Settings.UNALIGNED_MEMORY == 0, 'forced unaligned memory not supported in fastcomp' assert shared.Settings.CHECK_HEAP_ALIGN == 0, 'check heap align not supported in fastcomp yet' assert shared.Settings.SAFE_DYNCALLS == 0, 'safe dyncalls not supported in fastcomp' @@ -1246,8 +1245,8 @@ try: logging.warning('enabling js opts to allow SAFE_HEAP to work properly') if shared.Settings.ALLOW_MEMORY_GROWTH: - logging.error('Cannot enable ALLOW_MEMORY_GROWTH with asm.js, build with -s ASM_JS=0 if you need a growable heap'); - sys.exit(1); + logging.warning('Disabling asm.js validation for memory growth (memory can grow, but you lose some amount of speed)'); + shared.Settings.ASM_JS = 2 if shared.Settings.CORRECT_SIGNS >= 2 or shared.Settings.CORRECT_OVERFLOWS >= 2 or shared.Settings.CORRECT_ROUNDINGS >= 2: debug_level = 4 # must keep debug info to do line-by-line operations @@ -1308,6 +1307,10 @@ try: if js_opts: shared.Settings.RUNNING_JS_OPTS = 1 + shared.Settings.EMSCRIPTEN_VERSION = shared.EMSCRIPTEN_VERSION + shared.Settings.OPT_LEVEL = opt_level + shared.Settings.DEBUG_LEVEL = debug_level + ## Compile source code to bitcode logging.debug('compiling to bitcode') diff --git a/src/jsifier.js b/src/jsifier.js index 35846d39..c1ca893b 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1419,7 +1419,7 @@ function JSify(data, functionsOnly) { // store current list offset in tempInt, advance list offset by STACK_ALIGN, return list entry stored at tempInt return '(tempInt=' + makeGetValue(ident, Runtime.QUANTUM_SIZE, '*') + ',' + - makeSetValue(ident, Runtime.QUANTUM_SIZE, 'tempInt + ' + move, '*', null, null, null, null, ',') + ',' + + makeSetValue(ident, Runtime.QUANTUM_SIZE, asmCoercion('tempInt + ' + move, 'i32'), '*', null, null, null, null, ',') + ',' + makeGetValue(makeGetValue(ident, 0, '*'), 'tempInt', item.type) + ')'; } diff --git a/src/library.js b/src/library.js index f69b52e5..c1eb2219 100644 --- a/src/library.js +++ b/src/library.js @@ -9051,6 +9051,49 @@ LibraryManager.library = { _emscripten_log_js(flags, str); }, + emscripten_get_compiler_setting: function(name) { + name = Pointer_stringify(name); + + var ret = Runtime.getCompilerSetting(name); + if (typeof ret === 'number') return ret; + + if (!_emscripten_get_compiler_setting.cache) _emscripten_get_compiler_setting.cache = {}; + var cache = _emscripten_get_compiler_setting.cache; + var fullname = name + '__str'; + var fullret = cache[fullname]; + if (fullret) return fullret; + return cache[fullname] = allocate(intArrayFromString(ret + ''), 'i8', ALLOC_NORMAL); + }, + +#if ASM_JS +#if ALLOW_MEMORY_GROWTH + emscripten_replace_memory__asm: true, // this is used inside the asm module + emscripten_replace_memory__sig: 'viiiiiiii', // bogus + emscripten_replace_memory: function(_HEAP8, _HEAP16, _HEAP32, _HEAPU8, _HEAPU16, _HEAPU32, _HEAPF32, _HEAPF64) { + _HEAP8 = _HEAP8; // fake asm coercions + _HEAP16 = _HEAP16; + _HEAP32 = _HEAP32; + _HEAPU8 = _HEAPU8; + _HEAPU16 = _HEAPU16; + _HEAPU32 = _HEAPU32; + _HEAPF32 = _HEAPF32; + _HEAPF64 = _HEAPF64; + HEAP8 = _HEAP8; // replace the memory views + HEAP16 = _HEAP16; + HEAP32 = _HEAP32; + HEAPU8 = _HEAPU8; + HEAPU16 = _HEAPU16; + HEAPU32 = _HEAPU32; + HEAPF32 = _HEAPF32; + HEAPF64 = _HEAPF64; + }, + // this function is inside the asm block, but prevents validation as asm.js + // the codebase still benefits from being in the general asm.js shape, + // but should not declare itself as validating (which is prevented in ASM_JS == 2). + {{{ (assert(ASM_JS === 2), DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.push('emscripten_replace_memory'), '') }}} +#endif +#endif + //============================ // emscripten vector ops //============================ diff --git a/src/preamble.js b/src/preamble.js index 5038e9c4..4f715167 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -860,33 +860,19 @@ var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk #if USE_TYPED_ARRAYS function enlargeMemory() { #if ALLOW_MEMORY_GROWTH == 0 -#if ASM_JS == 0 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.'); #else - abort('Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', or (2) set Module.TOTAL_MEMORY before the program runs.'); -#endif -#else // TOTAL_MEMORY is the current size of the actual array, and DYNAMICTOP is the new top. #if ASSERTIONS - Module.printErr('Warning: Enlarging memory arrays, this is not fast, and ALLOW_MEMORY_GROWTH is not fully tested with all optimizations on! ' + [DYNAMICTOP, TOTAL_MEMORY]); // We perform safe elimination instead of elimination in this mode, but if you see this error, try to disable it and other optimizations entirely + Module.printErr('Warning: Enlarging memory arrays, this is not fast! ' + [DYNAMICTOP, TOTAL_MEMORY]); assert(DYNAMICTOP >= TOTAL_MEMORY); assert(TOTAL_MEMORY > 4); // So the loop below will not be infinite #endif - while (TOTAL_MEMORY <= DYNAMICTOP) { // Simple heuristic. Override enlargeMemory() if your program has something more optimal for it + + while (TOTAL_MEMORY <= DYNAMICTOP) { // Simple heuristic. TOTAL_MEMORY = alignMemoryPage(2*TOTAL_MEMORY); } assert(TOTAL_MEMORY <= Math.pow(2, 30)); // 2^30==1GB is a practical maximum - 2^31 is already close to possible negative numbers etc. -#if USE_TYPED_ARRAYS == 1 - var oldIHEAP = IHEAP; - Module['HEAP'] = Module['IHEAP'] = HEAP = IHEAP = new Int32Array(TOTAL_MEMORY); - IHEAP.set(oldIHEAP); - IHEAPU = new Uint32Array(IHEAP.buffer); -#if USE_FHEAP - var oldFHEAP = FHEAP; - Module['FHEAP'] = FHEAP = new Float64Array(TOTAL_MEMORY); - FHEAP.set(oldFHEAP); -#endif -#endif #if USE_TYPED_ARRAYS == 2 var oldHEAP8 = HEAP8; var buffer = new ArrayBuffer(TOTAL_MEMORY); @@ -899,6 +885,11 @@ function enlargeMemory() { Module['HEAPF32'] = HEAPF32 = new Float32Array(buffer); Module['HEAPF64'] = HEAPF64 = new Float64Array(buffer); HEAP8.set(oldHEAP8); +#else + abort('cannot enlarge memory arrays in non-ta2 modes'); +#endif +#if ASM_JS + _emscripten_replace_memory(HEAP8, HEAP16, HEAP32, HEAPU8, HEAPU16, HEAPU32, HEAPF32, HEAPF64); #endif #endif } diff --git a/src/proxyClient.js b/src/proxyClient.js index 8f4ad7a6..2d1c76fe 100644 --- a/src/proxyClient.js +++ b/src/proxyClient.js @@ -3,9 +3,39 @@ Module.ctx = Module.canvas.getContext('2d'); +// render + +var renderFrameData = null; + +function renderFrame() { + var dst = Module.canvasData.data; + if (dst.set) { + dst.set(renderFrameData); + } else { + for (var i = 0; i < renderFrameData.length; i++) { + dst[i] = renderFrameData[i]; + } + } + Module.ctx.putImageData(Module.canvasData, 0, 0); + renderFrameData = null; +} + +window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || + renderFrame; + +// end render + var worker = new Worker('{{{ filename }}}.js'); +var workerResponded = false; + worker.onmessage = function worker_onmessage(event) { + if (!workerResponded) { + workerResponded = true; + if (Module.setStatus) Module.setStatus(''); + } + var data = event.data; switch (data.target) { case 'stdout': { @@ -26,20 +56,18 @@ worker.onmessage = function worker_onmessage(event) { Module.canvas.width = data.width; Module.canvas.height = data.height; Module.canvasData = Module.ctx.getImageData(0, 0, data.width, data.height); - postMessage({ target: 'canvas', boundingClientRect: Module.canvas.getBoundingClientRect() }); + worker.postMessage({ target: 'canvas', boundingClientRect: cloneObject(Module.canvas.getBoundingClientRect()) }); break; } case 'render': { - var src = data.image.data; - var dst = Module.canvasData.data; - if (dst.set) { - dst.set(src); + if (renderFrameData) { + // previous image was not rendered yet, just update image + renderFrameData = data.image.data; } else { - for (var i = 0; i < src.length; i++) { - dst[i] = src[i]; - } + // previous image was rendered so update image and request another frame + renderFrameData = data.image.data; + window.requestAnimationFrame(renderFrame); } - Module.ctx.putImageData(Module.canvasData, 0, 0); break; } default: throw 'eh?'; @@ -50,7 +78,7 @@ worker.onmessage = function worker_onmessage(event) { } }; -function cloneEvent(event) { +function cloneObject(event) { var ret = {}; for (var x in event) { if (x == x.toUpperCase()) continue; @@ -62,20 +90,20 @@ function cloneEvent(event) { ['keydown', 'keyup', 'keypress', 'blur', 'visibilitychange'].forEach(function(event) { document.addEventListener(event, function(event) { - worker.postMessage({ target: 'document', event: cloneEvent(event) }); + worker.postMessage({ target: 'document', event: cloneObject(event) }); event.preventDefault(); }); }); ['unload'].forEach(function(event) { window.addEventListener(event, function(event) { - worker.postMessage({ target: 'window', event: cloneEvent(event) }); + worker.postMessage({ target: 'window', event: cloneObject(event) }); }); }); ['mousedown', 'mouseup', 'mousemove', 'DOMMouseScroll', 'mousewheel', 'mouseout'].forEach(function(event) { Module.canvas.addEventListener(event, function(event) { - worker.postMessage({ target: 'canvas', event: cloneEvent(event) }); + worker.postMessage({ target: 'canvas', event: cloneObject(event) }); event.preventDefault(); }, true); }); diff --git a/src/runtime.js b/src/runtime.js index a9265e70..0c724e50 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -487,6 +487,19 @@ var Runtime = { } }, +#if RETAIN_COMPILER_SETTINGS + compilerSettings: {}, +#endif + + getCompilerSetting: function(name) { +#if RETAIN_COMPILER_SETTINGS == 0 + throw 'You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work'; +#else + if (!(name in Runtime.compilerSettings)) return 'invalid compiler setting: ' + name; + return Runtime.compilerSettings[name]; +#endif + }, + #if RUNTIME_DEBUG debug: true, // Switch to false at runtime to disable logging at the right times @@ -612,3 +625,12 @@ function reSign(value, bits, ignore) { // Then 'dynamic' memory for sbrk. Runtime.GLOBAL_BASE = Runtime.alignMemory(1); +if (RETAIN_COMPILER_SETTINGS) { + var blacklist = set('RELOOPER', 'STRUCT_INFO'); + for (var x in this) { + try { + if (x[0] !== '_' && !(x in blacklist) && x == x.toUpperCase() && (typeof this[x] === 'number' || typeof this[x] === 'string' || this.isArray())) Runtime.compilerSettings[x] = this[x]; + } catch(e){} + } +} + diff --git a/src/settings.js b/src/settings.js index 1db91dca..c8114059 100644 --- a/src/settings.js +++ b/src/settings.js @@ -315,6 +315,17 @@ var EXPORT_ALL = 0; // If true, we export all the symbols. Note that this does * // still eliminate functions as dead. This just exports them on the Module object. var EXPORT_BINDINGS = 0; // Export all bindings generator functions (prefixed with emscripten_bind_). This // is necessary to use the bindings generator with asm.js +var RETAIN_COMPILER_SETTINGS = 0; // Remembers the values of these settings, and makes them accessible + // through Runtime.getCompilerSetting and emscripten_get_compiler_setting. + // To see what is retained, look for compilerSettings in the generated code. + + +var EMSCRIPTEN_VERSION = ''; // this will contain the emscripten version. you should not modify it. This + // and the following few settings are useful in combination with + // RETAIN_COMPILER_SETTINGS +var OPT_LEVEL = 0; // this will contain the optimization level (-Ox). you should not modify it. +var DEBUG_LEVEL = 0; // this will contain the debug level (-gx). you should not modify it. + // JS library functions (C functions implemented in JS) // that we include by default. If you want to make sure diff --git a/src/utility.js b/src/utility.js index 178c596b..54cc2d69 100644 --- a/src/utility.js +++ b/src/utility.js @@ -200,11 +200,11 @@ function dprint() { printErr(text); } -var PROF_ORIGIN = Date.now(); -var PROF_TIME = PROF_ORIGIN; +var _PROF_ORIGIN = Date.now(); +var _PROF_TIME = _PROF_ORIGIN; function PROF(pass) { if (!pass) { - dprint("Profiling: " + ((Date.now() - PROF_TIME)/1000) + ' seconds, total: ' + ((Date.now() - PROF_ORIGIN)/1000)); + dprint("Profiling: " + ((Date.now() - _PROF_TIME)/1000) + ' seconds, total: ' + ((Date.now() - _PROF_ORIGIN)/1000)); } PROF_TIME = Date.now(); } diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index eb5ded91..426206c4 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -420,6 +420,27 @@ int emscripten_get_worker_queue_size(worker_handle worker); #define EMSCRIPTEN_NETWORK_WEBRTC 1 void emscripten_set_network_backend(int backend); +/* + * Returns the value of a compiler setting. For example + * + * emscripten_get_compiler_setting("PRECISE_F32") + * + * will return an integer representing the value of + * PRECISE_F32 during compilation. For values containing + * anything other than an integer, a string is returned + * (you will need to cast the int return value to a char*). + * + * Some useful things this can do is provide the + * version of emscripten ("EMSCRIPTEN_VERSION"), the optimization + * level ("OPT_LEVEL"), debug level ("DEBUG_LEVEL"), etc. + * + * For this command to work, you must build with + * -s RETAIN_COMPILER_SETTINGS=1 + * as otherwise we do not want to increase the build size + * with this metadata. + */ +int emscripten_get_compiler_setting(const char *name); + /* Internal APIs. Be careful with these. */ /* diff --git a/tests/cases/boolret_fastcomp.ll b/tests/cases/boolret_fastcomp.ll new file mode 100644 index 00000000..a20cd001 --- /dev/null +++ b/tests/cases/boolret_fastcomp.ll @@ -0,0 +1,31 @@ +; ModuleID = 'tests/hello_world.bc' +target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32" +target triple = "le32-unknown-nacl" + +@.str = private unnamed_addr constant [15 x i8] c"helloworld%d.\0A\00", align 1 + +define i1 @boolretter() { + ret i1 -1 +} + +define i8 @smallretter() { + ret i8 -1 +} + +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + store i32 0, i32* %retval + %bool = call i1 ()* @boolretter() + %combined = xor i1 %bool, 1 + %int = select i1 %combined, i32 20, i32 30 + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %int) + %small = call i8 ()* @smallretter() + %bcombined = xor i8 %small, 1 + %bcheck = icmp eq i8 %bcombined, 255 + %bint = select i1 %bcheck, i32 20, i32 30 + %bcall = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %bint) + ret i32 1 +} + +declare i32 @printf(i8*, ...) diff --git a/tests/cases/boolret_fastcomp.txt b/tests/cases/boolret_fastcomp.txt new file mode 100644 index 00000000..e1ad61ab --- /dev/null +++ b/tests/cases/boolret_fastcomp.txt @@ -0,0 +1,2 @@ +helloworld30. +helloworld30. diff --git a/tests/core/emscripten_get_compiler_setting.c b/tests/core/emscripten_get_compiler_setting.c new file mode 100644 index 00000000..41eb8e38 --- /dev/null +++ b/tests/core/emscripten_get_compiler_setting.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <assert.h> +#include <emscripten.h> + +int main() { + printf("QS: %d\n", emscripten_get_compiler_setting("QUANTUM_SIZE")); + assert((unsigned)emscripten_get_compiler_setting("OPT_LEVEL") <= 3); + assert((unsigned)emscripten_get_compiler_setting("DEBUG_LEVEL") <= 4); + printf("EV: %s\n", (char*)emscripten_get_compiler_setting("EMSCRIPTEN_VERSION")); +} + diff --git a/tests/core/emscripten_get_compiler_setting.out b/tests/core/emscripten_get_compiler_setting.out new file mode 100644 index 00000000..cd520064 --- /dev/null +++ b/tests/core/emscripten_get_compiler_setting.out @@ -0,0 +1,2 @@ +QS: 4 +EV: waka diff --git a/tests/fuzz/9.c b/tests/fuzz/9.c new file mode 100644 index 00000000..3e69535e --- /dev/null +++ b/tests/fuzz/9.c @@ -0,0 +1,1296 @@ +/* + * This is a RANDOMLY GENERATED PROGRAM. + * + * Generator: csmith 2.2.0 + * Git version: bf42ffd + * Options: --no-volatiles --no-packed-struct --no-math64 + * Seed: 3993158628 + */ + +#include "csmith.h" + + +static long __undefined; + +/* --- Struct/Union Declarations --- */ +struct S0 { + signed f0 : 2; + signed f1 : 30; + const unsigned f2 : 2; + signed f3 : 15; + unsigned f4 : 13; + unsigned f5 : 2; + signed f6 : 6; + signed f7 : 19; + signed f8 : 5; +}; + +union U1 { + const int8_t f0; +}; + +/* --- GLOBAL VARIABLES --- */ +static int32_t g_2 = 0xDBC37078L; +static uint32_t g_24 = 1UL; +static int16_t g_36 = 1L; +static int32_t g_52 = 0L; +static int32_t g_53 = 0xB92BB776L; +static int32_t g_55 = 0xD870105CL; +static uint16_t g_72 = 0xB820L; +static int32_t *g_86 = &g_52; +static struct S0 g_109 = {1,-3768,1,145,49,0,-1,-585,0}; +static uint8_t g_113 = 0xB8L; +static uint8_t g_114 = 0xE1L; +static int16_t g_126[4][6] = {{0x5BB1L,0x13A7L,0x5786L,0x89D4L,0x5786L,0x13A7L},{0xD5BCL,0x5BB1L,0x5786L,2L,0x8967L,0x89D4L},{0x4E36L,2L,0x13A7L,0x13A7L,2L,0x4E36L},{0x13A7L,2L,0x4E36L,0xF1A0L,0x8967L,0x5786L}}; +static uint32_t g_141[2] = {1UL,1UL}; +static int8_t g_143 = 1L; +static uint8_t g_144 = 0x18L; +static uint16_t *g_194[1] = {&g_72}; +static int32_t g_215 = 3L; +static int32_t *g_214 = &g_215; +static int16_t g_217 = 0x0B9EL; +static int16_t *g_216 = &g_217; +static uint32_t g_234[6][6][7] = {{{4294967295UL,1UL,0xE50A6E4DL,0x7CBB9599L,0x4038AB73L,1UL,0x30275B19L},{0xEF103696L,4294967288UL,0xF9FCF56DL,4294967288UL,0xEF103696L,0UL,4UL},{0x4038AB73L,0x7CBB9599L,0xE50A6E4DL,1UL,4294967295UL,7UL,0xE50A6E4DL},{0UL,0xEF4BBCF4L,0UL,9UL,0UL,0xF9FCF56DL,0xF9FCF56DL},{0x30275B19L,0UL,0x7A5E963CL,0UL,0x30275B19L,0UL,0xE50A6E4DL},{0UL,9UL,0UL,0xEF4BBCF4L,0UL,0xF9FCF56DL,0xF01C7FA8L}},{{0xEEABF480L,0UL,0xB0A03C78L,0x3D45A5B2L,0x30275B19L,7UL,0xD95DDA20L},{0UL,0xEF4BBCF4L,1UL,0xEF4BBCF4L,0UL,0x9CA25930L,0xF01C7FA8L},{0x30275B19L,0x3D45A5B2L,0xB0A03C78L,0UL,0xEEABF480L,7UL,0xE50A6E4DL},{0UL,0xEF4BBCF4L,0UL,9UL,0UL,0xF9FCF56DL,0xF9FCF56DL},{0x30275B19L,0UL,0x7A5E963CL,0UL,0x30275B19L,0UL,0xE50A6E4DL},{0UL,9UL,0UL,0xEF4BBCF4L,0UL,0xF9FCF56DL,0xF01C7FA8L}},{{0xEEABF480L,0UL,0xB0A03C78L,0x3D45A5B2L,0x30275B19L,7UL,0xD95DDA20L},{0UL,0xEF4BBCF4L,1UL,0xEF4BBCF4L,0UL,0x9CA25930L,0xF01C7FA8L},{0x30275B19L,0x3D45A5B2L,0xB0A03C78L,0UL,0xEEABF480L,7UL,0xE50A6E4DL},{0UL,0xEF4BBCF4L,0UL,9UL,0UL,0xF9FCF56DL,0xF9FCF56DL},{0x30275B19L,0UL,0x7A5E963CL,0UL,0x30275B19L,0UL,0xE50A6E4DL},{0UL,9UL,0UL,0xEF4BBCF4L,0UL,0xF9FCF56DL,0xF01C7FA8L}},{{0xEEABF480L,0UL,0xB0A03C78L,0x3D45A5B2L,0x30275B19L,7UL,0xD95DDA20L},{0UL,0xEF4BBCF4L,1UL,0xEF4BBCF4L,0UL,0x9CA25930L,0xF01C7FA8L},{0x30275B19L,0x3D45A5B2L,0xB0A03C78L,0UL,0xEEABF480L,7UL,0xE50A6E4DL},{0UL,0xEF4BBCF4L,0UL,9UL,0UL,0xF9FCF56DL,0xF9FCF56DL},{0x30275B19L,0UL,0x7A5E963CL,0UL,0x30275B19L,0UL,0xE50A6E4DL},{0UL,9UL,0UL,0xEF4BBCF4L,0UL,0xF9FCF56DL,0xF01C7FA8L}},{{0xEEABF480L,0UL,0xB0A03C78L,0x3D45A5B2L,0x30275B19L,7UL,0xD95DDA20L},{0UL,0xEF4BBCF4L,1UL,0xEF4BBCF4L,0UL,0x9CA25930L,0xF01C7FA8L},{0x30275B19L,0x3D45A5B2L,0xB0A03C78L,0UL,0xEEABF480L,7UL,0xE50A6E4DL},{0UL,0xEF4BBCF4L,0UL,9UL,0UL,0xF9FCF56DL,0xF9FCF56DL},{0x30275B19L,0UL,0x7A5E963CL,0UL,0x30275B19L,0UL,0xE50A6E4DL},{0UL,9UL,0UL,0xEF4BBCF4L,0UL,0xF9FCF56DL,0xF01C7FA8L}},{{0x28C0AEB2L,0UL,0xFD89EE91L,0x495489C1L,0xD95DDA20L,0x177A3353L,0x7A5E963CL},{0xF9FCF56DL,4294967294UL,0x3E2A85B4L,4294967294UL,0xF9FCF56DL,4UL,0UL},{0xD95DDA20L,0x495489C1L,0xFD89EE91L,0UL,0x28C0AEB2L,0x177A3353L,0xB0A03C78L},{0x9CA25930L,4294967294UL,1UL,0xEF103696L,0xF9FCF56DL,1UL,1UL},{0xD95DDA20L,0UL,1UL,0UL,0xD95DDA20L,4294967295UL,0xB0A03C78L},{0xF9FCF56DL,0xEF103696L,1UL,4294967294UL,0x9CA25930L,1UL,0UL}}}; +static uint32_t *g_252[2][6] = {{&g_141[1],(void*)0,&g_141[1],(void*)0,&g_141[1],(void*)0},{&g_141[1],(void*)0,&g_141[1],(void*)0,&g_141[1],(void*)0}}; +static uint32_t g_312[2] = {0x15E444CFL,0x15E444CFL}; +static const union U1 g_331 = {-8L}; +static struct S0 g_350[9][8] = {{{-1,20557,0,-138,48,0,7,-279,4},{-0,-27047,1,59,12,0,3,510,2},{0,24814,0,172,41,1,5,583,-3},{1,12364,1,154,28,0,-0,-107,1},{0,24814,0,172,41,1,5,583,-3},{-0,-27047,1,59,12,0,3,510,2},{-1,20557,0,-138,48,0,7,-279,4},{-0,19189,1,60,64,1,1,97,2}},{{1,-6931,1,81,81,1,-2,483,0},{-1,-26584,0,-110,24,0,0,-318,3},{1,-10097,1,114,10,1,-4,152,3},{1,12364,1,154,28,0,-0,-107,1},{-1,20557,0,-138,48,0,7,-279,4},{-0,-28474,1,81,7,1,-7,16,2},{-1,32727,1,-65,83,1,4,-198,-0},{1,-10897,1,12,62,1,3,-592,2}},{{0,4827,1,-65,66,1,-3,-196,-3},{1,12364,1,154,28,0,-0,-107,1},{1,23006,1,51,25,1,-4,439,-4},{1,17086,1,-44,2,0,0,411,-4},{-1,20557,0,-138,48,0,7,-279,4},{1,17086,1,-44,2,0,0,411,-4},{1,23006,1,51,25,1,-4,439,-4},{1,12364,1,154,28,0,-0,-107,1}},{{1,-6931,1,81,81,1,-2,483,0},{-0,-27047,1,59,12,0,3,510,2},{0,4827,1,-65,66,1,-3,-196,-3},{1,-10897,1,12,62,1,3,-592,2},{0,24814,0,172,41,1,5,583,-3},{1,17086,1,-44,2,0,0,411,-4},{1,-6931,1,81,81,1,-2,483,0},{-0,19189,1,60,64,1,1,97,2}},{{-1,20557,0,-138,48,0,7,-279,4},{1,12364,1,154,28,0,-0,-107,1},{1,-10097,1,114,10,1,-4,152,3},{-1,-26584,0,-110,24,0,0,-318,3},{1,-6931,1,81,81,1,-2,483,0},{-0,-28474,1,81,7,1,-7,16,2},{1,-6931,1,81,81,1,-2,483,0},{-1,-26584,0,-110,24,0,0,-318,3}},{{0,4827,1,-65,66,1,-3,-196,-3},{-1,-26584,0,-110,24,0,0,-318,3},{0,4827,1,-65,66,1,-3,-196,-3},{1,17086,1,-44,2,0,0,411,-4},{-1,32727,1,-65,83,1,4,-198,-0},{-0,-27047,1,59,12,0,3,510,2},{1,23006,1,51,25,1,-4,439,-4},{-1,-26584,0,-110,24,0,0,-318,3}},{{-1,32727,1,-65,83,1,4,-198,-0},{-0,-27047,1,59,12,0,3,510,2},{1,23006,1,51,25,1,-4,439,-4},{-1,-26584,0,-110,24,0,0,-318,3},{0,24814,0,172,41,1,5,583,-3},{-0,19189,1,60,64,1,1,97,2},{-1,32727,1,-65,83,1,4,-198,-0},{-0,19189,1,60,64,1,1,97,2}},{{-1,32727,1,-65,83,1,4,-198,-0},{1,-10897,1,12,62,1,3,-592,2},{1,-10097,1,114,10,1,-4,152,3},{1,-10897,1,12,62,1,3,-592,2},{-1,32727,1,-65,83,1,4,-198,-0},{-0,-28474,1,81,7,1,-7,16,2},{-1,20557,0,-138,48,0,7,-279,4},{1,12364,1,154,28,0,-0,-107,1}},{{0,4827,1,-65,66,1,-3,-196,-3},{1,-10897,1,12,62,1,3,-592,2},{0,24814,0,172,41,1,5,583,-3},{1,17086,1,-44,2,0,0,411,-4},{1,-6931,1,81,81,1,-2,483,0},{-0,19189,1,60,64,1,1,97,2},{1,23006,1,51,25,1,-4,439,-4},{1,-10897,1,12,62,1,3,-592,2}}}; +static uint16_t *g_351 = (void*)0; +static int16_t g_408 = 0x7620L; +static union U1 g_477 = {1L}; +static int8_t *g_487 = &g_143; +static int8_t **g_486 = &g_487; +static const int32_t g_493 = 1L; +static int8_t g_543 = (-9L); +static uint8_t *g_555 = &g_144; +static uint8_t **g_554 = &g_555; +static uint16_t g_626 = 65526UL; +static const uint32_t g_664 = 1UL; +static const uint32_t g_666[1][9][4] = {{{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL},{4294967295UL,4294967293UL,4294967295UL,4294967293UL}}}; +static uint8_t g_733 = 0UL; +static uint32_t g_776 = 4294967291UL; +static int32_t ** const g_786 = &g_214; +static int32_t ** const *g_785 = &g_786; +static int32_t ** const **g_784[2] = {&g_785,&g_785}; +static uint16_t g_807 = 65535UL; +static int32_t *g_808 = (void*)0; +static int32_t g_812 = 0xAE392FB2L; +static union U1 g_824 = {0xC0L}; +static int32_t g_825 = (-1L); +static int16_t g_891 = (-1L); +static uint32_t *g_967[10][9] = {{&g_234[2][0][1],&g_234[2][0][1],&g_141[0],&g_141[1],&g_141[0],&g_141[0],&g_141[1],&g_141[0],&g_234[2][0][1]},{&g_141[0],&g_234[4][3][3],&g_141[1],&g_234[3][1][4],&g_24,&g_141[0],&g_141[1],&g_234[2][0][1],&g_141[0]},{&g_24,&g_234[2][0][1],&g_234[2][0][1],&g_234[2][0][1],(void*)0,&g_234[2][0][1],&g_141[0],(void*)0,&g_234[4][3][3]},{&g_776,&g_234[3][1][4],&g_141[0],&g_141[1],&g_24,&g_234[2][0][1],&g_234[2][0][1],&g_234[2][0][1],(void*)0},{&g_234[3][1][4],&g_234[2][0][1],&g_24,&g_234[3][1][1],&g_234[3][1][1],&g_24,&g_234[2][0][1],&g_234[3][1][4],&g_141[0]},{&g_776,&g_24,&g_234[2][0][1],&g_24,&g_234[3][1][1],&g_141[0],&g_141[1],&g_141[1],&g_141[1]},{&g_234[4][3][3],&g_141[0],&g_24,&g_234[3][1][4],&g_24,&g_141[0],&g_234[4][3][3],&g_141[0],&g_141[0]},{&g_141[0],&g_234[2][0][1],&g_234[4][3][3],&g_234[3][1][4],&g_141[1],&g_234[3][1][1],(void*)0,&g_24,(void*)0},{(void*)0,&g_776,&g_24,&g_24,&g_776,(void*)0,&g_141[0],&g_141[0],&g_234[4][3][3]},{&g_24,&g_234[2][0][1],&g_24,&g_234[3][1][1],&g_141[0],&g_141[1],&g_141[1],&g_141[1],&g_141[1]}}; +static int32_t * const *g_1021 = &g_214; +static int32_t * const **g_1020 = &g_1021; +static union U1 **g_1028 = (void*)0; +static int8_t g_1058 = 0x12L; +static int32_t ***g_1078 = (void*)0; +static int8_t ** const g_1095 = (void*)0; +static int8_t ** const *g_1094 = &g_1095; +static const union U1 g_1177 = {-3L}; +static const int8_t *g_1218 = &g_1177.f0; +static const int8_t **g_1217 = &g_1218; + + +/* --- FORWARD DECLARATIONS --- */ +static int16_t func_1(void); +static int32_t func_11(int32_t * p_12, uint32_t p_13, const int32_t p_14, int32_t p_15, int32_t * p_16); +static uint32_t func_20(uint32_t p_21); +static const uint8_t func_31(uint8_t p_32); +static int32_t * func_40(uint32_t p_41, int32_t * p_42, int16_t * p_43, int32_t p_44, uint32_t * p_45); +static union U1 func_46(int8_t p_47); +static int32_t func_48(int32_t * p_49); +static uint16_t func_97(uint32_t p_98); +static int32_t * func_99(uint32_t * const p_100, uint8_t p_101, uint8_t p_102, const int8_t p_103); +static uint8_t func_104(const struct S0 p_105, int16_t p_106, int32_t p_107); + + +/* --- FUNCTIONS --- */ +/* ------------------------------------------ */ +/* + * reads : g_2 g_24 g_36 g_53 g_86 g_52 g_109 g_114 g_72 g_144 g_55 g_126 g_141 g_214 g_216 g_215 g_217 g_234 g_312 g_331 g_350 g_351 g_143 g_408 g_486 g_493 g_487 g_543 g_113 g_554 g_555 g_477 g_626 g_784 g_666 g_824 g_825 g_785 g_786 g_891 g_733 g_967 g_1020 g_1028 g_807 g_1058 g_1078 g_1021 + * writes: g_2 g_24 g_36 g_52 g_53 g_55 g_86 g_113 g_126 g_109.f3 g_114 g_141 g_143 g_144 g_72 g_194 g_215 g_252 g_217 g_312 g_234 g_486 g_350.f8 g_214 g_351 g_626 g_776 g_808 g_408 g_733 g_1020 g_807 g_825 g_1078 g_1094 g_1058 g_967 g_543 + */ +static int16_t func_1(void) +{ /* block id: 0 */ + int32_t l_8 = (-1L); + int32_t *l_19 = (void*)0; + uint32_t l_39 = 18446744073709551615UL; + if (g_2) + { /* block id: 1 */ + uint8_t l_3 = 0UL; + int32_t l_22 = 0xB0420410L; + uint32_t *l_23 = &g_24; + int16_t *l_35 = &g_36; + int32_t *l_1232 = &g_52; + l_3--; + for (l_3 = 2; (l_3 <= 56); l_3 = safe_add_func_int8_t_s_s(l_3, 1)) + { /* block id: 5 */ + int16_t l_9[2][5][10] = {{{0x4E76L,0xFA83L,0x1F6FL,0xCA36L,0xCA36L,0x1F6FL,0xFA83L,0x4E76L,(-1L),0xC1D1L},{0x2278L,0xF72BL,0L,0xDB82L,8L,0x1F6FL,0xEE5AL,0x2278L,0xDB82L,0xCA36L},{0x4E76L,0x80DBL,0L,8L,0x391CL,0x2278L,2L,0x4E76L,1L,0xCA36L},{0L,0xD2B5L,0x1F6FL,0xC1D1L,8L,0L,2L,0L,8L,0xC1D1L},{0x9F7CL,0x80DBL,0x9F7CL,0xC1D1L,0xCA36L,0L,0xEE5AL,0x9F7CL,1L,(-1L)}},{{0x9F7CL,0xF72BL,0x4E76L,8L,1L,0L,0xFA83L,0x9F7CL,0xDB82L,1L},{0L,0xFA83L,0x9F7CL,0xDB82L,1L,0x2278L,0x80DBL,0L,(-1L),(-1L)},{0x4E76L,0xFA83L,0x1F6FL,0xCA36L,0xCA36L,0x1F6FL,0xFA83L,0x4E76L,(-1L),0xC1D1L},{0x2278L,0xF72BL,0L,0xDB82L,8L,0x1F6FL,0xEE5AL,0x2278L,0xDB82L,0xCA36L},{0x4E76L,0x80DBL,0L,8L,0x391CL,0x2278L,2L,0x4E76L,1L,0xCA36L}}}; + int32_t *l_10 = &g_2; + int i, j, k; + (*l_10) |= (l_9[0][1][8] = l_8); + } + (*l_1232) = func_11(&l_8, (safe_rshift_func_uint16_t_u_s((((void*)0 == l_19) , (func_20((++(*l_23))) , (safe_rshift_func_uint8_t_u_s(func_31(((safe_rshift_func_uint16_t_u_s((0xFA3CL & g_2), (((!((*l_35) ^= g_24)) <= g_24) || (safe_sub_func_int32_t_s_s((l_22 <= l_39), 0xE948ECA1L))))) , 1UL)), g_109.f2)))), g_666[0][0][3])), l_22, l_22, &l_22); + } + else + { /* block id: 556 */ + int16_t l_1233 = 0x9A09L; + int8_t *l_1240 = &g_1058; + const uint8_t l_1241 = 1UL; + union U1 l_1242 = {9L}; + (*g_214) = ((g_477 , l_1233) ^ (((safe_add_func_int16_t_s_s((safe_sub_func_uint8_t_u_u((((((!((safe_mul_func_int8_t_s_s(((*l_1240) = ((*g_487) = 4L)), ((-1L) & (-7L)))) & ((((l_1241 < (l_1241 | l_1241)) , (((l_1242 , l_1233) < l_1241) & l_39)) > l_1242.f0) | 6UL))) , l_1233) != (*g_86)) == 0x7FL) != (*g_555)), (*g_555))), (-1L))) , l_39) <= (**g_1021))); + (**g_786) &= 0x557529FFL; + } + return (*g_216); +} + + +/* ------------------------------------------ */ +/* + * reads : g_216 g_52 g_824 g_555 g_144 g_141 g_825 g_487 g_217 g_785 g_786 g_214 g_331 g_554 g_143 g_234 g_626 g_891 g_733 g_114 g_486 g_312 g_967 g_55 g_477 g_1020 g_1028 g_807 g_1058 g_408 g_1078 g_215 g_350.f6 g_72 g_113 + * writes: g_72 g_52 g_114 g_217 g_808 g_126 g_143 g_214 g_408 g_234 g_144 g_626 g_733 g_351 g_141 g_252 g_113 g_1020 g_807 g_776 g_55 g_24 g_825 g_1078 g_1094 g_1058 g_215 g_2 g_967 g_543 + */ +static int32_t func_11(int32_t * p_12, uint32_t p_13, const int32_t p_14, int32_t p_15, int32_t * p_16) +{ /* block id: 328 */ + int32_t *l_794 = &g_55; + uint32_t l_821 = 0UL; + const uint32_t *l_910 = (void*)0; + const int8_t *l_915 = &g_477.f0; + uint32_t **l_968 = &g_252[0][5]; + int16_t l_969 = 0L; + struct S0 l_988[8] = {{-1,2956,0,-52,85,0,1,513,4},{-1,747,0,116,79,1,2,-456,1},{-1,2956,0,-52,85,0,1,513,4},{-1,747,0,116,79,1,2,-456,1},{-1,2956,0,-52,85,0,1,513,4},{-1,747,0,116,79,1,2,-456,1},{-1,2956,0,-52,85,0,1,513,4},{-1,747,0,116,79,1,2,-456,1}}; + uint8_t **l_992[6] = {&g_555,&g_555,&g_555,&g_555,&g_555,&g_555}; + uint32_t l_1018 = 1UL; + int32_t l_1033[10] = {(-5L),0x05CEC50EL,(-5L),0x05CEC50EL,(-5L),0x05CEC50EL,(-5L),0x05CEC50EL,(-5L),0x05CEC50EL}; + int32_t l_1163[10]; + int32_t l_1220 = 9L; + int32_t l_1229 = 0x0A906A68L; + uint32_t l_1230[8][4] = {{0x1199E2CDL,0xCCF4C89AL,5UL,0UL},{0x1199E2CDL,0xE2EEF004L,0UL,0UL},{0xCCF4C89AL,0xCCF4C89AL,0x4DCCF4F6L,0xE2EEF004L},{0xE2EEF004L,0x1199E2CDL,0x4DCCF4F6L,0x1199E2CDL},{0xCCF4C89AL,5UL,0UL,0x4DCCF4F6L},{0x1199E2CDL,5UL,5UL,0x1199E2CDL},{5UL,0x1199E2CDL,0xCCF4C89AL,0xE2EEF004L},{5UL,0xCCF4C89AL,5UL,0UL}}; + uint16_t **l_1231[2]; + int i, j; + for (i = 0; i < 10; i++) + l_1163[i] = 0x1BA9B6D4L; + for (i = 0; i < 2; i++) + l_1231[i] = &g_194[0]; +lbl_1113: + for (g_72 = (-30); (g_72 < 11); g_72 = safe_add_func_uint16_t_u_u(g_72, 8)) + { /* block id: 331 */ + int32_t *l_793 = &g_52; + int32_t *l_815 = &g_812; + uint32_t l_889 = 18446744073709551615UL; + uint16_t *l_928 = &g_626; + int32_t l_956 = 0x322A5631L; + uint32_t l_957 = 0x0E4C1742L; + for (g_52 = 0; (g_52 == (-15)); --g_52) + { /* block id: 334 */ + int32_t l_792 = 0x51FDD8C4L; + (*p_12) &= l_792; + } + l_794 = l_793; + for (g_114 = 0; (g_114 == 36); ++g_114) + { /* block id: 340 */ + uint16_t * const l_806 = &g_807; + uint16_t * const *l_805 = &l_806; + int32_t l_816 = 1L; + uint32_t **l_831 = &g_252[1][0]; + for (g_52 = (-18); (g_52 == (-27)); g_52 = safe_sub_func_int16_t_s_s(g_52, 7)) + { /* block id: 343 */ + uint16_t **l_803 = &g_351; + uint16_t * const **l_804 = (void*)0; + int32_t **l_809 = (void*)0; + int32_t *l_811 = &g_812; + int32_t **l_810 = &l_811; + int32_t *l_814 = &g_812; + int32_t **l_813[9][9][3] = {{{&l_814,(void*)0,&l_814},{&l_814,&l_814,&l_814},{&l_814,&l_814,(void*)0},{&l_814,&l_814,&l_814},{&l_814,&l_814,&l_814},{&l_814,&l_814,&l_814},{&l_814,&l_814,(void*)0},{&l_814,&l_814,&l_814},{&l_814,&l_814,(void*)0}},{{&l_814,&l_814,&l_814},{&l_814,&l_814,&l_814},{(void*)0,&l_814,&l_814},{(void*) |