summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS3
-rw-r--r--cmake/Platform/Emscripten.cmake41
-rwxr-xr-xemcc214
-rwxr-xr-xemrun1087
-rw-r--r--emrun.bat2
-rwxr-xr-xemscripten.py107
-rw-r--r--src/analyzer.js15
-rw-r--r--src/compiler.js2
-rw-r--r--src/emrun_postjs.js20
-rw-r--r--src/emrun_prejs.js5
-rw-r--r--src/emscripten-source-map.min.js31
-rw-r--r--src/hello_world.js (renamed from tests/hello_world.js)0
-rw-r--r--src/jsifier.js20
-rw-r--r--src/library.js283
-rw-r--r--src/library_egl.js20
-rw-r--r--src/library_fs.js2
-rw-r--r--src/library_gl.js93
-rw-r--r--src/library_glfw.js8
-rw-r--r--src/library_sdl.js6
-rw-r--r--src/modules.js27
-rw-r--r--src/parseTools.js35
-rw-r--r--src/preamble.js19
-rw-r--r--src/relooper/Relooper.cpp50
-rw-r--r--src/relooper/Relooper.h34
-rw-r--r--src/relooper/fuzzer.py6
-rw-r--r--src/relooper/test.cpp28
-rw-r--r--src/relooper/test.txt377
-rw-r--r--src/relooper/test2.txt40
-rw-r--r--src/relooper/test3.txt82
-rw-r--r--src/relooper/test4.txt52
-rw-r--r--src/relooper/test5.txt104
-rw-r--r--src/relooper/test6.txt38
-rw-r--r--src/relooper/test_dead.txt2
-rw-r--r--src/relooper/test_debug.txt62
-rw-r--r--src/relooper/test_fuzz1.txt100
-rw-r--r--src/relooper/test_fuzz2.txt42
-rw-r--r--src/relooper/test_fuzz3.txt36
-rw-r--r--src/relooper/test_fuzz4.txt56
-rw-r--r--src/relooper/test_fuzz5.txt122
-rw-r--r--src/relooper/test_fuzz6.txt358
-rw-r--r--src/relooper/test_inf.txt1606
-rwxr-xr-xsrc/relooper/testit.sh30
-rw-r--r--src/runtime.js2
-rw-r--r--src/simd.js7
-rw-r--r--src/utility.js8
-rw-r--r--system/include/emscripten/emscripten.h64
-rw-r--r--tests/aniso.c5
-rw-r--r--tests/cases/514_ta2.ll4
-rw-r--r--tests/cases/aliasbitcast.ll12
-rw-r--r--tests/cases/atomicrmw.ll8
-rw-r--r--tests/cases/atomicrmw_unaligned.ll8
-rw-r--r--tests/cases/breakinthemiddle.ll11
-rw-r--r--tests/cases/breakinthemiddle2.ll17
-rw-r--r--tests/cases/breakinthemiddle3.ll11
-rw-r--r--tests/cases/caall.ll12
-rw-r--r--tests/cases/complexphi.ll6
-rw-r--r--tests/cases/dash.ll8
-rw-r--r--tests/cases/emptyalloca.ll31
-rw-r--r--tests/cases/emptyasm_le32.ll5
-rw-r--r--tests/cases/entry3.ll14
-rw-r--r--tests/cases/funcptr.ll8
-rw-r--r--tests/cases/i24_mem_ta2.ll10
-rw-r--r--tests/cases/i64toi8star.ll6
-rw-r--r--tests/cases/inttoptr.ll8
-rw-r--r--tests/cases/invokebitcast.ll7
-rw-r--r--tests/cases/invokeundef.ll9
-rw-r--r--tests/cases/legalizer_ta2.ll4
-rw-r--r--tests/cases/loadbitcastgep.ll7
-rw-r--r--tests/cases/longjmp_tiny_invoke_phi.ll46
-rw-r--r--tests/cases/longjmp_tiny_invoke_phi.txt4
-rw-r--r--tests/cases/oob_ta2.ll4
-rw-r--r--tests/cases/phi24_ta2.ll7
-rw-r--r--tests/cases/phicubed.ll2
-rw-r--r--tests/cases/phientryimplicit.ll36
-rw-r--r--tests/cases/phientryimplicitmix.ll22
-rw-r--r--tests/cases/phientryimplicitmoar.ll14
-rw-r--r--tests/cases/phiself.ll4
-rw-r--r--tests/cases/ptrtoi64.ll14
-rw-r--r--tests/cases/selectstruct.ll4
-rw-r--r--tests/cases/sillybitcast.ll4
-rw-r--r--tests/cases/sillybitcast2.ll35
-rw-r--r--tests/cases/sillyfuncast.ll6
-rw-r--r--tests/cases/storebigfloat.ll2
-rw-r--r--tests/cases/storestruct.ll10
-rw-r--r--tests/cases/structphiparam.ll4
-rw-r--r--tests/cases/sub_11_0.ll2
-rw-r--r--tests/cases/switch64_ta2.ll13
-rw-r--r--tests/cases/uadd_overflow_ta2.ll22
-rw-r--r--tests/cases/unaligneddouble.ll2
-rw-r--r--tests/cases/zeroembedded.ll4
-rw-r--r--tests/cases/zeroextarg.ll6
-rw-r--r--tests/core/closebitcasts.c32
-rw-r--r--tests/core/closebitcasts.txt2
-rw-r--r--tests/core/test_addr_of_stacked.in8
-rw-r--r--tests/core/test_addr_of_stacked.out1
-rw-r--r--tests/core/test_alloca.in9
-rw-r--r--tests/core/test_alloca.out1
-rw-r--r--tests/core/test_alloca_stack.in16
-rw-r--r--tests/core/test_alloca_stack.out1
-rw-r--r--tests/core/test_array2.in13
-rw-r--r--tests/core/test_array2.out1
-rw-r--r--tests/core/test_array2b.in12
-rw-r--r--tests/core/test_array2b.out2
-rw-r--r--tests/core/test_assert.in7
-rw-r--r--tests/core/test_assert.out1
-rw-r--r--tests/core/test_atexit.in11
-rw-r--r--tests/core/test_atexit.out1
-rw-r--r--tests/core/test_atoX.in40
-rw-r--r--tests/core/test_atoX.out3
-rw-r--r--tests/core/test_atomic.in18
-rw-r--r--tests/core/test_atomic.out5
-rw-r--r--tests/core/test_bigarray.in22
-rw-r--r--tests/core/test_bigarray.out1
-rw-r--r--tests/core/test_bitfields.in20
-rw-r--r--tests/core/test_bitfields.out1
-rw-r--r--tests/core/test_bsearch.in45
-rw-r--r--tests/core/test_bsearch.out10
-rw-r--r--tests/core/test_bswap64.in48
-rw-r--r--tests/core/test_bswap64.out7
-rw-r--r--tests/core/test_ccall.in22
-rw-r--r--tests/core/test_ccall.out23
-rw-r--r--tests/core/test_class.in28
-rw-r--r--tests/core/test_class.out1
-rw-r--r--tests/core/test_constglobalstructs.in21
-rw-r--r--tests/core/test_constglobalstructs.out1
-rw-r--r--tests/core/test_conststructs.in18
-rw-r--r--tests/core/test_conststructs.out1
-rw-r--r--tests/core/test_copyop.in34
-rw-r--r--tests/core/test_copyop.out4
-rw-r--r--tests/core/test_corruption_2.in21
-rw-r--r--tests/core/test_corruption_2.out2
-rw-r--r--tests/core/test_corruption_3.in19
-rw-r--r--tests/core/test_corruption_3.out1
-rw-r--r--tests/core/test_cxx03_do_run.in10
-rw-r--r--tests/core/test_cxx03_do_run.out1
-rw-r--r--tests/core/test_demangle_stacks.in20
-rw-r--r--tests/core/test_demangle_stacks.out1
-rw-r--r--tests/core/test_direct_string_constant_usage.in9
-rw-r--r--tests/core/test_direct_string_constant_usage.out1
-rw-r--r--tests/core/test_dlfcn_self.in23
-rw-r--r--tests/core/test_dlfcn_self.out2
-rw-r--r--tests/core/test_dlmalloc_partial_2.in10
-rw-r--r--tests/core/test_dlmalloc_partial_2.out2
-rw-r--r--tests/core/test_double_i64_conversion.in69
-rw-r--r--tests/core/test_double_i64_conversion.out1
-rw-r--r--tests/core/test_dynamic_cast.in12
-rw-r--r--tests/core/test_dynamic_cast.out1
-rw-r--r--tests/core/test_dynamic_cast_2.in10
-rw-r--r--tests/core/test_dynamic_cast_2.out1
-rw-r--r--tests/core/test_dynamic_cast_b.in31
-rw-r--r--tests/core/test_dynamic_cast_b.out9
-rw-r--r--tests/core/test_emptyclass.in11
-rw-r--r--tests/core/test_emptyclass.out1
-rw-r--r--tests/core/test_emscripten_api.in15
-rw-r--r--tests/core/test_emscripten_api.out4
-rw-r--r--tests/core/test_erf.in7
-rw-r--r--tests/core/test_erf.out1
-rw-r--r--tests/core/test_errar.in19
-rw-r--r--tests/core/test_errar.out4
-rw-r--r--tests/core/test_exception_2.in18
-rw-r--r--tests/core/test_exception_2.out1
-rw-r--r--tests/core/test_fakestat.in10
-rw-r--r--tests/core/test_fakestat.out1
-rw-r--r--tests/core/test_fast_math.in13
-rw-r--r--tests/core/test_fast_math.out1
-rw-r--r--tests/core/test_fcvt.in12
-rw-r--r--tests/core/test_fcvt.out1
-rw-r--r--tests/core/test_flexarray_struct.in21
-rw-r--r--tests/core/test_flexarray_struct.out1
-rw-r--r--tests/core/test_float32_precise.in19
-rw-r--r--tests/core/test_float32_precise.out2
-rw-r--r--tests/core/test_floatvars.in27
-rw-r--r--tests/core/test_floatvars.out3
-rw-r--r--tests/core/test_frexp.in29
-rw-r--r--tests/core/test_frexp.out7
-rw-r--r--tests/core/test_funcptr.in33
-rw-r--r--tests/core/test_funcptr.out3
-rw-r--r--tests/core/test_funcptr_namecollide.in24
-rw-r--r--tests/core/test_funcptr_namecollide.out1
-rw-r--r--tests/core/test_funcptrfunc.in12
-rw-r--r--tests/core/test_funcptrfunc.out1
-rw-r--r--tests/core/test_funcs.in6
-rw-r--r--tests/core/test_funcs.out1
-rw-r--r--tests/core/test_functionpointer_libfunc_varargs.in11
-rw-r--r--tests/core/test_functionpointer_libfunc_varargs.out1
-rw-r--r--tests/core/test_fwrite_0.in18
-rw-r--r--tests/core/test_fwrite_0.out1
-rw-r--r--tests/core/test_gc.in107
-rw-r--r--tests/core/test_gc.out18
-rw-r--r--tests/core/test_getgep.in14
-rw-r--r--tests/core/test_getgep.out1
-rw-r--r--tests/core/test_getloadavg.in13
-rw-r--r--tests/core/test_getloadavg.out6
-rw-r--r--tests/core/test_getopt.in40
-rw-r--r--tests/core/test_getopt.out2
-rw-r--r--tests/core/test_getopt_long.in73
-rw-r--r--tests/core/test_getopt_long.out2
-rw-r--r--tests/core/test_globaldoubles.in23
-rw-r--r--tests/core/test_globaldoubles.out2
-rw-r--r--tests/core/test_globals.in10
-rw-r--r--tests/core/test_globals.out1
-rw-r--r--tests/core/test_gmtime.in26
-rw-r--r--tests/core/test_gmtime.out1
-rw-r--r--tests/core/test_hello_world.in5
-rw-r--r--tests/core/test_hello_world.out1
-rw-r--r--tests/core/test_i16_emcc_intrinsic.in18
-rw-r--r--tests/core/test_i16_emcc_intrinsic.out1
-rw-r--r--tests/core/test_i32_mul_precise.in12
-rw-r--r--tests/core/test_i32_mul_precise.out1
-rw-r--r--tests/core/test_i32_mul_semiprecise.in26
-rw-r--r--tests/core/test_i32_mul_semiprecise.out10
-rw-r--r--tests/core/test_i64_7z.in14
-rw-r--r--tests/core/test_i64_7z.out1
-rw-r--r--tests/core/test_i64_b.in20
-rw-r--r--tests/core/test_i64_b.out2
-rw-r--r--tests/core/test_i64_cmp.in14
-rw-r--r--tests/core/test_i64_cmp.out1
-rw-r--r--tests/core/test_i64_cmp2.in28
-rw-r--r--tests/core/test_i64_cmp2.out9
-rw-r--r--tests/core/test_i64_double.in34
-rw-r--r--tests/core/test_i64_double.out2
-rw-r--r--tests/core/test_i64_i16.in10
-rw-r--r--tests/core/test_i64_i16.out1
-rw-r--r--tests/core/test_i64_llabs.in7
-rw-r--r--tests/core/test_i64_llabs.out1
-rw-r--r--tests/core/test_i64_qdouble.in14
-rw-r--r--tests/core/test_i64_qdouble.out1
-rw-r--r--tests/core/test_i64_umul.in18
-rw-r--r--tests/core/test_i64_umul.out1
-rw-r--r--tests/core/test_i64_varargs.in29
-rw-r--r--tests/core/test_i64_varargs.out12
-rw-r--r--tests/core/test_i64_zextneg.in13
-rw-r--r--tests/core/test_i64_zextneg.out1
-rw-r--r--tests/core/test_if.in8
-rw-r--r--tests/core/test_if.out1
-rw-r--r--tests/core/test_if_else.in10
-rw-r--r--tests/core/test_if_else.out1
-rw-r--r--tests/core/test_indirectbr.in20
-rw-r--r--tests/core/test_indirectbr.out2
-rw-r--r--tests/core/test_indirectbr_many.in44
-rw-r--r--tests/core/test_indirectbr_many.out1
-rw-r--r--tests/core/test_inherit.in22
-rw-r--r--tests/core/test_inherit.out1
-rw-r--r--tests/core/test_inlinejs.in27
-rw-r--r--tests/core/test_inlinejs.out2
-rw-r--r--tests/core/test_inlinejs2.in18
-rw-r--r--tests/core/test_inlinejs2.out3
-rw-r--r--tests/core/test_inlinejs3.in20
-rw-r--r--tests/core/test_inlinejs3.out12
-rw-r--r--tests/core/test_intvars.in49
-rw-r--r--tests/core/test_intvars.out5
-rw-r--r--tests/core/test_isdigit_l.in5
-rw-r--r--tests/core/test_isdigit_l.out1
-rw-r--r--tests/core/test_isnan.in16
-rw-r--r--tests/core/test_isnan.out9
-rw-r--r--tests/core/test_istream.in13
-rw-r--r--tests/core/test_istream.out1
-rw-r--r--tests/core/test_iswdigit.in10
-rw-r--r--tests/core/test_iswdigit.out1
-rw-r--r--tests/core/test_libcextra.in10
-rw-r--r--tests/core/test_libcextra.out1
-rw-r--r--tests/core/test_libgen.in39
-rw-r--r--tests/core/test_libgen.out9
-rw-r--r--tests/core/test_linked_list.in39
-rw-r--r--tests/core/test_linked_list.out1
-rw-r--r--tests/core/test_llrint.in7
-rw-r--r--tests/core/test_llrint.out4
-rw-r--r--tests/core/test_llvm_intrinsics.in44
-rw-r--r--tests/core/test_llvm_intrinsics.out10
-rw-r--r--tests/core/test_llvm_used.in13
-rw-r--r--tests/core/test_llvm_used.out1
-rw-r--r--tests/core/test_llvmswitch.in23
-rw-r--r--tests/core/test_llvmswitch.out1
-rw-r--r--tests/core/test_longjmp.in33
-rw-r--r--tests/core/test_longjmp.out4
-rw-r--r--tests/core/test_longjmp2.in35
-rw-r--r--tests/core/test_longjmp2.out6
-rw-r--r--tests/core/test_longjmp3.in40
-rw-r--r--tests/core/test_longjmp3.out7
-rw-r--r--tests/core/test_longjmp4.in40
-rw-r--r--tests/core/test_longjmp4.out4
-rw-r--r--tests/core/test_longjmp_exc.in28
-rw-r--r--tests/core/test_longjmp_exc.out1
-rw-r--r--tests/core/test_longjmp_funcptr.in31
-rw-r--r--tests/core/test_longjmp_funcptr.out2
-rw-r--r--tests/core/test_longjmp_repeat.in13
-rw-r--r--tests/core/test_longjmp_repeat.out8
-rw-r--r--tests/core/test_longjmp_stacked.in42
-rw-r--r--tests/core/test_longjmp_stacked.out13
-rw-r--r--tests/core/test_loop.in14
-rw-r--r--tests/core/test_loop.out1
-rw-r--r--tests/core/test_mainenv.in5
-rw-r--r--tests/core/test_mainenv.out1
-rw-r--r--tests/core/test_math.in34
-rw-r--r--tests/core/test_math.out1
-rw-r--r--tests/core/test_mathfuncptr.in11
-rw-r--r--tests/core/test_mathfuncptr.out1
-rw-r--r--tests/core/test_memcpy2.in20
-rw-r--r--tests/core/test_memcpy2.out1
-rw-r--r--tests/core/test_memcpy_memcmp.in43
-rw-r--r--tests/core/test_memcpy_memcmp.out1
-rw-r--r--tests/core/test_memmove.in8
-rw-r--r--tests/core/test_memmove.out1
-rw-r--r--tests/core/test_memmove2.in22
-rw-r--r--tests/core/test_memmove2.out1
-rw-r--r--tests/core/test_memmove3.in8
-rw-r--r--tests/core/test_memmove3.out1
-rw-r--r--tests/core/test_mmap.in36
-rw-r--r--tests/core/test_mmap.out1
-rw-r--r--tests/core/test_mod_globalstruct.in18
-rw-r--r--tests/core/test_mod_globalstruct.out1
-rw-r--r--tests/core/test_multiexception.in50
-rw-r--r--tests/core/test_multiexception.out9
-rw-r--r--tests/core/test_negative_zero.in27
-rw-r--r--tests/core/test_negative_zero.out20
-rw-r--r--tests/core/test_perrar.in10
-rw-r--r--tests/core/test_perrar.out1
-rw-r--r--tests/core/test_phiundef.in30
-rw-r--r--tests/core/test_phiundef.out5
-rw-r--r--tests/core/test_poll.in28
-rw-r--r--tests/core/test_poll.out7
-rw-r--r--tests/core/test_polymorph.in33
-rw-r--r--tests/core/test_polymorph.out3
-rw-r--r--tests/core/test_printf_2.in15
-rw-r--r--tests/core/test_printf_2.out2
-rw-r--r--tests/core/test_printf_more.in11
-rw-r--r--tests/core/test_printf_more.out2
-rw-r--r--tests/core/test_ptrtoint.in14
-rw-r--r--tests/core/test_ptrtoint.out1
-rw-r--r--tests/core/test_regex.in36
-rw-r--r--tests/core/test_regex.out2
-rw-r--r--tests/core/test_reinterpreted_ptrs.in40
-rw-r--r--tests/core/test_reinterpreted_ptrs.out1
-rw-r--r--tests/core/test_rounding.in26
-rw-r--r--tests/core/test_rounding.out1
-rw-r--r--tests/core/test_simd.in69
-rw-r--r--tests/core/test_simd.out8
-rw-r--r--tests/core/test_simd2.in35
-rw-r--r--tests/core/test_simd2.out4
-rw-r--r--tests/core/test_simd3.in488
-rw-r--r--tests/core/test_simd3.out1
-rw-r--r--tests/core/test_sintvars.in24
-rw-r--r--tests/core/test_sintvars.out4
-rw-r--r--tests/core/test_sizeof.in28
-rw-r--r--tests/core/test_sizeof.out1
-rw-r--r--tests/core/test_sscanf.in91
-rw-r--r--tests/core/test_sscanf.out29
-rw-r--r--tests/core/test_sscanf_3.in17
-rw-r--r--tests/core/test_sscanf_3.out4
-rw-r--r--tests/core/test_sscanf_4.in8
-rw-r--r--tests/core/test_sscanf_4.out2
-rw-r--r--tests/core/test_sscanf_5.in13
-rw-r--r--tests/core/test_sscanf_5.out3
-rw-r--r--tests/core/test_sscanf_6.in14
-rw-r--r--tests/core/test_sscanf_6.out2
-rw-r--r--tests/core/test_sscanf_caps.in8
-rw-r--r--tests/core/test_sscanf_caps.out1
-rw-r--r--tests/core/test_sscanf_float.in10
-rw-r--r--tests/core/test_sscanf_float.out2
-rw-r--r--tests/core/test_sscanf_hex.in7
-rw-r--r--tests/core/test_sscanf_hex.out1
-rw-r--r--tests/core/test_sscanf_n.in19
-rw-r--r--tests/core/test_sscanf_n.out3
-rw-r--r--tests/core/test_sscanf_other_whitespace.in23
-rw-r--r--tests/core/test_sscanf_other_whitespace.out1
-rw-r--r--tests/core/test_sscanf_skip.in15
-rw-r--r--tests/core/test_sscanf_skip.out4
-rw-r--r--tests/core/test_sscanf_whitespace.in16
-rw-r--r--tests/core/test_sscanf_whitespace.out1
-rw-r--r--tests/core/test_stack.in16
-rw-r--r--tests/core/test_stack.out1
-rw-r--r--tests/core/test_stack_byval.in21
-rw-r--r--tests/core/test_stack_byval.out1
-rw-r--r--tests/core/test_stack_varargs.in16
-rw-r--r--tests/core/test_stack_varargs.out1
-rw-r--r--tests/core/test_stack_void.in34
-rw-r--r--tests/core/test_stack_void.out1
-rw-r--r--tests/core/test_static_variable.in18
-rw-r--r--tests/core/test_static_variable.out1
-rw-r--r--tests/core/test_statics.in35
-rw-r--r--tests/core/test_statics.out2
-rw-r--r--tests/core/test_statvfs.in24
-rw-r--r--tests/core/test_statvfs.out13
-rw-r--r--tests/core/test_std_cout_new.in21
-rw-r--r--tests/core/test_std_cout_new.out1
-rw-r--r--tests/core/test_std_exception.in13
-rw-r--r--tests/core/test_std_exception.out1
-rw-r--r--tests/core/test_stdvec.in25
-rw-r--r--tests/core/test_stdvec.out2
-rw-r--r--tests/core/test_strcasecmp.in79
-rw-r--r--tests/core/test_strcasecmp.out62
-rw-r--r--tests/core/test_strcmp_uni.in14
-rw-r--r--tests/core/test_strcmp_uni.out3
-rw-r--r--tests/core/test_strftime.in134
-rw-r--r--tests/core/test_strftime.out1
-rw-r--r--tests/core/test_strings.in54
-rw-r--r--tests/core/test_strings.out13
-rw-r--r--tests/core/test_strndup.in38
-rw-r--r--tests/core/test_strndup.out6
-rw-r--r--tests/core/test_strptime_days.in32
-rw-r--r--tests/core/test_strptime_days.out12
-rw-r--r--tests/core/test_strptime_reentrant.in45
-rw-r--r--tests/core/test_strptime_reentrant.out1
-rw-r--r--tests/core/test_strptime_tm.in27
-rw-r--r--tests/core/test_strptime_tm.out1
-rw-r--r--tests/core/test_strstr.in32
-rw-r--r--tests/core/test_strstr.out24
-rw-r--r--tests/core/test_strtok.in20
-rw-r--r--tests/core/test_strtok.out32
-rw-r--r--tests/core/test_strtol_bin.in15
-rw-r--r--tests/core/test_strtol_bin.out1
-rw-r--r--tests/core/test_strtol_dec.in21
-rw-r--r--tests/core/test_strtol_dec.out1
-rw-r--r--tests/core/test_strtol_hex.in21
-rw-r--r--tests/core/test_strtol_hex.out1
-rw-r--r--tests/core/test_strtol_oct.in21
-rw-r--r--tests/core/test_strtol_oct.out1
-rw-r--r--tests/core/test_strtoll_bin.in15
-rw-r--r--tests/core/test_strtoll_bin.out1
-rw-r--r--tests/core/test_strtoll_dec.in21
-rw-r--r--tests/core/test_strtoll_dec.out1
-rw-r--r--tests/core/test_strtoll_hex.in21
-rw-r--r--tests/core/test_strtoll_hex.out1
-rw-r--r--tests/core/test_strtoll_oct.in21
-rw-r--r--tests/core/test_strtoll_oct.out1
-rw-r--r--tests/core/test_structs.in21
-rw-r--r--tests/core/test_structs.out1
-rw-r--r--tests/core/test_time_c.in7
-rw-r--r--tests/core/test_time_c.out1
-rw-r--r--tests/core/test_timeb.in13
-rw-r--r--tests/core/test_timeb.out1
-rw-r--r--tests/core/test_tinyfuncstr.in11
-rw-r--r--tests/core/test_tinyfuncstr.out1
-rw-r--r--tests/core/test_transtrcase.in11
-rw-r--r--tests/core/test_transtrcase.out1
-rw-r--r--tests/core/test_trickystring.in16
-rw-r--r--tests/core/test_trickystring.out1
-rw-r--r--tests/core/test_typeid.in52
-rw-r--r--tests/core/test_typeid.out23
-rw-r--r--tests/core/test_uname.in14
-rw-r--r--tests/core/test_uname.out6
-rw-r--r--tests/core/test_utf.in15
-rw-r--r--tests/core/test_utf.out2
-rw-r--r--tests/core/test_varargs.in112
-rw-r--r--tests/core/test_varargs.out16
-rw-r--r--tests/core/test_vprintf.in16
-rw-r--r--tests/core/test_vprintf.out2
-rw-r--r--tests/core/test_vsnprintf.in41
-rw-r--r--tests/core/test_vsnprintf.out7
-rw-r--r--tests/core/test_white_list_exception.in21
-rw-r--r--tests/core/test_white_list_exception.out1
-rw-r--r--tests/core/test_zero_multiplication.in12
-rw-r--r--tests/core/test_zero_multiplication.out1
-rw-r--r--tests/core/test_zerodiv.in18
-rw-r--r--tests/core/test_zerodiv.out4
-rw-r--r--tests/cubegeom.c12
-rw-r--r--tests/emscripten_log/emscripten_log.cpp136
-rw-r--r--tests/fuzz/13.c107
-rw-r--r--tests/fuzz/13.c.txt1
-rw-r--r--tests/fuzz/14.c2435
-rw-r--r--tests/fuzz/14.c.txt1
-rw-r--r--tests/fuzz/16.c1317
-rw-r--r--tests/fuzz/16.c.txt1
-rw-r--r--tests/fuzz/17.c982
-rw-r--r--tests/fuzz/17.c.txt1
-rwxr-xr-xtests/fuzz/csmith_driver.py15
-rwxr-xr-xtests/fuzz/test.sh39
-rw-r--r--tests/gles2_conformance.cpp24
-rw-r--r--tests/hello_image_sdl.c43
-rw-r--r--tests/hello_world_exit.c15
-rwxr-xr-xtests/runner.py11
-rw-r--r--tests/sockets/test_getprotobyname.c87
-rw-r--r--tests/test_benchmark.py272
-rw-r--r--tests/test_browser.py45
-rw-r--r--tests/test_core.py6289
-rw-r--r--tests/test_egl.c11
-rw-r--r--tests/test_other.py166
-rw-r--r--tests/test_sanity.py56
-rw-r--r--tests/test_sockets.py3
-rw-r--r--tools/eliminator/asm-eliminator-test-output.js10
-rw-r--r--tools/eliminator/asm-eliminator-test.js10
-rw-r--r--tools/eliminator/eliminator-test-output.js11
-rw-r--r--tools/eliminator/eliminator-test.js17
-rw-r--r--tools/file_packager.py108
-rw-r--r--tools/js-optimizer.js55
-rw-r--r--tools/shared.py65
-rw-r--r--tools/test-js-optimizer-asm-pre-output.js8
-rw-r--r--tools/test-js-optimizer-asm-pre.js4
488 files changed, 15996 insertions, 7778 deletions
diff --git a/AUTHORS b/AUTHORS
index b03bfe7b..6cf860ab 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -111,3 +111,6 @@ a license to everyone to use it as detailed in LICENSE.)
* Daniel Baulig <dbaulig@fb.com> (copyright owned by Facebook, Inc.)
* Lu Wang <coolwanglu@gmail.com>
* Heidi Pan <heidi.pan@intel.com> (copyright owned by Intel)
+* Vasilis Kalintiris <ehostunreach@gmail.com>
+* Adam C. Clifton <adam@hulkamaniac.com>
+* Volo Zyko <volo.zyko@gmail.com>
diff --git a/cmake/Platform/Emscripten.cmake b/cmake/Platform/Emscripten.cmake
index c30632ca..4f434d14 100644
--- a/cmake/Platform/Emscripten.cmake
+++ b/cmake/Platform/Emscripten.cmake
@@ -109,6 +109,8 @@ set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")
# Specify the program to use when building static libraries. Force Emscripten-related command line options to clang.
set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
+set(CMAKE_CXX_ARCHIVE_APPEND "${CMAKE_AR} r <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
+set(CMAKE_C_ARCHIVE_APPEND "${CMAKE_AR} r <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
# Set a global EMSCRIPTEN variable that can be used in client CMakeLists.txt to detect when building using Emscripten.
# There seems to be some kind of bug with CMake, so you might need to define this manually on the command line with "-DEMSCRIPTEN=1".
@@ -122,22 +124,22 @@ SET(APPLE)
set(CMAKE_C_SIZEOF_DATA_PTR 4)
set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
-set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG" CACHE STRING "Emscripten-overridden CMAKE_C_FLAGS_RELEASE")
-set(CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG" CACHE STRING "Emscripten-overridden CMAKE_C_FLAGS_MINSIZEREL")
-set(CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE STRING "Emscripten-overridden CMAKE_C_FLAGS_RELWITHDEBINFO")
-set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING "Emscripten-overridden CMAKE_CXX_FLAGS_RELEASE")
-set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG" CACHE STRING "Emscripten-overridden CMAKE_CXX_FLAGS_MINSIZEREL")
-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE STRING "Emscripten-overridden CMAKE_CXX_FLAGS_RELWITHDEBINFO")
+set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2" CACHE STRING "Emscripten-overridden CMAKE_C_FLAGS_RELEASE")
+set(CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -O2" CACHE STRING "Emscripten-overridden CMAKE_C_FLAGS_MINSIZEREL")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING "Emscripten-overridden CMAKE_C_FLAGS_RELWITHDEBINFO")
+set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2" CACHE STRING "Emscripten-overridden CMAKE_CXX_FLAGS_RELEASE")
+set(CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -O2" CACHE STRING "Emscripten-overridden CMAKE_CXX_FLAGS_MINSIZEREL")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING "Emscripten-overridden CMAKE_CXX_FLAGS_RELWITHDEBINFO")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-O2" CACHE STRING "Emscripten-overridden CMAKE_EXE_LINKER_FLAGS_RELEASE")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "-O2" CACHE STRING "Emscripten-overridden CMAKE_EXE_LINKER_FLAGS_MINSIZEREL")
-set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING "Emscripten-overridden CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO")
+set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Emscripten-overridden CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-O2" CACHE STRING "Emscripten-overridden CMAKE_SHARED_LINKER_FLAGS_RELEASE")
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "-O2" CACHE STRING "Emscripten-overridden CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL")
-set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING "Emscripten-overridden CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO")
+set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Emscripten-overridden CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "-O2" CACHE STRING "Emscripten-overridden CMAKE_MODULE_LINKER_FLAGS_RELEASE")
set(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "-O2" CACHE STRING "Emscripten-overridden CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL")
-set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING "Emscripten-overridden CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO")
+set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Emscripten-overridden CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO")
function(em_validate_asmjs_after_build target)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo Validating build output for asm.js... COMMAND "python" ARGS "${EMSCRIPTEN_ROOT_PATH}/tools/validate_asmjs.py" "$<TARGET_FILE:${target}>")
@@ -203,3 +205,24 @@ endfunction()
function(em_link_post_js target)
em_add_tracked_link_flag(${target} "--post-js" ${ARGN})
endfunction()
+
+# Experimental support for targeting generation of Visual Studio project files (vs-tool) of Emscripten projects for Windows.
+# To use this, pass the combination -G "Visual Studio 10" -DCMAKE_TOOLCHAIN_FILE=Emscripten.cmake
+if ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio.*")
+ # By default, CMake generates VS project files with a <GenerateManifest>true</GenerateManifest> directive.
+ # This causes VS to attempt to invoke rc.exe during the build, which will fail since app manifests are meaningless for Emscripten.
+ # To disable this, add the following linker flag. This flag will not go to emcc, since the Visual Studio CMake generator will swallow it.
+ set(EMSCRIPTEN_VS_LINKER_FLAGS "/MANIFEST:NO")
+ # CMake is hardcoded to write a ClCompile directive <ObjectFileName>$(IntDir)</ObjectFileName> in all VS project files it generates.
+ # This makes VS pass emcc a -o param that points to a directory instead of a file, which causes emcc autogenerate the output filename.
+ # CMake is hardcoded to assume all object files have the suffix .obj, so adjust the emcc-autogenerated default suffix name to match.
+ set(EMSCRIPTEN_VS_LINKER_FLAGS "${EMSCRIPTEN_VS_LINKER_FLAGS} --default-obj-ext .obj")
+ # Also hint CMake that it should not hardcode <ObjectFileName> generation. Requires a custom CMake build for this to work (ignored on others)
+ # See http://www.cmake.org/Bug/view.php?id=14673 and https://github.com/juj/CMake
+ set(CMAKE_VS_NO_DEFAULT_OBJECTFILENAME 1)
+
+ # Apply and cache Emscripten Visual Studio IDE-specific linker flags.
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_VS_LINKER_FLAGS}" CACHE STRING "")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${EMSCRIPTEN_VS_LINKER_FLAGS}" CACHE STRING "")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${EMSCRIPTEN_VS_LINKER_FLAGS}" CACHE STRING "")
+endif()
diff --git a/emcc b/emcc
index 029d60a1..621cb340 100755
--- a/emcc
+++ b/emcc
@@ -53,14 +53,17 @@ from tools import shared, jsrun
from tools.shared import Compression, execute, suffix, unsuffixed, unsuffixed_basename, WINDOWS
from tools.response_file import read_response_file
-C_SUFFIXES = ('.c', '.C')
-CXX_SUFFIXES = ('.cpp', '.cxx', '.cc', '.CPP', '.CXX', '.CC')
-SOURCE_SUFFIXES = C_SUFFIXES + CXX_SUFFIXES + ('.m', '.mm')
-BITCODE_SUFFIXES = ('.bc', '.o', '.obj')
-DYNAMICLIB_SUFFIXES = ('.dylib', '.so', '.dll')
-STATICLIB_SUFFIXES = ('.a',)
-ASSEMBLY_SUFFIXES = ('.ll',)
+# endings = dot + a suffix, safe to test by filename.endswith(endings)
+C_ENDINGS = ('.c', '.C')
+CXX_ENDINGS = ('.cpp', '.cxx', '.cc', '.CPP', '.CXX', '.CC')
+SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + ('.m', '.mm')
+BITCODE_ENDINGS = ('.bc', '.o', '.obj')
+DYNAMICLIB_ENDINGS = ('.dylib', '.so', '.dll')
+STATICLIB_ENDINGS = ('.a',)
+ASSEMBLY_ENDINGS = ('.ll',)
+
LIB_PREFIXES = ('', 'lib')
+
JS_CONTAINING_SUFFIXES = ('js', 'html')
# Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc opt
@@ -341,7 +344,13 @@ Options that are modified or new in %s include:
For more docs on the options --preload-file
accepts, see https://github.com/kripken/emscripten/wiki/Filesystem-Guide
- --compression <codec> Compress both the compiled code and embedded/
+ --exclude-file <name> Files and directories to be excluded from
+ --embed-file and --preload-file
+ wildcard is supported
+
+ --compression <codec> **THIS OPTION IS DEPRECATED**
+
+ Compress both the compiled code and embedded/
preloaded files. <codec> should be a triple,
<native_encoder>,<js_decoder>,<js_name>
@@ -499,6 +508,24 @@ Options that are modified or new in %s include:
--proxy-to-worker Generates both html and js files. The main
program is in js, and the html proxies to/from it.
+ --emrun Enables the generated output to be aware of the
+ emrun command line tool. This allows stdout, stderr
+ and exit(returncode) capture when running the
+ generated application through emrun.
+
+ --em-config Specifies the location of the .emscripten configuration
+ file for the current compiler run. If not specified,
+ the environment variable EM_CONFIG is read for this
+ file, and if that is not set, the default location
+ ~/.emscripten is assumed.
+
+ --default-obj-ext .ext Specifies the file suffix to generate if the location
+ of a directory name is passed to -o directive, e.g.
+ emcc -c a.c -o dir/
+ will by default generate an output name 'dir/a.o',
+ but this cmdline param can be passed to generate a
+ file with a custom suffix 'dir/a.ext'.
+
The target file, if specified (-o <target>), defines what will
be generated:
@@ -747,9 +774,13 @@ def in_temp(name):
def filename_type_suffix(filename):
for i in reversed(filename.split('.')[1:]):
if not i.isdigit():
- return '.' + i
+ return i
return ''
+def filename_type_ending(filename):
+ suffix = filename_type_suffix(filename)
+ return '' if not suffix else ('.' + suffix)
+
try:
call = CXX if use_cxx else CC
@@ -769,17 +800,20 @@ try:
split_js_file = None
preload_files = []
embed_files = []
+ exclude_files = []
compression = None
ignore_dynamic_linking = False
shell_path = shared.path_from_root('src', 'shell.html')
js_libraries = []
bind = False
+ emrun = False
jcache = False
save_bc = False
memory_init_file = False
use_preload_cache = False
no_heap_copy = False
proxy_to_worker = False
+ default_object_extension = '.o'
if use_cxx:
default_cxx_std = '-std=c++03' # Enforce a consistent C++ standard when compiling .cpp files, if user does not specify one on the cmdline.
@@ -884,7 +918,13 @@ try:
preload_files.append(newargs[i+1])
newargs[i] = ''
newargs[i+1] = ''
+ elif newargs[i].startswith('--exclude-file'):
+ check_bad_eq(newargs[i])
+ exclude_files.append(newargs[i+1])
+ newargs[i] = ''
+ newargs[i+1] = ''
elif newargs[i].startswith('--compression'):
+ logging.warning('--compression is deprecated. Instead, it is recommended you use native gzip compression in your webserver')
check_bad_eq(newargs[i])
parts = newargs[i+1].split(',')
assert len(parts) == 3, '--compression requires specifying native_encoder,js_decoder,js_name - see emcc --help. got: %s' % newargs[i+1]
@@ -963,12 +1003,30 @@ try:
if not absolute_warning_shown and os.path.isabs(path_name):
logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript). Pass \'-Wno-warn-absolute-paths\' to emcc to hide this warning.') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
absolute_warning_shown = True
+ elif newargs[i] == '--emrun':
+ emrun = True
+ newargs[i] = ''
+ elif newargs[i] == '--em-config':
+ # This option is parsed in tools/shared.py, here only clean it up from being passed to clang.
+ newargs[i] = ''
+ newargs[i+1] = ''
+ elif newargs[i] == '--default-obj-ext':
+ newargs[i] = ''
+ default_object_extension = newargs[i+1]
+ if not default_object_extension.startswith('.'):
+ default_object_extension = '.' + default_object_extension
+ newargs[i+1] = ''
+
newargs = [ arg for arg in newargs if arg is not '' ]
# If user did not specify a default -std for C++ code, specify the emscripten default.
if default_cxx_std:
newargs = newargs + [default_cxx_std]
+ if emrun:
+ pre_js += open(shared.path_from_root('src', 'emrun_prejs.js')).read() + '\n'
+ post_js += open(shared.path_from_root('src', 'emrun_postjs.js')).read() + '\n'
+
if js_opts is None: js_opts = opt_level >= 2
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
if llvm_lto is None and opt_level >= 3: llvm_lto = 3
@@ -1019,23 +1077,23 @@ try:
prev = newargs[i-1]
if prev in ['-MT', '-MF', '-MQ', '-D', '-U', '-o', '-x', '-Xpreprocessor', '-include', '-imacros', '-idirafter', '-iprefix', '-iwithprefix', '-iwithprefixbefore', '-isysroot', '-imultilib', '-A', '-isystem', '-iquote', '-install_name', '-compatibility_version', '-current_version', '-I', '-L']: continue # ignore this gcc-style argument
- if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES)):
+ if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS)):
arg = os.path.realpath(arg)
if not arg.startswith('-'):
if not os.path.exists(arg):
- logging.error(arg + ': No such file or directory')
+ logging.error('%s: No such file or directory ("%s" was expected to be an input file, based on the commandline arguments provided)' % (arg, arg))
exit(1)
- arg_suffix = filename_type_suffix(arg)
- if arg_suffix.endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
+ arg_ending = filename_type_ending(arg)
+ if arg_ending.endswith(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
newargs[i] = ''
- if arg_suffix.endswith(SOURCE_SUFFIXES):
+ if arg_ending.endswith(SOURCE_ENDINGS):
input_files.append(arg)
has_source_inputs = True
- elif arg_suffix.endswith(ASSEMBLY_SUFFIXES) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
+ elif arg_ending.endswith(ASSEMBLY_ENDINGS) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
input_files.append(arg)
- elif arg_suffix.endswith(STATICLIB_SUFFIXES + DYNAMICLIB_SUFFIXES):
+ elif arg_ending.endswith(STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS):
# if it's not, and it's a library, just add it to libs to find later
l = unsuffixed_basename(arg)
for prefix in LIB_PREFIXES:
@@ -1047,10 +1105,10 @@ try:
newargs[i] = ''
else:
logging.warning(arg + ' is not valid LLVM bitcode')
- elif arg_suffix.endswith(STATICLIB_SUFFIXES):
+ elif arg_ending.endswith(STATICLIB_ENDINGS):
if not shared.Building.is_ar(arg):
if shared.Building.is_bitcode(arg):
- logging.error(arg + ': File has a suffix of a static library ' + str(STATICLIB_SUFFIXES) + ', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes ' + str(BITCODE_SUFFIXES))
+ logging.error(arg + ': File has a suffix of a static library ' + str(STATICLIB_ENDINGS) + ', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes ' + str(BITCODE_ENDINGS))
else:
logging.error(arg + ': Unknown format, not a static library!')
exit(1)
@@ -1075,17 +1133,12 @@ try:
target = target_basename + '.o'
final_suffix = 'o'
- # do not link in libs when just generating object code (not an 'executable', i.e. JS, or a library)
- if ('.' + final_suffix) in BITCODE_SUFFIXES and len(libs) > 0:
- logging.warning('not linking against libraries since only compiling to bitcode')
- libs = []
-
# Find library files
for lib in libs:
logging.debug('looking for library "%s"' % lib)
found = False
for prefix in LIB_PREFIXES:
- for suff in STATICLIB_SUFFIXES + DYNAMICLIB_SUFFIXES:
+ for suff in STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS:
name = prefix + lib + suff
for lib_dir in lib_dirs:
path = os.path.join(lib_dir, name)
@@ -1096,12 +1149,21 @@ try:
break
if found: break
if found: break
-
- if ignore_dynamic_linking:
- input_files = filter(lambda input_file: not input_file.endswith(DYNAMICLIB_SUFFIXES), input_files)
+ if not found: logging.warning('emcc: cannot find library "%s"' % lib)
+
+ # If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so
+ # ignore dynamic linking, since multiple dynamic linkings can interfere with each other
+ if not filename_type_suffix(target) in JS_CONTAINING_SUFFIXES or ignore_dynamic_linking:
+ def check(input_file):
+ if filename_type_ending(input_file) in DYNAMICLIB_ENDINGS:
+ if not ignore_dynamic_linking: logging.warning('ignoring dynamic library %s because not compiling to JS or HTML, remember to link it when compiling to JS or HTML at the end' % os.path.basename(input_file))
+ return False
+ else:
+ return True
+ input_files = filter(lambda input_file: check(input_file), input_files)
if len(input_files) == 0:
- logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: ' + str(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + STATICLIB_SUFFIXES + ASSEMBLY_SUFFIXES))
+ logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: ' + str(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + STATICLIB_ENDINGS + ASSEMBLY_ENDINGS))
exit(0)
newargs = CC_ADDITIONAL_ARGS + newargs
@@ -1128,8 +1190,33 @@ try:
logging.warning('disabling asm.js since embind is not ready for it yet')
shared.Settings.ASM_JS = 0
+ fastcomp = os.environ.get('EMCC_FAST_COMPILER') == '1'
+
+ if fastcomp:
+ shared.Settings.ASM_JS = 1
+ if shared.Settings.DISABLE_EXCEPTION_CATCHING == 0:
+ logging.warning('disabling exception catching since not supported in fastcomp yet')
+ shared.Settings.DISABLE_EXCEPTION_CATCHING = 1
+ 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.SAFE_HEAP == 0, 'safe heap not supported in fastcomp yet'
+ 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'
+ assert shared.Settings.RESERVED_FUNCTION_POINTERS == 0, 'reserved function pointers not supported in fastcomp'
+ assert shared.Settings.ASM_HEAP_LOG == 0, 'asm heap log not supported in fastcomp'
+ assert shared.Settings.LABEL_DEBUG == 0, 'label debug not supported in fastcomp'
+ assert shared.Settings.LEGACY_GL_EMULATION == 0, 'legacy gl emulation not supported in fastcomp'
+ assert shared.Settings.EXECUTION_TIMEOUT == -1, 'execution timeout not supported in fastcomp'
+ assert shared.Settings.NAMED_GLOBALS == 0, 'named globals not supported in fastcomp'
+ assert shared.Settings.PGO == 0, 'pgo not supported in fastcomp'
+ assert shared.Settings.TARGET_LE32 == 1, 'fastcomp requires le32'
+ assert not bind, 'embind not supported in fastcomp yet'
+ if jcache:
+ logging.warning('jcache is not supported in fastcomp (you should not need it anyhow), disabling')
+ jcache = False
+
if shared.Settings.ASM_JS:
- assert opt_level >= 1, 'asm.js requires -O1 or above'
+ assert opt_level >= 1 or fastcomp, 'asm.js requires -O1 or above'
if bind:
shared.Settings.RESERVED_FUNCTION_POINTERS = max(shared.Settings.RESERVED_FUNCTION_POINTERS, 10)
@@ -1141,17 +1228,6 @@ try:
shared.Settings.CORRECT_OVERFLOWS = 1
assert not shared.Settings.PGO, 'cannot run PGO in ASM_JS mode'
- heap = 4096
- while heap < shared.Settings.TOTAL_MEMORY:
- heap *= 2
- #if heap <= 16*1024*1024:
- # heap *= 2
- #else:
- # heap += 16*1024*1024
- if heap != shared.Settings.TOTAL_MEMORY:
- logging.warning('increasing TOTAL_MEMORY to %d to be more reasonable for asm.js' % heap)
- shared.Settings.TOTAL_MEMORY = heap
-
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
@@ -1219,14 +1295,14 @@ try:
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
for input_file in input_files:
- file_suffix = filename_type_suffix(input_file)
- if file_suffix.endswith(SOURCE_SUFFIXES):
+ file_ending = filename_type_ending(input_file)
+ if file_ending.endswith(SOURCE_ENDINGS):
logging.debug('compiling source file: ' + input_file)
input_file = shared.Building.preprocess(input_file, in_temp(uniquename(input_file)))
output_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
temp_files.append(output_file)
args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file]
- if file_suffix.endswith(CXX_SUFFIXES):
+ if file_ending.endswith(CXX_ENDINGS):
args += shared.EMSDK_CXX_OPTS
logging.debug("running: " + call + ' ' + ' '.join(args))
execute([call] + args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
@@ -1234,17 +1310,17 @@ try:
logging.error('compiler frontend failed to generate LLVM bitcode, halting')
sys.exit(1)
else: # bitcode
- if file_suffix.endswith(BITCODE_SUFFIXES):
+ if file_ending.endswith(BITCODE_ENDINGS):
logging.debug('copying bitcode file: ' + input_file)
temp_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
shutil.copyfile(input_file, temp_file)
temp_files.append(temp_file)
- elif file_suffix.endswith(DYNAMICLIB_SUFFIXES) or shared.Building.is_ar(input_file):
+ elif file_ending.endswith(DYNAMICLIB_ENDINGS) or shared.Building.is_ar(input_file):
logging.debug('copying library file: ' + input_file)
temp_file = in_temp(uniquename(input_file))
shutil.copyfile(input_file, temp_file)
temp_files.append(temp_file)
- elif file_suffix.endswith(ASSEMBLY_SUFFIXES):
+ elif file_ending.endswith(ASSEMBLY_ENDINGS):
if not LEAVE_INPUTS_RAW:
# Note that by assembling the .ll file, then disassembling it later, we will
# remove annotations which is a good thing for compilation time
@@ -1262,8 +1338,8 @@ try:
# Optimize source files
if llvm_opts > 0:
for i, input_file in enumerate(input_files):
- file_suffix = filename_type_suffix(input_file)
- if file_suffix.endswith(SOURCE_SUFFIXES):
+ file_ending = filename_type_ending(input_file)
+ if file_ending.endswith(SOURCE_ENDINGS):
temp_file = temp_files[i]
logging.debug('optimizing %s with -O%s' % (input_file, llvm_opts))
shared.Building.llvm_opt(temp_file, llvm_opts)
@@ -1276,7 +1352,16 @@ try:
else:
if len(input_files) == 1:
temp_output_base = in_temp(unsuffixed(uniquename(input_files[0])))
- shutil.move(temp_output_base + '.o', specified_target)
+ if specified_target.endswith('/') or specified_target.endswith('\\') or os.path.isdir(specified_target): # User passed '-o <directory' as the location to output to.
+ obj_output_name = os.path.join(specified_target, os.path.splitext(os.path.basename(input_file))[0] + default_object_extension)
+ logging.debug('User specified -o <directoryname> as the location of the output. Generating output file ' + obj_output_name)
+ try:
+ shutil.move(temp_output_base + '.o', obj_output_name)
+ except IOError, e:
+ logging.error('Could not write to output file ' + obj_output_name + '. Perhaps the output directory does not exist?')
+ exit(1)
+ else: # User passed '-o <filename>' as the location to output to.
+ shutil.move(temp_output_base + '.o', specified_target)
if os.path.exists(temp_output_base + '.d'):
# There was a .d file generated, from -MD or -MMD and friends, save a copy of it to where the output resides,
# adjusting the target name away from the temporary file name to the specified target.
@@ -1608,11 +1693,11 @@ try:
# First, combine the bitcode files if there are several. We must also link if we have a singleton .a
if len(input_files) + len(extra_files_to_link) > 1 or \
- (not LEAVE_INPUTS_RAW and not (suffix(temp_files[0]) in BITCODE_SUFFIXES or suffix(temp_files[0]) in DYNAMICLIB_SUFFIXES) and shared.Building.is_ar(temp_files[0])):
+ (not LEAVE_INPUTS_RAW and not (suffix(temp_files[0]) in BITCODE_ENDINGS or suffix(temp_files[0]) in DYNAMICLIB_ENDINGS) and shared.Building.is_ar(temp_files[0])):
linker_inputs = temp_files + extra_files_to_link
logging.debug('linking: ' + str(linker_inputs))
t0 = time.time()
- shared.Building.link(linker_inputs, in_temp(target_basename + '.bc'), force_archive_contents = len(filter(lambda temp: not temp.endswith(STATICLIB_SUFFIXES), temp_files)) == 0)
+ shared.Building.link(linker_inputs, in_temp(target_basename + '.bc'), force_archive_contents = len(filter(lambda temp: not temp.endswith(STATICLIB_ENDINGS), temp_files)) == 0)
t1 = time.time()
logging.debug(' linking took %.2f seconds' % (t1 - t0))
final = in_temp(target_basename + '.bc')
@@ -1657,18 +1742,26 @@ try:
else:
# At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
link_opts += shared.Building.get_safe_internalize() + ['-globaldce']
- if not save_bc:
+
+
+ if (not save_bc and not fastcomp) or AUTODEBUG:
# let llvm opt directly emit ll, to skip writing and reading all the bitcode
link_opts += ['-S']
shared.Building.llvm_opt(final, link_opts, final + '.link.ll')
final = final + '.link.ll'
if DEBUG: save_intermediate('linktime', 'll')
else:
+ if fastcomp and not save_bc:
+ # Simplify LLVM bitcode for fastcomp
+ link_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
shared.Building.llvm_opt(final, link_opts)
if DEBUG: save_intermediate('linktime', 'bc')
-
- if save_bc:
- shutil.copyfile(final, save_bc)
+ if save_bc:
+ shutil.copyfile(final, save_bc)
+ if fastcomp:
+ shared.Building.llvm_opt(final, ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt'], final + '.adsimp.bc')
+ final += '.adsimp.bc'
+ if DEBUG: save_intermediate('adsimp', 'bc')
# Prepare .ll for Emscripten
if not LEAVE_INPUTS_RAW:
@@ -1684,6 +1777,12 @@ try:
final += '.ad.ll'
if DEBUG: save_intermediate('autodebug', 'll')
+ # Simplify bitcode after autodebug
+ if fastcomp and (AUTODEBUG or LEAVE_INPUTS_RAW):
+ shared.Building.llvm_opt(final, ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt'], final + '.adsimp.bc')
+ final += '.adsimp.bc'
+ if DEBUG: save_intermediate('adsimp', 'bc')
+
# Emscripten
logging.debug('LLVM => JS')
extra_args = [] if not js_libraries else ['--libraries', ','.join(map(os.path.abspath, js_libraries))]
@@ -1694,13 +1793,16 @@ try:
# Embed and preload files
if len(preload_files) + len(embed_files) > 0:
logging.debug('setting up files')
- file_args = ['--pre-run']
+ file_args = []
if len(preload_files) > 0:
file_args.append('--preload')
file_args += preload_files
if len(embed_files) > 0:
file_args.append('--embed')
file_args += embed_files
+ if len(exclude_files) > 0:
+ file_args.append('--exclude')
+ file_args += exclude_files
if Compression.on:
file_args += ['--compress', Compression.encoder, Compression.decoder, Compression.js_name]
if use_preload_cache:
diff --git a/emrun b/emrun
new file mode 100755
index 00000000..e3596eed
--- /dev/null
+++ b/emrun
@@ -0,0 +1,1087 @@
+#!/usr/bin/env python
+
+# emrun: Implements machinery that allows running a .html page as if it was a standard executable file.
+# Usage: emrun <options> filename.html <args to program>
+# See emrun --help for more information
+
+import os, platform, optparse, logging, re, pprint, atexit, urlparse, subprocess, sys, SocketServer, BaseHTTPServer, SimpleHTTPServer, time, string, struct, socket, cgi
+from operator import itemgetter
+from urllib import unquote
+from Queue import PriorityQueue
+from threading import Thread, RLock
+
+# Populated from cmdline params
+emrun_options = None
+
+# Represents the process object handle to the browser we opened to run the html page.
+browser_process = None
+
+# If we have routed browser output to file with --log_stdout and/or --log_stderr,
+# these track the handles.
+browser_stdout_handle = sys.stdout
+browser_stderr_handle = sys.stderr
+
+# This flag tracks whether the html page has sent any stdout messages back to us.
+# Used to detect whether we might have gotten detached from the browser process we
+# spawned, in which case we are not able to detect when user closes the browser with
+# the close button.
+have_received_messages = False
+
+# At startup print a warning message once if user did not build with --emrun.
+emrun_not_enabled_nag_printed = False
+
+# Stores the exit() code of the html page when/if it quits.
+page_exit_code = 0
+
+# If this is set to a non-empty string, all processes by this name will be killed at exit.
+# This is used to clean up after browsers that spawn subprocesses to handle the actual
+# browser launch. For example opera has a launcher.exe that runs the actual opera browser.
+# So killing browser_process would just kill launcher.exe and not the opera browser itself.
+processname_killed_atexit = ""
+
+# If user does not specify a --port parameter, this port is used to launch the server.
+default_webserver_port = 6931
+
+# Location of Android Debug Bridge executable
+ADB = ''
+
+# Host OS detection to autolocate browsers and other OS-specific support needs.
+WINDOWS = False
+LINUX = False
+OSX = False
+if os.name == 'nt':
+ WINDOWS = True
+
+ import win32api, _winreg
+ from win32com.client import GetObject
+ from win32api import GetFileVersionInfo, LOWORD, HIWORD
+ import shlex
+ from _winreg import HKEY_CURRENT_USER, OpenKey, QueryValue
+
+elif platform.system() == 'Linux':
+ LINUX = True
+elif platform.mac_ver()[0] != '':
+ OSX = True
+
+ import plistlib
+
+# If you are running on an OS that is not any of these, must add explicit support for it.
+if not WINDOWS and not LINUX and not OSX:
+ raise Exception("Unknown OS!")
+
+# Absolute wallclock time in seconds specifying when the previous HTTP stdout message from
+# the page was received.
+last_message_time = time.clock()
+
+# Absolute wallclock time in seconds telling when we launched emrun.
+page_start_time = time.clock()
+
+# Stores the time of most recent http page serve.
+page_last_served_time = None
+
+# Returns given log message formatted to be outputted on a HTML page.
+def format_html(msg):
+ if not msg.endswith('\n'):
+ msg += '\n'
+ msg = cgi.escape(msg)
+ msg = msg.replace('\r\n', '<br />').replace('\n', '<br />')
+ return msg
+
+# HTTP requests are handled from separate threads - synchronize them to avoid race conditions
+http_mutex = RLock()
+
+# Prints a log message to 'info' stdout channel. Always printed.
+def logi(msg):
+ global last_message_time
+ with http_mutex:
+ if emrun_options.log_html:
+ sys.stdout.write(format_html(msg))
+ else:
+ print >> sys.stdout, msg
+ sys.stdout.flush()
+ last_message_time = time.clock()
+
+# Prints a verbose log message to stdout channel. Only shown if run with --verbose.
+def logv(msg):
+ global emrun_options, last_message_time
+ with http_mutex:
+ if emrun_options.verbose:
+ if emrun_options.log_html:
+ sys.stdout.write(format_html(msg))
+ else:
+ print >> sys.stdout, msg
+ sys.stdout.flush()
+ last_message_time = time.clock()
+
+# Prints an error message to stderr channel.
+def loge(msg):
+ global last_message_time
+ with http_mutex:
+ if emrun_options.log_html:
+ sys.stderr.write(format_html(msg))
+ else:
+ print >> sys.stderr, msg
+ sys.stderr.flush()
+ last_message_time = time.clock()
+
+def format_eol(msg):
+ if WINDOWS:
+ msg = msg.replace('\r\n', '\n').replace('\n', '\r\n')
+ return msg
+
+# Prints a message to the browser stdout output stream.
+def browser_logi(msg):
+ global browser_stdout_handle
+ msg = format_eol(msg)
+ print >> browser_stdout_handle, msg
+ browser_stdout_handle.flush()
+ last_message_time = time.clock()
+
+# Prints a message to the browser stderr output stream.
+def browser_loge(msg):
+ global browser_stderr_handle
+ msg = format_eol(msg)
+ print >> browser_stderr_handle, msg
+ browser_stderr_handle.flush()
+ last_message_time = time.clock()
+
+# Unquotes a unicode string. (translates ascii-encoded utf string back to utf)
+def unquote_u(source):
+ result = unquote(source)
+ if '%u' in result:
+ result = result.replace('%u','\\u').decode('unicode_escape')
+ return result
+
+# Returns whether the browser page we spawned is still running.
+# (note, not perfect atm, in case we are running in detached mode)
+def is_browser_process_alive():
+ return browser_process and browser_process.poll() == None
+
+# Kills browser_process and processname_killed_atexit.
+def kill_browser_process():
+ global browser_process, processname_killed_atexit, emrun_options, ADB
+ if browser_process:
+ try:
+ logv('Terminating browser process..')
+ browser_process.kill()
+ except:
+ pass
+ browser_process = None
+ if len(processname_killed_atexit) > 0:
+ if emrun_options.android:
+ logv("Terminating Android app '" + processname_killed_atexit + "'.")
+ subprocess.call([ADB, 'shell', 'am', 'force-stop', processname_killed_atexit])
+ else:
+ logv("Terminating all processes that have string '" + processname_killed_atexit + "' in their name.")
+ if WINDOWS:
+ process_image = processname_killed_atexit if '.exe' in processname_killed_atexit else (processname_killed_atexit + '.exe')
+ process = subprocess.Popen(['taskkill', '/F', '/IM', process_image, '/T'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ process.communicate()
+ else:
+ try:
+ subprocess.call(['pkill', processname_killed_atexit])
+ except OSError, e:
+ try:
+ subprocess.call(['killall', processname_killed_atexit])
+ except OSError, e:
+ loge('Both commands pkill and killall failed to clean up the spawned browser process. Perhaps neither of these utilities is available on your system?')
+ # Clear the process name to represent that the browser is now dead.
+ processname_killed_atexit = ''
+
+# Our custom HTTP web server that will server the target page to run via .html.
+# This is used so that we can load the page via a http:// URL instead of a file:// URL, since those wouldn't work too well unless user allowed XHR without CORS rules.
+# Also, the target page will route its stdout and stderr back to here via HTTP requests.
+class HTTPWebServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):
+ # Log messaging arriving via HTTP can come in out of sequence. Implement a sequencing mechanism to enforce ordered transmission.
+ expected_http_seq_num = -1
+ # Stores messages that have arrived out of order, pending for a send as soon as the missing message arrives.
+ # Kept in sorted order, first element is the oldest message received.
+ http_message_queue = []
+
+ def handle_incoming_message(self, seq_num, log, data):
+ global have_received_messages
+ with http_mutex:
+ have_received_messages = True
+
+ if self.expected_http_seq_num == -1:
+ self.expected_http_seq_num = seq_num+1
+ log(data)
+ elif seq_num == -1: # Message arrived without a sequence number? Just log immediately
+ log(data)
+ elif seq_num == self.expected_http_seq_num:
+ log(data)
+ self.expected_http_seq_num += 1
+ self.print_messages_due()
+ elif seq_num < self.expected_http_seq_num:
+ log(data)
+ else:
+ self.http_message_queue += [(seq_num, data, log)]
+ self.http_message_queue.sort(key=itemgetter(0))
+ if len(self.http_message_queue) > 16:
+ self.print_next_message()
+
+ # If it's been too long since we we got a message, prints out the oldest queued message, ignoring the proper order.
+ # This ensures that if any messages are actually lost, that the message queue will be orderly flushed.
+ def print_timed_out_messages(self):
+ global last_message_time
+ with http_mutex:
+ now = time.clock()
+ max_message_queue_time = 5
+ if len(self.http_message_queue) > 0 and now - last_message_time > max_message_queue_time:
+ self.print_next_message()
+
+ # Skips to printing the next message in queue now, independent of whether there was missed messages in the sequence numbering.
+ def print_next_message(self):
+ with http_mutex:
+ if len(self.http_message_queue) > 0:
+ self.expected_http_seq_num = self.http_message_queue[0][0]
+ self.print_messages_due()
+
+ # Completely flushes all out-of-order messages in the queue.
+ def print_all_messages(self):
+ with http_mutex:
+ while len(self.http_message_queue) > 0:
+ self.print_next_message()
+
+ # Prints any messages that are now due after we logged some other previous messages.
+ def print_messages_due(self):
+ with http_mutex:
+ while len(self.http_message_queue) > 0:
+ msg = self.http_message_queue[0]
+ if msg[0] == self.expected_http_seq_num:
+ msg[2](msg[1])
+ self.expected_http_seq_num += 1
+ self.http_message_queue.pop(0)
+ else:
+ return
+
+ def serve_forever(self, timeout=0.5):
+ global emrun_options, last_message_time, page_exit_code, have_received_messages, emrun_not_enabled_nag_printed
+ self.is_running = True
+ self.timeout = timeout
+ while self.is_running:
+ now = time.clock()
+ # Did user close browser?
+ if not emrun_options.serve_after_close and browser_process and browser_process.poll() != None:
+ if not have_received_messages:
+ emrun_options.serve_after_close = True
+ logv('Warning: emrun got detached from the target browser process. Cannot detect when user closes the browser. Behaving as if --serve_after_close was passed in.')
+ else:
+ self.shutdown()
+ logv('Browser process has quit. Shutting down web server.. Pass --serve_after_close to keep serving the page even after the browser closes.')
+
+ # Serve HTTP
+ self.handle_request()
+ # Process message log queue
+ self.print_timed_out_messages()
+
+ # If web page was silent for too long without printing anything, kill process.
+ time_since_message = now - last_message_time
+ if emrun_options.silence_timeout != 0 and time_since_message > emrun_options.silence_timeout:
+ self.shutdown()
+ logv('No activity in ' + str(emrun_options.silence_timeout) + ' seconds. Quitting web server with return code ' + str(emrun_options.timeout_returncode) + '. (--silence_timeout option)')
+ page_exit_code = emrun_options.timeout_returncode
+ emrun_options.kill_on_exit = True
+
+ # If the page has been running too long as a whole, kill process.
+ time_since_start = now - page_start_time
+ if emrun_options.timeout != 0 and time_since_start > emrun_options.timeout:
+ self.shutdown()
+ logv('Page has not finished in ' + str(emrun_options.timeout) + ' seconds. Quitting web server with return code ' + str(emrun_options.timeout_returncode) + '. (--timeout option)')
+ emrun_options.kill_on_exit = True
+ page_exit_code = emrun_options.timeout_returncode
+
+ # If we detect that the page is not running with emrun enabled, print a warning message.
+ if not emrun_not_enabled_nag_printed and page_last_served_time is not None:
+ time_since_page_serve = now - page_last_served_time
+ if not have_received_messages and time_since_page_serve > 10:
+ logi('The html page you are running is not emrun-capable. Stdout, stderr and exit(returncode) capture will not work. Recompile the application with the --emrun linker flag to enable this, or pass --no_emrun_detect to emrun to hide this check.')
+ emrun_not_enabled_nag_printed = True
+
+ # Clean up at quit, print any leftover messages in queue.
+ self.print_all_messages()
+
+ def handle_error(self, request, client_address):
+ err = sys.exc_info()[1][0]
+ # Filter out the useless '[Errno 10054] An existing connection was forcibly closed by the remote host' errors that occur when we
+ # forcibly kill the client.
+ if err != 10054:
+ SocketServer.BaseServer.handle_error(self, request, client_address)
+
+ def shutdown(self):
+ self.is_running = False
+ self.print_all_messages()
+ return 1
+
+# Processes HTTP request back to the browser.
+class HTTPHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+ def send_head(self):
+ global page_last_served_time
+ path = self.translate_path(self.path)
+ f = None
+
+ if os.path.isdir(path):
+ if not self.path.endswith('/'):
+ self.send_response(301)
+ self.send_header("Location", self.path + "/")
+ self.end_headers()
+ return None
+ for index in "index.html", "index.htm":
+ index = os.path.join(path, index)
+ if os.path.isfile(index):
+ path = index
+ break
+ else:
+ # Manually implement directory listing support.
+ return self.list_directory(path)
+ ctype = self.guess_type(path)
+ try:
+ f = open(path, 'rb')
+ except IOError:
+ self.send_error(404, "File not found: " + path)
+ return None
+ self.send_response(200)
+ self.send_header("Content-type", ctype)
+ fs = os.fstat(f.fileno())
+ self.send_header("Content-Length", str(fs[6]))
+ self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
+ self.send_header('Cache-Control','no-cache, must-revalidate')
+ self.send_header('Expires','-1')
+ self.end_headers()
+ page_last_served_time = time.clock()
+ return f
+
+ def log_request(self, code):
+ # Filter out 200 OK messages to remove noise.
+ if code is not 200:
+ SimpleHTTPServer.SimpleHTTPRequestHandler.log_request(self, code)
+
+ def log_message(self, format, *args):
+ msg = "%s - - [%s] %s\n" % (self.address_string(), self.log_date_time_string(), format%args)
+ if not 'favicon.ico' in msg: # Filter out 404 messages on favicon.ico not being found to remove noise.
+ sys.stderr.write(msg)
+
+ def do_POST(self):
+ global page_exit_code, emrun_options, have_received_messages
+
+ (_, _, path, query, _) = urlparse.urlsplit(self.path)
+ data = self.rfile.read(int(self.headers['Content-Length']))
+ data = data.replace("+", " ")
+ data = unquote_u(data)
+
+ # The user page sent a message with POST. Parse the message and log it to stdout/stderr.
+ is_stdout = False
+ is_stderr = False
+ seq_num = -1
+ # The html shell is expected to send messages of form ^out^(number)^(message) or ^err^(number)^(message).
+ if data.startswith('^err^'):
+ is_stderr = True
+ elif data.startswith('^out^'):
+ is_stdout = True
+ if is_stderr or is_stdout:
+ try:
+ i = data.index('^', 5)
+ seq_num = int(data[5:i])
+ data = data[i+1:]
+ except:
+ pass
+
+ is_exit = data.startswith('^exit^')
+
+ if data == '^pageload^': # Browser is just notifying that it has successfully launched the page.
+ have_received_messages = True
+ elif not is_exit:
+ log = browser_loge if is_stderr else browser_logi
+ self.server.handle_incoming_message(seq_num, log, data)
+ elif not emrun_options.serve_after_exit:
+ page_exit_code = int(data[6:])
+ logv('Web page has quit with a call to exit() with return code ' + str(page_exit_code) + '. Shutting down web server. Pass --serve_after_exit to keep serving even after the page terminates with exit().')
+ self.server.shutdown()
+
+ self.send_response(200)
+ self.send_header("Content-type", "text/plain")
+ self.send_header('Cache-Control','no-cache, must-revalidate')
+ self.send_header('Expires','-1')
+ self.end_headers()
+ self.wfile.write('OK')
+
+# From http://stackoverflow.com/questions/4842448/getting-processor-information-in-python
+# Returns a string with something like "AMD64, Intel(R) Core(TM) i5-2557M CPU @ 1.70GHz, Intel64 Family 6 Model 42 Stepping 7, GenuineIntel"
+def get_cpu_infoline():
+ try:
+ if WINDOWS:
+ root_winmgmts = GetObject("winmgmts:root\cimv2")
+ cpus = root_winmgmts.ExecQuery("Select * from Win32_Processor")
+ cpu_name = cpus[0].Name + ', ' + platform.processor()
+ elif OSX:
+ cpu_name = subprocess.check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).strip()
+ elif LINUX:
+ command = "cat /proc/cpuinfo"
+ all_info = subprocess.check_output(command, shell=True).strip()
+ for line in all_info.split("\n"):
+ if "model name" in line:
+ cpu_name = re.sub( ".*model name.*:", "", line,1).strip()
+ except:
+ return "Unknown"
+
+ return platform.machine() + ', ' + cpu_name
+
+def get_android_cpu_infoline():
+ lines = subprocess.check_output([ADB, 'shell', 'cat', '/proc/cpuinfo']).split('\n')
+ processor = ''
+ hardware = ''
+ for line in lines:
+ if line.startswith('Processor'):
+ processor = line[line.find(':')+1:].strip()
+ elif line.startswith('Hardware'):
+ hardware = line[line.find(':')+1:].strip()
+
+ freq = int(subprocess.check_output([ADB, 'shell', 'cat', '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq']).strip())/1000
+ return 'CPU: ' + processor + ', ' + hardware + ' @ ' + str(freq) + ' MHz'
+
+def win_print_gpu_info():
+ gpus = []
+ gpu_memory = []
+
+ for i in range(0, 16):
+ try:
+ hHardwareReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "HARDWARE")
+ hDeviceMapReg = _winreg.OpenKey(hHardwareReg, "DEVICEMAP")
+ hVideoReg = _winreg.OpenKey(hDeviceMapReg, "VIDEO")
+ VideoCardString = _winreg.QueryValueEx(hVideoReg,"\Device\Video"+str(i))[0]
+ #Get Rid of Registry/Machine from the string
+ VideoCardStringSplit = VideoCardString.split("\\")
+ ClearnVideoCardString = string.join(VideoCardStringSplit[3:], "\\")
+ #Go up one level for detailed
+ VideoCardStringRoot = string.join(VideoCardStringSplit[3:len(VideoCardStringSplit)-1], "\\")
+
+ #Get the graphics card information
+ hVideoCardReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, ClearnVideoCardString)
+ try:
+ VideoCardDescription = _winreg.QueryValueEx(hVideoCardReg, "Device Description")[0]
+ except WindowsError:
+ VideoCardDescription = _winreg.QueryValueEx(hVideoCardReg, "DriverDesc")[0]
+
+ try:
+ driverVersion = _winreg.QueryValueEx(hVideoCardReg, "DriverVersion")[0]
+ VideoCardDescription += ', driver version ' + driverVersion
+ except:
+ pass
+
+ try:
+ driverDate = _winreg.QueryValueEx(hVideoCardReg, "DriverDate")[0]
+ VideoCardDescription += ' (' + driverDate + ')'
+ except:
+ pass
+
+ VideoCardMemorySize = _winreg.QueryValueEx(hVideoCardReg, "HardwareInformation.MemorySize")[0]
+ try:
+ vram = struct.unpack('l',VideoCardMemorySize)[0]
+ except struct.error:
+ vram = int(VideoCardMemorySize)
+ if not VideoCardDescription in gpus:
+ gpus += [VideoCardDescription]
+ gpu_memory += [str(int(vram/1024/1024))]
+ except WindowsError:
+ pass
+
+ if len(gpus) == 1:
+ print "GPU: " + gpus[0] + " with " + gpu_memory[0] + " MB of VRAM"
+ elif len(gpus) > 1:
+ for i in range(0, len(gpus)):
+ print "GPU"+str(i)+ ": " + gpus[i] + " with " + gpu_memory[i] + " MBs of VRAM"
+
+def linux_print_gpu_info():
+ try:
+ glxinfo = subprocess.check_output('glxinfo')
+ for line in glxinfo.split("\n"):
+ if "OpenGL vendor string:" in line:
+ gl_vendor = line[len("OpenGL vendor string:"):].strip()
+ if "OpenGL version string:" in line:
+ gl_version = line[len("OpenGL version string:"):].strip()
+ if "OpenGL renderer string:" in line:
+ gl_renderer = line[len("OpenGL renderer string:"):].strip()
+ logi('GPU: ' + gl_vendor + ' ' + gl_renderer + ', GL version ' + gl_version)
+ except:
+ pass
+
+def osx_print_gpu_info():
+ try:
+ info = subprocess.check_output(['system_profiler', 'SPDisplaysDataType'])
+ gpu = re.search("Chipset Model: (.*)", info)
+ if gpu:
+ chipset = gpu.group(1)
+ vram = re.search("VRAM \(Total\): (.*) MB", info)
+ if vram:
+ logi('GPU: ' + chipset + ' with ' + vram.group(1) + ' MBs of VRAM')
+ else:
+ logi('GPU: ' + chipset)
+ except:
+ pass
+
+def print_gpu_infolines():
+ if WINDOWS:
+ win_print_gpu_info()
+ elif LINUX:
+ linux_print_gpu_info()
+ elif OSX:
+ osx_print_gpu_info()
+
+def get_executable_version(filename):
+ try:
+ if WINDOWS:
+ info = GetFileVersionInfo(filename, "\\")
+ ms = info['FileVersionMS']
+ ls = info['FileVersionLS']
+ version = HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls)
+ return '.'.join(map(str, version))
+ elif OSX:
+ plistfile = app_name[0:app_name.find('MacOS')] + 'Info.plist'
+ info = plistlib.readPlist(plistfile)
+ # Data in Info.plists is a bit odd, this check combo gives best information on each browser.
+ if 'firefox' in app_name.lower():
+ return info['CFBundleShortVersionString'] + ' 20' + info['CFBundleVersion'][2:].replace('.', '-')
+ if 'opera' in app_name.lower():
+ return info['CFBundleVersion']
+ else:
+ return info['CFBundleShortVersionString']
+ elif LINUX:
+ if 'firefox' in filename.lower():
+ version = subprocess.check_output([filename, '-v'])
+ version = version.replace('Mozilla Firefox ', '')
+ return version.strip()
+ else:
+ return ""
+ except:
+ return ""
+
+# http://stackoverflow.com/questions/580924/python-windows-file-version-attribute
+def win_get_file_properties(fname):
+ propNames = ('Comments', 'InternalName', 'ProductName',
+ 'CompanyName', 'LegalCopyright', 'ProductVersion',
+ 'FileDescription', 'LegalTrademarks', 'PrivateBuild',
+ 'FileVersion', 'OriginalFilename', 'SpecialBuild')
+
+ props = {'FixedFileInfo': None, 'StringFileInfo': None, 'FileVersion': None}
+
+ try:
+ # backslash as parm returns dictionary of numeric info corresponding to VS_FIXEDFILEINFO struc
+ fixedInfo = win32api.GetFileVersionInfo(fname, '\\')
+ props['FixedFileInfo'] = fixedInfo
+ props['FileVersion'] = "%d.%d.%d.%d" % (fixedInfo['FileVersionMS'] / 65536,
+ fixedInfo['FileVersionMS'] % 65536, fixedInfo['FileVersionLS'] / 65536,
+ fixedInfo['FileVersionLS'] % 65536)
+
+ # \VarFileInfo\Translation returns list of available (language, codepage)
+ # pairs that can be used to retreive string info. We are using only the first pair.
+ lang, codepage = win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')[0]
+
+ # any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle
+ # two are language/codepage pair returned from above
+
+ strInfo = {}
+ for propName in propNames:
+ strInfoPath = u'\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
+ ## print str_info
+ strInfo[propName] = win32api.GetFileVersionInfo(fname, strInfoPath)
+
+ props['StringFileInfo'] = strInfo
+ except:
+ pass
+
+ return props
+
+def get_os_version():
+ try:
+ if WINDOWS:
+ versionHandle = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion")
+ productName = _winreg.QueryValueEx(versionHandle, "ProductName")
+ return productName[0]
+ elif OSX:
+ return 'Mac OS ' + platform.mac_ver()[0]
+ elif LINUX:
+ kernel_version = subprocess.check_output(['uname', '-r']).strip()
+ return ' '.join(platform.linux_distribution()) + ', linux kernel ' + kernel_version + ' ' + platform.architecture()[0]
+ except:
+ return 'Unknown OS'
+
+def get_system_memory():
+ global emrun_options
+
+ try:
+ if LINUX or emrun_options.android:
+ if emrun_options.android:
+ lines = subprocess.check_output([ADB, 'shell', 'cat', '/proc/meminfo']).split('\n')
+ else:
+ mem = open('/proc/meminfo', 'r')
+ lines = mem.readlines()
+ mem.close()
+ for i in lines:
+ sline = i.split()
+ if str(sline[0]) == 'MemTotal:':
+ return int(sline[1]) * 1024
+ elif WINDOWS:
+ return win32api.GlobalMemoryStatusEx()['TotalPhys']
+ elif OSX:
+ return int(subprocess.check_output(['sysctl', '-n', 'hw.memsize']).strip())
+ except:
+ return -1
+
+# Finds the given executable 'program' in PATH. Operates like the Unix tool 'which'.
+def which(program):
+ def is_exe(fpath):
+ return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+ fpath, fname = os.path.split(program)
+ if fpath:
+ if is_exe(program):
+ return program
+ else:
+ for path in os.environ["PATH"].split(os.pathsep):
+ path = path.strip('"')
+ exe_file = os.path.join(path, program)
+ if is_exe(exe_file):
+ return exe_file
+
+ if WINDOWS and not '.' in fname:
+ if is_exe(exe_file + '.exe'):
+ return exe_file + '.exe'
+ if is_exe(exe_file + '.cmd'):
+ return exe_file + '.cmd'
+ if is_exe(exe_file + '.bat'):
+ return exe_file + '.bat'
+
+ return None
+
+def win_get_default_browser():
+ # Manually find the default system browser on Windows without relying on 'start %1' since
+ # that method has an issue, see comment below.
+
+ # In Py3, this module is called winreg without the underscore
+
+ with OpenKey(HKEY_CURRENT_USER, r"Software\Classes\http\shell\open\command") as key:
+ cmd = QueryValue(key, None)
+ if cmd:
+ parts = shlex.split(cmd)
+ if len(parts) > 0:
+ return [parts[0]]
+
+ # Fall back to 'start %1', which we have to treat as if user passed --serve_forever, since
+ # for some reason, we are not able to detect when the browser closes when this is passed.
+ return ['cmd', '/C', 'start']
+
+def find_browser(name):
+ if WINDOWS and name == 'start':
+ return win_get_default_browser()
+ if OSX and name == 'open':
+ return [name]
+
+ if os.path.isfile(os.path.abspath(name)):
+ return [name]
+ if os.path.isfile(os.path.abspath(name)+'.exe'):
+ return [os.path.abspath(name)+'.exe']
+ if os.path.isfile(os.path.abspath(name)+'.cmd'):
+ return [os.path.abspath(name)+'.cmd']
+ if os.path.isfile(os.path.abspath(name)+'.bat'):
+ return [os.path.abspath(name)+'.bat']
+
+ path_lookup = which(name)
+ if path_lookup != None:
+ return [path_lookup]
+
+ browser_locations = []
+ if OSX:
+ # Note: by default Firefox beta installs as 'Firefox.app', you must manually rename it to
+ # FirefoxBeta.app after installation.
+ browser_locations = [ ('firefox', '/Applications/Firefox.app/Contents/MacOS/firefox'),
+ ('firefox_beta', '/Applications/FirefoxBeta.app/Contents/MacOS/firefox'),
+ ('firefox_aurora', '/Applications/FirefoxAurora.app/Contents/MacOS/firefox'),
+ ('firefox_nightly', '/Applications/FirefoxNightly.app/Contents/MacOS/firefox'),
+ ('safari', '/Applications/Safari.app/Contents/MacOS/Safari'),
+ ('opera', '/Applications/Opera.app/Contents/MacOS/Opera'),
+ ('chrome', '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'),
+ ('chrome_canary', '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary') ]
+ elif WINDOWS:
+ pf_locations = ['ProgramFiles(x86)', 'ProgramFiles', 'ProgramW6432']
+
+ for pf_env in pf_locations:
+ if not pf_env in os.environ:
+ continue
+ program_files = os.environ[pf_env] if WINDOWS else ''
+
+ browser_locations += [ ('chrome', os.path.join(program_files, 'Google/Chrome/Application/chrome.exe')),
+ ('chrome_canary', os.path.expanduser("~/AppData/Local/Google/Chrome SxS/Application/chrome.exe")),
+ ('firefox_nightly', os.path.join(program_files, 'Nightly/firefox.exe')),
+ ('firefox_aurora', os.path.join(program_files, 'Aurora/firefox.exe')),
+ ('firefox_beta', os.path.join(program_files, 'Beta/firefox.exe')),
+ ('firefox_beta', os.path.join(program_files, 'FirefoxBeta/firefox.exe')),
+ ('firefox_beta', os.path.join(program_files, 'Firefox Beta/firefox.exe')),
+ ('firefox', os.path.join(program_files, 'Mozilla Firefox/firefox.exe')),
+ ('iexplore', os.path.join(program_files, 'Internet Explorer/iexplore.exe')),
+ ('opera', os.path.join(program_files, 'Opera/launcher.exe')) ]
+
+ elif LINUX:
+ browser_locations = [ ('firefox', os.path.expanduser('~/firefox/firefox')),
+ ('firefox_beta', os.path.expanduser('~/firefox_beta/firefox')),
+ ('firefox_aurora', os.path.expanduser('~/firefox_aurora/firefox')),
+ ('firefox_nightly', os.path.expanduser('~/firefox_nightly/firefox')),
+ ('chrome', which('google-chrome-stable')),
+ ('chrome', which('google-chrome'))]
+
+ for (alias, browser_exe) in browser_locations:
+ if name == alias:
+ if browser_exe is not None and os.path.isfile(browser_exe):
+ return [browser_exe]
+
+ return None # Could not find the browser
+
+def get_android_model():
+ global ADB
+ manufacturer = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.product.manufacturer']).strip()
+ brand = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.product.brand']).strip()
+ model = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.product.model']).strip()
+ board = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.product.board']).strip()
+ device = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.product.device']).strip()
+ name = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.product.name']).strip()
+ return manufacturer + ' ' + brand + ' ' + model + ' ' + board + ' ' + device + ' ' + name
+
+def get_android_os_version():
+ global ADB
+ ver = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.build.version.release']).strip()
+ apiLevel = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.build.version.sdk']).strip()
+ if not apiLevel:
+ apiLevel = subprocess.check_output([ADB, 'shell', 'getprop', 'ro.build.version.sdk_int']).strip()
+
+ os = ''
+ if ver:
+ os += 'Android ' + ver + ' '
+ if apiLevel:
+ os += 'SDK API Level ' + apiLevel + ' '
+ os += subprocess.check_output([ADB, 'shell', 'getprop', 'ro.build.description']).strip()
+ return os
+
+def list_android_browsers():
+ global ADB
+ apps = subprocess.check_output([ADB, 'shell', 'pm', 'list', 'packages', '-f']).replace('\r\n', '\n')
+ browsers = []
+ for line in apps.split('\n'):
+ line = line.strip()
+ if line.endswith('=org.mozilla.firefox'):
+ browsers += ['firefox']
+ if line.endswith('=org.mozilla.firefox_beta'):
+ browsers += ['firefox_beta']
+ if line.endswith('=org.mozilla.fennec_aurora'):
+ browsers += ['firefox_aurora']
+ if line.endswith('=org.mozilla.fennec'):
+ browsers += ['firefox_nightly']
+ if line.endswith('=com.android.chrome'):
+ browsers += ['chrome']
+ if line.endswith('=com.chrome.beta'):
+ browsers += ['chrome_beta']
+ if line.endswith('=com.opera.browser'):
+ browsers += ['opera']
+ if line.endswith('=com.opera.mini.android'):
+ browsers += ['opera_mini']
+ if line.endswith('=mobi.mgeek.TunnyBrowser'):
+ browsers += ['dolphin']
+
+ browsers.sort()
+ logi('emrun has automatically found the following browsers on the connected Android device:')
+ for browser in browsers:
+ logi(' - ' + browser)
+
+def list_pc_browsers():
+ browsers = ['firefox', 'firefox_beta', 'firefox_aurora', 'firefox_nightly', 'chrome', 'chrome_canary', 'iexplore', 'safari', 'opera']
+ logi('emrun has automatically found the following browsers in the default install locations on the system:')
+ logi('')
+ for browser in browsers:
+ browser_exe = find_browser(browser)
+ if type(browser_exe) == list:
+ browser_exe = browser_exe[0]
+ if browser_exe:
+ logi(' - ' + browser + ': ' + browser_display_name(browser_exe) + ' ' + get_executable_version(browser_exe))
+ logi('')
+ logi('You can pass the --browser <id> option to launch with the given browser above.')
+ logi('Even if your browser was not detected, you can use --browser /path/to/browser/executable to launch with that browser.')
+
+def browser_display_name(browser):
+ b = browser.lower()
+ if 'iexplore' in b:
+ return 'Microsoft Internet Explorer'
+ if 'chrome' in b:
+ return 'Google Chrome'
+ if 'firefox' in b:
+ # Try to identify firefox flavor explicitly, to help show issues where emrun would launch the wrong browser.
+ product_name = win_get_file_properties(browser)['StringFileInfo']['ProductName'] if WINDOWS else 'firefox'
+ if product_name.lower() != 'firefox':
+ return 'Mozilla Firefox ' + product_name
+ else:
+ return 'Mozilla Firefox'
+ if 'opera' in b:
+ return 'Opera'
+ if 'safari' in b:
+ return 'Apple Safari'
+ return browser
+
+def main():
+ global browser_process, processname_killed_atexit, emrun_options, emrun_not_enabled_nag_printed, ADB
+ usage_str = "usage: %prog [options] [optional_portnum]"
+ parser = optparse.OptionParser(usage=usage_str)
+
+ parser.add_option('--kill_start', dest='kill_on_start', action='store_true', default=False,
+ help='If true, any previously running instances of the target browser are killed before starting.')
+
+ parser.add_option('--kill_exit', dest='kill_on_exit', action='store_true', default=False,
+ help='If true, the spawned browser process is forcibly killed when it calls exit().')
+
+ parser.add_option('--no_server', dest='no_server', action='store_true', default=False,
+ help='If specified, a HTTP web server is not launched to host the page to run.')
+
+ parser.add_option('--no_browser', dest='no_browser', action='store_true', default=False,
+ help='If specified, emrun will not launch a web browser to run the page.')
+
+ parser.add_option('--no_emrun_detect', dest='no_emrun_detect', action='store_true', default=False,
+ help='If specified, skips printing the warning message if html page is detected to not have been built with --emrun linker flag.')
+
+ parser.add_option('--serve_after_close', dest='serve_after_close', action='store_true', default=False,
+ help='If true, serves the web page even after the application quits by user closing the web page.')
+
+ parser.add_option('--serve_after_exit', dest='serve_after_exit', action='store_true', default=False,
+ help='If true, serves the web page even after the application quits by a call to exit().')
+
+ parser.add_option('--serve_root', dest='serve_root', default='',
+ help='If set, specifies the root path that the emrun web server serves. If not specified, the directory where the target .html page lives in is served.')
+
+ parser.add_option('--verbose', dest='verbose', action='store_true', default=False,
+ help='Enable verbose logging from emrun internal operation.')
+
+ parser.add_option('--port', dest='port', default=default_webserver_port, type="int",
+ help='Specifies the port the server runs in.')
+
+ parser.add_option('--log_stdout', dest='log_stdout', default='',
+ help='Specifies a log filename where the browser process stdout data will be appended to.')
+
+ parser.add_option('--log_stderr', dest='log_stderr', default='',
+ help='Specifies a log filename where the browser process stderr data will be appended to.')
+
+ parser.add_option('--silence_timeout', dest='silence_timeout', type="int", default=0,
+ help='If no activity is received in this many seconds, the browser process is assumed to be hung, and the web server is shut down and the target browser killed. Disabled by default.')
+
+ parser.add_option('--timeout', dest='timeout', type="int", default=0,
+ help='If the browser process does not quit or the page exit() in this many seconds, the browser is assumed to be hung, and the web server is shut down and the target browser killed. Disabled by default.')
+
+ parser.add_option('--timeout_returncode', dest='timeout_returncode', type="int", default=99999,
+ help='Sets the exit code that emrun reports back to caller in the case that a page timeout occurs. Default: 99999.')
+
+ parser.add_option('--list_browsers', dest='list_browsers', action='store_true',
+ help='Prints out all detected browser that emrun is able to use with the --browser command and exits.')
+
+ parser.add_option('--browser', dest='browser', default='',
+ help='Specifies the browser executable to run the web page in.')
+
+ parser.add_option('--android', dest='android', action='store_true', default=False,
+ help='Launches the page in a browser of an Android device connected to an USB on the local system. (via adb)')
+
+ parser.add_option('--system_info', dest='system_info', action='store_true',
+ help='Prints information about the current system at startup.')
+
+ parser.add_option('--browser_info', dest='browser_info', action='store_true',
+ help='Prints information about the target browser to launch at startup.')
+
+ parser.add_option('--log_html', dest='log_html', action='store_true',
+ help='If set, information lines are printed out an HTML-friendly format.')
+
+ (options, args) = parser.parse_args(sys.argv)
+ emrun_options = options
+
+ if options.android:
+ ADB = which('adb')
+ if not ADB:
+ loge("Could not find the adb tool. Install Android SDK and add the directory of adb to PATH.")
+ return 1
+
+ if not options.browser and not options.android:
+ if WINDOWS:
+ options.browser = 'start'
+ elif LINUX:
+ options.browser = which('xdg-open')
+ if not options.browser:
+ options.browser = 'firefox'
+ elif OSX:
+ options.browser = 'safari'
+
+ if options.list_browsers:
+ if options.android:
+ list_android_browsers()
+ else:
+ list_pc_browsers()
+ return
+
+ if len(args) < 2 and (options.system_info or options.browser_info):
+ options.no_server = options.no_browser = True # Don't run if only --system_info or --browser_info was passed.
+
+ if len(args) < 2 and not (options.no_server == True and options.no_browser == True):
+ logi('Usage: emrun filename.html')
+ return
+
+ file_to_serve = args[1] if len(args) > 1 else ''
+ cmdlineparams = args[2:] if len(args) > 2 else []
+
+ if options.serve_root:
+ serve_dir = os.path.abspath(options.serve_root)
+ else:
+ serve_dir = os.path.dirname(os.path.abspath(file_to_serve))
+ url = os.path.relpath(os.path.abspath(file_to_serve), serve_dir)
+ if len(cmdlineparams) > 0:
+ url += '?' + '&'.join(cmdlineparams)
+ server_root = 'localhost'
+ if options.android:
+ server_root = socket.gethostbyname(socket.gethostname())
+ url = 'http://' + server_root + ':' + str(options.port)+'/'+url
+
+ os.chdir(serve_dir)
+ logv('Web server root directory: ' + os.path.abspath('.'))
+
+ if options.android:
+ if not options.no_browser:
+ if not options.browser:
+ loge("Running on Android requires that you explicitly specify the browser to run with --browser <id>. Run emrun --android --list_browsers to obtain a list of installed browsers you can use.")
+ return 1
+ elif options.browser == 'firefox':
+ browser_app = 'org.mozilla.firefox/.App'
+ elif options.browser == 'firefox_beta':
+ browser_app = 'org.mozilla.firefox_beta/.App'
+ elif options.browser == 'firefox_aurora' or options.browser == 'fennec_aurora':
+ browser_app = 'org.mozilla.fennec_aurora/.App'
+ elif options.browser == 'firefox_nightly' or options.browser == 'fennec':
+ browser_app = 'org.mozilla.fennec/.App'
+ elif options.browser == 'chrome':
+ browser_app = 'com.android.chrome/.Main'
+ elif options.browser == 'chrome_beta' or options.browser == 'chrome_canary': # There is no Chrome Canary for Android, but Play store has 'Chrome Beta' instead.
+ browser_app = 'com.chrome.beta/com.android.chrome.Main'
+ elif options.browser == 'opera':
+ browser_app = 'com.opera.browser/com.opera.Opera'
+ elif options.browser == 'opera_mini': # Launching the URL works, but page seems to never load (Fails with 'Network problem' even when other browsers work)
+ browser_app = 'com.opera.mini.android/.Browser'
+ elif options.browser =='dolphin': # Current stable Dolphin as of 12/2013 does not have WebGL support.
+ browser_app = 'mobi.mgeek.TunnyBrowser/.BrowserActivity'
+ else:
+ loge("Don't know how to launch browser " + options.browser + ' on Android!')
+ return 1
+ # To add support for a new Android browser in the list above:
+ # 1. Install the browser to Android phone, connect it via adb to PC.
+ # 2. Type 'adb shell pm list packages -f' to locate the package name of that application.
+ # 3. Type 'adb pull <packagename>.apk' to copy the apk of that application to PC.
+ # 4. Type 'aapt d xmltree <packagename>.apk AndroidManifest.xml > manifest.txt' to extract the manifest from the package.
+ # 5. Locate the name of the main activity for the browser in manifest.txt and add an entry to above list in form 'appname/mainactivityname'
+
+ if WINDOWS:
+ url = url.replace('&', '\\&')
+ browser = [ADB, 'shell', 'am', 'start', '-a', 'android.intent.action.VIEW', '-n', browser_app, '-d', url]
+ processname_killed_atexit = browser_app[:browser_app.find('/')]
+ else: #Launching a web page on local system.
+ browser = find_browser(str(options.browser))
+ browser_exe = browser[0]
+ browser_args = []
+
+ if 'safari' in browser_exe.lower():
+ # Safari has a bug that a command line 'Safari http://page.com' does not launch that page,
+ # but instead launches 'file:///http://page.com'. To remedy this, must use the open -a command
+ # to run Safari, but unfortunately this will end up spawning Safari process detached from emrun.
+ if OSX:
+ browser = ['open', '-a', 'Safari'] + (browser[1:] if len(browser) > 1 else [])
+
+ processname_killed_atexit = 'Safari'
+ elif 'chrome' in browser_exe.lower():
+ processname_killed_atexit = 'chrome'
+ browser_args = ['--incognito', '--enable-nacl', '--enable-pnacl', '--disable-restore-session-state', '--enable-webgl', '--no-default-browser-check', '--no-first-run', '--allow-file-access-from-files']
+ # if options.no_server:
+ # browser_args += ['--disable-web-security']
+ elif 'firefox' in browser_exe.lower():
+ processname_killed_atexit = 'firefox'
+ elif 'iexplore' in browser_exe.lower():
+ processname_killed_atexit = 'iexplore'
+ browser_args = ['-private']
+ elif 'opera' in browser_exe.lower():
+ processname_killed_atexit = 'opera'
+
+ # In Windows cmdline, & character delimits multiple commmands, so must use ^ to escape them.
+ if browser_exe == 'cmd':
+ url = url.replace('&', '^&')
+ browser += browser_args + [url]
+
+ if options.kill_on_start:
+ pname = processname_killed_atexit
+ kill_browser_process()
+ processname_killed_atexit = pname
+
+ if options.system_info:
+ logi('Time of run: ' + time.strftime("%x %X"))
+ if options.android:
+ logi('Model: ' + get_android_model())
+ logi('OS: ' + get_android_os_version() + ' with ' + str(get_system_memory()/1024/1024) + ' MB of System RAM')
+ logi('CPU: ' + get_android_cpu_infoline())
+ else:
+ logi('Computer name: ' + socket.gethostname()) # http://stackoverflow.com/questions/799767/getting-name-of-windows-computer-running-python-script
+ logi('OS: ' + get_os_version() + ' with ' + str(get_system_memory()/1024/1024) + ' MB of System RAM')
+ logi('CPU: ' + get_cpu_infoline())
+ print_gpu_infolines()
+ if options.browser_info:
+ if options.android:
+ logi('Browser: Android ' + browser_app)
+ else:
+ logi('Browser: ' + browser_display_name(browser[0]) + ' ' + get_executable_version(browser_exe))
+
+ # Suppress run warning if requested.
+ if options.no_emrun_detect:
+ emrun_not_enabled_nag_printed = True
+
+ global browser_stdout_handle, browser_stderr_handle
+ if options.log_stdout:
+ browser_stdout_handle = open(options.log_stdout, 'ab')
+ if options.log_stderr:
+ if options.log_stderr == options.log_stdout:
+ browser_stderr_handle = browser_stdout_handle
+ else:
+ browser_stderr_handle = open(options.log_stderr, 'ab')
+
+ if not options.no_server:
+ logv('Starting web server in port ' + str(options.port))
+ httpd = HTTPWebServer(('', options.port), HTTPHandler)
+
+ if not options.no_browser:
+ logv("Executing %s" % ' '.join(browser))
+ if browser[0] == 'cmd':
+ serve_forever = True # Workaround an issue where passing 'cmd /C start' is not able to detect when the user closes the page.
+ browser_process = subprocess.Popen(browser)
+ if options.kill_on_exit:
+ atexit.register(kill_browser_process)
+ # For Android automation, we execute adb, so this process does not represent a browser and no point killing it.
+ if options.android:
+ browser_process = None
+
+ if browser_process and browser_process.poll() == None:
+ options.serve_after_close = True
+ logv('Warning: emrun got detached from the target browser process. Cannot detect when user closes the browser. Behaving as if --serve_after_close was passed in.')
+
+ if not options.no_server:
+ try:
+ httpd.serve_forever()
+ except KeyboardInterrupt:
+ httpd.server_close()
+ httpd.server_close()
+
+ logv('Closed web server.')
+
+ if not options.no_browser:
+ if options.kill_on_exit:
+ kill_browser_process()
+ elif is_browser_process_alive():
+ logv('Not terminating browser process, pass --kill_exit to terminate the browser when it calls exit().')
+
+ return page_exit_code
+
+if __name__ == '__main__':
+ returncode = main()
+ logv('emrun quitting with process exit code ' + str(returncode))
+ sys.exit(returncode)
diff --git a/emrun.bat b/emrun.bat
new file mode 100644
index 00000000..ae937e4d
--- /dev/null
+++ b/emrun.bat
@@ -0,0 +1,2 @@
+@echo off
+python "%~dp0\emrun" %* \ No newline at end of file
diff --git a/emscripten.py b/emscripten.py
index 907e88ce..42db0803 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -726,7 +726,6 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
"""
assert(settings['ASM_JS']) # TODO: apply ASM_JS even in -O0 for fastcomp
- assert(settings['RUNNING_JS_OPTS'])
# Overview:
# * Run LLVM backend to emit JS. JS includes function bodies, memory initializer,
@@ -734,46 +733,20 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
# * Run compiler.js on the metadata to emit the shell js code, pre/post-ambles,
# JS library dependencies, etc.
- if DEBUG: logging.debug('emscript: llvm backend')
-
- # TODO: proper temp files
- # TODO: use a single LLVM toolchain instead of normal for source, pnacl for simplification, custom for js backend
-
- if DEBUG: shutil.copyfile(infile, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp0.ll'))
-
- if DEBUG: logging.debug(' ..1..')
- temp1 = temp_files.get('.1.bc').name
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'opt'), infile, '-pnacl-abi-simplify-preopt', '-o', temp1]))
- assert os.path.exists(temp1)
- if DEBUG:
- shutil.copyfile(temp1, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp1.bc'))
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'llvm-dis'), 'temp1.bc', '-o', 'temp1.ll']))
-
- #if DEBUG: logging.debug(' ..2..')
- #temp2 = temp_files.get('.2.bc').name
- #shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'opt'), temp1, '-O3', '-o', temp2]))
- #assert os.path.exists(temp2)
- #if DEBUG:
- # shutil.copyfile(temp2, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp2.bc'))
- # shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'llvm-dis'), 'temp2.bc', '-o', 'temp2.ll']))
- temp2 = temp1 # XXX if we optimize the bc, we remove some pnacl clutter, but it also makes varargs stores be 8-byte aligned
-
- if DEBUG: logging.debug(' ..3..')
- temp3 = temp_files.get('.3.bc').name
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'opt'), temp2, '-pnacl-abi-simplify-postopt', '-o', temp3]))
- assert os.path.exists(temp3)
if DEBUG:
- shutil.copyfile(temp3, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp3.bc'))
- shared.jsrun.timeout_run(subprocess.Popen([os.path.join(shared.LLVM_ROOT, 'llvm-dis'), 'temp3.bc', '-o', 'temp3.ll']))
+ logging.debug('emscript: llvm backend')
+ t = time.time()
- if DEBUG: logging.debug(' ..4..')
- temp4 = temp_files.get('.4.js').name
+ temp_js = temp_files.get('.4.js').name
backend_compiler = os.path.join(shared.LLVM_ROOT, 'llc')
- shared.jsrun.timeout_run(subprocess.Popen([backend_compiler, temp3, '-march=js', '-filetype=asm', '-o', temp4], stdout=subprocess.PIPE))
- if DEBUG: shutil.copyfile(temp4, os.path.join(shared.CANONICAL_TEMP_DIR, 'temp4.js'))
+ shared.jsrun.timeout_run(subprocess.Popen([backend_compiler, infile, '-march=js', '-filetype=asm', '-o', temp_js], stdout=subprocess.PIPE))
+
+ if DEBUG:
+ logging.debug(' emscript: llvm backend took %s seconds' % (time.time() - t))
+ t = time.time()
# Split up output
- backend_output = open(temp4).read()
+ backend_output = open(temp_js).read()
#if DEBUG: print >> sys.stderr, backend_output
start_funcs_marker = '// EMSCRIPTEN_START_FUNCTIONS'
@@ -800,10 +773,31 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
table_sizes[k] = str(v.count(',')) # undercounts by one, but that is what we want
funcs = re.sub(r"#FM_(\w+)#", lambda m: table_sizes[m.groups(0)[0]], funcs)
+ # fix +float into float.0, if not running js opts
+ if not settings['RUNNING_JS_OPTS']:
+ def fix_dot_zero(m):
+ num = m.group(3)
+ # TODO: handle 0x floats?
+ if num.find('.') < 0:
+ e = num.find('e');
+ if e < 0:
+ num += '.0'
+ else:
+ num = num[:e] + '.0' + num[e:]
+ return m.group(1) + m.group(2) + num
+ funcs = re.sub(r'([(=,+\-*/%<>:?] *)\+(-?)((0x)?[0-9a-f]*\.?[0-9]+([eE][-+]?[0-9]+)?)', lambda m: fix_dot_zero(m), funcs)
+
# js compiler
if DEBUG: logging.debug('emscript: js compiler glue')
+ # Settings changes
+ assert settings['TARGET_LE32'] == 1
+ settings['TARGET_LE32'] = 2
+ if 'i64Add' in metadata['declares']: # TODO: others, once we split them up
+ settings['PRECISE_I64_MATH'] = 2
+ metadata['declares'] = filter(lambda i64_func: i64_func not in ['getHigh32', 'setHigh32', '__muldi3', '__divdi3', '__remdi3', '__udivdi3', '__uremdi3'], metadata['declares']) # FIXME: do these one by one as normal js lib funcs
+
# Integrate info from backend
settings['DEFAULT_LIBRARY_FUNCS_TO_INCLUDE'] = list(
set(settings['DEFAULT_LIBRARY_FUNCS_TO_INCLUDE'] + map(shared.JS.to_nice_ident, metadata['declares'])).difference(
@@ -811,10 +805,6 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
)
) + map(lambda x: x[1:], metadata['externs'])
- # Settings changes
- assert settings['TARGET_LE32'] == 1
- settings['TARGET_LE32'] = 2
-
# Save settings to a file to work around v8 issue 1579
settings_file = temp_files.get('.txt').name
def save_settings():
@@ -832,7 +822,9 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
assert '//FORWARDED_DATA:' in out, 'Did not receive forwarded data in pre output - process failed?'
glue, forwarded_data = out.split('//FORWARDED_DATA:')
- #print >> sys.stderr, out
+ if DEBUG:
+ logging.debug(' emscript: glue took %s seconds' % (time.time() - t))
+ t = time.time()
last_forwarded_json = forwarded_json = json.loads(forwarded_data)
@@ -885,18 +877,14 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
#if DEBUG: outfile.write('// funcs\n')
if settings.get('ASM_JS'):
- #print >> sys.stderr, '<<<<<<', post, '>>>>>>'
- post_funcs = '' #, post_rest = post.split('// EMSCRIPTEN_END_FUNCS\n')
- #post = post_rest
-
# Move preAsms to their right place
def move_preasm(m):
contents = m.groups(0)[0]
outfile.write(contents + '\n')
return ''
- post_funcs = re.sub(r'/\* PRE_ASM \*/(.*)\n', lambda m: move_preasm(m), post_funcs)
+ funcs_js[1] = re.sub(r'/\* PRE_ASM \*/(.*)\n', lambda m: move_preasm(m), funcs_js[1])
- funcs_js += ['\n' + post_funcs + '// EMSCRIPTEN_END_FUNCS\n']
+ funcs_js += ['\n// EMSCRIPTEN_END_FUNCS\n']
simple = os.environ.get('EMCC_SIMPLE_ASM')
class Counter:
@@ -913,8 +901,13 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
Counter.i += 1
bad = 'b' + str(i)
params = ','.join(['p%d' % p for p in range(len(sig)-1)])
+ coerced_params = ','.join([shared.JS.make_coercion('p%d', sig[p+1], settings) % p for p in range(len(sig)-1)])
coercions = ';'.join(['p%d = %s' % (p, shared.JS.make_coercion('p%d' % p, sig[p+1], settings)) for p in range(len(sig)-1)]) + ';'
- ret = '' if sig[0] == 'v' else ('return %s' % shared.JS.make_initializer(sig[0], settings))
+ def make_func(name, code):
+ return 'function %s(%s) { %s %s }' % (name, params, coercions, code)
+ Counter.pre = [make_func(bad, ('abort' if not settings['ASSERTIONS'] else 'nullFunc') + '(' + str(i) + ');' + (
+ '' if sig[0] == 'v' else ('return %s' % shared.JS.make_initializer(sig[0], settings))
+ ))]
start = raw.index('[')
end = raw.rindex(']')
body = raw[start+1:end].split(',')
@@ -925,11 +918,23 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
Counter.j += 1
newline = Counter.j % 30 == 29
if item == '0': return bad if not newline else (bad + '\n')
+ if item not in metadata['implementedFunctions']:
+ # this is imported into asm, we must wrap it
+ call_ident = item
+ if call_ident in metadata['redirects']: call_ident = metadata['redirects'][call_ident]
+ if not call_ident.startswith('_') and not call_ident.startswith('Math_'): call_ident = '_' + call_ident
+ code = call_ident + '(' + coerced_params + ')'
+ if sig[0] != 'v':
+ code = 'return ' + shared.JS.make_coercion(code, sig[0], settings)
+ code += ';'
+ Counter.pre.append(make_func(item + '__wrapper', code))
+ return item + '__wrapper'
return item if not newline else (item + '\n')
body = ','.join(map(fix_item, body))
- return ('function %s(%s) { %s %s(%d); %s }' % (bad, params, coercions, 'abort' if not settings['ASSERTIONS'] else 'nullFunc', i, ret), ''.join([raw[:start+1], body, raw[end:]]))
+ return ('\n'.join(Counter.pre), ''.join([raw[:start+1], body, raw[end:]]))
infos = [make_table(sig, raw) for sig, raw in last_forwarded_json['Functions']['tables'].iteritems()]
+ Counter.pre = []
function_tables_defs = '\n'.join([info[0] for info in infos]) + '\n// EMSCRIPTEN_END_FUNCS\n' + '\n'.join([info[1] for info in infos])
@@ -1013,7 +1018,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
pass
# If no named globals, only need externals
global_vars = metadata['externs'] #+ forwarded_json['Variables']['globals']
- global_funcs = list(set(['_' + key for key, value in forwarded_json['Functions']['libraryFunctions'].iteritems() if value != 2]).difference(set(global_vars))) # + metadata['externFuncs']/'declares'
+ global_funcs = list(set(['_' + key for key, value in forwarded_json['Functions']['libraryFunctions'].iteritems() if value != 2]).difference(set(global_vars)).difference(set(metadata['implementedFunctions'])))
def math_fix(g):
return g if not g.startswith('Math_') else g.split('_')[1]
asm_global_funcs = ''.join([' var ' + g.replace('.', '_') + '=global.' + g + ';\n' for g in maths]) + \
@@ -1189,6 +1194,8 @@ Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
outfile.close()
+ if DEBUG: logging.debug(' emscript: final python processing took %s seconds' % (time.time() - t))
+
if os.environ.get('EMCC_FAST_COMPILER'):
emscript = emscript_fast
diff --git a/src/analyzer.js b/src/analyzer.js
index 253c5505..e8ca6cf6 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -1570,7 +1570,17 @@ function analyzer(data, sidePass) {
for (var j = 0; j < label.lines.length; j++) {
var line = label.lines[j];
if ((line.intertype == 'call' || line.intertype == 'invoke') && line.ident == setjmp) {
- // Add a new label
+ if (line.intertype == 'invoke') {
+ // setjmp cannot trigger unwinding, so just reduce the invoke to a call + branch
+ line.intertype = 'call';
+ label.lines.push({
+ intertype: 'branch',
+ label: line.toLabel,
+ lineNum: line.lineNum + 0.01, // XXX legalizing might confuse this
+ });
+ line.toLabel = line.unwindLabel = -2;
+ }
+ // split this label into up to the setjmp (including), then a new label for the rest. longjmp will reach the rest
var oldLabel = label.ident;
var newLabel = func.labelIdCounter++;
if (!func.setjmpTable) func.setjmpTable = [];
@@ -1662,11 +1672,13 @@ function analyzer(data, sidePass) {
function stackAnalyzer() {
data.functions.forEach(function(func) {
var lines = func.labels[0].lines;
+ var hasAlloca = false;
for (var i = 0; i < lines.length; i++) {
var item = lines[i];
if (!item.assignTo || item.intertype != 'alloca' || !isNumber(item.ident)) break;
item.allocatedSize = func.variables[item.assignTo].impl === VAR_EMULATED ?
calcAllocatedSize(item.allocatedType)*item.ident: 0;
+ hasAlloca = true;
if (USE_TYPED_ARRAYS === 2) {
// We need to keep the stack aligned
item.allocatedSize = Runtime.forceAlign(item.allocatedSize, Runtime.STACK_ALIGN);
@@ -1682,6 +1694,7 @@ function analyzer(data, sidePass) {
}
func.initialStack = index;
func.otherStackAllocations = false;
+ if (func.initialStack === 0 && hasAlloca) func.otherStackAllocations = true; // a single alloca of zero still requires us to emit stack support code
while (func.initialStack == 0) { // one-time loop with possible abort in the middle
// If there is no obvious need for stack management, perhaps we don't need it
// (we try to optimize that way with SKIP_STACK_IN_SMALL). However,
diff --git a/src/compiler.js b/src/compiler.js
index 7d768c3d..e4ce1c88 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -134,7 +134,7 @@ load('settings.js');
var settings_file = arguments_[0];
var ll_file = arguments_[1];
phase = arguments_[2];
-if (phase == 'pre') {
+if (phase == 'pre' || phase == 'glue') {
additionalLibraries = Array.prototype.slice.call(arguments_, 3);
} else {
var forwardedDataFile = arguments_[3];
diff --git a/src/emrun_postjs.js b/src/emrun_postjs.js
new file mode 100644
index 00000000..eec203ec
--- /dev/null
+++ b/src/emrun_postjs.js
@@ -0,0 +1,20 @@
+function emrun_register_handlers() {
+ function post(msg) {
+ var http = new XMLHttpRequest();
+ http.open("POST", "stdio.html", true);
+ http.send(msg);
+ }
+ // If the address contains localhost, or we are running the page from port 6931, we can assume we're running the test runner and should post stdout logs.
+ if (document.URL.search("localhost") != -1 || document.URL.search(":6931/") != -1) {
+ var emrun_http_sequence_number = 1;
+ var prevExit = Module['exit'];
+ var prevPrint = Module['print'];
+ var prevErr = Module['printErr'];
+ Module['exit'] = function emrun_exit(returncode) { post('^exit^'+returncode); prevExit(returncode); }
+ Module['print'] = function emrun_print(text) { post('^out^'+(emrun_http_sequence_number++)+'^'+text); prevPrint(text); }
+ Module['printErr'] = function emrun_printErr(text) { post('^err^'+(emrun_http_sequence_number++)+'^'+text); prevErr(text); }
+ }
+ // Notify emrun web server that this browser has successfully launched the page.
+ post('^pageload^');
+}
+emrun_register_handlers();
diff --git a/src/emrun_prejs.js b/src/emrun_prejs.js
new file mode 100644
index 00000000..14613c5d
--- /dev/null
+++ b/src/emrun_prejs.js
@@ -0,0 +1,5 @@
+// Route URL GET parameters to argc+argv
+Module['arguments'] = window.location.search.substr(1).trim().split('&');
+// If no args were passed arguments = [''], in which case kill the single empty string.
+if (!Module['arguments'][0])
+ Module['arguments'] = [];
diff --git a/src/emscripten-source-map.min.js b/src/emscripten-source-map.min.js
new file mode 100644
index 00000000..9151400f
--- /dev/null
+++ b/src/emscripten-source-map.min.js
@@ -0,0 +1,31 @@
+function define(e,t,n){if(typeof e!="string")throw new TypeError("Expected string, got: "+e);arguments.length==2&&(n=t);if(e in define.modules)throw new Error("Module already defined: "+e);define.modules[e]=n}function Domain(){this.modules={},this._currentModule=null}define.modules={},function(){function e(e){var t=e.split("/"),n=1;while(n<t.length)t[n]===".."?t.splice(n-1,1):t[n]==="."?t.splice(n,1):n++;return t.join("/")}function t(e,t){return e=e.trim(),t=t.trim(),/^\//.test(t)?t:e.replace(/\/*$/,"/")+t}function n(e){var t=e.split("/");return t.pop(),t.join("/")}Domain.prototype.require=function(e,t){if(Array.isArray(e)){var n=e.map(function(e){return this.lookup(e)},this);return t&&t.apply(null,n),undefined}return this.lookup(e)},Domain.prototype.lookup=function(r){/^\./.test(r)&&(r=e(t(n(this._currentModule),r)));if(r in this.modules){var i=this.modules[r];return i}if(r in define.modules){var i=define.modules[r];if(typeof i=="function"){var s={},o=this._currentModule;this._currentModule=r,i(this.require.bind(this),s,{id:r,uri:""}),this._currentModule=o,i=s}return this.modules[r]=i,i}throw new Error("Module not defined: "+r)}}(),define.Domain=Domain,define.globalDomain=new Domain;var require=define.globalDomain.require.bind(define.globalDomain);define("source-map/source-map-generator",["require","exports","module","source-map/base64-vlq","source-map/util","source-map/array-set"],function(e,t,n){function o(e){this._file=i.getArg(e,"file"),this._sourceRoot=i.getArg(e,"sourceRoot",null),this._sources=new s,this._names=new s,this._mappings=[],this._sourcesContents=null}function u(e,t){var n=(e&&e.line)-(t&&t.line);return n?n:(e&&e.column)-(t&&t.column)}function a(e,t){return e=e||"",t=t||"",(e>t)-(e<t)}function f(e,t){return u(e.generated,t.generated)||u(e.original,t.original)||a(e.source,t.source)||a(e.name,t.name)}var r=e("./base64-vlq"),i=e("./util"),s=e("./array-set").ArraySet;o.prototype._version=3,o.fromSourceMap=function(t){var n=t.sourceRoot,r=new o({file:t.file,sourceRoot:n});return t.eachMapping(function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};e.source&&(t.source=e.source,n&&(t.source=i.relative(n,t.source)),t.original={line:e.originalLine,column:e.originalColumn},e.name&&(t.name=e.name)),r.addMapping(t)}),t.sources.forEach(function(e){var n=t.sourceContentFor(e);n&&r.setSourceContent(e,n)}),r},o.prototype.addMapping=function(t){var n=i.getArg(t,"generated"),r=i.getArg(t,"original",null),s=i.getArg(t,"source",null),o=i.getArg(t,"name",null);this._validateMapping(n,r,s,o),s&&!this._sources.has(s)&&this._sources.add(s),o&&!this._names.has(o)&&this._names.add(o),this._mappings.push({generated:n,original:r,source:s,name:o})},o.prototype.setSourceContent=function(t,n){var r=t;this._sourceRoot&&(r=i.relative(this._sourceRoot,r)),n!==null?(this._sourcesContents||(this._sourcesContents={}),this._sourcesContents[i.toSetString(r)]=n):(delete this._sourcesContents[i.toSetString(r)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},o.prototype.applySourceMap=function(t,n){n||(n=t.file);var r=this._sourceRoot;r&&(n=i.relative(r,n));var o=new s,u=new s;this._mappings.forEach(function(e){if(e.source===n&&e.original){var s=t.originalPositionFor({line:e.original.line,column:e.original.column});s.source!==null&&(r?e.source=i.relative(r,s.source):e.source=s.source,e.original.line=s.line,e.original.column=s.column,s.name!==null&&e.name!==null&&(e.name=s.name))}var a=e.source;a&&!o.has(a)&&o.add(a);var f=e.name;f&&!u.has(f)&&u.add(f)},this),this._sources=o,this._names=u,t.sources.forEach(function(e){var n=t.sourceContentFor(e);n&&(r&&(e=i.relative(r,e)),this.setSourceContent(e,n))},this)},o.prototype._validateMapping=function(t,n,r,i){if(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!n&&!r&&!i)return;if(t&&"line"in t&&"column"in t&&n&&"line"in n&&"column"in n&&t.line>0&&t.column>=0&&n.line>0&&n.column>=0&&r)return;throw new Error("Invalid mapping.")},o.prototype._serializeMappings=function(){var t=0,n=1,i=0,s=0,o=0,u=0,a="",l;this._mappings.sort(f);for(var c=0,h=this._mappings.length;c<h;c++){l=this._mappings[c];if(l.generated.line!==n){t=0;while(l.generated.line!==n)a+=";",n++}else if(c>0){if(!f(l,this._mappings[c-1]))continue;a+=","}a+=r.encode(l.generated.column-t),t=l.generated.column,l.source&&l.original&&(a+=r.encode(this._sources.indexOf(l.source)-u),u=this._sources.indexOf(l.source),a+=r.encode(l.original.line-1-s),s=l.original.line-1,a+=r.encode(l.original.column-i),i=l.original.column,l.name&&(a+=r.encode(this._names.indexOf(l.name)-o),o=this._names.indexOf(l.name)))}return a},o.prototype.toJSON=function(){var t={version:this._version,file:this._file,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._sourceRoot&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=t.sources.map(function(e){return t.sourceRoot&&(e=i.relative(t.sourceRoot,e)),Object.prototype.hasOwnProperty.call(this._sourcesContents,i.toSetString(e))?this._sourcesContents[i.toSetString(e)]:null},this)),t},o.prototype.toString=function(){return JSON.stringify(this)},t.SourceMapGenerator=o}),define("source-map/base64-vlq",["require","exports","module","source-map/base64"],function(e,t,n){function a(e){return e<0?(-e<<1)+1:(e<<1)+0}function f(e){var t=(e&1)===1,n=e>>1;return t?-n:n}var r=e("./base64"),i=5,s=1<<i,o=s-1,u=s;t.encode=function(t){var n="",s,f=a(t);do s=f&o,f>>>=i,f>0&&(s|=u),n+=r.encode(s);while(f>0);return n},t.decode=function(t){var n=0,s=t.length,a=0,l=0,c,h;do{if(n>=s)throw new Error("Expected more digits in base 64 VLQ value.");h=r.decode(t.charAt(n++)),c=!!(h&u),h&=o,a+=h<<l,l+=i}while(c);return{value:f(a),rest:t.slice(n)}}}),define("source-map/base64",["require","exports","module"],function(e,t,n){var r={},i={};"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("").forEach(function(e,t){r[e]=t,i[t]=e}),t.encode=function(t){if(t in i)return i[t];throw new TypeError("Must be between 0 and 63: "+t)},t.decode=function(t){if(t in r)return r[t];throw new TypeError("Not a valid base 64 digit: "+t)}}),define("source-map/util",["require","exports","module"],function(e,t,n){function r(e,t,n){if(t in e)return e[t];if(arguments.length===3)return n;throw new Error('"'+t+'" is a required argument.')}function s(e){var t=e.match(i);return t?{scheme:t[1],auth:t[3],host:t[4],port:t[6],path:t[7]}:null}function o(e){var t=e.scheme+"://";return e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function u(e,t){var n;return t.match(i)?t:t.charAt(0)==="/"&&(n=s(e))?(n.path=t,o(n)):e.replace(/\/$/,"")+"/"+t}function a(e){return"$"+e}function f(e){return e.substr(1)}function l(e,t){e=e.replace(/\/$/,"");var n=s(e);return t.charAt(0)=="/"&&n&&n.path=="/"?t.slice(1):t.indexOf(e+"/")===0?t.substr(e.length+1):t}t.getArg=r;var i=/([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/;t.urlParse=s,t.urlGenerate=o,t.join=u,t.toSetString=a,t.fromSetString=f,t.relative=l}),define("source-map/array-set",["require","exports","module","source-map/util"],function(e,t,n){function i(){this._array=[],this._set={}}var r=e("./util");i.fromArray=function(t,n){var r=new i;for(var s=0,o=t.length;s<o;s++)r.add(t[s],n);return r},i.prototype.add=function(t,n){var i=this.has(t),s=this._array.length;(!i||n)&&this._array.push(t),i||(this._set[r.toSetString(t)]=s)},i.prototype.has=function(t){return Object.prototype.hasOwnProperty.call(this._set,r.toSetString(t))},i.prototype.indexOf=function(t){if(this.has(t))return this._set[r.toSetString(t)];throw new Error('"'+t+'" is not in the set.')},i.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)},i.prototype.toArray=function(){return this._array.slice()},t.ArraySet=i}),define("source-map/source-map-consumer",["require","exports","module","source-map/util","source-map/binary-search","source-map/array-set","source-map/base64-vlq"],function(e,t,n){function u(e){var t=e;typeof e=="string"&&(t=JSON.parse(e.replace(/^\)\]\}'/,"")));var n=r.getArg(t,"version"),i=r.getArg(t,"sources"),o=r.getArg(t,"names"),u=r.getArg(t,"sourceRoot",null),a=r.getArg(t,"sourcesContent",null),f=r.getArg(t,"mappings"),l=r.getArg(t,"file",null);if(n!==this._version)throw new Error("Unsupported version: "+n);this._names=s.fromArray(o,!0),this._sources=s.fromArray(i,!0),this.sourceRoot=u,this.sourcesContent=a,this.file=l,this._generatedMappings=[],this._originalMappings=[],this._parseMappings(f,u)}var r=e("./util"),i=e("./binary-search"),s=e("./array-set").ArraySet,o=e("./base64-vlq");u.prototype._version=3,Object.defineProperty(u.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return this.sourceRoot?r.join(this.sourceRoot,e):e},this)}}),u.prototype._parseMappings=function(t,n){var r=1,i=0,s=0,u=0,a=0,f=0,l=/^[,;]/,c=t,h,p;while(c.length>0)if(c.charAt(0)===";")r++,c=c.slice(1),i=0;else if(c.charAt(0)===",")c=c.slice(1);else{h={},h.generatedLine=r,p=o.decode(c),h.generatedColumn=i+p.value,i=h.generatedColumn,c=p.rest;if(c.length>0&&!l.test(c.charAt(0))){p=o.decode(c),h.source=this._sources.at(a+p.value),a+=p.value,c=p.rest;if(c.length===0||l.test(c.charAt(0)))throw new Error("Found a source, but no line and column");p=o.decode(c),h.originalLine=s+p.value,s=h.originalLine,h.originalLine+=1,c=p.rest;if(c.length===0||l.test(c.charAt(0)))throw new Error("Found a source and line, but no column");p=o.decode(c),h.originalColumn=u+p.value,u=h.originalColumn,c=p.rest,c.length>0&&!l.test(c.charAt(0))&&(p=o.decode(c),h.name=this._names.at(f+p.value),f+=p.value,c=p.rest)}this._generatedMappings.push(h),typeof h.originalLine=="number"&&this._originalMappings.push(h)}this._originalMappings.sort(this._compareOriginalPositions)},u.prototype._compareOriginalPositions=function(t,n){if(t.source>n.source)return 1;if(t.source<n.source)return-1;var r=t.originalLine-n.originalLine;return r===0?t.originalColumn-n.originalColumn:r},u.prototype._compareGeneratedPositions=function(t,n){var r=t.generatedLine-n.generatedLine;return r===0?t.generatedColumn-n.generatedColumn:r},u.prototype._findMapping=function(t,n,r,s,o){if(t[r]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+t[r]);if(t[s]<0)throw new TypeError("Column must be greater than or equal to 0, got "+t[s]);return i.search(t,n,o)},u.prototype.originalPositionFor=function(t){var n={generatedLine:r.getArg(t,"line"),generatedColumn:r.getArg(t,"column")},i=this._findMapping(n,this._generatedMappings,"generatedLine","generatedColumn",this._compareGeneratedPositions);if(i){var s=r.getArg(i,"source",null);return s&&this.sourceRoot&&(s=r.join(this.sourceRoot,s)),{source:s,line:r.getArg(i,"originalLine",null),column:r.getArg(i,"originalColumn",null),name:r.getArg(i,"name",null)}}return{source:null,line:null,column:null,name:null}},u.prototype.sourceContentFor=function(t){if(!this.sourcesContent)return null;this.sourceRoot&&(t=r.relative(this.sourceRoot,t));if(this._sources.has(t))return this.sourcesContent[this._sources.indexOf(t)];var n;if(this.sourceRoot&&(n=r.urlParse(this.sourceRoot))){var i=t.replace(/^file:\/\//,"");if(n.scheme=="file"&&this._sources.has(i))return this.sourcesContent[this._sources.indexOf(i)];if((!n.path||n.path=="/")&&this._sources.has("/"+t))return this.sourcesContent[this._sources.indexOf("/"+t)]}throw new Error('"'+t+'" is not in the SourceMap.')},u.prototype.generatedPositionFor=function(t){var n={source:r.getArg(t,"source"),originalLine:r.getArg(t,"line"),originalColumn:r.getArg(t,"column")};this.sourceRoot&&(n.source=r.relative(this.sourceRoot,n.source));var i=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",this._compareOriginalPositions);return i?{line:r.getArg(i,"generatedLine",null),column:r.getArg(i,"generatedColumn",null)}:{line:null,column:null}},u.GENERATED_ORDER=1,u.ORIGINAL_ORDER=2,u.prototype.eachMapping=function(t,n,i){var s=n||null,o=i||u.GENERATED_ORDER,a;switch(o){case u.GENERATED_ORDER:a=this._generatedMappings;break;case u.ORIGINAL_ORDER:a=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var f=this.sourceRoot;a.map(function(e){var t=e.source;return t&&f&&(t=r.join(f,t)),{source:t,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name}}).forEach(t,s)},t.SourceMapConsumer=u}),define("source-map/binary-search",["require","exports","module"],function(e,t,n){function r(e,t,n,i,s){var o=Math.floor((t-e)/2)+e,u=s(n,i[o]);return u===0?i[o]:u>0?t-o>1?r(o,t,n,i,s):i[o]:o-e>1?r(e,o,n,i,s):e<0?null:i[e]}t.search=function(t,n,i){return n.length>0?r(-1,n.length,t,n,i):null}}),define("source-map/source-node",["require","exports","module","source-map/source-map-generator","source-map/util"],function(e,t,n){function s(e,t,n,r,i){this.children=[],this.sourceContents={},this.line=e===undefined?null:e,this.column=t===undefined?null:t,this.source=n===undefined?null:n,this.name=i===undefined?null:i,r!=null&&this.add(r)}var r=e("./source-map-generator").SourceMapGenerator,i=e("./util");s.fromStringWithSourceMap=function(t,n){function f(e,t){e===null||e.source===undefined?r.add(t):r.add(new s(e.originalLine,e.originalColumn,e.source,t,e.name))}var r=new s,i=t.split("\n"),o=1,u=0,a=null;return n.eachMapping(function(e){if(a===null){while(o<e.generatedLine)r.add(i.shift()+"\n"),o++;if(u<e.generatedColumn){var t=i[0];r.add(t.substr(0,e.generatedColumn)),i[0]=t.substr(e.generatedColumn),u=e.generatedColumn}}else if(o<e.generatedLine){var n="";do n+=i.shift()+"\n",o++,u=0;while(o<e.generatedLine);if(u<e.generatedColumn){var t=i[0];n+=t.substr(0,e.generatedColumn),i[0]=t.substr(e.generatedColumn),u=e.generatedColumn}f(a,n)}else{var t=i[0],n=t.substr(0,e.generatedColumn-u);i[0]=t.substr(e.generatedColumn-u),u=e.generatedColumn,f(a,n)}a=e},this),f(a,i.join("\n")),n.sources.forEach(function(e){var t=n.sourceContentFor(e);t&&r.setSourceContent(e,t)}),r},s.prototype.add=function(t){if(Array.isArray(t))t.forEach(function(e){this.add(e)},this);else{if(!(t instanceof s||typeof t=="string"))throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);t&&this.children.push(t)}return this},s.prototype.prepend=function(t){if(Array.isArray(t))for(var n=t.length-1;n>=0;n--)this.prepend(t[n]);else{if(!(t instanceof s||typeof t=="string"))throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);this.children.unshift(t)}return this},s.prototype.walk=function(t){this.children.forEach(function(e){e instanceof s?e.walk(t):e!==""&&t(e,{source:this.source,line:this.line,column:this.column,name:this.name})},this)},s.prototype.join=function(t){var n,r,i=this.children.length;if(i>0){n=[];for(r=0;r<i-1;r++)n.push(this.children[r]),n.push(t);n.push(this.children[r]),this.children=n}return this},s.prototype.replaceRight=function(t,n){var r=this.children[this.children.length-1];return r instanceof s?r.replaceRight(t,n):typeof r=="string"?this.children[this.children.length-1]=r.replace(t,n):this.children.push("".replace(t,n)),this},s.prototype.setSourceContent=function(t,n){this.sourceContents[i.toSetString(t)]=n},s.prototype.walkSourceContents=function(t){this.children.forEach(function(e){e instanceof s&&e.walkSourceContents(t)},this),Object.keys(this.sourceContents).forEach(function(e){t(i.fromSetString(e),this.sourceContents[e])},this)},s.prototype.toString=function(){var t="";return this.walk(function(e){t+=e}),t},s.prototype.toStringWithSourceMap=function(t){var n={code:"",line:1,column:0},i=new r(t),s=!1,o=null,u=null,a=null,f=null;return this.walk(function(e,t){n.code+=e,t.source!==null&&t.line!==null&&t.column!==null?((o!==t.source||u!==t.line||a!==t.column||f!==t.name)&&i.addMapping({source:t.source,original:{line:t.line,column:t.column},generated:{line:n.line,column:n.column},name:t.name}),o=t.source,u=t.line,a=t.column,f=t.name,s=!0):s&&(i.addMapping({generated:{line:n.line,column:n.column}}),o=null,s=!1),e.split("").forEach(function(e){e==="\n"?(n.line++,n.column=0):n.column++})}),this.walkSourceContents(function(e,t){i.setSourceContent(e,t)}),{code:n.code,map:i}},t.SourceNode=s}),window.sourceMap={SourceMapConsumer:require("source-map/source-map-consumer").SourceMapConsumer,SourceMapGenerator:require("source-map/source-map-generator").SourceMapGenerator,SourceNode:require("source-map/source-node").SourceNode}
+
+var emscripten_sourcemap_xmlHttp = undefined;
+function emscripten_sourceMapLoaded() {
+ if (emscripten_sourcemap_xmlHttp.readyState === 4) {
+ Module['removeRunDependency']('sourcemap');
+ if (emscripten_sourcemap_xmlHttp.status === 200) {
+ emscripten_source_map = new window.sourceMap.SourceMapConsumer(emscripten_sourcemap_xmlHttp.responseText);
+ console.log('Source map data loaded.');
+ } else {
+ console.warn('Source map data loading failed with status code ' + emscripten_sourcemap_xmlHttp.status + '.');
+ }
+ emscripten_sourcemap_xmlHttp = undefined;
+ }
+}
+function emscripten_loadSourceMap() {
+ var url = window.location.href+'.map';
+ console.log('Loading source map data from ' + url + '..');
+ Module['addRunDependency']('sourcemap');
+ emscripten_sourcemap_xmlHttp = new XMLHttpRequest();
+ emscripten_sourcemap_xmlHttp.onreadystatechange = emscripten_sourceMapLoaded;
+ emscripten_sourcemap_xmlHttp.open("GET", url, true);
+ emscripten_sourcemap_xmlHttp.send(null);
+}
+
+var Module;
+if (Module['preRun'] instanceof Array) {
+ Module['preRun'].push(emscripten_loadSourceMap);
+} else {
+ Module['preRun'] = [emscripten_loadSourceMap];
+}
diff --git a/tests/hello_world.js b/src/hello_world.js
index 01082eb4..01082eb4 100644
--- a/tests/hello_world.js
+++ b/src/hello_world.js
diff --git a/src/jsifier.js b/src/jsifier.js
index 907855e7..58dc4653 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -6,7 +6,6 @@
// Handy sets
var STRUCT_LIST = set('struct', 'list');
-var UNDERSCORE_OPENPARENS = set('_', '(');
var RELOOP_IGNORED_LASTS = set('return', 'unreachable', 'resume');
var addedLibraryItems = {};
@@ -96,19 +95,6 @@ function JSify(data, functionsOnly, givenFunctions) {
// Functions
- Functions.currExternalFunctions = !mainPass ? givenFunctions.currExternalFunctions : {};
-
- data.functionStubs.forEach(function(func) {
- // Don't overwrite stubs that have more info.
- if (!Functions.currExternalFunctions.hasOwnProperty(func.ident) ||
- !Functions.currExternalFunctions[func.ident].numParams === undefined) {
- Functions.currExternalFunctions[func.ident] = {
- hasVarArgs: func.hasVarArgs,
- numParams: func.params && func.params.length
- };
- }
- });
-
if (phase == 'funcs') { // || phase == 'pre') { // pre has function shells, just to defined implementedFunctions
var MAX_BATCH_FUNC_LINES = 1000;
while (data.unparsedFunctions.length > 0) {
@@ -1824,7 +1810,7 @@ function JSify(data, functionsOnly, givenFunctions) {
print('staticSealed = true; // seal the static portion of memory\n');
print('STACK_MAX = STACK_BASE + ' + TOTAL_STACK + ';\n');
print('DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);\n');
- print('assert(DYNAMIC_BASE < TOTAL_MEMORY); // Stack must fit in TOTAL_MEMORY; allocations from here on may enlarge TOTAL_MEMORY\n');
+ print('assert(DYNAMIC_BASE < TOTAL_MEMORY, "TOTAL_MEMORY not big enough for stack");\n');
}
if (asmLibraryFunctions.length > 0) {
@@ -1859,10 +1845,10 @@ function JSify(data, functionsOnly, givenFunctions) {
// first row are utilities called from generated code, second are needed from fastLong
['i64Add', 'i64Subtract', 'bitshift64Shl', 'bitshift64Lshr', 'bitshift64Ashr',
'llvm_ctlz_i32', 'llvm_cttz_i32'].forEach(function(func) {
- if (!Functions.libraryFunctions[func]) {
+ if (!Functions.libraryFunctions[func] || (phase == 'glue' && func[0] === 'l' && !addedLibraryItems[func])) { // TODO: one-by-one in fastcomp glue mode
print(processLibraryFunction(LibraryManager.library[func], func)); // must be first to be close to generated code
Functions.implementedFunctions['_' + func] = LibraryManager.library[func + '__sig'];
- Functions.libraryFunctions[func] = 1;
+ Functions.libraryFunctions[func] = phase == 'glue' ? 2 : 1; // XXX
// limited dependency handling
var deps = LibraryManager.library[func + '__deps'];
if (deps) {
diff --git a/src/library.js b/src/library.js
index 26d766e9..354e5549 100644
--- a/src/library.js
+++ b/src/library.js
@@ -1868,14 +1868,13 @@ LibraryManager.library = {
#endif
#if USE_TYPED_ARRAYS == 2
} else if (type == 'i64') {
-
-#if TARGET_LE32
+#if TARGET_LE32 == 1
ret = [{{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}},
{{{ makeGetValue('varargs', 'argIndex+8', 'i32', undefined, undefined, true) }}}];
argIndex += {{{ STACK_ALIGN }}}; // each 32-bit chunk is in a 64-bit block
#else
- ret = [{{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}},
- {{{ makeGetValue('varargs', 'argIndex+4', 'i32', undefined, undefined, true) }}}];
+ ret = [{{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true, 4) }}},
+ {{{ makeGetValue('varargs', 'argIndex+4', 'i32', undefined, undefined, true, 4) }}}];
#endif
#else
@@ -7702,6 +7701,94 @@ LibraryManager.library = {
return _gai_strerror.buffer;
},
+ // Implement netdb.h protocol entry (getprotoent, getprotobyname, getprotobynumber, setprotoent, endprotoent)
+ // http://pubs.opengroup.org/onlinepubs/9699919799/functions/getprotobyname.html
+ // The Protocols object holds our 'fake' protocols 'database'.
+ $Protocols: {
+ list: [],
+ map: {}
+ },
+ setprotoent__deps: ['$Protocols'],
+ setprotoent: function(stayopen) {
+ // void setprotoent(int stayopen);
+
+ // Allocate and populate a protoent structure given a name, protocol number and array of aliases
+ function allocprotoent(name, proto, aliases) {
+ // write name into buffer
+ var nameBuf = _malloc(name.length + 1);
+ writeAsciiToMemory(name, nameBuf);
+
+ // write aliases into buffer
+ var j = 0;
+ var length = aliases.length;
+ var aliasListBuf = _malloc((length + 1) * 4); // Use length + 1 so we have space for the terminating NULL ptr.
+
+ for (var i = 0; i < length; i++, j += 4) {
+ var alias = aliases[i];
+ var aliasBuf = _malloc(alias.length + 1);
+ writeAsciiToMemory(alias, aliasBuf);
+ {{{ makeSetValue('aliasListBuf', 'j', 'aliasBuf', 'i8*') }}};
+ }
+ {{{ makeSetValue('aliasListBuf', 'j', '0', 'i8*') }}}; // Terminating NULL pointer.
+
+ // generate protoent
+ var pe = _malloc({{{ C_STRUCTS.protoent.__size__ }}});
+ {{{ makeSetValue('pe', C_STRUCTS.protoent.p_name, 'nameBuf', 'i8*') }}};
+ {{{ makeSetValue('pe', C_STRUCTS.protoent.p_aliases, 'aliasListBuf', 'i8**') }}};
+ {{{ makeSetValue('pe', C_STRUCTS.protoent.p_proto, 'proto', 'i32') }}};
+ return pe;
+ };
+
+ // Populate the protocol 'database'. The entries are limited to tcp and udp, though it is fairly trivial
+ // to add extra entries from /etc/protocols if desired - though not sure if that'd actually be useful.
+ var list = Protocols.list;
+ var map = Protocols.map;
+ if (list.length === 0) {
+ var entry = allocprotoent('tcp', 6, ['TCP']);
+ list.push(entry);
+ map['tcp'] = map['6'] = entry;
+ entry = allocprotoent('udp', 17, ['UDP']);
+ list.push(entry);
+ map['udp'] = map['17'] = entry;
+ }
+
+ _setprotoent.index = 0;
+ },
+
+ endprotoent: function() {
+ // void endprotoent(void);
+ // We're not using a real protocol database so we don't do a real close.
+ },
+
+ getprotoent__deps: ['setprotoent', '$Protocols'],
+ getprotoent: function(number) {
+ // struct protoent *getprotoent(void);
+ // reads the next entry from the protocols 'database' or return NULL if 'eof'
+ if (_setprotoent.index === Protocols.list.length) {
+ return 0;
+ } else {
+ var result = Protocols.list[_setprotoent.index++];
+ return result;
+ }
+ },
+
+ getprotobyname__deps: ['setprotoent', '$Protocols'],
+ getprotobyname: function(name) {
+ // struct protoent *getprotobyname(const char *);
+ name = Pointer_stringify(name);
+ _setprotoent(true);
+ var result = Protocols.map[name];
+ return result;
+ },
+
+ getprotobynumber__deps: ['setprotoent', '$Protocols'],
+ getprotobynumber: function(number) {
+ // struct protoent *getprotobynumber(int proto);
+ _setprotoent(true);
+ var result = Protocols.map[number];
+ return result;
+ },
+
// ==========================================================================
// sockets. Note that the implementation assumes all sockets are always
// nonblocking
@@ -8748,6 +8835,194 @@ LibraryManager.library = {
}
},
+ // Returns [parentFuncArguments, functionName, paramListName]
+ _emscripten_traverse_stack: function(args) {
+ if (!args || !args.callee || !args.callee.name) {
+ return [null, '', ''];
+ }
+
+ var funstr = args.callee.toString();
+ var funcname = args.callee.name;
+ var str = '(';
+ var first = true;
+ for(i in args) {
+ var a = args[i];
+ if (!first) {
+ str += ", ";
+ }
+ first = false;
+ if (typeof a === 'number' || typeof a === 'string') {
+ str += a;
+ } else {
+ str += '(' + typeof a + ')';
+ }
+ }
+ str += ')';
+ var caller = args.callee.caller;
+ args = caller ? caller.arguments : [];
+ if (first)
+ str = '';
+ return [args, funcname, str];
+ },
+
+ emscripten_get_callstack_js__deps: ['_emscripten_traverse_stack'],
+ emscripten_get_callstack_js: function(flags) {
+ var err = new Error();
+ if (!err.stack) {
+ Runtime.warnOnce('emscripten_get_callstack_js is not supported on this browser!');
+ return '';
+ }
+ var callstack = new Error().stack.toString();
+
+ // Find the symbols in the callstack that corresponds to the functions that report callstack information, and remove everyhing up to these from the output.
+ var iThisFunc = callstack.lastIndexOf('_emscripten_log');
+ var iThisFunc2 = callstack.lastIndexOf('_emscripten_get_callstack');
+ var iNextLine = callstack.indexOf('\n', Math.max(iThisFunc, iThisFunc2))+1;
+ callstack = callstack.slice(iNextLine);
+
+ // If user requested to see the original source stack, but no source map information is available, just fall back to showing the JS stack.
+ if (flags & 8/*EM_LOG_C_STACK*/ && typeof emscripten_source_map === 'undefined') {
+ Runtime.warnOnce('Source map information is not available, emscripten_log with EM_LOG_C_STACK will be ignored. Build with "--pre-js $EMSCRIPTEN/src/emscripten-source-map.min.js" linker flag to add source map loading to code.');
+ flags ^= 8/*EM_LOG_C_STACK*/;
+ flags |= 16/*EM_LOG_JS_STACK*/;
+ }
+
+ var stack_args = null;
+ if (flags & 128 /*EM_LOG_FUNC_PARAMS*/) {
+ // To get the actual parameters to the functions, traverse the stack via the unfortunately deprecated 'arguments.callee' method, if it works:
+ var stack_args = __emscripten_traverse_stack(arguments);
+ while (stack_args[1].indexOf('_emscripten_') >= 0)
+ stack_args = __emscripten_traverse_stack(stack_args[0]);
+ }
+
+ // Process all lines:
+ lines = callstack.split('\n');
+ callstack = '';
+ var firefoxRe = new RegExp('\\s*(.*?)@(.*):(.*)'); // Extract components of form ' Object._main@http://server.com:4324'
+ var chromeRe = new RegExp('\\s*at (.*?) \\\((.*):(.*):(.*)\\\)'); // Extract components of form ' at Object._main (http://server.com/file.html:4324:12)'
+
+ for(l in lines) {
+ var line = lines[l];
+
+ var jsSymbolName = '';
+ var file = '';
+ var lineno = 0;
+ var column = 0;
+
+ var parts = chromeRe.exec(line);
+ if (parts && parts.length == 5) {
+ jsSymbolName = parts[1];
+ file = parts[2];
+ lineno = parts[3];
+ column = parts[4];
+ } else {
+ parts = firefoxRe.exec(line);
+ if (parts && parts.length == 4) {
+ jsSymbolName = parts[1];
+ file = parts[2];
+ lineno = parts[3];
+ column = 0; // Firefox doesn't carry column information. See https://bugzilla.mozilla.org/show_bug.cgi?id=762556
+ } else {
+ // Was not able to extract this line for demangling/sourcemapping purposes. Output it as-is.
+ callstack += line + '\n';
+ continue;
+ }
+ }
+
+ // Try to demangle the symbol, but fall back to showing the original JS symbol name if not available.
+ var cSymbolName = (flags & 32/*EM_LOG_DEMANGLE*/) ? demangle(jsSymbolName) : jsSymbolName;
+ if (!cSymbolName) {
+ cSymbolName = jsSymbolName;
+ }
+
+ var haveSourceMap = false;
+
+ if (flags & 8/*EM_LOG_C_STACK*/) {
+ var orig = emscripten_source_map.originalPositionFor({line: lineno, column: column});
+ haveSourceMap = (orig && orig.source);
+ if (haveSourceMap) {
+ if (flags & 64/*EM_LOG_NO_PATHS*/) {
+ orig.source = orig.source.substring(orig.source.replace(/\\/g, "/").lastIndexOf('/')+1);
+ }
+ callstack += ' at ' + cSymbolName + ' (' + orig.source + ':' + orig.line + ':' + orig.column + ')\n';
+ }
+ }
+ if ((flags & 16/*EM_LOG_JS_STACK*/) || !haveSourceMap) {
+ if (flags & 64/*EM_LOG_NO_PATHS*/) {
+ file = file.substring(file.replace(/\\/g, "/").lastIndexOf('/')+1);
+ }
+ callstack += (haveSourceMap ? (' = '+jsSymbolName) : (' at '+cSymbolName)) + ' (' + file + ':' + lineno + ':' + column + ')\n';
+ }
+
+ // If we are still keeping track with the callstack by traversing via 'arguments.callee', print the function parameters as well.
+ if (flags & 128 /*EM_LOG_FUNC_PARAMS*/ && stack_args[0]) {
+ if (stack_args[1] == jsSymbolName && stack_args[2].length > 0) {
+ callstack = callstack.replace(/\s+$/, '');
+ callstack += ' with values: ' + stack_args[1] + stack_args[2] + '\n';
+ }
+ stack_args = __emscripten_traverse_stack(stack_args[0]);
+ }
+ }
+ // Trim extra whitespace at the end of the output.
+ callstack = callstack.replace(/\s+$/, '');
+ return callstack;
+ },
+
+ emscripten_get_callstack__deps: ['emscripten_get_callstack_js'],
+ emscripten_get_callstack: function(flags, str, maxbytes) {
+ var callstack = _emscripten_get_callstack_js(flags);
+ // User can query the required amount of bytes to hold the callstack.
+ if (!str || maxbytes <= 0) {
+ return callstack.length+1;
+ }
+ // Truncate output to avoid writing past bounds.
+ if (callstack.length > maxbytes-1) {
+ callstack.slice(0, maxbytes-1);
+ }
+ // Output callstack string as C string to HEAP.
+ writeStringToMemory(callstack, str, false);
+
+ // Return number of bytes written.
+ return callstack.length+1;
+ },
+
+ emscripten_log_js__deps: ['emscripten_get_callstack_js'],
+ emscripten_log_js: function(flags, str) {
+ if (flags & 24/*EM_LOG_C_STACK | EM_LOG_JS_STACK*/) {
+ str = str.replace(/\s+$/, ''); // Ensure the message and the callstack are joined cleanly with exactly one newline.
+ str += (str.length > 0 ? '\n' : '') + _emscripten_get_callstack_js(flags);
+ }
+
+ if (flags & 1 /*EM_LOG_CONSOLE*/) {
+ if (flags & 4 /*EM_LOG_ERROR*/) {
+ console.error(str);
+ } else if (flags & 2 /*EM_LOG_WARN*/) {
+ console.warn(str);
+ } else {
+ console.log(str);
+ }
+ } else if (flags & 6 /*EM_LOG_ERROR|EM_LOG_WARN*/) {
+ Module.printErr(str);
+ } else {
+ Module.print(str);
+ }
+ },
+
+ emscripten_log__deps: ['_formatString', 'emscripten_log_js'],
+ emscripten_log: function(flags, varargs) {
+ // Extract the (optionally-existing) printf format specifier field from varargs.
+ var format = {{{ makeGetValue('varargs', '0', 'i32', undefined, undefined, true) }}};
+ varargs += Math.max(Runtime.getNativeFieldSize('i32'), Runtime.getAlignSize('i32', null, true));
+ var str = '';
+ if (format) {
+ var result = __formatString(format, varargs);
+ for(var i = 0 ; i < result.length; ++i) {
+ str += String.fromCharCode(result[i]);
+ }
+ }
+ _emscripten_log_js(flags, str);
+ },
+
//============================
// emscripten vector ops
//============================
diff --git a/src/library_egl.js b/src/library_egl.js
index 73d5e544..11cf8951 100644
--- a/src/library_egl.js
+++ b/src/library_egl.js
@@ -264,6 +264,26 @@ var LibraryEGL = {
return 0;
}
+ // EGL 1.4 spec says default EGL_CONTEXT_CLIENT_VERSION is GLES1, but this is not supported by Emscripten.
+ // So user must pass EGL_CONTEXT_CLIENT_VERSION == 2 to initialize EGL.
+ var glesContextVersion = 1;
+ for(;;) {
+ var param = {{{ makeGetValue('contextAttribs', '0', 'i32') }}};
+ if (!param) break;
+ var value = {{{ makeGetValue('contextAttribs', '4', 'i32') }}};
+ if (param == 0x3098 /*EGL_CONTEXT_CLIENT_VERSION*/) {
+ glesContextVersion = value;
+ }
+ contextAttribs += 8;
+ }
+ if (glesContextVersion != 2) {
+#if GL_ASSERTIONS
+ Module.printErr('When initializing GLES2/WebGL1 via EGL, one must pass EGL_CONTEXT_CLIENT_VERSION = 2 to GL context attributes! GLES version ' + glesContextVersion + ' is not supported!');
+#endif
+ EGL.setErrorCode(0x3005 /* EGL_BAD_CONFIG */);
+ return 0; /* EGL_NO_CONTEXT */
+ }
+
_glutInitDisplayMode(0x92 /* GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE */);
EGL.windowID = _glutCreateWindow();
if (EGL.windowID != 0) {
diff --git a/src/library_fs.js b/src/library_fs.js
index 5412185f..1e7856aa 100644
--- a/src/library_fs.js
+++ b/src/library_fs.js
@@ -961,7 +961,7 @@ mergeInto(LibraryManager.library, {
throw new FS.ErrnoError(ERRNO_CODES.EACCES);
}
if (!stream.stream_ops.mmap) {
- throw new FS.errnoError(ERRNO_CODES.ENODEV);
+ throw new FS.ErrnoError(ERRNO_CODES.ENODEV);
}
return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);
},
diff --git a/src/library_gl.js b/src/library_gl.js
index cc39b048..075d7cb5 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -210,21 +210,30 @@ var LibraryGL = {
},
get: function(name_, p, type) {
+ // Guard against user passing a null pointer.
+ // Note that GLES2 spec does not say anything about how passing a null pointer should be treated.
+ // Testing on desktop core GL 3, the application crashes on glGetIntegerv to a null pointer, but
+ // better to report an error instead of doing anything random.
+ if (!p) {
+#if GL_ASSERTIONS
+ Module.printErr('GL_INVALID_VALUE in glGet' + type + 'v(name=' + name_ + ': Function called with null out pointer!');
+#endif
+ GL.recordError(0x0501 /* GL_INVALID_VALUE */);
+ return;
+ }
var ret = undefined;
switch(name_) { // Handle a few trivial GLES values
case 0x8DFA: // GL_SHADER_COMPILER
ret = 1;
break;
case 0x8DF8: // GL_SHADER_BINARY_FORMATS
- if (type === 'Integer') {
- // fall through, see gles2_conformance.cpp
- } else {
+ if (type !== 'Integer') {
GL.recordError(0x0500); // GL_INVALID_ENUM
#if GL_ASSERTIONS
Module.printErr('GL_INVALID_ENUM in glGet' + type + 'v(GL_SHADER_BINARY_FORMATS): Invalid parameter type!');
#endif
- return;
}
+ return; // Do not write anything to the out pointer, since no binary formats are supported.
case 0x8DF9: // GL_NUM_SHADER_BINARY_FORMATS
ret = 0;
break;
@@ -259,11 +268,27 @@ var LibraryGL = {
return;
case "object":
if (result === null) {
- GL.recordError(0x0500); // GL_INVALID_ENUM
+ // null is a valid result for some (e.g., which buffer is bound - perhaps nothing is bound), but otherwise
+ // can mean an invalid name_, which we need to report as an error
+ switch(name_) {
+ case 0x8894: // ARRAY_BUFFER_BINDING
+ case 0x8B8D: // CURRENT_PROGRAM
+ case 0x8895: // ELEMENT_ARRAY_BUFFER_BINDING
+ case 0x8CA6: // FRAMEBUFFER_BINDING
+ case 0x8CA7: // RENDERBUFFER_BINDING
+ case 0x8069: // TEXTURE_BINDING_2D
+ case 0x8514: { // TEXTURE_BINDING_CUBE_MAP
+ ret = 0;
+ break;
+ }
+ default: {
+ GL.recordError(0x0500); // GL_INVALID_ENUM
#if GL_ASSERTIONS
- Module.printErr('GL_INVALID_ENUM in glGet' + type + 'v(' + name_ + ') and it returns null!');
+ Module.printErr('GL_INVALID_ENUM in glGet' + type + 'v(' + name_ + ') and it returns null!');
#endif
- return;
+ return;
+ }
+ }
} else if (result instanceof Float32Array ||
result instanceof Uint32Array ||
result instanceof Int32Array ||
@@ -538,6 +563,9 @@ var LibraryGL = {
Module.ctx.getExtension('WEBKIT_EXT_texture_filter_anisotropic');
GL.floatExt = Module.ctx.getExtension('OES_texture_float');
+
+ // Extension available from Firefox 26 and Google Chrome 30
+ GL.instancedArraysExt = Module.ctx.getExtension('ANGLE_instanced_arrays');
// These are the 'safe' feature-enabling extensions that don't add any performance impact related to e.g. debugging, and
// should be enabled by default so that client GLES2/GL code will not need to go through extra hoops to get its stuff working.
@@ -1676,7 +1704,7 @@ var LibraryGL = {
glGetFramebufferAttachmentParameteriv__sig: 'viiii',
glGetFramebufferAttachmentParameteriv: function(target, attachment, pname, params) {
var result = Module.ctx.getFramebufferAttachmentParameter(target, attachment, pname);
- {{{ makeSetValue('params', '0', 'params', 'i32') }}};
+ {{{ makeSetValue('params', '0', 'result', 'i32') }}};
},
glIsFramebuffer__sig: 'ii',
@@ -1907,6 +1935,13 @@ var LibraryGL = {
return id;
};
+ function ensurePrecision(source) {
+ if (!/precision +(low|medium|high)p +float *;/.test(source)) {
+ source = 'precision mediump float;\n' + source;
+ }
+ return source;
+ }
+
var glShaderSource = _glShaderSource;
_glShaderSource = function _glShaderSource(shader, count, string, length) {
var source = GL.getSource(shader, count, string, length);
@@ -1980,6 +2015,7 @@ var LibraryGL = {
source = 'varying float v_fogFragCoord; \n' +
source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
}
+ source = ensurePrecision(source);
} else { // Fragment shader
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
var old = source;
@@ -2011,7 +2047,7 @@ var LibraryGL = {
source = 'varying float v_fogFragCoord; \n' +
source.replace(/gl_FogFragCoord/g, 'v_fogFragCoord');
}
- source = 'precision mediump float;\n' + source;
+ source = ensurePrecision(source);
}
#if GL_DEBUG
GL.shaderSources[shader] = source;
@@ -4950,6 +4986,45 @@ var LibraryGL = {
return Module.ctx.getError();
}
},
+
+ // ANGLE_instanced_arrays WebGL extension related functions
+
+ glVertexAttribDivisor__sig: 'vii',
+ glVertexAttribDivisor: function(index, divisor) {
+#if GL_ASSERTIONS
+ assert(GL.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing');
+#endif
+ GL.instancedArraysExt.vertexAttribDivisorANGLE(index, divisor);
+ },
+
+ glDrawArraysInstanced__sig: 'viiii',
+ glDrawArraysInstanced: function(mode, first, count, primcount) {
+#if GL_ASSERTIONS
+ assert(GL.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing');
+#endif
+ GL.instancedArraysExt.drawArraysInstancedANGLE(mode, first, count, primcount);
+ },
+
+ glDrawElementsInstanced__sig: 'viiiii',
+ glDrawElementsInstanced: function(mode, count, type, indices, primcount) {
+#if GL_ASSERTIONS
+ assert(GL.instancedArraysExt, 'Must have ANGLE_instanced_arrays extension to use WebGL instancing');
+#endif
+ GL.instancedArraysExt.drawElementsInstancedANGLE(mode, count, type, indices, primcount);
+ },
+
+ // OpenGL Desktop/ES 2.0 instancing extensions compatibility
+
+ glVertexAttribDivisorNV: 'glVertexAttribDivisor',
+ glDrawArraysInstancedNV: 'glDrawArraysInstanced',
+ glDrawElementsInstancedNV: 'glDrawElementsInstanced',
+ glVertexAttribDivisorEXT: 'glVertexAttribDivisor',
+ glDrawArraysInstancedEXT: 'glDrawArraysInstanced',
+ glDrawElementsInstancedEXT: 'glDrawElementsInstanced',
+ glVertexAttribDivisorARB: 'glVertexAttribDivisor',
+ glDrawArraysInstancedARB: 'glDrawArraysInstanced',
+ glDrawElementsInstancedARB: 'glDrawElementsInstanced',
+
// signatures of simple pass-through functions, see later
glActiveTexture__sig: 'vi',
diff --git a/src/library_glfw.js b/src/library_glfw.js
index 647d4bb6..17e8956a 100644
--- a/src/library_glfw.js
+++ b/src/library_glfw.js
@@ -120,7 +120,6 @@ var LibraryGLFW = {
if (event.charCode) {
var char = GLFW.getUnicodeChar(event.charCode);
if (char !== null && GLFW.charFunc) {
- event.preventDefault();
Runtime.dynCall('vii', GLFW.charFunc, [event.charCode, 1]);
}
}
@@ -130,13 +129,18 @@ var LibraryGLFW = {
var key = GLFW.DOMToGLFWKeyCode(event.keyCode);
if (key && GLFW.keyFunc) {
GLFW.keys[key] = status;
- event.preventDefault();
Runtime.dynCall('vii', GLFW.keyFunc, [key, status]);
}
},
onKeydown: function(event) {
GLFW.onKeyChanged(event, 1);//GLFW_PRESS
+ // This logic comes directly from the sdl implementation. We cannot
+ // call preventDefault on all keydown events otherwise onKeyPress will
+ // not get called
+ if (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */) {
+ event.preventDefault();
+ }
},
onKeyup: function(event) {
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 40e5e3ab..1c1e8107 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -1220,6 +1220,7 @@ var LibrarySDL = {
if (surf) SDL.freeSurface(surf);
},
+ SDL_UpperBlit__deps: ['SDL_LockSurface'],
SDL_UpperBlit: function(src, srcrect, dst, dstrect) {
var srcData = SDL.surfaces[src];
var dstData = SDL.surfaces[dst];
@@ -1247,10 +1248,7 @@ var LibrarySDL = {
return 0;
},
- SDL_LowerBlit__deps: ['SDL_UpperBlit'],
- SDL_LowerBlit: function(src, srcrect, dst, dstrect) {
- return _SDL_UpperBlit(src, srcrect, dst, dstrect);
- },
+ SDL_LowerBlit: 'SDL_UpperBlit',
SDL_FillRect: function(surf, rect, color) {
var surfData = SDL.surfaces[surf];
diff --git a/src/modules.js b/src/modules.js
index e80115c4..e2d3433f 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -282,7 +282,12 @@ var Functions = {
sig += Functions.getSignatureLetter(type);
} else {
var chunks = getNumIntChunks(type);
- for (var j = 0; j < chunks; j++) sig += 'i';
+ if (chunks > 0) {
+ for (var j = 0; j < chunks; j++) sig += 'i';
+ } else if (type !== '...') {
+ // some special type like a SIMD vector (anything but varargs, which we handle below)
+ sig += Functions.getSignatureLetter(type);
+ }
}
}
if (hasVarArgs) sig += 'i';
@@ -424,6 +429,26 @@ var LibraryManager = {
eval(processMacros(preprocess(read(libraries[i]))));
}
+ /*
+ // export code for CallHandlers.h
+ printErr('============================');
+ for (var x in this.library) {
+ var y = this.library[x];
+ if (typeof y === 'string' && x.indexOf('__sig') < 0 && x.indexOf('__postset') < 0 && y.indexOf(' ') < 0) {
+ printErr('DEF_REDIRECT_HANDLER(' + x + ', ' + y + ');');
+ }
+ }
+ printErr('============================');
+ for (var x in this.library) {
+ var y = this.library[x];
+ if (typeof y === 'string' && x.indexOf('__sig') < 0 && x.indexOf('__postset') < 0 && y.indexOf(' ') < 0) {
+ printErr(' SETUP_CALL_HANDLER(' + x + ');');
+ }
+ }
+ printErr('============================');
+ // end export code for CallHandlers.h
+ */
+
this.loaded = true;
},
diff --git a/src/parseTools.js b/src/parseTools.js
index ff981264..874514b1 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -16,6 +16,7 @@ function processMacros(text) {
// Simple #if/else/endif preprocessing for a file. Checks if the
// ident checked is true in our global.
+// Also handles #include x.js (similar to C #include <file>)
function preprocess(text) {
var lines = text.split('\n');
var ret = '';
@@ -30,25 +31,29 @@ function preprocess(text) {
ret += line + '\n';
}
} else {
- if (line[1] && line[1] == 'i') { // if
- var parts = line.split(' ');
- var ident = parts[1];
- var op = parts[2];
- var value = parts[3];
- if (op) {
- if (op === '==') {
- showStack.push(ident in this && this[ident] == value);
- } else if (op === '!=') {
- showStack.push(!(ident in this && this[ident] == value));
+ if (line[1] == 'i') {
+ if (line[2] == 'f') { // if
+ var parts = line.split(' ');
+ var ident = parts[1];
+ var op = parts[2];
+ var value = parts[3];
+ if (op) {
+ if (op === '==') {
+ showStack.push(ident in this && this[ident] == value);
+ } else if (op === '!=') {
+ showStack.push(!(ident in this && this[ident] == value));
+ } else {
+ error('unsupported preprecessor op ' + op);
+ }
} else {
- error('unsupported preprecessor op ' + op);
+ showStack.push(ident in this && this[ident] > 0);
}
- } else {
- showStack.push(ident in this && this[ident] > 0);
+ } else if (line[2] == 'n') { // include
+ ret += '\n' + read(line.substr(line.indexOf(' ')+1)) + '\n'
}
- } else if (line[2] && line[2] == 'l') { // else
+ } else if (line[2] == 'l') { // else
showStack.push(!showStack.pop());
- } else if (line[2] && line[2] == 'n') { // endif
+ } else if (line[2] == 'n') { // endif
showStack.pop();
} else {
throw "Unclear preprocessor command: " + line;
diff --git a/src/preamble.js b/src/preamble.js
index 710b7c52..f9fccdf6 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -642,6 +642,10 @@ Module['stringToUTF32'] = stringToUTF32;
function demangle(func) {
try {
+ // Special-case the entry point, since its name differs from other name mangling.
+ if (func == 'Object._main' || func == '_main') {
+ return 'main()';
+ }
if (typeof func === 'number') func = Pointer_stringify(func);
if (func[0] !== '_') return func;
if (func[1] !== '_') return func; // C function
@@ -862,6 +866,21 @@ var TOTAL_STACK = Module['TOTAL_STACK'] || {{{ TOTAL_STACK }}};
var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || {{{ TOTAL_MEMORY }}};
var FAST_MEMORY = Module['FAST_MEMORY'] || {{{ FAST_MEMORY }}};
+#if ASM_JS
+var totalMemory = 4096;
+while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
+ if (totalMemory < 16*1024*1024) {
+ totalMemory *= 2;
+ } else {
+ totalMemory += 16*1024*1024
+ }
+}
+if (totalMemory !== TOTAL_MEMORY) {
+ Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
+ TOTAL_MEMORY = totalMemory;
+}
+#endif
+
// Initialize the runtime's memory
#if USE_TYPED_ARRAYS
// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp
index d2a48f63..de69e0ef 100644
--- a/src/relooper/Relooper.cpp
+++ b/src/relooper/Relooper.cpp
@@ -101,9 +101,7 @@ void Branch::Render(Block *Target, bool SetLabel) {
// Block
-int Block::IdCounter = 1; // 0 is reserved for clearings
-
-Block::Block(const char *CodeInit, const char *BranchVarInit) : Parent(NULL), Id(Block::IdCounter++), IsCheckedMultipleEntry(false) {
+Block::Block(const char *CodeInit, const char *BranchVarInit) : Parent(NULL), Id(-1), IsCheckedMultipleEntry(false) {
Code = strdup(CodeInit);
BranchVar = BranchVarInit ? strdup(BranchVarInit) : NULL;
}
@@ -142,6 +140,7 @@ void Block::Render(bool InLoop) {
if (!ProcessedBranchesOut.size()) return;
bool SetLabel = true; // in some cases it is clear we can avoid setting label, see later
+ bool ForceSetLabel = Shape::IsEmulated(Parent);
// A setting of the label variable (label = x) is necessary if it can
// cause an impact. The main case is where we set label to x, then elsewhere
@@ -210,7 +209,7 @@ void Block::Render(bool InLoop) {
Target = DefaultTarget;
Details = ProcessedBranchesOut[DefaultTarget];
}
- bool SetCurrLabel = SetLabel && Target->IsCheckedMultipleEntry;
+ bool SetCurrLabel = (SetLabel && Target->IsCheckedMultipleEntry) || ForceSetLabel;
bool HasFusedContent = Fused && contains(Fused->InnerMap, Target);
bool HasContent = SetCurrLabel || Details->Type != Branch::Direct || HasFusedContent || Details->Code;
if (iter != ProcessedBranchesOut.end()) {
@@ -272,10 +271,6 @@ void Block::Render(bool InLoop) {
}
}
-// Shape
-
-int Shape::IdCounter = 0;
-
// MultipleShape
void MultipleShape::RenderLoopPrefix() {
@@ -330,16 +325,19 @@ void LoopShape::Render(bool InLoop) {
if (Next) Next->Render(InLoop);
};
-/*
// EmulatedShape
void EmulatedShape::Render(bool InLoop) {
+ PrintIndented("label = %d;\n", Entry->Id);
+ if (Labeled) {
+ PrintIndented("L%d: ", Id);
+ }
PrintIndented("while(1) {\n");
Indenter::Indent();
- PrintIndented("switch(label) {\n");
+ PrintIndented("switch(label|0) {\n");
Indenter::Indent();
- for (int i = 0; i < Blocks.size(); i++) {
- Block *Curr = Blocks[i];
+ for (BlockSet::iterator iter = Blocks.begin(); iter != Blocks.end(); iter++) {
+ Block *Curr = *iter;
PrintIndented("case %d: {\n", Curr->Id);
Indenter::Indent();
Curr->Render(InLoop);
@@ -353,11 +351,10 @@ void EmulatedShape::Render(bool InLoop) {
PrintIndented("}\n");
if (Next) Next->Render(InLoop);
};
-*/
// Relooper
-Relooper::Relooper() : Root(NULL) {
+Relooper::Relooper() : Root(NULL), Emulate(false), BlockIdCounter(1), ShapeIdCounter(0) { // block ID 0 is reserved for clearings
}
Relooper::~Relooper() {
@@ -366,6 +363,7 @@ Relooper::~Relooper() {
}
void Relooper::AddBlock(Block *New) {
+ New->Id = BlockIdCounter++;
Blocks.push_back(New);
}
@@ -419,7 +417,7 @@ void Relooper::Calculate(Block *Entry) {
for (BlockSet::iterator iter = Original->BranchesIn.begin(); iter != Original->BranchesIn.end(); iter++) {
Block *Prior = *iter;
Block *Split = new Block(Original->Code, Original->BranchVar);
- Parent->Blocks.push_back(Split);
+ Parent->AddBlock(Split);
PrintDebug(" to %d\n", Split->Id);
Split->BranchesIn.insert(Prior);
Branch *Details = Prior->BranchesOut[Original];
@@ -461,7 +459,7 @@ void Relooper::Calculate(Block *Entry) {
}
}
- Pre.SplitDeadEnds();
+ if (!Emulate) Pre.SplitDeadEnds();
// Recursively process the graph
@@ -470,6 +468,7 @@ void Relooper::Calculate(Block *Entry) {
// Add a shape to the list of shapes in this Relooper calculation
void Notice(Shape *New) {
+ New->Id = Parent->ShapeIdCounter++;
Parent->Shapes.push_back(New);
}
@@ -526,6 +525,21 @@ void Relooper::Calculate(Block *Entry) {
return Simple;
}
+ Shape *MakeEmulated(BlockSet &Blocks, Block *Entry, BlockSet &NextEntries) {
+ PrintDebug("creating emulated block with entry #%d and everything it can reach, %d blocks\n", Entry->Id, Blocks.size());
+ EmulatedShape *Emulated = new EmulatedShape;
+ Notice(Emulated);
+ Emulated->Entry = Entry;
+ for (BlockSet::iterator iter = Blocks.begin(); iter != Blocks.end(); iter++) {
+ Block *Curr = *iter;
+ Emulated->Blocks.insert(Curr);
+ Curr->Parent = Emulated;
+ Solipsize(Curr, Branch::Continue, Emulated, Blocks);
+ }
+ Blocks.clear();
+ return Emulated;
+ }
+
Shape *MakeLoop(BlockSet &Blocks, BlockSet& Entries, BlockSet &NextEntries) {
// Find the inner blocks in this loop. Proceed backwards from the entries until
// you reach a seen block, collecting as you go.
@@ -837,6 +851,9 @@ void Relooper::Calculate(Block *Entry) {
if (Entries->size() == 0) return Ret;
if (Entries->size() == 1) {
Block *Curr = *(Entries->begin());
+ if (Parent->Emulate) {
+ Make(MakeEmulated(Blocks, Curr, *NextEntries));
+ }
if (Curr->BranchesIn.size() == 0) {
// One entry, no looping ==> Simple
Make(MakeSimple(Blocks, Curr, *NextEntries));
@@ -844,6 +861,7 @@ void Relooper::Calculate(Block *Entry) {
// One entry, looping ==> Loop
Make(MakeLoop(Blocks, *Entries, *NextEntries));
}
+
// More than one entry, try to eliminate through a Multiple groups of
// independent blocks from an entry/ies. It is important to remove through
// multiples as opposed to looping since the former is more performant.
diff --git a/src/relooper/Relooper.h b/src/relooper/Relooper.h
index f3dedf8c..04f2ffc3 100644
--- a/src/relooper/Relooper.h
+++ b/src/relooper/Relooper.h
@@ -57,7 +57,7 @@ struct Block {
BlockBranchMap ProcessedBranchesOut;
BlockSet ProcessedBranchesIn;
Shape *Parent; // The shape we are directly inside
- int Id; // A unique identifier
+ int Id; // A unique identifier, defined when added to relooper
const char *Code; // The string representation of the code in this block. Owning pointer (we copy the input)
const char *BranchVar; // If we have more than one branch out, the variable whose value determines where we go
bool IsCheckedMultipleEntry; // If true, we are a multiple entry, so reaching us requires setting the label variable
@@ -69,9 +69,6 @@ struct Block {
// Prints out the instructions code and branchings
void Render(bool InLoop);
-
- // INTERNAL
- static int IdCounter;
};
// Represents a structured control flow shape, one of
@@ -96,20 +93,22 @@ class SimpleShape;
class LabeledShape;
class MultipleShape;
class LoopShape;
+class EmulatedShape;
struct Shape {
- int Id; // A unique identifier. Used to identify loops, labels are Lx where x is the Id.
+ int Id; // A unique identifier. Used to identify loops, labels are Lx where x is the Id. Defined when added to relooper
Shape *Next; // The shape that will appear in the code right after this one
Shape *Natural; // The shape that control flow gets to naturally (if there is Next, then this is Next)
enum ShapeType {
Simple,
Multiple,
- Loop
+ Loop,
+ Emulated
};
ShapeType Type;
- Shape(ShapeType TypeInit) : Id(Shape::IdCounter++), Next(NULL), Type(TypeInit) {}
+ Shape(ShapeType TypeInit) : Id(-1), Next(NULL), Type(TypeInit) {}
virtual ~Shape() {}
virtual void Render(bool InLoop) = 0;
@@ -118,9 +117,7 @@ struct Shape {
static MultipleShape *IsMultiple(Shape *It) { return It && It->Type == Multiple ? (MultipleShape*)It : NULL; }
static LoopShape *IsLoop(Shape *It) { return It && It->Type == Loop ? (LoopShape*)It : NULL; }
static LabeledShape *IsLabeled(Shape *It) { return IsMultiple(It) || IsLoop(It) ? (LabeledShape*)It : NULL; }
-
- // INTERNAL
- static int IdCounter;
+ static EmulatedShape *IsEmulated(Shape *It) { return It && It->Type == Emulated ? (EmulatedShape*)It : NULL; }
};
struct SimpleShape : public Shape {
@@ -162,12 +159,15 @@ struct LoopShape : public LabeledShape {
void Render(bool InLoop);
};
-/*
-struct EmulatedShape : public Shape {
- std::deque<Block*> Blocks;
+// TODO EmulatedShape is only partially functional. Currently it can be used for the
+// entire set of blocks being relooped, but not subsets.
+struct EmulatedShape : public LabeledShape {
+ Block *Entry;
+ BlockSet Blocks;
+
+ EmulatedShape() : LabeledShape(Emulated) { Labeled = true; }
void Render(bool InLoop);
};
-*/
// Implements the relooper algorithm for a function's blocks.
//
@@ -184,6 +184,9 @@ struct Relooper {
std::deque<Block*> Blocks;
std::deque<Shape*> Shapes;
Shape *Root;
+ bool Emulate;
+ int BlockIdCounter;
+ int ShapeIdCounter;
Relooper();
~Relooper();
@@ -204,6 +207,9 @@ struct Relooper {
// Sets asm.js mode on or off (default is off)
static void SetAsmJSMode(int On);
+
+ // Sets whether we must emulate everything with switch-loop code
+ void SetEmulate(int E) { Emulate = E; }
};
typedef std::map<Block*, BlockSet> BlockBlockSetMap;
diff --git a/src/relooper/fuzzer.py b/src/relooper/fuzzer.py
index 50846d10..fa47583e 100644
--- a/src/relooper/fuzzer.py
+++ b/src/relooper/fuzzer.py
@@ -87,6 +87,12 @@ int main() {
Relooper r;
'''
+ if random.random() < 0.1:
+ print 'emulate'
+ fast += '''
+ r.SetEmulate(true);
+'''
+
for i in range(num):
fast += ''' r.AddBlock(b%d);
''' % i
diff --git a/src/relooper/test.cpp b/src/relooper/test.cpp
index fbd9c7aa..773f6ee4 100644
--- a/src/relooper/test.cpp
+++ b/src/relooper/test.cpp
@@ -258,5 +258,33 @@ int main() {
puts(buffer);
}
+
+ if (1) {
+ Relooper::SetOutputBuffer(buffer, sizeof(buffer));
+
+ printf("\n\n-- If pattern, emulated --\n\n", "the_var");
+
+ Block *b_a = new Block("// block A\n", NULL);
+ Block *b_b = new Block("// block B\n", "b_check()");
+ Block *b_c = new Block("// block C\n", NULL);
+
+ b_a->AddBranchTo(b_b, "check == 10", "atob();");
+ b_a->AddBranchTo(b_c, NULL, "atoc();");
+
+ b_b->AddBranchTo(b_c, "case 17:", "btoc();");
+ b_b->AddBranchTo(b_a, NULL, NULL);
+
+ Relooper r;
+ r.SetEmulate(true);
+ r.AddBlock(b_a);
+ r.AddBlock(b_b);
+ r.AddBlock(b_c);
+
+ r.Calculate(b_a);
+ printf("\n\n", "the_var");
+ r.Render();
+
+ puts(buffer);
+ }
}
diff --git a/src/relooper/test.txt b/src/relooper/test.txt
index 2c530567..540f7bdb 100644
--- a/src/relooper/test.txt
+++ b/src/relooper/test.txt
@@ -4,23 +4,23 @@
-// block A
-switch (the_var) {
-check == 10 {
- atob();
- // block B
+ // block A
switch (the_var) {
+ check == 10 {
+ atob();
+ // block B
+ switch (the_var) {
+ default: {
+ btoc();
+ }
+ }
+ break;
+ }
default: {
- btoc();
+ atoc();
}
}
- break;
-}
-default: {
- atoc();
-}
-}
-// block C
+ // block C
@@ -28,25 +28,25 @@ default: {
-// block A
-switch (the_var) {
-check == 15 {
- // block B
+ // block A
switch (the_var) {
- default: {
- }
+ check == 15 {
+ // block B
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
-}
-default: {
- // block C
- switch (the_var) {
default: {
+ // block C
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
-}
-}
-// block D
+ // block D
@@ -54,81 +54,81 @@ default: {
-L9: while(1) {
- // block A
- var check = maybe();
- switch (the_var) {
- default: {
- }
- }
- // block B
- switch (the_var) {
- check == 41 {
- break;
- }
- default: {
- break L9;
- }
+ L0: while(1) {
+ // block A
+ var check = maybe();
+ switch (the_var) {
+ default: {
+ }
+ }
+ // block B
+ switch (the_var) {
+ check == 41 {
+ break;
+ }
+ default: {
+ break L0;
+ }
+ }
}
-}
-// block C
+ // block C
-- Loop with phi to head
-// code 1
-switch (the_var) {
-default: {
- var $i_0 = 0;var $x_0 = 5;
-}
-}
-L14: while(1) {
- // code 2
+ // code 1
switch (the_var) {
- $2 {
- break;
- }
default: {
- var $x_1 = $x_0;
- label = 18;
- break L14;
+ var $i_0 = 0;var $x_0 = 5;
+ }
+ }
+ L1: while(1) {
+ // code 2
+ switch (the_var) {
+ $2 {
+ break;
+ }
+ default: {
+ var $x_1 = $x_0;
+ label = -1;
+ break L1;
+ }
+ }
+ // code 3
+ switch (the_var) {
+ $6 {
+ break L1;
+ break;
+ }
+ default: {
+ var $i_0 = $7;var $x_0 = $5;
+ }
+ }
}
+ if (label == -1) {
+ // code 7
}
- // code 3
+ // code 4
switch (the_var) {
- $6 {
- break L14;
+ $10 {
+ // code 5
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- var $i_0 = $7;var $x_0 = $5;
}
}
-}
-if (label == 18) {
- // code 7
-}
-// code 4
-switch (the_var) {
-$10 {
- // code 5
+ // code 6
switch (the_var) {
default: {
+ var $x_1 = $13;
}
}
- break;
-}
-default: {
-}
-}
-// code 6
-switch (the_var) {
-default: {
- var $x_1 = $13;
-}
-}
-// code 7
+ // code 7
@@ -136,30 +136,30 @@ default: {
-// block A...................................................................................................
-switch (the_var) {
-chak() {
- atob();
- // block B...................................................................................................
+ // block A...................................................................................................
switch (the_var) {
- default: {
- btod();
- }
+ chak() {
+ atob();
+ // block B...................................................................................................
+ switch (the_var) {
+ default: {
+ btod();
+ }
+ }
+ // block D
+ break;
}
- // block D
- break;
-}
-default: {
- atoc();
- // block C...................................................................................................
- switch (the_var) {
default: {
- ctod2();
+ atoc();
+ // block C...................................................................................................
+ switch (the_var) {
+ default: {
+ ctod2();
+ }
+ }
+ // block D
}
}
- // block D
-}
-}
@@ -167,27 +167,27 @@ default: {
-// block A
-switch (the_var) {
-check == 10 {
- break;
-}
-default: {
- return C;
-}
-}
-while(1) {
- // block B
+ // block A
switch (the_var) {
- default: {
- }
+ check == 10 {
+ break;
}
- // block D
- switch (the_var) {
default: {
+ return C;
}
}
-}
+ while(1) {
+ // block B
+ switch (the_var) {
+ default: {
+ }
+ }
+ // block D
+ switch (the_var) {
+ default: {
+ }
+ }
+ }
@@ -195,51 +195,51 @@ while(1) {
-// block A
-L37: do {
- switch (the_var) {
- expensive() {
- label = 33;
- break;
- }
- default: {
- // block B
+ // block A
+ L1: do {
switch (the_var) {
- expensive2() {
- label = 33;
- break L37;
+ expensive() {
+ label = 3;
break;
}
default: {
+ // block B
+ switch (the_var) {
+ expensive2() {
+ label = 3;
+ break L1;
+ break;
+ }
+ default: {
+ }
+ }
+ // block D
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- // block D
+ } while(0);
+ if (label == 3) {
+ // block C;
switch (the_var) {
default: {
}
}
}
+ while(1) {
+ // block E
+ switch (the_var) {
+ default: {
+ }
+ }
+ // block F
+ switch (the_var) {
+ default: {
+ }
+ }
}
-} while(0);
-if (label == 33) {
- // block C;
- switch (the_var) {
- default: {
- }
- }
-}
-while(1) {
- // block E
- switch (the_var) {
- default: {
- }
- }
- // block F
- switch (the_var) {
- default: {
- }
- }
-}
@@ -247,26 +247,71 @@ while(1) {
-// block A
-L46: do {
- switch (the_var) {
- shouldLoop() {
- while(1) {
- // block B
- switch (the_var) {
- moarLoop() {
+ // block A
+ L1: do {
+ switch (the_var) {
+ shouldLoop() {
+ while(1) {
+ // block B
+ switch (the_var) {
+ moarLoop() {
+ break;
+ }
+ default: {
+ break L1;
+ }
+ }
+ }
+ break;
+ }
+ default: {
+ }
+ }
+ } while(0);
+ // block C
+
+
+
+-- If pattern, emulated --
+
+
+
+ label = 1;
+ L0: while(1) {
+ switch(label|0) {
+ case 3: {
+ // block C
break;
}
- default: {
- break L46;
+ case 1: {
+ // block A
+ if (check == 10) {
+ atob();
+ label = 2;
+ continue L0;
+ } else {
+ atoc();
+ label = 3;
+ continue L0;
+ }
+ break;
}
+ case 2: {
+ // block B
+ switch (b_check()) {
+ case 17: {
+ btoc();
+ label = 3;
+ continue L0;
+ break;
+ }
+ default: {
+ label = 1;
+ continue L0;
+ }
+ }
+ break;
}
}
- break;
- }
- default: {
- }
}
-} while(0);
-// block C
diff --git a/src/relooper/test2.txt b/src/relooper/test2.txt
index a558a8b7..aba9ec1f 100644
--- a/src/relooper/test2.txt
+++ b/src/relooper/test2.txt
@@ -1,26 +1,26 @@
-ep
-L1: do {
- switch (var) {
- ep -> LBB1 {
- LBB1
- switch (the_var) {
- LBB1 -> LBB2 {
+ ep
+ L1: do {
+ switch (var) {
+ ep -> LBB1 {
+ LBB1
+ switch (the_var) {
+ LBB1 -> LBB2 {
+ break;
+ }
+ default: {
+ break L1;
+ }
+ }
+ LBB2
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- break L1;
}
}
- LBB2
- switch (the_var) {
- default: {
- }
- }
- break;
- }
- default: {
- }
- }
-} while(0);
-LBB3
+ } while(0);
+ LBB3
diff --git a/src/relooper/test3.txt b/src/relooper/test3.txt
index f77e2618..33f85a7e 100644
--- a/src/relooper/test3.txt
+++ b/src/relooper/test3.txt
@@ -1,56 +1,56 @@
-ep
-L1: do {
- switch (the_var) {
- ep -> LBB1 {
- LBB1
+ ep
+ L1: do {
switch (the_var) {
- LBB1 -> LBB2 {
+ ep -> LBB1 {
+ LBB1
+ switch (the_var) {
+ LBB1 -> LBB2 {
+ break;
+ }
+ default: {
+ break L1;
+ }
+ }
+ LBB2
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- break L1;
- }
- }
- LBB2
- switch (the_var) {
- default: {
}
}
- break;
- }
- default: {
- }
- }
-} while(0);
-LBB3
-L5: do {
- switch (the_var) {
- LBB3 -> LBB4 {
- LBB4
+ } while(0);
+ LBB3
+ L5: do {
switch (the_var) {
- LBB4 -> LBB5 {
- break;
- }
- default: {
- break L5;
- }
- }
- while(1) {
- LBB5
+ LBB3 -> LBB4 {
+ LBB4
switch (the_var) {
- LBB5 -> LBB6 {
- break L5;
+ LBB4 -> LBB5 {
break;
}
default: {
+ break L5;
+ }
}
+ while(1) {
+ LBB5
+ switch (the_var) {
+ LBB5 -> LBB6 {
+ break L5;
+ break;
+ }
+ default: {
+ }
+ }
}
+ break;
+ }
+ default: {
+ }
}
- break;
- }
- default: {
- }
- }
-} while(0);
-LBB6
+ } while(0);
+ LBB6
diff --git a/src/relooper/test4.txt b/src/relooper/test4.txt
index 1829e523..7e3fe8e1 100644
--- a/src/relooper/test4.txt
+++ b/src/relooper/test4.txt
@@ -1,44 +1,44 @@
-//19
-L1: do {
- switch (the_var) {
- 1 {
- //20
+ //19
+ L1: do {
switch (the_var) {
1 {
+ //20
+ switch (the_var) {
+ 1 {
+ break;
+ }
+ default: {
+ label = 4;
+ break L1;
+ }
+ }
+ //21
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
label = 4;
- break L1;
}
}
- //21
+ } while(0);
+ if (label == 4) {
+ //22
switch (the_var) {
default: {
}
}
- break;
- }
- default: {
- label = 4;
}
- }
-} while(0);
-if (label == 4) {
- //22
+ //23
switch (the_var) {
+ 1 {
+ //24
+ break;
+ }
default: {
+ //28
}
}
-}
-//23
-switch (the_var) {
- 1 {
- //24
- break;
-}
-default: {
- //28
-}
-}
diff --git a/src/relooper/test5.txt b/src/relooper/test5.txt
index 82ef5edf..e3c204f6 100644
--- a/src/relooper/test5.txt
+++ b/src/relooper/test5.txt
@@ -1,56 +1,56 @@
-//0
-switch (the_var) {
-check(0) {
- L2: while(1) {
- //1
- switch (the_var) {
- check(1) {
- break;
- }
- default: {
- break L2;
- }
- }
+ //0
+ switch (the_var) {
+ check(0) {
+ L2: while(1) {
+ //1
+ switch (the_var) {
+ check(1) {
+ break;
+ }
+ default: {
+ break L2;
+ }
+ }
+ }
+ L4: while(1) {
+ //2
+ switch (the_var) {
+ check(2) {
+ break;
+ }
+ default: {
+ break L4;
+ }
+ }
+ }
+ //3
+ break;
}
- L4: while(1) {
- //2
- switch (the_var) {
- check(2) {
- break;
- }
- default: {
- break L4;
- }
- }
+ default: {
+ goingFrom0to4();
+ L7: while(1) {
+ //4
+ switch (the_var) {
+ check(4) {
+ break;
+ }
+ default: {
+ break L7;
+ }
+ }
+ }
+ L9: while(1) {
+ //5
+ switch (the_var) {
+ check(5) {
+ break L9;
+ break;
+ }
+ default: {
+ }
+ }
+ }
+ //3
}
- //3
- break;
-}
-default: {
- goingFrom0to4();
- L7: while(1) {
- //4
- switch (the_var) {
- check(4) {
- break;
- }
- default: {
- break L7;
- }
- }
- }
- L9: while(1) {
- //5
- switch (the_var) {
- check(5) {
- break L9;
- break;
- }
- default: {
- }
- }
}
- //3
-}
-}
diff --git a/src/relooper/test6.txt b/src/relooper/test6.txt
index f9d6e93a..837fc243 100644
--- a/src/relooper/test6.txt
+++ b/src/relooper/test6.txt
@@ -1,26 +1,26 @@
-//0
-L1: do {
- switch (the_var) {
- check(0) {
- //1
+ //0
+ L1: do {
switch (the_var) {
- check(1) {
+ check(0) {
+ //1
+ switch (the_var) {
+ check(1) {
+ break;
+ }
+ default: {
+ break L1;
+ }
+ }
+ //2
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- break L1;
}
}
- //2
- switch (the_var) {
- default: {
- }
- }
- break;
- }
- default: {
- }
- }
-} while(0);
-//3
+ } while(0);
+ //3
diff --git a/src/relooper/test_dead.txt b/src/relooper/test_dead.txt
index ae54e2cd..43d557ae 100644
--- a/src/relooper/test_dead.txt
+++ b/src/relooper/test_dead.txt
@@ -4,6 +4,6 @@
-// block A
+ // block A
I did not crash even though I have dead code with a branch!
diff --git a/src/relooper/test_debug.txt b/src/relooper/test_debug.txt
index eb33fdbc..498dee39 100644
--- a/src/relooper/test_debug.txt
+++ b/src/relooper/test_debug.txt
@@ -4,18 +4,18 @@ int main() {
rl_set_output_buffer(buffer);
void *block_map[10000];
void *rl = rl_new_relooper();
- void *b1 = rl_new_block("// code 1");
- block_map[1] = b1;
- rl_relooper_add_block(rl, block_map[1]);
- void *b2 = rl_new_block("// code 2");
- block_map[2] = b2;
- rl_relooper_add_block(rl, block_map[2]);
- void *b3 = rl_new_block("// code 3");
- block_map[3] = b3;
- rl_relooper_add_block(rl, block_map[3]);
- void *b4 = rl_new_block("// code 4");
- block_map[4] = b4;
- rl_relooper_add_block(rl, block_map[4]);
+ void *b-1 = rl_new_block("// code -1");
+ block_map[-1] = b-1;
+ rl_relooper_add_block(rl, block_map[-1]);
+ void *b-1 = rl_new_block("// code -1");
+ block_map[-1] = b-1;
+ rl_relooper_add_block(rl, block_map[-1]);
+ void *b-1 = rl_new_block("// code -1");
+ block_map[-1] = b-1;
+ rl_relooper_add_block(rl, block_map[-1]);
+ void *b-1 = rl_new_block("// code -1");
+ block_map[-1] = b-1;
+ rl_relooper_add_block(rl, block_map[-1]);
rl_block_add_branch_to(block_map[1], block_map[2], "ep -> LBB1", NULL);
rl_block_add_branch_to(block_map[1], block_map[4], NULL, NULL);
rl_block_add_branch_to(block_map[2], block_map[3], "LBB1 -> LBB2", NULL);
@@ -114,29 +114,29 @@ int main() {
// Process() returning
// === Optimizing shapes ===
// Fusing Multiple to Simple
-ep
-L1: do {
- switch (the_var) {
- ep -> LBB1 {
- LBB1
+ ep
+ L1: do {
switch (the_var) {
- LBB1 -> LBB2 {
+ ep -> LBB1 {
+ LBB1
+ switch (the_var) {
+ LBB1 -> LBB2 {
+ break;
+ }
+ default: {
+ break L1;
+ }
+ }
+ LBB2
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- break L1;
}
}
- LBB2
- switch (the_var) {
- default: {
- }
- }
- break;
- }
- default: {
- }
- }
-} while(0);
-LBB3
+ } while(0);
+ LBB3
diff --git a/src/relooper/test_fuzz1.txt b/src/relooper/test_fuzz1.txt
index d887f5b8..ccd38934 100644
--- a/src/relooper/test_fuzz1.txt
+++ b/src/relooper/test_fuzz1.txt
@@ -1,72 +1,72 @@
-print('entry'); var label; var state; var decisions = [4, 1, 7, 2, 6, 6, 8]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
-switch (the_var) {
-default: {
-}
-}
-print(5); state = check();
-switch (the_var) {
-default: {
-}
-}
-print(6); state = check();
-switch (the_var) {
-state == 7 {
- print(7); state = check();
+ print('entry'); var label; var state; var decisions = [4, 1, 7, 2, 6, 6, 8]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
switch (the_var) {
default: {
- label = 3;
}
}
- break;
-}
-default: {
-}
-}
-L5: while(1) {
- if (label == 3) {
- label = 0;
- print(2); state = check();
+ print(5); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(6); state = check();
+ switch (the_var) {
+ state == 7 {
+ print(7); state = check();
switch (the_var) {
default: {
+ label = 3;
}
}
+ break;
}
- print(1); state = check();
- switch (the_var) {
default: {
}
}
- while(1) {
- print(3); state = check();
- switch (the_var) {
- state == 8 {
- break;
+ L5: while(1) {
+ if (label == 3) {
+ label = 0;
+ print(2); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
}
- default: {
- continue L5;
- }
- }
- print(8); state = check();
+ print(1); state = check();
switch (the_var) {
- state == 4 {
- break;
- }
default: {
- label = 3;
- continue L5;
}
}
- print(4); state = check();
- switch (the_var) {
- state == 3 {
- break;
- }
- default: {
- continue L5;
- }
+ while(1) {
+ print(3); state = check();
+ switch (the_var) {
+ state == 8 {
+ break;
+ }
+ default: {
+ continue L5;
+ }
+ }
+ print(8); state = check();
+ switch (the_var) {
+ state == 4 {
+ break;
+ }
+ default: {
+ label = 3;
+ continue L5;
+ }
+ }
+ print(4); state = check();
+ switch (the_var) {
+ state == 3 {
+ break;
+ }
+ default: {
+ continue L5;
+ }
+ }
}
}
-}
diff --git a/src/relooper/test_fuzz2.txt b/src/relooper/test_fuzz2.txt
index 69f4350c..a94908a1 100644
--- a/src/relooper/test_fuzz2.txt
+++ b/src/relooper/test_fuzz2.txt
@@ -1,30 +1,30 @@
-print('entry'); var label; var state; var decisions = [4, 1, 4, 3, 4, 1, 2, 5, 1, 3, 5, 5, 1, 5, 2, 4, 4, 3]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
-switch (the_var) {
-state == 1 {
- while(1) {
- print(1); state = check();
- switch (the_var) {
- default: {
- }
+ print('entry'); var label; var state; var decisions = [4, 1, 4, 3, 4, 1, 2, 5, 1, 3, 5, 5, 1, 5, 2, 4, 4, 3]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
+ switch (the_var) {
+ state == 1 {
+ while(1) {
+ print(1); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
}
+ break;
}
- break;
-}
-default: {
-}
-}
-while(1) {
- print(3); state = check();
- switch (the_var) {
default: {
}
}
- print(2); state = check();
- switch (the_var) {
- default: {
- }
+ while(1) {
+ print(3); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(2); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
}
-}
diff --git a/src/relooper/test_fuzz3.txt b/src/relooper/test_fuzz3.txt
index 398b4803..15037eec 100644
--- a/src/relooper/test_fuzz3.txt
+++ b/src/relooper/test_fuzz3.txt
@@ -1,25 +1,25 @@
-print('entry'); var label; var state; var decisions = [3, 3, 4, 1, 2, 1, 2, 4, 4, 4, 2, 3, 3, 1, 2]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
-switch (the_var) {
-default: {
-}
-}
-print(1); state = check();
-switch (the_var) {
-default: {
-}
-}
-print(3); state = check();
-switch (the_var) {
-default: {
-}
-}
-while(1) {
- print(4); state = check();
+ print('entry'); var label; var state; var decisions = [3, 3, 4, 1, 2, 1, 2, 4, 4, 4, 2, 3, 3, 1, 2]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
switch (the_var) {
default: {
}
}
-}
+ print(1); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(3); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ while(1) {
+ print(4); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ }
diff --git a/src/relooper/test_fuzz4.txt b/src/relooper/test_fuzz4.txt
index 2e2f2c6f..adf879f9 100644
--- a/src/relooper/test_fuzz4.txt
+++ b/src/relooper/test_fuzz4.txt
@@ -1,41 +1,41 @@
-print('entry'); var label; var state; var decisions = [2, 2, 1, 3, 2, 2, 1, 3, 2, 3, 3, 1, 3, 2, 1]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
-switch (the_var) {
-state == 2 {
- while(1) {
- print(2); state = check();
- switch (the_var) {
- default: {
- }
- }
- }
- break;
-}
-default: {
-}
-}
-L4: while(1) {
- print(4); state = check();
+ print('entry'); var label; var state; var decisions = [2, 2, 1, 3, 2, 2, 1, 3, 2, 3, 3, 1, 3, 2, 1]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
switch (the_var) {
- state == 4 {
+ state == 2 {
+ while(1) {
+ print(2); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ }
break;
}
default: {
- break L4;
}
}
-}
-print(3); state = check();
-switch (the_var) {
-default: {
-}
-}
-while(1) {
- print(1); state = check();
+ L4: while(1) {
+ print(4); state = check();
+ switch (the_var) {
+ state == 4 {
+ break;
+ }
+ default: {
+ break L4;
+ }
+ }
+ }
+ print(3); state = check();
switch (the_var) {
default: {
}
}
-}
+ while(1) {
+ print(1); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ }
diff --git a/src/relooper/test_fuzz5.txt b/src/relooper/test_fuzz5.txt
index f87e5b79..fea540ed 100644
--- a/src/relooper/test_fuzz5.txt
+++ b/src/relooper/test_fuzz5.txt
@@ -1,86 +1,86 @@
-print('entry'); var label; var state; var decisions = [133, 98, 134, 143, 162, 187, 130, 87, 91, 49, 102, 47, 9, 132, 179, 176, 157, 25, 64, 161, 57, 107, 16, 167, 185, 45, 191, 180, 23, 131]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
-switch (the_var) {
-default: {
-}
-}
-L1: while(1) {
- print(7); state = check();
+ print('entry'); var label; var state; var decisions = [133, 98, 134, 143, 162, 187, 130, 87, 91, 49, 102, 47, 9, 132, 179, 176, 157, 25, 64, 161, 57, 107, 16, 167, 185, 45, 191, 180, 23, 131]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
switch (the_var) {
- state % 3 == 1 {
- label = 3;
- break;
+ default: {
+ }
}
- state % 3 == 0 {
- print(8); state = check();
+ L1: while(1) {
+ print(7); state = check();
switch (the_var) {
- state % 2 == 0 {
- label = 5;
+ state % 3 == 1 {
+ label = 3;
break;
}
- default: {
- label = 7;
- }
- }
- break;
- }
- default: {
- break L1;
- }
- }
- L5: while(1) {
- if (label == 3) {
- label = 0;
- print(2); state = check();
- switch (the_var) {
- default: {
- }
- }
- print(1); state = check();
+ state % 3 == 0 {
+ print(8); state = check();
switch (the_var) {
state % 2 == 0 {
label = 5;
- continue L5;
break;
}
default: {
label = 7;
- continue L5;
}
}
+ break;
}
- else if (label == 5) {
- label = 0;
- print(4); state = check();
- switch (the_var) {
- default: {
- label = 3;
- continue L5;
- }
- }
+ default: {
+ break L1;
}
- else if (label == 7) {
- label = 0;
- print(6); state = check();
- switch (the_var) {
- state % 2 == 0 {
- continue L1;
- break;
+ }
+ L5: while(1) {
+ if (label == 3) {
+ label = 0;
+ print(2); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(1); state = check();
+ switch (the_var) {
+ state % 2 == 0 {
+ label = 5;
+ continue L5;
+ break;
+ }
+ default: {
+ label = 7;
+ continue L5;
+ }
+ }
}
- default: {
- label = 7;
- continue L5;
+ else if (label == 5) {
+ label = 0;
+ print(4); state = check();
+ switch (the_var) {
+ default: {
+ label = 3;
+ continue L5;
+ }
+ }
}
+ else if (label == 7) {
+ label = 0;
+ print(6); state = check();
+ switch (the_var) {
+ state % 2 == 0 {
+ continue L1;
+ break;
+ }
+ default: {
+ label = 7;
+ continue L5;
+ }
+ }
}
}
}
-}
-while(1) {
- print(3); state = check();
- switch (the_var) {
- default: {
- }
+ while(1) {
+ print(3); state = check();
+ switch (the_var) {
+ default: {
+ }
+ }
}
-}
diff --git a/src/relooper/test_fuzz6.txt b/src/relooper/test_fuzz6.txt
index b9c1499a..40605dfc 100644
--- a/src/relooper/test_fuzz6.txt
+++ b/src/relooper/test_fuzz6.txt
@@ -1,291 +1,291 @@
-print('entry'); var label; var state; var decisions = [759, 1223, 618, 1805, 277, 512, 204, 1545, 606, 734, 585, 447, 1670, 1031, 665, 1728, 353, 634, 1033, 13, 658, 589, 474, 854, 405, 1111, 1640, 697, 1156, 1357, 317, 618, 990, 1401, 405, 564, 497, 829, 653, 1194, 25, 322, 1178, 198, 1565, 1419, 1608, 486, 368, 606, 813, 22, 148, 141, 261, 375, 472, 964, 1106, 694, 205, 771, 44, 675, 545, 1027, 1528, 240, 1289, 564, 792, 744, 366, 668, 823, 210, 428, 1009, 1662, 1317, 1183, 681, 14, 1334, 712, 506, 224, 695, 401, 1035, 384, 486, 1519, 122, 1186, 1487, 1819, 1702, 463, 1706, 660, 1642, 847, 991, 976, 940, 867, 46, 23, 1449, 56, 1711, 634, 404, 1558, 168, 710, 1581, 1302, 870, 997, 1295, 1739, 769, 1005, 291, 1638, 1771, 842, 659, 1695, 713, 935, 802, 1173, 1572, 850, 607, 996, 55, 1576, 321, 1815, 662, 1044, 1612, 1680, 1050, 844, 553, 278, 1447, 1662, 1094, 1797, 774, 1013, 1204, 907, 340, 1172, 1460, 869, 1264, 111, 1176, 484, 845, 258, 417, 1246, 1017, 745, 189, 333, 1658, 1395, 1764, 1786, 165, 404, 847, 1429, 1574, 403, 718, 1118, 1756, 94, 56, 1498, 1696, 1355, 840, 50, 82, 371, 1087, 875, 1337, 267, 958, 1209, 1167, 1025, 1684, 184, 962, 1496, 201, 127, 372, 1, 1005, 402, 1387, 213, 1143, 1271, 167, 10, 12, 1060, 1390, 1366, 893, 747, 1005, 481, 876, 227, 514, 589, 250, 273, 1188, 1052, 719, 219, 1006, 38, 120, 1454, 489, 672, 149, 534, 1081, 1721, 586, 330, 25, 356, 1743, 1607, 336, 981, 419, 1036, 1293, 1026, 1300, 1453, 792, 22, 45, 420, 409, 1027, 1437, 1421, 795, 136, 1276, 1610, 1593]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
-switch (the_var) {
-default: {
-}
-}
-L1: while(1) {
- print(30); state = check();// .................................................................................................................................................................................................................
- switch (the_var) {
- state % 3 == 0 {
- break;
- }
- state % 3 == 1 {
- label = 67;
- break L1;
- break;
- }
- default: {
- break L1;
- }
- }
- print(58); state = check();// ......................................................................................
- switch (the_var) {
- default: {
- }
- }
-}
-if (label == 67) {
- print(66); state = check();// ...............................................................................................................
+ print('entry'); var label; var state; var decisions = [759, 1223, 618, 1805, 277, 512, 204, 1545, 606, 734, 585, 447, 1670, 1031, 665, 1728, 353, 634, 1033, 13, 658, 589, 474, 854, 405, 1111, 1640, 697, 1156, 1357, 317, 618, 990, 1401, 405, 564, 497, 829, 653, 1194, 25, 322, 1178, 198, 1565, 1419, 1608, 486, 368, 606, 813, 22, 148, 141, 261, 375, 472, 964, 1106, 694, 205, 771, 44, 675, 545, 1027, 1528, 240, 1289, 564, 792, 744, 366, 668, 823, 210, 428, 1009, 1662, 1317, 1183, 681, 14, 1334, 712, 506, 224, 695, 401, 1035, 384, 486, 1519, 122, 1186, 1487, 1819, 1702, 463, 1706, 660, 1642, 847, 991, 976, 940, 867, 46, 23, 1449, 56, 1711, 634, 404, 1558, 168, 710, 1581, 1302, 870, 997, 1295, 1739, 769, 1005, 291, 1638, 1771, 842, 659, 1695, 713, 935, 802, 1173, 1572, 850, 607, 996, 55, 1576, 321, 1815, 662, 1044, 1612, 1680, 1050, 844, 553, 278, 1447, 1662, 1094, 1797, 774, 1013, 1204, 907, 340, 1172, 1460, 869, 1264, 111, 1176, 484, 845, 258, 417, 1246, 1017, 745, 189, 333, 1658, 1395, 1764, 1786, 165, 404, 847, 1429, 1574, 403, 718, 1118, 1756, 94, 56, 1498, 1696, 1355, 840, 50, 82, 371, 1087, 875, 1337, 267, 958, 1209, 1167, 1025, 1684, 184, 962, 1496, 201, 127, 372, 1, 1005, 402, 1387, 213, 1143, 1271, 167, 10, 12, 1060, 1390, 1366, 893, 747, 1005, 481, 876, 227, 514, 589, 250, 273, 1188, 1052, 719, 219, 1006, 38, 120, 1454, 489, 672, 149, 534, 1081, 1721, 586, 330, 25, 356, 1743, 1607, 336, 981, 419, 1036, 1293, 1026, 1300, 1453, 792, 22, 45, 420, 409, 1027, 1437, 1421, 795, 136, 1276, 1610, 1593]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
switch (the_var) {
default: {
}
}
-}
-print(6); state = check();// .........
-switch (the_var) {
-default: {
-}
-}
-while(1) {
- print(88); state = check();// ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
- switch (the_var) {
- default: {
+ L1: while(1) {
+ print(30); state = check();// .................................................................................................................................................................................................................
+ switch (the_var) {
+ state % 3 == 0 {
+ break;
+ }
+ state % 3 == 1 {
+ label = 67;
+ break L1;
+ break;
+ }
+ default: {
+ break L1;
+ }
+ }
+ print(58); state = check();// ......................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
}
+ if (label == 67) {
+ print(66); state = check();// ...............................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
}
- print(70); state = check();// ..........................................................................................................................
+ print(6); state = check();// .........
switch (the_var) {
default: {
}
}
- L10: while(1) {
- print(47); state = check();// ....................................................................................................................................
+ while(1) {
+ print(88); state = check();// ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
switch (the_var) {
default: {
}
}
- print(28); state = check();// ..............................................................................................................
+ print(70); state = check();// ..........................................................................................................................
switch (the_var) {
default: {
}
}
- L13: while(1) {
- print(75); state = check();// .............................................
+ L10: while(1) {
+ print(47); state = check();// ....................................................................................................................................
switch (the_var) {
default: {
}
}
- print(7); state = check();// .............................................................................................................................................................................................
+ print(28); state = check();// ..............................................................................................................
switch (the_var) {
- state % 2 == 0 {
- break;
- }
default: {
- break L13;
- }
}
- }
- print(89); state = check();// ......................................................................................................................................................................................................................................................................................................................................................
- switch (the_var) {
- default: {
- }
- }
- print(68); state = check();// ......................................................................................................................................................................................................................................................................................................................
- switch (the_var) {
- default: {
- }
- }
- L18: while(1) {
- print(51); state = check();// .............................................................................................
- switch (the_var) {
- default: {
}
- }
- L20: while(1) {
- print(36); state = check();// .........................
+ L13: while(1) {
+ print(75); state = check();// .............................................
switch (the_var) {
- state % 2 == 0 {
- break L20;
- break;
- }
default: {
}
}
- print(16); state = check();// ................................................................................................................................................................................................................................................................................................................................................................
+ print(7); state = check();// .............................................................................................................................................................................................
switch (the_var) {
- default: {
- }
+ state % 2 == 0 {
+ break;
}
- print(57); state = check();// ...........................................................................................................................................................................................................................................................................................................................
- switch (the_var) {
default: {
+ break L13;
}
}
- print(39); state = check();// ................
+ }
+ print(89); state = check();// ......................................................................................................................................................................................................................................................................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(68); state = check();// ......................................................................................................................................................................................................................................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ L18: while(1) {
+ print(51); state = check();// .............................................................................................
switch (the_var) {
- state % 3 == 0 {
- break;
- }
- state % 3 == 1 {
- label = 74;
- break;
- }
default: {
- label = 32;
- break L20;
}
}
- L25: while(1) {
- if (label == 74) {
- label = 0;
- print(73); state = check();// .
+ L20: while(1) {
+ print(36); state = check();// .........................
+ switch (the_var) {
+ state % 2 == 0 {
+ break L20;
+ break;
+ }
+ default: {
+ }
+ }
+ print(16); state = check();// ................................................................................................................................................................................................................................................................................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(57); state = check();// ...........................................................................................................................................................................................................................................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(39); state = check();// ................
+ switch (the_var) {
+ state % 3 == 0 {
+ break;
+ }
+ state % 3 == 1 {
+ label = 74;
+ break;
+ }
+ default: {
+ label = 32;
+ break L20;
+ }
+ }
+ L25: while(1) {
+ if (label == 74) {
+ label = 0;
+ print(73); state = check();// .
+ switch (the_var) {
+ state % 3 == 1 {
+ label = 32;
+ break L20;
+ break;
+ }
+ state % 3 == 0 {
+ break L25;
+ break;
+ }
+ default: {
+ }
+ }
+ print(43); state = check();// .........
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(32); state = check();// ......................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(83); state = check();// ........................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(77); state = check();// ...........................................................................................................................................................................................................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(76); state = check();// ..............................................................................................................................................................................................................................................................................................................................................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ print(22); state = check();// .........................................................................................................
+ switch (the_var) {
+ default: {
+ }
+ }
+ }
+ print(72); state = check();// ..........................................................................................................
switch (the_var) {
- state % 3 == 1 {
- label = 32;
+ state % 2 == 0 {
+ label = 92;
break L20;
break;
}
- state % 3 == 0 {
- break L25;
+ default: {
+ }
+ }
+ print(80); state = check();// ....................................
+ switch (the_var) {
+ state % 2 == 0 {
+ continue L18;
break;
}
default: {
}
}
- print(43); state = check();// .........
+ print(50); state = check();// ........................................
switch (the_var) {
default: {
}
}
- print(32); state = check();// ......................................................................................................
+ print(29); state = check();// ...............
switch (the_var) {
default: {
}
}
- print(83); state = check();// ........................................................................................
+ print(8); state = check();// ....................................................................................................................................................................................................................................................
switch (the_var) {
+ state % 2 == 0 {
+ continue L10;
+ break;
+ }
default: {
}
}
- print(77); state = check();// ...........................................................................................................................................................................................................................................................................................
+ print(19); state = check();// ......................................................................................................................................................................................................................
switch (the_var) {
default: {
}
}
- print(76); state = check();// ..............................................................................................................................................................................................................................................................................................................................................................................................................................
+ print(56); state = check();// ....................................................................................................................................................................................................................
switch (the_var) {
default: {
}
}
- print(22); state = check();// .........................................................................................................
+ print(34); state = check();// ..........................................................................................................................................
switch (the_var) {
default: {
+ label = 74;
}
}
}
- print(72); state = check();// ..........................................................................................................
- switch (the_var) {
- state % 2 == 0 {
- label = 92;
- break L20;
- break;
- }
- default: {
- }
- }
- print(80); state = check();// ....................................
- switch (the_var) {
- state % 2 == 0 {
- continue L18;
- break;
- }
- default: {
- }
- }
- print(50); state = check();// ........................................
- switch (the_var) {
- default: {
- }
- }
- print(29); state = check();// ...............
- switch (the_var) {
- default: {
- }
- }
- print(8); state = check();// ....................................................................................................................................................................................................................................................
+ print(62); state = check();// .......................................................................................
switch (the_var) {
- state % 2 == 0 {
- continue L10;
- break;
- }
default: {
}
}
- print(19); state = check();// ......................................................................................................................................................................................................................
+ }
+ if (label == 32) {
+ label = 0;
+ print(31); state = check();// ..........................................................................................................................................................................................................
switch (the_var) {
default: {
}
}
- print(56); state = check();// ....................................................................................................................................................................................................................
+ }
+ else if (label == 92) {
+ label = 0;
+ print(91); state = check();// ..............................................
switch (the_var) {
default: {
}
}
- print(34); state = check();// ..........................................................................................................................................
+ print(33); state = check();// ....
switch (the_var) {
default: {
- label = 74;
}
}
}
- print(62); state = check();// .......................................................................................
+ print(60); state = check();// ......................................................................................................................................................................................................................................
switch (the_var) {
default: {
}
}
- }
- if (label == 32) {
- label = 0;
- print(31); state = check();// ..........................................................................................................................................................................................................
+ print(10); state = check();// ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
switch (the_var) {
default: {
}
}
- }
- else if (label == 92) {
- label = 0;
- print(91); state = check();// ..............................................
+ print(52); state = check();// ..............................................................................
switch (the_var) {
+ state % 2 == 0 {
+ break L10;
+ break;
+ }
default: {
}
}
- print(33); state = check();// ....
+ print(2); state = check();// .........
switch (the_var) {
default: {
}
}
}
- print(60); state = check();// ......................................................................................................................................................................................................................................
- switch (the_var) {
- default: {
- }
- }
- print(10); state = check();// ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
- switch (the_var) {
- default: {
- }
- }
- print(52); state = check();// ..............................................................................
- switch (the_var) {
- state % 2 == 0 {
- break L10;
- break;
- }
- default: {
- }
- }
- print(2); state = check();// .........
- switch (the_var) {
- default: {
- }
- }
+ }
+ print(61); state = check();// .........................................................................................................................................................
+ switch (the_var) {
+ default: {
+ }
}
}
- print(61); state = check();// .........................................................................................................................................................
- switch (the_var) {
- default: {
- }
- }
-}
diff --git a/src/relooper/test_inf.txt b/src/relooper/test_inf.txt
index 6db32edb..2acadbfb 100644
--- a/src/relooper/test_inf.txt
+++ b/src/relooper/test_inf.txt
@@ -1,1072 +1,1039 @@
-code 0
-switch (the_var) {
-uint(i4) >= uint(i5) {
- code 2
+ code 0
switch (the_var) {
- default: {
- }
- }
- break;
-}
-default: {
- code 1
- switch (the_var) {
- default: {
- }
- }
-}
-}
-code 3
-L5: do {
- switch (the_var) {
- i2 == 0 {
+ uint(i4) >= uint(i5) {
+ code 2
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- code 4
+ code 1
switch (the_var) {
default: {
}
}
- while(1) {
- code 5
+ }
+ }
+ code 3
+ L5: do {
+ switch (the_var) {
+ i2 == 0 {
+ break;
+ }
+ default: {
+ code 4
switch (the_var) {
- uint(i6) >= uint(i7) {
- code 7
- switch (the_var) {
- default: {
- }
- }
- break;
- }
default: {
- code 6
- switch (the_var) {
- default: {
- }
- }
}
}
- code 8
- switch (the_var) {
- uint(i6) >= uint(i7) {
- code 10
+ while(1) {
+ code 5
switch (the_var) {
+ uint(i6) >= uint(i7) {
+ code 7
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 6
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 9
+ code 8
switch (the_var) {
+ uint(i6) >= uint(i7) {
+ code 10
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 9
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 11
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 13
+ code 11
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 13
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 12
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 12
+ code 14
switch (the_var) {
+ i2 != 0 {
+ break;
+ }
default: {
+ break L5;
}
}
}
- }
- code 14
- switch (the_var) {
- i2 != 0 {
- break;
- }
- default: {
- break L5;
- }
- }
}
- }
- }
-} while(0);
-code 15
-switch (the_var) {
-uint(i4) >= uint(i5) {
- code 17
- switch (the_var) {
- default: {
- }
- }
- break;
-}
-default: {
- code 16
- switch (the_var) {
- default: {
- }
- }
-}
-}
-code 18
-L26: do {
+ }
+ } while(0);
+ code 15
switch (the_var) {
- i2 == 0 {
+ uint(i4) >= uint(i5) {
+ code 17
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- code 19
+ code 16
switch (the_var) {
default: {
}
}
- while(1) {
- code 20
+ }
+ }
+ code 18
+ L26: do {
+ switch (the_var) {
+ i2 == 0 {
+ break;
+ }
+ default: {
+ code 19
switch (the_var) {
- uint(i5) >= uint(i6) {
- code 22
- switch (the_var) {
- default: {
- }
- }
- break;
- }
default: {
- code 21
- switch (the_var) {
- default: {
- }
- }
}
}
- code 23
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 25
+ while(1) {
+ code 20
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 22
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 24
- switch (the_var) {
default: {
+ code 21
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 26
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 28
+ code 23
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 25
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 27
- switch (the_var) {
default: {
+ code 24
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 29
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 31
+ code 26
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 28
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 30
- switch (the_var) {
default: {
+ code 27
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 32
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 34
+ code 29
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 31
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 33
- switch (the_var) {
default: {
+ code 30
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 35
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 37
+ code 32
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 34
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 36
- switch (the_var) {
default: {
+ code 33
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 38
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 40
+ code 35
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 37
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 39
- switch (the_var) {
default: {
+ code 36
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 41
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 43
+ code 38
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 40
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 42
- switch (the_var) {
default: {
+ code 39
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 44
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 46
+ code 41
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 43
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 45
- switch (the_var) {
default: {
+ code 42
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 47
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 49
+ code 44
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 46
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 48
- switch (the_var) {
default: {
+ code 45
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 50
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 52
+ code 47
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 49
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 51
- switch (the_var) {
default: {
+ code 48
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 53
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 55
+ code 50
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 52
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 54
- switch (the_var) {
default: {
+ code 51
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 56
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 58
+ code 53
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 55
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 57
- switch (the_var) {
default: {
+ code 54
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 59
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 61
+ code 56
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 58
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 60
- switch (the_var) {
default: {
+ code 57
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 62
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 64
+ code 59
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 61
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 63
- switch (the_var) {
default: {
+ code 60
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 65
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 67
+ code 62
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 64
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 66
- switch (the_var) {
default: {
+ code 63
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 68
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 70
+ code 65
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 67
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 69
- switch (the_var) {
default: {
+ code 66
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 71
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 73
+ code 68
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 70
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 72
- switch (the_var) {
default: {
+ code 69
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 74
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 76
+ code 71
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 73
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 75
- switch (the_var) {
default: {
+ code 72
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 77
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 79
+ code 74
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 76
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 78
- switch (the_var) {
default: {
+ code 75
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 80
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 82
+ code 77
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 79
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 81
- switch (the_var) {
default: {
+ code 78
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 83
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 85
+ code 80
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 82
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 84
- switch (the_var) {
default: {
+ code 81
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 86
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 88
+ code 83
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 85
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 87
- switch (the_var) {
default: {
+ code 84
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 89
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 91
+ code 86
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 88
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 90
- switch (the_var) {
default: {
+ code 87
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 92
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 94
+ code 89
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 91
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 93
- switch (the_var) {
default: {
+ code 90
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 95
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 97
+ code 92
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 94
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 93
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 96
+ code 95
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 97
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 96
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 98
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 100
+ code 98
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 100
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 99
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 99
+ code 101
switch (the_var) {
+ i2 != 0 {
+ break;
+ }
default: {
+ break L26;
}
}
}
- }
- code 101
- switch (the_var) {
- i2 != 0 {
- break;
- }
- default: {
- break L26;
- }
- }
}
- }
- }
-} while(0);
-code 102
-switch (the_var) {
-uint(i4) >= uint(i5) {
- code 104
- switch (the_var) {
- default: {
- }
- }
- break;
-}
-default: {
- code 103
- switch (the_var) {
- default: {
- }
- }
-}
-}
-code 105
-L143: do {
+ }
+ } while(0);
+ code 102
switch (the_var) {
- i2 == 0 {
+ uint(i4) >= uint(i5) {
+ code 104
+ switch (the_var) {
+ default: {
+ }
+ }
break;
}
default: {
- code 106
+ code 103
switch (the_var) {
default: {
}
}
- while(1) {
- code 107
+ }
+ }
+ code 105
+ L143: do {
+ switch (the_var) {
+ i2 == 0 {
+ break;
+ }
+ default: {
+ code 106
switch (the_var) {
- uint(i5) >= uint(i6) {
- code 109
- switch (the_var) {
- default: {
- }
- }
- break;
- }
default: {
- code 108
- switch (the_var) {
- default: {
- }
- }
}
}
- code 110
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 112
+ while(1) {
+ code 107
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 109
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 111
- switch (the_var) {
default: {
+ code 108
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 113
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 115
+ code 110
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 112
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 114
- switch (the_var) {
default: {
+ code 111
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 116
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 118
+ code 113
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 115
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 117
- switch (the_var) {
default: {
+ code 114
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 119
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 121
+ code 116
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 118
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 120
- switch (the_var) {
default: {
+ code 117
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 122
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 124
+ code 119
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 121
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 123
- switch (the_var) {
default: {
+ code 120
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 125
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 127
+ code 122
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 124
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 126
- switch (the_var) {
default: {
+ code 123
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 128
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 130
+ code 125
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 127
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 129
- switch (the_var) {
default: {
+ code 126
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 131
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 133
+ code 128
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 130
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 132
- switch (the_var) {
default: {
+ code 129
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 134
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 136
+ code 131
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 133
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 135
- switch (the_var) {
default: {
+ code 132
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 137
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 139
+ code 134
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 136
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 138
- switch (the_var) {
default: {
+ code 135
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 140
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 142
+ code 137
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 139
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 141
- switch (the_var) {
default: {
+ code 138
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 143
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 145
+ code 140
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 142
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 144
- switch (the_var) {
default: {
+ code 141
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 146
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 148
+ code 143
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 145
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 147
- switch (the_var) {
default: {
+ code 144
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 149
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 151
+ code 146
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 148
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 150
- switch (the_var) {
default: {
+ code 147
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 152
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 154
+ code 149
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 151
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 153
- switch (the_var) {
default: {
+ code 150
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 155
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 157
+ code 152
switch (the_var) {
- default: {
+ uint(i5) >= uint(i6) {
+ code 154
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- }
- break;
- }
- default: {
- code 156
- switch (the_var) {
default: {
+ code 153
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 158
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 160
+ code 155
switch (the_var) {
- default: {
- }
+ uint(i5) >= uint(i6) {
+ code 157
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
}
- break;
- }
- default: {
- code 159
- switch (the_var) {
default: {
+ code 156
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 161
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 163
+ code 158
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 160
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 159
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 162
+ code 161
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 163
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 162
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 164
- switch (the_var) {
- uint(i5) >= uint(i6) {
- code 166
+ code 164
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 166
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 165
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 165
+ code 167
switch (the_var) {
+ i2 != 0 {
+ break;
+ }
default: {
+ break L143;
}
}
}
- }
- code 167
- switch (the_var) {
- i2 != 0 {
- break;
- }
- default: {
- break L143;
- }
- }
}
- }
- }
-} while(0);
-code 168
-switch (the_var) {
-uint(i4) >= uint(i5) {
- code 170
- switch (the_var) {
- default: {
- }
- }
- break;
-}
-default: {
- code 169
- switch (the_var) {
- default: {
- }
- }
-}
-}
-code 171
-switch (the_var) {
-i2 == 0 {
- code 183
- break;
-}
-default: {
-}
-}
-code 172
-switch (the_var) {
-default: {
-}
-}
-L235: while(1) {
- code 173
+ }
+ } while(0);
+ code 168
switch (the_var) {
- uint(i5) >= uint(i6) {
- code 175
+ uint(i4) >= uint(i5) {
+ code 170
switch (the_var) {
default: {
}
@@ -1074,58 +1041,91 @@ L235: while(1) {
break;
}
default: {
- code 174
+ code 169
switch (the_var) {
default: {
}
}
}
}
- code 176
+ code 171
+ switch (the_var) {
+ i2 == 0 {
+ code 183
+ break;
+ }
+ default: {
+ }
+ }
+ code 172
switch (the_var) {
- uint(i5) >= uint(i6) {
- code 178
+ default: {
+ }
+ }
+ L235: while(1) {
+ code 173
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 175
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 174
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 177
+ code 176
switch (the_var) {
+ uint(i5) >= uint(i6) {
+ code 178
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 177
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- }
- }
- code 179
- switch (the_var) {
- uint(i4) >= uint(i5) {
- code 181
+ code 179
switch (the_var) {
+ uint(i4) >= uint(i5) {
+ code 181
+ switch (the_var) {
+ default: {
+ }
+ }
+ break;
+ }
default: {
+ code 180
+ switch (the_var) {
+ default: {
+ }
+ }
}
}
- break;
- }
- default: {
- code 180
+ code 182
switch (the_var) {
+ i2 != 0 {
+ break;
+ }
default: {
+ break L235;
}
}
}
- }
- code 182
- switch (the_var) {
- i2 != 0 {
- break;
- }
- default: {
- break L235;
- }
- }
-}
-code 183
+ code 183
diff --git a/src/relooper/testit.sh b/src/relooper/testit.sh
index 88db35fb..6e984b5a 100755
--- a/src/relooper/testit.sh
+++ b/src/relooper/testit.sh
@@ -2,61 +2,61 @@
echo "test"
./test &> test.out
-diff -U 5 test.txt test.out
+diff -w -U 5 test.txt test.out
echo "test 2"
./test2 &> test2.out
-diff -U 5 test2.txt test2.out
+diff -w -U 5 test2.txt test2.out
echo "test 3"
./test3 &> test3.out
-diff -U 5 test3.txt test3.out
+diff -w -U 5 test3.txt test3.out
echo "test debug"
./test_debug &> test_debug.out
-diff -U 5 test_debug.txt test_debug.out
+diff -w -U 5 test_debug.txt test_debug.out
echo "test dead"
./test_dead &> test_dead.out
-diff -U 5 test_dead.txt test_dead.out
+diff -w -U 5 test_dead.txt test_dead.out
echo "test 4"
./test4 &> test4.out
-diff -U 5 test4.txt test4.out
+diff -w -U 5 test4.txt test4.out
echo "test 5"
./test5 &> test5.out
-diff -U 5 test5.txt test5.out
+diff -w -U 5 test5.txt test5.out
echo "test 6"
./test6 &> test6.out
-diff -U 5 test6.txt test6.out
+diff -w -U 5 test6.txt test6.out
echo "test inf"
./test_inf &> test_inf.out
-diff -U 5 test_inf.txt test_inf.out
+diff -w -U 5 test_inf.txt test_inf.out
echo "test fuzz1"
./test_fuzz1 &> test_fuzz1.out
-diff -U 5 test_fuzz1.txt test_fuzz1.out
+diff -w -U 5 test_fuzz1.txt test_fuzz1.out
echo "test fuzz2"
./test_fuzz2 &> test_fuzz2.out
-diff -U 5 test_fuzz2.txt test_fuzz2.out
+diff -w -U 5 test_fuzz2.txt test_fuzz2.out
echo "test fuzz3"
./test_fuzz3 &> test_fuzz3.out
-diff -U 5 test_fuzz3.txt test_fuzz3.out
+diff -w -U 5 test_fuzz3.txt test_fuzz3.out
echo "test fuzz4"
./test_fuzz4 &> test_fuzz4.out
-diff -U 5 test_fuzz4.txt test_fuzz4.out
+diff -w -U 5 test_fuzz4.txt test_fuzz4.out
echo "test fuzz5"
./test_fuzz5 &> test_fuzz5.out
-diff -U 5 test_fuzz5.txt test_fuzz5.out
+diff -w -U 5 test_fuzz5.txt test_fuzz5.out
echo "test fuzz6"
./test_fuzz6 &> test_fuzz6.out
-diff -U 5 test_fuzz6.txt test_fuzz6.out
+diff -w -U 5 test_fuzz6.txt test_fuzz6.out
diff --git a/src/runtime.js b/src/runtime.js
index 8ba5d08d..cd3afb4b 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -250,7 +250,7 @@ var Runtime = {
prev = curr;
return curr;
});
- if (type.name_[0] === '[') {
+ if (type.name_ && type.name_[0] === '[') {
// arrays have 2 elements, so we get the proper difference. then we scale here. that way we avoid
// allocating a potentially huge array for [999999 x i8] etc.
type.flatSize = parseInt(type.name_.substr(1))*type.flatSize/2;
diff --git a/src/simd.js b/src/simd.js
index c7f5ff48..6e3e3675 100644
--- a/src/simd.js
+++ b/src/simd.js
@@ -848,8 +848,11 @@ var SIMD = (function () {
* @return {float32x4} a bit-wise copy of t as a float32x4.
*/
bitsToFloat32x4: function(t) {
- var alias = new Float32Array(t.storage_.buffer);
- return new float32x4(alias[0], alias[1], alias[2], alias[3]);
+ var temp_storage = new Int32Array([t.storage_[0], t.storage_[1], t.storage_[2], t.storage_[3]]);
+ var alias = new Float32Array(temp_storage.buffer);
+ var fx4 = float32x4.zero();
+ fx4.storage_ = alias;
+ return fx4;
},
/**
* @param {int32x4} t An instance of int32x4.
diff --git a/src/utility.js b/src/utility.js
index cd27b209..178c596b 100644
--- a/src/utility.js
+++ b/src/utility.js
@@ -346,13 +346,19 @@ function sortedJsonCompare(x, y) {
return true;
}
+function escapeJSONKey(x) {
+ if (/^[\d\w_]+$/.exec(x) || x[0] === '"' || x[0] === "'") return x;
+ assert(x.indexOf("'") < 0, 'cannot have internal single quotes in keys: ' + x);
+ return "'" + x + "'";
+}
+
function stringifyWithFunctions(obj) {
if (typeof obj === 'function') return obj.toString();
if (obj === null || typeof obj !== 'object') return JSON.stringify(obj);
if (isArray(obj)) {
return '[' + obj.map(stringifyWithFunctions).join(',') + ']';
} else {
- return '{' + keys(obj).map(function(key) { return key + ':' + stringifyWithFunctions(obj[key]) }).join(',') + '}';
+ return '{' + keys(obj).map(function(key) { return escapeJSONKey(key) + ':' + stringifyWithFunctions(obj[key]) }).join(',') + '}';
}
}
diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h
index ddcbc43a..b6e6307b 100644
--- a/system/include/emscripten/emscripten.h
+++ b/system/include/emscripten/emscripten.h
@@ -447,6 +447,70 @@ void emscripten_asm_const(const char *code);
int emscripten_asm_const_int(const char *code, ...);
double emscripten_asm_const_double(const char *code, ...);
+/* If specified, logs directly to the browser console/inspector
+ * window. If not specified, logs via the application Module. */
+#define EM_LOG_CONSOLE 1
+/* If specified, prints a warning message. */
+#define EM_LOG_WARN 2
+/* If specified, prints an error message. If neither EM_LOG_WARN
+ * or EM_LOG_ERROR is specified, an info message is printed.
+ * EM_LOG_WARN and EM_LOG_ERROR are mutually exclusive. */
+#define EM_LOG_ERROR 4
+/* If specified, prints a callstack that contains filenames referring
+ * to original C sources using source map information. */
+#define EM_LOG_C_STACK 8
+/* If specified, prints a callstack that contains filenames referring
+ * to lines to the built .js/.html file along with the message. The
+ * flags EM_LOG_C_STACK and EM_LOG_JS_STACK can be combined to output
+ * both untranslated and translated file+line information. */
+#define EM_LOG_JS_STACK 16
+/* If specified, C/C++ function names are demangled before printing.
+ * Otherwise, the mangled post-compilation JS function names are
+ * displayed. */
+#define EM_LOG_DEMANGLE 32
+/* If specified, the pathnames of the file information in the call
+ * stack will be omitted. */
+#define EM_LOG_NO_PATHS 64
+/* If specified, prints out the actual values of the parameters the
+ * functions were invoked with. */
+#define EM_LOG_FUNC_PARAMS 128
+
+/*
+ * Prints out a message to the console, optionally with the
+ * callstack information.
+ * @param flags A binary OR of items from the list of EM_LOG_xxx
+ * flags that specify printing options.
+ * @param '...' A printf-style "format, ..." parameter list that
+ * is parsed according to the printf formatting rules.
+ */
+void emscripten_log(int flags, ...);
+
+/*
+ * Programmatically obtains the current callstack.
+ * @param flags A binary OR of items from the list of EM_LOG_xxx
+ * flags that specify printing options. The
+ * items EM_LOG_CONSOLE, EM_LOG_WARN and
+ * EM_LOG_ERROR do not apply in this function and
+ * are ignored.
+ * @param out A pointer to a memory region where the callstack
+ * string will be written to. The string outputted
+ * by this function will always be null-terminated.
+ * @param maxbytes The maximum number of bytes that this function can
+ * write to the memory pointed to by 'out'. If
+ * there is no enough space, the output will be
+ * truncated (but always null-terminated).
+ * @return Returns the number of bytes written. (not number of
+ * characters, so this will also include the terminating zero)
+
+ * To query the amount of bytes needed for a callstack without writing
+ * it, pass 0 to 'out' and 'maxbytes', in which case the function will
+ * return the number of bytes (including the terminating zero) that
+ * will be needed to hold the full callstack. Note that this might be
+ * fully accurate since subsequent calls will carry different line
+ * numbers, so it is best to allocate a few bytes extra to be safe.
+ */
+int emscripten_get_callstack(int flags, char *out, int maxbytes);
+
#ifdef __cplusplus
}
#endif
diff --git a/tests/aniso.c b/tests/aniso.c
index f1674cad..443e50aa 100644
--- a/tests/aniso.c
+++ b/tests/aniso.c
@@ -151,6 +151,11 @@ int main(int argc, char *argv[])
assert(!glGetError());
glBindFramebuffer(GL_RENDERBUFFER, 0);
assert(glGetError());
+
+ GLint out = 321;
+ assert(!glGetError());
+ glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &out); // invalid, just test output
+ assert(out == 0);
}
// Prepare and Render
diff --git a/tests/cases/514_ta2.ll b/tests/cases/514_ta2.ll
index ae60191c..ab363242 100644
--- a/tests/cases/514_ta2.ll
+++ b/tests/cases/514_ta2.ll
@@ -1,6 +1,6 @@
; ModuleID = '/tmp/tmpxFUbAg/test_emcc1.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
%struct.c_s = type { i8, float, i32 }
diff --git a/tests/cases/aliasbitcast.ll b/tests/cases/aliasbitcast.ll
index 70dc64ef..5e5f13aa 100644
--- a/tests/cases/aliasbitcast.ll
+++ b/tests/cases/aliasbitcast.ll
@@ -1,15 +1,15 @@
; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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 constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
-@_ZN16FormWidgetChoiceD2Ev = alias bitcast (i32 678 to i8*) ; [#uses=1]
+@_ZN16FormWidgetChoiceD2Ev = alias i8* inttoptr (i32 678 to i8*) ; [#uses=1]
; [#uses=2]
-define void @"\01_Z5hellov"() {
+define void @"_Z5hellov"() {
entry:
- %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %0 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
br label %return
return: ; preds = %entry
@@ -25,7 +25,7 @@ entry:
%retval = alloca i32 ; [#uses=2]
%0 = alloca i32 ; [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
- call void @"\01_Z5hellov"()
+ call void @"_Z5hellov"()
store i32 0, i32* %0, align 4
%1 = load i32* %0, align 4 ; [#uses=1]
store i32 %1, i32* %retval, align 4
diff --git a/tests/cases/atomicrmw.ll b/tests/cases/atomicrmw.ll
index fe479dce..31529250 100644
--- a/tests/cases/atomicrmw.ll
+++ b/tests/cases/atomicrmw.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"hello, %d,%d!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@@ -10,10 +10,10 @@ entry:
%t = alloca i32, align 4 ; [#uses=2 type=i32**]
store i32 50, i32* %t, align 4
%0 = load i32* %t
- %1 = atomicrmw add i32* %t, i32 3 seq_cst, ; [#uses=0 type=i32] [debug line = 21:12]
+ %1 = atomicrmw add i32* %t, i32 3 seq_cst ; [#uses=0 type=i32] [debug line = 21:12]
%2 = load i32* %t
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %0, i32 %2) ; [#uses=0 type=i32]
- %3 = atomicrmw volatile add i32* %t, i32 3 seq_cst, ; [#uses=0 type=i32] [debug line = 21:12]
+ %3 = atomicrmw volatile add i32* %t, i32 3 seq_cst ; [#uses=0 type=i32] [debug line = 21:12]
ret i32 1
}
diff --git a/tests/cases/atomicrmw_unaligned.ll b/tests/cases/atomicrmw_unaligned.ll
index fe479dce..31529250 100644
--- a/tests/cases/atomicrmw_unaligned.ll
+++ b/tests/cases/atomicrmw_unaligned.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"hello, %d,%d!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@@ -10,10 +10,10 @@ entry:
%t = alloca i32, align 4 ; [#uses=2 type=i32**]
store i32 50, i32* %t, align 4
%0 = load i32* %t
- %1 = atomicrmw add i32* %t, i32 3 seq_cst, ; [#uses=0 type=i32] [debug line = 21:12]
+ %1 = atomicrmw add i32* %t, i32 3 seq_cst ; [#uses=0 type=i32] [debug line = 21:12]
%2 = load i32* %t
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %0, i32 %2) ; [#uses=0 type=i32]
- %3 = atomicrmw volatile add i32* %t, i32 3 seq_cst, ; [#uses=0 type=i32] [debug line = 21:12]
+ %3 = atomicrmw volatile add i32* %t, i32 3 seq_cst ; [#uses=0 type=i32] [debug line = 21:12]
ret i32 1
}
diff --git a/tests/cases/breakinthemiddle.ll b/tests/cases/breakinthemiddle.ll
index 769b0e11..6e05b853 100644
--- a/tests/cases/breakinthemiddle.ll
+++ b/tests/cases/breakinthemiddle.ll
@@ -1,8 +1,11 @@
+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 constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
-define linkonce_odr i32* @main() align 2 {
- %199 = trunc i8 1 to i1 ; [#uses=1]
- br i1 %199, label %label555, label %label569
+define linkonce_odr i32 @main() align 2 {
+ %1 = trunc i8 1 to i1 ; [#uses=1]
+ br i1 %1, label %label555, label %label569
label555: ; preds = %353
br label %label569
@@ -10,7 +13,7 @@ label555: ; preds = %353
br label %label569
label569: ; preds = %555
- %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %3 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
ret i32 0
}
diff --git a/tests/cases/breakinthemiddle2.ll b/tests/cases/breakinthemiddle2.ll
index 318b49dc..ba96654f 100644
--- a/tests/cases/breakinthemiddle2.ll
+++ b/tests/cases/breakinthemiddle2.ll
@@ -1,21 +1,24 @@
+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 constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
define linkonce_odr i32 @main() align 2 {
- %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- %199 = trunc i8 1 to i1 ; [#uses=1]
- br i1 %199, label %label555, label %label569
+ %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %b199 = trunc i8 1 to i1 ; [#uses=1]
+ br i1 %b199, label %label555, label %label569
label555: ; preds = %0
br label %label569 ; branch should ignore all code after it in the block
; No predecessors!
- %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ %aa472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
cleanup
- %a473 = extractvalue { i8*, i32 } %a472, 0
- %a474 = extractvalue { i8*, i32 } %a472, 1
+ %aa473 = extractvalue { i8*, i32 } %aa472, 0
+ %aa474 = extractvalue { i8*, i32 } %aa472, 1
br label %label569
label569: ; preds = %0
- br i1 %199, label %label990, label %label999
+ br i1 %b199, label %label990, label %label999
label990:
ret i32 0 ; ret should ignore all code after it in the block
diff --git a/tests/cases/breakinthemiddle3.ll b/tests/cases/breakinthemiddle3.ll
index e9173965..38da15ef 100644
--- a/tests/cases/breakinthemiddle3.ll
+++ b/tests/cases/breakinthemiddle3.ll
@@ -1,9 +1,12 @@
+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 constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
define linkonce_odr i32 @main() align 2 {
- %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- %199 = trunc i8 1 to i1 ; [#uses=1]
- switch i32 %333, label %label999 [
+ %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %z199 = trunc i8 1 to i1 ; [#uses=1]
+ switch i32 %a333, label %label999 [
i32 1000, label %label995
] ; switch should ignore all code after it in the block
; No predecessors!
@@ -14,7 +17,7 @@ define linkonce_odr i32 @main() align 2 {
br label %label999
label995:
- %333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %b333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
br label %label999
label999: ; preds = %555
diff --git a/tests/cases/caall.ll b/tests/cases/caall.ll
index 5b8f7f29..2cc231ec 100644
--- a/tests/cases/caall.ll
+++ b/tests/cases/caall.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@@ -11,14 +11,14 @@ entry:
store i32 0, i32* %retval
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
%call12 = call void (i32*)** @_ZNSt3__13mapINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPFvP6ObjectENS_4lessIS6_EENS4_INS_4pairIKS6_SA_EEEEEixERSE_(i32 10)
- %26 = load void (%class.Object*)** %call12
+ %l26 = load void (i32*)** %call12
ret i32 1
}
-define (i32*)** @_ZNSt3__13mapINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPFvP6ObjectENS_4lessIS6_EENS4_INS_4pairIKS6_SA_EEEEEixERSE_(i32 %x) {
+define void (i32*)** @_ZNSt3__13mapINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEPFvP6ObjectENS_4lessIS6_EENS4_INS_4pairIKS6_SA_EEEEEixERSE_(i32 %x) {
entry:
- %ret = inttoptr i32 0 to (i32*)**
- ret (i32*)** %ret
+ %ret = inttoptr i32 0 to void (i32*)**
+ ret void (i32*)** %ret
}
; [#uses=1]
diff --git a/tests/cases/complexphi.ll b/tests/cases/complexphi.ll
index fcb7185f..e79e6f1b 100644
--- a/tests/cases/complexphi.ll
+++ b/tests/cases/complexphi.ll
@@ -1,6 +1,6 @@
; ModuleID = '/dev/shm/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@_dispatchTable = internal global i64 0
@@ -21,8 +21,6 @@ cond.end: ; preds = %cond.false, %cond.t
%cond = phi { i32, i32 } [ { i32 5, i32 6 }, %entry ], [ zeroinitializer, %cond.null ] ; [#uses=1]
store { i32, i32 } %cond, { i32, i32 }* %comp
- store { i32, i32 } { i32 ptrtoint (i64* @_dispatchTable to i32), i32 0 }, { i32, i32 }* getelementptr inbounds ([1 x i64]* @_dispatchTable, i32 0, i32 0, i32 1), align 4
-
ret i32 0 ; [debug line = 6:13]
}
diff --git a/tests/cases/dash.ll b/tests/cases/dash.ll
index ed5b01ae..6833a42e 100644
--- a/tests/cases/dash.ll
+++ b/tests/cases/dash.ll
@@ -1,6 +1,6 @@
; ModuleID = '/tmp/tmpqfApGD/a.out.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
@other-name = alias i32 ()* @main
@@ -10,9 +10,9 @@ define i32 @main() {
entry:
%ret-val = alloca i32, align 4
store i32 0, i32* %ret-val
- %aaa = bitcast i32 ()* @other-name to i32
+ %aaa = ptrtoint i32 ()* @other-name to i32
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.st-r, i32 0, i32 0), i32 %aaa)
- ret i32 %ret-val
+ ret i32 0
}
declare i32 @printf(i8*, ...)
diff --git a/tests/cases/emptyalloca.ll b/tests/cases/emptyalloca.ll
new file mode 100644
index 00000000..f12a4161
--- /dev/null
+++ b/tests/cases/emptyalloca.ll
@@ -0,0 +1,31 @@
+; ModuleID = '/tmp/tmpjSNiky/a.out.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 [30 x i8] c"Module.print('hello, world!')\00", align 1
+
+; Function Attrs: nounwind
+define internal void @_Z9doNothingPi(i32* %arr) #0 {
+ %1 = alloca i32*, align 4
+ store i32* %arr, i32** %1, align 4
+ ret void
+}
+
+define i32 @main() #1 {
+ %arr = alloca [0 x i32], align 4
+ %1 = bitcast [0 x i32]* %arr to i8*
+ call void @llvm.memset.p0i8.i32(i8* %1, i8 0, i32 0, i32 4, i1 false)
+ %2 = getelementptr inbounds [0 x i32]* %arr, i32 0, i32 0
+ call void @_Z9doNothingPi(i32* %2)
+ call void @emscripten_asm_const(i8* getelementptr inbounds ([30 x i8]* @.str, i32 0, i32 0))
+ ret i32 0
+}
+
+; Function Attrs: nounwind
+declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) #2
+
+declare void @emscripten_asm_const(i8*) #1
+
+attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #2 = { nounwind }
diff --git a/tests/cases/emptyasm_le32.ll b/tests/cases/emptyasm_le32.ll
index e123d3d5..8f6b606e 100644
--- a/tests/cases/emptyasm_le32.ll
+++ b/tests/cases/emptyasm_le32.ll
@@ -1,3 +1,6 @@
+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"
+
; ModuleID = 'tests/hello_world.bc'
@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@@ -7,7 +10,7 @@ define i32 @main() {
entry:
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
store i32 0, i32* %retval
- call void asm sideeffect "", "~{memory}"() nounwind, !srcloc !0
+ call void asm sideeffect "", "~{memory}"() nounwind
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
ret i32 1
}
diff --git a/tests/cases/entry3.ll b/tests/cases/entry3.ll
index a20c6843..6888d0a8 100644
--- a/tests/cases/entry3.ll
+++ b/tests/cases/entry3.ll
@@ -1,25 +1,25 @@
; ModuleID = '/tmp/tmpKnA2D3/a.out.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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 [11 x i8] c"getgid=%d\0A\00", align 1
@.str1 = private unnamed_addr constant [6 x i8] c"f=%d\0A\00", align 1
define internal i32 @_Z1fii(i32, i32) noinline {
entry:
- %3 = tail call i32 @getgid()
- %4 = icmp eq i32 %3, 0
- br i1 %4, label %cond.b, label %cond.a
+ %a3 = tail call i32 @getgid()
+ %a4 = icmp eq i32 %a3, 0
+ br i1 %a4, label %cond.b, label %cond.a
cond.a:
- %6 = tail call i32 @getgid()
+ %a6 = tail call i32 @getgid()
br label %cond.end
cond.b:
br label %cond.end
cond.end:
- %.0 = phi i32 [ 0, %cond.b ], [ 1, %1 ]
+ %.0 = phi i32 [ 0, %cond.b ], [ 1, %cond.a ]
ret i32 %.0
}
diff --git a/tests/cases/funcptr.ll b/tests/cases/funcptr.ll
index 0aa03fcf..ef869c33 100644
--- a/tests/cases/funcptr.ll
+++ b/tests/cases/funcptr.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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 [17 x i8] c"hello %d world!\0A\00", align 1 ; [#uses=1 type=[17 x i8]*]
@@ -9,7 +9,7 @@ define i32 @main() {
entry:
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
store i32 0, i32* %retval
- %access_virt_barray = bitcast i32 100 to [64 x i16]* (i32*, i32)**
+ %access_virt_barray = inttoptr i32 100 to [64 x i16]* (i32*, i32)**
store [64 x i16]* (i32*, i32)* @access_virt_barray, [64 x i16]* (i32*, i32)** %access_virt_barray, align 4
%wakaptr = bitcast [64 x i16]* (i32*, i32)** %access_virt_barray to i32*
%waka = load i32* %wakaptr
@@ -20,7 +20,7 @@ entry:
}
define [64 x i16]* @access_virt_barray(i32*, i32) {
- ret void
+ ret [64 x i16]* inttoptr (i32 0 to [64 x i16]*)
}
; [#uses=1]
diff --git a/tests/cases/i24_mem_ta2.ll b/tests/cases/i24_mem_ta2.ll
index e50014ca..550389fe 100644
--- a/tests/cases/i24_mem_ta2.ll
+++ b/tests/cases/i24_mem_ta2.ll
@@ -1,8 +1,8 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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".%x.\0A\00", align 1 ; [#uses=1 type=[5 x i8]*]
+@.str = private unnamed_addr constant [6 x i8] c".%x.\0A\00", align 1 ; [#uses=1 type=[5 x i8]*]
define i32 @main() {
entry:
@@ -11,11 +11,11 @@ entry:
%i24 = bitcast i32* %mem to i24*
%load = load i24* %i24, align 4
%load32 = zext i24 %load to i32
- %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %load32)
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i32 %load32)
%val_24 = trunc i32 4041265344 to i24
store i24 %val_24, i24* %i24, align 4
%load32b = load i32* %mem, align 4
- %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %load32b)
+ %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i32 %load32b)
ret i32 1
}
diff --git a/tests/cases/i64toi8star.ll b/tests/cases/i64toi8star.ll
index d4a39340..b2307449 100644
--- a/tests/cases/i64toi8star.ll
+++ b/tests/cases/i64toi8star.ll
@@ -25,8 +25,8 @@ entry:
%retval = alloca i32 ; [#uses=2]
%0 = alloca i32 ; [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
- %5 = call i32 @PyLong_FromVoidPtr(i8* null) nounwind ; [#uses=0]
- %13 = call i32 @PyLong_FromVoidPtr(i8* inttoptr (i64 1 to i8*)) nounwind ; [#uses=0]
- %1 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %a5 = call i32 @PyLong_FromVoidPtr(i8* null) nounwind ; [#uses=0]
+ %a13 = call i32 @PyLong_FromVoidPtr(i8* inttoptr (i64 1 to i8*)) nounwind ; [#uses=0]
+ %a1 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
ret i32 0
}
diff --git a/tests/cases/inttoptr.ll b/tests/cases/inttoptr.ll
index b0711672..c1b40a74 100644
--- a/tests/cases/inttoptr.ll
+++ b/tests/cases/inttoptr.ll
@@ -1,6 +1,6 @@
; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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 constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
@@ -14,7 +14,7 @@ entry:
%0 = alloca i32 ; [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%sz.i7 = inttoptr i32 64 to i32* ; [#uses=1 type=i32*]
- store i32 184, i32* %sz.i7, align 8, !tbaa !1610
- %1 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ store i32 184, i32* %sz.i7, align 8
+ %1 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
ret i32 0
}
diff --git a/tests/cases/invokebitcast.ll b/tests/cases/invokebitcast.ll
index ffb5803f..ec090b0d 100644
--- a/tests/cases/invokebitcast.ll
+++ b/tests/cases/invokebitcast.ll
@@ -1,7 +1,7 @@
; ModuleID = '/dev/shm/tmp/src.cpp.o'
; Just test for compilation here
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-f128:128:128-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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"
%struct.CPU_Regs = type { [8 x %union.GenReg32] }
%union.GenReg32 = type { [1 x i32] }
@@ -16,7 +16,8 @@ entry:
%0 = alloca i32 ; [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%1 = load i32* bitcast (i32* getelementptr inbounds (%struct.CPU_Regs* @cpu_regs, i32 0, i32 0, i32 1, i32 0, i32 0) to i32*), align 2 ; [#uses=1]
- store i16 %1, i16* bitcast (%struct.CPU_Regs* @cpu_regs to i16*), align 2
+ %s = trunc i32 %1 to i16
+ store i16 %s, i16* bitcast (%struct.CPU_Regs* @cpu_regs to i16*), align 2
%2 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
store i32 0, i32* %0, align 4
%3 = load i32* %0, align 4 ; [#uses=1]
diff --git a/tests/cases/invokeundef.ll b/tests/cases/invokeundef.ll
index 9dc1f93d..be1dd671 100644
--- a/tests/cases/invokeundef.ll
+++ b/tests/cases/invokeundef.ll
@@ -1,7 +1,7 @@
; ModuleID = '/dev/shm/tmp/src.cpp.o'
; Just test for compilation here
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-f128:128:128-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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"
%struct.CPU_Regs = type { [8 x %union.GenReg32] }
%union.GenReg32 = type { [1 x i32] }
@@ -16,14 +16,15 @@ entry:
%0 = alloca i32 ; [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%1 = load i32* bitcast (i32* getelementptr inbounds (%struct.CPU_Regs* @cpu_regs, i32 0, i32 0, i32 1, i32 0, i32 0) to i32*), align 2 ; [#uses=1]
- store i16 %1, i16* bitcast (%struct.CPU_Regs* @cpu_regs to i16*), align 2
+ %a1 = trunc i32 %1 to i16
+ store i16 %a1, i16* bitcast (%struct.CPU_Regs* @cpu_regs to i16*), align 2
%2 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
store i32 0, i32* %0, align 4
%3 = load i32* %0, align 4 ; [#uses=1]
store i32 %3, i32* %retval, align 4
br label %return
- invoke void undef(%struct.CPU_Regs* noalias @cpu_regs, i32 %99)
+ invoke void undef(%struct.CPU_Regs* noalias @cpu_regs, i32 0)
to label %invcont33 unwind label %lpad106
invcont33:
diff --git a/tests/cases/legalizer_ta2.ll b/tests/cases/legalizer_ta2.ll
index 89ebcef6..6f153ad2 100644
--- a/tests/cases/legalizer_ta2.ll
+++ b/tests/cases/legalizer_ta2.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
@globaliz = global [300 x i8] zeroinitializer
diff --git a/tests/cases/loadbitcastgep.ll b/tests/cases/loadbitcastgep.ll
index 2a90dbb7..cfb88a0d 100644
--- a/tests/cases/loadbitcastgep.ll
+++ b/tests/cases/loadbitcastgep.ll
@@ -1,6 +1,6 @@
; ModuleID = '/dev/shm/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-f128:128:128-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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"
%struct.CPU_Regs = type { [8 x %union.GenReg32] }
%union.GenReg32 = type { [1 x i32] }
@@ -15,7 +15,8 @@ entry:
%0 = alloca i32 ; [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%1 = load i32* bitcast (i32* getelementptr inbounds (%struct.CPU_Regs* @cpu_regs, i32 0, i32 0, i32 1, i32 0, i32 0) to i32*), align 2 ; [#uses=1]
- store i16 %1, i16* bitcast (%struct.CPU_Regs* @cpu_regs to i16*), align 2
+ %b = trunc i32 %1 to i16
+ store i16 %b, i16* bitcast (%struct.CPU_Regs* @cpu_regs to i16*), align 2
%2 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
store i32 0, i32* %0, align 4
%3 = load i32* %0, align 4 ; [#uses=1]
diff --git a/tests/cases/longjmp_tiny_invoke_phi.ll b/tests/cases/longjmp_tiny_invoke_phi.ll
new file mode 100644
index 00000000..30c43339
--- /dev/null
+++ b/tests/cases/longjmp_tiny_invoke_phi.ll
@@ -0,0 +1,46 @@
+; ModuleID = '/tmp/emscripten_temp/src.cpp.o'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
+target triple = "i386-pc-linux-gnu"
+
+@_ZL3buf = internal global [20 x i16] zeroinitializer, align 2
+@.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00", align 1
+@.str1 = private unnamed_addr constant [6 x i8] c"more\0A\00", align 1
+@.str2 = private unnamed_addr constant [6 x i8] c"fair\0A\00", align 1
+
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4
+ store i32 0, i32* %retval
+ %call = invoke i32 @setjmp(i16* getelementptr inbounds ([20 x i16]* @_ZL3buf, i32 0, i32 0)) returns_twice
+ to label %allgood unwind label %awful
+
+allgood:
+ %p = phi i32 [0, %entry], [1, %if.else]
+ %calll = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str2, i32 0, i32 0))
+ %total = add i32 %p, %call
+ %tobool = icmp ne i32 %total, 10
+ br i1 %tobool, label %if.then, label %if.else
+
+if.then: ; preds = %entry
+ %call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0))
+ call void @longjmp(i16* getelementptr inbounds ([20 x i16]* @_ZL3buf, i32 0, i32 0), i32 10)
+ br label %if.end
+
+if.else: ; preds = %entry
+ %call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0))
+ %chak = icmp ne i32 %call2, 1337
+ br i1 %chak, label %if.end, label %allgood
+
+if.end: ; preds = %if.else, %if.then
+ ret i32 0
+
+awful:
+ ret i32 1
+}
+
+declare i32 @setjmp(i16*) returns_twice
+
+declare i32 @printf(i8*, ...)
+
+declare void @longjmp(i16*, i32)
+
diff --git a/tests/cases/longjmp_tiny_invoke_phi.txt b/tests/cases/longjmp_tiny_invoke_phi.txt
new file mode 100644
index 00000000..aaa41d11
--- /dev/null
+++ b/tests/cases/longjmp_tiny_invoke_phi.txt
@@ -0,0 +1,4 @@
+fair
+hello world
+fair
+more
diff --git a/tests/cases/oob_ta2.ll b/tests/cases/oob_ta2.ll
index 3c94c13c..b95d28da 100644
--- a/tests/cases/oob_ta2.ll
+++ b/tests/cases/oob_ta2.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
%structy = type { [2 x [10 x i8]] }
diff --git a/tests/cases/phi24_ta2.ll b/tests/cases/phi24_ta2.ll
index 2d9b6646..18577fee 100644
--- a/tests/cases/phi24_ta2.ll
+++ b/tests/cases/phi24_ta2.ll
@@ -1,9 +1,6 @@
-;;; trunc i32 into i24, needs $0 on target variable name
-
-; ModuleID = '/tmp/tmpvqlBv2/a.out.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
%union.U4 = type { i32 }
%union.U3 = type { i8* }
diff --git a/tests/cases/phicubed.ll b/tests/cases/phicubed.ll
index a0799997..5fc3208b 100644
--- a/tests/cases/phicubed.ll
+++ b/tests/cases/phicubed.ll
@@ -1,4 +1,6 @@
; ModuleID = '/dev/shm/tmp/src.cpp.o'
+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"
%struct.worker_args = type { i32, %struct.worker_args* }
diff --git a/tests/cases/phientryimplicit.ll b/tests/cases/phientryimplicit.ll
index 8a510f43..c237457c 100644
--- a/tests/cases/phientryimplicit.ll
+++ b/tests/cases/phientryimplicit.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
; Phi nodes can refer to the entry. And the entry might be unnamed, and doesn't even have a consistent implicit name!
@@ -9,35 +9,35 @@ target triple = "i386-pc-linux-gnu"
; [#uses=0]
define i32 @main() {
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
- %16 = trunc i32 1 to i1
- br i1 %16, label %17, label %26, !dbg !1269853 ; [debug line = 3920:5]
+ %a16 = trunc i32 1 to i1
+ br i1 %a16, label %L17, label %L26, !dbg !1269853 ; [debug line = 3920:5]
-; <label>:17 ; preds = %1
- %25 = trunc i32 1 to i1
- br label %26
+L17:
+ %a25 = trunc i32 1 to i1
+ br label %L26
-; <label>:26 ; preds = %17, %1
- %27 = phi i1 [ false, %1 ], [ %25, %17 ] ; [#uses=1 type=i1]
+L26:
+ %a27 = phi i1 [ false, %1 ], [ %a25, %L17 ] ; [#uses=1 type=i1]
store i32 0, i32* %retval
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
- %cal2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %27) ; make sure %27 is used
+ %cal2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i1 %a27) ; make sure %27 is used
ret i32 1
}
define i32 @main0() {
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
- %16 = trunc i32 1 to i1
- br i1 %16, label %17, label %26, !dbg !1269853 ; [debug line = 3920:5]
+ %a16 = trunc i32 1 to i1
+ br i1 %a16, label %L17, label %L26, !dbg !1269853 ; [debug line = 3920:5]
-; <label>:17 ; preds = %1
- %25 = trunc i32 1 to i1
- br label %26
+L17:
+ %a25 = trunc i32 1 to i1
+ br label %L26
-; <label>:26 ; preds = %17, %1
- %27 = phi i1 [ false, %0 ], [ %25, %17 ] ; [#uses=1 type=i1]
+L26:
+ %a27 = phi i1 [ false, %0 ], [ %a25, %L17 ] ; [#uses=1 type=i1]
store i32 0, i32* %retval
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
- %cal2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %27) ; make sure %27 is used
+ %cal2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i1 %a27) ; make sure %27 is used
ret i32 1
}
diff --git a/tests/cases/phientryimplicitmix.ll b/tests/cases/phientryimplicitmix.ll
index 9223c059..527c761f 100644
--- a/tests/cases/phientryimplicitmix.ll
+++ b/tests/cases/phientryimplicitmix.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
; Phi nodes can refer to the entry. And the entry might be unnamed, and doesn't even have a consistent implicit name!
@@ -9,20 +9,20 @@ target triple = "i386-pc-linux-gnu"
; [#uses=0]
define i32 @main() {
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
- %16 = trunc i32 1 to i1
- br i1 %16, label %whoosh, label %26, !dbg !1269853 ; [debug line = 3920:5]
+ %1 = trunc i32 1 to i1
+ br i1 %1, label %whoosh, label %L26
whoosh: ; preds = %1
- %25 = trunc i32 1 to i1
- br label %26
+ %a25 = trunc i32 1 to i1
+ br label %L26
-; <label>:26 ; preds = %17, %1
- %27 = phi i1 [ false, %1 ], [ %25, %whoosh ] ; [#uses=1 type=i1]
- %28 = phi i1 [ true, %1 ], [ %25, %whoosh ] ; [#uses=1 type=i1]
+L26:
+ %a27 = phi i1 [ false, %0 ], [ true, %whoosh ] ; [#uses=1 type=i1]
+ %a28 = phi i1 [ true, %0 ], [ false, %whoosh ] ; [#uses=1 type=i1]
store i32 0, i32* %retval
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
- %cal2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %27) ; make sure %27 is used
- %cal3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %28) ; make sure %28 is used
+ %cal2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i1 %a27) ; make sure %27 is used
+ %cal3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i1 %a28) ; make sure %28 is used
ret i32 1
}
diff --git a/tests/cases/phientryimplicitmoar.ll b/tests/cases/phientryimplicitmoar.ll
index c83458e6..0f07cc44 100644
--- a/tests/cases/phientryimplicitmoar.ll
+++ b/tests/cases/phientryimplicitmoar.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@.str2 = private unnamed_addr constant [15 x i8] c"hello!!world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@@ -9,16 +9,16 @@ define i32 @main() {
%retval = alloca i32, align 4
%call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str2, i32 0, i32 0))
%a12 = zext i1 1 to i32
- br label %13
+ br label %L13
-; <label>:13 ; preds = %13, %1
- %a14 = phi i32 [ %a12, %1 ], [ %a15, %13 ]
+L13:
+ %a14 = phi i32 [ %a12, %0 ], [ %a15, %L13 ]
%call0 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0))
%a15 = add nsw i32 %a14, 2
%a16 = icmp eq i32 %a15, 9
- br i1 %a16, label %17, label %13
+ br i1 %a16, label %L17, label %L13
-; <label>:17 ; preds = %1
+L17:
%call1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str2, i32 0, i32 0))
ret i32 1
}
diff --git a/tests/cases/phiself.ll b/tests/cases/phiself.ll
index 81249799..0a06fcca 100644
--- a/tests/cases/phiself.ll
+++ b/tests/cases/phiself.ll
@@ -1,6 +1,6 @@
; ModuleID = '/tmp/emscripten_temp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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 [7 x i8] c"cheez\0A\00", align 1
@.str1 = private unnamed_addr constant [6 x i8] c"*%d*\0A\00", align 1
diff --git a/tests/cases/ptrtoi64.ll b/tests/cases/ptrtoi64.ll
index 01e466fe..5898f529 100644
--- a/tests/cases/ptrtoi64.ll
+++ b/tests/cases/ptrtoi64.ll
@@ -1,8 +1,8 @@
; pointer to i64, then to i32
; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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"
@.str2 = private constant [9 x i8] c"*%d,%d*\0A\00", align 1 ; [#uses=1]
@@ -18,10 +18,10 @@ entry:
%0 = alloca i32 ; [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
%sz.i7 = inttoptr i32 400 to i32* ; [#uses=1 type=i32*]
- %10 = ptrtoint i32* %sz.i7 to i64, !dbg !8557 ; [#uses=1 type=i64] [debug line = 99:3]
- %conv5 = trunc i64 %10 to i32, !dbg !8557 ; [#uses=1 type=i32] [debug line = 99:3]
- %11 = ptrtoint i32* %sz.i7 to i8, !dbg !8557 ; [#uses=1 type=i64] [debug line = 99:3]
- %conv6 = zext i8 %11 to i32, !dbg !8557 ; [#uses=1 type=i32] [debug line = 99:3]
- %55 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %conv5, i32 %conv6) ; [#uses=0]
+ %a10 = ptrtoint i32* %sz.i7 to i64
+ %conv5 = trunc i64 %a10 to i32
+ %a11 = ptrtoint i32* %sz.i7 to i8
+ %conv6 = zext i8 %a11 to i32
+ %a55 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %conv5, i32 %conv6)
ret i32 0
}
diff --git a/tests/cases/selectstruct.ll b/tests/cases/selectstruct.ll
index 5c9fecf7..58b1848e 100644
--- a/tests/cases/selectstruct.ll
+++ b/tests/cases/selectstruct.ll
@@ -8,7 +8,9 @@ target triple = "i386-pc-linux-gnu"
define i32 @main() {
entry:
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
- %. = select i1 %retval, { i32, i32 } { i32 55, i32 99 }, { i32, i32 } { i32 2, i32 6 } ; [#uses=1 type={ i32, i32 }]
+ %check = ptrtoint i32* %retval to i32
+ %check1 = trunc i32 %check to i1
+ %. = select i1 %check1, { i32, i32 } { i32 55, i32 99 }, { i32, i32 } { i32 2, i32 6 } ; [#uses=1 type={ i32, i32 }]
store i32 0, i32* %retval
%.1 = extractvalue { i32, i32 } %., 0
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i32 %.1) ; [#uses=0 type=i32]
diff --git a/tests/cases/sillybitcast.ll b/tests/cases/sillybitcast.ll
index c5ca4f9a..50a54da9 100644
--- a/tests/cases/sillybitcast.ll
+++ b/tests/cases/sillybitcast.ll
@@ -1,6 +1,6 @@
; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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 constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
diff --git a/tests/cases/sillybitcast2.ll b/tests/cases/sillybitcast2.ll
new file mode 100644
index 00000000..02cf8615
--- /dev/null
+++ b/tests/cases/sillybitcast2.ll
@@ -0,0 +1,35 @@
+; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
+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 constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
+
+; [#uses=2]
+define void @"_Z5hellov"() {
+entry:
+ %0 = call i32 bitcast (i32 (i32*)* @puts to i32 (i8*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ br label %return
+
+return: ; preds = %entry
+ ret void
+}
+
+; [#uses=1]
+declare i32 @puts(i32*)
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32 ; [#uses=2]
+ %0 = alloca i32 ; [#uses=2]
+ %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
+ call void @"_Z5hellov"()
+ store i32 0, i32* %0, align 4
+ %1 = load i32* %0, align 4 ; [#uses=1]
+ store i32 %1, i32* %retval, align 4
+ br label %return
+
+return: ; preds = %entry
+ %retval1 = load i32* %retval ; [#uses=1]
+ ret i32 %retval1
+}
diff --git a/tests/cases/sillyfuncast.ll b/tests/cases/sillyfuncast.ll
index 36c26720..33598104 100644
--- a/tests/cases/sillyfuncast.ll
+++ b/tests/cases/sillyfuncast.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@@ -13,7 +13,7 @@ define i32 @main() {
entry:
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
store i32 0, i32* %retval
- %58 = tail call i32 bitcast (void ()* @doit to i32 ()*)() nounwind
+ %0 = tail call i32 bitcast (void ()* @doit to i32 ()*)() nounwind
ret i32 1
}
diff --git a/tests/cases/storebigfloat.ll b/tests/cases/storebigfloat.ll
index c9995835..b940f5ca 100644
--- a/tests/cases/storebigfloat.ll
+++ b/tests/cases/storebigfloat.ll
@@ -1,3 +1,5 @@
+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"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
diff --git a/tests/cases/storestruct.ll b/tests/cases/storestruct.ll
index a5b7483b..3e996195 100644
--- a/tests/cases/storestruct.ll
+++ b/tests/cases/storestruct.ll
@@ -1,6 +1,6 @@
; ModuleID = '/dev/shm/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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"
; Load and store an entire structure as a whole (and also load as a whole, extract values and save separately, etc.)
@@ -43,7 +43,11 @@ entry:
%call2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %tmp5, i32 %tmp6), !dbg !18 ; [#uses=0]
%ptr = inttoptr i32 52 to i32* ; [#uses=1]
- store %struct.X { i32 ptrtoint (i32* getelementptr inbounds (i32* %ptr, i32 1, i32 0) to i32), i32 3 }, %struct.X* %y, align 4 ; store entire struct at once
+ %ptrgep = getelementptr inbounds i32* %ptr, i32 1
+ %ptrgepint = ptrtoint i32* %ptrgep to i32
+ %ss1 = insertvalue %struct.X undef, i32 %ptrgepint, 0
+ %ss2 = insertvalue %struct.X %ss1, i32 3, 1
+ store %struct.X %ss2, %struct.X* %y, align 4 ; store entire struct at once
%tmp5b = load i32* %a1, align 4, !dbg !18 ; [#uses=1]
%tmp6b = load i32* %b2, align 4, !dbg !18 ; [#uses=1]
diff --git a/tests/cases/structphiparam.ll b/tests/cases/structphiparam.ll
index 117bdf77..fadf4d29 100644
--- a/tests/cases/structphiparam.ll
+++ b/tests/cases/structphiparam.ll
@@ -1,6 +1,6 @@
; ModuleID = '/dev/shm/tmp/src.cpp.o'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
-target triple = "i386-pc-linux-gnu"
+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"hello, %d %d!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
@_dispatchTable = internal global i64 0
diff --git a/tests/cases/sub_11_0.ll b/tests/cases/sub_11_0.ll
index 7f0bb285..d4094556 100644
--- a/tests/cases/sub_11_0.ll
+++ b/tests/cases/sub_11_0.ll
@@ -1,4 +1,6 @@
; 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"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
diff --git a/tests/cases/switch64_ta2.ll b/tests/cases/switch64_ta2.ll
index e56ccfba..4d5c6273 100644
--- a/tests/cases/switch64_ta2.ll
+++ b/tests/cases/switch64_ta2.ll
@@ -1,10 +1,13 @@
+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 constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
define linkonce_odr i32 @main() align 2 {
- %333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- %444 = zext i32 %333 to i64
- %199 = trunc i8 1 to i1 ; [#uses=1]
- switch i64 %444, label %label999 [
+ %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %a444 = zext i32 %a333 to i64
+ %a199 = trunc i8 1 to i1 ; [#uses=1]
+ switch i64 %a444, label %label999 [
i64 1000, label %label9950
i64 1001, label %label9951
i64 1002, label %label9952
@@ -24,7 +27,7 @@ define linkonce_odr i32 @main() align 2 {
br label %label999
label9950:
- %333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %a333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
br label %label999
label9951:
diff --git a/tests/cases/uadd_overflow_ta2.ll b/tests/cases/uadd_overflow_ta2.ll
index feac60e3..e827cb38 100644
--- a/tests/cases/uadd_overflow_ta2.ll
+++ b/tests/cases/uadd_overflow_ta2.ll
@@ -1,6 +1,6 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"
@.str2 = private constant [9 x i8] c"*%d,%d*\0A\00", align 1 ; [#uses=1]
@@ -24,14 +24,14 @@ entry:
%ba2 = zext i1 %ba1 to i32
call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %ba0, i32 %ba2) ; [#uses=0]
- %64buadd1pre = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 5000, i64 3000)
- %64buadd1 = insertvalue { i64, i1 } %64buadd1pre, i64 9875, 0
- %64buadd2 = insertvalue { i64, i1 } %64buadd1, i1 1, 1
- %64ba0pre = extractvalue { i64, i1 } %64buadd2, 0
- %64ba0 = trunc i64 %64ba0pre to i32
- %64ba1 = extractvalue { i64, i1 } %64buadd2, 1
- %64ba2 = zext i1 %64ba1 to i32
- call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %64ba0, i32 %64ba2) ; [#uses=0]
+ %z64buadd1pre = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 5000, i64 3000)
+ %z64buadd1 = insertvalue { i64, i1 } %z64buadd1pre, i64 9875, 0
+ %z64buadd2 = insertvalue { i64, i1 } %z64buadd1, i1 1, 1
+ %z64ba0pre = extractvalue { i64, i1 } %z64buadd2, 0
+ %z64ba0 = trunc i64 %z64ba0pre to i32
+ %z64ba1 = extractvalue { i64, i1 } %z64buadd2, 1
+ %z64ba2 = zext i1 %z64ba1 to i32
+ call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str2, i32 0, i32 0), i32 %z64ba0, i32 %z64ba2) ; [#uses=0]
%zbuadd1 = insertvalue { i32, i1 } { i32 undef, i1 false }, i32 10, 0 ; undef and explicit
%zba0 = extractvalue { i32, i1 } %zbuadd1, 0
@@ -46,5 +46,5 @@ entry:
declare i32 @printf(i8*, ...)
declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
-declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i32) nounwind readnone
+declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone
diff --git a/tests/cases/unaligneddouble.ll b/tests/cases/unaligneddouble.ll
index 22b92741..e4067831 100644
--- a/tests/cases/unaligneddouble.ll
+++ b/tests/cases/unaligneddouble.ll
@@ -10,7 +10,7 @@ entry:
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
%doub = alloca double, align 4
store i32 0, i32* %retval
- %0 = bitcast double* %doub to i32
+ %0 = ptrtoint double* %doub to i32
%1 = uitofp i32 %0 to double
store double %1, double* %doub, align 1
store double %1, double* %doub, align 2
diff --git a/tests/cases/zeroembedded.ll b/tests/cases/zeroembedded.ll
index 6a4f6073..167fe278 100644
--- a/tests/cases/zeroembedded.ll
+++ b/tests/cases/zeroembedded.ll
@@ -1,4 +1,6 @@
-; a.ll
+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"
+
%struct.pypy_str = type { i32, [0 x i8] }
%struct.pypy_strval = type { i32, [13 x i8] }
diff --git a/tests/cases/zeroextarg.ll b/tests/cases/zeroextarg.ll
index 25efb7ec..a3caa74c 100644
--- a/tests/cases/zeroextarg.ll
+++ b/tests/cases/zeroextarg.ll
@@ -1,10 +1,10 @@
; ModuleID = 'tests/hello_world.bc'
-target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"
-target triple = "i386-pc-linux-gnu"
+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"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
-define void @glSampleCoverage(float %18, i8 zeroext %invert) {
+define void @glSampleCoverage(float %a18, i8 zeroext %invert) {
entry:
%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
ret void
diff --git a/tests/core/closebitcasts.c b/tests/core/closebitcasts.c
new file mode 100644
index 00000000..2c9d5ab5
--- /dev/null
+++ b/tests/core/closebitcasts.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ float x = argc%17, y = (argc+1)*(argc+2)*(argc+3)*(argc+4)*(argc*5);
+ y *= 1<<30;
+ y *= -13;
+ if (argc == 17) { x++; y--; }
+ int *xi = (int*)&x;
+ int *yi = (int*)&y;
+ int z = *xi - *yi;
+ while (z % 15) {
+ z++;
+ }
+ printf("!%d\n", z);
+
+ double xd = x, yd = y;
+ yd = yd*yd;
+ yd = yd*yd;
+ int *xl = (int*)&xd;
+ int *xh = &((int*)&xd)[1];
+ int *yl = (int*)&yd;
+ int *yh = &((int*)&yd)[1];
+ int l = *xl - *yl;
+ int h = *xh - *yh;
+ while (l % 15) {
+ l++;
+ h += 3;
+ }
+ printf("%d,%d!\n", l, h);
+ return 0;
+}
+
diff --git a/tests/core/closebitcasts.txt b/tests/core/closebitcasts.txt
new file mode 100644
index 00000000..f97366cd
--- /dev/null
+++ b/tests/core/closebitcasts.txt
@@ -0,0 +1,2 @@
+!1787576325
+589815810,-179981561!
diff --git a/tests/core/test_addr_of_stacked.in b/tests/core/test_addr_of_stacked.in
new file mode 100644
index 00000000..7a4d9ba7
--- /dev/null
+++ b/tests/core/test_addr_of_stacked.in
@@ -0,0 +1,8 @@
+#include <stdio.h>
+void alter(int *y) { *y += 5; }
+int main() {
+ int x = 2;
+ alter(&x);
+ printf("*%d*\n", x);
+ return 0;
+}
diff --git a/tests/core/test_addr_of_stacked.out b/tests/core/test_addr_of_stacked.out
new file mode 100644
index 00000000..2b8cf4a1
--- /dev/null
+++ b/tests/core/test_addr_of_stacked.out
@@ -0,0 +1 @@
+*7* \ No newline at end of file
diff --git a/tests/core/test_alloca.in b/tests/core/test_alloca.in
new file mode 100644
index 00000000..bfad3324
--- /dev/null
+++ b/tests/core/test_alloca.in
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ char *pc;
+ pc = (char *)alloca(5);
+ printf("z:%d*%d*\n", pc > 0, (int)pc);
+ return 0;
+}
diff --git a/tests/core/test_alloca.out b/tests/core/test_alloca.out
new file mode 100644
index 00000000..37de3d6b
--- /dev/null
+++ b/tests/core/test_alloca.out
@@ -0,0 +1 @@
+z:1* \ No newline at end of file
diff --git a/tests/core/test_alloca_stack.in b/tests/core/test_alloca_stack.in
new file mode 100644
index 00000000..ba3afcc7
--- /dev/null
+++ b/tests/core/test_alloca_stack.in
@@ -0,0 +1,16 @@
+// We should not blow up the stack with numerous allocas
+#include <stdio.h>
+#include <stdlib.h>
+
+func(int i) {
+ char *pc = (char *)alloca(100);
+ *pc = i;
+ (*pc)++;
+ return (*pc) % 10;
+}
+int main() {
+ int total = 0;
+ for (int i = 0; i < 1024 * 1024; i++) total += func(i);
+ printf("ok:%d*\n", total);
+ return 0;
+}
diff --git a/tests/core/test_alloca_stack.out b/tests/core/test_alloca_stack.out
new file mode 100644
index 00000000..d6a90d4e
--- /dev/null
+++ b/tests/core/test_alloca_stack.out
@@ -0,0 +1 @@
+ok:-32768* \ No newline at end of file
diff --git a/tests/core/test_array2.in b/tests/core/test_array2.in
new file mode 100644
index 00000000..452e0792
--- /dev/null
+++ b/tests/core/test_array2.in
@@ -0,0 +1,13 @@
+#include <stdio.h>
+
+static const double grid[4][2] = {{-3 / 3., -1 / 3.},
+ {+1 / 3., -3 / 3.},
+ {-1 / 3., +3 / 3.},
+ {+3 / 3., +1 / 3.}};
+
+int main() {
+ for (int i = 0; i < 4; i++)
+ printf("%d:%.2f,%.2f ", i, grid[i][0], grid[i][1]);
+ printf("\n");
+ return 0;
+}
diff --git a/tests/core/test_array2.out b/tests/core/test_array2.out
new file mode 100644
index 00000000..a6ee88bb
--- /dev/null
+++ b/tests/core/test_array2.out
@@ -0,0 +1 @@
+0:-1.00,-0.33 1:0.33,-1.00 2:-0.33,1.00 3:1.00,0.33 \ No newline at end of file
diff --git a/tests/core/test_array2b.in b/tests/core/test_array2b.in
new file mode 100644
index 00000000..97ace8db
--- /dev/null
+++ b/tests/core/test_array2b.in
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+static const struct {
+ unsigned char left;
+ unsigned char right;
+} prioritah[] = {{6, 6}, {6, 6}, {7, 95}, {7, 7}};
+
+int main() {
+ printf("*%d,%d\n", prioritah[1].left, prioritah[1].right);
+ printf("%d,%d*\n", prioritah[2].left, prioritah[2].right);
+ return 0;
+}
diff --git a/tests/core/test_array2b.out b/tests/core/test_array2b.out
new file mode 100644
index 00000000..422896dc
--- /dev/null
+++ b/tests/core/test_array2b.out
@@ -0,0 +1,2 @@
+*6,6
+7,95* \ No newline at end of file
diff --git a/tests/core/test_assert.in b/tests/core/test_assert.in
new file mode 100644
index 00000000..3a1898fa
--- /dev/null
+++ b/tests/core/test_assert.in
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include <assert.h>
+int main() {
+ assert(1 == true); // pass
+ assert(1 == false); // fail
+ return 0;
+}
diff --git a/tests/core/test_assert.out b/tests/core/test_assert.out
new file mode 100644
index 00000000..870c1784
--- /dev/null
+++ b/tests/core/test_assert.out
@@ -0,0 +1 @@
+Assertion failed: 1 == false \ No newline at end of file
diff --git a/tests/core/test_atexit.in b/tests/core/test_atexit.in
new file mode 100644
index 00000000..b40c01c0
--- /dev/null
+++ b/tests/core/test_atexit.in
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static void cleanA() { printf("A"); }
+static void cleanB() { printf("B"); }
+
+int main() {
+ atexit(cleanA);
+ atexit(cleanB);
+ return 0;
+}
diff --git a/tests/core/test_atexit.out b/tests/core/test_atexit.out
new file mode 100644
index 00000000..c1c30196
--- /dev/null
+++ b/tests/core/test_atexit.out
@@ -0,0 +1 @@
+BA \ No newline at end of file
diff --git a/tests/core/test_atoX.in b/tests/core/test_atoX.in
new file mode 100644
index 00000000..327871b8
--- /dev/null
+++ b/tests/core/test_atoX.in
@@ -0,0 +1,40 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ printf("%d*", atoi(""));
+ printf("%d*", atoi("a"));
+ printf("%d*", atoi(" b"));
+ printf("%d*", atoi(" c "));
+ printf("%d*", atoi("6"));
+ printf("%d*", atoi(" 5"));
+ printf("%d*", atoi("4 "));
+ printf("%d*", atoi("3 6"));
+ printf("%d*", atoi(" 3 7"));
+ printf("%d*", atoi("9 d"));
+ printf("%d\n", atoi(" 8 e"));
+ printf("%d*", atol(""));
+ printf("%d*", atol("a"));
+ printf("%d*", atol(" b"));
+ printf("%d*", atol(" c "));
+ printf("%d*", atol("6"));
+ printf("%d*", atol(" 5"));
+ printf("%d*", atol("4 "));
+ printf("%d*", atol("3 6"));
+ printf("%d*", atol(" 3 7"));
+ printf("%d*", atol("9 d"));
+ printf("%d\n", atol(" 8 e"));
+ printf("%lld*", atoll("6294967296"));
+ printf("%lld*", atoll(""));
+ printf("%lld*", atoll("a"));
+ printf("%lld*", atoll(" b"));
+ printf("%lld*", atoll(" c "));
+ printf("%lld*", atoll("6"));
+ printf("%lld*", atoll(" 5"));
+ printf("%lld*", atoll("4 "));
+ printf("%lld*", atoll("3 6"));
+ printf("%lld*", atoll(" 3 7"));
+ printf("%lld*", atoll("9 d"));
+ printf("%lld\n", atoll(" 8 e"));
+ return 0;
+}
diff --git a/tests/core/test_atoX.out b/tests/core/test_atoX.out
new file mode 100644
index 00000000..4b76d26d
--- /dev/null
+++ b/tests/core/test_atoX.out
@@ -0,0 +1,3 @@
+0*0*0*0*6*5*4*3*3*9*8
+0*0*0*0*6*5*4*3*3*9*8
+6294967296*0*0*0*0*6*5*4*3*3*9*8
diff --git a/tests/core/test_atomic.in b/tests/core/test_atomic.in
new file mode 100644
index 00000000..2390941f
--- /dev/null
+++ b/tests/core/test_atomic.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+int main() {
+ int x = 10;
+ int y = __sync_add_and_fetch(&x, 5);
+ printf("*%d,%d*\n", x, y);
+ x = 10;
+ y = __sync_fetch_and_add(&x, 5);
+ printf("*%d,%d*\n", x, y);
+ x = 10;
+ y = __sync_lock_test_and_set(&x, 6);
+ printf("*%d,%d*\n", x, y);
+ x = 10;
+ y = __sync_bool_compare_and_swap(&x, 9, 7);
+ printf("*%d,%d*\n", x, y);
+ y = __sync_bool_compare_and_swap(&x, 10, 7);
+ printf("*%d,%d*\n", x, y);
+ return 0;
+}
diff --git a/tests/core/test_atomic.out b/tests/core/test_atomic.out
new file mode 100644
index 00000000..ed11bce0
--- /dev/null
+++ b/tests/core/test_atomic.out
@@ -0,0 +1,5 @@
+*15,15*
+*15,10*
+*6,10*
+*10,0*
+*7,1* \ No newline at end of file
diff --git a/tests/core/test_bigarray.in b/tests/core/test_bigarray.in
new file mode 100644
index 00000000..292a44e5
--- /dev/null
+++ b/tests/core/test_bigarray.in
@@ -0,0 +1,22 @@
+// avoid "array initializer too large" errors
+#include <stdio.h>
+#include <assert.h>
+
+#define SIZE (1024 * 100)
+struct Struct {
+ char x;
+ int y;
+};
+Struct buffy[SIZE];
+
+int main() {
+ for (int i = 0; i < SIZE; i++) {
+ assert(buffy[i].x == 0 && buffy[i].y == 0);
+ } // we were zeroinitialized
+ for (int i = 0; i < SIZE; i++) {
+ buffy[i].x = i * i;
+ buffy[i].y = i * i * i;
+ } // we can save data
+ printf("*%d*\n", buffy[SIZE / 3].x);
+ return 0;
+}
diff --git a/tests/core/test_bigarray.out b/tests/core/test_bigarray.out
new file mode 100644
index 00000000..33485c46
--- /dev/null
+++ b/tests/core/test_bigarray.out
@@ -0,0 +1 @@
+*57* \ No newline at end of file
diff --git a/tests/core/test_bitfields.in b/tests/core/test_bitfields.in
new file mode 100644
index 00000000..cbc7ccf2
--- /dev/null
+++ b/tests/core/test_bitfields.in
@@ -0,0 +1,20 @@
+#include <stdio.h>
+struct bitty {
+ unsigned x : 1;
+ unsigned y : 1;
+ unsigned z : 1;
+};
+int main() {
+ bitty b;
+ printf("*");
+ for (int i = 0; i <= 1; i++)
+ for (int j = 0; j <= 1; j++)
+ for (int k = 0; k <= 1; k++) {
+ b.x = i;
+ b.y = j;
+ b.z = k;
+ printf("%d,%d,%d,", b.x, b.y, b.z);
+ }
+ printf("*\n");
+ return 0;
+}
diff --git a/tests/core/test_bitfields.out b/tests/core/test_bitfields.out
new file mode 100644
index 00000000..e121b181
--- /dev/null
+++ b/tests/core/test_bitfields.out
@@ -0,0 +1 @@
+*0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,1,0,1,1,1,0,1,1,1,* \ No newline at end of file
diff --git a/tests/core/test_bsearch.in b/tests/core/test_bsearch.in
new file mode 100644
index 00000000..3b5fb6bc
--- /dev/null
+++ b/tests/core/test_bsearch.in
@@ -0,0 +1,45 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int cmp(const void* key, const void* member) {
+ return *(int*)key - *(int*)member;
+}
+
+void printResult(int* needle, int* haystack, unsigned int len) {
+ void* result = bsearch(needle, haystack, len, sizeof(unsigned int), cmp);
+
+ if (result == NULL) {
+ printf("null\n");
+ } else {
+ printf("%d\n", *(unsigned int*)result);
+ }
+}
+
+int main() {
+ int a[] = {-2, -1, 0, 6, 7, 9};
+ int b[] = {0, 1};
+
+ /* Find all keys that exist. */
+ for (int i = 0; i < 6; i++) {
+ int val = a[i];
+
+ printResult(&val, a, 6);
+ }
+
+ /* Keys that are covered by the range of the array but aren't in
+ * the array cannot be found.
+ */
+ int v1 = 3;
+ int v2 = 8;
+ printResult(&v1, a, 6);
+ printResult(&v2, a, 6);
+
+ /* Keys outside the range of the array cannot be found. */
+ int v3 = -1;
+ int v4 = 2;
+
+ printResult(&v3, b, 2);
+ printResult(&v4, b, 2);
+
+ return 0;
+}
diff --git a/tests/core/test_bsearch.out b/tests/core/test_bsearch.out
new file mode 100644
index 00000000..cc6a3205
--- /dev/null
+++ b/tests/core/test_bsearch.out
@@ -0,0 +1,10 @@
+-2
+-1
+0
+6
+7
+9
+null
+null
+null
+null \ No newline at end of file
diff --git a/tests/core/test_bswap64.in b/tests/core/test_bswap64.in
new file mode 100644
index 00000000..a608ad22
--- /dev/null
+++ b/tests/core/test_bswap64.in
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <iostream>
+#include <string>
+#include <sstream>
+
+typedef unsigned long long quint64;
+
+using namespace std;
+
+inline quint64 qbswap(quint64 source) {
+ return 0 | ((source & quint64(0x00000000000000ffLL)) << 56) |
+ ((source & quint64(0x000000000000ff00LL)) << 40) |
+ ((source & quint64(0x0000000000ff0000LL)) << 24) |
+ ((source & quint64(0x00000000ff000000LL)) << 8) |
+ ((source & quint64(0x000000ff00000000LL)) >> 8) |
+ ((source & quint64(0x0000ff0000000000LL)) >> 24) |
+ ((source & quint64(0x00ff000000000000LL)) >> 40) |
+ ((source & quint64(0xff00000000000000LL)) >> 56);
+}
+
+int main() {
+ quint64 v = strtoull("4433ffeeddccbb00", NULL, 16);
+ printf("%lld\n", v);
+
+ const string string64bitInt = "4433ffeeddccbb00";
+ stringstream s(string64bitInt);
+ quint64 int64bitInt = 0;
+ printf("1\n");
+ s >> hex >> int64bitInt;
+ printf("2\n");
+
+ stringstream out;
+ out << hex << qbswap(int64bitInt);
+
+ cout << out.str() << endl;
+ cout << hex << int64bitInt << endl;
+ cout << string64bitInt << endl;
+
+ if (out.str() != "bbccddeeff3344") {
+ cout << "Failed!" << endl;
+ } else {
+ cout << "Succeeded!" << endl;
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_bswap64.out b/tests/core/test_bswap64.out
new file mode 100644
index 00000000..af129b5f
--- /dev/null
+++ b/tests/core/test_bswap64.out
@@ -0,0 +1,7 @@
+4914553019779824384
+1
+2
+bbccddeeff3344
+4433ffeeddccbb00
+4433ffeeddccbb00
+Succeeded!
diff --git a/tests/core/test_ccall.in b/tests/core/test_ccall.in
new file mode 100644
index 00000000..0aefdc9d
--- /dev/null
+++ b/tests/core/test_ccall.in
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern "C" {
+int get_int() { return 5; }
+float get_float() { return 3.14; }
+char *get_string() { return "hello world"; }
+void print_int(int x) { printf("%d\n", x); }
+void print_float(float x) { printf("%.2f\n", x); }
+void print_string(char *x) { printf("%s\n", x); }
+int multi(int x, float y, int z, char *str) {
+ if (x) puts(str);
+ return (x + y) * z;
+}
+int *pointer(int *in) {
+ printf("%d\n", *in);
+ static int ret = 21;
+ return &ret;
+}
+}
+
+int main(int argc, char **argv) { return 0; }
diff --git a/tests/core/test_ccall.out b/tests/core/test_ccall.out
new file mode 100644
index 00000000..526ed80d
--- /dev/null
+++ b/tests/core/test_ccall.out
@@ -0,0 +1,23 @@
+*
+number,5
+number,3.14
+string,hello world
+12
+undefined
+14.56
+undefined
+cheez
+undefined
+arr-ay
+undefined
+more
+number,10
+650
+number,21
+*
+atr
+10
+bret
+53
+*
+stack is ok.
diff --git a/tests/core/test_class.in b/tests/core/test_class.in
new file mode 100644
index 00000000..9450b4a1
--- /dev/null
+++ b/tests/core/test_class.in
@@ -0,0 +1,28 @@
+#include <stdio.h>
+struct Random {
+ enum {
+ IM = 139968,
+ IA = 3877,
+ IC = 29573
+ };
+ Random() : last(42) {}
+ float get(float max = 1.0f) {
+ last = (last * IA + IC) % IM;
+ return max * last / IM;
+ }
+
+ protected:
+ unsigned int last;
+} rng1;
+int main() {
+ Random rng2;
+ int count = 0;
+ for (int i = 0; i < 100; i++) {
+ float x1 = rng1.get();
+ float x2 = rng2.get();
+ printf("%f, %f\n", x1, x2);
+ if (x1 != x2) count += 1;
+ }
+ printf("*%d*\n", count);
+ return 0;
+}
diff --git a/tests/core/test_class.out b/tests/core/test_class.out
new file mode 100644
index 00000000..a5e8240e
--- /dev/null
+++ b/tests/core/test_class.out
@@ -0,0 +1 @@
+*0* \ No newline at end of file
diff --git a/tests/core/test_constglobalstructs.in b/tests/core/test_constglobalstructs.in
new file mode 100644
index 00000000..182fae2f
--- /dev/null
+++ b/tests/core/test_constglobalstructs.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+struct IUB {
+ int c;
+ double p;
+ unsigned int pi;
+};
+
+IUB iub[] = {{'a', 0.27, 5}, {'c', 0.15, 4}, {'g', 0.12, 3}, {'t', 0.27, 2}, };
+
+const unsigned char faceedgesidx[6][4] = {{4, 5, 8, 10},
+ {6, 7, 9, 11},
+ {0, 2, 8, 9},
+ {1, 3, 10, 11},
+ {0, 1, 4, 6},
+ {2, 3, 5, 7}, };
+
+int main(int argc, const char *argv[]) {
+ printf("*%d,%d,%d,%d*\n", iub[0].c, int(iub[1].p * 100), iub[2].pi,
+ faceedgesidx[3][2]);
+ return 0;
+}
diff --git a/tests/core/test_constglobalstructs.out b/tests/core/test_constglobalstructs.out
new file mode 100644
index 00000000..1d530091
--- /dev/null
+++ b/tests/core/test_constglobalstructs.out
@@ -0,0 +1 @@
+*97,15,3,10* \ No newline at end of file
diff --git a/tests/core/test_conststructs.in b/tests/core/test_conststructs.in
new file mode 100644
index 00000000..6d664bea
--- /dev/null
+++ b/tests/core/test_conststructs.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+struct IUB {
+ int c;
+ double p;
+ unsigned int pi;
+};
+
+int main(int argc, const char *argv[]) {
+ int before = 70;
+ IUB iub[] = {{'a', 0.3029549426680, 5},
+ {'c', 0.15, 4},
+ {'g', 0.12, 3},
+ {'t', 0.27, 2}, };
+ int after = 90;
+ printf("*%d,%d,%d,%d,%d,%d*\n", before, iub[0].c, int(iub[1].p * 100),
+ iub[2].pi, int(iub[0].p * 10000), after);
+ return 0;
+}
diff --git a/tests/core/test_conststructs.out b/tests/core/test_conststructs.out
new file mode 100644
index 00000000..af600061
--- /dev/null
+++ b/tests/core/test_conststructs.out
@@ -0,0 +1 @@
+*70,97,15,3,3029,90* \ No newline at end of file
diff --git a/tests/core/test_copyop.in b/tests/core/test_copyop.in
new file mode 100644
index 00000000..847a516c
--- /dev/null
+++ b/tests/core/test_copyop.in
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+
+struct vec {
+ double x, y, z;
+ vec() : x(0), y(0), z(0) {};
+ vec(const double a, const double b, const double c) : x(a), y(b), z(c) {};
+};
+
+struct basis {
+ vec a, b, c;
+ basis(const vec& v) {
+ a = v; // should not touch b!
+ printf("*%.2f,%.2f,%.2f*\n", b.x, b.y, b.z);
+ }
+};
+
+int main() {
+ basis B(vec(1, 0, 0));
+
+ // Part 2: similar problem with memset and memmove
+ int x = 1, y = 77, z = 2;
+ memset((void*)&x, 0, sizeof(int));
+ memset((void*)&z, 0, sizeof(int));
+ printf("*%d,%d,%d*\n", x, y, z);
+ memcpy((void*)&x, (void*)&z, sizeof(int));
+ memcpy((void*)&z, (void*)&x, sizeof(int));
+ printf("*%d,%d,%d*\n", x, y, z);
+ memmove((void*)&x, (void*)&z, sizeof(int));
+ memmove((void*)&z, (void*)&x, sizeof(int));
+ printf("*%d,%d,%d*\n", x, y, z);
+ return 0;
+}
diff --git a/tests/core/test_copyop.out b/tests/core/test_copyop.out
new file mode 100644
index 00000000..17bde9e7
--- /dev/null
+++ b/tests/core/test_copyop.out
@@ -0,0 +1,4 @@
+*0.00,0.00,0.00*
+*0,77,0*
+*0,77,0*
+*0,77,0* \ No newline at end of file
diff --git a/tests/core/test_corruption_2.in b/tests/core/test_corruption_2.in
new file mode 100644
index 00000000..4db3b7c4
--- /dev/null
+++ b/tests/core/test_corruption_2.in
@@ -0,0 +1,21 @@
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+#include <stdio.h>
+
+void bye() { printf("all ok\n"); }
+
+int main() {
+ atexit(bye);
+
+ std::string testPath = "/Script/WA-KA.txt";
+ std::fstream str(testPath.c_str(), std::ios::in | std::ios::binary);
+
+ if (str.is_open()) {
+ std::cout << "open!" << std::endl;
+ } else {
+ std::cout << "missing!" << std::endl;
+ }
+
+ return 1;
+}
diff --git a/tests/core/test_corruption_2.out b/tests/core/test_corruption_2.out
new file mode 100644
index 00000000..26795dba
--- /dev/null
+++ b/tests/core/test_corruption_2.out
@@ -0,0 +1,2 @@
+missing!
+all ok
diff --git a/tests/core/test_corruption_3.in b/tests/core/test_corruption_3.in
new file mode 100644
index 00000000..08e7d345
--- /dev/null
+++ b/tests/core/test_corruption_3.in
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+void bye() { printf("all ok\n"); }
+
+int main(int argc, char **argv) {
+ atexit(bye);
+
+ char *buffer = (char *)malloc(100);
+ for (int i = 0; i < 100; i++) buffer[i] = (i * i) % 256;
+ buffer = (char *)realloc(buffer, argc + 50);
+ for (int i = 0; i < argc + 50; i++) {
+ // printf("%d : %d : %d : %d\n", i, (int)(buffer + i), buffer[i],
+ // (char)((i*i)%256));
+ assert(buffer[i] == (char)((i * i) % 256));
+ }
+ return 1;
+}
diff --git a/tests/core/test_corruption_3.out b/tests/core/test_corruption_3.out
new file mode 100644
index 00000000..d48ce729
--- /dev/null
+++ b/tests/core/test_corruption_3.out
@@ -0,0 +1 @@
+all ok
diff --git a/tests/core/test_cxx03_do_run.in b/tests/core/test_cxx03_do_run.in
new file mode 100644
index 00000000..2ed0d2cf
--- /dev/null
+++ b/tests/core/test_cxx03_do_run.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+#if __cplusplus != 199711L
+#error By default, if no -std is specified, emscripten should be compiling with -std=c++03!
+#endif
+
+int main(int argc, const char *argv[]) {
+ printf("Hello world!\n");
+ return 0;
+}
diff --git a/tests/core/test_cxx03_do_run.out b/tests/core/test_cxx03_do_run.out
new file mode 100644
index 00000000..6769dd60
--- /dev/null
+++ b/tests/core/test_cxx03_do_run.out
@@ -0,0 +1 @@
+Hello world! \ No newline at end of file
diff --git a/tests/core/test_demangle_stacks.in b/tests/core/test_demangle_stacks.in
new file mode 100644
index 00000000..e19d1a70
--- /dev/null
+++ b/tests/core/test_demangle_stacks.in
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+namespace NameSpace {
+class Class {
+ public:
+ int Aborter(double x, char y, int *z) {
+ int addr = x + y + (int)z;
+ void *p = (void *)addr;
+ for (int i = 0; i < 100; i++)
+ free(p); // will abort, should show proper stack trace
+ }
+};
+}
+
+int main(int argc, char **argv) {
+ NameSpace::Class c;
+ c.Aborter(1.234, 'a', NULL);
+ return 0;
+}
diff --git a/tests/core/test_demangle_stacks.out b/tests/core/test_demangle_stacks.out
new file mode 100644
index 00000000..d1c61b45
--- /dev/null
+++ b/tests/core/test_demangle_stacks.out
@@ -0,0 +1 @@
+NameSpace::Class::Aborter(double, char, int*) \ No newline at end of file
diff --git a/tests/core/test_direct_string_constant_usage.in b/tests/core/test_direct_string_constant_usage.in
new file mode 100644
index 00000000..cab335bd
--- /dev/null
+++ b/tests/core/test_direct_string_constant_usage.in
@@ -0,0 +1,9 @@
+#include <iostream>
+template <int i>
+void printText(const char (&text)[i]) {
+ std::cout << text;
+}
+int main() {
+ printText("some string constant");
+ return 0;
+}
diff --git a/tests/core/test_direct_string_constant_usage.out b/tests/core/test_direct_string_constant_usage.out
new file mode 100644
index 00000000..ddb4b681
--- /dev/null
+++ b/tests/core/test_direct_string_constant_usage.out
@@ -0,0 +1 @@
+some string constant \ No newline at end of file
diff --git a/tests/core/test_dlfcn_self.in b/tests/core/test_dlfcn_self.in
new file mode 100644
index 00000000..7094b97d
--- /dev/null
+++ b/tests/core/test_dlfcn_self.in
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <dlfcn.h>
+#include <emscripten.h>
+
+int EMSCRIPTEN_KEEPALIVE global = 123;
+
+extern "C" EMSCRIPTEN_KEEPALIVE void foo(int x) {
+ printf("%d\n", x);
+}
+
+extern "C" EMSCRIPTEN_KEEPALIVE void repeatable() {
+ void* self = dlopen(NULL, RTLD_LAZY);
+ int* global_ptr = (int*)dlsym(self, "global");
+ void (*foo_ptr)(int) = (void (*)(int))dlsym(self, "foo");
+ foo_ptr(*global_ptr);
+ dlclose(self);
+}
+
+int main() {
+ repeatable();
+ repeatable();
+ return 0;
+}
diff --git a/tests/core/test_dlfcn_self.out b/tests/core/test_dlfcn_self.out
new file mode 100644
index 00000000..4ca9456b
--- /dev/null
+++ b/tests/core/test_dlfcn_self.out
@@ -0,0 +1,2 @@
+123
+123 \ No newline at end of file
diff --git a/tests/core/test_dlmalloc_partial_2.in b/tests/core/test_dlmalloc_partial_2.in
new file mode 100644
index 00000000..1e16657e
--- /dev/null
+++ b/tests/core/test_dlmalloc_partial_2.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <stdlib.h>
+void *malloc(size_t size) { return (void *)123; }
+int main() {
+ void *x = malloc(10);
+ printf("got %p\n", x);
+ free(x);
+ printf("freed the faker\n");
+ return 1;
+}
diff --git a/tests/core/test_dlmalloc_partial_2.out b/tests/core/test_dlmalloc_partial_2.out
new file mode 100644
index 00000000..5512c7a8
--- /dev/null
+++ b/tests/core/test_dlmalloc_partial_2.out
@@ -0,0 +1,2 @@
+got 0x7b
+freed \ No newline at end of file
diff --git a/tests/core/test_double_i64_conversion.in b/tests/core/test_double_i64_conversion.in
new file mode 100644
index 00000000..4033e211
--- /dev/null
+++ b/tests/core/test_double_i64_conversion.in
@@ -0,0 +1,69 @@
+#include <cassert>
+#include <inttypes.h>
+#include <stdio.h>
+
+__attribute((noinline)) bool eq(double d, int64_t i) {
+ int64_t i2 = (int64_t)d;
+ if (i != i2) {
+ printf("%.20g converted to int64 returns %lld, not %lld as expected!\n", d,
+ i2, i);
+ }
+ return i == i2;
+}
+
+int main() {
+ assert(eq(0.0, 0));
+ assert(eq(-0.0, 0));
+ assert(eq(0.1, 0));
+ assert(eq(-0.1, 0));
+ assert(eq(0.6, 0));
+ assert(eq(-0.6, 0));
+ assert(eq(1.0, 1));
+ assert(eq(-1.0, -1));
+ assert(eq(1.1, 1));
+ assert(eq(-1.1, -1));
+ assert(eq(1.6, 1));
+ assert(eq(-1.6, -1));
+ assert(eq(4294967295.0, 4294967295LL));
+ assert(eq(4294967295.5, 4294967295LL));
+ assert(eq(4294967296.0, 4294967296LL));
+ assert(eq(4294967296.5, 4294967296LL));
+ assert(eq(14294967295.0, 14294967295LL));
+ assert(eq(14294967295.5, 14294967295LL));
+ assert(eq(14294967296.0, 14294967296LL));
+ assert(eq(14294967296.5, 14294967296LL));
+ assert(eq(-4294967295.0, -4294967295LL));
+ assert(eq(-4294967295.5, -4294967295LL));
+ assert(eq(-4294967296.0, -4294967296LL));
+ assert(eq(-4294967296.5, -4294967296LL));
+ assert(eq(-14294967295.0, -14294967295LL));
+ assert(eq(-14294967295.5, -14294967295LL));
+ assert(eq(-14294967296.0, -14294967296LL));
+ assert(eq(-14294967296.5, -14294967296LL));
+
+ assert(eq(4294967295.3, 4294967295LL));
+ assert(eq(4294967296.3, 4294967296LL));
+ assert(eq(14294967295.3, 14294967295LL));
+ assert(eq(14294967296.3, 14294967296LL));
+ assert(eq(-4294967295.3, -4294967295LL));
+ assert(eq(-4294967296.3, -4294967296LL));
+ assert(eq(-14294967295.3, -14294967295LL));
+ assert(eq(-14294967296.3, -14294967296LL));
+
+ assert(eq(4294967295.8, 4294967295LL));
+ assert(eq(4294967296.8, 4294967296LL));
+ assert(eq(14294967295.8, 14294967295LL));
+ assert(eq(14294967296.8, 14294967296LL));
+ assert(eq(-4294967295.8, -4294967295LL));
+ assert(eq(-4294967296.8, -4294967296LL));
+ assert(eq(-14294967295.8, -14294967295LL));
+ assert(eq(-14294967296.8, -14294967296LL));
+
+ // The following number is the largest double such that all integers smaller
+ // than this can exactly be represented in a double.
+ assert(eq(9007199254740992.0, 9007199254740992LL /* == 2^53 */));
+ assert(eq(-9007199254740992.0, -9007199254740992LL /* == -2^53 */));
+
+ printf("OK!\n");
+ return 0;
+}
diff --git a/tests/core/test_double_i64_conversion.out b/tests/core/test_double_i64_conversion.out
new file mode 100644
index 00000000..d6406617
--- /dev/null
+++ b/tests/core/test_double_i64_conversion.out
@@ -0,0 +1 @@
+OK!
diff --git a/tests/core/test_dynamic_cast.in b/tests/core/test_dynamic_cast.in
new file mode 100644
index 00000000..1752573c
--- /dev/null
+++ b/tests/core/test_dynamic_cast.in
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+struct Support {
+ virtual void f() { printf("f()\n"); }
+};
+
+struct Derived : Support {};
+
+int main() {
+ Support* p = new Derived;
+ dynamic_cast<Derived*>(p)->f();
+}
diff --git a/tests/core/test_dynamic_cast.out b/tests/core/test_dynamic_cast.out
new file mode 100644
index 00000000..a19096b5
--- /dev/null
+++ b/tests/core/test_dynamic_cast.out
@@ -0,0 +1 @@
+f()
diff --git a/tests/core/test_dynamic_cast_2.in b/tests/core/test_dynamic_cast_2.in
new file mode 100644
index 00000000..634ff5c2
--- /dev/null
+++ b/tests/core/test_dynamic_cast_2.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <typeinfo>
+
+class Class {};
+
+int main() {
+ const Class* dp = dynamic_cast<const Class*>(&typeid(Class));
+ // should return dp == NULL,
+ printf("pointer: %p\n", dp);
+}
diff --git a/tests/core/test_dynamic_cast_2.out b/tests/core/test_dynamic_cast_2.out
new file mode 100644
index 00000000..be38bbcc
--- /dev/null
+++ b/tests/core/test_dynamic_cast_2.out
@@ -0,0 +1 @@
+pointer: (nil) \ No newline at end of file
diff --git a/tests/core/test_dynamic_cast_b.in b/tests/core/test_dynamic_cast_b.in
new file mode 100644
index 00000000..77981035
--- /dev/null
+++ b/tests/core/test_dynamic_cast_b.in
@@ -0,0 +1,31 @@
+#include <stdio.h>
+
+class CBase {
+ virtual void dummy() {}
+};
+class CDerived : public CBase {
+ int a;
+};
+class CDerivedest : public CDerived {
+ float b;
+};
+
+int main() {
+ CBase *pa = new CBase;
+ CBase *pb = new CDerived;
+ CBase *pc = new CDerivedest;
+
+ printf("a1: %d\n", dynamic_cast<CDerivedest *>(pa) != NULL);
+ printf("a2: %d\n", dynamic_cast<CDerived *>(pa) != NULL);
+ printf("a3: %d\n", dynamic_cast<CBase *>(pa) != NULL);
+
+ printf("b1: %d\n", dynamic_cast<CDerivedest *>(pb) != NULL);
+ printf("b2: %d\n", dynamic_cast<CDerived *>(pb) != NULL);
+ printf("b3: %d\n", dynamic_cast<CBase *>(pb) != NULL);
+
+ printf("c1: %d\n", dynamic_cast<CDerivedest *>(pc) != NULL);
+ printf("c2: %d\n", dynamic_cast<CDerived *>(pc) != NULL);
+ printf("c3: %d\n", dynamic_cast<CBase *>(pc) != NULL);
+
+ return 0;
+}
diff --git a/tests/core/test_dynamic_cast_b.out b/tests/core/test_dynamic_cast_b.out
new file mode 100644
index 00000000..090390e8
--- /dev/null
+++ b/tests/core/test_dynamic_cast_b.out
@@ -0,0 +1,9 @@
+a1: 0
+a2: 0
+a3: 1
+b1: 0
+b2: 1
+b3: 1
+c1: 1
+c2: 1
+c3: 1
diff --git a/tests/core/test_emptyclass.in b/tests/core/test_emptyclass.in
new file mode 100644
index 00000000..370cacf5
--- /dev/null
+++ b/tests/core/test_emptyclass.in
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+struct Randomized {
+ Randomized(int x) { printf("*zzcheezzz*\n"); }
+};
+
+int main(int argc, const char *argv[]) {
+ new Randomized(55);
+
+ return 0;
+}
diff --git a/tests/core/test_emptyclass.out b/tests/core/test_emptyclass.out
new file mode 100644
index 00000000..1be15e15
--- /dev/null
+++ b/tests/core/test_emptyclass.out
@@ -0,0 +1 @@
+*zzcheezzz* \ No newline at end of file
diff --git a/tests/core/test_emscripten_api.in b/tests/core/test_emscripten_api.in
new file mode 100644
index 00000000..7ece877f
--- /dev/null
+++ b/tests/core/test_emscripten_api.in
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include "emscripten.h"
+
+extern "C" {
+void save_me_aimee() { printf("mann\n"); }
+}
+
+int main() {
+ // EMSCRIPTEN_COMMENT("hello from the source");
+ emscripten_run_script("Module.print('hello world' + '!')");
+ printf("*%d*\n", emscripten_run_script_int("5*20"));
+ printf("*%s*\n", emscripten_run_script_string("'five'+'six'"));
+ emscripten_run_script("Module['_save_me_aimee']()");
+ return 0;
+}
diff --git a/tests/core/test_emscripten_api.out b/tests/core/test_emscripten_api.out
new file mode 100644
index 00000000..c0807cf1
--- /dev/null
+++ b/tests/core/test_emscripten_api.out
@@ -0,0 +1,4 @@
+hello world!
+*100*
+*fivesix*
+mann
diff --git a/tests/core/test_erf.in b/tests/core/test_erf.in
new file mode 100644
index 00000000..bd14b14f
--- /dev/null
+++ b/tests/core/test_erf.in
@@ -0,0 +1,7 @@
+#include <math.h>
+#include <stdio.h>
+int main() {
+ printf("%1.6f, %1.6f, %1.6f, %1.6f, %1.6f, %1.6f\n", erf(1.0), erf(3.0),
+ erf(-1.0), erfc(1.0), erfc(3.0), erfc(-1.5));
+ return 0;
+}
diff --git a/tests/core/test_erf.out b/tests/core/test_erf.out
new file mode 100644
index 00000000..3b48202f
--- /dev/null
+++ b/tests/core/test_erf.out
@@ -0,0 +1 @@
+0.842701, 0.999978, -0.842701, 0.157299, 0.000022, 1.966105 \ No newline at end of file
diff --git a/tests/core/test_errar.in b/tests/core/test_errar.in
new file mode 100644
index 00000000..9fda2099
--- /dev/null
+++ b/tests/core/test_errar.in
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+int main() {
+ char* err;
+ char buffer[200];
+
+ err = strerror(EDOM);
+ strerror_r(EWOULDBLOCK, buffer, 200);
+ printf("<%s>\n", err);
+ printf("<%s>\n", buffer);
+
+ printf("<%d>\n", strerror_r(EWOULDBLOCK, buffer, 0));
+ errno = 123;
+ printf("<%d>\n", errno);
+
+ return 0;
+}
diff --git a/tests/core/test_errar.out b/tests/core/test_errar.out
new file mode 100644
index 00000000..2a042eb1
--- /dev/null
+++ b/tests/core/test_errar.out
@@ -0,0 +1,4 @@
+<Math arg out of domain of func>
+<No more processes>
+<34>
+<123>
diff --git a/tests/core/test_exception_2.in b/tests/core/test_exception_2.in
new file mode 100644
index 00000000..2eae3198
--- /dev/null
+++ b/tests/core/test_exception_2.in
@@ -0,0 +1,18 @@
+#include <stdexcept>
+#include <stdio.h>
+
+typedef void (*FuncPtr)();
+
+void ThrowException() { throw std::runtime_error("catch me!"); }
+
+FuncPtr ptr = ThrowException;
+
+int main() {
+ try {
+ ptr();
+ }
+ catch (...) {
+ printf("Exception caught successfully!\n");
+ }
+ return 0;
+}
diff --git a/tests/core/test_exception_2.out b/tests/core/test_exception_2.out
new file mode 100644
index 00000000..aa89c67d
--- /dev/null
+++ b/tests/core/test_exception_2.out
@@ -0,0 +1 @@
+Exception caught successfully! \ No newline at end of file
diff --git a/tests/core/test_fakestat.in b/tests/core/test_fakestat.in
new file mode 100644
index 00000000..d1dbed29
--- /dev/null
+++ b/tests/core/test_fakestat.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+struct stat {
+ int x, y;
+};
+int main() {
+ stat s;
+ s.x = 10;
+ s.y = 22;
+ printf("*%d,%d*\n", s.x, s.y);
+}
diff --git a/tests/core/test_fakestat.out b/tests/core/test_fakestat.out
new file mode 100644
index 00000000..fbb3ab3c
--- /dev/null
+++ b/tests/core/test_fakestat.out
@@ -0,0 +1 @@
+*10,22* \ No newline at end of file
diff --git a/tests/core/test_fast_math.in b/tests/core/test_fast_math.in
new file mode 100644
index 00000000..e3b283aa
--- /dev/null
+++ b/tests/core/test_fast_math.in
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ char* endptr;
+ --argc, ++argv;
+ double total = 0.0;
+ for (; argc; argc--, argv++) {
+ total += strtod(*argv, &endptr);
+ }
+ printf("total: %g\n", total);
+ return 0;
+}
diff --git a/tests/core/test_fast_math.out b/tests/core/test_fast_math.out
new file mode 100644
index 00000000..d1bb5700
--- /dev/null
+++ b/tests/core/test_fast_math.out
@@ -0,0 +1 @@
+total: 19 \ No newline at end of file
diff --git a/tests/core/test_fcvt.in b/tests/core/test_fcvt.in
new file mode 100644
index 00000000..2e3fdbc6
--- /dev/null
+++ b/tests/core/test_fcvt.in
@@ -0,0 +1,12 @@
+/* This example borrowed from MSDN documentation */#include <stdlib.h>
+#include <stdio.h>
+
+int main() {
+ int decimal, sign;
+ char *buffer;
+ double source = 3.1415926535;
+
+ buffer = fcvt(source, 7, &decimal, &sign);
+ printf("source: %2.10f buffer: '%s' decimal: %d sign: %d\n", source,
+ buffer, decimal, sign);
+}
diff --git a/tests/core/test_fcvt.out b/tests/core/test_fcvt.out
new file mode 100644
index 00000000..835f34e7
--- /dev/null
+++ b/tests/core/test_fcvt.out
@@ -0,0 +1 @@
+source: 3.1415926535 buffer: '31415927' decimal: 1 sign: 0 \ No newline at end of file
diff --git a/tests/core/test_flexarray_struct.in b/tests/core/test_flexarray_struct.in
new file mode 100644
index 00000000..cb83a7e5
--- /dev/null
+++ b/tests/core/test_flexarray_struct.in
@@ -0,0 +1,21 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef struct {
+ uint16_t length;
+ struct {
+ int32_t int32;
+ } value[];
+} Tuple;
+
+int main() {
+ Tuple T[10];
+ Tuple *t = &T[0];
+
+ t->length = 4;
+ t->value->int32 = 100;
+
+ printf("(%d, %d)\n", t->length, t->value->int32);
+ return 0;
+}
diff --git a/tests/core/test_flexarray_struct.out b/tests/core/test_flexarray_struct.out
new file mode 100644
index 00000000..b6f53a0d
--- /dev/null
+++ b/tests/core/test_flexarray_struct.out
@@ -0,0 +1 @@
+(4, 100) \ No newline at end of file
diff --git a/tests/core/test_float32_precise.in b/tests/core/test_float32_precise.in
new file mode 100644
index 00000000..969f5ed6
--- /dev/null
+++ b/tests/core/test_float32_precise.in
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ float x = 1.23456789123456789;
+ float y = 5.20456089123406709;
+ while (argc > 10 || argc % 19 == 15) {
+ // confuse optimizer
+ x /= y;
+ y = 2 * y - 1;
+ argc--;
+ }
+ x = x - y;
+ y = 3 * y - x / 2;
+ x = x * y;
+ y += 0.000000000123123123123;
+ x -= y / 7.654;
+ printf("\n%.20f, %.20f\n", x, y);
+ return 0;
+}
diff --git a/tests/core/test_float32_precise.out b/tests/core/test_float32_precise.out
new file mode 100644
index 00000000..f5eeb505
--- /dev/null
+++ b/tests/core/test_float32_precise.out
@@ -0,0 +1,2 @@
+
+-72.16590881347656250000, 17.59867858886718750000
diff --git a/tests/core/test_floatvars.in b/tests/core/test_floatvars.in
new file mode 100644
index 00000000..b6c94c82
--- /dev/null
+++ b/tests/core/test_floatvars.in
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+// headers test, see issue #1013
+#include <cfloat>
+#include <cmath>
+
+int main(int argc, char **argv) {
+ float x = 1.234, y = 3.5, q = 0.00000001;
+ y *= 3;
+ int z = x < y;
+ printf("*%d,%d,%.1f,%d,%.4f,%.2f*\n", z, int(y), y, (int)x, x, q);
+
+ printf("%.2f, %.2f, %.2f, %.2f\n", fmin(0.5, 3.3), fmin(NAN, 3.3),
+ fmax(0.5, 3.3), fmax(NAN, 3.3));
+
+ printf("small: %.10f\n", argc * 0.000001);
+
+ /*
+ // Rounding behavior
+ float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
+ double ds[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
+ for (int i = 0; i < 6; i++)
+ printf("*int(%.2f)=%d,%d*\n", fs[i], int(fs[i]), int(ds[i]));
+ */
+
+ return 0;
+}
diff --git a/tests/core/test_floatvars.out b/tests/core/test_floatvars.out
new file mode 100644
index 00000000..57635092
--- /dev/null
+++ b/tests/core/test_floatvars.out
@@ -0,0 +1,3 @@
+*1,10,10.5,1,1.2340,0.00*
+0.50, 3.30, 3.30, 3.30
+small: 0.0000010000
diff --git a/tests/core/test_frexp.in b/tests/core/test_frexp.in
new file mode 100644
index 00000000..fba3231f
--- /dev/null
+++ b/tests/core/test_frexp.in
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <math.h>
+#include <assert.h>
+
+static const double tol = 1e-16;
+
+void test_value(double value) {
+ int exponent;
+ double x = frexp(value, &exponent);
+ double expected = x * pow(2.0, exponent);
+
+ printf("%f=%f*2^%d\n", value, x, exponent);
+
+ assert(fabs(expected - value) < tol);
+ assert(x == 0 || (fabs(x) >= 5e-1 && fabs(x) < 1)); // x has a magnitude in
+ // the interval [1/2, 1)
+}
+
+int main() {
+ test_value(0);
+ test_value(100.1);
+ test_value(-100.1);
+ test_value(.5);
+ test_value(-.5);
+ test_value(1 - 1e-16);
+ test_value(-(1 - 1e-16));
+
+ return 0;
+}
diff --git a/tests/core/test_frexp.out b/tests/core/test_frexp.out
new file mode 100644
index 00000000..341b790e
--- /dev/null
+++ b/tests/core/test_frexp.out
@@ -0,0 +1,7 @@
+0.000000=0.000000*2^0
+100.100000=0.782031*2^7
+-100.100000=-0.782031*2^7
+0.500000=0.500000*2^0
+-0.500000=-0.500000*2^0
+1.000000=1.000000*2^0
+-1.000000=-1.000000*2^0 \ No newline at end of file
diff --git a/tests/core/test_funcptr.in b/tests/core/test_funcptr.in
new file mode 100644
index 00000000..23813b33
--- /dev/null
+++ b/tests/core/test_funcptr.in
@@ -0,0 +1,33 @@
+#include <stdio.h>
+int calc1() { return 26; }
+int calc2() { return 90; }
+typedef int (*fp_t)();
+
+fp_t globally1 = calc1;
+fp_t globally2 = calc2;
+
+int nothing(const char *str) { return 0; }
+
+int main() {
+ fp_t fp = calc1;
+ void *vp = (void *)fp;
+ fp_t fpb = (fp_t)vp;
+ fp_t fp2 = calc2;
+ void *vp2 = (void *)fp2;
+ fp_t fpb2 = (fp_t)vp2;
+ printf("*%d,%d,%d,%d,%d,%d*\n", fp(), fpb(), fp2(), fpb2(), globally1(),
+ globally2());
+
+ fp_t t = calc1;
+ printf("*%d,%d", t == calc1, t == calc2);
+ t = calc2;
+ printf(",%d,%d*\n", t == calc1, t == calc2);
+
+ int (*other)(const char * str);
+ other = nothing;
+ other("*hello!*");
+ other = puts;
+ other("*goodbye!*");
+
+ return 0;
+}
diff --git a/tests/core/test_funcptr.out b/tests/core/test_funcptr.out
new file mode 100644
index 00000000..d6d3366a
--- /dev/null
+++ b/tests/core/test_funcptr.out
@@ -0,0 +1,3 @@
+*26,26,90,90,26,90*
+*1,0,0,1*
+*goodbye!* \ No newline at end of file
diff --git a/tests/core/test_funcptr_namecollide.in b/tests/core/test_funcptr_namecollide.in
new file mode 100644
index 00000000..dc5cfaba
--- /dev/null
+++ b/tests/core/test_funcptr_namecollide.in
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+void do_call(void (*puts)(const char *), const char *str);
+
+void do_print(const char *str) {
+ if (!str) do_call(NULL, "delusion");
+ if ((int)str == -1) do_print(str + 10);
+ puts("====");
+ puts(str);
+ puts("====");
+}
+
+void do_call(void (*puts)(const char *), const char *str) {
+ if (!str) do_print("confusion");
+ if ((int)str == -1) do_call(NULL, str - 10);
+ (*puts)(str);
+}
+
+int main(int argc, char **argv) {
+ for (int i = 0; i < argc; i++) {
+ do_call(i != 10 ? do_print : NULL, i != 15 ? "waka waka" : NULL);
+ }
+ return 0;
+}
diff --git a/tests/core/test_funcptr_namecollide.out b/tests/core/test_funcptr_namecollide.out
new file mode 100644
index 00000000..360b24da
--- /dev/null
+++ b/tests/core/test_funcptr_namecollide.out
@@ -0,0 +1 @@
+waka \ No newline at end of file
diff --git a/tests/core/test_funcptrfunc.in b/tests/core/test_funcptrfunc.in
new file mode 100644
index 00000000..c6487b88
--- /dev/null
+++ b/tests/core/test_funcptrfunc.in
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+typedef void (*funcptr)(int, int);
+typedef funcptr (*funcptrfunc)(int);
+
+funcptr __attribute__((noinline)) getIt(int x) { return (funcptr)x; }
+
+int main(int argc, char **argv) {
+ funcptrfunc fpf = argc < 100 ? getIt : NULL;
+ printf("*%p*\n", fpf(argc));
+ return 0;
+}
diff --git a/tests/core/test_funcptrfunc.out b/tests/core/test_funcptrfunc.out
new file mode 100644
index 00000000..0d1299f6
--- /dev/null
+++ b/tests/core/test_funcptrfunc.out
@@ -0,0 +1 @@
+*0x1* \ No newline at end of file
diff --git a/tests/core/test_funcs.in b/tests/core/test_funcs.in
new file mode 100644
index 00000000..3619faec
--- /dev/null
+++ b/tests/core/test_funcs.in
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int funcy(int x) { return x * 9; }
+int main() {
+ printf("*%d,%d*\n", funcy(8), funcy(10));
+ return 0;
+}
diff --git a/tests/core/test_funcs.out b/tests/core/test_funcs.out
new file mode 100644
index 00000000..f58def9a
--- /dev/null
+++ b/tests/core/test_funcs.out
@@ -0,0 +1 @@
+*72,90* \ No newline at end of file
diff --git a/tests/core/test_functionpointer_libfunc_varargs.in b/tests/core/test_functionpointer_libfunc_varargs.in
new file mode 100644
index 00000000..69faefa2
--- /dev/null
+++ b/tests/core/test_functionpointer_libfunc_varargs.in
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <fcntl.h>
+typedef int (*fp_t)(int, int, ...);
+int main(int argc, char **argv) {
+ fp_t fp = &fcntl;
+ if (argc == 1337) fp = (fp_t) & main;
+ (*fp)(0, 10);
+ (*fp)(0, 10, 5);
+ printf("waka\n");
+ return 0;
+}
diff --git a/tests/core/test_functionpointer_libfunc_varargs.out b/tests/core/test_functionpointer_libfunc_varargs.out
new file mode 100644
index 00000000..360b24da
--- /dev/null
+++ b/tests/core/test_functionpointer_libfunc_varargs.out
@@ -0,0 +1 @@
+waka \ No newline at end of file
diff --git a/tests/core/test_fwrite_0.in b/tests/core/test_fwrite_0.in
new file mode 100644
index 00000000..990ab250
--- /dev/null
+++ b/tests/core/test_fwrite_0.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ FILE *fh;
+
+ fh = fopen("a.txt", "wb");
+ if (!fh) exit(1);
+ fclose(fh);
+
+ fh = fopen("a.txt", "rb");
+ if (!fh) exit(1);
+
+ char data[] = "foobar";
+ size_t written = fwrite(data, 1, sizeof(data), fh);
+
+ printf("written=%zu\n", written);
+}
diff --git a/tests/core/test_fwrite_0.out b/tests/core/test_fwrite_0.out
new file mode 100644
index 00000000..d96592d1
--- /dev/null
+++ b/tests/core/test_fwrite_0.out
@@ -0,0 +1 @@
+written=0 \ No newline at end of file
diff --git a/tests/core/test_gc.in b/tests/core/test_gc.in
new file mode 100644
index 00000000..55d98e60
--- /dev/null
+++ b/tests/core/test_gc.in
@@ -0,0 +1,107 @@
+#include <stdio.h>
+#include <gc.h>
+#include <assert.h>
+
+void *global;
+
+void finalizer(void *ptr, void *arg) {
+ printf("finalizing %d (global == %d)\n", (int)arg, ptr == global);
+}
+
+void finalizer2(void *ptr, void *arg) {
+ printf("finalizing2 %d (global == %d)\n", (int)arg, ptr == global);
+}
+
+int main() {
+ GC_INIT();
+
+ void *local, *local2, *local3, *local4, *local5, *local6;
+
+ // Hold on to global, drop locals
+
+ global = GC_MALLOC(1024); // rooted since in a static allocation
+ GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0);
+ printf("alloc %p\n", global);
+
+ local = GC_MALLOC(1024); // not rooted since stack is not scanned
+ GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void *)1, 0, 0);
+ printf("alloc %p\n", local);
+
+ assert((char *)local - (char *)global >= 1024 ||
+ (char *)global - (char *)local >= 1024);
+
+ local2 = GC_MALLOC(1024); // no finalizer
+ printf("alloc %p\n", local2);
+
+ local3 = GC_MALLOC(1024); // with finalizable2
+ GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer2, (void *)2, 0, 0);
+ printf("alloc %p\n", local);
+
+ local4 = GC_MALLOC(1024); // yet another
+ GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer2, (void *)3, 0, 0);
+ printf("alloc %p\n", local);
+
+ printf("basic test\n");
+
+ GC_FORCE_COLLECT();
+
+ printf("*\n");
+
+ GC_FREE(global); // force free will actually work
+
+ // scanning inside objects
+
+ global = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0);
+ local = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void *)1, 0, 0);
+ local2 = GC_MALLOC_ATOMIC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local2, finalizer, (void *)2, 0, 0);
+ local3 = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer, (void *)3, 0, 0);
+ local4 = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer, (void *)4, 0, 0);
+ local5 = GC_MALLOC_UNCOLLECTABLE(12);
+ // This should never trigger since local5 is uncollectable
+ GC_REGISTER_FINALIZER_NO_ORDER(local5, finalizer, (void *)5, 0, 0);
+
+ printf("heap size = %d\n", GC_get_heap_size());
+
+ local4 = GC_REALLOC(local4, 24);
+
+ printf("heap size = %d\n", GC_get_heap_size());
+
+ local6 = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local6, finalizer, (void *)6, 0, 0);
+ // This should be the same as a free
+ GC_REALLOC(local6, 0);
+
+ void **globalData = (void **)global;
+ globalData[0] = local;
+ globalData[1] = local2;
+
+ void **localData = (void **)local;
+ localData[0] = local3;
+
+ void **local2Data = (void **)local2;
+ local2Data[0] =
+ local4; // actually ignored, because local2 is atomic, so 4 is freeable
+
+ printf("object scan test test\n");
+
+ GC_FORCE_COLLECT();
+
+ printf("*\n");
+
+ GC_FREE(global); // force free will actually work
+
+ printf("*\n");
+
+ GC_FORCE_COLLECT();
+
+ printf(".\n");
+
+ global = 0;
+
+ return 0;
+}
diff --git a/tests/core/test_gc.out b/tests/core/test_gc.out
new file mode 100644
index 00000000..6ce8bff9
--- /dev/null
+++ b/tests/core/test_gc.out
@@ -0,0 +1,18 @@
+basic test
+finalizing 1 (global == 0)
+finalizing2 2 (global == 0)
+finalizing2 3 (global == 0)
+*
+finalizing 0 (global == 1)
+heap size = 72
+heap size = 84
+finalizing 6 (global == 0)
+object scan test test
+finalizing 4 (global == 0)
+*
+finalizing 0 (global == 1)
+*
+finalizing 1 (global == 0)
+finalizing 2 (global == 0)
+finalizing 3 (global == 0)
+.
diff --git a/tests/core/test_getgep.in b/tests/core/test_getgep.in
new file mode 100644
index 00000000..452942f9
--- /dev/null
+++ b/tests/core/test_getgep.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+struct {
+ int y[10];
+ int z[10];
+} commonblock;
+
+int main() {
+ for (int i = 0; i < 10; ++i) {
+ commonblock.y[i] = 1;
+ commonblock.z[i] = 2;
+ }
+ printf("*%d %d*\n", commonblock.y[0], commonblock.z[0]);
+ return 0;
+}
diff --git a/tests/core/test_getgep.out b/tests/core/test_getgep.out
new file mode 100644
index 00000000..a53d59ff
--- /dev/null
+++ b/tests/core/test_getgep.out
@@ -0,0 +1 @@
+*1 2* \ No newline at end of file
diff --git a/tests/core/test_getloadavg.in b/tests/core/test_getloadavg.in
new file mode 100644
index 00000000..c592985a
--- /dev/null
+++ b/tests/core/test_getloadavg.in
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ double load[5] = {42.13, 42.13, 42.13, 42.13, 42.13};
+ printf("ret: %d\n", getloadavg(load, 5));
+ printf("load[0]: %.3lf\n", load[0]);
+ printf("load[1]: %.3lf\n", load[1]);
+ printf("load[2]: %.3lf\n", load[2]);
+ printf("load[3]: %.3lf\n", load[3]);
+ printf("load[4]: %.3lf\n", load[4]);
+ return 0;
+}
diff --git a/tests/core/test_getloadavg.out b/tests/core/test_getloadavg.out
new file mode 100644
index 00000000..a7433f65
--- /dev/null
+++ b/tests/core/test_getloadavg.out
@@ -0,0 +1,6 @@
+ret: 3
+load[0]: 0.100
+load[1]: 0.100
+load[2]: 0.100
+load[3]: 42.130
+load[4]: 42.130
diff --git a/tests/core/test_getopt.in b/tests/core/test_getopt.in
new file mode 100644
index 00000000..6a678b79
--- /dev/null
+++ b/tests/core/test_getopt.in
@@ -0,0 +1,40 @@
+#pragma clang diagnostic ignored "-Winvalid-pp-token"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ int flags, opt;
+ int nsecs, tfnd;
+
+ nsecs = 0;
+ tfnd = 0;
+ flags = 0;
+ while ((opt = getopt(argc, argv, "nt:")) != -1) {
+ switch (opt) {
+ case 'n':
+ flags = 1;
+ break;
+ case 't':
+ nsecs = atoi(optarg);
+ tfnd = 1;
+ break;
+ default: /* '?' */
+ fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\n", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ printf("flags=%d; tfnd=%d; optind=%d\n", flags, tfnd, optind);
+
+ if (optind >= argc) {
+ fprintf(stderr, "Expected argument after options\n");
+ exit(EXIT_FAILURE);
+ }
+
+ printf("name argument = %s\n", argv[optind]);
+
+ /* Other code omitted */
+
+ exit(EXIT_SUCCESS);
+}
diff --git a/tests/core/test_getopt.out b/tests/core/test_getopt.out
new file mode 100644
index 00000000..d06da507
--- /dev/null
+++ b/tests/core/test_getopt.out
@@ -0,0 +1,2 @@
+flags=1; tfnd=1; optind=4
+name argument = foobar \ No newline at end of file
diff --git a/tests/core/test_getopt_long.in b/tests/core/test_getopt_long.in
new file mode 100644
index 00000000..18f19f2e
--- /dev/null
+++ b/tests/core/test_getopt_long.in
@@ -0,0 +1,73 @@
+#pragma clang diagnostic ignored "-Winvalid-pp-token"
+#pragma clang diagnostic ignored "-Wdeprecated-writable-strings"
+#include <stdio.h> /* for printf */
+#include <stdlib.h> /* for exit */
+#include <getopt.h>
+
+int main(int argc, char **argv) {
+ int c;
+ int digit_optind = 0;
+
+ while (1) {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] = {
+ {"add", required_argument, 0, 0},
+ {"append", no_argument, 0, 0},
+ {"delete", required_argument, 0, 0},
+ {"verbose", no_argument, 0, 0},
+ {"create", required_argument, 0, 'c'},
+ {"file", required_argument, 0, 0},
+ {0, 0, 0, 0}};
+
+ c = getopt_long(argc, argv, "abc:d:012", long_options, &option_index);
+ if (c == -1) break;
+
+ switch (c) {
+ case 0:
+ printf("option %s", long_options[option_index].name);
+ if (optarg) printf(" with arg %s", optarg);
+ printf("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf("option %c\n", c);
+ break;
+
+ case 'a':
+ printf("option a\n");
+ break;
+
+ case 'b':
+ printf("option b\n");
+ break;
+
+ case 'c':
+ printf("option c with value '%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf("option d with value '%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc) {
+ printf("non-option ARGV-elements: ");
+ while (optind < argc) printf("%s ", argv[optind++]);
+ printf("\n");
+ }
+
+ exit(EXIT_SUCCESS);
+}
diff --git a/tests/core/test_getopt_long.out b/tests/core/test_getopt_long.out
new file mode 100644
index 00000000..22a7bd52
--- /dev/null
+++ b/tests/core/test_getopt_long.out
@@ -0,0 +1,2 @@
+option file with arg foobar
+option b \ No newline at end of file
diff --git a/tests/core/test_globaldoubles.in b/tests/core/test_globaldoubles.in
new file mode 100644
index 00000000..9ccfb521
--- /dev/null
+++ b/tests/core/test_globaldoubles.in
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+double testVu, testVv, testWu, testWv;
+
+void Test(double _testVu, double _testVv, double _testWu, double _testWv) {
+ testVu = _testVu;
+ testVv = _testVv;
+ testWu = _testWu;
+ testWv = _testWv;
+ printf("BUG?\n");
+ printf("Display: Vu=%f Vv=%f Wu=%f Wv=%f\n", testVu, testVv, testWu,
+ testWv);
+}
+
+int main(void) {
+ double v1 = 465.1;
+ double v2 = 465.2;
+ double v3 = 160.3;
+ double v4 = 111.4;
+ Test(v1, v2, v3, v4);
+ return 0;
+}
diff --git a/tests/core/test_globaldoubles.out b/tests/core/test_globaldoubles.out
new file mode 100644
index 00000000..b47c9691
--- /dev/null
+++ b/tests/core/test_globaldoubles.out
@@ -0,0 +1,2 @@
+BUG?
+Display: Vu=465.100000 Vv=465.200000 Wu=160.300000 Wv=111.400000 \ No newline at end of file
diff --git a/tests/core/test_globals.in b/tests/core/test_globals.in
new file mode 100644
index 00000000..f972687a
--- /dev/null
+++ b/tests/core/test_globals.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+
+char cache[256], *next = cache;
+
+int main() {
+ cache[10] = 25;
+ next[20] = 51;
+ printf("*%d,%d*\n", next[10], cache[20]);
+ return 0;
+}
diff --git a/tests/core/test_globals.out b/tests/core/test_globals.out
new file mode 100644
index 00000000..2cb6768e
--- /dev/null
+++ b/tests/core/test_globals.out
@@ -0,0 +1 @@
+*25,51* \ No newline at end of file
diff --git a/tests/core/test_gmtime.in b/tests/core/test_gmtime.in
new file mode 100644
index 00000000..7b7227ba
--- /dev/null
+++ b/tests/core/test_gmtime.in
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <assert.h>
+
+int main(void) {
+ time_t t = time(NULL);
+ struct tm *ptm = gmtime(&t);
+ struct tm tmCurrent = *ptm;
+ int hour = tmCurrent.tm_hour;
+
+ t -= hour * 3600; // back to midnight
+ int yday = -1;
+ for (hour = 0; hour < 24; hour++) {
+ ptm = gmtime(&t);
+ // tm_yday must be constant all day...
+ printf("yday: %d, hour: %d\n", ptm->tm_yday, hour);
+ if (yday == -1)
+ yday = ptm->tm_yday;
+ else
+ assert(yday == ptm->tm_yday);
+ t += 3600; // add one hour
+ }
+ printf("ok!\n");
+ return (0);
+}
diff --git a/tests/core/test_gmtime.out b/tests/core/test_gmtime.out
new file mode 100644
index 00000000..e036282a
--- /dev/null
+++ b/tests/core/test_gmtime.out
@@ -0,0 +1 @@
+ok! \ No newline at end of file
diff --git a/tests/core/test_hello_world.in b/tests/core/test_hello_world.in
new file mode 100644
index 00000000..b1d9bbbc
--- /dev/null
+++ b/tests/core/test_hello_world.in
@@ -0,0 +1,5 @@
+#include <stdio.h>
+int main() {
+ printf("hello, world!\n");
+ return 0;
+}
diff --git a/tests/core/test_hello_world.out b/tests/core/test_hello_world.out
new file mode 100644
index 00000000..30f51a3f
--- /dev/null
+++ b/tests/core/test_hello_world.out
@@ -0,0 +1 @@
+hello, world! \ No newline at end of file
diff --git a/tests/core/test_i16_emcc_intrinsic.in b/tests/core/test_i16_emcc_intrinsic.in
new file mode 100644
index 00000000..a2aa27ee
--- /dev/null
+++ b/tests/core/test_i16_emcc_intrinsic.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+int test(unsigned short a, unsigned short b) {
+ unsigned short result = a;
+ result += b;
+ if (result < b) printf("C!");
+ return result;
+}
+
+int main(void) {
+ printf(",%d,", test(0, 0));
+ printf(",%d,", test(1, 1));
+ printf(",%d,", test(65535, 1));
+ printf(",%d,", test(1, 65535));
+ printf(",%d,", test(32768, 32767));
+ printf(",%d,", test(32768, 32768));
+ return 0;
+}
diff --git a/tests/core/test_i16_emcc_intrinsic.out b/tests/core/test_i16_emcc_intrinsic.out
new file mode 100644
index 00000000..35af1e0d
--- /dev/null
+++ b/tests/core/test_i16_emcc_intrinsic.out
@@ -0,0 +1 @@
+,0,,2,C!,0,C!,0,,65535,C!,0, \ No newline at end of file
diff --git a/tests/core/test_i32_mul_precise.in b/tests/core/test_i32_mul_precise.in
new file mode 100644
index 00000000..2e62b4ba
--- /dev/null
+++ b/tests/core/test_i32_mul_precise.in
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ unsigned long d1 = 0x847c9b5d;
+ unsigned long q = 0x549530e1;
+ if (argc > 1000) {
+ q += argc;
+ d1 -= argc;
+ } // confuse optimizer
+ printf("%lu\n", d1 * q);
+ return 0;
+}
diff --git a/tests/core/test_i32_mul_precise.out b/tests/core/test_i32_mul_precise.out
new file mode 100644
index 00000000..d46a5055
--- /dev/null
+++ b/tests/core/test_i32_mul_precise.out
@@ -0,0 +1 @@
+3217489085 \ No newline at end of file
diff --git a/tests/core/test_i32_mul_semiprecise.in b/tests/core/test_i32_mul_semiprecise.in
new file mode 100644
index 00000000..a93a69da
--- /dev/null
+++ b/tests/core/test_i32_mul_semiprecise.in
@@ -0,0 +1,26 @@
+#include <stdio.h>
+
+typedef unsigned int uint;
+
+// from cube2, zlib licensed
+
+#define N (624)
+#define M (397)
+#define K (0x9908B0DFU)
+
+static uint state[N];
+static int next = N;
+
+void seedMT(uint seed) {
+ state[0] = seed;
+ for (uint i = 1; i < N; i++) // if we do not do this precisely, at least we
+ // should coerce to int immediately, not wait
+ state[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i;
+ next = 0;
+}
+
+int main() {
+ seedMT(5497);
+ for (int i = 0; i < 10; i++) printf("%d: %u\n", i, state[i]);
+ return 0;
+}
diff --git a/tests/core/test_i32_mul_semiprecise.out b/tests/core/test_i32_mul_semiprecise.out
new file mode 100644
index 00000000..261bf9a9
--- /dev/null
+++ b/tests/core/test_i32_mul_semiprecise.out
@@ -0,0 +1,10 @@
+0: 5497
+1: 2916432318
+2: 2502517762
+3: 3151524867
+4: 2323729668
+5: 2053478917
+6: 2409490438
+7: 848473607
+8: 691103752
+9: 3915535113
diff --git a/tests/core/test_i64_7z.in b/tests/core/test_i64_7z.in
new file mode 100644
index 00000000..c15bfd78
--- /dev/null
+++ b/tests/core/test_i64_7z.in
@@ -0,0 +1,14 @@
+#include <stdint.h>
+#include <stdio.h>
+uint64_t a, b;
+int main(int argc, char *argv[]) {
+ a = argc;
+ b = argv[1][0];
+ printf("%d,%d\n", a, b);
+ if (a > a + b || a > a + b + 1) {
+ printf("one %lld, %lld", a, b);
+ return 0;
+ }
+ printf("zero %lld, %lld", a, b);
+ return 0;
+}
diff --git a/tests/core/test_i64_7z.out b/tests/core/test_i64_7z.out
new file mode 100644
index 00000000..3e9d35a4
--- /dev/null
+++ b/tests/core/test_i64_7z.out
@@ -0,0 +1 @@
+zero 2, 104 \ No newline at end of file
diff --git a/tests/core/test_i64_b.in b/tests/core/test_i64_b.in
new file mode 100644
index 00000000..1cd87104
--- /dev/null
+++ b/tests/core/test_i64_b.in
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <sys/time.h>
+
+typedef long long int64;
+
+#define PRMJ_USEC_PER_SEC 1000000L
+
+int main(int argc, char* argv[]) {
+ int64 sec = 1329409675 + argc;
+ int64 usec = 2329509675;
+ int64 mul = int64(sec) * PRMJ_USEC_PER_SEC;
+ int64 add = mul + int64(usec);
+ int add_low = add;
+ int add_high = add >> 32;
+ printf("*%lld,%lld,%u,%u*\n", mul, add, add_low, add_high);
+ int64 x = sec + (usec << 25);
+ x >>= argc * 3;
+ printf("*%llu*\n", x);
+ return 0;
+}
diff --git a/tests/core/test_i64_b.out b/tests/core/test_i64_b.out
new file mode 100644
index 00000000..70d0a95c
--- /dev/null
+++ b/tests/core/test_i64_b.out
@@ -0,0 +1,2 @@
+*1329409676000000,1329412005509675,3663280683,309527*
+*9770671914067409*
diff --git a/tests/core/test_i64_cmp.in b/tests/core/test_i64_cmp.in
new file mode 100644
index 00000000..b9cadd4a
--- /dev/null
+++ b/tests/core/test_i64_cmp.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+typedef long long int64;
+
+bool compare(int64 val) { return val == -12; }
+
+bool compare2(int64 val) { return val < -12; }
+
+int main(int argc, char* argv[]) {
+ printf("*%d,%d,%d,%d,%d,%d*\n", argc, compare(argc - 1 - 12),
+ compare(1000 + argc), compare2(argc - 1 - 10), compare2(argc - 1 - 14),
+ compare2(argc + 1000));
+ return 0;
+}
diff --git a/tests/core/test_i64_cmp.out b/tests/core/test_i64_cmp.out
new file mode 100644
index 00000000..6474e7f5
--- /dev/null
+++ b/tests/core/test_i64_cmp.out
@@ -0,0 +1 @@
+*1,1,0,0,1,0*
diff --git a/tests/core/test_i64_cmp2.in b/tests/core/test_i64_cmp2.in
new file mode 100644
index 00000000..8985e5a8
--- /dev/null
+++ b/tests/core/test_i64_cmp2.in
@@ -0,0 +1,28 @@
+#include <inttypes.h>
+#include <stdio.h>
+
+typedef int32_t INT32;
+typedef int64_t INT64;
+typedef uint8_t UINT8;
+
+void interface_clock_changed() {
+ UINT8 m_divshift;
+ INT32 m_divisor;
+
+ // INT64 attos = m_attoseconds_per_cycle;
+ INT64 attos = 279365114840;
+ m_divshift = 0;
+ while (attos >= (1UL << 31)) {
+ m_divshift++;
+ printf("m_divshift is %i, on %Ld >?= %lu\n", m_divshift, attos, 1UL << 31);
+ attos >>= 1;
+ }
+ m_divisor = attos;
+
+ printf("m_divisor is %i\n", m_divisor);
+}
+
+int main() {
+ interface_clock_changed();
+ return 0;
+}
diff --git a/tests/core/test_i64_cmp2.out b/tests/core/test_i64_cmp2.out
new file mode 100644
index 00000000..893bb826
--- /dev/null
+++ b/tests/core/test_i64_cmp2.out
@@ -0,0 +1,9 @@
+m_divshift is 1, on 279365114840 >?= 2147483648
+m_divshift is 2, on 139682557420 >?= 2147483648
+m_divshift is 3, on 69841278710 >?= 2147483648
+m_divshift is 4, on 34920639355 >?= 2147483648
+m_divshift is 5, on 17460319677 >?= 2147483648
+m_divshift is 6, on 8730159838 >?= 2147483648
+m_divshift is 7, on 4365079919 >?= 2147483648
+m_divshift is 8, on 2182539959 >?= 2147483648
+m_divisor is 1091269979
diff --git a/tests/core/test_i64_double.in b/tests/core/test_i64_double.in
new file mode 100644
index 00000000..2b524971
--- /dev/null
+++ b/tests/core/test_i64_double.in
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+typedef long long int64;
+#define JSDOUBLE_HI32_SIGNBIT 0x80000000
+
+bool JSDOUBLE_IS_NEGZERO(double d) {
+ union {
+ struct {
+ unsigned int lo, hi;
+ } s;
+ double d;
+ } x;
+ if (d != 0) return false;
+ x.d = d;
+ return (x.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0;
+}
+
+bool JSINT64_IS_NEGZERO(int64 l) {
+ union {
+ int64 i;
+ double d;
+ } x;
+ if (l != 0) return false;
+ x.i = l;
+ return x.d == -0;
+}
+
+int main(int argc, char* argv[]) {
+ printf("*%d,%d,%d,%d*\n", JSDOUBLE_IS_NEGZERO(0), JSDOUBLE_IS_NEGZERO(-0),
+ JSDOUBLE_IS_NEGZERO(-1), JSDOUBLE_IS_NEGZERO(+1));
+ printf("*%d,%d,%d,%d*\n", JSINT64_IS_NEGZERO(0), JSINT64_IS_NEGZERO(-0),
+ JSINT64_IS_NEGZERO(-1), JSINT64_IS_NEGZERO(+1));
+ return 0;
+}
diff --git a/tests/core/test_i64_double.out b/tests/core/test_i64_double.out
new file mode 100644
index 00000000..cfb98703
--- /dev/null
+++ b/tests/core/test_i64_double.out
@@ -0,0 +1,2 @@
+*0,0,0,0*
+*1,1,0,0*
diff --git a/tests/core/test_i64_i16.in b/tests/core/test_i64_i16.in
new file mode 100644
index 00000000..81d4a7bd
--- /dev/null
+++ b/tests/core/test_i64_i16.in
@@ -0,0 +1,10 @@
+#include <stdint.h>
+#include <stdio.h>
+int main(int argc, char** argv) {
+ int y = -133;
+ int64_t x = ((int64_t)((short)(y))) * (100 + argc);
+ if (x > 0)
+ printf(">0\n");
+ else
+ printf("<=0\n");
+}
diff --git a/tests/core/test_i64_i16.out b/tests/core/test_i64_i16.out
new file mode 100644
index 00000000..01adb429
--- /dev/null
+++ b/tests/core/test_i64_i16.out
@@ -0,0 +1 @@
+<=0 \ No newline at end of file
diff --git a/tests/core/test_i64_llabs.in b/tests/core/test_i64_llabs.in
new file mode 100644
index 00000000..5d10bee0
--- /dev/null
+++ b/tests/core/test_i64_llabs.in
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+ printf("%lld,%lld\n", llabs(-576460752303423489), llabs(576460752303423489));
+ return 0;
+}
diff --git a/tests/core/test_i64_llabs.out b/tests/core/test_i64_llabs.out
new file mode 100644
index 00000000..e1ec5062
--- /dev/null
+++ b/tests/core/test_i64_llabs.out
@@ -0,0 +1 @@
+576460752303423489,576460752303423489 \ No newline at end of file
diff --git a/tests/core/test_i64_qdouble.in b/tests/core/test_i64_qdouble.in
new file mode 100644
index 00000000..db47afa6
--- /dev/null
+++ b/tests/core/test_i64_qdouble.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+typedef long long qint64; /* 64 bit signed */
+typedef double qreal;
+
+int main(int argc, char **argv) {
+ qreal c = 111;
+ qint64 d = -111 + (argc - 1);
+ c += d;
+ if (c < -1 || c > 1) {
+ printf("Failed!\n");
+ } else {
+ printf("Succeeded!\n");
+ }
+};
diff --git a/tests/core/test_i64_qdouble.out b/tests/core/test_i64_qdouble.out
new file mode 100644
index 00000000..0b9e5e9e
--- /dev/null
+++ b/tests/core/test_i64_qdouble.out
@@ -0,0 +1 @@
+Succeeded! \ No newline at end of file
diff --git a/tests/core/test_i64_umul.in b/tests/core/test_i64_umul.in
new file mode 100644
index 00000000..bfe97154
--- /dev/null
+++ b/tests/core/test_i64_umul.in
@@ -0,0 +1,18 @@
+#include <inttypes.h>
+#include <stdio.h>
+
+typedef uint32_t UINT32;
+typedef uint64_t UINT64;
+
+int main() {
+ volatile UINT32 testu32a = 2375724032U;
+ UINT32 bigu32 = 0xffffffffU;
+ volatile UINT64 testu64a = 14746250828952703000U;
+
+ while ((UINT64)testu32a * (UINT64)bigu32 < testu64a) {
+ printf("testu64a is %llu\n", testu64a);
+ testu64a /= 2;
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_i64_umul.out b/tests/core/test_i64_umul.out
new file mode 100644
index 00000000..eb85c3ab
--- /dev/null
+++ b/tests/core/test_i64_umul.out
@@ -0,0 +1 @@
+testu64a is 14746250828952703000
diff --git a/tests/core/test_i64_varargs.in b/tests/core/test_i64_varargs.in
new file mode 100644
index 00000000..7d2e4267
--- /dev/null
+++ b/tests/core/test_i64_varargs.in
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <stdarg.h>
+
+int64_t ccv_cache_generate_signature(char *msg, int len, int64_t sig_start,
+ ...) {
+ if (sig_start < 10123) printf("%s\n", msg + len);
+ va_list v;
+ va_start(v, sig_start);
+ if (sig_start > 1413)
+ printf("%d\n", va_arg(v, int));
+ else
+ printf("nada\n");
+ va_end(v);
+ return len * sig_start * (msg[0] + 1);
+}
+
+int main(int argc, char **argv) {
+ for (int i = 0; i < argc; i++) {
+ int64_t x;
+ if (i % 123123 == 0)
+ x = ccv_cache_generate_signature(argv[i], i + 2, (int64_t)argc * argc,
+ 54.111);
+ else
+ x = ccv_cache_generate_signature(argv[i], i + 2, (int64_t)argc * argc,
+ 13);
+ printf("%lld\n", x);
+ }
+};
diff --git a/tests/core/test_i64_varargs.out b/tests/core/test_i64_varargs.out
new file mode 100644
index 00000000..8c7b7843
--- /dev/null
+++ b/tests/core/test_i64_varargs.out
@@ -0,0 +1,12 @@
+in/this.program
+nada
+1536
+a
+nada
+5760
+fl
+nada
+6592
+sdfasdfasdf
+nada
+7840
diff --git a/tests/core/test_i64_zextneg.in b/tests/core/test_i64_zextneg.in
new file mode 100644
index 00000000..b7e204fe
--- /dev/null
+++ b/tests/core/test_i64_zextneg.in
@@ -0,0 +1,13 @@
+#include <stdint.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ uint8_t byte = 0x80;
+ uint16_t two = byte;
+ uint32_t four = byte;
+ uint64_t eight = byte;
+
+ printf("value: %d,%d,%d,%lld.\n", byte, two, four, eight);
+
+ return 0;
+}
diff --git a/tests/core/test_i64_zextneg.out b/tests/core/test_i64_zextneg.out
new file mode 100644
index 00000000..e2d9fd34
--- /dev/null
+++ b/tests/core/test_i64_zextneg.out
@@ -0,0 +1 @@
+value: 128,128,128,128. \ No newline at end of file
diff --git a/tests/core/test_if.in b/tests/core/test_if.in
new file mode 100644
index 00000000..07edbe8d
--- /dev/null
+++ b/tests/core/test_if.in
@@ -0,0 +1,8 @@
+#include <stdio.h>
+int main() {
+ int x = 5;
+ if (x > 3) {
+ printf("*yes*\n");
+ }
+ return 0;
+}
diff --git a/tests/core/test_if.out b/tests/core/test_if.out
new file mode 100644
index 00000000..f74b0639
--- /dev/null
+++ b/tests/core/test_if.out
@@ -0,0 +1 @@
+*yes* \ No newline at end of file
diff --git a/tests/core/test_if_else.in b/tests/core/test_if_else.in
new file mode 100644
index 00000000..b7693eed
--- /dev/null
+++ b/tests/core/test_if_else.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+int main() {
+ int x = 5;
+ if (x > 10) {
+ printf("*yes*\n");
+ } else {
+ printf("*no*\n");
+ }
+ return 0;
+}
diff --git a/tests/core/test_if_else.out b/tests/core/test_if_else.out
new file mode 100644
index 00000000..208ac5ec
--- /dev/null
+++ b/tests/core/test_if_else.out
@@ -0,0 +1 @@
+*no* \ No newline at end of file
diff --git a/tests/core/test_indirectbr.in b/tests/core/test_indirectbr.in
new file mode 100644
index 00000000..ae3f1baa
--- /dev/null
+++ b/tests/core/test_indirectbr.in
@@ -0,0 +1,20 @@
+#include <stdio.h>
+int main(void) {
+ const void *addrs[2] = {&&FOO, &&BAR};
+
+ // confuse the optimizer so it doesn't hardcode the jump and avoid generating
+ // an |indirectbr| instruction
+ int which = 0;
+ for (int x = 0; x < 1000; x++) which = (which + x * x) % 7;
+ which = (which % 2) + 1;
+
+ goto *addrs[which];
+
+FOO:
+ printf("bad\n");
+ return 0;
+BAR:
+ printf("good\n");
+ const void *addr = &&FOO;
+ goto *addr;
+}
diff --git a/tests/core/test_indirectbr.out b/tests/core/test_indirectbr.out
new file mode 100644
index 00000000..5364b418
--- /dev/null
+++ b/tests/core/test_indirectbr.out
@@ -0,0 +1,2 @@
+good
+bad \ No newline at end of file
diff --git a/tests/core/test_indirectbr_many.in b/tests/core/test_indirectbr_many.in
new file mode 100644
index 00000000..7937d197
--- /dev/null
+++ b/tests/core/test_indirectbr_many.in
@@ -0,0 +1,44 @@
+#include <stdio.h>
+
+/* Store, "declare" (but jump over) the current B_* label */
+#define IND_BLOCK(X) \
+do { \
+ addrs[i] = &&B_##X; \
+ i++; \
+ goto JMP_##X; \
+ B_##X: \
+ printf(#X "\n"); \
+ return 0; \
+ JMP_##X: \
+ ; \
+} while (0)
+
+/* Add an indirection block to enable token pasting */
+#define SINGLE(X) IND_BLOCK(X);
+
+#define P2 SINGLE(__COUNTER__) SINGLE(__COUNTER__)
+#define P4 P2 P2
+#define P8 P4 P4
+#define P16 P8 P8
+#define P32 P16 P16
+#define P64 P32 P32
+#define P128 P64 P64
+#define P256 P128 P128
+#define P512 P256 P256
+#define P1024 P512 P512
+
+int main(int argc, char *argv[])
+{
+ const void *addrs[1024 + 512];
+ int i = 0;
+
+ /*
+ * Repeat as many times as you want, but remember to update
+ * the labels address array's size accordingly.
+ */
+ P1024;
+ P512;
+
+ /* jump back at the correct label */
+ goto *addrs[(argc * argc) + 1000];
+}
diff --git a/tests/core/test_indirectbr_many.out b/tests/core/test_indirectbr_many.out
new file mode 100644
index 00000000..dd117240
--- /dev/null
+++ b/tests/core/test_indirectbr_many.out
@@ -0,0 +1 @@
+1001
diff --git a/tests/core/test_inherit.in b/tests/core/test_inherit.in
new file mode 100644
index 00000000..ae5b819d
--- /dev/null
+++ b/tests/core/test_inherit.in
@@ -0,0 +1,22 @@
+#include <stdio.h>
+struct Parent {
+ int x1, x2;
+};
+struct Child : Parent {
+ int y;
+};
+int main() {
+ Parent a;
+ a.x1 = 50;
+ a.x2 = 87;
+ Child b;
+ b.x1 = 78;
+ b.x2 = 550;
+ b.y = 101;
+ Child* c = (Child*)&a;
+ c->x1++;
+ c = &b;
+ c->y--;
+ printf("*%d,%d,%d,%d,%d,%d,%d*\n", a.x1, a.x2, b.x1, b.x2, b.y, c->x1, c->x2);
+ return 0;
+}
diff --git a/tests/core/test_inherit.out b/tests/core/test_inherit.out
new file mode 100644
index 00000000..34570bd7
--- /dev/null
+++ b/tests/core/test_inherit.out
@@ -0,0 +1 @@
+*51,87,78,550,100,78,550* \ No newline at end of file
diff --git a/tests/core/test_inlinejs.in b/tests/core/test_inlinejs.in
new file mode 100644
index 00000000..b6a98954
--- /dev/null
+++ b/tests/core/test_inlinejs.in
@@ -0,0 +1,27 @@
+#include <stdio.h>
+
+double get() {
+ double ret = 0;
+ __asm __volatile__("Math.abs(-12/3.3)" : "=r"(ret)); // write to a variable
+ asm("#comment1");
+ asm volatile("#comment2");
+ asm volatile(
+ "#comment3\n"
+ "#comment4\n");
+ return ret;
+}
+
+int main() {
+ asm("Module.print('Inline JS is very cool')");
+ printf("%.2f\n", get());
+
+ // Test that passing multiple input and output variables works.
+ int src1 = 1, src2 = 2, src3 = 3;
+ int dst1 = 0, dst2 = 0, dst3 = 0;
+ // TODO asm("Module.print(%3); Module.print(%4); Module.print(%5); %0 = %3; %1
+ // = %4; %2 = %5;" : "=r"(dst1),"=r"(dst2),"=r"(dst3):
+ // "r"(src1),"r"(src2),"r"(src3));
+ // TODO printf("%d\n%d\n%d\n", dst1, dst2, dst3);
+
+ return 0;
+}
diff --git a/tests/core/test_inlinejs.out b/tests/core/test_inlinejs.out
new file mode 100644
index 00000000..1838ef2e
--- /dev/null
+++ b/tests/core/test_inlinejs.out
@@ -0,0 +1,2 @@
+Inline JS is very cool
+3.64
diff --git a/tests/core/test_inlinejs2.in b/tests/core/test_inlinejs2.in
new file mode 100644
index 00000000..438253c2
--- /dev/null
+++ b/tests/core/test_inlinejs2.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+int mix(int x, int y) {
+ int ret;
+ asm("Math.pow(2, %0+%1+1)" : "=r"(ret) : "r"(x), "r"(y)); // read and write
+ return ret;
+}
+
+void mult() {
+ asm("var $_$1 = Math.abs(-100); $_$1 *= 2; Module.print($_$1)"); // multiline
+ asm __volatile__("Module.print('done')");
+}
+
+int main(int argc, char **argv) {
+ printf("%d\n", mix(argc, argc / 2));
+ mult();
+ return 0;
+}
diff --git a/tests/core/test_inlinejs2.out b/tests/core/test_inlinejs2.out
new file mode 100644
index 00000000..68dd9b64
--- /dev/null
+++ b/tests/core/test_inlinejs2.out
@@ -0,0 +1,3 @@
+4
+200
+done
diff --git a/tests/core/test_inlinejs3.in b/tests/core/test_inlinejs3.in
new file mode 100644
index 00000000..3e1913ff
--- /dev/null
+++ b/tests/core/test_inlinejs3.in
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <emscripten.h>
+
+int main(int argc, char **argv) {
+ EM_ASM(Module.print('hello dere1'));
+ EM_ASM(Module.print('hello dere2'););
+ for (int i = 0; i < 3; i++) {
+ EM_ASM(Module.print('hello dere3'); Module.print('hello dere' + 4););
+ }
+ int sum = 0;
+ for (int i = 0; i < argc * 3; i++) {
+ sum += EM_ASM_INT({
+ Module.print('i: ' + [ $0, ($1).toFixed(2) ]);
+ return $0 * 2;
+ },
+ i, double(i) / 12);
+ }
+ printf("sum: %d\n", sum);
+ return 0;
+}
diff --git a/tests/core/test_inlinejs3.out b/tests/core/test_inlinejs3.out
new file mode 100644
index 00000000..c293e80b
--- /dev/null
+++ b/tests/core/test_inlinejs3.out
@@ -0,0 +1,12 @@
+hello dere1
+hello dere2
+hello dere3
+hello dere4
+hello dere3
+hello dere4
+hello dere3
+hello dere4
+i: 0,0.00
+i: 1,0.08
+i: 2,0.17
+sum: 6
diff --git a/tests/core/test_intvars.in b/tests/core/test_intvars.in
new file mode 100644
index 00000000..27b4180b
--- /dev/null
+++ b/tests/core/test_intvars.in
@@ -0,0 +1,49 @@
+#include <stdio.h>
+int global = 20;
+int *far;
+int main() {
+ int x = 5;
+ int y = x + 17;
+ int z = (y - 1) / 2; // Should stay an integer after division!
+ y += 1;
+ int w = x * 3 + 4;
+ int k = w < 15 ? 99 : 101;
+ far = &k;
+ *far += global;
+ int i = k > 100; // Should be an int, not a bool!
+ int j = i << 6;
+ j >>= 1;
+ j = j ^ 5;
+ int h = 1;
+ h |= 0;
+ int p = h;
+ p &= 0;
+ printf("*%d,%d,%d,%d,%d,%d,%d,%d,%d*\n", x, y, z, w, k, i, j, h, p);
+
+ long hash = -1;
+ size_t perturb;
+ int ii = 0;
+ for (perturb = hash;; perturb >>= 5) {
+ printf("%d:%d", ii, perturb);
+ ii++;
+ if (ii == 9) break;
+ printf(",");
+ }
+ printf("*\n");
+ printf("*%.1d,%.2d*\n", 56, 9);
+
+ // Fixed-point math on 64-bit ints. Tricky to support since we have no 64-bit
+ // shifts in JS
+ {
+ struct Fixed {
+ static int Mult(int a, int b) {
+ return ((long long)a * (long long)b) >> 16;
+ }
+ };
+ printf("fixed:%d\n", Fixed::Mult(150000, 140000));
+ }
+
+ printf("*%ld*%p\n", (long)21,
+ &hash); // The %p should not enter an infinite loop!
+ return 0;
+}
diff --git a/tests/core/test_intvars.out b/tests/core/test_intvars.out
new file mode 100644
index 00000000..9d1cada7
--- /dev/null
+++ b/tests/core/test_intvars.out
@@ -0,0 +1,5 @@
+*5,23,10,19,121,1,37,1,0*
+0:-1,1:134217727,2:4194303,3:131071,4:4095,5:127,6:3,7:0,8:0*
+*56,09*
+fixed:320434
+*21* \ No newline at end of file
diff --git a/tests/core/test_isdigit_l.in b/tests/core/test_isdigit_l.in
new file mode 100644
index 00000000..069f2027
--- /dev/null
+++ b/tests/core/test_isdigit_l.in
@@ -0,0 +1,5 @@
+#include <iostream>
+int main() {
+ using namespace std;
+ use_facet<num_put<char> >(cout.getloc()).put(cout, cout, '0', 3.14159265);
+}
diff --git a/tests/core/test_isdigit_l.out b/tests/core/test_isdigit_l.out
new file mode 100644
index 00000000..2c0cac55
--- /dev/null
+++ b/tests/core/test_isdigit_l.out
@@ -0,0 +1 @@
+3.14159 \ No newline at end of file
diff --git a/tests/core/test_isnan.in b/tests/core/test_isnan.in
new file mode 100644
index 00000000..808ffa19
--- /dev/null
+++ b/tests/core/test_isnan.in
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int IsNaN(double x) {
+ int rc; /* The value return */
+ volatile double y = x;
+ volatile double z = y;
+ rc = (y != z);
+ return rc;
+}
+
+int main() {
+ double tests[] = {1.0, 3.333, 1.0 / 0.0, 0.0 / 0.0, -1.0 / 0.0,
+ -0, 0, -123123123, 12.0E200};
+ for (int i = 0; i < sizeof(tests) / sizeof(double); i++)
+ printf("%d - %f - %d\n", i, tests[i], IsNaN(tests[i]));
+}
diff --git a/tests/core/test_isnan.out b/tests/core/test_isnan.out
new file mode 100644
index 00000000..b7e33f0e
--- /dev/null
+++ b/tests/core/test_isnan.out
@@ -0,0 +1,9 @@
+0 - 1.000000 - 0
+1 - 3.333000 - 0
+2 - inf - 0
+3 - nan - 1
+4 - -inf - 0
+5 - 0.000000 - 0
+6 - 0.000000 - 0
+7 - -123123123.000000 - 0
+8 - 1.2e+201 - 0
diff --git a/tests/core/test_istream.in b/tests/core/test_istream.in
new file mode 100644
index 00000000..e5988d24
--- /dev/null
+++ b/tests/core/test_istream.in
@@ -0,0 +1,13 @@
+#include <string>
+#include <sstream>
+#include <iostream>
+
+int main() {
+ std::string mystring("1 2 3");
+ std::istringstream is(mystring);
+ int one, two, three;
+
+ is >> one >> two >> three;
+
+ printf("%i %i %i", one, two, three);
+}
diff --git a/tests/core/test_istream.out b/tests/core/test_istream.out
new file mode 100644
index 00000000..703ca85b
--- /dev/null
+++ b/tests/core/test_istream.out
@@ -0,0 +1 @@
+1 2 3 \ No newline at end of file
diff --git a/tests/core/test_iswdigit.in b/tests/core/test_iswdigit.in
new file mode 100644
index 00000000..74277a41
--- /dev/null
+++ b/tests/core/test_iswdigit.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <cctype>
+#include <cwctype>
+
+int main() {
+ using namespace std;
+ printf("%d ", isdigit('0'));
+ printf("%d ", iswdigit(L'0'));
+ return 0;
+}
diff --git a/tests/core/test_iswdigit.out b/tests/core/test_iswdigit.out
new file mode 100644
index 00000000..92880af7
--- /dev/null
+++ b/tests/core/test_iswdigit.out
@@ -0,0 +1 @@
+1 1 \ No newline at end of file
diff --git a/tests/core/test_libcextra.in b/tests/core/test_libcextra.in
new file mode 100644
index 00000000..ebeb8b50
--- /dev/null
+++ b/tests/core/test_libcextra.in
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <wchar.h>
+
+int main() {
+ const wchar_t* wstr = L"Hello";
+
+ printf("wcslen: %d\n", wcslen(wstr));
+
+ return 0;
+}
diff --git a/tests/core/test_libcextra.out b/tests/core/test_libcextra.out
new file mode 100644
index 00000000..d0191c32
--- /dev/null
+++ b/tests/core/test_libcextra.out
@@ -0,0 +1 @@
+wcslen: 5 \ No newline at end of file
diff --git a/tests/core/test_libgen.in b/tests/core/test_libgen.in
new file mode 100644
index 00000000..d62e4a00
--- /dev/null
+++ b/tests/core/test_libgen.in
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <libgen.h>
+
+int main() {
+ char p1[16] = "/usr/lib", p1x[16] = "/usr/lib";
+ printf("%s -> ", p1);
+ printf("%s : %s\n", dirname(p1x), basename(p1));
+
+ char p2[16] = "/usr", p2x[16] = "/usr";
+ printf("%s -> ", p2);
+ printf("%s : %s\n", dirname(p2x), basename(p2));
+
+ char p3[16] = "/usr/", p3x[16] = "/usr/";
+ printf("%s -> ", p3);
+ printf("%s : %s\n", dirname(p3x), basename(p3));
+
+ char p4[16] = "/usr/lib///", p4x[16] = "/usr/lib///";
+ printf("%s -> ", p4);
+ printf("%s : %s\n", dirname(p4x), basename(p4));
+
+ char p5[16] = "/", p5x[16] = "/";
+ printf("%s -> ", p5);
+ printf("%s : %s\n", dirname(p5x), basename(p5));
+
+ char p6[16] = "///", p6x[16] = "///";
+ printf("%s -> ", p6);
+ printf("%s : %s\n", dirname(p6x), basename(p6));
+
+ char p7[16] = "/usr/../lib/..", p7x[16] = "/usr/../lib/..";
+ printf("%s -> ", p7);
+ printf("%s : %s\n", dirname(p7x), basename(p7));
+
+ char p8[16] = "", p8x[16] = "";
+ printf("(empty) -> %s : %s\n", dirname(p8x), basename(p8));
+
+ printf("(null) -> %s : %s\n", dirname(0), basename(0));
+
+ return 0;
+}
diff --git a/tests/core/test_libgen.out b/tests/core/test_libgen.out
new file mode 100644
index 00000000..b29893a8
--- /dev/null
+++ b/tests/core/test_libgen.out
@@ -0,0 +1,9 @@
+/usr/lib -> /usr : lib
+/usr -> / : usr
+/usr/ -> / : usr
+/usr/lib/// -> /usr : lib
+/ -> / : /
+/// -> / : /
+/usr/../lib/.. -> /usr/../lib : ..
+(empty) -> . : .
+(null) -> . : .
diff --git a/tests/core/test_linked_list.in b/tests/core/test_linked_list.in
new file mode 100644
index 00000000..c3d457dd
--- /dev/null
+++ b/tests/core/test_linked_list.in
@@ -0,0 +1,39 @@
+#include <stdio.h>
+struct worker_args {
+ int value;
+ struct worker_args* next;
+};
+int main() {
+ worker_args a;
+ worker_args b;
+ a.value = 60;
+ a.next = &b;
+ b.value = 900;
+ b.next = NULL;
+ worker_args* c = &a;
+ int total = 0;
+ while (c) {
+ total += c->value;
+ c = c->next;
+ }
+
+ // Chunk of em
+ worker_args chunk[10];
+ for (int i = 0; i < 9; i++) {
+ chunk[i].value = i * 10;
+ chunk[i].next = &chunk[i + 1];
+ }
+ chunk[9].value = 90;
+ chunk[9].next = &chunk[0];
+
+ c = chunk;
+ do {
+ total += c->value;
+ c = c->next;
+ } while (c != chunk);
+
+ printf("*%d,%d*\n", total, b.next);
+ // NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
+
+ return 0;
+}
diff --git a/tests/core/test_linked_list.out b/tests/core/test_linked_list.out
new file mode 100644
index 00000000..f3b615b1
--- /dev/null
+++ b/tests/core/test_linked_list.out
@@ -0,0 +1 @@
+*1410,0* \ No newline at end of file
diff --git a/tests/core/test_llrint.in b/tests/core/test_llrint.in
new file mode 100644
index 00000000..2744c73a
--- /dev/null
+++ b/tests/core/test_llrint.in
@@ -0,0 +1,7 @@
+#include <stdio.h>
+#include <math.h>
+int main() {
+ printf("%lld\n%lld\n%lld\n%lld\n", llrint(0.1), llrint(0.6), llrint(1.25),
+ llrint(1099511627776.667));
+ return 0;
+}
diff --git a/tests/core/test_llrint.out b/tests/core/test_llrint.out
new file mode 100644
index 00000000..80e9c908
--- /dev/null
+++ b/tests/core/test_llrint.out
@@ -0,0 +1,4 @@
+0
+1
+1
+1099511627777
diff --git a/tests/core/test_llvm_intrinsics.in b/tests/core/test_llvm_intrinsics.in
new file mode 100644
index 00000000..2bc87a54
--- /dev/null
+++ b/tests/core/test_llvm_intrinsics.in
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <sys/types.h>
+
+extern "C" {
+extern unsigned short llvm_bswap_i16(unsigned short x);
+extern unsigned int llvm_bswap_i32(unsigned int x);
+extern int32_t llvm_ctlz_i32(int32_t x);
+extern int64_t llvm_ctlz_i64(int64_t x);
+extern int32_t llvm_cttz_i32(int32_t x);
+extern int64_t llvm_cttz_i64(int64_t x);
+extern int32_t llvm_ctpop_i32(int32_t x);
+extern int64_t llvm_ctpop_i64(int64_t x);
+extern int llvm_expect_i32(int x, int y);
+}
+
+int main(void) {
+ unsigned short x = 0xc8ef;
+ printf("%x,%x\n", x & 0xff, x >> 8);
+ x = llvm_bswap_i16(x);
+ printf("%x,%x\n", x & 0xff, x >> 8);
+
+ unsigned int y = 0xc5de158a;
+ printf("%x,%x,%x,%x\n", y & 0xff, (y >> 8) & 0xff, (y >> 16) & 0xff,
+ (y >> 24) & 0xff);
+ y = llvm_bswap_i32(y);
+ printf("%x,%x,%x,%x\n", y & 0xff, (y >> 8) & 0xff, (y >> 16) & 0xff,
+ (y >> 24) & 0xff);
+
+ printf("%d,%d\n", (int)llvm_ctlz_i64(((int64_t)1) << 40),
+ llvm_ctlz_i32(1 << 10));
+ printf("%d,%d\n", (int)llvm_cttz_i64(((int64_t)1) << 40),
+ llvm_cttz_i32(1 << 10));
+ printf("%d,%d\n", (int)llvm_ctpop_i64((0x3101ULL << 32) | 1),
+ llvm_ctpop_i32(0x3101));
+ printf("%d\n", (int)llvm_ctpop_i32(-594093059));
+
+ printf("%d\n", llvm_expect_i32(x % 27, 3));
+
+ int64_t a = 1;
+ a = __builtin_bswap64(a);
+ printf("%lld\n", a);
+
+ return 0;
+}
diff --git a/tests/core/test_llvm_intrinsics.out b/tests/core/test_llvm_intrinsics.out
new file mode 100644
index 00000000..659b3c21
--- /dev/null
+++ b/tests/core/test_llvm_intrinsics.out
@@ -0,0 +1,10 @@
+ef,c8
+c8,ef
+8a,15,de,c5
+c5,de,15,8a
+23,21
+40,10
+5,4
+22
+13
+72057594037927936
diff --git a/tests/core/test_llvm_used.in b/tests/core/test_llvm_used.in
new file mode 100644
index 00000000..b3c9f10e
--- /dev/null
+++ b/tests/core/test_llvm_used.in
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <emscripten.h>
+
+extern "C" {
+ EMSCRIPTEN_KEEPALIVE void foobar(int x) {
+ printf("Worked! %d\n", x);
+ }
+}
+
+int main() {
+ emscripten_run_script("Module['_foobar'](10)");
+ return 0;
+}
diff --git a/tests/core/test_llvm_used.out b/tests/core/test_llvm_used.out
new file mode 100644
index 00000000..87ef2612
--- /dev/null
+++ b/tests/core/test_llvm_used.out
@@ -0,0 +1 @@
+Worked! 10
diff --git a/tests/core/test_llvmswitch.in b/tests/core/test_llvmswitch.in
new file mode 100644
index 00000000..b3f871e4
--- /dev/null
+++ b/tests/core/test_llvmswitch.in
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <string.h>
+
+int switcher(int p) {
+ switch (p) {
+ case 'a':
+ case 'b':
+ case 'c':
+ return p - 1;
+ case -15:
+ return p + 1;
+ }
+ return p;
+}
+
+int main(int argc, const char *argv[]) {
+ unsigned int x = 0xfffffff1;
+ x >>= (argc - 1); // force it to be unsigned for purpose of checking our
+ // switch comparison in signed/unsigned
+ printf("*%d,%d,%d,%d,%d,%d*\n", switcher('a'), switcher('b'), switcher('c'),
+ switcher(x), switcher(-15), switcher('e'));
+ return 0;
+}
diff --git a/tests/core/test_llvmswitch.out b/tests/core/test_llvmswitch.out
new file mode 100644
index 00000000..4647c7e1
--- /dev/null
+++ b/tests/core/test_llvmswitch.out
@@ -0,0 +1 @@
+*96,97,98,-14,-14,101* \ No newline at end of file
diff --git a/tests/core/test_longjmp.in b/tests/core/test_longjmp.in
new file mode 100644
index 00000000..44940cdd
--- /dev/null
+++ b/tests/core/test_longjmp.in
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <setjmp.h>
+
+static jmp_buf buf;
+
+void second(void) {
+ printf("second\n");
+ longjmp(buf, -1);
+}
+
+void first(void) {
+ printf("first\n"); // prints
+ longjmp(buf, 1); // jumps back to where setjmp was called - making setjmp now
+ // return 1
+}
+
+int main() {
+ volatile int x = 0;
+ int jmpval = setjmp(buf);
+ if (!jmpval) {
+ x++; // should be properly restored once longjmp jumps back
+ first(); // when executed, setjmp returns 1
+ printf("skipped\n"); // does not print
+ } else if (jmpval == 1) { // when first() jumps back, setjmp returns 1
+ printf("result: %d %d\n", x, jmpval); // prints
+ x++;
+ second(); // when executed, setjmp returns -1
+ } else if (jmpval == -1) { // when second() jumps back, setjmp returns -1
+ printf("result: %d %d\n", x, jmpval); // prints
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_longjmp.out b/tests/core/test_longjmp.out
new file mode 100644
index 00000000..4a412fef
--- /dev/null
+++ b/tests/core/test_longjmp.out
@@ -0,0 +1,4 @@
+first
+result: 1 1
+second
+result: 2 -1 \ No newline at end of file
diff --git a/tests/core/test_longjmp2.in b/tests/core/test_longjmp2.in
new file mode 100644
index 00000000..e09a33f7
--- /dev/null
+++ b/tests/core/test_longjmp2.in
@@ -0,0 +1,35 @@
+#include <setjmp.h>
+#include <stdio.h>
+
+typedef struct {
+ jmp_buf* jmp;
+} jmp_state;
+
+void stack_manipulate_func(jmp_state* s, int level) {
+ jmp_buf buf;
+
+ printf("Entering stack_manipulate_func, level: %d\n", level);
+
+ if (level == 0) {
+ s->jmp = &buf;
+ if (setjmp(*(s->jmp)) == 0) {
+ printf("Setjmp normal execution path, level: %d\n", level);
+ stack_manipulate_func(s, level + 1);
+ } else {
+ printf("Setjmp error execution path, level: %d\n", level);
+ }
+ } else {
+ printf("Perform longjmp at level %d\n", level);
+ longjmp(*(s->jmp), 1);
+ }
+
+ printf("Exiting stack_manipulate_func, level: %d\n", level);
+}
+
+int main(int argc, char* argv[]) {
+ jmp_state s;
+ s.jmp = NULL;
+ stack_manipulate_func(&s, 0);
+
+ return 0;
+}
diff --git a/tests/core/test_longjmp2.out b/tests/core/test_longjmp2.out
new file mode 100644
index 00000000..82956215
--- /dev/null
+++ b/tests/core/test_longjmp2.out
@@ -0,0 +1,6 @@
+Entering stack_manipulate_func, level: 0
+Setjmp normal execution path, level: 0
+Entering stack_manipulate_func, level: 1
+Perform longjmp at level 1
+Setjmp error execution path, level: 0
+Exiting stack_manipulate_func, level: 0
diff --git a/tests/core/test_longjmp3.in b/tests/core/test_longjmp3.in
new file mode 100644
index 00000000..f9b88469
--- /dev/null
+++ b/tests/core/test_longjmp3.in
@@ -0,0 +1,40 @@
+#include <setjmp.h>
+#include <stdio.h>
+
+typedef struct {
+ jmp_buf* jmp;
+} jmp_state;
+
+void setjmp_func(jmp_state* s, int level) {
+ jmp_buf* prev_jmp = s->jmp;
+ jmp_buf c_jmp;
+
+ if (level == 2) {
+ printf("level is 2, perform longjmp!\n");
+ longjmp(*(s->jmp), 1);
+ }
+
+ if (setjmp(c_jmp) == 0) {
+ printf("setjmp normal execution path, level: %d\n", level);
+ s->jmp = &c_jmp;
+ setjmp_func(s, level + 1);
+ } else {
+ printf("setjmp exception execution path, level: %d\n", level);
+ if (prev_jmp) {
+ printf("prev_jmp is not empty, continue with longjmp!\n");
+ s->jmp = prev_jmp;
+ longjmp(*(s->jmp), 1);
+ }
+ }
+
+ printf("Exiting setjmp function, level: %d\n", level);
+}
+
+int main(int argc, char* argv[]) {
+ jmp_state s;
+ s.jmp = NULL;
+
+ setjmp_func(&s, 0);
+
+ return 0;
+}
diff --git a/tests/core/test_longjmp3.out b/tests/core/test_longjmp3.out
new file mode 100644
index 00000000..c0d39cfb
--- /dev/null
+++ b/tests/core/test_longjmp3.out
@@ -0,0 +1,7 @@
+setjmp normal execution path, level: 0
+setjmp normal execution path, level: 1
+level is 2, perform longjmp!
+setjmp exception execution path, level: 1
+prev_jmp is not empty, continue with longjmp!
+setjmp exception execution path, level: 0
+Exiting setjmp function, level: 0
diff --git a/tests/core/test_longjmp4.in b/tests/core/test_longjmp4.in
new file mode 100644
index 00000000..68fa4c22
--- /dev/null
+++ b/tests/core/test_longjmp4.in
@@ -0,0 +1,40 @@
+#include <setjmp.h>
+#include <stdio.h>
+
+typedef struct {
+ jmp_buf* jmp;
+} jmp_state;
+
+void second_func(jmp_state* s);
+
+void first_func(jmp_state* s) {
+ jmp_buf* prev_jmp = s->jmp;
+ jmp_buf c_jmp;
+ volatile int once = 0;
+
+ if (setjmp(c_jmp) == 0) {
+ printf("Normal execution path of first function!\n");
+
+ s->jmp = &c_jmp;
+ second_func(s);
+ } else {
+ printf("Exception execution path of first function! %d\n", once);
+
+ if (!once) {
+ printf("Calling longjmp the second time!\n");
+ once = 1;
+ longjmp(*(s->jmp), 1);
+ }
+ }
+}
+
+void second_func(jmp_state* s) { longjmp(*(s->jmp), 1); }
+
+int main(int argc, char* argv[]) {
+ jmp_state s;
+ s.jmp = NULL;
+
+ first_func(&s);
+
+ return 0;
+}
diff --git a/tests/core/test_longjmp4.out b/tests/core/test_longjmp4.out
new file mode 100644
index 00000000..53fdd41b
--- /dev/null
+++ b/tests/core/test_longjmp4.out
@@ -0,0 +1,4 @@
+Normal execution path of first function!
+Exception execution path of first function! 0
+Calling longjmp the second time!
+Exception execution path of first function! 1
diff --git a/tests/core/test_longjmp_exc.in b/tests/core/test_longjmp_exc.in
new file mode 100644
index 00000000..4e568242
--- /dev/null
+++ b/tests/core/test_longjmp_exc.in
@@ -0,0 +1,28 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include <emscripten.h>
+
+jmp_buf abortframe;
+
+void dostuff(int a) {
+ printf("pre\n");
+ if (a != 42)
+ emscripten_run_script(
+ "waka_waka()"); // this should fail, and never reach "never"
+ printf("never\n");
+
+ if (a == 100) {
+ longjmp(abortframe, -1);
+ }
+
+ if (setjmp(abortframe)) {
+ printf("got 100");
+ }
+}
+
+int main(int argc, char **argv) {
+ dostuff(argc);
+ exit(1);
+ return 1;
+}
diff --git a/tests/core/test_longjmp_exc.out b/tests/core/test_longjmp_exc.out
new file mode 100644
index 00000000..b12dbd82
--- /dev/null
+++ b/tests/core/test_longjmp_exc.out
@@ -0,0 +1 @@
+waka_waka \ No newline at end of file
diff --git a/tests/core/test_longjmp_funcptr.in b/tests/core/test_longjmp_funcptr.in
new file mode 100644
index 00000000..38cbd86e
--- /dev/null
+++ b/tests/core/test_longjmp_funcptr.in
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <setjmp.h>
+
+static jmp_buf buf;
+
+void (*fp)() = NULL;
+
+void second(void) {
+ printf("second\n"); // prints
+ longjmp(buf, 1); // jumps back to where setjmp was called - making setjmp now
+ // return 1
+}
+
+void first(void) {
+ fp();
+ printf("first\n"); // does not print
+}
+
+int main(int argc, char **argv) {
+ fp = argc == 200 ? NULL : second;
+
+ volatile int x = 0;
+ if (!setjmp(buf)) {
+ x++;
+ first(); // when executed, setjmp returns 0
+ } else { // when longjmp jumps back, setjmp returns 1
+ printf("main: %d\n", x); // prints
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_longjmp_funcptr.out b/tests/core/test_longjmp_funcptr.out
new file mode 100644
index 00000000..0e823e76
--- /dev/null
+++ b/tests/core/test_longjmp_funcptr.out
@@ -0,0 +1,2 @@
+second
+main: 1
diff --git a/tests/core/test_longjmp_repeat.in b/tests/core/test_longjmp_repeat.in
new file mode 100644
index 00000000..f782fc0c
--- /dev/null
+++ b/tests/core/test_longjmp_repeat.in
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <setjmp.h>
+
+static jmp_buf buf;
+
+int main() {
+ volatile int x = 0;
+ printf("setjmp:%d\n", setjmp(buf));
+ x++;
+ printf("x:%d\n", x);
+ if (x < 4) longjmp(buf, x * 2);
+ return 0;
+}
diff --git a/tests/core/test_longjmp_repeat.out b/tests/core/test_longjmp_repeat.out
new file mode 100644
index 00000000..8f4183b9
--- /dev/null
+++ b/tests/core/test_longjmp_repeat.out
@@ -0,0 +1,8 @@
+setjmp:0
+x:1
+setjmp:2
+x:2
+setjmp:4
+x:3
+setjmp:6
+x:4
diff --git a/tests/core/test_longjmp_stacked.in b/tests/core/test_longjmp_stacked.in
new file mode 100644
index 00000000..b7fd6bfa
--- /dev/null
+++ b/tests/core/test_longjmp_stacked.in
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <string.h>
+
+int bottom, top;
+
+int run(int y) {
+ // confuse stack
+ char *s = (char *)alloca(100);
+ memset(s, 1, 100);
+ s[y] = y;
+ s[y / 2] = y * 2;
+ volatile int x = s[y];
+ top = (int)alloca(4);
+ if (x <= 2) return x;
+ jmp_buf buf;
+ printf("setjmp of %d\n", x);
+ if (setjmp(buf) == 0) {
+ printf("going\n");
+ x += run(x / 2);
+ longjmp(buf, 1);
+ }
+ printf("back\n");
+ return x / 2;
+}
+
+int main(int argc, char **argv) {
+ int sum = 0;
+ for (int i = 0; i < argc * 2; i++) {
+ bottom = (int)alloca(4);
+ sum += run(10);
+ // scorch the earth
+ if (bottom < top) {
+ memset((void *)bottom, 1, top - bottom);
+ } else {
+ memset((void *)top, 1, bottom - top);
+ }
+ }
+ printf("%d\n", sum);
+ return sum;
+}
diff --git a/tests/core/test_longjmp_stacked.out b/tests/core/test_longjmp_stacked.out
new file mode 100644
index 00000000..d16a8e7d
--- /dev/null
+++ b/tests/core/test_longjmp_stacked.out
@@ -0,0 +1,13 @@
+setjmp of 10
+going
+setjmp of 5
+going
+back
+back
+setjmp of 10
+going
+setjmp of 5
+going
+back
+back
+12
diff --git a/tests/core/test_loop.in b/tests/core/test_loop.in
new file mode 100644
index 00000000..83721d17
--- /dev/null
+++ b/tests/core/test_loop.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+int main() {
+ int x = 5;
+ for (int i = 0; i < 6; i++) {
+ x += x * i;
+ if (x > 1000) {
+ if (x % 7 == 0) printf("cheez\n");
+ x /= 2;
+ break;
+ }
+ }
+ printf("*%d*\n", x);
+ return 0;
+}
diff --git a/tests/core/test_loop.out b/tests/core/test_loop.out
new file mode 100644
index 00000000..428e01b6
--- /dev/null
+++ b/tests/core/test_loop.out
@@ -0,0 +1 @@
+*1800* \ No newline at end of file
diff --git a/tests/core/test_mainenv.in b/tests/core/test_mainenv.in
new file mode 100644
index 00000000..f42c6b59
--- /dev/null
+++ b/tests/core/test_mainenv.in
@@ -0,0 +1,5 @@
+#include <stdio.h>
+int main(int argc, char **argv, char **envp) {
+ printf("*%p*\n", envp);
+ return 0;
+}
diff --git a/tests/core/test_mainenv.out b/tests/core/test_mainenv.out
new file mode 100644
index 00000000..abc8f766
--- /dev/null
+++ b/tests/core/test_mainenv.out
@@ -0,0 +1 @@
+*(nil)* \ No newline at end of file
diff --git a/tests/core/test_math.in b/tests/core/test_math.in
new file mode 100644
index 00000000..e638404b
--- /dev/null
+++ b/tests/core/test_math.in
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cmath>
+int main(int argc, char **argv) {
+ printf("*%.2f,%.2f,%d", M_PI, -M_PI, (1 / 0.0) > 1e300); // could end up as
+ // infinity, or just
+ // a very very big
+ // number
+ printf(",%d", isfinite(NAN) != 0);
+ printf(",%d", isfinite(INFINITY) != 0);
+ printf(",%d", isfinite(-INFINITY) != 0);
+ printf(",%d", isfinite(12.3) != 0);
+ printf(",%d", isinf(NAN) != 0);
+ printf(",%d", isinf(INFINITY) != 0);
+ printf(",%d", isinf(-INFINITY) != 0);
+ printf(",%d", isinf(12.3) != 0);
+ div_t div_result = div(23, 10);
+ printf(",%d", div_result.quot);
+ printf(",%d", div_result.rem);
+ double sine = -1.0, cosine = -1.0;
+ sincos(0.0, &sine, &cosine);
+ printf(",%1.1lf", sine);
+ printf(",%1.1lf", cosine);
+ float fsine = -1.0f, fcosine = -1.0f;
+ sincosf(0.0, &fsine, &fcosine);
+ printf(",%1.1f", fsine);
+ printf(",%1.1f", fcosine);
+ fsine = sinf(1.1 + argc - 1);
+ fcosine = cosf(1.1 + argc - 1);
+ printf(",%1.1f", fsine);
+ printf(",%1.1f", fcosine);
+ printf("*\n");
+ return 0;
+}
diff --git a/tests/core/test_math.out b/tests/core/test_math.out
new file mode 100644
index 00000000..6deb8df4
--- /dev/null
+++ b/tests/core/test_math.out
@@ -0,0 +1 @@
+*3.14,-3.14,1,0,0,0,1,0,1,1,0,2,3,0.0,1.0,0.0,1.0,0.9,0.5* \ No newline at end of file
diff --git a/tests/core/test_mathfuncptr.in b/tests/core/test_mathfuncptr.in
new file mode 100644
index 00000000..87feaade
--- /dev/null
+++ b/tests/core/test_mathfuncptr.in
@@ -0,0 +1,11 @@
+#include <math.h>
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ float (*fn)(float) = argc != 12 ? &sqrtf : &fabsf;
+ float (*fn2)(float) = argc != 13 ? &fabsf : &sqrtf;
+ float (*fn3)(float) = argc != 14 ? &erff : &fabsf;
+ printf("fn2(-5) = %d, fn(10) = %.2f, erf(10) = %.2f\n", (int)fn2(-5), fn(10),
+ fn3(10));
+ return 0;
+}
diff --git a/tests/core/test_mathfuncptr.out b/tests/core/test_mathfuncptr.out
new file mode 100644
index 00000000..166cc3da
--- /dev/null
+++ b/tests/core/test_mathfuncptr.out
@@ -0,0 +1 @@
+fn2(-5) = 5, fn(10) = 3.16, erf(10) = 1.00 \ No newline at end of file
diff --git a/tests/core/test_memcpy2.in b/tests/core/test_memcpy2.in
new file mode 100644
index 00000000..c7b4de89
--- /dev/null
+++ b/tests/core/test_memcpy2.in
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+int main() {
+ char buffer[256];
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ for (int k = 0; k < 35; k++) {
+ for (int t = 0; t < 256; t++) buffer[t] = t;
+ char *dest = buffer + i + 128;
+ char *src = buffer + j;
+ // printf("%d, %d, %d\n", i, j, k);
+ assert(memcpy(dest, src, k) == dest);
+ assert(memcmp(dest, src, k) == 0);
+ }
+ }
+ }
+ printf("ok.\n");
+ return 1;
+}
diff --git a/tests/core/test_memcpy2.out b/tests/core/test_memcpy2.out
new file mode 100644
index 00000000..59f3f984
--- /dev/null
+++ b/tests/core/test_memcpy2.out
@@ -0,0 +1 @@
+ok. \ No newline at end of file
diff --git a/tests/core/test_memcpy_memcmp.in b/tests/core/test_memcpy_memcmp.in
new file mode 100644
index 00000000..fb5dfe6f
--- /dev/null
+++ b/tests/core/test_memcpy_memcmp.in
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#define MAXX 48
+void reset(unsigned char *buffer) {
+ for (int i = 0; i < MAXX; i++) buffer[i] = i + 1;
+}
+void dump(unsigned char *buffer) {
+ for (int i = 0; i < MAXX - 1; i++) printf("%2d,", buffer[i]);
+ printf("%d\n", buffer[MAXX - 1]);
+}
+int main() {
+ unsigned char buffer[MAXX];
+ for (int i = MAXX / 4; i < MAXX - MAXX / 4; i++) {
+ for (int j = MAXX / 4; j < MAXX - MAXX / 4; j++) {
+ for (int k = 1; k < MAXX / 4; k++) {
+ if (i == j) continue;
+ if (i < j && i + k > j) continue;
+ if (j < i && j + k > i) continue;
+ printf("[%d,%d,%d] ", i, j, k);
+ reset(buffer);
+ memcpy(buffer + i, buffer + j, k);
+ dump(buffer);
+ assert(memcmp(buffer + i, buffer + j, k) == 0);
+ buffer[i + k / 2]++;
+ if (buffer[i + k / 2] != 0) {
+ assert(memcmp(buffer + i, buffer + j, k) > 0);
+ } else {
+ assert(memcmp(buffer + i, buffer + j, k) < 0);
+ }
+ buffer[i + k / 2]--;
+ buffer[j + k / 2]++;
+ if (buffer[j + k / 2] != 0) {
+ assert(memcmp(buffer + i, buffer + j, k) < 0);
+ } else {
+ assert(memcmp(buffer + i, buffer + j, k) > 0);
+ }
+ }
+ }
+ }
+ return 0;
+}
diff --git a/tests/core/test_memcpy_memcmp.out b/tests/core/test_memcpy_memcmp.out
new file mode 100644
index 00000000..93420981
--- /dev/null
+++ b/tests/core/test_memcpy_memcmp.out
@@ -0,0 +1 @@
+6c9cdfe937383b79e52ca7a2cce83a21d9f5422c \ No newline at end of file
diff --git a/tests/core/test_memmove.in b/tests/core/test_memmove.in
new file mode 100644
index 00000000..615a5ae1
--- /dev/null
+++ b/tests/core/test_memmove.in
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include <string.h>
+int main() {
+ char str[] = "memmove can be very useful....!";
+ memmove(str + 20, str + 15, 11);
+ puts(str);
+ return 0;
+}
diff --git a/tests/core/test_memmove.out b/tests/core/test_memmove.out
new file mode 100644
index 00000000..e2a1ac2f
--- /dev/null
+++ b/tests/core/test_memmove.out
@@ -0,0 +1 @@
+memmove can be very very useful \ No newline at end of file
diff --git a/tests/core/test_memmove2.in b/tests/core/test_memmove2.in
new file mode 100644
index 00000000..2aed0b51
--- /dev/null
+++ b/tests/core/test_memmove2.in
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+int main() {
+ int sum = 0;
+ char buffer[256];
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ for (int k = 0; k < 35; k++) {
+ for (int t = 0; t < 256; t++) buffer[t] = t;
+ char *dest = buffer + i;
+ char *src = buffer + j;
+ if (dest == src) continue;
+ // printf("%d, %d, %d\n", i, j, k);
+ assert(memmove(dest, src, k) == dest);
+ for (int t = 0; t < 256; t++) sum += buffer[t];
+ }
+ }
+ }
+ printf("final: %d.\n", sum);
+ return 1;
+}
diff --git a/tests/core/test_memmove2.out b/tests/core/test_memmove2.out
new file mode 100644
index 00000000..0e06b2e7
--- /dev/null
+++ b/tests/core/test_memmove2.out
@@ -0,0 +1 @@
+final: -403200. \ No newline at end of file
diff --git a/tests/core/test_memmove3.in b/tests/core/test_memmove3.in
new file mode 100644
index 00000000..27f9055b
--- /dev/null
+++ b/tests/core/test_memmove3.in
@@ -0,0 +1,8 @@
+#include <stdio.h>
+#include <string.h>
+int main() {
+ char str[] = "memmove can be vvery useful....!";
+ memmove(str + 15, str + 16, 17);
+ puts(str);
+ return 0;
+}
diff --git a/tests/core/test_memmove3.out b/tests/core/test_memmove3.out
new file mode 100644
index 00000000..1adadcc2
--- /dev/null
+++ b/tests/core/test_memmove3.out
@@ -0,0 +1 @@
+memmove can be very useful....! \ No newline at end of file
diff --git a/tests/core/test_mmap.in b/tests/core/test_mmap.in
new file mode 100644
index 00000000..16c1c647
--- /dev/null
+++ b/tests/core/test_mmap.in
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <sys/mman.h>
+#include <assert.h>
+
+int main(int argc, char* argv[]) {
+ for (int i = 0; i < 10; i++) {
+ int* map = (int*)mmap(0, 5000, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_ANON, -1, 0);
+ /* TODO: Should we align to 4k?
+ assert(((int)map) % 4096 == 0); // aligned
+ */
+ assert(munmap(map, 5000) == 0);
+ }
+
+ const int NUM_BYTES = 8 * 1024 * 1024;
+ const int NUM_INTS = NUM_BYTES / sizeof(int);
+
+ int* map = (int*)mmap(0, NUM_BYTES, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_ANON, -1, 0);
+ assert(map != MAP_FAILED);
+
+ int i;
+
+ for (i = 0; i < NUM_INTS; i++) {
+ map[i] = i;
+ }
+
+ for (i = 0; i < NUM_INTS; i++) {
+ assert(map[i] == i);
+ }
+
+ assert(munmap(map, NUM_BYTES) == 0);
+
+ printf("hello,world");
+ return 0;
+}
diff --git a/tests/core/test_mmap.out b/tests/core/test_mmap.out
new file mode 100644
index 00000000..f2fff68f
--- /dev/null
+++ b/tests/core/test_mmap.out
@@ -0,0 +1 @@
+hello,world \ No newline at end of file
diff --git a/tests/core/test_mod_globalstruct.in b/tests/core/test_mod_globalstruct.in
new file mode 100644
index 00000000..3a8522cc
--- /dev/null
+++ b/tests/core/test_mod_globalstruct.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+struct malloc_params {
+ size_t magic, page_size;
+};
+
+malloc_params mparams;
+
+#define SIZE_T_ONE ((size_t)1)
+#define page_align(S) \
+ (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE))
+
+int main() {
+ mparams.page_size = 4096;
+ printf("*%d,%d,%d,%d*\n", mparams.page_size, page_align(1000),
+ page_align(6000), page_align(66474));
+ return 0;
+}
diff --git a/tests/core/test_mod_globalstruct.out b/tests/core/test_mod_globalstruct.out
new file mode 100644
index 00000000..3be9bc19
--- /dev/null
+++ b/tests/core/test_mod_globalstruct.out
@@ -0,0 +1 @@
+*4096,4096,8192,69632* \ No newline at end of file
diff --git a/tests/core/test_multiexception.in b/tests/core/test_multiexception.in
new file mode 100644
index 00000000..46acbbf3
--- /dev/null
+++ b/tests/core/test_multiexception.in
@@ -0,0 +1,50 @@
+#include <stdio.h>
+
+static int current_exception_id = 0;
+
+typedef struct {
+ int jmp;
+} jmp_state;
+
+void setjmp_func(jmp_state* s, int level) {
+ int prev_jmp = s->jmp;
+ int c_jmp;
+
+ if (level == 2) {
+ printf("level is 2, perform longjmp!\n");
+ throw 1;
+ }
+
+ c_jmp = current_exception_id++;
+ try {
+ printf("setjmp normal execution path, level: %d, prev_jmp: %d\n", level,
+ prev_jmp);
+ s->jmp = c_jmp;
+ setjmp_func(s, level + 1);
+ }
+ catch (int catched_eid) {
+ printf("caught %d\n", catched_eid);
+ if (catched_eid == c_jmp) {
+ printf("setjmp exception execution path, level: %d, prev_jmp: %d\n",
+ level, prev_jmp);
+ if (prev_jmp != -1) {
+ printf("prev_jmp is not empty, continue with longjmp!\n");
+ s->jmp = prev_jmp;
+ throw s->jmp;
+ }
+ } else {
+ throw;
+ }
+ }
+
+ printf("Exiting setjmp function, level: %d, prev_jmp: %d\n", level, prev_jmp);
+}
+
+int main(int argc, char* argv[]) {
+ jmp_state s;
+ s.jmp = -1;
+
+ setjmp_func(&s, 0);
+
+ return 0;
+}
diff --git a/tests/core/test_multiexception.out b/tests/core/test_multiexception.out
new file mode 100644
index 00000000..33efe46e
--- /dev/null
+++ b/tests/core/test_multiexception.out
@@ -0,0 +1,9 @@
+setjmp normal execution path, level: 0, prev_jmp: -1
+setjmp normal execution path, level: 1, prev_jmp: 0
+level is 2, perform longjmp!
+caught 1
+setjmp exception execution path, level: 1, prev_jmp: 0
+prev_jmp is not empty, continue with longjmp!
+caught 0
+setjmp exception execution path, level: 0, prev_jmp: -1
+Exiting setjmp function, level: 0, prev_jmp: -1
diff --git a/tests/core/test_negative_zero.in b/tests/core/test_negative_zero.in
new file mode 100644
index 00000000..395f84ce
--- /dev/null
+++ b/tests/core/test_negative_zero.in
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <math.h>
+
+int main() {
+#define TEST(x, y) printf("%.2f, %.2f ==> %.2f\n", x, y, copysign(x, y));
+ TEST(5.0f, 5.0f);
+ TEST(5.0f, -5.0f);
+ TEST(-5.0f, 5.0f);
+ TEST(-5.0f, -5.0f);
+ TEST(5.0f, 4.0f);
+ TEST(5.0f, -4.0f);
+ TEST(-5.0f, 4.0f);
+ TEST(-5.0f, -4.0f);
+ TEST(0.0f, 5.0f);
+ TEST(0.0f, -5.0f);
+ TEST(-0.0f, 5.0f);
+ TEST(-0.0f, -5.0f);
+ TEST(5.0f, 0.0f);
+ TEST(5.0f, -0.0f);
+ TEST(-5.0f, 0.0f);
+ TEST(-5.0f, -0.0f);
+ TEST(0.0f, 0.0f);
+ TEST(0.0f, -0.0f);
+ TEST(-0.0f, 0.0f);
+ TEST(-0.0f, -0.0f);
+ return 0;
+}
diff --git a/tests/core/test_negative_zero.out b/tests/core/test_negative_zero.out
new file mode 100644
index 00000000..5d792ffb
--- /dev/null
+++ b/tests/core/test_negative_zero.out
@@ -0,0 +1,20 @@
+5.00, 5.00 ==> 5.00
+5.00, -5.00 ==> -5.00
+-5.00, 5.00 ==> 5.00
+-5.00, -5.00 ==> -5.00
+5.00, 4.00 ==> 5.00
+5.00, -4.00 ==> -5.00
+-5.00, 4.00 ==> 5.00
+-5.00, -4.00 ==> -5.00
+0.00, 5.00 ==> 0.00
+0.00, -5.00 ==> -0.00
+-0.00, 5.00 ==> 0.00
+-0.00, -5.00 ==> -0.00
+5.00, 0.00 ==> 5.00
+5.00, -0.00 ==> -5.00
+-5.00, 0.00 ==> 5.00
+-5.00, -0.00 ==> -5.00
+0.00, 0.00 ==> 0.00
+0.00, -0.00 ==> -0.00
+-0.00, 0.00 ==> 0.00
+-0.00, -0.00 ==> -0.00
diff --git a/tests/core/test_perrar.in b/tests/core/test_perrar.in
new file mode 100644
index 00000000..d7c9eae7
--- /dev/null
+++ b/tests/core/test_perrar.in
@@ -0,0 +1,10 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int main(int argc, char** argv) {
+ int retval = open("NonExistingFile", O_RDONLY);
+ if (retval == -1) perror("Cannot open NonExistingFile");
+ return 0;
+}
diff --git a/tests/core/test_perrar.out b/tests/core/test_perrar.out
new file mode 100644
index 00000000..0de5f448
--- /dev/null
+++ b/tests/core/test_perrar.out
@@ -0,0 +1 @@
+Cannot open NonExistingFile: No such file or directory
diff --git a/tests/core/test_phiundef.in b/tests/core/test_phiundef.in
new file mode 100644
index 00000000..91273cc9
--- /dev/null
+++ b/tests/core/test_phiundef.in
@@ -0,0 +1,30 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+static int state;
+
+struct my_struct {
+ union {
+ struct {
+ unsigned char a;
+ unsigned char b;
+ } c;
+ unsigned int d;
+ } e;
+ unsigned int f;
+};
+
+int main(int argc, char **argv) {
+ struct my_struct r;
+
+ state = 0;
+
+ for (int i = 0; i < argc + 10; i++) {
+ if (state % 2 == 0)
+ r.e.c.a = 3;
+ else
+ printf("%d\n", r.e.c.a);
+ state++;
+ }
+ return 0;
+}
diff --git a/tests/core/test_phiundef.out b/tests/core/test_phiundef.out
new file mode 100644
index 00000000..3b04a039
--- /dev/null
+++ b/tests/core/test_phiundef.out
@@ -0,0 +1,5 @@
+3
+3
+3
+3
+3
diff --git a/tests/core/test_poll.in b/tests/core/test_poll.in
new file mode 100644
index 00000000..aa2c09ee
--- /dev/null
+++ b/tests/core/test_poll.in
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+
+int main() {
+ struct pollfd multi[5];
+ multi[0].fd = open("/file", O_RDONLY, 0777);
+ multi[1].fd = open("/device", O_RDONLY, 0777);
+ multi[2].fd = 123;
+ multi[3].fd = open("/file", O_RDONLY, 0777);
+ multi[4].fd = open("/file", O_RDONLY, 0777);
+ multi[0].events = POLLIN | POLLOUT | POLLNVAL | POLLERR;
+ multi[1].events = POLLIN | POLLOUT | POLLNVAL | POLLERR;
+ multi[2].events = POLLIN | POLLOUT | POLLNVAL | POLLERR;
+ multi[3].events = 0x00;
+ multi[4].events = POLLOUT | POLLNVAL | POLLERR;
+
+ printf("ret: %d\n", poll(multi, 5, 123));
+ printf("errno: %d\n", errno);
+ printf("multi[0].revents: %d\n", multi[0].revents == (POLLIN | POLLOUT));
+ printf("multi[1].revents: %d\n", multi[1].revents == (POLLIN | POLLOUT));
+ printf("multi[2].revents: %d\n", multi[2].revents == POLLNVAL);
+ printf("multi[3].revents: %d\n", multi[3].revents == 0);
+ printf("multi[4].revents: %d\n", multi[4].revents == POLLOUT);
+
+ return 0;
+}
diff --git a/tests/core/test_poll.out b/tests/core/test_poll.out
new file mode 100644
index 00000000..8ffd3264
--- /dev/null
+++ b/tests/core/test_poll.out
@@ -0,0 +1,7 @@
+ret: 4
+errno: 0
+multi[0].revents: 1
+multi[1].revents: 1
+multi[2].revents: 1
+multi[3].revents: 1
+multi[4].revents: 1
diff --git a/tests/core/test_polymorph.in b/tests/core/test_polymorph.in
new file mode 100644
index 00000000..1f24a1aa
--- /dev/null
+++ b/tests/core/test_polymorph.in
@@ -0,0 +1,33 @@
+#include <stdio.h>
+struct Pure {
+ virtual int implme() = 0;
+};
+struct Parent : Pure {
+ virtual int getit() {
+ return 11;
+ };
+ int implme() { return 32; }
+};
+struct Child : Parent {
+ int getit() { return 74; }
+ int implme() { return 1012; }
+};
+
+struct Other {
+ int one() { return 11; }
+ int two() { return 22; }
+};
+
+int main() {
+ Parent *x = new Parent();
+ Parent *y = new Child();
+ printf("*%d,%d,%d,%d*\n", x->getit(), y->getit(), x->implme(), y->implme());
+
+ Other *o = new Other;
+ int (Other::*Ls)() = &Other::one;
+ printf("*%d*\n", (o->*(Ls))());
+ Ls = &Other::two;
+ printf("*%d*\n", (o->*(Ls))());
+
+ return 0;
+}
diff --git a/tests/core/test_polymorph.out b/tests/core/test_polymorph.out
new file mode 100644
index 00000000..0d036bf0
--- /dev/null
+++ b/tests/core/test_polymorph.out
@@ -0,0 +1,3 @@
+*11,74,32,1012*
+*11*
+*22* \ No newline at end of file
diff --git a/tests/core/test_printf_2.in b/tests/core/test_printf_2.in
new file mode 100644
index 00000000..8fb16173
--- /dev/null
+++ b/tests/core/test_printf_2.in
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int main() {
+ char c = '1';
+ short s = 2;
+ int i = 3;
+ long long l = 4;
+ float f = 5.5;
+ double d = 6.6;
+
+ printf("%c,%hd,%d,%lld,%.1f,%.1llf\n", c, s, i, l, f, d);
+ printf("%#x,%#x\n", 1, 0);
+
+ return 0;
+}
diff --git a/tests/core/test_printf_2.out b/tests/core/test_printf_2.out
new file mode 100644
index 00000000..002cd93a
--- /dev/null
+++ b/tests/core/test_printf_2.out
@@ -0,0 +1,2 @@
+1,2,3,4,5.5,6.6
+0x1,0
diff --git a/tests/core/test_printf_more.in b/tests/core/test_printf_more.in
new file mode 100644
index 00000000..ad1cebc8
--- /dev/null
+++ b/tests/core/test_printf_more.in
@@ -0,0 +1,11 @@
+#include <stdio.h>
+int main() {
+ int size = snprintf(NULL, 0, "%s %d %.2f\n", "me and myself", 25, 1.345);
+ char buf[size];
+ snprintf(buf, size, "%s %d %.2f\n", "me and myself", 25, 1.345);
+ printf("%d : %s\n", size, buf);
+ char *buff = NULL;
+ asprintf(&buff, "%d waka %d\n", 21, 95);
+ puts(buff);
+ return 0;
+}
diff --git a/tests/core/test_printf_more.out b/tests/core/test_printf_more.out
new file mode 100644
index 00000000..e31f1d50
--- /dev/null
+++ b/tests/core/test_printf_more.out
@@ -0,0 +1,2 @@
+22 : me and myself 25 1.34
+21 waka 95
diff --git a/tests/core/test_ptrtoint.in b/tests/core/test_ptrtoint.in
new file mode 100644
index 00000000..88e91262
--- /dev/null
+++ b/tests/core/test_ptrtoint.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int main(int argc, const char *argv[]) {
+ char *a = new char[10];
+ char *a0 = a + 0;
+ char *a5 = a + 5;
+ int *b = new int[10];
+ int *b0 = b + 0;
+ int *b5 = b + 5;
+ int c = (int)b5 - (int)b0; // Emscripten should warn!
+ int d = (int)b5 - (int)b0; // Emscripten should warn!
+ printf("*%d*\n", (int)a5 - (int)a0);
+ return 0;
+}
diff --git a/tests/core/test_ptrtoint.out b/tests/core/test_ptrtoint.out
new file mode 100644
index 00000000..770e08e0
--- /dev/null
+++ b/tests/core/test_ptrtoint.out
@@ -0,0 +1 @@
+*5* \ No newline at end of file
diff --git a/tests/core/test_regex.in b/tests/core/test_regex.in
new file mode 100644
index 00000000..4f1bdd21
--- /dev/null
+++ b/tests/core/test_regex.in
@@ -0,0 +1,36 @@
+// This is from// http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frtref%2Fregexec.htm
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void) {
+ regex_t preg;
+ const char *string = "a very simple simple simple string";
+ const char *pattern = "\\(sim[a-z]le\\) \\1";
+ int rc;
+ size_t nmatch = 2;
+ regmatch_t pmatch[2];
+
+ if (0 != (rc = regcomp(&preg, pattern, 0))) {
+ printf("regcomp() failed, returning nonzero (%d)\n", rc);
+ exit(EXIT_FAILURE);
+ }
+
+ if (0 != (rc = regexec(&preg, string, nmatch, pmatch, 0))) {
+ printf("Failed to match '%s' with '%s',returning %d.\n", string, pattern,
+ rc);
+ } else {
+ printf(
+ "With the whole expression, "
+ "a matched substring \"%.*s\" is found at position %d to %d.\n",
+ pmatch[0].rm_eo - pmatch[0].rm_so, &string[pmatch[0].rm_so],
+ pmatch[0].rm_so, pmatch[0].rm_eo - 1);
+ printf(
+ "With the sub-expression, "
+ "a matched substring \"%.*s\" is found at position %d to %d.\n",
+ pmatch[1].rm_eo - pmatch[1].rm_so, &string[pmatch[1].rm_so],
+ pmatch[1].rm_so, pmatch[1].rm_eo - 1);
+ }
+ regfree(&preg);
+ return 0;
+}
diff --git a/tests/core/test_regex.out b/tests/core/test_regex.out
new file mode 100644
index 00000000..f238d2e3
--- /dev/null
+++ b/tests/core/test_regex.out
@@ -0,0 +1,2 @@
+With the whole expression, a matched substring "simple simple" is found at position 7 to 19.
+With the sub-expression, a matched substring "simple" is found at position 7 to 12. \ No newline at end of file
diff --git a/tests/core/test_reinterpreted_ptrs.in b/tests/core/test_reinterpreted_ptrs.in
new file mode 100644
index 00000000..9865c61f
--- /dev/null
+++ b/tests/core/test_reinterpreted_ptrs.in
@@ -0,0 +1,40 @@
+#include <stdio.h>
+
+class Foo {
+ private:
+ float bar;
+
+ public:
+ int baz;
+
+ Foo() : bar(0), baz(4711) {};
+
+ int getBar() const;
+};
+
+int Foo::getBar() const {
+ return this->bar;
+};
+
+const Foo *magic1 = reinterpret_cast<Foo *>(0xDEAD111F);
+const Foo *magic2 = reinterpret_cast<Foo *>(0xDEAD888F);
+
+static void runTest() {
+
+ const Foo *a = new Foo();
+ const Foo *b = a;
+
+ if (a->getBar() == 0) {
+ if (a->baz == 4712)
+ b = magic1;
+ else
+ b = magic2;
+ }
+
+ printf("%s\n",
+ (b == magic1 ? "magic1" : (b == magic2 ? "magic2" : "neither")));
+};
+
+extern "C" {
+int main(int argc, char **argv) { runTest(); }
+}
diff --git a/tests/core/test_reinterpreted_ptrs.out b/tests/core/test_reinterpreted_ptrs.out
new file mode 100644
index 00000000..36033502
--- /dev/null
+++ b/tests/core/test_reinterpreted_ptrs.out
@@ -0,0 +1 @@
+magic2 \ No newline at end of file
diff --git a/tests/core/test_rounding.in b/tests/core/test_rounding.in
new file mode 100644
index 00000000..af7d9099
--- /dev/null
+++ b/tests/core/test_rounding.in
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <math.h>
+
+int main() {
+ printf("%.1f ", round(1.4));
+ printf("%.1f ", round(1.6));
+ printf("%.1f ", round(-1.4));
+ printf("%.1f ", round(-1.6));
+
+ printf("%.1f ", round(1.5));
+ printf("%.1f ", round(2.5));
+ printf("%.1f ", round(-1.5));
+ printf("%.1f ", round(-2.5));
+
+ printf("%ld ", lrint(1.4));
+ printf("%ld ", lrint(1.6));
+ printf("%ld ", lrint(-1.4));
+ printf("%ld ", lrint(-1.6));
+
+ printf("%ld ", lrint(1.5));
+ printf("%ld ", lrint(2.5));
+ printf("%ld ", lrint(-1.5));
+ printf("%ld ", lrint(-2.5));
+
+ return 0;
+}
diff --git a/tests/core/test_rounding.out b/tests/core/test_rounding.out
new file mode 100644
index 00000000..b826ceab
--- /dev/null
+++ b/tests/core/test_rounding.out
@@ -0,0 +1 @@
+1.0 2.0 -1.0 -2.0 2.0 3.0 -2.0 -3.0 1 2 -1 -2 2 2 -2 -2 \ No newline at end of file
diff --git a/tests/core/test_simd.in b/tests/core/test_simd.in
new file mode 100644
index 00000000..5018b8e3
--- /dev/null
+++ b/tests/core/test_simd.in
@@ -0,0 +1,69 @@
+#include <stdio.h>
+
+#include <emscripten/vector.h>
+
+static inline float32x4 __attribute__((always_inline))
+ _mm_set_ps(const float __Z, const float __Y, const float __X,
+ const float __W) {
+ return (float32x4) {__W, __X, __Y, __Z};
+}
+
+static __inline__ float32x4 __attribute__((__always_inline__))
+ _mm_setzero_ps(void) {
+ return (float32x4) {0.0, 0.0, 0.0, 0.0};
+}
+
+int main(int argc, char **argv) {
+ float data[8];
+ for (int i = 0; i < 32; i++)
+ data[i] = (1 + i + argc) * (2 + i + argc * argc); // confuse optimizer
+ {
+ float32x4 *a = (float32x4 *)&data[0];
+ float32x4 *b = (float32x4 *)&data[4];
+ float32x4 c, d;
+ c = *a;
+ d = *b;
+ printf("1floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1],
+ (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
+ c = c + d;
+ printf("2floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1],
+ (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
+ d = c * d;
+ printf("3floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1],
+ (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
+ c = _mm_setzero_ps();
+ printf("zeros %d, %d, %d, %d\n", (int)c[0], (int)c[1], (int)c[2],
+ (int)c[3]);
+ }
+ {
+ int32x4 *a = (int32x4 *)&data[0];
+ int32x4 *b = (int32x4 *)&data[4];
+ int32x4 c, d, e, f;
+ c = *a;
+ d = *b;
+ printf("4ints! %d, %d, %d, %d %d, %d, %d, %d\n", c[0], c[1], c[2], c[3],
+ d[0], d[1], d[2], d[3]);
+ e = c + d;
+ f = c - d;
+ printf("5ints! %d, %d, %d, %d %d, %d, %d, %d\n", e[0], e[1], e[2], e[3],
+ f[0], f[1], f[2], f[3]);
+ e = c & d;
+ f = c | d;
+ e = ~c & d;
+ f = c ^ d;
+ printf("5intops! %d, %d, %d, %d %d, %d, %d, %d\n", e[0], e[1], e[2], e[3],
+ f[0], f[1], f[2], f[3]);
+ }
+ {
+ float32x4 c, d, e, f;
+ c = _mm_set_ps(9.0, 4.0, 0, -9.0);
+ d = _mm_set_ps(10.0, 14.0, -12, -2.0);
+ printf("6floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1],
+ (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
+ printf("7calcs: %d\n",
+ emscripten_float32x4_signmask(c)); // TODO: just not just
+ // compilation but output as well
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_simd.out b/tests/core/test_simd.out
new file mode 100644
index 00000000..08ca3738
--- /dev/null
+++ b/tests/core/test_simd.out
@@ -0,0 +1,8 @@
+1floats! 6, 12, 20, 30 42, 56, 72, 90
+2floats! 48, 68, 92, 120 42, 56, 72, 90
+3floats! 48, 68, 92, 120 2016, 3808, 6624, 10800
+zeros 0, 0, 0, 0
+4ints! 1086324736, 1094713344, 1101004800, 1106247680 1109917696, 1113587712, 1116733440, 1119092736
+5ints! -2098724864, -2086666240, -2077229056, -2069626880 -23592960, -18874368, -15728640, -12845056
+5intops! 36175872, 35651584, 34603008, 33816576 48758784, 52428800, 53477376, 54788096
+6floats! -9, 0, 4, 9 -2, -12, 14, 10
diff --git a/tests/core/test_simd2.in b/tests/core/test_simd2.in
new file mode 100644
index 00000000..be1655c2
--- /dev/null
+++ b/tests/core/test_simd2.in
@@ -0,0 +1,35 @@
+#include <stdio.h>
+
+typedef float __m128 __attribute__((__vector_size__(16)));
+
+static inline __m128 __attribute__((always_inline))
+ _mm_set_ps(const float __Z, const float __Y, const float __X,
+ const float __W) {
+ return (__m128) {__W, __X, __Y, __Z};
+}
+
+static inline void __attribute__((always_inline))
+ _mm_store_ps(float *__P, __m128 __A) {
+ *(__m128 *)__P = __A;
+}
+
+static inline __m128 __attribute__((always_inline))
+ _mm_add_ps(__m128 __A, __m128 __B) {
+ return __A + __B;
+}
+
+using namespace std;
+
+int main(int argc, char **argv) {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(9.0, 4.0, 0, -9.0);
+ __m128 v2 = _mm_set_ps(7.0, 3.0, 2.5, 1.0);
+ __m128 v3 = _mm_add_ps(v1, v2);
+ _mm_store_ps(ar, v3);
+
+ for (int i = 0; i < 4; i++) {
+ printf("%f\n", ar[i]);
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_simd2.out b/tests/core/test_simd2.out
new file mode 100644
index 00000000..4b01ec86
--- /dev/null
+++ b/tests/core/test_simd2.out
@@ -0,0 +1,4 @@
+-8.000000
+2.500000
+7.000000
+16.000000
diff --git a/tests/core/test_simd3.in b/tests/core/test_simd3.in
new file mode 100644
index 00000000..f005d847
--- /dev/null
+++ b/tests/core/test_simd3.in
@@ -0,0 +1,488 @@
+#include <iostream>
+#include <emmintrin.h>
+#include <assert.h>
+#include <stdint.h>
+#include <bitset>
+
+using namespace std;
+
+void testSetPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v = _mm_set_ps(1.0, 2.0, 3.0, 4.0);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 4.0);
+ assert(ar[1] == 3.0);
+ assert(ar[2] == 2.0);
+ assert(ar[3] == 1.0);
+}
+
+void testSet1Ps() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v = _mm_set1_ps(5.5);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 5.5);
+ assert(ar[1] == 5.5);
+ assert(ar[2] == 5.5);
+ assert(ar[3] == 5.5);
+}
+
+void testSetZeroPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v = _mm_setzero_ps();
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 0);
+ assert(ar[1] == 0);
+ assert(ar[2] == 0);
+ assert(ar[3] == 0);
+}
+
+void testSetEpi32() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v = _mm_set_epi32(5, 7, 126, 381);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 381);
+ assert(ar[1] == 126);
+ assert(ar[2] == 7);
+ assert(ar[3] == 5);
+ v = _mm_set_epi32(0x55555555, 0xaaaaaaaa, 0xffffffff, 0x12345678);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 0x12345678);
+ assert(ar[1] == 0xffffffff);
+ assert(ar[2] == 0xaaaaaaaa);
+ assert(ar[3] == 0x55555555);
+}
+
+void testSet1Epi32() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v = _mm_set1_epi32(-5);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == -5);
+ assert(ar[1] == -5);
+ assert(ar[2] == -5);
+ assert(ar[3] == -5);
+}
+
+void testSetZeroSi128() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v = _mm_setzero_si128();
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 0);
+ assert(ar[1] == 0);
+ assert(ar[2] == 0);
+ assert(ar[3] == 0);
+}
+
+void testBitCasts() {
+ int32_t __attribute__((__aligned__(16))) ar1[4];
+ float __attribute__((__aligned__(16))) ar2[4];
+ __m128i v1 = _mm_set_epi32(0x3f800000, 0x40000000, 0x40400000, 0x40800000);
+ __m128 v2 = _mm_castsi128_ps(v1);
+ _mm_store_ps(ar2, v2);
+ assert(ar2[0] == 4.0);
+ assert(ar2[1] == 3.0);
+ assert(ar2[2] == 2.0);
+ assert(ar2[3] == 1.0);
+ v2 = _mm_set_ps(5.0, 6.0, 7.0, 8.0);
+ v1 = _mm_castps_si128(v2);
+ _mm_store_si128((__m128i *)ar1, v1);
+ assert(ar1[0] == 0x41000000);
+ assert(ar1[1] == 0x40e00000);
+ assert(ar1[2] == 0x40c00000);
+ assert(ar1[3] == 0x40a00000);
+ float w = 0;
+ float z = -278.3;
+ float y = 5.2;
+ float x = -987654321;
+ v1 = _mm_castps_si128(_mm_set_ps(w, z, y, x));
+ _mm_store_ps(ar2, _mm_castsi128_ps(v1));
+ assert(ar2[0] == x);
+ assert(ar2[1] == y);
+ assert(ar2[2] == z);
+ assert(ar2[3] == w);
+ /*
+ std::bitset<sizeof(float)*CHAR_BIT> bits1x(*reinterpret_cast<unsigned
+ long*>(&(ar2[0])));
+ std::bitset<sizeof(float)*CHAR_BIT> bits1y(*reinterpret_cast<unsigned
+ long*>(&(ar2[1])));
+ std::bitset<sizeof(float)*CHAR_BIT> bits1z(*reinterpret_cast<unsigned
+ long*>(&(ar2[2])));
+ std::bitset<sizeof(float)*CHAR_BIT> bits1w(*reinterpret_cast<unsigned
+ long*>(&(ar2[3])));
+ std::bitset<sizeof(float)*CHAR_BIT> bits2x(*reinterpret_cast<unsigned
+ long*>(&x));
+ std::bitset<sizeof(float)*CHAR_BIT> bits2y(*reinterpret_cast<unsigned
+ long*>(&y));
+ std::bitset<sizeof(float)*CHAR_BIT> bits2z(*reinterpret_cast<unsigned
+ long*>(&z));
+ std::bitset<sizeof(float)*CHAR_BIT> bits2w(*reinterpret_cast<unsigned
+ long*>(&w));
+ assert(bits1x == bits2x);
+ assert(bits1y == bits2y);
+ assert(bits1z == bits2z);
+ assert(bits1w == bits2w);
+ */
+ v2 = _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0, 0x5555cccc, 0xaaaaaaaa));
+ _mm_store_si128((__m128i *)ar1, _mm_castps_si128(v2));
+ assert(ar1[0] == 0xaaaaaaaa);
+ assert(ar1[1] == 0x5555cccc);
+ assert(ar1[2] == 0);
+ assert(ar1[3] == 0xffffffff);
+}
+
+void testConversions() {
+ int32_t __attribute__((__aligned__(16))) ar1[4];
+ float __attribute__((__aligned__(16))) ar2[4];
+ __m128i v1 = _mm_set_epi32(0, -3, -517, 256);
+ __m128 v2 = _mm_cvtepi32_ps(v1);
+ _mm_store_ps(ar2, v2);
+ assert(ar2[0] == 256.0);
+ assert(ar2[1] == -517.0);
+ assert(ar2[2] == -3.0);
+ assert(ar2[3] == 0);
+ v2 = _mm_set_ps(5.0, 6.0, 7.45, -8.0);
+ v1 = _mm_cvtps_epi32(v2);
+ _mm_store_si128((__m128i *)ar1, v1);
+ assert(ar1[0] == -8);
+ assert(ar1[1] == 7);
+ assert(ar1[2] == 6);
+ assert(ar1[3] == 5);
+}
+
+void testMoveMaskPs() {
+ __m128 v =
+ _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0xffffffff, 0, 0xffffffff));
+ int mask = _mm_movemask_ps(v);
+ assert(mask == 13);
+}
+
+void testAddPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(4.0, 3.0, 2.0, 1.0);
+ __m128 v2 = _mm_set_ps(10.0, 20.0, 30.0, 40.0);
+ __m128 v = _mm_add_ps(v1, v2);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 41.0);
+ assert(ar[1] == 32.0);
+ assert(ar[2] == 23.0);
+ assert(ar[3] == 14.0);
+}
+
+void testSubPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(4.0, 3.0, 2.0, 1.0);
+ __m128 v2 = _mm_set_ps(10.0, 20.0, 30.0, 40.0);
+ __m128 v = _mm_sub_ps(v1, v2);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == -39.0);
+ assert(ar[1] == -28.0);
+ assert(ar[2] == -17.0);
+ assert(ar[3] == -6.0);
+}
+
+void testMulPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(4.0, 3.0, 2.0, 1.0);
+ __m128 v2 = _mm_set_ps(10.0, 20.0, 30.0, 40.0);
+ __m128 v = _mm_mul_ps(v1, v2);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 40.0);
+ assert(ar[1] == 60.0);
+ assert(ar[2] == 60.0);
+ assert(ar[3] == 40.0);
+}
+
+void testDivPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(4.0, 9.0, 8.0, 1.0);
+ __m128 v2 = _mm_set_ps(2.0, 3.0, 1.0, 0.5);
+ __m128 v = _mm_div_ps(v1, v2);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 2.0);
+ assert(ar[1] == 8.0);
+ assert(ar[2] == 3.0);
+ assert(ar[3] == 2.0);
+}
+
+void testMinPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(-20.0, 10.0, 30.0, 0.5);
+ __m128 v2 = _mm_set_ps(2.0, 1.0, 50.0, 0.0);
+ __m128 v = _mm_min_ps(v1, v2);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 0.0);
+ assert(ar[1] == 30.0);
+ assert(ar[2] == 1.0);
+ assert(ar[3] == -20.0);
+}
+
+void testMaxPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(-20.0, 10.0, 30.0, 0.5);
+ __m128 v2 = _mm_set_ps(2.5, 5.0, 55.0, 1.0);
+ __m128 v = _mm_max_ps(v1, v2);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 1.0);
+ assert(ar[1] == 55.0);
+ assert(ar[2] == 10.0);
+ assert(ar[3] == 2.5);
+}
+
+void testSqrtPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(16.0, 9.0, 4.0, 1.0);
+ __m128 v = _mm_sqrt_ps(v1);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 1.0);
+ assert(ar[1] == 2.0);
+ assert(ar[2] == 3.0);
+ assert(ar[3] == 4.0);
+}
+
+void testCmpLtPs() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
+ __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
+ __m128 v = _mm_cmplt_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
+ assert(ar[0] == 0xffffffff);
+ assert(ar[1] == 0);
+ assert(ar[2] == 0);
+ assert(ar[3] == 0xffffffff);
+ assert(_mm_movemask_ps(v) == 9);
+}
+
+void testCmpLePs() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
+ __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
+ __m128 v = _mm_cmple_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
+ assert(ar[0] == 0xffffffff);
+ assert(ar[1] == 0);
+ assert(ar[2] == 0xffffffff);
+ assert(ar[3] == 0xffffffff);
+ assert(_mm_movemask_ps(v) == 13);
+}
+
+void testCmpEqPs() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
+ __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
+ __m128 v = _mm_cmpeq_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
+ assert(ar[0] == 0);
+ assert(ar[1] == 0);
+ assert(ar[2] == 0xffffffff);
+ assert(ar[3] == 0);
+ assert(_mm_movemask_ps(v) == 4);
+}
+
+void testCmpGePs() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
+ __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
+ __m128 v = _mm_cmpge_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
+ assert(ar[0] == 0);
+ assert(ar[1] == 0xffffffff);
+ assert(ar[2] == 0xffffffff);
+ assert(ar[3] == 0);
+ assert(_mm_movemask_ps(v) == 6);
+}
+
+void testCmpGtPs() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
+ __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
+ __m128 v = _mm_cmpgt_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
+ assert(ar[0] == 0);
+ assert(ar[1] == 0xffffffff);
+ assert(ar[2] == 0);
+ assert(ar[3] == 0);
+ assert(_mm_movemask_ps(v) == 2);
+}
+
+void testAndPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(425, -501, -32, 68);
+ __m128 v2 =
+ _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0xffffffff, 0, 0xffffffff));
+ __m128 v = _mm_and_ps(v1, v2);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 68);
+ assert(ar[1] == 0);
+ assert(ar[2] == -501);
+ assert(ar[3] == 425);
+ int32_t __attribute__((__aligned__(16))) ar2[4];
+ v1 = _mm_castsi128_ps(
+ _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa));
+ v2 = _mm_castsi128_ps(
+ _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
+ v = _mm_and_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar2, _mm_castps_si128(v));
+ assert(ar2[0] == 0);
+ assert(ar2[1] == 0);
+ assert(ar2[2] == 0);
+ assert(ar2[3] == 0);
+}
+
+void testAndNotPs() {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(425, -501, -32, 68);
+ __m128 v2 =
+ _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0xffffffff, 0, 0xffffffff));
+ __m128 v = _mm_andnot_ps(v2, v1);
+ _mm_store_ps(ar, v);
+ assert(ar[0] == 0);
+ assert(ar[1] == -32);
+ assert(ar[2] == 0);
+ assert(ar[3] == 0);
+ int32_t __attribute__((__aligned__(16))) ar2[4];
+ v1 = _mm_castsi128_ps(
+ _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa));
+ v2 = _mm_castsi128_ps(
+ _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
+ v = _mm_andnot_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar2, _mm_castps_si128(v));
+ assert(ar2[0] == 0x55555555);
+ assert(ar2[1] == 0x55555555);
+ assert(ar2[2] == 0x55555555);
+ assert(ar2[3] == 0x55555555);
+}
+
+void testOrPs() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 =
+ _mm_castsi128_ps(_mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0));
+ __m128 v2 = _mm_castsi128_ps(
+ _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
+ __m128 v = _mm_or_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
+ assert(ar[0] == 0x55555555);
+ assert(ar[1] == 0xffffffff);
+ assert(ar[2] == 0xffffffff);
+ assert(ar[3] == 0xffffffff);
+}
+
+void testXorPs() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 =
+ _mm_castsi128_ps(_mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0));
+ __m128 v2 = _mm_castsi128_ps(
+ _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
+ __m128 v = _mm_xor_ps(v1, v2);
+ _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
+ assert(ar[0] == 0x55555555);
+ assert(ar[1] == 0xaaaaaaaa);
+ assert(ar[2] == 0xffffffff);
+ assert(ar[3] == 0xffffffff);
+}
+
+void testAndSi128() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa);
+ __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
+ __m128i v = _mm_and_si128(v1, v2);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 0);
+ assert(ar[1] == 0);
+ assert(ar[2] == 0);
+ assert(ar[3] == 0);
+}
+
+void testAndNotSi128() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa);
+ __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
+ __m128i v = _mm_andnot_si128(v1, v2);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 0x55555555);
+ assert(ar[1] == 0x55555555);
+ assert(ar[2] == 0x55555555);
+ assert(ar[3] == 0x55555555);
+}
+
+void testOrSi128() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0);
+ __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
+ __m128i v = _mm_or_si128(v1, v2);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 0x55555555);
+ assert(ar[1] == 0xffffffff);
+ assert(ar[2] == 0xffffffff);
+ assert(ar[3] == 0xffffffff);
+}
+
+void testXorSi128() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0);
+ __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
+ __m128i v = _mm_xor_si128(v1, v2);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 0x55555555);
+ assert(ar[1] == 0xaaaaaaaa);
+ assert(ar[2] == 0xffffffff);
+ assert(ar[3] == 0xffffffff);
+}
+
+void testAddEpi32() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v1 = _mm_set_epi32(4, 3, 2, 1);
+ __m128i v2 = _mm_set_epi32(10, 20, 30, 40);
+ __m128i v = _mm_add_epi32(v1, v2);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == 41);
+ assert(ar[1] == 32);
+ assert(ar[2] == 23);
+ assert(ar[3] == 14);
+}
+
+void testSubEpi32() {
+ int32_t __attribute__((__aligned__(16))) ar[4];
+ __m128i v1 = _mm_set_epi32(4, 3, 2, 1);
+ __m128i v2 = _mm_set_epi32(10, 20, 30, 40);
+ __m128i v = _mm_sub_epi32(v1, v2);
+ _mm_store_si128((__m128i *)ar, v);
+ assert(ar[0] == -39);
+ assert(ar[1] == -28);
+ assert(ar[2] == -17);
+ assert(ar[3] == -6);
+}
+
+int main(int argc, char **argv) {
+ testSetPs();
+ testSet1Ps();
+ testSetZeroPs();
+ testSetEpi32();
+ testSet1Epi32();
+ testSetZeroSi128();
+ testBitCasts();
+ testConversions();
+ testMoveMaskPs();
+ testAddPs();
+ testSubPs();
+ testMulPs();
+ testDivPs();
+ testMaxPs();
+ testMinPs();
+ testSqrtPs();
+ testCmpLtPs();
+ testCmpLePs();
+ testCmpEqPs();
+ testCmpGePs();
+ testCmpGtPs();
+ testAndPs();
+ testAndNotPs();
+ testOrPs();
+ testXorPs();
+ testAndSi128();
+ testAndNotSi128();
+ testOrSi128();
+ testXorSi128();
+ testAddEpi32();
+ testSubEpi32();
+ printf("DONE");
+ return 0;
+}
diff --git a/tests/core/test_simd3.out b/tests/core/test_simd3.out
new file mode 100644
index 00000000..09626497
--- /dev/null
+++ b/tests/core/test_simd3.out
@@ -0,0 +1 @@
+DONE \ No newline at end of file
diff --git a/tests/core/test_sintvars.in b/tests/core/test_sintvars.in
new file mode 100644
index 00000000..570dba48
--- /dev/null
+++ b/tests/core/test_sintvars.in
@@ -0,0 +1,24 @@
+#include <stdio.h>
+struct S {
+ char *match_start;
+ char *strstart;
+};
+int main() {
+ struct S _s;
+ struct S *s = &_s;
+ unsigned short int sh;
+
+ s->match_start = (char *)32522;
+ s->strstart = (char *)(32780);
+ printf("*%d,%d,%d*\n", (int)s->strstart, (int)s->match_start,
+ (int)(s->strstart - s->match_start));
+ sh = s->strstart - s->match_start;
+ printf("*%d,%d*\n", sh, sh >> 7);
+
+ s->match_start = (char *)32999;
+ s->strstart = (char *)(32780);
+ printf("*%d,%d,%d*\n", (int)s->strstart, (int)s->match_start,
+ (int)(s->strstart - s->match_start));
+ sh = s->strstart - s->match_start;
+ printf("*%d,%d*\n", sh, sh >> 7);
+}
diff --git a/tests/core/test_sintvars.out b/tests/core/test_sintvars.out
new file mode 100644
index 00000000..aea5592e
--- /dev/null
+++ b/tests/core/test_sintvars.out
@@ -0,0 +1,4 @@
+*32780,32522,258*
+*258,2*
+*32780,32999,-219*
+*65317,510* \ No newline at end of file
diff --git a/tests/core/test_sizeof.in b/tests/core/test_sizeof.in
new file mode 100644
index 00000000..1186ce41
--- /dev/null
+++ b/tests/core/test_sizeof.in
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <string.h>
+#include "emscripten.h"
+
+struct A {
+ int x, y;
+};
+
+int main(int argc, const char *argv[]) {
+ int *a = new int[10];
+ int *b = new int[1];
+ int *c = new int[10];
+ for (int i = 0; i < 10; i++) a[i] = 2;
+ *b = 5;
+ for (int i = 0; i < 10; i++) c[i] = 8;
+ printf("*%d,%d,%d,%d,%d*\n", a[0], a[9], *b, c[0], c[9]);
+ // Should overwrite a, but not touch b!
+ memcpy(a, c, 10 * sizeof(int));
+ printf("*%d,%d,%d,%d,%d*\n", a[0], a[9], *b, c[0], c[9]);
+
+ // Part 2
+ A as[3] = {{5, 12}, {6, 990}, {7, 2}};
+ memcpy(&as[0], &as[2], sizeof(A));
+
+ printf("*%d,%d,%d,%d,%d,%d*\n", as[0].x, as[0].y, as[1].x, as[1].y, as[2].x,
+ as[2].y);
+ return 0;
+}
diff --git a/tests/core/test_sizeof.out b/tests/core/test_sizeof.out
new file mode 100644
index 00000000..43d2c3b7
--- /dev/null
+++ b/tests/core/test_sizeof.out
@@ -0,0 +1 @@
+*2,2,5,8,8***8,8,5,8,8***7,2,6,990,7,2* \ No newline at end of file
diff --git a/tests/core/test_sscanf.in b/tests/core/test_sscanf.in
new file mode 100644
index 00000000..d5289fe5
--- /dev/null
+++ b/tests/core/test_sscanf.in
@@ -0,0 +1,91 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main() {
+#define CHECK(str) \
+ { \
+ char name[1000]; \
+ memset(name, 0, 1000); \
+ int prio = 99; \
+ sscanf(str, "%s %d", name, &prio); \
+ printf("%s : %d\n", name, prio); \
+ }
+ CHECK("en-us 2");
+ CHECK("en-r");
+ CHECK("en 3");
+
+ printf("%f, %f\n", atof("1.234567"), atof("cheez"));
+
+ char float_formats[] = "fegE";
+ char format[] = "%_";
+ for (int i = 0; i < 4; ++i) {
+ format[1] = float_formats[i];
+
+ float n = -1;
+ sscanf(" 2.8208", format, &n);
+ printf("%.4f\n", n);
+
+ float a = -1;
+ sscanf("-3.03", format, &a);
+ printf("%.4f\n", a);
+ }
+
+ char buffy[100];
+ sscanf("cheez some thing moar 123\nyet more\n", "cheez %s", buffy);
+ printf("|%s|\n", buffy);
+ sscanf("cheez something\nmoar 123\nyet more\n", "cheez %s", buffy);
+ printf("|%s|\n", buffy);
+ sscanf("cheez somethingmoar\tyet more\n", "cheez %s", buffy);
+ printf("|%s|\n", buffy);
+
+ int numverts = -1;
+ printf("%d\n",
+ sscanf(" numverts 1499\n", " numverts %d",
+ &numverts)); // white space is the same, even if tab vs space
+ printf("%d\n", numverts);
+
+ int index;
+ float u, v;
+ short start, count;
+ printf("%d\n",
+ sscanf(" vert 87 ( 0.481565 0.059481 ) 0 1\n",
+ " vert %d ( %f %f ) %hu %hu", &index, &u, &v, &start, &count));
+ printf("%d,%.6f,%.6f,%hu,%hu\n", index, u, v, start, count);
+
+ int neg, neg2, neg3 = 0;
+ printf("%d\n", sscanf("-123 -765 -34-6", "%d %u %d", &neg, &neg2, &neg3));
+ printf("%d,%u,%d\n", neg, neg2, neg3);
+
+ {
+ int a = 0;
+ sscanf("1", "%i", &a);
+ printf("%i\n", a);
+ }
+
+ char buf1[100], buf2[100], buf3[100], buf4[100];
+
+ int numItems = sscanf("level=4:ref=3", "%255[^:=]=%255[^:]:%255[^=]=%255c",
+ buf1, buf2, buf3, buf4);
+ printf("%d, %s, %s, %s, %s\n", numItems, buf1, buf2, buf3, buf4);
+
+ numItems = sscanf("def|456", "%[a-z]|%[0-9]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
+ numItems = sscanf("3-4,-ab", "%[-0-9],%[ab-z-]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
+ numItems = sscanf("Hello,World", "%[A-Za-z],%[^0-9]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
+ numItems = sscanf("Hello4711", "%[^0-9],%[^0-9]", buf1, buf2);
+ printf("%d, %s\n", numItems, buf1);
+
+ numItems = sscanf("JavaScript", "%4[A-Za-z]", buf1);
+ printf("%d, %s\n", numItems, buf1);
+
+ numItems = sscanf("[]", "%1[[]%1[]]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
+ return 0;
+}
diff --git a/tests/core/test_sscanf.out b/tests/core/test_sscanf.out
new file mode 100644
index 00000000..f9c3d478
--- /dev/null
+++ b/tests/core/test_sscanf.out
@@ -0,0 +1,29 @@
+en-us : 2
+en-r : 99
+en : 3
+1.234567, 0.000000
+2.8208
+-3.0300
+2.8208
+-3.0300
+2.8208
+-3.0300
+2.8208
+-3.0300
+|some|
+|something|
+|somethingmoar|
+1
+1499
+5
+87,0.481565,0.059481,0,1
+3
+-123,4294966531,-34
+1
+4, level, 4, ref, 3
+2, def, 456
+2, 3-4, -ab
+2, Hello, World
+1, Hello
+1, Java
+2, [, ] \ No newline at end of file
diff --git a/tests/core/test_sscanf_3.in b/tests/core/test_sscanf_3.in
new file mode 100644
index 00000000..e21897ed
--- /dev/null
+++ b/tests/core/test_sscanf_3.in
@@ -0,0 +1,17 @@
+#include <stdint.h>
+#include <stdio.h>
+
+int main() {
+
+ int64_t s, m, l;
+ printf("%d\n", sscanf("123 1073741823 1125899906842620", "%lld %lld %lld", &s,
+ &m, &l));
+ printf("%lld,%lld,%lld\n", s, m, l);
+
+ int64_t negS, negM, negL;
+ printf("%d\n", sscanf("-123 -1073741823 -1125899906842620", "%lld %lld %lld",
+ &negS, &negM, &negL));
+ printf("%lld,%lld,%lld\n", negS, negM, negL);
+
+ return 0;
+}
diff --git a/tests/core/test_sscanf_3.out b/tests/core/test_sscanf_3.out
new file mode 100644
index 00000000..fe1d5b41
--- /dev/null
+++ b/tests/core/test_sscanf_3.out
@@ -0,0 +1,4 @@
+3
+123,1073741823,1125899906842620
+3
+-123,-1073741823,-1125899906842620
diff --git a/tests/core/test_sscanf_4.in b/tests/core/test_sscanf_4.in
new file mode 100644
index 00000000..c9e3b5f1
--- /dev/null
+++ b/tests/core/test_sscanf_4.in
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main() {
+ char pYear[16], pMonth[16], pDay[16], pDate[64];
+ printf("%d\n", sscanf("Nov 19 2012", "%s%s%s", pMonth, pDay, pYear));
+ printf("day %s, month %s, year %s \n", pDay, pMonth, pYear);
+ return (0);
+}
diff --git a/tests/core/test_sscanf_4.out b/tests/core/test_sscanf_4.out
new file mode 100644
index 00000000..02dba361
--- /dev/null
+++ b/tests/core/test_sscanf_4.out
@@ -0,0 +1,2 @@
+3
+day 19, month Nov, year 2012 \ No newline at end of file
diff --git a/tests/core/test_sscanf_5.in b/tests/core/test_sscanf_5.in
new file mode 100644
index 00000000..c344258d
--- /dev/null
+++ b/tests/core/test_sscanf_5.in
@@ -0,0 +1,13 @@
+#include "stdio.h"
+
+static const char *colors[] = {" c black", ". c #001100", "X c #111100"};
+
+int main() {
+ unsigned char code;
+ char color[32];
+ int rcode;
+ for (int i = 0; i < 3; i++) {
+ rcode = sscanf(colors[i], "%c c %s", &code, color);
+ printf("%i, %c, %s\n", rcode, code, color);
+ }
+}
diff --git a/tests/core/test_sscanf_5.out b/tests/core/test_sscanf_5.out
new file mode 100644
index 00000000..823ae41f
--- /dev/null
+++ b/tests/core/test_sscanf_5.out
@@ -0,0 +1,3 @@
+2, , black
+2, ., #001100
+2, X, #111100 \ No newline at end of file
diff --git a/tests/core/test_sscanf_6.in b/tests/core/test_sscanf_6.in
new file mode 100644
index 00000000..63ede53f
--- /dev/null
+++ b/tests/core/test_sscanf_6.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <string.h>
+int main() {
+ char *date = "18.07.2013w";
+ char c[10];
+ memset(c, 0, 10);
+ int y, m, d, i;
+ i = sscanf(date, "%d.%d.%4d%c", &d, &m, &y, c);
+ printf("date: %s; day %2d, month %2d, year %4d, extra: %c, %d\n", date, d, m,
+ y, c[0], i);
+ i = sscanf(date, "%d.%d.%3c", &d, &m, c);
+ printf("date: %s; day %2d, month %2d, year %4d, extra: %s, %d\n", date, d, m,
+ y, c, i);
+}
diff --git a/tests/core/test_sscanf_6.out b/tests/core/test_sscanf_6.out
new file mode 100644
index 00000000..4aee073e
--- /dev/null
+++ b/tests/core/test_sscanf_6.out
@@ -0,0 +1,2 @@
+date: 18.07.2013w; day 18, month 7, year 2013, extra: w, 4
+date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3
diff --git a/tests/core/test_sscanf_caps.in b/tests/core/test_sscanf_caps.in
new file mode 100644
index 00000000..b0936036
--- /dev/null
+++ b/tests/core/test_sscanf_caps.in
@@ -0,0 +1,8 @@
+#include "stdio.h"
+
+int main() {
+ unsigned int a;
+ float e, f, g;
+ sscanf("a 1.1 1.1 1.1", "%X %E %F %G", &a, &e, &f, &g);
+ printf("%d %.1F %.1F %.1F\n", a, e, f, g);
+}
diff --git a/tests/core/test_sscanf_caps.out b/tests/core/test_sscanf_caps.out
new file mode 100644
index 00000000..20e20fe8
--- /dev/null
+++ b/tests/core/test_sscanf_caps.out
@@ -0,0 +1 @@
+10 1.1 1.1 1.1 \ No newline at end of file
diff --git a/tests/core/test_sscanf_float.in b/tests/core/test_sscanf_float.in
new file mode 100644
index 00000000..29fe2d56
--- /dev/null
+++ b/tests/core/test_sscanf_float.in
@@ -0,0 +1,10 @@
+#include "stdio.h"
+
+int main() {
+ float f1, f2, f3, f4, f5, f6, f7, f8, f9;
+ sscanf("0.512 0.250x5.129_-9.98 1.12*+54.32E3 +54.32E3^87.5E-3 87.5E-3$",
+ "%f %fx%f_%f %f*%f %f^%f %f$", &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8,
+ &f9);
+ printf("\n%f, %f, %f, %f, %f, %f, %f, %f, %f\n", f1, f2, f3, f4, f5, f6, f7,
+ f8, f9);
+}
diff --git a/tests/core/test_sscanf_float.out b/tests/core/test_sscanf_float.out
new file mode 100644
index 00000000..ea5a276d
--- /dev/null
+++ b/tests/core/test_sscanf_float.out
@@ -0,0 +1,2 @@
+
+0.512000, 0.250000, 5.129000, -9.980000, 1.120000, 54320.000000, 54320.000000, 0.087500, 0.087500
diff --git a/tests/core/test_sscanf_hex.in b/tests/core/test_sscanf_hex.in
new file mode 100644
index 00000000..d8175e82
--- /dev/null
+++ b/tests/core/test_sscanf_hex.in
@@ -0,0 +1,7 @@
+#include "stdio.h"
+
+int main() {
+ unsigned int a, b;
+ sscanf("0x12AB 12AB", "%x %x", &a, &b);
+ printf("%d %d\n", a, b);
+}
diff --git a/tests/core/test_sscanf_hex.out b/tests/core/test_sscanf_hex.out
new file mode 100644
index 00000000..ac855044
--- /dev/null
+++ b/tests/core/test_sscanf_hex.out
@@ -0,0 +1 @@
+4779 4779 \ No newline at end of file
diff --git a/tests/core/test_sscanf_n.in b/tests/core/test_sscanf_n.in
new file mode 100644
index 00000000..b383a3d7
--- /dev/null
+++ b/tests/core/test_sscanf_n.in
@@ -0,0 +1,19 @@
+#include <stdio.h>
+int main() {
+ char *line = "version 1.0";
+ int i, l, lineno;
+ char word[80];
+ if (sscanf(line, "%s%n", word, &l) != 1) {
+ printf("Header format error, line %d\n", lineno);
+ }
+ printf("[DEBUG] word 1: %s, l: %d\n", word, l);
+
+ int x = sscanf("one %n two", "%s %n", word, &l);
+ printf("%d,%s,%d\n", x, word, l);
+ {
+ int a, b, c, count;
+ count = sscanf("12345 6789", "%d %n%d", &a, &b, &c);
+ printf("%i %i %i %i\n", count, a, b, c);
+ }
+ return 0;
+}
diff --git a/tests/core/test_sscanf_n.out b/tests/core/test_sscanf_n.out
new file mode 100644
index 00000000..c3ce6f04
--- /dev/null
+++ b/tests/core/test_sscanf_n.out
@@ -0,0 +1,3 @@
+[DEBUG] word 1: version, l: 7
+1,one,4
+2 12345 6 6789
diff --git a/tests/core/test_sscanf_other_whitespace.in b/tests/core/test_sscanf_other_whitespace.in
new file mode 100644
index 00000000..467fa4f0
--- /dev/null
+++ b/tests/core/test_sscanf_other_whitespace.in
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+int main() {
+ short int x;
+ short int y;
+
+ const char* buffer[] = {
+ "\t2\t3\t", /* TAB - horizontal tab */
+ "\t\t5\t\t7\t\t", "\n11\n13\n", /* LF - line feed */
+ "\n\n17\n\n19\n\n", "\v23\v29\v", /* VT - vertical tab */
+ "\v\v31\v\v37\v\v", "\f41\f43\f", /* FF - form feed */
+ "\f\f47\f\f53\f\f", "\r59\r61\r", /* CR - carrage return */
+ "\r\r67\r\r71\r\r"};
+
+ for (int i = 0; i < 10; ++i) {
+ x = 0;
+ y = 0;
+ sscanf(buffer[i], " %d %d ", &x, &y);
+ printf("%d, %d, ", x, y);
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_sscanf_other_whitespace.out b/tests/core/test_sscanf_other_whitespace.out
new file mode 100644
index 00000000..0d0f4beb
--- /dev/null
+++ b/tests/core/test_sscanf_other_whitespace.out
@@ -0,0 +1 @@
+2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, \ No newline at end of file
diff --git a/tests/core/test_sscanf_skip.in b/tests/core/test_sscanf_skip.in
new file mode 100644
index 00000000..f4ef8265
--- /dev/null
+++ b/tests/core/test_sscanf_skip.in
@@ -0,0 +1,15 @@
+#include <stdint.h>
+#include <stdio.h>
+
+int main() {
+ int val1;
+ printf("%d\n", sscanf("10 20 30 40", "%*lld %*d %d", &val1));
+ printf("%d\n", val1);
+
+ int64_t large, val2;
+ printf("%d\n", sscanf("1000000 -1125899906842620 -123 -1073741823",
+ "%lld %*lld %ld %*d", &large, &val2));
+ printf("%lld,%d\n", large, val2);
+
+ return 0;
+}
diff --git a/tests/core/test_sscanf_skip.out b/tests/core/test_sscanf_skip.out
new file mode 100644
index 00000000..cf1cdfb8
--- /dev/null
+++ b/tests/core/test_sscanf_skip.out
@@ -0,0 +1,4 @@
+1
+30
+2
+1000000,-123
diff --git a/tests/core/test_sscanf_whitespace.in b/tests/core/test_sscanf_whitespace.in
new file mode 100644
index 00000000..8bcf1c7b
--- /dev/null
+++ b/tests/core/test_sscanf_whitespace.in
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int main() {
+ short int x;
+ short int y;
+
+ const char* buffer[] = {"173,16", " 16,173", "183, 173",
+ " 17, 287", " 98, 123, "};
+
+ for (int i = 0; i < 5; ++i) {
+ sscanf(buffer[i], "%hd,%hd", &x, &y);
+ printf("%d:%d,%d ", i, x, y);
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_sscanf_whitespace.out b/tests/core/test_sscanf_whitespace.out
new file mode 100644
index 00000000..9a26dd1d
--- /dev/null
+++ b/tests/core/test_sscanf_whitespace.out
@@ -0,0 +1 @@
+0:173,16 1:16,173 2:183,173 3:17,287 4:98,123 \ No newline at end of file
diff --git a/tests/core/test_stack.in b/tests/core/test_stack.in
new file mode 100644
index 00000000..b2bca9a1
--- /dev/null
+++ b/tests/core/test_stack.in
@@ -0,0 +1,16 @@
+#include <stdio.h>
+int test(int i) {
+ int x = 10;
+ if (i > 0) {
+ return test(i - 1);
+ }
+ return int(&x); // both for the number, and forces x to not be nativized
+}
+int main(int argc, char **argv) {
+ // We should get the same value for the first and last - stack has unwound
+ int x1 = test(argc - 2);
+ int x2 = test(100);
+ int x3 = test((argc - 2) / 4);
+ printf("*%d,%d*\n", x3 - x1, x2 != x1);
+ return 0;
+}
diff --git a/tests/core/test_stack.out b/tests/core/test_stack.out
new file mode 100644
index 00000000..687e8ad6
--- /dev/null
+++ b/tests/core/test_stack.out
@@ -0,0 +1 @@
+*0,1* \ No newline at end of file
diff --git a/tests/core/test_stack_byval.in b/tests/core/test_stack_byval.in
new file mode 100644
index 00000000..d7007d0a
--- /dev/null
+++ b/tests/core/test_stack_byval.in
@@ -0,0 +1,21 @@
+// We should also not blow up the stack with byval arguments
+#include <stdio.h>
+struct vec {
+ int x, y, z;
+ vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
+ static vec add(vec a, vec b) { return vec(a.x + b.x, a.y + b.y, a.z + b.z); }
+};
+int main() {
+ int total = 0;
+ for (int i = 0; i < 1000; i++) {
+ for (int j = 0; j < 1000; j++) {
+ vec c(i + i % 10, j * 2, i % 255);
+ vec d(j * 2, j % 255, i % 120);
+ vec f = vec::add(c, d);
+ total += (f.x + f.y + f.z) % 100;
+ total %= 10240;
+ }
+ }
+ printf("sum:%d*\n", total);
+ return 0;
+}
diff --git a/tests/core/test_stack_byval.out b/tests/core/test_stack_byval.out
new file mode 100644
index 00000000..62f1b081
--- /dev/null
+++ b/tests/core/test_stack_byval.out
@@ -0,0 +1 @@
+sum:9780* \ No newline at end of file
diff --git a/tests/core/test_stack_varargs.in b/tests/core/test_stack_varargs.in
new file mode 100644
index 00000000..01c231af
--- /dev/null
+++ b/tests/core/test_stack_varargs.in
@@ -0,0 +1,16 @@
+// We should not blow up the stack with numerous varargs
+#include <stdio.h>
+#include <stdlib.h>
+
+void func(int i) {
+ printf(
+ "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,"
+ "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+ i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i,
+ i, i, i, i, i, i, i, i, i, i, i, i, i, i);
+}
+int main() {
+ for (int i = 0; i < 1024; i++) func(i);
+ printf("ok!\n");
+ return 0;
+}
diff --git a/tests/core/test_stack_varargs.out b/tests/core/test_stack_varargs.out
new file mode 100644
index 00000000..e036282a
--- /dev/null
+++ b/tests/core/test_stack_varargs.out
@@ -0,0 +1 @@
+ok! \ No newline at end of file
diff --git a/tests/core/test_stack_void.in b/tests/core/test_stack_void.in
new file mode 100644
index 00000000..0e72e509
--- /dev/null
+++ b/tests/core/test_stack_void.in
@@ -0,0 +1,34 @@
+#include <stdio.h>
+
+static char s[100] = "aaaaa";
+static int func(void) {
+ if (s[0] != 'a') return 0;
+ printf("iso open %s\n", s, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001,
+ 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001);
+ return 0;
+}
+int main() {
+ int i;
+ for (i = 0; i < 5000; i++) func();
+ printf(".ok.\n");
+}
diff --git a/tests/core/test_stack_void.out b/tests/core/test_stack_void.out
new file mode 100644
index 00000000..c8e99c4e
--- /dev/null
+++ b/tests/core/test_stack_void.out
@@ -0,0 +1 @@
+.ok.
diff --git a/tests/core/test_static_variable.in b/tests/core/test_static_variable.in
new file mode 100644
index 00000000..70b41324
--- /dev/null
+++ b/tests/core/test_static_variable.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+struct DATA {
+ int value;
+
+ DATA() { value = 0; }
+};
+
+DATA& GetData() {
+ static DATA data;
+
+ return data;
+}
+
+int main() {
+ GetData().value = 10;
+ printf("value:%i", GetData().value);
+}
diff --git a/tests/core/test_static_variable.out b/tests/core/test_static_variable.out
new file mode 100644
index 00000000..8ab80f3b
--- /dev/null
+++ b/tests/core/test_static_variable.out
@@ -0,0 +1 @@
+value:10 \ No newline at end of file
diff --git a/tests/core/test_statics.in b/tests/core/test_statics.in
new file mode 100644
index 00000000..d3302db5
--- /dev/null
+++ b/tests/core/test_statics.in
@@ -0,0 +1,35 @@
+#include <stdio.h>
+#include <string.h>
+
+#define CONSTRLEN 32
+
+char *(*func)(char *, const char *) = NULL;
+
+void conoutfv(const char *fmt) {
+ static char buf[CONSTRLEN];
+ func(buf, fmt); // call by function pointer to make sure we test strcpy here
+ puts(buf);
+}
+
+struct XYZ {
+ float x, y, z;
+ XYZ(float a, float b, float c) : x(a), y(b), z(c) {}
+ static const XYZ &getIdentity() {
+ static XYZ iT(1, 2, 3);
+ return iT;
+ }
+};
+struct S {
+ static const XYZ &getIdentity() {
+ static const XYZ iT(XYZ::getIdentity());
+ return iT;
+ }
+};
+
+int main() {
+ func = &strcpy;
+ conoutfv("*staticccz*");
+ printf("*%.2f,%.2f,%.2f*\n", S::getIdentity().x, S::getIdentity().y,
+ S::getIdentity().z);
+ return 0;
+}
diff --git a/tests/core/test_statics.out b/tests/core/test_statics.out
new file mode 100644
index 00000000..c34f2cb6
--- /dev/null
+++ b/tests/core/test_statics.out
@@ -0,0 +1,2 @@
+*staticccz*
+*1.00,2.00,3.00* \ No newline at end of file
diff --git a/tests/core/test_statvfs.in b/tests/core/test_statvfs.in
new file mode 100644
index 00000000..72891505
--- /dev/null
+++ b/tests/core/test_statvfs.in
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <errno.h>
+#include <sys/statvfs.h>
+
+int main() {
+ struct statvfs s;
+
+ printf("result: %d\n", statvfs("/test", &s));
+ printf("errno: %d\n", errno);
+
+ printf("f_bsize: %lu\n", s.f_bsize);
+ printf("f_frsize: %lu\n", s.f_frsize);
+ printf("f_blocks: %lu\n", s.f_blocks);
+ printf("f_bfree: %lu\n", s.f_bfree);
+ printf("f_bavail: %lu\n", s.f_bavail);
+ printf("f_files: %d\n", s.f_files > 5);
+ printf("f_ffree: %lu\n", s.f_ffree);
+ printf("f_favail: %lu\n", s.f_favail);
+ printf("f_fsid: %lu\n", s.f_fsid);
+ printf("f_flag: %lu\n", s.f_flag);
+ printf("f_namemax: %lu\n", s.f_namemax);
+
+ return 0;
+}
diff --git a/tests/core/test_statvfs.out b/tests/core/test_statvfs.out
new file mode 100644
index 00000000..8c414d09
--- /dev/null
+++ b/tests/core/test_statvfs.out
@@ -0,0 +1,13 @@
+result: 0
+errno: 0
+f_bsize: 4096
+f_frsize: 4096
+f_blocks: 1000000
+f_bfree: 500000
+f_bavail: 500000
+f_files: 1
+f_ffree: 1000000
+f_favail: 1000000
+f_fsid: 42
+f_flag: 2
+f_namemax: 255
diff --git a/tests/core/test_std_cout_new.in b/tests/core/test_std_cout_new.in
new file mode 100644
index 00000000..d1ab3c45
--- /dev/null
+++ b/tests/core/test_std_cout_new.in
@@ -0,0 +1,21 @@
+#include <iostream>
+
+struct NodeInfo { // structure that we want to transmit to our shaders
+ float x;
+ float y;
+ float s;
+ float c;
+};
+const int nbNodes = 100;
+NodeInfo* data = new NodeInfo[nbNodes]; // our data that will be transmitted
+ // using float texture.
+
+template <int i>
+void printText(const char (&text)[i]) {
+ std::cout << text << std::endl;
+}
+
+int main() {
+ printText("some string constant");
+ return 0;
+}
diff --git a/tests/core/test_std_cout_new.out b/tests/core/test_std_cout_new.out
new file mode 100644
index 00000000..ddb4b681
--- /dev/null
+++ b/tests/core/test_std_cout_new.out
@@ -0,0 +1 @@
+some string constant \ No newline at end of file
diff --git a/tests/core/test_std_exception.in b/tests/core/test_std_exception.in
new file mode 100644
index 00000000..4b5905d8
--- /dev/null
+++ b/tests/core/test_std_exception.in
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <exception>
+
+int main() {
+ std::exception e;
+ try {
+ throw e;
+ }
+ catch (std::exception e) {
+ printf("caught std::exception\n");
+ }
+ return 0;
+}
diff --git a/tests/core/test_std_exception.out b/tests/core/test_std_exception.out
new file mode 100644
index 00000000..c1660de4
--- /dev/null
+++ b/tests/core/test_std_exception.out
@@ -0,0 +1 @@
+caught std::exception \ No newline at end of file
diff --git a/tests/core/test_stdvec.in b/tests/core/test_stdvec.in
new file mode 100644
index 00000000..b370eb61
--- /dev/null
+++ b/tests/core/test_stdvec.in
@@ -0,0 +1,25 @@
+#include <vector>
+#include <stdio.h>
+
+struct S {
+ int a;
+ float b;
+};
+
+void foo(int a, float b) { printf("%d:%.2f\n", a, b); }
+
+int main(int argc, char *argv[]) {
+ std::vector<S> ar;
+ S s;
+
+ s.a = 789;
+ s.b = 123.456f;
+ ar.push_back(s);
+
+ s.a = 0;
+ s.b = 100.1f;
+ ar.push_back(s);
+
+ foo(ar[0].a, ar[0].b);
+ foo(ar[1].a, ar[1].b);
+}
diff --git a/tests/core/test_stdvec.out b/tests/core/test_stdvec.out
new file mode 100644
index 00000000..cb3a61fc
--- /dev/null
+++ b/tests/core/test_stdvec.out
@@ -0,0 +1,2 @@
+789:123.46
+0:100.1 \ No newline at end of file
diff --git a/tests/core/test_strcasecmp.in b/tests/core/test_strcasecmp.in
new file mode 100644
index 00000000..2fb69d1a
--- /dev/null
+++ b/tests/core/test_strcasecmp.in
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <strings.h>
+int sign(int x) {
+ if (x < 0) return -1;
+ if (x > 0) return 1;
+ return 0;
+}
+int main() {
+ printf("*\n");
+
+ printf("%d\n", sign(strcasecmp("hello", "hello")));
+ printf("%d\n", sign(strcasecmp("hello1", "hello")));
+ printf("%d\n", sign(strcasecmp("hello", "hello1")));
+ printf("%d\n", sign(strcasecmp("hello1", "hello1")));
+ printf("%d\n", sign(strcasecmp("iello", "hello")));
+ printf("%d\n", sign(strcasecmp("hello", "iello")));
+ printf("%d\n", sign(strcasecmp("A", "hello")));
+ printf("%d\n", sign(strcasecmp("Z", "hello")));
+ printf("%d\n", sign(strcasecmp("a", "hello")));
+ printf("%d\n", sign(strcasecmp("z", "hello")));
+ printf("%d\n", sign(strcasecmp("hello", "a")));
+ printf("%d\n", sign(strcasecmp("hello", "z")));
+
+ printf("%d\n", sign(strcasecmp("Hello", "hello")));
+ printf("%d\n", sign(strcasecmp("Hello1", "hello")));
+ printf("%d\n", sign(strcasecmp("Hello", "hello1")));
+ printf("%d\n", sign(strcasecmp("Hello1", "hello1")));
+ printf("%d\n", sign(strcasecmp("Iello", "hello")));
+ printf("%d\n", sign(strcasecmp("Hello", "iello")));
+ printf("%d\n", sign(strcasecmp("A", "hello")));
+ printf("%d\n", sign(strcasecmp("Z", "hello")));
+ printf("%d\n", sign(strcasecmp("a", "hello")));
+ printf("%d\n", sign(strcasecmp("z", "hello")));
+ printf("%d\n", sign(strcasecmp("Hello", "a")));
+ printf("%d\n", sign(strcasecmp("Hello", "z")));
+
+ printf("%d\n", sign(strcasecmp("hello", "Hello")));
+ printf("%d\n", sign(strcasecmp("hello1", "Hello")));
+ printf("%d\n", sign(strcasecmp("hello", "Hello1")));
+ printf("%d\n", sign(strcasecmp("hello1", "Hello1")));
+ printf("%d\n", sign(strcasecmp("iello", "Hello")));
+ printf("%d\n", sign(strcasecmp("hello", "Iello")));
+ printf("%d\n", sign(strcasecmp("A", "Hello")));
+ printf("%d\n", sign(strcasecmp("Z", "Hello")));
+ printf("%d\n", sign(strcasecmp("a", "Hello")));
+ printf("%d\n", sign(strcasecmp("z", "Hello")));
+ printf("%d\n", sign(strcasecmp("hello", "a")));
+ printf("%d\n", sign(strcasecmp("hello", "z")));
+
+ printf("%d\n", sign(strcasecmp("Hello", "Hello")));
+ printf("%d\n", sign(strcasecmp("Hello1", "Hello")));
+ printf("%d\n", sign(strcasecmp("Hello", "Hello1")));
+ printf("%d\n", sign(strcasecmp("Hello1", "Hello1")));
+ printf("%d\n", sign(strcasecmp("Iello", "Hello")));
+ printf("%d\n", sign(strcasecmp("Hello", "Iello")));
+ printf("%d\n", sign(strcasecmp("A", "Hello")));
+ printf("%d\n", sign(strcasecmp("Z", "Hello")));
+ printf("%d\n", sign(strcasecmp("a", "Hello")));
+ printf("%d\n", sign(strcasecmp("z", "Hello")));
+ printf("%d\n", sign(strcasecmp("Hello", "a")));
+ printf("%d\n", sign(strcasecmp("Hello", "z")));
+
+ printf("%d\n", sign(strncasecmp("hello", "hello", 3)));
+ printf("%d\n", sign(strncasecmp("hello1", "hello", 3)));
+ printf("%d\n", sign(strncasecmp("hello", "hello1", 3)));
+ printf("%d\n", sign(strncasecmp("hello1", "hello1", 3)));
+ printf("%d\n", sign(strncasecmp("iello", "hello", 3)));
+ printf("%d\n", sign(strncasecmp("hello", "iello", 3)));
+ printf("%d\n", sign(strncasecmp("A", "hello", 3)));
+ printf("%d\n", sign(strncasecmp("Z", "hello", 3)));
+ printf("%d\n", sign(strncasecmp("a", "hello", 3)));
+ printf("%d\n", sign(strncasecmp("z", "hello", 3)));
+ printf("%d\n", sign(strncasecmp("hello", "a", 3)));
+ printf("%d\n", sign(strncasecmp("hello", "z", 3)));
+
+ printf("*\n");
+
+ return 0;
+}
diff --git a/tests/core/test_strcasecmp.out b/tests/core/test_strcasecmp.out
new file mode 100644
index 00000000..b572c269
--- /dev/null
+++ b/tests/core/test_strcasecmp.out
@@ -0,0 +1,62 @@
+*
+0
+1
+-1
+0
+1
+-1
+-1
+1
+-1
+1
+1
+-1
+0
+1
+-1
+0
+1
+-1
+-1
+1
+-1
+1
+1
+-1
+0
+1
+-1
+0
+1
+-1
+-1
+1
+-1
+1
+1
+-1
+0
+1
+-1
+0
+1
+-1
+-1
+1
+-1
+1
+1
+-1
+0
+0
+0
+0
+1
+-1
+-1
+1
+-1
+1
+1
+-1
+*
diff --git a/tests/core/test_strcmp_uni.in b/tests/core/test_strcmp_uni.in
new file mode 100644
index 00000000..82819dde
--- /dev/null
+++ b/tests/core/test_strcmp_uni.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <string.h>
+int main() {
+#define TEST(func) \
+ { \
+ char *word = "WORD"; \
+ char wordEntry[2] = {-61, -126}; /* "Â"; */ \
+ int cmp = func(word, wordEntry, 2); \
+ printf("Compare value " #func " is %d\n", cmp); \
+ }
+ TEST(strncmp);
+ TEST(strncasecmp);
+ TEST(memcmp);
+}
diff --git a/tests/core/test_strcmp_uni.out b/tests/core/test_strcmp_uni.out
new file mode 100644
index 00000000..58e237d7
--- /dev/null
+++ b/tests/core/test_strcmp_uni.out
@@ -0,0 +1,3 @@
+Compare value strncmp is -1
+Compare value strncasecmp is -1
+Compare value memcmp is -1
diff --git a/tests/core/test_strftime.in b/tests/core/test_strftime.in
new file mode 100644
index 00000000..4a3a7fda
--- /dev/null
+++ b/tests/core/test_strftime.in
@@ -0,0 +1,134 @@
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+void test(int result, const char* comment, const char* parsed = "") {
+ printf("%d", result);
+ if (!result) {
+ printf("\nERROR: %s (\"%s\")\n", comment, parsed);
+ }
+}
+
+int cmp(const char* s1, const char* s2) {
+ for (; *s1 == *s2; s1++, s2++) {
+ if (*s1 == '\0') break;
+ }
+
+ return (*s1 - *s2);
+}
+
+int main() {
+ struct tm tm;
+ char s[1000];
+ size_t size;
+
+ tm.tm_sec = 4;
+ tm.tm_min = 23;
+ tm.tm_hour = 20;
+ tm.tm_mday = 21;
+ tm.tm_mon = 1;
+ tm.tm_year = 74;
+ tm.tm_wday = 4;
+ tm.tm_yday = 51;
+ tm.tm_isdst = 0;
+
+ size = strftime(s, 1000, "", &tm);
+ test((size == 0) && (*s == '\0'), "strftime test #1", s);
+
+ size = strftime(s, 1000, "%a", &tm);
+ test((size == 3) && !cmp(s, "Thu"), "strftime test #2", s);
+
+ size = strftime(s, 1000, "%A", &tm);
+ test((size == 8) && !cmp(s, "Thursday"), "strftime test #3", s);
+
+ size = strftime(s, 1000, "%b", &tm);
+ test((size == 3) && !cmp(s, "Feb"), "strftime test #4", s);
+
+ size = strftime(s, 1000, "%B", &tm);
+ test((size == 8) && !cmp(s, "February"), "strftime test #5", s);
+
+ size = strftime(s, 1000, "%d", &tm);
+ test((size == 2) && !cmp(s, "21"), "strftime test #6", s);
+
+ size = strftime(s, 1000, "%H", &tm);
+ test((size == 2) && !cmp(s, "20"), "strftime test #7", s);
+
+ size = strftime(s, 1000, "%I", &tm);
+ test((size == 2) && !cmp(s, "08"), "strftime test #8", s);
+
+ size = strftime(s, 1000, "%j", &tm);
+ test((size == 3) && !cmp(s, "052"), "strftime test #9", s);
+
+ size = strftime(s, 1000, "%m", &tm);
+ test((size == 2) && !cmp(s, "02"), "strftime test #10", s);
+
+ size = strftime(s, 1000, "%M", &tm);
+ test((size == 2) && !cmp(s, "23"), "strftime test #11", s);
+
+ size = strftime(s, 1000, "%p", &tm);
+ test((size == 2) && !cmp(s, "PM"), "strftime test #12", s);
+
+ size = strftime(s, 1000, "%S", &tm);
+ test((size == 2) && !cmp(s, "04"), "strftime test #13", s);
+
+ size = strftime(s, 1000, "%U", &tm);
+ test((size == 2) && !cmp(s, "07"), "strftime test #14", s);
+
+ size = strftime(s, 1000, "%w", &tm);
+ test((size == 1) && !cmp(s, "4"), "strftime test #15", s);
+
+ size = strftime(s, 1000, "%W", &tm);
+ test((size == 2) && !cmp(s, "07"), "strftime test #16", s);
+
+ size = strftime(s, 1000, "%y", &tm);
+ test((size == 2) && !cmp(s, "74"), "strftime test #17", s);
+
+ size = strftime(s, 1000, "%Y", &tm);
+ test((size == 4) && !cmp(s, "1974"), "strftime test #18", s);
+
+ size = strftime(s, 1000, "%%", &tm);
+ test((size == 1) && !cmp(s, "%"), "strftime test #19", s);
+
+ size = strftime(s, 5, "%Y", &tm);
+ test((size == 4) && !cmp(s, "1974"), "strftime test #20", s);
+
+ size = strftime(s, 4, "%Y", &tm);
+ test((size == 0), "strftime test #21", s);
+
+ tm.tm_mon = 0;
+ tm.tm_mday = 1;
+ size = strftime(s, 10, "%U", &tm);
+ test((size == 2) && !cmp(s, "00"), "strftime test #22", s);
+
+ size = strftime(s, 10, "%W", &tm);
+ test((size == 2) && !cmp(s, "00"), "strftime test #23", s);
+
+ // 1/1/1973 was a Sunday and is in CW 1
+ tm.tm_year = 73;
+ size = strftime(s, 10, "%W", &tm);
+ test((size == 2) && !cmp(s, "01"), "strftime test #24", s);
+
+ // 1/1/1978 was a Monday and is in CW 1
+ tm.tm_year = 78;
+ size = strftime(s, 10, "%U", &tm);
+ test((size == 2) && !cmp(s, "01"), "strftime test #25", s);
+
+ // 2/1/1999
+ tm.tm_year = 99;
+ tm.tm_yday = 1;
+ size = strftime(s, 10, "%G (%V)", &tm);
+ test((size == 9) && !cmp(s, "1998 (53)"), "strftime test #26", s);
+
+ size = strftime(s, 10, "%g", &tm);
+ test((size == 2) && !cmp(s, "98"), "strftime test #27", s);
+
+ // 30/12/1997
+ tm.tm_year = 97;
+ tm.tm_yday = 363;
+ size = strftime(s, 10, "%G (%V)", &tm);
+ test((size == 9) && !cmp(s, "1998 (01)"), "strftime test #28", s);
+
+ size = strftime(s, 10, "%g", &tm);
+ test((size == 2) && !cmp(s, "98"), "strftime test #29", s);
+}
diff --git a/tests/core/test_strftime.out b/tests/core/test_strftime.out
new file mode 100644
index 00000000..0e2f2d7c
--- /dev/null
+++ b/tests/core/test_strftime.out
@@ -0,0 +1 @@
+11111111111111111111111111111 \ No newline at end of file
diff --git a/tests/core/test_strings.in b/tests/core/test_strings.in
new file mode 100644
index 00000000..3161b73f
--- /dev/null
+++ b/tests/core/test_strings.in
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ int x = 5, y = 9, magic = 7; // fool compiler with magic
+ memmove(&x, &y, magic - 7); // 0 should not crash us
+
+ int xx, yy, zz;
+ char s[32];
+ int cc = sscanf("abc_10.b1_xyz9_543_defg", "abc_%d.%2x_xyz9_%3d_%3s", &xx,
+ &yy, &zz, s);
+ printf("%d:%d,%d,%d,%s\n", cc, xx, yy, zz, s);
+
+ printf("%d\n", argc);
+ puts(argv[1]);
+ puts(argv[2]);
+ printf("%d\n", atoi(argv[3]) + 2);
+ const char *foolingthecompiler = "\rabcd";
+ printf("%d\n", strlen(foolingthecompiler)); // Tests parsing /0D in llvm -
+ // should not be a 0 (end string)
+ // then a D!
+ printf("%s\n", NULL); // Should print '(null)', not the string at address 0,
+ // which is a real address for us!
+ printf("/* a comment */\n"); // Should not break the generated code!
+ printf("// another\n"); // Should not break the generated code!
+
+ char *strdup_val = strdup("test");
+ printf("%s\n", strdup_val);
+ free(strdup_val);
+
+ {
+ char *one = "one 1 ONE !";
+ char *two = "two 2 TWO ?";
+ char three[1024];
+ memset(three, '.', 1024);
+ three[50] = 0;
+ strncpy(three + argc, one + (argc / 2), argc + 1);
+ strncpy(three + argc * 3, two + (argc / 3), argc + 2);
+ printf("waka %s\n", three);
+ }
+
+ {
+ char *one = "string number one top notch";
+ char *two = "fa la sa ho fi FI FO FUM WHEN WHERE WHY HOW WHO";
+ char three[1000];
+ strcpy(three, &one[argc * 2]);
+ char *four = strcat(three, &two[argc * 3]);
+ printf("cat |%s|\n", three);
+ printf("returned |%s|\n", four);
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_strings.out b/tests/core/test_strings.out
new file mode 100644
index 00000000..ddf9aee7
--- /dev/null
+++ b/tests/core/test_strings.out
@@ -0,0 +1,13 @@
+4:10,177,543,def
+4
+wowie
+too
+76
+5
+(null)
+/* a comment */
+// another
+test
+waka ....e 1 O...wo 2 T................................
+cat |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|
+returned |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO| \ No newline at end of file
diff --git a/tests/core/test_strndup.in b/tests/core/test_strndup.in
new file mode 100644
index 00000000..2457de0c
--- /dev/null
+++ b/tests/core/test_strndup.in
@@ -0,0 +1,38 @@
+//---------------
+//- http://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html
+//---------------
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char** argv) {
+ const char* source =
+ "strndup - duplicate a specific number of bytes from a string";
+
+ char* strdup_val = strndup(source, 0);
+ printf("1:%s\n", strdup_val);
+ free(strdup_val);
+
+ strdup_val = strndup(source, 7);
+ printf("2:%s\n", strdup_val);
+ free(strdup_val);
+
+ strdup_val = strndup(source, 1000);
+ printf("3:%s\n", strdup_val);
+ free(strdup_val);
+
+ strdup_val = strndup(source, 60);
+ printf("4:%s\n", strdup_val);
+ free(strdup_val);
+
+ strdup_val = strndup(source, 19);
+ printf("5:%s\n", strdup_val);
+ free(strdup_val);
+
+ strdup_val = strndup(source, -1);
+ printf("6:%s\n", strdup_val);
+ free(strdup_val);
+
+ return 0;
+}
diff --git a/tests/core/test_strndup.out b/tests/core/test_strndup.out
new file mode 100644
index 00000000..681f00cc
--- /dev/null
+++ b/tests/core/test_strndup.out
@@ -0,0 +1,6 @@
+1:
+2:strndup
+3:strndup - duplicate a specific number of bytes from a string
+4:strndup - duplicate a specific number of bytes from a string
+5:strndup - duplicate
+6:
diff --git a/tests/core/test_strptime_days.in b/tests/core/test_strptime_days.in
new file mode 100644
index 00000000..382ea8ef
--- /dev/null
+++ b/tests/core/test_strptime_days.in
@@ -0,0 +1,32 @@
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+
+static const struct {
+ const char *input;
+ const char *format;
+} day_tests[] = {{"2000-01-01", "%Y-%m-%d"},
+ {"03/03/00", "%D"},
+ {"9/9/99", "%x"},
+ {"19990502123412", "%Y%m%d%H%M%S"},
+ {"2001 20 Mon", "%Y %U %a"},
+ {"2006 4 Fri", "%Y %U %a"},
+ {"2001 21 Mon", "%Y %W %a"},
+ {"2013 29 Wed", "%Y %W %a"},
+ {"2000-01-01 08:12:21 AM", "%Y-%m-%d %I:%M:%S %p"},
+ {"2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p"},
+ {"2001 17 Tue", "%Y %U %a"},
+ {"2001 8 Thursday", "%Y %W %a"}, };
+
+int main() {
+ struct tm tm;
+
+ for (int i = 0; i < sizeof(day_tests) / sizeof(day_tests[0]); ++i) {
+ memset(&tm, '\0', sizeof(tm));
+ char *ptr = strptime(day_tests[i].input, day_tests[i].format, &tm);
+
+ printf("%s: %d/%d/%d (%dth DoW, %dth DoY)\n",
+ (ptr != NULL && *ptr == '\0') ? "OK" : "ERR", tm.tm_mon + 1,
+ tm.tm_mday, 1900 + tm.tm_year, tm.tm_wday, tm.tm_yday);
+ }
+}
diff --git a/tests/core/test_strptime_days.out b/tests/core/test_strptime_days.out
new file mode 100644
index 00000000..dc409032
--- /dev/null
+++ b/tests/core/test_strptime_days.out
@@ -0,0 +1,12 @@
+OK: 1/1/2000 (6th DoW, 0th DoY)
+OK: 3/3/2000 (5th DoW, 62th DoY)
+OK: 9/9/1999 (4th DoW, 251th DoY)
+OK: 5/2/1999 (0th DoW, 121th DoY)
+OK: 5/21/2001 (1th DoW, 140th DoY)
+OK: 1/27/2006 (5th DoW, 26th DoY)
+OK: 5/21/2001 (1th DoW, 140th DoY)
+OK: 7/24/2013 (3th DoW, 204th DoY)
+OK: 1/1/2000 (6th DoW, 0th DoY)
+OK: 1/1/2000 (6th DoW, 0th DoY)
+OK: 5/1/2001 (2th DoW, 120th DoY)
+OK: 2/22/2001 (4th DoW, 52th DoY)
diff --git a/tests/core/test_strptime_reentrant.in b/tests/core/test_strptime_reentrant.in
new file mode 100644
index 00000000..b2a14d1d
--- /dev/null
+++ b/tests/core/test_strptime_reentrant.in
@@ -0,0 +1,45 @@
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main() {
+ int result = 0;
+ struct tm tm;
+
+ memset(&tm, 0xaa, sizeof(tm));
+
+ /* Test we don't crash on uninitialized struct tm.
+ Some fields might contain bogus values until everything
+ needed is initialized, but we shouldn't crash. */
+ if (strptime("2007", "%Y", &tm) == NULL ||
+ strptime("12", "%d", &tm) == NULL || strptime("Feb", "%b", &tm) == NULL ||
+ strptime("13", "%M", &tm) == NULL || strptime("21", "%S", &tm) == NULL ||
+ strptime("16", "%H", &tm) == NULL) {
+ printf("ERR: returned NULL");
+ exit(EXIT_FAILURE);
+ }
+
+ if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16 ||
+ tm.tm_mday != 12 || tm.tm_mon != 1 || tm.tm_year != 107 ||
+ tm.tm_wday != 1 || tm.tm_yday != 42) {
+ printf("ERR: unexpected tm content (1) - %d/%d/%d %d:%d:%d", tm.tm_mon + 1,
+ tm.tm_mday, tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
+ exit(EXIT_FAILURE);
+ }
+
+ if (strptime("8", "%d", &tm) == NULL) {
+ printf("ERR: strptime failed");
+ exit(EXIT_FAILURE);
+ }
+
+ if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16 ||
+ tm.tm_mday != 8 || tm.tm_mon != 1 || tm.tm_year != 107 ||
+ tm.tm_wday != 4 || tm.tm_yday != 38) {
+ printf("ERR: unexpected tm content (2) - %d/%d/%d %d:%d:%d", tm.tm_mon + 1,
+ tm.tm_mday, tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
+ exit(EXIT_FAILURE);
+ }
+
+ printf("OK");
+}
diff --git a/tests/core/test_strptime_reentrant.out b/tests/core/test_strptime_reentrant.out
new file mode 100644
index 00000000..a0aba931
--- /dev/null
+++ b/tests/core/test_strptime_reentrant.out
@@ -0,0 +1 @@
+OK \ No newline at end of file
diff --git a/tests/core/test_strptime_tm.in b/tests/core/test_strptime_tm.in
new file mode 100644
index 00000000..93cdb1d5
--- /dev/null
+++ b/tests/core/test_strptime_tm.in
@@ -0,0 +1,27 @@
+#include <time.h>
+#include <stdio.h>
+#include <string.h>
+
+int main() {
+ struct tm tm;
+ char *ptr = strptime("17410105012000", "%H%M%S%d%m%Y", &tm);
+
+ printf(
+ "%s: %s, %d/%d/%d %d:%d:%d", (ptr != NULL && *ptr == '\0') ? "OK" : "ERR",
+ tm.tm_wday == 0
+ ? "Sun"
+ : (tm.tm_wday == 1
+ ? "Mon"
+ : (tm.tm_wday == 2
+ ? "Tue"
+ : (tm.tm_wday == 3
+ ? "Wed"
+ : (tm.tm_wday == 4
+ ? "Thu"
+ : (tm.tm_wday == 5
+ ? "Fri"
+ : (tm.tm_wday == 6 ? "Sat"
+ : "ERR")))))),
+ tm.tm_mon + 1, tm.tm_mday, tm.tm_year + 1900, tm.tm_hour, tm.tm_min,
+ tm.tm_sec);
+}
diff --git a/tests/core/test_strptime_tm.out b/tests/core/test_strptime_tm.out
new file mode 100644
index 00000000..32c321f7
--- /dev/null
+++ b/tests/core/test_strptime_tm.out
@@ -0,0 +1 @@
+OK: Wed, 1/5/2000 17:41:1 \ No newline at end of file
diff --git a/tests/core/test_strstr.in b/tests/core/test_strstr.in
new file mode 100644
index 00000000..8aa56d4a
--- /dev/null
+++ b/tests/core/test_strstr.in
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <string.h>
+
+int main() {
+ printf("%d\n", !!strstr("\\n", "\\n"));
+ printf("%d\n", !!strstr("cheezy", "ez"));
+ printf("%d\n", !!strstr("cheeezy", "ez"));
+ printf("%d\n", !!strstr("cheeeeeeeeeezy", "ez"));
+ printf("%d\n", !!strstr("cheeeeeeeeee1zy", "ez"));
+ printf("%d\n", !!strstr("che1ezy", "ez"));
+ printf("%d\n", !!strstr("che1ezy", "che"));
+ printf("%d\n", !!strstr("ce1ezy", "che"));
+ printf("%d\n", !!strstr("ce1ezy", "ezy"));
+ printf("%d\n", !!strstr("ce1ezyt", "ezy"));
+ printf("%d\n", !!strstr("ce1ez1y", "ezy"));
+ printf("%d\n", !!strstr("cheezy", "a"));
+ printf("%d\n", !!strstr("cheezy", "b"));
+ printf("%d\n", !!strstr("cheezy", "c"));
+ printf("%d\n", !!strstr("cheezy", "d"));
+ printf("%d\n", !!strstr("cheezy", "g"));
+ printf("%d\n", !!strstr("cheezy", "h"));
+ printf("%d\n", !!strstr("cheezy", "i"));
+ printf("%d\n", !!strstr("cheezy", "e"));
+ printf("%d\n", !!strstr("cheezy", "x"));
+ printf("%d\n", !!strstr("cheezy", "y"));
+ printf("%d\n", !!strstr("cheezy", "z"));
+ printf("%d\n", !!strstr("cheezy", "_"));
+
+ const char *str = "a big string";
+ printf("%d\n", strstr(str, "big") - str);
+ return 0;
+}
diff --git a/tests/core/test_strstr.out b/tests/core/test_strstr.out
new file mode 100644
index 00000000..aa0d917b
--- /dev/null
+++ b/tests/core/test_strstr.out
@@ -0,0 +1,24 @@
+1
+1
+1
+1
+0
+1
+1
+0
+1
+1
+0
+0
+0
+1
+0
+0
+1
+0
+1
+0
+1
+1
+0
+2
diff --git a/tests/core/test_strtok.in b/tests/core/test_strtok.in
new file mode 100644
index 00000000..6ef57191
--- /dev/null
+++ b/tests/core/test_strtok.in
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <string.h>
+
+int main() {
+ char test[80], blah[80];
+ char *sep = "\\/:;=-";
+ char *word, *phrase, *brkt, *brkb;
+
+ strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
+
+ for (word = strtok_r(test, sep, &brkt); word;
+ word = strtok_r(NULL, sep, &brkt)) {
+ strcpy(blah, "blah:blat:blab:blag");
+ for (phrase = strtok_r(blah, sep, &brkb); phrase;
+ phrase = strtok_r(NULL, sep, &brkb)) {
+ printf("at %s:%s\n", word, phrase);
+ }
+ }
+ return 0;
+}
diff --git a/tests/core/test_strtok.out b/tests/core/test_strtok.out
new file mode 100644
index 00000000..1e63af4b
--- /dev/null
+++ b/tests/core/test_strtok.out
@@ -0,0 +1,32 @@
+at This:blah
+at This:blat
+at This:blab
+at This:blag
+at is.a:blah
+at is.a:blat
+at is.a:blab
+at is.a:blag
+at test:blah
+at test:blat
+at test:blab
+at test:blag
+at of:blah
+at of:blat
+at of:blab
+at of:blag
+at the:blah
+at the:blat
+at the:blab
+at the:blag
+at string:blah
+at string:blat
+at string:blab
+at string:blag
+at tokenizer:blah
+at tokenizer:blat
+at tokenizer:blab
+at tokenizer:blag
+at function.:blah
+at function.:blat
+at function.:blab
+at function.:blag
diff --git a/tests/core/test_strtol_bin.in b/tests/core/test_strtol_bin.in
new file mode 100644
index 00000000..e54e0173
--- /dev/null
+++ b/tests/core/test_strtol_bin.in
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "1 -101 +1011";
+ char *end_char;
+
+ // defined base
+ long l4 = strtol(STRING, &end_char, 2);
+ long l5 = strtol(end_char, &end_char, 2);
+ long l6 = strtol(end_char, NULL, 2);
+
+ printf("%d%d%d\n", l4 == 1, l5 == -5, l6 == 11);
+ return 0;
+}
diff --git a/tests/core/test_strtol_bin.out b/tests/core/test_strtol_bin.out
new file mode 100644
index 00000000..9d07aa0d
--- /dev/null
+++ b/tests/core/test_strtol_bin.out
@@ -0,0 +1 @@
+111 \ No newline at end of file
diff --git a/tests/core/test_strtol_dec.in b/tests/core/test_strtol_dec.in
new file mode 100644
index 00000000..56053521
--- /dev/null
+++ b/tests/core/test_strtol_dec.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "4 -38 +4711";
+ char *end_char;
+
+ // undefined base
+ long l1 = strtol(STRING, &end_char, 0);
+ long l2 = strtol(end_char, &end_char, 0);
+ long l3 = strtol(end_char, NULL, 0);
+
+ // defined base
+ long l4 = strtol(STRING, &end_char, 10);
+ long l5 = strtol(end_char, &end_char, 10);
+ long l6 = strtol(end_char, NULL, 10);
+
+ printf("%d%d%d%d%d%d\n", l1 == 4, l2 == -38, l3 == 4711, l4 == 4, l5 == -38,
+ l6 == 4711);
+ return 0;
+}
diff --git a/tests/core/test_strtol_dec.out b/tests/core/test_strtol_dec.out
new file mode 100644
index 00000000..b23c1c51
--- /dev/null
+++ b/tests/core/test_strtol_dec.out
@@ -0,0 +1 @@
+111111 \ No newline at end of file
diff --git a/tests/core/test_strtol_hex.in b/tests/core/test_strtol_hex.in
new file mode 100644
index 00000000..65a43ed0
--- /dev/null
+++ b/tests/core/test_strtol_hex.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "0x4 -0x3A +0xDEAD";
+ char *end_char;
+
+ // undefined base
+ long l1 = strtol(STRING, &end_char, 0);
+ long l2 = strtol(end_char, &end_char, 0);
+ long l3 = strtol(end_char, NULL, 0);
+
+ // defined base
+ long l4 = strtol(STRING, &end_char, 16);
+ long l5 = strtol(end_char, &end_char, 16);
+ long l6 = strtol(end_char, NULL, 16);
+
+ printf("%d%d%d%d%d%d\n", l1 == 0x4, l2 == -0x3a, l3 == 0xdead, l4 == 0x4,
+ l5 == -0x3a, l6 == 0xdead);
+ return 0;
+}
diff --git a/tests/core/test_strtol_hex.out b/tests/core/test_strtol_hex.out
new file mode 100644
index 00000000..b23c1c51
--- /dev/null
+++ b/tests/core/test_strtol_hex.out
@@ -0,0 +1 @@
+111111 \ No newline at end of file
diff --git a/tests/core/test_strtol_oct.in b/tests/core/test_strtol_oct.in
new file mode 100644
index 00000000..94b9c3ff
--- /dev/null
+++ b/tests/core/test_strtol_oct.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "0 -035 +04711";
+ char *end_char;
+
+ // undefined base
+ long l1 = strtol(STRING, &end_char, 0);
+ long l2 = strtol(end_char, &end_char, 0);
+ long l3 = strtol(end_char, NULL, 0);
+
+ // defined base
+ long l4 = strtol(STRING, &end_char, 8);
+ long l5 = strtol(end_char, &end_char, 8);
+ long l6 = strtol(end_char, NULL, 8);
+
+ printf("%d%d%d%d%d%d\n", l1 == 0, l2 == -29, l3 == 2505, l4 == 0, l5 == -29,
+ l6 == 2505);
+ return 0;
+}
diff --git a/tests/core/test_strtol_oct.out b/tests/core/test_strtol_oct.out
new file mode 100644
index 00000000..b23c1c51
--- /dev/null
+++ b/tests/core/test_strtol_oct.out
@@ -0,0 +1 @@
+111111 \ No newline at end of file
diff --git a/tests/core/test_strtoll_bin.in b/tests/core/test_strtoll_bin.in
new file mode 100644
index 00000000..cbe5546f
--- /dev/null
+++ b/tests/core/test_strtoll_bin.in
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "1 -101 +1011";
+ char *end_char;
+
+ // defined base
+ long long int l4 = strtoll(STRING, &end_char, 2);
+ long long int l5 = strtoll(end_char, &end_char, 2);
+ long long int l6 = strtoll(end_char, NULL, 2);
+
+ printf("%d%d%d\n", l4 == 1, l5 == -5, l6 == 11);
+ return 0;
+}
diff --git a/tests/core/test_strtoll_bin.out b/tests/core/test_strtoll_bin.out
new file mode 100644
index 00000000..9d07aa0d
--- /dev/null
+++ b/tests/core/test_strtoll_bin.out
@@ -0,0 +1 @@
+111 \ No newline at end of file
diff --git a/tests/core/test_strtoll_dec.in b/tests/core/test_strtoll_dec.in
new file mode 100644
index 00000000..f4d2950e
--- /dev/null
+++ b/tests/core/test_strtoll_dec.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "4 -38 +4711";
+ char *end_char;
+
+ // undefined base
+ long long int l1 = strtoll(STRING, &end_char, 0);
+ long long int l2 = strtoll(end_char, &end_char, 0);
+ long long int l3 = strtoll(end_char, NULL, 0);
+
+ // defined base
+ long long int l4 = strtoll(STRING, &end_char, 10);
+ long long int l5 = strtoll(end_char, &end_char, 10);
+ long long int l6 = strtoll(end_char, NULL, 10);
+
+ printf("%d%d%d%d%d%d\n", l1 == 4, l2 == -38, l3 == 4711, l4 == 4, l5 == -38,
+ l6 == 4711);
+ return 0;
+}
diff --git a/tests/core/test_strtoll_dec.out b/tests/core/test_strtoll_dec.out
new file mode 100644
index 00000000..b23c1c51
--- /dev/null
+++ b/tests/core/test_strtoll_dec.out
@@ -0,0 +1 @@
+111111 \ No newline at end of file
diff --git a/tests/core/test_strtoll_hex.in b/tests/core/test_strtoll_hex.in
new file mode 100644
index 00000000..a432d0dd
--- /dev/null
+++ b/tests/core/test_strtoll_hex.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "0x4 -0x3A +0xDEADBEEF";
+ char *end_char;
+
+ // undefined base
+ long long int l1 = strtoll(STRING, &end_char, 0);
+ long long int l2 = strtoll(end_char, &end_char, 0);
+ long long int l3 = strtoll(end_char, NULL, 0);
+
+ // defined base
+ long long int l4 = strtoll(STRING, &end_char, 16);
+ long long int l5 = strtoll(end_char, &end_char, 16);
+ long long int l6 = strtoll(end_char, NULL, 16);
+
+ printf("%d%d%d%d%d%d\n", l1 == 0x4, l2 == -0x3a, l3 == 0xdeadbeef, l4 == 0x4,
+ l5 == -0x3a, l6 == 0xdeadbeef);
+ return 0;
+}
diff --git a/tests/core/test_strtoll_hex.out b/tests/core/test_strtoll_hex.out
new file mode 100644
index 00000000..b23c1c51
--- /dev/null
+++ b/tests/core/test_strtoll_hex.out
@@ -0,0 +1 @@
+111111 \ No newline at end of file
diff --git a/tests/core/test_strtoll_oct.in b/tests/core/test_strtoll_oct.in
new file mode 100644
index 00000000..e5e12e24
--- /dev/null
+++ b/tests/core/test_strtoll_oct.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main() {
+ const char *STRING = "0 -035 +04711";
+ char *end_char;
+
+ // undefined base
+ long long int l1 = strtoll(STRING, &end_char, 0);
+ long long int l2 = strtoll(end_char, &end_char, 0);
+ long long int l3 = strtoll(end_char, NULL, 0);
+
+ // defined base
+ long long int l4 = strtoll(STRING, &end_char, 8);
+ long long int l5 = strtoll(end_char, &end_char, 8);
+ long long int l6 = strtoll(end_char, NULL, 8);
+
+ printf("%d%d%d%d%d%d\n", l1 == 0, l2 == -29, l3 == 2505, l4 == 0, l5 == -29,
+ l6 == 2505);
+ return 0;
+}
diff --git a/tests/core/test_strtoll_oct.out b/tests/core/test_strtoll_oct.out
new file mode 100644
index 00000000..b23c1c51
--- /dev/null
+++ b/tests/core/test_strtoll_oct.out
@@ -0,0 +1 @@
+111111 \ No newline at end of file
diff --git a/tests/core/test_structs.in b/tests/core/test_structs.in
new file mode 100644
index 00000000..2d48a9aa
--- /dev/null
+++ b/tests/core/test_structs.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+struct S {
+ int x, y;
+};
+int main() {
+ S a, b;
+ a.x = 5;
+ a.y = 6;
+ b.x = 101;
+ b.y = 7009;
+ S *c, *d;
+ c = &a;
+ c->x *= 2;
+ c = &b;
+ c->y -= 1;
+ d = c;
+ d->y += 10;
+ printf("*%d,%d,%d,%d,%d,%d,%d,%d*\n", a.x, a.y, b.x, b.y, c->x, c->y, d->x,
+ d->y);
+ return 0;
+}
diff --git a/tests/core/test_structs.out b/tests/core/test_structs.out
new file mode 100644
index 00000000..7748b49e
--- /dev/null
+++ b/tests/core/test_structs.out
@@ -0,0 +1 @@
+*10,6,101,7018,101,7018,101,7018* \ No newline at end of file
diff --git a/tests/core/test_time_c.in b/tests/core/test_time_c.in
new file mode 100644
index 00000000..9719464c
--- /dev/null
+++ b/tests/core/test_time_c.in
@@ -0,0 +1,7 @@
+#include <time.h>
+#include <stdio.h>
+
+int main() {
+ time_t t = time(0);
+ printf("time: %s\n", ctime(&t));
+}
diff --git a/tests/core/test_time_c.out b/tests/core/test_time_c.out
new file mode 100644
index 00000000..dc3e339b
--- /dev/null
+++ b/tests/core/test_time_c.out
@@ -0,0 +1 @@
+time: \ No newline at end of file
diff --git a/tests/core/test_timeb.in b/tests/core/test_timeb.in
new file mode 100644
index 00000000..1e59f301
--- /dev/null
+++ b/tests/core/test_timeb.in
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <assert.h>
+#include <sys/timeb.h>
+
+int main() {
+ timeb tb;
+ tb.timezone = 1;
+ printf("*%d\n", ftime(&tb));
+ assert(tb.time > 10000);
+ assert(tb.timezone == 0);
+ assert(tb.dstflag == 0);
+ return 0;
+}
diff --git a/tests/core/test_timeb.out b/tests/core/test_timeb.out
new file mode 100644
index 00000000..488c9af7
--- /dev/null
+++ b/tests/core/test_timeb.out
@@ -0,0 +1 @@
+*0
diff --git a/tests/core/test_tinyfuncstr.in b/tests/core/test_tinyfuncstr.in
new file mode 100644
index 00000000..fd1c9563
--- /dev/null
+++ b/tests/core/test_tinyfuncstr.in
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+struct Class {
+ static char *name1() { return "nameA"; }
+ char *name2() { return "nameB"; }
+};
+
+int main() {
+ printf("*%s,%s*\n", Class::name1(), (new Class())->name2());
+ return 0;
+}
diff --git a/tests/core/test_tinyfuncstr.out b/tests/core/test_tinyfuncstr.out
new file mode 100644
index 00000000..ed0d2567
--- /dev/null
+++ b/tests/core/test_tinyfuncstr.out
@@ -0,0 +1 @@
+*nameA,nameB* \ No newline at end of file
diff --git a/tests/core/test_transtrcase.in b/tests/core/test_transtrcase.in
new file mode 100644
index 00000000..a19fcb6e
--- /dev/null
+++ b/tests/core/test_transtrcase.in
@@ -0,0 +1,11 @@
+#include <stdio.h>
+#include <string.h>
+int main() {
+ char szToupr[] = "hello, ";
+ char szTolwr[] = "EMSCRIPTEN";
+ strupr(szToupr);
+ strlwr(szTolwr);
+ printf(szToupr);
+ printf(szTolwr);
+ return 0;
+}
diff --git a/tests/core/test_transtrcase.out b/tests/core/test_transtrcase.out
new file mode 100644
index 00000000..dbb541e6
--- /dev/null
+++ b/tests/core/test_transtrcase.out
@@ -0,0 +1 @@
+HELLO, emscripten \ No newline at end of file
diff --git a/tests/core/test_trickystring.in b/tests/core/test_trickystring.in
new file mode 100644
index 00000000..2735ef7c
--- /dev/null
+++ b/tests/core/test_trickystring.in
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+typedef struct {
+ int (*f)(void *);
+ void *d;
+ char s[16];
+} LMEXFunctionStruct;
+
+int f(void *user) { return 0; }
+
+static LMEXFunctionStruct const a[] = {{f, (void *)(int)'a', "aa"}};
+
+int main() {
+ printf("ok\n");
+ return a[0].f(a[0].d);
+}
diff --git a/tests/core/test_trickystring.out b/tests/core/test_trickystring.out
new file mode 100644
index 00000000..9766475a
--- /dev/null
+++ b/tests/core/test_trickystring.out
@@ -0,0 +1 @@
+ok
diff --git a/tests/core/test_typeid.in b/tests/core/test_typeid.in
new file mode 100644
index 00000000..1f87e66e
--- /dev/null
+++ b/tests/core/test_typeid.in
@@ -0,0 +1,52 @@
+#include <stdio.h>
+#include <string.h>
+#include <typeinfo>
+int main() {
+ printf("*\n");
+#define MAX 100
+ int ptrs[MAX];
+ int groups[MAX];
+ memset(ptrs, 0, MAX * sizeof(int));
+ memset(groups, 0, MAX * sizeof(int));
+ int next_group = 1;
+#define TEST(X) \
+ { \
+ int ptr = (int)&typeid(X); \
+ int group = 0; \
+ int i; \
+ for (i = 0; i < MAX; i++) { \
+ if (!groups[i]) break; \
+ if (ptrs[i] == ptr) { \
+ group = groups[i]; \
+ break; \
+ } \
+ } \
+ if (!group) { \
+ groups[i] = group = next_group++; \
+ ptrs[i] = ptr; \
+ } \
+ printf("%s:%d\n", #X, group); \
+ }
+ TEST(int);
+ TEST(unsigned int);
+ TEST(unsigned);
+ TEST(signed int);
+ TEST(long);
+ TEST(unsigned long);
+ TEST(signed long);
+ TEST(long long);
+ TEST(unsigned long long);
+ TEST(signed long long);
+ TEST(short);
+ TEST(unsigned short);
+ TEST(signed short);
+ TEST(char);
+ TEST(unsigned char);
+ TEST(signed char);
+ TEST(float);
+ TEST(double);
+ TEST(long double);
+ TEST(void);
+ TEST(void*);
+ printf("*\n");
+}
diff --git a/tests/core/test_typeid.out b/tests/core/test_typeid.out
new file mode 100644
index 00000000..6355c27d
--- /dev/null
+++ b/tests/core/test_typeid.out
@@ -0,0 +1,23 @@
+*
+int:1
+unsigned int:2
+unsigned:2
+signed int:1
+long:3
+unsigned long:4
+signed long:3
+long long:5
+unsigned long long:6
+signed long long:5
+short:7
+unsigned short:8
+signed short:7
+char:9
+unsigned char:10
+signed char:11
+float:12
+double:13
+long double:14
+void:15
+void*:16
+*
diff --git a/tests/core/test_uname.in b/tests/core/test_uname.in
new file mode 100644
index 00000000..780a754b
--- /dev/null
+++ b/tests/core/test_uname.in
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <sys/utsname.h>
+
+int main() {
+ struct utsname u;
+ printf("ret: %d\n", uname(&u));
+ printf("sysname: %s\n", u.sysname);
+ printf("nodename: %s\n", u.nodename);
+ printf("release: %s\n", u.release);
+ printf("version: %s\n", u.version);
+ printf("machine: %s\n", u.machine);
+ printf("invalid: %d\n", uname(0));
+ return 0;
+}
diff --git a/tests/core/test_uname.out b/tests/core/test_uname.out
new file mode 100644
index 00000000..cd36c531
--- /dev/null
+++ b/tests/core/test_uname.out
@@ -0,0 +1,6 @@
+ret: 0
+sysname: Emscripten
+nodename: emscripten
+release: 1.0
+version: #1
+machine: x86-JS
diff --git a/tests/core/test_utf.in b/tests/core/test_utf.in
new file mode 100644
index 00000000..87731186
--- /dev/null
+++ b/tests/core/test_utf.in
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <emscripten.h>
+
+int main() {
+ char *c = "μ†ℱ ╋ℯ╳╋ 😇";
+ printf("%d %d %d %d %s\n", c[0] & 0xff, c[1] & 0xff, c[2] & 0xff, c[3] & 0xff,
+ c);
+ emscripten_run_script(
+ "cheez = _malloc(100);"
+ "Module.writeStringToMemory(\"μ†ℱ ╋ℯ╳╋ 😇\", cheez);"
+ "Module.print([Pointer_stringify(cheez), Module.getValue(cheez, "
+ "'i8')&0xff, Module.getValue(cheez+1, 'i8')&0xff, "
+ "Module.getValue(cheez+2, 'i8')&0xff, Module.getValue(cheez+3, "
+ "'i8')&0xff, ]);");
+}
diff --git a/tests/core/test_utf.out b/tests/core/test_utf.out
new file mode 100644
index 00000000..a2af5f8b
--- /dev/null
+++ b/tests/core/test_utf.out
@@ -0,0 +1,2 @@
+206 188 226 128 μ†ℱ ╋ℯ╳╋ 😇
+μ†ℱ ╋ℯ╳╋ 😇,206,188,226,128
diff --git a/tests/core/test_varargs.in b/tests/core/test_varargs.in
new file mode 100644
index 00000000..653a6557
--- /dev/null
+++ b/tests/core/test_varargs.in
@@ -0,0 +1,112 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+void vary(const char *s, ...) {
+ va_list v;
+ va_start(v, s);
+ char d[20];
+ vsnprintf(d, 20, s, v);
+ puts(d);
+
+ // Try it with copying
+ va_list tempva;
+ va_copy(tempva, v);
+ vsnprintf(d, 20, s, tempva);
+ puts(d);
+
+ va_end(v);
+}
+
+void vary2(char color, const char *s, ...) {
+ va_list v;
+ va_start(v, s);
+ char d[21];
+ d[0] = color;
+ vsnprintf(d + 1, 20, s, v);
+ puts(d);
+ va_end(v);
+}
+
+void varargs_listoffsets_list_evaluate(int count, va_list ap, int vaIteration) {
+ while (count > 0) {
+ const char *string = va_arg(ap, const char *);
+ printf("%s", string);
+ count--;
+ }
+ printf("\n");
+}
+
+void varags_listoffsets_list_copy(int count, va_list ap, int iteration) {
+ va_list ap_copy;
+ va_copy(ap_copy, ap);
+ varargs_listoffsets_list_evaluate(count, ap_copy, iteration);
+ va_end(ap_copy);
+}
+
+void varargs_listoffsets_args(int type, int count, ...) {
+ va_list ap;
+ va_start(ap, count);
+
+ // evaluate a copied list
+ varags_listoffsets_list_copy(count, ap, 1);
+ varags_listoffsets_list_copy(count, ap, 2);
+ varags_listoffsets_list_copy(count, ap, 3);
+ varags_listoffsets_list_copy(count, ap, 4);
+
+ varargs_listoffsets_list_evaluate(count, ap, 1);
+
+ // NOTE: we expect this test to fail, so we will check the stdout for
+ // <BAD+0><BAD+1>.....
+ varargs_listoffsets_list_evaluate(count, ap, 2);
+
+ // NOTE: this test has to work again, as we restart the list
+ va_end(ap);
+ va_start(ap, count);
+ varargs_listoffsets_list_evaluate(count, ap, 3);
+ va_end(ap);
+}
+
+void varargs_listoffsets_main() {
+ varargs_listoffsets_args(0, 5, "abc", "def", "ghi", "jkl", "mno", "<BAD+0>",
+ "<BAD+1>", "<BAD+2>", "<BAD+3>", "<BAD+4>",
+ "<BAD+5>", "<BAD+6>", "<BAD+7>", "<BAD+8>",
+ "<BAD+9>", "<BAD+10>", "<BAD+11>", "<BAD+12>",
+ "<BAD+13>", "<BAD+14>", "<BAD+15>", "<BAD+16>");
+}
+
+#define GETMAX(pref, type) \
+ type getMax##pref(int num, ...) { \
+ va_list vv; \
+ va_start(vv, num); \
+ type maxx = va_arg(vv, type); \
+ for (int i = 1; i < num; i++) { \
+ type curr = va_arg(vv, type); \
+ maxx = curr > maxx ? curr : maxx; \
+ } \
+ va_end(vv); \
+ return maxx; \
+ }
+GETMAX(i, int);
+GETMAX(D, double);
+
+int main(int argc, char **argv) {
+ vary("*cheez: %d+%d*", 0,
+ 24); // Also tests that '0' is not special as an array ender
+ vary("*albeit*"); // Should not fail with no var args in vararg function
+ vary2('Q', "%d*", 85);
+
+ int maxxi = getMaxi(6, 2, 5, 21, 4, -10, 19);
+ printf("maxxi:%d*\n", maxxi);
+ double maxxD = getMaxD(6, (double)2.1, (double)5.1, (double)22.1, (double)4.1,
+ (double)-10.1, (double)19.1, (double)2);
+ printf("maxxD:%.2f*\n", (float)maxxD);
+
+ // And, as a function pointer
+ void (*vfp)(const char * s, ...) = argc == 1211 ? NULL : vary;
+ vfp("*vfp:%d,%d*", 22, 199);
+
+ // ensure lists work properly when copied, reinited etc.
+ varargs_listoffsets_main();
+
+ return 0;
+}
diff --git a/tests/core/test_varargs.out b/tests/core/test_varargs.out
new file mode 100644
index 00000000..42a30d74
--- /dev/null
+++ b/tests/core/test_varargs.out
@@ -0,0 +1,16 @@
+*cheez: 0+24*
+*cheez: 0+24*
+*albeit*
+*albeit*
+Q85*
+maxxi:21*
+maxxD:22.10*
+*vfp:22,199*
+*vfp:22,199*
+abcdefghijklmno
+abcdefghijklmno
+abcdefghijklmno
+abcdefghijklmno
+abcdefghijklmno
+<BAD+0><BAD+1><BAD+2><BAD+3><BAD+4>
+abcdefghijklmno
diff --git a/tests/core/test_vprintf.in b/tests/core/test_vprintf.in
new file mode 100644
index 00000000..a8af5735
--- /dev/null
+++ b/tests/core/test_vprintf.in
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdarg.h>
+
+void print(char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+}
+
+int main() {
+ print("Call with %d variable argument.\n", 1);
+ print("Call with %d variable %s.\n", 2, "arguments");
+
+ return 0;
+}
diff --git a/tests/core/test_vprintf.out b/tests/core/test_vprintf.out
new file mode 100644
index 00000000..16f21510
--- /dev/null
+++ b/tests/core/test_vprintf.out
@@ -0,0 +1,2 @@
+Call with 1 variable argument.
+Call with 2 variable arguments.
diff --git a/tests/core/test_vsnprintf.in b/tests/core/test_vsnprintf.in
new file mode 100644
index 00000000..85f91e94
--- /dev/null
+++ b/tests/core/test_vsnprintf.in
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdint.h>
+
+void printy(const char *f, ...) {
+ char buffer[256];
+ va_list args;
+ va_start(args, f);
+ vsnprintf(buffer, 256, f, args);
+ puts(buffer);
+ va_end(args);
+}
+
+int main(int argc, char **argv) {
+ int64_t x = argc - 1;
+ int64_t y = argc - 1 + 0x400000;
+ if (x % 3 == 2) y *= 2;
+
+ printy("0x%llx_0x%llx", x, y);
+ printy("0x%llx_0x%llx", x, x);
+ printy("0x%llx_0x%llx", y, x);
+ printy("0x%llx_0x%llx", y, y);
+
+ {
+ uint64_t A = 0x800000;
+ uint64_t B = 0x800000000000ULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+ {
+ uint64_t A = 0x800;
+ uint64_t B = 0x12340000000000ULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+ {
+ uint64_t A = 0x000009182746756;
+ uint64_t B = 0x192837465631ACBDULL;
+ printy("0x%llx_0x%llx", A, B);
+ }
+
+ return 0;
+}
diff --git a/tests/core/test_vsnprintf.out b/tests/core/test_vsnprintf.out
new file mode 100644
index 00000000..ef8a3f7e
--- /dev/null
+++ b/tests/core/test_vsnprintf.out
@@ -0,0 +1,7 @@
+0x0_0x400000
+0x0_0x0
+0x400000_0x0
+0x400000_0x400000
+0x800000_0x800000000000
+0x800_0x12340000000000
+0x9182746756_0x192837465631acbd
diff --git a/tests/core/test_white_list_exception.in b/tests/core/test_white_list_exception.in
new file mode 100644
index 00000000..2944f9fe
--- /dev/null
+++ b/tests/core/test_white_list_exception.in
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+void thrower() {
+ printf("infunc...");
+ throw(99);
+ printf("FAIL");
+}
+
+void somefunction() {
+ try {
+ thrower();
+ }
+ catch (...) {
+ printf("done!*\n");
+ }
+}
+
+int main() {
+ somefunction();
+ return 0;
+}
diff --git a/tests/core/test_white_list_exception.out b/tests/core/test_white_list_exception.out
new file mode 100644
index 00000000..62e1a81c
--- /dev/null
+++ b/tests/core/test_white_list_exception.out
@@ -0,0 +1 @@
+infunc...done!* \ No newline at end of file
diff --git a/tests/core/test_zero_multiplication.in b/tests/core/test_zero_multiplication.in
new file mode 100644
index 00000000..bb6e7e12
--- /dev/null
+++ b/tests/core/test_zero_multiplication.in
@@ -0,0 +1,12 @@
+#include <stdio.h>
+int main(int argc, char* argv[]) {
+ int one = argc;
+
+ printf("%d ", 0 * one);
+ printf("%d ", 0 * -one);
+ printf("%d ", -one * 0);
+ printf("%g ", 0.0 * one);
+ printf("%g ", 0.0 * -one);
+ printf("%g", -one * 0.0);
+ return 0;
+}
diff --git a/tests/core/test_zero_multiplication.out b/tests/core/test_zero_multiplication.out
new file mode 100644
index 00000000..bb69c671
--- /dev/null
+++ b/tests/core/test_zero_multiplication.out
@@ -0,0 +1 @@
+0 0 0 0 -0 -0 \ No newline at end of file
diff --git a/tests/core/test_zerodiv.in b/tests/core/test_zerodiv.in
new file mode 100644
index 00000000..21430772
--- /dev/null
+++ b/tests/core/test_zerodiv.in
@@ -0,0 +1,18 @@
+#include <stdio.h>
+int main(int argc, const char* argv[]) {
+ float f1 = 1.0f;
+ float f2 = 0.0f;
+ float f_zero = 0.0f;
+
+ float f3 = 0.0f / f2;
+ float f4 = f2 / 0.0f;
+ float f5 = f2 / f2;
+ float f6 = f2 / f_zero;
+
+ printf("f3: %f\n", f3);
+ printf("f4: %f\n", f4);
+ printf("f5: %f\n", f5);
+ printf("f6: %f\n", f6);
+
+ return 0;
+}
diff --git a/tests/core/test_zerodiv.out b/tests/core/test_zerodiv.out
new file mode 100644
index 00000000..3bb47f8a
--- /dev/null
+++ b/tests/core/test_zerodiv.out
@@ -0,0 +1,4 @@
+f3: nan
+f4: nan
+f5: nan
+f6: nan
diff --git a/tests/cubegeom.c b/tests/cubegeom.c
index 96d56339..e749045b 100644
--- a/tests/cubegeom.c
+++ b/tests/cubegeom.c
@@ -54,9 +54,21 @@ int main(int argc, char *argv[])
// Create a texture
+ GLuint boundTex = 123;
+ assert(!glGetError());
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &boundTex);
+ assert(!glGetError());
+ assert(boundTex == 0);
+
GLuint texture;
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
+
+ assert(!glGetError());
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &boundTex);
+ assert(!glGetError());
+ assert(boundTex == texture);
+
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
GLubyte textureData[16*16*4];
diff --git a/tests/emscripten_log/emscripten_log.cpp b/tests/emscripten_log/emscripten_log.cpp
new file mode 100644
index 00000000..a5bb8432
--- /dev/null
+++ b/tests/emscripten_log/emscripten_log.cpp
@@ -0,0 +1,136 @@
+#include <emscripten.h>
+#include <stdio.h>
+#include <cstring>
+
+#define STRINGIZE_HELPER(x) #x
+#define STRINGIZE(x) STRINGIZE_HELPER(x)
+
+#ifndef REPORT_RESULT
+#define REPORT_RESULT int dummy
+#endif
+
+int result = 1; // If 1, this test succeeded.
+
+// A custom assert macro to test varargs routing to emscripten_log().
+#define MYASSERT(condition, ...) \
+ do { \
+ if (!(condition)) { \
+ emscripten_log(EM_LOG_ERROR, "%s", "Condition '" #condition "' failed in file " __FILE__ ":" STRINGIZE(__LINE__) "!"); \
+ emscripten_log(EM_LOG_ERROR, ##__VA_ARGS__); \
+ result = 0; \
+ } \
+ } while(0)
+
+void __attribute__((noinline)) kitten()
+{
+ // Log to Emscripten Module.
+ emscripten_log(EM_LOG_NO_PATHS, "Print a log message: int: %d, string: %s.", 42, "hello");
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_WARN, "Print a warning message");
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_ERROR, "This is an error!");
+
+ // Log directly to Browser web inspector/console.
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE, "Info log to console: int: %d, string: %s", 42, "hello");
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_WARN, "Warning message to console.");
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR, "Error message to console! This should appear in red!");
+
+ // Log to with full callstack information (both original C source and JS callstacks):
+ emscripten_log(EM_LOG_C_STACK | EM_LOG_JS_STACK | EM_LOG_DEMANGLE, "A message with as full call stack information as possible:");
+
+ // Log with just mangled JS callstacks:
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_JS_STACK, "This is a message with a mangled JS callstack:");
+
+ // Log only clean C callstack:
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_C_STACK | EM_LOG_DEMANGLE, "This message should have a clean C callstack:");
+
+ // We can leave out the message to just print out the callstack:
+ printf("The following line should show just the callstack without a message:\n");
+ emscripten_log(EM_LOG_NO_PATHS | EM_LOG_ERROR | EM_LOG_C_STACK | EM_LOG_JS_STACK | EM_LOG_DEMANGLE);
+}
+
+void __attribute__((noinline)) bar(int = 0, char * = 0, double = 0) // Arbitrary function signature to add some content to callstack.
+{
+ if (1 == 2)
+ MYASSERT(2 == 1, "World falls apart!");
+ else
+ MYASSERT(1 == 1);
+
+ int flags = EM_LOG_NO_PATHS | EM_LOG_JS_STACK | EM_LOG_DEMANGLE | EM_LOG_FUNC_PARAMS;
+#ifndef RUN_FROM_JS_SHELL
+ flags |= EM_LOG_C_STACK;
+#endif
+
+ // We can programmatically get the callstack.
+ // 1. Ask for callstack length:
+ int nbytes = emscripten_get_callstack(flags, 0, 0);
+ // 2. Allocate temp memory to hold the callstack.
+ char *callstack = new char[nbytes];
+ // 3. Obtain it.
+ // 4. Do something with the callstack string.
+
+ emscripten_get_callstack(flags, callstack, nbytes);
+
+ /* The callstack should be something like
+ at bar(int, char*, double) (src.cpp.o.js:5383:12)
+ at void Foo<int>() (src.cpp.o.js:5417:4)
+ at main() (src.cpp.o.js:5404:2)
+ at Object.callMain (src.cpp.o.js:71344:30)
+ at doRun (src.cpp.o.js:71383:25)
+ at run (src.cpp.o.js:71396:5)
+ at Object.<anonymous> (src.cpp.o.js:71439:1)
+ at Module._compile (module.js:456:26)
+
+ but the line numbers will greatly vary depending on the mode we are compiling in, so cannot test with direct string comparison. */
+
+ if ((flags & EM_LOG_C_STACK) != 0)
+ {
+ MYASSERT(!!strstr(callstack, "at bar(int, char*, double) (src.cpp:"), "Callstack was %s!", callstack);
+ MYASSERT(!!strstr(callstack, "at void Foo<int>() (src.cpp:"), "Callstack was %s!", callstack);
+ }
+ else
+ {
+ MYASSERT(!!strstr(callstack, "at bar(int, char*, double) (src.cpp.o.js:"), "Callstack was %s!", callstack);
+ MYASSERT(!!strstr(callstack, "at void Foo<int>() (src.cpp.o.js:"), "Callstack was %s!", callstack);
+ }
+
+ // 5. Clean up.
+ delete[] callstack;
+
+ // Or alternatively use a fixed-size buffer for the callstack (and get a truncated output if it was too small).
+ char str[1024];
+ emscripten_get_callstack(EM_LOG_NO_PATHS | EM_LOG_JS_STACK, str, 1024);
+
+ /* With EM_LOG_JS_STACK, the callstack will be
+ at __Z3bariPcd (src.cpp.o.js:5394:12)
+ at __Z3FooIiEvv (src.cpp.o.js:5417:4)
+ at Object._main (src.cpp.o.js:5404:2)
+ at Object.callMain (src.cpp.o.js:71344:30)
+ at doRun (src.cpp.o.js:71383:25)
+ at run (src.cpp.o.js:71396:5)
+ at Object.<anonymous> (src.cpp.o.js:71439:1)
+ at Module._compile (module.js:456:26) */
+#ifdef RUN_FROM_JS_SHELL
+ MYASSERT(!!strstr(str, "at __Z3bariPcd (src.cpp"), "Callstack was %s!", str);
+ MYASSERT(!!strstr(str, "at __Z3FooIiEvv (src.cpp"), "Callstack was %s!", str);
+#else
+ MYASSERT(!!strstr(str, "at __Z3bariPcd (page.js"), "Callstack was %s!", str);
+ MYASSERT(!!strstr(str, "at __Z3FooIiEvv (page.js"), "Callstack was %s!", str);
+#endif
+}
+
+template<typename T>
+void __attribute__((noinline)) Foo() // Arbitrary function signature to add some content to callstack.
+{
+ bar();
+}
+
+int main()
+{
+ Foo<int>();
+#ifndef RUN_FROM_JS_SHELL
+ REPORT_RESULT();
+ return 0;
+#else
+ if (result)
+ printf("Success!\n");
+#endif
+}
diff --git a/tests/fuzz/13.c b/tests/fuzz/13.c
new file mode 100644
index 00000000..623f0dee
--- /dev/null
+++ b/tests/fuzz/13.c
@@ -0,0 +1,107 @@
+/*
+ * This is a RANDOMLY GENERATED PROGRAM.
+ *
+ * Generator: csmith 2.2.0
+ * Git version: bf42ffd
+ * Options: --no-volatiles --no-math64 --no-packed-struct
+ * Seed: 4004715028
+ */
+
+#include "csmith.h"
+
+
+static long __undefined;
+
+/* --- Struct/Union Declarations --- */
+/* --- GLOBAL VARIABLES --- */
+static uint16_t g_2[9][5] = {{1UL,65535UL,0xF90EL,1UL,65532UL},{1UL,1UL,0x4C8DL,1UL,1UL},{65532UL,65535UL,6UL,65529UL,65529UL},{0xF90EL,65532UL,0xF90EL,0x4C8DL,65529UL},{0xC891L,1UL,9UL,1UL,1UL},{65535UL,1UL,0xAA6EL,0xC891L,65532UL},{65526UL,65532UL,9UL,1UL,65535UL},{1UL,0xF90EL,0xF90EL,1UL,65526UL},{1UL,0xC891L,6UL,1UL,0xC891L}};
+
+
+/* --- FORWARD DECLARATIONS --- */
+static uint8_t func_1(void);
+
+
+/* --- FUNCTIONS --- */
+/* ------------------------------------------ */
+/*
+ * reads : g_2
+ * writes:
+ */
+static uint8_t func_1(void)
+{ /* block id: 0 */
+ return g_2[8][2];
+}
+
+
+
+
+/* ---------------------------------------- */
+int main (int argc, char* argv[])
+{
+ int i, j;
+ int print_hash_value = 0;
+ if (argc == 2 && strcmp(argv[1], "1") == 0) print_hash_value = 1;
+ platform_main_begin();
+ crc32_gentab();
+ func_1();
+ for (i = 0; i < 9; i++)
+ {
+ for (j = 0; j < 5; j++)
+ {
+ transparent_crc(g_2[i][j], "g_2[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
+ return 0;
+}
+
+/************************ statistics *************************
+XXX max struct depth: 0
+breakdown:
+ depth: 0, occurrence: 1
+XXX total union variables: 0
+
+XXX non-zero bitfields defined in structs: 0
+XXX zero bitfields defined in structs: 0
+XXX const bitfields defined in structs: 0
+XXX volatile bitfields defined in structs: 0
+XXX structs with bitfields in the program: 0
+breakdown:
+XXX full-bitfields structs in the program: 0
+breakdown:
+XXX times a bitfields struct's address is taken: 0
+XXX times a bitfields struct on LHS: 0
+XXX times a bitfields struct on RHS: 0
+XXX times a single bitfield on LHS: 0
+XXX times a single bitfield on RHS: 0
+
+XXX max expression depth: 1
+breakdown:
+ depth: 1, occurrence: 1
+
+XXX total number of pointers: 0
+
+XXX times a non-volatile is read: 1
+XXX times a non-volatile is write: 0
+XXX times a volatile is read: 0
+XXX times read thru a pointer: 0
+XXX times a volatile is write: 0
+XXX times written thru a pointer: 0
+XXX times a volatile is available for access: 0
+XXX percentage of non-volatile access: 100
+
+XXX forward jumps: 0
+XXX backward jumps: 0
+
+XXX stmts: 1
+XXX max block depth: 0
+breakdown:
+ depth: 0, occurrence: 1
+
+XXX percentage a fresh-made variable is used: 100
+XXX percentage an existing variable is used: 0
+FYI: the random generator makes assumptions about the integer size. See platform.info for more details.
+********************* end of statistics **********************/
+
diff --git a/tests/fuzz/13.c.txt b/tests/fuzz/13.c.txt
new file mode 100644
index 00000000..696a3908
--- /dev/null
+++ b/tests/fuzz/13.c.txt
@@ -0,0 +1 @@
+checksum = 3F436227
diff --git a/tests/fuzz/14.c b/tests/fuzz/14.c
new file mode 100644
index 00000000..17e7ec5f
--- /dev/null
+++ b/tests/fuzz/14.c
@@ -0,0 +1,2435 @@
+/*
+ * This is a RANDOMLY GENERATED PROGRAM.
+ *
+ * Generator: csmith 2.2.0
+ * Git version: bf42ffd
+ * Options: --no-volatiles --no-math64 --no-packed-struct
+ * Seed: 695215668
+ */
+
+#include "csmith.h"
+
+
+static long __undefined;
+
+/* --- Struct/Union Declarations --- */
+/* --- GLOBAL VARIABLES --- */
+static int8_t g_2 = 9L;
+static uint8_t g_31[1] = {0x5BL};
+static int32_t g_36 = 0L;
+static int32_t *g_37 = &g_36;
+static int32_t g_59[9] = {0x5D8284A8L,0xF1AC28C4L,0x5D8284A8L,0xF1AC28C4L,0x5D8284A8L,0xF1AC28C4L,0x5D8284A8L,0xF1AC28C4L,0x5D8284A8L};
+static int32_t g_60[2][5][4] = {{{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL}},{{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL},{0x92628F0FL,0x92628F0FL,0x92628F0FL,0x92628F0FL}}};
+static int32_t g_61 = 0xCBABA27FL;
+static uint16_t g_69[9] = {0x26B3L,0x26B3L,0x26B3L,0x26B3L,0x26B3L,0x26B3L,0x26B3L,0x26B3L,0x26B3L};
+static int16_t g_124 = 1L;
+static int8_t g_126 = 0x2EL;
+static uint8_t g_131 = 246UL;
+static uint32_t g_138[4] = {0x7CE49567L,0x7CE49567L,0x7CE49567L,0x7CE49567L};
+static uint16_t g_145 = 0xDE95L;
+static int32_t * const g_146 = &g_60[0][4][3];
+static int32_t g_358 = (-1L);
+static int32_t g_360 = (-1L);
+static uint32_t g_408[6][10] = {{0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL},{0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL},{0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL},{0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL},{0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL},{0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL,0x1EE3AD7CL}};
+static int8_t g_415 = 0x70L;
+static uint32_t *g_434 = &g_138[3];
+static int8_t **g_435 = (void*)0;
+static uint32_t g_436 = 0x61B69271L;
+static int32_t **g_455 = (void*)0;
+static int32_t ***g_454 = &g_455;
+static int8_t g_510 = 0xF4L;
+static int32_t *g_514 = &g_59[1];
+static uint8_t *g_659 = (void*)0;
+static uint8_t **g_658[5] = {&g_659,&g_659,&g_659,&g_659,&g_659};
+static uint16_t *g_713 = &g_69[6];
+static uint16_t **g_712 = &g_713;
+static int16_t g_775 = 0x1E63L;
+static const uint16_t g_961 = 0UL;
+static uint16_t ** const *g_993 = &g_712;
+static uint16_t ** const * const *g_992 = &g_993;
+static int32_t g_1096[1] = {0x8DF1AA83L};
+static int32_t g_1202 = 0x400DAD15L;
+static uint16_t g_1250 = 65535UL;
+static uint32_t g_1312 = 0x3F36EED0L;
+static uint16_t ***g_1324 = &g_712;
+static uint32_t g_1484 = 18446744073709551612UL;
+static uint32_t *g_1483 = &g_1484;
+static uint16_t g_1509 = 0x40B6L;
+static int32_t *g_1591[6][7] = {{&g_360,&g_360,&g_360,&g_360,&g_360,&g_360,&g_360},{&g_360,&g_360,&g_360,&g_360,&g_360,&g_360,&g_360},{&g_360,&g_360,&g_360,&g_360,&g_360,&g_360,&g_360},{&g_360,&g_360,&g_360,&g_360,&g_360,&g_360,&g_360},{&g_360,&g_360,&g_360,&g_360,&g_360,&g_360,&g_360},{&g_360,&g_360,&g_360,&g_360,&g_360,&g_360,&g_360}};
+static int32_t **g_1590 = &g_1591[5][6];
+static uint16_t g_1758[6][9][3] = {{{0UL,0xC542L,0xD8C5L},{0xC7C1L,0xC7C1L,7UL},{0xAF46L,9UL,0UL},{5UL,1UL,0x6937L},{3UL,0xCD4DL,1UL},{0x6937L,5UL,0x6937L},{0x0379L,0x9AA8L,0UL},{0UL,65535UL,7UL},{0UL,0x0FA7L,0xD8C5L}},{{0x294EL,0UL,0UL},{0UL,65526UL,3UL},{0UL,0x4878L,0xC7C1L},{0x0379L,0x8A66L,0UL},{0x6937L,7UL,65535UL},{3UL,0x8A66L,1UL},{5UL,0x4878L,65532UL},{0xAF46L,65526UL,0UL},{0xC7C1L,0UL,0x4878L}},{{0UL,0x0FA7L,0UL},{65530UL,65535UL,65532UL},{65532UL,0x9AA8L,1UL},{0UL,5UL,65535UL},{3UL,0x2348L,7UL},{0x294EL,65532UL,7UL},{0UL,0xCD4DL,1UL},{65535UL,7UL,0x294EL},{1UL,0x0FA7L,65532UL}},{{7UL,7UL,5UL},{0x0379L,0xCD4DL,0xD8C5L},{65530UL,65532UL,0x4878L},{1UL,0x2348L,0UL},{0x4878L,65530UL,0x4878L},{65535UL,65526UL,0xD8C5L},{0x6937L,1UL,5UL},{7UL,0x8290L,65532UL},{0xC7C1L,0x294EL,0x294EL}},{{7UL,0x7770L,1UL},{0x6937L,0UL,7UL},{65535UL,0xC542L,7UL},{0x4878L,5UL,0UL},{1UL,0xC542L,0xAF46L},{65530UL,0UL,65535UL},{0x0379L,0x7770L,1UL},{7UL,0x294EL,0UL},{1UL,0x8290L,1UL}},{{65535UL,1UL,65535UL},{0UL,65526UL,0xAF46L},{0x294EL,65530UL,0UL},{3UL,0x2348L,7UL},{0x294EL,65532UL,7UL},{0UL,0xCD4DL,1UL},{65535UL,7UL,0x294EL},{1UL,0x0FA7L,65532UL},{7UL,7UL,5UL}}};
+static int16_t g_1847 = 0x0129L;
+static int16_t *g_1846 = &g_1847;
+static const int32_t g_1959 = (-6L);
+static int16_t **g_2019 = (void*)0;
+static uint16_t g_2057[7][8] = {{0x80D1L,65533UL,0xF5B1L,1UL,0xF5B1L,65533UL,0x80D1L,0x80D1L},{65533UL,1UL,0x152EL,0x152EL,1UL,65533UL,0x3260L,65533UL},{1UL,65533UL,0x3260L,65533UL,1UL,0x152EL,0x152EL,1UL},{65533UL,0x80D1L,0x80D1L,65533UL,0xF5B1L,1UL,0xF5B1L,65533UL},{0x80D1L,0xF5B1L,0x80D1L,0x152EL,0x3260L,0x3260L,0x152EL,0x80D1L},{0xF5B1L,0xF5B1L,0x3260L,1UL,0UL,1UL,0x3260L,0xF5B1L},{0xF5B1L,0x80D1L,0x152EL,0x3260L,0x3260L,0x152EL,0x80D1L,0xF5B1L}};
+static int32_t **** const *g_2075 = (void*)0;
+static int32_t ** const **g_2127 = (void*)0;
+static int16_t g_2156 = 0xBBD0L;
+static uint8_t ***g_2219 = (void*)0;
+static int16_t g_2225[10] = {5L,5L,5L,5L,5L,5L,5L,5L,5L,5L};
+static int32_t g_2234 = (-1L);
+static int32_t g_2236 = 0xBA7E2085L;
+static int8_t g_2239 = 0xEBL;
+static int8_t *g_2246 = &g_510;
+static uint8_t g_2387[3][3] = {{255UL,249UL,255UL},{255UL,255UL,255UL},{255UL,249UL,255UL}};
+static const int16_t g_2451 = 0x2C58L;
+static uint8_t ***** const g_2561 = (void*)0;
+static const int32_t *g_2575 = &g_36;
+static int8_t ** const ** const g_2675 = (void*)0;
+static uint8_t * const ***g_2799 = (void*)0;
+static uint32_t g_2907 = 0x8E6C6828L;
+static const uint32_t g_3051 = 0UL;
+static int8_t ***** const g_3152 = (void*)0;
+static int8_t ***** const *g_3151 = &g_3152;
+static int8_t g_3207[10] = {0xB9L,(-7L),0xB9L,0xB9L,(-7L),0xB9L,0xB9L,(-7L),0xB9L,0xB9L};
+static uint32_t g_3271 = 0UL;
+static uint32_t g_3299 = 0x6396F30FL;
+static int32_t ****g_3325[2] = {&g_454,&g_454};
+static uint8_t g_3397 = 0x67L;
+static uint8_t g_3398 = 1UL;
+
+
+/* --- FORWARD DECLARATIONS --- */
+static uint32_t func_1(void);
+static const int32_t func_3(const uint32_t p_4, int32_t p_5, const int16_t p_6);
+static uint32_t func_7(int8_t p_8, int16_t p_9, int32_t p_10, int16_t p_11, int32_t p_12);
+static int32_t func_13(int32_t p_14, int32_t p_15, int16_t p_16, uint16_t p_17);
+static int32_t func_19(int32_t p_20, uint32_t p_21, const int32_t p_22, int32_t p_23, int32_t p_24);
+static int32_t * const func_32(int32_t * p_33);
+static uint8_t func_41(int32_t ** p_42, int32_t * p_43);
+static int32_t ** func_44(const int16_t p_45, uint16_t p_46, uint16_t p_47, int8_t p_48);
+static uint32_t func_49(uint16_t p_50, int32_t ** const p_51, int32_t p_52, int8_t p_53, uint8_t p_54);
+static uint32_t func_57(int16_t p_58);
+
+
+/* --- FUNCTIONS --- */
+/* ------------------------------------------ */
+/*
+ * reads : g_2 g_37 g_145 g_1250 g_69 g_713 g_434 g_2387 g_1846 g_1847 g_993 g_712 g_1590 g_1591 g_61 g_138 g_1324 g_992 g_1758 g_2246 g_510 g_2675 g_146 g_514 g_59 g_454 g_455 g_435 g_36 g_60 g_2236 g_1509 g_3051 g_408 g_131 g_436 g_2225 g_360 g_2575 g_3151 g_124 g_3207 g_1483 g_1484 g_2239 g_3271 g_126 g_3299 g_3325 g_3397 g_3398
+ * writes: g_2234 g_36 g_145 g_1250 g_138 g_69 g_1591 g_61 g_131 g_1847 g_1758 g_2225 g_31 g_60 g_59 g_2236 g_1509 g_436 g_2387 g_713 g_408 g_37 g_124 g_510 g_1312 g_2239 g_455 g_126 g_3299 g_1484 g_658 g_3398
+ */
+static uint32_t func_1(void)
+{ /* block id: 0 */
+ int32_t l_26 = 0xF4039EE4L;
+ int32_t l_3026[7][3] = {{0x1A749151L,0x425EA4C2L,0x425EA4C2L},{(-1L),0x425EA4C2L,0x97D45EBDL},{0xE085E4B3L,0x425EA4C2L,(-1L)},{0x7AAD61BDL,0x7AAD61BDL,(-1L)},{0x425EA4C2L,0x97D45EBDL,(-3L)},{0xE085E4B3L,0x7AAD61BDL,0xE085E4B3L},{0xE085E4B3L,0x425EA4C2L,0x7AAD61BDL}};
+ int8_t l_3266[10][5][2] = {{{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L}},{{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L}},{{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L}},{{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L}},{{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L}},{{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L}},{{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L}},{{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L}},{{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L}},{{0x10L,0x85L},{0x85L,0x10L},{0x85L,0x85L},{0x10L,0x85L},{0x85L,0x10L}}};
+ int32_t * const *l_3293 = &g_514;
+ int32_t * const **l_3292 = &l_3293;
+ int32_t * const ***l_3291 = &l_3292;
+ uint8_t *l_3327 = &g_31[0];
+ uint16_t l_3340 = 0x2D69L;
+ uint16_t l_3380 = 0x6577L;
+ int8_t **l_3395[6];
+ int i, j, k;
+ for (i = 0; i < 6; i++)
+ l_3395[i] = &g_2246;
+ if (g_2)
+ { /* block id: 1 */
+ uint8_t l_18 = 0x0EL;
+ int32_t l_25 = (-5L);
+ l_3026[0][0] = func_3(func_7(g_2, g_2, (l_3026[1][2] |= (0x6F7FBF21L > func_13(l_18, func_19(((l_25 = (((l_18 <= g_2) && (0x0A9B27FAL && (l_18 > 0xC5A3D7F1L))) < 0x2530A9BCL)) == g_2), l_26, l_18, g_2, g_2), l_26, l_26))), l_18, l_18), l_18, l_18);
+ }
+ else
+ { /* block id: 1616 */
+ uint32_t l_3127 = 8UL;
+ int32_t l_3138 = 0x0C4C8D53L;
+ int32_t l_3153 = 0x33A3E34BL;
+ int32_t **l_3155 = &g_37;
+ const int16_t l_3197 = 0xABAEL;
+ uint8_t l_3232 = 0xCDL;
+ const uint8_t *l_3242 = &g_2387[2][1];
+ const uint8_t * const *l_3241 = &l_3242;
+ int32_t * const l_3286 = &g_36;
+ uint32_t l_3302 = 6UL;
+ for (g_145 = (-20); (g_145 <= 3); g_145++)
+ { /* block id: 1619 */
+ int16_t l_3147[9] = {0L,0L,0L,0L,0L,0L,0L,0L,0L};
+ int i;
+ (*g_146) = (l_3127 , 1L);
+ if ((*g_2575))
+ continue;
+ for (g_131 = (-12); (g_131 <= 1); g_131 = safe_add_func_uint16_t_u_u(g_131, 1))
+ { /* block id: 1624 */
+ uint32_t *l_3148 = &g_408[2][6];
+ int16_t l_3154 = 0x527AL;
+ (*g_514) ^= ((*g_146) = (safe_mul_func_uint16_t_u_u((safe_rshift_func_int16_t_s_s(0xD70CL, (((*g_434) , (--(*g_713))) & (safe_sub_func_uint16_t_u_u(((l_3138 &= (*g_1846)) & 0xAD6EL), (l_3127 != (((((safe_sub_func_uint8_t_u_u((0x27E1980DL < (((safe_mod_func_int16_t_s_s((l_3153 ^= (safe_add_func_int8_t_s_s((safe_mod_func_uint32_t_u_u((l_3147[5] | (-5L)), ((*l_3148)++))), (((((((void*)0 == g_3151) , 2L) , l_3147[5]) < (*g_1846)) >= l_3147[5]) | 0x77L)))), l_3154)) > l_3127) == 0L)), l_3154)) ^ (*g_434)) , l_3026[1][2]) >= l_3154) , l_3154))))))), (*g_1846))));
+ }
+ }
+ (*l_3155) = &l_3153;
+ if ((+0xFF1AF652L))
+ { /* block id: 1634 */
+ int32_t *l_3156[5];
+ uint8_t ***l_3173 = &g_658[2];
+ int8_t **l_3181 = &g_2246;
+ const int16_t l_3183 = (-1L);
+ int32_t l_3243 = 5L;
+ uint32_t l_3267 = 4294967288UL;
+ int i;
+ for (i = 0; i < 5; i++)
+ l_3156[i] = &g_36;
+ (*l_3155) = &l_3026[0][0];
+ for (g_124 = 0; (g_124 > (-8)); g_124--)
+ { /* block id: 1638 */
+ uint32_t l_3178 = 0xC9609AEAL;
+ int8_t l_3179[1][5];
+ uint32_t l_3180 = 18446744073709551612UL;
+ int32_t l_3182 = (-1L);
+ uint16_t **l_3227 = (void*)0;
+ int32_t *l_3260[8] = {&g_358,&g_358,&g_1096[0],&g_358,&g_358,&g_1096[0],&g_358,&g_358};
+ int32_t l_3265 = (-7L);
+ uint16_t *l_3276[7] = {&g_1758[2][3][0],&g_1250,&g_1758[2][3][0],&g_1758[2][3][0],&g_1250,&g_1758[2][3][0],&g_1758[2][3][0]};
+ int8_t *l_3277 = &g_126;
+ int32_t * const *l_3278 = &g_146;
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 5; j++)
+ l_3179[i][j] = 0x60L;
+ }
+ (*g_514) ^= ((l_26 && ((safe_sub_func_int32_t_s_s(((*g_37) != (((safe_rshift_func_uint8_t_u_s(((-1L) ^ (safe_rshift_func_uint8_t_u_s((safe_mul_func_uint16_t_u_u(l_3026[1][2], (0xE2F6L <= (((((l_3182 = (safe_sub_func_int32_t_s_s((safe_rshift_func_int16_t_s_s((**l_3155), (((*g_434) ^= ((safe_rshift_func_int8_t_s_s(((*g_2246) &= ((l_3173 == &g_658[2]) != (((((safe_div_func_uint32_t_u_u((safe_div_func_int32_t_s_s(((l_3178 ^ l_3178) | (**l_3155)), l_3179[0][0])), 4294967295UL)) == (**l_3155)) | l_3180) , l_3181) != &g_2246))), 4)) == l_3178)) != (**l_3155)))), 4294967295UL))) , (*g_454)) != &l_3156[1]) && l_3183) , 0UL)))), 4))), (**l_3155))) == 0x78F00C48L) || (**g_712))), 9L)) == 0x17DDD041L)) != 0x7496L);
+ for (l_3178 = 26; (l_3178 != 20); l_3178--)
+ { /* block id: 1645 */
+ uint8_t l_3231 = 0x9BL;
+ int16_t l_3268 = (-1L);
+ for (g_1312 = (-17); (g_1312 >= 7); g_1312 = safe_add_func_int8_t_s_s(g_1312, 5))
+ { /* block id: 1648 */
+ uint32_t *l_3198 = &g_408[2][6];
+ const uint16_t *l_3229 = &g_2057[5][1];
+ const uint16_t **l_3228 = &l_3229;
+ int32_t l_3230 = 0x605411FEL;
+ int8_t *l_3233 = (void*)0;
+ uint8_t **l_3240 = &g_659;
+ l_3156[1] = (((*l_3198) |= ((safe_lshift_func_int16_t_s_s((safe_mul_func_int8_t_s_s(((l_3179[0][4] <= (0L == (*g_1846))) & (safe_lshift_func_int8_t_s_s((**l_3155), (((((l_26 , (safe_div_func_uint8_t_u_u((((*g_2246) , ((*g_514) = (safe_unary_minus_func_int32_t_s(((*g_1846) > 0x8D74L))))) || ((*g_434) ^ (*g_434))), 0x0AL))) > l_3197) & l_3179[0][0]) , 0x7BL) && 0UL)))), 0x3FL)), l_26)) != 0xFF74B1E8L)) , (*l_3155));
+ (*g_146) |= (safe_mod_func_int16_t_s_s((safe_mul_func_uint16_t_u_u(((safe_mod_func_uint32_t_u_u((safe_add_func_uint16_t_u_u(g_3207[7], (safe_unary_minus_func_int16_t_s((((safe_sub_func_uint16_t_u_u((safe_mod_func_uint8_t_u_u((safe_mod_func_int32_t_s_s((safe_mod_func_int8_t_s_s((g_2239 &= ((((*g_1846) && (0xBCL && ((~(((((safe_mod_func_int16_t_s_s(((*g_1846) &= (safe_lshift_func_uint16_t_u_u((safe_rshift_func_uint8_t_u_u((((safe_sub_func_uint32_t_u_u(((safe_add_func_int16_t_s_s((((**l_3155) == (*g_2246)) != (l_3227 == l_3228)), (0xF5E6L & (0xCC5E7D7EL != l_3230)))) <= 0xD3L), (*g_2575))) == (**l_3155)) >= l_3231), l_3178)), 11))), l_3026[1][2])) < 0x6C78F6E4L) <= l_3232) , l_3179[0][0]) , (*g_1483))) , 0x5EL))) ^ 0xDC82L) < 0x6ACCL)), l_3026[1][1])), (**l_3155))), 0x50L)), (***g_993))) && (***g_1324)) , (-8L)))))), l_3179[0][2])) , 0x38A6L), (****g_992))), l_3179[0][0]));
+ (*g_514) |= (~((!(l_3230 > ((l_3230 , ((*g_2246) || l_3182)) , (safe_add_func_uint16_t_u_u((((safe_mul_func_uint16_t_u_u(((**l_3155) , ((***g_1324) = ((safe_rshift_func_uint16_t_u_s((((l_3240 == l_3241) , l_3243) , (safe_rshift_func_int16_t_s_s(((*g_1846) &= (l_3231 < 0xE8F6L)), l_3230))), l_3230)) , l_3230))), (**l_3155))) < l_3230) < (**l_3155)), l_3230))))) == (-1L)));
+ (*g_514) = ((*g_146) = ((**l_3155) = (((safe_sub_func_uint8_t_u_u((safe_mul_func_uint8_t_u_u(1UL, (*g_2246))), (((((((*l_3198) = (safe_add_func_uint16_t_u_u((safe_lshift_func_int8_t_s_u(0xDBL, 7)), ((safe_div_func_int8_t_s_s((safe_div_func_int32_t_s_s((safe_rshift_func_uint16_t_u_s((l_3173 != ((l_3156[1] == l_3260[3]) , (void*)0)), 0)), (((safe_mul_func_uint8_t_u_u((((l_3265 = ((safe_mul_func_int8_t_s_s((l_3230 | 7L), (*g_2246))) ^ l_3230)) | (*g_2575)) != l_3266[7][2][0]), l_3267)) | l_3182) , 0xC94E0367L))), l_3268)) >= 251UL)))) >= (**l_3155)) && 246UL) == l_3268) ^ 0x6F59L) | (**l_3155)))) | 0x97L) == l_3230)));
+ }
+ (*g_514) = (**l_3155);
+ (*g_454) = (*g_454);
+ if (l_3026[1][2])
+ break;
+ }
+ (*g_146) = (((((safe_rshift_func_int8_t_s_u(((**l_3181) = g_3271), 3)) && (*g_434)) , (**g_712)) ^ (**l_3155)) == ((*g_454) != ((safe_lshift_func_uint8_t_u_s((safe_lshift_func_uint16_t_u_u(3UL, (l_26 | (l_3182 = l_3179[0][0])))), ((*l_3277) ^= 0xE3L))) , l_3278)));
+ }
+ }
+ else
+ { /* block id: 1673 */
+ int8_t l_3279 = 0x05L;
+ int32_t l_3298 = 1L;
+ int16_t l_3328 = (-2L);
+ int8_t l_3378 = 0x76L;
+ const uint32_t l_3379 = 9UL;
+ int8_t l_3384 = 0xF5L;
+ (*g_37) = (*g_514);
+ l_3138 |= (~(**l_3155));
+ if (((*g_146) = l_3279))
+ { /* block id: 1677 */
+ int32_t ****l_3294[1][4][5] = {{{&g_454,&g_454,(void*)0,&g_454,&g_454},{(void*)0,&g_454,(void*)0,(void*)0,&g_454},{&g_454,(void*)0,(void*)0,&g_454,(void*)0},{&g_454,&g_454,&g_454,&g_454,&g_454}}};
+ const uint8_t * const **l_3317[9] = {&l_3241,&l_3241,&l_3241,&l_3241,&l_3241,&l_3241,&l_3241,&l_3241,&l_3241};
+ const uint8_t * const ***l_3316 = &l_3317[1];
+ int i, j, k;
+ if ((safe_unary_minus_func_int16_t_s(((*g_1846) = ((&g_3271 != (void*)0) > (*g_1846))))))
+ { /* block id: 1679 */
+ int32_t * const l_3281[8] = {&g_36,&g_36,&g_36,&g_36,&g_36,&g_36,&g_36,&g_36};
+ int32_t **l_3282 = (void*)0;
+ int32_t **l_3283 = &g_37;
+ int i;
+ (*l_3283) = l_3281[5];
+ (*l_3283) = ((((*g_2575) > 0xB5BFD70DL) || (safe_div_func_uint32_t_u_u(((void*)0 != l_3286), (safe_add_func_uint8_t_u_u(((safe_rshift_func_int16_t_s_s(((((l_3291 == l_3294[0][0][2]) > ((safe_add_func_int16_t_s_s(((****l_3291) >= (l_3279 <= (((safe_unary_minus_func_uint8_t_u((**l_3283))) || 0x4EL) , (-1L)))), (*g_1846))) , l_3279)) != (*g_434)) , l_3279), 0)) , 5UL), (-5L)))))) , (*l_3283));
+ g_3299++;
+ }
+ else
+ { /* block id: 1683 */
+ uint32_t l_3307[9] = {0x1754E157L,0x1754E157L,0x1754E157L,0x1754E157L,0x1754E157L,0x1754E157L,0x1754E157L,0x1754E157L,0x1754E157L};
+ uint8_t ****l_3318 = &g_2219;
+ int i;
+ --l_3302;
+ if ((*g_146))
+ { /* block id: 1685 */
+ int32_t *** const **l_3319 = (void*)0;
+ int32_t *** const **l_3320 = (void*)0;
+ int32_t **l_3324 = &g_514;
+ int32_t *** const l_3323 = &l_3324;
+ int32_t *** const *l_3322[10][5] = {{&l_3323,&l_3323,&l_3323,&l_3323,&l_3323},{&l_3323,&l_3323,&l_3323,(void*)0,(void*)0},{&l_3323,&l_3323,&l_3323,&l_3323,&l_3323},{(void*)0,&l_3323,&l_3323,(void*)0,&l_3323},{(void*)0,(void*)0,&l_3323,&l_3323,&l_3323},{&l_3323,&l_3323,&l_3323,&l_3323,&l_3323},{&l_3323,&l_3323,&l_3323,&l_3323,&l_3323},{&l_3323,&l_3323,&l_3323,&l_3323,&l_3323},{&l_3323,(void*)0,&l_3323,&l_3323,(void*)0},{&l_3323,&l_3323,&l_3323,&l_3323,&l_3323}};
+ int32_t *** const **l_3321 = &l_3322[9][1];
+ int16_t l_3326 = 0x5EE0L;
+ int i, j;
+ (**l_3324) = (((l_3307[7] && (safe_rshift_func_int8_t_s_u(((((((((((void*)0 == &g_1846) <= ((safe_lshift_func_int16_t_s_u((safe_add_func_int8_t_s_s((((*g_1483) = (0x6558BEDCL > (*g_434))) , ((*g_2246) = (safe_lshift_func_uint16_t_u_s((l_3316 == l_3318), 11)))), (****l_3291))), ((((((*l_3321) = &g_454) == g_3325[0]) || l_3298) > (*g_434)) == l_3326))) , (-1L))) & (*g_514)) , (void*)0) != l_3327) & 0xA7L) == (***l_3292)) | (*g_434)) ^ (*g_146)), 3))) && 0L) != l_3298);
+ (**l_3293) |= l_3328;
+ }
+ else
+ { /* block id: 1691 */
+ (****l_3291) = (((void*)0 != &g_124) , (safe_sub_func_uint16_t_u_u((**g_712), (*g_1846))));
+ }
+ }
+ for (l_3138 = 0; (l_3138 <= (-17)); l_3138 = safe_sub_func_uint8_t_u_u(l_3138, 3))
+ { /* block id: 1697 */
+ (*g_514) ^= (*g_2575);
+ }
+ }
+ else
+ { /* block id: 1700 */
+ uint8_t l_3339[9] = {251UL,251UL,251UL,251UL,251UL,251UL,251UL,251UL,251UL};
+ int i;
+ (*g_514) &= ((safe_mul_func_int8_t_s_s((((safe_mul_func_uint16_t_u_u((safe_div_func_uint32_t_u_u(4294967295UL, l_3339[8])), (((l_3340 = (9L && 250UL)) & ((l_3339[5] , ((safe_sub_func_int16_t_s_s(((-10L) ^ ((*g_434)--)), 7UL)) > (((((**g_712) | (&g_454 != (void*)0)) > l_3339[8]) , l_3339[8]) < 0xF9L))) , 0x7C37L)) <= l_3339[2]))) , l_3339[0]) && (*g_2246)), 0x6CL)) && l_3339[3]);
+ }
+ for (g_2239 = (-16); (g_2239 <= (-26)); g_2239--)
+ { /* block id: 1707 */
+ uint8_t l_3383[4][5][8] = {{{0x22L,0x97L,247UL,0xC9L,0xC9L,247UL,0x97L,0x22L},{0xE5L,250UL,0x1FL,0x75L,9UL,255UL,1UL,3UL},{0xA8L,0xE3L,0x97L,4UL,0x75L,255UL,0UL,0x09L},{1UL,250UL,0x1EL,1UL,252UL,247UL,0x1FL,247UL},{0x09L,0x97L,252UL,0x97L,0x09L,0UL,250UL,0x1FL}},{{0UL,250UL,0x88L,1UL,1UL,0x0BL,0x65L,0x97L},{0xC9L,0xA8L,0x88L,0UL,0x97L,0UL,250UL,0x1EL},{1UL,4UL,252UL,0x1FL,0x88L,0x88L,0x1FL,252UL},{9UL,9UL,0x1EL,250UL,0UL,0x97L,0UL,0x88L},{0x1EL,255UL,0x97L,0x65L,0x0BL,1UL,1UL,0x88L}},{{255UL,0x22L,0x1FL,250UL,0UL,0x09L,0x97L,252UL},{1UL,252UL,247UL,0x1FL,247UL,252UL,1UL,0x1EL},{0x1FL,0xF3L,0x09L,0UL,255UL,0x75L,4UL,0x97L},{0UL,0x09L,3UL,1UL,255UL,9UL,0x75L,0x1FL},{0x1FL,4UL,0x22L,0x97L,247UL,0xC9L,0xC9L,247UL}},{{1UL,1UL,1UL,1UL,0UL,4UL,0x88L,0x09L},{255UL,247UL,1UL,4UL,0x0BL,0x1EL,0xF3L,3UL},{0x1EL,247UL,0x65L,0x88L,1UL,0x22L,0x75L,0xF3L},{0x75L,0xC9L,0xE5L,250UL,4UL,250UL,0xE5L,0xC9L},{4UL,0x22L,9UL,4UL,0UL,0x75L,0x65L,247UL}}};
+ int32_t *l_3387 = &l_3298;
+ int32_t ***l_3393 = &g_455;
+ int i, j, k;
+ for (g_436 = 0; (g_436 >= 58); g_436 = safe_add_func_uint8_t_u_u(g_436, 9))
+ { /* block id: 1710 */
+ uint8_t l_3350 = 0UL;
+ int16_t l_3382 = 0x906CL;
+ const uint8_t l_3390 = 1UL;
+ int32_t ** const *l_3396 = &g_455;
+ if (l_3279)
+ { /* block id: 1711 */
+ uint8_t ***l_3349 = &g_658[2];
+ int32_t l_3355 = 0xE58C1806L;
+ uint32_t l_3381 = 0x8D96A914L;
+ int32_t **l_3385[4];
+ int32_t **l_3386 = &g_37;
+ int i;
+ for (i = 0; i < 4; i++)
+ l_3385[i] = &g_514;
+ (*l_3349) = &g_659;
+ l_3384 = (l_3350 || (safe_mul_func_uint16_t_u_u((((safe_div_func_int32_t_s_s(((l_3355 <= (*g_713)) , (l_3350 < (safe_rshift_func_uint8_t_u_u((((void*)0 == &g_2799) && (**l_3155)), 0)))), (safe_mul_func_int8_t_s_s(((*g_2246) = (safe_add_func_int16_t_s_s((safe_mul_func_int16_t_s_s((safe_add_func_int8_t_s_s(((safe_lshift_func_int16_t_s_s((((safe_rshift_func_uint8_t_u_u((safe_sub_func_int8_t_s_s((safe_rshift_func_uint16_t_u_s((((((*g_713) == (((((((safe_rshift_func_int16_t_s_s(((((*g_1846) = (*g_1846)) | g_2236) < 0x4AL), l_3378)) & (*g_2246)) || 0x10L) == l_3379) > 4294967289UL) && (-1L)) >= 1L)) < (**l_3155)) != (*g_434)) <= (*g_434)), 11)), (***l_3292))), 1)) == l_3380) , 0xF838L), (*l_3286))) > 1L), l_3381)), l_3382)), 0x3F1DL))), l_3383[0][1][7])))) ^ (-9L)) > (*g_434)), l_3383[3][2][6])));
+ (*l_3386) = (**l_3292);
+ }
+ else
+ { /* block id: 1717 */
+ int32_t ****l_3394 = &l_3393;
+ l_3387 = (void*)0;
+ (*g_146) = ((((**l_3293) >= (safe_mod_func_int8_t_s_s(((l_3390 ^ ((**l_3155) | ((((safe_mul_func_int16_t_s_s((((*l_3394) = l_3393) != ((l_3379 | (l_3395[4] != (void*)0)) , l_3396)), 5L)) & (*g_146)) >= (**l_3155)) & l_3298))) , (-1L)), (****l_3291)))) & 1L) ^ g_3397);
+ g_3398++;
+ }
+ }
+ }
+ }
+ }
+ return (****l_3291);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_1846 g_514 g_59 g_1509 g_434 g_138 g_3051 g_1847 g_408 g_37 g_36 g_131 g_712 g_713 g_69 g_436 g_2225 g_993 g_1590 g_1591 g_360
+ * writes: g_1847 g_59 g_1509 g_138 g_131 g_36 g_436 g_2387 g_2225 g_713
+ */
+static const int32_t func_3(const uint32_t p_4, int32_t p_5, const int16_t p_6)
+{ /* block id: 1558 */
+ int8_t l_3038[3][4][7] = {{{(-9L),(-8L),0x33L,(-1L),1L,1L,(-2L)},{1L,(-6L),(-1L),0xE3L,0x61L,0x0FL,0x58L},{(-1L),0xF9L,(-9L),1L,0x61L,(-6L),(-6L)},{1L,0x33L,1L,0x33L,1L,0x00L,0x13L}},{{1L,0x61L,0xB1L,0x31L,(-1L),0xB9L,8L},{1L,0xFEL,0L,(-4L),0xFBL,(-1L),0xB1L},{1L,0x31L,(-8L),1L,(-6L),(-1L),0xE3L},{1L,1L,(-2L),0xFBL,0x52L,(-7L),(-1L)}},{{(-1L),(-2L),0xCAL,0xFBL,1L,0xFEL,1L},{1L,0x00L,0x00L,1L,(-2L),0x58L,1L},{(-9L),1L,(-9L),(-4L),0L,0x31L,0x1AL},{0x00L,0x58L,(-6L),0x31L,0x0FL,0xE3L,1L}}};
+ uint8_t *l_3071 = &g_2387[1][1];
+ int32_t l_3080 = 0L;
+ int32_t l_3081 = 0x141AEC86L;
+ int32_t l_3082 = 4L;
+ int32_t l_3087[4] = {1L,1L,1L,1L};
+ int8_t * const ***l_3105 = (void*)0;
+ int8_t * const ****l_3104 = &l_3105;
+ int8_t * const *****l_3106 = &l_3104;
+ uint16_t l_3107 = 0x130AL;
+ int16_t *l_3108 = &g_2225[6];
+ uint16_t l_3122 = 65529UL;
+ int i, j, k;
+ (*g_514) ^= ((safe_lshift_func_uint16_t_u_s((safe_rshift_func_uint16_t_u_u(0x5884L, 4)), 7)) ^ (safe_mul_func_int16_t_s_s(((l_3038[1][1][5] > 249UL) <= p_4), ((*g_1846) = (0x837FL ^ 0xE54FL)))));
+ for (p_5 = (-20); (p_5 < (-18)); ++p_5)
+ { /* block id: 1563 */
+ uint32_t l_3043 = 1UL;
+ int32_t l_3053 = 0x27A5B9B0L;
+ int32_t l_3079 = 0xBA3474DDL;
+ int32_t l_3083 = 0x0378FB79L;
+ int32_t l_3084 = 0x4EC607B8L;
+ int32_t l_3086 = 0x87B4D2E8L;
+ int32_t l_3088 = 5L;
+ int32_t l_3089 = 0xEFC3DAA0L;
+ int32_t l_3090 = 0xB68C8DD3L;
+ int32_t l_3091 = 1L;
+ int32_t l_3092 = (-1L);
+ int32_t l_3093[4][1][7] = {{{0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL}},{{0L,0L,0L,0L,0L,0L,0L}},{{0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL,0x9167FBDEL}},{{0L,0L,0L,0L,0L,0L,0L}}};
+ uint32_t l_3094 = 18446744073709551615UL;
+ int i, j, k;
+ for (g_1509 = 0; (g_1509 <= 6); g_1509 += 1)
+ { /* block id: 1566 */
+ uint32_t *l_3050 = &g_408[4][7];
+ int32_t l_3052 = 0x71A954C8L;
+ uint8_t *l_3068 = &g_131;
+ int32_t ****l_3074 = &g_454;
+ int32_t *l_3075 = &g_60[0][4][3];
+ int32_t *l_3076 = (void*)0;
+ int32_t *l_3077[2];
+ int8_t l_3078 = 0x3FL;
+ int32_t l_3085[3][2][9] = {{{0L,0L,0L,0L,0L,0L,0L,0L,0L},{0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL}},{{0L,0L,0L,0L,0L,0L,0L,0L,0L},{0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL}},{{0L,0L,0L,0L,0L,0L,0L,0L,0L},{0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL,0x2A21343BL}}};
+ int i, j, k;
+ for (i = 0; i < 2; i++)
+ l_3077[i] = &l_3052;
+ if ((safe_sub_func_int8_t_s_s(((l_3053 = (l_3043 < (safe_mod_func_int32_t_s_s(p_6, (((*g_434) = (*g_434)) ^ (l_3038[0][0][0] ^ (((1UL && (safe_sub_func_uint8_t_u_u(((((p_4 | p_5) , (safe_lshift_func_uint8_t_u_u(((void*)0 != l_3050), g_3051))) ^ l_3052) & 0x3911L), l_3038[1][1][5]))) | 0x33036F19L) , l_3052))))))) | 0x5FL), p_6)))
+ { /* block id: 1569 */
+ for (l_3043 = 1; (l_3043 <= 5); l_3043 += 1)
+ { /* block id: 1572 */
+ uint32_t l_3055 = 3UL;
+ int i, j;
+ for (g_1847 = 4; (g_1847 >= 0); g_1847 -= 1)
+ { /* block id: 1575 */
+ int32_t l_3054 = 0xE1145BC8L;
+ int i, j;
+ (*g_514) = 0x27A2A679L;
+ if (g_408[g_1847][(g_1847 + 2)])
+ continue;
+ --l_3055;
+ }
+ if (g_408[l_3043][(g_1509 + 3)])
+ continue;
+ (*g_514) |= (*g_37);
+ }
+ if (l_3053)
+ break;
+ }
+ else
+ { /* block id: 1584 */
+ (*g_514) ^= (-2L);
+ return p_5;
+ }
+ (*g_37) &= ((safe_div_func_int8_t_s_s((4L == l_3052), (safe_rshift_func_int8_t_s_s(((safe_mod_func_uint16_t_u_u((0xF60BDD11L | ((safe_rshift_func_uint8_t_u_s(((safe_lshift_func_int8_t_s_u(p_6, (++(*l_3068)))) <= ((*g_1846) ^= ((l_3071 != ((l_3068 == (void*)0) , (void*)0)) <= ((((safe_div_func_int32_t_s_s(((l_3053 = ((void*)0 != l_3074)) != p_5), 0x66F4258AL)) , 0xD0AF22D9L) , 0UL) >= 0x60F4L)))), l_3038[2][3][4])) , l_3043)), p_6)) >= p_4), 2)))) | (**g_712));
+ --l_3094;
+ for (g_436 = 0; (g_436 <= 6); g_436 += 1)
+ { /* block id: 1595 */
+ for (l_3092 = 6; (l_3092 >= 0); l_3092 -= 1)
+ { /* block id: 1598 */
+ return p_4;
+ }
+ if (p_5)
+ break;
+ }
+ }
+ }
+ l_3087[0] = (safe_div_func_int32_t_s_s((((**g_993) = (((((*l_3108) &= ((*g_434) ^ (((safe_lshift_func_int8_t_s_s(p_4, 2)) ^ (safe_unary_minus_func_uint32_t_u(((-1L) == (safe_mul_func_uint8_t_u_u(((*l_3071) = 0x55L), ((l_3082 = ((*g_1846) = p_6)) | p_6))))))) , ((l_3080 & (((((((*l_3106) = l_3104) == (void*)0) , 0x7096EE73L) >= p_4) >= l_3107) != 0xC9CFL)) > l_3082)))) != p_4) , l_3081) , &l_3107)) != (void*)0), l_3080));
+ (*g_514) &= ((((*g_37) = (safe_mod_func_uint16_t_u_u((safe_add_func_uint32_t_u_u((0xBB8BL | (p_6 <= (safe_mod_func_int8_t_s_s(p_6, ((safe_rshift_func_int16_t_s_u(0x7606L, (p_6 && l_3087[0]))) , (((((safe_div_func_int32_t_s_s((safe_rshift_func_int8_t_s_u(((safe_unary_minus_func_int32_t_s(l_3122)) , ((safe_div_func_int16_t_s_s(8L, l_3122)) != 0x444F67B9L)), l_3081)), 2L)) ^ (-1L)) > p_4) , (**g_1590)) , 0x96L)))))), l_3038[1][1][5])), p_6))) >= 0x6C7D49EBL) == 0xF40DL);
+ return l_3038[1][1][6];
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_2236
+ * writes: g_2236
+ */
+static uint32_t func_7(int8_t p_8, int16_t p_9, int32_t p_10, int16_t p_11, int32_t p_12)
+{ /* block id: 1551 */
+ uint16_t l_3029 = 0x94C3L;
+ for (g_2236 = (-17); (g_2236 > 22); g_2236++)
+ { /* block id: 1554 */
+ l_3029++;
+ }
+ return l_3029;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_146 g_60
+ * writes:
+ */
+static int32_t func_13(int32_t p_14, int32_t p_15, int16_t p_16, uint16_t p_17)
+{ /* block id: 1548 */
+ return (*g_146);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_37 g_145 g_1250 g_69 g_713 g_434 g_2387 g_1846 g_1847 g_993 g_712 g_1590 g_1591 g_61 g_138 g_1324 g_992 g_1758 g_2246 g_510 g_2675 g_146 g_514 g_59 g_454 g_455 g_435 g_36
+ * writes: g_2234 g_36 g_145 g_1250 g_138 g_69 g_1591 g_61 g_131 g_1847 g_1758 g_2225 g_31 g_60 g_59
+ */
+static int32_t func_19(int32_t p_20, uint32_t p_21, const int32_t p_22, int32_t p_23, int32_t p_24)
+{ /* block id: 3 */
+ uint16_t l_2271[8] = {0xDEC2L,0xDEC2L,0UL,0xDEC2L,0xDEC2L,0UL,0xDEC2L,0xDEC2L};
+ int32_t l_2279 = 0x4E8C2824L;
+ int32_t l_2329 = 0x307D7E8CL;
+ int32_t l_2330 = 1L;
+ int32_t l_2331 = 1L;
+ int32_t l_2332 = 6L;
+ uint8_t l_2333[6][9][4] = {{{255UL,4UL,255UL,3UL},{0UL,0x56L,2UL,0UL},{246UL,3UL,0x97L,0x56L},{3UL,4UL,0x97L,0x97L},{246UL,246UL,2UL,0x5BL},{0UL,0x19L,255UL,0x56L},{255UL,0x56L,3UL,255UL},{246UL,0x56L,252UL,0x56L},{0x56L,0x19L,0x97L,0x5BL}},{{0x45L,246UL,3UL,0x97L},{0UL,4UL,5UL,0x56L},{0UL,3UL,3UL,0UL},{0x45L,0x56L,0x97L,3UL},{0x56L,4UL,252UL,0x5BL},{246UL,0x45L,3UL,0x5BL},{255UL,4UL,255UL,3UL},{0UL,0x56L,2UL,0UL},{246UL,3UL,0x97L,0x56L}},{{3UL,4UL,0x97L,0x97L},{246UL,246UL,2UL,0x5BL},{0UL,0x19L,255UL,0x56L},{255UL,0x56L,3UL,255UL},{246UL,0x56L,252UL,0x56L},{0x56L,0x19L,0x97L,0x5BL},{0x45L,246UL,3UL,0x97L},{0UL,4UL,5UL,0x56L},{0UL,3UL,3UL,0UL}},{{0x45L,0x56L,0x97L,3UL},{0x56L,4UL,252UL,0x5BL},{246UL,0x45L,3UL,0x5BL},{255UL,4UL,255UL,3UL},{0UL,0x56L,2UL,0UL},{246UL,3UL,0x97L,0x56L},{3UL,4UL,0x97L,0x97L},{246UL,246UL,2UL,0x5BL},{0UL,0x19L,255UL,0x56L}},{{255UL,0x56L,3UL,255UL},{246UL,0x56L,252UL,0x56L},{0x56L,0x19L,0x97L,0x5BL},{0x45L,246UL,3UL,0x97L},{0UL,4UL,5UL,0x56L},{0UL,3UL,3UL,0UL},{0x45L,0x56L,0x97L,3UL},{0x56L,4UL,252UL,0x5BL},{246UL,0x45L,3UL,0x5BL}},{{255UL,4UL,252UL,5UL},{0x97L,255UL,0UL,0x97L},{3UL,5UL,6UL,255UL},{5UL,0x45L,6UL,6UL},{3UL,3UL,0UL,0x19L},{0x97L,255UL,252UL,255UL},{252UL,255UL,5UL,252UL},{3UL,255UL,4UL,255UL},{255UL,255UL,6UL,0x19L}}};
+ int16_t l_2338 = (-1L);
+ int32_t l_2339 = 0xCE9AC76DL;
+ int32_t l_2340 = 1L;
+ uint8_t **l_2352 = (void*)0;
+ int16_t l_2375 = 1L;
+ int8_t ***l_2396 = (void*)0;
+ int8_t ****l_2395 = &l_2396;
+ int32_t l_2405 = 0xE7CA1D27L;
+ int32_t l_2419 = 0xCAE5D46BL;
+ uint32_t l_2446 = 0x4AF43DC1L;
+ uint16_t **l_2486[2][9][10] = {{{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{(void*)0,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,(void*)0,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{(void*)0,&g_713,&g_713,(void*)0,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713}},{{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,(void*)0,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,(void*)0,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,(void*)0,(void*)0,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713},{&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713}}};
+ int32_t l_2528[2];
+ uint8_t l_2534 = 0xC1L;
+ uint32_t l_2562 = 0xBBC01CAAL;
+ const int32_t **l_2615 = &g_2575;
+ const int32_t ***l_2614 = &l_2615;
+ int8_t l_2718 = 0x7FL;
+ int32_t l_2727 = 1L;
+ uint16_t l_2757 = 0xBD99L;
+ int32_t * const *l_2787[6];
+ uint8_t ****l_2801 = (void*)0;
+ int16_t l_2802 = 0x2117L;
+ int16_t *l_2803 = &g_2225[9];
+ const uint16_t l_2829 = 65529UL;
+ uint32_t * const l_2837 = (void*)0;
+ int32_t l_2854 = (-1L);
+ int16_t l_2994 = 0x4B9BL;
+ int32_t l_2995 = 0x159AF702L;
+ uint32_t l_3018 = 0x29CF6467L;
+ uint16_t ****l_3023 = &g_1324;
+ int i, j, k;
+ for (i = 0; i < 2; i++)
+ l_2528[i] = 0x408F1F41L;
+ for (i = 0; i < 6; i++)
+ l_2787[i] = &g_37;
+ for (p_21 = (-4); (p_21 == 4); p_21 = safe_add_func_int16_t_s_s(p_21, 3))
+ { /* block id: 6 */
+ const int16_t l_2281 = 0x5292L;
+ int32_t *l_2321 = &g_2234;
+ int32_t *l_2322 = (void*)0;
+ int32_t l_2323 = 0L;
+ int32_t *l_2324 = (void*)0;
+ int32_t *l_2325 = &g_60[0][0][2];
+ int32_t *l_2326 = &l_2279;
+ int32_t *l_2327 = &g_60[0][4][3];
+ int32_t *l_2328[1][4][10] = {{{&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0]},{&g_61,&g_61,&g_2236,&g_61,&g_61,&g_2236,&g_61,&g_61,&g_2236,&g_61},{&g_61,&g_60[1][2][0],&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0],&g_61},{&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0],&g_61,&g_60[1][2][0],&g_60[1][2][0]}}};
+ int i, j, k;
+ for (p_20 = 11; (p_20 == (-22)); --p_20)
+ { /* block id: 9 */
+ uint32_t **l_2265 = &g_434;
+ int32_t l_2282 = (-1L);
+ uint32_t l_2317 = 0UL;
+ int32_t *l_2320 = &l_2282;
+ for (p_23 = 0; (p_23 >= 0); p_23 -= 1)
+ { /* block id: 12 */
+ int32_t *l_35[7][7] = {{&g_36,&g_36,&g_36,(void*)0,&g_36,&g_36,&g_36},{&g_36,&g_36,&g_36,&g_36,&g_36,&g_36,&g_36},{&g_36,&g_36,&g_36,&g_36,&g_36,&g_36,&g_36},{&g_36,(void*)0,&g_36,&g_36,(void*)0,&g_36,(void*)0},{&g_36,&g_36,&g_36,&g_36,&g_36,&g_36,&g_36},{&g_36,&g_36,&g_36,&g_36,&g_36,&g_36,&g_36},{&g_36,&g_36,(void*)0,&g_36,&g_36,&g_36,&g_36}};
+ int32_t **l_34[9][10][2] = {{{&l_35[4][1],&l_35[1][3]},{&l_35[0][0],&l_35[1][3]},{&l_35[5][1],(void*)0},{(void*)0,&l_35[1][3]},{(void*)0,(void*)0},{&l_35[5][1],&l_35[1][3]},{&l_35[0][0],&l_35[1][3]},{&l_35[4][1],(void*)0},{&l_35[1][3],(void*)0},{(void*)0,&l_35[1][3]}},{{&l_35[4][1],&l_35[1][3]},{&l_35[1][3],&l_35[1][3]},{&l_35[4][1],&l_35[1][3]},{(void*)0,(void*)0},{&l_35[1][3],(void*)0},{&l_35[4][1],&l_35[1][3]},{&l_35[0][0],&l_35[1][3]},{&l_35[5][1],(void*)0},{(void*)0,&l_35[1][3]},{(void*)0,(void*)0}},{{&l_35[5][1],&l_35[1][3]},{&l_35[0][0],&l_35[1][3]},{&l_35[4][1],(void*)0},{&l_35[1][3],(void*)0},{(void*)0,&l_35[1][3]},{&l_35[4][1],&l_35[1][3]},{&l_35[1][3],&l_35[1][3]},{&l_35[4][1],&l_35[1][3]},{(void*)0,(void*)0},{&l_35[1][3],(void*)0}},{{&l_35[4][1],&l_35[1][3]},{&l_35[0][0],&l_35[1][3]},{&l_35[5][1],(void*)0},{(void*)0,&l_35[1][3]},{(void*)0,(void*)0},{&l_35[5][1],&l_35[1][3]},{&l_35[0][0],&l_35[1][3]},{&l_35[4][1],(void*)0},{&l_35[1][3],(void*)0},{(void*)0,&l_35[1][0]}},{{&l_35[1][3],&l_35[1][3]},{&l_35[5][6],&l_35[1][3]},{&l_35[1][3],&l_35[1][0]},{&l_35[1][3],&l_35[1][3]},{&l_35[2][1],&l_35[6][4]},{&l_35[1][3],&l_35[0][3]},{&l_35[5][1],&l_35[1][3]},{&l_35[1][3],&l_35[6][4]},{&l_35[1][3],&l_35[5][0]},{&l_35[1][3],&l_35[6][4]}},{{&l_35[1][3],&l_35[1][3]},{&l_35[5][1],&l_35[0][3]},{&l_35[1][3],&l_35[6][4]},{&l_35[2][1],&l_35[1][3]},{&l_35[1][3],&l_35[1][0]},{&l_35[1][3],&l_35[1][3]},{&l_35[5][6],&l_35[1][3]},{&l_35[1][3],&l_35[1][0]},{&l_35[1][3],&l_35[1][3]},{&l_35[2][1],&l_35[6][4]}},{{&l_35[1][3],&l_35[0][3]},{&l_35[5][1],&l_35[1][3]},{&l_35[1][3],&l_35[6][4]},{&l_35[1][3],&l_35[5][0]},{&l_35[1][3],&l_35[6][4]},{&l_35[1][3],&l_35[1][3]},{&l_35[5][1],&l_35[0][3]},{&l_35[1][3],&l_35[6][4]},{&l_35[2][1],&l_35[1][3]},{&l_35[1][3],&l_35[1][0]}},{{&l_35[1][3],&l_35[1][3]},{&l_35[5][6],&l_35[1][3]},{&l_35[1][3],&l_35[1][0]},{&l_35[1][3],&l_35[1][3]},{&l_35[2][1],&l_35[6][4]},{&l_35[1][3],&l_35[0][3]},{&l_35[5][1],&l_35[1][3]},{&l_35[1][3],&l_35[6][4]},{&l_35[1][3],&l_35[5][0]},{&l_35[1][3],&l_35[6][4]}},{{&l_35[1][3],&l_35[1][3]},{&l_35[5][1],&l_35[0][3]},{&l_35[1][3],&l_35[6][4]},{&l_35[2][1],&l_35[1][3]},{&l_35[1][3],&l_35[1][0]},{&l_35[1][3],&l_35[1][3]},{&l_35[5][6],&l_35[1][3]},{&l_35[1][3],&l_35[1][0]},{&l_35[1][3],&l_35[1][3]},{&l_35[2][1],&l_35[6][4]}}};
+ int32_t **l_2264 = &l_35[1][3];
+ const int16_t l_2276[8] = {0xA6A5L,0xA6A5L,0xA6A5L,0xA6A5L,0xA6A5L,0xA6A5L,0xA6A5L,0xA6A5L};
+ uint8_t ****l_2288 = &g_2219;
+ int i, j, k;
+ }
+ return p_21;
+ }
+ l_2333[4][4][3]++;
+ if (((*g_37) = ((*l_2321) = (safe_mod_func_int8_t_s_s((-1L), 0xF3L)))))
+ { /* block id: 1225 */
+ return l_2338;
+ }
+ else
+ { /* block id: 1227 */
+ uint32_t l_2341 = 18446744073709551615UL;
+ l_2341++;
+ }
+ for (l_2329 = 0; (l_2329 >= 27); l_2329++)
+ { /* block id: 1232 */
+ for (g_145 = 0; (g_145 > 23); g_145 = safe_add_func_uint16_t_u_u(g_145, 1))
+ { /* block id: 1235 */
+ return l_2331;
+ }
+ for (l_2330 = 0; (l_2330 > (-5)); l_2330 = safe_sub_func_int16_t_s_s(l_2330, 5))
+ { /* block id: 1240 */
+ return l_2333[4][3][1];
+ }
+ (*g_37) = (safe_rshift_func_int8_t_s_s(p_23, 2));
+ }
+ }
+ for (g_1250 = 0; (g_1250 <= 2); g_1250 += 1)
+ { /* block id: 1248 */
+ const int32_t *l_2353 = &g_36;
+ const int32_t **l_2354 = &l_2353;
+ int8_t * const *l_2386 = (void*)0;
+ int8_t * const **l_2385[5] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
+ int8_t ***l_2393 = &g_435;
+ int8_t ****l_2392 = &l_2393;
+ int32_t l_2400 = 0xE45F6443L;
+ int8_t l_2430[4];
+ const int16_t *l_2450 = &g_2451;
+ int16_t *l_2452 = &g_775;
+ const uint16_t *l_2485 = &g_145;
+ const uint16_t **l_2484 = &l_2485;
+ const uint16_t ***l_2483[8];
+ const uint32_t l_2507 = 0xC6FC5E1DL;
+ int8_t *l_2512 = &g_126;
+ int32_t l_2523 = 4L;
+ int32_t l_2524 = 9L;
+ int32_t l_2525 = 0x626DBABCL;
+ int32_t l_2526 = 0xB725935DL;
+ int32_t l_2527 = (-4L);
+ int32_t l_2529 = 1L;
+ int32_t l_2530 = 1L;
+ uint8_t l_2531[6][3][9] = {{{0xF8L,0x49L,7UL,9UL,6UL,0x07L,254UL,255UL,2UL},{9UL,0x1EL,0xA4L,0x69L,248UL,0xBCL,1UL,0x07L,0xADL},{2UL,7UL,3UL,0xFBL,0x34L,0xFBL,3UL,7UL,2UL}},{{0xFBL,2UL,9UL,4UL,4UL,0x5FL,0xAEL,255UL,0x21L},{0xD8L,9UL,255UL,0x53L,0xBCL,0x34L,4UL,0xEEL,7UL},{0xFBL,4UL,0xAEL,0xD8L,0xEAL,0xEAL,7UL,9UL,3UL}},{{2UL,0x4AL,0xF8L,0UL,0x21L,250UL,9UL,0xDAL,255UL},{9UL,0x46L,0xDAL,9UL,249UL,0UL,0x28L,0x03L,1UL},{0xF8L,0xBCL,0xBBL,0x58L,0x56L,9UL,0xF2L,0xBCL,0x07L}},{{0x58L,0x11L,251UL,0x07L,0xB7L,252UL,4UL,0x44L,255UL},{0x03L,6UL,248UL,251UL,251UL,248UL,6UL,0x03L,0x21L},{6UL,0x0BL,0xD8L,2UL,255UL,0x56L,0UL,0x49L,255UL}},{{249UL,3UL,0x44L,255UL,0xBCL,0xFBL,0x56L,0x98L,0x21L},{0xBFL,254UL,0xEAL,3UL,0x5FL,248UL,255UL,251UL,255UL},{0xBBL,248UL,4UL,248UL,255UL,255UL,254UL,7UL,0x07L}},{{0xF2L,4UL,0x21L,0x4AL,9UL,0x11L,0xEEL,0xD6L,0xBFL},{0xCCL,255UL,0xF2L,0x4AL,7UL,4UL,0x34L,248UL,0x49L},{255UL,0xBFL,0x03L,248UL,0x98L,9UL,0xCCL,0x53L,0x53L}}};
+ uint32_t l_2558 = 4294967295UL;
+ int16_t l_2602 = (-1L);
+ int i, j, k;
+ for (i = 0; i < 4; i++)
+ l_2430[i] = 0L;
+ for (i = 0; i < 8; i++)
+ l_2483[i] = &l_2484;
+ p_24 = (&g_659 != l_2352);
+ if (g_69[(g_1250 + 6)])
+ continue;
+ (*l_2354) = l_2353;
+ (*l_2354) = &p_22;
+ for (l_2330 = 0; (l_2330 <= 2); l_2330 += 1)
+ { /* block id: 1255 */
+ int8_t ****l_2382 = (void*)0;
+ int8_t ***l_2384 = &g_435;
+ int8_t ****l_2383 = &l_2384;
+ int8_t *****l_2394 = &l_2383;
+ int32_t l_2399[9][6][1] = {{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}},{{(-1L)},{(-1L)},{(-1L)},{0x5EEB2947L},{(-1L)},{(-1L)}}};
+ uint16_t l_2418 = 65533UL;
+ uint32_t *l_2426 = &g_138[3];
+ uint32_t l_2509 = 1UL;
+ uint8_t ****l_2560 = &g_2219;
+ uint8_t *****l_2559 = &l_2560;
+ uint32_t l_2573 = 18446744073709551612UL;
+ int i, j, k;
+ (*g_37) = (safe_lshift_func_int8_t_s_s(((((((*g_1590) = ((safe_mod_func_uint16_t_u_u(((*g_713) = (((((((safe_div_func_uint8_t_u_u((safe_lshift_func_int16_t_s_u(((safe_div_func_uint16_t_u_u(((((*g_434) = ((safe_mul_func_uint8_t_u_u(l_2340, (safe_mul_func_uint16_t_u_u((((safe_rshift_func_int8_t_s_u(l_2333[4][4][3], p_21)) , ((!(0x8BAFL > (((*l_2383) = ((safe_mul_func_int16_t_s_s(((safe_mod_func_int16_t_s_s(l_2375, (*g_713))) & (safe_mul_func_uint8_t_u_u(0xC5L, (safe_rshift_func_int16_t_s_u((safe_rshift_func_int8_t_s_s(p_24, 6)), 7))))), (*g_713))) , (void*)0)) != l_2385[4]))) >= 0x4190L)) >= l_2339), l_2339)))) && 6UL)) && p_24) , p_23), p_23)) || (-1L)), (*g_713))), g_2387[2][1])) | (*g_1846)) == p_21) , (***g_993)) | 1UL) > (*g_1846)) , 1UL)), p_22)) , (*g_1590))) == &p_23) == l_2333[4][4][3]) <= p_20) == 251UL), 5));
+ }
+ }
+ for (l_2332 = 1; (l_2332 >= 0); l_2332 -= 1)
+ { /* block id: 1347 */
+ const int32_t *l_2638 = &l_2339;
+ uint16_t ** const l_2650[10] = {&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713,&g_713};
+ int32_t l_2656 = 1L;
+ int32_t l_2659 = 0x8D981328L;
+ int16_t l_2694 = (-10L);
+ int16_t l_2706 = 0L;
+ int32_t l_2709 = 0xF0B25886L;
+ int32_t l_2712 = (-8L);
+ int32_t l_2713[10][1] = {{4L},{4L},{0x088957D1L},{4L},{4L},{0x088957D1L},{4L},{4L},{0x088957D1L},{4L}};
+ uint16_t l_2730 = 0xFE70L;
+ uint8_t **l_2752 = &g_659;
+ uint32_t **l_2791 = (void*)0;
+ uint32_t ***l_2790 = &l_2791;
+ uint32_t ***l_2792 = (void*)0;
+ uint32_t **l_2793 = &g_434;
+ int8_t *** const *l_2798 = (void*)0;
+ uint8_t * const ****l_2800[2][10][6] = {{{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,(void*)0},{&g_2799,(void*)0,&g_2799,(void*)0,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,(void*)0,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,(void*)0,&g_2799,&g_2799},{&g_2799,(void*)0,&g_2799,&g_2799,&g_2799,&g_2799}},{{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,(void*)0,(void*)0,&g_2799,&g_2799,(void*)0},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{(void*)0,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,(void*)0,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799},{&g_2799,&g_2799,&g_2799,&g_2799,&g_2799,&g_2799}}};
+ uint8_t l_2914 = 255UL;
+ int i, j, k;
+ }
+ for (p_24 = 1; (p_24 >= 0); p_24 -= 1)
+ { /* block id: 1503 */
+ int32_t *l_2915 = &g_1096[0];
+ int8_t ** const l_2916 = (void*)0;
+ int32_t l_2928 = 0xB06FF22EL;
+ uint16_t *l_2938[5][3];
+ int32_t l_2971 = 9L;
+ int8_t ***l_2975 = &g_435;
+ uint32_t **l_2984 = (void*)0;
+ int32_t l_2998 = (-4L);
+ int32_t l_2999 = 0xB5DEAA51L;
+ int32_t l_3000[7];
+ uint16_t *****l_3024 = (void*)0;
+ uint16_t *****l_3025 = &l_3023;
+ int i, j;
+ for (i = 0; i < 5; i++)
+ {
+ for (j = 0; j < 3; j++)
+ l_2938[i][j] = &g_1758[3][0][1];
+ }
+ for (i = 0; i < 7; i++)
+ l_3000[i] = (-3L);
+ if (((*g_1590) != l_2915))
+ { /* block id: 1504 */
+ uint16_t *l_2937 = &g_1250;
+ int8_t **** const l_2974 = &l_2396;
+ int32_t l_2983 = 4L;
+ int32_t ****l_2993 = &g_454;
+ int32_t l_2996[3][1];
+ uint32_t l_3015 = 0xBEECD428L;
+ int i, j;
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 1; j++)
+ l_2996[i][j] = 6L;
+ }
+ for (g_61 = 0; (g_61 <= 1); g_61 += 1)
+ { /* block id: 1507 */
+ int8_t l_2929 = (-4L);
+ int32_t *l_2930 = &g_36;
+ int8_t ***l_2976[5];
+ int32_t l_2997 = 0L;
+ int i;
+ for (i = 0; i < 5; i++)
+ l_2976[i] = &g_435;
+ for (l_2854 = 0; (l_2854 <= 2); l_2854 += 1)
+ { /* block id: 1510 */
+ int8_t **l_2917 = &g_2246;
+ uint16_t ****l_2925 = &g_1324;
+ int32_t l_2977 = 1L;
+ uint8_t l_3001[3][3][5] = {{{0xC0L,253UL,253UL,0xC0L,253UL},{251UL,0UL,0x97L,0UL,251UL},{253UL,0xC0L,253UL,253UL,0xC0L}},{{251UL,0x17L,0xEAL,0UL,0xEAL},{0xC0L,0xC0L,0x82L,0xC0L,0xC0L},{0xEAL,0UL,0xEAL,0x17L,251UL}},{{0xC0L,253UL,253UL,0xC0L,253UL},{251UL,0UL,0x97L,0UL,251UL},{253UL,0xC0L,253UL,253UL,0xC0L}}};
+ int i, j, k;
+ for (g_131 = 0; (g_131 <= 4); g_131 += 1)
+ { /* block id: 1513 */
+ int8_t ***l_2918 = &l_2917;
+ int8_t l_2939 = 0x4DL;
+ int32_t l_2946 = (-7L);
+ uint8_t *l_2978 = &g_31[0];
+ int i, j, k;
+ l_2930 = (((l_2916 == ((*l_2918) = l_2917)) , (safe_rshift_func_int8_t_s_u((0xA3L || ((safe_lshift_func_int8_t_s_s(((void*)0 != l_2915), 6)) >= (safe_lshift_func_int8_t_s_u(((((*g_1846) = (l_2925 != (void*)0)) < (((safe_mul_func_int16_t_s_s(l_2928, ((+((0xCEL >= 0x34L) , l_2928)) != p_22))) , (*g_434)) , (-1L))) , (-2L)), l_2929)))), p_23))) , (void*)0);
+ l_2930 = ((safe_add_func_int8_t_s_s((p_24 & (safe_mod_func_uint32_t_u_u(((safe_add_func_uint32_t_u_u(((**g_1324) != (l_2938[4][2] = l_2937)), ((((l_2939 | (safe_sub_func_int32_t_s_s(0x0979E7F6L, (safe_lshift_func_int16_t_s_s(p_24, 14))))) != ((p_22 >= (l_2528[p_24] = (safe_mod_func_uint8_t_u_u(0x34L, p_20)))) == p_23)) < 0xC3B9L) ^ (****g_992)))) ^ l_2939), p_24))), l_2946)) , (void*)0);
+ (*g_146) = (safe_div_func_int32_t_s_s((safe_mod_func_uint16_t_u_u((g_1758[(l_2854 + 3)][(l_2854 + 3)][l_2854] |= 1UL), (safe_lshift_func_uint16_t_u_u((((void*)0 != &g_434) , (safe_lshift_func_int16_t_s_u((((*l_2978) = (safe_mod_func_int32_t_s_s((((safe_mul_func_int16_t_s_s((safe_add_func_uint16_t_u_u((safe_sub_func_uint8_t_u_u(((((safe_div_func_int8_t_s_s((((**g_712) |= ((+((((safe_div_func_uint16_t_u_u((((safe_lshift_func_uint8_t_u_s(((*g_1846) != ((*l_2803) = (safe_mul_func_uint16_t_u_u((l_2971 || ((((*g_2246) == ((safe_add_func_uint32_t_u_u((g_2675 != l_2974), ((((*l_2974) = l_2975) == l_2976[0]) < p_24))) , l_2928)) <= p_20) != 0x89L)), p_20)))), (*g_2246))) ^ l_2977) ^ (*g_2246)), p_22)) ^ p_21) <= 0xE8FBL) == l_2528[p_24])) != p_22)) , 0L), 0xA7L)) , l_2528[p_24]) | (*g_434)) ^ (*g_1846)), 3L)), p_20)), 65527UL)) , 2L) & (*g_1846)), p_24))) <= p_24), l_2939))), 5)))), 0xAECA8320L));
+ }
+ if ((((safe_mod_func_int16_t_s_s((safe_lshift_func_uint16_t_u_u((l_2971 <= p_21), 3)), ((l_2528[p_24] = l_2983) , ((((((p_22 , (l_2984 == &g_434)) >= (safe_add_func_uint8_t_u_u((l_2528[p_24] != (((safe_add_func_int16_t_s_s((safe_add_func_uint16_t_u_u((((*g_37) = ((l_2993 == (void*)0) < 0UL)) , (***g_993)), p_23)), (***g_993))) , (void*)0) == l_2993)), p_24))) & 0xEC1A434FL) , p_23) , p_21) | 0xBD554C6CL)))) && (****g_992)) & (*g_434)))
+ { /* block id: 1529 */
+ ++l_3001[1][0][3];
+ (*g_514) ^= p_21;
+ }
+ else
+ { /* block id: 1532 */
+ int32_t l_3012 = 0L;
+ int i, j, k;
+ (*g_37) ^= (safe_mul_func_uint16_t_u_u((safe_sub_func_uint16_t_u_u(65535UL, ((safe_add_func_int8_t_s_s((safe_lshift_func_int8_t_s_u(((p_20 , &l_2930) == (*g_454)), l_3012)), ((((safe_sub_func_int16_t_s_s((((*g_434) = (p_21 = (p_22 != l_3001[1][0][3]))) < ((((g_1758[(g_61 + 3)][(p_24 + 7)][l_2854] = (&g_2246 != (*l_2975))) != p_23) , 0xEEL) > p_22)), (**g_712))) <= (*g_713)) , l_3015) >= p_24))) , p_22))), 2UL));
+ }
+ }
+ }
+ return p_24;
+ }
+ else
+ { /* block id: 1541 */
+ int32_t l_3016 = 0x8DB39DADL;
+ int32_t l_3017[3];
+ int i;
+ for (i = 0; i < 3; i++)
+ l_3017[i] = 0x6AFC90CCL;
+ l_3018--;
+ }
+ (*g_514) |= (&g_1324 != ((safe_mul_func_uint8_t_u_u(6UL, 0x72L)) , ((*l_3025) = l_3023)));
+ }
+ return p_21;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_36 g_69 g_37 g_138 g_436 g_360 g_510 g_434 g_408 g_31 g_59 g_146 g_60 g_2 g_514 g_124 g_415 g_658 g_126 g_61 g_713 g_454 g_455 g_358 g_775 g_435 g_131 g_961 g_1096 g_145 g_992 g_993 g_1202 g_1250 g_712 g_1312 g_1324 g_1590 g_659 g_1509 g_1758 g_2057 g_2075 g_1846 g_1847 g_2127 g_2156 g_1591 g_2236 g_2234
+ * writes: g_36 g_59 g_60 g_61 g_69 g_37 g_360 g_510 g_436 g_145 g_415 g_131 g_31 g_138 g_658 g_712 g_659 g_455 g_775 g_126 g_124 g_358 g_408 g_454 g_1324 g_1483 g_435 g_1509 g_1758 g_514 g_1590 g_1847 g_2219 g_2246 g_2236 g_2234
+ */
+static int32_t * const func_32(int32_t * p_33)
+{ /* block id: 14 */
+ uint16_t l_40 = 0xF32AL;
+ int32_t *l_526 = &g_360;
+ int32_t **l_525 = &l_526;
+ int32_t ** const l_533 = &g_37;
+ int16_t *l_774[2];
+ int16_t *l_776[5][9] = {{&g_124,&g_775,&g_775,&g_124,(void*)0,&g_124,&g_775,&g_775,&g_124},{&g_775,&g_775,&g_124,&g_775,&g_775,&g_775,&g_775,&g_124,&g_775},{&g_775,(void*)0,&g_124,&g_775,(void*)0,&g_775,(void*)0,&g_124,&g_124},{&g_775,&g_775,&g_775,&g_775,&g_775,&g_775,&g_775,&g_775,&g_124},{&g_124,(void*)0,&g_124,&g_775,&g_775,&g_124,(void*)0,&g_124,&g_775}};
+ uint16_t l_777[6][1] = {{65535UL},{9UL},{65535UL},{65535UL},{9UL},{65535UL}};
+ int32_t ***l_1792 = &g_455;
+ int32_t *l_2249 = &g_2236;
+ int32_t *l_2250 = &g_2234;
+ int i, j;
+ for (i = 0; i < 2; i++)
+ l_774[i] = &g_775;
+ (*l_2250) ^= ((*l_2249) |= (safe_mul_func_uint8_t_u_u(l_40, func_41(((*l_1792) = func_44((g_775 ^= ((l_40 < func_49(l_40, (((safe_lshift_func_uint16_t_u_u((((func_57(l_40) >= (l_525 == ((0UL ^ (safe_div_func_uint8_t_u_u((safe_mod_func_uint8_t_u_u((safe_mod_func_int8_t_s_s(0xA1L, l_40)), 255UL)), l_40))) , &l_526))) ^ l_40) , 0x108BL), 3)) >= 8UL) , l_533), g_138[3], l_40, g_436)) <= g_408[3][9])), l_40, l_40, l_777[4][0])), p_33))));
+ (*p_33) = (((safe_div_func_uint32_t_u_u((*l_2249), (safe_unary_minus_func_int8_t_s((safe_div_func_uint16_t_u_u((~(safe_rshift_func_int8_t_s_u((((*l_2249) >= ((safe_sub_func_int32_t_s_s(((((*g_713) = (safe_mul_func_int8_t_s_s((*l_2249), (*l_2249)))) <= (*l_2250)) != ((*l_2250) & 0x31L)), ((((*l_2250) || 0x9EL) & (*l_2249)) >= (*p_33)))) ^ (*l_2249))) <= (*g_434)), 4))), (*l_2249))))))) ^ (*l_2250)) & (*l_2250));
+ p_33 = ((*l_533) = p_33);
+ for (g_124 = 0; (g_124 < (-4)); g_124--)
+ { /* block id: 1175 */
+ return p_33;
+ }
+ return p_33;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_415 g_124 g_60 g_434 g_138 g_1509 g_510 g_358 g_2057 g_61 g_146 g_31 g_2075 g_514 g_59 g_408 g_1846 g_1847 g_2127 g_1096 g_36 g_713 g_69 g_2156 g_131 g_436 g_775 g_1591 p_24
+ * writes: g_415 g_124 g_1509 g_131 g_510 g_358 g_514 g_61 g_60 g_1590 g_436 g_1847 g_59 g_36 g_69 g_775 g_126 g_31 g_138 g_2219 g_2246 p_24
+ */
+static uint8_t func_41(int32_t ** p_42, int32_t * p_43)
+{ /* block id: 912 */
+ int32_t *l_1795 = &g_60[0][3][2];
+ int32_t l_1864 = 0x3228974EL;
+ int32_t l_1869[4] = {0xA483868DL,0xA483868DL,0xA483868DL,0xA483868DL};
+ const int8_t *l_1930 = &g_126;
+ const int8_t **l_1929 = &l_1930;
+ const int8_t ***l_1928 = &l_1929;
+ const int8_t ****l_1927 = &l_1928;
+ uint32_t l_1968[8][4] = {{2UL,1UL,2UL,0xDC5C3954L},{1UL,2UL,4294967292UL,2UL},{2UL,0UL,4294967292UL,4294967292UL},{1UL,1UL,2UL,4294967292UL},{0xDC5C3954L,0UL,0xDC5C3954L,2UL},{0xDC5C3954L,2UL,2UL,0xDC5C3954L},{1UL,2UL,4294967292UL,2UL},{2UL,0UL,4294967292UL,4294967292UL}};
+ int32_t l_1988 = 0x9CEC8610L;
+ uint32_t l_1993 = 0xC327587BL;
+ uint16_t *l_2036 = &g_69[4];
+ int32_t l_2046 = (-6L);
+ int32_t l_2047 = 3L;
+ int32_t l_2149 = 1L;
+ uint32_t l_2171 = 0x43A65C1DL;
+ uint8_t l_2174 = 0x1AL;
+ const int8_t l_2220 = (-3L);
+ int8_t l_2223[8] = {0x4EL,0x4EL,0x4EL,0x4EL,0x4EL,0x4EL,0x4EL,0x4EL};
+ int i, j;
+lbl_1873:
+ for (g_415 = 0; (g_415 < (-25)); g_415--)
+ { /* block id: 915 */
+ int32_t l_1813 = 0xD5715D00L;
+ int8_t l_1828 = 3L;
+ int32_t l_1831 = 0xCCA7621AL;
+ int32_t *l_1862 = &g_59[1];
+ int32_t *l_1863 = &g_59[3];
+ int32_t *l_1865 = &g_60[0][4][3];
+ int32_t *l_1866 = &g_59[6];
+ int32_t *l_1867 = (void*)0;
+ int32_t *l_1868[4][4][2] = {{{&g_61,&g_36},{&g_60[0][4][1],&g_61},{&l_1831,&g_59[1]},{&l_1831,&g_61}},{{&g_60[0][4][1],&g_36},{&g_61,&l_1831},{(void*)0,&g_59[1]},{&g_59[1],&g_60[0][1][0]}},{{&g_60[0][1][0],&g_60[0][4][1]},{&g_36,&g_60[0][4][1]},{&g_60[0][1][0],&g_60[0][1][0]},{&g_59[1],&g_59[1]}},{{(void*)0,&l_1831},{&g_61,&g_36},{&g_60[0][4][1],&g_61},{&l_1831,&g_59[1]}}};
+ uint8_t l_1870 = 7UL;
+ int i, j, k;
+ for (g_124 = 2; (g_124 >= 0); g_124 -= 1)
+ { /* block id: 918 */
+ uint8_t l_1803 = 0UL;
+ int32_t l_1812 = 0x0A2A1D39L;
+ int32_t l_1815[7][2][5] = {{{0L,0x1DDBFAEFL,0x1394708CL,(-7L),0xCF951AD2L},{9L,0x81596779L,(-7L),(-8L),0xB9144199L}},{{0x5CDB587BL,0L,0x81596779L,6L,0x08D53763L},{(-9L),0L,0L,0L,(-9L)}},{{(-1L),0x81596779L,0xB9144199L,1L,0x9F509A90L},{0xFFC6732DL,0x1DDBFAEFL,0xFAAD1AA0L,0xCF951AD2L,0xE291B965L}},{{(-7L),(-1L),0x4A8C519EL,0x81596779L,0x9F509A90L},{0xEA7A38EFL,0xCF951AD2L,6L,(-1L),(-9L)}},{{0x9F509A90L,(-9L),0xB975A64AL,0xFAAD1AA0L,0x08D53763L},{0xCF951AD2L,0xB9144199L,0xB975A64AL,0xB975A64AL,0xB9144199L}},{{0x2DAB1CE3L,8L,6L,(-1L),0xCF951AD2L},{(-1L),1L,0x4A8C519EL,0x08D53763L,0L}},{{0xB9144199L,0x4A8C519EL,0xFAAD1AA0L,0xFFC6732DL,(-1L)},{(-1L),(-1L),0xB9144199L,8L,0x4A8C519EL}}};
+ int16_t *l_1843 = &g_124;
+ const uint8_t *l_1858 = (void*)0;
+ const uint8_t **l_1857[6][1];
+ const uint8_t ***l_1856 = &l_1857[4][0];
+ int i, j, k;
+ for (i = 0; i < 6; i++)
+ {
+ for (j = 0; j < 1; j++)
+ l_1857[i][j] = &l_1858;
+ }
+ }
+ l_1870--;
+ if (g_124)
+ goto lbl_1873;
+ }
+ if ((0xB1F92AABL == ((safe_lshift_func_int8_t_s_u(((*l_1795) , (*l_1795)), 4)) > (*g_434))))
+ { /* block id: 956 */
+ const int32_t *l_1884 = &l_1869[3];
+ int8_t ***l_1901 = &g_435;
+ int8_t * const l_1904 = (void*)0;
+ int8_t * const *l_1903[1][6];
+ int8_t * const **l_1902 = &l_1903[0][2];
+ uint8_t l_1951 = 0xABL;
+ int32_t l_1966 = 0xF42C7F39L;
+ int32_t l_1967[3][8][6] = {{{7L,0x6AE2ACC6L,0L,0x34FDF0B3L,0x63305F13L,4L},{0x7CA956D1L,(-1L),0x63305F13L,0x6AE2ACC6L,4L,4L},{0L,0L,0L,0L,(-3L),0x6AE2ACC6L},{4L,(-1L),0xC143E02DL,0xB364E1CBL,0L,0x63305F13L},{0xC143E02DL,0x7CA956D1L,0L,(-1L),0L,(-1L)},{(-1L),(-1L),(-1L),4L,(-3L),0x7CA956D1L},{0x6AE2ACC6L,0L,0x34FDF0B3L,0x63305F13L,4L,(-3L)},{0xB364E1CBL,(-1L),4L,0x63305F13L,0x63305F13L,4L}},{{0x6AE2ACC6L,0x6AE2ACC6L,(-1L),7L,(-1L),(-3L)},{(-3L),0x6AE2ACC6L,0xC143E02DL,0x7CA956D1L,0L,(-1L)},{0xB364E1CBL,(-3L),0xC143E02DL,0L,0xC143E02DL,(-3L)},{4L,0L,(-1L),4L,0L,7L},{4L,0L,7L,0xC143E02DL,0x63305F13L,(-1L)},{0L,0L,(-1L),(-1L),0L,0L},{0L,0L,(-3L),0x6AE2ACC6L,0xC143E02DL,0x7CA956D1L},{(-1L),(-3L),0x63305F13L,0xB364E1CBL,0L,0x34FDF0B3L}},{{(-1L),0x6AE2ACC6L,0xB364E1CBL,0x6AE2ACC6L,(-1L),0xC143E02DL},{0L,0xC143E02DL,0L,(-1L),0x34FDF0B3L,4L},{0L,0x7CA956D1L,0x34FDF0B3L,0xC143E02DL,4L,4L},{4L,0L,0L,4L,(-1L),0xC143E02DL},{4L,(-1L),0xB364E1CBL,0L,0x6AE2ACC6L,0x34FDF0B3L},{0xB364E1CBL,0L,0x63305F13L,0x7CA956D1L,0x6AE2ACC6L,0x7CA956D1L},{(-3L),(-1L),(-3L),7L,(-1L),0L},{0xC143E02DL,0L,(-1L),0x34FDF0B3L,4L,(-1L)}}};
+ int8_t l_2037 = 0L;
+ int i, j, k;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 6; j++)
+ l_1903[i][j] = &l_1904;
+ }
+ for (g_1509 = (-16); (g_1509 != 56); ++g_1509)
+ { /* block id: 959 */
+ int32_t *l_1880 = &g_36;
+ int32_t **l_1881 = &l_1795;
+ uint16_t **l_1896 = (void*)0;
+ int16_t l_1915 = 0xADC0L;
+ uint32_t l_1971 = 1UL;
+ int32_t l_1990 = 0x95171AE5L;
+ uint16_t ****l_2016 = &g_1324;
+ for (g_131 = 24; (g_131 <= 16); --g_131)
+ { /* block id: 962 */
+ l_1880 = &l_1869[0];
+ }
+ (*l_1881) = p_43;
+ for (g_510 = 0; (g_510 > (-17)); --g_510)
+ { /* block id: 968 */
+ const int32_t **l_1885 = &l_1884;
+ (*l_1885) = l_1884;
+ }
+ for (g_358 = 0; (g_358 != (-19)); g_358 = safe_sub_func_uint8_t_u_u(g_358, 9))
+ { /* block id: 973 */
+ int8_t * const ***l_1905 = &l_1902;
+ int32_t l_1909 = 0x8ABB3F3DL;
+ int32_t l_1914[4][3];
+ uint32_t l_1916 = 1UL;
+ int16_t l_1950 = (-1L);
+ uint8_t ***l_1956 = &g_658[4];
+ uint8_t **l_1976 = (void*)0;
+ uint32_t **l_1977 = (void*)0;
+ int32_t l_2045 = (-1L);
+ int32_t *** const *l_2053 = &g_454;
+ int i, j;
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 3; j++)
+ l_1914[i][j] = 0x04CCC10CL;
+ }
+ }
+ }
+ }
+ else
+ { /* block id: 1063 */
+ uint16_t l_2086 = 0x4952L;
+ int32_t **l_2087 = &g_1591[5][6];
+ const int32_t *l_2094 = (void*)0;
+ const int32_t **l_2093[3][8];
+ const int32_t ** const *l_2092 = &l_2093[0][7];
+ const int32_t ** const **l_2091 = &l_2092;
+ const int32_t ** const ***l_2090[6][3][9] = {{{&l_2091,&l_2091,&l_2091,(void*)0,(void*)0,&l_2091,&l_2091,&l_2091,(void*)0},{&l_2091,(void*)0,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,(void*)0,&l_2091},{&l_2091,(void*)0,&l_2091,(void*)0,&l_2091,&l_2091,(void*)0,&l_2091,(void*)0}},{{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091},{&l_2091,&l_2091,(void*)0,&l_2091,(void*)0,&l_2091,&l_2091,(void*)0,&l_2091},{&l_2091,&l_2091,&l_2091,(void*)0,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091}},{{&l_2091,(void*)0,(void*)0,&l_2091,&l_2091,&l_2091,(void*)0,(void*)0,&l_2091},{&l_2091,(void*)0,&l_2091,(void*)0,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091},{(void*)0,&l_2091,&l_2091,&l_2091,&l_2091,(void*)0,&l_2091,&l_2091,&l_2091}},{{&l_2091,(void*)0,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,(void*)0,&l_2091},{&l_2091,&l_2091,&l_2091,(void*)0,(void*)0,&l_2091,&l_2091,&l_2091,&l_2091},{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091}},{{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,(void*)0,&l_2091,&l_2091,&l_2091},{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091},{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,(void*)0,&l_2091,&l_2091,&l_2091}},{{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091},{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,&l_2091},{&l_2091,&l_2091,&l_2091,&l_2091,&l_2091,(void*)0,&l_2091,&l_2091,&l_2091}}};
+ int32_t l_2095 = 6L;
+ int32_t l_2096[7] = {(-7L),(-7L),(-1L),(-7L),(-7L),(-1L),(-7L)};
+ int8_t l_2105 = 0L;
+ int16_t l_2140 = 0xC8C6L;
+ const int8_t l_2173 = 0L;
+ uint32_t **l_2189 = &g_434;
+ int32_t l_2190 = (-7L);
+ uint8_t ***l_2218 = &g_658[3];
+ int16_t l_2235 = 0x4B03L;
+ int32_t l_2237 = (-9L);
+ int16_t l_2238 = 1L;
+ int i, j, k;
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 8; j++)
+ l_2093[i][j] = &l_2094;
+ }
+ for (g_358 = (-3); (g_358 == 7); g_358 = safe_add_func_uint32_t_u_u(g_358, 9))
+ { /* block id: 1066 */
+ int32_t **l_2056 = &g_514;
+ (*l_2056) = &l_1869[1];
+ if (g_2057[4][3])
+ break;
+ }
+ if ((*p_43))
+ { /* block id: 1070 */
+ int16_t l_2081 = 0xFF8CL;
+ int32_t l_2102 = 0xDFDFE83FL;
+ int32_t l_2103 = 0xA84F3B43L;
+ int32_t l_2106 = 0x97BF29E5L;
+ uint16_t *l_2132 = &g_69[6];
+ int8_t *l_2138[7] = {&l_2105,&l_2105,&l_2105,&l_2105,&l_2105,&l_2105,&l_2105};
+ uint16_t l_2139 = 0x7CF9L;
+ int32_t *l_2141[9][5][5] = {{{&l_2102,&l_1864,&l_1988,(void*)0,&g_60[1][2][3]},{&g_60[0][4][3],&l_2102,&l_2095,&l_2096[6],&l_2095},{&l_2102,&g_60[0][4][3],&l_2095,&l_1864,&l_2096[4]},{&l_2096[4],&g_36,&l_2095,&l_2102,(void*)0},{(void*)0,&l_2095,&l_2095,&g_60[0][4][3],&l_2106}},{{&l_2102,&l_2102,&l_1988,&g_60[0][4][3],(void*)0},{&l_2102,&l_2095,&l_2095,&l_1864,&l_2096[4]},{(void*)0,&l_2095,&l_2095,&g_36,&l_2095},{&g_36,&l_2102,(void*)0,(void*)0,&g_60[1][2][3]},{&g_60[0][0][2],&l_2095,&g_60[1][1][2],&g_36,&g_36}},{{&l_2095,&g_36,(void*)0,&l_1864,&l_2096[3]},{&l_2095,&g_60[0][4][3],(void*)0,&g_60[0][4][3],&l_2095},{&g_60[0][0][2],&l_2102,&l_2096[4],&g_60[0][4][3],&l_1988},{&g_36,&l_1864,(void*)0,&l_2102,(void*)0},{(void*)0,(void*)0,(void*)0,&l_1864,(void*)0}},{{&l_2102,&l_1988,&g_60[1][1][2],&l_2096[6],&l_1988},{&l_2102,&l_2103,(void*)0,(void*)0,&l_2095},{(void*)0,&l_1988,&l_2095,&g_36,&l_2096[3]},{&l_2096[4],(void*)0,&l_2095,&g_36,&g_36},{&l_2102,&l_1864,&l_1988,(void*)0,&g_60[1][2][3]}},{{&g_60[0][4][3],&l_2102,&l_2095,&l_2096[6],&l_2095},{&l_2102,&g_60[0][4][3],&l_2095,&l_1864,&l_2096[4]},{&l_2096[4],&g_36,(void*)0,&l_2106,&l_2095},{&l_2095,&l_1988,&g_60[0][1][2],(void*)0,&g_60[0][4][3]},{(void*)0,&l_1988,&l_2103,&l_2106,&l_2095}},{{(void*)0,(void*)0,&g_60[0][4][3],&g_60[1][4][3],&l_2096[3]},{&l_2106,(void*)0,(void*)0,&l_1864,(void*)0},{&g_60[1][1][2],&l_1988,&l_2095,&l_2096[4],&l_2095},{&l_2095,&l_1988,(void*)0,&l_1864,&l_2102},{&l_1988,&g_60[1][1][2],&g_36,&g_60[1][4][3],(void*)0}},{{&l_1988,&l_2095,&l_2096[0],&l_2106,&g_60[0][1][2]},{&l_2095,&l_2102,&l_2096[3],(void*)0,(void*)0},{&g_60[1][1][2],(void*)0,&l_2096[0],&l_2106,&l_2096[0]},{&l_2106,&l_2106,&g_36,&l_1864,&l_2096[0]},{(void*)0,&g_60[1][2][3],(void*)0,&g_36,(void*)0}},{{(void*)0,&l_1988,&l_2095,&l_2096[4],&g_60[0][1][2]},{&l_2095,&g_60[1][2][3],(void*)0,&g_60[0][3][0],(void*)0},{&g_36,&l_2106,&g_60[0][4][3],&g_60[0][3][0],&l_2102},{&l_1988,(void*)0,&l_2103,&l_2096[4],&l_2095},{&l_2095,&l_2102,&g_60[0][1][2],&g_36,(void*)0}},{{&l_1988,&l_2095,(void*)0,&l_1864,&l_2096[3]},{&g_36,&g_60[1][1][2],(void*)0,&l_2106,&l_2095},{&l_2095,&l_1988,&g_60[0][1][2],(void*)0,&g_60[0][4][3]},{(void*)0,&l_1988,&l_2103,&l_2106,&l_2095},{(void*)0,(void*)0,&g_60[0][4][3],&g_60[1][4][3],&l_2096[3]}}};
+ int16_t l_2170 = (-5L);
+ int32_t *l_2175 = &g_59[1];
+ uint8_t l_2240 = 0UL;
+ uint16_t l_2243[9] = {5UL,65529UL,5UL,65529UL,5UL,65529UL,5UL,65529UL,5UL};
+ int i, j, k;
+ for (g_61 = 0; (g_61 <= 3); g_61 += 1)
+ { /* block id: 1073 */
+ int8_t l_2071 = 0x1AL;
+ int32_t ** const *l_2078 = &g_455;
+ int32_t ** const **l_2077 = &l_2078;
+ int32_t ** const ***l_2076 = &l_2077;
+ int32_t l_2101[5][1] = {{0xB5C5EAD7L},{4L},{0xB5C5EAD7L},{4L},{0xB5C5EAD7L}};
+ int16_t l_2104 = 1L;
+ int i, j;
+ for (g_358 = 0; (g_358 <= 0); g_358 += 1)
+ { /* block id: 1076 */
+ uint32_t **l_2069 = &g_434;
+ uint32_t ***l_2068 = &l_2069;
+ int32_t l_2070 = 9L;
+ if (((*p_43) = ((*g_146) = 0xE83D4D8CL)))
+ { /* block id: 1079 */
+ (*g_146) = 0x04E90537L;
+ }
+ else
+ { /* block id: 1081 */
+ int i, j;
+ (*p_43) = ((((safe_rshift_func_uint16_t_u_s(g_31[g_358], 0)) || (safe_sub_func_int16_t_s_s((-1L), (safe_rshift_func_int16_t_s_u((g_31[g_358] != ((l_1968[g_358][g_61] || (safe_add_func_int32_t_s_s(((*g_146) = ((safe_sub_func_int32_t_s_s(((((~(!(~(+(*l_1795))))) , 0xFAC5F3D3L) , p_43) == p_43), ((void*)0 != l_2068))) , 0L)), (*g_434)))) <= (-7L))), 6))))) <= l_2070) >= l_2071);
+ }
+ }
+ if ((safe_div_func_uint32_t_u_u(((((*g_146) = (safe_unary_minus_func_int16_t_s((g_2075 != l_2076)))) , (safe_add_func_int32_t_s_s((*p_43), (*g_514)))) & (l_2081 != ((safe_add_func_int32_t_s_s(0xAE26118AL, (safe_mul_func_uint16_t_u_u(l_2086, (!(l_2095 = (((l_2087 == (g_1590 = ((safe_sub_func_uint32_t_u_u(0xEE70B60DL, (*g_514))) , l_2087))) , g_2075) != l_2090[1][2][6]))))))) , 0x877CL))), l_2081)))
+ { /* block id: 1089 */
+ int32_t *l_2097 = &l_1988;
+ int32_t *l_2098 = &g_59[1];
+ int32_t *l_2099 = &l_2096[4];
+ int32_t *l_2100[3];
+ uint32_t l_2107 = 0x9327F5E4L;
+ int i;
+ for (i = 0; i < 3; i++)
+ l_2100[i] = &l_1869[0];
+ l_2107++;
+ for (l_2046 = 1; (l_2046 <= 5); l_2046 += 1)
+ { /* block id: 1093 */
+ const int16_t l_2110 = 0L;
+ if (l_2110)
+ break;
+ }
+ }
+ else
+ { /* block id: 1096 */
+ int16_t l_2117[4] = {0x585BL,0x585BL,0x585BL,0x585BL};
+ int i;
+ for (l_1988 = 4; (l_1988 >= 0); l_1988 -= 1)
+ { /* block id: 1099 */
+ uint8_t *l_2124[6][3][8] = {{{(void*)0,(void*)0,&g_31[0],&g_31[0],(void*)0,(void*)0,&g_131,(void*)0},{(void*)0,(void*)0,&g_131,(void*)0,(void*)0,&g_31[0],&g_31[0],(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,&g_31[0],&g_131,&g_131,&g_31[0],(void*)0},{(void*)0,(void*)0,&g_131,(void*)0,(void*)0,(void*)0,&g_131,(void*)0},{(void*)0,(void*)0,&g_31[0],&g_131,&g_131,&g_31[0],(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,&g_31[0],&g_31[0],&g_31[0],(void*)0,(void*)0,(void*)0},{&g_31[0],(void*)0,(void*)0,(void*)0,&g_31[0],&g_131,&g_131,&g_31[0]}},{{(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,&g_31[0],(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,&g_131,(void*)0,(void*)0,&g_131,(void*)0},{(void*)0,(void*)0,(void*)0,&g_31[0],(void*)0,&g_31[0],(void*)0,(void*)0}},{{(void*)0,(void*)0,&g_131,(void*)0,(void*)0,&g_131,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,&g_31[0],(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,&g_31[0],&g_131,&g_131,&g_31[0],(void*)0,(void*)0,(void*)0}},{{&g_31[0],(void*)0,(void*)0,(void*)0,&g_31[0],&g_131,&g_131,&g_31[0]},{(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,&g_31[0],(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,&g_131,(void*)0,(void*)0,&g_131,(void*)0}}};
+ int i, j, k;
+ (*p_43) |= (safe_div_func_int16_t_s_s((safe_mul_func_uint8_t_u_u(g_408[(g_61 + 2)][(g_61 + 4)], ((safe_add_func_uint8_t_u_u(((l_2103 > l_2117[0]) , ((((((*g_1846) ^ (safe_mul_func_uint8_t_u_u(((~((((safe_lshift_func_uint16_t_u_u(l_2102, (safe_lshift_func_uint8_t_u_u(((*l_1795) = g_408[(g_61 + 2)][(g_61 + 4)]), 7)))) , (safe_sub_func_int32_t_s_s((((*l_2076) = g_2127) != (void*)0), (*l_1795)))) == (-1L)) >= l_2117[2])) <= (*g_434)), 2L))) , l_2106) == g_408[(g_61 + 2)][(g_61 + 4)]) , (-7L)) >= g_1096[0])), 0UL)) == (*g_434)))), 0x2AABL));
+ }
+ (*p_43) &= ((*l_1795) = l_2081);
+ }
+ for (g_436 = 0; (g_436 <= 5); g_436 += 1)
+ { /* block id: 1109 */
+ (***l_2091) = p_43;
+ }
+ }
+ g_36 |= ((~(safe_rshift_func_uint8_t_u_u(((((safe_lshift_func_uint8_t_u_s(((*l_1795) > (((*g_514) ^= (((void*)0 == l_2132) >= (((void*)0 == &g_434) == (((*g_1846) &= (*l_1795)) || (safe_mod_func_int32_t_s_s((*p_43), (safe_add_func_int8_t_s_s((g_510 ^= (!((safe_unary_minus_func_uint8_t_u((*l_1795))) != (*g_434)))), l_2139)))))))) , 0x3B27455CL)), (*l_1795))) < (*g_146)) , (*l_1795)) > l_2140), l_2081))) != (*l_1795));
+ for (l_2086 = 0; (l_2086 <= 5); l_2086 += 1)
+ { /* block id: 1119 */
+ uint32_t l_2148 = 0x2EC0A92AL;
+ uint8_t *l_2167 = &g_131;
+ int16_t *l_2172[7][7] = {{&l_2170,&g_775,(void*)0,&l_2081,&g_775,&l_2081,(void*)0},{&g_775,&g_775,&l_2081,&g_775,&g_2156,&l_2081,&g_2156},{&g_775,(void*)0,(void*)0,&g_775,&l_2081,&l_2170,&g_775},{&l_2170,&g_2156,&l_2081,&l_2081,&g_2156,&l_2170,(void*)0},{&g_2156,&g_775,&l_2081,&g_775,&g_775,&l_2081,&g_775},{&g_2156,(void*)0,&l_2170,&g_2156,&l_2081,&l_2081,&g_2156},{&l_2170,&g_775,&l_2170,&l_2081,&g_775,(void*)0,(void*)0}};
+ uint16_t l_2210 = 65530UL;
+ int32_t l_2221 = 0x2F3755E1L;
+ int32_t l_2222[3];
+ int32_t l_2224 = 0x60EE7009L;
+ int32_t l_2226 = 2L;
+ int32_t l_2227 = 0xEA617DEEL;
+ int32_t l_2228[1];
+ int i, j;
+ for (i = 0; i < 3; i++)
+ l_2222[i] = 0x6F7B8276L;
+ for (i = 0; i < 1; i++)
+ l_2228[i] = (-1L);
+ (***l_2091) = (**l_2092);
+ if ((*l_1795))
+ break;
+ l_1795 = (((((safe_div_func_uint16_t_u_u((4294967295UL ^ (((safe_sub_func_uint16_t_u_u(((l_2095 = (*l_1795)) || (((g_775 |= (safe_mul_func_uint8_t_u_u((((l_2148 && l_2149) != (safe_sub_func_uint16_t_u_u(((*g_434) && ((((safe_sub_func_int16_t_s_s((safe_rshift_func_int16_t_s_s((l_2148 , ((*g_1846) = ((((*g_713) = (*g_713)) | ((((g_2156 , ((safe_rshift_func_int8_t_s_s((safe_div_func_int8_t_s_s(((safe_add_func_int8_t_s_s(((safe_add_func_int32_t_s_s((safe_sub_func_uint8_t_u_u(((*l_2167)--), (((4UL ^ (*g_1846)) , (*g_146)) & (*g_146)))), (*g_434))) && l_2170), 0xEFL)) < 0x9E20L), g_31[0])), (*l_1795))) <= 0xFE4DL)) == 5UL) , (*l_1795)) || l_2148)) == (*l_1795)))), (*l_1795))), l_2148)) ^ l_2171) & 253UL) & (*p_43))), 65535UL))) || (*l_1795)), g_436))) , l_2173) >= l_2148)), l_2148)) <= (*l_1795)) , 0xC481E029L)), 1L)) ^ l_2148) >= (*g_434)) <= l_2174) , l_2175);
+ for (l_2139 = 1; (l_2139 <= 6); l_2139 += 1)
+ { /* block id: 1130 */
+ uint8_t *l_2176 = &g_31[0];
+ uint16_t *l_2183 = &g_1758[3][0][1];
+ int32_t l_2209 = 1L;
+ uint32_t l_2211[2][9];
+ int32_t l_2229 = 0xF892FDB3L;
+ int32_t l_2230 = 0xD0E01647L;
+ int32_t l_2231 = 1L;
+ int32_t l_2232 = 4L;
+ int32_t l_2233[9] = {(-10L),(-10L),0xEFA8FB7FL,(-10L),(-10L),0xEFA8FB7FL,(-10L),(-10L),0xEFA8FB7FL};
+ int i, j;
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 9; j++)
+ l_2211[i][j] = 0x465FC43EL;
+ }
+ for (g_131 = 1; (g_131 <= 4); g_131 += 1)
+ { /* block id: 1133 */
+ const uint16_t **l_2180 = (void*)0;
+ const uint16_t *l_2182[6][9][4];
+ const uint16_t **l_2181 = &l_2182[2][6][3];
+ int32_t l_2186 = 0xE8A6026BL;
+ int i, j, k;
+ for (i = 0; i < 6; i++)
+ {
+ for (j = 0; j < 9; j++)
+ {
+ for (k = 0; k < 4; k++)
+ l_2182[i][j][k] = &g_961;
+ }
+ }
+ (*g_146) ^= (l_2176 != ((((((g_510 = (((safe_unary_minus_func_int16_t_s(((l_2036 = &l_2139) != ((safe_rshift_func_uint16_t_u_u((((*l_2181) = &l_2086) == l_2183), 2)) , (((((((safe_lshift_func_int16_t_s_u((9UL >= l_2186), 14)) , ((safe_sub_func_int8_t_s_s((((+(&g_434 == ((*g_434) , l_2189))) || (*g_1846)) , g_138[3]), l_2190)) , (*l_1795))) & (-10L)) < l_2148) <= l_2148) , 0UL) , (void*)0))))) < (*p_43)) > l_2148)) , l_2148) >= 0xB2L) , &l_1928) == &l_1928) , l_2167));
+ l_2141[l_2139][g_131][g_131] = ((safe_lshift_func_int16_t_s_s(((*g_1846) = (((((safe_sub_func_int16_t_s_s(((((((5L && 0x0CL) > (0L <= (l_2186 || l_2148))) || (g_126 = l_2148)) ^ ((safe_mod_func_int8_t_s_s(((((*l_1795) = (((safe_add_func_uint32_t_u_u((((**l_2189) = (((safe_mul_func_int16_t_s_s(((safe_mul_func_uint8_t_u_u(((((((safe_rshift_func_uint8_t_u_u(((*l_2176) = (*l_1795)), 2)) | (((safe_rshift_func_uint16_t_u_u(65535UL, (((safe_rshift_func_uint8_t_u_u((*l_1795), 3)) & 0xF2244D35L) ^ l_2148))) <= 0x883EL) | 0x30L)) <= l_2186) & l_2186) != (*g_434)) != l_2186), 247UL)) && 0x03BCL), (*g_1846))) && (*l_1795)) ^ 0xB4BFL)) == l_2148), 1UL)) , 0UL) > l_2186)) && l_2209) != l_2209), 0x52L)) | (-1L))) < l_2148) < l_2209), (*g_1846))) , (void*)0) == (void*)0) | l_2210) != l_2186)), l_2211[0][5])) , g_1591[l_2086][l_2086]);
+ (*p_43) ^= (!(safe_add_func_int16_t_s_s((safe_lshift_func_int8_t_s_s((l_2209 , 0x98L), 2)), (((((*l_2175) |= (l_2221 = (l_2209 <= ((*l_2176) = ((+l_2186) || ((*g_146) | (!(safe_div_func_int32_t_s_s(0L, (((l_2210 , &g_658[3]) != (g_2219 = l_2218)) & l_2220)))))))))) > (*g_434)) && (*l_2175)) <= 3L))));
+ }
+ for (l_2105 = 0; (l_2105 <= 6); l_2105 += 1)
+ { /* block id: 1152 */
+ return (*l_1795);
+ }
+ ++l_2240;
+ }
+ }
+ (*g_514) ^= (l_2243[6] ^ 0x9B59B1E0L);
+ }
+ else
+ { /* block id: 1159 */
+ int8_t *l_2247 = &g_2239;
+ int8_t * const l_2248[6] = {&g_2,&g_2,&g_2,&g_2,&g_2,&g_2};
+ int i;
+ l_2096[4] ^= (safe_div_func_uint32_t_u_u(((l_2247 = (g_2246 = &l_2105)) == l_2248[4]), 6UL));
+ }
+ }
+ p_43 = &l_1988;
+ return (*l_1795);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_126 g_434 g_138 g_514 g_59 g_713 g_69 g_146 g_60 g_775 g_436 g_124 g_358 g_454 g_455 g_435 g_408 g_360 g_415 g_131 g_961 g_1096 g_510 g_145 g_37 g_61 g_992 g_993 g_1202 g_36 g_1250 g_712 g_1312 g_2 g_1324 g_31 g_1590 g_658 g_659 g_1509 g_1758
+ * writes: g_415 g_60 g_59 g_775 g_138 g_436 g_69 g_126 g_124 g_358 g_408 g_658 g_360 g_61 g_131 g_510 g_145 g_37 g_454 g_1324 g_712 g_31 g_1483 g_659 g_435 g_1509 g_36 g_1758 g_514
+ */
+static int32_t ** func_44(const int16_t p_45, uint16_t p_46, uint16_t p_47, int8_t p_48)
+{ /* block id: 453 */
+ uint32_t l_789 = 3UL;
+ int8_t *l_790 = &g_415;
+ uint16_t *l_793[2][1];
+ int32_t ***l_824 = &g_455;
+ int32_t l_825 = 8L;
+ uint32_t l_826 = 0xD587BD29L;
+ int32_t *l_827 = (void*)0;
+ int32_t l_851 = 0xD020B236L;
+ int32_t l_855 = 0x2CE1D691L;
+ int32_t l_856 = 0L;
+ int32_t l_857[10] = {(-8L),0xCA3E0D9AL,0xF01EADB4L,0xF01EADB4L,0xCA3E0D9AL,(-8L),0xCA3E0D9AL,0xF01EADB4L,0xF01EADB4L,0xCA3E0D9AL};
+ int32_t l_858 = (-6L);
+ uint32_t l_860 = 7UL;
+ uint16_t **l_874 = &l_793[0][0];
+ int16_t l_919 = 0xCBE8L;
+ const uint16_t *l_963 = (void*)0;
+ const uint16_t **l_962 = &l_963;
+ const uint16_t **l_964 = &l_963;
+ const uint8_t l_1041[3][8][7] = {{{0xC9L,0xE7L,0xEFL,0x0CL,0x6BL,0xC2L,0xC9L},{0x14L,1UL,250UL,0xEFL,0xC9L,247UL,0xE7L},{1UL,246UL,247UL,249UL,0UL,255UL,1UL},{0xC9L,246UL,0x09L,7UL,255UL,0x99L,0x04L},{0xE5L,7UL,0x7DL,0x7DL,3UL,0x1BL,0x82L},{255UL,246UL,1UL,0x8FL,0xE5L,255UL,0xC2L},{247UL,255UL,255UL,0xEFL,0UL,0x60L,0x7DL},{0x23L,246UL,3UL,251UL,250UL,247UL,0xCAL}},{{0x09L,3UL,0xFBL,247UL,255UL,246UL,0xE5L},{1UL,0xCAL,0UL,0xE5L,0UL,255UL,9UL},{0x6CL,1UL,0x82L,0x71L,0xABL,0x38L,0x29L},{9UL,0xE5L,246UL,255UL,247UL,0xFBL,3UL},{255UL,247UL,0x29L,255UL,0x38L,0UL,1UL},{0x23L,0xEFL,0x9AL,0x71L,0x6BL,0x5EL,0x82L},{8UL,0xC2L,255UL,0xE5L,0x8FL,1UL,246UL},{0UL,255UL,0xABL,247UL,0x71L,0x71L,247UL}},{{0x1BL,255UL,0x1BL,251UL,0xC2L,247UL,0x29L},{246UL,0UL,255UL,0xEFL,1UL,246UL,1UL},{0xABL,0x29L,0x60L,0x8FL,0xB9L,247UL,0x99L},{0x6CL,0x1AL,247UL,0xB9L,9UL,0x71L,0xCAL},{0x8FL,0x9CL,246UL,246UL,0x5FL,1UL,0xEFL},{253UL,0x29L,255UL,1UL,0x38L,0x5EL,246UL},{0xABL,0x5FL,0x38L,0UL,0UL,0UL,0x82L},{0xEFL,0x09L,0xFBL,0x14L,1UL,0xFBL,255UL}}};
+ int8_t ***l_1061 = &g_435;
+ int8_t ***l_1064 = &g_435;
+ uint8_t l_1067 = 248UL;
+ int32_t *l_1124 = &l_825;
+ int32_t **l_1123 = &l_1124;
+ int8_t l_1173[1];
+ int32_t l_1178 = (-10L);
+ uint32_t l_1365 = 0xC69FFE11L;
+ int16_t l_1432 = 0x41AEL;
+ uint32_t l_1561 = 8UL;
+ int32_t l_1572 = 0xF6720B70L;
+ uint8_t ***l_1593[4];
+ uint8_t *l_1594 = &l_1067;
+ uint32_t l_1670 = 1UL;
+ uint32_t *l_1691 = &g_408[4][8];
+ uint16_t ** const **l_1710 = &g_993;
+ int32_t l_1742[8][4][5] = {{{0x0F03A4D8L,1L,(-1L),5L,1L},{0xAE8F677BL,(-1L),0x2EAAF741L,0x2EAAF741L,(-1L)},{(-5L),1L,(-1L),1L,3L},{0L,2L,0x1BFB8ECBL,(-1L),0xE39D686EL}},{{8L,(-5L),(-5L),8L,0x485B1D2AL},{0L,0x2EAAF741L,0x63768321L,0x2619FB32L,(-1L)},{(-5L),0xA73697A5L,0x8F9D8BBDL,(-1L),0x8F9D8BBDL},{0xAE8F677BL,0xAE8F677BL,(-1L),0x2619FB32L,0x63768321L}},{{0x0F03A4D8L,5L,0x485B1D2AL,8L,(-5L)},{0x1BFB8ECBL,(-1L),0xE39D686EL,(-1L),0x1BFB8ECBL},{0xE1025F8AL,5L,3L,1L,(-1L)},{0xE4018007L,(-1L),0L,(-1L),(-1L)}},{{1L,0xE1025F8AL,1L,1L,0x485B1D2AL},{0x1BFB8ECBL,(-1L),(-1L),2L,0x2EAAF741L},{0x485B1D2AL,8L,(-5L),(-5L),8L},{0L,0x63768321L,(-1L),0x2EAAF741L,0xE39D686EL}},{{0xE1025F8AL,3L,1L,0xA73697A5L,0x0F03A4D8L},{0xAE8F677BL,0L,0L,0xAE8F677BL,0L},{0xE1025F8AL,(-5L),0x8F9D8BBDL,5L,0xA73697A5L},{0L,0x2619FB32L,1L,(-1L),1L}},{{0x485B1D2AL,0x485B1D2AL,0xA73697A5L,5L,0x8F9D8BBDL},{0x1BFB8ECBL,2L,0L,0xAE8F677BL,0L},{1L,0xA73697A5L,0x0F03A4D8L,0xA73697A5L,1L},{0xE4018007L,2L,0xE39D686EL,0x2EAAF741L,(-1L)}},{{5L,0x485B1D2AL,8L,(-5L),(-5L)},{0x2EAAF741L,0x2619FB32L,0x2EAAF741L,2L,(-1L)},{1L,(-5L),0x485B1D2AL,1L,1L},{(-1L),0L,(-1L),(-1L),0L}},{{8L,3L,0x485B1D2AL,1L,0x8F9D8BBDL},{0x2619FB32L,0x63768321L,0x2EAAF741L,0L,1L},{(-1L),8L,8L,(-1L),0xA73697A5L},{0x2619FB32L,(-1L),0xE39D686EL,0xE4018007L,0L}}};
+ int i, j, k;
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 1; j++)
+ l_793[i][j] = &g_145;
+ }
+ for (i = 0; i < 1; i++)
+ l_1173[i] = (-1L);
+ for (i = 0; i < 4; i++)
+ l_1593[i] = &g_658[3];
+ if ((safe_lshift_func_uint8_t_u_s((((safe_add_func_int32_t_s_s(((*g_146) = (p_45 != (((g_126 != ((&g_69[4] != ((+(safe_sub_func_uint16_t_u_u(((safe_sub_func_uint32_t_u_u((*g_434), p_46)) > ((safe_mul_func_uint8_t_u_u((0x40L ^ ((*l_790) = (safe_unary_minus_func_uint8_t_u(l_789)))), (p_48 = (safe_lshift_func_int16_t_s_u((-6L), ((((((*g_434) ^ (*g_514)) , (*g_713)) , (*g_514)) > p_46) | 0x6DC26841L)))))) ^ p_47)), 65535UL))) , l_793[0][0])) && 0x8ACC9E21L)) | p_46) || 0xBD077CC9L))), l_789)) <= p_46) != p_45), l_789)))
+ { /* block id: 457 */
+ uint32_t * const l_796 = &g_436;
+ int32_t l_810 = 0x310EDFCEL;
+ int16_t *l_811 = &g_775;
+ int8_t l_844 = 0xF9L;
+ int32_t *l_845 = &g_59[4];
+ int32_t l_846 = 0x652F5472L;
+ int32_t *l_847 = (void*)0;
+ int32_t *l_848 = (void*)0;
+ int32_t *l_849 = (void*)0;
+ int32_t *l_850 = &g_59[1];
+ int32_t *l_852 = &l_846;
+ int32_t *l_853 = &g_61;
+ int32_t *l_854[3];
+ int16_t l_859 = 0L;
+ int i;
+ for (i = 0; i < 3; i++)
+ l_854[i] = &g_60[0][4][3];
+ if ((safe_sub_func_int32_t_s_s((l_796 != (((((((((safe_lshift_func_int8_t_s_u((safe_unary_minus_func_uint8_t_u((safe_rshift_func_uint8_t_u_u((((*g_434) |= (safe_div_func_int8_t_s_s((((*g_146) != (((void*)0 == &g_69[2]) > ((*l_811) ^= ((safe_mod_func_int32_t_s_s(5L, ((*g_514) = (safe_sub_func_uint8_t_u_u(((l_789 <= (safe_sub_func_int32_t_s_s((+p_45), (!l_810)))) , p_46), p_46))))) , p_47)))) > p_48), p_48))) > 0x42A497C5L), 2)))), l_810)) | l_810) & 8UL) >= p_46) <= l_789) , &l_793[0][0]) != &l_793[0][0]) && (*g_514)) , (void*)0)), 0x2E530132L)))
+ { /* block id: 461 */
+ int32_t l_821 = 7L;
+ (*g_514) = (safe_div_func_int16_t_s_s((g_59[1] == (safe_sub_func_int8_t_s_s((0x3683L ^ (((safe_rshift_func_int8_t_s_s((safe_unary_minus_func_int16_t_s((((safe_mod_func_int8_t_s_s((((*l_790) = l_821) && (safe_rshift_func_int16_t_s_s((((((((((((((0x42L < (l_824 == (void*)0)) , ((*g_146) &= (((*l_796) |= l_810) , l_810))) >= 1L) , l_825) & p_46) , 1L) , 0xFEL) , (-1L)) & 0x050B61B1L) && (*g_434)) < p_45) , (void*)0) != (void*)0), 2))), p_46)) > p_48) >= g_124))), l_810)) <= g_358) < l_826)), 5UL))), 65535UL));
+ l_827 = &g_60[0][4][3];
+ }
+ else
+ { /* block id: 467 */
+ const int16_t l_834 = 1L;
+ int32_t ** const l_843[8] = {&g_514,&g_514,&g_514,&g_514,&g_514,&g_514,&g_514,&g_514};
+ int i;
+ (*g_514) ^= (0x3980058AL <= (-8L));
+ (*g_146) = (safe_lshift_func_uint16_t_u_u((safe_mod_func_int32_t_s_s(((safe_mul_func_uint8_t_u_u(l_834, ((safe_div_func_uint32_t_u_u((safe_div_func_int16_t_s_s(((safe_sub_func_uint32_t_u_u(0x27FAB59DL, (++(*g_434)))) == ((((*g_454) == l_843[5]) ^ (((*g_713) != (p_46 = (*g_713))) != ((*l_811) = ((p_47 || 4294967289UL) , (l_810 = g_59[1]))))) , l_844)), 0x917AL)), p_48)) == p_45))) >= 0x45993A07L), p_47)), (*g_713)));
+ }
+ --l_860;
+ }
+ else
+ { /* block id: 476 */
+ uint16_t ***l_873[10] = {&g_712,&g_712,&g_712,&g_712,&g_712,&g_712,&g_712,&g_712,&g_712,&g_712};
+ int32_t l_879 = (-2L);
+ int32_t *l_880 = &g_60[0][4][1];
+ uint32_t l_990[3];
+ int8_t ***l_1063 = &g_435;
+ int8_t ***l_1065 = &g_435;
+ int32_t ****l_1071 = &g_454;
+ int32_t l_1108[2];
+ int32_t l_1182 = 0xF31FF310L;
+ uint32_t l_1249 = 0x30B3AA77L;
+ uint8_t l_1382 = 1UL;
+ uint8_t l_1431[3];
+ uint8_t ***l_1435 = &g_658[2];
+ uint8_t *l_1479 = (void*)0;
+ uint8_t *l_1480 = &l_1431[2];
+ uint32_t l_1485[2][6][9] = {{{0x001AC486L,1UL,0xD4514F8AL,0x7B4E6C99L,4294967293UL,0x43196522L,0x43196522L,4294967293UL,0x7B4E6C99L},{4294967295UL,0x0ACDEEBDL,4294967295UL,3UL,4294967290UL,0xF5ACFD47L,0x66335B3AL,4294967290UL,0x5C4275B8L},{0x001AC486L,0x972DEFA1L,0x0646B95BL,0x7B4E6C99L,1UL,1UL,0x43196522L,1UL,4294967295UL},{4294967295UL,4294967288UL,0x6102B2CFL,3UL,0x0ACDEEBDL,0x66335B3AL,0x66335B3AL,0x0ACDEEBDL,3UL},{0x001AC486L,4294967293UL,0x001AC486L,0x7B4E6C99L,0x972DEFA1L,0x4F90B9DFL,0x43196522L,0x972DEFA1L,0x05838E02L},{4294967295UL,4294967290UL,4294967295UL,3UL,4294967288UL,0x22B6C2F9L,0x66335B3AL,4294967288UL,0xBB659700L}},{{0x001AC486L,1UL,0xD4514F8AL,0x7B4E6C99L,4294967293UL,0x43196522L,0x43196522L,4294967293UL,0x7B4E6C99L},{4294967295UL,0x0ACDEEBDL,4294967295UL,3UL,4294967290UL,4294967295UL,0UL,0x66335B3AL,0x8121F976L},{4294967295UL,0x43196522L,0x55E71AF7L,0x6C626E1CL,1UL,0x2A49B2C7L,4UL,1UL,0xC95BEA71L},{0x9FBED03EL,0x22B6C2F9L,4294967295UL,0x5A1F2CF3L,0xF5ACFD47L,0UL,0UL,0xF5ACFD47L,0x5A1F2CF3L},{4294967295UL,0x4F90B9DFL,4294967295UL,0x6C626E1CL,0x43196522L,0x764EA846L,4UL,0x43196522L,8UL},{0x9FBED03EL,0x66335B3AL,0x5B65FAAEL,0x5A1F2CF3L,0x22B6C2F9L,0x4FA3FF0EL,0UL,0x22B6C2F9L,0x7F81A6ADL}}};
+ uint32_t l_1538 = 18446744073709551606UL;
+ uint32_t l_1542 = 0x5126608CL;
+ const int8_t l_1564 = 0xCFL;
+ int16_t l_1674 = 0L;
+ uint32_t l_1675[4][2][6] = {{{9UL,9UL,0UL,0x1A6A88C2L,0UL,9UL},{0UL,4294967295UL,0x1A6A88C2L,0x1A6A88C2L,4294967295UL,0UL}},{{9UL,0UL,0x1A6A88C2L,0UL,9UL,9UL},{4294967295UL,0UL,0UL,4294967295UL,4294967295UL,4294967295UL}},{{4294967295UL,4294967295UL,4294967295UL,0UL,0UL,4294967295UL},{9UL,9UL,0UL,0x1A6A88C2L,0UL,9UL}},{{0UL,4294967295UL,0x1A6A88C2L,0x1A6A88C2L,4294967295UL,0UL},{9UL,0UL,0x1A6A88C2L,0UL,9UL,9UL}}};
+ uint8_t l_1682 = 249UL;
+ int32_t l_1755 = 0L;
+ uint8_t l_1776 = 248UL;
+ int i, j, k;
+ for (i = 0; i < 3; i++)
+ l_990[i] = 4294967295UL;
+ for (i = 0; i < 2; i++)
+ l_1108[i] = 0xA99751B8L;
+ for (i = 0; i < 3; i++)
+ l_1431[i] = 0UL;
+ if ((safe_rshift_func_int8_t_s_s(0L, (((((safe_rshift_func_int16_t_s_s((((((safe_lshift_func_int16_t_s_s(((p_45 || (!(((*g_713)--) > p_48))) , (safe_mod_func_uint16_t_u_u((((&g_713 != (l_874 = &g_713)) , (++(*g_713))) != 0x7FDBL), (((p_45 && ((safe_sub_func_int16_t_s_s((((((&g_713 == &g_713) != 0x7EC58B7AL) , 0x7A3783A8L) == l_879) & p_47), 1UL)) != 2UL)) || 0UL) && l_879)))), g_775)) < 0xDACD2365L) == l_879) == 0UL) > p_48), 7)) == l_879) , (*g_434)) || p_47) >= p_46))))
+ { /* block id: 480 */
+ uint16_t l_892 = 0x8211L;
+ int32_t *l_941 = (void*)0;
+ int32_t *l_944 = &l_851;
+ uint16_t ****l_1005 = &l_873[3];
+ l_880 = &l_879;
+ if (((p_47 | 0x59C7L) == ((*g_434) = ((p_45 || (*g_434)) >= (safe_lshift_func_int16_t_s_u((safe_mod_func_int32_t_s_s(((*g_434) && (safe_unary_minus_func_uint16_t_u((p_47 ^ (0x8C6AL | ((safe_lshift_func_uint8_t_u_u(((((safe_lshift_func_uint8_t_u_u(0x1BL, p_47)) != (*l_880)) != g_59[1]) , l_892), 3)) & 0xA9L)))))), (*l_880))), p_48))))))
+ { /* block id: 483 */
+ int32_t *l_925 = (void*)0;
+ int32_t **l_945 = &l_827;
+ uint8_t l_954 = 0xC4L;
+ const uint16_t *l_960 = &g_961;
+ const uint16_t **l_959 = &l_960;
+ const uint16_t ***l_958[6];
+ int i;
+ for (i = 0; i < 6; i++)
+ l_958[i] = &l_959;
+ for (g_126 = 2; (g_126 > 7); ++g_126)
+ { /* block id: 486 */
+ int16_t *l_913 = (void*)0;
+ int16_t *l_914 = (void*)0;
+ int16_t *l_915 = &g_124;
+ int32_t l_916 = 0x331B7C2BL;
+ uint32_t *l_917[2][9] = {{&l_826,(void*)0,(void*)0,&l_826,(void*)0,&l_826,(void*)0,(void*)0,&l_826},{(void*)0,(void*)0,&l_789,(void*)0,(void*)0,(void*)0,(void*)0,&l_789,(void*)0}};
+ int32_t l_918[9];
+ int32_t l_920[4];
+ int16_t *l_921 = &g_775;
+ int i, j;
+ for (i = 0; i < 9; i++)
+ l_918[i] = 2L;
+ for (i = 0; i < 4; i++)
+ l_920[i] = 9L;
+ (*l_880) = (safe_add_func_uint32_t_u_u((~(safe_add_func_int32_t_s_s(0x2B42C6FBL, (((*l_921) |= (((safe_rshift_func_int16_t_s_u((safe_mul_func_uint8_t_u_u((p_48 ^ ((((safe_mul_func_uint16_t_u_u((p_45 <= (safe_lshift_func_uint8_t_u_u(((void*)0 != &g_454), 4))), ((safe_mul_func_int16_t_s_s(((safe_lshift_func_uint8_t_u_s(p_46, 6)) ^ (-1L)), ((l_918[4] = (safe_add_func_uint16_t_u_u(((((l_916 &= (p_47 , (((((((*l_915) = g_138[3]) > p_47) < p_45) < p_45) & 6UL) | 0xCCFFEDAEL))) ^ 0x8F8481BCL) | (*l_880)) , p_45), l_892))) , l_919))) == 251UL))) >= p_46) , (*l_880)) || 0xB3L)), l_920[1])), 14)) >= 0x4644L) , 1L)) != 0x0A15L)))), (*g_434)));
+ for (g_358 = 0; (g_358 == (-9)); g_358 = safe_sub_func_int32_t_s_s(g_358, 7))
+ { /* block id: 494 */
+ int32_t *l_924 = (void*)0;
+ uint32_t *l_940 = &g_408[2][5];
+ int32_t **l_942 = &l_924;
+ uint8_t ***l_943 = &g_658[3];
+ l_925 = l_924;
+ l_918[4] ^= (((safe_lshift_func_uint8_t_u_s(((safe_mod_func_uint16_t_u_u((g_435 == g_435), (((*g_514) = p_48) && ((*g_434) = (*l_880))))) > 4UL), p_47)) >= (((safe_div_func_int32_t_s_s((((*g_146) = l_892) && ((*l_940) &= (safe_lshift_func_int16_t_s_u((safe_sub_func_uint8_t_u_u((safe_mul_func_uint8_t_u_u((9UL < ((safe_add_func_uint8_t_u_u(p_48, p_47)) > l_892)), l_892)), (-1L))), 14)))), (*l_880))) || 0UL) || 255UL)) <= l_920[1]);
+ (*l_942) = l_941;
+ (*l_943) = &g_659;
+ }
+ (*g_514) = (p_48 && (-1L));
+ }
+ (*l_945) = l_944;
+ for (g_775 = 0; (g_775 >= (-1)); g_775 = safe_sub_func_uint16_t_u_u(g_775, 1))
+ { /* block id: 509 */
+ uint16_t l_957 = 1UL;
+ for (g_360 = 8; (g_360 >= 0); g_360 -= 1)
+ { /* block id: 512 */
+ int i;
+ (*l_827) = g_69[g_360];
+ }
+ for (l_826 = 7; (l_826 > 57); l_826 = safe_add_func_uint8_t_u_u(l_826, 2))
+ { /* block id: 517 */
+ int32_t *l_950 = &g_60[0][4][3];
+ int32_t *l_951 = &g_59[4];
+ int32_t *l_952 = &l_851;
+ int32_t *l_953[6][7][6] = {{{&l_851,&l_857[1],&g_36,(void*)0,(void*)0,&g_61},{&l_851,&l_857[1],&g_36,&g_60[0][4][3],&l_857[1],&l_857[1]},{(void*)0,&l_851,&l_851,(void*)0,&l_851,(void*)0},{&g_60[0][4][3],&g_36,&l_857[1],&l_851,&g_61,&l_857[4]},{(void*)0,&g_36,&l_857[1],&l_851,&g_61,&g_60[0][4][3]},{&g_61,&g_36,(void*)0,&g_60[1][0][3],&l_851,&g_60[1][0][3]},{&g_60[1][1][0],&l_851,&g_60[1][1][0],&l_857[1],&l_857[1],&g_61}},{{&g_61,&l_857[1],&l_857[4],&l_857[1],(void*)0,&g_36},{&l_857[1],&l_857[1],&g_61,&l_857[1],&l_879,&l_857[1]},{&g_61,(void*)0,&l_851,&l_857[1],&l_857[1],&l_851},{&g_60[1][1][0],&g_60[1][1][0],&l_855,&g_60[1][0][3],&g_59[1],&l_857[1]},{&g_61,&l_857[4],&g_59[1],&l_851,(void*)0,&l_855},{(void*)0,&g_61,&g_59[1],&l_851,&g_60[1][1][0],&l_857[1]},{&g_60[0][4][3],&l_851,&l_855,(void*)0,&l_855,&l_851}},{{&g_61,&g_36,&l_851,&l_857[4],(void*)0,&l_857[1]},{&l_851,&g_60[1][0][3],&g_61,&l_857[1],&g_61,&l_857[1]},{&g_61,&g_60[1][0][3],&g_61,&g_61,(void*)0,(void*)0},{&g_60[1][1][0],&g_36,&g_59[8],&g_59[8],&g_36,&g_60[1][1][0]},{&l_857[1],&l_851,&l_857[1],(void*)0,&g_59[8],&l_857[4]},{&l_879,&g_61,&l_855,&g_36,&l_851,&g_61},{&l_879,&g_61,&g_36,(void*)0,&g_60[1][0][3],&l_851}},{{&l_857[1],&g_59[8],&g_61,&g_59[8],&l_857[1],&l_855},{&g_60[1][1][0],&l_857[1],&l_857[1],&g_61,(void*)0,&g_59[1]},{&g_61,&l_855,&l_857[1],&l_857[1],&g_61,&g_59[1]},{&l_851,&g_36,&l_857[1],&l_857[4],&l_855,&l_855},{&g_61,&g_61,&g_61,&g_61,&l_851,&l_851},{&l_857[4],&l_857[1],&g_36,&l_851,(void*)0,&g_61},{&l_857[1],&l_857[1],&l_855,&g_61,(void*)0,&l_857[4]}},{{&g_61,&l_857[1],&l_857[1],&g_60[1][1][0],&l_851,&g_60[1][1][0]},{&g_59[8],&g_61,&g_59[8],&l_857[1],&l_855,(void*)0},{(void*)0,&g_36,&g_61,&l_879,&g_61,&l_857[1]},{&g_36,&l_855,&g_61,&l_879,(void*)0,&l_857[1]},{(void*)0,&l_857[1],&l_851,&l_857[1],&l_857[1],&l_851},{&g_59[8],&g_59[8],&g_36,&g_60[1][1][0],&g_60[1][0][3],&g_36},{&g_61,&g_61,&g_60[1][0][3],&g_61,&l_851,&g_36}},{{&l_857[1],&g_61,&g_60[1][0][3],&l_851,&g_59[8],&g_36},{&l_857[4],&l_851,&g_36,&g_61,&g_36,&l_851},{&g_61,&g_36,&l_851,&l_857[4],(void*)0,&l_857[1]},{&l_851,&g_60[1][0][3],&g_61,&l_857[1],&g_61,&l_857[1]},{&g_61,&g_60[1][0][3],&g_61,&g_61,(void*)0,(void*)0},{&g_60[1][1][0],&g_36,&g_59[8],&g_59[8],&g_36,&g_60[1][1][0]},{&l_857[1],&l_851,&l_857[1],(void*)0,&g_59[8],&l_857[4]}}};
+ int i, j, k;
+ ++l_954;
+ l_957 |= ((*l_952) = (((*l_790) ^= (-1L)) & (*l_944)));
+ }
+ (*g_514) = ((*l_827) |= (*l_880));
+ }
+ l_964 = (l_962 = (void*)0);
+ }
+ else
+ { /* block id: 528 */
+ for (g_61 = 0; g_61 < 2; g_61 += 1)
+ {
+ for (l_892 = 0; l_892 < 5; l_892 += 1)
+ {
+ for (g_358 = 0; g_358 < 4; g_358 += 1)
+ {
+ g_60[g_61][l_892][g_358] = 6L;
+ }
+ }
+ }
+ }
+ for (g_131 = (-5); (g_131 <= 34); g_131 = safe_add_func_int16_t_s_s(g_131, 5))
+ { /* block id: 533 */
+ uint16_t ***l_973 = &l_874;
+ int32_t l_984 = 0xDFBF9410L;
+ int32_t **l_1000 = &l_941;
+ uint8_t *l_1027 = &g_131;
+ for (p_47 = (-26); (p_47 < 29); p_47 = safe_add_func_int32_t_s_s(p_47, 6))
+ { /* block id: 536 */
+ uint16_t ****l_974 = &l_973;
+ uint16_t ****l_975 = &l_873[1];
+ int32_t *l_985[6][2][2] = {{{&g_61,&g_59[1]},{&g_59[1],&g_61}},{{&g_59[1],&g_59[1]},{&g_61,&g_59[1]}},{{&g_59[1],&g_61},{&g_59[1],&g_59[1]}},{{&g_61,&g_59[1]},{&g_59[1],&g_61}},{{&g_59[1],&g_59[1]},{&g_61,&g_59[1]}},{{&g_59[1],&g_61},{&g_59[1],&g_61}}};
+ uint16_t l_995[10][3][3] = {{{0x876CL,0xB242L,0x0660L},{65532UL,65532UL,65535UL},{65530UL,0xB242L,65535UL}},{{65535UL,4UL,65535UL},{65530UL,0xA11BL,65530UL},{65532UL,65535UL,65535UL}},{{0x876CL,1UL,65535UL},{65532UL,65535UL,65535UL},{65535UL,0xA11BL,0x0660L}},{{65532UL,4UL,65532UL},{0x876CL,0xB242L,0x0660L},{65532UL,65532UL,65535UL}},{{65530UL,0xB242L,65535UL},{65535UL,4UL,65535UL},{65530UL,0xA11BL,65530UL}},{{65532UL,65535UL,65535UL},{0x876CL,1UL,65535UL},{65532UL,65535UL,65535UL}},{{65535UL,0xA11BL,0x0660L},{65532UL,4UL,65532UL},{0x876CL,0xB242L,0x0660L}},{{65532UL,65532UL,65535UL},{65530UL,0xB242L,65535UL},{65535UL,4UL,65535UL}},{{65530UL,0xA11BL,65530UL},{65532UL,65535UL,65535UL},{0x876CL,1UL,65535UL}},{{65532UL,65535UL,65535UL},{65535UL,0xA11BL,0x0660L},{65532UL,4UL,65532UL}}};
+ int i, j, k;
+ }
+ }
+ }
+ else
+ { /* block id: 565 */
+ int8_t ****l_1062 = &l_1061;
+ uint8_t ***l_1066 = &g_658[3];
+ int32_t *l_1068 = (void*)0;
+ int32_t *l_1069 = (void*)0;
+ int32_t l_1070 = (-1L);
+ int32_t l_1105 = 0x2603CE82L;
+ int32_t l_1109 = 0x5D5B4DEDL;
+ int32_t l_1110[4] = {4L,4L,4L,4L};
+ uint16_t l_1112 = 0x8815L;
+ int i;
+ if ((((*g_434) < (safe_mul_func_int8_t_s_s(((safe_sub_func_int32_t_s_s(((((safe_mod_func_uint8_t_u_u(((safe_lshift_func_int16_t_s_u(((safe_add_func_uint32_t_u_u((safe_rshift_func_uint16_t_u_s(((((((((g_358 = (((safe_sub_func_uint16_t_u_u((p_47 = (safe_add_func_int16_t_s_s((((safe_sub_func_uint16_t_u_u(p_45, (((*l_1062) = l_1061) == l_1063))) , 0x4037D8D8L) <= (((*g_434) >= ((l_1064 != (l_1065 = l_1064)) != ((void*)0 == l_1066))) , l_1067)), (*l_880)))), p_45)) , (void*)0) == (void*)0)) , p_47) | 0x9FE39FA7L) , g_961) , p_47) < (*l_880)) == 0x4F7AL) || p_47), g_138[3])), p_46)) <= p_45), l_1070)) || 0x0DL), 0x71L)) < p_45) , l_1071) == &l_824), 0xDE5D4DB2L)) , l_1070), p_45))) <= p_45))
+ { /* block id: 570 */
+lbl_1099:
+ l_880 = &l_1070;
+ }
+ else
+ { /* block id: 572 */
+ const int8_t ****l_1085 = (void*)0;
+ for (g_436 = 0; (g_436 > 39); ++g_436)
+ { /* block id: 575 */
+ uint32_t l_1076 = 1UL;
+ const int32_t *l_1100 = &l_857[1];
+ for (g_358 = 0; (g_358 >= (-14)); g_358 = safe_sub_func_int16_t_s_s(g_358, 4))
+ { /* block id: 578 */
+ l_1076++;
+ if ((*l_880))
+ break;
+ if (p_46)
+ continue;
+ }
+ (*g_514) ^= ((safe_rshift_func_uint16_t_u_s(0x7586L, ((p_45 & (((safe_lshift_func_int16_t_s_u((((safe_lshift_func_uint16_t_u_s(((void*)0 == l_1085), (safe_div_func_int16_t_s_s((safe_sub_func_int16_t_s_s(((!0xE0L) && p_46), (l_1070 == (safe_sub_func_uint16_t_u_u((safe_lshift_func_uint8_t_u_s((safe_mul_func_int8_t_s_s(0L, l_1070)), 6)), 0xCBD5L))))), p_47)))) , (void*)0) != (void*)0), g_1096[0])) >= 0xE085DD08L) > l_1076)) == (-1L)))) , 0xEB6DF802L);
+ l_1070 |= (-2L);
+ for (g_510 = (-2); (g_510 != (-29)); g_510--)
+ { /* block id: 587 */
+ const int32_t **l_1101 = &l_1100;
+ if (g_360)
+ goto lbl_1099;
+ (*l_1101) = l_1100;
+ (*l_1101) = &l_1070;
+ if (p_48)
+ break;
+ }
+ }
+ }
+ for (g_145 = 0; (g_145 == 21); ++g_145)
+ { /* block id: 597 */
+ int32_t *l_1104 = (void*)0;
+ int32_t *l_1106 = (void*)0;
+ int32_t *l_1107[6][5] = {{&l_1070,(void*)0,&g_36,&g_60[0][4][3],&g_60[0][4][3]},{(void*)0,(void*)0,(void*)0,&g_59[0],(void*)0},{&g_60[0][4][3],&g_59[3],&g_59[0],&g_60[0][4][3],&g_59[0]},{&g_60[0][4][3],&g_60[0][4][3],&g_36,(void*)0,&l_1070},{(void*)0,&l_1070,&g_59[0],&g_59[0],&l_1070},{&l_1070,&g_59[3],(void*)0,&l_1070,&g_59[0]}};
+ int32_t l_1111 = 0xC680B001L;
+ int i, j;
+ l_1070 = 0x81C649FFL;
+ l_1112++;
+ return (*g_454);
+ }
+ }
+ for (p_46 = 0; (p_46 > 38); ++p_46)
+ { /* block id: 605 */
+ uint8_t l_1129[1][5][9] = {{{255UL,255UL,0xC0L,255UL,255UL,0xC0L,255UL,255UL,0xC0L},{1UL,1UL,0x8DL,1UL,1UL,0x8DL,1UL,1UL,0x8DL},{255UL,255UL,0xC0L,255UL,255UL,0xC0L,255UL,255UL,0xC0L},{1UL,1UL,0x8DL,1UL,1UL,0x8DL,1UL,1UL,0x8DL},{255UL,255UL,0xC0L,255UL,255UL,0xC0L,255UL,255UL,0xC0L}}};
+ int16_t *l_1144 = &g_124;
+ int32_t *l_1148[6][1][3] = {{{&l_1108[1],(void*)0,&l_851}},{{&g_36,&g_36,&l_851}},{{(void*)0,&l_1108[1],&l_851}},{{&l_1108[1],(void*)0,&l_851}},{{&g_36,&g_36,&l_851}},{{(void*)0,&l_1108[1],&l_851}}};
+ uint16_t ***l_1211 = &l_874;
+ uint32_t l_1212[4][2] = {{1UL,1UL},{1UL,1UL},{1UL,1UL},{1UL,1UL}};
+ uint32_t l_1258[3][10][8] = {{{0x0ECC242CL,2UL,0xBBA08DF3L,18446744073709551614UL,18446744073709551615UL,0x4194A657L,0xACFC1F18L,18446744073709551606UL},{1UL,0x728BE276L,18446744073709551615UL,0x4194A657L,18446744073709551613UL,0x4A4E1478L,18446744073709551614UL,2UL},{0xBBA08DF3L,0xC6AFF327L,0xEBB805F8L,18446744073709551613UL,0xEBB805F8L,0xC6AFF327L,0xBBA08DF3L,18446744073709551615UL},{18446744073709551609UL,0x073E66A2L,0x4194A657L,0x93447063L,0xC450AD13L,2UL,0xC6AFF327L,0xF001BE9DL},{0UL,0UL,2UL,0x0ECC242CL,0xC450AD13L,18446744073709551609UL,18446744073709551615UL,18446744073709551613UL},{18446744073709551609UL,0xD0026597L,0xACFC1F18L,0xF001BE9DL,0xEBB805F8L,2UL,0x93447063L,0x073E66A2L},{0xBBA08DF3L,0x71035224L,0xFAD7F9E8L,0UL,18446744073709551613UL,18446744073709551614UL,18446744073709551615UL,4UL},{1UL,1UL,0xFC2D4B21L,0xFAD7F9E8L,18446744073709551615UL,18446744073709551615UL,0xFAD7F9E8L,0xFC2D4B21L},{0x0ECC242CL,0x0ECC242CL,0xCE6368AAL,1UL,0xD0026597L,0xFC2D4B21L,0x71035224L,0UL},{0x71035224L,0xEBB805F8L,0x3A03219BL,0xC450AD13L,18446744073709551614UL,0UL,2UL,0UL}},{{0xEBB805F8L,18446744073709551615UL,18446744073709551614UL,1UL,2UL,0UL,0x834DBD27L,0xFC2D4B21L},{18446744073709551606UL,0x3A03219BL,18446744073709551614UL,0xFAD7F9E8L,0xBBA08DF3L,0x834DBD27L,1UL,4UL},{18446744073709551614UL,0xFC2D4B21L,18446744073709551615UL,0UL,0UL,0x073E66A2L,0xEBB805F8L,0x073E66A2L},{0xFAD7F9E8L,0xF001BE9DL,0xD0026597L,0xF001BE9DL,0xFAD7F9E8L,0x728BE276L,2UL,18446744073709551613UL},{2UL,4UL,1UL,0x0ECC242CL,18446744073709551615UL,18446744073709551606UL,0x073E66A2L,0xF001BE9DL},{1UL,4UL,1UL,0x93447063L,4UL,0x3A03219BL,2UL,18446744073709551615UL},{18446744073709551615UL,0x4A4E1478L,0xD0026597L,18446744073709551613UL,0x728BE276L,18446744073709551613UL,0xEBB805F8L,2UL},{18446744073709551613UL,18446744073709551615UL,18446744073709551615UL,0x4194A657L,18446744073709551609UL,0x71035224L,1UL,18446744073709551606UL},{0xC6AFF327L,0x834DBD27L,18446744073709551614UL,18446744073709551614UL,18446744073709551614UL,18446744073709551614UL,0x834DBD27L,0xC6AFF327L},{18446744073709551615UL,0xECA7B7A3L,18446744073709551614UL,0x834DBD27L,0x0ECC242CL,18446744073709551615UL,2UL,18446744073709551609UL}},{{1UL,18446744073709551609UL,0x3A03219BL,4UL,0x834DBD27L,18446744073709551615UL,0x71035224L,0UL},{18446744073709551613UL,0xECA7B7A3L,0xCE6368AAL,18446744073709551606UL,0x3A03219BL,18446744073709551614UL,0xFAD7F9E8L,0xBBA08DF3L},{0UL,0x834DBD27L,0xFC2D4B21L,18446744073709551613UL,0x073E66A2L,0x71035224L,18446744073709551615UL,0x5DC9B454L},{0x4A4E1478L,0UL,0x93447063L,0xBBA08DF3L,0x0ECC242CL,0UL,0x0ECC242CL,0xBBA08DF3L},{0xECA7B7A3L,18446744073709551606UL,0xECA7B7A3L,2UL,0xACFC1F18L,18446744073709551615UL,1UL,0xC450AD13L},{0UL,18446744073709551615UL,0xFC2D4B21L,18446744073709551614UL,0x4194A657L,0xFAD7F9E8L,0xACFC1F18L,0UL},{0UL,4UL,18446744073709551609UL,0xD0026597L,0xACFC1F18L,0xF001BE9DL,0xEBB805F8L,2UL},{0xECA7B7A3L,0x3A03219BL,0x71035224L,18446744073709551615UL,0x0ECC242CL,18446744073709551614UL,0x728BE276L,0xF001BE9DL},{18446744073709551606UL,0xD0026597L,0xCE6368AAL,18446744073709551613UL,18446744073709551614UL,4UL,0xECA7B7A3L,0xECA7B7A3L},{0x4194A657L,18446744073709551615UL,0xEBB805F8L,0xEBB805F8L,18446744073709551615UL,0x4194A657L,18446744073709551613UL,0UL}}};
+ int32_t ****l_1285 = &g_454;
+ int32_t l_1306 = 0xD7709800L;
+ uint32_t l_1354 = 0UL;
+ int i, j, k;
+ if (((safe_mod_func_uint32_t_u_u((safe_add_func_int32_t_s_s((+(safe_mod_func_uint32_t_u_u(((((l_1123 != &l_1124) >= (~(safe_sub_func_int8_t_s_s((safe_lshift_func_uint16_t_u_u(l_1129[0][0][2], (safe_div_func_uint16_t_u_u((safe_rshift_func_uint8_t_u_u((safe_rshift_func_uint16_t_u_u(((g_408[2][6] ^ (safe_add_func_int8_t_s_s((safe_sub_func_uint8_t_u_u((((safe_mul_func_int16_t_s_s(((*l_1144) = (((*g_146) = ((*g_146) > p_47)) && (safe_mod_func_int16_t_s_s(2L, 0xCCE6L)))), (((*g_514) = (!(((&g_435 == (void*)0) && 0x1E7E6082L) , (*g_514)))) , p_45))) ^ p_47) , 253UL), p_46)), p_45))) ^ (*g_434)), l_1129[0][1][7])), l_1129[0][4][0])), p_46)))), p_46)))) , 0L) , p_45), 8UL))), 0x70A85053L)), (*g_434))) | 254UL))
+ { /* block id: 609 */
+ int32_t **l_1145 = &g_37;
+ (*l_1145) = &g_59[1];
+ for (l_860 = 0; (l_860 < 52); l_860 = safe_add_func_int8_t_s_s(l_860, 8))
+ { /* block id: 613 */
+ l_1148[3][0][0] = (*l_1145);
+ }
+ }
+ else
+ { /* block id: 616 */
+ uint32_t *l_1161 = (void*)0;
+ uint32_t *l_1162 = &g_408[4][7];
+ uint32_t *l_1163[2];
+ int32_t l_1164 = 0L;
+ int8_t l_1165 = 0x78L;
+ int32_t l_1175 = 0x51F4F9EEL;
+ int32_t l_1177 = 0x008E83A0L;
+ int32_t l_1180 = 0xCBB2DE62L;
+ int32_t l_1181 = (-1L);
+ int32_t l_1183 = 0x5E58F2BFL;
+ int32_t l_1189 = 9L;
+ int32_t l_1191 = 0xFD59E9D3L;
+ int32_t l_1192[6][5] = {{2L,1L,2L,2L,1L},{0x04104790L,(-3L),(-10L),0x1EC6F59FL,(-10L)},{1L,1L,0x167B7268L,1L,1L},{(-10L),0x1EC6F59FL,(-10L),(-3L),0x04104790L},{1L,2L,2L,1L,2L},{0x04104790L,0x1EC6F59FL,1L,0x1EC6F59FL,0x04104790L}};
+ uint8_t l_1193 = 4UL;
+ const uint16_t ***l_1205 = &l_962;
+ int16_t l_1223 = 0x7D73L;
+ int32_t l_1251 = 2L;
+ int32_t l_1329[1];
+ const uint32_t l_1448 = 0x7DF362DFL;
+ int32_t **l_1458 = (void*)0;
+ int i, j;
+ for (i = 0; i < 2; i++)
+ l_1163[i] = &g_436;
+ for (i = 0; i < 1; i++)
+ l_1329[i] = 1L;
+ if (((+(safe_mul_func_int8_t_s_s((p_46 & ((((*g_434)++) ^ (((l_1164 = (safe_sub_func_uint32_t_u_u(((g_61 ^ (+(~(+(safe_lshift_func_int8_t_s_s(0xE2L, 3)))))) , ((*l_1162) = (0L ^ ((*g_514) &= ((*g_146) = (safe_rshift_func_int16_t_s_s((9UL != ((g_358 , ((*g_992) != &l_962)) | p_48)), g_61))))))), p_48))) < 0L) <= p_46)) == l_1165)), 0x64L))) != 65535UL))
+ { /* block id: 622 */
+ uint16_t l_1169 = 65535UL;
+ int32_t **l_1172 = &l_827;
+ int32_t l_1174 = (-7L);
+ int32_t l_1176 = (-1L);
+ int32_t l_1179 = 0xE825BFAEL;
+ int32_t l_1184 = 1L;
+ int32_t l_1185 = (-1L);
+ int32_t l_1186 = 0x368B2BF9L;
+ int32_t l_1187 = 0x2D5947ADL;
+ int32_t l_1188 = 0xA351F4C8L;
+ int32_t l_1190[8] = {0xD6BFCEA0L,(-10L),0xD6BFCEA0L,0xD6BFCEA0L,(-10L),0xD6BFCEA0L,0xD6BFCEA0L,(-10L)};
+ int i;
+ for (l_919 = 1; (l_919 == 1); l_919++)
+ { /* block id: 625 */
+ int8_t l_1168 = 0x45L;
+ ++l_1169;
+ }
+ (*l_1172) = l_1148[3][0][0];
+ ++l_1193;
+ }
+ else
+ { /* block id: 630 */
+ int8_t l_1214[6][7][1] = {{{5L},{1L},{5L},{1L},{5L},{1L},{5L}},{{1L},{5L},{1L},{5L},{1L},{5L},{1L}},{{5L},{1L},{5L},{1L},{5L},{1L},{5L}},{{1L},{5L},{1L},{5L},{1L},{5L},{1L}},{{5L},{1L},{5L},{1L},{5L},{1L},{5L}},{{1L},{5L},{1L},{5L},{1L},{5L},{1L}}};
+ uint16_t ***l_1323 = &l_874;
+ int32_t l_1330 = 0x3DE92DE1L;
+ int32_t ***l_1331 = (void*)0;
+ int i, j, k;
+ for (l_856 = 8; (l_856 >= 0); l_856 -= 1)
+ { /* block id: 633 */
+ const uint16_t ***l_1204 = &l_962;
+ const uint16_t ****l_1203[9][3][9] = {{{&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0},{&l_1204,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204},{&l_1204,(void*)0,(void*)0,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204}},{{(void*)0,&l_1204,(void*)0,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204},{&l_1204,(void*)0,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204},{&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0}},{{(void*)0,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204},{&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,(void*)0,(void*)0,&l_1204,&l_1204},{&l_1204,(void*)0,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204}},{{&l_1204,(void*)0,&l_1204,(void*)0,&l_1204,(void*)0,&l_1204,(void*)0,&l_1204},{&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204,&l_1204},{&l_1204,&l_1204,&l_1204,(void*)0,(void*)0,&l_1204,&l_1204,(void*)0,&l_1204}},{{&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204},{(void*)0,&l_1204,&l_1204,(void*)0,&l_1204,(void*)0,(void*)0,&l_1204,(void*)0},{&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204}},{{(void*)0,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204},{&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204},{&l_1204,(void*)0,&l_1204,(void*)0,&l_1204,(void*)0,(void*)0,(void*)0,&l_1204}},{{&l_1204,(void*)0,(void*)0,&l_1204,&l_1204,(void*)0,(void*)0,&l_1204,&l_1204},{(void*)0,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204},{&l_1204,&l_1204,(void*)0,&l_1204,&l_1204,(void*)0,(void*)0,&l_1204,&l_1204}},{{&l_1204,&l_1204,(void*)0,(void*)0,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204},{(void*)0,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204},{&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204}},{{&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204},{&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204,(void*)0},{&l_1204,(void*)0,&l_1204,&l_1204,&l_1204,&l_1204,(void*)0,&l_1204,&l_1204}}};
+ int32_t ****l_1206 = &l_824;
+ uint32_t l_1213 = 0x6CD7B8E6L;
+ uint8_t *l_1238 = &g_131;
+ int i, j, k;
+ (*g_146) = (((((safe_mod_func_uint32_t_u_u(((safe_lshift_func_uint8_t_u_u((!(((safe_mul_func_int8_t_s_s(((*l_790) |= g_1202), (l_1177 = (!(p_45 ^ ((l_1205 = (void*)0) != (((((*l_1071) = (void*)0) == ((*l_1206) = &g_455)) , (safe_rshift_func_int8_t_s_s((((*l_1162) = 4294967295UL) >= (safe_mod_func_uint16_t_u_u(((l_1211 != ((((void*)0 != (*l_1061)) > p_46) , (void*)0)) , l_1193), g_60[0][4][3]))), 4))) , (*g_992)))))))) , l_1212[2][0]) <= 8L)), 4)) != p_46), (*g_434))) , l_1213) != 0UL) , p_47) <= l_1214[5][5][0]);
+ l_1251 ^= ((safe_mod_func_uint16_t_u_u(((safe_mul_func_uint16_t_u_u((safe_sub_func_int32_t_s_s((+((safe_add_func_uint16_t_u_u(l_1223, ((g_69[l_856] = (safe_rshift_func_int8_t_s_u((safe_add_func_uint8_t_u_u((safe_mod_func_uint8_t_u_u((safe_mod_func_uint16_t_u_u((safe_div_func_int8_t_s_s(((((((((((safe_add_func_uint32_t_u_u(l_1191, (((safe_rshift_func_int8_t_s_s(((((*g_146) |= ((((*l_1238) ^= p_48) , (safe_mul_func_uint16_t_u_u(((safe_mod_func_uint32_t_u_u(((*g_713) || (safe_div_func_uint32_t_u_u((((((((safe_mul_func_int8_t_s_s(p_47, p_46)) ^ (safe_sub_func_int16_t_s_s(g_69[6], (l_1214[5][5][0] | ((p_46 <= 1UL) <= g_36))))) | l_1214[5][5][0]) || (*g_713)) >= (*g_434)) , g_138[0]) && p_45), (*g_514)))), p_48)) <= p_47), p_48))) , l_1249)) <= p_45) & p_47), 3)) | (*g_514)) == p_46))) != 0x4E7AL) != p_46) < 0UL) , g_1250) , p_46) != l_1214[3][6][0]) < 0xB137L) , (*g_146)) , p_45), 1UL)), p_48)), 0xBDL)), 1UL)), l_1214[3][2][0]))) | l_1214[5][5][0]))) && 0x02L)), 0xC9004992L)), p_45)) != l_1214[5][5][0]), l_1214[5][5][0])) < p_48);
+ }
+ if ((((safe_div_func_int32_t_s_s(((*g_514) = ((p_46 >= 0x9A75L) || 0xACL)), p_47)) || (*g_713)) && (safe_lshift_func_int8_t_s_u((safe_add_func_uint32_t_u_u(((p_47 < (g_436 != (((**g_992) == ((*l_1211) = (void*)0)) ^ (*g_514)))) && p_47), 8UL)), l_1258[2][3][3]))))
+ { /* block id: 648 */
+ uint8_t *l_1269 = &l_1193;
+ uint8_t *l_1279 = &l_1067;
+ int32_t *****l_1284 = &l_1071;
+ uint16_t ***l_1307 = &g_712;
+ (*g_146) = (safe_add_func_int32_t_s_s((safe_lshift_func_int16_t_s_s((safe_mod_func_uint8_t_u_u(p_45, (safe_lshift_func_uint16_t_u_u((((*l_1279) = (((((safe_add_func_uint8_t_u_u(((((((*l_1269) = p_47) > ((!(safe_div_func_int16_t_s_s(p_45, (((safe_unary_minus_func_int8_t_s((l_1214[5][5][0] | ((safe_div_func_uint32_t_u_u((p_48 != (p_47 , (safe_add_func_uint16_t_u_u((l_1214[5][5][0] < (!(1L != (safe_lshift_func_int16_t_s_s(((*l_1144) &= g_1202), 13))))), p_46)))), p_46)) | 0xBEL)))) <= (-7L)) ^ 9UL)))) >= p_48)) && (*g_434)) != p_46) , p_48), 5UL)) || 0x1207L) ^ l_1214[5][5][0]) && 2L) ^ p_45)) && p_45), p_46)))), l_1214[1][5][0])), 4294967295UL));
+ (*g_514) ^= (((*l_790) &= (-8L)) == ((safe_mul_func_uint8_t_u_u((((*l_1284) = &g_454) == l_1285), (((safe_mul_func_uint16_t_u_u((safe_add_func_int16_t_s_s(l_1191, (l_1108[0] &= (((l_1306 = (safe_div_func_uint8_t_u_u(((*l_1279) = ((safe_sub_func_uint16_t_u_u(((safe_rshift_func_uint8_t_u_u((p_47 & (safe_rshift_func_int8_t_s_s((!((safe_sub_func_uint32_t_u_u((l_1214[1][6][0] >= l_1214[5][5][0]), ((safe_sub_func_uint16_t_u_u((((safe_div_func_uint16_t_u_u((((((*g_713) = (!(safe_mul_func_uint8_t_u_u(((*l_1269) |= 0x14L), (l_1144 == &g_775))))) ^ 0x29A5L) < p_47) != 0xCE61ED42L), p_46)) > 0x3BE5L) , (*g_713)), p_46)) | 0xC9L))) != l_1214[1][3][0])), 2))), 0)) > l_1214[2][4][0]), g_510)) , 0x2AL)), l_1214[5][5][0]))) , l_1307) != (*g_992))))), (-1L))) < g_60[0][4][3]) , p_45))) >= p_46));
+ return &g_37;
+ }
+ else
+ { /* block id: 662 */
+ uint8_t *l_1313 = &l_1129[0][2][4];
+ int32_t l_1322[9] = {(-3L),(-10L),(-3L),(-10L),(-3L),(-10L),(-3L),(-10L),(-3L)};
+ int i;
+ l_1329[0] = ((safe_sub_func_int8_t_s_s(((safe_mul_func_uint8_t_u_u(((*l_1313) |= g_1312), (p_48 <= (+(safe_rshift_func_int16_t_s_s((safe_div_func_uint32_t_u_u((safe_lshift_func_uint8_t_u_u(((safe_rshift_func_uint8_t_u_s(l_1322[4], 7)) < (l_1323 == (g_1324 = &l_874))), 5)), ((*l_1162) = (safe_rshift_func_int8_t_s_s((safe_div_func_int32_t_s_s((~p_45), (p_47 , 0x74FE25C3L))), 1))))), g_131)))))) != p_47), 0x79L)) | p_48);
+ l_1330 = l_1322[4];
+ l_1322[4] = ((void*)0 != l_1331);
+ }
+ }
+ for (l_789 = (-25); (l_789 >= 52); l_789 = safe_add_func_int8_t_s_s(l_789, 8))
+ { /* block id: 673 */
+ uint32_t l_1350[2][1][4];
+ int32_t **l_1355 = &l_1148[3][0][0];
+ int i, j, k;
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 1; j++)
+ {
+ for (k = 0; k < 4; k++)
+ l_1350[i][j][k] = 18446744073709551615UL;
+ }
+ }
+ for (p_48 = (-2); (p_48 == (-3)); p_48 = safe_sub_func_uint32_t_u_u(p_48, 5))
+ { /* block id: 676 */
+ uint32_t l_1353 = 18446744073709551615UL;
+ (*g_146) &= ((p_47 , (safe_mul_func_uint8_t_u_u(p_45, (safe_rshift_func_uint16_t_u_s(((safe_add_func_int16_t_s_s(p_47, ((+(((safe_mod_func_uint32_t_u_u((((*l_1162) = (safe_add_func_int32_t_s_s((((g_1096[0] , ((((safe_div_func_int32_t_s_s(((safe_sub_func_uint16_t_u_u(((*g_514) | p_48), (l_1350[0][0][1] = p_46))) & (safe_mul_func_int16_t_s_s(g_358, g_2))), (*g_434))) || p_48) , 65535UL) | p_47)) && 1UL) | l_1353), 0xB364D226L))) , 0xA0A58F63L), l_1191)) && p_46) != l_1353)) != l_1354))) >= p_45), g_415))))) ^ (*g_713));
+ return &g_37;
+ }
+ }
+ (*g_146) |= ((*g_713) && ((((((*g_1324) = (*g_1324)) == &l_793[0][0]) & (((((safe_unary_minus_func_int16_t_s(((safe_add_func_uint32_t_u_u((safe_div_func_uint16_t_u_u(0UL, ((*g_713) = p_45))), (safe_add_func_uint8_t_u_u(((safe_mod_func_int32_t_s_s(l_1365, (((safe_div_func_uint32_t_u_u((((safe_rshift_func_uint8_t_u_s(((*l_1071) == l_824), 7)) < g_1096[0]) != 0x39CA519CL), 0xF92D732FL)) , p_48) && p_46))) , 252UL), p_46)))) , p_47))) != 0x16L) != l_1180) | 1UL) | l_1192[4][4])) || 0x53A17BC8L) | 6L));
+ if ((((safe_mod_func_uint16_t_u_u(l_1249, 0x29DDL)) | ((safe_div_func_uint32_t_u_u((((*l_1162) = (p_46 && (safe_rshift_func_int8_t_s_u(g_145, ((l_1251 = (p_47 = (&g_775 != ((safe_div_func_int8_t_s_s(((*l_790) = p_45), p_47)) , &p_45)))) == (+(g_775 ^= (safe_rshift_func_uint16_t_u_u(((*g_713) = ((((*l_1144) = ((safe_sub_func_uint16_t_u_u((((*g_146) = p_48) || p_48), p_45)) , (-5L))) <= 0L) != (*g_514))), 12))))))))) ^ l_1164), (*g_434))) < l_1382)) < p_45))
+ { /* block id: 694 */
+ uint8_t *l_1385 = &g_31[0];
+ int32_t l_1414 = 7L;
+ uint8_t l_1447 = 0x67L;
+ int32_t **l_1455 = (void*)0;
+ l_880 = &l_1181;
+ if ((safe_mul_func_uint16_t_u_u(((((*l_1385)--) && 8UL) < ((((!(p_47 = (safe_sub_func_uint16_t_u_u((safe_lshift_func_int8_t_s_u(0xD6L, ((safe_sub_func_int8_t_s_s((((safe_div_func_uint16_t_u_u(((safe_mul_func_int16_t_s_s((safe_rshift_func_uint8_t_u_u(p_46, 1)), (safe_add_func_uint8_t_u_u((safe_sub_func_int16_t_s_s(g_415, ((safe_mul_func_int8_t_s_s((safe_lshift_func_uint16_t_u_u(((*g_713) = (l_1164 = ((g_408[2][6] , ((safe_sub_func_uint8_t_u_u((p_45 ^ 0x25L), (*l_880))) ^ (safe_div_func_uint8_t_u_u((safe_sub_func_int8_t_s_s((((g_36 , p_47) & p_46) , g_126), p_45)), l_1414)))) , 0xF394L))), l_1414)), (*l_880))) != 0x04DC5837L))), p_48)))) , p_48), 0x7F7CL)) & 0x8846L) && (*g_146)), p_48)) >= 4294967295UL))), p_48)))) && 0x5D09L) > 0UL) , p_46)), p_46)))
+ { /* block id: 700 */
+ int16_t l_1430 = 0xBBD6L;
+ (*g_514) = (safe_add_func_int32_t_s_s((((safe_div_func_int32_t_s_s(0x9175FE28L, (~((safe_mul_func_uint8_t_u_u((safe_add_func_uint16_t_u_u(((safe_lshift_func_uint8_t_u_u((safe_mul_func_int8_t_s_s((safe_div_func_int32_t_s_s(((void*)0 == &l_1192[3][4]), (+(safe_unary_minus_func_uint8_t_u(l_1430))))), 0xBBL)), l_1414)) == p_48), (1L <= l_1431[0]))), (-10L))) , (*g_434))))) , l_1432) , (*g_146)), p_48));
+ }
+ else
+ { /* block id: 702 */
+ uint8_t ****l_1436 = &l_1435;
+ int32_t l_1445 = 9L;
+ int16_t *l_1446[1];
+ int i;
+ for (i = 0; i < 1; i++)
+ l_1446[i] = &g_775;
+ l_1251 = (l_1063 != (((!(l_1447 = ((*l_1144) = ((0xEB40L ^ (safe_add_func_uint32_t_u_u((*g_434), (((*l_1436) = l_1435) == &g_658[3])))) == (((safe_lshift_func_uint8_t_u_s((safe_div_func_int8_t_s_s(p_47, 0x51L)), ((safe_add_func_int16_t_s_s((((-8L) & (safe_mul_func_int16_t_s_s(p_46, 7L))) > p_47), 1UL)) ^ g_415))) > 4294967290UL) || l_1445))))) != p_47) , (void*)0));
+ (*g_146) = (((*g_146) , 0x7A77L) ^ ((0xBAD2L || (l_1448 >= (p_48 = (safe_div_func_uint16_t_u_u(2UL, ((((*l_880) = ((safe_lshift_func_uint16_t_u_s(p_47, (((*g_514) = ((~((safe_add_func_uint32_t_u_u(((((((*l_1071) != &g_455) != 0x7B6E557FL) >= (*g_514)) < l_1447) <= 0x290502A0L), 4294967295UL)) >= p_48)) , (*g_514))) && 0x6D566369L))) , p_48)) , 0x9053L) , g_60[0][4][3])))))) , (*l_880)));
+ return l_1455;
+ }
+ }
+ else
+ { /* block id: 713 */
+ for (g_126 = 0; (g_126 != (-12)); g_126--)
+ { /* block id: 716 */
+ return l_1458;
+ }
+ }
+ }
+ for (g_415 = 0; (g_415 != 10); g_415 = safe_add_func_int32_t_s_s(g_415, 3))
+ { /* block id: 723 */
+ int32_t l_1465 = 0x90C86AAFL;
+ int32_t **l_1466[3];
+ int i;
+ for (i = 0; i < 3; i++)
+ l_1466[i] = &l_827;
+ }
+ }
+ if ((safe_lshift_func_uint16_t_u_u((g_360 >= (p_47 != ((safe_div_func_uint8_t_u_u((((!((*g_514) , (safe_div_func_uint16_t_u_u(((safe_rshift_func_uint16_t_u_u((safe_mul_func_uint8_t_u_u(((*l_1480) = ((void*)0 == &l_793[0][0])), ((*l_790) |= 2L))), (*g_713))) < 0xB9L), (((((g_1483 = ((safe_lshift_func_int8_t_s_u(((&g_659 == (void*)0) ^ 0x34L), p_48)) , &l_1249)) != &l_1249) ^ 0x8F060E18L) == p_48) | l_1485[1][5][1]))))) | p_45) != 0xA1L), p_46)) < g_408[2][6]))), 8)))
+ { /* block id: 744 */
+ uint32_t l_1512 = 0x0753D77DL;
+ int32_t **l_1517 = &l_827;
+ int32_t l_1537 = 0xA118C07FL;
+ int32_t *l_1566 = &g_61;
+ int32_t *l_1567 = &l_1537;
+ int32_t *l_1568 = &l_856;
+ int32_t *l_1569 = &g_59[1];
+ int32_t *l_1570 = &l_879;
+ int32_t *l_1571[9];
+ uint8_t l_1573 = 7UL;
+ int i;
+ for (i = 0; i < 9; i++)
+ l_1571[i] = &l_1182;
+ for (g_436 = 12; (g_436 <= 55); g_436 = safe_add_func_int8_t_s_s(g_436, 9))
+ { /* block id: 747 */
+ int32_t * const l_1490 = &g_59[1];
+ for (l_858 = (-21); (l_858 <= (-8)); l_858 = safe_add_func_int8_t_s_s(l_858, 1))
+ { /* block id: 750 */
+ int32_t **l_1491 = &l_880;
+ (*l_1491) = l_1490;
+ }
+ for (g_131 = (-22); (g_131 < 32); g_131++)
+ { /* block id: 755 */
+ int32_t *l_1494 = &g_59[1];
+ int32_t **l_1495 = &g_37;
+ int32_t ****l_1504 = &l_824;
+ uint16_t **l_1505 = &g_713;
+ uint16_t * const l_1508 = &g_1509;
+ uint16_t * const *l_1507[5][8][1] = {{{(void*)0},{&l_1508},{&l_1508},{(void*)0},{&l_1508},{&l_1508},{&l_1508},{(void*)0}},{{&l_1508},{&l_1508},{(void*)0},{&l_1508},{&l_1508},{&l_1508},{(void*)0},{&l_1508}},{{&l_1508},{(void*)0},{&l_1508},{&l_1508},{&l_1508},{(void*)0},{&l_1508},{&l_1508}},{{(void*)0},{&l_1508},{&l_1508},{&l_1508},{(void*)0},{&l_1508},{&l_1508},{(void*)0}},{{&l_1508},{&l_1508},{&l_1508},{(void*)0},{&l_1508},{&l_1508},{(void*)0},{&l_1508}}};
+ uint16_t * const **l_1506 = &l_1507[3][4][0];
+ int32_t ****l_1510 = (void*)0;
+ int32_t *****l_1511 = &l_1071;
+ int i, j, k;
+ if (p_46)
+ break;
+ (*l_1495) = l_1494;
+ (*l_1490) = ((safe_rshift_func_int16_t_s_s((safe_mul_func_uint8_t_u_u(247UL, (safe_div_func_uint16_t_u_u(((*g_434) && (*l_1490)), (safe_div_func_uint32_t_u_u(((((*l_1490) || (l_1504 == ((*l_1511) = (l_1510 = ((l_1505 != ((*l_1506) = l_1505)) , &g_454))))) , l_1061) == (void*)0), (*g_434))))))), (*l_1490))) , p_48);
+ }
+ l_1512--;
+ }
+ if (((*g_146) |= l_1512))
+ { /* block id: 766 */
+ for (p_48 = (-8); (p_48 >= 24); p_48 = safe_add_func_int32_t_s_s(p_48, 5))
+ { /* block id: 769 */
+ return (*l_824);
+ }
+ }
+ else
+ { /* block id: 772 */
+ int32_t l_1520 = (-1L);
+ for (l_1382 = 0; (l_1382 != 48); l_1382 = safe_add_func_uint32_t_u_u(l_1382, 3))
+ { /* block id: 775 */
+ int8_t l_1522 = 1L;
+ int32_t l_1523 = 1L;
+ int32_t l_1536 = (-10L);
+ int32_t l_1541 = 0x1F61027AL;
+ if ((l_1520 = ((*g_146) = (-1L))))
+ { /* block id: 778 */
+ int8_t l_1521 = (-4L);
+ if (p_47)
+ break;
+ l_1522 = l_1521;
+ }
+ else
+ { /* block id: 781 */
+ int32_t *l_1524 = &l_855;
+ int32_t *l_1525 = &g_36;
+ int32_t *l_1526 = &l_1108[0];
+ int32_t *l_1527 = &g_60[0][4][3];
+ int32_t *l_1528 = &l_879;
+ int32_t *l_1529 = (void*)0;
+ int32_t *l_1530 = &g_60[0][2][2];
+ int32_t *l_1531 = &g_36;
+ int32_t *l_1532 = (void*)0;
+ int32_t *l_1533 = &l_855;
+ int32_t *l_1534 = &g_36;
+ int32_t *l_1535[2];
+ int i;
+ for (i = 0; i < 2; i++)
+ l_1535[i] = (void*)0;
+ ++l_1538;
+ l_1542--;
+ }
+ return &g_514;
+ }
+ }
+ for (l_851 = 21; (l_851 <= 10); l_851 = safe_sub_func_int8_t_s_s(l_851, 1))
+ { /* block id: 790 */
+ int32_t l_1565 = (-1L);
+ (*g_514) |= (((safe_sub_func_uint16_t_u_u((safe_div_func_int8_t_s_s((safe_mod_func_uint32_t_u_u(p_46, 4L)), (safe_mod_func_uint8_t_u_u(p_45, (((safe_lshift_func_uint16_t_u_s(((safe_mul_func_int16_t_s_s((0xC1L <= ((safe_rshift_func_uint8_t_u_s(((((l_1561 < (safe_add_func_uint16_t_u_u(l_1564, ((~p_45) && ((*l_1480) = (l_1565 < 1L)))))) , &g_454) != &g_454) <= p_45), 1)) > 0x8D0979DCL)), l_1565)) != p_47), 6)) , p_46) || p_48))))), p_46)) , g_69[6]) != 0x8BL);
+ }
+ l_1573--;
+ }
+ else
+ { /* block id: 795 */
+ uint8_t *l_1579 = &g_131;
+ uint8_t ** const l_1578 = &l_1579;
+ uint8_t ** const *l_1577 = &l_1578;
+ uint8_t ** const **l_1576 = &l_1577;
+ int32_t l_1605 = 0x9D3CEF20L;
+ uint32_t l_1635 = 0xA0B6A9DBL;
+ int8_t **l_1656 = (void*)0;
+ int32_t l_1663 = (-1L);
+ int32_t **l_1673[5] = {&g_514,&g_514,&g_514,&g_514,&g_514};
+ int16_t l_1711 = 0x11BEL;
+ int32_t l_1714 = 4L;
+ int32_t *l_1744 = &l_855;
+ uint8_t l_1765 = 0xB3L;
+ uint32_t l_1790 = 5UL;
+ uint32_t l_1791 = 0x09D0C495L;
+ int i;
+ if (((((*l_1480) &= 250UL) & ((((((*l_1576) = l_1435) == (((*g_514) = (+(safe_lshift_func_uint8_t_u_s(p_46, (g_435 == g_435))))) , &g_658[3])) , ((safe_div_func_int32_t_s_s(0x3603FE2EL, (safe_rshift_func_uint8_t_u_s((++(*l_1579)), 4)))) ^ p_47)) ^ 0UL) < p_47)) && 0xA1D3L))
+ { /* block id: 800 */
+ int8_t l_1607 = 0xDBL;
+ for (g_775 = (-4); (g_775 >= 1); ++g_775)
+ { /* block id: 803 */
+ uint8_t ****l_1592[8];
+ int32_t l_1606 = (-1L);
+ int i;
+ for (i = 0; i < 8; i++)
+ l_1592[i] = &l_1435;
+ (*g_146) = ((*g_713) < (g_1590 == &g_1591[5][6]));
+ l_1607 &= ((((l_1593[1] = l_1435) != &g_658[2]) || (+(((((***l_1576) = (**l_1435)) == ((*l_1578) = l_1594)) && (4294967290UL != (((safe_mul_func_int8_t_s_s((safe_add_func_uint8_t_u_u((l_1606 ^= (safe_mul_func_int16_t_s_s(((((((&p_48 == &p_48) , ((*l_790) = ((safe_rshift_func_uint16_t_u_s(((*g_713) = (+0xDA44L)), (safe_rshift_func_int8_t_s_s(8L, p_46)))) == 1L))) < l_1605) >= 0x4746L) == p_48) > 3L), g_131))), p_48)), 1L)) && p_48) < p_48))) || l_1605))) , (*g_146));
+ if (l_1607)
+ continue;
+ (*g_514) ^= (safe_mod_func_int16_t_s_s(((*g_434) , (255UL <= l_1606)), p_48));
+ }
+ return (*l_824);
+ }
+ else
+ { /* block id: 816 */
+ int16_t l_1625[5][7];
+ int8_t **l_1626 = &l_790;
+ uint32_t l_1629 = 0xA3E6BA5DL;
+ int8_t *l_1630 = &l_1173[0];
+ int i, j;
+ for (i = 0; i < 5; i++)
+ {
+ for (j = 0; j < 7; j++)
+ l_1625[i][j] = 0x8253L;
+ }
+ (*g_146) = ((safe_mod_func_uint32_t_u_u((safe_add_func_int8_t_s_s(p_45, (safe_mod_func_int16_t_s_s(((safe_mul_func_int16_t_s_s((safe_unary_minus_func_int8_t_s((p_45 != ((safe_sub_func_uint8_t_u_u((safe_add_func_uint16_t_u_u(((((*l_790) = (l_1625[2][5] , l_1605)) || (p_48 = ((*l_1630) = ((l_1626 == ((*l_1064) = (void*)0)) < ((safe_div_func_int32_t_s_s((((l_1629 && (&g_658[2] != l_1435)) | 0xD91DL) , 0xD5441AC9L), 0x10740426L)) , p_48))))) ^ p_46), l_1605)), g_59[7])) , p_46)))), 0x547DL)) && (*g_434)), p_46)))), p_46)) ^ g_1509);
+ }
+ for (g_1509 = 0; (g_1509 < 38); g_1509 = safe_add_func_uint16_t_u_u(g_1509, 1))
+ { /* block id: 825 */
+ uint8_t l_1647 = 0x58L;
+ uint16_t *l_1661[8] = {&g_69[0],&g_69[5],&g_69[0],&g_69[5],&g_69[0],&g_69[5],&g_69[0],&g_69[5]};
+ int32_t l_1662[8][3] = {{(-1L),0xF23F40CAL,0xA058F09DL},{0x60BB2647L,(-1L),0xF23F40CAL},{0x60BB2647L,3L,0xB82B7CEFL},{(-1L),0xFA4AA8CDL,(-1L)},{0xB82B7CEFL,3L,0x60BB2647L},{0xF23F40CAL,(-1L),0x60BB2647L},{0xA058F09DL,0xF23F40CAL,(-1L)},{1L,1L,0xB82B7CEFL}};
+ int i, j;
+ for (l_789 = (-9); (l_789 == 15); ++l_789)
+ { /* block id: 828 */
+ --l_1635;
+ }
+ for (g_36 = 0; (g_36 == (-18)); g_36 = safe_sub_func_uint16_t_u_u(g_36, 5))
+ { /* block id: 833 */
+ uint32_t l_1640[1];
+ int32_t l_1669 = 0x1BDB15C6L;
+ int i;
+ for (i = 0; i < 1; i++)
+ l_1640[i] = 0xAFBC8874L;
+ if (p_48)
+ { /* block id: 834 */
+ int8_t l_1643 = (-1L);
+ int32_t *l_1644 = (void*)0;
+ int32_t *l_1645 = &l_1182;
+ int32_t *l_1646[4][1][6] = {{{&l_1182,&g_36,(void*)0,(void*)0,&g_36,&l_1182}},{{&l_1605,&l_1182,(void*)0,&l_1182,&l_1605,&l_1605}},{{&l_855,&l_1182,&l_1182,&l_855,&g_36,&l_855}},{{&l_855,&g_36,&l_855,&l_1182,&l_1182,&l_855}}};
+ int i, j, k;
+ --l_1640[0];
+ if (l_1640[0])
+ continue;
+ l_1647++;
+ (*g_146) &= (safe_sub_func_uint32_t_u_u((l_1640[0] , (safe_lshift_func_int8_t_s_s((g_510 &= (safe_mul_func_int8_t_s_s((((l_1656 == ((*l_1061) = l_1656)) < g_1509) | ((p_47++) ^ (0x42L != (((!(p_45 | (l_1661[0] != &p_46))) , &g_510) == &g_510)))), (-1L)))), g_408[2][6]))), p_45));
+ }
+ else
+ { /* block id: 842 */
+ int32_t *l_1664 = &l_855;
+ int32_t *l_1665 = (void*)0;
+ int32_t *l_1666 = &l_1663;
+ int32_t *l_1667 = &l_1662[2][0];
+ int32_t *l_1668[7][2] = {{&g_59[8],&l_1662[2][0]},{&g_59[8],&l_1662[2][0]},{&g_59[8],&l_1662[2][0]},{&g_59[8],&l_1662[2][0]},{&g_59[8],&l_1662[2][0]},{&g_59[8],&l_1662[2][0]},{&g_59[8],&l_1662[2][0]}};
+ int i, j;
+ (*g_146) = p_48;
+ ++l_1670;
+ l_1662[1][0] = ((*g_146) = 0x32BC2857L);
+ }
+ return l_1673[2];
+ }
+ --l_1675[3][1][0];
+ for (g_360 = 0; (g_360 >= 25); g_360 = safe_add_func_uint16_t_u_u(g_360, 2))
+ { /* block id: 853 */
+ uint32_t *l_1689[8] = {&l_1542,&l_1542,&l_1542,&l_1542,&l_1542,&l_1542,&l_1542,&l_1542};
+ uint32_t **l_1690 = (void*)0;
+ int32_t l_1703 = 0x9EF797C4L;
+ int i;
+ (*g_514) &= (*g_146);
+ if (((safe_rshift_func_int8_t_s_u(p_48, 2)) > (((*l_1579) = (--l_1682)) == (safe_mod_func_int8_t_s_s((safe_mul_func_int16_t_s_s(0L, p_47)), (((l_1691 = l_1689[1]) != ((safe_div_func_int8_t_s_s(0L, (p_48 || ((safe_div_func_int16_t_s_s((safe_mod_func_int8_t_s_s(((*l_790) = (safe_mul_func_uint8_t_u_u(((*l_1594) = ((void*)0 != l_873[7])), (safe_unary_minus_func_uint16_t_u(((safe_mod_func_int8_t_s_s((l_1662[1][2] ^= l_1703), 0x88L)) , 1UL)))))), l_1703)), p_46)) || g_145)))) , &l_1670)) & l_1647))))))
+ { /* block id: 861 */
+ return (*l_824);
+ }
+ else
+ { /* block id: 863 */
+ return (*l_824);
+ }
+ }
+ }
+ if (((((safe_lshift_func_uint8_t_u_u(p_47, ((((*g_146) = ((((*g_514) = ((((void*)0 == &g_408[5][0]) && p_45) <= ((*g_434)++))) | p_47) | (1L <= (((void*)0 == l_1710) & (((g_124 &= ((0x09BA0DEDL > (-1L)) , 0L)) && p_47) != 0UL))))) , (*g_434)) != 0x6663A05DL))) || p_47) > p_46) , 0x9E8BC888L))
+ { /* block id: 872 */
+ int32_t l_1712[1];
+ int32_t l_1713[8][2][3] = {{{0xE0DAFB5FL,(-7L),(-7L)},{0x6966D37CL,(-7L),0xDF1FC2D9L}},{{(-1L),(-7L),0L},{0xE0DAFB5FL,(-7L),(-7L)}},{{0x6966D37CL,(-7L),0xDF1FC2D9L},{(-1L),(-7L),0L}},{{0xE0DAFB5FL,(-7L),(-7L)},{0x6966D37CL,(-7L),0xDF1FC2D9L}},{{(-1L),(-7L),0L},{0xE0DAFB5FL,(-7L),(-7L)}},{{0x6966D37CL,(-7L),0xDF1FC2D9L},{(-1L),(-7L),0L}},{{0xE0DAFB5FL,(-7L),(-7L)},{0x6966D37CL,(-7L),0xDF1FC2D9L}},{{(-1L),(-7L),0L},{0xE0DAFB5FL,(-7L),(-7L)}}};
+ int16_t l_1715 = 9L;
+ int32_t l_1716 = (-1L);
+ uint32_t l_1717 = 1UL;
+ int32_t *l_1720[4] = {&l_1714,&l_1714,&l_1714,&l_1714};
+ int i, j, k;
+ for (i = 0; i < 1; i++)
+ l_1712[i] = 0x31D00C21L;
+ for (g_775 = 0; g_775 < 9; g_775 += 1)
+ {
+ g_69[g_775] = 0xA232L;
+ }
+ ++l_1717;
+ l_1720[1] = &l_1713[7][0][1];
+ for (l_1715 = 9; (l_1715 <= 15); l_1715++)
+ { /* block id: 878 */
+ uint32_t l_1725[1][2][1];
+ int32_t *l_1743 = (void*)0;
+ int32_t l_1757[2][8][6] = {{{0x49E5A31AL,0xA31FA484L,2L,0L,0x8FADFB52L,0xC791BA3CL},{0xC791BA3CL,0L,0xFCCBC020L,0L,2L,0x49E5A31AL},{2L,0x8FADFB52L,0xA71F3D56L,1L,0xC791BA3CL,0xC791BA3CL},{0x8FADFB52L,0x46E5F6F7L,0x46E5F6F7L,0x8FADFB52L,0xA31FA484L,0xC791BA3CL},{0xFCCBC020L,0xC791BA3CL,0xA71F3D56L,0x49E5A31AL,1L,0x49E5A31AL},{0xA31FA484L,0L,0xA31FA484L,0L,1L,2L},{0xA71F3D56L,0xC791BA3CL,0xFCCBC020L,0xA31FA484L,0xA31FA484L,0xFCCBC020L},{0x46E5F6F7L,0x46E5F6F7L,0x8FADFB52L,0xA31FA484L,0xC791BA3CL,0L}},{{0xA71F3D56L,0x8FADFB52L,2L,0L,2L,0x8FADFB52L},{0xA31FA484L,0xA71F3D56L,2L,0x49E5A31AL,0x46E5F6F7L,0L},{0xFCCBC020L,0x49E5A31AL,0x8FADFB52L,0x8FADFB52L,0x49E5A31AL,0xFCCBC020L},{0x8FADFB52L,0x49E5A31AL,0xFCCBC020L,1L,0x46E5F6F7L,2L},{2L,0xA71F3D56L,0xA31FA484L,0xA71F3D56L,2L,0x49E5A31AL},{2L,0x8FADFB52L,0xA71F3D56L,1L,0xC791BA3CL,0xC791BA3CL},{0x8FADFB52L,0x46E5F6F7L,0x46E5F6F7L,0x8FADFB52L,0xA31FA484L,0xC791BA3CL},{0xFCCBC020L,0xC791BA3CL,0xA71F3D56L,0x49E5A31AL,1L,0x49E5A31AL}}};
+ int i, j, k;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
+ for (k = 0; k < 1; k++)
+ l_1725[i][j][k] = 9UL;
+ }
+ }
+ (*g_514) |= p_47;
+ if ((((!(((((!(*g_434)) & (g_59[1] & p_46)) & (l_1725[0][0][0] > (safe_mul_func_int16_t_s_s((safe_mod_func_uint16_t_u_u(0x764CL, (safe_mul_func_int16_t_s_s(((g_1250 == (safe_mul_func_int8_t_s_s(p_45, (((((safe_div_func_int32_t_s_s((safe_lshift_func_uint16_t_u_u(1UL, (~(safe_add_func_uint32_t_u_u((&g_455 == &g_455), p_46))))), p_48)) , 0x19E31692L) ^ 0L) != 0L) || (*g_434))))) && p_47), 65529UL)))), l_1742[6][3][3])))) & p_45) == g_360)) , 1UL) < 0x0FL))
+ { /* block id: 880 */
+ int32_t ***l_1751 = &l_1673[0];
+ int16_t *l_1754 = &l_1432;
+ int16_t *l_1756 = &g_775;
+ l_1744 = l_1743;
+ (*g_146) ^= (safe_lshift_func_int16_t_s_s((safe_mul_func_int16_t_s_s(p_46, (safe_sub_func_int8_t_s_s((((*l_1071) != l_1751) <= (&g_435 != (void*)0)), 0UL)))), (safe_lshift_func_int16_t_s_u(((((*l_1754) = ((void*)0 == &g_658[0])) | ((*l_1756) ^= ((p_45 , p_45) | l_1755))) < (***l_1751)), p_45))));
+ }
+ else
+ { /* block id: 885 */
+ l_827 = &l_857[1];
+ g_1758[3][0][1]++;
+ g_514 = &g_61;
+ }
+ for (p_47 = 2; (p_47 > 57); p_47 = safe_add_func_int32_t_s_s(p_47, 2))
+ { /* block id: 892 */
+ int8_t l_1763 = (-7L);
+ int32_t l_1764 = 1L;
+ (*g_146) &= 1L;
+ --l_1765;
+ if (p_47)
+ break;
+ return &g_514;
+ }
+ }
+ }
+ else
+ { /* block id: 899 */
+ int8_t l_1789 = (-1L);
+ for (l_1249 = 18; (l_1249 <= 9); l_1249 = safe_sub_func_int8_t_s_s(l_1249, 1))
+ { /* block id: 902 */
+ (*g_514) |= ((safe_mod_func_int16_t_s_s(p_45, 0xDE63L)) > (safe_mod_func_uint8_t_u_u(((g_775 , (safe_sub_func_uint16_t_u_u(l_1776, (!((safe_mul_func_int8_t_s_s(p_46, ((safe_mod_func_int16_t_s_s((((p_45 <= ((safe_mod_func_int8_t_s_s((safe_mod_func_int16_t_s_s((((g_145 | p_45) & ((safe_sub_func_uint8_t_u_u(((*l_1579) ^= ((safe_sub_func_int16_t_s_s((l_1789 ^ 0L), p_47)) , p_46)), 0xA2L)) > 0xD456L)) && l_1790), 0x2067L)), 0xCDL)) ^ p_47)) | p_46) == l_1789), (*g_713))) || 0xB4L))) < 3L))))) ^ 0xD0L), l_1791)));
+ }
+ }
+ for (l_858 = 0; l_858 < 8; l_858 += 1)
+ {
+ for (l_1790 = 0; l_1790 < 4; l_1790 += 1)
+ {
+ for (g_775 = 0; g_775 < 5; g_775 += 1)
+ {
+ l_1742[l_858][l_1790][g_775] = 0x47264078L;
+ }
+ }
+ }
+ }
+ }
+ return (*l_824);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_434 g_138 g_436 g_408 g_31 g_59 g_146 g_60 g_69 g_2 g_360 g_36 g_514 g_37 g_124 g_415 g_658 g_126 g_61 g_713 g_454 g_455 g_358 g_510
+ * writes: g_360 g_37 g_510 g_436 g_145 g_415 g_69 g_59 g_60 g_131 g_31 g_138 g_658 g_712 g_659 g_455
+ */
+static uint32_t func_49(uint16_t p_50, int32_t ** const p_51, int32_t p_52, int8_t p_53, uint8_t p_54)
+{ /* block id: 265 */
+ int32_t *l_540 = (void*)0;
+ int32_t l_551 = 0x82C03D9FL;
+ int32_t l_555 = (-1L);
+ int32_t l_557 = 0xD8A38C6FL;
+ int32_t ***l_583[5] = {&g_455,&g_455,&g_455,&g_455,&g_455};
+ uint32_t l_633 = 18446744073709551609UL;
+ const uint32_t l_656 = 0x411EFF5AL;
+ uint16_t *l_710 = &g_69[4];
+ uint16_t **l_709 = &l_710;
+ int i;
+lbl_539:
+ for (g_360 = 1; (g_360 >= 0); g_360 -= 1)
+ { /* block id: 268 */
+ int32_t *l_534 = &g_59[5];
+ (*p_51) = l_534;
+ for (g_510 = 0; (g_510 <= 1); g_510 += 1)
+ { /* block id: 272 */
+ return (*g_434);
+ }
+ }
+ for (g_436 = 25; (g_436 > 44); g_436 = safe_add_func_uint8_t_u_u(g_436, 5))
+ { /* block id: 278 */
+ const uint16_t *l_541 = &g_69[7];
+ int32_t l_546 = 6L;
+ int8_t *l_547 = &g_415;
+ int32_t l_552 = 0xFCB77EC7L;
+ int32_t l_553 = 0x0A279ABBL;
+ int32_t l_554 = 0x31D6845EL;
+ int32_t l_556 = 0xC2775E94L;
+ int32_t l_558 = 2L;
+ int32_t l_559 = 0xB7C1040AL;
+ int32_t ***l_581[10] = {&g_455,&g_455,&g_455,&g_455,&g_455,&g_455,&g_455,&g_455,&g_455,&g_455};
+ uint32_t l_616 = 0x0D85AE67L;
+ int32_t l_635[10] = {0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L,0x7AF0BAD7L};
+ uint16_t l_664 = 1UL;
+ int16_t l_734 = 0xCC65L;
+ uint32_t l_735 = 0x14DBAF86L;
+ int i;
+ for (g_145 = 0; (g_145 > 47); g_145 = safe_add_func_uint16_t_u_u(g_145, 4))
+ { /* block id: 281 */
+ if (g_436)
+ goto lbl_539;
+ }
+ (*p_51) = l_540;
+ if ((((void*)0 != l_541) != (safe_rshift_func_int16_t_s_u((((!(safe_lshift_func_int8_t_s_s(((*l_547) = l_546), 7))) ^ g_408[4][8]) ^ 0x8BL), 4))))
+ { /* block id: 286 */
+ int32_t *l_550[10] = {&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3],&g_60[0][4][3]};
+ uint8_t l_560 = 0UL;
+ uint16_t *l_567 = &g_145;
+ uint16_t *l_576 = &g_69[7];
+ int32_t ****l_582[10][1];
+ uint32_t l_615 = 0x6C53EE8BL;
+ int32_t l_638 = (-8L);
+ int i, j;
+ for (i = 0; i < 10; i++)
+ {
+ for (j = 0; j < 1; j++)
+ l_582[i][j] = (void*)0;
+ }
+ for (g_360 = 0; (g_360 != (-29)); g_360 = safe_sub_func_uint16_t_u_u(g_360, 8))
+ { /* block id: 289 */
+ return (*g_434);
+ }
+ --l_560;
+ if ((safe_sub_func_uint8_t_u_u((safe_lshift_func_uint16_t_u_u((((*l_567) = g_138[3]) <= (l_552 ^ (safe_mod_func_uint16_t_u_u(((*l_576) = (safe_mul_func_uint8_t_u_u((safe_add_func_int8_t_s_s(g_31[0], 8L)), (l_546 = (safe_add_func_uint32_t_u_u(p_50, (*g_434))))))), ((((safe_add_func_int16_t_s_s((p_54 , (safe_sub_func_int8_t_s_s(((l_583[4] = l_581[2]) != l_581[2]), p_52))), g_59[1])) | (*g_146)) & p_54) & (-6L)))))), g_408[2][6])), (-5L))))
+ { /* block id: 297 */
+ uint32_t l_603[3];
+ int32_t *l_617 = (void*)0;
+ int i;
+ for (i = 0; i < 3; i++)
+ l_603[i] = 0x9414E551L;
+ for (g_510 = 9; (g_510 >= 0); g_510 -= 1)
+ { /* block id: 300 */
+ const uint8_t l_602 = 0UL;
+ uint8_t l_604 = 255UL;
+ int32_t l_605 = (-1L);
+ for (l_560 = 0; (l_560 <= 9); l_560 += 1)
+ { /* block id: 303 */
+ int i;
+ l_605 = (((((((((safe_div_func_uint8_t_u_u((safe_sub_func_uint16_t_u_u(p_50, ((*g_146) && (l_603[2] ^= ((((((((p_53 , (safe_mod_func_uint32_t_u_u((&l_541 == (void*)0), (+((p_54 || ((safe_lshift_func_int8_t_s_u((safe_add_func_uint32_t_u_u((g_69[5] | ((*l_547) = 0x37L)), (safe_rshift_func_uint16_t_u_u((safe_rshift_func_int16_t_s_s((((safe_mod_func_uint8_t_u_u((safe_div_func_int8_t_s_s((((!((((4294967287UL > p_53) | g_59[1]) & 8UL) <= 0L)) ^ p_54) == p_53), p_52)), p_54)) | p_54) && (-1L)), 9)), g_138[3])))), g_2)) ^ 255UL)) >= l_602))))) & (*g_146)) > (*g_146)) , g_436) && 0xCBL) == p_50) == (-2L)) >= 65533UL))))), (-10L))) & g_60[0][4][3]) , l_602) || l_603[2]) || l_603[2]) >= l_604) > g_360) >= g_436) >= g_36);
+ (*g_146) = ((0x1D37402DL || (*g_514)) , ((*g_514) = p_54));
+ (*g_514) = (*g_514);
+ }
+ (*p_51) = (*p_51);
+ }
+ if (p_50)
+ { /* block id: 313 */
+ return (*g_434);
+ }
+ else
+ { /* block id: 315 */
+ uint32_t l_608 = 0x2C838B9FL;
+ uint8_t l_612 = 0xA6L;
+ for (l_546 = 22; (l_546 <= 12); l_546 = safe_sub_func_int8_t_s_s(l_546, 8))
+ { /* block id: 318 */
+ uint8_t l_609 = 0UL;
+ if (l_608)
+ break;
+ --l_609;
+ }
+ p_52 |= l_608;
+ (*g_514) ^= l_612;
+ for (l_559 = 0; (l_559 < (-28)); l_559 = safe_sub_func_uint16_t_u_u(l_559, 7))
+ { /* block id: 326 */
+ (*g_146) &= l_615;
+ (*g_514) &= (p_52 , l_616);
+ if (l_603[2])
+ continue;
+ (*p_51) = l_617;
+ }
+ }
+ if ((*g_514))
+ break;
+ }
+ else
+ { /* block id: 334 */
+ uint32_t l_637 = 0UL;
+ uint32_t l_657 = 0x8AE57ECFL;
+ (*g_146) &= (&g_436 == (void*)0);
+ for (g_131 = 0; (g_131 < 17); g_131 = safe_add_func_uint32_t_u_u(g_131, 4))
+ { /* block id: 338 */
+ uint32_t l_623 = 0x5CA092ADL;
+ for (l_554 = (-7); (l_554 == (-20)); l_554--)
+ { /* block id: 341 */
+ int16_t l_622 = 0L;
+ l_623++;
+ if ((*g_146))
+ continue;
+ }
+ for (l_559 = 0; (l_559 <= 8); l_559 += 1)
+ { /* block id: 347 */
+ const int32_t *l_632 = &g_61;
+ int32_t *l_634[7];
+ int32_t **** const l_636 = &l_583[4];
+ int i;
+ for (i = 0; i < 7; i++)
+ l_634[i] = (void*)0;
+ l_638 |= (((safe_div_func_int32_t_s_s((((safe_sub_func_uint32_t_u_u((safe_mul_func_int16_t_s_s((g_59[l_559] <= ((*l_567) = ((*l_576) &= (l_632 != ((l_633 &= (*g_146)) , l_634[4]))))), 7UL)), (*g_434))) , ((g_124 , l_635[4]) , l_636)) != l_582[7][0]), (*g_434))) == 0x07D52D4DL) > l_637);
+ p_52 &= 0xA782E568L;
+ }
+ }
+ for (l_616 = 0; (l_616 == 29); ++l_616)
+ { /* block id: 357 */
+ uint32_t l_653 = 18446744073709551615UL;
+ int32_t *l_654[7][5] = {{&l_546,(void*)0,&l_557,&g_61,&l_555},{&g_60[0][0][2],(void*)0,&l_558,&l_559,&g_59[1]},{(void*)0,&l_559,&l_556,&g_60[1][0][2],&g_60[1][0][2]},{&g_60[0][0][2],&l_557,&g_60[0][0][2],&l_556,&l_551},{&l_546,&l_557,&g_59[1],(void*)0,(void*)0},{(void*)0,&l_559,&g_60[1][0][2],&l_558,&l_546},{&l_555,(void*)0,&g_59[1],(void*)0,&l_555}};
+ uint8_t *l_655 = &g_31[0];
+ uint8_t ***l_660 = (void*)0;
+ uint8_t ***l_661 = &g_658[3];
+ int i, j;
+ p_52 = (((*l_661) = ((safe_div_func_uint32_t_u_u((l_657 = ((*g_434) = (((*g_514) = (l_637 | 0UL)) || (safe_mul_func_int16_t_s_s((g_408[4][2] ^ p_53), (safe_mod_func_uint32_t_u_u(((safe_mul_func_int8_t_s_s((!(safe_sub_func_uint8_t_u_u(g_415, (((*l_655) = ((safe_mul_func_uint16_t_u_u(((0xE3L != ((((0UL & ((l_653 ^ (((*g_434) & (*g_514)) , 0xDF15A246L)) ^ 0x1573C95DL)) > 0L) , l_654[2][0]) != (void*)0)) , 0x53B7L), p_53)) >= 0xAB7CL)) & g_59[7])))), 248UL)) , p_53), l_656))))))), l_637)) , g_658[3])) != (void*)0);
+ (*p_51) = (*p_51);
+ if (p_53)
+ continue;
+ for (l_553 = (-15); (l_553 < 21); l_553++)
+ { /* block id: 368 */
+ (*g_514) = ((*g_146) |= (*g_514));
+ l_664--;
+ return (*g_434);
+ }
+ }
+ }
+ for (g_145 = 24; (g_145 != 26); ++g_145)
+ { /* block id: 378 */
+ int32_t l_671 = (-3L);
+ for (p_50 = 1; (p_50 <= 5); p_50 += 1)
+ { /* block id: 381 */
+ int16_t *l_682[10] = {&g_124,&g_124,&g_124,&g_124,&g_124,&g_124,&g_124,&g_124,&g_124,&g_124};
+ int32_t l_683 = 6L;
+ uint8_t *l_696[3][10] = {{&g_131,&g_131,&l_560,&g_31[0],&g_31[0],&g_31[0],&l_560,&g_131,&g_131,&l_560},{&l_560,&g_31[0],&g_31[0],&g_31[0],&g_31[0],&l_560,&l_560,&l_560,&g_31[0],&g_31[0]},{&g_31[0],&g_131,&g_31[0],&g_31[0],&l_560,&g_131,&l_560,&g_31[0],&g_31[0],&g_31[0]}};
+ int32_t l_705 = 0x94593FD2L;
+ int i, j;
+ if ((*g_514))
+ break;
+ (*g_514) = ((((+(safe_add_func_uint8_t_u_u(p_50, l_671))) , ((((g_408[2][6] , (safe_div_func_uint16_t_u_u(0UL, ((((safe_rshift_func_int8_t_s_u(((safe_rshift_func_uint8_t_u_s((2L > (((((safe_rshift_func_int8_t_s_s((((safe_div_func_uint16_t_u_u(p_53, (l_683 = g_124))) && (safe_mod_func_uint16_t_u_u((safe_mul_func_int8_t_s_s((safe_lshift_func_uint16_t_u_u((safe_lshift_func_int16_t_s_u((safe_sub_func_uint8_t_u_u((safe_add_func_int8_t_s_s(((p_52 > (++p_54)) > ((safe_sub_func_int8_t_s_s((((safe_mul_func_uint16_t_u_u((safe_lshift_func_int16_t_s_u((&g_659 == &l_696[1][4]), p_52)), 0x415CL)) , (void*)0) != &l_560), (-1L))) , g_126)), p_52)), 0x83L)), 9)), 1)), p_50)), g_415))) == 4L), p_50)) , (-1L)) , 4294967289UL) >= (*g_434)) & 0x9D18L)), l_671)) > p_53), 7)) == 0x15L) != l_705) || (*g_434))))) >= l_671) & p_50) | g_61)) != p_50) == p_50);
+ if (l_671)
+ break;
+ }
+ }
+ }
+ else
+ { /* block id: 389 */
+ uint16_t **l_711 = (void*)0;
+ int32_t l_714 = (-2L);
+ int32_t l_718[1][4];
+ int32_t l_733 = (-1L);
+ const int16_t *l_768 = &g_124;
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 4; j++)
+ l_718[i][j] = 0xE11A78C6L;
+ }
+ for (l_556 = 0; (l_556 >= (-25)); --l_556)
+ { /* block id: 392 */
+ uint8_t l_708 = 254UL;
+ for (g_510 = 0; (g_510 <= 4); g_510 += 1)
+ { /* block id: 395 */
+ int i;
+ if (l_708)
+ break;
+ (*g_514) = l_708;
+ }
+ l_718[0][1] &= (l_708 >= (((g_126 < (l_709 == (g_712 = l_711))) && (((*g_434) = (l_714 != (safe_unary_minus_func_int32_t_s(((*g_514) = (((*g_514) >= (safe_mod_func_int16_t_s_s(g_59[1], g_60[0][0][1]))) != ((((p_53 < (*g_434)) ^ p_50) >= 0xE6L) == 0x38L))))))) , p_50)) == (*g_146)));
+ if (l_718[0][1])
+ break;
+ if ((*g_146))
+ break;
+ }
+ for (l_558 = 25; (l_558 != 20); l_558 = safe_sub_func_uint32_t_u_u(l_558, 9))
+ { /* block id: 408 */
+ int8_t ***l_725 = &g_435;
+ int32_t l_738 = 9L;
+ uint32_t l_746 = 1UL;
+ if ((*g_146))
+ { /* block id: 409 */
+ uint32_t l_745[5] = {0UL,0UL,0UL,0UL,0UL};
+ int i;
+ for (l_664 = 3; (l_664 <= 9); l_664 += 1)
+ { /* block id: 412 */
+ int8_t ***l_726 = &g_435;
+ int32_t l_727[7][7][5] = {{{1L,1L,(-8L),0L,0xAC6AC439L},{0xE288136EL,0x1BA38A8AL,1L,(-1L),(-1L)},{1L,0xB996CF60L,0xBC9EBEC7L,0L,0xBC9EBEC7L},{0x1BA38A8AL,0x1BA38A8AL,0L,0x47413CE9L,(-1L)},{0xB996CF60L,1L,0xBC9EBEC7L,0xA7A60C50L,0xAC6AC439L},{0x1BA38A8AL,0xE288136EL,1L,0x47413CE9L,1L},{1L,1L,(-8L),0L,0xAC6AC439L}},{{0xE288136EL,0x1BA38A8AL,1L,(-1L),(-1L)},{1L,0xB996CF60L,0xBC9EBEC7L,0L,0xBC9EBEC7L},{0x1BA38A8AL,0x1BA38A8AL,0L,0x47413CE9L,(-1L)},{0xB996CF60L,1L,0xBC9EBEC7L,0xA7A60C50L,0xAC6AC439L},{0x1BA38A8AL,0xE288136EL,1L,0x47413CE9L,1L},{1L,1L,(-8L),0L,0xAC6AC439L},{0xE288136EL,0x1BA38A8AL,1L,(-1L),(-1L)}},{{1L,0xB996CF60L,0xBC9EBEC7L,0L,0xBC9EBEC7L},{0x1BA38A8AL,0x1BA38A8AL,0L,0x47413CE9L,(-1L)},{0xB996CF60L,1L,0xBC9EBEC7L,0xA7A60C50L,0xAC6AC439L},{0x1BA38A8AL,0xE288136EL,1L,0x47413CE9L,1L},{1L,1L,(-8L),0L,0xAC6AC439L},{0xE288136EL,0x1BA38A8AL,1L,(-1L),(-1L)},{1L,0xB996CF60L,0xBC9EBEC7L,0L,0xBC9EBEC7L}},{{0x1BA38A8AL,0x1BA38A8AL,0L,0x47413CE9L,(-1L)},{0xB996CF60L,1L,0xBC9EBEC7L,0xA7A60C50L,0xAC6AC439L},{0x1BA38A8AL,0xE288136EL,1L,0x47413CE9L,1L},{1L,1L,(-8L),0L,0xAC6AC439L},{0xE288136EL,0x1BA38A8AL,1L,(-1L),(-1L)},{1L,0xB996CF60L,0xBC9EBEC7L,0L,0xBC9EBEC7L},{0x1BA38A8AL,0x1BA38A8AL,0L,0x47413CE9L,(-1L)}},{{0xB996CF60L,1L,0xBC9EBEC7L,0xA7A60C50L,0xAC6AC439L},{0x1BA38A8AL,0xE288136EL,1L,0x47413CE9L,1L},{1L,1L,(-8L),0L,0xAC6AC439L},{0xE288136EL,0x1BA38A8AL,1L,(-1L),(-1L)},{1L,0xB996CF60L,0xBC9EBEC7L,0L,0xBC9EBEC7L},{0x1BA38A8AL,0x1BA38A8AL,0L,0x47413CE9L,(-1L)},{0xB996CF60L,1L,0xBC9EBEC7L,0xA7A60C50L,0xAC6AC439L}},{{0x1BA38A8AL,0xE288136EL,1L,0x47413CE9L,1L},{0xBC9EBEC7L,0xBC9EBEC7L,0xBF005C69L,1L,2L},{0L,1L,0L,1L,0L},{0xBC9EBEC7L,(-8L),0L,1L,0L},{1L,1L,0x29987E69L,(-2L),0L},{(-8L),0xBC9EBEC7L,0L,0xAA4F085EL,2L},{1L,0L,0L,(-2L),0L}},{{0xBC9EBEC7L,0xBC9EBEC7L,0xBF005C69L,1L,2L},{0L,1L,0L,1L,0L},{0xBC9EBEC7L,(-8L),0L,1L,0L},{1L,1L,0x29987E69L,(-2L),0L},{(-8L),0xBC9EBEC7L,0L,0xAA4F085EL,2L},{1L,0L,0L,(-2L),0L},{0xBC9EBEC7L,0xBC9EBEC7L,0xBF005C69L,1L,2L}}};
+ uint8_t **l_732 = &g_659;
+ uint8_t *l_736 = &g_31[0];
+ int16_t *l_737[7][10][3] = {{{&g_124,(void*)0,&l_734},{(void*)0,&g_124,(void*)0},{&g_124,&g_124,&l_734},{&g_124,&g_124,&l_734},{&g_124,&g_124,&l_734},{&g_124,&g_124,&l_734},{&l_734,(void*)0,(void*)0},{&g_124,(void*)0,&l_734},{&g_124,&g_124,&g_124},{&g_124,&l_734,&g_124}},{{(void*)0,(void*)0,&g_124},{&l_734,&g_124,(void*)0},{&l_734,&l_734,(void*)0},{&g_124,&l_734,&l_734},{&l_734,&g_124,&g_124},{&l_734,&l_734,&g_124},{(void*)0,(void*)0,&g_124},{&g_124,&g_124,(void*)0},{&g_124,&l_734,(void*)0},{&g_124,&l_734,&g_124}},{{&l_734,(void*)0,&l_734},{&g_124,&l_734,&g_124},{&g_124,&l_734,&g_124},{&g_124,(void*)0,&g_124},{&g_124,&l_734,(void*)0},{(void*)0,&l_734,&g_124},{&g_124,&g_124,&g_124},{(void*)0,(void*)0,&g_124},{&l_734,&l_734,&g_124},{&l_734,&g_124,&g_124}},{{&g_124,&l_734,&l_734},{&g_124,&l_734,&g_124},{&g_124,&g_124,&g_124},{&g_124,(void*)0,&g_124},{&g_124,&l_734,&g_124},{&l_734,&g_124,&g_124},{&l_734,(void*)0,(void*)0},{&l_734,(void*)0,&g_124},{(void*)0,&g_124,&g_124},{&g_124,&g_124,&g_124}},{{&g_124,&g_124,&l_734},{(void*)0,&g_124,&g_124},{&g_124,&g_124,&l_734},{&g_124,(void*)0,&g_124},{&l_734,&l_734,&l_734},{&g_124,(void*)0,&g_124},{(void*)0,(void*)0,&g_124},{&g_124,&l_734,&g_124},{&l_734,(void*)0,&g_124},{(void*)0,&l_734,(void*)0}},{{&l_734,(void*)0,&l_734},{&l_734,(void*)0,&g_124},{&l_734,&l_734,&l_734},{&l_734,(void*)0,&g_124},{&l_734,&g_124,(void*)0},{&g_124,&g_124,&l_734},{&l_734,&l_734,&l_734},{&l_734,&g_124,&l_734},{&g_124,&g_124,&l_734},{(void*)0,&g_124,(void*)0}},{{&l_734,&g_124,&g_124},{(void*)0,&g_124,&l_734},{&g_124,&g_124,&g_124},{&g_124,&l_734,&l_734},{&g_124,&g_124,(void*)0},{&g_124,&l_734,&g_124},{&l_734,&l_734,&g_124},{&g_124,&l_734,&g_124},{&g_124,(void*)0,&g_124},{&g_124,&l_734,&l_734}}};
+ int i, j, k;
+ (*p_51) = &l_718[0][1];
+ l_635[l_664] |= (safe_sub_func_int8_t_s_s(((+(*g_713)) <= (safe_rshift_func_uint16_t_u_s(((**p_51) ^ (l_725 == l_726)), (((*l_547) = p_53) != l_727[4][5][3])))), ((*l_736) = (safe_lshift_func_uint8_t_u_u(((p_54 ^ (safe_mod_func_uint16_t_u_u((((0x77L > (((*l_732) = ((l_718[0][3] , p_52) , (void*)0)) == &p_54)) || l_733) > l_727[4][5][3]), 0x2525L))) <= l_734), l_735)))));
+ l_746 ^= ((*g_146) = ((l_718[0][1] = 0x564EL) , ((l_738 || ((**l_709) |= 0xC3CCL)) < (safe_sub_func_uint16_t_u_u(p_50, (safe_add_func_uint16_t_u_u(((safe_add_func_int8_t_s_s(((*l_547) = p_53), (l_718[0][3] || ((l_745[0] < (((*g_454) = (*g_454)) != (void*)0)) & p_50)))) & l_745[3]), g_61)))))));
+ (**p_51) &= (0x54A292B6L > (p_54 & (g_358 , ((*l_736) = (~(safe_mul_func_uint16_t_u_u(p_50, 9UL)))))));
+ }
+ (*g_146) |= (safe_add_func_int32_t_s_s(((safe_add_func_int16_t_s_s(((void*)0 != &g_2), p_53)) | (safe_div_func_int16_t_s_s((safe_lshift_func_int8_t_s_u((p_54 , ((0x7874L == (safe_div_func_int16_t_s_s((((((p_50 >= ((safe_unary_minus_func_int16_t_s((safe_lshift_func_int8_t_s_u(((*l_547) = g_2), 5)))) | ((l_714 = (((safe_mod_func_int32_t_s_s((safe_add_func_int8_t_s_s(p_50, p_53)), (*g_514))) ^ 0UL) || p_54)) | 4294967295UL))) ^ (-1L)) != l_745[3]) , (*g_434)) , 0xF7FBL), 1L))) >= 1UL)), 6)), 0x7B0EL))), l_738));
+ }
+ else
+ { /* block id: 430 */
+ for (l_559 = 0; (l_559 < 25); l_559++)
+ { /* block id: 433 */
+ (*g_146) ^= ((g_126 , &l_734) != l_768);
+ (*p_51) = (*p_51);
+ }
+ }
+ for (p_54 = 0; (p_54 <= 24); p_54 = safe_add_func_int16_t_s_s(p_54, 4))
+ { /* block id: 440 */
+ uint16_t l_773[8][2] = {{0x9B95L,0x9F13L},{0xE64DL,0x9F13L},{0x9B95L,0x9F13L},{0xE64DL,0x9F13L},{0x9B95L,0x9F13L},{0xE64DL,0x9F13L},{0x9B95L,0x9F13L},{0xE64DL,0x9F13L}};
+ int i, j;
+ for (l_664 = 0; (l_664 >= 19); l_664 = safe_add_func_int16_t_s_s(l_664, 1))
+ { /* block id: 443 */
+ (*g_146) |= l_718[0][1];
+ }
+ (*g_146) = l_773[3][0];
+ }
+ }
+ }
+ }
+ return p_54;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_36 g_69 g_37 p_24 l_3153
+ * writes: g_36 g_59 g_60 g_61 g_69 g_37 p_24 l_3153
+ */
+static uint32_t func_57(int16_t p_58)
+{ /* block id: 15 */
+ int32_t *l_62 = &g_59[1];
+ int32_t l_67 = 3L;
+ int32_t l_91 = 0xC7F14991L;
+ int32_t l_92[8][8] = {{1L,0x1594A516L,6L,6L,0x1594A516L,1L,0x1594A516L,6L},{0x03B84D85L,0x1594A516L,0x03B84D85L,1L,1L,0x03B84D85L,0x1594A516L,0x03B84D85L},{0xC4F7295DL,1L,6L,1L,0xC4F7295DL,0xC4F7295DL,1L,6L},{0xC4F7295DL,0xC4F7295DL,1L,6L,1L,0xC4F7295DL,0xC4F7295DL,1L},{0x03B84D85L,1L,1L,0x03B84D85L,0x1594A516L,0x03B84D85L,1L,1L},{1L,0x1594A516L,6L,6L,0x1594A516L,1L,0x1594A516L,6L},{0x03B84D85L,0x1594A516L,0x03B84D85L,1L,1L,0x03B84D85L,0x1594A516L,0x03B84D85L},{0xC4F7295DL,1L,6L,1L,0xC4F7295DL,0xC4F7295DL,1L,6L}};
+ int32_t l_94 = (-7L);
+ uint8_t l_95 = 0x96L;
+ int32_t **l_100 = (void*)0;
+ uint8_t *l_177 = &g_31[0];
+ const int32_t l_181 = 0xD7EB5230L;
+ uint16_t l_218 = 0x8B7BL;
+ int8_t l_219 = 0xA8L;
+ const uint8_t l_274 = 3UL;
+ int32_t **l_302 = &g_37;
+ uint8_t l_356 = 1UL;
+ const int8_t l_406 = 1L;
+ int32_t *l_438[5] = {&l_94,&l_94,&l_94,&l_94,&l_94};
+ uint16_t *l_457 = &l_218;
+ const int8_t *l_484[6] = {&l_406,&l_406,&l_406,&l_406,&l_406,&l_406};
+ const int8_t **l_483 = &l_484[2];
+ uint8_t l_492 = 0x16L;
+ int32_t l_513 = 0L;
+ uint32_t l_523 = 0x8A4C21B0L;
+ int i, j;
+ for (g_36 = 0; (g_36 <= 0); g_36 += 1)
+ { /* block id: 18 */
+ int32_t l_68 = 2L;
+ int32_t l_89 = 0x7EEACC20L;
+ int32_t l_93 = (-5L);
+ for (p_58 = 0; (p_58 <= 0); p_58 += 1)
+ { /* block id: 21 */
+ uint8_t l_72 = 255UL;
+ int32_t l_87 = 0x6EE5324EL;
+ int32_t l_88 = (-2L);
+ int32_t l_90 = 2L;
+ int32_t **l_98 = &g_37;
+ int32_t ***l_99[1][3];
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 3; j++)
+ l_99[i][j] = &l_98;
+ }
+ for (g_59[1] = 0; (g_59[1] <= 0); g_59[1] += 1)
+ { /* block id: 24 */
+ int8_t l_65 = 0xA8L;
+ int32_t l_66[10] = {0L,0L,0x855F075FL,0L,0L,0x855F075FL,0L,0L,0x855F075FL,0L};
+ int i;
+ for (g_60[0][4][3] = 0; (g_60[0][4][3] <= 0); g_60[0][4][3] += 1)
+ { /* block id: 27 */
+ int32_t *l_64[7];
+ int i;
+ for (i = 0; i < 7; i++)
+ l_64[i] = &g_61;
+ for (g_61 = 0; (g_61 >= 0); g_61 -= 1)
+ { /* block id: 30 */
+ int32_t **l_63 = &l_62;
+ (*l_63) = l_62;
+ }
+ ++g_69[6];
+ }
+ ++l_72;
+ for (l_68 = 0; (l_68 <= 0); l_68 += 1)
+ { /* block id: 38 */
+ int32_t *l_79 = &l_67;
+ int32_t *l_80 = &g_61;
+ int32_t *l_81 = &g_60[0][4][3];
+ int32_t *l_82 = &l_66[5];
+ int32_t *l_83 = (void*)0;
+ int32_t *l_84 = &l_67;
+ int32_t *l_85 = &g_60[0][4][3];
+ int32_t *l_86[2];
+ int i;
+ for (i = 0; i < 2; i++)
+ l_86[i] = &g_61;
+ (*l_79) |= (safe_sub_func_int32_t_s_s((safe_sub_func_int8_t_s_s(0xBDL, g_36)), ((*g_37) ^= ((p_58 > p_58) >= g_36))));
+ (*l_79) = 9L;
+ ++l_95;
+ }
+ }
+ l_100 = l_98;
+ for (l_94 = 0; (l_94 >= 0); l_94 -= 1)
+ { /* block id: 48 */
+ for (l_67 = 0; (l_67 <= 0); l_67 += 1)
+ { /* block id: 51 */
+ for (g_61 = 0; (g_61 <= 7); g_61 += 1)
+ { /* block id: 54 */
+ int i, j;
+ (*l_100) = &l_92[(l_94 + 3)][(g_36 + 5)];
+ }
+ }
+ if (p_58)
+ break;
+ }
+ }
+ }
+ for (l_95 = 0; (l_95 < 13); l_95 = safe_add_func_int8_t_s_s(l_95, 6))
+ { /* block id: 64 */
+ const int32_t l_122 = 0xE33F915BL;
+ int32_t * const l_132 = &g_60[0][4][3];
+ int32_t *l_133[9][4][6] = {{{(void*)0,&g_36,(void*)0,&l_92[2][7],(void*)0,&g_59[0]},{&g_36,&g_59[0],(void*)0,&l_92[6][7],&l_92[6][7],(void*)0},{&l_92[2][7],&l_92[2][7],&g_60[1][2][2],&l_92[6][7],&g_59[0],(void*)0},{&g_36,&g_60[1][2][2],&l_92[4][2],(void*)0,&l_92[4][2],&g_60[1][2][2]}},{{&l_92[6][7],&g_36,&l_92[4][2],(void*)0,&l_92[2][7],(void*)0},{(void*)0,(void*)0,&g_60[1][2][2],&g_60[1][2][2],(void*)0,(void*)0},{&g_60[1][2][2],(void*)0,(void*)0,&g_60[0][0][1],&l_92[2][7],&l_92[4][2]},{&l_92[4][2],&g_36,&l_92[6][7],&g_36,&l_92[4][2],(void*)0}},{{&l_92[4][2],&g_60[1][2][2],&g_36,&g_60[0][0][1],&g_59[0],&g_59[0]},{&g_60[1][2][2],&l_92[2][7],&l_92[2][7],&g_60[1][2][2],&l_92[6][7],&g_59[0]},{(void*)0,&g_59[0],&g_36,(void*)0,&g_60[0][0][1],(void*)0},{&l_92[6][7],(void*)0,&l_92[6][7],(void*)0,&g_60[0][0][1],&l_92[4][2]}},{{&g_36,&g_59[0],(void*)0,&l_92[6][7],&l_92[6][7],(void*)0},{&l_92[2][7],&l_92[2][7],&g_60[1][2][2],&l_92[6][7],&g_59[0],(void*)0},{&g_36,&g_60[1][2][2],&l_92[4][2],(void*)0,&l_92[4][2],&g_60[1][2][2]},{&l_92[6][7],&g_36,&l_92[4][2],(void*)0,&l_92[2][7],(void*)0}},{{(void*)0,(void*)0,&g_60[1][2][2],&g_60[1][2][2],(void*)0,(void*)0},{&g_60[1][2][2],(void*)0,(void*)0,&g_60[0][0][1],&l_92[2][7],&l_92[4][2]},{&l_92[4][2],&g_36,&l_92[6][7],&g_36,&l_92[4][2],(void*)0},{&l_92[4][2],&g_60[1][2][2],&g_36,&g_60[0][0][1],&g_59[0],&g_59[0]}},{{&g_60[1][2][2],&l_92[2][7],&l_92[2][7],&g_60[1][2][2],&l_92[6][7],&g_59[0]},{(void*)0,&g_59[0],&g_36,(void*)0,&g_60[0][0][1],(void*)0},{&l_92[6][7],(void*)0,&l_92[6][7],(void*)0,&g_60[0][0][1],&l_92[4][2]},{&g_36,&g_59[0],(void*)0,&l_92[6][7],&l_92[6][7],(void*)0}},{{&l_92[2][7],&l_92[2][7],&g_60[1][2][2],&l_92[6][7],&g_59[0],(void*)0},{&g_36,&g_60[1][2][2],&l_92[4][2],(void*)0,&l_92[4][2],&g_60[1][2][2]},{&l_92[6][7],&g_36,&l_92[4][2],(void*)0,&l_92[2][7],(void*)0},{(void*)0,(void*)0,&g_60[1][2][2],&g_60[1][2][2],(void*)0,(void*)0}},{{&g_60[1][2][2],(void*)0,(void*)0,&g_60[0][0][1],&l_92[2][7],&l_92[4][2]},{&l_92[4][2],&g_36,&l_92[6][7],&g_36,&l_92[4][2],(void*)0},{&l_92[4][2],&g_60[1][2][2],&g_36,&g_60[0][0][1],&g_59[0],&g_59[0]},{&g_60[1][2][2],&l_92[2][7],&l_92[2][7],&g_60[1][2][2],&l_92[6][7],&g_59[0]}},{{(void*)0,&g_59[0],&g_36,(void*)0,&g_59[0],&g_60[1][2][2]},{(void*)0,&g_60[0][0][1],(void*)0,&g_36,&g_59[0],(void*)0},{(void*)0,&l_92[4][2],&l_92[6][7],(void*)0,(void*)0,&l_92[6][7]},{(void*)0,(void*)0,&l_92[2][7],(void*)0,&l_92[4][2],&g_36}}};
+ int8_t *l_175[1][4];
+ int16_t l_217 = 0x3422L;
+ uint16_t *l_255 = &g_69[6];
+ int32_t * const **l_303[1];
+ uint32_t *l_407 = &g_408[2][6];
+ const int32_t *l_475 = (void*)0;
+ int8_t * const *l_511 = (void*)0;
+ int i, j, k;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 4; j++)
+ l_175[i][j] = &g_126;
+ }
+ for (i = 0; i < 1; i++)
+ l_303[i] = (void*)0;
+ }
+ return p_58;
+}
+
+
+
+
+/* ---------------------------------------- */
+int main (int argc, char* argv[])
+{
+ int i, j, k;
+ int print_hash_value = 0;
+ if (argc == 2 && strcmp(argv[1], "1") == 0) print_hash_value = 1;
+ platform_main_begin();
+ crc32_gentab();
+ func_1();
+ transparent_crc(g_2, "g_2", print_hash_value);
+ for (i = 0; i < 1; i++)
+ {
+ transparent_crc(g_31[i], "g_31[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_36, "g_36", print_hash_value);
+ for (i = 0; i < 9; i++)
+ {
+ transparent_crc(g_59[i], "g_59[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 5; j++)
+ {
+ for (k = 0; k < 4; k++)
+ {
+ transparent_crc(g_60[i][j][k], "g_60[i][j][k]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
+
+ }
+ }
+ }
+ transparent_crc(g_61, "g_61", print_hash_value);
+ for (i = 0; i < 9; i++)
+ {
+ transparent_crc(g_69[i], "g_69[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_124, "g_124", print_hash_value);
+ transparent_crc(g_126, "g_126", print_hash_value);
+ transparent_crc(g_131, "g_131", print_hash_value);
+ for (i = 0; i < 4; i++)
+ {
+ transparent_crc(g_138[i], "g_138[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_145, "g_145", print_hash_value);
+ transparent_crc(g_358, "g_358", print_hash_value);
+ transparent_crc(g_360, "g_360", print_hash_value);
+ for (i = 0; i < 6; i++)
+ {
+ for (j = 0; j < 10; j++)
+ {
+ transparent_crc(g_408[i][j], "g_408[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ transparent_crc(g_415, "g_415", print_hash_value);
+ transparent_crc(g_436, "g_436", print_hash_value);
+ transparent_crc(g_510, "g_510", print_hash_value);
+ transparent_crc(g_775, "g_775", print_hash_value);
+ transparent_crc(g_961, "g_961", print_hash_value);
+ for (i = 0; i < 1; i++)
+ {
+ transparent_crc(g_1096[i], "g_1096[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_1202, "g_1202", print_hash_value);
+ transparent_crc(g_1250, "g_1250", print_hash_value);
+ transparent_crc(g_1312, "g_1312", print_hash_value);
+ transparent_crc(g_1484, "g_1484", print_hash_value);
+ transparent_crc(g_1509, "g_1509", print_hash_value);
+ for (i = 0; i < 6; i++)
+ {
+ for (j = 0; j < 9; j++)
+ {
+ for (k = 0; k < 3; k++)
+ {
+ transparent_crc(g_1758[i][j][k], "g_1758[i][j][k]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
+
+ }
+ }
+ }
+ transparent_crc(g_1847, "g_1847", print_hash_value);
+ transparent_crc(g_1959, "g_1959", print_hash_value);
+ for (i = 0; i < 7; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ transparent_crc(g_2057[i][j], "g_2057[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ transparent_crc(g_2156, "g_2156", print_hash_value);
+ for (i = 0; i < 10; i++)
+ {
+ transparent_crc(g_2225[i], "g_2225[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_2234, "g_2234", print_hash_value);
+ transparent_crc(g_2236, "g_2236", print_hash_value);
+ transparent_crc(g_2239, "g_2239", print_hash_value);
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ transparent_crc(g_2387[i][j], "g_2387[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ transparent_crc(g_2451, "g_2451", print_hash_value);
+ transparent_crc(g_2907, "g_2907", print_hash_value);
+ transparent_crc(g_3051, "g_3051", print_hash_value);
+ for (i = 0; i < 10; i++)
+ {
+ transparent_crc(g_3207[i], "g_3207[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_3271, "g_3271", print_hash_value);
+ transparent_crc(g_3299, "g_3299", print_hash_value);
+ transparent_crc(g_3397, "g_3397", print_hash_value);
+ transparent_crc(g_3398, "g_3398", print_hash_value);
+ platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
+ return 0;
+}
+
+/************************ statistics *************************
+XXX max struct depth: 0
+breakdown:
+ depth: 0, occurrence: 805
+XXX total union variables: 0
+
+XXX non-zero bitfields defined in structs: 0
+XXX zero bitfields defined in structs: 0
+XXX const bitfields defined in structs: 0
+XXX volatile bitfields defined in structs: 0
+XXX structs with bitfields in the program: 0
+breakdown:
+XXX full-bitfields structs in the program: 0
+breakdown:
+XXX times a bitfields struct's address is taken: 0
+XXX times a bitfields struct on LHS: 0
+XXX times a bitfields struct on RHS: 0
+XXX times a single bitfield on LHS: 0
+XXX times a single bitfield on RHS: 0
+
+XXX max expression depth: 50
+breakdown:
+ depth: 1, occurrence: 386
+ depth: 2, occurrence: 129
+ depth: 3, occurrence: 4
+ depth: 4, occurrence: 6
+ depth: 5, occurrence: 3
+ depth: 6, occurrence: 2
+ depth: 8, occurrence: 1
+ depth: 9, occurrence: 1
+ depth: 14, occurrence: 2
+ depth: 15, occurrence: 2
+ depth: 16, occurrence: 2
+ depth: 17, occurrence: 5
+ depth: 18, occurrence: 6
+ depth: 19, occurrence: 4
+ depth: 20, occurrence: 5
+ depth: 21, occurrence: 5
+ depth: 22, occurrence: 2
+ depth: 23, occurrence: 6
+ depth: 24, occurrence: 1
+ depth: 25, occurrence: 5
+ depth: 26, occurrence: 4
+ depth: 27, occurrence: 3
+ depth: 28, occurrence: 3
+ depth: 30, occurrence: 3
+ depth: 31, occurrence: 6
+ depth: 32, occurrence: 1
+ depth: 35, occurrence: 2
+ depth: 36, occurrence: 2
+ depth: 38, occurrence: 2
+ depth: 39, occurrence: 1
+ depth: 40, occurrence: 1
+ depth: 42, occurrence: 2
+ depth: 43, occurrence: 1
+ depth: 46, occurrence: 1
+ depth: 47, occurrence: 1
+ depth: 50, occurrence: 1
+
+XXX total number of pointers: 604
+
+XXX times a variable address is taken: 1521
+XXX times a pointer is dereferenced on RHS: 568
+breakdown:
+ depth: 1, occurrence: 463
+ depth: 2, occurrence: 78
+ depth: 3, occurrence: 18
+ depth: 4, occurrence: 9
+XXX times a pointer is dereferenced on LHS: 494
+breakdown:
+ depth: 1, occurrence: 467
+ depth: 2, occurrence: 18
+ depth: 3, occurrence: 5
+ depth: 4, occurrence: 4
+XXX times a pointer is compared with null: 72
+XXX times a pointer is compared with address of another variable: 24
+XXX times a pointer is compared with another pointer: 23
+XXX times a pointer is qualified to be dereferenced: 11166
+
+XXX max dereference level: 6
+breakdown:
+ level: 0, occurrence: 0
+ level: 1, occurrence: 2371
+ level: 2, occurrence: 300
+ level: 3, occurrence: 264
+ level: 4, occurrence: 115
+ level: 5, occurrence: 8
+ level: 6, occurrence: 3
+XXX number of pointers point to pointers: 292
+XXX number of pointers point to scalars: 312
+XXX number of pointers point to structs: 0
+XXX percent of pointers has null in alias set: 29.3
+XXX average alias set size: 1.49
+
+XXX times a non-volatile is read: 3202
+XXX times a non-volatile is write: 1494
+XXX times a volatile is read: 0
+XXX times read thru a pointer: 0
+XXX times a volatile is write: 0
+XXX times written thru a pointer: 0
+XXX times a volatile is available for access: 0
+XXX percentage of non-volatile access: 100
+
+XXX forward jumps: 1
+XXX backward jumps: 9
+
+XXX stmts: 414
+XXX max block depth: 5
+breakdown:
+ depth: 0, occurrence: 32
+ depth: 1, occurrence: 35
+ depth: 2, occurrence: 65
+ depth: 3, occurrence: 80
+ depth: 4, occurrence: 95
+ depth: 5, occurrence: 107
+
+XXX percentage a fresh-made variable is used: 14.8
+XXX percentage an existing variable is used: 85.2
+********************* end of statistics **********************/
+
diff --git a/tests/fuzz/14.c.txt b/tests/fuzz/14.c.txt
new file mode 100644
index 00000000..118ce7dd
--- /dev/null
+++ b/tests/fuzz/14.c.txt
@@ -0,0 +1 @@
+523D07B9
diff --git a/tests/fuzz/16.c b/tests/fuzz/16.c
new file mode 100644
index 00000000..187a6c64
--- /dev/null
+++ b/tests/fuzz/16.c
@@ -0,0 +1,1317 @@
+/*
+ * This is a RANDOMLY GENERATED PROGRAM.
+ *
+ * Generator: csmith 2.2.0
+ * Git version: bf42ffd
+ * Options: --no-volatiles --no-math64 --no-packed-struct
+ * Seed: 599346178
+ */
+
+#include "csmith.h"
+
+
+static long __undefined;
+
+/* --- Struct/Union Declarations --- */
+struct S0 {
+ signed f0 : 15;
+ unsigned f1 : 8;
+ unsigned f2 : 10;
+ unsigned f3 : 14;
+};
+
+struct S1 {
+ uint16_t f0;
+ uint16_t f1;
+};
+
+struct S2 {
+ signed f0 : 3;
+ unsigned f1 : 27;
+ unsigned f2 : 29;
+ const unsigned f3 : 5;
+ unsigned f4 : 31;
+ int32_t f5;
+ unsigned f6 : 24;
+ signed f7 : 15;
+ signed f8 : 15;
+};
+
+struct S3 {
+ const signed f0 : 30;
+ const signed f1 : 5;
+ unsigned f2 : 21;
+ signed f3 : 8;
+ unsigned f4 : 7;
+ unsigned f5 : 30;
+ unsigned f6 : 14;
+ signed f7 : 11;
+ const signed f8 : 14;
+ unsigned f9 : 26;
+};
+
+struct S4 {
+ struct S3 f0;
+ const signed f1 : 26;
+};
+
+struct S5 {
+ uint16_t f0;
+ uint16_t f1;
+ const struct S3 f2;
+ int32_t f3;
+};
+
+/* --- GLOBAL VARIABLES --- */
+static struct S1 g_22 = {0x9E5FL,0xF1BEL};
+static uint8_t g_23 = 0xDFL;
+static struct S1 g_43[8][10][3] = {{{{65530UL,1UL},{1UL,0xEB2EL},{0x7628L,1UL}},{{0x3094L,0xC7A5L},{0x2614L,65527UL},{0xCBE0L,0x4EC4L}},{{65530UL,1UL},{0UL,0x894BL},{65530UL,0xE41CL}},{{0xA3A0L,0xB06FL},{1UL,0x7DC5L},{7UL,65535UL}},{{65530UL,0x5790L},{0xEF29L,65535UL},{65530UL,1UL}},{{65535UL,65535UL},{0x4FDBL,65535UL},{65534UL,0xCDD4L}},{{65530UL,0xE41CL},{0xEF29L,65535UL},{4UL,0xDB38L}},{{0xC793L,0x51EAL},{1UL,0x7DC5L},{65535UL,2UL}},{{0x2801L,1UL},{0UL,0x894BL},{0xEBE4L,1UL}},{{7UL,65535UL},{0x2614L,65527UL},{0xED68L,0xD092L}}},{{{0xEBE4L,1UL},{1UL,0xEB2EL},{0xEBE4L,1UL}},{{0x9622L,0UL},{0UL,0xFB19L},{65535UL,2UL}},{{0x4927L,8UL},{0x1B31L,1UL},{4UL,0xDB38L}},{{0xCBE0L,0x4EC4L},{0x980DL,0x298BL},{65534UL,0xCDD4L}},{{0xCC22L,0xCDAAL},{0x64E9L,3UL},{65530UL,1UL}},{{0xCBE0L,0x4EC4L},{65535UL,2UL},{1UL,6UL}},{{65528UL,65532UL},{65530UL,1UL},{4UL,0x44EEL}},{{0xFCBCL,1UL},{65527UL,0x159EL},{1UL,0x5F07L}},{{0UL,0xE035L},{0x2801L,1UL},{0x7F1FL,1UL}},{{1UL,6UL},{65527UL,0x159EL},{0xF3A5L,0x7C9EL}}},{{{0xDF6EL,0x0FB7L},{65530UL,1UL},{0x6A5CL,5UL}},{{0xB7CFL,65535UL},{65535UL,2UL},{65526UL,0xC961L}},{{4UL,0x44EEL},{0xCC22L,0xCDAAL},{0UL,0x5C63L}},{{65526UL,0xC961L},{0x9622L,0UL},{65526UL,0xC961L}},{{0x9A5AL,0xFD0BL},{0x459FL,0x79DDL},{0x6A5CL,5UL}},{{0x6F24L,1UL},{0xBE1DL,0UL},{0xF3A5L,0x7C9EL}},{{0xB77DL,0xD86EL},{65530UL,0x5790L},{0x7F1FL,1UL}},{{0x2E96L,65531UL},{0x3094L,0xC7A5L},{1UL,0x5F07L}},{{0xB77DL,0xD86EL},{0x167AL,65530UL},{4UL,0x44EEL}},{{0x6F24L,1UL},{0xCBE0L,0x4EC4L},{1UL,6UL}}},{{{0x9A5AL,0xFD0BL},{4UL,0xDB38L},{0xB77DL,0xD86EL}},{{65526UL,0xC961L},{0xC793L,0x51EAL},{0x0DAEL,65535UL}},{{4UL,0x44EEL},{4UL,0xDB38L},{65533UL,0xBBCAL}},{{0xB7CFL,65535UL},{0xCBE0L,0x4EC4L},{65535UL,65535UL}},{{0xDF6EL,0x0FB7L},{0x167AL,65530UL},{0UL,0xE035L}},{{1UL,6UL},{0x3094L,0xC7A5L},{0UL,0xF9ADL}},{{0UL,0xE035L},{65530UL,0x5790L},{0UL,0xE035L}},{{0xFCBCL,1UL},{0xBE1DL,0UL},{65535UL,65535UL}},{{65528UL,65532UL},{0x459FL,0x79DDL},{65533UL,0xBBCAL}},{{1UL,0x5F07L},{0x9622L,0UL},{0x0DAEL,65535UL}}},{{{65530UL,9UL},{0xCC22L,0xCDAAL},{0xB77DL,0xD86EL}},{{1UL,0x5F07L},{65535UL,2UL},{1UL,6UL}},{{65528UL,65532UL},{65530UL,1UL},{4UL,0x44EEL}},{{0xFCBCL,1UL},{65527UL,0x159EL},{1UL,0x5F07L}},{{0UL,0xE035L},{0x2801L,1UL},{0x7F1FL,1UL}},{{1UL,6UL},{65527UL,0x159EL},{0xF3A5L,0x7C9EL}},{{0xDF6EL,0x0FB7L},{65530UL,1UL},{0x6A5CL,5UL}},{{0xB7CFL,65535UL},{65535UL,2UL},{65526UL,0xC961L}},{{4UL,0x44EEL},{0xCC22L,0xCDAAL},{0UL,0x5C63L}},{{65526UL,0xC961L},{0x9622L,0UL},{65526UL,0xC961L}}},{{{0x9A5AL,0xFD0BL},{0x459FL,0x79DDL},{0x6A5CL,5UL}},{{0x6F24L,1UL},{0xBE1DL,0UL},{0xF3A5L,0x7C9EL}},{{0xB77DL,0xD86EL},{65530UL,0x5790L},{0x7F1FL,1UL}},{{0x2E96L,65531UL},{0x3094L,0xC7A5L},{1UL,0x5F07L}},{{0xB77DL,0xD86EL},{0x167AL,65530UL},{4UL,0x44EEL}},{{0x6F24L,1UL},{0xCBE0L,0x4EC4L},{1UL,6UL}},{{0x9A5AL,0xFD0BL},{4UL,0xDB38L},{0xB77DL,0xD86EL}},{{65526UL,0xC961L},{0xC793L,0x51EAL},{0x0DAEL,65535UL}},{{4UL,0x44EEL},{4UL,0xDB38L},{65533UL,0xBBCAL}},{{0xB7CFL,65535UL},{0xCBE0L,0x4EC4L},{65535UL,65535UL}}},{{{0xDF6EL,0x0FB7L},{0x167AL,65530UL},{0UL,0xE035L}},{{1UL,6UL},{0x3094L,0xC7A5L},{0UL,0xF9ADL}},{{0UL,0xE035L},{65530UL,0x5790L},{0UL,0xE035L}},{{0xFCBCL,1UL},{0xBE1DL,0UL},{65535UL,65535UL}},{{65528UL,65532UL},{0x459FL,0x79DDL},{65533UL,0xBBCAL}},{{1UL,0x5F07L},{0x9622L,0UL},{0x0DAEL,65535UL}},{{65530UL,9UL},{0xCC22L,0xCDAAL},{0xB77DL,0xD86EL}},{{1UL,0x5F07L},{65535UL,2UL},{1UL,6UL}},{{65528UL,65532UL},{65530UL,1UL},{4UL,0x44EEL}},{{0xFCBCL,1UL},{65527UL,0x159EL},{1UL,0x5F07L}}},{{{0UL,0xE035L},{0x2801L,1UL},{0x7F1FL,1UL}},{{1UL,6UL},{65527UL,0x159EL},{0xF3A5L,0x7C9EL}},{{0xDF6EL,0x0FB7L},{65530UL,1UL},{0x6A5CL,5UL}},{{0xB7CFL,65535UL},{65535UL,2UL},{65526UL,0xC961L}},{{4UL,0x44EEL},{0xCC22L,0xCDAAL},{0UL,0x5C63L}},{{65526UL,0xC961L},{0x9622L,0UL},{65526UL,0xC961L}},{{0x9A5AL,0xFD0BL},{0x459FL,0x79DDL},{0x6A5CL,5UL}},{{0x6F24L,1UL},{0xBE1DL,0UL},{0xF3A5L,0x7C9EL}},{{0xB77DL,0xD86EL},{65530UL,0x5790L},{0x7F1FL,1UL}},{{0x4FDBL,65535UL},{0x2E96L,65531UL},{0x1FCFL,65528UL}}}};
+static struct S1 *g_42 = &g_43[6][6][2];
+static struct S5 g_69 = {1UL,0x0ACFL,{8641,1,66,-9,5,16167,108,18,97,2292},-1L};
+static struct S5 *g_76 = (void*)0;
+static struct S5 **g_75 = &g_76;
+static int32_t g_84 = 1L;
+static uint32_t g_85 = 0xA7E1DD48L;
+static uint8_t g_94 = 0xAFL;
+static int16_t g_109 = 0x89DBL;
+static struct S3 g_111 = {25828,3,536,-9,6,32740,94,43,-66,805};
+static struct S3 g_113 = {19961,-2,968,11,6,26254,93,-34,-102,7793};
+static struct S3 *g_112 = &g_113;
+static uint32_t g_131 = 4294967295UL;
+static struct S4 g_138 = {{-26187,-2,1070,5,2,15692,110,-5,66,322},7315};
+static int32_t *g_151[9] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
+static struct S0 g_153 = {-53,3,7,82};
+static struct S3 g_182 = {-615,-4,889,-1,1,13978,113,20,74,1261};
+static int32_t g_214 = (-10L);
+static int8_t g_253 = 0xD8L;
+static const int8_t *g_252 = &g_253;
+static int16_t g_274 = 0xB1F5L;
+static uint32_t *g_346[10][3][5] = {{{&g_131,&g_131,&g_131,&g_131,(void*)0},{&g_131,&g_131,&g_131,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}},{{&g_131,&g_131,&g_131,&g_131,&g_131},{(void*)0,&g_131,&g_131,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}},{{&g_131,&g_131,&g_131,&g_131,&g_131},{&g_131,(void*)0,(void*)0,&g_131,&g_131},{(void*)0,&g_131,&g_131,&g_131,(void*)0}},{{&g_131,&g_131,&g_131,(void*)0,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}},{{&g_131,&g_131,&g_131,&g_131,(void*)0},{&g_131,&g_131,(void*)0,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}},{{&g_131,&g_131,(void*)0,&g_131,&g_131},{(void*)0,&g_131,&g_131,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}},{{&g_131,&g_131,&g_131,&g_131,&g_131},{&g_131,(void*)0,&g_131,&g_131,&g_131},{(void*)0,&g_131,&g_131,&g_131,(void*)0}},{{&g_131,&g_131,(void*)0,(void*)0,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}},{{&g_131,&g_131,&g_131,&g_131,(void*)0},{&g_131,&g_131,&g_131,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}},{{&g_131,&g_131,&g_131,&g_131,&g_131},{(void*)0,&g_131,&g_131,&g_131,&g_131},{&g_131,&g_131,&g_131,&g_131,&g_131}}};
+static uint32_t **g_345 = &g_346[0][2][2];
+static struct S2 g_349 = {-0,10399,13744,1,23366,0x73A13C76L,2460,-117,-63};
+static struct S2 *g_348 = &g_349;
+static struct S3 *g_352 = (void*)0;
+static struct S3 *g_355 = (void*)0;
+static struct S3 g_357 = {21505,3,625,-0,1,22557,91,-24,91,4258};
+static struct S3 *g_356 = &g_357;
+static uint32_t **g_401 = (void*)0;
+static uint32_t g_494[4] = {0xF410F1BCL,0xF410F1BCL,0xF410F1BCL,0xF410F1BCL};
+static struct S4 g_518[8] = {{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776},{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776},{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776},{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776},{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776},{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776},{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776},{{-7073,-1,1273,-8,2,4384,85,5,12,2244},-5776}};
+static struct S4 *g_517 = &g_518[1];
+static struct S4 g_521[5][2][4] = {{{{{11267,4,50,0,0,23117,4,21,-42,449},-4258},{{11267,4,50,0,0,23117,4,21,-42,449},-4258},{{9750,-2,1241,6,5,3993,72,-4,66,4292},-6475},{{-32497,-1,427,1,10,16937,126,28,46,2174},3226}},{{{-17361,-1,25,8,3,23008,28,17,26,6153},2330},{{9750,-2,1241,6,5,3993,72,-4,66,4292},-6475},{{-22579,4,416,8,10,18216,1,12,11,5405},-4220},{{26283,3,971,4,9,10669,69,-23,-39,3125},6498}}},{{{{16235,0,21,-9,0,24889,42,-32,104,5527},-1564},{{16645,-0,330,-13,7,14218,38,36,88,1244},-5752},{{11050,-0,1023,-12,5,13403,121,-44,-26,7622},-3567},{{-22579,4,416,8,10,18216,1,12,11,5405},-4220}},{{{-22579,4,416,8,10,18216,1,12,11,5405},-4220},{{16645,-0,330,-13,7,14218,38,36,88,1244},-5752},{{11267,4,50,0,0,23117,4,21,-42,449},-4258},{{26283,3,971,4,9,10669,69,-23,-39,3125},6498}}},{{{{-27039,0,1347,9,7,17637,27,0,-93,8164},-4957},{{21599,1,11,15,10,12835,80,-43,-115,622},1327},{{-27039,0,1347,9,7,17637,27,0,-93,8164},-4957},{{30649,1,566,-14,4,26449,55,-3,38,555},-4627}},{{{-2727,2,211,13,7,2544,112,-36,83,238},-7275},{{-22579,4,416,8,10,18216,1,12,11,5405},-4220},{{11050,-0,1023,-12,5,13403,121,-44,-26,7622},-3567},{{16645,-0,330,-13,7,14218,38,36,88,1244},-5752}}},{{{{-17361,-1,25,8,3,23008,28,17,26,6153},2330},{{-2727,2,211,13,7,2544,112,-36,83,238},-7275},{{30649,1,566,-14,4,26449,55,-3,38,555},-4627},{{-22579,4,416,8,10,18216,1,12,11,5405},-4220}},{{{18460,-2,1432,5,10,14352,80,32,86,7371},4860},{{-10379,4,1045,-7,10,6983,94,-28,-104,1529},2147},{{30649,1,566,-14,4,26449,55,-3,38,555},-4627},{{16235,0,21,-9,0,24889,42,-32,104,5527},-1564}}},{{{{-17361,-1,25,8,3,23008,28,17,26,6153},2330},{{11050,-0,1023,-12,5,13403,121,-44,-26,7622},-3567},{{11050,-0,1023,-12,5,13403,121,-44,-26,7622},-3567},{{-17361,-1,25,8,3,23008,28,17,26,6153},2330}},{{{-2727,2,211,13,7,2544,112,-36,83,238},-7275},{{18460,-2,1432,5,10,14352,80,32,86,7371},4860},{{-27039,0,1347,9,7,17637,27,0,-93,8164},-4957},{{11267,4,50,0,0,23117,4,21,-42,449},-4258}}}};
+static uint16_t g_599 = 0x3677L;
+static int32_t g_601[2][3] = {{(-3L),(-3L),(-3L)},{(-3L),(-3L),(-3L)}};
+static uint8_t g_745 = 0x79L;
+static struct S0 *g_750 = (void*)0;
+static struct S0 **g_749 = &g_750;
+static const int32_t g_763 = 0x2FF78294L;
+static const int32_t *g_762 = &g_763;
+static int8_t g_798 = 9L;
+static int8_t g_809 = 7L;
+static struct S4 g_903 = {{1711,1,1044,15,3,21405,47,3,-94,3477},1019};
+static uint16_t g_922[6] = {0xC1F3L,0xC1F3L,0xC1F3L,0xC1F3L,0xC1F3L,0xC1F3L};
+static const struct S4 g_1001 = {{-16006,-3,1349,8,5,30049,50,-3,125,3359},4405};
+static struct S5 g_1017 = {0x37CCL,0x3778L,{-20731,-3,745,-15,3,27561,18,-35,-28,3640},0x8265F5ECL};
+
+
+/* --- FORWARD DECLARATIONS --- */
+static int32_t func_1(void);
+static struct S1 func_2(struct S1 p_3, struct S4 p_4, struct S3 p_5, const struct S3 p_6, struct S5 p_7);
+static struct S1 func_8(uint32_t p_9, struct S0 p_10);
+static uint32_t func_11(const struct S2 p_12, const struct S5 p_13, uint8_t p_14, uint8_t p_15, struct S0 p_16);
+static const struct S2 func_17(struct S1 p_18, int32_t p_19);
+static uint32_t func_26(uint8_t p_27, uint8_t p_28, struct S1 * p_29, struct S1 * p_30, const struct S1 * p_31);
+static struct S0 func_47(struct S0 p_48, struct S1 * p_49, const uint16_t p_50, struct S2 p_51);
+static struct S0 func_52(struct S0 p_53, struct S1 * p_54, struct S1 * p_55, struct S1 * p_56, struct S1 p_57);
+static struct S0 func_58(int16_t p_59, int32_t p_60, struct S1 * p_61, uint16_t p_62, struct S1 * p_63);
+static struct S1 * func_64(struct S1 * const p_65, struct S1 * p_66, struct S1 * p_67);
+
+
+/* --- FUNCTIONS --- */
+/* ------------------------------------------ */
+/*
+ * reads : g_23 g_42 g_43.f0 g_75 g_94 g_85 g_69.f2.f7 g_84 g_69.f1 g_131 g_138 g_111.f5 g_111.f6 g_111.f3 g_153 g_113.f9 g_69.f2.f3 g_69.f2.f2 g_69.f2.f0 g_111.f1 g_43 g_113.f8 g_214 g_113.f3 g_252 g_253 g_69.f0 g_109 g_182.f9 g_113.f0 g_69.f3 g_345 g_113.f6 g_348 g_182.f0 g_113.f5 g_349.f0 g_111.f4 g_346 g_357.f9 g_111.f7 g_349 g_69.f2.f4 g_494 g_517 g_518 g_182.f8 g_274 g_599 g_69 g_1017 g_601 g_762 g_763 g_903.f0.f7 g_903.f0 g_22.f1 g_22.f0
+ * writes: g_22 g_43 g_69.f0 g_84 g_85 g_69.f1 g_94 g_109 g_112 g_131 g_151 g_214 g_274 g_348 g_352 g_355 g_356 g_345 g_401 g_253 g_76 g_349.f5 g_494 g_517 g_599 g_69.f3 g_153
+ */
+static int32_t func_1(void)
+{ /* block id: 0 */
+ struct S1 l_20[8] = {{0x097EL,0UL},{0x097EL,0UL},{1UL,1UL},{0x097EL,0UL},{0x097EL,0UL},{1UL,1UL},{0x097EL,0UL},{0x097EL,0UL}};
+ struct S1 *l_21[4] = {(void*)0,(void*)0,(void*)0,(void*)0};
+ const struct S5 l_25 = {65529UL,6UL,{15351,-3,1209,-9,2,27860,14,-8,-117,4412},4L};
+ struct S0 l_1069 = {-51,6,31,68};
+ struct S4 l_1075[1] = {{{-2640,-0,453,-5,8,18251,94,17,-33,5958},-3807}};
+ int i;
+ (*g_42) = func_2(((*g_42) = func_8((func_11(func_17((g_22 = l_20[5]), g_23), l_25, (func_26(g_23, ((safe_rshift_func_uint16_t_u_u((safe_lshift_func_int16_t_s_u(0xBB1EL, (((safe_rshift_func_uint16_t_u_s((safe_mod_func_uint8_t_u_u(l_25.f2.f6, (safe_add_func_uint8_t_u_u(l_25.f2.f0, (l_25.f2.f4 < g_23))))), g_23)) , g_23) , 6UL))), l_25.f2.f9)) | g_23), g_42, &g_43[3][5][0], &l_20[1]) >= 0UL), g_903.f0.f7, l_1069) >= 4294967295UL), l_1069)), l_1075[0], g_903.f0, g_1017.f2, g_1017);
+ return l_25.f2.f9;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_84 g_22.f1 g_94 g_22.f0 g_494 g_42 g_43
+ * writes: g_84 g_22.f1 g_94 g_22.f0
+ */
+static struct S1 func_2(struct S1 p_3, struct S4 p_4, struct S3 p_5, const struct S3 p_6, struct S5 p_7)
+{ /* block id: 578 */
+ const int8_t **l_1080 = &g_252;
+ for (g_84 = 8; (g_84 != (-5)); g_84 = safe_sub_func_int8_t_s_s(g_84, 7))
+ { /* block id: 581 */
+ for (g_22.f1 = 0; (g_22.f1 <= 22); g_22.f1 = safe_add_func_uint32_t_u_u(g_22.f1, 1))
+ { /* block id: 584 */
+ for (g_94 = 0; (g_94 <= 2); g_94 += 1)
+ { /* block id: 587 */
+ for (g_22.f0 = 2; (g_22.f0 <= 8); g_22.f0 += 1)
+ { /* block id: 590 */
+ int i;
+ if (g_494[(g_94 + 1)])
+ break;
+ }
+ for (p_3.f1 = 0; (p_3.f1 <= 2); p_3.f1 += 1)
+ { /* block id: 595 */
+ int i;
+ if (g_494[p_3.f1])
+ break;
+ }
+ return (*g_42);
+ }
+ return p_3;
+ }
+ }
+ l_1080 = l_1080;
+ return (*g_42);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads :
+ * writes: g_84
+ */
+static struct S1 func_8(uint32_t p_9, struct S0 p_10)
+{ /* block id: 574 */
+ uint16_t l_1072 = 0xD8F4L;
+ int32_t *l_1073 = &g_84;
+ struct S1 l_1074 = {1UL,1UL};
+ (*l_1073) = (safe_lshift_func_uint16_t_u_u(l_1072, 8));
+ return l_1074;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads :
+ * writes:
+ */
+static uint32_t func_11(const struct S2 p_12, const struct S5 p_13, uint8_t p_14, uint8_t p_15, struct S0 p_16)
+{ /* block id: 572 */
+ return p_12.f0;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads :
+ * writes:
+ */
+static const struct S2 func_17(struct S1 p_18, int32_t p_19)
+{ /* block id: 2 */
+ const struct S2 l_24 = {0,9374,5952,0,29241,1L,2915,-142,113};
+ return l_24;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_42 g_43.f0 g_75 g_94 g_85 g_69.f2.f7 g_84 g_23 g_69.f1 g_131 g_138 g_111.f5 g_111.f6 g_111.f3 g_153 g_113.f9 g_69.f2.f3 g_69.f2.f2 g_69.f2.f0 g_111.f1 g_43 g_113.f8 g_214 g_113.f3 g_252 g_253 g_69.f0 g_109 g_182.f9 g_113.f0 g_69.f3 g_345 g_113.f6 g_348 g_182.f0 g_113.f5 g_349.f0 g_111.f4 g_346 g_357.f9 g_111.f7 g_349 g_69.f2.f4 g_494 g_517 g_518 g_182.f8 g_274 g_599 g_69 g_1017 g_601 g_762 g_763
+ * writes: g_43 g_69.f0 g_84 g_85 g_69.f1 g_94 g_109 g_112 g_131 g_151 g_214 g_274 g_348 g_352 g_355 g_356 g_345 g_401 g_253 g_76 g_349.f5 g_494 g_517 g_599 g_69.f3 g_153
+ */
+static uint32_t func_26(uint8_t p_27, uint8_t p_28, struct S1 * p_29, struct S1 * p_30, const struct S1 * p_31)
+{ /* block id: 4 */
+ struct S1 l_46[5] = {{0UL,0xDF2DL},{0UL,0xDF2DL},{0UL,0xDF2DL},{0UL,0xDF2DL},{0UL,0xDF2DL}};
+ struct S5 **l_74 = (void*)0;
+ struct S1 *l_226 = &l_46[1];
+ struct S2 l_656 = {1,4806,1292,0,44121,0x66CCED79L,1233,93,31};
+ struct S0 l_659[3][5] = {{{51,2,31,109},{29,0,5,118},{-168,3,28,54},{-168,3,28,54},{29,0,5,118}},{{-179,5,22,23},{85,9,13,127},{-168,3,28,54},{126,4,25,11},{126,4,25,11}},{{85,9,13,127},{-179,5,22,23},{85,9,13,127},{-168,3,28,54},{126,4,25,11}}};
+ int32_t *l_660 = (void*)0;
+ int32_t **l_661 = (void*)0;
+ int32_t **l_662 = &l_660;
+ struct S4 l_726 = {{23764,4,181,9,6,19678,94,29,2,2307},-943};
+ uint32_t * const *l_784[2];
+ uint32_t * const **l_783[10];
+ uint32_t l_805 = 4294967295UL;
+ uint8_t *l_819[3];
+ int32_t l_904 = 0x227435A8L;
+ int32_t l_905 = 0x908C76C9L;
+ int32_t l_907 = 0L;
+ int32_t l_908[5][10][2] = {{{4L,0xDBBACBE8L},{0x1EB7CE3BL,6L},{6L,(-1L)},{0x373DBA5FL,0xDBBACBE8L},{9L,0xE060BC82L},{0xB21D5BCAL,0x1EB7CE3BL},{0xA2DA418AL,0xB21D5BCAL},{0L,0x5DAABF8FL},{0xF99A1A17L,(-1L)},{0xA2DA418AL,0x373DBA5FL}},{{(-1L),0xE060BC82L},{4L,1L},{0x373DBA5FL,6L},{(-1L),6L},{0x373DBA5FL,1L},{4L,0xE060BC82L},{(-1L),0x373DBA5FL},{0xA2DA418AL,(-1L)},{0xF99A1A17L,0x5DAABF8FL},{0L,0xB21D5BCAL}},{{0xA2DA418AL,0x1EB7CE3BL},{0xB21D5BCAL,0xE060BC82L},{9L,0xDBBACBE8L},{0x373DBA5FL,(-1L)},{6L,6L},{0x1EB7CE3BL,0xDBBACBE8L},{4L,3L},{0xB21D5BCAL,0x373DBA5FL},{0L,0xB21D5BCAL},{0xF99A1A17L,0xF88AD893L}},{{0xF99A1A17L,0xB21D5BCAL},{0L,0x373DBA5FL},{0xB21D5BCAL,3L},{4L,0xDBBACBE8L},{0x1EB7CE3BL,6L},{6L,(-1L)},{0x373DBA5FL,0xDBBACBE8L},{9L,0xE060BC82L},{0xB21D5BCAL,0x1EB7CE3BL},{0xA2DA418AL,0xB21D5BCAL}},{{0L,0x5DAABF8FL},{0xF99A1A17L,(-1L)},{0xA2DA418AL,0x373DBA5FL},{(-1L),0xE060BC82L},{4L,1L},{0x373DBA5FL,6L},{(-1L),6L},{0x373DBA5FL,1L},{4L,0xE060BC82L},{(-1L),0x373DBA5FL}}};
+ int32_t l_919 = 0x8475D920L;
+ uint8_t l_945 = 0x96L;
+ struct S3 *l_962 = (void*)0;
+ const int32_t *l_995 = &l_905;
+ struct S0 **l_1045 = &g_750;
+ uint32_t l_1063 = 0xC92B0175L;
+ int32_t *l_1068 = &g_214;
+ int i, j, k;
+ for (i = 0; i < 2; i++)
+ l_784[i] = &g_346[0][2][2];
+ for (i = 0; i < 10; i++)
+ l_783[i] = &l_784[1];
+ for (i = 0; i < 3; i++)
+ l_819[i] = &g_745;
+ for (p_28 = 0; (p_28 < 43); p_28 = safe_add_func_int32_t_s_s(p_28, 4))
+ { /* block id: 7 */
+ uint16_t *l_81 = (void*)0;
+ struct S1 *l_82[6][2][3] = {{{&l_46[3],&g_43[4][7][2],&l_46[3]},{(void*)0,&g_43[4][7][2],&l_46[1]}},{{&g_43[0][8][0],&g_43[4][7][2],&g_43[4][7][2]},{&l_46[3],&g_43[4][7][2],&l_46[3]}},{{(void*)0,&g_43[4][7][2],&l_46[1]},{&g_43[0][8][0],&g_43[4][7][2],&g_43[4][7][2]}},{{&l_46[3],&g_43[4][7][2],&l_46[3]},{(void*)0,&g_43[3][2][2],&l_46[1]}},{{&g_43[4][7][2],&g_43[3][2][2],&g_43[3][2][2]},{&l_46[1],&g_43[3][2][2],(void*)0}},{{&l_46[3],&g_43[3][2][2],&l_46[1]},{&g_43[4][7][2],&g_43[3][2][2],&g_43[3][2][2]}}};
+ const int32_t l_655 = 0L;
+ struct S0 *l_658[6] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
+ int i, j, k;
+ (*g_42) = l_46[1];
+ g_153 = (l_659[2][4] = func_47(func_52(func_58(l_46[1].f1, g_43[6][6][2].f0, func_64(p_29, &g_43[0][2][1], p_30), (g_69.f0 = (safe_add_func_int16_t_s_s((l_74 != g_75), (safe_mul_func_uint8_t_u_u((safe_add_func_uint16_t_u_u((p_27 != p_27), 0xC976L)), 0xA7L))))), l_82[4][0][2]), p_30, &g_43[6][6][2], l_226, (*g_42)), g_42, l_655, l_656));
+ }
+ (*l_662) = l_660;
+ for (g_349.f5 = 0; (g_349.f5 > (-23)); g_349.f5 = safe_sub_func_uint8_t_u_u(g_349.f5, 8))
+ { /* block id: 352 */
+ int32_t l_688 = 0x3816D0D3L;
+ int32_t l_713 = 0L;
+ int32_t l_716[9][8][3] = {{{0x3BCCE3A3L,0xFE70B519L,1L},{0x3CD82101L,0L,(-1L)},{0x7C325AC9L,(-7L),(-8L)},{0xC7B04A55L,0x4A0176CCL,1L},{0xFE70B519L,0x0DD4E228L,0x0DD4E228L},{0x5542C803L,0xF31E4DAEL,0xBF445B9AL},{0x0F15FBADL,(-9L),0xCE133DEBL},{(-1L),(-1L),0x3BBD2679L}},{{0xBF445B9AL,0x6C83F1EEL,(-8L)},{0x6CAF9D30L,(-1L),0x04ADB9DFL},{1L,(-9L),0xD0FFF10AL},{8L,0xF31E4DAEL,0L},{0L,0x0DD4E228L,9L},{0x9B75BFF6L,0x4A0176CCL,0xD9072743L},{(-10L),(-7L),(-1L)},{0xF742CD06L,0L,0x5542C803L}},{{0x6A7C68C7L,0xFE70B519L,2L},{0L,0xBF445B9AL,0xF742CD06L},{1L,0L,0xC7B04A55L},{0x20F5AD6DL,0x7C325AC9L,8L},{0x3BBD2679L,0xF8CFA606L,(-8L)},{0x46A37A33L,0x827C1ED6L,0L},{0xBD005C73L,0xB6E969FCL,0xE3047B84L},{0x5DD129CFL,(-5L),1L}},{{0xCE133DEBL,0x9DB6C7FFL,0xE3277720L},{0L,1L,0xB6E969FCL},{2L,0x3BBD2679L,0xB6E969FCL},{0xF8CFA606L,0x04ADB9DFL,0xE3277720L},{(-9L),0x3BCCE3A3L,1L},{0xF00157DCL,1L,0xE3047B84L},{1L,0xEDBC2C95L,0L},{8L,0xE3047B84L,(-8L)}},{{(-8L),0xCE133DEBL,8L},{(-6L),0L,0xC7B04A55L},{0x827C1ED6L,0L,0xF742CD06L},{0L,0x8430A39AL,2L},{0x1D9E6B75L,0x745CECD1L,0x5542C803L},{(-5L),0x5542C803L,(-1L)},{(-1L),0x57658509L,0xD9072743L},{0x24009C27L,(-1L),9L}},{{0L,1L,0L},{1L,0xD7884624L,0xD0FFF10AL},{0xB3DD4A61L,1L,0x04ADB9DFL},{0xBAF9344DL,1L,(-8L)},{4L,(-8L),0x3BBD2679L},{0xBAF9344DL,0L,0xCE133DEBL},{0xB3DD4A61L,(-7L),0xBF445B9AL},{1L,0L,0x0DD4E228L}},{{0L,(-1L),1L},{0x24009C27L,0xF730B445L,(-8L)},{(-1L),0x20F5AD6DL,(-1L)},{(-5L),0x9B8547DBL,1L},{0x1D9E6B75L,0x6CAF9D30L,0x9DB6C7FFL},{0L,0x3CD82101L,0xB6095228L},{0x827C1ED6L,(-6L),0x4F266C63L},{(-6L),4L,1L}},{{(-8L),9L,0xEDBC2C95L},{0x6A7C68C7L,0L,0xE3277720L},{8L,(-8L),1L},{(-7L),(-10L),(-1L)},{(-10L),0L,1L},{0x6CAF9D30L,0x6C83F1EEL,0xC7B04A55L},{0x4F266C63L,0x6C83F1EEL,0x3BBD2679L},{0x5DD129CFL,0L,0xC92C255AL}},{{0x7C325AC9L,(-10L),0x3E2BF1D1L},{0L,(-8L),(-1L)},{(-1L),0L,1L},{(-7L),0x9B8547DBL,2L},{(-6L),0x9DB6C7FFL,0L},{0x4A0176CCL,0xEDBC2C95L,0xB5E31D23L},{0xF730B445L,2L,0xF31E4DAEL},{0x1B78B7DEL,0L,0x3CD82101L}}};
+ int32_t *l_731[10] = {&g_84,&g_84,&g_84,&g_84,&g_84,&g_84,&g_84,&g_84,&g_84,&g_84};
+ int32_t l_748 = 0xB46690BEL;
+ const struct S0 l_787 = {-75,4,1,63};
+ struct S1 *l_812[4];
+ const uint32_t *l_817 = &g_494[1];
+ const uint32_t **l_816[10];
+ struct S4 l_821 = {{22752,2,1164,1,7,29048,25,-24,82,6268},-1323};
+ int8_t l_834 = 0xB9L;
+ int16_t *l_849 = &g_274;
+ int16_t **l_848 = &l_849;
+ int16_t *** const l_847[9] = {&l_848,&l_848,&l_848,&l_848,&l_848,&l_848,&l_848,&l_848,&l_848};
+ struct S4 *l_902 = &g_903;
+ struct S5 l_938[6] = {{1UL,2UL,{-12957,3,1222,8,1,6685,24,-39,-99,7802},1L},{0x099DL,0x20E4L,{-1296,3,899,-1,9,6177,108,3,14,1101},-1L},{1UL,2UL,{-12957,3,1222,8,1,6685,24,-39,-99,7802},1L},{1UL,2UL,{-12957,3,1222,8,1,6685,24,-39,-99,7802},1L},{0x099DL,0x20E4L,{-1296,3,899,-1,9,6177,108,3,14,1101},-1L},{1UL,2UL,{-12957,3,1222,8,1,6685,24,-39,-99,7802},1L}};
+ int32_t l_1023 = 0x8D8FD03DL;
+ uint32_t l_1058 = 0x051FCD20L;
+ uint32_t ***l_1060 = &g_345;
+ uint32_t ****l_1059 = &l_1060;
+ uint16_t *l_1066 = &l_46[1].f0;
+ uint16_t *l_1067 = &g_43[6][6][2].f0;
+ int i, j, k;
+ for (i = 0; i < 4; i++)
+ l_812[i] = &g_43[5][3][2];
+ for (i = 0; i < 10; i++)
+ l_816[i] = &l_817;
+ for (g_94 = 0; (g_94 > 18); ++g_94)
+ { /* block id: 355 */
+ uint16_t l_669 = 8UL;
+ for (g_69.f1 = 0; (g_69.f1 < 46); g_69.f1 = safe_add_func_int8_t_s_s(g_69.f1, 2))
+ { /* block id: 358 */
+ uint32_t l_670 = 0xA45EC3F1L;
+ for (g_253 = 0; (g_253 <= 2); g_253 += 1)
+ { /* block id: 361 */
+ int i, j, k;
+ l_669 = p_27;
+ (*l_662) = (g_151[(g_253 + 3)] = g_346[(g_253 + 7)][g_253][g_253]);
+ return p_27;
+ }
+ ++l_670;
+ }
+ }
+ if (p_27)
+ break;
+ for (p_27 = (-2); (p_27 <= 11); ++p_27)
+ { /* block id: 373 */
+ struct S1 l_677 = {4UL,1UL};
+ uint16_t *l_678 = &l_46[1].f0;
+ uint16_t *l_679 = &l_46[1].f1;
+ int32_t l_686 = 3L;
+ int32_t l_687 = 0x1F991E30L;
+ int32_t l_712 = (-3L);
+ int32_t l_715 = (-7L);
+ int32_t l_717 = 1L;
+ int32_t l_718 = 0L;
+ int32_t l_719 = 5L;
+ int32_t l_720 = 0L;
+ int32_t l_722 = (-1L);
+ uint32_t l_723 = 18446744073709551607UL;
+ struct S4 l_794[9] = {{{-24595,-1,930,-9,8,18801,42,8,-108,1131},820},{{-22623,-3,856,14,10,3217,36,-26,-92,2350},-7770},{{-24595,-1,930,-9,8,18801,42,8,-108,1131},820},{{-22623,-3,856,14,10,3217,36,-26,-92,2350},-7770},{{-24595,-1,930,-9,8,18801,42,8,-108,1131},820},{{-22623,-3,856,14,10,3217,36,-26,-92,2350},-7770},{{-24595,-1,930,-9,8,18801,42,8,-108,1131},820},{{-22623,-3,856,14,10,3217,36,-26,-92,2350},-7770},{{-24595,-1,930,-9,8,18801,42,8,-108,1131},820}};
+ struct S0 l_815[4][10] = {{{-124,2,22,31},{-88,15,5,17},{-27,11,7,35},{57,6,26,49},{57,6,26,49},{-27,11,7,35},{-88,15,5,17},{-124,2,22,31},{-124,2,22,31},{-88,15,5,17}},{{-124,2,22,31},{57,6,26,49},{-88,15,5,17},{-88,15,5,17},{57,6,26,49},{-124,2,22,31},{-27,11,7,35},{-27,11,7,35},{-124,2,22,31},{57,6,26,49}},{{57,6,26,49},{-88,15,5,17},{-88,15,5,17},{57,6,26,49},{-124,2,22,31},{-27,11,7,35},{-27,11,7,35},{-124,2,22,31},{57,6,26,49},{-88,15,5,17}},{{57,6,26,49},{57,6,26,49},{-27,11,7,35},{-88,15,5,17},{-124,2,22,31},{-124,2,22,31},{-88,15,5,17},{-27,11,7,35},{57,6,26,49},{57,6,26,49}}};
+ const struct S0 *l_857 = &l_815[2][5];
+ int32_t l_906 = 0x6DAA9DF0L;
+ int32_t l_914 = 0xEF2044C3L;
+ int32_t l_915 = (-1L);
+ int32_t l_916 = 0xB33D429DL;
+ int32_t l_920 = 0xCD43F33BL;
+ int32_t l_921[6][5][7] = {{{(-1L),0x91634774L,0x68746CC2L,5L,5L,0x68746CC2L,0x91634774L},{0x171B7552L,0L,(-1L),0xCDAAB82EL,0x171B7552L,0xCDAAB82EL,(-1L)},{5L,9L,0x68746CC2L,0x64AF7050L,(-1L),(-1L),0x64AF7050L},{0x88DB7A49L,0xD9E1FA8EL,0x88DB7A49L,0xCDAAB82EL,0x45C4CF09L,0xD9E1FA8EL,0x45C4CF09L},{9L,0x64AF7050L,0x91634774L,5L,(-1L),0x28F9752DL,0x28F9752DL}},{{0x171B7552L,(-7L),0x4C84DF75L,(-7L),0x171B7552L,0xD9E1FA8EL,0x4C84DF75L},{1L,9L,0x64AF7050L,0x91634774L,5L,(-1L),0x28F9752DL},{0x45C4CF09L,0xCDAAB82EL,0x88DB7A49L,0xD9E1FA8EL,0x88DB7A49L,0xCDAAB82EL,0x45C4CF09L},{1L,0x91634774L,0x28F9752DL,5L,9L,0x68746CC2L,0x64AF7050L},{0x171B7552L,0xCDAAB82EL,(-1L),0L,0x171B7552L,0L,(-1L)}},{{9L,9L,0x28F9752DL,0x64AF7050L,1L,(-1L),0x91634774L},{0x88DB7A49L,(-7L),0x88DB7A49L,0L,0x45C4CF09L,(-7L),0x45C4CF09L},{5L,0x64AF7050L,0x64AF7050L,5L,1L,0x28F9752DL,0x68746CC2L},{0x171B7552L,0xD9E1FA8EL,0x4C84DF75L,0xD9E1FA8EL,0x171B7552L,(-7L),0x4C84DF75L},{(-1L),9L,0x91634774L,0x91634774L,9L,(-1L),0x68746CC2L}},{{0x45C4CF09L,0L,0x88DB7A49L,(-7L),0x88DB7A49L,0L,0x45C4CF09L},{(-1L),0x91634774L,0x68746CC2L,5L,5L,0x68746CC2L,0x91634774L},{0x171B7552L,0L,(-1L),0xCDAAB82EL,0x171B7552L,0xCDAAB82EL,(-1L)},{5L,9L,0x68746CC2L,0x64AF7050L,(-1L),(-1L),0x64AF7050L},{0x88DB7A49L,0xD9E1FA8EL,0x88DB7A49L,0xCDAAB82EL,0x45C4CF09L,0xD9E1FA8EL,0x45C4CF09L}},{{9L,0x64AF7050L,0x91634774L,5L,(-1L),0x28F9752DL,0x28F9752DL},{0x171B7552L,(-7L),0x4C84DF75L,(-7L),0x171B7552L,0xD9E1FA8EL,0x4C84DF75L},{1L,9L,0x64AF7050L,0x91634774L,5L,(-1L),0x28F9752DL},{0x45C4CF09L,0xCDAAB82EL,0x88DB7A49L,0xD9E1FA8EL,0x88DB7A49L,0xCDAAB82EL,0x45C4CF09L},{1L,0x91634774L,0x28F9752DL,5L,9L,0x68746CC2L,0x64AF7050L}},{{0x171B7552L,0xCDAAB82EL,(-1L),0L,0x171B7552L,0L,(-1L)},{9L,9L,0x28F9752DL,0x64AF7050L,1L,(-1L),0x91634774L},{0x88DB7A49L,(-7L),0x88DB7A49L,0L,0x45C4CF09L,(-7L),0x45C4CF09L},{5L,0x64AF7050L,0x64AF7050L,5L,1L,0x28F9752DL,0x68746CC2L},{0x171B7552L,0xD9E1FA8EL,0x4C84DF75L,0xD9E1FA8EL,0x171B7552L,(-7L),0x4C84DF75L}}};
+ int8_t l_937 = 1L;
+ int32_t l_946 = 0xF1A2D0D4L;
+ struct S1 l_975 = {0x427BL,65527UL};
+ const struct S3 l_984 = {-14746,-2,662,-4,10,30454,114,16,-56,7335};
+ uint32_t l_994 = 7UL;
+ const int32_t *l_1029 = &l_946;
+ int i, j, k;
+ }
+ l_908[1][1][1] ^= (+(safe_div_func_uint32_t_u_u(((g_1017 , ((*l_1067) = (((safe_lshift_func_uint16_t_u_u((safe_lshift_func_uint8_t_u_u((g_94 |= (safe_add_func_int32_t_s_s(p_28, (safe_mod_func_uint8_t_u_u((l_1058 = g_182.f8), ((((*l_1059) = &g_345) != &g_345) && ((-10L) <= (((safe_mod_func_uint16_t_u_u(((*l_1066) = (l_1063 != (safe_mod_func_uint16_t_u_u(((*g_252) >= p_27), g_138.f0.f4)))), g_109)) != (*g_252)) <= 6L)))))))), p_27)), g_601[0][2])) | 0UL) <= (*l_995)))) | (*l_995)), p_27)));
+ }
+ (*l_1068) &= ((p_28 < (1L & (*g_762))) , p_28);
+ return p_27;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads :
+ * writes:
+ */
+static struct S0 func_47(struct S0 p_48, struct S1 * p_49, const uint16_t p_50, struct S2 p_51)
+{ /* block id: 343 */
+ struct S3 *l_657 = &g_138.f0;
+ l_657 = l_657;
+ return p_48;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_94 g_113.f8 g_214 g_113.f3 g_252 g_253 g_69.f0 g_109 g_182.f9 g_113.f0 g_69.f3 g_153 g_345 g_113.f6 g_69.f2.f3 g_138.f0.f2 g_348 g_69.f1 g_84 g_182.f0 g_75 g_113.f5 g_349.f0 g_111.f4 g_42 g_43 g_346 g_357.f9 g_349.f5 g_111.f6 g_111.f7 g_111.f5 g_138 g_349 g_113.f9 g_69.f2.f4 g_85 g_494 g_517 g_518 g_182.f8 g_274 g_131 g_599 g_69
+ * writes: g_214 g_94 g_69.f0 g_109 g_43.f1 g_274 g_348 g_112 g_352 g_355 g_356 g_84 g_151 g_345 g_401 g_253 g_76 g_349.f5 g_43 g_494 g_517 g_85 g_131 g_599 g_69.f3
+ */
+static struct S0 func_52(struct S0 p_53, struct S1 * p_54, struct S1 * p_55, struct S1 * p_56, struct S1 p_57)
+{ /* block id: 101 */
+ uint8_t l_227 = 3UL;
+ int32_t *l_228 = &g_214;
+ const struct S3 l_229 = {-12834,3,624,-6,8,31570,34,35,4,446};
+ struct S1 l_234 = {0x7CBEL,65531UL};
+ int8_t *l_255 = &g_253;
+ int32_t l_280 = 0xE149A9F4L;
+ int32_t l_281 = 3L;
+ int32_t l_318 = (-2L);
+ int32_t l_320 = 0xFA7069FDL;
+ int32_t l_322[1][1];
+ int32_t l_383[6] = {1L,1L,1L,1L,1L,1L};
+ struct S5 *l_427 = &g_69;
+ int16_t **l_492 = (void*)0;
+ uint16_t l_548 = 1UL;
+ int8_t l_581 = 0x33L;
+ int16_t ***l_597 = &l_492;
+ uint32_t l_646 = 0UL;
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 1; j++)
+ l_322[i][j] = 0L;
+ }
+ if ((((*l_228) = l_227) <= ((l_229 , (&p_57 != (void*)0)) == p_53.f2)))
+ { /* block id: 103 */
+ for (g_94 = 8; (g_94 > 31); g_94 = safe_add_func_uint16_t_u_u(g_94, 2))
+ { /* block id: 106 */
+ if (p_57.f1)
+ break;
+ }
+ }
+ else
+ { /* block id: 109 */
+ int16_t *l_247 = &g_109;
+ int16_t * const l_249 = (void*)0;
+ int32_t l_250 = (-1L);
+ int32_t l_272 = 0L;
+ int32_t l_275 = 0L;
+ int32_t l_329 = 0x121242E4L;
+ struct S0 l_363 = {175,9,31,37};
+ int32_t l_374 = 0x9A027F3BL;
+ uint32_t l_391 = 0xCD74C835L;
+ uint32_t ***l_400 = &g_345;
+ uint32_t *l_409 = (void*)0;
+ int32_t *l_410 = &l_280;
+ const uint16_t l_411 = 0x43A9L;
+ int32_t *l_412 = &l_250;
+ struct S5 l_415[5][8] = {{{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L}},{{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L}},{{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L}},{{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L}},{{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{65534UL,65532UL,{5369,2,486,12,0,13875,95,41,123,1543},0xC4F27E92L},{1UL,0x3AC6L,{-12171,2,112,-9,2,32314,79,-30,68,750},-6L}}};
+ uint32_t l_544 = 4294967293UL;
+ uint32_t l_582 = 0xA0A9C2C1L;
+ int32_t l_621[4] = {0xC353EE67L,0xC353EE67L,0xC353EE67L,0xC353EE67L};
+ int16_t ***l_630 = &l_492;
+ struct S3 l_639 = {-32711,-2,123,13,10,14313,101,-44,-66,6352};
+ struct S1 *l_645 = &l_234;
+ int i, j;
+ for (l_227 = (-14); (l_227 <= 46); l_227++)
+ { /* block id: 112 */
+ struct S0 *l_236 = &g_153;
+ struct S0 **l_235 = &l_236;
+ struct S0 **l_237 = (void*)0;
+ struct S0 *l_239[4][5] = {{&g_153,(void*)0,&g_153,&g_153,&g_153},{(void*)0,&g_153,(void*)0,&g_153,&g_153},{&g_153,(void*)0,&g_153,&g_153,&g_153},{(void*)0,&g_153,(void*)0,&g_153,&g_153}};
+ struct S0 **l_238 = &l_239[2][1];
+ int32_t l_244 = 3L;
+ int16_t **l_248 = &l_247;
+ int32_t l_305 = 0xFBD691C8L;
+ int32_t l_323 = (-5L);
+ int32_t l_326[3][3][10] = {{{0x1F4B9C93L,8L,8L,0x1F4B9C93L,0x349389C5L,5L,0x73619E2BL,(-1L),(-1L),1L},{0xFDE84D4DL,(-1L),(-1L),0x73619E2BL,8L,0x7A2AB3D7L,8L,0x73619E2BL,(-1L),(-1L)},{(-1L),1L,(-1L),0x1F4B9C93L,0x71D502BBL,0xDEF5D37AL,5L,(-1L),0x349389C5L,0x349389C5L}},{{1L,1L,0xDEF5D37AL,0x7A2AB3D7L,0x7A2AB3D7L,0xDEF5D37AL,1L,1L,0x1F4B9C93L,5L},{(-1L),(-1L),0x73619E2BL,1L,0L,0x7A2AB3D7L,(-1L),5L,(-1L),0x7A2AB3D7L},{0xFDE84D4DL,0L,0x73619E2BL,0L,0xFDE84D4DL,5L,0x1F4B9C93L,1L,1L,0xDEF5D37AL}},{{0x1F4B9C93L,0x71D502BBL,0xDEF5D37AL,5L,(-1L),0x349389C5L,0x349389C5L,(-1L),5L,0xDEF5D37AL},{5L,5L,(-1L),0xDEF5D37AL,0xFDE84D4DL,(-1L),(-1L),0x73619E2BL,8L,0x7A2AB3D7L},{0x73619E2BL,(-1L),(-1L),1L,0L,1L,(-1L),(-1L),0x73619E2BL,5L}}};
+ int32_t *l_373 = &l_329;
+ int32_t *l_378 = &l_323;
+ int32_t *l_379 = &l_275;
+ int32_t *l_380 = &l_280;
+ int32_t *l_381[8] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
+ int32_t l_382 = 0x5FE0C3B8L;
+ uint16_t l_384 = 1UL;
+ uint8_t l_388[10][1][2] = {{{0x82L,0xB0L}},{{0xB0L,0x5FL}},{{0xB0L,0x5FL}},{{0xB0L,0xB0L}},{{0x82L,0x82L}},{{0x82L,0xB0L}},{{0xB0L,0x5FL}},{{0xB0L,0x5FL}},{{0xB0L,0xB0L}},{{0x82L,0x82L}}};
+ int i, j, k;
+ if ((((p_53.f0 == (func_17(l_234, (((*l_238) = ((*l_235) = &p_53)) != &p_53)) , g_113.f8)) < (safe_rshift_func_uint16_t_u_s((((((safe_add_func_uint8_t_u_u(l_244, ((safe_mul_func_int8_t_s_s((250UL != (+((((*l_248) = l_247) != l_249) ^ p_53.f2))), (*l_228))) || p_53.f2))) , (*l_228)) , 0xC7L) || l_250) | p_53.f3), g_113.f3))) == l_250))
+ { /* block id: 116 */
+ int32_t l_251 = 0xAE49ED9AL;
+ int8_t *l_254 = &g_253;
+ for (g_69.f0 = 0; (g_69.f0 <= 8); g_69.f0 += 1)
+ { /* block id: 119 */
+ uint16_t *l_262 = (void*)0;
+ uint16_t *l_263 = &l_234.f0;
+ int16_t *l_273[5];
+ int i;
+ for (i = 0; i < 5; i++)
+ l_273[i] = &g_274;
+ if (l_251)
+ break;
+ (*l_228) |= ((0x2AL | (g_252 == (l_255 = l_254))) , (p_53 , (safe_add_func_uint16_t_u_u((safe_div_func_int16_t_s_s((l_275 ^= (p_53 , ((safe_div_func_int32_t_s_s((((*l_263) = 0x18A4L) | ((((g_109 = (l_272 &= (safe_mul_func_uint16_t_u_u(((safe_sub_func_uint8_t_u_u(((-1L) || (!((safe_mul_func_uint8_t_u_u((safe_mod_func_int16_t_s_s((-7L), (5UL && 251UL))), l_250)) ^ l_244))), 7UL)) || l_251), 0L)))) != 0UL) , (void*)0) != &l_229)), p_57.f1)) > (*g_252)))), p_57.f1)), 0x5575L))));
+ if (l_251)
+ break;
+ p_53.f0 = ((safe_rshift_func_int8_t_s_s((*g_252), p_53.f2)) , (0UL || (*l_228)));
+ }
+ }
+ else
+ { /* block id: 130 */
+ int32_t *l_278 = &l_250;
+ int32_t *l_279[8][4] = {{&l_244,(void*)0,(void*)0,(void*)0},{(void*)0,&l_272,&l_275,&l_244},{(void*)0,&l_250,&l_250,(void*)0},{(void*)0,(void*)0,&l_275,&g_214},{(void*)0,(void*)0,(void*)0,&l_244},{&l_244,&l_250,&l_244,&l_244},{(void*)0,(void*)0,(void*)0,&g_214},{&l_275,(void*)0,(void*)0,(void*)0}};
+ uint8_t l_282 = 253UL;
+ uint16_t *l_289[6] = {&g_43[6][6][2].f0,&g_43[6][6][2].f0,&g_43[6][6][2].f0,&g_43[6][6][2].f0,&g_43[6][6][2].f0,&g_43[6][6][2].f0};
+ struct S0 *l_300[7] = {&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153};
+ uint8_t *l_303 = &g_94;
+ uint32_t l_304 = 0x5DECD937L;
+ int32_t l_328 = 0L;
+ uint32_t **l_333 = (void*)0;
+ struct S5 l_358 = {65526UL,65535UL,{-17020,-3,129,6,9,5641,116,6,16,3716},0x87A08BDBL};
+ int i, j;
+ ++l_282;
+ if ((((((safe_mul_func_int16_t_s_s((l_244 = (safe_add_func_int8_t_s_s(((((--g_69.f0) || l_244) & (g_43[6][6][2].f1 = p_53.f2)) ^ ((**l_248) |= (g_274 = p_57.f1))), (*g_252)))), (safe_div_func_int8_t_s_s((safe_rshift_func_uint8_t_u_u(g_182.f9, 0)), ((*l_303) = ((p_53.f1 && ((safe_lshift_func_uint8_t_u_s((safe_sub_func_uint32_t_u_u((l_300[0] == (*l_235)), ((*l_228) = ((safe_sub_func_int8_t_s_s(0x3CL, 1L)) | p_57.f1)))), 5)) <= l_250)) | g_113.f0)))))) | g_69.f3) || p_53.f0) , l_304) != l_305))
+ { /* block id: 139 */
+ struct S4 *l_308 = &g_138;
+ int32_t l_315 = 1L;
+ int32_t l_316 = 0xC4D5F313L;
+ int32_t l_317 = 0x579CAB94L;
+ int32_t l_325 = 0L;
+ int32_t l_327[4][3][8] = {{{0x030C2675L,3L,0xE8FD32BEL,0xFF4CD6DDL,(-1L),1L,1L,1L},{3L,(-10L),0x51BD3FEEL,1L,(-10L),0x8A8F9135L,0x3ADFECCFL,0xDE5CFD58L},{0x51BD3FEEL,(-1L),0x57BA0327L,1L,0xFDD9E36FL,3L,0x3D1CCB86L,1L}},{{0x3D1CCB86L,0x3ADFECCFL,0x57BA0327L,0xFF4CD6DDL,0xFF4CD6DDL,0x57BA0327L,0x3ADFECCFL,0x3D1CCB86L},{0xFDD9E36FL,0x5D09D952L,0x51BD3FEEL,0xDE5CFD58L,(-1L),(-1L),0xE8FD32BEL,0x57BA0327L},{0L,1L,(-1L),0x8A8F9135L,0xDE5CFD58L,(-1L),0xDE5CFD58L,0x8A8F9135L}},{{0x3ADFECCFL,0x5D09D952L,0x3ADFECCFL,0x51BD3FEEL,(-1L),0x57BA0327L,1L,0xFDD9E36FL},{0x8A8F9135L,0x3ADFECCFL,0xDE5CFD58L,0xE8FD32BEL,0L,3L,(-1L),(-1L)},{0x8A8F9135L,(-1L),0x3D1CCB86L,0x3D1CCB86L,(-1L),0x8A8F9135L,0x5D09D952L,(-10L)}},{{0x3ADFECCFL,1L,3L,0x5D09D952L,0xDE5CFD58L,0x030C2675L,0xFDD9E36FL,0xFF4CD6DDL},{0L,(-10L),0x030C2675L,0x5D09D952L,(-1L),0x5D09D952L,0x030C2675L,(-10L)},{0xFDD9E36FL,(-1L),0xE8FD32BEL,0x3D1CCB86L,0xFF4CD6DDL,0x51BD3FEEL,0L,(-1L)}}};
+ int i, j, k;
+ for (p_57.f0 = (-21); (p_57.f0 < 48); ++p_57.f0)
+ { /* block id: 142 */
+ struct S4 **l_309 = &l_308;
+ (*l_309) = l_308;
+ return g_153;
+ }
+ if (l_305)
+ break;
+ for (l_305 = (-25); (l_305 < 11); l_305 = safe_add_func_int16_t_s_s(l_305, 1))
+ { /* block id: 149 */
+ int8_t l_312 = 0xE5L;
+ int32_t l_313 = 1L;
+ int32_t l_314 = 0xB566A646L;
+ int32_t l_319 = 1L;
+ int32_t l_321 = 3L;
+ int32_t l_324[4];
+ uint16_t l_330 = 0xFA7FL;
+ int i;
+ for (i = 0; i < 4; i++)
+ l_324[i] = 0x82E92E31L;
+ l_330--;
+ }
+ for (l_244 = 0; (l_244 <= 3); l_244 += 1)
+ { /* block id: 154 */
+ uint32_t ***l_334 = &l_333;
+ int32_t l_347 = 0xF0677D09L;
+ struct S2 **l_350 = &g_348;
+ int i, j;
+ (*l_334) = l_333;
+ p_53.f0 = (247UL & (safe_lshift_func_uint16_t_u_u((safe_mod_func_uint16_t_u_u((safe_lshift_func_int16_t_s_s((safe_add_func_uint16_t_u_u((p_57.f1 = ((&l_239[l_244][(l_244 + 1)] == &l_239[l_244][l_244]) < (~(((((*l_228) && p_57.f0) ^ (safe_lshift_func_int16_t_s_s((+(*l_278)), (((((((((((l_315 > ((g_345 == (void*)0) , g_113.f6)) < g_69.f2.f3) >= p_53.f0) , l_326[1][0][2]) || 1UL) != (*g_252)) && (*g_252)) >= p_57.f0) >= 65532UL) , 0x41F066B9L) || p_57.f1)))) ^ l_347) < l_305)))), p_53.f2)), p_53.f3)), g_138.f0.f2)), 15)));
+ (*l_350) = g_348;
+ }
+ }
+ else
+ { /* block id: 160 */
+ struct S3 **l_351 = &g_112;
+ struct S3 *l_354 = &g_138.f0;
+ struct S3 **l_353[1];
+ int i;
+ for (i = 0; i < 1; i++)
+ l_353[i] = &l_354;
+ g_356 = (g_355 = (g_352 = ((*l_351) = (void*)0)));
+ if (l_329)
+ continue;
+ }
+ (*l_228) = (l_358 , ((*l_278) = p_53.f0));
+ (*l_228) ^= (g_69.f1 <= (p_57.f1 || (*g_252)));
+ }
+ for (l_318 = 0; (l_318 <= (-8)); --l_318)
+ { /* block id: 173 */
+ uint16_t l_367[3];
+ int32_t *l_372 = &g_214;
+ int i;
+ for (i = 0; i < 3; i++)
+ l_367[i] = 65527UL;
+ for (l_234.f1 = (-8); (l_234.f1 >= 26); ++l_234.f1)
+ { /* block id: 176 */
+ (*l_228) = (l_275 > (*g_252));
+ return l_363;
+ }
+ l_244 = (*l_228);
+ for (l_234.f1 = 3; (l_234.f1 <= 8); l_234.f1 += 1)
+ { /* block id: 183 */
+ uint16_t l_375 = 0x71EFL;
+ for (l_244 = 0; (l_244 <= 8); l_244 += 1)
+ { /* block id: 186 */
+ return g_153;
+ }
+ for (g_84 = 8; (g_84 >= 0); g_84 -= 1)
+ { /* block id: 191 */
+ int32_t *l_364 = &l_329;
+ int32_t *l_365 = (void*)0;
+ int32_t *l_366[1];
+ int32_t **l_370 = &l_366[0];
+ int32_t **l_371 = (void*)0;
+ int i;
+ for (i = 0; i < 1; i++)
+ l_366[i] = (void*)0;
+ l_367[1]++;
+ g_151[4] = (l_373 = (l_372 = ((*l_370) = &g_214)));
+ --l_375;
+ }
+ }
+ }
+ l_384++;
+ for (g_94 = 2; (g_94 <= 7); g_94 += 1)
+ { /* block id: 204 */
+ int16_t l_387[1][8];
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 8; j++)
+ l_387[i][j] = 1L;
+ }
+ l_388[6][0][1]--;
+ (*l_380) = l_387[0][0];
+ }
+ }
+ if (((*l_412) = ((((p_53.f3 = ((*l_228) = (p_53.f1 = l_391))) || ((*l_410) ^= (safe_rshift_func_int16_t_s_u((((p_53.f3 <= (((safe_sub_func_uint8_t_u_u((safe_mul_func_int16_t_s_s((-2L), (safe_lshift_func_uint16_t_u_u((l_374 != 65530UL), 13)))), ((*l_255) = ((((*l_400) = &g_346[3][1][3]) != (g_401 = &g_346[0][2][2])) <= (l_272 ^= (safe_sub_func_uint8_t_u_u((((safe_sub_func_uint32_t_u_u((((safe_unary_minus_func_uint16_t_u(((safe_lshift_func_int16_t_s_u(((((*l_228) && ((*g_252) | 2UL)) , p_53.f1) != g_69.f0), 9)) > (-5L)))) >= p_53.f0) > (*l_228)), (*l_228))) >= (*l_228)) , (*l_228)), 1UL))))))) | 65528UL) | p_57.f1)) <= 1L) < g_182.f0), l_275)))) > l_411) , p_53.f3)))
+ { /* block id: 218 */
+ uint8_t l_443[8] = {0x1DL,0x1DL,0x1DL,0x1DL,0x1DL,0x1DL,0x1DL,0x1DL};
+ uint32_t *l_451 = &g_131;
+ int32_t l_504[3][5] = {{(-1L),(-1L),1L,1L,(-1L)},{(-1L),(-1L),1L,1L,(-1L)},{(-1L),(-1L),1L,1L,(-1L)}};
+ struct S4 *l_574 = &g_518[1];
+ int16_t ***l_595 = &l_492;
+ int16_t l_620 = (-6L);
+ uint8_t l_622 = 0x8BL;
+ uint32_t *l_636 = &g_494[2];
+ uint16_t l_644 = 0x655EL;
+ int i, j;
+ if ((((safe_mul_func_uint8_t_u_u(p_53.f2, ((l_415[1][6] , ((*l_228) = (((safe_mod_func_uint8_t_u_u((safe_unary_minus_func_int8_t_s(p_53.f2)), 0xEFL)) >= ((safe_sub_func_uint8_t_u_u((safe_div_func_int16_t_s_s((safe_lshift_func_uint16_t_u_s((safe_add_func_uint32_t_u_u((7UL < (((*g_75) = l_427) == (void*)0)), ((safe_div_func_uint8_t_u_u(((safe_div_func_uint32_t_u_u((((safe_lshift_func_uint8_t_u_u((safe_mod_func_int32_t_s_s(p_53.f2, (g_113.f5 && 255UL))), g_94)) >= 0x48L) , 0x0A836DACL), p_53.f1)) | g_349.f0), (*l_228))) , 4L))), g_111.f4)), p_53.f1)), (*g_252))) || p_53.f1)) , 0xA8E3F1E3L))) ^ 0x4A00F90DL))) ^ 0x7BL) < 0x4F381AB7L))
+ { /* block id: 221 */
+ struct S1 l_450 = {0x958CL,0UL};
+ int8_t l_468[8][4][2] = {{{0x38L,1L},{0x38L,0x38L},{1L,0x38L},{0x38L,1L}},{{0x38L,0x38L},{1L,0x38L},{0x38L,1L},{0x38L,0x38L}},{{1L,0x38L},{0x38L,1L},{0x38L,0x38L},{1L,0x38L}},{{0x38L,1L},{0x38L,0x38L},{1L,0x38L},{0x38L,1L}},{{0x38L,0x38L},{1L,0x38L},{0x38L,1L},{0x38L,0x38L}},{{1L,0x38L},{0x38L,1L},{0x38L,0x38L},{1L,0x38L}},{{0x38L,1L},{0x38L,0x38L},{1L,0x38L},{0x38L,1L}},{{0x38L,0x38L},{1L,0x38L},{0x38L,1L},{0x38L,0x38L}}};
+ int32_t l_476 = (-1L);
+ int16_t ***l_493 = &l_492;
+ int32_t l_503 = (-3L);
+ struct S4 *l_520 = &g_521[4][0][0];
+ const struct S3 l_529 = {2366,0,1008,2,10,12108,126,-23,-15,1054};
+ int32_t *l_575 = &l_476;
+ int32_t *l_576 = &l_503;
+ int32_t *l_577 = &l_374;
+ int32_t *l_578 = &l_281;
+ int32_t *l_579 = &l_476;
+ int32_t *l_580[7];
+ int i, j, k;
+ for (i = 0; i < 7; i++)
+ l_580[i] = &l_250;
+ if ((safe_unary_minus_func_int8_t_s((safe_div_func_int16_t_s_s((((safe_rshift_func_uint16_t_u_s((safe_div_func_int8_t_s_s(p_53.f3, l_443[6])), ((((*l_247) = ((*g_42) , (p_53.f3 && (*l_412)))) >= (safe_div_func_uint8_t_u_u(9UL, 1UL))) <= p_57.f0))) > (safe_sub_func_int32_t_s_s((safe_add_func_uint8_t_u_u((((l_451 = (func_17(l_450, l_450.f0) , (*g_345))) != (**l_400)) == (*l_410)), (*l_228))), (*l_228)))) < l_443[6]), g_357.f9)))))
+ { /* block id: 224 */
+ int8_t l_457[7];
+ int i;
+ for (i = 0; i < 7; i++)
+ l_457[i] = 0xE6L;
+ for (g_349.f5 = 15; (g_349.f5 == (-25)); --g_349.f5)
+ { /* block id: 227 */
+ uint16_t l_460[9] = {0x13E5L,1UL,0x13E5L,0x13E5L,1UL,0x13E5L,0x13E5L,1UL,0x13E5L};
+ uint16_t *l_463 = &l_450.f1;
+ int i;
+ (*l_412) |= ((p_53.f3 & ((*l_247) = 0xA57DL)) & (*l_228));
+ if (p_53.f0)
+ break;
+ p_53.f0 = ((!((safe_unary_minus_func_uint32_t_u(((safe_mod_func_int32_t_s_s(((*l_410) = (-2L)), ((*l_228) &= p_53.f3))) ^ l_457[0]))) || (((g_153.f0 >= (+(safe_div_func_uint32_t_u_u(p_53.f2, (((l_460[8] , (safe_lshift_func_uint16_t_u_u(p_53.f2, 15))) ^ (((*l_463) = g_111.f6) , (((0x2BB8L < p_53.f2) ^ p_53.f0) > 4294967295UL))) , p_53.f0))))) && l_457[0]) <= 0x1EL))) == p_53.f3);
+ (*g_42) = (*p_54);
+ }
+ }
+ else
+ { /* block id: 237 */
+ uint8_t l_477 = 0x96L;
+ for (l_450.f0 = 0; (l_450.f0 != 42); l_450.f0 = safe_add_func_int16_t_s_s(l_450.f0, 2))
+ { /* block id: 240 */
+ int32_t l_466[6] = {0x1655F412L,0x1655F412L,0x1655F412L,0x1655F412L,0x1655F412L,0x1655F412L};
+ int32_t *l_467 = (void*)0;
+ int32_t *l_469 = (void*)0;
+ int32_t *l_470 = &l_466[5];
+ int32_t *l_471 = &l_322[0][0];
+ int32_t *l_472 = &l_320;
+ int32_t *l_473 = &l_272;
+ int32_t *l_474 = &l_374;
+ int32_t *l_475[8][1] = {{&l_320},{&l_281},{&l_281},{&l_322[0][0]},{&l_320},{&l_320},{&l_322[0][0]},{&l_320}};
+ int i, j;
+ l_477--;
+ return g_153;
+ }
+ }
+ if (((*l_228) |= (((g_494[2] = (!((safe_rshift_func_int16_t_s_s(((*l_247) = ((void*)0 == &g_23)), 6)) == (safe_add_func_int32_t_s_s(((safe_rshift_func_int16_t_s_u((((p_53.f1 = (*l_412)) > (*l_410)) && (safe_add_func_uint8_t_u_u(((safe_rshift_func_int8_t_s_u((safe_rshift_func_int16_t_s_u((g_274 = (&g_76 != (((*g_252) , (((*l_493) = l_492) != (void*)0)) , &g_76))), p_53.f1)), g_111.f7)) | l_450.f0), p_57.f0))), g_111.f5)) , 1L), p_53.f0))))) > l_468[7][3][0]) || 1L)))
+ { /* block id: 251 */
+ struct S3 *l_497[9][10][2] = {{{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113}},{{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111}},{{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113}},{{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0}},{{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182}},{{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182}},{{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0}},{{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113}},{{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111},{&g_138.f0,(void*)0},{&g_111,&g_182},{&g_111,&g_113},{(void*)0,&g_113},{&g_111,&g_182},{&g_111,(void*)0},{&g_138.f0,&g_111}}};
+ int32_t l_505 = 0x3BBE76C4L;
+ uint8_t l_506 = 6UL;
+ int i, j, k;
+ (*l_410) |= ((*l_412) = p_53.f0);
+ for (l_374 = (-26); (l_374 == 16); l_374 = safe_add_func_int16_t_s_s(l_374, 4))
+ { /* block id: 256 */
+ struct S3 **l_498 = &l_497[8][7][0];
+ (*l_498) = l_497[8][9][0];
+ }
+ for (p_57.f0 = 0; (p_57.f0 != 45); p_57.f0 = safe_add_func_uint8_t_u_u(p_57.f0, 7))
+ { /* block id: 261 */
+ int32_t **l_501 = &l_412;
+ int32_t *l_502[1];
+ int i;
+ for (i = 0; i < 1; i++)
+ l_502[i] = &l_281;
+ (*l_501) = &l_281;
+ l_506++;
+ }
+ }
+ else
+ { /* block id: 265 */
+ struct S4 *l_516 = &g_138;
+ struct S4 **l_515 = &l_516;
+ struct S4 **l_519 = (void*)0;
+ uint16_t *l_523 = (void*)0;
+ uint16_t *l_524 = &l_450.f0;
+ int32_t l_547 = 2L;
+ struct S5 *l_566 = (void*)0;
+ p_53.f0 = (((safe_div_func_int32_t_s_s((safe_mul_func_uint16_t_u_u(((*l_524) = (+(l_504[1][2] || (g_138 , (((*l_410) = (safe_add_func_int8_t_s_s((*g_252), ((l_520 = (g_517 = ((*l_515) = &g_138))) == ((*g_348) , &g_521[4][0][0]))))) >= (safe_unary_minus_func_int16_t_s((g_113.f9 < ((g_69.f2.f4 ^ (~p_57.f0)) <= p_53.f3))))))))), 0x3F82L)), 1L)) || 8L) != p_53.f1);
+ for (g_85 = 0; (g_85 <= 2); g_85 += 1)
+ { /* block id: 274 */
+ uint32_t *l_532 = &g_494[3];
+ int32_t l_535 = (-6L);
+ uint16_t *l_545 = &g_43[6][6][2].f1;
+ uint16_t l_546 = 65532UL;
+ struct S2 **l_551 = &g_348;
+ int32_t *l_567 = &l_503;
+ (*l_412) = ((safe_lshift_func_uint8_t_u_s((safe_mod_func_uint32_t_u_u(((g_153 , ((l_529 , (((*l_545) = (safe_sub_func_int8_t_s_s(((((+(--(*l_532))) , ((*g_517) , (l_535 | ((g_182.f8 , (((((safe_add_func_uint8_t_u_u((safe_div_func_int32_t_s_s((safe_sub_func_int32_t_s_s(l_504[0][1], p_53.f3)), (safe_lshift_func_uint8_t_u_u((((*l_524) = p_57.f0) <= (*l_228)), 1)))), 0x9CL)) > 0x6DCC9F64L) || l_544) >= (*g_252)) > 4UL)) >= 4294967295UL)))) <= g_138.f0.f6) < 5UL), 0xB6L))) == l_546)) | 0xC305L)) , l_529.f8), l_547)), (*g_252))) || l_548);
+ (*l_412) &= (safe_add_func_int32_t_s_s(p_53.f3, (0xFA528CD4L <= ((((*p_56) = (*g_42)) , &l_228) == (void*)0))));
+ (*l_551) = &g_349;
+ (*l_567) ^= ((*l_228) > (safe_lshift_func_uint16_t_u_s(((safe_add_func_int32_t_s_s(p_57.f1, (((((g_153 , ((((*l_410) &= p_53.f3) ^ 4294967295UL) > (safe_mul_func_int16_t_s_s(p_57.f1, 5UL)))) <= ((safe_mul_func_uint16_t_u_u((safe_mul_func_uint8_t_u_u((safe_add_func_int16_t_s_s((((((255UL != (~(4294967294UL == 0UL))) , (void*)0) == l_566) , g_69.f3) ^ l_504[2][3]), g_274)), 0x5DL)), g_111.f6)) == l_535)) & 8UL) && p_53.f2) | (*l_412)))) || p_53.f0), 3)));
+ }
+ (*l_412) = (((g_274 |= 0L) == g_349.f1) && (safe_lshift_func_int8_t_s_s(0L, (safe_rshift_func_int16_t_s_s((safe_add_func_uint16_t_u_u(((void*)0 != l_574), (l_234 , l_529.f8))), 12)))));
+ }
+ l_582++;
+ }
+ else
+ { /* block id: 289 */
+ uint32_t l_606[6];
+ int32_t l_609 = 0x40AE2A13L;
+ int32_t *l_610 = &l_504[1][3];
+ int32_t *l_611 = &l_318;
+ int32_t *l_612 = &g_84;
+ int32_t *l_613 = &l_609;
+ int32_t *l_614 = (void*)0;
+ int32_t *l_615 = &l_504[1][2];
+ int32_t l_616 = 0x99467C25L;
+ int32_t *l_617 = &l_322[0][0];
+ int32_t *l_618[5];
+ int16_t l_619 = 8L;
+ int i;
+ for (i = 0; i < 6; i++)
+ l_606[i] = 0x997170ADL;
+ for (i = 0; i < 5; i++)
+ l_618[i] = &l_616;
+ for (g_131 = (-27); (g_131 == 22); g_131++)
+ { /* block id: 292 */
+ for (l_318 = 2; (l_318 >= 0); l_318 -= 1)
+ { /* block id: 295 */
+ (*l_410) = ((*l_228) = p_57.f1);
+ }
+ }
+ for (p_57.f0 = 3; (p_57.f0 <= 8); p_57.f0 += 1)
+ { /* block id: 302 */
+ int32_t *l_600 = (void*)0;
+ int32_t *l_602 = &l_504[2][0];
+ int32_t *l_603 = &l_320;
+ int32_t *l_604 = &l_281;
+ int32_t *l_605[9][2] = {{(void*)0,&l_329},{(void*)0,(void*)0},{&l_329,&l_329},{&l_329,&l_280},{&l_329,&l_329},{&l_280,&l_329},{&l_329,&l_280},{&l_329,&l_329},{&l_280,&l_329}};
+ int i, j;
+ for (l_250 = 0; (l_250 <= 8); l_250 += 1)
+ { /* block id: 305 */
+ struct S3 l_594[7] = {{-9867,4,834,0,10,12828,54,32,17,4899},{-9867,4,834,0,10,12828,54,32,17,4899},{-9867,4,834,0,10,12828,54,32,17,4899},{-9867,4,834,0,10,12828,54,32,17,4899},{-9867,4,834,0,10,12828,54,32,17,4899},{-9867,4,834,0,10,12828,54,32,17,4899},{-9867,4,834,0,10,12828,54,32,17,4899}};
+ int16_t ****l_596[10] = {&l_595,&l_595,&l_595,&l_595,&l_595,&l_595,&l_595,&l_595,&l_595,&l_595};
+ uint16_t *l_598 = &l_415[1][6].f0;
+ int i;
+ (*l_410) |= ((safe_add_func_int8_t_s_s((safe_mod_func_uint16_t_u_u((((safe_unary_minus_func_int8_t_s((((&g_356 == &g_112) & (safe_mod_func_uint8_t_u_u((249UL >= (l_594[6] , (p_53.f1 != ((*l_598) = ((l_597 = l_595) == (void*)0))))), (*g_252)))) <= ((void*)0 == l_451)))) != g_599) != p_57.f0), 2UL)), (-1L))) != (*l_228));
+ }
+ l_606[2]--;
+ }
+ l_622++;
+ }
+ for (l_582 = 0; (l_582 > 11); l_582 = safe_add_func_int16_t_s_s(l_582, 7))
+ { /* block id: 316 */
+ struct S3 **l_627 = &g_356;
+ (*l_627) = &g_113;
+ }
+ (*l_410) |= (safe_sub_func_uint32_t_u_u(p_53.f1, (l_630 != ((g_599 = (safe_add_func_int32_t_s_s((*l_228), (safe_div_func_int16_t_s_s((safe_unary_minus_func_uint32_t_u(((*l_636) |= 1UL))), (safe_add_func_int8_t_s_s((*g_252), (g_153 , 0x7DL)))))))) , l_595))));
+ g_151[2] = &l_374;
+ }
+ else
+ { /* block id: 323 */
+ if (l_646)
+ { /* block id: 324 */
+ return p_53;
+ }
+ else
+ { /* block id: 326 */
+ struct S0 l_647[3][6][8] = {{{{-136,13,28,56},{145,13,26,9},{25,0,13,51},{-81,8,14,33},{-140,15,5,35},{-129,10,27,47},{124,4,0,104},{121,11,4,41}},{{30,12,15,71},{-136,13,28,56},{-55,14,13,73},{-148,11,29,18},{25,0,13,51},{-61,5,20,10},{66,11,28,12},{174,14,3,98}},{{110,4,20,75},{-150,13,15,70},{-141,10,31,71},{47,14,31,82},{-116,6,24,66},{95,3,18,52},{-81,14,25,100},{29,12,13,108}},{{-61,5,20,10},{-114,12,30,14},{-23,5,25,53},{172,13,28,120},{29,2,12,91},{174,14,3,98},{174,14,3,98},{29,2,12,91}},{{-23,5,25,53},{56,4,31,53},{56,4,31,53},{-23,5,25,53},{59,9,19,14},{30,12,15,71},{-61,5,20,10},{-118,2,9,105}},{{124,4,0,104},{47,14,31,82},{154,4,1,112},{-129,10,27,47},{-150,13,15,70},{-140,15,5,35},{172,13,28,120},{74,8,2,48}}},{{{-0,14,5,119},{47,14,31,82},{145,13,26,9},{-150,12,27,48},{174,14,3,98},{30,12,15,71},{-134,5,10,54},{154,4,1,112}},{{-97,7,20,120},{56,4,31,53},{-81,14,25,100},{-19,5,8,89},{-134,10,28,16},{174,14,3,98},{-112,11,31,77},{-149,15,5,23}},{{-140,15,5,35},{-114,12,30,14},{-116,6,24,66},{101,10,31,13},{95,1,23,52},{95,3,18,52},{-129,10,27,47},{172,13,28,120}},{{59,6,30,38},{-150,13,15,70},{59,9,19,14},{124,4,0,104},{152,6,21,93},{-61,5,20,10},{-141,10,31,71},{56,4,31,53}},{{-148,11,29,18},{-136,13,28,56},{-39,7,30,57},{-150,13,15,70},{29,12,13,108},{-129,10,27,47},{-114,12,30,14},{-141,10,31,71}},{{42,8,21,80},{145,13,26,9},{-81,8,14,33},{130,13,14,91},{-81,8,14,33},{145,13,26,9},{42,8,21,80},{-86,15,8,7}}},{{{25,0,13,51},{128,3,7,9},{59,6,30,38},{95,1,23,52},{154,4,1,112},{74,8,2,48},{45,11,4,116},{-116,6,24,66}},{{59,9,19,14},{101,10,31,13},{-118,2,9,105},{-136,13,28,56},{154,4,1,112},{-112,11,31,77},{110,4,20,75},{130,13,14,91}},{{25,0,13,51},{9,13,20,103},{-134,10,28,16},{-116,6,24,66},{-81,8,14,33},{161,6,7,45},{83,12,31,120},{-134,5,10,54}},{{42,8,21,80},{110,4,20,75},{-129,10,27,47},{34,6,31,81},{29,12,13,108},{95,1,23,52},{-46,5,11,42},{145,13,26,9}},{{-148,11,29,18},{-39,7,30,57},{30,12,15,71},{29,2,12,91},{152,6,21,93},{101,10,31,13},{154,4,1,112},{-19,5,8,89}},{{59,6,30,38},{-118,2,9,105},{42,8,21,80},{66,11,28,12},{95,1,23,52},{-136,13,28,56},{-140,15,5,35},{161,6,7,45}}}};
+ int i, j, k;
+ return l_647[1][1][5];
+ }
+ }
+ for (l_329 = 0; (l_329 != (-25)); l_329--)
+ { /* block id: 332 */
+ struct S1 **l_650[10] = {&l_645,&l_645,&l_645,&l_645,&l_645,&l_645,&l_645,&l_645,&l_645,&l_645};
+ int i;
+ p_56 = &g_43[1][0][0];
+ }
+ return l_363;
+ }
+ for (g_69.f3 = 6; (g_69.f3 <= (-1)); --g_69.f3)
+ { /* block id: 339 */
+ const int32_t *l_653 = &l_322[0][0];
+ const int32_t **l_654 = &l_653;
+ (*l_654) = ((*l_427) , l_653);
+ }
+ return g_153;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_94 g_85 g_69.f2.f7 g_84 g_23 g_69.f1 g_131 g_43.f0 g_138 g_111.f5 g_111.f6 g_111.f3 g_153 g_113.f9 g_69.f2.f3 g_69.f2.f2 g_69.f2.f0 g_111.f1
+ * writes: g_84 g_85 g_69.f1 g_94 g_109 g_112 g_131 g_151
+ */
+static struct S0 func_58(int16_t p_59, int32_t p_60, struct S1 * p_61, uint16_t p_62, struct S1 * p_63)
+{ /* block id: 14 */
+ int32_t *l_83 = &g_84;
+ int32_t l_91 = 0xF83796EEL;
+ int32_t l_93[5][6] = {{(-10L),0x1B442378L,0x08F057B9L,0xA9A3A129L,0xA9A3A129L,0x08F057B9L},{0xBEE15430L,1L,0xBEE15430L,1L,0xBA1556E8L,(-10L)},{1L,0xBEE15430L,0x08F057B9L,(-10L),0x08F057B9L,0xBEE15430L},{1L,1L,0x08F057B9L,(-1L),1L,(-10L)},{0xA9A3A129L,(-1L),0xBEE15430L,0xBEE15430L,(-1L),0xA9A3A129L}};
+ int8_t l_142 = 0x11L;
+ int32_t **l_180 = &g_151[4];
+ struct S3 *l_181 = &g_182;
+ struct S0 l_225 = {-105,9,22,104};
+ int i, j;
+ g_85 = ((*l_83) = 1L);
+lbl_205:
+ for (g_69.f1 = (-24); (g_69.f1 > 31); g_69.f1++)
+ { /* block id: 19 */
+ int32_t *l_88 = &g_84;
+ int32_t *l_89 = &g_84;
+ int32_t *l_90 = &g_84;
+ int32_t *l_92[2][7][8] = {{{&g_84,&g_84,&l_91,&g_84,&g_84,(void*)0,(void*)0,&g_84},{&g_84,&g_84,&g_84,&g_84,&g_84,&g_84,&g_84,&g_84},{&g_84,(void*)0,&g_84,&g_84,&g_84,&g_84,&l_91,&g_84},{&l_91,&g_84,&l_91,&g_84,&g_84,&g_84,&l_91,&l_91},{&l_91,(void*)0,(void*)0,&l_91,&g_84,&g_84,&g_84,(void*)0},{&l_91,&g_84,&l_91,&l_91,&g_84,(void*)0,&g_84,(void*)0},{&l_91,&g_84,&g_84,&g_84,&g_84,(void*)0,&l_91,&l_91}},{{(void*)0,&g_84,&g_84,&l_91,&g_84,&l_91,&g_84,&g_84},{&l_91,&g_84,&g_84,&g_84,&l_91,(void*)0,(void*)0,&l_91},{&g_84,&l_91,&g_84,&g_84,&l_91,(void*)0,(void*)0,&l_91},{(void*)0,&g_84,&g_84,(void*)0,&l_91,&l_91,&g_84,&l_91},{&l_91,&l_91,&g_84,&l_91,&g_84,&l_91,&l_91,(void*)0},{&g_84,&l_91,&g_84,&g_84,&g_84,&g_84,&g_84,&l_91},{&l_91,&l_91,&l_91,&g_84,(void*)0,(void*)0,&g_84,&l_91}}};
+ int i, j, k;
+ ++g_94;
+ }
+ for (p_59 = 4; (p_59 >= 1); p_59 -= 1)
+ { /* block id: 24 */
+ uint32_t l_101 = 0x928AAD06L;
+ struct S1 * const l_122[1] = {&g_43[6][6][2]};
+ int32_t l_123 = 0x0C6443E6L;
+ uint8_t l_146 = 0x0DL;
+ uint16_t l_160[4];
+ int32_t l_210 = 4L;
+ int32_t l_211 = 0xFD14C5FFL;
+ int32_t l_212 = (-4L);
+ int32_t l_213 = (-1L);
+ int32_t l_215 = 0x9EB05264L;
+ int32_t l_216 = 0L;
+ int32_t l_217 = 0xE4B4E971L;
+ int32_t l_218[3];
+ int32_t l_219 = 0x5BEEE314L;
+ uint16_t l_220 = 0xB3DFL;
+ int i;
+ for (i = 0; i < 4; i++)
+ l_160[i] = 65535UL;
+ for (i = 0; i < 3; i++)
+ l_218[i] = 0x77C93981L;
+ for (g_85 = 0; (g_85 <= 2); g_85 += 1)
+ { /* block id: 27 */
+ int32_t l_127 = (-1L);
+ struct S4 l_163 = {{-17390,4,292,-10,2,16271,17,29,-55,7808},-5540};
+ struct S3 *l_165 = &g_138.f0;
+ int32_t **l_179 = &l_83;
+ int i, j;
+ if (l_93[p_59][g_85])
+ break;
+ for (p_62 = 1; (p_62 <= 4); p_62 += 1)
+ { /* block id: 31 */
+ const uint16_t l_107 = 0x3CE0L;
+ int16_t *l_108 = &g_109;
+ struct S1 *l_120[2];
+ int32_t l_126 = 0x6F6EEB39L;
+ int32_t l_130 = 1L;
+ struct S5 l_134 = {0x658AL,65534UL,{-27175,1,1343,1,2,13314,81,9,-34,991},0L};
+ struct S5 **l_137 = &g_76;
+ int i;
+ for (i = 0; i < 2; i++)
+ l_120[i] = &g_43[0][8][0];
+ if (p_60)
+ break;
+ if ((safe_lshift_func_int8_t_s_s((((safe_add_func_int8_t_s_s((1UL < p_59), g_69.f2.f7)) , (((((l_101 != (*l_83)) || 4294967286UL) <= (l_101 & (safe_unary_minus_func_uint8_t_u((safe_mul_func_uint16_t_u_u(g_23, ((safe_add_func_int32_t_s_s(((((*l_108) = (l_107 , l_101)) & 0x9021L) < 3UL), g_69.f1)) & 0UL))))))) <= (-1L)) < (*l_83))) > 0xBFDD0443L), 6)))
+ { /* block id: 34 */
+ for (p_60 = 0; (p_60 <= 4); p_60 += 1)
+ { /* block id: 37 */
+ struct S3 *l_110 = &g_111;
+ g_112 = l_110;
+ }
+ }
+ else
+ { /* block id: 40 */
+ const struct S2 l_121[5][9][1] = {{{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}},{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}},{{-1,10083,9718,2,9836,8L,3398,-135,38}},{{-0,7117,4484,1,13754,0xEE6007DAL,2870,165,-29}},{{-0,8270,6048,0,30763,0xAE96437FL,1414,97,-111}},{{-1,5203,21771,0,26939,6L,2897,-13,-86}},{{0,5200,14207,3,36662,0xB4F79F91L,2945,-6,101}},{{-0,10871,5590,2,27478,-5L,4068,71,10}},{{0,5200,14207,3,36662,0xB4F79F91L,2945,-6,101}}},{{{-1,5203,21771,0,26939,6L,2897,-13,-86}},{{-0,8270,6048,0,30763,0xAE96437FL,1414,97,-111}},{{-0,7117,4484,1,13754,0xEE6007DAL,2870,165,-29}},{{-1,10083,9718,2,9836,8L,3398,-135,38}},{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}},{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}},{{-1,10083,9718,2,9836,8L,3398,-135,38}},{{-0,7117,4484,1,13754,0xEE6007DAL,2870,165,-29}},{{-0,8270,6048,0,30763,0xAE96437FL,1414,97,-111}}},{{{-1,5203,21771,0,26939,6L,2897,-13,-86}},{{0,5200,14207,3,36662,0xB4F79F91L,2945,-6,101}},{{-0,10871,5590,2,27478,-5L,4068,71,10}},{{0,5200,14207,3,36662,0xB4F79F91L,2945,-6,101}},{{-1,5203,21771,0,26939,6L,2897,-13,-86}},{{-0,8270,6048,0,30763,0xAE96437FL,1414,97,-111}},{{-0,7117,4484,1,13754,0xEE6007DAL,2870,165,-29}},{{-1,10083,9718,2,9836,8L,3398,-135,38}},{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}}},{{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}},{{-1,10083,9718,2,9836,8L,3398,-135,38}},{{-0,7117,4484,1,13754,0xEE6007DAL,2870,165,-29}},{{-0,8270,6048,0,30763,0xAE96437FL,1414,97,-111}},{{-1,5203,21771,0,26939,6L,2897,-13,-86}},{{0,5200,14207,3,36662,0xB4F79F91L,2945,-6,101}},{{-0,10871,5590,2,27478,-5L,4068,71,10}},{{0,5200,14207,3,36662,0xB4F79F91L,2945,-6,101}},{{-1,5203,21771,0,26939,6L,2897,-13,-86}}},{{{-0,8270,6048,0,30763,0xAE96437FL,1414,97,-111}},{{-0,7117,4484,1,13754,0xEE6007DAL,2870,165,-29}},{{-1,10083,9718,2,9836,8L,3398,-135,38}},{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}},{{0,10989,2755,4,45111,0x0F242EEFL,3188,149,-109}},{{-1,10083,9718,2,9836,8L,3398,-135,38}},{{-0,7117,4484,1,13754,0xEE6007DAL,2870,165,-29}},{{-0,8270,6048,0,30763,0xAE96437FL,1414,97,-111}},{{-1,5203,21771,0,26939,6L,2897,-13,-86}}}};
+ int32_t l_128 = 0L;
+ int32_t l_129 = 0xA5D6F3FEL;
+ int32_t *l_150 = (void*)0;
+ struct S0 *l_152[6][10] = {{&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153},{&g_153,&g_153,&g_153,(void*)0,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153},{&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153},{&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153},{&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153,&g_153},{&g_153,&g_153,(void*)0,&g_153,(void*)0,&g_153,&g_153,&g_153,&g_153,&g_153}};
+ int32_t *l_157 = &l_93[p_59][p_59];
+ int32_t *l_158 = (void*)0;
+ int32_t *l_159[2][8][2] = {{{&g_84,&l_126},{&l_93[0][3],(void*)0},{&l_93[0][3],&l_126},{&g_84,&g_84},{&l_126,&l_93[0][3]},{(void*)0,&l_93[0][3]},{&l_126,&g_84},{&g_84,&l_126}},{{&l_93[0][3],(void*)0},{&l_93[0][3],&l_126},{&g_84,&g_84},{&l_126,&l_93[0][3]},{(void*)0,&l_93[0][3]},{&l_126,&g_84},{&g_84,&l_126},{&l_93[0][3],(void*)0}}};
+ struct S3 *l_164 = &l_163.f0;
+ uint32_t *l_176 = &g_131;
+ int i, j, k;
+ if ((((safe_add_func_uint8_t_u_u(p_62, ((safe_lshift_func_int16_t_s_s((&l_93[2][4] == (void*)0), (((void*)0 == &p_62) <= 6UL))) | ((l_93[p_59][p_59] |= 0L) & (((l_123 ^= (safe_lshift_func_uint16_t_u_s((l_120[1] != (l_121[0][7][0] , l_122[0])), p_60))) && 1UL) || (-7L)))))) >= (*l_83)) | (-1L)))
+ { /* block id: 43 */
+ int32_t *l_124 = &l_123;
+ int32_t *l_125[2][5][2] = {{{&l_93[p_59][p_59],(void*)0},{&l_93[p_59][g_85],&l_93[p_59][g_85]},{(void*)0,&l_93[p_59][g_85]},{&l_93[p_59][g_85],(void*)0},{&l_93[p_59][p_59],&l_93[p_59][p_59]}},{{&l_93[p_59][p_59],(void*)0},{&l_93[p_59][g_85],&l_93[p_59][g_85]},{(void*)0,&l_93[p_59][g_85]},{&l_93[p_59][g_85],(void*)0},{&l_93[p_59][p_59],&l_93[p_59][p_59]}}};
+ int i, j, k;
+ ++g_131;
+ p_60 ^= (l_134 , (((-1L) ^ (safe_mod_func_int32_t_s_s((*l_83), (((*l_124) &= g_43[6][6][2].f0) || (l_137 == (g_138 , &g_76)))))) != ((((void*)0 == &g_84) == p_62) || (*l_83))));
+ p_60 ^= 0x3CCC8CD9L;
+ }
+ else
+ { /* block id: 48 */
+ uint32_t *l_139 = &g_131;
+ int32_t l_143 = 0x4D29C7E7L;
+ int32_t *l_144 = &l_129;
+ int32_t *l_145[7][7] = {{&l_93[p_59][g_85],(void*)0,&l_130,(void*)0,&l_93[p_59][g_85],&l_93[p_59][g_85],(void*)0},{&l_128,&g_84,&l_128,&l_93[p_59][p_59],(void*)0,&l_143,&l_91},{(void*)0,&l_127,&l_130,&l_130,&l_127,(void*)0,&l_127},{&l_128,&l_93[p_59][p_59],(void*)0,&l_143,&l_91,&l_143,(void*)0},{&l_93[p_59][g_85],&l_93[p_59][g_85],(void*)0,&l_130,(void*)0,&l_93[p_59][g_85],&l_93[p_59][g_85]},{(void*)0,&l_93[p_59][p_59],(void*)0,&l_93[p_59][p_59],(void*)0,&l_123,(void*)0},{&l_93[p_59][g_85],&l_127,&l_93[p_59][g_85],(void*)0,(void*)0,&l_93[p_59][g_85],&l_127}};
+ int32_t **l_149[8] = {&l_145[0][1],&l_83,&l_145[0][1],&l_145[0][1],&l_83,&l_145[0][1],&l_145[0][1],&l_83};
+ struct S0 **l_154 = &l_152[5][8];
+ struct S0 *l_156 = &g_153;
+ struct S0 **l_155 = &l_156;
+ int i, j;
+ (*l_83) ^= ((p_62 | ((--(*l_139)) & l_123)) , (l_142 != l_143));
+ ++l_146;
+ g_151[4] = (l_150 = &l_143);
+ (*l_155) = ((*l_154) = l_152[5][8]);
+ }
+ if (p_62)
+ break;
+ ++l_160[3];
+ (*l_157) = ((l_163 , ((p_60 & (8UL & (((g_112 = l_164) != l_165) > (safe_lshift_func_uint8_t_u_s(l_146, (((l_163.f0.f1 || ((0xC9L ^ (safe_mul_func_uint8_t_u_u((safe_mod_func_uint32_t_u_u((((*l_176) = (((((((safe_rshift_func_uint16_t_u_s((((safe_div_func_int8_t_s_s(1L, g_111.f5)) < 0x7EL) & p_60), p_59)) , p_62) == l_134.f3) & 0x03L) ^ p_62) >= g_111.f6) > (*l_83))) || p_59), l_160[2])), (*l_83)))) , l_134.f1)) > 0xD4A83E69L) > p_62)))))) > p_62)) > 0xF8C4L);
+ }
+ if (((**l_179) = ((safe_lshift_func_int16_t_s_u((*l_83), 5)) >= ((0xB5L & (l_179 == l_180)) , g_111.f3))))
+ { /* block id: 64 */
+ int32_t l_185 = (-2L);
+ l_181 = l_165;
+ for (l_101 = 0; (l_101 <= 2); l_101 += 1)
+ { /* block id: 68 */
+ int8_t *l_186 = &l_142;
+ uint32_t *l_199 = (void*)0;
+ uint32_t *l_200 = &g_131;
+ uint16_t *l_203 = &g_69.f1;
+ int32_t *l_204[1][8];
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 8; j++)
+ l_204[i][j] = &l_127;
+ }
+ l_123 |= (safe_rshift_func_int8_t_s_s(((*l_186) = l_185), (((safe_lshift_func_int8_t_s_s((safe_lshift_func_int16_t_s_u(((3UL < ((g_153 , ((safe_mod_func_uint8_t_u_u(p_60, ((&g_109 != (void*)0) , (((safe_lshift_func_uint8_t_u_s((((safe_mod_func_uint8_t_u_u((((((*l_203) = (((p_62 ^ ((*l_83) = (safe_mod_func_uint32_t_u_u(((*l_200) = g_113.f9), ((safe_sub_func_int32_t_s_s((((**l_179) , &g_153) == &g_153), g_69.f2.f3)) , (-7L)))))) , g_69.f2.f2) | p_60)) || p_62) , 0x0F5ECD5AL) , l_185), g_153.f3)) == 0x31L) != p_62), p_62)) , 4UL) || p_62)))) || g_69.f2.f0)) | 0x452CL)) , g_111.f1), 13)), 4)) != l_185) >= g_138.f0.f5)));
+ }
+ if (p_60)
+ break;
+ }
+ else
+ { /* block id: 76 */
+ (*l_180) = (void*)0;
+ }
+ if (l_134.f2.f7)
+ goto lbl_205;
+ }
+ }
+ for (l_146 = 0; (l_146 <= 4); l_146 += 1)
+ { /* block id: 84 */
+ int32_t *l_206 = &l_93[4][4];
+ int32_t *l_207 = (void*)0;
+ int32_t *l_208 = &l_93[0][3];
+ int32_t *l_209[3][1];
+ int i, j;
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 1; j++)
+ l_209[i][j] = &g_84;
+ }
+ --l_220;
+ for (g_94 = 0; (g_94 <= 3); g_94 += 1)
+ { /* block id: 88 */
+ struct S4 *l_223 = &g_138;
+ struct S4 **l_224 = &l_223;
+ int i, j;
+ if (l_93[(g_94 + 1)][l_146])
+ break;
+ for (l_123 = 0; (l_123 <= 3); l_123 += 1)
+ { /* block id: 92 */
+ if (p_59)
+ break;
+ }
+ (*l_224) = l_223;
+ }
+ return l_225;
+ }
+ }
+ return l_225;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads :
+ * writes:
+ */
+static struct S1 * func_64(struct S1 * const p_65, struct S1 * p_66, struct S1 * p_67)
+{ /* block id: 9 */
+ struct S5 *l_68 = &g_69;
+ struct S5 **l_70 = &l_68;
+ int32_t l_71 = 1L;
+ (*l_70) = l_68;
+ l_71 &= (-1L);
+ return p_66;
+}
+
+
+
+
+/* ---------------------------------------- */
+int main (int argc, char* argv[])
+{
+ int i, j, k;
+ int print_hash_value = 0;
+ if (argc == 2 && strcmp(argv[1], "1") == 0) print_hash_value = 1;
+ platform_main_begin();
+ crc32_gentab();
+ func_1();
+ transparent_crc(g_22.f0, "g_22.f0", print_hash_value);
+ transparent_crc(g_22.f1, "g_22.f1", print_hash_value);
+ transparent_crc(g_23, "g_23", print_hash_value);
+ for (i = 0; i < 8; i++)
+ {
+ for (j = 0; j < 10; j++)
+ {
+ for (k = 0; k < 3; k++)
+ {
+ transparent_crc(g_43[i][j][k].f0, "g_43[i][j][k].f0", print_hash_value);
+ transparent_crc(g_43[i][j][k].f1, "g_43[i][j][k].f1", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
+
+ }
+ }
+ }
+ transparent_crc(g_69.f0, "g_69.f0", print_hash_value);
+ transparent_crc(g_69.f1, "g_69.f1", print_hash_value);
+ transparent_crc(g_69.f2.f0, "g_69.f2.f0", print_hash_value);
+ transparent_crc(g_69.f2.f1, "g_69.f2.f1", print_hash_value);
+ transparent_crc(g_69.f2.f2, "g_69.f2.f2", print_hash_value);
+ transparent_crc(g_69.f2.f3, "g_69.f2.f3", print_hash_value);
+ transparent_crc(g_69.f2.f4, "g_69.f2.f4", print_hash_value);
+ transparent_crc(g_69.f2.f5, "g_69.f2.f5", print_hash_value);
+ transparent_crc(g_69.f2.f6, "g_69.f2.f6", print_hash_value);
+ transparent_crc(g_69.f2.f7, "g_69.f2.f7", print_hash_value);
+ transparent_crc(g_69.f2.f8, "g_69.f2.f8", print_hash_value);
+ transparent_crc(g_69.f2.f9, "g_69.f2.f9", print_hash_value);
+ transparent_crc(g_69.f3, "g_69.f3", print_hash_value);
+ transparent_crc(g_84, "g_84", print_hash_value);
+ transparent_crc(g_85, "g_85", print_hash_value);
+ transparent_crc(g_94, "g_94", print_hash_value);
+ transparent_crc(g_109, "g_109", print_hash_value);
+ transparent_crc(g_111.f0, "g_111.f0", print_hash_value);
+ transparent_crc(g_111.f1, "g_111.f1", print_hash_value);
+ transparent_crc(g_111.f2, "g_111.f2", print_hash_value);
+ transparent_crc(g_111.f3, "g_111.f3", print_hash_value);
+ transparent_crc(g_111.f4, "g_111.f4", print_hash_value);
+ transparent_crc(g_111.f5, "g_111.f5", print_hash_value);
+ transparent_crc(g_111.f6, "g_111.f6", print_hash_value);
+ transparent_crc(g_111.f7, "g_111.f7", print_hash_value);
+ transparent_crc(g_111.f8, "g_111.f8", print_hash_value);
+ transparent_crc(g_111.f9, "g_111.f9", print_hash_value);
+ transparent_crc(g_113.f0, "g_113.f0", print_hash_value);
+ transparent_crc(g_113.f1, "g_113.f1", print_hash_value);
+ transparent_crc(g_113.f2, "g_113.f2", print_hash_value);
+ transparent_crc(g_113.f3, "g_113.f3", print_hash_value);
+ transparent_crc(g_113.f4, "g_113.f4", print_hash_value);
+ transparent_crc(g_113.f5, "g_113.f5", print_hash_value);
+ transparent_crc(g_113.f6, "g_113.f6", print_hash_value);
+ transparent_crc(g_113.f7, "g_113.f7", print_hash_value);
+ transparent_crc(g_113.f8, "g_113.f8", print_hash_value);
+ transparent_crc(g_113.f9, "g_113.f9", print_hash_value);
+ transparent_crc(g_131, "g_131", print_hash_value);
+ transparent_crc(g_138.f0.f0, "g_138.f0.f0", print_hash_value);
+ transparent_crc(g_138.f0.f1, "g_138.f0.f1", print_hash_value);
+ transparent_crc(g_138.f0.f2, "g_138.f0.f2", print_hash_value);
+ transparent_crc(g_138.f0.f3, "g_138.f0.f3", print_hash_value);
+ transparent_crc(g_138.f0.f4, "g_138.f0.f4", print_hash_value);
+ transparent_crc(g_138.f0.f5, "g_138.f0.f5", print_hash_value);
+ transparent_crc(g_138.f0.f6, "g_138.f0.f6", print_hash_value);
+ transparent_crc(g_138.f0.f7, "g_138.f0.f7", print_hash_value);
+ transparent_crc(g_138.f0.f8, "g_138.f0.f8", print_hash_value);
+ transparent_crc(g_138.f0.f9, "g_138.f0.f9", print_hash_value);
+ transparent_crc(g_138.f1, "g_138.f1", print_hash_value);
+ transparent_crc(g_153.f0, "g_153.f0", print_hash_value);
+ transparent_crc(g_153.f1, "g_153.f1", print_hash_value);
+ transparent_crc(g_153.f2, "g_153.f2", print_hash_value);
+ transparent_crc(g_153.f3, "g_153.f3", print_hash_value);
+ transparent_crc(g_182.f0, "g_182.f0", print_hash_value);
+ transparent_crc(g_182.f1, "g_182.f1", print_hash_value);
+ transparent_crc(g_182.f2, "g_182.f2", print_hash_value);
+ transparent_crc(g_182.f3, "g_182.f3", print_hash_value);
+ transparent_crc(g_182.f4, "g_182.f4", print_hash_value);
+ transparent_crc(g_182.f5, "g_182.f5", print_hash_value);
+ transparent_crc(g_182.f6, "g_182.f6", print_hash_value);
+ transparent_crc(g_182.f7, "g_182.f7", print_hash_value);
+ transparent_crc(g_182.f8, "g_182.f8", print_hash_value);
+ transparent_crc(g_182.f9, "g_182.f9", print_hash_value);
+ transparent_crc(g_214, "g_214", print_hash_value);
+ transparent_crc(g_253, "g_253", print_hash_value);
+ transparent_crc(g_274, "g_274", print_hash_value);
+ transparent_crc(g_349.f0, "g_349.f0", print_hash_value);
+ transparent_crc(g_349.f1, "g_349.f1", print_hash_value);
+ transparent_crc(g_349.f2, "g_349.f2", print_hash_value);
+ transparent_crc(g_349.f3, "g_349.f3", print_hash_value);
+ transparent_crc(g_349.f4, "g_349.f4", print_hash_value);
+ transparent_crc(g_349.f5, "g_349.f5", print_hash_value);
+ transparent_crc(g_349.f6, "g_349.f6", print_hash_value);
+ transparent_crc(g_349.f7, "g_349.f7", print_hash_value);
+ transparent_crc(g_349.f8, "g_349.f8", print_hash_value);
+ transparent_crc(g_357.f0, "g_357.f0", print_hash_value);
+ transparent_crc(g_357.f1, "g_357.f1", print_hash_value);
+ transparent_crc(g_357.f2, "g_357.f2", print_hash_value);
+ transparent_crc(g_357.f3, "g_357.f3", print_hash_value);
+ transparent_crc(g_357.f4, "g_357.f4", print_hash_value);
+ transparent_crc(g_357.f5, "g_357.f5", print_hash_value);
+ transparent_crc(g_357.f6, "g_357.f6", print_hash_value);
+ transparent_crc(g_357.f7, "g_357.f7", print_hash_value);
+ transparent_crc(g_357.f8, "g_357.f8", print_hash_value);
+ transparent_crc(g_357.f9, "g_357.f9", print_hash_value);
+ for (i = 0; i < 4; i++)
+ {
+ transparent_crc(g_494[i], "g_494[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ for (i = 0; i < 8; i++)
+ {
+ transparent_crc(g_518[i].f0.f0, "g_518[i].f0.f0", print_hash_value);
+ transparent_crc(g_518[i].f0.f1, "g_518[i].f0.f1", print_hash_value);
+ transparent_crc(g_518[i].f0.f2, "g_518[i].f0.f2", print_hash_value);
+ transparent_crc(g_518[i].f0.f3, "g_518[i].f0.f3", print_hash_value);
+ transparent_crc(g_518[i].f0.f4, "g_518[i].f0.f4", print_hash_value);
+ transparent_crc(g_518[i].f0.f5, "g_518[i].f0.f5", print_hash_value);
+ transparent_crc(g_518[i].f0.f6, "g_518[i].f0.f6", print_hash_value);
+ transparent_crc(g_518[i].f0.f7, "g_518[i].f0.f7", print_hash_value);
+ transparent_crc(g_518[i].f0.f8, "g_518[i].f0.f8", print_hash_value);
+ transparent_crc(g_518[i].f0.f9, "g_518[i].f0.f9", print_hash_value);
+ transparent_crc(g_518[i].f1, "g_518[i].f1", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ for (i = 0; i < 5; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
+ for (k = 0; k < 4; k++)
+ {
+ transparent_crc(g_521[i][j][k].f0.f0, "g_521[i][j][k].f0.f0", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f1, "g_521[i][j][k].f0.f1", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f2, "g_521[i][j][k].f0.f2", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f3, "g_521[i][j][k].f0.f3", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f4, "g_521[i][j][k].f0.f4", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f5, "g_521[i][j][k].f0.f5", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f6, "g_521[i][j][k].f0.f6", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f7, "g_521[i][j][k].f0.f7", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f8, "g_521[i][j][k].f0.f8", print_hash_value);
+ transparent_crc(g_521[i][j][k].f0.f9, "g_521[i][j][k].f0.f9", print_hash_value);
+ transparent_crc(g_521[i][j][k].f1, "g_521[i][j][k].f1", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
+
+ }
+ }
+ }
+ transparent_crc(g_599, "g_599", print_hash_value);
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ transparent_crc(g_601[i][j], "g_601[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ transparent_crc(g_745, "g_745", print_hash_value);
+ transparent_crc(g_763, "g_763", print_hash_value);
+ transparent_crc(g_798, "g_798", print_hash_value);
+ transparent_crc(g_809, "g_809", print_hash_value);
+ transparent_crc(g_903.f0.f0, "g_903.f0.f0", print_hash_value);
+ transparent_crc(g_903.f0.f1, "g_903.f0.f1", print_hash_value);
+ transparent_crc(g_903.f0.f2, "g_903.f0.f2", print_hash_value);
+ transparent_crc(g_903.f0.f3, "g_903.f0.f3", print_hash_value);
+ transparent_crc(g_903.f0.f4, "g_903.f0.f4", print_hash_value);
+ transparent_crc(g_903.f0.f5, "g_903.f0.f5", print_hash_value);
+ transparent_crc(g_903.f0.f6, "g_903.f0.f6", print_hash_value);
+ transparent_crc(g_903.f0.f7, "g_903.f0.f7", print_hash_value);
+ transparent_crc(g_903.f0.f8, "g_903.f0.f8", print_hash_value);
+ transparent_crc(g_903.f0.f9, "g_903.f0.f9", print_hash_value);
+ transparent_crc(g_903.f1, "g_903.f1", print_hash_value);
+ for (i = 0; i < 6; i++)
+ {
+ transparent_crc(g_922[i], "g_922[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_1001.f0.f0, "g_1001.f0.f0", print_hash_value);
+ transparent_crc(g_1001.f0.f1, "g_1001.f0.f1", print_hash_value);
+ transparent_crc(g_1001.f0.f2, "g_1001.f0.f2", print_hash_value);
+ transparent_crc(g_1001.f0.f3, "g_1001.f0.f3", print_hash_value);
+ transparent_crc(g_1001.f0.f4, "g_1001.f0.f4", print_hash_value);
+ transparent_crc(g_1001.f0.f5, "g_1001.f0.f5", print_hash_value);
+ transparent_crc(g_1001.f0.f6, "g_1001.f0.f6", print_hash_value);
+ transparent_crc(g_1001.f0.f7, "g_1001.f0.f7", print_hash_value);
+ transparent_crc(g_1001.f0.f8, "g_1001.f0.f8", print_hash_value);
+ transparent_crc(g_1001.f0.f9, "g_1001.f0.f9", print_hash_value);
+ transparent_crc(g_1001.f1, "g_1001.f1", print_hash_value);
+ transparent_crc(g_1017.f0, "g_1017.f0", print_hash_value);
+ transparent_crc(g_1017.f1, "g_1017.f1", print_hash_value);
+ transparent_crc(g_1017.f2.f0, "g_1017.f2.f0", print_hash_value);
+ transparent_crc(g_1017.f2.f1, "g_1017.f2.f1", print_hash_value);
+ transparent_crc(g_1017.f2.f2, "g_1017.f2.f2", print_hash_value);
+ transparent_crc(g_1017.f2.f3, "g_1017.f2.f3", print_hash_value);
+ transparent_crc(g_1017.f2.f4, "g_1017.f2.f4", print_hash_value);
+ transparent_crc(g_1017.f2.f5, "g_1017.f2.f5", print_hash_value);
+ transparent_crc(g_1017.f2.f6, "g_1017.f2.f6", print_hash_value);
+ transparent_crc(g_1017.f2.f7, "g_1017.f2.f7", print_hash_value);
+ transparent_crc(g_1017.f2.f8, "g_1017.f2.f8", print_hash_value);
+ transparent_crc(g_1017.f2.f9, "g_1017.f2.f9", print_hash_value);
+ transparent_crc(g_1017.f3, "g_1017.f3", print_hash_value);
+ platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
+ return 0;
+}
+
+/************************ statistics *************************
+XXX max struct depth: 2
+breakdown:
+ depth: 0, occurrence: 261
+ depth: 1, occurrence: 31
+ depth: 2, occurrence: 14
+XXX total union variables: 0
+
+XXX non-zero bitfields defined in structs: 23
+XXX zero bitfields defined in structs: 0
+XXX const bitfields defined in structs: 5
+XXX volatile bitfields defined in structs: 0
+XXX structs with bitfields in the program: 66
+breakdown:
+ indirect level: 0, occurrence: 35
+ indirect level: 1, occurrence: 25
+ indirect level: 2, occurrence: 6
+XXX full-bitfields structs in the program: 16
+breakdown:
+ indirect level: 0, occurrence: 16
+XXX times a bitfields struct's address is taken: 89
+XXX times a bitfields struct on LHS: 8
+XXX times a bitfields struct on RHS: 69
+XXX times a single bitfield on LHS: 10
+XXX times a single bitfield on RHS: 131
+
+XXX max expression depth: 37
+breakdown:
+ depth: 1, occurrence: 153
+ depth: 2, occurrence: 53
+ depth: 3, occurrence: 2
+ depth: 4, occurrence: 5
+ depth: 6, occurrence: 3
+ depth: 7, occurrence: 1
+ depth: 9, occurrence: 1
+ depth: 10, occurrence: 1
+ depth: 12, occurrence: 1
+ depth: 17, occurrence: 2
+ depth: 19, occurrence: 2
+ depth: 20, occurrence: 2
+ depth: 22, occurrence: 1
+ depth: 24, occurrence: 2
+ depth: 25, occurrence: 2
+ depth: 27, occurrence: 4
+ depth: 29, occurrence: 2
+ depth: 33, occurrence: 1
+ depth: 35, occurrence: 1
+ depth: 37, occurrence: 1
+
+XXX total number of pointers: 257
+
+XXX times a variable address is taken: 468
+XXX times a pointer is dereferenced on RHS: 95
+breakdown:
+ depth: 1, occurrence: 91
+ depth: 2, occurrence: 4
+XXX times a pointer is dereferenced on LHS: 124
+breakdown:
+ depth: 1, occurrence: 120
+ depth: 2, occurrence: 4
+XXX times a pointer is compared with null: 12
+XXX times a pointer is compared with address of another variable: 2
+XXX times a pointer is compared with another pointer: 5
+XXX times a pointer is qualified to be dereferenced: 3560
+
+XXX max dereference level: 3
+breakdown:
+ level: 0, occurrence: 0
+ level: 1, occurrence: 756
+ level: 2, occurrence: 89
+ level: 3, occurrence: 4
+XXX number of pointers point to pointers: 71
+XXX number of pointers point to scalars: 126
+XXX number of pointers point to structs: 60
+XXX percent of pointers has null in alias set: 25.3
+XXX average alias set size: 1.37
+
+XXX times a non-volatile is read: 778
+XXX times a non-volatile is write: 446
+XXX times a volatile is read: 0
+XXX times read thru a pointer: 0
+XXX times a volatile is write: 0
+XXX times written thru a pointer: 0
+XXX times a volatile is available for access: 0
+XXX percentage of non-volatile access: 100
+
+XXX forward jumps: 0
+XXX backward jumps: 3
+
+XXX stmts: 166
+XXX max block depth: 5
+breakdown:
+ depth: 0, occurrence: 26
+ depth: 1, occurrence: 16
+ depth: 2, occurrence: 19
+ depth: 3, occurrence: 31
+ depth: 4, occurrence: 40
+ depth: 5, occurrence: 34
+
+XXX percentage a fresh-made variable is used: 19.7
+XXX percentage an existing variable is used: 80.3
+FYI: the random generator makes assumptions about the integer size. See platform.info for more details.
+********************* end of statistics **********************/
+
diff --git a/tests/fuzz/16.c.txt b/tests/fuzz/16.c.txt
new file mode 100644
index 00000000..222e3adc
--- /dev/null
+++ b/tests/fuzz/16.c.txt
@@ -0,0 +1 @@
+checksum = 8C69559B
diff --git a/tests/fuzz/17.c b/tests/fuzz/17.c
new file mode 100644
index 00000000..25b3028e
--- /dev/null
+++ b/tests/fuzz/17.c
@@ -0,0 +1,982 @@
+/*
+ * This is a RANDOMLY GENERATED PROGRAM.
+ *
+ * Generator: csmith 2.2.0
+ * Git version: bf42ffd
+ * Options: --no-volatiles --no-math64 --no-packed-struct
+ * Seed: 3580928136
+ */
+
+#include "csmith.h"
+
+
+static long __undefined;
+
+/* --- Struct/Union Declarations --- */
+struct S0 {
+ const uint16_t f0;
+ int8_t f1;
+ int16_t f2;
+ const int8_t f3;
+ int32_t f4;
+};
+
+struct S1 {
+ unsigned f0 : 15;
+ signed f1 : 17;
+ signed f2 : 2;
+ const unsigned f3 : 30;
+ signed f4 : 20;
+};
+
+/* --- GLOBAL VARIABLES --- */
+static int32_t g_3[6] = {0x99D94B4BL,0x99D94B4BL,0x99D94B4BL,0x99D94B4BL,0x99D94B4BL,0x99D94B4BL};
+static int32_t g_5 = (-1L);
+static uint16_t g_6[10] = {0xD814L,0x4B54L,0xD814L,0xD814L,0x4B54L,0xD814L,0xD814L,0x4B54L,0xD814L,0xD814L};
+static int32_t g_11 = 0L;
+static int32_t g_12 = 0xBD4856CDL;
+static int32_t g_15 = (-1L);
+static int16_t g_20 = 0xE3D4L;
+static int32_t *g_54 = &g_3[0];
+static int32_t **g_53 = &g_54;
+static struct S1 g_68 = {97,-181,0,30095,273};
+static int8_t g_83 = 0x24L;
+static int32_t g_90 = 0xA07F58E9L;
+static struct S0 g_92[6][4][9] = {{{{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L}},{{0x8624L,1L,1L,-1L,0xD6B41A24L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65535UL,0x4CL,-1L,-1L,1L},{65535UL,0x4CL,-1L,-1L,1L},{65530UL,-1L,8L,3L,0xCB4F9107L},{0x8624L,1L,1L,-1L,0xD6B41A24L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65535UL,0x4CL,-1L,-1L,1L},{65535UL,0x4CL,-1L,-1L,1L}},{{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L}},{{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,0x4CL,-1L,-1L,1L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL}}},{{{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L}},{{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL}},{{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{65535UL,-4L,0L,-1L,0x3BBBF133L}},{{0x8624L,1L,1L,-1L,0xD6B41A24L},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L}}},{{{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L}},{{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,0x4CL,-1L,-1L,1L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,0x4CL,-1L,-1L,1L}},{{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L}},{{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65530UL,-1L,8L,3L,0xCB4F9107L}}},{{{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L}},{{65535UL,0x4CL,-1L,-1L,1L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,0x4CL,-1L,-1L,1L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL}},{{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L}},{{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL}}},{{{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{65535UL,-4L,0L,-1L,0x3BBBF133L}},{{0x8624L,1L,1L,-1L,0xD6B41A24L},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0x8624L,1L,1L,-1L,0xD6B41A24L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65530UL,-1L,8L,3L,0xCB4F9107L}},{{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x78D3L,0L,0x3BA0L,0x38L,-1L},{0x85E4L,0xCFL,0x1528L,0x9DL,0xD8B2F938L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L}},{{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,0x4CL,-1L,-1L,1L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,0x4CL,-1L,-1L,1L}}},{{{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L}},{{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65530UL,-1L,8L,3L,0xCB4F9107L},{65530UL,-1L,8L,3L,0xCB4F9107L}},{{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x3FE2L,0xFCL,0x2E64L,-4L,0xAE891756L},{0x68CBL,0x47L,-8L,0x60L,0x879556C6L},{65535UL,-4L,0L,-1L,0x3BBBF133L}},{{65535UL,0x4CL,-1L,-1L,1L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL},{65535UL,0x4CL,-1L,-1L,1L},{65535UL,-1L,6L,1L,0x50DEC7D6L},{65535UL,0x4CL,-1L,-1L,1L},{0xE1C3L,-9L,-8L,-1L,0x4BB8EBACL}}}};
+static struct S0 *g_91 = &g_92[3][1][3];
+static int32_t *g_94 = &g_90;
+static int32_t g_97 = 0L;
+static const int32_t *g_130 = (void*)0;
+static const int32_t **g_129[4] = {(void*)0,(void*)0,(void*)0,(void*)0};
+static uint16_t g_150 = 0xD7ECL;
+static uint32_t g_156[6][8] = {{4294967295UL,0x5E426DA7L,5UL,0x5E426DA7L,0UL,0UL,0x5E426DA7L,5UL},{0UL,0UL,0x5E426DA7L,5UL,0x5E426DA7L,0UL,0UL,0x5E426DA7L},{0x43A2B23CL,0x5E426DA7L,0x5E426DA7L,0x43A2B23CL,4294967295UL,0x43A2B23CL,0x5E426DA7L,0x5E426DA7L},{0x5E426DA7L,4294967295UL,5UL,5UL,4294967295UL,0x5E426DA7L,4294967295UL,5UL},{0x43A2B23CL,4294967295UL,0x43A2B23CL,0x5E426DA7L,0x5E426DA7L,0x43A2B23CL,4294967295UL,0x43A2B23CL},{0UL,0x5E426DA7L,5UL,0x5E426DA7L,0UL,0UL,0x5E426DA7L,5UL}};
+static int32_t *g_185 = &g_97;
+static int32_t **g_184 = &g_185;
+static uint32_t g_213 = 2UL;
+static int8_t ***g_272 = (void*)0;
+static uint16_t g_278[1][4] = {{65535UL,65535UL,65535UL,65535UL}};
+static uint8_t g_294 = 0x8DL;
+static int8_t g_353 = 0x6DL;
+static uint32_t g_356 = 0UL;
+static const uint16_t g_357 = 0xF420L;
+static int8_t g_359[4] = {0x2CL,0x2CL,0x2CL,0x2CL};
+static uint32_t g_428 = 0x0034FCF9L;
+static const struct S1 g_433 = {96,257,-1,30005,-437};
+static const struct S1 *g_432 = &g_433;
+static uint32_t g_489 = 0UL;
+static uint32_t g_504 = 0x38500FCCL;
+static uint32_t g_518 = 0x7A80F367L;
+static int32_t g_544[9][4] = {{0x433C63A2L,0xE3D1AC7EL,6L,0L},{5L,6L,0xFD45AB81L,0xBDED5D88L},{6L,0x433C63A2L,0x00D2AF56L,0x00D2AF56L},{6L,6L,0xFD45AB81L,0xD4E567DBL},{5L,0x00D2AF56L,6L,6L},{0x433C63A2L,7L,(-4L),6L},{0L,7L,0L,6L},{7L,0x00D2AF56L,0x7AF8F90EL,0xD4E567DBL},{0xD4E567DBL,6L,0x433C63A2L,0x00D2AF56L}};
+static struct S0 g_576 = {65535UL,-1L,0L,0x7CL,-3L};
+static int32_t g_584 = 0xEF0DB528L;
+static int32_t ***g_667 = (void*)0;
+static int32_t ****g_666[5][4] = {{&g_667,&g_667,&g_667,&g_667},{&g_667,&g_667,&g_667,&g_667},{&g_667,&g_667,&g_667,&g_667},{&g_667,&g_667,&g_667,&g_667},{&g_667,&g_667,&g_667,&g_667}};
+static int8_t g_698 = 0x03L;
+static int32_t g_760 = (-1L);
+static uint8_t *g_780 = &g_294;
+static uint8_t **g_779 = &g_780;
+static uint8_t **g_785[3][2] = {{&g_780,(void*)0},{(void*)0,&g_780},{(void*)0,(void*)0}};
+static int8_t g_857[1][9][4] = {{{0xEBL,(-1L),0xEBL,0xEBL},{(-1L),(-1L),(-1L),(-1L)},{(-1L),0xEBL,0xEBL,(-1L)},{0xEBL,(-1L),0xEBL,0xEBL},{(-1L),(-1L),(-1L),(-1L)},{(-1L),0xEBL,0xEBL,(-1L)},{0xEBL,(-1L),0xEBL,0xEBL},{(-1L),(-1L),(-1L),(-1L)},{(-1L),0xEBL,0xEBL,(-1L)}}};
+static struct S1 g_905[7] = {{91,303,0,27868,-625},{91,303,0,27868,-625},{91,303,0,27868,-625},{91,303,0,27868,-625},{91,303,0,27868,-625},{91,303,0,27868,-625},{91,303,0,27868,-625}};
+static struct S0 **g_910 = &g_91;
+static struct S0 ***g_909 = &g_910;
+static uint32_t g_1042 = 4294967288UL;
+static uint32_t g_1058 = 0UL;
+static uint32_t g_1138[10] = {0x2CC729EFL,0x2CC729EFL,0x2CC729EFL,0x2CC729EFL,0x2CC729EFL,0x2CC729EFL,0x2CC729EFL,0x2CC729EFL,0x2CC729EFL,0x2CC729EFL};
+static uint32_t *g_1145 = &g_1138[0];
+static uint32_t **g_1144 = &g_1145;
+static int32_t g_1225 = 0xC7C95C74L;
+static int32_t g_1239 = 0x41BFFEA5L;
+static int8_t g_1257[8] = {5L,0x31L,5L,0x31L,5L,0x31L,5L,0x31L};
+static int16_t g_1261 = 0x1F90L;
+static struct S0 **g_1294 = (void*)0;
+static uint32_t *g_1339 = &g_1042;
+static uint32_t **g_1338[3] = {&g_1339,&g_1339,&g_1339};
+static int16_t *g_1372 = &g_1261;
+static int16_t **g_1371 = &g_1372;
+static uint8_t ***g_1386 = &g_785[1][0];
+static uint8_t g_1402[5] = {255UL,255UL,255UL,255UL,255UL};
+static const int32_t g_1436 = 0x93A97107L;
+static int32_t *g_1450[5] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
+static uint8_t g_1682 = 1UL;
+static uint8_t * const g_1681 = &g_1682;
+static uint8_t * const *g_1680 = &g_1681;
+static uint8_t * const **g_1679 = &g_1680;
+static uint8_t * const ***g_1678[8][6][4] = {{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}},{{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0},{(void*)0,(void*)0,(void*)0,(void*)0}}};
+static int32_t g_1695[4][5][9] = {{{(-6L),0x427FB25DL,(-1L),0x073E8F67L,8L,1L,3L,0x537E2500L,0x56EAC977L},{0xD85C7FAFL,0x5DB9A4CCL,(-6L),0x073E8F67L,(-7L),8L,3L,9L,0xAD915C69L},{0x903CDB84L,3L,0x0AE52047L,(-1L),1L,1L,(-1L),0x0AE52047L,3L},{0x0C02BF6DL,0xE4C26D6EL,(-1L),1L,(-1L),(-1L),0x0653B189L,0L,0xE5196C37L},{0x2B93F6CCL,0L,0x073E8F67L,(-1L),(-1L),(-7L),0x58D09167L,(-6L),(-1L)}},{{8L,0xE4C26D6EL,1L,(-1L),0x58D09167L,0L,(-10L),0x2B93F6CCL,0L},{0x9B61D6B7L,3L,0xE5196C37L,0x21E388DCL,5L,0x427FB25DL,0L,(-10L),(-7L)},{0x537E2500L,0x5DB9A4CCL,0x2A65B087L,0x85E59DB9L,0xB966E758L,1L,1L,1L,(-7L)},{0x073E8F67L,0x427FB25DL,0x21E388DCL,0x0AE52047L,1L,(-1L),0L,5L,0L},{(-6L),9L,0L,0L,9L,(-6L),0x2B93F6CCL,0xD85C7FAFL,(-1L)}},{{0L,(-1L),0x2B93F6CCL,0x427FB25DL,0x0C02BF6DL,0L,0x0AE52047L,(-1L),0xE5196C37L},{0xDEA2987DL,(-1L),0x046970CFL,(-1L),0x537E2500L,(-6L),0x2B93F6CCL,0x9B61D6B7L,3L},{1L,(-1L),0x58D09167L,0L,(-10L),0x2B93F6CCL,0L,0x427FB25DL,0xAD915C69L},{1L,0xFB6358FBL,0x5DB9A4CCL,3L,(-1L),0xAD915C69L,1L,(-2L),0x56EAC977L},{8L,0x0AE52047L,5L,(-1L),(-1L),0xB966E758L,0L,1L,(-1L)}},{{(-1L),1L,(-1L),0x58D09167L,(-10L),3L,(-10L),0x58D09167L,(-1L)},{0x56EAC977L,0x56EAC977L,0x903CDB84L,8L,0x537E2500L,0xE4C26D6EL,0x58D09167L,1L,0x21E388DCL},{0x58D09167L,0xCDBE185FL,(-2L),(-9L),0x0C02BF6DL,(-1L),0x0653B189L,(-1L),1L},{(-1L),1L,0x903CDB84L,0xE5196C37L,9L,0xFB6358FBL,(-1L),(-1L),0L},{0x05DCEBBBL,8L,(-1L),0xD85C7FAFL,1L,0x0368BC60L,3L,0x046970CFL,0xFB6358FBL}}};
+static int8_t g_2022 = 0L;
+static int32_t g_2037 = 0L;
+static uint32_t g_2052 = 0x9C7F09F6L;
+static uint32_t ***g_2099 = (void*)0;
+
+
+/* --- FORWARD DECLARATIONS --- */
+static uint32_t func_1(void);
+static int32_t ** func_13(int32_t * p_14);
+static int32_t func_21(int32_t ** p_22, int32_t * const p_23, int8_t p_24);
+static int32_t ** func_25(int32_t * p_26, int32_t ** p_27, int16_t p_28, int16_t p_29);
+static int32_t * func_30(int32_t p_31, int32_t * p_32, struct S0 p_33, int32_t ** p_34);
+static uint8_t func_40(int32_t p_41);
+static struct S1 func_47(int32_t * p_48);
+static int32_t * func_49(int32_t ** p_50, int16_t p_51, struct S0 p_52);
+static struct S0 func_60(int32_t p_61);
+static struct S0 * func_62(struct S1 p_63, uint32_t p_64, uint32_t p_65, int32_t ** const p_66, int32_t ** p_67);
+
+
+/* --- FUNCTIONS --- */
+/* ------------------------------------------ */
+/*
+ * reads : g_92.f2 g_53 g_54 g_1680 g_1681 g_1682 g_94 g_3 g_15 g_90 g_1257 g_432 g_433 g_68 g_6 g_83 g_20 g_91 g_97 g_92 g_780 g_294 g_2022 g_2037 g_1679 g_150 g_1371 g_1372 g_1261 g_779 g_2052 g_1339 g_1042 g_359 g_1239 g_910
+ * writes: g_3 g_1261 g_92.f2 g_83 g_15 g_1257 g_90 g_91 g_94 g_97 g_2022 g_1682 g_294 g_1042 g_428 g_54 g_20 g_584 g_2099 g_1450 g_504
+ */
+static uint32_t func_1(void)
+{ /* block id: 0 */
+ int32_t l_2[10] = {0L,0L,0L,0L,0L,0L,0L,0L,0L,0L};
+ int32_t **l_1500 = &g_185;
+ uint16_t l_1513 = 0x73BAL;
+ int32_t l_1564 = 0x551E51B6L;
+ int32_t l_1578 = 0L;
+ int32_t **l_1609 = &g_1450[4];
+ int32_t l_1653 = 0x77865CC7L;
+ int32_t l_1656 = 0L;
+ int32_t l_1658[2][4] = {{4L,4L,4L,4L},{4L,4L,4L,4L}};
+ int32_t l_1696 = (-7L);
+ uint16_t l_1759 = 1UL;
+ int8_t *l_1783 = &g_1257[1];
+ int8_t **l_1782[6] = {(void*)0,&l_1783,&l_1783,(void*)0,&l_1783,&l_1783};
+ int32_t *l_1801[3];
+ struct S0 l_1802 = {0x3C70L,0L,0xE823L,0xB4L,8L};
+ int16_t l_1835 = 0x24A2L;
+ uint8_t l_1868 = 0x8EL;
+ struct S0 **l_1881[6][2];
+ uint8_t l_1908 = 0x6CL;
+ struct S1 *l_1958[6] = {&g_68,&g_68,&g_68,&g_68,&g_68,&g_68};
+ struct S1 **l_1957[10] = {&l_1958[0],&l_1958[0],&l_1958[0],&l_1958[0],&l_1958[0],&l_1958[0],&l_1958[0],&l_1958[0],&l_1958[0],&l_1958[0]};
+ const uint32_t *l_1999 = &g_518;
+ const uint32_t **l_1998 = &l_1999;
+ int32_t ***** const l_2000 = &g_666[1][2];
+ uint16_t l_2002 = 0x939BL;
+ uint32_t l_2004 = 0x02546869L;
+ uint32_t l_2018 = 8UL;
+ uint32_t l_2053 = 0x6D00545FL;
+ uint16_t l_2065 = 0x89B5L;
+ int32_t l_2066[9] = {(-1L),(-1L),(-1L),(-1L),(-1L),(-1L),(-1L),(-1L),(-1L)};
+ uint32_t l_2067 = 0x46071B4CL;
+ uint16_t l_2082 = 2UL;
+ int i, j;
+ for (i = 0; i < 3; i++)
+ l_1801[i] = &l_1658[0][1];
+ for (i = 0; i < 6; i++)
+ {
+ for (j = 0; j < 2; j++)
+ l_1881[i][j] = &g_91;
+ }
+lbl_2105:
+ for (g_3[0] = 1; (g_3[0] <= 9); g_3[0] += 1)
+ { /* block id: 3 */
+ int16_t ***l_1574 = (void*)0;
+ int32_t l_1577 = 0L;
+ int32_t l_1579 = 0L;
+ struct S0 l_1616 = {1UL,0xF6L,6L,7L,0L};
+ uint16_t l_1618 = 0x18F5L;
+ int32_t l_1619 = (-8L);
+ int32_t **l_1621[5][5] = {{(void*)0,&g_185,(void*)0,&g_185,(void*)0},{&g_185,&g_185,&g_185,&g_185,&g_185},{(void*)0,&g_185,(void*)0,&g_185,(void*)0},{&g_185,&g_185,&g_185,&g_185,&g_185},{(void*)0,&g_185,(void*)0,&g_185,(void*)0}};
+ int32_t l_1657 = 5L;
+ int8_t *l_1699 = &g_576.f1;
+ int8_t **l_1698 = &l_1699;
+ int8_t ***l_1697 = &l_1698;
+ uint32_t l_1709 = 1UL;
+ int32_t l_1730 = 0xA4003686L;
+ int32_t l_1731 = 1L;
+ int32_t l_1733 = 8L;
+ int32_t l_1734 = (-1L);
+ int32_t l_1735 = 1L;
+ int32_t l_1736 = 1L;
+ int32_t l_1737 = 0x063BC762L;
+ int32_t l_1738 = 0L;
+ int32_t l_1739 = 0xEE142BBCL;
+ int32_t l_1740[7] = {1L,1L,1L,1L,1L,1L,1L};
+ int16_t l_1748 = 0xC892L;
+ int32_t *l_1803 = &l_1734;
+ const uint8_t ** const ***l_1808 = (void*)0;
+ int32_t ****l_1834 = &g_667;
+ uint32_t l_1849 = 0x5FFDC98BL;
+ uint16_t l_1935 = 0x99F0L;
+ int i, j;
+ }
+ for (g_1261 = 0; (g_1261 >= 11); ++g_1261)
+ { /* block id: 929 */
+ uint32_t l_1947 = 0UL;
+ uint8_t l_2001 = 0xB8L;
+ uint8_t l_2021[1][5];
+ int32_t l_2069 = 0x28203BBBL;
+ int32_t *l_2094 = &g_576.f4;
+ int32_t l_2106 = 0x8F4603E5L;
+ int32_t l_2107 = 0xD7C30BE3L;
+ int32_t l_2108 = 0x7A725D9CL;
+ int32_t l_2109[8] = {0L,0L,0L,0L,0L,0L,0L,0L};
+ uint16_t l_2110 = 0xA6BBL;
+ int i, j;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 5; j++)
+ l_2021[i][j] = 0xE3L;
+ }
+ for (l_1802.f4 = 17; (l_1802.f4 >= 14); l_1802.f4--)
+ { /* block id: 932 */
+ int32_t l_1959 = 0x5C4E9040L;
+ int32_t l_1960 = 0xD082F1F8L;
+ int32_t l_1968 = (-6L);
+ int16_t ***l_1995 = (void*)0;
+ uint32_t *l_2063 = &g_428;
+ uint8_t l_2071 = 0UL;
+ struct S0 l_2097 = {6UL,0x5CL,-1L,0x3FL,2L};
+ int32_t **l_2101 = &l_1801[0];
+ for (l_1802.f2 = 20; (l_1802.f2 == (-10)); --l_1802.f2)
+ { /* block id: 935 */
+ int16_t l_1954 = 0xD64CL;
+ int32_t l_2016 = 0xBD733EEBL;
+ struct S1 *l_2020 = &g_68;
+ l_1960 ^= ((l_1947 >= (safe_lshift_func_uint8_t_u_u(((((safe_rshift_func_int16_t_s_u((g_92[3][1][3].f2 |= (safe_div_func_uint8_t_u_u(0xA5L, l_1954))), 13)) || (safe_sub_func_int16_t_s_s(0xD018L, 65535UL))) , (func_47((*g_53)) , &g_432)) != l_1957[0]), (**g_1680)))) < l_1959);
+ if ((*g_94))
+ { /* block id: 938 */
+ int16_t ****l_1996 = &l_1995;
+ uint32_t l_1997 = 1UL;
+ uint32_t l_2003 = 0x5496A29AL;
+ if ((safe_unary_minus_func_uint8_t_u((safe_div_func_uint8_t_u_u((safe_lshift_func_uint8_t_u_u((safe_sub_func_int8_t_s_s(((*l_1783) &= l_1968), (func_60(((*g_432) , 6L)) , (*g_780)))), 7)), l_2001)))))
+ { /* block id: 942 */
+ l_1960 |= (*g_54);
+ }
+ else
+ { /* block id: 944 */
+ if (l_1968)
+ break;
+ }
+ }
+ else
+ { /* block id: 947 */
+ uint8_t l_2013 = 0xD2L;
+ int16_t *l_2017[5][5][8] = {{{&g_576.f2,&g_576.f2,&l_1954,&g_576.f2,&g_576.f2,&l_1954,&l_1954,&l_1954},{&g_92[3][1][3].f2,&g_576.f2,&l_1835,&l_1835,&g_576.f2,&g_92[3][1][3].f2,&l_1835,&g_576.f2},{&l_1954,&l_1835,&l_1835,&l_1954,&l_1835,&l_1835,&l_1954,&g_92[3][1][3].f2},{&g_576.f2,&g_576.f2,&l_1954,&l_1954,&l_1954,&l_1954,&g_576.f2,&g_576.f2},{&g_92[3][1][3].f2,&l_1954,&l_1835,&l_1835,&l_1954,&l_1835,&l_1835,&l_1954}},{{&g_576.f2,&l_1835,&g_92[3][1][3].f2,&g_576.f2,&l_1835,&l_1835,&g_576.f2,&g_92[3][1][3].f2},{&l_1954,&l_1954,&l_1954,&g_576.f2,&g_576.f2,&l_1954,&g_576.f2,&g_576.f2},{&g_92[3][1][3].f2,&g_576.f2,&g_92[3][1][3].f2,&l_1835,&g_576.f2,&l_1835,&l_1835,&g_576.f2},{&g_576.f2,&l_1835,&l_1835,&g_576.f2,&l_1835,&g_92[3][1][3].f2,&g_576.f2,&g_92[3][1][3].f2},{&g_576.f2,&g_576.f2,&l_1954,&g_576.f2,&g_576.f2,&l_1954,&l_1954,&l_1954}},{{&g_92[3][1][3].f2,&g_576.f2,&l_1835,&l_1835,&g_576.f2,&g_92[3][1][3].f2,&l_1835,&g_576.f2},{&l_1954,&l_1835,&l_1835,&l_1954,&l_1835,&l_1835,&l_1954,&g_92[3][1][3].f2},{&g_576.f2,&g_576.f2,&l_1954,&l_1954,&l_1954,&l_1954,&g_576.f2,&g_576.f2},{&g_92[3][1][3].f2,&l_1954,&l_1835,&l_1835,&l_1954,&l_1835,&l_1835,&g_92[3][1][3].f2},{&l_1835,&l_1954,(void*)0,&l_1835,&g_20,&g_20,&l_1835,(void*)0}},{{&g_92[3][1][3].f2,&g_92[3][1][3].f2,&l_1954,&l_1835,&l_1835,&l_1954,&l_1835,&l_1835},{(void*)0,&l_1835,(void*)0,&g_20,&l_1835,&l_1954,&l_1954,&l_1835},{&l_1835,&l_1954,&l_1954,&l_1835,&g_20,(void*)0,&l_1835,(void*)0},{&l_1835,&l_1835,&l_1954,&l_1835,&l_1835,&l_1954,&g_92[3][1][3].f2,&g_92[3][1][3].f2},{(void*)0,&l_1835,&g_20,&g_20,&l_1835,(void*)0,&l_1954,&l_1835}},{{&g_92[3][1][3].f2,&l_1954,&g_20,&g_92[3][1][3].f2,&g_20,&l_1954,&g_92[3][1][3].f2,(void*)0},{&l_1835,&l_1835,&l_1954,&g_92[3][1][3].f2,&g_92[3][1][3].f2,&l_1954,&l_1835,&l_1835},{(void*)0,&g_92[3][1][3].f2,&l_1954,&g_20,&g_92[3][1][3].f2,&g_20,&l_1954,&g_92[3][1][3].f2},{&l_1835,&l_1954,(void*)0,&l_1835,&g_20,&g_20,&l_1835,(void*)0},{&g_92[3][1][3].f2,&g_92[3][1][3].f2,&l_1954,&l_1835,&l_1835,&l_1954,&l_1835,&l_1835}}};
+ uint16_t *l_2019 = &l_1513;
+ int32_t l_2054 = 0x15864E9CL;
+ int i, j, k;
+ g_2022 &= ((safe_add_func_uint32_t_u_u((0x35C2757CL < l_1959), (safe_mod_func_int8_t_s_s(((*l_1783) = ((safe_mod_func_int8_t_s_s((safe_lshift_func_uint8_t_u_u((((l_2013 , ((*l_2019) &= (safe_rshift_func_int16_t_s_s((l_2018 = l_2016), 0)))) ^ (((func_60(l_2013) , l_2020) != &g_68) && (l_2013 > 0x26F129C6L))) | l_2021[0][1]), 6)), 1L)) ^ 1L)), l_1954)))) <= 1UL);
+ (*g_54) = l_2013;
+ l_2054 |= (safe_mod_func_int32_t_s_s(((safe_div_func_uint16_t_u_u(((((safe_rshift_func_uint16_t_u_s(l_1968, (safe_div_func_uint32_t_u_u((((l_1959 = (safe_lshift_func_int8_t_s_u((safe_sub_func_int16_t_s_s((((l_1960 |= ((**g_779) = (safe_sub_func_int8_t_s_s((g_2037 , (safe_sub_func_int16_t_s_s((((!((safe_sub_func_uint32_t_u_u((safe_lshift_func_uint8_t_u_s(((***g_1679) = (**g_1680)), l_2021[0][1])), ((safe_lshift_func_uint16_t_u_s(g_3[4], 13)) < (safe_sub_func_uint16_t_u_u(65535UL, (((safe_sub_func_uint8_t_u_u((safe_add_func_uint32_t_u_u(l_2016, ((func_60((*g_94)) , (-6L)) && l_1959))), l_1959)) , g_150) | l_2013)))))) && 0x909A7A8FL)) < (-5L)) || 65531UL), (**g_1371)))), l_1954)))) <= 0x83L) | l_2013), 1L)), l_2013))) < 0x0C9DL) < 1L), g_2052)))) || 0x89L) > l_2013) < 0UL), 65534UL)) < l_2001), l_2053));
+ }
+ return (*g_1339);
+ }
+ l_2067 &= (l_2066[2] = (0x57717F14L != (!(safe_add_func_int16_t_s_s(((safe_add_func_int8_t_s_s((0x63L > (safe_mod_func_int32_t_s_s(((*g_54) = (safe_mul_func_int8_t_s_s(l_1959, (((*l_2063) = (+((*g_1339) = 4294967291UL))) >= 0x26BB40F7L)))), 1UL))), l_1947)) >= (safe_unary_minus_func_uint16_t_u(2UL))), ((l_2065 ^ l_1947) <= g_433.f2))))));
+ for (g_428 = 0; (g_428 <= 1); g_428 += 1)
+ { /* block id: 968 */
+ int32_t l_2068 = (-1L);
+ int32_t l_2070 = 0x1F9A11E0L;
+ l_2071--;
+ }
+ if ((safe_mod_func_uint32_t_u_u(l_1959, ((*g_1339) = 4294967292UL))))
+ { /* block id: 972 */
+ uint8_t l_2078 = 2UL;
+ int8_t *l_2087 = &g_2022;
+ for (l_1802.f1 = 0; (l_1802.f1 < 28); l_1802.f1 = safe_add_func_int8_t_s_s(l_1802.f1, 8))
+ { /* block id: 975 */
+ if ((*g_94))
+ break;
+ return l_2078;
+ }
+ for (l_1656 = 0; (l_1656 <= 3); l_1656 += 1)
+ { /* block id: 981 */
+ int32_t *l_2079 = &g_15;
+ int16_t *l_2090 = (void*)0;
+ int16_t *l_2091[6];
+ int i;
+ for (i = 0; i < 6; i++)
+ l_2091[i] = &g_576.f2;
+ if (g_1257[(l_1656 + 2)])
+ break;
+ if (l_2069)
+ break;
+ (*g_53) = l_2079;
+ (*g_54) &= ((safe_mod_func_uint8_t_u_u(l_2082, (safe_mul_func_int8_t_s_s((((safe_sub_func_uint8_t_u_u(0x7DL, ((~(((void*)0 == l_2087) & l_2001)) < (((((safe_lshift_func_uint8_t_u_s(l_2071, 2)) > (~(g_20 |= (*g_1372)))) == g_359[3]) <= ((*g_1680) == (*g_779))) ^ (**g_779))))) != (**g_1680)) <= (*g_1681)), l_2069)))) && (*g_1372));
+ }
+ }
+ else
+ { /* block id: 988 */
+ uint32_t ***l_2098 = (void*)0;
+ int32_t l_2104 = 0L;
+ for (g_584 = (-27); (g_584 > 23); ++g_584)
+ { /* block id: 991 */
+ l_2094 = (*g_53);
+ for (g_15 = 14; (g_15 >= (-7)); g_15 = safe_sub_func_uint32_t_u_u(g_15, 6))
+ { /* block id: 995 */
+ int32_t *l_2100 = &g_544[0][0];
+ (*g_53) = func_30(((*g_1339) > ((-10L) & (l_2097 , (0L && ((g_2099 = l_2098) != (g_1239 , &g_1338[2])))))), ((*l_1609) = l_2100), (*g_91), l_2101);
+ }
+ for (l_1578 = 0; (l_1578 != 0); ++l_1578)
+ { /* block id: 1002 */
+ if (l_2104)
+ break;
+ }
+ }
+ if (g_150)
+ goto lbl_2105;
+ (**l_2101) ^= ((0x77L <= (*g_780)) | 4L);
+ }
+ }
+ (**g_53) |= 0x338F39E1L;
+ l_2110++;
+ }
+ return (*g_1339);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_15 g_12 g_20 g_53 g_294 g_1450 g_1372 g_1261 g_94 g_90 g_3 g_1339 g_1042
+ * writes: g_15 g_20 g_54 g_294 g_83 g_698 g_432 g_1261 g_90
+ */
+static int32_t ** func_13(int32_t * p_14)
+{ /* block id: 16 */
+ struct S0 l_55 = {0x0EABL,1L,0xC62BL,0x19L,-8L};
+ int32_t *l_913 = &g_15;
+ int16_t **l_1374 = &g_1372;
+ int32_t l_1416 = 0x288A7F16L;
+ int32_t l_1417 = 8L;
+ int32_t l_1418 = 0xF05E35F3L;
+ int32_t l_1419 = 0L;
+ int32_t l_1420[10][7] = {{0x02F3AB36L,(-1L),0x02F3AB36L,0x02F3AB36L,(-1L),0x02F3AB36L,0x02F3AB36L},{0x64FCE704L,0x64FCE704L,3L,0x64FCE704L,0x64FCE704L,3L,0x64FCE704L},{(-1L),0x02F3AB36L,0x02F3AB36L,(-1L),0x02F3AB36L,0x02F3AB36L,(-1L)},{8L,0x64FCE704L,8L,8L,0x64FCE704L,8L,8L},{(-1L),(-1L),0xB6B56C67L,(-1L),(-1L),0xB6B56C67L,(-1L)},{0x64FCE704L,8L,8L,0x64FCE704L,8L,8L,0x64FCE704L},{0x02F3AB36L,(-1L),0x02F3AB36L,0x02F3AB36L,(-1L),0x02F3AB36L,0x02F3AB36L},{0x64FCE704L,0x64FCE704L,3L,0x64FCE704L,0x64FCE704L,3L,0x64FCE704L},{(-1L),0x02F3AB36L,0x02F3AB36L,(-1L),0x02F3AB36L,0x02F3AB36L,(-1L)},{8L,0x64FCE704L,8L,8L,0x64FCE704L,8L,8L}};
+ int8_t l_1427 = 0x3FL;
+ int32_t l_1429 = 0x3BD3FFBDL;
+ struct S1 l_1460 = {59,102,-0,21913,-681};
+ int8_t *l_1478 = &g_359[3];
+ int8_t ** const l_1477 = &l_1478;
+ int8_t ** const *l_1476 = &l_1477;
+ int32_t **l_1484 = (void*)0;
+ int i, j;
+ for (g_15 = 0; (g_15 <= 21); g_15++)
+ { /* block id: 19 */
+ int32_t *l_19 = &g_3[0];
+ int32_t **l_18 = &l_19;
+ int32_t l_37 = 0L;
+ uint32_t *l_912 = &g_518;
+ struct S0 l_1360 = {6UL,0xB1L,1L,0x9DL,0L};
+ uint8_t ** const *l_1383[5][8] = {{&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779},{&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779},{&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779},{&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779},{&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779,&g_779}};
+ int32_t l_1413 = (-5L);
+ int32_t l_1414 = 1L;
+ int32_t l_1415 = 0x2585D5A7L;
+ int32_t l_1421 = 0x7D67A841L;
+ int32_t l_1422 = 1L;
+ int32_t l_1423 = 0xA2EE8647L;
+ int32_t l_1424 = 2L;
+ int32_t l_1425 = 0x2EFF0BD9L;
+ int32_t l_1428[2];
+ uint8_t l_1430 = 255UL;
+ struct S0 *l_1439 = (void*)0;
+ uint32_t l_1442 = 0xA45523CEL;
+ int32_t *l_1448 = (void*)0;
+ int32_t *l_1449 = &l_1419;
+ int i, j;
+ for (i = 0; i < 2; i++)
+ l_1428[i] = 0L;
+ (*l_18) = (void*)0;
+ g_20 &= g_12;
+ }
+ (*g_53) = p_14;
+ (*g_53) = &l_1420[4][3];
+ for (g_294 = 0; (g_294 <= 3); g_294 += 1)
+ { /* block id: 705 */
+ int32_t l_1459 = 0x47B85732L;
+ int32_t ***l_1464[10];
+ int8_t * const *l_1480 = &l_1478;
+ int8_t * const **l_1479 = &l_1480;
+ int i;
+ for (i = 0; i < 10; i++)
+ l_1464[i] = (void*)0;
+ (*g_53) = g_1450[2];
+ for (g_83 = 3; (g_83 >= 0); g_83 -= 1)
+ { /* block id: 709 */
+ struct S1 *l_1451 = &g_68;
+ int32_t l_1463 = 0xB66E4D5EL;
+ int8_t *l_1474 = (void*)0;
+ int8_t *l_1475[10] = {(void*)0,(void*)0,&g_353,&l_55.f1,&g_353,(void*)0,(void*)0,&g_353,&l_55.f1,&g_353};
+ int8_t ** const l_1473[9] = {(void*)0,&l_1475[2],(void*)0,(void*)0,&l_1475[2],(void*)0,(void*)0,&l_1475[2],(void*)0};
+ int8_t ** const *l_1472 = &l_1473[1];
+ int8_t ** const **l_1471[1];
+ struct S0 l_1481 = {1UL,-1L,-1L,0x33L,0xFB97AB4BL};
+ int32_t *****l_1482 = (void*)0;
+ uint16_t l_1483 = 0x3C40L;
+ int i;
+ for (i = 0; i < 1; i++)
+ l_1471[i] = &l_1472;
+ for (g_698 = 5; (g_698 >= 1); g_698 -= 1)
+ { /* block id: 712 */
+ struct S1 **l_1452 = &l_1451;
+ struct S1 **l_1453 = (void*)0;
+ struct S1 **l_1454 = (void*)0;
+ g_432 = ((*l_1452) = l_1451);
+ }
+ (*g_94) = ((((*g_1372) = ((((safe_div_func_uint8_t_u_u((((safe_sub_func_int16_t_s_s((((l_1459 & ((&g_666[3][0] != (((((l_1460 , (((safe_mul_func_int16_t_s_s(l_1463, ((void*)0 == l_1464[6]))) ^ ((safe_lshift_func_int16_t_s_u((0xFC449DBAL || (safe_sub_func_uint16_t_u_u((safe_add_func_uint32_t_u_u((+((l_1476 = (void*)0) != l_1479)), (*p_14))), (*g_1372)))), l_1463)) >= 0xE908L)) && l_1459)) && 1UL) == (*p_14)) , l_1481) , l_1482)) == (*l_913))) ^ l_1483) < (*g_94)), 65526UL)) & 0x697DL) & (*l_913)), 0x98L)) <= l_1459) != g_3[0]) >= 65535UL)) > 5UL) && (*g_1339));
+ }
+ }
+ return l_1484;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_428 g_53 g_1338 g_54 g_3
+ * writes: g_428 g_54 g_1338
+ */
+static int32_t func_21(int32_t ** p_22, int32_t * const p_23, int8_t p_24)
+{ /* block id: 630 */
+ int32_t *l_1337 = (void*)0;
+ int32_t l_1342 = (-2L);
+ for (g_428 = 1; (g_428 < 32); g_428++)
+ { /* block id: 633 */
+ uint32_t ***l_1340 = &g_1338[0];
+ int32_t *l_1341[5] = {(void*)0,(void*)0,(void*)0,(void*)0,(void*)0};
+ int i;
+ (*g_53) = l_1337;
+ (*g_53) = l_1337;
+ (*l_1340) = g_1338[0];
+ l_1342 ^= ((void*)0 == (*g_53));
+ }
+ return (*p_23);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_90 g_94 g_15 g_3 g_780 g_294 g_1294 g_909 g_910 g_433.f2 g_857 g_1042 g_353 g_1225 g_504 g_779 g_156 g_83 g_91 g_53 g_54 g_92 g_544
+ * writes: g_90 g_910 g_92.f2 g_294 g_156 g_91
+ */
+static int32_t ** func_25(int32_t * p_26, int32_t ** p_27, int16_t p_28, int16_t p_29)
+{ /* block id: 606 */
+ uint8_t l_1273 = 0UL;
+ int32_t l_1287 = 0x988A4625L;
+ struct S0 **l_1305 = &g_91;
+ struct S0 **l_1307 = &g_91;
+ struct S0 ***l_1306 = &l_1307;
+ int8_t *l_1310[8];
+ int32_t l_1311[4][2] = {{0x85BF4A12L,0x85BF4A12L},{0x85BF4A12L,0x85BF4A12L},{0x85BF4A12L,0x85BF4A12L},{0x85BF4A12L,0x85BF4A12L}};
+ int16_t *l_1314 = &g_92[3][1][3].f2;
+ int32_t l_1315[5][8] = {{0x9A7D1D6DL,0L,0x5D141B90L,0L,0x9A7D1D6DL,1L,1L,0x9A7D1D6DL},{0L,0xFC94235DL,0xFC94235DL,0L,0x5A407FBCL,0x9A7D1D6DL,0x5A407FBCL,0L},{0xFC94235DL,0x5A407FBCL,0xFC94235DL,1L,0x5D141B90L,0x5D141B90L,1L,0xFC94235DL},{0x5A407FBCL,0x5A407FBCL,0x5D141B90L,0x9A7D1D6DL,1L,0x9A7D1D6DL,0x5D141B90L,0x5A407FBCL},{0x5A407FBCL,0xFC94235DL,1L,0x5D141B90L,0x5D141B90L,1L,0xFC94235DL,0x5A407FBCL}};
+ int32_t l_1316[1];
+ uint32_t *l_1317[9] = {&g_428,&g_1042,&g_428,&g_1042,&g_428,&g_1042,&g_428,&g_1042,&g_428};
+ int16_t l_1318[10][5][5] = {{{1L,0xCA09L,0xDB76L,0x9AB2L,(-1L)},{0xC6CFL,0x329AL,0x4616L,1L,0x200DL},{0x27C9L,0xE21FL,(-2L),0x4CF8L,0xF4CDL},{0x8A57L,0x657FL,0xAC44L,1L,7L},{0x1E8AL,0xAF8AL,0xEE93L,0x4D00L,0xB5C3L}},{{0x924DL,0L,1L,0x0C44L,0xB5C3L},{(-8L),0L,0xC6CFL,0x200DL,7L},{(-4L),0x200DL,0x4CF8L,0xEAF3L,0xF4CDL},{(-5L),0xAC44L,0x2C37L,(-5L),0x200DL},{0xAF8AL,1L,0x97E4L,0x4E6EL,(-1L)}},{{0xE21FL,0x9AB2L,(-1L),(-1L),0x97E4L},{0x4616L,0xD6BDL,5L,0xD2F8L,(-5L)},{7L,1L,(-8L),(-8L),1L},{0x0890L,0xC8E9L,0x8A57L,(-9L),0L},{0xE35BL,1L,7L,0x7C90L,0xD74DL}},{{0xD74DL,0x4E6EL,(-4L),0xB5C3L,0x9AB2L},{0xE35BL,0x4D00L,(-1L),(-2L),0xEAF3L},{0x0890L,0L,0xD6BDL,(-1L),0x4D11L},{7L,(-7L),0x3E6CL,0xC8E9L,(-1L)},{0x4616L,(-2L),0xE21FL,0xCB11L,0xD4A1L}},{{0xE21FL,0xEAF3L,0x0459L,0x3E6CL,0x329AL},{0xFA67L,(-2L),1L,0x36C8L,7L},{(-5L),(-9L),1L,1L,1L},{0xAC44L,0x1E8AL,0xAF8AL,0xEE93L,0x4D00L},{0xC6CFL,0xCA09L,0x879DL,0x657FL,1L}},{{0xEE93L,0xCA09L,0L,1L,0xD2F8L},{0xEAF3L,0x1E8AL,0x4D00L,0x0890L,0xC6CFL},{0x7C90L,(-9L),9L,(-5L),(-7L)},{(-8L),(-2L),(-2L),8L,(-1L)},{0x9AB2L,0xEAF3L,0x97E4L,0x0F72L,0L}},{{(-5L),(-1L),(-9L),0L,0L},{0x04F8L,(-4L),0xEE93L,(-2L),(-2L)},{0x4616L,0x657FL,0x4616L,0x1E8AL,0x0F72L},{0L,0x4E6EL,0xF4CDL,0xC6CFL,9L},{0x2C37L,0x879DL,0xC2C1L,0L,0xCA09L}},{{0x2C75L,8L,0xF4CDL,9L,0xAC44L},{0x329AL,0xD2F8L,0x4616L,1L,0x8A57L},{1L,(-8L),0xEE93L,1L,0x0459L},{0xC37DL,0x36C8L,(-9L),0x200DL,0x04F8L},{0xC2C1L,5L,0x97E4L,7L,0L}},{{9L,(-7L),(-2L),0xE35BL,0x1E8AL},{0x879DL,0x924DL,9L,(-1L),(-1L)},{(-7L),0x97E4L,0x4D00L,0x2C37L,(-4L)},{(-1L),(-4L),0L,0xCB11L,(-1L)},{0xDB76L,0x0459L,0x879DL,0xCB11L,6L}},{{1L,0xFA67L,0xAF8AL,0x2C37L,0x4616L},{7L,(-1L),1L,(-1L),0xE35BL},{0x27C9L,0L,1L,0xE35BL,(-1L)},{1L,0xD6BDL,0x0459L,7L,0L},{0x36C8L,1L,0L,0x200DL,0x7C90L}}};
+ int32_t l_1319 = 0xCFB328C7L;
+ int32_t **l_1322[3][9] = {{&g_54,&g_94,&g_54,&g_54,&g_94,&g_54,&g_54,&g_94,&g_54},{&g_54,&g_94,&g_54,&g_54,&g_94,&g_54,&g_54,&g_94,&g_54},{&g_54,&g_94,&g_54,&g_54,&g_94,&g_54,&g_54,&g_94,&g_54}};
+ struct S0 * const l_1333 = &g_576;
+ uint32_t l_1334[1][9];
+ int i, j, k;
+ for (i = 0; i < 8; i++)
+ l_1310[i] = &g_576.f1;
+ for (i = 0; i < 1; i++)
+ l_1316[i] = 0x0B92BB51L;
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 9; j++)
+ l_1334[i][j] = 4294967286UL;
+ }
+ for (g_90 = (-11); (g_90 <= (-11)); ++g_90)
+ { /* block id: 609 */
+ uint32_t l_1270 = 0xE1184BB9L;
+ int16_t *l_1282 = &g_1261;
+ l_1287 &= ((safe_div_func_int16_t_s_s(1L, (l_1270 , (safe_lshift_func_int8_t_s_u((l_1273 < (safe_div_func_int16_t_s_s(((safe_div_func_int32_t_s_s((safe_sub_func_uint16_t_u_u((l_1270 | (safe_sub_func_int16_t_s_s(((&g_20 != l_1282) ^ l_1273), (safe_rshift_func_int8_t_s_u((safe_lshift_func_int16_t_s_s(1L, p_29)), l_1270))))), l_1273)), l_1270)) || (*g_94)), 65535UL))), (*g_780)))))) <= g_90);
+ }
+ l_1319 = ((0x8F3813C5L >= ((safe_rshift_func_int16_t_s_u((safe_add_func_int8_t_s_s((+((((g_156[0][0] |= (((l_1287 |= (*g_94)) >= ((((**g_779) = ((safe_mul_func_int8_t_s_s((g_1294 != ((*g_909) = (*g_909))), ((l_1316[0] = (l_1315[3][4] = ((safe_rshift_func_int8_t_s_s(((((safe_div_func_uint16_t_u_u(((safe_lshift_func_int8_t_s_s((safe_lshift_func_int16_t_s_s((g_433.f2 || (safe_mod_func_int16_t_s_s(((*l_1314) = ((l_1305 == ((*l_1306) = l_1305)) , (((safe_mul_func_int8_t_s_s((l_1311[3][0] = 0xD7L), ((safe_sub_func_uint8_t_u_u(((g_857[0][8][2] != l_1273) > l_1273), p_29)) >= g_1042))) || l_1311[3][0]) ^ 1UL))), g_353))), 6)), 4)) <= g_1225), g_504)) != p_28) <= p_29) > l_1273), l_1273)) || l_1273))) ^ 1UL))) & 0L)) >= l_1273) ^ l_1273)) || l_1287)) , 1L) & 0UL) >= l_1318[9][3][0])), p_29)), 11)) && p_28)) >= (**p_27));
+ for (g_90 = 0; (g_90 >= 27); g_90 = safe_add_func_int32_t_s_s(g_90, 9))
+ { /* block id: 624 */
+ return l_1322[0][0];
+ }
+ l_1334[0][0] = (((safe_mul_func_uint16_t_u_u(((g_83 != (((safe_sub_func_int32_t_s_s((**p_27), (((((((((safe_rshift_func_int16_t_s_s(((void*)0 == l_1322[1][0]), 5)) >= (p_28 >= ((((**p_27) != ((((**p_27) >= (safe_mod_func_int32_t_s_s(((p_29 ^ (((((*l_1305) = (**l_1306)) == l_1333) && 1L) , p_28)) && g_90), 4294967295UL))) , (void*)0) != &l_1317[6])) || (**g_53)) , p_28))) , (**l_1305)) , &g_213) == p_26) & p_29) | (**g_779)) != p_28) >= 0xA1FC27BAL))) ^ 65534UL) , g_90)) <= p_28), 0x1068L)) > p_28) ^ (**g_779));
+ return l_1322[0][0];
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_83 g_20 g_90 g_91 g_910
+ * writes: g_504 g_83 g_90 g_91
+ */
+static int32_t * func_30(int32_t p_31, int32_t * p_32, struct S0 p_33, int32_t ** p_34)
+{ /* block id: 472 */
+ int32_t **l_914[8][10] = {{&g_94,&g_94,&g_54,&g_94,&g_54,(void*)0,&g_94,(void*)0,&g_94,(void*)0},{&g_94,(void*)0,&g_54,&g_54,&g_54,&g_54,&g_94,&g_54,&g_94,&g_94},{&g_94,&g_94,&g_94,(void*)0,(void*)0,&g_54,&g_54,&g_54,&g_54,&g_54},{&g_54,&g_94,&g_54,&g_54,&g_94,&g_54,&g_94,&g_94,&g_54,&g_54},{&g_94,&g_54,&g_94,&g_54,(void*)0,&g_94,(void*)0,&g_94,(void*)0,&g_94},{&g_94,&g_54,&g_94,&g_54,&g_94,&g_54,&g_94,&g_94,&g_54,&g_54},{&g_54,&g_94,&g_94,&g_54,&g_54,&g_54,&g_94,&g_94,&g_54,&g_54},{&g_94,&g_54,&g_54,&g_94,&g_94,&g_54,&g_94,&g_54,(void*)0,&g_94}};
+ struct S1 l_915 = {78,-58,0,25102,417};
+ uint16_t l_916[5];
+ struct S0 ****l_926[10] = {&g_909,(void*)0,(void*)0,&g_909,&g_909,&g_909,(void*)0,(void*)0,&g_909,&g_909};
+ const int32_t l_929 = 0L;
+ const int32_t l_932 = (-7L);
+ uint32_t l_933 = 1UL;
+ uint16_t l_981 = 7UL;
+ struct S1 * const l_1010 = &g_905[2];
+ struct S1 * const *l_1009[10] = {&l_1010,(void*)0,&l_1010,(void*)0,&l_1010,(void*)0,&l_1010,(void*)0,&l_1010,(void*)0};
+ int8_t l_1015 = 0xE6L;
+ int16_t l_1049 = 0x9987L;
+ uint8_t * const *l_1115[2][6][6] = {{{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780}},{{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780},{&g_780,&g_780,&g_780,&g_780,&g_780,&g_780}}};
+ int32_t ****l_1123[4];
+ uint8_t l_1188 = 2UL;
+ int8_t l_1226 = (-1L);
+ int32_t **l_1247 = &g_185;
+ int32_t l_1258 = 0x7F18010EL;
+ int32_t l_1260[5] = {0L,0L,0L,0L,0L};
+ int i, j, k;
+ for (i = 0; i < 5; i++)
+ l_916[i] = 0xF8D7L;
+ for (i = 0; i < 4; i++)
+ l_1123[i] = &g_667;
+ (*p_34) = (*p_34);
+ (*g_910) = func_62(l_915, (g_504 = (p_33 , 0x9F0AE6BEL)), l_916[2], &p_32, l_914[0][1]);
+ return (*p_34);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads :
+ * writes:
+ */
+static uint8_t func_40(int32_t p_41)
+{ /* block id: 22 */
+ uint32_t l_42 = 0x5CB296ADL;
+ return l_42;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_83
+ * writes: g_83 g_92.f4 g_3 g_15
+ */
+static struct S1 func_47(int32_t * p_48)
+{ /* block id: 62 */
+ int32_t **l_133[10][5] = {{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94},{&g_94,&g_94,&g_94,&g_94,&g_94}};
+ int16_t l_161 = 6L;
+ int8_t *l_205 = &g_83;
+ int32_t l_247 = (-1L);
+ const int8_t * const l_270[8][1] = {{&g_83},{&g_83},{&g_83},{&g_83},{&g_83},{&g_83},{&g_83},{&g_83}};
+ const int8_t * const *l_269 = &l_270[3][0];
+ const int8_t * const **l_268[5][4] = {{&l_269,&l_269,&l_269,&l_269},{&l_269,&l_269,&l_269,&l_269},{&l_269,&l_269,&l_269,&l_269},{&l_269,&l_269,&l_269,&l_269},{&l_269,&l_269,&l_269,&l_269}};
+ uint32_t l_301[5];
+ int16_t l_311[4][6] = {{0x68BFL,0x95B2L,1L,1L,0x95B2L,1L},{0x68BFL,0x3D51L,0x68BFL,1L,0x3D51L,1L},{0x68BFL,9L,1L,1L,9L,0x68BFL},{0x68BFL,0x95B2L,1L,1L,0x95B2L,1L}};
+ struct S0 **l_416 = &g_91;
+ const uint8_t l_542 = 0xE5L;
+ struct S1 l_560 = {172,-330,-0,18929,95};
+ uint32_t l_611 = 1UL;
+ int32_t *l_705 = (void*)0;
+ int32_t l_758 = (-6L);
+ int8_t l_759 = (-1L);
+ uint8_t l_778 = 3UL;
+ int32_t l_797 = 0L;
+ int32_t l_862 = 0xB39451ADL;
+ int32_t l_873 = 0xFE5FDFEFL;
+ int16_t l_889 = (-7L);
+ int i, j;
+ for (i = 0; i < 5; i++)
+ l_301[i] = 0x350790CDL;
+ for (g_83 = 0; (g_83 == 10); g_83 = safe_add_func_uint8_t_u_u(g_83, 3))
+ { /* block id: 65 */
+ int16_t *l_122[7][5][1] = {{{(void*)0},{&g_20},{&g_20},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2}},{{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2}},{{&g_92[3][1][3].f2},{&g_20},{&g_20},{(void*)0},{&g_20}},{{&g_20},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2}},{{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_20}},{{&g_20},{(void*)0},{&g_20},{&g_20},{&g_92[3][1][3].f2}},{{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2},{&g_92[3][1][3].f2}}};
+ int32_t l_123 = 0L;
+ int32_t l_124 = 1L;
+ const int32_t ***l_131 = (void*)0;
+ const int32_t ***l_132 = &g_129[1];
+ int32_t *l_153 = &l_123;
+ struct S0 *l_154 = &g_92[1][0][6];
+ int16_t *l_162 = &g_20;
+ int32_t l_172 = (-1L);
+ int32_t l_173 = 0xAD3B4E33L;
+ const int8_t l_242 = 0x4DL;
+ int8_t **l_265 = &l_205;
+ const int32_t *l_284 = &l_173;
+ uint8_t l_331 = 250UL;
+ struct S0 l_396 = {9UL,-6L,1L,0x34L,-1L};
+ uint32_t *l_419 = &g_213;
+ uint32_t **l_418 = &l_419;
+ int32_t l_441 = 0x8C037808L;
+ int16_t l_488 = 0L;
+ uint8_t l_605 = 0xA4L;
+ uint32_t l_670 = 18446744073709551607UL;
+ int32_t l_689 = 1L;
+ int32_t l_692 = 0xE43AF478L;
+ int32_t l_693 = 0xC0F3538AL;
+ int32_t l_695 = 0L;
+ int32_t l_696 = 0xCFD69C5FL;
+ int32_t l_699 = (-6L);
+ int16_t l_707 = 0L;
+ struct S0 ***l_727[7][2] = {{&l_416,(void*)0},{&l_416,&l_416},{(void*)0,&l_416},{&l_416,(void*)0},{&l_416,&l_416},{&l_416,(void*)0},{&l_416,&l_416}};
+ struct S0 ****l_726 = &l_727[0][0];
+ uint32_t *l_734 = &g_504;
+ uint16_t *l_743 = &g_150;
+ int16_t l_882 = 0L;
+ int32_t l_884[7][1][7] = {{{7L,7L,0xFD203C11L,(-3L),(-8L),(-3L),0xFD203C11L}},{{0x83438ED6L,0x83438ED6L,1L,0L,(-1L),0L,1L}},{{7L,7L,0xFD203C11L,(-3L),(-8L),(-3L),0xFD203C11L}},{{0x83438ED6L,0x83438ED6L,1L,0L,(-1L),0L,1L}},{{7L,7L,0xFD203C11L,(-3L),(-8L),(-3L),0xFD203C11L}},{{0x83438ED6L,0x83438ED6L,1L,0L,(-1L),0L,1L}},{{7L,7L,0xFD203C11L,(-3L),(-8L),(-3L),0xFD203C11L}}};
+ struct S1 *l_892 = &g_68;
+ uint32_t l_896 = 0x3B23285FL;
+ int i, j, k;
+ }
+ (*p_48) = (-1L);
+ return l_560;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_54 g_3 g_68 g_6 g_83 g_20 g_90 g_91 g_97 g_94 g_53 g_92 g_12 g_15
+ * writes: g_83 g_90 g_91 g_94 g_97 g_92.f4
+ */
+static int32_t * func_49(int32_t ** p_50, int16_t p_51, struct S0 p_52)
+{ /* block id: 24 */
+ const uint16_t l_110 = 0xE3F5L;
+ int32_t *l_111 = &g_92[3][1][3].f4;
+ (*l_111) = (safe_mul_func_int8_t_s_s(func_40((**p_50)), ((safe_sub_func_int8_t_s_s((((func_60((*g_54)) , (*g_53)) != (g_20 , (*p_50))) & (safe_lshift_func_uint16_t_u_s((safe_mod_func_int8_t_s_s(((p_52.f1 = p_52.f0) & (((safe_lshift_func_int8_t_s_s((p_52.f3 == l_110), g_6[8])) > l_110) , g_92[3][1][3].f1)), 1UL)), l_110))), l_110)) > g_12)));
+ return l_111;
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_68 g_6 g_83 g_20 g_90 g_91 g_54 g_97 g_3 g_94 g_53 g_92 g_15
+ * writes: g_83 g_90 g_91 g_94 g_97
+ */
+static struct S0 func_60(int32_t p_61)
+{ /* block id: 25 */
+ int32_t l_71 = (-4L);
+ int32_t ** const l_72[1][6][3] = {{{&g_54,&g_54,&g_54},{&g_54,&g_54,&g_54},{&g_54,&g_54,&g_54},{&g_54,&g_54,&g_54},{&g_54,&g_54,&g_54},{&g_54,&g_54,&g_54}}};
+ int32_t **l_73 = &g_54;
+ int32_t ***l_74 = &l_73;
+ struct S0 **l_93 = &g_91;
+ int32_t *l_95 = &g_92[3][1][3].f4;
+ uint8_t l_96[5];
+ int i, j, k;
+ for (i = 0; i < 5; i++)
+ l_96[i] = 0UL;
+ (*l_93) = func_62(g_68, p_61, (safe_mul_func_int16_t_s_s(g_6[3], l_71)), l_72[0][5][0], ((*l_74) = l_73));
+ l_95 = (g_94 = (*l_73));
+ for (p_61 = 1; (p_61 <= 4); p_61 += 1)
+ { /* block id: 36 */
+ int32_t l_98 = 0xFA4E93F4L;
+ int32_t *l_102[3];
+ int i;
+ for (i = 0; i < 3; i++)
+ l_102[i] = (void*)0;
+ g_97 ^= (~l_96[p_61]);
+ l_98 = (-1L);
+ for (g_90 = 4; (g_90 >= 0); g_90 -= 1)
+ { /* block id: 41 */
+ int16_t l_99[5];
+ int i;
+ for (i = 0; i < 5; i++)
+ l_99[i] = 0x8431L;
+ l_99[2] |= ((***l_74) , ((void*)0 == &g_91));
+ for (l_71 = 0; (l_71 <= 4); l_71 += 1)
+ { /* block id: 45 */
+ int32_t *l_100 = (void*)0;
+ int32_t *l_101 = &g_97;
+ l_98 &= (((*l_101) = p_61) , (*g_94));
+ l_102[1] = (*g_53);
+ if (l_99[1])
+ break;
+ }
+ }
+ }
+ for (g_90 = 0; (g_90 <= 4); g_90 += 1)
+ { /* block id: 55 */
+ int32_t *l_103 = &g_15;
+ g_94 = l_103;
+ }
+ return (*g_91);
+}
+
+
+/* ------------------------------------------ */
+/*
+ * reads : g_83 g_20 g_90 g_91
+ * writes: g_83 g_90
+ */
+static struct S0 * func_62(struct S1 p_63, uint32_t p_64, uint32_t p_65, int32_t ** const p_66, int32_t ** p_67)
+{ /* block id: 27 */
+ uint16_t l_81 = 0xC310L;
+ int8_t *l_82 = &g_83;
+ struct S1 l_86 = {5,-235,-1,9762,-453};
+ int32_t *l_89 = &g_90;
+ (*l_89) ^= (safe_mod_func_int8_t_s_s(((safe_add_func_uint32_t_u_u(p_65, ((+p_63.f0) && (safe_div_func_int8_t_s_s((l_81 , ((*l_82) &= p_63.f3)), ((l_81 && l_81) | (safe_rshift_func_int16_t_s_s(1L, (l_86 , ((safe_mod_func_int32_t_s_s(0x986173B0L, l_86.f0)) & g_20)))))))))) != 0x4030L), l_81));
+ return g_91;
+}
+
+
+
+
+/* ---------------------------------------- */
+int main (int argc, char* argv[])
+{
+ int i, j, k;
+ int print_hash_value = 0;
+ if (argc == 2 && strcmp(argv[1], "1") == 0) print_hash_value = 1;
+ platform_main_begin();
+ crc32_gentab();
+ func_1();
+ for (i = 0; i < 6; i++)
+ {
+ transparent_crc(g_3[i], "g_3[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_5, "g_5", print_hash_value);
+ for (i = 0; i < 10; i++)
+ {
+ transparent_crc(g_6[i], "g_6[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_11, "g_11", print_hash_value);
+ transparent_crc(g_12, "g_12", print_hash_value);
+ transparent_crc(g_15, "g_15", print_hash_value);
+ transparent_crc(g_20, "g_20", print_hash_value);
+ transparent_crc(g_68.f0, "g_68.f0", print_hash_value);
+ transparent_crc(g_68.f1, "g_68.f1", print_hash_value);
+ transparent_crc(g_68.f2, "g_68.f2", print_hash_value);
+ transparent_crc(g_68.f3, "g_68.f3", print_hash_value);
+ transparent_crc(g_68.f4, "g_68.f4", print_hash_value);
+ transparent_crc(g_83, "g_83", print_hash_value);
+ transparent_crc(g_90, "g_90", print_hash_value);
+ for (i = 0; i < 6; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ for (k = 0; k < 9; k++)
+ {
+ transparent_crc(g_92[i][j][k].f0, "g_92[i][j][k].f0", print_hash_value);
+ transparent_crc(g_92[i][j][k].f1, "g_92[i][j][k].f1", print_hash_value);
+ transparent_crc(g_92[i][j][k].f2, "g_92[i][j][k].f2", print_hash_value);
+ transparent_crc(g_92[i][j][k].f3, "g_92[i][j][k].f3", print_hash_value);
+ transparent_crc(g_92[i][j][k].f4, "g_92[i][j][k].f4", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
+
+ }
+ }
+ }
+ transparent_crc(g_97, "g_97", print_hash_value);
+ transparent_crc(g_150, "g_150", print_hash_value);
+ for (i = 0; i < 6; i++)
+ {
+ for (j = 0; j < 8; j++)
+ {
+ transparent_crc(g_156[i][j], "g_156[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ transparent_crc(g_213, "g_213", print_hash_value);
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ transparent_crc(g_278[i][j], "g_278[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ transparent_crc(g_294, "g_294", print_hash_value);
+ transparent_crc(g_353, "g_353", print_hash_value);
+ transparent_crc(g_356, "g_356", print_hash_value);
+ transparent_crc(g_357, "g_357", print_hash_value);
+ for (i = 0; i < 4; i++)
+ {
+ transparent_crc(g_359[i], "g_359[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_428, "g_428", print_hash_value);
+ transparent_crc(g_433.f0, "g_433.f0", print_hash_value);
+ transparent_crc(g_433.f1, "g_433.f1", print_hash_value);
+ transparent_crc(g_433.f2, "g_433.f2", print_hash_value);
+ transparent_crc(g_433.f3, "g_433.f3", print_hash_value);
+ transparent_crc(g_433.f4, "g_433.f4", print_hash_value);
+ transparent_crc(g_489, "g_489", print_hash_value);
+ transparent_crc(g_504, "g_504", print_hash_value);
+ transparent_crc(g_518, "g_518", print_hash_value);
+ for (i = 0; i < 9; i++)
+ {
+ for (j = 0; j < 4; j++)
+ {
+ transparent_crc(g_544[i][j], "g_544[i][j]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d]\n", i, j);
+
+ }
+ }
+ transparent_crc(g_576.f0, "g_576.f0", print_hash_value);
+ transparent_crc(g_576.f1, "g_576.f1", print_hash_value);
+ transparent_crc(g_576.f2, "g_576.f2", print_hash_value);
+ transparent_crc(g_576.f3, "g_576.f3", print_hash_value);
+ transparent_crc(g_576.f4, "g_576.f4", print_hash_value);
+ transparent_crc(g_584, "g_584", print_hash_value);
+ transparent_crc(g_698, "g_698", print_hash_value);
+ transparent_crc(g_760, "g_760", print_hash_value);
+ for (i = 0; i < 1; i++)
+ {
+ for (j = 0; j < 9; j++)
+ {
+ for (k = 0; k < 4; k++)
+ {
+ transparent_crc(g_857[i][j][k], "g_857[i][j][k]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
+
+ }
+ }
+ }
+ for (i = 0; i < 7; i++)
+ {
+ transparent_crc(g_905[i].f0, "g_905[i].f0", print_hash_value);
+ transparent_crc(g_905[i].f1, "g_905[i].f1", print_hash_value);
+ transparent_crc(g_905[i].f2, "g_905[i].f2", print_hash_value);
+ transparent_crc(g_905[i].f3, "g_905[i].f3", print_hash_value);
+ transparent_crc(g_905[i].f4, "g_905[i].f4", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_1042, "g_1042", print_hash_value);
+ transparent_crc(g_1058, "g_1058", print_hash_value);
+ for (i = 0; i < 10; i++)
+ {
+ transparent_crc(g_1138[i], "g_1138[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_1225, "g_1225", print_hash_value);
+ transparent_crc(g_1239, "g_1239", print_hash_value);
+ for (i = 0; i < 8; i++)
+ {
+ transparent_crc(g_1257[i], "g_1257[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_1261, "g_1261", print_hash_value);
+ for (i = 0; i < 5; i++)
+ {
+ transparent_crc(g_1402[i], "g_1402[i]", print_hash_value);
+ if (print_hash_value) printf("index = [%d]\n", i);
+
+ }
+ transparent_crc(g_1436, "g_1436", print_hash_value);
+ transparent_crc(g_1682, "g_1682", print_hash_value);
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; j < 5; j++)
+ {
+ for (k = 0; k < 9; k++)
+ {
+ transparent_crc(g_1695[i][j][k], "g_1695[i][j][k]", print_hash_value);
+ if (print_hash_value) printf("index = [%d][%d][%d]\n", i, j, k);
+
+ }
+ }
+ }
+ transparent_crc(g_2022, "g_2022", print_hash_value);
+ transparent_crc(g_2037, "g_2037", print_hash_value);
+ transparent_crc(g_2052, "g_2052", print_hash_value);
+ platform_main_end(crc32_context ^ 0xFFFFFFFFUL, print_hash_value);
+ return 0;
+}
+
+/************************ statistics *************************
+XXX max struct depth: 1
+breakdown:
+ depth: 0, occurrence: 547
+ depth: 1, occurrence: 33
+XXX total union variables: 0
+
+XXX non-zero bitfields defined in structs: 5
+XXX zero bitfields defined in structs: 0
+XXX const bitfields defined in structs: 1
+XXX volatile bitfields defined in structs: 0
+XXX structs with bitfields in the program: 27
+breakdown:
+ indirect level: 0, occurrence: 16
+ indirect level: 1, occurrence: 8
+ indirect level: 2, occurrence: 3
+XXX full-bitfields structs in the program: 16
+breakdown:
+ indirect level: 0, occurrence: 16
+XXX times a bitfields struct's address is taken: 24
+XXX times a bitfields struct on LHS: 0
+XXX times a bitfields struct on RHS: 24
+XXX times a single bitfield on LHS: 5
+XXX times a single bitfield on RHS: 74
+
+XXX max expression depth: 46
+breakdown:
+ depth: 1, occurrence: 83
+ depth: 2, occurrence: 25
+ depth: 3, occurrence: 4
+ depth: 8, occurrence: 3
+ depth: 13, occurrence: 2
+ depth: 14, occurrence: 1
+ depth: 15, occurrence: 1
+ depth: 16, occurrence: 1
+ depth: 17, occurrence: 1
+ depth: 18, occurrence: 1
+ depth: 20, occurrence: 1
+ depth: 32, occurrence: 1
+ depth: 33, occurrence: 1
+ depth: 37, occurrence: 1
+ depth: 46, occurrence: 1
+
+XXX total number of pointers: 404
+
+XXX times a variable address is taken: 729
+XXX times a pointer is dereferenced on RHS: 359
+breakdown:
+ depth: 1, occurrence: 251
+ depth: 2, occurrence: 71
+ depth: 3, occurrence: 35
+ depth: 4, occurrence: 2
+XXX times a pointer is dereferenced on LHS: 280
+breakdown:
+ depth: 1, occurrence: 245
+ depth: 2, occurrence: 30
+ depth: 3, occurrence: 5
+XXX times a pointer is compared with null: 33
+XXX times a pointer is compared with address of another variable: 8
+XXX times a pointer is compared with another pointer: 10
+XXX times a pointer is qualified to be dereferenced: 8112
+
+XXX max dereference level: 5
+breakdown:
+ level: 0, occurrence: 0
+ level: 1, occurrence: 1335
+ level: 2, occurrence: 410
+ level: 3, occurrence: 168
+ level: 4, occurrence: 15
+ level: 5, occurrence: 8
+XXX number of pointers point to pointers: 190
+XXX number of pointers point to scalars: 194
+XXX number of pointers point to structs: 20
+XXX percent of pointers has null in alias set: 29.5
+XXX average alias set size: 1.4
+
+XXX times a non-volatile is read: 1935
+XXX times a non-volatile is write: 902
+XXX times a volatile is read: 0
+XXX times read thru a pointer: 0
+XXX times a volatile is write: 0
+XXX times written thru a pointer: 0
+XXX times a volatile is available for access: 0
+XXX percentage of non-volatile access: 100
+
+XXX forward jumps: 0
+XXX backward jumps: 3
+
+XXX stmts: 86
+XXX max block depth: 5
+breakdown:
+ depth: 0, occurrence: 31
+ depth: 1, occurrence: 17
+ depth: 2, occurrence: 8
+ depth: 3, occurrence: 13
+ depth: 4, occurrence: 13
+ depth: 5, occurrence: 4
+
+XXX percentage a fresh-made variable is used: 16.4
+XXX percentage an existing variable is used: 83.6
+FYI: the random generator makes assumptions about the integer size. See platform.info for more details.
+********************* end of statistics **********************/
+
diff --git a/tests/fuzz/17.c.txt b/tests/fuzz/17.c.txt
new file mode 100644
index 00000000..ec5e8b3c
--- /dev/null
+++ b/tests/fuzz/17.c.txt
@@ -0,0 +1 @@
+checksum = B0C9CB31
diff --git a/tests/fuzz/csmith_driver.py b/tests/fuzz/csmith_driver.py
index c987a3be..90c7df2e 100755
--- a/tests/fuzz/csmith_driver.py
+++ b/tests/fuzz/csmith_driver.py
@@ -6,11 +6,11 @@ Runs csmith, a C fuzzer, and looks for bugs.
CSMITH_PATH should be set to something like /usr/local/include/csmith
'''
-import os, sys, difflib, shutil
+import os, sys, difflib, shutil, random
from distutils.spawn import find_executable
from subprocess import check_call, Popen, PIPE, STDOUT, CalledProcessError
-sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'tools')]
+sys.path += [os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), 'tools')]
import shared
engine1 = eval('shared.' + sys.argv[1]) if len(sys.argv) > 1 else shared.JS_ENGINES[0]
@@ -35,9 +35,12 @@ notes = { 'invalid': 0, 'unaligned': 0, 'embug': 0 }
fails = 0
while 1:
+ opts = '-O' + str(random.randint(0, 2))
+ print 'opt level:', opts
+
print 'Tried %d, notes: %s' % (tried, notes)
print '1) Generate C'
- check_call([CSMITH, '--no-volatiles', '--no-math64', '--no-packed-struct'],# +
+ check_call([CSMITH, '--no-volatiles', '--no-packed-struct'],# '--no-math64'
#['--max-block-depth', '2', '--max-block-size', '2', '--max-expr-complexity', '2', '--max-funcs', '2'],
stdout=open(filename + '.c', 'w'))
#shutil.copyfile(filename + '.c', 'testcase%d.c' % tried)
@@ -47,8 +50,8 @@ while 1:
print '2) Compile natively'
shared.try_delete(filename)
- shared.check_execute([shared.CLANG_CC, '-O2', filename + '.c', '-o', filename + '1'] + CSMITH_CFLAGS) # + shared.EMSDK_OPTS
- shared.check_execute([shared.CLANG_CC, '-O2', '-emit-llvm', '-c', '-Xclang', '-triple=i386-pc-linux-gnu', filename + '.c', '-o', filename + '.bc'] + CSMITH_CFLAGS + shared.EMSDK_OPTS)
+ shared.check_execute([shared.CLANG_CC, opts, filename + '.c', '-o', filename + '1'] + CSMITH_CFLAGS) # + shared.EMSDK_OPTS
+ shared.check_execute([shared.CLANG_CC, opts, '-emit-llvm', '-c', '-Xclang', '-triple=i386-pc-linux-gnu', filename + '.c', '-o', filename + '.bc'] + CSMITH_CFLAGS + shared.EMSDK_OPTS)
shared.check_execute([shared.path_from_root('tools', 'nativize_llvm.py'), filename + '.bc'])
shutil.move(filename + '.bc.run', filename + '2')
shared.check_execute([shared.CLANG_CC, filename + '.c', '-o', filename + '3'] + CSMITH_CFLAGS)
@@ -71,7 +74,7 @@ while 1:
def try_js(args):
shared.try_delete(filename + '.js')
print '(compile)'
- shared.check_execute([shared.EMCC, '-O2', '-s', 'ASM_JS=1', filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args)
+ shared.check_execute([shared.EMCC, opts, filename + '.c', '-o', filename + '.js'] + CSMITH_CFLAGS + args)
assert os.path.exists(filename + '.js')
print '(run)'
js = shared.run_js(filename + '.js', stderr=PIPE, engine=engine1, check_timeout=True)
diff --git a/tests/fuzz/test.sh b/tests/fuzz/test.sh
new file mode 100755
index 00000000..166d4bab
--- /dev/null
+++ b/tests/fuzz/test.sh
@@ -0,0 +1,39 @@
+# e.g.
+# ~/Dev/emscripten/tests/fuzz$ CSMITH=~/Dev/csmith/src/csmith CSMITH_PATH=~/Dev/csmith python ./csmith_driver.py
+# to find failures, then check those out with this script
+
+echo "builds"
+gcc $@ -I/home/alon/Dev/csmith/runtime -o n1.out &> /dev/null
+/home/alon/Dev/fastcomp/build/Release/bin/clang $@ -I/home/alon/Dev/csmith/runtime -o n2.out &> /dev/null
+/home/alon/Dev/fastcomp/build/Release/bin/clang $@ -I/home/alon/Dev/csmith/runtime -emit-llvm -c -o bc.bc &> o
+~/Dev/emscripten/emcc $@ -I/home/alon/Dev/csmith/runtime -o js.out.js &> /dev/null
+#~/Dev/emscripten/emcc $@ -s UNALIGNED_MEMORY=1 -I/home/alon/Dev/csmith/runtime -o ua.out.js &> /dev/null
+#~/Dev/emscripten/emcc $@ -s SAFE_HEAP=1 -I/home/alon/Dev/csmith/runtime -o sh.out.js &> /dev/null
+EMCC_FAST_COMPILER=1 ~/Dev/emscripten/emcc $@ -I/home/alon/Dev/csmith/runtime -o fc.out.js &> /dev/null
+echo "run n1"
+./n1.out &> n1
+echo "run n2"
+./n2.out &> n2
+echo "run bc"
+/home/alon/Dev/fastcomp/build/Release/bin/lli bc.bc &> bc
+echo "run js"
+mozjs js.out.js &> js
+echo "run ua"
+#mozjs ua.out.js &> ua
+echo "run sh"
+#mozjs sh.out.js &> sh
+echo "run fc"
+mozjs fc.out.js &> fc
+echo "n/n"
+diff n1 n2
+echo "n/bc"
+diff n1 bc
+echo "n/js"
+diff n1 js | grep -v warning
+echo "n/js-ua"
+#diff n1 ua | grep -v warning
+echo "n/js-sh"
+#diff n1 sh | grep -v warning
+echo "js/js"
+diff js fc | grep -v warning
+
diff --git a/tests/gles2_conformance.cpp b/tests/gles2_conformance.cpp
index 80539f7f..77681bf4 100644
--- a/tests/gles2_conformance.cpp
+++ b/tests/gles2_conformance.cpp
@@ -30,6 +30,16 @@ int main(int argc, char *argv[])
glShaderBinary(1, &vs, 0, 0, 0);
assert(glGetError() != GL_NO_ERROR);
+ // Calling any of glGet() with null pointer should be detected and not crash.
+ // Note that native code can crash when passed a null pointer, and the GL spec does not say anything
+ // about this, so we spec that Emscripten GLES2 code should generate GL_INVALID_VALUE.
+ glGetBooleanv(GL_ACTIVE_TEXTURE, 0);
+ assert(glGetError() == GL_INVALID_VALUE);
+ glGetIntegerv(GL_ACTIVE_TEXTURE, 0);
+ assert(glGetError() == GL_INVALID_VALUE);
+ glGetFloatv(GL_ACTIVE_TEXTURE, 0);
+ assert(glGetError() == GL_INVALID_VALUE);
+
GLboolean b = GL_TRUE;
GLint i = -1;
GLfloat f = -1.f;
@@ -44,18 +54,14 @@ int main(int argc, char *argv[])
assert(f == 0.f);
// Currently testing that glGetIntegerv(GL_SHADER_BINARY_FORMATS) should be a no-op.
- // The spec is somewhat vague here, equally as good could be to return GL_INVALID_ENUM here.
- i = 123;
- glGetIntegerv(GL_SHADER_BINARY_FORMATS, &i);
+ int formats[10] = { 123 };
+ glGetIntegerv(GL_SHADER_BINARY_FORMATS, formats);
assert(glGetError() == GL_NO_ERROR);
- assert(i == 0);
+ assert(formats[0] == 123);
- // Spec does not say what to report on the following, but since GL_SHADER_BINARY_FORMATS is supposed
- // to return a a pointer to an array representing a list, the pointer can't be converted to bool or float,
- // so report a GL_INVALID_ENUM.
+ // Converting enums to booleans or floats would be odd, so test that the following report a GL_INVALID_ENUM.
glGetBooleanv(GL_SHADER_BINARY_FORMATS, &b);
- assert(glGetError() == GL_INVALID_ENUM);
-
+ assert(glGetError() == GL_INVALID_ENUM);
glGetFloatv(GL_SHADER_BINARY_FORMATS, &f);
assert(glGetError() == GL_INVALID_ENUM);
diff --git a/tests/hello_image_sdl.c b/tests/hello_image_sdl.c
new file mode 100644
index 00000000..449798bd
--- /dev/null
+++ b/tests/hello_image_sdl.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
+#include <assert.h>
+#include <emscripten.h>
+#include <unistd.h>
+
+int testImage(SDL_Surface* screen, const char* fileName) {
+ SDL_Surface *image = IMG_Load(fileName);
+ if (!image)
+ {
+ printf("IMG_Load: %s\n", IMG_GetError());
+ return 0;
+ }
+ assert(image->format->BitsPerPixel == 32);
+ assert(image->format->BytesPerPixel == 4);
+ assert(image->pitch == 4*image->w);
+ int result = image->w;
+
+ SDL_BlitSurface (image, NULL, screen, NULL);
+ SDL_FreeSurface (image);
+
+ return result;
+}
+
+int main() {
+ SDL_Init(SDL_INIT_VIDEO);
+ SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE);
+
+ int result = 0;
+
+ result |= testImage(screen, "screenshot.jpg"); // absolute path
+ assert(result != 0);
+
+ SDL_Flip(screen);
+
+ printf("you should see an image.\n");
+
+ SDL_Quit();
+
+ return 0;
+}
+
diff --git a/tests/hello_world_exit.c b/tests/hello_world_exit.c
new file mode 100644
index 00000000..8932caf2
--- /dev/null
+++ b/tests/hello_world_exit.c
@@ -0,0 +1,15 @@
+#include<stdio.h>
+#include<stdlib.h>
+
+int main(int argc, char **argv) {
+ printf("argc: %d\n", argc);
+ for(int i = 0; i < argc; ++i) {
+ printf("argv[%d]: %s\n", i, argv[i]);
+ }
+ if (argc <= 1)
+ exit(1);
+ printf("hello, world!\n");
+ fprintf(stderr, "hello, error stream!\n");
+ exit(100);
+}
+
diff --git a/tests/runner.py b/tests/runner.py
index 34435383..37e307e9 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -328,7 +328,10 @@ process(sys.argv[1])
os.makedirs(ret)
return ret
- def get_library(self, name, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=True, env_init={}, cache_name_extra='', native=False):
+ def get_library(self, name, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args='help', cache=True, env_init={}, cache_name_extra='', native=False):
+ if make_args == 'help':
+ make_args = ['-j', str(multiprocessing.cpu_count())]
+
build_dir = self.get_build_dir()
output_dir = self.get_dir()
@@ -418,6 +421,12 @@ process(sys.argv[1])
'''
return (main, supp)
+ def do_run_from_file(self, src, expected_output, args=[], output_nicerizer=None, output_processor=None, no_build=False, main_file=None, additional_files=[], js_engines=None, post_build=None, basename='src.cpp', libraries=[], includes=[], force_c=False, build_ll_hook=None, extra_emscripten_args=[]):
+ self.do_run(open(src).read(), open(expected_output).read(),
+ args, output_nicerizer, output_processor, no_build, main_file,
+ additional_files, js_engines, post_build, basename, libraries,
+ includes, force_c, build_ll_hook, extra_emscripten_args)
+
## Does a complete test - builds, runs, checks output, etc.
def do_run(self, src, expected_output, args=[], output_nicerizer=None, output_processor=None, no_build=False, main_file=None, additional_files=[], js_engines=None, post_build=None, basename='src.cpp', libraries=[], includes=[], force_c=False, build_ll_hook=None, extra_emscripten_args=[]):
if force_c or (main_file is not None and main_file[-2:]) == '.c':
diff --git a/tests/sockets/test_getprotobyname.c b/tests/sockets/test_getprotobyname.c
new file mode 100644
index 00000000..571a287e
--- /dev/null
+++ b/tests/sockets/test_getprotobyname.c
@@ -0,0 +1,87 @@
+#include <assert.h>
+#include <errno.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void checkEntryByValue(char* name, int port, char** aliasArray) {
+ struct protoent* entry;
+ char** aliases;
+
+ // Perform a protocol look up by name
+ entry = getprotobyname(name);
+ assert(entry != NULL);
+
+ // Check results
+ assert(strcmp(name, entry->p_name) == 0);
+ assert(port == entry->p_proto);
+
+ aliases = entry->p_aliases;
+ for (int i = 0; aliases[i] != NULL; i++) {
+ assert(strcmp(aliases[i], aliasArray[i]) == 0);
+ }
+
+ // Perform a protocol look up by number
+ entry = getprotobynumber(port);
+ assert(entry != NULL);
+
+ // Check results
+ assert(strcmp(name, entry->p_name) == 0);
+ assert(port == entry->p_proto);
+
+ aliases = entry->p_aliases;
+ for (int i = 0; aliases[i] != NULL; i++) {
+ assert(strcmp(aliases[i], aliasArray[i]) == 0);
+ }
+}
+
+void checkEntryDatabase() {
+ struct protoent* entry;
+
+ // Don't call setprotoent() initially as getprotoent() should open the "database" if necessary.
+ entry = getprotoent();
+ assert(entry != NULL);
+ assert(strcmp("tcp", entry->p_name) == 0);
+
+ entry = getprotoent();
+ assert(entry != NULL);
+ assert(strcmp("udp", entry->p_name) == 0);
+
+ // Check that setprotoent() correctly sets the next entry to the first entry
+ setprotoent(1);
+
+ entry = getprotoent();
+ assert(entry != NULL);
+ assert(strcmp("tcp", entry->p_name) == 0);
+
+ entry = getprotoent();
+ assert(entry != NULL);
+ assert(strcmp("udp", entry->p_name) == 0);
+
+ // If we do a getprotoent() that goes past the end of the 'database' check that it returns NULL.
+ entry = getprotoent();
+ assert(entry == NULL);
+}
+
+int main() {
+ // First check getprotobyname() and getprotobynumber()
+ char* aliases[] = {"TCP"};
+ checkEntryByValue("tcp", 6, aliases);
+
+ aliases[0] = "UDP";
+ checkEntryByValue("udp", 17, aliases);
+
+ // Check that the doomsday protocol hasn't been implemented :-) ......
+ assert(getprotobyname("doomsday") == NULL);
+
+ // Now check setprotoent() and getprotoent()
+ checkEntryDatabase();
+
+ endprotoent();
+
+ puts("success");
+
+ return EXIT_SUCCESS;
+}
+
diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py
index 63e0041f..d84f36e4 100644
--- a/tests/test_benchmark.py
+++ b/tests/test_benchmark.py
@@ -14,6 +14,122 @@ DEFAULT_ARG = '4'
TEST_REPS = 2
+CORE_BENCHMARKS = True # core benchmarks vs full regression suite
+
+class Benchmarker:
+ def __init__(self, name):
+ self.name = name
+
+ def bench(self, args, output_parser=None):
+ self.times = []
+ for i in range(TEST_REPS):
+ start = time.time()
+ output = self.run(args)
+ if not output_parser:
+ curr = time.time()-start
+ else:
+ curr = output_parser(output)
+ self.times.append(curr)
+
+ def display(self, baseline=None):
+ if baseline == self: baseline = None
+ mean = sum(self.times)/len(self.times)
+ squared_times = map(lambda x: x*x, self.times)
+ mean_of_squared = sum(squared_times)/len(self.times)
+ std = math.sqrt(mean_of_squared - mean*mean)
+ sorted_times = self.times[:]
+ sorted_times.sort()
+ median = sum(sorted_times[len(sorted_times)/2 - 1:len(sorted_times)/2 + 1])/2
+
+ print ' %10s: mean: %4.3f (+-%4.3f) secs median: %4.3f range: %4.3f-%4.3f (noise: %4.3f%%) (%d runs)' % (self.name, mean, std, median, min(self.times), max(self.times), 100*std/mean, TEST_REPS),
+
+ if baseline:
+ mean_baseline = sum(baseline.times)/len(baseline.times)
+ final = mean / mean_baseline
+ print ' Relative: %.2f X slower' % final
+ else:
+ print
+
+class NativeBenchmarker(Benchmarker):
+ def __init__(self, name, cc, cxx):
+ self.name = name
+ self.cc = cc
+ self.cxx = cxx
+
+ def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
+ self.parent = parent
+ if lib_builder: native_args += lib_builder(self.name, native=True, env_init={ 'CC': self.cc, 'CXX': self.cxx })
+ if not native_exec:
+ compiler = self.cxx if filename.endswith('cpp') else self.cc
+ process = Popen([compiler, '-O2', '-fno-math-errno', filename, '-o', filename+'.native'] + shared_args + native_args, stdout=PIPE, stderr=parent.stderr_redirect)
+ output = process.communicate()
+ if process.returncode is not 0:
+ print >> sys.stderr, "Building native executable with command '%s' failed with a return code %d!" % (' '.join([compiler, '-O2', filename, '-o', filename+'.native']), process.returncode)
+ print "Output: " + output[0]
+ else:
+ print '(using clang)'
+ shutil.copyfile(native_exec, filename + '.native')
+ shutil.copymode(native_exec, filename + '.native')
+
+ final = os.path.dirname(filename) + os.path.sep + self.name+'_' + os.path.basename(filename) + '.native'
+ shutil.move(filename + '.native', final)
+ self.filename = final
+
+ def run(self, args):
+ process = Popen([self.filename] + args, stdout=PIPE, stderr=PIPE)
+ return process.communicate()[0]
+
+class JSBenchmarker(Benchmarker):
+ def __init__(self, name, engine, extra_args=[], env={}):
+ self.name = name
+ self.engine = engine
+ self.extra_args = extra_args
+ self.env = os.environ.copy()
+ for k, v in env.iteritems():
+ self.env[k] = v
+
+ def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder):
+ self.filename = filename
+ if lib_builder: emcc_args += lib_builder('js', native=False, env_init={})
+
+ open('hardcode.py', 'w').write('''
+def process(filename):
+ js = open(filename).read()
+ replaced = js.replace("run();", "run(%s.concat(Module[\\"arguments\\"]));")
+ assert js != replaced
+ open(filename, 'w').write(replaced)
+import sys
+process(sys.argv[1])
+''' % str(args[:-1]) # do not hardcode in the last argument, the default arg
+)
+
+ final = os.path.dirname(filename) + os.path.sep + self.name+'_' + os.path.basename(filename) + '.js'
+ try_delete(final)
+ output = Popen([PYTHON, EMCC, filename, #'-O3',
+ '-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0',
+ '--memory-init-file', '0', '--js-transform', 'python hardcode.py',
+ '-s', 'TOTAL_MEMORY=128*1024*1024',
+ #'--closure', '1',
+ #'-g2',
+ '-o', final] + shared_args + emcc_args + self.extra_args, stdout=PIPE, stderr=PIPE, env=self.env).communicate()
+ assert os.path.exists(final), 'Failed to compile file: ' + output[0]
+ self.filename = final
+
+ def run(self, args):
+ return run_js(self.filename, engine=self.engine, args=args, stderr=PIPE, full_output=True)
+
+# Benchmarkers
+benchmarkers = [
+ NativeBenchmarker('clang', CLANG_CC, CLANG),
+ #NativeBenchmarker('gcc', 'gcc', 'g++'),
+ #JSBenchmarker('sm-f32', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2']),
+ JSBenchmarker('sm', SPIDERMONKEY_ENGINE),
+ #JSBenchmarker('sm-fc', SPIDERMONKEY_ENGINE, env={ 'EMCC_FAST_COMPILER': '1' }),
+ #JSBenchmarker('sm-noasm', SPIDERMONKEY_ENGINE + ['--no-asmjs']),
+ #JSBenchmarker('sm-noasm-f32', SPIDERMONKEY_ENGINE + ['--no-asmjs'], ['-s', 'PRECISE_F32=2']),
+ #JSBenchmarker('v8', V8_ENGINE)
+]
+
class benchmark(RunnerCore):
save_dir = True
@@ -49,47 +165,7 @@ class benchmark(RunnerCore):
Building.COMPILER = CLANG
Building.COMPILER_TEST_OPTS = []
- # Pick the JS engine to benchmark. If you specify one, it will be picked. For example, python tests/runner.py benchmark SPIDERMONKEY_ENGINE
- global JS_ENGINE
- JS_ENGINE = Building.JS_ENGINE_OVERRIDE if Building.JS_ENGINE_OVERRIDE is not None else JS_ENGINES[0]
- print 'Benchmarking JS engine: %s' % JS_ENGINE
-
- def print_stats(self, times, native_times, last=False, reps=TEST_REPS):
- if reps == 0:
- print '(no reps)'
- return
- mean = sum(times)/len(times)
- squared_times = map(lambda x: x*x, times)
- mean_of_squared = sum(squared_times)/len(times)
- std = math.sqrt(mean_of_squared - mean*mean)
- sorted_times = times[:]
- sorted_times.sort()
- median = sum(sorted_times[len(sorted_times)/2 - 1:len(sorted_times)/2 + 1])/2
-
- mean_native = sum(native_times)/len(native_times)
- squared_native_times = map(lambda x: x*x, native_times)
- mean_of_squared_native = sum(squared_native_times)/len(native_times)
- std_native = math.sqrt(mean_of_squared_native - mean_native*mean_native)
- sorted_native_times = native_times[:]
- sorted_native_times.sort()
- median_native = sum(sorted_native_times[len(sorted_native_times)/2 - 1:len(sorted_native_times)/2 + 1])/2
-
- final = mean / mean_native
-
- if last:
- norm = 0
- for i in range(len(times)):
- norm += times[i]/native_times[i]
- norm /= len(times)
- print
- print ' JavaScript: %.3f Native: %.3f Ratio: %.3f Normalized ratio: %.3f' % (mean, mean_native, final, norm)
- return
-
- print
- print ' JavaScript: mean: %.3f (+-%.3f) secs median: %.3f range: %.3f-%.3f (noise: %3.3f%%) (%d runs)' % (mean, std, median, min(times), max(times), 100*std/mean, reps)
- print ' Native : mean: %.3f (+-%.3f) secs median: %.3f range: %.3f-%.3f (noise: %3.3f%%) JS is %.2f X slower' % (mean_native, std_native, median_native, min(native_times), max(native_times), 100*std_native/mean_native, final)
-
- def do_benchmark(self, name, src, expected_output='FAIL', args=[], emcc_args=[], native_args=[], shared_args=[], force_c=False, reps=TEST_REPS, native_exec=None, output_parser=None, args_processor=None):
+ def do_benchmark(self, name, src, expected_output='FAIL', args=[], emcc_args=[], native_args=[], shared_args=[], force_c=False, reps=TEST_REPS, native_exec=None, output_parser=None, args_processor=None, lib_builder=None):
args = args or [DEFAULT_ARG]
if args_processor: args = args_processor(args)
@@ -98,68 +174,12 @@ class benchmark(RunnerCore):
f = open(filename, 'w')
f.write(src)
f.close()
- final_filename = os.path.join(dirname, name + '.js')
-
- open('hardcode.py', 'w').write('''
-def process(filename):
- js = open(filename).read()
- replaced = js.replace("run();", "run(%s.concat(Module[\\"arguments\\"]));")
- assert js != replaced
- open(filename, 'w').write(replaced)
-import sys
-process(sys.argv[1])
-''' % str(args[:-1]) # do not hardcode in the last argument, the default arg
-)
-
- try_delete(final_filename)
- output = Popen([PYTHON, EMCC, filename, #'-O3',
- '-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0',
- '--memory-init-file', '0', '--js-transform', 'python hardcode.py',
- '-s', 'TOTAL_MEMORY=128*1024*1024',
- '--closure', '1',
- #'-s', 'PRECISE_F32=1',
- #'-g',
- '-o', final_filename] + shared_args + emcc_args, stdout=PIPE, stderr=self.stderr_redirect).communicate()
- assert os.path.exists(final_filename), 'Failed to compile file: ' + output[0]
-
- # Run JS
- times = []
- for i in range(reps):
- start = time.time()
- js_output = run_js(final_filename, engine=JS_ENGINE, args=args, stderr=PIPE, full_output=True)
-
- if i == 0 and 'uccessfully compiled asm.js code' in js_output:
- if 'asm.js link error' not in js_output:
- print "[%s was asm.js'ified]" % name
- if not output_parser:
- curr = time.time()-start
- else:
- curr = output_parser(js_output)
- times.append(curr)
- if i == 0:
- # Sanity check on output
- self.assertContained(expected_output, js_output)
- # Run natively
- if not native_exec:
- self.build_native(filename, shared_args + native_args)
- else:
- shutil.copyfile(native_exec, filename + '.native')
- shutil.copymode(native_exec, filename + '.native')
- native_times = []
- for i in range(reps):
- start = time.time()
- native_output = self.run_native(filename, args)
- if i == 0:
- # Sanity check on output
- self.assertContained(expected_output, native_output)
- if not output_parser:
- curr = time.time()-start
- else:
- curr = output_parser(native_output)
- native_times.append(curr)
-
- self.print_stats(times, native_times, reps=reps)
+ print
+ for b in benchmarkers:
+ b.build(self, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder)
+ b.bench(args, output_parser)
+ b.display(benchmarkers[0])
def test_primes(self):
src = r'''
@@ -402,9 +422,11 @@ process(sys.argv[1])
self.fasta('fasta_float', 'float')
def test_fasta_double(self):
+ if CORE_BENCHMARKS: return
self.fasta('fasta_double', 'double')
def test_fasta_double_full(self):
+ if CORE_BENCHMARKS: return
self.fasta('fasta_double_full', 'double', emcc_args=['-s', 'DOUBLE_MODE=1'])
def test_skinning(self):
@@ -412,10 +434,12 @@ process(sys.argv[1])
self.do_benchmark('skinning', src, 'blah=0.000000')
def test_life(self):
+ if CORE_BENCHMARKS: return
src = open(path_from_root('tests', 'life.c'), 'r').read()
self.do_benchmark('life', src, '''--------------------------------''', shared_args=['-std=c99'], force_c=True)
def test_linpack_double(self):
+ if CORE_BENCHMARKS: return
def output_parser(output):
return 100.0/float(re.search('Unrolled Double Precision +([\d\.]+) Mflops', output).group(1))
self.do_benchmark('linpack_double', open(path_from_root('tests', 'linpack.c')).read(), '''Unrolled Double Precision''', force_c=True, output_parser=output_parser)
@@ -426,6 +450,7 @@ process(sys.argv[1])
self.do_benchmark('linpack_float', open(path_from_root('tests', 'linpack.c')).read(), '''Unrolled Single Precision''', force_c=True, output_parser=output_parser, shared_args=['-DSP'])
def test_zzz_java_nbody(self): # tests xmlvm compiled java, including bitcasts of doubles, i64 math, etc.
+ if CORE_BENCHMARKS: return
args = [path_from_root('tests', 'nbody-java', x) for x in os.listdir(path_from_root('tests', 'nbody-java')) if x.endswith('.c')] + \
['-I' + path_from_root('tests', 'nbody-java')]
self.do_benchmark('nbody_java', '', '''Time(s)''',
@@ -458,42 +483,29 @@ process(sys.argv[1])
def test_zzz_zlib(self):
src = open(path_from_root('tests', 'zlib', 'benchmark.c'), 'r').read()
- emcc_args = self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a']) + \
- ['-I' + path_from_root('tests', 'zlib')]
- native_args = self.get_library('zlib_native', os.path.join('libz.a'), make_args=['libz.a'], native=True) + \
- ['-I' + path_from_root('tests', 'zlib')]
+ def lib_builder(name, native, env_init):
+ return self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a'], native=native, cache_name_extra=name, env_init=env_init)
self.do_benchmark('zlib', src, '''ok.''',
- force_c=True, emcc_args=emcc_args, native_args=native_args)
+ force_c=True, shared_args=['-I' + path_from_root('tests', 'zlib')], lib_builder=lib_builder)
def test_zzz_box2d(self): # Called thus so it runs late in the alphabetical cycle... it is long
src = open(path_from_root('tests', 'box2d', 'Benchmark.cpp'), 'r').read()
-
- js_lib = self.get_library('box2d', [os.path.join('box2d.a')], configure=None)
- native_lib = self.get_library('box2d_native', [os.path.join('box2d.a')], configure=None, native=True)
-
- emcc_args = js_lib + ['-I' + path_from_root('tests', 'box2d')]
- native_args = native_lib + ['-I' + path_from_root('tests', 'box2d')]
-
- self.do_benchmark('box2d', src, 'frame averages', emcc_args=emcc_args, native_args=native_args)
+ def lib_builder(name, native, env_init):
+ return self.get_library('box2d', [os.path.join('box2d.a')], configure=None, native=native, cache_name_extra=name, env_init=env_init)
+ self.do_benchmark('box2d', src, 'frame averages', shared_args=['-I' + path_from_root('tests', 'box2d')], lib_builder=lib_builder)
def test_zzz_bullet(self): # Called thus so it runs late in the alphabetical cycle... it is long
src = open(path_from_root('tests', 'bullet', 'Demos', 'Benchmarks', 'BenchmarkDemo.cpp'), 'r').read() + \
open(path_from_root('tests', 'bullet', 'Demos', 'Benchmarks', 'main.cpp'), 'r').read()
- js_lib = self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletDynamics.a'),
+ def lib_builder(name, native, env_init):
+ return self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletDynamics.a'),
os.path.join('src', '.libs', 'libBulletCollision.a'),
os.path.join('src', '.libs', 'libLinearMath.a')],
- configure_args=['--disable-demos','--disable-dependency-tracking'])
- native_lib = self.get_library('bullet_native', [os.path.join('src', '.libs', 'libBulletDynamics.a'),
- os.path.join('src', '.libs', 'libBulletCollision.a'),
- os.path.join('src', '.libs', 'libLinearMath.a')],
- configure_args=['--disable-demos','--disable-dependency-tracking'],
- native=True)
-
- emcc_args = js_lib + ['-I' + path_from_root('tests', 'bullet', 'src'),
- '-I' + path_from_root('tests', 'bullet', 'Demos', 'Benchmarks'),
- '-s', 'DEAD_FUNCTIONS=["__ZSt9terminatev"]']
- native_args = native_lib + ['-I' + path_from_root('tests', 'bullet', 'src'),
- '-I' + path_from_root('tests', 'bullet', 'Demos', 'Benchmarks')]
-
- self.do_benchmark('bullet', src, '\nok.\n', emcc_args=emcc_args, native_args=native_args)
+ configure_args=['--disable-demos','--disable-dependency-tracking'], native=native, cache_name_extra=name, env_init=env_init)
+
+ emcc_args = ['-s', 'DEAD_FUNCTIONS=["__ZSt9terminatev"]']
+
+ self.do_benchmark('bullet', src, '\nok.\n', emcc_args=emcc_args, shared_args=['-I' + path_from_root('tests', 'bullet', 'src'),
+ '-I' + path_from_root('tests', 'bullet', 'Demos', 'Benchmarks')], lib_builder=lib_builder)
+
diff --git a/tests/test_browser.py b/tests/test_browser.py
index d0618af8..920c6f8c 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -119,6 +119,13 @@ If manually bisecting:
Even better, add a breakpoint, e.g. on the printf, then reload, then step through and see the print (best to run with EM_SAVE_DIR=1 for the reload).
'''
+ def test_emscripten_log(self):
+ src = os.path.join(self.get_dir(), 'src.cpp')
+ open(src, 'w').write(self.with_report_result(open(path_from_root('tests', 'emscripten_log', 'emscripten_log.cpp')).read()))
+
+ Popen([PYTHON, EMCC, src, '--pre-js', path_from_root('src', 'emscripten-source-map.min.js'), '-g', '-o', 'page.html']).communicate()
+ self.run_browser('page.html', None, '/report_result?1')
+
def build_native_lzma(self):
lzma_native = path_from_root('third_party', 'lzma.js', 'lzma-native')
if os.path.isfile(lzma_native) and os.access(lzma_native, os.X_OK): return
@@ -402,6 +409,7 @@ If manually bisecting:
self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
# Test subdirectory handling with asset packaging.
+ try_delete(self.in_dir('assets'))
os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset1/').replace('\\', '/'))
os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset1/.git').replace('\\', '/')) # Test adding directory that shouldn't exist.
os.makedirs(os.path.join(self.get_dir(), 'assets/sub/asset2/').replace('\\', '/'))
@@ -452,7 +460,7 @@ If manually bisecting:
(srcpath, dstpath1, dstpath2, nonexistingpath) = test
make_main_two_files(dstpath1, dstpath2, nonexistingpath)
print srcpath
- Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', srcpath, '-o', 'page.html']).communicate()
+ Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', srcpath, '--exclude-file', '*/.*', '-o', 'page.html']).communicate()
self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
# Should still work with -o subdir/..
@@ -1595,7 +1603,7 @@ keydown(100);keyup(100); // trigger the end
shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds')
shutil.copyfile(path_from_root('tests', 'bloom.dds'), 'bloom.dds')
shutil.copyfile(path_from_root('tests', 'water.dds'), 'water.dds')
- Popen([PYTHON, FILE_PACKAGER, 'test.data', '--pre-run', '--crunch', '--preload', 'ship.dds', 'bloom.dds', 'water.dds'], stdout=open('pre.js', 'w')).communicate()
+ Popen([PYTHON, FILE_PACKAGER, 'test.data', '--crunch', '--preload', 'ship.dds', 'bloom.dds', 'water.dds'], stdout=open('pre.js', 'w')).communicate()
assert os.stat('test.data').st_size < 0.5*(os.stat('ship.dds').st_size+os.stat('bloom.dds').st_size+os.stat('water.dds').st_size), 'Compressed should be smaller than dds'
shutil.move('ship.dds', 'ship.donotfindme.dds') # make sure we load from the compressed
shutil.move('bloom.dds', 'bloom.donotfindme.dds') # make sure we load from the compressed
@@ -1606,8 +1614,8 @@ keydown(100);keyup(100); // trigger the end
shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds')
shutil.copyfile(path_from_root('tests', 'bloom.dds'), 'bloom.dds')
shutil.copyfile(path_from_root('tests', 'water.dds'), 'water.dds')
- Popen([PYTHON, FILE_PACKAGER, 'asset_a.data', '--pre-run', '--crunch', '--preload', 'ship.dds', 'bloom.dds'], stdout=open('asset_a.js', 'w')).communicate()
- Popen([PYTHON, FILE_PACKAGER, 'asset_b.data', '--pre-run', '--crunch', '--preload', 'water.dds'], stdout=open('asset_b.js', 'w')).communicate()
+ Popen([PYTHON, FILE_PACKAGER, 'asset_a.data', '--crunch', '--preload', 'ship.dds', 'bloom.dds'], stdout=open('asset_a.js', 'w')).communicate()
+ Popen([PYTHON, FILE_PACKAGER, 'asset_b.data', '--crunch', '--preload', 'water.dds'], stdout=open('asset_b.js', 'w')).communicate()
shutil.move('ship.dds', 'ship.donotfindme.dds') # make sure we load from the compressed
shutil.move('bloom.dds', 'bloom.donotfindme.dds') # make sure we load from the compressed
shutil.move('water.dds', 'water.donotfindme.dds') # make sure we load from the compressed
@@ -1680,3 +1688,32 @@ keydown(100);keyup(100); // trigger the end
open(self.in_dir('data.dat'), 'w').write('data from the file ' + ('.' * 9000))
for extra_args in [[], ['--no-heap-copy']]:
self.btest(path_from_root('tests', 'mmap_file.c'), expected='1', args=['--preload-file', 'data.dat'] + extra_args)
+
+ def test_emrun_info(self):
+ result = subprocess.check_output([PYTHON, path_from_root('emrun'), '--system_info', '--browser_info'])
+ assert 'CPU' in result
+ assert 'Browser' in result
+ assert 'Traceback' not in result
+
+ result = subprocess.check_output([PYTHON, path_from_root('emrun'), '--list_browsers'])
+ assert 'Traceback' not in result
+
+ def test_emrun(self):
+ Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_exit.c'), '--emrun', '-o', 'hello_world.html']).communicate()
+ outdir = os.getcwd()
+ # We cannot run emrun from the temp directory the suite will clean up afterwards, since the browser that is launched will have that directory as startup directory,
+ # and the browser will not close as part of the test, pinning down the cwd on Windows and it wouldn't be possible to delete it. Therefore switch away from that directory
+ # before launching.
+ os.chdir(path_from_root())
+ args = [PYTHON, path_from_root('emrun'), '--timeout', '30', '--verbose', os.path.join(outdir, 'hello_world.html'), '1', '2', '3', '--log_stdout', os.path.join(outdir, 'stdout.txt'), '--log_stderr', os.path.join(outdir, 'stderr.txt')]
+ if emscripten_browser is not None:
+ args += ['--browser', emscripten_browser]
+ process = subprocess.Popen(args)
+ process.communicate()
+ stdout = open(os.path.join(outdir, 'stdout.txt'), 'r').read()
+ stderr = open(os.path.join(outdir, 'stderr.txt'), 'r').read()
+ assert process.returncode == 100
+ assert 'argc: 4' in stdout
+ assert 'argv[3]: 3' in stdout
+ assert 'hello, world!' in stdout
+ assert 'hello, error stream!' in stderr
diff --git a/tests/test_core.py b/tests/test_core.py
index 69abfc0e..c149281b 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -10,103 +10,29 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
return not ('i386-pc-linux-gnu' in COMPILER_OPTS or self.env.get('EMCC_LLVM_TARGET') == 'i386-pc-linux-gnu')
def test_hello_world(self):
- src = '''
- #include <stdio.h>
- int main()
- {
- printf("hello, world!\\n");
- return 0;
- }
- '''
- self.do_run(src, 'hello, world!')
+ test_path = path_from_root('tests', 'core', 'test_hello_world')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
assert 'EMSCRIPTEN_GENERATED_FUNCTIONS' not in open(self.in_dir('src.cpp.o.js')).read(), 'must not emit this unneeded internal thing'
def test_intvars(self):
if self.emcc_args == None: return self.skip('needs ta2')
- src = '''
- #include <stdio.h>
- int global = 20;
- int *far;
- int main()
- {
- int x = 5;
- int y = x+17;
- int z = (y-1)/2; // Should stay an integer after division!
- y += 1;
- int w = x*3+4;
- int k = w < 15 ? 99 : 101;
- far = &k;
- *far += global;
- int i = k > 100; // Should be an int, not a bool!
- int j = i << 6;
- j >>= 1;
- j = j ^ 5;
- int h = 1;
- h |= 0;
- int p = h;
- p &= 0;
- printf("*%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n", x, y, z, w, k, i, j, h, p);
-
- long hash = -1;
- size_t perturb;
- int ii = 0;
- for (perturb = hash; ; perturb >>= 5) {
- printf("%d:%d", ii, perturb);
- ii++;
- if (ii == 9) break;
- printf(",");
- }
- printf("*\\n");
- printf("*%.1d,%.2d*\\n", 56, 9);
-
- // Fixed-point math on 64-bit ints. Tricky to support since we have no 64-bit shifts in JS
- {
- struct Fixed {
- static int Mult(int a, int b) {
- return ((long long)a * (long long)b) >> 16;
- }
- };
- printf("fixed:%d\\n", Fixed::Mult(150000, 140000));
- }
+ test_path = path_from_root('tests', 'core', 'test_intvars')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("*%ld*%p\\n", (long)21, &hash); // The %p should not enter an infinite loop!
- return 0;
- }
- '''
- self.do_run(src, '*5,23,10,19,121,1,37,1,0*\n0:-1,1:134217727,2:4194303,3:131071,4:4095,5:127,6:3,7:0,8:0*\n*56,09*\nfixed:320434\n*21*')
+ self.do_run_from_file(src, output)
def test_sintvars(self):
Settings.CORRECT_SIGNS = 1 # Relevant to this test
- src = '''
- #include <stdio.h>
- struct S {
- char *match_start;
- char *strstart;
- };
- int main()
- {
- struct S _s;
- struct S *s = &_s;
- unsigned short int sh;
-
- s->match_start = (char*)32522;
- s->strstart = (char*)(32780);
- printf("*%d,%d,%d*\\n", (int)s->strstart, (int)s->match_start, (int)(s->strstart - s->match_start));
- sh = s->strstart - s->match_start;
- printf("*%d,%d*\\n", sh, sh>>7);
-
- s->match_start = (char*)32999;
- s->strstart = (char*)(32780);
- printf("*%d,%d,%d*\\n", (int)s->strstart, (int)s->match_start, (int)(s->strstart - s->match_start));
- sh = s->strstart - s->match_start;
- printf("*%d,%d*\\n", sh, sh>>7);
- }
- '''
- output = '*32780,32522,258*\n*258,2*\n*32780,32999,-219*\n*65317,510*'
Settings.CORRECT_OVERFLOWS = 0 # We should not need overflow correction to get this right
- self.do_run(src, output, force_c=True)
+
+ test_path = path_from_root('tests', 'core', 'test_sintvars')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, force_c=True)
def test_i64(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('i64 mode 1 requires ta2')
@@ -338,169 +264,42 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
def test_i64_b(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <stdio.h>
- #include <sys/time.h>
-
- typedef long long int64;
-
- #define PRMJ_USEC_PER_SEC 1000000L
-
- int main(int argc, char * argv[]) {
- int64 sec = 1329409675 + argc;
- int64 usec = 2329509675;
- int64 mul = int64(sec) * PRMJ_USEC_PER_SEC;
- int64 add = mul + int64(usec);
- int add_low = add;
- int add_high = add >> 32;
- printf("*%lld,%lld,%u,%u*\n", mul, add, add_low, add_high);
- int64 x = sec + (usec << 25);
- x >>= argc*3;
- printf("*%llu*\n", x);
- return 0;
- }
- '''
+ test_path = path_from_root('tests', 'core', 'test_i64_b')
+ src, output = (test_path + s for s in ('.in', '.out'))
- self.do_run(src, '*1329409676000000,1329412005509675,3663280683,309527*\n*9770671914067409*\n')
+ self.do_run_from_file(src, output)
def test_i64_cmp(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <stdio.h>
-
- typedef long long int64;
-
- bool compare(int64 val) {
- return val == -12;
- }
-
- bool compare2(int64 val) {
- return val < -12;
- }
-
- int main(int argc, char * argv[]) {
- printf("*%d,%d,%d,%d,%d,%d*\n", argc, compare(argc-1-12), compare(1000+argc), compare2(argc-1-10), compare2(argc-1-14), compare2(argc+1000));
- return 0;
- }
- '''
+ test_path = path_from_root('tests', 'core', 'test_i64_cmp')
+ src, output = (test_path + s for s in ('.in', '.out'))
- self.do_run(src, '*1,1,0,0,1,0*\n')
+ self.do_run_from_file(src, output)
def test_i64_cmp2(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <inttypes.h>
- #include <stdio.h>
-
- typedef int32_t INT32;
- typedef int64_t INT64;
- typedef uint8_t UINT8;
-
- void interface_clock_changed()
- {
- UINT8 m_divshift;
- INT32 m_divisor;
+ test_path = path_from_root('tests', 'core', 'test_i64_cmp2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- //INT64 attos = m_attoseconds_per_cycle;
- INT64 attos = 279365114840;
- m_divshift = 0;
- while (attos >= (1UL << 31))
- {
- m_divshift++;
- printf("m_divshift is %i, on %Ld >?= %lu\n", m_divshift, attos, 1UL << 31);
- attos >>= 1;
- }
- m_divisor = attos;
-
- printf("m_divisor is %i\n",m_divisor);
- }
-
- int main() {
- interface_clock_changed();
- return 0;
- }
- '''
- self.do_run(src, '''m_divshift is 1, on 279365114840 >?= 2147483648
-m_divshift is 2, on 139682557420 >?= 2147483648
-m_divshift is 3, on 69841278710 >?= 2147483648
-m_divshift is 4, on 34920639355 >?= 2147483648
-m_divshift is 5, on 17460319677 >?= 2147483648
-m_divshift is 6, on 8730159838 >?= 2147483648
-m_divshift is 7, on 4365079919 >?= 2147483648
-m_divshift is 8, on 2182539959 >?= 2147483648
-m_divisor is 1091269979
-''')
+ self.do_run_from_file(src, output)
def test_i64_double(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
+ test_path = path_from_root('tests', 'core', 'test_i64_double')
+ src, output = (test_path + s for s in ('.in', '.out'))
- src = r'''
- #include <stdio.h>
-
- typedef long long int64;
- #define JSDOUBLE_HI32_SIGNBIT 0x80000000
-
- bool JSDOUBLE_IS_NEGZERO(double d)
- {
- union {
- struct {
- unsigned int lo, hi;
- } s;
- double d;
- } x;
- if (d != 0)
- return false;
- x.d = d;
- return (x.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0;
- }
-
- bool JSINT64_IS_NEGZERO(int64 l)
- {
- union {
- int64 i;
- double d;
- } x;
- if (l != 0)
- return false;
- x.i = l;
- return x.d == -0;
- }
-
- int main(int argc, char * argv[]) {
- printf("*%d,%d,%d,%d*\n", JSDOUBLE_IS_NEGZERO(0), JSDOUBLE_IS_NEGZERO(-0), JSDOUBLE_IS_NEGZERO(-1), JSDOUBLE_IS_NEGZERO(+1));
- printf("*%d,%d,%d,%d*\n", JSINT64_IS_NEGZERO(0), JSINT64_IS_NEGZERO(-0), JSINT64_IS_NEGZERO(-1), JSINT64_IS_NEGZERO(+1));
- return 0;
- }
- '''
- self.do_run(src, '*0,0,0,0*\n*1,1,0,0*\n') # same as gcc
+ self.do_run_from_file(src, output)
def test_i64_umul(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <inttypes.h>
- #include <stdio.h>
-
- typedef uint32_t UINT32;
- typedef uint64_t UINT64;
+ test_path = path_from_root('tests', 'core', 'test_i64_umul')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- volatile UINT32 testu32a = 2375724032U;
- UINT32 bigu32 = 0xffffffffU;
- volatile UINT64 testu64a = 14746250828952703000U;
-
- while ((UINT64)testu32a * (UINT64)bigu32 < testu64a) {
- printf("testu64a is %llu\n", testu64a);
- testu64a /= 2;
- }
-
- return 0;
- }
- '''
- self.do_run(src, 'testu64a is 14746250828952703000\n')
+ self.do_run_from_file(src, output)
def test_i64_precise(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
@@ -552,6 +351,9 @@ m_divisor is 1091269979
}
'''
self.do_run(src, '*4903566027370624, 153236438355333*')
+
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
code = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read()
assert 'goog.math.Long' not in code, 'i64 precise math should not have been included if not actually used'
@@ -579,513 +381,119 @@ m_divisor is 1091269979
def test_i64_llabs(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
Settings.PRECISE_I64_MATH = 2
- self.do_run(r'''
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char ** argv) {
- printf("%lld,%lld\n", llabs(-576460752303423489), llabs(576460752303423489));
- return 0;
- }
- ''', '576460752303423489,576460752303423489')
+ test_path = path_from_root('tests', 'core', 'test_i64_llabs')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_i64_zextneg(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <stdint.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_i64_zextneg')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char *argv[])
- {
- uint8_t byte = 0x80;
- uint16_t two = byte;
- uint32_t four = byte;
- uint64_t eight = byte;
-
- printf("value: %d,%d,%d,%lld.\n", byte, two, four, eight);
-
- return 0;
- }
- '''
- self.do_run(src, 'value: 128,128,128,128.')
+ self.do_run_from_file(src, output)
def test_i64_7z(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <stdint.h>
- #include <stdio.h>
- uint64_t a, b;
- int main(int argc, char *argv[])
- {
- a = argc;
- b = argv[1][0];
- printf("%d,%d\n", a, b);
- if (a > a + b || a > a + b + 1) {
- printf("one %lld, %lld", a, b);
- return 0;
- }
- printf("zero %lld, %lld", a, b);
- return 0;
- }
- '''
- self.do_run(src, 'zero 2, 104', ['hallo'])
+ test_path = path_from_root('tests', 'core', 'test_i64_7z')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, ['hallo'])
def test_i64_i16(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <stdint.h>
- #include <stdio.h>
- int main(int argc, char ** argv){
- int y=-133;
- int64_t x= ((int64_t)((short)(y)))*(100 + argc);
- if(x>0)
- printf(">0\n");
- else
- printf("<=0\n");
- }
- '''
- self.do_run(src, '<=0')
+ test_path = path_from_root('tests', 'core', 'test_i64_i16')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_i64_qdouble(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <stdio.h>
- typedef long long qint64; /* 64 bit signed */
- typedef double qreal;
+ test_path = path_from_root('tests', 'core', 'test_i64_qdouble')
+ src, output = (test_path + s for s in ('.in', '.out'))
-
- int main(int argc, char **argv)
- {
- qreal c = 111;
- qint64 d = -111 + (argc - 1);
- c += d;
- if (c < -1 || c > 1)
- {
- printf("Failed!\n");
- }
- else
- {
- printf("Succeeded!\n");
- }
- };
- '''
- self.do_run(src, 'Succeeded!')
+ self.do_run_from_file(src, output)
def test_i64_varargs(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
- src = r'''
- #include <stdio.h>
- #include <stdint.h>
- #include <stdarg.h>
-
- int64_t ccv_cache_generate_signature(char *msg, int len, int64_t sig_start, ...) {
- if (sig_start < 10123)
- printf("%s\n", msg+len);
- va_list v;
- va_start(v, sig_start);
- if (sig_start > 1413)
- printf("%d\n", va_arg(v, int));
- else
- printf("nada\n");
- va_end(v);
- return len*sig_start*(msg[0]+1);
- }
+ test_path = path_from_root('tests', 'core', 'test_i64_varargs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char **argv)
- {
- for (int i = 0; i < argc; i++) {
- int64_t x;
- if (i % 123123 == 0)
- x = ccv_cache_generate_signature(argv[i], i+2, (int64_t)argc*argc, 54.111);
- else
- x = ccv_cache_generate_signature(argv[i], i+2, (int64_t)argc*argc, 13);
- printf("%lld\n", x);
- }
- };
- '''
- self.do_run(src, '''in/this.program
-nada
-1536
-a
-nada
-5760
-fl
-nada
-6592
-sdfasdfasdf
-nada
-7840
-''', 'waka fleefl asdfasdfasdfasdf'.split(' '))
+ self.do_run_from_file(src, output, 'waka fleefl asdfasdfasdfasdf'.split(' '))
def test_i32_mul_precise(self):
if self.emcc_args == None: return self.skip('needs ta2')
- src = r'''
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_i32_mul_precise')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char **argv) {
- unsigned long d1 = 0x847c9b5d;
- unsigned long q = 0x549530e1;
- if (argc > 1000) { q += argc; d1 -= argc; } // confuse optimizer
- printf("%lu\n", d1*q);
- return 0;
- }
- '''
- self.do_run(src, '3217489085')
+ self.do_run_from_file(src, output)
def test_i32_mul_semiprecise(self):
if Settings.ASM_JS: return self.skip('asm is always fully precise')
Settings.PRECISE_I32_MUL = 0 # we want semiprecise here
- src = r'''
- #include <stdio.h>
-
- typedef unsigned int uint;
+ test_path = path_from_root('tests', 'core', 'test_i32_mul_semiprecise')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // from cube2, zlib licensed
-
- #define N (624)
- #define M (397)
- #define K (0x9908B0DFU)
-
- static uint state[N];
- static int next = N;
-
- void seedMT(uint seed)
- {
- state[0] = seed;
- for(uint i = 1; i < N; i++) // if we do not do this precisely, at least we should coerce to int immediately, not wait
- state[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i;
- next = 0;
- }
-
- int main() {
- seedMT(5497);
- for (int i = 0; i < 10; i++) printf("%d: %u\n", i, state[i]);
- return 0;
- }
- '''
- self.do_run(src, '''0: 5497
-1: 2916432318
-2: 2502517762
-3: 3151524867
-4: 2323729668
-5: 2053478917
-6: 2409490438
-7: 848473607
-8: 691103752
-9: 3915535113
-''')
+ self.do_run_from_file(src, output)
def test_i16_emcc_intrinsic(self):
Settings.CORRECT_SIGNS = 1 # Relevant to this test
- src = r'''
- #include <stdio.h>
-
- int test(unsigned short a, unsigned short b) {
- unsigned short result = a;
- result += b;
- if (result < b) printf("C!");
- return result;
- }
+ test_path = path_from_root('tests', 'core', 'test_i16_emcc_intrinsic')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(void) {
- printf(",%d,", test(0, 0));
- printf(",%d,", test(1, 1));
- printf(",%d,", test(65535, 1));
- printf(",%d,", test(1, 65535));
- printf(",%d,", test(32768, 32767));
- printf(",%d,", test(32768, 32768));
- return 0;
- }
- '''
- self.do_run(src, ',0,,2,C!,0,C!,0,,65535,C!,0,')
+ self.do_run_from_file(src, output)
def test_double_i64_conversion(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2')
- src = r'''
- #include <cassert>
- #include <inttypes.h>
- #include <stdio.h>
-
- __attribute((noinline)) bool eq(double d, int64_t i) {
- int64_t i2 = (int64_t)d;
- if (i != i2) {
- printf("%.20g converted to int64 returns %lld, not %lld as expected!\n", d, i2, i);
- }
- return i == i2;
- }
+ test_path = path_from_root('tests', 'core', 'test_double_i64_conversion')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- assert(eq(0.0, 0));
- assert(eq(-0.0, 0));
- assert(eq(0.1, 0));
- assert(eq(-0.1, 0));
- assert(eq(0.6, 0));
- assert(eq(-0.6, 0));
- assert(eq(1.0, 1));
- assert(eq(-1.0, -1));
- assert(eq(1.1, 1));
- assert(eq(-1.1, -1));
- assert(eq(1.6, 1));
- assert(eq(-1.6, -1));
- assert(eq(4294967295.0, 4294967295LL));
- assert(eq(4294967295.5, 4294967295LL));
- assert(eq(4294967296.0, 4294967296LL));
- assert(eq(4294967296.5, 4294967296LL));
- assert(eq(14294967295.0, 14294967295LL));
- assert(eq(14294967295.5, 14294967295LL));
- assert(eq(14294967296.0, 14294967296LL));
- assert(eq(14294967296.5, 14294967296LL));
- assert(eq(-4294967295.0, -4294967295LL));
- assert(eq(-4294967295.5, -4294967295LL));
- assert(eq(-4294967296.0, -4294967296LL));
- assert(eq(-4294967296.5, -4294967296LL));
- assert(eq(-14294967295.0, -14294967295LL));
- assert(eq(-14294967295.5, -14294967295LL));
- assert(eq(-14294967296.0, -14294967296LL));
- assert(eq(-14294967296.5, -14294967296LL));
-
- assert(eq(4294967295.3, 4294967295LL));
- assert(eq(4294967296.3, 4294967296LL));
- assert(eq(14294967295.3, 14294967295LL));
- assert(eq(14294967296.3, 14294967296LL));
- assert(eq(-4294967295.3, -4294967295LL));
- assert(eq(-4294967296.3, -4294967296LL));
- assert(eq(-14294967295.3, -14294967295LL));
- assert(eq(-14294967296.3, -14294967296LL));
-
- assert(eq(4294967295.8, 4294967295LL));
- assert(eq(4294967296.8, 4294967296LL));
- assert(eq(14294967295.8, 14294967295LL));
- assert(eq(14294967296.8, 14294967296LL));
- assert(eq(-4294967295.8, -4294967295LL));
- assert(eq(-4294967296.8, -4294967296LL));
- assert(eq(-14294967295.8, -14294967295LL));
- assert(eq(-14294967296.8, -14294967296LL));
-
- // The following number is the largest double such that all integers smaller than this can exactly be represented in a double.
- assert(eq(9007199254740992.0, 9007199254740992LL /* == 2^53 */));
- assert(eq(-9007199254740992.0, -9007199254740992LL /* == -2^53 */));
-
- printf("OK!\n");
- return 0;
- }
- '''
- self.do_run(src, 'OK!\n');
+ self.do_run_from_file(src, output)
def test_float32_precise(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
Settings.PRECISE_F32 = 1
- src = r'''
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_float32_precise')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char **argv) {
- float x = 1.23456789123456789;
- float y = 5.20456089123406709;
- while (argc > 10 || argc % 19 == 15) {
- // confuse optimizer
- x /= y;
- y = 2*y - 1;
- argc--;
- }
- x = x - y;
- y = 3*y - x/2;
- x = x*y;
- y += 0.000000000123123123123;
- x -= y/7.654;
- printf("\n%.20f, %.20f\n", x, y);
- return 0;
- }
- '''
- self.do_run(src, '\n-72.16590881347656250000, 17.59867858886718750000\n')
+ self.do_run_from_file(src, output)
def test_negative_zero(self):
- src = r'''
- #include <stdio.h>
- #include <math.h>
+ test_path = path_from_root('tests', 'core', 'test_negative_zero')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- #define TEST(x, y) \
- printf("%.2f, %.2f ==> %.2f\n", x, y, copysign(x, y));
- TEST( 5.0f, 5.0f);
- TEST( 5.0f, -5.0f);
- TEST(-5.0f, 5.0f);
- TEST(-5.0f, -5.0f);
- TEST( 5.0f, 4.0f);
- TEST( 5.0f, -4.0f);
- TEST(-5.0f, 4.0f);
- TEST(-5.0f, -4.0f);
- TEST( 0.0f, 5.0f);
- TEST( 0.0f, -5.0f);
- TEST(-0.0f, 5.0f);
- TEST(-0.0f, -5.0f);
- TEST( 5.0f, 0.0f);
- TEST( 5.0f, -0.0f);
- TEST(-5.0f, 0.0f);
- TEST(-5.0f, -0.0f);
- TEST( 0.0f, 0.0f);
- TEST( 0.0f, -0.0f);
- TEST(-0.0f, 0.0f);
- TEST(-0.0f, -0.0f);
- return 0;
- }
- '''
- self.do_run(src, '''5.00, 5.00 ==> 5.00
-5.00, -5.00 ==> -5.00
--5.00, 5.00 ==> 5.00
--5.00, -5.00 ==> -5.00
-5.00, 4.00 ==> 5.00
-5.00, -4.00 ==> -5.00
--5.00, 4.00 ==> 5.00
--5.00, -4.00 ==> -5.00
-0.00, 5.00 ==> 0.00
-0.00, -5.00 ==> -0.00
--0.00, 5.00 ==> 0.00
--0.00, -5.00 ==> -0.00
-5.00, 0.00 ==> 5.00
-5.00, -0.00 ==> -5.00
--5.00, 0.00 ==> 5.00
--5.00, -0.00 ==> -5.00
-0.00, 0.00 ==> 0.00
-0.00, -0.00 ==> -0.00
--0.00, 0.00 ==> 0.00
--0.00, -0.00 ==> -0.00
-''')
+ self.do_run_from_file(src, output)
def test_llvm_intrinsics(self):
if self.emcc_args == None: return self.skip('needs ta2')
Settings.PRECISE_I64_MATH = 2 # for bswap64
- src = r'''
- #include <stdio.h>
- #include <sys/types.h>
-
- extern "C" {
- extern unsigned short llvm_bswap_i16(unsigned short x);
- extern unsigned int llvm_bswap_i32(unsigned int x);
- extern int32_t llvm_ctlz_i32(int32_t x);
- extern int64_t llvm_ctlz_i64(int64_t x);
- extern int32_t llvm_cttz_i32(int32_t x);
- extern int64_t llvm_cttz_i64(int64_t x);
- extern int32_t llvm_ctpop_i32(int32_t x);
- extern int64_t llvm_ctpop_i64(int64_t x);
- extern int llvm_expect_i32(int x, int y);
- }
-
- int main(void) {
- unsigned short x = 0xc8ef;
- printf("%x,%x\n", x&0xff, x >> 8);
- x = llvm_bswap_i16(x);
- printf("%x,%x\n", x&0xff, x >> 8);
-
- unsigned int y = 0xc5de158a;
- printf("%x,%x,%x,%x\n", y&0xff, (y>>8)&0xff, (y>>16)&0xff, (y>>24)&0xff);
- y = llvm_bswap_i32(y);
- printf("%x,%x,%x,%x\n", y&0xff, (y>>8)&0xff, (y>>16)&0xff, (y>>24)&0xff);
+ test_path = path_from_root('tests', 'core', 'test_llvm_intrinsics')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("%d,%d\n", (int)llvm_ctlz_i64(((int64_t)1) << 40), llvm_ctlz_i32(1<<10));
- printf("%d,%d\n", (int)llvm_cttz_i64(((int64_t)1) << 40), llvm_cttz_i32(1<<10));
- printf("%d,%d\n", (int)llvm_ctpop_i64((0x3101ULL << 32) | 1), llvm_ctpop_i32(0x3101));
- printf("%d\n", (int)llvm_ctpop_i32(-594093059));
-
- printf("%d\n", llvm_expect_i32(x % 27, 3));
-
- int64_t a = 1;
- a = __builtin_bswap64(a);
- printf("%lld\n", a);
-
- return 0;
- }
- '''
- self.do_run(src, '''ef,c8
-c8,ef
-8a,15,de,c5
-c5,de,15,8a
-23,21
-40,10
-5,4
-22
-13
-72057594037927936
-''')
+ self.do_run_from_file(src, output)
def test_bswap64(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2')
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <iostream>
- #include <string>
- #include <sstream>
-
- typedef unsigned long long quint64;
-
- using namespace std;
-
- inline quint64 qbswap(quint64 source)
- {
- return 0
- | ((source & quint64(0x00000000000000ffLL)) << 56)
- | ((source & quint64(0x000000000000ff00LL)) << 40)
- | ((source & quint64(0x0000000000ff0000LL)) << 24)
- | ((source & quint64(0x00000000ff000000LL)) << 8)
- | ((source & quint64(0x000000ff00000000LL)) >> 8)
- | ((source & quint64(0x0000ff0000000000LL)) >> 24)
- | ((source & quint64(0x00ff000000000000LL)) >> 40)
- | ((source & quint64(0xff00000000000000LL)) >> 56);
- }
-
- int main()
- {
- quint64 v = strtoull("4433ffeeddccbb00", NULL, 16);
- printf("%lld\n", v);
-
- const string string64bitInt = "4433ffeeddccbb00";
- stringstream s(string64bitInt);
- quint64 int64bitInt = 0;
- printf("1\n");
- s >> hex >> int64bitInt;
- printf("2\n");
-
- stringstream out;
- out << hex << qbswap(int64bitInt);
+ test_path = path_from_root('tests', 'core', 'test_bswap64')
+ src, output = (test_path + s for s in ('.in', '.out'))
- cout << out.str() << endl;
- cout << hex << int64bitInt << endl;
- cout << string64bitInt << endl;
-
- if (out.str() != "bbccddeeff3344")
- {
- cout << "Failed!" << endl;
- }
- else
- {
- cout << "Succeeded!" << endl;
- }
-
- return 0;
- }
- '''
- self.do_run(src, '''4914553019779824384
-1
-2
-bbccddeeff3344
-4433ffeeddccbb00
-4433ffeeddccbb00
-Succeeded!
-''')
+ self.do_run_from_file(src, output)
def test_sha1(self):
if self.emcc_args == None: return self.skip('needs ta2')
@@ -1117,7 +525,7 @@ Succeeded!
os.environ['EMSCRIPT_MAX_CHUNK_SIZE'] = old_chunk_size
assert 'asm1' in test_modes
- if self.run_name == 'asm1':
+ if self.run_name == 'asm1' and not os.environ.get('EMCC_FAST_COMPILER'):
assert Settings.RELOOP
generated = open('src.cpp.o.js').read()
main = generated[generated.find('function _main'):]
@@ -1351,240 +759,70 @@ Succeeded!
def test_bitfields(self):
if self.emcc_args is None: Settings.SAFE_HEAP = 0 # bitfields do loads on invalid areas, by design
- src = '''
- #include <stdio.h>
- struct bitty {
- unsigned x : 1;
- unsigned y : 1;
- unsigned z : 1;
- };
- int main()
- {
- bitty b;
- printf("*");
- for (int i = 0; i <= 1; i++)
- for (int j = 0; j <= 1; j++)
- for (int k = 0; k <= 1; k++) {
- b.x = i;
- b.y = j;
- b.z = k;
- printf("%d,%d,%d,", b.x, b.y, b.z);
- }
- printf("*\\n");
- return 0;
- }
- '''
- self.do_run(src, '*0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,1,0,1,1,1,0,1,1,1,*')
- def test_floatvars(self):
- src = '''
- #include <stdio.h>
-
- // headers test, see issue #1013
- #include<cfloat>
- #include<cmath>
+ test_path = path_from_root('tests', 'core', 'test_bitfields')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char **argv)
- {
- float x = 1.234, y = 3.5, q = 0.00000001;
- y *= 3;
- int z = x < y;
- printf("*%d,%d,%.1f,%d,%.4f,%.2f*\\n", z, int(y), y, (int)x, x, q);
+ self.do_run_from_file(src, output)
- printf("%.2f, %.2f, %.2f, %.2f\\n", fmin(0.5, 3.3), fmin(NAN, 3.3), fmax(0.5, 3.3), fmax(NAN, 3.3));
-
- printf("small: %.10f\\n", argc * 0.000001);
+ def test_floatvars(self):
+ test_path = path_from_root('tests', 'core', 'test_floatvars')
+ src, output = (test_path + s for s in ('.in', '.out'))
- /*
- // Rounding behavior
- float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
- double ds[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
- for (int i = 0; i < 6; i++)
- printf("*int(%.2f)=%d,%d*\\n", fs[i], int(fs[i]), int(ds[i]));
- */
+ self.do_run_from_file(src, output)
- return 0;
- }
- '''
- self.do_run(src, '*1,10,10.5,1,1.2340,0.00*\n0.50, 3.30, 3.30, 3.30\nsmall: 0.0000010000\n')
+ def test_closebitcasts(self):
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2')
+ test_path = path_from_root('tests', 'core', 'closebitcasts')
+ src, output = (test_path + s for s in ('.c', '.txt'))
+ self.do_run_from_file(src, output)
def test_fast_math(self):
if self.emcc_args is None: return self.skip('requires emcc')
Building.COMPILER_TEST_OPTS += ['-ffast-math']
- self.do_run(r'''
-#include <stdio.h>
-#include <stdlib.h>
-
-int main(int argc, char** argv) {
- char* endptr;
- --argc, ++argv;
- double total = 0.0;
- for (; argc; argc--, argv++) {
- total += strtod(*argv, &endptr);
- }
- printf("total: %g\n", total);
- return 0;
-}
-''', 'total: 19', ['5', '6', '8'])
+ test_path = path_from_root('tests', 'core', 'test_fast_math')
+ src, output = (test_path + s for s in ('.in', '.out'))
- def test_zerodiv(self):
- self.do_run(r'''
- #include <stdio.h>
- int main(int argc, const char* argv[])
- {
- float f1 = 1.0f;
- float f2 = 0.0f;
- float f_zero = 0.0f;
+ self.do_run_from_file(src, output, ['5', '6', '8'])
- float f3 = 0.0f / f2;
- float f4 = f2 / 0.0f;
- float f5 = f2 / f2;
- float f6 = f2 / f_zero;
+ def test_zerodiv(self):
+ test_path = path_from_root('tests', 'core', 'test_zerodiv')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("f3: %f\n", f3);
- printf("f4: %f\n", f4);
- printf("f5: %f\n", f5);
- printf("f6: %f\n", f6);
-
- return 0;
- }
- ''', '''f3: nan
-f4: nan
-f5: nan
-f6: nan
-''')
+ self.do_run_from_file(src, output)
def test_zero_multiplication(self):
- src = '''
- #include <stdio.h>
- int main(int argc, char * argv[]) {
- int one = argc;
-
- printf("%d ", 0 * one);
- printf("%d ", 0 * -one);
- printf("%d ", -one * 0);
- printf("%g ", 0.0 * one);
- printf("%g ", 0.0 * -one);
- printf("%g", -one * 0.0);
- return 0;
- }
- '''
- self.do_run(src, '0 0 0 0 -0 -0')
+ test_path = path_from_root('tests', 'core', 'test_zero_multiplication')
+ src, output = (test_path + s for s in ('.in', '.out'))
- def test_isnan(self):
- src = r'''
- #include <stdio.h>
+ self.do_run_from_file(src, output)
- int IsNaN(double x){
- int rc; /* The value return */
- volatile double y = x;
- volatile double z = y;
- rc = (y!=z);
- return rc;
- }
+ def test_isnan(self):
+ test_path = path_from_root('tests', 'core', 'test_isnan')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- double tests[] = { 1.0, 3.333, 1.0/0.0, 0.0/0.0, -1.0/0.0, -0, 0, -123123123, 12.0E200 };
- for (int i = 0; i < sizeof(tests)/sizeof(double); i++)
- printf("%d - %f - %d\n", i, tests[i], IsNaN(tests[i]));
- }
- '''
- self.do_run(src, '''0 - 1.000000 - 0
-1 - 3.333000 - 0
-2 - inf - 0
-3 - nan - 1
-4 - -inf - 0
-5 - 0.000000 - 0
-6 - 0.000000 - 0
-7 - -123123123.000000 - 0
-8 - 1.2e+201 - 0
-''')
+ self.do_run_from_file(src, output)
def test_globaldoubles(self):
- src = r'''
- #include <stdlib.h>
- #include <stdio.h>
-
- double testVu, testVv, testWu, testWv;
+ test_path = path_from_root('tests', 'core', 'test_globaldoubles')
+ src, output = (test_path + s for s in ('.in', '.out'))
- void Test(double _testVu, double _testVv, double _testWu, double _testWv)
- {
- testVu = _testVu;
- testVv = _testVv;
- testWu = _testWu;
- testWv = _testWv;
- printf("BUG?\n");
- printf("Display: Vu=%f Vv=%f Wu=%f Wv=%f\n", testVu, testVv, testWu, testWv);
- }
-
- int main(void)
- {
- double v1 = 465.1;
- double v2 = 465.2;
- double v3 = 160.3;
- double v4 = 111.4;
- Test(v1, v2, v3, v4);
- return 0;
- }
- '''
- self.do_run(src, 'BUG?\nDisplay: Vu=465.100000 Vv=465.200000 Wu=160.300000 Wv=111.400000')
+ self.do_run_from_file(src, output)
def test_math(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2')
- src = '''
- #include <stdio.h>
- #include <stdlib.h>
- #include <cmath>
- int main(int argc, char **argv)
- {
- printf("*%.2f,%.2f,%d", M_PI, -M_PI, (1/0.0) > 1e300); // could end up as infinity, or just a very very big number
- printf(",%d", isfinite(NAN) != 0);
- printf(",%d", isfinite(INFINITY) != 0);
- printf(",%d", isfinite(-INFINITY) != 0);
- printf(",%d", isfinite(12.3) != 0);
- printf(",%d", isinf(NAN) != 0);
- printf(",%d", isinf(INFINITY) != 0);
- printf(",%d", isinf(-INFINITY) != 0);
- printf(",%d", isinf(12.3) != 0);
- div_t div_result = div(23, 10);
- printf(",%d", div_result.quot);
- printf(",%d", div_result.rem);
- double sine = -1.0, cosine = -1.0;
- sincos(0.0, &sine, &cosine);
- printf(",%1.1lf", sine);
- printf(",%1.1lf", cosine);
- float fsine = -1.0f, fcosine = -1.0f;
- sincosf(0.0, &fsine, &fcosine);
- printf(",%1.1f", fsine);
- printf(",%1.1f", fcosine);
- fsine = sinf(1.1 + argc - 1);
- fcosine = cosf(1.1 + argc - 1);
- printf(",%1.1f", fsine);
- printf(",%1.1f", fcosine);
- printf("*\\n");
- return 0;
- }
- '''
- self.do_run(src, '*3.14,-3.14,1,0,0,0,1,0,1,1,0,2,3,0.0,1.0,0.0,1.0,0.9,0.5*')
+
+ test_path = path_from_root('tests', 'core', 'test_math')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_erf(self):
- src = '''
- #include <math.h>
- #include <stdio.h>
- int main()
- {
- printf("%1.6f, %1.6f, %1.6f, %1.6f, %1.6f, %1.6f\\n",
- erf(1.0),
- erf(3.0),
- erf(-1.0),
- erfc(1.0),
- erfc(3.0),
- erfc(-1.5));
- return 0;
- }
- '''
- self.do_run(src, '0.842701, 0.999978, -0.842701, 0.157299, 0.000022, 1.966105')
+ test_path = path_from_root('tests', 'core', 'test_erf')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_math_hyperbolic(self):
src = open(path_from_root('tests', 'hyperbolic', 'src.c'), 'r').read()
@@ -1592,131 +830,39 @@ f6: nan
self.do_run(src, expected)
def test_frexp(self):
- src = '''
- #include <stdio.h>
- #include <math.h>
- #include <assert.h>
-
- static const double tol=1e-16;
+ test_path = path_from_root('tests', 'core', 'test_frexp')
+ src, output = (test_path + s for s in ('.in', '.out'))
- void test_value(double value)
- {
- int exponent;
- double x=frexp(value, &exponent);
- double expected=x*pow(2.0, exponent);
-
- printf("%f=%f*2^%d\\n", value, x, exponent);
-
- assert(fabs(expected-value)<tol);
- assert(x==0 || (fabs(x)>=5e-1 && fabs(x)<1)); // x has a magnitude in the interval [1/2, 1)
- }
-
- int main()
- {
- test_value(0);
- test_value(100.1);
- test_value(-100.1);
- test_value(.5);
- test_value(-.5);
- test_value(1-1e-16);
- test_value(-(1-1e-16));
-
- return 0;
- }
- '''
- self.do_run(src, '''0.000000=0.000000*2^0
-100.100000=0.782031*2^7
--100.100000=-0.782031*2^7
-0.500000=0.500000*2^0
--0.500000=-0.500000*2^0
-1.000000=1.000000*2^0
--1.000000=-1.000000*2^0''')
+ self.do_run_from_file(src, output)
def test_rounding(self):
- src = '''
- #include <stdio.h>
- #include <math.h>
-
- int main()
- {
- printf("%.1f ", round(1.4));
- printf("%.1f ", round(1.6));
- printf("%.1f ", round(-1.4));
- printf("%.1f ", round(-1.6));
-
- printf("%.1f ", round(1.5));
- printf("%.1f ", round(2.5));
- printf("%.1f ", round(-1.5));
- printf("%.1f ", round(-2.5));
-
- printf("%ld ", lrint(1.4));
- printf("%ld ", lrint(1.6));
- printf("%ld ", lrint(-1.4));
- printf("%ld ", lrint(-1.6));
-
- printf("%ld ", lrint(1.5));
- printf("%ld ", lrint(2.5));
- printf("%ld ", lrint(-1.5));
- printf("%ld ", lrint(-2.5));
+ test_path = path_from_root('tests', 'core', 'test_rounding')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, "1.0 2.0 -1.0 -2.0 2.0 3.0 -2.0 -3.0 "
- "1 2 -1 -2 2 2 -2 -2")
+ self.do_run_from_file(src, output)
- # This example borrowed from MSDN documentation
def test_fcvt(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <stdlib.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_fcvt')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- int decimal, sign;
- char *buffer;
- double source = 3.1415926535;
-
- buffer = fcvt(source, 7, &decimal, &sign);
- printf("source: %2.10f buffer: '%s' decimal: %d sign: %d\\n",
- source, buffer, decimal, sign);
- }
- '''
- self.do_run(src, "source: 3.1415926535 buffer: '31415927' decimal: 1 sign: 0");
+ self.do_run_from_file(src, output)
def test_llrint(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2')
- src = r'''
- #include <stdio.h>
- #include <math.h>
- int main() {
- printf("%lld\n%lld\n%lld\n%lld\n", llrint(0.1), llrint(0.6), llrint(1.25), llrint(1099511627776.667));
- return 0;
- }
- '''
- self.do_run(src, '0\n1\n1\n1099511627777\n')
+
+ test_path = path_from_root('tests', 'core', 'test_llrint')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_getgep(self):
- # Generated code includes getelementptr (getelementptr, 0, 1), i.e., GEP as the first param to GEP
- src = '''
- #include <stdio.h>
- struct {
- int y[10];
- int z[10];
- } commonblock;
+ # Generated code includes getelementptr (getelementptr, 0, 1), i.e., GEP as the first param to GEP
+ test_path = path_from_root('tests', 'core', 'test_getgep')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- for (int i = 0; i < 10; ++i) {
- commonblock.y[i] = 1;
- commonblock.z[i] = 2;
- }
- printf("*%d %d*\\n", commonblock.y[0], commonblock.z[0]);
- return 0;
- }
- '''
- self.do_run(src, '*1 2*')
+ self.do_run_from_file(src, output)
def test_multiply_defined_symbols(self):
a1 = "int f() { return 1; }"
@@ -1759,288 +905,80 @@ f6: nan
self.do_ll_run(all_name, 'result: 1')
def test_if(self):
- src = '''
- #include <stdio.h>
- int main()
- {
- int x = 5;
- if (x > 3) {
- printf("*yes*\\n");
- }
- return 0;
- }
- '''
- self.do_run(src, '*yes*')
+ test_path = path_from_root('tests', 'core', 'test_if')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_if_else(self):
- src = '''
- #include <stdio.h>
- int main()
- {
- int x = 5;
- if (x > 10) {
- printf("*yes*\\n");
- } else {
- printf("*no*\\n");
- }
- return 0;
- }
- '''
- self.do_run(src, '*no*')
+ test_path = path_from_root('tests', 'core', 'test_if_else')
+ src, output = (test_path + s for s in ('.in', '.out'))
- def test_loop(self):
- src = '''
- #include <stdio.h>
- int main()
- {
- int x = 5;
- for (int i = 0; i < 6; i++) {
- x += x*i;
- if (x > 1000) {
- if (x % 7 == 0) printf("cheez\\n");
- x /= 2;
- break;
- }
- }
- printf("*%d*\\n", x);
- return 0;
- }
- '''
+ self.do_run_from_file(src, output)
- self.do_run(src, '*1800*')
+ def test_loop(self):
+ test_path = path_from_root('tests', 'core', 'test_loop')
+ src, output = (test_path + s for s in ('.in', '.out'))
- generated = open('src.cpp.o.js', 'r').read()
+ self.do_run_from_file(src, output)
def test_stack(self):
- Settings.INLINING_LIMIT = 50
-
- src = '''
- #include <stdio.h>
- int test(int i) {
- int x = 10;
- if (i > 0) {
- return test(i-1);
- }
- return int(&x); // both for the number, and forces x to not be nativized
- }
- int main(int argc, char **argv)
- {
- // We should get the same value for the first and last - stack has unwound
- int x1 = test(argc - 2);
- int x2 = test(100);
- int x3 = test((argc - 2) / 4);
- printf("*%d,%d*\\n", x3-x1, x2 != x1);
- return 0;
- }
- '''
- self.do_run(src, '*0,1*')
-
- def test_strings(self):
- src = '''
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
+ Settings.INLINING_LIMIT = 50
- int main(int argc, char **argv)
- {
- int x = 5, y = 9, magic = 7; // fool compiler with magic
- memmove(&x, &y, magic-7); // 0 should not crash us
-
- int xx, yy, zz;
- char s[32];
- int cc = sscanf("abc_10.b1_xyz9_543_defg", "abc_%d.%2x_xyz9_%3d_%3s", &xx, &yy, &zz, s);
- printf("%d:%d,%d,%d,%s\\n", cc, xx, yy, zz, s);
-
- printf("%d\\n", argc);
- puts(argv[1]);
- puts(argv[2]);
- printf("%d\\n", atoi(argv[3])+2);
- const char *foolingthecompiler = "\\rabcd";
- printf("%d\\n", strlen(foolingthecompiler)); // Tests parsing /0D in llvm - should not be a 0 (end string) then a D!
- printf("%s\\n", NULL); // Should print '(null)', not the string at address 0, which is a real address for us!
- printf("/* a comment */\\n"); // Should not break the generated code!
- printf("// another\\n"); // Should not break the generated code!
-
- char* strdup_val = strdup("test");
- printf("%s\\n", strdup_val);
- free(strdup_val);
+ test_path = path_from_root('tests', 'core', 'test_stack')
+ src, output = (test_path + s for s in ('.in', '.out'))
- {
- char *one = "one 1 ONE !";
- char *two = "two 2 TWO ?";
- char three[1024];
- memset(three, '.', 1024);
- three[50] = 0;
- strncpy(three + argc, one + (argc/2), argc+1);
- strncpy(three + argc*3, two + (argc/3), argc+2);
- printf("waka %s\\n", three);
- }
+ self.do_run_from_file(src, output)
- {
- char *one = "string number one top notch";
- char *two = "fa la sa ho fi FI FO FUM WHEN WHERE WHY HOW WHO";
- char three[1000];
- strcpy(three, &one[argc*2]);
- char *four = strcat(three, &two[argc*3]);
- printf("cat |%s|\\n", three);
- printf("returned |%s|\\n", four);
- }
+ def test_strings(self):
+ test_path = path_from_root('tests', 'core', 'test_strings')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
for named in (0, 1):
print named
+
Settings.NAMED_GLOBALS = named
- self.do_run(src, '''4:10,177,543,def\n4\nwowie\ntoo\n76\n5\n(null)\n/* a comment */\n// another\ntest\nwaka ....e 1 O...wo 2 T................................
-cat |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|
-returned |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|''', ['wowie', 'too', '74'])
+ self.do_run_from_file(src, output, ['wowie', 'too', '74'])
+
if self.emcc_args == []:
gen = open(self.in_dir('src.cpp.o.js')).read()
assert ('var __str1;' in gen) == named
def test_strcmp_uni(self):
- src = '''
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- #define TEST(func) \
- { \
- char *word = "WORD"; \
- char wordEntry[2] = { -61,-126 }; /* "Â"; */ \
- int cmp = func(word, wordEntry, 2); \
- printf("Compare value " #func " is %d\\n", cmp); \
- }
- TEST(strncmp);
- TEST(strncasecmp);
- TEST(memcmp);
- }
- '''
- self.do_run(src, 'Compare value strncmp is -1\nCompare value strncasecmp is -1\nCompare value memcmp is -1\n')
-
- def test_strndup(self):
- src = '''
- //---------------
- //- http://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html
- //---------------
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- int main(int argc, char **argv) {
- const char* source = "strndup - duplicate a specific number of bytes from a string";
-
- char* strdup_val = strndup(source, 0);
- printf("1:%s\\n", strdup_val);
- free(strdup_val);
-
- strdup_val = strndup(source, 7);
- printf("2:%s\\n", strdup_val);
- free(strdup_val);
+ test_path = path_from_root('tests', 'core', 'test_strcmp_uni')
+ src, output = (test_path + s for s in ('.in', '.out'))
- strdup_val = strndup(source, 1000);
- printf("3:%s\\n", strdup_val);
- free(strdup_val);
+ self.do_run_from_file(src, output)
- strdup_val = strndup(source, 60);
- printf("4:%s\\n", strdup_val);
- free(strdup_val);
-
- strdup_val = strndup(source, 19);
- printf("5:%s\\n", strdup_val);
- free(strdup_val);
-
- strdup_val = strndup(source, -1);
- printf("6:%s\\n", strdup_val);
- free(strdup_val);
+ def test_strndup(self):
+ test_path = path_from_root('tests', 'core', 'test_strndup')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '1:\n2:strndup\n3:strndup - duplicate a specific number of bytes from a string\n4:strndup - duplicate a specific number of bytes from a string\n5:strndup - duplicate\n6:\n')
+ self.do_run_from_file(src, output)
def test_errar(self):
- src = r'''
- #include <stdio.h>
- #include <errno.h>
- #include <string.h>
-
- int main() {
- char* err;
- char buffer[200];
-
- err = strerror(EDOM);
- strerror_r(EWOULDBLOCK, buffer, 200);
- printf("<%s>\n", err);
- printf("<%s>\n", buffer);
+ test_path = path_from_root('tests', 'core', 'test_errar')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("<%d>\n", strerror_r(EWOULDBLOCK, buffer, 0));
- errno = 123;
- printf("<%d>\n", errno);
-
- return 0;
- }
- '''
- expected = '''
- <Math arg out of domain of func>
- <No more processes>
- <34>
- <123>
- '''
- self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
+ self.do_run_from_file(src, output)
def test_mainenv(self):
- src = '''
- #include <stdio.h>
- int main(int argc, char **argv, char **envp)
- {
- printf("*%p*\\n", envp);
- return 0;
- }
- '''
- self.do_run(src, '*(nil)*')
+ test_path = path_from_root('tests', 'core', 'test_mainenv')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_funcs(self):
- src = '''
- #include <stdio.h>
- int funcy(int x)
- {
- return x*9;
- }
- int main()
- {
- printf("*%d,%d*\\n", funcy(8), funcy(10));
- return 0;
- }
- '''
- self.do_run(src, '*72,90*')
+ test_path = path_from_root('tests', 'core', 'test_funcs')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_structs(self):
- src = '''
- #include <stdio.h>
- struct S
- {
- int x, y;
- };
- int main()
- {
- S a, b;
- a.x = 5; a.y = 6;
- b.x = 101; b.y = 7009;
- S *c, *d;
- c = &a;
- c->x *= 2;
- c = &b;
- c->y -= 1;
- d = c;
- d->y += 10;
- printf("*%d,%d,%d,%d,%d,%d,%d,%d*\\n", a.x, a.y, b.x, b.y, c->x, c->y, d->x, d->y);
- return 0;
- }
- '''
- self.do_run(src, '*10,6,101,7018,101,7018,101,7018*')
+ test_path = path_from_root('tests', 'core', 'test_structs')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
gen_struct_src = '''
#include <stdio.h>
@@ -2069,82 +1007,22 @@ returned |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|''', ['wowie',
self.do_run(self.gen_struct_src.replace('{{gen_struct}}', 'new S').replace('{{del_struct}}', 'delete'), '*51,62*')
def test_addr_of_stacked(self):
- src = '''
- #include <stdio.h>
- void alter(int *y)
- {
- *y += 5;
- }
- int main()
- {
- int x = 2;
- alter(&x);
- printf("*%d*\\n", x);
- return 0;
- }
- '''
- self.do_run(src, '*7*')
+ test_path = path_from_root('tests', 'core', 'test_addr_of_stacked')
+ src, output = (test_path + s for s in ('.in', '.out'))
- def test_globals(self):
- src = '''
- #include <stdio.h>
+ self.do_run_from_file(src, output)
- char cache[256], *next = cache;
+ def test_globals(self):
+ test_path = path_from_root('tests', 'core', 'test_globals')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- cache[10] = 25;
- next[20] = 51;
- printf("*%d,%d*\\n", next[10], cache[20]);
- return 0;
- }
- '''
- self.do_run(src, '*25,51*')
+ self.do_run_from_file(src, output)
def test_linked_list(self):
- src = '''
- #include <stdio.h>
- struct worker_args {
- int value;
- struct worker_args *next;
- };
- int main()
- {
- worker_args a;
- worker_args b;
- a.value = 60;
- a.next = &b;
- b.value = 900;
- b.next = NULL;
- worker_args* c = &a;
- int total = 0;
- while (c) {
- total += c->value;
- c = c->next;
- }
+ test_path = path_from_root('tests', 'core', 'test_linked_list')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // Chunk of em
- worker_args chunk[10];
- for (int i = 0; i < 9; i++) {
- chunk[i].value = i*10;
- chunk[i].next = &chunk[i+1];
- }
- chunk[9].value = 90;
- chunk[9].next = &chunk[0];
-
- c = chunk;
- do {
- total += c->value;
- c = c->next;
- } while (c != chunk);
-
- printf("*%d,%d*\\n", total, b.next);
- // NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
-
- return 0;
- }
- '''
- self.do_run(src, '*1410,0*')
+ self.do_run_from_file(src, output)
def test_sup(self):
src = '''
@@ -2197,418 +1075,97 @@ returned |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|''', ['wowie',
self.do_run(src, 'sizeofs:6,8\n*C___: 0,6,12,20<24*\n*Carr: 0,6,12,20<24*\n*C__w: 0,6,12,20<24*\n*Cp1_: 4,6,12,20<24*\n*Cp2_: 0,6,12,20<24*\n*Cint: 0,8,12,20<24*\n*C4__: 0,8,12,20<24*\n*C4_2: 0,6,10,16<20*\n*C__z: 0,8,16,24<28*')
def test_assert(self):
- src = '''
- #include <stdio.h>
- #include <assert.h>
- int main() {
- assert(1 == true); // pass
- assert(1 == false); // fail
- return 0;
- }
- '''
- self.do_run(src, 'Assertion failed: 1 == false')
+ test_path = path_from_root('tests', 'core', 'test_assert')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_libcextra(self):
if self.emcc_args is None: return self.skip('needs emcc for libcextra')
- src = r'''
- #include <stdio.h>
- #include <wchar.h>
-
- int main()
- {
- const wchar_t* wstr = L"Hello";
- printf("wcslen: %d\n", wcslen(wstr));
+ test_path = path_from_root('tests', 'core', 'test_libcextra')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, 'wcslen: 5')
+ self.do_run_from_file(src, output)
def test_regex(self):
- # This is from http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frtref%2Fregexec.htm
if self.emcc_args is None: return self.skip('needs emcc for libcextra')
- src = r'''
- #include <regex.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- int main(void)
- {
- regex_t preg;
- const char *string = "a very simple simple simple string";
- const char *pattern = "\\(sim[a-z]le\\) \\1";
- int rc;
- size_t nmatch = 2;
- regmatch_t pmatch[2];
-
- if (0 != (rc = regcomp(&preg, pattern, 0))) {
- printf("regcomp() failed, returning nonzero (%d)\n", rc);
- exit(EXIT_FAILURE);
- }
-
- if (0 != (rc = regexec(&preg, string, nmatch, pmatch, 0))) {
- printf("Failed to match '%s' with '%s',returning %d.\n",
- string, pattern, rc);
- }
- else {
- printf("With the whole expression, "
- "a matched substring \"%.*s\" is found at position %d to %d.\n",
- pmatch[0].rm_eo - pmatch[0].rm_so, &string[pmatch[0].rm_so],
- pmatch[0].rm_so, pmatch[0].rm_eo - 1);
- printf("With the sub-expression, "
- "a matched substring \"%.*s\" is found at position %d to %d.\n",
- pmatch[1].rm_eo - pmatch[1].rm_so, &string[pmatch[1].rm_so],
- pmatch[1].rm_so, pmatch[1].rm_eo - 1);
- }
- regfree(&preg);
- return 0;
- }
- '''
- self.do_run(src, 'With the whole expression, a matched substring "simple simple" is found at position 7 to 19.\n'
- 'With the sub-expression, a matched substring "simple" is found at position 7 to 12.')
-
- def test_longjmp(self):
- src = r'''
- #include <stdio.h>
- #include <setjmp.h>
- static jmp_buf buf;
+ test_path = path_from_root('tests', 'core', 'test_regex')
+ src, output = (test_path + s for s in ('.in', '.out'))
- void second(void) {
- printf("second\n");
- longjmp(buf,-1);
- }
+ self.do_run_from_file(src, output)
- void first(void) {
- printf("first\n"); // prints
- longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1
- }
+ def test_longjmp(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- int main() {
- volatile int x = 0;
- int jmpval = setjmp(buf);
- if (!jmpval) {
- x++; // should be properly restored once longjmp jumps back
- first(); // when executed, setjmp returns 1
- printf("skipped\n"); // does not print
- } else if (jmpval == 1) { // when first() jumps back, setjmp returns 1
- printf("result: %d %d\n", x, jmpval); // prints
- x++;
- second(); // when executed, setjmp returns -1
- } else if (jmpval == -1) { // when second() jumps back, setjmp returns -1
- printf("result: %d %d\n", x, jmpval); // prints
- }
+ test_path = path_from_root('tests', 'core', 'test_longjmp')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, 'first\nresult: 1 1\nsecond\nresult: 2 -1')
+ self.do_run_from_file(src, output)
def test_longjmp2(self):
- src = r'''
- #include <setjmp.h>
- #include <stdio.h>
-
- typedef struct {
- jmp_buf* jmp;
- } jmp_state;
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- void stack_manipulate_func(jmp_state* s, int level) {
- jmp_buf buf;
-
- printf("Entering stack_manipulate_func, level: %d\n", level);
-
- if (level == 0) {
- s->jmp = &buf;
- if (setjmp(*(s->jmp)) == 0) {
- printf("Setjmp normal execution path, level: %d\n", level);
- stack_manipulate_func(s, level + 1);
- } else {
- printf("Setjmp error execution path, level: %d\n", level);
- }
- } else {
- printf("Perform longjmp at level %d\n", level);
- longjmp(*(s->jmp), 1);
- }
+ test_path = path_from_root('tests', 'core', 'test_longjmp2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("Exiting stack_manipulate_func, level: %d\n", level);
- }
-
- int main(int argc, char *argv[]) {
- jmp_state s;
- s.jmp = NULL;
- stack_manipulate_func(&s, 0);
-
- return 0;
- }
- '''
- self.do_run(src, '''Entering stack_manipulate_func, level: 0
-Setjmp normal execution path, level: 0
-Entering stack_manipulate_func, level: 1
-Perform longjmp at level 1
-Setjmp error execution path, level: 0
-Exiting stack_manipulate_func, level: 0
-''')
+ self.do_run_from_file(src, output)
def test_longjmp3(self):
- src = r'''
- #include <setjmp.h>
- #include <stdio.h>
-
- typedef struct {
- jmp_buf* jmp;
- } jmp_state;
-
- void setjmp_func(jmp_state* s, int level) {
- jmp_buf* prev_jmp = s->jmp;
- jmp_buf c_jmp;
-
- if (level == 2) {
- printf("level is 2, perform longjmp!\n");
- longjmp(*(s->jmp), 1);
- }
-
- if (setjmp(c_jmp) == 0) {
- printf("setjmp normal execution path, level: %d\n", level);
- s->jmp = &c_jmp;
- setjmp_func(s, level + 1);
- } else {
- printf("setjmp exception execution path, level: %d\n", level);
- if (prev_jmp) {
- printf("prev_jmp is not empty, continue with longjmp!\n");
- s->jmp = prev_jmp;
- longjmp(*(s->jmp), 1);
- }
- }
-
- printf("Exiting setjmp function, level: %d\n", level);
- }
-
- int main(int argc, char *argv[]) {
- jmp_state s;
- s.jmp = NULL;
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- setjmp_func(&s, 0);
+ test_path = path_from_root('tests', 'core', 'test_longjmp3')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '''setjmp normal execution path, level: 0
-setjmp normal execution path, level: 1
-level is 2, perform longjmp!
-setjmp exception execution path, level: 1
-prev_jmp is not empty, continue with longjmp!
-setjmp exception execution path, level: 0
-Exiting setjmp function, level: 0
-''')
+ self.do_run_from_file(src, output)
def test_longjmp4(self):
- src = r'''
- #include <setjmp.h>
- #include <stdio.h>
-
- typedef struct {
- jmp_buf* jmp;
- } jmp_state;
-
- void second_func(jmp_state* s);
-
- void first_func(jmp_state* s) {
- jmp_buf* prev_jmp = s->jmp;
- jmp_buf c_jmp;
- volatile int once = 0;
-
- if (setjmp(c_jmp) == 0) {
- printf("Normal execution path of first function!\n");
-
- s->jmp = &c_jmp;
- second_func(s);
- } else {
- printf("Exception execution path of first function! %d\n", once);
-
- if (!once) {
- printf("Calling longjmp the second time!\n");
- once = 1;
- longjmp(*(s->jmp), 1);
- }
- }
- }
-
- void second_func(jmp_state* s) {
- longjmp(*(s->jmp), 1);
- }
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- int main(int argc, char *argv[]) {
- jmp_state s;
- s.jmp = NULL;
+ test_path = path_from_root('tests', 'core', 'test_longjmp4')
+ src, output = (test_path + s for s in ('.in', '.out'))
- first_func(&s);
-
- return 0;
- }
- '''
- self.do_run(src, '''Normal execution path of first function!
-Exception execution path of first function! 0
-Calling longjmp the second time!
-Exception execution path of first function! 1
-''')
+ self.do_run_from_file(src, output)
def test_longjmp_funcptr(self):
- src = r'''
- #include <stdio.h>
- #include <setjmp.h>
-
- static jmp_buf buf;
-
- void (*fp)() = NULL;
-
- void second(void) {
- printf("second\n"); // prints
- longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1
- }
-
- void first(void) {
- fp();
- printf("first\n"); // does not print
- }
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- int main(int argc, char **argv) {
- fp = argc == 200 ? NULL : second;
-
- volatile int x = 0;
- if ( ! setjmp(buf) ) {
- x++;
- first(); // when executed, setjmp returns 0
- } else { // when longjmp jumps back, setjmp returns 1
- printf("main: %d\n", x); // prints
- }
+ test_path = path_from_root('tests', 'core', 'test_longjmp_funcptr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, 'second\nmain: 1\n')
+ self.do_run_from_file(src, output)
def test_longjmp_repeat(self):
- Settings.MAX_SETJMPS = 1
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- src = r'''
- #include <stdio.h>
- #include <setjmp.h>
+ Settings.MAX_SETJMPS = 1
- static jmp_buf buf;
+ test_path = path_from_root('tests', 'core', 'test_longjmp_repeat')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- volatile int x = 0;
- printf("setjmp:%d\n", setjmp(buf));
- x++;
- printf("x:%d\n", x);
- if (x < 4) longjmp(buf, x*2);
- return 0;
- }
- '''
- self.do_run(src, '''setjmp:0
-x:1
-setjmp:2
-x:2
-setjmp:4
-x:3
-setjmp:6
-x:4
-''')
+ self.do_run_from_file(src, output)
def test_longjmp_stacked(self):
- src = r'''
- #include <stdio.h>
- #include <setjmp.h>
- #include <stdlib.h>
- #include <string.h>
-
- int bottom, top;
-
- int run(int y) {
- // confuse stack
- char *s = (char*)alloca(100);
- memset(s, 1, 100);
- s[y] = y;
- s[y/2] = y*2;
- volatile int x = s[y];
- top = (int)alloca(4);
- if (x <= 2) return x;
- jmp_buf buf;
- printf("setjmp of %d\n", x);
- if (setjmp(buf) == 0) {
- printf("going\n");
- x += run(x/2);
- longjmp(buf, 1);
- }
- printf("back\n");
- return x/2;
- }
-
- int main(int argc, char **argv) {
- int sum = 0;
- for (int i = 0; i < argc*2; i++) {
- bottom = (int)alloca(4);
- sum += run(10);
- // scorch the earth
- if (bottom < top) {
- memset((void*)bottom, 1, top - bottom);
- } else {
- memset((void*)top, 1, bottom - top);
- }
- }
- printf("%d\n", sum);
- return sum;
- }
- '''
- self.do_run(src, '''setjmp of 10
-going
-setjmp of 5
-going
-back
-back
-setjmp of 10
-going
-setjmp of 5
-going
-back
-back
-12
-''')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- def test_longjmp_exc(self):
- src = r'''
- #include <stdlib.h>
- #include <stdio.h>
- #include <setjmp.h>
- #include <emscripten.h>
+ test_path = path_from_root('tests', 'core', 'test_longjmp_stacked')
+ src, output = (test_path + s for s in ('.in', '.out'))
- jmp_buf abortframe;
+ self.do_run_from_file(src, output)
- void dostuff(int a) {
- printf("pre\n");
- if (a != 42) emscripten_run_script("waka_waka()"); // this should fail, and never reach "never"
- printf("never\n");
- if (a == 100) {
- longjmp (abortframe, -1);
- }
+ def test_longjmp_exc(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- if (setjmp(abortframe)) {
- printf("got 100");
- }
- }
+ test_path = path_from_root('tests', 'core', 'test_longjmp_exc')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char **argv) {
- dostuff(argc);
- exit(1);
- return 1;
- }
- '''
- self.do_run(src, 'waka_waka');
+ self.do_run_from_file(src, output)
def test_setjmp_many(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
src = r'''
#include <stdio.h>
#include <setjmp.h>
@@ -2627,6 +1184,7 @@ back
def test_exceptions(self):
if Settings.QUANTUM_SIZE == 1: return self.skip("we don't support libcxx in q1")
if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.EXCEPTION_DEBUG = 1
@@ -2715,69 +1273,32 @@ back
def test_exception_2(self):
if self.emcc_args is None: return self.skip('need emcc to add in libcxx properly')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.DISABLE_EXCEPTION_CATCHING = 0
- src = r'''
- #include <stdexcept>
- #include <stdio.h>
-
- typedef void (*FuncPtr)();
-
- void ThrowException()
- {
- throw std::runtime_error("catch me!");
- }
- FuncPtr ptr = ThrowException;
+ test_path = path_from_root('tests', 'core', 'test_exception_2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- try
- {
- ptr();
- }
- catch(...)
- {
- printf("Exception caught successfully!\n");
- }
- return 0;
- }
- '''
- self.do_run(src, 'Exception caught successfully!')
+ self.do_run_from_file(src, output)
def test_white_list_exception(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
Settings.DISABLE_EXCEPTION_CATCHING = 2
Settings.EXCEPTION_CATCHING_WHITELIST = ["__Z12somefunctionv"]
Settings.INLINING_LIMIT = 50 # otherwise it is inlined and not identified
- src = '''
- #include <stdio.h>
-
- void thrower() {
- printf("infunc...");
- throw(99);
- printf("FAIL");
- }
-
- void somefunction() {
- try {
- thrower();
- } catch(...) {
- printf("done!*\\n");
- }
- }
+ test_path = path_from_root('tests', 'core', 'test_white_list_exception')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- somefunction();
- return 0;
- }
- '''
- self.do_run(src, 'infunc...done!*')
+ self.do_run_from_file(src, output)
Settings.DISABLE_EXCEPTION_CATCHING = 0
Settings.EXCEPTION_CATCHING_WHITELIST = []
def test_uncaught_exception(self):
if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.DISABLE_EXCEPTION_CATCHING = 0
@@ -2816,6 +1337,8 @@ back
self.do_run(src, 'success')
def test_typed_exceptions(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
Settings.DISABLE_EXCEPTION_CATCHING = 0
Settings.SAFE_HEAP = 0 # Throwing null will cause an ignorable null pointer access.
src = open(path_from_root('tests', 'exceptions', 'typed.cpp'), 'r').read()
@@ -2823,90 +1346,29 @@ back
self.do_run(src, expected)
def test_multiexception(self):
- Settings.DISABLE_EXCEPTION_CATCHING = 0
- src = r'''
-#include <stdio.h>
-
-static int current_exception_id = 0;
-
-typedef struct {
-int jmp;
-} jmp_state;
-
-void setjmp_func(jmp_state* s, int level) {
-int prev_jmp = s->jmp;
-int c_jmp;
-
-if (level == 2) {
- printf("level is 2, perform longjmp!\n");
- throw 1;
-}
-
-c_jmp = current_exception_id++;
-try {
- printf("setjmp normal execution path, level: %d, prev_jmp: %d\n", level, prev_jmp);
- s->jmp = c_jmp;
- setjmp_func(s, level + 1);
-} catch (int catched_eid) {
- printf("caught %d\n", catched_eid);
- if (catched_eid == c_jmp) {
- printf("setjmp exception execution path, level: %d, prev_jmp: %d\n", level, prev_jmp);
- if (prev_jmp != -1) {
- printf("prev_jmp is not empty, continue with longjmp!\n");
- s->jmp = prev_jmp;
- throw s->jmp;
- }
- } else {
- throw;
- }
-}
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
-printf("Exiting setjmp function, level: %d, prev_jmp: %d\n", level, prev_jmp);
-}
-
-int main(int argc, char *argv[]) {
-jmp_state s;
-s.jmp = -1;
+ Settings.DISABLE_EXCEPTION_CATCHING = 0
-setjmp_func(&s, 0);
+ test_path = path_from_root('tests', 'core', 'test_multiexception')
+ src, output = (test_path + s for s in ('.in', '.out'))
-return 0;
-}
-'''
- self.do_run(src, '''setjmp normal execution path, level: 0, prev_jmp: -1
-setjmp normal execution path, level: 1, prev_jmp: 0
-level is 2, perform longjmp!
-caught 1
-setjmp exception execution path, level: 1, prev_jmp: 0
-prev_jmp is not empty, continue with longjmp!
-caught 0
-setjmp exception execution path, level: 0, prev_jmp: -1
-Exiting setjmp function, level: 0, prev_jmp: -1
-''')
+ self.do_run_from_file(src, output)
def test_std_exception(self):
if self.emcc_args is None: return self.skip('requires emcc')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.DISABLE_EXCEPTION_CATCHING = 0
self.emcc_args += ['-s', 'SAFE_HEAP=0']
- src = r'''
- #include <stdio.h>
- #include <exception>
+ test_path = path_from_root('tests', 'core', 'test_std_exception')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- std::exception e;
- try {
- throw e;
- } catch(std::exception e) {
- printf("caught std::exception\n");
- }
- return 0;
- }
- '''
- self.do_run(src, 'caught std::exception')
+ self.do_run_from_file(src, output)
def test_async_exit(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
open('main.c', 'w').write(r'''
#include <stdio.h>
#include <stdlib.h>
@@ -2974,128 +1436,40 @@ Exiting setjmp function, level: 0, prev_jmp: -1
self.do_run(src, '''reported\nExit Status: 1\npostRun\nok.\n''')
def test_class(self):
- src = '''
- #include <stdio.h>
- struct Random {
- enum { IM = 139968, IA = 3877, IC = 29573 };
- Random() : last(42) {}
- float get( float max = 1.0f ) {
- last = ( last * IA + IC ) % IM;
- return max * last / IM;
- }
- protected:
- unsigned int last;
- } rng1;
- int main()
- {
- Random rng2;
- int count = 0;
- for (int i = 0; i < 100; i++) {
- float x1 = rng1.get();
- float x2 = rng2.get();
- printf("%f, %f\\n", x1, x2);
- if (x1 != x2) count += 1;
- }
- printf("*%d*\\n", count);
- return 0;
- }
- '''
- self.do_run(src, '*0*')
+ test_path = path_from_root('tests', 'core', 'test_class')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_inherit(self):
- src = '''
- #include <stdio.h>
- struct Parent {
- int x1, x2;
- };
- struct Child : Parent {
- int y;
- };
- int main()
- {
- Parent a;
- a.x1 = 50;
- a.x2 = 87;
- Child b;
- b.x1 = 78;
- b.x2 = 550;
- b.y = 101;
- Child* c = (Child*)&a;
- c->x1 ++;
- c = &b;
- c->y --;
- printf("*%d,%d,%d,%d,%d,%d,%d*\\n", a.x1, a.x2, b.x1, b.x2, b.y, c->x1, c->x2);
- return 0;
- }
- '''
- self.do_run(src, '*51,87,78,550,100,78,550*')
+ test_path = path_from_root('tests', 'core', 'test_inherit')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_isdigit_l(self):
if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc')
- src = '''
- #include <iostream>
- int main() {
- using namespace std;
- use_facet<num_put<char> >(cout.getloc()).put(cout, cout, '0', 3.14159265);
- }
- '''
- self.do_run(src, '3.14159')
+ test_path = path_from_root('tests', 'core', 'test_isdigit_l')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_iswdigit(self):
if self.emcc_args is None: return self.skip('no libcxx inclusion without emcc')
- src = '''
- #include <stdio.h>
- #include <cctype>
- #include <cwctype>
+ test_path = path_from_root('tests', 'core', 'test_iswdigit')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- using namespace std;
- printf("%d ", isdigit('0'));
- printf("%d ", iswdigit(L'0'));
- return 0;
- }
- '''
- self.do_run(src, '1 1')
+ self.do_run_from_file(src, output)
def test_polymorph(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <stdio.h>
- struct Pure {
- virtual int implme() = 0;
- };
- struct Parent : Pure {
- virtual int getit() { return 11; };
- int implme() { return 32; }
- };
- struct Child : Parent {
- int getit() { return 74; }
- int implme() { return 1012; }
- };
- struct Other {
- int one() { return 11; }
- int two() { return 22; }
- };
+ test_path = path_from_root('tests', 'core', 'test_polymorph')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- Parent *x = new Parent();
- Parent *y = new Child();
- printf("*%d,%d,%d,%d*\\n", x->getit(), y->getit(), x->implme(), y->implme());
-
- Other *o = new Other;
- int (Other::*Ls)() = &Other::one;
- printf("*%d*\\n", (o->*(Ls))());
- Ls = &Other::two;
- printf("*%d*\\n", (o->*(Ls))());
-
- return 0;
- }
- '''
- self.do_run(src, '*11,74,32,1012*\n*11*\n*22*')
+ self.do_run_from_file(src, output)
def test_segfault(self):
if self.emcc_args is None: return self.skip('SAFE_HEAP without ta2 means we check types too, which hide segfaults')
@@ -3165,211 +1539,64 @@ Exiting setjmp function, level: 0, prev_jmp: -1
def test_dynamic_cast(self):
if self.emcc_args is None: return self.skip('need libcxxabi')
- src = r'''
- #include <stdio.h>
-
- struct Support {
- virtual void f() {
- printf("f()\n");
- }
- };
+ test_path = path_from_root('tests', 'core', 'test_dynamic_cast')
+ src, output = (test_path + s for s in ('.in', '.out'))
- struct Derived : Support {
- };
-
- int main() {
- Support * p = new Derived;
- dynamic_cast<Derived*>(p)->f();
- }
- '''
- self.do_run(src, 'f()\n')
+ self.do_run_from_file(src, output)
def test_dynamic_cast_b(self):
if self.emcc_args is None: return self.skip('need libcxxabi')
- src = '''
- #include <stdio.h>
-
- class CBase { virtual void dummy() {} };
- class CDerived : public CBase { int a; };
- class CDerivedest : public CDerived { float b; };
+ test_path = path_from_root('tests', 'core', 'test_dynamic_cast_b')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main ()
- {
- CBase *pa = new CBase;
- CBase *pb = new CDerived;
- CBase *pc = new CDerivedest;
-
- printf("a1: %d\\n", dynamic_cast<CDerivedest*>(pa) != NULL);
- printf("a2: %d\\n", dynamic_cast<CDerived*>(pa) != NULL);
- printf("a3: %d\\n", dynamic_cast<CBase*>(pa) != NULL);
-
- printf("b1: %d\\n", dynamic_cast<CDerivedest*>(pb) != NULL);
- printf("b2: %d\\n", dynamic_cast<CDerived*>(pb) != NULL);
- printf("b3: %d\\n", dynamic_cast<CBase*>(pb) != NULL);
-
- printf("c1: %d\\n", dynamic_cast<CDerivedest*>(pc) != NULL);
- printf("c2: %d\\n", dynamic_cast<CDerived*>(pc) != NULL);
- printf("c3: %d\\n", dynamic_cast<CBase*>(pc) != NULL);
-
- return 0;
- }
- '''
- self.do_run(src, 'a1: 0\na2: 0\na3: 1\nb1: 0\nb2: 1\nb3: 1\nc1: 1\nc2: 1\nc3: 1\n')
+ self.do_run_from_file(src, output)
def test_dynamic_cast_2(self):
if self.emcc_args is None: return self.skip('need libcxxabi')
- src = r'''
- #include <stdio.h>
- #include <typeinfo>
+ test_path = path_from_root('tests', 'core', 'test_dynamic_cast_2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- class Class {};
-
- int main() {
- const Class* dp = dynamic_cast<const Class*>(&typeid(Class));
- // should return dp == NULL,
- printf("pointer: %p\n", dp);
- }
- '''
- self.do_run(src, "pointer: (nil)")
+ self.do_run_from_file(src, output)
def test_funcptr(self):
- src = '''
- #include <stdio.h>
- int calc1() { return 26; }
- int calc2() { return 90; }
- typedef int (*fp_t)();
-
- fp_t globally1 = calc1;
- fp_t globally2 = calc2;
+ test_path = path_from_root('tests', 'core', 'test_funcptr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int nothing(const char *str) { return 0; }
-
- int main()
- {
- fp_t fp = calc1;
- void *vp = (void*)fp;
- fp_t fpb = (fp_t)vp;
- fp_t fp2 = calc2;
- void *vp2 = (void*)fp2;
- fp_t fpb2 = (fp_t)vp2;
- printf("*%d,%d,%d,%d,%d,%d*\\n", fp(), fpb(), fp2(), fpb2(), globally1(), globally2());
-
- fp_t t = calc1;
- printf("*%d,%d", t == calc1, t == calc2);
- t = calc2;
- printf(",%d,%d*\\n", t == calc1, t == calc2);
-
- int (*other)(const char *str);
- other = nothing;
- other("*hello!*");
- other = puts;
- other("*goodbye!*");
-
- return 0;
- }
- '''
- self.do_run(src, '*26,26,90,90,26,90*\n*1,0,0,1*\n*goodbye!*')
+ self.do_run_from_file(src, output)
def test_mathfuncptr(self):
- src = '''
- #include <math.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_mathfuncptr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int
- main(int argc, char **argv) {
- float (*fn)(float) = argc != 12 ? &sqrtf : &fabsf;
- float (*fn2)(float) = argc != 13 ? &fabsf : &sqrtf;
- float (*fn3)(float) = argc != 14 ? &erff : &fabsf;
- printf("fn2(-5) = %d, fn(10) = %.2f, erf(10) = %.2f\\n", (int)fn2(-5), fn(10), fn3(10));
- return 0;
- }
- '''
- self.do_run(src, 'fn2(-5) = 5, fn(10) = 3.16, erf(10) = 1.00')
+ self.do_run_from_file(src, output)
def test_funcptrfunc(self):
- src = r'''
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_funcptrfunc')
+ src, output = (test_path + s for s in ('.in', '.out'))
- typedef void (*funcptr)(int, int);
- typedef funcptr (*funcptrfunc)(int);
-
- funcptr __attribute__ ((noinline)) getIt(int x) {
- return (funcptr)x;
- }
-
- int main(int argc, char **argv)
- {
- funcptrfunc fpf = argc < 100 ? getIt : NULL;
- printf("*%p*\n", fpf(argc));
- return 0;
- }
- '''
- self.do_run(src, '*0x1*')
+ self.do_run_from_file(src, output)
def test_funcptr_namecollide(self):
- src = r'''
- #include <stdio.h>
-
- void do_call(void (*puts)(const char *), const char *str);
-
- void do_print(const char *str) {
- if (!str) do_call(NULL, "delusion");
- if ((int)str == -1) do_print(str+10);
- puts("====");
- puts(str);
- puts("====");
- }
-
- void do_call(void (*puts)(const char *), const char *str) {
- if (!str) do_print("confusion");
- if ((int)str == -1) do_call(NULL, str-10);
- (*puts)(str);
- }
+ test_path = path_from_root('tests', 'core', 'test_funcptr_namecollide')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char **argv)
- {
- for (int i = 0; i < argc; i++) {
- do_call(i != 10 ? do_print : NULL, i != 15 ? "waka waka" : NULL);
- }
- return 0;
- }
- '''
- self.do_run(src, 'waka', force_c=True)
+ self.do_run_from_file(src, output, force_c=True)
def test_emptyclass(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <stdio.h>
- struct Randomized {
- Randomized(int x) {
- printf("*zzcheezzz*\\n");
- }
- };
+ test_path = path_from_root('tests', 'core', 'test_emptyclass')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main( int argc, const char *argv[] ) {
- new Randomized(55);
-
- return 0;
- }
- '''
- self.do_run(src, '*zzcheezzz*')
+ self.do_run_from_file(src, output)
def test_alloca(self):
- src = '''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_alloca')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- char *pc;
- pc = (char *)alloca(5);
- printf("z:%d*%d*\\n", pc > 0, (int)pc);
- return 0;
- }
- '''
- self.do_run(src, 'z:1*', force_c=True)
+ self.do_run_from_file(src, output, force_c=True)
def test_rename(self):
src = open(path_from_root('tests', 'stdio', 'test_rename.c'), 'r').read()
@@ -3378,80 +1605,29 @@ Exiting setjmp function, level: 0, prev_jmp: -1
def test_alloca_stack(self):
if self.emcc_args is None: return # too slow in other modes
- # We should not blow up the stack with numerous allocas
- src = '''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_alloca_stack')
+ src, output = (test_path + s for s in ('.in', '.out'))
- func(int i) {
- char *pc = (char *)alloca(100);
- *pc = i;
- (*pc)++;
- return (*pc) % 10;
- }
- int main() {
- int total = 0;
- for (int i = 0; i < 1024*1024; i++)
- total += func(i);
- printf("ok:%d*\\n", total);
- return 0;
- }
- '''
- self.do_run(src, 'ok:-32768*', force_c=True)
+ self.do_run_from_file(src, output, force_c=True)
def test_stack_byval(self):
if self.emcc_args is None: return # too slow in other modes
- # We should also not blow up the stack with byval arguments
- src = r'''
- #include<stdio.h>
- struct vec {
- int x, y, z;
- vec(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
- static vec add(vec a, vec b) {
- return vec(a.x+b.x, a.y+b.y, a.z+b.z);
- }
- };
- int main() {
- int total = 0;
- for (int i = 0; i < 1000; i++) {
- for (int j = 0; j < 1000; j++) {
- vec c(i+i%10, j*2, i%255);
- vec d(j*2, j%255, i%120);
- vec f = vec::add(c, d);
- total += (f.x + f.y + f.z) % 100;
- total %= 10240;
- }
- }
- printf("sum:%d*\n", total);
- return 0;
- }
- '''
- self.do_run(src, 'sum:9780*')
+ test_path = path_from_root('tests', 'core', 'test_stack_byval')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_stack_varargs(self):
if self.emcc_args is None: return # too slow in other modes
Settings.INLINING_LIMIT = 50
+ Settings.TOTAL_STACK = 1024
- # We should not blow up the stack with numerous varargs
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_stack_varargs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- void func(int i) {
- printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
- i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i, i);
- }
- int main() {
- for (int i = 0; i < 1024; i++)
- func(i);
- printf("ok!\n");
- return 0;
- }
- '''
- Settings.TOTAL_STACK = 1024
- self.do_run(src, 'ok!')
+ self.do_run_from_file(src, output)
def test_stack_varargs2(self):
if self.emcc_args is None: return # too slow in other modes
@@ -3532,23 +1708,10 @@ Exiting setjmp function, level: 0, prev_jmp: -1
def test_stack_void(self):
Settings.INLINING_LIMIT = 50
- src = r'''
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_stack_void')
+ src, output = (test_path + s for s in ('.in', '.out'))
- static char s[100]="aaaaa";
- static int func(void) {
- if(s[0]!='a') return 0;
- printf("iso open %s\n", s, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001, 1.001);
- return 0;
- }
- int main(){
- int i;
- for(i=0;i<5000;i++)
- func();
- printf(".ok.\n");
- }
- '''
- self.do_run(src, '.ok.\n')
+ self.do_run_from_file(src, output)
def test_life(self):
if self.emcc_args is None: return self.skip('need c99')
@@ -3591,145 +1754,42 @@ Exiting setjmp function, level: 0, prev_jmp: -1
''', ['2'], force_c=True)
def test_array2(self):
- src = '''
- #include <stdio.h>
-
- static const double grid[4][2] = {
- {-3/3.,-1/3.},{+1/3.,-3/3.},
- {-1/3.,+3/3.},{+3/3.,+1/3.}
- };
+ test_path = path_from_root('tests', 'core', 'test_array2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- for (int i = 0; i < 4; i++)
- printf("%d:%.2f,%.2f ", i, grid[i][0], grid[i][1]);
- printf("\\n");
- return 0;
- }
- '''
- self.do_run(src, '0:-1.00,-0.33 1:0.33,-1.00 2:-0.33,1.00 3:1.00,0.33')
+ self.do_run_from_file(src, output)
def test_array2b(self):
- src = '''
- #include <stdio.h>
-
- static const struct {
- unsigned char left;
- unsigned char right;
- } prioritah[] = {
- {6, 6}, {6, 6}, {7, 95}, {7, 7}
- };
-
- int main() {
- printf("*%d,%d\\n", prioritah[1].left, prioritah[1].right);
- printf("%d,%d*\\n", prioritah[2].left, prioritah[2].right);
- return 0;
- }
- '''
- self.do_run(src, '*6,6\n7,95*')
+ test_path = path_from_root('tests', 'core', 'test_array2b')
+ src, output = (test_path + s for s in ('.in', '.out'))
+ self.do_run_from_file(src, output)
def test_constglobalstructs(self):
- src = '''
- #include <stdio.h>
- struct IUB {
- int c;
- double p;
- unsigned int pi;
- };
+ test_path = path_from_root('tests', 'core', 'test_constglobalstructs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- IUB iub[] = {
- { 'a', 0.27, 5 },
- { 'c', 0.15, 4 },
- { 'g', 0.12, 3 },
- { 't', 0.27, 2 },
- };
-
- const unsigned char faceedgesidx[6][4] =
- {
- { 4, 5, 8, 10 },
- { 6, 7, 9, 11 },
- { 0, 2, 8, 9 },
- { 1, 3, 10,11 },
- { 0, 1, 4, 6 },
- { 2, 3, 5, 7 },
- };
-
- int main( int argc, const char *argv[] ) {
- printf("*%d,%d,%d,%d*\\n", iub[0].c, int(iub[1].p*100), iub[2].pi, faceedgesidx[3][2]);
- return 0;
- }
- '''
- self.do_run(src, '*97,15,3,10*')
+ self.do_run_from_file(src, output)
def test_conststructs(self):
- src = '''
- #include <stdio.h>
- struct IUB {
- int c;
- double p;
- unsigned int pi;
- };
+ test_path = path_from_root('tests', 'core', 'test_conststructs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main( int argc, const char *argv[] ) {
- int before = 70;
- IUB iub[] = {
- { 'a', 0.3029549426680, 5 },
- { 'c', 0.15, 4 },
- { 'g', 0.12, 3 },
- { 't', 0.27, 2 },
- };
- int after = 90;
- printf("*%d,%d,%d,%d,%d,%d*\\n", before, iub[0].c, int(iub[1].p*100), iub[2].pi, int(iub[0].p*10000), after);
- return 0;
- }
- '''
- self.do_run(src, '*70,97,15,3,3029,90*')
+ self.do_run_from_file(src, output)
def test_bigarray(self):
if self.emcc_args is None: return self.skip('need ta2 to compress type data on zeroinitializers')
- # avoid "array initializer too large" errors
- src = r'''
- #include <stdio.h>
- #include <assert.h>
+ test_path = path_from_root('tests', 'core', 'test_bigarray')
+ src, output = (test_path + s for s in ('.in', '.out'))
- #define SIZE (1024*100)
- struct Struct {
- char x;
- int y;
- };
- Struct buffy[SIZE];
-
- int main() {
- for (int i = 0; i < SIZE; i++) { assert(buffy[i].x == 0 && buffy[i].y == 0); } // we were zeroinitialized
- for (int i = 0; i < SIZE; i++) { buffy[i].x = i*i; buffy[i].y = i*i*i; } // we can save data
- printf("*%d*\n", buffy[SIZE/3].x);
- return 0;
- }
- '''
- self.do_run(src, '*57*')
+ self.do_run_from_file(src, output)
def test_mod_globalstruct(self):
- src = '''
- #include <stdio.h>
-
- struct malloc_params {
- size_t magic, page_size;
- };
+ test_path = path_from_root('tests', 'core', 'test_mod_globalstruct')
+ src, output = (test_path + s for s in ('.in', '.out'))
- malloc_params mparams;
-
- #define SIZE_T_ONE ((size_t)1)
- #define page_align(S) (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE))
-
- int main()
- {
- mparams.page_size = 4096;
- printf("*%d,%d,%d,%d*\\n", mparams.page_size, page_align(1000), page_align(6000), page_align(66474));
- return 0;
- }
- '''
- self.do_run(src, '*4096,4096,8192,69632*')
+ self.do_run_from_file(src, output)
def test_pystruct(self):
src = '''
@@ -3803,107 +1863,41 @@ Exiting setjmp function, level: 0, prev_jmp: -1
def test_ptrtoint(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <stdio.h>
- int main( int argc, const char *argv[] ) {
- char *a = new char[10];
- char *a0 = a+0;
- char *a5 = a+5;
- int *b = new int[10];
- int *b0 = b+0;
- int *b5 = b+5;
- int c = (int)b5-(int)b0; // Emscripten should warn!
- int d = (int)b5-(int)b0; // Emscripten should warn!
- printf("*%d*\\n", (int)a5-(int)a0);
- return 0;
- }
- '''
runner = self
def check_warnings(output):
runner.assertEquals(filter(lambda line: 'Warning' in line, output.split('\n')).__len__(), 4)
- self.do_run(src, '*5*', output_processor=check_warnings)
+
+ test_path = path_from_root('tests', 'core', 'test_ptrtoint')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, output_processor=check_warnings)
def test_sizeof(self):
if self.emcc_args is None: return self.skip('requires emcc')
# Has invalid writes between printouts
Settings.SAFE_HEAP = 0
- src = '''
- #include <stdio.h>
- #include <string.h>
- #include "emscripten.h"
-
- struct A { int x, y; };
-
- int main( int argc, const char *argv[] ) {
- int *a = new int[10];
- int *b = new int[1];
- int *c = new int[10];
- for (int i = 0; i < 10; i++)
- a[i] = 2;
- *b = 5;
- for (int i = 0; i < 10; i++)
- c[i] = 8;
- printf("*%d,%d,%d,%d,%d*\\n", a[0], a[9], *b, c[0], c[9]);
- // Should overwrite a, but not touch b!
- memcpy(a, c, 10*sizeof(int));
- printf("*%d,%d,%d,%d,%d*\\n", a[0], a[9], *b, c[0], c[9]);
-
- // Part 2
- A as[3] = { { 5, 12 }, { 6, 990 }, { 7, 2 } };
- memcpy(&as[0], &as[2], sizeof(A));
-
- printf("*%d,%d,%d,%d,%d,%d*\\n", as[0].x, as[0].y, as[1].x, as[1].y, as[2].x, as[2].y);
- return 0;
- }
- '''
- self.do_run(src, '*2,2,5,8,8***8,8,5,8,8***7,2,6,990,7,2*', [], lambda x, err: x.replace('\n', '*'))
+ test_path = path_from_root('tests', 'core', 'test_sizeof')
+ src, output = (test_path + s for s in ('.in', '.out'))
- def test_float_h(self):
- process = Popen([PYTHON, EMCC, path_from_root('tests', 'float+.c')], stdout=PIPE, stderr=PIPE)
- process.communicate()
- assert process.returncode is 0, 'float.h should agree with our system'
+ self.do_run_from_file(src, output, [], lambda x, err: x.replace('\n', '*'))
def test_llvm_used(self):
- src = r'''
- #include <stdio.h>
- #include <emscripten.h>
-
- extern "C" {
- EMSCRIPTEN_KEEPALIVE void foobar(int x) {
- printf("Worked! %d\n", x);
- }
- }
-
- int main() {
- emscripten_run_script("Module['_foobar'](10)");
- return 0;
- }'''
-
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('pnacl kills llvm_used')
+
Building.LLVM_OPTS = 3
- self.do_run(src, 'Worked! 10\n')
- def test_emscripten_api(self):
- #if Settings.MICRO_OPTS or Settings.RELOOP or Building.LLVM_OPTS: return self.skip('FIXME')
+ test_path = path_from_root('tests', 'core', 'test_llvm_used')
+ src, output = (test_path + s for s in ('.in', '.out'))
- src = r'''
- #include <stdio.h>
- #include "emscripten.h"
+ self.do_run_from_file(src, output)
- extern "C" {
- void save_me_aimee() { printf("mann\n"); }
- }
+ def test_emscripten_api(self):
+ #if Settings.MICRO_OPTS or Settings.RELOOP or Building.LLVM_OPTS: return self.skip('FIXME')
- int main() {
- // EMSCRIPTEN_COMMENT("hello from the source");
- emscripten_run_script("Module.print('hello world' + '!')");
- printf("*%d*\n", emscripten_run_script_int("5*20"));
- printf("*%s*\n", emscripten_run_script_string("'five'+'six'"));
- emscripten_run_script("Module['_save_me_aimee']()");
- return 0;
- }
- '''
+ test_path = path_from_root('tests', 'core', 'test_emscripten_api')
+ src, output = (test_path + s for s in ('.in', '.out'))
check = '''
def process(filename):
@@ -3911,12 +1905,12 @@ def process(filename):
# TODO: restore this (see comment in emscripten.h) assert '// hello from the source' in src
'''
Settings.EXPORTED_FUNCTIONS = ['_main', '_save_me_aimee']
- self.do_run(src, 'hello world!\n*100*\n*fivesix*\nmann\n', post_build=check)
+ self.do_run_from_file(src, output, post_build=check)
# test EXPORT_ALL
Settings.EXPORTED_FUNCTIONS = []
Settings.EXPORT_ALL = 1
- self.do_run(src, 'hello world!\n*100*\n*fivesix*\nmann\n', post_build=check)
+ self.do_run_from_file(src, output, post_build=check)
def test_emscripten_get_now(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2')
@@ -3927,92 +1921,31 @@ def process(filename):
def test_inlinejs(self):
if not self.is_le32(): return self.skip('le32 needed for inline js')
- src = r'''
- #include <stdio.h>
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- double get() {
- double ret = 0;
- __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable
- asm("#comment1");
- asm volatile("#comment2");
- asm volatile("#comment3\n"
- "#comment4\n");
- return ret;
- }
+ test_path = path_from_root('tests', 'core', 'test_inlinejs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- asm("Module.print('Inline JS is very cool')");
- printf("%.2f\n", get());
+ self.do_run_from_file(src, output)
- // Test that passing multiple input and output variables works.
- int src1 = 1, src2 = 2, src3 = 3;
- int dst1 = 0, dst2 = 0, dst3 = 0;
- // TODO asm("Module.print(%3); Module.print(%4); Module.print(%5); %0 = %3; %1 = %4; %2 = %5;" : "=r"(dst1),"=r"(dst2),"=r"(dst3): "r"(src1),"r"(src2),"r"(src3));
- // TODO printf("%d\n%d\n%d\n", dst1, dst2, dst3);
-
- return 0;
- }
- '''
-
- self.do_run(src, 'Inline JS is very cool\n3.64\n') # TODO 1\n2\n3\n1\n2\n3\n')
if self.emcc_args == []: # opts will eliminate the comments
out = open('src.cpp.o.js').read()
for i in range(1, 5): assert ('comment%d' % i) in out
def test_inlinejs2(self):
if not self.is_le32(): return self.skip('le32 needed for inline js')
- src = r'''
- #include <stdio.h>
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- int mix(int x, int y) {
- int ret;
- asm("Math.pow(2, %0+%1+1)" : "=r"(ret) : "r"(x), "r"(y)); // read and write
- return ret;
- }
-
- void mult() {
- asm("var $_$1 = Math.abs(-100); $_$1 *= 2; Module.print($_$1)"); // multiline
- asm __volatile__("Module.print('done')");
- }
-
- int main(int argc, char **argv) {
- printf("%d\n", mix(argc, argc/2));
- mult();
- return 0;
- }
- '''
+ test_path = path_from_root('tests', 'core', 'test_inlinejs2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- self.do_run(src, '4\n200\ndone\n')
+ self.do_run_from_file(src, output)
def test_inlinejs3(self):
- src = r'''
- #include <stdio.h>
- #include <emscripten.h>
-
- int main(int argc, char **argv) {
- EM_ASM(Module.print('hello dere1'));
- EM_ASM(
- Module.print('hello dere2');
- );
- for (int i = 0; i < 3; i++) {
- EM_ASM(
- Module.print('hello dere3');
- Module.print('hello dere' + 4);
- );
- }
- int sum = 0;
- for (int i = 0; i < argc*3; i++) {
- sum += EM_ASM_INT({
- Module.print('i: ' + [$0, ($1).toFixed(2)]);
- return $0*2;
- }, i, double(i)/12);
- }
- printf("sum: %d\n", sum);
- return 0;
- }
- '''
+ test_path = path_from_root('tests', 'core', 'test_inlinejs3')
+ src, output = (test_path + s for s in ('.in', '.out'))
- self.do_run(src, 'hello dere1\nhello dere2\nhello dere3\nhello dere4\nhello dere3\nhello dere4\nhello dere3\nhello dere4\ni: 0,0.00\ni: 1,0.08\ni: 2,0.17\nsum: 6\n')
+ self.do_run_from_file(src, output)
def test_memorygrowth(self):
if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays')
@@ -4106,71 +2039,33 @@ def process(filename):
def test_tinyfuncstr(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <stdio.h>
- struct Class {
- static char *name1() { return "nameA"; }
- char *name2() { return "nameB"; }
- };
+ test_path = path_from_root('tests', 'core', 'test_tinyfuncstr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- printf("*%s,%s*\\n", Class::name1(), (new Class())->name2());
- return 0;
- }
- '''
- self.do_run(src, '*nameA,nameB*')
+ self.do_run_from_file(src, output)
def test_llvmswitch(self):
Settings.CORRECT_SIGNS = 1
- src = '''
- #include <stdio.h>
- #include <string.h>
-
- int switcher(int p)
- {
- switch(p) {
- case 'a':
- case 'b':
- case 'c':
- return p-1;
- case -15:
- return p+1;
- }
- return p;
- }
+ test_path = path_from_root('tests', 'core', 'test_llvmswitch')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main( int argc, const char *argv[] ) {
- unsigned int x = 0xfffffff1;
- x >>= (argc-1); // force it to be unsigned for purpose of checking our switch comparison in signed/unsigned
- printf("*%d,%d,%d,%d,%d,%d*\\n", switcher('a'), switcher('b'), switcher('c'), switcher(x), switcher(-15), switcher('e'));
- return 0;
- }
- '''
- self.do_run(src, '*96,97,98,-14,-14,101*')
+ self.do_run_from_file(src, output)
# By default, when user has not specified a -std flag, Emscripten should always build .cpp files using the C++03 standard,
# i.e. as if "-std=c++03" had been passed on the command line. On Linux with Clang 3.2 this is the case, but on Windows
# with Clang 3.2 -std=c++11 has been chosen as default, because of
# < jrose> clb: it's deliberate, with the idea that for people who don't care about the standard, they should be using the "best" thing we can offer on that platform
def test_cxx03_do_run(self):
- src = '''
- #include <stdio.h>
-
- #if __cplusplus != 199711L
- #error By default, if no -std is specified, emscripten should be compiling with -std=c++03!
- #endif
+ test_path = path_from_root('tests', 'core', 'test_cxx03_do_run')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main( int argc, const char *argv[] ) {
- printf("Hello world!\\n");
- return 0;
- }
- '''
- self.do_run(src, 'Hello world!')
+ self.do_run_from_file(src, output)
def test_bigswitch(self):
if self.run_name != 'default': return self.skip('TODO: issue #781')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
src = open(path_from_root('tests', 'bigswitch.cpp')).read()
self.do_run(src, '''34962: GL_ARRAY_BUFFER (0x8892)
@@ -4179,49 +2074,24 @@ def process(filename):
''', args=['34962', '26214', '35040'])
def test_indirectbr(self):
- Building.COMPILER_TEST_OPTS = filter(lambda x: x != '-g', Building.COMPILER_TEST_OPTS)
-
- src = '''
- #include <stdio.h>
- int main(void) {
- const void *addrs[2] = { &&FOO, &&BAR };
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- // confuse the optimizer so it doesn't hardcode the jump and avoid generating an |indirectbr| instruction
- int which = 0;
- for (int x = 0; x < 1000; x++) which = (which + x*x) % 7;
- which = (which % 2) + 1;
+ Building.COMPILER_TEST_OPTS = filter(lambda x: x != '-g', Building.COMPILER_TEST_OPTS)
- goto *addrs[which];
+ test_path = path_from_root('tests', 'core', 'test_indirectbr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- FOO:
- printf("bad\\n");
- return 0;
- BAR:
- printf("good\\n");
- const void *addr = &&FOO;
- goto *addr;
- }
- '''
- self.do_run(src, 'good\nbad')
+ self.do_run_from_file(src, output)
def test_indirectbr_many(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('blockaddr > 255 requires ta2')
- blocks = range(1500)
- init = ', '.join(['&&B%d' % b for b in blocks])
- defs = '\n'.join(['B%d: printf("%d\\n"); return 0;' % (b,b) for b in blocks])
- src = '''
- #include <stdio.h>
- int main(int argc, char **argv) {
- printf("\\n");
- const void *addrs[] = { %s };
- goto *addrs[argc*argc + 1000];
+ test_path = path_from_root('tests', 'core', 'test_indirectbr_many')
+ src, output = (test_path + s for s in ('.in', '.out'))
-%s
- return 0;
- }
- ''' % (init, defs)
- self.do_run(src, '\n1001\n')
+ self.do_run_from_file(src, output)
def test_pack(self):
src = '''
@@ -4261,124 +2131,10 @@ def process(filename):
if Settings.QUANTUM_SIZE == 1: return self.skip('FIXME: Add support for this')
if not self.is_le32(): return self.skip('we do not support all varargs stuff without le32')
- src = '''
- #include <stdio.h>
- #include <stdarg.h>
-
- void vary(const char *s, ...)
- {
- va_list v;
- va_start(v, s);
- char d[20];
- vsnprintf(d, 20, s, v);
- puts(d);
-
- // Try it with copying
- va_list tempva;
- va_copy(tempva, v);
- vsnprintf(d, 20, s, tempva);
- puts(d);
-
- va_end(v);
- }
-
- void vary2(char color, const char *s, ...)
- {
- va_list v;
- va_start(v, s);
- char d[21];
- d[0] = color;
- vsnprintf(d+1, 20, s, v);
- puts(d);
- va_end(v);
- }
-
- void varargs_listoffsets_list_evaluate(int count, va_list ap, int vaIteration)
- {
- while(count > 0)
- {
- const char* string = va_arg(ap, const char*);
- printf("%s", string);
- count--;
- }
- printf("\\n");
- }
-
- void varags_listoffsets_list_copy(int count, va_list ap, int iteration)
- {
- va_list ap_copy;
- va_copy(ap_copy, ap);
- varargs_listoffsets_list_evaluate(count, ap_copy, iteration);
- va_end(ap_copy);
- }
-
- void varargs_listoffsets_args(int type, int count, ...)
- {
- va_list ap;
- va_start(ap, count);
-
- // evaluate a copied list
- varags_listoffsets_list_copy(count, ap, 1);
- varags_listoffsets_list_copy(count, ap, 2);
- varags_listoffsets_list_copy(count, ap, 3);
- varags_listoffsets_list_copy(count, ap, 4);
-
- varargs_listoffsets_list_evaluate(count, ap, 1);
-
- // NOTE: we expect this test to fail, so we will check the stdout for <BAD+0><BAD+1>.....
- varargs_listoffsets_list_evaluate(count, ap, 2);
-
- // NOTE: this test has to work again, as we restart the list
- va_end(ap);
- va_start(ap, count);
- varargs_listoffsets_list_evaluate(count, ap, 3);
- va_end(ap);
- }
-
- void varargs_listoffsets_main()
- {
- varargs_listoffsets_args(0, 5, "abc", "def", "ghi", "jkl", "mno", "<BAD+0>", "<BAD+1>", "<BAD+2>", "<BAD+3>", "<BAD+4>", "<BAD+5>", "<BAD+6>", "<BAD+7>", "<BAD+8>", "<BAD+9>", "<BAD+10>", "<BAD+11>", "<BAD+12>", "<BAD+13>", "<BAD+14>", "<BAD+15>", "<BAD+16>");
- }
-
- #define GETMAX(pref, type) \
- type getMax##pref(int num, ...) \
- { \
- va_list vv; \
- va_start(vv, num); \
- type maxx = va_arg(vv, type); \
- for (int i = 1; i < num; i++) \
- { \
- type curr = va_arg(vv, type); \
- maxx = curr > maxx ? curr : maxx; \
- } \
- va_end(vv); \
- return maxx; \
- }
- GETMAX(i, int);
- GETMAX(D, double);
-
- int main(int argc, char **argv) {
- vary("*cheez: %d+%d*", 0, 24); // Also tests that '0' is not special as an array ender
- vary("*albeit*"); // Should not fail with no var args in vararg function
- vary2('Q', "%d*", 85);
-
- int maxxi = getMaxi(6, 2, 5, 21, 4, -10, 19);
- printf("maxxi:%d*\\n", maxxi);
- double maxxD = getMaxD(6, (double)2.1, (double)5.1, (double)22.1, (double)4.1, (double)-10.1, (double)19.1, (double)2);
- printf("maxxD:%.2f*\\n", (float)maxxD);
-
- // And, as a function pointer
- void (*vfp)(const char *s, ...) = argc == 1211 ? NULL : vary;
- vfp("*vfp:%d,%d*", 22, 199);
+ test_path = path_from_root('tests', 'core', 'test_varargs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // ensure lists work properly when copied, reinited etc.
- varargs_listoffsets_main();
-
- return 0;
- }
- '''
- self.do_run(src, '*cheez: 0+24*\n*cheez: 0+24*\n*albeit*\n*albeit*\nQ85*\nmaxxi:21*\nmaxxD:22.10*\n*vfp:22,199*\n*vfp:22,199*\n'+
- 'abcdefghijklmno\nabcdefghijklmno\nabcdefghijklmno\nabcdefghijklmno\nabcdefghijklmno\n<BAD+0><BAD+1><BAD+2><BAD+3><BAD+4>\nabcdefghijklmno\n')
+ self.do_run_from_file(src, output)
def test_varargs_byval(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('FIXME: Add support for this')
@@ -4454,20 +2210,10 @@ The current type of b is: 9
''')
def test_functionpointer_libfunc_varargs(self):
- src = r'''
- #include <stdio.h>
- #include <fcntl.h>
- typedef int (*fp_t)(int, int, ...);
- int main(int argc, char **argv) {
- fp_t fp = &fcntl;
- if (argc == 1337) fp = (fp_t)&main;
- (*fp)(0, 10);
- (*fp)(0, 10, 5);
- printf("waka\n");
- return 0;
- }
- '''
- self.do_run(src, '''waka''')
+ test_path = path_from_root('tests', 'core', 'test_functionpointer_libfunc_varargs')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_structbyval(self):
Settings.INLINING_LIMIT = 50
@@ -4655,228 +2401,72 @@ The current type of b is: 9
if self.emcc_args is None: return self.skip('requires emcc')
# tests strtoll for hex strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_strtoll_hex')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- const char *STRING = "0x4 -0x3A +0xDEADBEEF";
- char *end_char;
-
- // undefined base
- long long int l1 = strtoll(STRING, &end_char, 0);
- long long int l2 = strtoll(end_char, &end_char, 0);
- long long int l3 = strtoll(end_char, NULL, 0);
-
- // defined base
- long long int l4 = strtoll(STRING, &end_char, 16);
- long long int l5 = strtoll(end_char, &end_char, 16);
- long long int l6 = strtoll(end_char, NULL, 16);
-
- printf("%d%d%d%d%d%d\n", l1==0x4, l2==-0x3a, l3==0xdeadbeef, l4==0x4, l5==-0x3a, l6==0xdeadbeef);
- return 0;
- }
- '''
- self.do_run(src, '111111')
+ self.do_run_from_file(src, output)
def test_strtoll_dec(self):
if self.emcc_args is None: return self.skip('requires emcc')
# tests strtoll for decimal strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- int main() {
- const char *STRING = "4 -38 +4711";
- char *end_char;
+ test_path = path_from_root('tests', 'core', 'test_strtoll_dec')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // undefined base
- long long int l1 = strtoll(STRING, &end_char, 0);
- long long int l2 = strtoll(end_char, &end_char, 0);
- long long int l3 = strtoll(end_char, NULL, 0);
-
- // defined base
- long long int l4 = strtoll(STRING, &end_char, 10);
- long long int l5 = strtoll(end_char, &end_char, 10);
- long long int l6 = strtoll(end_char, NULL, 10);
-
- printf("%d%d%d%d%d%d\n", l1==4, l2==-38, l3==4711, l4==4, l5==-38, l6==4711);
- return 0;
- }
- '''
- self.do_run(src, '111111')
+ self.do_run_from_file(src, output)
def test_strtoll_bin(self):
if self.emcc_args is None: return self.skip('requires emcc')
# tests strtoll for binary strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- int main() {
- const char *STRING = "1 -101 +1011";
- char *end_char;
-
- // defined base
- long long int l4 = strtoll(STRING, &end_char, 2);
- long long int l5 = strtoll(end_char, &end_char, 2);
- long long int l6 = strtoll(end_char, NULL, 2);
+ test_path = path_from_root('tests', 'core', 'test_strtoll_bin')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("%d%d%d\n", l4==1, l5==-5, l6==11);
- return 0;
- }
- '''
- self.do_run(src, '111')
+ self.do_run_from_file(src, output)
def test_strtoll_oct(self):
if self.emcc_args is None: return self.skip('requires emcc')
# tests strtoll for decimal strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- int main() {
- const char *STRING = "0 -035 +04711";
- char *end_char;
+ test_path = path_from_root('tests', 'core', 'test_strtoll_oct')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // undefined base
- long long int l1 = strtoll(STRING, &end_char, 0);
- long long int l2 = strtoll(end_char, &end_char, 0);
- long long int l3 = strtoll(end_char, NULL, 0);
+ self.do_run_from_file(src, output)
- // defined base
- long long int l4 = strtoll(STRING, &end_char, 8);
- long long int l5 = strtoll(end_char, &end_char, 8);
- long long int l6 = strtoll(end_char, NULL, 8);
-
- printf("%d%d%d%d%d%d\n", l1==0, l2==-29, l3==2505, l4==0, l5==-29, l6==2505);
- return 0;
- }
- '''
- self.do_run(src, '111111')
-
def test_strtol_hex(self):
# tests strtoll for hex strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_strtol_hex')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- const char *STRING = "0x4 -0x3A +0xDEAD";
- char *end_char;
-
- // undefined base
- long l1 = strtol(STRING, &end_char, 0);
- long l2 = strtol(end_char, &end_char, 0);
- long l3 = strtol(end_char, NULL, 0);
-
- // defined base
- long l4 = strtol(STRING, &end_char, 16);
- long l5 = strtol(end_char, &end_char, 16);
- long l6 = strtol(end_char, NULL, 16);
-
- printf("%d%d%d%d%d%d\n", l1==0x4, l2==-0x3a, l3==0xdead, l4==0x4, l5==-0x3a, l6==0xdead);
- return 0;
- }
- '''
- self.do_run(src, '111111')
+ self.do_run_from_file(src, output)
def test_strtol_dec(self):
# tests strtoll for decimal strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- int main() {
- const char *STRING = "4 -38 +4711";
- char *end_char;
+ test_path = path_from_root('tests', 'core', 'test_strtol_dec')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // undefined base
- long l1 = strtol(STRING, &end_char, 0);
- long l2 = strtol(end_char, &end_char, 0);
- long l3 = strtol(end_char, NULL, 0);
-
- // defined base
- long l4 = strtol(STRING, &end_char, 10);
- long l5 = strtol(end_char, &end_char, 10);
- long l6 = strtol(end_char, NULL, 10);
-
- printf("%d%d%d%d%d%d\n", l1==4, l2==-38, l3==4711, l4==4, l5==-38, l6==4711);
- return 0;
- }
- '''
- self.do_run(src, '111111')
+ self.do_run_from_file(src, output)
def test_strtol_bin(self):
# tests strtoll for binary strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- int main() {
- const char *STRING = "1 -101 +1011";
- char *end_char;
+ test_path = path_from_root('tests', 'core', 'test_strtol_bin')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // defined base
- long l4 = strtol(STRING, &end_char, 2);
- long l5 = strtol(end_char, &end_char, 2);
- long l6 = strtol(end_char, NULL, 2);
-
- printf("%d%d%d\n", l4==1, l5==-5, l6==11);
- return 0;
- }
- '''
- self.do_run(src, '111')
+ self.do_run_from_file(src, output)
def test_strtol_oct(self):
# tests strtoll for decimal strings (0x...)
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- int main() {
- const char *STRING = "0 -035 +04711";
- char *end_char;
-
- // undefined base
- long l1 = strtol(STRING, &end_char, 0);
- long l2 = strtol(end_char, &end_char, 0);
- long l3 = strtol(end_char, NULL, 0);
+ test_path = path_from_root('tests', 'core', 'test_strtol_oct')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // defined base
- long l4 = strtol(STRING, &end_char, 8);
- long l5 = strtol(end_char, &end_char, 8);
- long l6 = strtol(end_char, NULL, 8);
-
- printf("%d%d%d%d%d%d\n", l1==0, l2==-29, l3==2505, l4==0, l5==-29, l6==2505);
- return 0;
- }
- '''
- self.do_run(src, '111111')
+ self.do_run_from_file(src, output)
def test_atexit(self):
# Confirms they are called in reverse order
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- static void cleanA() {
- printf("A");
- }
- static void cleanB() {
- printf("B");
- }
+ test_path = path_from_root('tests', 'core', 'test_atexit')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- atexit(cleanA);
- atexit(cleanB);
- return 0;
- }
- '''
- self.do_run(src, 'BA')
+ self.do_run_from_file(src, output)
def test_pthread_specific(self):
if self.emcc_args is None: return self.skip('requires emcc')
@@ -4899,346 +2489,50 @@ The current type of b is: 9
def test_timeb(self):
# Confirms they are called in reverse order
- src = r'''
- #include <stdio.h>
- #include <assert.h>
- #include <sys/timeb.h>
+ test_path = path_from_root('tests', 'core', 'test_timeb')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- timeb tb;
- tb.timezone = 1;
- printf("*%d\n", ftime(&tb));
- assert(tb.time > 10000);
- assert(tb.timezone == 0);
- assert(tb.dstflag == 0);
- return 0;
- }
- '''
- self.do_run(src, '*0\n')
+ self.do_run_from_file(src, output)
def test_time_c(self):
- src = r'''
- #include <time.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_time_c')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- time_t t = time(0);
- printf("time: %s\n", ctime(&t));
- }
- '''
- self.do_run(src, 'time: ') # compilation check, mainly
+ self.do_run_from_file(src, output)
def test_gmtime(self):
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <assert.h>
+ test_path = path_from_root('tests', 'core', 'test_gmtime')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(void)
- {
- time_t t=time(NULL);
- struct tm *ptm=gmtime(&t);
- struct tm tmCurrent=*ptm;
- int hour=tmCurrent.tm_hour;
-
- t-=hour*3600; // back to midnight
- int yday = -1;
- for(hour=0;hour<24;hour++)
- {
- ptm=gmtime(&t);
- // tm_yday must be constant all day...
- printf("yday: %d, hour: %d\n", ptm->tm_yday, hour);
- if (yday == -1) yday = ptm->tm_yday;
- else assert(yday == ptm->tm_yday);
- t+=3600; // add one hour
- }
- printf("ok!\n");
- return(0);
- }
- '''
- self.do_run(src, '''ok!''')
+ self.do_run_from_file(src, output)
def test_strptime_tm(self):
- src=r'''
- #include <time.h>
- #include <stdio.h>
- #include <string.h>
+ test_path = path_from_root('tests', 'core', 'test_strptime_tm')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- struct tm tm;
- char *ptr = strptime("17410105012000", "%H%M%S%d%m%Y", &tm);
-
- printf("%s: %s, %d/%d/%d %d:%d:%d",
- (ptr != NULL && *ptr=='\0') ? "OK" : "ERR",
- tm.tm_wday == 0 ? "Sun" : (tm.tm_wday == 1 ? "Mon" : (tm.tm_wday == 2 ? "Tue" : (tm.tm_wday == 3 ? "Wed" : (tm.tm_wday == 4 ? "Thu" : (tm.tm_wday == 5 ? "Fri" : (tm.tm_wday == 6 ? "Sat" : "ERR")))))),
- tm.tm_mon+1,
- tm.tm_mday,
- tm.tm_year+1900,
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec
- );
- }
- '''
- self.do_run(src, 'OK: Wed, 1/5/2000 17:41:1')
+ self.do_run_from_file(src, output)
def test_strptime_days(self):
- src = r'''
- #include <time.h>
- #include <stdio.h>
- #include <string.h>
+ test_path = path_from_root('tests', 'core', 'test_strptime_days')
+ src, output = (test_path + s for s in ('.in', '.out'))
- static const struct {
- const char *input;
- const char *format;
- } day_tests[] = {
- { "2000-01-01", "%Y-%m-%d"},
- { "03/03/00", "%D"},
- { "9/9/99", "%x"},
- { "19990502123412", "%Y%m%d%H%M%S"},
- { "2001 20 Mon", "%Y %U %a"},
- { "2006 4 Fri", "%Y %U %a"},
- { "2001 21 Mon", "%Y %W %a"},
- { "2013 29 Wed", "%Y %W %a"},
- { "2000-01-01 08:12:21 AM", "%Y-%m-%d %I:%M:%S %p"},
- { "2000-01-01 08:12:21 PM", "%Y-%m-%d %I:%M:%S %p"},
- { "2001 17 Tue", "%Y %U %a"},
- { "2001 8 Thursday", "%Y %W %a"},
- };
-
- int main() {
- struct tm tm;
-
- for (int i = 0; i < sizeof (day_tests) / sizeof (day_tests[0]); ++i) {
- memset (&tm, '\0', sizeof (tm));
- char *ptr = strptime(day_tests[i].input, day_tests[i].format, &tm);
-
- printf("%s: %d/%d/%d (%dth DoW, %dth DoY)\n", (ptr != NULL && *ptr=='\0') ? "OK" : "ERR", tm.tm_mon+1, tm.tm_mday, 1900+tm.tm_year, tm.tm_wday, tm.tm_yday);
- }
- }
- '''
- self.do_run(src, 'OK: 1/1/2000 (6th DoW, 0th DoY)\n'\
- 'OK: 3/3/2000 (5th DoW, 62th DoY)\n'\
- 'OK: 9/9/1999 (4th DoW, 251th DoY)\n'\
- 'OK: 5/2/1999 (0th DoW, 121th DoY)\n'\
- 'OK: 5/21/2001 (1th DoW, 140th DoY)\n'\
- 'OK: 1/27/2006 (5th DoW, 26th DoY)\n'\
- 'OK: 5/21/2001 (1th DoW, 140th DoY)\n'\
- 'OK: 7/24/2013 (3th DoW, 204th DoY)\n'\
- 'OK: 1/1/2000 (6th DoW, 0th DoY)\n'\
- 'OK: 1/1/2000 (6th DoW, 0th DoY)\n'\
- 'OK: 5/1/2001 (2th DoW, 120th DoY)\n'\
- 'OK: 2/22/2001 (4th DoW, 52th DoY)\n'\
- )
+ self.do_run_from_file(src, output)
def test_strptime_reentrant(self):
- src=r'''
- #include <time.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- int main () {
- int result = 0;
- struct tm tm;
-
- memset (&tm, 0xaa, sizeof (tm));
-
- /* Test we don't crash on uninitialized struct tm.
- Some fields might contain bogus values until everything
- needed is initialized, but we shouldn't crash. */
- if (strptime ("2007", "%Y", &tm) == NULL
- || strptime ("12", "%d", &tm) == NULL
- || strptime ("Feb", "%b", &tm) == NULL
- || strptime ("13", "%M", &tm) == NULL
- || strptime ("21", "%S", &tm) == NULL
- || strptime ("16", "%H", &tm) == NULL) {
- printf("ERR: returned NULL");
- exit(EXIT_FAILURE);
- }
-
- if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16
- || tm.tm_mday != 12 || tm.tm_mon != 1 || tm.tm_year != 107
- || tm.tm_wday != 1 || tm.tm_yday != 42) {
- printf("ERR: unexpected tm content (1) - %d/%d/%d %d:%d:%d", tm.tm_mon+1, tm.tm_mday, tm.tm_year+1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
- exit(EXIT_FAILURE);
- }
+ test_path = path_from_root('tests', 'core', 'test_strptime_reentrant')
+ src, output = (test_path + s for s in ('.in', '.out'))
- if (strptime ("8", "%d", &tm) == NULL) {
- printf("ERR: strptime failed");
- exit(EXIT_FAILURE);
- }
-
- if (tm.tm_sec != 21 || tm.tm_min != 13 || tm.tm_hour != 16
- || tm.tm_mday != 8 || tm.tm_mon != 1 || tm.tm_year != 107
- || tm.tm_wday != 4 || tm.tm_yday != 38) {
- printf("ERR: unexpected tm content (2) - %d/%d/%d %d:%d:%d", tm.tm_mon+1, tm.tm_mday, tm.tm_year+1900, tm.tm_hour, tm.tm_min, tm.tm_sec);
- exit(EXIT_FAILURE);
- }
-
- printf("OK");
- }
- '''
- self.do_run(src, 'OK')
+ self.do_run_from_file(src, output)
def test_strftime(self):
- src=r'''
- #include <time.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- void test(int result, const char* comment, const char* parsed = "") {
- printf("%d",result);
- if (!result) {
- printf("\nERROR: %s (\"%s\")\n", comment, parsed);
- }
- }
-
- int cmp(const char *s1, const char *s2) {
- for ( ; *s1 == *s2 ; s1++,s2++ ) {
- if ( *s1 == '\0' )
- break;
- }
-
- return (*s1 - *s2);
- }
-
- int main() {
- struct tm tm;
- char s[1000];
- size_t size;
-
- tm.tm_sec = 4;
- tm.tm_min = 23;
- tm.tm_hour = 20;
- tm.tm_mday = 21;
- tm.tm_mon = 1;
- tm.tm_year = 74;
- tm.tm_wday = 4;
- tm.tm_yday = 51;
- tm.tm_isdst = 0;
-
- size = strftime(s, 1000, "", &tm);
- test((size==0) && (*s=='\0'), "strftime test #1", s);
-
- size = strftime(s, 1000, "%a", &tm);
- test((size==3) && !cmp(s, "Thu"), "strftime test #2", s);
-
- size = strftime(s, 1000, "%A", &tm);
- test((size==8) && !cmp(s, "Thursday"), "strftime test #3", s);
-
- size = strftime(s, 1000, "%b", &tm);
- test((size==3) && !cmp(s, "Feb"), "strftime test #4", s);
-
- size = strftime(s, 1000, "%B", &tm);
- test((size==8) && !cmp(s, "February"),
- "strftime test #5", s);
-
- size = strftime(s, 1000, "%d", &tm);
- test((size==2) && !cmp(s, "21"),
- "strftime test #6", s);
-
- size = strftime(s, 1000, "%H", &tm);
- test((size==2) && !cmp(s, "20"),
- "strftime test #7", s);
-
- size = strftime(s, 1000, "%I", &tm);
- test((size==2) && !cmp(s, "08"),
- "strftime test #8", s);
-
- size = strftime(s, 1000, "%j", &tm);
- test((size==3) && !cmp(s, "052"),
- "strftime test #9", s);
-
- size = strftime(s, 1000, "%m", &tm);
- test((size==2) && !cmp(s, "02"),
- "strftime test #10", s);
-
- size = strftime(s, 1000, "%M", &tm);
- test((size==2) && !cmp(s, "23"),
- "strftime test #11", s);
-
- size = strftime(s, 1000, "%p", &tm);
- test((size==2) && !cmp(s, "PM"),
- "strftime test #12", s);
-
- size = strftime(s, 1000, "%S", &tm);
- test((size==2) && !cmp(s, "04"),
- "strftime test #13", s);
-
- size = strftime(s, 1000, "%U", &tm);
- test((size==2) && !cmp(s, "07"),
- "strftime test #14", s);
-
- size = strftime(s, 1000, "%w", &tm);
- test((size==1) && !cmp(s, "4"),
- "strftime test #15", s);
-
- size = strftime(s, 1000, "%W", &tm);
- test((size==2) && !cmp(s, "07"),
- "strftime test #16", s);
-
- size = strftime(s, 1000, "%y", &tm);
- test((size==2) && !cmp(s, "74"),
- "strftime test #17", s);
-
- size = strftime(s, 1000, "%Y", &tm);
- test((size==4) && !cmp(s, "1974"),
- "strftime test #18", s);
-
- size = strftime(s, 1000, "%%", &tm);
- test((size==1) && !cmp(s, "%"),
- "strftime test #19", s);
-
- size = strftime(s, 5, "%Y", &tm);
- test((size==4) && !cmp(s, "1974"),
- "strftime test #20", s);
-
- size = strftime(s, 4, "%Y", &tm);
- test((size==0), "strftime test #21", s);
-
- tm.tm_mon = 0;
- tm.tm_mday = 1;
- size = strftime(s, 10, "%U", &tm);
- test((size==2) && !cmp(s, "00"), "strftime test #22", s);
-
- size = strftime(s, 10, "%W", &tm);
- test((size==2) && !cmp(s, "00"), "strftime test #23", s);
-
- // 1/1/1973 was a Sunday and is in CW 1
- tm.tm_year = 73;
- size = strftime(s, 10, "%W", &tm);
- test((size==2) && !cmp(s, "01"), "strftime test #24", s);
-
- // 1/1/1978 was a Monday and is in CW 1
- tm.tm_year = 78;
- size = strftime(s, 10, "%U", &tm);
- test((size==2) && !cmp(s, "01"), "strftime test #25", s);
-
- // 2/1/1999
- tm.tm_year = 99;
- tm.tm_yday = 1;
- size = strftime(s, 10, "%G (%V)", &tm);
- test((size==9) && !cmp(s, "1998 (53)"), "strftime test #26", s);
-
- size = strftime(s, 10, "%g", &tm);
- test((size==2) && !cmp(s, "98"), "strftime test #27", s);
+ test_path = path_from_root('tests', 'core', 'test_strftime')
+ src, output = (test_path + s for s in ('.in', '.out'))
- // 30/12/1997
- tm.tm_year = 97;
- tm.tm_yday = 363;
- size = strftime(s, 10, "%G (%V)", &tm);
- test((size==9) && !cmp(s, "1998 (01)"), "strftime test #28", s);
-
- size = strftime(s, 10, "%g", &tm);
- test((size==2) && !cmp(s, "98"), "strftime test #29", s);
- }
- '''
- self.do_run(src, '11111111111111111111111111111')
+ self.do_run_from_file(src, output)
def test_intentional_fault(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1' and self.run_name == 'default': return self.skip('todo in fastcomp in default')
+
# Some programs intentionally segfault themselves, we should compile that into a throw
src = r'''
int main () {
@@ -5249,33 +2543,10 @@ The current type of b is: 9
self.do_run(src, 'fault on write to 0' if not Settings.ASM_JS else 'abort()')
def test_trickystring(self):
- src = r'''
- #include <stdio.h>
-
- typedef struct
- {
- int (*f)(void *);
- void *d;
- char s[16];
- } LMEXFunctionStruct;
-
- int f(void *user)
- {
- return 0;
- }
-
- static LMEXFunctionStruct const a[] =
- {
- {f, (void *)(int)'a', "aa"}
- };
+ test_path = path_from_root('tests', 'core', 'test_trickystring')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- printf("ok\n");
- return a[0].f(a[0].d);
- }
- '''
- self.do_run(src, 'ok\n')
+ self.do_run_from_file(src, output)
def test_statics(self):
# static initializers save i16 but load i8 for some reason (or i64 and load i8)
@@ -5283,46 +2554,10 @@ The current type of b is: 9
Settings.SAFE_HEAP = 3
Settings.SAFE_HEAP_LINES = ['src.cpp:19', 'src.cpp:26', 'src.cpp:28']
- src = '''
- #include <stdio.h>
- #include <string.h>
-
- #define CONSTRLEN 32
-
- char * (*func)(char *, const char *) = NULL;
-
- void conoutfv(const char *fmt)
- {
- static char buf[CONSTRLEN];
- func(buf, fmt); // call by function pointer to make sure we test strcpy here
- puts(buf);
- }
-
- struct XYZ {
- float x, y, z;
- XYZ(float a, float b, float c) : x(a), y(b), z(c) { }
- static const XYZ& getIdentity()
- {
- static XYZ iT(1,2,3);
- return iT;
- }
- };
- struct S {
- static const XYZ& getIdentity()
- {
- static const XYZ iT(XYZ::getIdentity());
- return iT;
- }
- };
+ test_path = path_from_root('tests', 'core', 'test_statics')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- func = &strcpy;
- conoutfv("*staticccz*");
- printf("*%.2f,%.2f,%.2f*\\n", S::getIdentity().x, S::getIdentity().y, S::getIdentity().z);
- return 0;
- }
- '''
- self.do_run(src, '*staticccz*\n*1.00,2.00,3.00*')
+ self.do_run_from_file(src, output)
def test_copyop(self):
if self.emcc_args is None: return self.skip('requires emcc')
@@ -5331,392 +2566,75 @@ The current type of b is: 9
# memcpy for assignments, with hardcoded numbers of bytes
# (llvm-gcc copies items one by one). See QUANTUM_SIZE in
# settings.js.
- src = '''
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
-
- struct vec {
- double x,y,z;
- vec() : x(0), y(0), z(0) { };
- vec(const double a, const double b, const double c) : x(a), y(b), z(c) { };
- };
-
- struct basis {
- vec a, b, c;
- basis(const vec& v) {
- a=v; // should not touch b!
- printf("*%.2f,%.2f,%.2f*\\n", b.x, b.y, b.z);
- }
- };
+ test_path = path_from_root('tests', 'core', 'test_copyop')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- basis B(vec(1,0,0));
-
- // Part 2: similar problem with memset and memmove
- int x = 1, y = 77, z = 2;
- memset((void*)&x, 0, sizeof(int));
- memset((void*)&z, 0, sizeof(int));
- printf("*%d,%d,%d*\\n", x, y, z);
- memcpy((void*)&x, (void*)&z, sizeof(int));
- memcpy((void*)&z, (void*)&x, sizeof(int));
- printf("*%d,%d,%d*\\n", x, y, z);
- memmove((void*)&x, (void*)&z, sizeof(int));
- memmove((void*)&z, (void*)&x, sizeof(int));
- printf("*%d,%d,%d*\\n", x, y, z);
- return 0;
- }
- '''
- self.do_run(src, '*0.00,0.00,0.00*\n*0,77,0*\n*0,77,0*\n*0,77,0*')
+ self.do_run_from_file(src, output)
def test_memcpy_memcmp(self):
- src = '''
- #include <stdio.h>
- #include <string.h>
- #include <assert.h>
+ test_path = path_from_root('tests', 'core', 'test_memcpy_memcmp')
+ src, output = (test_path + s for s in ('.in', '.out'))
- #define MAXX 48
- void reset(unsigned char *buffer) {
- for (int i = 0; i < MAXX; i++) buffer[i] = i+1;
- }
- void dump(unsigned char *buffer) {
- for (int i = 0; i < MAXX-1; i++) printf("%2d,", buffer[i]);
- printf("%d\\n", buffer[MAXX-1]);
- }
- int main() {
- unsigned char buffer[MAXX];
- for (int i = MAXX/4; i < MAXX-MAXX/4; i++) {
- for (int j = MAXX/4; j < MAXX-MAXX/4; j++) {
- for (int k = 1; k < MAXX/4; k++) {
- if (i == j) continue;
- if (i < j && i+k > j) continue;
- if (j < i && j+k > i) continue;
- printf("[%d,%d,%d] ", i, j, k);
- reset(buffer);
- memcpy(buffer+i, buffer+j, k);
- dump(buffer);
- assert(memcmp(buffer+i, buffer+j, k) == 0);
- buffer[i + k/2]++;
- if (buffer[i + k/2] != 0) {
- assert(memcmp(buffer+i, buffer+j, k) > 0);
- } else {
- assert(memcmp(buffer+i, buffer+j, k) < 0);
- }
- buffer[i + k/2]--;
- buffer[j + k/2]++;
- if (buffer[j + k/2] != 0) {
- assert(memcmp(buffer+i, buffer+j, k) < 0);
- } else {
- assert(memcmp(buffer+i, buffer+j, k) > 0);
- }
- }
- }
- }
- return 0;
- }
- '''
def check(result, err):
return hashlib.sha1(result).hexdigest()
- self.do_run(src, '6c9cdfe937383b79e52ca7a2cce83a21d9f5422c',
- output_nicerizer = check)
+
+ self.do_run_from_file(src, output, output_nicerizer = check)
def test_memcpy2(self):
- src = r'''
- #include <stdio.h>
- #include <string.h>
- #include <assert.h>
- int main() {
- char buffer[256];
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- for (int k = 0; k < 35; k++) {
- for (int t = 0; t < 256; t++) buffer[t] = t;
- char *dest = buffer + i + 128;
- char *src = buffer+j;
- //printf("%d, %d, %d\n", i, j, k);
- assert(memcpy(dest, src, k) == dest);
- assert(memcmp(dest, src, k) == 0);
- }
- }
- }
- printf("ok.\n");
- return 1;
- }
- '''
- self.do_run(src, 'ok.');
+ test_path = path_from_root('tests', 'core', 'test_memcpy2')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_getopt(self):
if self.emcc_args is None: return self.skip('needs emcc for libc')
- src = '''
- #pragma clang diagnostic ignored "-Winvalid-pp-token"
- #include <unistd.h>
- #include <stdlib.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_getopt')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int
- main(int argc, char *argv[])
- {
- int flags, opt;
- int nsecs, tfnd;
-
- nsecs = 0;
- tfnd = 0;
- flags = 0;
- while ((opt = getopt(argc, argv, "nt:")) != -1) {
- switch (opt) {
- case 'n':
- flags = 1;
- break;
- case 't':
- nsecs = atoi(optarg);
- tfnd = 1;
- break;
- default: /* '?' */
- fprintf(stderr, "Usage: %s [-t nsecs] [-n] name\\n",
- argv[0]);
- exit(EXIT_FAILURE);
- }
- }
-
- printf("flags=%d; tfnd=%d; optind=%d\\n", flags, tfnd, optind);
-
- if (optind >= argc) {
- fprintf(stderr, "Expected argument after options\\n");
- exit(EXIT_FAILURE);
- }
-
- printf("name argument = %s\\n", argv[optind]);
-
- /* Other code omitted */
-
- exit(EXIT_SUCCESS);
- }
- '''
- self.do_run(src, 'flags=1; tfnd=1; optind=4\nname argument = foobar', args=['-t', '12', '-n', 'foobar'])
+ self.do_run_from_file(src, output, args=['-t', '12', '-n', 'foobar'])
def test_getopt_long(self):
if self.emcc_args is None: return self.skip('needs emcc for libc')
- src = '''
- #pragma clang diagnostic ignored "-Winvalid-pp-token"
- #pragma clang diagnostic ignored "-Wdeprecated-writable-strings"
- #include <stdio.h> /* for printf */
- #include <stdlib.h> /* for exit */
- #include <getopt.h>
-
- int
- main(int argc, char **argv)
- {
- int c;
- int digit_optind = 0;
-
- while (1) {
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] = {
- {"add", required_argument, 0, 0 },
- {"append", no_argument, 0, 0 },
- {"delete", required_argument, 0, 0 },
- {"verbose", no_argument, 0, 0 },
- {"create", required_argument, 0, 'c'},
- {"file", required_argument, 0, 0 },
- {0, 0, 0, 0 }
- };
-
- c = getopt_long(argc, argv, "abc:d:012",
- long_options, &option_index);
- if (c == -1)
- break;
-
- switch (c) {
- case 0:
- printf("option %s", long_options[option_index].name);
- if (optarg)
- printf(" with arg %s", optarg);
- printf("\\n");
- break;
-
- case '0':
- case '1':
- case '2':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf("digits occur in two different argv-elements.\\n");
- digit_optind = this_option_optind;
- printf("option %c\\n", c);
- break;
-
- case 'a':
- printf("option a\\n");
- break;
-
- case 'b':
- printf("option b\\n");
- break;
-
- case 'c':
- printf("option c with value '%s'\\n", optarg);
- break;
-
- case 'd':
- printf("option d with value '%s'\\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf("?? getopt returned character code 0%o ??\\n", c);
- }
- }
-
- if (optind < argc) {
- printf("non-option ARGV-elements: ");
- while (optind < argc)
- printf("%s ", argv[optind++]);
- printf("\\n");
- }
-
- exit(EXIT_SUCCESS);
- }
- '''
- self.do_run(src, 'option file with arg foobar\noption b', args=['--file', 'foobar', '-b'])
+ test_path = path_from_root('tests', 'core', 'test_getopt_long')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, args=['--file', 'foobar', '-b'])
def test_memmove(self):
- src = '''
- #include <stdio.h>
- #include <string.h>
- int main() {
- char str[] = "memmove can be very useful....!";
- memmove (str+20, str+15, 11);
- puts(str);
- return 0;
- }
- '''
- self.do_run(src, 'memmove can be very very useful')
+ test_path = path_from_root('tests', 'core', 'test_memmove')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_memmove2(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('need ta2')
- src = r'''
- #include <stdio.h>
- #include <string.h>
- #include <assert.h>
- int main() {
- int sum = 0;
- char buffer[256];
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- for (int k = 0; k < 35; k++) {
- for (int t = 0; t < 256; t++) buffer[t] = t;
- char *dest = buffer + i;
- char *src = buffer + j;
- if (dest == src) continue;
- //printf("%d, %d, %d\n", i, j, k);
- assert(memmove(dest, src, k) == dest);
- for (int t = 0; t < 256; t++) sum += buffer[t];
- }
- }
- }
- printf("final: %d.\n", sum);
- return 1;
- }
- '''
- self.do_run(src, 'final: -403200.');
+ test_path = path_from_root('tests', 'core', 'test_memmove2')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_memmove3(self):
- src = '''
- #include <stdio.h>
- #include <string.h>
- int main() {
- char str[] = "memmove can be vvery useful....!";
- memmove(str+15, str+16, 17);
- puts(str);
- return 0;
- }
- '''
- self.do_run(src, 'memmove can be very useful....!')
+ test_path = path_from_root('tests', 'core', 'test_memmove3')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_flexarray_struct(self):
- src = r'''
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_flexarray_struct')
+ src, output = (test_path + s for s in ('.in', '.out'))
-typedef struct
-{
- uint16_t length;
- struct
- {
- int32_t int32;
- } value[];
-} Tuple;
-
-int main() {
- Tuple T[10];
- Tuple *t = &T[0];
-
- t->length = 4;
- t->value->int32 = 100;
-
- printf("(%d, %d)\n", t->length, t->value->int32);
- return 0;
-}
-'''
- self.do_run(src, '(4, 100)')
+ self.do_run_from_file(src, output)
def test_bsearch(self):
if Settings.QUANTUM_SIZE == 1: return self.skip('Test cannot work with q1')
- src = '''
- #include <stdlib.h>
- #include <stdio.h>
-
- int cmp(const void* key, const void* member) {
- return *(int *)key - *(int *)member;
- }
-
- void printResult(int* needle, int* haystack, unsigned int len) {
- void *result = bsearch(needle, haystack, len, sizeof(unsigned int), cmp);
-
- if (result == NULL) {
- printf("null\\n");
- } else {
- printf("%d\\n", *(unsigned int *)result);
- }
- }
-
- int main() {
- int a[] = { -2, -1, 0, 6, 7, 9 };
- int b[] = { 0, 1 };
-
- /* Find all keys that exist. */
- for(int i = 0; i < 6; i++) {
- int val = a[i];
-
- printResult(&val, a, 6);
- }
-
- /* Keys that are covered by the range of the array but aren't in
- * the array cannot be found.
- */
- int v1 = 3;
- int v2 = 8;
- printResult(&v1, a, 6);
- printResult(&v2, a, 6);
+ test_path = path_from_root('tests', 'core', 'test_bsearch')
+ src, output = (test_path + s for s in ('.in', '.out'))
- /* Keys outside the range of the array cannot be found. */
- int v3 = -1;
- int v4 = 2;
-
- printResult(&v3, b, 2);
- printResult(&v4, b, 2);
-
- return 0;
- }
- '''
-
- self.do_run(src, '-2\n-1\n0\n6\n7\n9\nnull\nnull\nnull\nnull')
+ self.do_run_from_file(src, output)
def test_nestedstructs(self):
src = '''
@@ -5816,6 +2734,10 @@ int main() {
self.do_run(main, 'supp: 54,2\nmain: 56\nsupp see: 543\nmain see: 76\nok.')
def can_dlfcn(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1':
+ self.skip('todo in fastcomp')
+ return False
+
if self.emcc_args and '--memory-init-file' in self.emcc_args:
for i in range(len(self.emcc_args)):
if self.emcc_args[i] == '--memory-init-file':
@@ -6194,32 +3116,9 @@ def process(filename):
def test_dlfcn_self(self):
if Settings.USE_TYPED_ARRAYS == 1: return self.skip('Does not work with USE_TYPED_ARRAYS=1')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.DLOPEN_SUPPORT = 1
- src = r'''
-#include <stdio.h>
-#include <dlfcn.h>
-#include <emscripten.h>
-
-int EMSCRIPTEN_KEEPALIVE global = 123;
-
-extern "C" EMSCRIPTEN_KEEPALIVE void foo(int x) {
-printf("%d\n", x);
-}
-
-extern "C" EMSCRIPTEN_KEEPALIVE void repeatable() {
-void* self = dlopen(NULL, RTLD_LAZY);
-int* global_ptr = (int*)dlsym(self, "global");
-void (*foo_ptr)(int) = (void (*)(int))dlsym(self, "foo");
-foo_ptr(*global_ptr);
-dlclose(self);
-}
-
-int main() {
-repeatable();
-repeatable();
-return 0;
-}'''
def post(filename):
with open(filename) as f:
for line in f:
@@ -6231,8 +3130,11 @@ return 0;
table = table[table.find('{'):table.rfind('}')+1]
# ensure there aren't too many globals; we don't want unnamed_addr
assert table.count(',') <= 4
- self.do_run(src, '123\n123', post_build=(None, post))
+ test_path = path_from_root('tests', 'core', 'test_dlfcn_self')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, post_build=(None, post))
def test_dlfcn_unique_sig(self):
if not self.can_dlfcn(): return
@@ -6711,61 +3613,10 @@ ok
self.do_run(src.replace('strtod', 'strtold'), re.sub(r'\n\s+', '\n', expected)) # XXX add real support for long double
def test_strtok(self):
- src = r'''
- #include<stdio.h>
- #include<string.h>
-
- int main() {
- char test[80], blah[80];
- char *sep = "\\/:;=-";
- char *word, *phrase, *brkt, *brkb;
+ test_path = path_from_root('tests', 'core', 'test_strtok')
+ src, output = (test_path + s for s in ('.in', '.out'))
- strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
-
- for (word = strtok_r(test, sep, &brkt); word; word = strtok_r(NULL, sep, &brkt)) {
- strcpy(blah, "blah:blat:blab:blag");
- for (phrase = strtok_r(blah, sep, &brkb); phrase; phrase = strtok_r(NULL, sep, &brkb)) {
- printf("at %s:%s\n", word, phrase);
- }
- }
- return 0;
- }
- '''
-
- expected = '''at This:blah
-at This:blat
-at This:blab
-at This:blag
-at is.a:blah
-at is.a:blat
-at is.a:blab
-at is.a:blag
-at test:blah
-at test:blat
-at test:blab
-at test:blag
-at of:blah
-at of:blat
-at of:blab
-at of:blag
-at the:blah
-at the:blat
-at the:blab
-at the:blag
-at string:blah
-at string:blat
-at string:blab
-at string:blag
-at tokenizer:blah
-at tokenizer:blat
-at tokenizer:blab
-at tokenizer:blag
-at function.:blah
-at function.:blat
-at function.:blab
-at function.:blag
-'''
- self.do_run(src, expected)
+ self.do_run_from_file(src, output)
def test_parseInt(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('i64 mode 1 requires ta2')
@@ -6775,20 +3626,10 @@ at function.:blag
self.do_run(src, expected)
def test_transtrcase(self):
- src = '''
- #include <stdio.h>
- #include <string.h>
- int main() {
- char szToupr[] = "hello, ";
- char szTolwr[] = "EMSCRIPTEN";
- strupr(szToupr);
- strlwr(szTolwr);
- printf(szToupr);
- printf(szTolwr);
- return 0;
- }
- '''
- self.do_run(src, 'HELLO, emscripten')
+ test_path = path_from_root('tests', 'core', 'test_transtrcase')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_printf(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('i64 mode 1 requires ta2')
@@ -6799,350 +3640,58 @@ at function.:blag
self.do_run(src, expected)
def test_printf_2(self):
- src = r'''
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_printf_2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- char c = '1';
- short s = 2;
- int i = 3;
- long long l = 4;
- float f = 5.5;
- double d = 6.6;
-
- printf("%c,%hd,%d,%lld,%.1f,%.1llf\n", c, s, i, l, f, d);
- printf("%#x,%#x\n", 1, 0);
-
- return 0;
- }
- '''
- self.do_run(src, '1,2,3,4,5.5,6.6\n0x1,0\n')
+ self.do_run_from_file(src, output)
def test_vprintf(self):
- src = r'''
- #include <stdio.h>
- #include <stdarg.h>
-
- void print(char* format, ...) {
- va_list args;
- va_start (args, format);
- vprintf (format, args);
- va_end (args);
- }
+ test_path = path_from_root('tests', 'core', 'test_vprintf')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main () {
- print("Call with %d variable argument.\n", 1);
- print("Call with %d variable %s.\n", 2, "arguments");
-
- return 0;
- }
- '''
- expected = '''
- Call with 1 variable argument.
- Call with 2 variable arguments.
- '''
- self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
+ self.do_run_from_file(src, output)
def test_vsnprintf(self):
if self.emcc_args is None: return self.skip('needs i64 math')
- src = r'''
- #include <stdio.h>
- #include <stdarg.h>
- #include <stdint.h>
-
- void printy(const char *f, ...)
- {
- char buffer[256];
- va_list args;
- va_start(args, f);
- vsnprintf(buffer, 256, f, args);
- puts(buffer);
- va_end(args);
- }
-
- int main(int argc, char **argv) {
- int64_t x = argc - 1;
- int64_t y = argc - 1 + 0x400000;
- if (x % 3 == 2) y *= 2;
-
- printy("0x%llx_0x%llx", x, y);
- printy("0x%llx_0x%llx", x, x);
- printy("0x%llx_0x%llx", y, x);
- printy("0x%llx_0x%llx", y, y);
-
- {
- uint64_t A = 0x800000;
- uint64_t B = 0x800000000000ULL;
- printy("0x%llx_0x%llx", A, B);
- }
- {
- uint64_t A = 0x800;
- uint64_t B = 0x12340000000000ULL;
- printy("0x%llx_0x%llx", A, B);
- }
- {
- uint64_t A = 0x000009182746756;
- uint64_t B = 0x192837465631ACBDULL;
- printy("0x%llx_0x%llx", A, B);
- }
+ test_path = path_from_root('tests', 'core', 'test_vsnprintf')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '''0x0_0x400000
-0x0_0x0
-0x400000_0x0
-0x400000_0x400000
-0x800000_0x800000000000
-0x800_0x12340000000000
-0x9182746756_0x192837465631acbd
-''')
+ self.do_run_from_file(src, output)
def test_printf_more(self):
- src = r'''
- #include <stdio.h>
- int main() {
- int size = snprintf(NULL, 0, "%s %d %.2f\n", "me and myself", 25, 1.345);
- char buf[size];
- snprintf(buf, size, "%s %d %.2f\n", "me and myself", 25, 1.345);
- printf("%d : %s\n", size, buf);
- char *buff = NULL;
- asprintf(&buff, "%d waka %d\n", 21, 95);
- puts(buff);
- return 0;
- }
- '''
- self.do_run(src, '22 : me and myself 25 1.34\n21 waka 95\n')
+ test_path = path_from_root('tests', 'core', 'test_printf_more')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_perrar(self):
- src = r'''
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_perrar')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main( int argc, char** argv ){
- int retval = open( "NonExistingFile", O_RDONLY );
- if( retval == -1 )
- perror( "Cannot open NonExistingFile" );
- return 0;
- }
- '''
- self.do_run(src, 'Cannot open NonExistingFile: No such file or directory\n')
+ self.do_run_from_file(src, output)
def test_atoX(self):
if self.emcc_args is None: return self.skip('requires ta2')
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_atoX')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main () {
- printf("%d*", atoi(""));
- printf("%d*", atoi("a"));
- printf("%d*", atoi(" b"));
- printf("%d*", atoi(" c "));
- printf("%d*", atoi("6"));
- printf("%d*", atoi(" 5"));
- printf("%d*", atoi("4 "));
- printf("%d*", atoi("3 6"));
- printf("%d*", atoi(" 3 7"));
- printf("%d*", atoi("9 d"));
- printf("%d\n", atoi(" 8 e"));
- printf("%d*", atol(""));
- printf("%d*", atol("a"));
- printf("%d*", atol(" b"));
- printf("%d*", atol(" c "));
- printf("%d*", atol("6"));
- printf("%d*", atol(" 5"));
- printf("%d*", atol("4 "));
- printf("%d*", atol("3 6"));
- printf("%d*", atol(" 3 7"));
- printf("%d*", atol("9 d"));
- printf("%d\n", atol(" 8 e"));
- printf("%lld*", atoll("6294967296"));
- printf("%lld*", atoll(""));
- printf("%lld*", atoll("a"));
- printf("%lld*", atoll(" b"));
- printf("%lld*", atoll(" c "));
- printf("%lld*", atoll("6"));
- printf("%lld*", atoll(" 5"));
- printf("%lld*", atoll("4 "));
- printf("%lld*", atoll("3 6"));
- printf("%lld*", atoll(" 3 7"));
- printf("%lld*", atoll("9 d"));
- printf("%lld\n", atoll(" 8 e"));
- return 0;
- }
- '''
- self.do_run(src, '0*0*0*0*6*5*4*3*3*9*8\n0*0*0*0*6*5*4*3*3*9*8\n6294967296*0*0*0*0*6*5*4*3*3*9*8\n')
+ self.do_run_from_file(src, output)
def test_strstr(self):
- src = r'''
- #include <stdio.h>
- #include <string.h>
+ test_path = path_from_root('tests', 'core', 'test_strstr')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- printf("%d\n", !!strstr("\\n", "\\n"));
- printf("%d\n", !!strstr("cheezy", "ez"));
- printf("%d\n", !!strstr("cheeezy", "ez"));
- printf("%d\n", !!strstr("cheeeeeeeeeezy", "ez"));
- printf("%d\n", !!strstr("cheeeeeeeeee1zy", "ez"));
- printf("%d\n", !!strstr("che1ezy", "ez"));
- printf("%d\n", !!strstr("che1ezy", "che"));
- printf("%d\n", !!strstr("ce1ezy", "che"));
- printf("%d\n", !!strstr("ce1ezy", "ezy"));
- printf("%d\n", !!strstr("ce1ezyt", "ezy"));
- printf("%d\n", !!strstr("ce1ez1y", "ezy"));
- printf("%d\n", !!strstr("cheezy", "a"));
- printf("%d\n", !!strstr("cheezy", "b"));
- printf("%d\n", !!strstr("cheezy", "c"));
- printf("%d\n", !!strstr("cheezy", "d"));
- printf("%d\n", !!strstr("cheezy", "g"));
- printf("%d\n", !!strstr("cheezy", "h"));
- printf("%d\n", !!strstr("cheezy", "i"));
- printf("%d\n", !!strstr("cheezy", "e"));
- printf("%d\n", !!strstr("cheezy", "x"));
- printf("%d\n", !!strstr("cheezy", "y"));
- printf("%d\n", !!strstr("cheezy", "z"));
- printf("%d\n", !!strstr("cheezy", "_"));
-
- const char *str = "a big string";
- printf("%d\n", strstr(str, "big") - str);
- return 0;
- }
- '''
- self.do_run(src, '''1
-1
-1
-1
-0
-1
-1
-0
-1
-1
-0
-0
-0
-1
-0
-0
-1
-0
-1
-0
-1
-1
-0
-2
-''')
+ self.do_run_from_file(src, output)
def test_sscanf(self):
if self.emcc_args is None: return self.skip('needs emcc for libc')
- src = r'''
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- int main () {
- #define CHECK(str) \
- { \
- char name[1000]; \
- memset(name, 0, 1000); \
- int prio = 99; \
- sscanf(str, "%s %d", name, &prio); \
- printf("%s : %d\n", name, prio); \
- }
- CHECK("en-us 2");
- CHECK("en-r");
- CHECK("en 3");
-
- printf("%f, %f\n", atof("1.234567"), atof("cheez"));
-
- char float_formats[] = "fegE";
- char format[] = "%_";
- for(int i = 0; i < 4; ++i) {
- format[1] = float_formats[i];
-
- float n = -1;
- sscanf(" 2.8208", format, &n);
- printf("%.4f\n", n);
-
- float a = -1;
- sscanf("-3.03", format, &a);
- printf("%.4f\n", a);
- }
-
- char buffy[100];
- sscanf("cheez some thing moar 123\nyet more\n", "cheez %s", buffy);
- printf("|%s|\n", buffy);
- sscanf("cheez something\nmoar 123\nyet more\n", "cheez %s", buffy);
- printf("|%s|\n", buffy);
- sscanf("cheez somethingmoar\tyet more\n", "cheez %s", buffy);
- printf("|%s|\n", buffy);
-
- int numverts = -1;
- printf("%d\n", sscanf(" numverts 1499\n", " numverts %d", &numverts)); // white space is the same, even if tab vs space
- printf("%d\n", numverts);
-
- int index;
- float u, v;
- short start, count;
- printf("%d\n", sscanf(" vert 87 ( 0.481565 0.059481 ) 0 1\n", " vert %d ( %f %f ) %hu %hu", &index, &u, &v, &start, &count));
- printf("%d,%.6f,%.6f,%hu,%hu\n", index, u, v, start, count);
-
- int neg, neg2, neg3 = 0;
- printf("%d\n", sscanf("-123 -765 -34-6", "%d %u %d", &neg, &neg2, &neg3));
- printf("%d,%u,%d\n", neg, neg2, neg3);
-
- {
- int a = 0;
- sscanf("1", "%i", &a);
- printf("%i\n", a);
- }
-
- char buf1[100], buf2[100], buf3[100], buf4[100];
-
- int numItems = sscanf("level=4:ref=3", "%255[^:=]=%255[^:]:%255[^=]=%255c", buf1, buf2, buf3, buf4);
- printf("%d, %s, %s, %s, %s\n", numItems, buf1, buf2, buf3, buf4);
-
- numItems = sscanf("def|456", "%[a-z]|%[0-9]", buf1, buf2);
- printf("%d, %s, %s\n", numItems, buf1, buf2);
+ test_path = path_from_root('tests', 'core', 'test_sscanf')
+ src, output = (test_path + s for s in ('.in', '.out'))
- numItems = sscanf("3-4,-ab", "%[-0-9],%[ab-z-]", buf1, buf2);
- printf("%d, %s, %s\n", numItems, buf1, buf2);
-
- numItems = sscanf("Hello,World", "%[A-Za-z],%[^0-9]", buf1, buf2);
- printf("%d, %s, %s\n", numItems, buf1, buf2);
-
- numItems = sscanf("Hello4711", "%[^0-9],%[^0-9]", buf1, buf2);
- printf("%d, %s\n", numItems, buf1);
-
- numItems = sscanf("JavaScript", "%4[A-Za-z]", buf1);
- printf("%d, %s\n", numItems, buf1);
-
- numItems = sscanf("[]", "%1[[]%1[]]", buf1, buf2);
- printf("%d, %s, %s\n", numItems, buf1, buf2);
-
- return 0;
- }
- '''
- self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n2.8208\n-3.0300\n2.8208\n-3.0300\n2.8208\n-3.0300\n2.8208\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' +
- '1\n1499\n' +
- '5\n87,0.481565,0.059481,0,1\n' +
- '3\n-123,4294966531,-34\n' +
- '1\n' +
- '4, level, 4, ref, 3\n' +
- '2, def, 456\n' +
- '2, 3-4, -ab\n' +
- '2, Hello, World\n' +
- '1, Hello\n' +
- '1, Java\n' +
- '2, [, ]')
+ self.do_run_from_file(src, output)
def test_sscanf_2(self):
# doubles
@@ -7201,226 +3750,77 @@ Pass: 0.000012 0.000012
Pass: 0.000012 0.000012''')
def test_sscanf_n(self):
- src = r'''
- #include<stdio.h>
- int main() {
- char *line = "version 1.0";
- int i, l, lineno;
- char word[80];
- if (sscanf(line, "%s%n", word, &l) != 1) {
- printf("Header format error, line %d\n", lineno);
- }
- printf("[DEBUG] word 1: %s, l: %d\n", word, l);
+ test_path = path_from_root('tests', 'core', 'test_sscanf_n')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int x = sscanf("one %n two", "%s %n", word, &l);
- printf("%d,%s,%d\n", x, word, l);
- {
- int a, b, c, count;
- count = sscanf("12345 6789", "%d %n%d", &a, &b, &c);
- printf("%i %i %i %i\n", count, a, b, c);
- }
- return 0;
- }
- '''
- self.do_run(src, '''[DEBUG] word 1: version, l: 7\n1,one,4\n2 12345 6 6789\n''')
+ self.do_run_from_file(src, output)
def test_sscanf_whitespace(self):
- src = r'''
- #include<stdio.h>
-
- int main() {
- short int x;
- short int y;
-
- const char* buffer[] = {
- "173,16",
- " 16,173",
- "183, 173",
- " 17, 287",
- " 98, 123, "
- };
+ test_path = path_from_root('tests', 'core', 'test_sscanf_whitespace')
+ src, output = (test_path + s for s in ('.in', '.out'))
- for (int i=0; i<5; ++i) {
- sscanf(buffer[i], "%hd,%hd", &x, &y);
- printf("%d:%d,%d ", i, x, y);
- }
-
- return 0;
- }
- '''
- self.do_run(src, '''0:173,16 1:16,173 2:183,173 3:17,287 4:98,123''')
+ self.do_run_from_file(src, output)
def test_sscanf_other_whitespace(self):
Settings.SAFE_HEAP = 0 # use i16s in printf
- src = r'''
- #include<stdio.h>
-
- int main() {
- short int x;
- short int y;
-
- const char* buffer[] = {
- "\t2\t3\t", /* TAB - horizontal tab */
- "\t\t5\t\t7\t\t",
- "\n11\n13\n", /* LF - line feed */
- "\n\n17\n\n19\n\n",
- "\v23\v29\v", /* VT - vertical tab */
- "\v\v31\v\v37\v\v",
- "\f41\f43\f", /* FF - form feed */
- "\f\f47\f\f53\f\f",
- "\r59\r61\r", /* CR - carrage return */
- "\r\r67\r\r71\r\r"
- };
-
- for (int i=0; i<10; ++i) {
- x = 0; y = 0;
- sscanf(buffer[i], " %d %d ", &x, &y);
- printf("%d, %d, ", x, y);
- }
+ test_path = path_from_root('tests', 'core', 'test_sscanf_other_whitespace')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '''2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, ''')
+ self.do_run_from_file(src, output)
def test_sscanf_3(self):
# i64
if not Settings.USE_TYPED_ARRAYS == 2: return self.skip('64-bit sscanf only supported in ta2')
- src = r'''
- #include <stdint.h>
- #include <stdio.h>
- int main(){
+ test_path = path_from_root('tests', 'core', 'test_sscanf_3')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int64_t s, m, l;
- printf("%d\n", sscanf("123 1073741823 1125899906842620", "%lld %lld %lld", &s, &m, &l));
- printf("%lld,%lld,%lld\n", s, m, l);
-
- int64_t negS, negM, negL;
- printf("%d\n", sscanf("-123 -1073741823 -1125899906842620", "%lld %lld %lld", &negS, &negM, &negL));
- printf("%lld,%lld,%lld\n", negS, negM, negL);
-
- return 0;
- }
- '''
-
- self.do_run(src, '3\n123,1073741823,1125899906842620\n' +
- '3\n-123,-1073741823,-1125899906842620\n')
+ self.do_run_from_file(src, output)
def test_sscanf_4(self):
- src = r'''
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_sscanf_4')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- char pYear[16], pMonth[16], pDay[16], pDate[64];
- printf("%d\n", sscanf("Nov 19 2012", "%s%s%s", pMonth, pDay, pYear));
- printf("day %s, month %s, year %s \n", pDay, pMonth, pYear);
- return(0);
- }
- '''
- self.do_run(src, '3\nday 19, month Nov, year 2012');
+ self.do_run_from_file(src, output)
def test_sscanf_5(self):
- src = r'''
- #include "stdio.h"
+ test_path = path_from_root('tests', 'core', 'test_sscanf_5')
+ src, output = (test_path + s for s in ('.in', '.out'))
- static const char *colors[] = {
- " c black",
- ". c #001100",
- "X c #111100"
- };
-
- int main(){
- unsigned char code;
- char color[32];
- int rcode;
- for(int i = 0; i < 3; i++) {
- rcode = sscanf(colors[i], "%c c %s", &code, color);
- printf("%i, %c, %s\n", rcode, code, color);
- }
- }
- '''
- self.do_run(src, '2, , black\n2, ., #001100\n2, X, #111100');
+ self.do_run_from_file(src, output)
def test_sscanf_6(self):
- src = r'''
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char *date = "18.07.2013w";
- char c[10];
- memset(c, 0, 10);
- int y, m, d, i;
- i = sscanf(date, "%d.%d.%4d%c", &d, &m, &y, c);
- printf("date: %s; day %2d, month %2d, year %4d, extra: %c, %d\n", date, d, m, y, c[0], i);
- i = sscanf(date, "%d.%d.%3c", &d, &m, c);
- printf("date: %s; day %2d, month %2d, year %4d, extra: %s, %d\n", date, d, m, y, c, i);
- }
- '''
- self.do_run(src, '''date: 18.07.2013w; day 18, month 7, year 2013, extra: w, 4
-date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3
-''');
+ test_path = path_from_root('tests', 'core', 'test_sscanf_6')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_sscanf_skip(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip("need ta2 for full i64")
- src = r'''
- #include <stdint.h>
- #include <stdio.h>
+ test_path = path_from_root('tests', 'core', 'test_sscanf_skip')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(){
- int val1;
- printf("%d\n", sscanf("10 20 30 40", "%*lld %*d %d", &val1));
- printf("%d\n", val1);
-
- int64_t large, val2;
- printf("%d\n", sscanf("1000000 -1125899906842620 -123 -1073741823", "%lld %*lld %ld %*d", &large, &val2));
- printf("%lld,%d\n", large, val2);
-
- return 0;
- }
- '''
- self.do_run(src, '1\n30\n2\n1000000,-123\n')
+ self.do_run_from_file(src, output)
def test_sscanf_caps(self):
- src = r'''
- #include "stdio.h"
+ test_path = path_from_root('tests', 'core', 'test_sscanf_caps')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(){
- unsigned int a;
- float e, f, g;
- sscanf("a 1.1 1.1 1.1", "%X %E %F %G", &a, &e, &f, &g);
- printf("%d %.1F %.1F %.1F\n", a, e, f, g);
- }
- '''
- self.do_run(src, '10 1.1 1.1 1.1');
+ self.do_run_from_file(src, output)
def test_sscanf_hex(self):
- src = r'''
- #include "stdio.h"
+ test_path = path_from_root('tests', 'core', 'test_sscanf_hex')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(){
- unsigned int a, b;
- sscanf("0x12AB 12AB", "%x %x", &a, &b);
- printf("%d %d\n", a, b);
- }
- '''
- self.do_run(src, '4779 4779')
+ self.do_run_from_file(src, output)
def test_sscanf_float(self):
- src = r'''
- #include "stdio.h"
+ test_path = path_from_root('tests', 'core', 'test_sscanf_float')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(){
- float f1, f2, f3, f4, f5, f6, f7, f8, f9;
- sscanf("0.512 0.250x5.129_-9.98 1.12*+54.32E3 +54.32E3^87.5E-3 87.5E-3$", "%f %fx%f_%f %f*%f %f^%f %f$", &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8, &f9);
- printf("\n%f, %f, %f, %f, %f, %f, %f, %f, %f\n", f1, f2, f3, f4, f5, f6, f7, f8, f9);
- }
- '''
- self.do_run(src, '\n0.512000, 0.250000, 5.129000, -9.980000, 1.120000, 54320.000000, 54320.000000, 0.087500, 0.087500\n')
+ self.do_run_from_file(src, output)
def test_langinfo(self):
src = open(path_from_root('tests', 'langinfo', 'test.c'), 'r').read()
@@ -7499,28 +3899,10 @@ def process(filename):
self.do_run(src, ('got: 35\ngot: 45\ngot: 25\ngot: 15\nisatty? 0,0,1\n', 'isatty? 0,0,1\ngot: 35\ngot: 45\ngot: 25\ngot: 15\n'), post_build=post)
def test_fwrite_0(self):
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_fwrite_0')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main ()
- {
- FILE *fh;
-
- fh = fopen("a.txt", "wb");
- if (!fh) exit(1);
- fclose(fh);
-
- fh = fopen("a.txt", "rb");
- if (!fh) exit(1);
-
- char data[] = "foobar";
- size_t written = fwrite(data, 1, sizeof(data), fh);
-
- printf("written=%zu\n", written);
- }
- '''
- self.do_run(src, 'written=0')
+ self.do_run_from_file(src, output)
def test_fgetc_ungetc(self):
src = open(path_from_root('tests', 'stdio', 'test_fgetc_ungetc.c'), 'r').read()
@@ -7651,145 +4033,22 @@ def process(filename):
)
open(filename, 'w').write(src)
'''
- src = r'''
- #include <stdio.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <poll.h>
-
- int main() {
- struct pollfd multi[5];
- multi[0].fd = open("/file", O_RDONLY, 0777);
- multi[1].fd = open("/device", O_RDONLY, 0777);
- multi[2].fd = 123;
- multi[3].fd = open("/file", O_RDONLY, 0777);
- multi[4].fd = open("/file", O_RDONLY, 0777);
- multi[0].events = POLLIN | POLLOUT | POLLNVAL | POLLERR;
- multi[1].events = POLLIN | POLLOUT | POLLNVAL | POLLERR;
- multi[2].events = POLLIN | POLLOUT | POLLNVAL | POLLERR;
- multi[3].events = 0x00;
- multi[4].events = POLLOUT | POLLNVAL | POLLERR;
-
- printf("ret: %d\n", poll(multi, 5, 123));
- printf("errno: %d\n", errno);
- printf("multi[0].revents: %d\n", multi[0].revents == (POLLIN | POLLOUT));
- printf("multi[1].revents: %d\n", multi[1].revents == (POLLIN | POLLOUT));
- printf("multi[2].revents: %d\n", multi[2].revents == POLLNVAL);
- printf("multi[3].revents: %d\n", multi[3].revents == 0);
- printf("multi[4].revents: %d\n", multi[4].revents == POLLOUT);
+ test_path = path_from_root('tests', 'core', 'test_poll')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- expected = r'''
- ret: 4
- errno: 0
- multi[0].revents: 1
- multi[1].revents: 1
- multi[2].revents: 1
- multi[3].revents: 1
- multi[4].revents: 1
- '''
- self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run, extra_emscripten_args=['-H', 'libc/fcntl.h,poll.h'])
+ self.do_run_from_file(src, output, post_build=add_pre_run, extra_emscripten_args=['-H', 'libc/fcntl.h,poll.h'])
def test_statvfs(self):
- src = r'''
- #include <stdio.h>
- #include <errno.h>
- #include <sys/statvfs.h>
-
- int main() {
- struct statvfs s;
-
- printf("result: %d\n", statvfs("/test", &s));
- printf("errno: %d\n", errno);
-
- printf("f_bsize: %lu\n", s.f_bsize);
- printf("f_frsize: %lu\n", s.f_frsize);
- printf("f_blocks: %lu\n", s.f_blocks);
- printf("f_bfree: %lu\n", s.f_bfree);
- printf("f_bavail: %lu\n", s.f_bavail);
- printf("f_files: %d\n", s.f_files > 5);
- printf("f_ffree: %lu\n", s.f_ffree);
- printf("f_favail: %lu\n", s.f_favail);
- printf("f_fsid: %lu\n", s.f_fsid);
- printf("f_flag: %lu\n", s.f_flag);
- printf("f_namemax: %lu\n", s.f_namemax);
+ test_path = path_from_root('tests', 'core', 'test_statvfs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- expected = r'''
- result: 0
- errno: 0
- f_bsize: 4096
- f_frsize: 4096
- f_blocks: 1000000
- f_bfree: 500000
- f_bavail: 500000
- f_files: 1
- f_ffree: 1000000
- f_favail: 1000000
- f_fsid: 42
- f_flag: 2
- f_namemax: 255
- '''
- self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
+ self.do_run_from_file(src, output)
def test_libgen(self):
- src = r'''
- #include <stdio.h>
- #include <libgen.h>
-
- int main() {
- char p1[16] = "/usr/lib", p1x[16] = "/usr/lib";
- printf("%s -> ", p1);
- printf("%s : %s\n", dirname(p1x), basename(p1));
-
- char p2[16] = "/usr", p2x[16] = "/usr";
- printf("%s -> ", p2);
- printf("%s : %s\n", dirname(p2x), basename(p2));
-
- char p3[16] = "/usr/", p3x[16] = "/usr/";
- printf("%s -> ", p3);
- printf("%s : %s\n", dirname(p3x), basename(p3));
-
- char p4[16] = "/usr/lib///", p4x[16] = "/usr/lib///";
- printf("%s -> ", p4);
- printf("%s : %s\n", dirname(p4x), basename(p4));
+ test_path = path_from_root('tests', 'core', 'test_libgen')
+ src, output = (test_path + s for s in ('.in', '.out'))
- char p5[16] = "/", p5x[16] = "/";
- printf("%s -> ", p5);
- printf("%s : %s\n", dirname(p5x), basename(p5));
-
- char p6[16] = "///", p6x[16] = "///";
- printf("%s -> ", p6);
- printf("%s : %s\n", dirname(p6x), basename(p6));
-
- char p7[16] = "/usr/../lib/..", p7x[16] = "/usr/../lib/..";
- printf("%s -> ", p7);
- printf("%s : %s\n", dirname(p7x), basename(p7));
-
- char p8[16] = "", p8x[16] = "";
- printf("(empty) -> %s : %s\n", dirname(p8x), basename(p8));
-
- printf("(null) -> %s : %s\n", dirname(0), basename(0));
-
- return 0;
- }
- '''
- expected = '''
- /usr/lib -> /usr : lib
- /usr -> / : usr
- /usr/ -> / : usr
- /usr/lib/// -> /usr : lib
- / -> / : /
- /// -> / : /
- /usr/../lib/.. -> /usr/../lib : ..
- (empty) -> . : .
- (null) -> . : .
- '''
- self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
+ self.do_run_from_file(src, output)
def test_utime(self):
src = open(path_from_root('tests', 'utime', 'test_utime.c'), 'r').read()
@@ -7799,98 +4058,45 @@ def process(filename):
self.banned_js_engines = [SPIDERMONKEY_ENGINE] # only node handles utf well
Settings.EXPORTED_FUNCTIONS = ['_main', '_malloc']
- src = r'''
- #include <stdio.h>
- #include <emscripten.h>
+ test_path = path_from_root('tests', 'core', 'test_utf')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- char *c = "μ†ℱ ╋ℯ╳╋ 😇";
- printf("%d %d %d %d %s\n", c[0]&0xff, c[1]&0xff, c[2]&0xff, c[3]&0xff, c);
- emscripten_run_script(
- "cheez = _malloc(100);"
- "Module.writeStringToMemory(\"μ†ℱ ╋ℯ╳╋ 😇\", cheez);"
- "Module.print([Pointer_stringify(cheez), Module.getValue(cheez, 'i8')&0xff, Module.getValue(cheez+1, 'i8')&0xff, Module.getValue(cheez+2, 'i8')&0xff, Module.getValue(cheez+3, 'i8')&0xff, ]);");
- }
- '''
- self.do_run(src, '206 188 226 128 μ†ℱ ╋ℯ╳╋ 😇\nμ†ℱ ╋ℯ╳╋ 😇,206,188,226,128\n');
+ self.do_run_from_file(src, output)
def test_utf32(self):
if self.emcc_args is None: return self.skip('need libc for wcslen()')
if not self.is_le32(): return self.skip('this test uses inline js, which requires le32')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
self.do_run(open(path_from_root('tests', 'utf32.cpp')).read(), 'OK.')
self.do_run(open(path_from_root('tests', 'utf32.cpp')).read(), 'OK.', args=['-fshort-wchar'])
def test_direct_string_constant_usage(self):
if self.emcc_args is None: return self.skip('requires libcxx')
- src = '''
- #include <iostream>
- template<int i>
- void printText( const char (&text)[ i ] )
- {
- std::cout << text;
- }
- int main()
- {
- printText( "some string constant" );
- return 0;
- }
- '''
- self.do_run(src, "some string constant")
+ test_path = path_from_root('tests', 'core', 'test_direct_string_constant_usage')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_std_cout_new(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <iostream>
-
- struct NodeInfo { //structure that we want to transmit to our shaders
- float x;
- float y;
- float s;
- float c;
- };
- const int nbNodes = 100;
- NodeInfo * data = new NodeInfo[nbNodes]; //our data that will be transmitted using float texture.
-
- template<int i>
- void printText( const char (&text)[ i ] )
- {
- std::cout << text << std::endl;
- }
-
- int main()
- {
- printText( "some string constant" );
- return 0;
- }
- '''
+ test_path = path_from_root('tests', 'core', 'test_std_cout_new')
+ src, output = (test_path + s for s in ('.in', '.out'))
- self.do_run(src, "some string constant")
+ self.do_run_from_file(src, output)
def test_istream(self):
if self.emcc_args is None: return self.skip('requires libcxx')
- src = '''
- #include <string>
- #include <sstream>
- #include <iostream>
+ test_path = path_from_root('tests', 'core', 'test_istream')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- std::string mystring("1 2 3");
- std::istringstream is(mystring);
- int one, two, three;
-
- is >> one >> two >> three;
-
- printf( "%i %i %i", one, two, three );
- }
- '''
for linkable in [0]:#, 1]:
print linkable
Settings.LINKABLE = linkable # regression check for issue #273
- self.do_run(src, "1 2 3")
+ self.do_run_from_file(src, output)
def test_fs_base(self):
Settings.INCLUDE_FULL_LIBRARY = 1
@@ -8032,31 +4238,10 @@ def process(filename):
self.do_run(src, expected, js_engines=[NODE_JS])
def test_uname(self):
- src = r'''
- #include <stdio.h>
- #include <sys/utsname.h>
+ test_path = path_from_root('tests', 'core', 'test_uname')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- struct utsname u;
- printf("ret: %d\n", uname(&u));
- printf("sysname: %s\n", u.sysname);
- printf("nodename: %s\n", u.nodename);
- printf("release: %s\n", u.release);
- printf("version: %s\n", u.version);
- printf("machine: %s\n", u.machine);
- printf("invalid: %d\n", uname(0));
- return 0;
- }
- '''
- expected = '''
- ret: 0
- sysname: Emscripten
- nodename: emscripten
- release: 1.0
- version: #1
- machine: x86-JS
- '''
- self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
+ self.do_run_from_file(src, output)
def test_env(self):
src = open(path_from_root('tests', 'env', 'src.c'), 'r').read()
@@ -8069,30 +4254,10 @@ def process(filename):
self.do_run(src, expected)
def test_getloadavg(self):
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_getloadavg')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- double load[5] = {42.13, 42.13, 42.13, 42.13, 42.13};
- printf("ret: %d\n", getloadavg(load, 5));
- printf("load[0]: %.3lf\n", load[0]);
- printf("load[1]: %.3lf\n", load[1]);
- printf("load[2]: %.3lf\n", load[2]);
- printf("load[3]: %.3lf\n", load[3]);
- printf("load[4]: %.3lf\n", load[4]);
- return 0;
- }
- '''
- expected = '''
- ret: 3
- load[0]: 0.100
- load[1]: 0.100
- load[2]: 0.100
- load[3]: 42.130
- load[4]: 42.130
- '''
- self.do_run(src, re.sub('(^|\n)\s+', '\\1', expected))
+ self.do_run_from_file(src, output)
def test_799(self):
src = open(path_from_root('tests', '799.cpp'), 'r').read()
@@ -8109,149 +4274,22 @@ PORT: 3979
self.do_run(src, expected)
def test_strcasecmp(self):
- src = r'''
- #include <stdio.h>
- #include <strings.h>
- int sign(int x) {
- if (x < 0) return -1;
- if (x > 0) return 1;
- return 0;
- }
- int main() {
- printf("*\n");
-
- printf("%d\n", sign(strcasecmp("hello", "hello")));
- printf("%d\n", sign(strcasecmp("hello1", "hello")));
- printf("%d\n", sign(strcasecmp("hello", "hello1")));
- printf("%d\n", sign(strcasecmp("hello1", "hello1")));
- printf("%d\n", sign(strcasecmp("iello", "hello")));
- printf("%d\n", sign(strcasecmp("hello", "iello")));
- printf("%d\n", sign(strcasecmp("A", "hello")));
- printf("%d\n", sign(strcasecmp("Z", "hello")));
- printf("%d\n", sign(strcasecmp("a", "hello")));
- printf("%d\n", sign(strcasecmp("z", "hello")));
- printf("%d\n", sign(strcasecmp("hello", "a")));
- printf("%d\n", sign(strcasecmp("hello", "z")));
-
- printf("%d\n", sign(strcasecmp("Hello", "hello")));
- printf("%d\n", sign(strcasecmp("Hello1", "hello")));
- printf("%d\n", sign(strcasecmp("Hello", "hello1")));
- printf("%d\n", sign(strcasecmp("Hello1", "hello1")));
- printf("%d\n", sign(strcasecmp("Iello", "hello")));
- printf("%d\n", sign(strcasecmp("Hello", "iello")));
- printf("%d\n", sign(strcasecmp("A", "hello")));
- printf("%d\n", sign(strcasecmp("Z", "hello")));
- printf("%d\n", sign(strcasecmp("a", "hello")));
- printf("%d\n", sign(strcasecmp("z", "hello")));
- printf("%d\n", sign(strcasecmp("Hello", "a")));
- printf("%d\n", sign(strcasecmp("Hello", "z")));
-
- printf("%d\n", sign(strcasecmp("hello", "Hello")));
- printf("%d\n", sign(strcasecmp("hello1", "Hello")));
- printf("%d\n", sign(strcasecmp("hello", "Hello1")));
- printf("%d\n", sign(strcasecmp("hello1", "Hello1")));
- printf("%d\n", sign(strcasecmp("iello", "Hello")));
- printf("%d\n", sign(strcasecmp("hello", "Iello")));
- printf("%d\n", sign(strcasecmp("A", "Hello")));
- printf("%d\n", sign(strcasecmp("Z", "Hello")));
- printf("%d\n", sign(strcasecmp("a", "Hello")));
- printf("%d\n", sign(strcasecmp("z", "Hello")));
- printf("%d\n", sign(strcasecmp("hello", "a")));
- printf("%d\n", sign(strcasecmp("hello", "z")));
-
- printf("%d\n", sign(strcasecmp("Hello", "Hello")));
- printf("%d\n", sign(strcasecmp("Hello1", "Hello")));
- printf("%d\n", sign(strcasecmp("Hello", "Hello1")));
- printf("%d\n", sign(strcasecmp("Hello1", "Hello1")));
- printf("%d\n", sign(strcasecmp("Iello", "Hello")));
- printf("%d\n", sign(strcasecmp("Hello", "Iello")));
- printf("%d\n", sign(strcasecmp("A", "Hello")));
- printf("%d\n", sign(strcasecmp("Z", "Hello")));
- printf("%d\n", sign(strcasecmp("a", "Hello")));
- printf("%d\n", sign(strcasecmp("z", "Hello")));
- printf("%d\n", sign(strcasecmp("Hello", "a")));
- printf("%d\n", sign(strcasecmp("Hello", "z")));
-
- printf("%d\n", sign(strncasecmp("hello", "hello", 3)));
- printf("%d\n", sign(strncasecmp("hello1", "hello", 3)));
- printf("%d\n", sign(strncasecmp("hello", "hello1", 3)));
- printf("%d\n", sign(strncasecmp("hello1", "hello1", 3)));
- printf("%d\n", sign(strncasecmp("iello", "hello", 3)));
- printf("%d\n", sign(strncasecmp("hello", "iello", 3)));
- printf("%d\n", sign(strncasecmp("A", "hello", 3)));
- printf("%d\n", sign(strncasecmp("Z", "hello", 3)));
- printf("%d\n", sign(strncasecmp("a", "hello", 3)));
- printf("%d\n", sign(strncasecmp("z", "hello", 3)));
- printf("%d\n", sign(strncasecmp("hello", "a", 3)));
- printf("%d\n", sign(strncasecmp("hello", "z", 3)));
-
- printf("*\n");
+ test_path = path_from_root('tests', 'core', 'test_strcasecmp')
+ src, output = (test_path + s for s in ('.in', '.out'))
- return 0;
- }
- '''
- self.do_run(src, '''*\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n0\n0\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n*\n''')
+ self.do_run_from_file(src, output)
def test_atomic(self):
- src = '''
- #include <stdio.h>
- int main() {
- int x = 10;
- int y = __sync_add_and_fetch(&x, 5);
- printf("*%d,%d*\\n", x, y);
- x = 10;
- y = __sync_fetch_and_add(&x, 5);
- printf("*%d,%d*\\n", x, y);
- x = 10;
- y = __sync_lock_test_and_set(&x, 6);
- printf("*%d,%d*\\n", x, y);
- x = 10;
- y = __sync_bool_compare_and_swap(&x, 9, 7);
- printf("*%d,%d*\\n", x, y);
- y = __sync_bool_compare_and_swap(&x, 10, 7);
- printf("*%d,%d*\\n", x, y);
- return 0;
- }
- '''
+ test_path = path_from_root('tests', 'core', 'test_atomic')
+ src, output = (test_path + s for s in ('.in', '.out'))
- self.do_run(src, '*15,15*\n*15,10*\n*6,10*\n*10,0*\n*7,1*')
+ self.do_run_from_file(src, output)
def test_phiundef(self):
- src = r'''
-#include <stdlib.h>
-#include <stdio.h>
-
-static int state;
-
-struct my_struct {
-union {
- struct {
- unsigned char a;
- unsigned char b;
- } c;
- unsigned int d;
-} e;
-unsigned int f;
-};
-
-int main(int argc, char **argv) {
- struct my_struct r;
-
- state = 0;
-
- for (int i=0;i<argc+10;i++)
- {
- if (state % 2 == 0)
- r.e.c.a = 3;
- else
- printf("%d\n", r.e.c.a);
- state++;
- }
- return 0;
-}
- '''
+ test_path = path_from_root('tests', 'core', 'test_phiundef')
+ src, output = (test_path + s for s in ('.in', '.out'))
- self.do_run(src, '3\n3\n3\n3\n3\n')
+ self.do_run_from_file(src, output)
# libc++ tests
@@ -8274,86 +4312,19 @@ int main(int argc, char **argv) {
def test_stdvec(self):
if self.emcc_args is None: return self.skip('requires emcc')
- src = '''
- #include <vector>
- #include <stdio.h>
-
- struct S {
- int a;
- float b;
- };
- void foo(int a, float b)
- {
- printf("%d:%.2f\\n", a, b);
- }
+ test_path = path_from_root('tests', 'core', 'test_stdvec')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main ( int argc, char *argv[] )
- {
- std::vector<S> ar;
- S s;
-
- s.a = 789;
- s.b = 123.456f;
- ar.push_back(s);
-
- s.a = 0;
- s.b = 100.1f;
- ar.push_back(s);
-
- foo(ar[0].a, ar[0].b);
- foo(ar[1].a, ar[1].b);
- }
- '''
-
- self.do_run(src, '789:123.46\n0:100.1')
+ self.do_run_from_file(src, output)
def test_reinterpreted_ptrs(self):
if self.emcc_args is None: return self.skip('needs emcc and libc')
- src = r'''
-#include <stdio.h>
-
-class Foo {
-private:
- float bar;
-public:
- int baz;
-
- Foo(): bar(0), baz(4711) {};
-
- int getBar() const;
-};
-
-int Foo::getBar() const {
- return this->bar;
-};
-
-const Foo *magic1 = reinterpret_cast<Foo*>(0xDEAD111F);
-const Foo *magic2 = reinterpret_cast<Foo*>(0xDEAD888F);
-
-static void runTest() {
-
- const Foo *a = new Foo();
- const Foo *b = a;
-
- if (a->getBar() == 0) {
- if (a->baz == 4712)
- b = magic1;
- else
- b = magic2;
- }
+ test_path = path_from_root('tests', 'core', 'test_reinterpreted_ptrs')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("%s\n", (b == magic1 ? "magic1" : (b == magic2 ? "magic2" : "neither")));
-};
-
-extern "C" {
- int main(int argc, char **argv) {
- runTest();
- }
-}
-'''
- self.do_run(src, 'magic2')
+ self.do_run_from_file(src, output)
def test_jansson(self):
return self.skip('currently broken')
@@ -8522,22 +4493,11 @@ return malloc(size);
def test_dlmalloc_partial_2(self):
if self.emcc_args is None or 'SAFE_HEAP' in str(self.emcc_args) or 'CHECK_HEAP_ALIGN' in str(self.emcc_args): return self.skip('only emcc will link in dlmalloc, and we do unsafe stuff')
# present part of the symbols of dlmalloc, not all. malloc is harder to link than new which is weak.
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
- void *malloc(size_t size)
- {
- return (void*)123;
- }
- int main() {
- void *x = malloc(10);
- printf("got %p\n", x);
- free(x);
- printf("freed the faker\n");
- return 1;
- }
-'''
- self.do_run(src, 'got 0x7b\nfreed')
+
+ test_path = path_from_root('tests', 'core', 'test_dlmalloc_partial_2')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_libcxx(self):
if self.emcc_args is None: return self.skip('requires emcc')
@@ -8556,171 +4516,35 @@ return malloc(size);
''', 'hello world');
def test_typeid(self):
- self.do_run(r'''
- #include <stdio.h>
- #include <string.h>
- #include <typeinfo>
- int main() {
- printf("*\n");
- #define MAX 100
- int ptrs[MAX];
- int groups[MAX];
- memset(ptrs, 0, MAX*sizeof(int));
- memset(groups, 0, MAX*sizeof(int));
- int next_group = 1;
- #define TEST(X) { \
- int ptr = (int)&typeid(X); \
- int group = 0; \
- int i; \
- for (i = 0; i < MAX; i++) { \
- if (!groups[i]) break; \
- if (ptrs[i] == ptr) { \
- group = groups[i]; \
- break; \
- } \
- } \
- if (!group) { \
- groups[i] = group = next_group++; \
- ptrs[i] = ptr; \
- } \
- printf("%s:%d\n", #X, group); \
- }
- TEST(int);
- TEST(unsigned int);
- TEST(unsigned);
- TEST(signed int);
- TEST(long);
- TEST(unsigned long);
- TEST(signed long);
- TEST(long long);
- TEST(unsigned long long);
- TEST(signed long long);
- TEST(short);
- TEST(unsigned short);
- TEST(signed short);
- TEST(char);
- TEST(unsigned char);
- TEST(signed char);
- TEST(float);
- TEST(double);
- TEST(long double);
- TEST(void);
- TEST(void*);
- printf("*\n");
- }
- ''', '''*
-int:1
-unsigned int:2
-unsigned:2
-signed int:1
-long:3
-unsigned long:4
-signed long:3
-long long:5
-unsigned long long:6
-signed long long:5
-short:7
-unsigned short:8
-signed short:7
-char:9
-unsigned char:10
-signed char:11
-float:12
-double:13
-long double:14
-void:15
-void*:16
-*
-''');
+ test_path = path_from_root('tests', 'core', 'test_typeid')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_static_variable(self):
if self.emcc_args is None: Settings.SAFE_HEAP = 0 # LLVM mixes i64 and i8 in the guard check
- src = '''
- #include <stdio.h>
- struct DATA
- {
- int value;
-
- DATA()
- {
- value = 0;
- }
- };
+ test_path = path_from_root('tests', 'core', 'test_static_variable')
+ src, output = (test_path + s for s in ('.in', '.out'))
- DATA & GetData()
- {
- static DATA data;
-
- return data;
- }
-
- int main()
- {
- GetData().value = 10;
- printf( "value:%i", GetData().value );
- }
- '''
- self.do_run(src, 'value:10')
+ self.do_run_from_file(src, output)
def test_fakestat(self):
- src = r'''
- #include <stdio.h>
- struct stat { int x, y; };
- int main() {
- stat s;
- s.x = 10;
- s.y = 22;
- printf("*%d,%d*\n", s.x, s.y);
- }
- '''
- self.do_run(src, '*10,22*')
+ test_path = path_from_root('tests', 'core', 'test_fakestat')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_mmap(self):
if self.emcc_args is None: return self.skip('requires emcc')
Settings.TOTAL_MEMORY = 128*1024*1024
- src = '''
- #include <stdio.h>
- #include <sys/mman.h>
- #include <assert.h>
-
- int main(int argc, char *argv[]) {
- for (int i = 0; i < 10; i++) {
- int* map = (int*)mmap(0, 5000, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANON, -1, 0);
- /* TODO: Should we align to 4k?
- assert(((int)map) % 4096 == 0); // aligned
- */
- assert(munmap(map, 5000) == 0);
- }
-
- const int NUM_BYTES = 8 * 1024 * 1024;
- const int NUM_INTS = NUM_BYTES / sizeof(int);
-
- int* map = (int*)mmap(0, NUM_BYTES, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANON, -1, 0);
- assert(map != MAP_FAILED);
-
- int i;
-
- for (i = 0; i < NUM_INTS; i++) {
- map[i] = i;
- }
-
- for (i = 0; i < NUM_INTS; i++) {
- assert(map[i] == i);
- }
-
- assert(munmap(map, NUM_BYTES) == 0);
+ test_path = path_from_root('tests', 'core', 'test_mmap')
+ src, output = (test_path + s for s in ('.in', '.out'))
- printf("hello,world");
- return 0;
- }
- '''
- self.do_run(src, 'hello,world')
- self.do_run(src, 'hello,world', force_c=True)
+ self.do_run_from_file(src, output)
+ self.do_run_from_file(src, output, force_c=True)
def test_mmap_file(self):
if self.emcc_args is None: return self.skip('requires emcc')
@@ -8778,605 +4602,34 @@ void*:16
def test_simd(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2')
if Settings.ASM_JS: Settings.ASM_JS = 2 # does not validate
- src = r'''
-#include <stdio.h>
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
-#include <emscripten/vector.h>
+ test_path = path_from_root('tests', 'core', 'test_simd')
+ src, output = (test_path + s for s in ('.in', '.out'))
-static inline float32x4 __attribute__((always_inline))
-_mm_set_ps(const float __Z, const float __Y, const float __X, const float __W)
-{
- return (float32x4){ __W, __X, __Y, __Z };
-}
-
-static __inline__ float32x4 __attribute__((__always_inline__))
-_mm_setzero_ps(void)
-{
- return (float32x4){ 0.0, 0.0, 0.0, 0.0 };
-}
-
-int main(int argc, char **argv) {
- float data[8];
- for (int i = 0; i < 32; i++) data[i] = (1+i+argc)*(2+i+argc*argc); // confuse optimizer
- {
- float32x4 *a = (float32x4*)&data[0];
- float32x4 *b = (float32x4*)&data[4];
- float32x4 c, d;
- c = *a;
- d = *b;
- printf("1floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1], (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
- c = c+d;
- printf("2floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1], (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
- d = c*d;
- printf("3floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1], (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
- c = _mm_setzero_ps();
- printf("zeros %d, %d, %d, %d\n", (int)c[0], (int)c[1], (int)c[2], (int)c[3]);
- }
- {
- int32x4 *a = (int32x4*)&data[0];
- int32x4 *b = (int32x4*)&data[4];
- int32x4 c, d, e, f;
- c = *a;
- d = *b;
- printf("4ints! %d, %d, %d, %d %d, %d, %d, %d\n", c[0], c[1], c[2], c[3], d[0], d[1], d[2], d[3]);
- e = c+d;
- f = c-d;
- printf("5ints! %d, %d, %d, %d %d, %d, %d, %d\n", e[0], e[1], e[2], e[3], f[0], f[1], f[2], f[3]);
- e = c&d;
- f = c|d;
- e = ~c&d;
- f = c^d;
- printf("5intops! %d, %d, %d, %d %d, %d, %d, %d\n", e[0], e[1], e[2], e[3], f[0], f[1], f[2], f[3]);
- }
- {
- float32x4 c, d, e, f;
- c = _mm_set_ps(9.0, 4.0, 0, -9.0);
- d = _mm_set_ps(10.0, 14.0, -12, -2.0);
- printf("6floats! %d, %d, %d, %d %d, %d, %d, %d\n", (int)c[0], (int)c[1], (int)c[2], (int)c[3], (int)d[0], (int)d[1], (int)d[2], (int)d[3]);
- printf("7calcs: %d\n", emscripten_float32x4_signmask(c)); // TODO: just not just compilation but output as well
- }
-
- return 0;
-}
- '''
-
- self.do_run(src, '''1floats! 6, 12, 20, 30 42, 56, 72, 90
-2floats! 48, 68, 92, 120 42, 56, 72, 90
-3floats! 48, 68, 92, 120 2016, 3808, 6624, 10800
-zeros 0, 0, 0, 0
-4ints! 1086324736, 1094713344, 1101004800, 1106247680 1109917696, 1113587712, 1116733440, 1119092736
-5ints! -2098724864, -2086666240, -2077229056, -2069626880 -23592960, -18874368, -15728640, -12845056
-5intops! 36175872, 35651584, 34603008, 33816576 48758784, 52428800, 53477376, 54788096
-6floats! -9, 0, 4, 9 -2, -12, 14, 10
-''')
+ self.do_run_from_file(src, output)
def test_simd2(self):
if Settings.ASM_JS: Settings.ASM_JS = 2 # does not validate
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- self.do_run(r'''
- #include <stdio.h>
-
- typedef float __m128 __attribute__ ((__vector_size__ (16)));
-
- static inline __m128 __attribute__((always_inline))
- _mm_set_ps(const float __Z, const float __Y, const float __X, const float __W)
- {
- return (__m128){ __W, __X, __Y, __Z };
- }
-
- static inline void __attribute__((always_inline))
- _mm_store_ps(float *__P, __m128 __A)
- {
- *(__m128 *)__P = __A;
- }
-
- static inline __m128 __attribute__((always_inline))
- _mm_add_ps(__m128 __A, __m128 __B)
- {
- return __A + __B;
- }
+ test_path = path_from_root('tests', 'core', 'test_simd2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- using namespace std;
-
- int main(int argc, char ** argv) {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(9.0, 4.0, 0, -9.0);
- __m128 v2 = _mm_set_ps(7.0, 3.0, 2.5, 1.0);
- __m128 v3 = _mm_add_ps(v1, v2);
- _mm_store_ps(ar, v3);
-
- for (int i = 0; i < 4; i++) {
- printf("%f\n", ar[i]);
- }
-
- return 0;
- }
- ''', '''-8.000000
-2.500000
-7.000000
-16.000000
-''')
+ self.do_run_from_file(src, output)
def test_simd3(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('needs ta2')
if Settings.ASM_JS: Settings.ASM_JS = 2 # does not validate
- src = r'''
- #include <iostream>
- #include <emmintrin.h>
- #include <assert.h>
- #include <stdint.h>
- #include <bitset>
-
- using namespace std;
-
- void testSetPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v = _mm_set_ps(1.0, 2.0, 3.0, 4.0);
- _mm_store_ps(ar, v);
- assert(ar[0] == 4.0);
- assert(ar[1] == 3.0);
- assert(ar[2] == 2.0);
- assert(ar[3] == 1.0);
- }
-
- void testSet1Ps() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v = _mm_set1_ps(5.5);
- _mm_store_ps(ar, v);
- assert(ar[0] == 5.5);
- assert(ar[1] == 5.5);
- assert(ar[2] == 5.5);
- assert(ar[3] == 5.5);
- }
-
- void testSetZeroPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v = _mm_setzero_ps();
- _mm_store_ps(ar, v);
- assert(ar[0] == 0);
- assert(ar[1] == 0);
- assert(ar[2] == 0);
- assert(ar[3] == 0);
- }
-
- void testSetEpi32() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v = _mm_set_epi32(5, 7, 126, 381);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 381);
- assert(ar[1] == 126);
- assert(ar[2] == 7);
- assert(ar[3] == 5);
- v = _mm_set_epi32(0x55555555, 0xaaaaaaaa, 0xffffffff, 0x12345678);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 0x12345678);
- assert(ar[1] == 0xffffffff);
- assert(ar[2] == 0xaaaaaaaa);
- assert(ar[3] == 0x55555555);
- }
-
- void testSet1Epi32() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v = _mm_set1_epi32(-5);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == -5);
- assert(ar[1] == -5);
- assert(ar[2] == -5);
- assert(ar[3] == -5);
- }
-
- void testSetZeroSi128() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v = _mm_setzero_si128();
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 0);
- assert(ar[1] == 0);
- assert(ar[2] == 0);
- assert(ar[3] == 0);
- }
-
- void testBitCasts() {
- int32_t __attribute__((__aligned__(16))) ar1[4];
- float __attribute__((__aligned__(16))) ar2[4];
- __m128i v1 = _mm_set_epi32(0x3f800000, 0x40000000, 0x40400000, 0x40800000);
- __m128 v2 = _mm_castsi128_ps(v1);
- _mm_store_ps(ar2, v2);
- assert(ar2[0] == 4.0);
- assert(ar2[1] == 3.0);
- assert(ar2[2] == 2.0);
- assert(ar2[3] == 1.0);
- v2 = _mm_set_ps(5.0, 6.0, 7.0, 8.0);
- v1 = _mm_castps_si128(v2);
- _mm_store_si128((__m128i *)ar1, v1);
- assert(ar1[0] == 0x41000000);
- assert(ar1[1] == 0x40e00000);
- assert(ar1[2] == 0x40c00000);
- assert(ar1[3] == 0x40a00000);
- float w = 0;
- float z = -278.3;
- float y = 5.2;
- float x = -987654321;
- v1 = _mm_castps_si128(_mm_set_ps(w, z, y, x));
- _mm_store_ps(ar2, _mm_castsi128_ps(v1));
- assert(ar2[0] == x);
- assert(ar2[1] == y);
- assert(ar2[2] == z);
- assert(ar2[3] == w);
- /*
- std::bitset<sizeof(float)*CHAR_BIT> bits1x(*reinterpret_cast<unsigned long*>(&(ar2[0])));
- std::bitset<sizeof(float)*CHAR_BIT> bits1y(*reinterpret_cast<unsigned long*>(&(ar2[1])));
- std::bitset<sizeof(float)*CHAR_BIT> bits1z(*reinterpret_cast<unsigned long*>(&(ar2[2])));
- std::bitset<sizeof(float)*CHAR_BIT> bits1w(*reinterpret_cast<unsigned long*>(&(ar2[3])));
- std::bitset<sizeof(float)*CHAR_BIT> bits2x(*reinterpret_cast<unsigned long*>(&x));
- std::bitset<sizeof(float)*CHAR_BIT> bits2y(*reinterpret_cast<unsigned long*>(&y));
- std::bitset<sizeof(float)*CHAR_BIT> bits2z(*reinterpret_cast<unsigned long*>(&z));
- std::bitset<sizeof(float)*CHAR_BIT> bits2w(*reinterpret_cast<unsigned long*>(&w));
- assert(bits1x == bits2x);
- assert(bits1y == bits2y);
- assert(bits1z == bits2z);
- assert(bits1w == bits2w);
- */
- v2 = _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0, 0x5555cccc, 0xaaaaaaaa));
- _mm_store_si128((__m128i *)ar1, _mm_castps_si128(v2));
- assert(ar1[0] == 0xaaaaaaaa);
- assert(ar1[1] == 0x5555cccc);
- assert(ar1[2] == 0);
- assert(ar1[3] == 0xffffffff);
- }
-
- void testConversions() {
- int32_t __attribute__((__aligned__(16))) ar1[4];
- float __attribute__((__aligned__(16))) ar2[4];
- __m128i v1 = _mm_set_epi32(0, -3, -517, 256);
- __m128 v2 = _mm_cvtepi32_ps(v1);
- _mm_store_ps(ar2, v2);
- assert(ar2[0] == 256.0);
- assert(ar2[1] == -517.0);
- assert(ar2[2] == -3.0);
- assert(ar2[3] == 0);
- v2 = _mm_set_ps(5.0, 6.0, 7.45, -8.0);
- v1 = _mm_cvtps_epi32(v2);
- _mm_store_si128((__m128i *)ar1, v1);
- assert(ar1[0] == -8);
- assert(ar1[1] == 7);
- assert(ar1[2] == 6);
- assert(ar1[3] == 5);
- }
-
- void testMoveMaskPs() {
- __m128 v = _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0xffffffff, 0, 0xffffffff));
- int mask = _mm_movemask_ps(v);
- assert(mask == 13);
- }
-
- void testAddPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(4.0, 3.0, 2.0, 1.0);
- __m128 v2 = _mm_set_ps(10.0, 20.0, 30.0, 40.0);
- __m128 v = _mm_add_ps(v1, v2);
- _mm_store_ps(ar, v);
- assert(ar[0] == 41.0);
- assert(ar[1] == 32.0);
- assert(ar[2] == 23.0);
- assert(ar[3] == 14.0);
- }
-
- void testSubPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(4.0, 3.0, 2.0, 1.0);
- __m128 v2 = _mm_set_ps(10.0, 20.0, 30.0, 40.0);
- __m128 v = _mm_sub_ps(v1, v2);
- _mm_store_ps(ar, v);
- assert(ar[0] == -39.0);
- assert(ar[1] == -28.0);
- assert(ar[2] == -17.0);
- assert(ar[3] == -6.0);
- }
-
- void testMulPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(4.0, 3.0, 2.0, 1.0);
- __m128 v2 = _mm_set_ps(10.0, 20.0, 30.0, 40.0);
- __m128 v = _mm_mul_ps(v1, v2);
- _mm_store_ps(ar, v);
- assert(ar[0] == 40.0);
- assert(ar[1] == 60.0);
- assert(ar[2] == 60.0);
- assert(ar[3] == 40.0);
- }
-
- void testDivPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(4.0, 9.0, 8.0, 1.0);
- __m128 v2 = _mm_set_ps(2.0, 3.0, 1.0, 0.5);
- __m128 v = _mm_div_ps(v1, v2);
- _mm_store_ps(ar, v);
- assert(ar[0] == 2.0);
- assert(ar[1] == 8.0);
- assert(ar[2] == 3.0);
- assert(ar[3] == 2.0);
- }
-
- void testMinPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(-20.0, 10.0, 30.0, 0.5);
- __m128 v2 = _mm_set_ps(2.0, 1.0, 50.0, 0.0);
- __m128 v = _mm_min_ps(v1, v2);
- _mm_store_ps(ar, v);
- assert(ar[0] == 0.0);
- assert(ar[1] == 30.0);
- assert(ar[2] == 1.0);
- assert(ar[3] == -20.0);
- }
-
- void testMaxPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(-20.0, 10.0, 30.0, 0.5);
- __m128 v2 = _mm_set_ps(2.5, 5.0, 55.0, 1.0);
- __m128 v = _mm_max_ps(v1, v2);
- _mm_store_ps(ar, v);
- assert(ar[0] == 1.0);
- assert(ar[1] == 55.0);
- assert(ar[2] == 10.0);
- assert(ar[3] == 2.5);
- }
-
- void testSqrtPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(16.0, 9.0, 4.0, 1.0);
- __m128 v = _mm_sqrt_ps(v1);
- _mm_store_ps(ar, v);
- assert(ar[0] == 1.0);
- assert(ar[1] == 2.0);
- assert(ar[2] == 3.0);
- assert(ar[3] == 4.0);
- }
-
- void testCmpLtPs() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
- __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
- __m128 v = _mm_cmplt_ps(v1, v2);
- _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
- assert(ar[0] == 0xffffffff);
- assert(ar[1] == 0);
- assert(ar[2] == 0);
- assert(ar[3] == 0xffffffff);
- assert(_mm_movemask_ps(v) == 9);
- }
-
- void testCmpLePs() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
- __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
- __m128 v = _mm_cmple_ps(v1, v2);
- _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
- assert(ar[0] == 0xffffffff);
- assert(ar[1] == 0);
- assert(ar[2] == 0xffffffff);
- assert(ar[3] == 0xffffffff);
- assert(_mm_movemask_ps(v) == 13);
- }
-
- void testCmpEqPs() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
- __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
- __m128 v = _mm_cmpeq_ps(v1, v2);
- _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
- assert(ar[0] == 0);
- assert(ar[1] == 0);
- assert(ar[2] == 0xffffffff);
- assert(ar[3] == 0);
- assert(_mm_movemask_ps(v) == 4);
- }
-
- void testCmpGePs() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
- __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
- __m128 v = _mm_cmpge_ps(v1, v2);
- _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
- assert(ar[0] == 0);
- assert(ar[1] == 0xffffffff);
- assert(ar[2] == 0xffffffff);
- assert(ar[3] == 0);
- assert(_mm_movemask_ps(v) == 6);
- }
-
- void testCmpGtPs() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(1.0, 2.0, 0.1, 0.001);
- __m128 v2 = _mm_set_ps(2.0, 2.0, 0.001, 0.1);
- __m128 v = _mm_cmpgt_ps(v1, v2);
- _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
- assert(ar[0] == 0);
- assert(ar[1] == 0xffffffff);
- assert(ar[2] == 0);
- assert(ar[3] == 0);
- assert(_mm_movemask_ps(v) == 2);
- }
-
- void testAndPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(425, -501, -32, 68);
- __m128 v2 = _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0xffffffff, 0, 0xffffffff));
- __m128 v = _mm_and_ps(v1, v2);
- _mm_store_ps(ar, v);
- assert(ar[0] == 68);
- assert(ar[1] == 0);
- assert(ar[2] == -501);
- assert(ar[3] == 425);
- int32_t __attribute__((__aligned__(16))) ar2[4];
- v1 = _mm_castsi128_ps(_mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa));
- v2 = _mm_castsi128_ps(_mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
- v = _mm_and_ps(v1, v2);
- _mm_store_si128((__m128i *)ar2, _mm_castps_si128(v));
- assert(ar2[0] == 0);
- assert(ar2[1] == 0);
- assert(ar2[2] == 0);
- assert(ar2[3] == 0);
- }
-
- void testAndNotPs() {
- float __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_set_ps(425, -501, -32, 68);
- __m128 v2 = _mm_castsi128_ps(_mm_set_epi32(0xffffffff, 0xffffffff, 0, 0xffffffff));
- __m128 v = _mm_andnot_ps(v2, v1);
- _mm_store_ps(ar, v);
- assert(ar[0] == 0);
- assert(ar[1] == -32);
- assert(ar[2] == 0);
- assert(ar[3] == 0);
- int32_t __attribute__((__aligned__(16))) ar2[4];
- v1 = _mm_castsi128_ps(_mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa));
- v2 = _mm_castsi128_ps(_mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
- v = _mm_andnot_ps(v1, v2);
- _mm_store_si128((__m128i *)ar2, _mm_castps_si128(v));
- assert(ar2[0] == 0x55555555);
- assert(ar2[1] == 0x55555555);
- assert(ar2[2] == 0x55555555);
- assert(ar2[3] == 0x55555555);
- }
-
- void testOrPs() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_castsi128_ps(_mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0));
- __m128 v2 = _mm_castsi128_ps(_mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
- __m128 v = _mm_or_ps(v1, v2);
- _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
- assert(ar[0] == 0x55555555);
- assert(ar[1] == 0xffffffff);
- assert(ar[2] == 0xffffffff);
- assert(ar[3] == 0xffffffff);
- }
-
- void testXorPs() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128 v1 = _mm_castsi128_ps(_mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0));
- __m128 v2 = _mm_castsi128_ps(_mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555));
- __m128 v = _mm_xor_ps(v1, v2);
- _mm_store_si128((__m128i *)ar, _mm_castps_si128(v));
- assert(ar[0] == 0x55555555);
- assert(ar[1] == 0xaaaaaaaa);
- assert(ar[2] == 0xffffffff);
- assert(ar[3] == 0xffffffff);
- }
-
- void testAndSi128() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa);
- __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
- __m128i v = _mm_and_si128(v1, v2);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 0);
- assert(ar[1] == 0);
- assert(ar[2] == 0);
- assert(ar[3] == 0);
- }
-
- void testAndNotSi128() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, -1431655766, 0xaaaaaaaa);
- __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
- __m128i v = _mm_andnot_si128(v1, v2);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 0x55555555);
- assert(ar[1] == 0x55555555);
- assert(ar[2] == 0x55555555);
- assert(ar[3] == 0x55555555);
- }
-
- void testOrSi128() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0);
- __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
- __m128i v = _mm_or_si128(v1, v2);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 0x55555555);
- assert(ar[1] == 0xffffffff);
- assert(ar[2] == 0xffffffff);
- assert(ar[3] == 0xffffffff);
- }
-
- void testXorSi128() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v1 = _mm_set_epi32(0xaaaaaaaa, 0xaaaaaaaa, 0xffffffff, 0);
- __m128i v2 = _mm_set_epi32(0x55555555, 0x55555555, 0x55555555, 0x55555555);
- __m128i v = _mm_xor_si128(v1, v2);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 0x55555555);
- assert(ar[1] == 0xaaaaaaaa);
- assert(ar[2] == 0xffffffff);
- assert(ar[3] == 0xffffffff);
- }
-
- void testAddEpi32() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v1 = _mm_set_epi32(4, 3, 2, 1);
- __m128i v2 = _mm_set_epi32(10, 20, 30, 40);
- __m128i v = _mm_add_epi32(v1, v2);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == 41);
- assert(ar[1] == 32);
- assert(ar[2] == 23);
- assert(ar[3] == 14);
- }
-
- void testSubEpi32() {
- int32_t __attribute__((__aligned__(16))) ar[4];
- __m128i v1 = _mm_set_epi32(4, 3, 2, 1);
- __m128i v2 = _mm_set_epi32(10, 20, 30, 40);
- __m128i v = _mm_sub_epi32(v1, v2);
- _mm_store_si128((__m128i *)ar, v);
- assert(ar[0] == -39);
- assert(ar[1] == -28);
- assert(ar[2] == -17);
- assert(ar[3] == -6);
- }
-
- int main(int argc, char ** argv) {
- testSetPs();
- testSet1Ps();
- testSetZeroPs();
- testSetEpi32();
- testSet1Epi32();
- testSetZeroSi128();
- testBitCasts();
- testConversions();
- testMoveMaskPs();
- testAddPs();
- testSubPs();
- testMulPs();
- testDivPs();
- testMaxPs();
- testMinPs();
- testSqrtPs();
- testCmpLtPs();
- testCmpLePs();
- testCmpEqPs();
- testCmpGePs();
- testCmpGtPs();
- testAndPs();
- testAndNotPs();
- testOrPs();
- testXorPs();
- testAndSi128();
- testAndNotSi128();
- testOrSi128();
- testXorSi128();
- testAddEpi32();
- testSubEpi32();
- printf("DONE");
- return 0;
- }
- '''
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
- self.do_run(src, 'DONE')
+ test_path = path_from_root('tests', 'core', 'test_simd3')
+ src, output = (test_path + s for s in ('.in', '.out'))
+ self.do_run_from_file(src, output)
def test_gcc_unmangler(self):
- Settings.NAMED_GLOBALS = 1 # test coverage for this
+ if os.environ.get('EMCC_FAST_COMPILER') != '1': Settings.NAMED_GLOBALS = 1 # test coverage for this
Building.COMPILER_TEST_OPTS += ['-I' + path_from_root('third_party')]
@@ -9395,6 +4648,7 @@ zeros 0, 0, 0, 0
def test_lua(self):
if self.emcc_args is None: return self.skip('requires emcc')
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: make this work')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
self.do_run('',
'hello lua world!\n17\n1\n2\n3\n4\n7',
@@ -9412,6 +4666,7 @@ zeros 0, 0, 0, 0
def test_freetype(self):
if self.emcc_args is None: return self.skip('requires emcc')
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: Figure out and try to fix')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
assert 'asm2g' in test_modes
if self.run_name == 'asm2g':
@@ -9544,7 +4799,7 @@ def process(filename):
test()
assert 'asm2g' in test_modes
- if self.run_name == 'asm2g' and not use_cmake:
+ if self.run_name == 'asm2g' and not use_cmake and os.environ.get('EMCC_FAST_COMPILER') != '1':
# Test forced alignment
print >> sys.stderr, 'testing FORCE_ALIGNED_MEMORY'
old = open('src.cpp.o.js').read()
@@ -9557,6 +4812,7 @@ def process(filename):
def test_poppler(self):
if self.emcc_args is None: return self.skip('very slow, we only do this in emcc runs')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.CORRECT_OVERFLOWS = 1
Settings.CORRECT_SIGNS = 1
@@ -9771,6 +5027,14 @@ def process(filename):
for name in glob.glob(path_from_root('tests', 'cases', '*.ll')):
shortname = name.replace('.ll', '')
if '' not in shortname: continue
+ if os.environ.get('EMCC_FAST_COMPILER') == '1' and os.path.basename(shortname) in [
+ 'structparam', 'uadd_overflow_ta2', 'extendedprecision', 'issue_39', 'emptystruct', 'phinonexist', 'quotedlabel', 'oob_ta2', 'phientryimplicit', 'phiself', 'invokebitcast', # invalid ir
+ 'structphiparam', 'callwithstructural_ta2', 'callwithstructural64_ta2', 'structinparam', # pnacl limitations in ExpandStructRegs
+ '2xi40', # pnacl limitations in ExpandGetElementPtr
+ 'legalizer_ta2', '514_ta2', # pnacl limitation in not legalizing i104, i96, etc.
+ 'longjmp_tiny', 'longjmp_tiny_invoke', 'longjmp_tiny_phi', 'longjmp_tiny_phi2', 'longjmp_tiny_invoke_phi', 'indirectbrphi', 'ptrtoint_blockaddr', 'quoted', # current fastcomp limitations FIXME
+ 'sillyfuncast', 'sillyfuncast2', 'sillybitcast', 'atomicrmw_unaligned' # TODO XXX
+ ]: continue
if '_ta2' in shortname and not Settings.USE_TYPED_ARRAYS == 2:
print self.skip('case "%s" only relevant for ta2' % shortname)
continue
@@ -9814,6 +5078,9 @@ def process(filename):
def run_all(x):
print x
for name in glob.glob(path_from_root('tests', 'fuzz', '*.c')):
+ #if os.path.basename(name) != '4.c': continue
+ if os.environ.get('EMCC_FAST_COMPILER') == '1' and os.path.basename(name) in ['17.c']: continue # pnacl limitation in not legalizing i104, i96, etc.
+
print name
self.do_run(open(path_from_root('tests', 'fuzz', name)).read(),
open(path_from_root('tests', 'fuzz', name + '.txt')).read(), force_c=True)
@@ -9913,33 +5180,10 @@ def process(filename):
Settings.CORRUPTION_CHECK = 1
# test for free(0), malloc(0), etc.
- src = r'''
- #include <iostream>
- #include <fstream>
- #include <stdlib.h>
- #include <stdio.h>
-
- void bye() {
- printf("all ok\n");
- }
+ test_path = path_from_root('tests', 'core', 'test_corruption_2')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main() {
- atexit(bye);
-
- std::string testPath = "/Script/WA-KA.txt";
- std::fstream str(testPath.c_str(), std::ios::in | std::ios::binary);
-
- if (str.is_open())
- {
- std::cout << "open!" << std::endl;
- } else {
- std::cout << "missing!" << std::endl;
- }
-
- return 1;
- }
- '''
- self.do_run(src, 'missing!\nall ok\n')
+ self.do_run_from_file(src, output)
def test_corruption_3(self):
if Settings.ASM_JS: return self.skip('cannot use corruption checks in asm')
@@ -9948,29 +5192,10 @@ def process(filename):
Settings.CORRUPTION_CHECK = 1
# realloc
- src = r'''
- #include <stdlib.h>
- #include <stdio.h>
- #include <assert.h>
-
- void bye() {
- printf("all ok\n");
- }
+ test_path = path_from_root('tests', 'core', 'test_corruption_3')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main(int argc, char **argv) {
- atexit(bye);
-
- char *buffer = (char*)malloc(100);
- for (int i = 0; i < 100; i++) buffer[i] = (i*i)%256;
- buffer = (char*)realloc(buffer, argc + 50);
- for (int i = 0; i < argc + 50; i++) {
- //printf("%d : %d : %d : %d\n", i, (int)(buffer + i), buffer[i], (char)((i*i)%256));
- assert(buffer[i] == (char)((i*i)%256));
- }
- return 1;
- }
- '''
- self.do_run(src, 'all ok\n')
+ self.do_run_from_file(src, output)
### Integration tests
@@ -9978,26 +5203,6 @@ def process(filename):
if self.emcc_args is not None and '-O2' in self.emcc_args:
self.emcc_args += ['--closure', '1'] # Use closure here, to test we export things right
- src = r'''
- #include <stdio.h>
- #include <stdlib.h>
-
- extern "C" {
- int get_int() { return 5; }
- float get_float() { return 3.14; }
- char * get_string() { return "hello world"; }
- void print_int(int x) { printf("%d\n", x); }
- void print_float(float x) { printf("%.2f\n", x); }
- void print_string(char *x) { printf("%s\n", x); }
- int multi(int x, float y, int z, char *str) { if (x) puts(str); return (x+y)*z; }
- int * pointer(int *in) { printf("%d\n", *in); static int ret = 21; return &ret; }
- }
-
- int main(int argc, char **argv) {
- return 0;
- }
- '''
-
post = '''
def process(filename):
src = \'\'\'
@@ -10036,7 +5241,10 @@ def process(filename):
Settings.EXPORTED_FUNCTIONS += ['_get_int', '_get_float', '_get_string', '_print_int', '_print_float', '_print_string', '_multi', '_pointer', '_malloc']
- self.do_run(src, '*\nnumber,5\nnumber,3.14\nstring,hello world\n12\nundefined\n14.56\nundefined\ncheez\nundefined\narr-ay\nundefined\nmore\nnumber,10\n650\nnumber,21\n*\natr\n10\nbret\n53\n*\nstack is ok.\n', post_build=post)
+ test_path = path_from_root('tests', 'core', 'test_ccall')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output, post_build=post)
def test_pgo(self):
if Settings.ASM_JS: return self.skip('PGO does not work in asm mode')
@@ -10111,6 +5319,7 @@ def process(filename):
def test_asm_pgo(self):
if not Settings.ASM_JS: return self.skip('this is a test for PGO for asm (NB: not *in* asm)')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
src = open(path_from_root('tests', 'hello_libcxx.cpp')).read()
output = 'hello, world!'
@@ -10183,6 +5392,7 @@ def process(filename):
def test_add_function(self):
if self.emcc_args is None: return self.skip('requires emcc')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.INVOKE_RUN = 0
Settings.RESERVED_FUNCTION_POINTERS = 1
@@ -10223,31 +5433,14 @@ def process(filename):
def test_demangle_stacks(self):
if Settings.ASM_JS: return self.skip('spidermonkey has stack trace issues')
- src = r'''
- #include<stdio.h>
- #include<stdlib.h>
+ test_path = path_from_root('tests', 'core', 'test_demangle_stacks')
+ src, output = (test_path + s for s in ('.in', '.out'))
- namespace NameSpace {
- class Class {
- public:
- int Aborter(double x, char y, int *z) {
- int addr = x+y+(int)z;
- void *p = (void*)addr;
- for (int i = 0; i < 100; i++) free(p); // will abort, should show proper stack trace
- }
- };
- }
-
- int main(int argc, char **argv) {
- NameSpace::Class c;
- c.Aborter(1.234, 'a', NULL);
- return 0;
- }
- '''
- self.do_run(src, 'NameSpace::Class::Aborter(double, char, int*)');
+ self.do_run_from_file(src, output)
def test_embind(self):
if self.emcc_args is None: return self.skip('requires emcc')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Building.COMPILER_TEST_OPTS += ['--bind']
src = r'''
@@ -10270,6 +5463,7 @@ def process(filename):
def test_embind_2(self):
if self.emcc_args is None: return self.skip('requires emcc')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Building.COMPILER_TEST_OPTS += ['--bind', '--post-js', 'post.js']
open('post.js', 'w').write('''
Module.print('lerp ' + Module.lerp(1, 2, 0.66) + '.');
@@ -10290,6 +5484,7 @@ def process(filename):
def test_scriptaclass(self):
if self.emcc_args is None: return self.skip('requires emcc')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
Settings.EXPORT_BINDINGS = 1
@@ -10779,6 +5974,7 @@ def process(filename):
def test_source_map(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip("doesn't pass without typed arrays")
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
if NODE_JS not in JS_ENGINES: return self.skip('sourcemapper requires Node to run')
if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
@@ -10862,6 +6058,7 @@ def process(filename):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip("doesn't pass without typed arrays")
if '-g4' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g4')
if NODE_JS not in JS_ENGINES: return self.skip('sourcemapper requires Node to run')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
src = '''
#include <stdio.h>
@@ -10893,6 +6090,12 @@ def process(filename):
dirname = self.get_dir()
self.build(src, dirname, os.path.join(dirname, 'src.cpp'), post_build=(None, post))
+ def test_emscripten_log(self):
+ self.banned_js_engines = [SPIDERMONKEY_ENGINE] # XXX, emscripten_log is broken in spidermonkey currently, issue #1970
+ if self.emcc_args is None: return self.skip('This test needs libc.')
+ if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
+ self.do_run('#define RUN_FROM_JS_SHELL\n' + open(path_from_root('tests', 'emscripten_log', 'emscripten_log.cpp')).read(), "Success!")
+
def test_linespecific(self):
if Settings.ASM_JS: return self.skip('asm always has corrections on')
@@ -11084,132 +6287,10 @@ def process(filename):
Settings.GC_SUPPORT = 1
- src = r'''
- #include <stdio.h>
- #include <gc.h>
- #include <assert.h>
-
- void *global;
-
- void finalizer(void *ptr, void *arg) {
- printf("finalizing %d (global == %d)\n", (int)arg, ptr == global);
- }
-
- void finalizer2(void *ptr, void *arg) {
- printf("finalizing2 %d (global == %d)\n", (int)arg, ptr == global);
- }
-
- int main() {
- GC_INIT();
-
- void *local, *local2, *local3, *local4, *local5, *local6;
-
- // Hold on to global, drop locals
-
- global = GC_MALLOC(1024); // rooted since in a static allocation
- GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0);
- printf("alloc %p\n", global);
-
- local = GC_MALLOC(1024); // not rooted since stack is not scanned
- GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void*)1, 0, 0);
- printf("alloc %p\n", local);
+ test_path = path_from_root('tests', 'core', 'test_gc')
+ src, output = (test_path + s for s in ('.in', '.out'))
- assert((char*)local - (char*)global >= 1024 || (char*)global - (char*)local >= 1024);
-
- local2 = GC_MALLOC(1024); // no finalizer
- printf("alloc %p\n", local2);
-
- local3 = GC_MALLOC(1024); // with finalizable2
- GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer2, (void*)2, 0, 0);
- printf("alloc %p\n", local);
-
- local4 = GC_MALLOC(1024); // yet another
- GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer2, (void*)3, 0, 0);
- printf("alloc %p\n", local);
-
- printf("basic test\n");
-
- GC_FORCE_COLLECT();
-
- printf("*\n");
-
- GC_FREE(global); // force free will actually work
-
- // scanning inside objects
-
- global = GC_MALLOC(12);
- GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0);
- local = GC_MALLOC(12);
- GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void*)1, 0, 0);
- local2 = GC_MALLOC_ATOMIC(12);
- GC_REGISTER_FINALIZER_NO_ORDER(local2, finalizer, (void*)2, 0, 0);
- local3 = GC_MALLOC(12);
- GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer, (void*)3, 0, 0);
- local4 = GC_MALLOC(12);
- GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer, (void*)4, 0, 0);
- local5 = GC_MALLOC_UNCOLLECTABLE(12);
- // This should never trigger since local5 is uncollectable
- GC_REGISTER_FINALIZER_NO_ORDER(local5, finalizer, (void*)5, 0, 0);
-
- printf("heap size = %d\n", GC_get_heap_size());
-
- local4 = GC_REALLOC(local4, 24);
-
- printf("heap size = %d\n", GC_get_heap_size());
-
- local6 = GC_MALLOC(12);
- GC_REGISTER_FINALIZER_NO_ORDER(local6, finalizer, (void*)6, 0, 0);
- // This should be the same as a free
- GC_REALLOC(local6, 0);
-
- void **globalData = (void**)global;
- globalData[0] = local;
- globalData[1] = local2;
-
- void **localData = (void**)local;
- localData[0] = local3;
-
- void **local2Data = (void**)local2;
- local2Data[0] = local4; // actually ignored, because local2 is atomic, so 4 is freeable
-
- printf("object scan test test\n");
-
- GC_FORCE_COLLECT();
-
- printf("*\n");
-
- GC_FREE(global); // force free will actually work
-
- printf("*\n");
-
- GC_FORCE_COLLECT();
-
- printf(".\n");
-
- global = 0;
-
- return 0;
- }
- '''
- self.do_run(src, '''basic test
-finalizing 1 (global == 0)
-finalizing2 2 (global == 0)
-finalizing2 3 (global == 0)
-*
-finalizing 0 (global == 1)
-heap size = 72
-heap size = 84
-finalizing 6 (global == 0)
-object scan test test
-finalizing 4 (global == 0)
-*
-finalizing 0 (global == 1)
-*
-finalizing 1 (global == 0)
-finalizing 2 (global == 0)
-finalizing 3 (global == 0)
-.
-''')
+ self.do_run_from_file(src, output)
# Generate tests for everything
def make_run(fullname, name=-1, compiler=-1, embetter=0, quantum_size=0,
@@ -11295,7 +6376,7 @@ def make_run(fullname, name=-1, compiler=-1, embetter=0, quantum_size=0,
return TT
# Make one run with the defaults
-default = make_run("default", compiler=CLANG, emcc_args=[])
+default = make_run("default", compiler=CLANG, emcc_args=[] if os.environ.get('EMCC_FAST_COMPILER') != '1' else ['-s', 'ASM_JS=1'])
# Make one run with -O1, with safe heap
o1 = make_run("o1", compiler=CLANG, emcc_args=["-O1", "-s", "ASM_JS=0", "-s", "SAFE_HEAP=1"])
diff --git a/tests/test_egl.c b/tests/test_egl.c
index 5864a797..d66949d0 100644
--- a/tests/test_egl.c
+++ b/tests/test_egl.c
@@ -37,12 +37,21 @@ int main(int argc, char *argv[])
assert(eglGetError() == EGL_SUCCESS);
assert(surface != 0);
+ // WebGL maps to GLES2. GLES1 is not supported.
+ EGLint contextAttribsOld[] =
+ {
+ EGL_CONTEXT_CLIENT_VERSION, 1,
+ EGL_NONE
+ };
+ EGLContext context = eglCreateContext(display, config, NULL, contextAttribsOld);
+ assert(eglGetError() != EGL_SUCCESS);
+
EGLint contextAttribs[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
- EGLContext context = eglCreateContext(display, config, NULL, contextAttribs);
+ context = eglCreateContext(display, config, NULL, contextAttribs);
assert(eglGetError() == EGL_SUCCESS);
assert(context != 0);
diff --git a/tests/test_other.py b/tests/test_other.py
index 5100db72..4bdd889b 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -397,6 +397,8 @@ f.close()
self.assertContained('hello, world!', run_js(os.path.join(self.get_dir(), 'a.out.js')))
def test_unaligned_memory(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
open(os.path.join(self.get_dir(), 'test.cpp'), 'w').write(r'''
#include <stdio.h>
#include <stdarg.h>
@@ -421,6 +423,8 @@ f.close()
self.assertContained('data: 67452301\ndata[0,1] 16bit: 2301\ndata[1,2] 16bit: 4523', run_js(os.path.join(self.get_dir(), 'a.out.js')))
def test_unaligned_memory_2(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
open(os.path.join(self.get_dir(), 'test.cpp'), 'w').write(r'''
#include <string>
#include <stdio.h>
@@ -463,6 +467,7 @@ f.close()
assert 'function _malloc' in src
def test_dangerous_func_cast(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
src = r'''
#include <stdio.h>
typedef void (*voidfunc)();
@@ -522,6 +527,8 @@ f.close()
assert not os.path.exists('a.out') and not os.path.exists('a.exe'), 'Must not leave unneeded linker stubs'
def test_static_link(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
def test(name, header, main, side, expected, args=[], suffix='cpp', first=True):
print name
#t = main ; main = side ; side = t
@@ -843,7 +850,7 @@ f.close()
for test_opts, expected_ranges in [
([], {
- 100: (190, 275),
+ 100: (190, 500),
250: (200, 500),
500: (250, 500),
1000: (230, 1000),
@@ -1165,7 +1172,7 @@ f.close()
''')
Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--js-library', os.path.join(self.get_dir(), 'mylib1.js'),
- '--js-library', os.path.join(self.get_dir(), 'mylib2.js')]).communicate()
+ '--js-library', os.path.join(self.get_dir(), 'mylib2.js')]).communicate()
self.assertContained('hello from lib!\n*32*\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
def test_identical_basenames(self):
@@ -1347,61 +1354,93 @@ f.close()
Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--embed-file', 'tst']).communicate()
self.assertContained('|frist|\n|sacond|\n|thard|\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
- def test_multidynamic_link(self):
- # Linking the same dynamic library in will error, normally, since we statically link it, causing dupe symbols
- # A workaround is to use --ignore-dynamic-linking, see emcc --help for details
+ def test_exclude_file(self):
+ try_delete(os.path.join(self.get_dir(), 'tst'))
+ os.mkdir(os.path.join(self.get_dir(), 'tst'))
+ os.mkdir(os.path.join(self.get_dir(), 'tst', 'abc.exe'))
+ os.mkdir(os.path.join(self.get_dir(), 'tst', 'abc.txt'))
+ open(os.path.join(self.get_dir(), 'tst', 'hello.exe'), 'w').write('''hello''')
+ open(os.path.join(self.get_dir(), 'tst', 'hello.txt'), 'w').write('''world''')
+ open(os.path.join(self.get_dir(), 'tst', 'abc.exe', 'foo'), 'w').write('''emscripten''')
+ open(os.path.join(self.get_dir(), 'tst', 'abc.txt', 'bar'), 'w').write('''!!!''')
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
#include <stdio.h>
- extern void printey();
- extern void printother();
int main() {
- printf("*");
- printey();
- printf("\n");
- printother();
- printf("\n");
- printf("*");
+ if(fopen("tst/hello.exe", "rb")) printf("Failed\n");
+ if(!fopen("tst/hello.txt", "rb")) printf("Failed\n");
+ if(fopen("tst/abc.exe/foo", "rb")) printf("Failed\n");
+ if(!fopen("tst/abc.txt/bar", "rb")) printf("Failed\n");
+
return 0;
}
''')
- try:
- os.makedirs(os.path.join(self.get_dir(), 'libdir'));
- except:
- pass
+ Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--embed-file', 'tst', '--exclude-file', '*.exe']).communicate()
+ output = run_js(os.path.join(self.get_dir(), 'a.out.js'))
+ assert output == ''
- open(os.path.join(self.get_dir(), 'libdir', 'libfile.cpp'), 'w').write('''
- #include <stdio.h>
- void printey() {
- printf("hello from lib");
- }
- ''')
+ def test_multidynamic_link(self):
+ # Linking the same dynamic library in statically will error, normally, since we statically link it, causing dupe symbols
- open(os.path.join(self.get_dir(), 'libdir', 'libother.cpp'), 'w').write('''
- #include <stdio.h>
- extern void printey();
- void printother() {
- printf("|");
- printey();
- printf("|");
- }
- ''')
+ def test(link_cmd, lib_suffix=''):
+ print link_cmd, lib_suffix
- # This lets us link the same dynamic lib twice. We will need to link it in manually at the end.
- compiler = [PYTHON, EMCC, '--ignore-dynamic-linking']
+ self.clear()
- # Build libfile normally into an .so
- Popen(compiler + [os.path.join(self.get_dir(), 'libdir', 'libfile.cpp'), '-o', os.path.join(self.get_dir(), 'libdir', 'libfile.so')]).communicate()
- # Build libother and dynamically link it to libfile - but add --ignore-dynamic-linking
- Popen(compiler + [os.path.join(self.get_dir(), 'libdir', 'libother.cpp'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile', '-o', os.path.join(self.get_dir(), 'libdir', 'libother.so')]).communicate()
- # Build the main file, linking in both the libs
- Popen(compiler + [os.path.join(self.get_dir(), 'main.cpp'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile', '-lother', '-c']).communicate()
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
+ #include <stdio.h>
+ extern void printey();
+ extern void printother();
+ int main() {
+ printf("*");
+ printey();
+ printf("\n");
+ printother();
+ printf("\n");
+ printf("*");
+ return 0;
+ }
+ ''')
- # The normal build system is over. We need to do an additional step to link in the dynamic libraries, since we ignored them before
- Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.o'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile', '-lother']).communicate()
+ try:
+ os.makedirs(os.path.join(self.get_dir(), 'libdir'));
+ except:
+ pass
- self.assertContained('*hello from lib\n|hello from lib|\n*', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ open(os.path.join(self.get_dir(), 'libdir', 'libfile.cpp'), 'w').write('''
+ #include <stdio.h>
+ void printey() {
+ printf("hello from lib");
+ }
+ ''')
+
+ open(os.path.join(self.get_dir(), 'libdir', 'libother.cpp'), 'w').write('''
+ #include <stdio.h>
+ extern void printey();
+ void printother() {
+ printf("|");
+ printey();
+ printf("|");
+ }
+ ''')
+
+ compiler = [PYTHON, EMCC]
+
+ # Build libfile normally into an .so
+ Popen(compiler + [os.path.join(self.get_dir(), 'libdir', 'libfile.cpp'), '-o', os.path.join(self.get_dir(), 'libdir', 'libfile.so' + lib_suffix)]).communicate()
+ # Build libother and dynamically link it to libfile
+ Popen(compiler + [os.path.join(self.get_dir(), 'libdir', 'libother.cpp')] + link_cmd + ['-o', os.path.join(self.get_dir(), 'libdir', 'libother.so')]).communicate()
+ # Build the main file, linking in both the libs
+ Popen(compiler + [os.path.join(self.get_dir(), 'main.cpp')] + link_cmd + ['-lother', '-c']).communicate()
+ print '...'
+ # The normal build system is over. We need to do an additional step to link in the dynamic libraries, since we ignored them before
+ Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.o')] + link_cmd + ['-lother']).communicate()
+
+ self.assertContained('*hello from lib\n|hello from lib|\n*', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
+ test(['-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile']) # -l, auto detection from library path
+ test(['-L' + os.path.join(self.get_dir(), 'libdir'), os.path.join(self.get_dir(), 'libdir', 'libfile.so.3.1.4.1.5.9')], '.3.1.4.1.5.9') # handle libX.so.1.2.3 as well
def test_js_link(self):
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write('''
@@ -1759,6 +1798,7 @@ f.close()
assert 'If you see this - the world is all right!' in output
def test_embind(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
for args, fail in [
([], True), # without --bind, we fail
(['--bind'], False),
@@ -1824,6 +1864,8 @@ seeked= file.
assert output == invalid
def test_link_s(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo safe heap in fastcomp')
+
# -s OPT=VALUE can conflict with -s as a linker option. We warn and ignore
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
extern "C" {
@@ -1918,19 +1960,19 @@ seeked= file.
# crunch should not be run if a .crn exists that is more recent than the .dds
shutil.copyfile(path_from_root('tests', 'ship.dds'), 'ship.dds')
time.sleep(0.1)
- Popen([PYTHON, FILE_PACKAGER, 'test.data', '--pre-run', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
+ Popen([PYTHON, FILE_PACKAGER, 'test.data', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
assert os.stat('test.data').st_size < 0.25*os.stat('ship.dds').st_size, 'Compressed should be much smaller than dds'
crunch_time = os.stat('ship.crn').st_mtime
dds_time = os.stat('ship.dds').st_mtime
assert crunch_time > dds_time, 'Crunch is more recent'
# run again, should not recrunch!
time.sleep(0.1)
- Popen([PYTHON, FILE_PACKAGER, 'test.data', '--pre-run', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
+ Popen([PYTHON, FILE_PACKAGER, 'test.data', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
assert crunch_time == os.stat('ship.crn').st_mtime, 'Crunch is unchanged'
# update dds, so should recrunch
time.sleep(0.1)
os.utime('ship.dds', None)
- Popen([PYTHON, FILE_PACKAGER, 'test.data', '--pre-run', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
+ Popen([PYTHON, FILE_PACKAGER, 'test.data', '--crunch=32', '--preload', 'ship.dds'], stdout=open('pre.js', 'w')).communicate()
assert crunch_time < os.stat('ship.crn').st_mtime, 'Crunch was changed'
def test_headless(self):
@@ -1995,7 +2037,7 @@ done.
Popen([PYTHON, EMCC, 'src.cpp', '-s', 'LINKABLE=1']).communicate()
output = run_js('a.out.js')
self.assertContained('''operator new()
-_main
+main()
f2()
abcdabcdabcd(int)
abcdabcdabcd(int)
@@ -2107,6 +2149,8 @@ int main()
self.assertContained('File size: 722', out)
def test_simd(self):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('todo in fastcomp')
+
self.clear()
Popen([PYTHON, EMCC, path_from_root('tests', 'linpack.c'), '-O2', '-DSP', '--llvm-opts', '''['-O3', '-vectorize', '-vectorize-loops', '-bb-vectorize-vector-bits=128', '-force-vector-width=4']''']).communicate()
self.assertContained('Unrolled Single Precision', run_js('a.out.js'))
@@ -2136,3 +2180,31 @@ int main()
assert 'test.o' in head, 'Invalid dependency target'
assert 'test.cpp' in tail and 'test.hpp' in tail, 'Invalid dependencies generated'
+ def test_quoted_js_lib_key(self):
+ open('lib.js', 'w').write(r'''
+mergeInto(LibraryManager.library, {
+ __internal_data:{
+ '<' : 0,
+ 'white space' : 1
+ },
+ printf__deps: ['__internal_data', 'fprintf']
+});
+''')
+
+ Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '--js-library', 'lib.js']).communicate()
+ self.assertContained('hello, world!', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
+ def test_float_h(self):
+ process = Popen([PYTHON, EMCC, path_from_root('tests', 'float+.c')], stdout=PIPE, stderr=PIPE)
+ out, err = process.communicate()
+ assert process.returncode is 0, 'float.h should agree with our system: ' + out + '\n\n\n' + err
+
+ def test_default_obj_ext(self):
+ outdir = os.path.join(self.get_dir(), 'out_dir') + '/'
+ os.mkdir(outdir)
+ process = Popen([PYTHON, EMCC, '-c', path_from_root('tests', 'hello_world.c'), '-o', outdir], stdout=PIPE, stderr=PIPE)
+ process.communicate()
+ assert(os.path.isfile(outdir + 'hello_world.o'))
+ process = Popen([PYTHON, EMCC, '-c', path_from_root('tests', 'hello_world.c'), '-o', outdir, '--default-obj-ext', 'obj'], stdout=PIPE, stderr=PIPE)
+ process.communicate()
+ assert(os.path.isfile(outdir + 'hello_world.obj'))
diff --git a/tests/test_sanity.py b/tests/test_sanity.py
index c7dd86e4..e8b1f885 100644
--- a/tests/test_sanity.py
+++ b/tests/test_sanity.py
@@ -195,6 +195,34 @@ class sanity(RunnerCore):
finally:
del os.environ['EM_IGNORE_SANITY']
+ def test_llvm_fastcomp(self):
+ if os.environ.get('EMCC_FAST_COMPILER') != '1': return self.skip('not using fastcomp')
+
+ WARNING = 'fastcomp in use, but LLVM has not been built with the JavaScript backend as a target'
+
+ restore()
+
+ # Should see js backend during sanity check
+ assert check_fastcomp()
+ output = self.check_working(EMCC)
+ assert WARNING not in output, output
+
+ # Fake incorrect llc output, no mention of js backend
+ restore()
+ f = open(CONFIG_FILE, 'a')
+ f.write('LLVM_ROOT = "' + path_from_root('tests', 'fake') + '"')
+ f.close()
+
+ if not os.path.exists(path_from_root('tests', 'fake')):
+ os.makedirs(path_from_root('tests', 'fake'))
+
+ f = open(path_from_root('tests', 'fake', 'llc'), 'w')
+ f.write('#!/bin/sh\n')
+ f.write('echo "llc fake output\nRegistered Targets:\nno j-s backend for you!"')
+ f.close()
+ os.chmod(path_from_root('tests', 'fake', 'llc'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
+ output = self.check_working(EMCC, WARNING)
+
def test_node(self):
NODE_WARNING = 'node version appears too old'
NODE_WARNING_2 = 'cannot check node version'
@@ -548,3 +576,31 @@ fi
if old:
os.environ['EMCC_LLVM_TARGET'] = old
+ def test_emconfig(self):
+ restore()
+
+ (fd, custom_config_filename) = tempfile.mkstemp(prefix='.emscripten_config_')
+
+ orig_config = open(CONFIG_FILE, 'r').read()
+
+ # Move the ~/.emscripten to a custom location.
+ tfile = os.fdopen(fd, "w")
+ tfile.write(orig_config)
+ tfile.close()
+
+ # Make a syntax error in the original config file so that attempting to access it would fail.
+ open(CONFIG_FILE, 'w').write('asdfasdfasdfasdf\n\'\'\'' + orig_config)
+
+ temp_dir = tempfile.mkdtemp(prefix='emscripten_temp_')
+
+ os.chdir(temp_dir)
+ self.do([EMCC, '-O2', '--em-config', custom_config_filename, path_from_root('tests', 'hello_world.c')])
+ result = run_js('a.out.js')
+
+ # Clean up created temp files.
+ os.remove(custom_config_filename)
+ os.chdir(path_from_root())
+ shutil.rmtree(temp_dir)
+
+ self.assertContained('hello, world!', result)
+
diff --git a/tests/test_sockets.py b/tests/test_sockets.py
index 1229aa70..f9dcbc68 100644
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -228,6 +228,9 @@ class sockets(BrowserCore):
def test_gethostbyname(self):
self.do_run(open(path_from_root('tests', 'sockets', 'test_gethostbyname.c')).read(), 'success')
+ def test_getprotobyname(self):
+ self.do_run(open(path_from_root('tests', 'sockets', 'test_getprotobyname.c')).read(), 'success')
+
def test_sockets_echo(self):
sockets_include = '-I'+path_from_root('tests', 'sockets')
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js
index 434fbaf9..a344fc35 100644
--- a/tools/eliminator/asm-eliminator-test-output.js
+++ b/tools/eliminator/asm-eliminator-test-output.js
@@ -280,9 +280,10 @@ function tempDouble2($46, $14, $28, $42, $20, $32, $45) {
$20 = $20 | 0;
$32 = $32 | 0;
$45 = $45 | 0;
- var $_sroa_06_0_insert_insert$1 = 0;
+ var $46 = 0, $_sroa_06_0_insert_insert$1 = 0;
+ $46 = (HEAPF32[tempDoublePtr >> 2] = ($14 < $28 ? $14 : $28) - $42, HEAP32[tempDoublePtr >> 2] | 0);
$_sroa_06_0_insert_insert$1 = (HEAPF32[tempDoublePtr >> 2] = ($20 < $32 ? $20 : $32) - $42, HEAP32[tempDoublePtr >> 2] | 0) | 0;
- HEAP32[$45 >> 2] = 0 | (HEAPF32[tempDoublePtr >> 2] = ($14 < $28 ? $14 : $28) - $42, HEAP32[tempDoublePtr >> 2] | 0);
+ HEAP32[$45 >> 2] = 0 | $46;
HEAP32[$45 + 4 >> 2] = $_sroa_06_0_insert_insert$1;
HEAP32[$45 + 8 >> 2] = $_sroa_06_0_insert_insert$1;
}
@@ -298,4 +299,9 @@ function select2($foundBase_0_off0) {
STACKTOP = sp;
return ($foundBase_0_off0 ? 0 : $call24) | 0;
}
+function binary(x) {
+ x = x | 0;
+ memset(f(x)) | 0;
+ +dmemset(f(x));
+}
diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js
index 7ec277d5..4b45e4d4 100644
--- a/tools/eliminator/asm-eliminator-test.js
+++ b/tools/eliminator/asm-eliminator-test.js
@@ -370,5 +370,13 @@ function select2($foundBase_0_off0) {
STACKTOP = sp;
return $retval_0 | 0;
}
-// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2"]
+function binary(x) {
+ x = x | 0;
+ var y = 0, z = 0;
+ y = f(x);
+ memset(y) | 0;
+ z = f(x);
+ +dmemset(z);
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2", "binary"]
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js
index 0171e99b..4551fb34 100644
--- a/tools/eliminator/eliminator-test-output.js
+++ b/tools/eliminator/eliminator-test-output.js
@@ -6122,4 +6122,15 @@ function intoCond() {
function math(a, b, c, d) {
print(Math_imul(d) + (Math_fround(c) + (a + Math_abs(b))));
}
+function td(x, y) {
+ HEAP32[tempDoublePtr >> 2] = x;
+ var xf = HEAPF32[tempDoublePtr >> 2];
+ HEAP32[tempDoublePtr >> 2] = y;
+ func(xf, HEAPF32[tempDoublePtr >> 2]);
+ HEAPF64[tempDoublePtr >> 3] = x;
+ var xl = HEAP32[tempDoublePtr >> 2];
+ var xh = HEAP32[tempDoublePtr >> 2];
+ HEAPF64[tempDoublePtr >> 3] = y;
+ func(xl, xh, HEAP32[tempDoublePtr >> 2], HEAP32[tempDoublePtr >> 2]);
+}
diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js
index ef17b388..e629d9f0 100644
--- a/tools/eliminator/eliminator-test.js
+++ b/tools/eliminator/eliminator-test.js
@@ -8860,5 +8860,20 @@ function math(a, b, c, d) {
w = Math_imul(d);
print(x + y + z + w);
}
-// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond", "math"]
+function td(x, y) { // tempDoublePtr should invalidate each other
+ HEAP32[tempDoublePtr>>2] = x;
+ var xf = HEAPF32[tempDoublePtr>>2];
+ HEAP32[tempDoublePtr>>2] = y;
+ var yf = HEAPF32[tempDoublePtr>>2];
+ func(xf, yf);
+ //
+ HEAPF64[tempDoublePtr>>3] = x;
+ var xl = HEAP32[tempDoublePtr>>2];
+ var xh = HEAP32[tempDoublePtr>>2];
+ HEAPF64[tempDoublePtr>>3] = y;
+ var yl = HEAP32[tempDoublePtr>>2];
+ var yh = HEAP32[tempDoublePtr>>2];
+ func(xl, xh, yl, yh);
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond", "math", "td"]
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 7d9344cd..8b65b219 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -11,7 +11,7 @@ data downloads.
Usage:
- file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
+ file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
--crunch=X Will compress dxt files to crn with quality level X. The crunch commandline tool must be present
and CRUNCH should be defined in ~/.emscripten that points to it. JS crunch decompressing code will
@@ -45,9 +45,10 @@ import posixpath
import shared
from shared import Compression, execute, suffix, unsuffixed
from subprocess import Popen, PIPE, STDOUT
+import fnmatch
if len(sys.argv) == 1:
- print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
+ print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--exclude C...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy]
See the source for more details.'''
sys.exit(0)
@@ -66,10 +67,10 @@ DDS_HEADER_SIZE = 128
AV_WORKAROUND = 0 # Set to 1 to randomize file order and add some padding, to work around silly av false positives
data_files = []
-in_preload = False
-in_embed = False
+excluded_patterns = []
+leading = ''
has_preloaded = False
-in_compress = 0
+compress_cnt = 0
crunch = 0
plugins = []
jsoutput = None
@@ -81,45 +82,40 @@ use_preload_cache = False
# If set to False, the XHR blob is kept intact, and fread()s etc. are performed directly to that data. This optimizes for minimal memory usage and fread() performance.
no_heap_copy = True
-for arg in sys.argv[1:]:
+for arg in sys.argv[2:]:
if arg == '--preload':
- in_preload = True
- in_embed = False
has_preloaded = True
- in_compress = 0
+ leading = 'preload'
elif arg == '--embed':
- in_embed = True
- in_preload = False
- in_compress = 0
+ leading = 'embed'
+ elif arg == '--exclude':
+ leading = 'exclude'
elif arg == '--compress':
+ compress_cnt = 1
Compression.on = True
- in_compress = 1
- in_preload = False
- in_embed = False
+ leading = 'compress'
elif arg == '--no-force':
force = False
+ leading = ''
elif arg == '--use-preload-cache':
use_preload_cache = True
+ leading = ''
elif arg == '--no-heap-copy':
no_heap_copy = False
+ leading = ''
elif arg.startswith('--js-output'):
jsoutput = arg.split('=')[1] if '=' in arg else None
+ leading = ''
elif arg.startswith('--crunch'):
from shared import CRUNCH
crunch = arg.split('=')[1] if '=' in arg else '128'
- in_preload = False
- in_embed = False
- in_compress = 0
+ leading = ''
elif arg.startswith('--plugin'):
plugin = open(arg.split('=')[1], 'r').read()
eval(plugin) # should append itself to plugins
- in_preload = False
- in_embed = False
- in_compress = 0
- elif in_preload or in_embed:
- mode = 'preload'
- if in_embed:
- mode = 'embed'
+ leading = ''
+ elif leading == 'preload' or leading == 'embed':
+ mode = leading
if '@' in arg:
srcpath, dstpath = arg.split('@') # User is specifying destination filename explicitly.
else:
@@ -128,16 +124,21 @@ for arg in sys.argv[1:]:
data_files.append({ 'srcpath': srcpath, 'dstpath': dstpath, 'mode': mode })
else:
print >> sys.stderr, 'Warning: ' + arg + ' does not exist, ignoring.'
- elif in_compress:
- if in_compress == 1:
+ elif leading == 'exclude':
+ excluded_patterns.append(arg)
+ elif leading == 'compress':
+ if compress_cnt == 1:
Compression.encoder = arg
- in_compress = 2
- elif in_compress == 2:
+ compress_cnt = 2
+ elif compress_cnt == 2:
Compression.decoder = arg
- in_compress = 3
- elif in_compress == 3:
+ compress_cnt = 3
+ elif compress_cnt == 3:
Compression.js_name = arg
- in_compress = 0
+ compress_cnt = 0
+ else:
+ print >> sys.stderr, 'Unknown parameter:', arg
+ sys.exit(1)
if (not force) and len(data_files) == 0:
has_preloaded = False
@@ -172,16 +173,14 @@ def has_hidden_attribute(filepath):
result = False
return result
-# The packager should never preload/embed any directories that have a component starting with '.' in them,
-# or if the file is hidden (Win32). Note that this filter ONLY applies to directories. Explicitly specified single files
-# are always preloaded/embedded, even if they start with a '.'.
-def should_ignore(filename):
- if has_hidden_attribute(filename):
+# The packager should never preload/embed files if the file is hidden (Win32).
+# or it matches any pattern specified in --exclude
+def should_ignore(fullname):
+ if has_hidden_attribute(fullname):
return True
- components = filename.replace('\\\\', '/').replace('\\', '/').split('/')
- for c in components:
- if c.startswith('.') and c != '.' and c != '..':
+ for p in excluded_patterns:
+ if fnmatch.fnmatch(fullname, p):
return True
return False
@@ -190,20 +189,31 @@ def add(arg, dirname, names):
# rootpathsrc: The path name of the root directory on the local FS we are adding to emscripten virtual FS.
# rootpathdst: The name we want to make the source path available on the emscripten virtual FS.
mode, rootpathsrc, rootpathdst = arg
+ new_names = []
for name in names:
fullname = os.path.join(dirname, name)
- if not os.path.isdir(fullname):
- if should_ignore(fullname):
- if DEBUG:
- print >> sys.stderr, 'Skipping hidden file "' + fullname + '" from inclusion in the emscripten virtual file system.'
- else:
+ if should_ignore(fullname):
+ if DEBUG:
+ print >> sys.stderr, 'Skipping file "' + fullname + '" from inclusion in the emscripten virtual file system.'
+ else:
+ new_names.append(name)
+ if not os.path.isdir(fullname):
dstpath = os.path.join(rootpathdst, os.path.relpath(fullname, rootpathsrc)) # Convert source filename relative to root directory of target FS.
- data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode })
+ new_data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode })
+ del names[:]
+ names.extend(new_names)
+new_data_files = []
for file_ in data_files:
- if os.path.isdir(file_['srcpath']):
- os.path.walk(file_['srcpath'], add, [file_['mode'], file_['srcpath'], file_['dstpath']])
-data_files = filter(lambda file_: not os.path.isdir(file_['srcpath']), data_files)
+ if not should_ignore(file_['srcpath']):
+ if os.path.isdir(file_['srcpath']):
+ os.path.walk(file_['srcpath'], add, [file_['mode'], file_['srcpath'], file_['dstpath']])
+ else:
+ new_data_files.append(file_)
+data_files = filter(lambda file_: not os.path.isdir(file_['srcpath']), new_data_files)
+if len(data_files) == 0:
+ print >> sys.stderr, 'Nothing to do!'
+ sys.exit(1)
# Absolutize paths, and check that they make sense
curr_abspath = os.path.abspath(os.getcwd())
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 57ce0071..161ed59c 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -271,6 +271,16 @@ function isEmptyNode(node) {
return node.length === 2 && node[0] === 'toplevel' && node[1].length === 0;
}
+function clearEmptyNodes(list) {
+ for (var i = 0; i < list.length;) {
+ if (isEmptyNode(list[i]) || (list[i][0] === 'stat' && isEmptyNode(list[i][1]))) {
+ list.splice(i, 1);
+ } else {
+ i++;
+ }
+ }
+}
+
// Passes
// Dump the AST. Useful for debugging. For example,
@@ -585,12 +595,24 @@ function simplifyExpressions(ast) {
}
} else if (type === 'assign') {
// optimizations for assigning into HEAP32 specifically
- if (node[1] === true && node[2][0] === 'sub' && node[2][1][0] === 'name' && node[2][1][1] === 'HEAP32') {
- // HEAP32[..] = x | 0 does not need the | 0 (unless it is a mandatory |0 of a call)
- if (node[3][0] === 'binary' && node[3][1] === '|') {
- if (node[3][2][0] === 'num' && node[3][2][1] === 0 && node[3][3][0] != 'call') {
- node[3] = node[3][3];
- } else if (node[3][3][0] === 'num' && node[3][3][1] === 0 && node[3][2][0] != 'call') {
+ if (node[1] === true && node[2][0] === 'sub' && node[2][1][0] === 'name') {
+ if (node[2][1][1] === 'HEAP32') {
+ // HEAP32[..] = x | 0 does not need the | 0 (unless it is a mandatory |0 of a call)
+ if (node[3][0] === 'binary' && node[3][1] === '|') {
+ if (node[3][2][0] === 'num' && node[3][2][1] === 0 && node[3][3][0] != 'call') {
+ node[3] = node[3][3];
+ } else if (node[3][3][0] === 'num' && node[3][3][1] === 0 && node[3][2][0] != 'call') {
+ node[3] = node[3][2];
+ }
+ }
+ } else if (node[2][1][1] === 'HEAP8') {
+ // HEAP8[..] = x & 0xff does not need the & 0xff
+ if (node[3][0] === 'binary' && node[3][1] === '&' && node[3][3][0] == 'num' && node[3][3][1] == 0xff) {
+ node[3] = node[3][2];
+ }
+ } else if (node[2][1][1] === 'HEAP16') {
+ // HEAP16[..] = x & 0xffff does not need the & 0xffff
+ if (node[3][0] === 'binary' && node[3][1] === '&' && node[3][3][0] == 'num' && node[3][3][1] == 0xffff) {
node[3] = node[3][2];
}
}
@@ -2122,7 +2144,7 @@ function registerize(ast) {
// In memSafe mode, we are more careful and assume functions can replace HEAP and FUNCTION_TABLE, which
// can happen in ALLOW_MEMORY_GROWTH mode
-var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel', 'do', 'return', 'label', 'switch'); // do is checked carefully, however
+var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel', 'do', 'return', 'label', 'switch', 'binary', 'unary-prefix'); // do is checked carefully, however
var IGNORABLE_ELIMINATOR_SCAN_NODES = set('num', 'toplevel', 'string', 'break', 'continue', 'dot'); // dot can only be STRING_TABLE.*
var ABORTING_ELIMINATOR_SCAN_NODES = set('new', 'object', 'function', 'defun', 'for', 'while', 'array', 'throw'); // we could handle some of these, TODO, but nontrivial (e.g. for while, the condition is hit multiple times after the body)
@@ -2412,7 +2434,12 @@ function eliminate(ast, memSafe) {
if (allowTracking) track(name, node[3], node);
}
} else if (target[0] === 'sub') {
- if (!isTempDoublePtrAccess(target) && !memoryInvalidated) {
+ if (isTempDoublePtrAccess(target)) {
+ if (!globalsInvalidated) {
+ invalidateGlobals();
+ globalsInvalidated = true;
+ }
+ } else if (!memoryInvalidated) {
invalidateMemory();
memoryInvalidated = true;
}
@@ -2672,6 +2699,7 @@ function eliminate(ast, memSafe) {
}
if (ifTrue[1][0] && ifTrue[1][0][0] === 'break') {
var assigns = ifFalse[1];
+ clearEmptyNodes(assigns);
var loopers = [], helpers = [];
for (var i = 0; i < assigns.length; i++) {
if (assigns[i][0] === 'stat' && assigns[i][1][0] === 'assign') {
@@ -3097,6 +3125,17 @@ function outline(ast) {
parts = [];
var curr = node;
while (1) {
+ if (!curr[3]) {
+ // we normally expect ..if (cond) { .. } else [if (nextCond) {] (in [] is what we hope to see)
+ // but are now seeing ..if (cond) { .. } with no else. This might be
+ // ..if (cond) if (nextCond) {
+ // which vacuum can generate from if (cond) {} else if (nextCond), making it
+ // if (!cond) if (nextCond)
+ // so we undo that, in hopes of making it more flattenable
+ curr[3] = curr[2];
+ curr[2] = ['block', []];
+ curr[1] = simplifyNotCompsDirect(['unary-prefix', '!', curr[1]]);
+ }
parts.push({ condition: curr[1], body: curr[2] });
curr = curr[3];
if (!curr) break;
diff --git a/tools/shared.py b/tools/shared.py
index 3eb72a1e..5b02fa4c 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -176,13 +176,28 @@ if WINDOWS:
else:
logging.StreamHandler.emit = add_coloring_to_emit_ansi(logging.StreamHandler.emit)
-# Emscripten configuration is done through the EM_CONFIG environment variable.
-# If the string value contained in this environment variable contains newline
-# separated definitions, then these definitions will be used to configure
+# Emscripten configuration is done through the --em-config command line option or
+# the EM_CONFIG environment variable. If the specified string value contains newline
+# or semicolon-separated definitions, then these definitions will be used to configure
# Emscripten. Otherwise, the string is understood to be a path to a settings
# file that contains the required definitions.
-EM_CONFIG = os.environ.get('EM_CONFIG')
+try:
+ EM_CONFIG = sys.argv[sys.argv.index('--em-config')+1]
+ # Emscripten compiler spawns other processes, which can reimport shared.py, so make sure that
+ # those child processes get the same configuration file by setting it to the currently active environment.
+ os.environ['EM_CONFIG'] = EM_CONFIG
+except:
+ EM_CONFIG = os.environ.get('EM_CONFIG')
+
+if EM_CONFIG and not os.path.isfile(EM_CONFIG):
+ if EM_CONFIG.startswith('-'):
+ raise Exception('Passed --em-config without an argument. Usage: --em-config /path/to/.emscripten or --em-config EMSCRIPTEN_ROOT=/path/;LLVM_ROOT=/path;...')
+ if not '=' in EM_CONFIG:
+ raise Exception('File ' + EM_CONFIG + ' passed to --em-config does not exist!')
+ else:
+ EM_CONFIG = EM_CONFIG.replace(';', '\n') + '\n'
+
if not EM_CONFIG:
EM_CONFIG = '~/.emscripten'
if '\n' in EM_CONFIG:
@@ -271,6 +286,21 @@ def check_llvm_version():
except Exception, e:
logging.warning('Could not verify LLVM version: %s' % str(e))
+def check_fastcomp():
+ try:
+ llc_version_info = Popen([LLVM_COMPILER, '--version'], stdout=PIPE).communicate()[0]
+ pre, targets = llc_version_info.split('Registered Targets:')
+ if 'js' not in targets or 'JavaScript (asm.js, emscripten) backend' not in targets:
+ logging.critical('fastcomp in use, but LLVM has not been built with the JavaScript backend as a target, llc reports:')
+ print >> sys.stderr, '==========================================================================='
+ print >> sys.stderr, llc_version_info,
+ print >> sys.stderr, '==========================================================================='
+ return False
+ return True
+ except Exception, e:
+ logging.warning('cound not check fastcomp: %s' % str(e))
+ return True
+
EXPECTED_NODE_VERSION = (0,8,0)
def check_node_version():
@@ -307,7 +337,7 @@ def find_temp_directory():
# we re-check sanity when the settings are changed)
# We also re-check sanity and clear the cache when the version changes
-EMSCRIPTEN_VERSION = '1.7.8'
+EMSCRIPTEN_VERSION = '1.8.2'
def generate_sanity():
return EMSCRIPTEN_VERSION + '|' + get_llvm_target() + '|' + LLVM_ROOT
@@ -316,7 +346,7 @@ def check_sanity(force=False):
try:
reason = None
if not CONFIG_FILE:
- if not force: return # config stored directly in EM_CONFIG => skip sanity checks
+ return # config stored directly in EM_CONFIG => skip sanity checks
else:
settings_mtime = os.stat(CONFIG_FILE).st_mtime
sanity_file = CONFIG_FILE + '_sanity'
@@ -338,9 +368,11 @@ def check_sanity(force=False):
Cache.erase()
force = False # the check actually failed, so definitely write out the sanity file, to avoid others later seeing failures too
- # some warning, not fatal checks - do them even if EM_IGNORE_SANITY is on
+ # some warning, mostly not fatal checks - do them even if EM_IGNORE_SANITY is on
check_llvm_version()
check_node_version()
+ if os.environ.get('EMCC_FAST_COMPILER') == '1':
+ fastcomp_ok = check_fastcomp()
if os.environ.get('EM_IGNORE_SANITY'):
logging.info('EM_IGNORE_SANITY set, ignoring sanity checks')
@@ -362,6 +394,11 @@ def check_sanity(force=False):
logging.critical('Cannot find %s, check the paths in %s' % (cmd, EM_CONFIG))
sys.exit(1)
+ if os.environ.get('EMCC_FAST_COMPILER') == '1':
+ if not fastcomp_ok:
+ logging.critical('failing sanity checks due to previous fastcomp failure')
+ sys.exit(1)
+
try:
subprocess.call([JAVA, '-version'], stdout=PIPE, stderr=PIPE)
except:
@@ -637,7 +674,7 @@ def check_engine(engine):
try:
if not CONFIG_FILE:
return True # config stored directly in EM_CONFIG => skip engine check
- return 'hello, world!' in run_js(path_from_root('tests', 'hello_world.js'), engine)
+ return 'hello, world!' in run_js(path_from_root('src', 'hello_world.js'), engine)
except Exception, e:
print 'Checking JS engine %s failed. Check %s. Details: %s' % (str(engine), EM_CONFIG, str(e))
return False
@@ -667,7 +704,7 @@ def line_splitter(data):
return out
-def limit_size(string, MAX=12000*20):
+def limit_size(string, MAX=800*20):
if len(string) < MAX: return string
return string[0:MAX/2] + '\n[..]\n' + string[-MAX/2:]
@@ -926,7 +963,7 @@ class Building:
@staticmethod
- def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None, native=False):
+ def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args='help', cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None, native=False):
''' Build a library into a .bc file. We build the .bc file once and cache it for all our tests. (We cache in
memory since the test directory is destroyed and recreated for each test. Note that we cache separately
for different compilers).
@@ -934,6 +971,8 @@ class Building:
if type(generated_libs) is not list: generated_libs = [generated_libs]
if source_dir is None: source_dir = path_from_root('tests', name.replace('_native', ''))
+ if make_args == 'help':
+ make_args = ['-j', str(multiprocessing.cpu_count())]
temp_dir = build_dir
if copy_project:
@@ -1077,7 +1116,7 @@ class Building:
# 8k is a bit of an arbitrary limit, but a reasonable one
# for max command line size before we use a respose file
response_file = None
- if WINDOWS and len(' '.join(link_cmd)) > 8192:
+ if len(' '.join(link_cmd)) > 8192:
logging.debug('using response file for llvm-link')
[response_fd, response_file] = mkstemp(suffix='.response', dir=TEMP_DIR)
@@ -1421,7 +1460,7 @@ class Building:
@staticmethod
def ensure_relooper(relooper):
if os.path.exists(relooper): return
- if os.environ.get('EMCC_FAST_COMPILER'):
+ if os.environ.get('EMCC_FAST_COMPILER') == '1':
logging.debug('not building relooper to js, using it in c++ backend')
return
@@ -1496,6 +1535,8 @@ class Building:
text = m.groups(0)[0]
assert text.count('(') == 1 and text.count(')') == 1, 'must have simple expressions in emscripten_jcache_printf calls, no parens'
assert text.count('"') == 2, 'must have simple expressions in emscripten_jcache_printf calls, no strings as varargs parameters'
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': # fake it in fastcomp
+ return text.replace('emscripten_jcache_printf', 'printf')
start = text.index('(')
end = text.rindex(')')
args = text[start+1:end].split(',')
diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js
index 2e3db000..0fa81050 100644
--- a/tools/test-js-optimizer-asm-pre-output.js
+++ b/tools/test-js-optimizer-asm-pre-output.js
@@ -58,12 +58,14 @@ function b($this, $__n) {
_memset($38 + $23 | 0, 0, $__n | 0, 1, 1213141516);
$40 = $23 + $__n | 0;
if ((HEAP8[$4 & 16777215] & 1) == 0) {
- HEAP8[$4 & 16777215] = $40 << 1 & 255;
+ HEAP8[$4 & 16777215] = $40 << 1;
} else {
HEAP32[($this + 4 & 16777215) >> 2] = $40;
}
HEAP8[$38 + $40 & 16777215] = 0;
HEAP32[$4] = ~HEAP32[$5];
+ HEAP8[$4] = HEAP32[$5];
+ HEAP16[$4] = HEAP32[$5];
HEAP32[$4] = ~HEAP32[$5];
HEAP32[$4] = ~HEAP32[$5];
h(~~g ^ -1);
@@ -240,10 +242,10 @@ function _main($argc, $argv) {
}
if (($i_09_i_i | 0) > (HEAP32[9600 + ($j_08_i_i << 2) >> 2] | 0)) {
$34 = $j_08_i_i + 1 | 0;
- HEAP8[$i_09_i_i + 8952 | 0] = $34 & 255;
+ HEAP8[$i_09_i_i + 8952 | 0] = $34;
$j_1_i_i = $34;
} else {
- HEAP8[$i_09_i_i + 8952 | 0] = $j_08_i_i & 255;
+ HEAP8[$i_09_i_i + 8952 | 0] = $j_08_i_i;
$j_1_i_i = $j_08_i_i;
}
$38 = $i_09_i_i + 1 | 0;
diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js
index 9e6edf0f..dadeef53 100644
--- a/tools/test-js-optimizer-asm-pre.js
+++ b/tools/test-js-optimizer-asm-pre.js
@@ -66,6 +66,10 @@ function b($this, $__n) {
HEAP8[($38 + $40 | 0) & 16777215] = 0;
// Eliminate the |0.
HEAP32[$4] = ((~(HEAP32[$5]|0))|0);
+ // Eliminate the &255
+ HEAP8[$4] = HEAP32[$5]&255;
+ // Eliminate the &65535
+ HEAP16[$4] = HEAP32[$5]&65535;
// Rewrite to ~.
HEAP32[$4] = HEAP32[$5]^-1;
// Rewrite to ~ and eliminate the |0.