├── m2c ├── py.typed ├── __init__.py └── error.py ├── tests ├── unit │ └── __init__.py └── end_to_end │ ├── incbin │ ├── test.bin │ ├── manual-flags.txt │ ├── manual-out.c │ └── manual.s │ ├── break │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── loop │ ├── agbcc-o0-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── agbcc-o0-out.c │ └── irix-g-out.c │ ├── lwl │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── misc1 │ ├── agbcc-o2-flags.txt │ ├── irix-o2-regvars-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── irix-o2-stacklow-flags.txt │ └── irix-o2-validsyntax-flags.txt │ ├── nor │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ ├── mwcc-o4p.s │ ├── agbcc-o2.s │ └── irix-o2.s │ ├── return-detection │ ├── ctx.c │ ├── ppc-void-flags.txt │ ├── circular-phis-ctx-flags.txt │ ├── ppc-void-out.c │ ├── conditional-use-out.c │ ├── circular-phis2-out.c │ ├── circular-phis-out.c │ ├── conditional-use.s │ ├── circular-phis-ctx-out.c │ └── circular-phis-ctx.s │ ├── sqrt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ └── agbcc-o2-out.c │ ├── switch │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── test │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── abs-sqrt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── irix-o2-out.c │ ├── irix-g-out.c │ ├── orig.c │ └── mwcc-o4p-out.c │ ├── arguments │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ └── agbcc-o2-out.c │ ├── arrays │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ └── agbcc-o2-out.c │ ├── big-stack │ └── agbcc-o2-flags.txt │ ├── comparison │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ └── irix-o2-out.c │ ├── division │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── mwcc-o4p.s │ └── agbcc-o2.s │ ├── doubles │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ └── irix-g-out.c │ ├── float-fn │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── mwcc-o4p-out.c │ ├── irix-o2-out.c │ ├── orig.c │ ├── irix-g-out.c │ └── agbcc-o2-out.c │ ├── if-bitand │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ └── orig.c │ ├── if_postdec │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── agbcc-o2-out.c │ └── mwcc-o4p-out.c │ ├── int-float │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── mwcc-o4p-out.c │ ├── orig.c │ └── irix-g-out.c │ ├── load-types │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ └── mwcc-o4p-out.c │ ├── loop_with_if │ ├── irix-o2-allman-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── nested_ifs │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── rlwimi │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ └── orig.c │ ├── skip-casts │ ├── manual-flags.txt │ ├── manual-out.c │ └── manual.s │ ├── struct │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ └── orig.c │ ├── switch-with-if │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── abi-float-regs │ ├── agbcc-o2-flags.txt │ └── orig.c │ ├── andor_loops │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── andor_mixed │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── andor_return │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ └── mwcc-o4p-out.c │ ├── array-access │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── mwcc-o4p-out.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── custom-return │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── jump-into-loop │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ └── agbcc-o2-out.c │ ├── loop_nested │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── irix-o2-detvar-flags.txt │ └── orig.c │ ├── mipsee-mult1 │ └── test-flags.txt │ ├── mult-by-two │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── mwcc-o4p-out.c │ └── irix-o2-out.c │ ├── nested_ifs2 │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── orig.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── nested_ifs3 │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── orig.c │ └── mwcc-o4p-out.c │ ├── nested_ifs4 │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ └── orig.c │ ├── recursive-type │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ └── mwcc-o4p-out.c │ ├── return-float │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── agbcc-o2-out.c │ ├── rodata-literals │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ └── agbcc-o2-out.c │ ├── stack_reference │ ├── irix-o2-nocontext-flags.txt │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── irix-o2-out.c │ ├── irix-o2-nocontext-out.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── orig.c │ ├── mwcc-o4p-out.c │ └── agbcc-o2.s │ ├── store-casts │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ ├── agbcc-o2-out.c │ └── orig.c │ ├── struct-copy │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── gcc-mipsel-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── irix-o2-out.c │ └── irix-o2-mips1-out.c │ ├── void_pointers │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── irix-g-out.c │ ├── mwcc-o4p-out.c │ ├── orig.c │ ├── agbcc-o2-out.c │ └── irix-o2-out.c │ ├── andor_assignment │ ├── agbcc-o2-flags.txt │ ├── irix-o2-noandor-flags.txt │ ├── mwcc-o4p-flags.txt │ └── irix-o2-detvar-flags.txt │ ├── andor_assignment2 │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── float-conversions │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── mwcc-o4p-out.c │ ├── orig.c │ └── irix-g-out.c │ ├── fn-write-reordering │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── function-pointer │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── mwcc-o4p-out.c │ ├── irix-o2-out.c │ └── agbcc-o2.s │ ├── gcc-attributes │ ├── test.s │ └── test-flags.txt │ ├── int-float-doublelit │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── mwcc-o4p-out.c │ └── orig.c │ ├── large-struct-offset │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ └── orig.c │ ├── loop-selfassign-phi │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ └── irix-o2-out.c │ ├── mult-by-constant │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── multiple-assigns │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── ptr-inference │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ └── orig.c │ ├── signed-conversion │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ └── mwcc-o4p-out.c │ ├── switch-with-default │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── typedef │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── context.c │ ├── orig.c │ ├── irix-o2-out.c │ ├── irix-g-out.c │ ├── agbcc-o2-out.c │ └── mwcc-o4p-out.c │ ├── unreachable-return │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── mwcc-o4p-out.c │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p.s │ └── agbcc-o2.s │ ├── unreachable-return2 │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── irix-g-out.c │ └── irix-o2-out.c │ ├── asm-arith │ ├── test-flags.txt │ ├── test-out.c │ └── test.s │ ├── complicated_context │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ └── irix-o2-typemap-flags.txt │ ├── division-by-power-of-two │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── ido53-o2-out.c │ ├── ido71-o2-out.c │ ├── mwcc-o4p-out.c │ ├── orig.c │ ├── agbcc-o2-out.c │ ├── agbcc-o2.s │ └── mwcc-o4p.s │ ├── enums │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-out.c │ ├── irix-o2-out.c │ └── agbcc-o2-out.c │ ├── flexible-array-members │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── irix-o2-out.c │ ├── agbcc-o2-out.c │ └── orig.c │ ├── float-branch-evalonce │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── mwcc-o4p-out.c │ └── irix-o2-out.c │ ├── hi-offsets-type-info │ ├── manual-flags.txt │ ├── manual-out.c │ ├── manual.s │ └── context.c │ ├── ir-pattern-input │ ├── manual-flags.txt │ ├── manual.s │ └── manual-out.c │ ├── known_called_function │ ├── irix-o2-flags.txt │ ├── irix-g-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-flags.txt │ ├── irix-g-out.c │ ├── agbcc-o2-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ └── orig.c │ ├── modulo-by-power-of-two │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── mwcc-o4p-out.c │ ├── ido53-o2-out.c │ ├── ido71-o2-out.c │ ├── orig.c │ ├── agbcc-o2-out.c │ └── agbcc-o2.s │ ├── phi-recursive-struct │ ├── test-flags.txt │ ├── context.c │ └── test-out.c │ ├── premature_returns_all │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── orig.c │ └── agbcc-o2.s │ ├── premature_returns_none │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ ├── orig.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── agbcc-o2.s │ └── mwcc-o4p.s │ ├── premature_returns_one │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ ├── irix-g-out.c │ ├── irix-o2-out.c │ ├── agbcc-o2-out.c │ ├── mwcc-o4p-out.c │ └── agbcc-o2.s │ ├── switch-different-block │ └── agbcc-o2-flags.txt │ ├── unsized-pointers │ ├── manual-flags.txt │ ├── context.c │ ├── manual-out.c │ └── manual.s │ ├── duplicated-early-returns │ ├── gotos-only-flags.txt │ ├── manual-out.c │ ├── manual.s │ ├── gotos-only.s │ └── gotos-only-out.c │ ├── eabi64 │ ├── eabi64-int-float-args-flags.txt │ ├── ctx.c │ ├── eabi64-int-float-args-ctx-flags.txt │ ├── eabi64-int-float-args-ctx-out.c │ └── eabi64-int-float-args-out.c │ ├── function-pointer2 │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── context.c │ ├── mwcc-o4p-flags.txt │ ├── agbcc-o2-out.c │ ├── irix-o2-out.c │ ├── mwcc-o4p-out.c │ └── orig.c │ ├── global_floats │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ └── mwcc-o4p-flags.txt │ ├── no-ifs-early-returns │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── orig.c │ └── irix-o2-out.c │ ├── recursive-struct │ ├── test-flags.txt │ ├── context.c │ └── test.s │ ├── custom_stack │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ └── agbcc-o2-flags.txt │ ├── large-struct-member-address │ ├── manual-flags.txt │ ├── context.c │ ├── manual.s │ └── manual-out.c │ ├── ppc-packed-singles-saved-registers │ ├── manual-flags.txt │ └── manual-out.c │ ├── gcc-division-by-two │ ├── s16-out.c │ ├── s32-out.c │ ├── s32.s │ └── s16.s │ ├── union_override │ ├── test-flags.txt │ ├── test-out.c │ ├── test.s │ └── ctx.h │ ├── arg-temp │ ├── test.s │ └── test-out.c │ ├── gcc-sqrtf │ ├── with-mov-out.c │ ├── with-trunc-out.c │ ├── with-trunc.s │ └── with-mov.s │ ├── multiple_context │ ├── context_1.c │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ ├── context_3.c │ ├── context_2.c │ └── agbcc-o2-out.c │ ├── union_override_samesize │ ├── test-flags.txt │ ├── test-out.c │ └── test.s │ ├── multi-switch │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ └── irix-o2-noswitch-flags.txt │ ├── branch-likely-b │ ├── manual-out.c │ └── manual.s │ ├── global_decls │ ├── irix-o2-flags.txt │ ├── irix-o2-noemitglobals-flags.txt │ ├── agbcc-o2-flags.txt │ └── irix-o2-allglobals-flags.txt │ ├── struct-copy2 │ ├── agbcc-o2-flags.txt │ ├── mwcc-o0p-flags.txt │ └── mwcc-o4p-flags.txt │ ├── trapuv │ ├── orig.c │ └── irix-o2-trapuv-out.c │ ├── tail-call │ ├── non-tail-call-out.c │ ├── tail-call-ps2.s │ ├── tail-call-ps2-out.c │ └── non-tail-call.s │ ├── empty-if │ ├── manual-out.c │ └── manual.s │ ├── phi-prevent │ ├── manual.s │ └── manual-out.c │ ├── conditional-moves │ ├── manual-out.c │ └── manual.s │ ├── delay-slot-branch │ ├── manual.s │ └── manual-out.c │ ├── branch-likely-general │ ├── manual-out.c │ └── manual.s │ ├── gcc-division │ ├── irix-g-flags.txt │ ├── irix-o2-flags.txt │ ├── agbcc-o2-flags.txt │ ├── gcc-o2-flags.txt │ ├── mwcc-o4p-flags.txt │ └── mwcc27-o4p-flags.txt │ ├── phi-samevalue-replacement │ ├── manual.s │ └── manual-out.c │ ├── seb-seh │ ├── seb-mwcc-out.c │ ├── seh-mwcc-out.c │ ├── seb-mwcc.s │ └── seh-mwcc.s │ ├── branch-likely-one-instruction │ ├── manual-out.c │ └── manual.s │ ├── cpp_vtables │ └── mwcc-o4p-flags.txt │ ├── ida │ ├── handwritten-out.c │ └── handwritten.s │ ├── ps2 │ ├── manual_mwcc-out.c │ ├── manual-out.c │ └── manual.s │ ├── var-prevent-bug │ ├── manual-out.c │ └── manual.s │ ├── weird-asm │ └── test-out.c │ ├── phi-output2 │ └── test.s │ ├── phis-1 │ ├── manual-out.c │ └── manual.s │ └── phi-output │ └── test.s ├── m2c_pycparser ├── tests │ ├── __init__.py │ ├── c_files │ │ ├── hdir │ │ │ └── 9 │ │ │ │ └── inc.h │ │ ├── simplemain.c │ │ ├── empty.h │ │ └── example_c_file.c │ ├── README.txt │ └── fake_libc_include │ │ ├── _ansi.h │ │ ├── aio.h │ │ ├── ar.h │ │ ├── argz.h │ │ ├── cpio.h │ │ ├── ctype.h │ │ ├── dlfcn.h │ │ ├── envz.h │ │ ├── errno.h │ │ ├── fcntl.h │ │ ├── fenv.h │ │ ├── float.h │ │ ├── ftw.h │ │ ├── glob.h │ │ ├── grp.h │ │ ├── iconv.h │ │ ├── math.h │ │ ├── ndbm.h │ │ ├── netdb.h │ │ ├── paths.h │ │ ├── poll.h │ │ ├── pwd.h │ │ ├── reent.h │ │ ├── regex.h │ │ ├── sched.h │ │ ├── spawn.h │ │ ├── stdio.h │ │ ├── tar.h │ │ ├── time.h │ │ ├── trace.h │ │ ├── utime.h │ │ ├── utmp.h │ │ ├── utmpx.h │ │ ├── wchar.h │ │ ├── _syslist.h │ │ ├── alloca.h │ │ ├── arpa │ │ └── inet.h │ │ ├── assert.h │ │ ├── complex.h │ │ ├── dirent.h │ │ ├── emmintrin.h │ │ ├── endian.h │ │ ├── fastmath.h │ │ ├── features.h │ │ ├── fmtmsg.h │ │ ├── fnmatch.h │ │ ├── getopt.h │ │ ├── ieeefp.h │ │ ├── immintrin.h │ │ ├── inttypes.h │ │ ├── iso646.h │ │ ├── langinfo.h │ │ ├── libgen.h │ │ ├── libintl.h │ │ ├── limits.h │ │ ├── locale.h │ │ ├── malloc.h │ │ ├── monetary.h │ │ ├── mqueue.h │ │ ├── net │ │ └── if.h │ │ ├── netinet │ │ ├── in.h │ │ └── tcp.h │ │ ├── newlib.h │ │ ├── nl_types.h │ │ ├── process.h │ │ ├── pthread.h │ │ ├── regdef.h │ │ ├── search.h │ │ ├── semaphore.h │ │ ├── setjmp.h │ │ ├── signal.h │ │ ├── smmintrin.h │ │ ├── stdalign.h │ │ ├── stdarg.h │ │ ├── stdatomic.h │ │ ├── stdbool.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── stdlib.h │ │ ├── string.h │ │ ├── strings.h │ │ ├── stropts.h │ │ ├── sys │ │ ├── ioctl.h │ │ ├── ipc.h │ │ ├── mman.h │ │ ├── msg.h │ │ ├── poll.h │ │ ├── select.h │ │ ├── sem.h │ │ ├── shm.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── sysctl.h │ │ ├── time.h │ │ ├── times.h │ │ ├── types.h │ │ ├── uio.h │ │ ├── un.h │ │ ├── wait.h │ │ ├── resource.h │ │ ├── statvfs.h │ │ └── utsname.h │ │ ├── syslog.h │ │ ├── termios.h │ │ ├── tgmath.h │ │ ├── threads.h │ │ ├── ulimit.h │ │ ├── unctrl.h │ │ ├── unistd.h │ │ ├── wctype.h │ │ ├── wordexp.h │ │ ├── xcb │ │ └── xcb.h │ │ ├── linux │ │ ├── socket.h │ │ └── version.h │ │ ├── openssl │ │ ├── err.h │ │ ├── evp.h │ │ ├── hmac.h │ │ ├── ssl.h │ │ └── x509v3.h │ │ ├── stdnoreturn.h │ │ ├── asm-generic │ │ └── int-ll64.h │ │ ├── mir_toolkit │ │ └── client_types.h │ │ └── X11 │ │ ├── Xlib.h │ │ ├── Intrinsic.h │ │ └── _X11_fake_defines.h ├── .gitattributes ├── ply │ └── __init__.py ├── README └── test.py ├── m2c.py └── .pre-commit-config.yaml /m2c/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /m2c/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/unit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/end_to_end/incbin/test.bin: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /tests/end_to_end/break/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop/agbcc-o0-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/lwl/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/misc1/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/ctx.c: -------------------------------------------------------------------------------- 1 | s32 test(); 2 | -------------------------------------------------------------------------------- /tests/end_to_end/sqrt/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --no-andor 2 | -------------------------------------------------------------------------------- /tests/end_to_end/test/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/c_files/hdir/9/inc.h: -------------------------------------------------------------------------------- 1 | extern int ie; 2 | -------------------------------------------------------------------------------- /tests/end_to_end/abs-sqrt/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/arguments/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/arrays/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/big-stack/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/comparison/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/division/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/doubles/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/float-fn/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/if-bitand/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/if_postdec/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/incbin/manual-flags.txt: -------------------------------------------------------------------------------- 1 | --incbin-dir . 2 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/load-types/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/irix-o2-allman-flags.txt: -------------------------------------------------------------------------------- 1 | --allman -------------------------------------------------------------------------------- /tests/end_to_end/lwl/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/rlwimi/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/skip-casts/manual-flags.txt: -------------------------------------------------------------------------------- 1 | --no-casts 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --unk-underscore 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch-with-if/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --void 2 | -------------------------------------------------------------------------------- /tests/end_to_end/abi-float-regs/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/abs-sqrt/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_loops/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_mixed/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_return/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/arrays/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/break/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/custom-return/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/division/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/doubles/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/float-fn/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/jump-into-loop/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_nested/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/mipsee-mult1/test-flags.txt: -------------------------------------------------------------------------------- 1 | -f test2 -f test3 2 | -------------------------------------------------------------------------------- /tests/end_to_end/misc1/irix-o2-regvars-flags.txt: -------------------------------------------------------------------------------- 1 | --reg-vars all 2 | -------------------------------------------------------------------------------- /tests/end_to_end/misc1/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/mult-by-two/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs2/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs3/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs4/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-type/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/return-float/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/rlwimi/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/rodata-literals/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/sqrt/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/irix-o2-nocontext-flags.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/test/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_assignment/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_assignment2/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_loops/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_mixed/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_return/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/arguments/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/comparison/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/custom-return/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/float-conversions/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/fn-write-reordering/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-attributes/test.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | jr $ra 3 | nop 4 | -------------------------------------------------------------------------------- /tests/end_to_end/if-bitand/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/if_postdec/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float-doublelit/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-offset/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/load-types/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop-selfassign-phi/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_nested/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/misc1/irix-o2-stacklow-flags.txt: -------------------------------------------------------------------------------- 1 | --target=mips-gcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/mult-by-constant/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/mult-by-two/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple-assigns/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs2/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs3/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs4/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/ptr-inference/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/return-float/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/signed-conversion/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch-with-default/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --no-andor 2 | --hex-case 3 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --void 2 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --void 2 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return2/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_assignment/irix-o2-noandor-flags.txt: -------------------------------------------------------------------------------- 1 | --no-andor 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_assignment/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_assignment2/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/asm-arith/test-flags.txt: -------------------------------------------------------------------------------- 1 | -D sym1 -D sym2=0x10 -U sym3 2 | -------------------------------------------------------------------------------- /tests/end_to_end/complicated_context/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/complicated_context/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/enums/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --globals=all 2 | -------------------------------------------------------------------------------- /tests/end_to_end/enums/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --globals=all 2 | -------------------------------------------------------------------------------- /tests/end_to_end/flexible-array-members/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/float-branch-evalonce/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/float-conversions/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/hi-offsets-type-info/manual-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/ir-pattern-input/manual-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/jump-into-loop/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_nested/irix-o2-detvar-flags.txt: -------------------------------------------------------------------------------- 1 | --deterministic-vars 2 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/mult-by-constant/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple-assigns/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-recursive-struct/test-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-type/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/ppc-void-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/rodata-literals/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/signed-conversion/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy/gcc-mipsel-flags.txt: -------------------------------------------------------------------------------- 1 | --target mipsel-gcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch-different-block/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch-with-if/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --void --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/unsized-pointers/manual-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c 2 | -------------------------------------------------------------------------------- /m2c.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from m2c.main import main 3 | 4 | main() 5 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_assignment/irix-o2-detvar-flags.txt: -------------------------------------------------------------------------------- 1 | --deterministic-vars 2 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/duplicated-early-returns/gotos-only-flags.txt: -------------------------------------------------------------------------------- 1 | --gotos-only 2 | -------------------------------------------------------------------------------- /tests/end_to_end/eabi64/eabi64-int-float-args-flags.txt: -------------------------------------------------------------------------------- 1 | --target mipsee-gcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/enums/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c --context orig.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/float-branch-evalonce/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/fn-write-reordering/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --void 2 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-attributes/test-flags.txt: -------------------------------------------------------------------------------- 1 | --context test.c --dump-typemap 2 | -------------------------------------------------------------------------------- /tests/end_to_end/global_floats/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --globals=all 2 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float-doublelit/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-offset/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/loop-selfassign-phi/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/no-ifs-early-returns/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --gotos-only --void 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/ptr-inference/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-struct/test-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --passes 1 2 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/circular-phis-ctx-flags.txt: -------------------------------------------------------------------------------- 1 | --context ctx.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --unk-underscore --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch-with-default/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch-with-if/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --void --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --no-andor --hex-case --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return2/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target gba 2 | -------------------------------------------------------------------------------- /m2c_pycparser/.gitattributes: -------------------------------------------------------------------------------- 1 | /yacctab.py -diff -merge 2 | /lextab.py -diff -merge 3 | -------------------------------------------------------------------------------- /tests/end_to_end/custom_stack/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --stack-structs --no-unk-inference 2 | -------------------------------------------------------------------------------- /tests/end_to_end/custom_stack/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --stack-structs 2 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-member-address/manual-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --void --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/complicated_context/irix-o2-typemap-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --dump-typemap -------------------------------------------------------------------------------- /tests/end_to_end/division/orig.c: -------------------------------------------------------------------------------- 1 | int test(int a, int b) { 2 | return a / b; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/enums/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --globals=all --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/flexible-array-members/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/misc1/irix-o2-validsyntax-flags.txt: -------------------------------------------------------------------------------- 1 | --valid-syntax --comment-style=none 2 | -------------------------------------------------------------------------------- /tests/end_to_end/no-ifs-early-returns/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --gotos-only --void --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/orig.c: -------------------------------------------------------------------------------- 1 | 2 | int test(int a, int b) { 3 | return ~(a | b); 4 | } 5 | -------------------------------------------------------------------------------- /tests/end_to_end/ppc-packed-singles-saved-registers/manual-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/ptr-inference/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/switch/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --no-andor 2 | --hex-case --target ppc-mwcc-c 3 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --void --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/global_floats/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --globals=all --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/hi-offsets-type-info/manual-out.c: -------------------------------------------------------------------------------- 1 | s32 test(void) { 2 | return a.b; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --pointer-style left 2 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/no-ifs-early-returns/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --no-ifs --void --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/return-float/orig.c: -------------------------------------------------------------------------------- 1 | float test(float x) { 2 | return x ? 15.0f : x; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --void --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(void) { 2 | test(); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/custom_stack/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --stack-structs --no-unk-inference --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/eabi64/ctx.c: -------------------------------------------------------------------------------- 1 | void no_args_func(); 2 | void func_with_args(float, int, float, int); 3 | -------------------------------------------------------------------------------- /tests/end_to_end/eabi64/eabi64-int-float-args-ctx-flags.txt: -------------------------------------------------------------------------------- 1 | --context ctx.c --target mipsee-gcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/context.c: -------------------------------------------------------------------------------- 1 | int foo(float x); 2 | int (*volatile glob)(float); 3 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division-by-two/s16-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s16 arg0) { 2 | return arg0 / 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division-by-two/s32-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | return arg0 / 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/context.c: -------------------------------------------------------------------------------- 1 | typedef int int_t; 2 | int_t func_00400090(int x, int_t *y); 3 | -------------------------------------------------------------------------------- /tests/end_to_end/union_override/test-flags.txt: -------------------------------------------------------------------------------- 1 | --context ctx.h --union-field TestUnion:int_field 2 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/README.txt: -------------------------------------------------------------------------------- 1 | Run 'python3 -m unittest discover' from the root repository directory. 2 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/_ansi.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/aio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/ar.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/argz.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/cpio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/ctype.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/dlfcn.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/envz.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/errno.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/fcntl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/fenv.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/float.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/ftw.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/glob.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/grp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/iconv.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/math.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/ndbm.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/netdb.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/paths.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/poll.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/pwd.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/reent.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/regex.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sched.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/spawn.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/tar.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/time.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/trace.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/utime.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/utmp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/utmpx.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/wchar.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /tests/end_to_end/arg-temp/test.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | sw $zero, ($sp) 3 | move $v0, $a0 4 | jr $ra 5 | nop 6 | -------------------------------------------------------------------------------- /tests/end_to_end/division/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return arg0 / arg1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/division/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return arg0 / arg1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context context.c --void --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-sqrtf/with-mov-out.c: -------------------------------------------------------------------------------- 1 | f32 test(f32 arg0) { 2 | return sqrtf(arg0) * 0.5f; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-sqrtf/with-trunc-out.c: -------------------------------------------------------------------------------- 1 | s32 test(f32 arg0) { 2 | return (s32) sqrtf(arg0); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/global_floats/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --globals=all --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 *arg0) { 2 | *arg0 %= 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/context_1.c: -------------------------------------------------------------------------------- 1 | struct vec2 { 2 | float x; 3 | float y; 4 | }; 5 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return ~(arg0 | arg1); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return ~(arg0 | arg1); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return ~(arg0 | arg1); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return ~(arg0 | arg1); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/union_override_samesize/test-flags.txt: -------------------------------------------------------------------------------- 1 | --context ctx.h --union-field SameSizeUnion:ints 2 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/_syslist.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/alloca.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/arpa/inet.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/assert.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/complex.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/dirent.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/emmintrin.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/endian.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/fastmath.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/features.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/fmtmsg.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/fnmatch.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/getopt.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/ieeefp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/immintrin.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/inttypes.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/iso646.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/langinfo.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/libgen.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/libintl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/limits.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/locale.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/malloc.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/monetary.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/mqueue.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/net/if.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/netinet/in.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/newlib.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/nl_types.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/process.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/pthread.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/regdef.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/search.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/semaphore.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/setjmp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/signal.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/smmintrin.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdalign.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdarg.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdatomic.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdbool.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stddef.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdint.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdlib.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/string.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/strings.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stropts.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/ipc.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/mman.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/msg.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/poll.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/select.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/sem.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/shm.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/socket.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/stat.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/sysctl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/time.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/times.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/types.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/uio.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/un.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/wait.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/syslog.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/termios.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/tgmath.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/threads.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/ulimit.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/unctrl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/unistd.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/wctype.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/wordexp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/xcb/xcb.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /tests/end_to_end/division/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return arg0 / arg1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/division/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return arg0 / arg1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/orig.c: -------------------------------------------------------------------------------- 1 | int test(int (*fn)(int), int x) { 2 | return fn(x) + 1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --pointer-style left --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/multi-switch/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --comment-style=oneline --comment-column=0 --zfill-constants 2 | -------------------------------------------------------------------------------- /tests/end_to_end/ptr-inference/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(struct A *arg4) { 2 | foo(&unksp0, &arg4); 3 | } 4 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/linux/socket.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/linux/version.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/openssl/err.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/openssl/evp.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/openssl/hmac.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/openssl/ssl.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/openssl/x509v3.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/stdnoreturn.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/resource.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/statvfs.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/sys/utsname.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /tests/end_to_end/branch-likely-b/manual-out.c: -------------------------------------------------------------------------------- 1 | void test(void) { 2 | *NULL = 0; 3 | *(s32 *)1 = 0; 4 | } 5 | -------------------------------------------------------------------------------- /tests/end_to_end/global_decls/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --valid-syntax --stack-structs --zfill-constants 2 | -------------------------------------------------------------------------------- /tests/end_to_end/skip-casts/manual-out.c: -------------------------------------------------------------------------------- 1 | void test(u32 arg0) { 2 | *NULL = arg0 >> 1; 3 | *NULL = 5; 4 | } 5 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/asm-generic/int-ll64.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/ido53-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 *arg0) { 2 | *arg0 = (s32) *arg0 / 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/ido71-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 *arg0) { 2 | *arg0 = (s32) *arg0 / 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 *arg0) { 2 | *arg0 = (s32) *arg0 / 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/ido53-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 *arg0) { 2 | *arg0 = (s32) *arg0 % 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/ido71-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 *arg0) { 2 | *arg0 = (s32) *arg0 % 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context context_1.c --context context_2.c --context context_3.c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context context_1.c --context context_2.c --context context_3.c 2 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/c_files/simplemain.c: -------------------------------------------------------------------------------- 1 | #include "hdir\emptydir\..\9\inc.h" 2 | 3 | int main() { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/mir_toolkit/client_types.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/orig.c: -------------------------------------------------------------------------------- 1 | void test(int* ptr) { 2 | int val = *ptr / 2; 3 | *ptr = val; 4 | } 5 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 (*arg0)(s32), s32 arg1) { 2 | return arg0(arg1) + 1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 (*arg0)(s32), s32 arg1) { 2 | return arg0(arg1) + 1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 (*arg0)(s32), s32 arg1) { 2 | return arg0(arg1) + 1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/global_decls/irix-o2-noemitglobals-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --valid-syntax --globals=none --stack-structs 2 | -------------------------------------------------------------------------------- /tests/end_to_end/hi-offsets-type-info/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | lui $v0, %hi(a + 4) 3 | jr $ra 4 | lw $v0, %lo(a + 4)($v0) 5 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/orig.c: -------------------------------------------------------------------------------- 1 | void test(int* ptr) { 2 | int val = *ptr % 2; 3 | *ptr = val; 4 | } 5 | -------------------------------------------------------------------------------- /tests/end_to_end/multi-switch/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --comment-style=oneline --comment-column=0 --zfill-constants --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | return (s32) (&arg1 - sp) >> 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/union_override_samesize/test-out.c: -------------------------------------------------------------------------------- 1 | s32 test(struct Container *arg) { 2 | return arg->data.ints.x; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/abs-sqrt/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | f32 test(f32 arg0) { 2 | return (f32) sqrt(fabs((f64) sqrtf(fabsf(arg0)))); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 (*arg0)(?, ?), ? arg1) { 2 | return arg0(arg1, arg0) + 1; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/global_decls/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --valid-syntax --stack-structs --zfill-constants --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/mult-by-two/orig.c: -------------------------------------------------------------------------------- 1 | float x; 2 | double y; 3 | 4 | void test(void) { 5 | x *= 2.0f; 6 | y *= 2.0; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/multi-switch/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --comment-style=oneline --comment-column=0 --zfill-constants --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/ppc-packed-singles-saved-registers/manual-out.c: -------------------------------------------------------------------------------- 1 | extern f32 x; 2 | 3 | f32 test(void) { 4 | return x; 5 | } 6 | -------------------------------------------------------------------------------- /tests/end_to_end/test/orig.c: -------------------------------------------------------------------------------- 1 | int foo; 2 | 3 | void bar(void) {} 4 | 5 | void test(void) { 6 | bar(); 7 | foo = 4; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/orig.c: -------------------------------------------------------------------------------- 1 | int x; 2 | void test(void) { 3 | for (;;) { 4 | x = 1; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-member-address/context.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | char a; 3 | char b; 4 | }; 5 | void test(struct A *a); 6 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context context_1.c --context context_2.c --context context_3.c --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | u32 test(s32 arg0) { 2 | return (u32) ((0 - arg0) | arg0) >> 0x1F; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/irix-o2-nocontext-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, ? arg1) { 2 | return (s32) (&arg1 - sp) >> 2; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/global_decls/irix-o2-allglobals-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --valid-syntax --globals=all --stack-structs --zfill-constants 2 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-offset/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 glob; 2 | 3 | void test(void *arg0) { 4 | glob = arg0->unk12348; 5 | } 6 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context context_1.c --context context_2.c --context context_3.c --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/flexible-array-members/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(struct A *a, struct C *c, s32 i) { 2 | return c->bs[i].y + a->ys[i]; 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/hi-offsets-type-info/context.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | int a; 3 | int b; 4 | } a; 5 | 6 | int test(void) { 7 | return a.b; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/multi-switch/irix-o2-noswitch-flags.txt: -------------------------------------------------------------------------------- 1 | --no-switch --no-andor --comment-style=oneline --comment-column=0 --zfill-constants 2 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/orig.c: -------------------------------------------------------------------------------- 1 | int test(int arg) { 2 | if (arg) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/ptr-inference/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(void) { 2 | s32 *sp1C; 3 | struct A *sp18; 4 | 5 | foo(&sp1C, &sp18); 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/ptr-inference/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(void) { 2 | s32 *spC; 3 | struct A *sp8; 4 | 5 | foo(&spC, &sp8); 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/skip-casts/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | srl $a0, $a0, 1 3 | sb $a0, ($zero) 4 | li $t0, 5 5 | sb $t0, ($zero) 6 | jr $ra 7 | nop 8 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy2/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --target gba -f test_0 -f test_1 -f test_2 -f test_3 -f test_4 -f test_5 -f test_6 -f test_7 2 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/psf/black-pre-commit-mirror 3 | rev: 24.4.2 4 | hooks: 5 | - id: black 6 | -------------------------------------------------------------------------------- /m2c_pycparser/ply/__init__.py: -------------------------------------------------------------------------------- 1 | # PLY package 2 | # Author: David Beazley (dave@dabeaz.com) 3 | 4 | __version__ = '3.9' 5 | __all__ = ['lex','yacc'] 6 | -------------------------------------------------------------------------------- /tests/end_to_end/eabi64/eabi64-int-float-args-ctx-out.c: -------------------------------------------------------------------------------- 1 | void test(void) { 2 | no_args_func(); 3 | func_with_args(2.0f, 1, 1.0f, 2); 4 | } 5 | -------------------------------------------------------------------------------- /tests/end_to_end/if_postdec/orig.c: -------------------------------------------------------------------------------- 1 | int glob; 2 | int test(void) { 3 | if (glob-- < 1) { 4 | return 4; 5 | } 6 | return 6; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/loop/orig.c: -------------------------------------------------------------------------------- 1 | void test(char *foo, int length) { 2 | int i; 3 | 4 | for(i = 0; i < length; i++) 5 | foo[i] = 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/mult-by-two/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern f32 x; 2 | extern f64 y; 3 | 4 | void test(void) { 5 | y *= 2.0; 6 | x *= 2.0f; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | arg5 = arg0; 3 | arg4 = arg1; 4 | return -1; 5 | } 6 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy2/mwcc-o0p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c -f test_0 -f test_1 -f test_2 -f test_3 -f test_4 -f test_5 -f test_6 -f test_7 2 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy2/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c -f test_0 -f test_1 -f test_2 -f test_3 -f test_4 -f test_5 -f test_6 -f test_7 2 | -------------------------------------------------------------------------------- /tests/end_to_end/trapuv/orig.c: -------------------------------------------------------------------------------- 1 | void foo(int x); 2 | 3 | void test(int x) { 4 | foo(x + 1); 5 | foo(x + 2); 6 | } 7 | 8 | void foo(int x) {} 9 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 x; 2 | 3 | void test(void) { 4 | loop_1: 5 | x = 1; 6 | goto loop_1; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/unsized-pointers/context.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | char pad[4]; 3 | void (*fptr)(void); 4 | }; 5 | int foo(struct A *a, void *b); 6 | -------------------------------------------------------------------------------- /tests/end_to_end/unsized-pointers/manual-out.c: -------------------------------------------------------------------------------- 1 | void *test(void *arg0, void *arg1) { 2 | return arg0->unk4 + 1 + arg1->unk4 + (arg1 + 1); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-struct/context.c: -------------------------------------------------------------------------------- 1 | typedef struct { 2 | char pad[0x10]; 3 | int whatever[0x1000]; 4 | } SomeStruct; 5 | extern SomeStruct glob; 6 | -------------------------------------------------------------------------------- /tests/end_to_end/arg-temp/test-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | s32 temp_a0; 3 | 4 | temp_a0 = arg0; 5 | arg0 = 0; 6 | return temp_a0; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/duplicated-early-returns/manual-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 0; 4 | } 5 | return 1; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/flexible-array-members/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(struct A *a, struct C *c, s32 i) { 2 | return a->ys[i] + *(&c->bs[0].y + (i * 8)); 3 | } 4 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-recursive-struct/context.c: -------------------------------------------------------------------------------- 1 | typedef struct { 2 | char pad[0x10]; 3 | int whatever[0x1000]; 4 | } SomeStruct; 5 | extern SomeStruct glob; 6 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 == 0) { 3 | return 0; 4 | } 5 | return 1; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 == 0) { 3 | return 0; 4 | } 5 | return 1; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 != 0) { 3 | return 1; 4 | } 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/return-float/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | f32 test(f32 arg0) { 2 | if (arg0 != 0.0f) { 3 | return 15.0f; 4 | } 5 | return arg0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/return-float/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | f32 test(f32 farg0) { 2 | if (farg0 != 0.0f) { 3 | return 15.0f; 4 | } 5 | return farg0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/tail-call/non-tail-call-out.c: -------------------------------------------------------------------------------- 1 | ? foo(); /* extern */ 2 | 3 | void test(void) { 4 | foo(); 5 | } 6 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100E0; 2 | 3 | void test(void) { 4 | loop_0: 5 | D_4100E0 = 1; 6 | goto loop_0; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100F0; 2 | 3 | void test(void) { 4 | D_4100F0 = 1; 5 | loop_1: 6 | goto loop_1; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return2/orig.c: -------------------------------------------------------------------------------- 1 | int x; 2 | void test(void) { 3 | for (;;) { 4 | if (x == 2) break; 5 | x = 1; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-member-address/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | li $at, 1 3 | addu $a0, $a0, $at 4 | jal foo 5 | nop 6 | jr $ra 7 | nop 8 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/orig.c: -------------------------------------------------------------------------------- 1 | int test(int arg) { 2 | if (arg) { 3 | return 1; 4 | } else { 5 | return 0; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/orig.c: -------------------------------------------------------------------------------- 1 | int test(int arg) { 2 | int ret = 0; 3 | if (arg) { 4 | ret = 1; 5 | } 6 | return ret; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | s32 sp4; 3 | 4 | sp4 = 0; 5 | return (s32) (&arg1 - &arg0) >> 2; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | Blah *test(Blah *b, Blah *b2) { 2 | b->b += b->a; 3 | b2->a = b->a; 4 | b2->b = b->b; 5 | return b; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/abs-sqrt/irix-g-out.c: -------------------------------------------------------------------------------- 1 | f32 test(f32 arg0) { 2 | f64 sp10; 3 | 4 | sp10 = (f64) sqrtf(fabsf(arg0)); 5 | return (f32) sqrt(fabs(sp10)); 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/irix-g-out.c: -------------------------------------------------------------------------------- 1 | void test(struct A *a, s32 b, s16 c) { 2 | a->x = 2; 3 | a->y = (s16) b; 4 | a->z = c; 5 | a->w = c + b; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(struct A *a, s32 b, s16 c) { 2 | a->x = 2; 3 | a->y = (s16) b; 4 | a->z = c; 5 | a->w = c + b; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/empty-if/manual-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0, s32 arg1) { 2 | if ((arg0 != 1) && (arg1 != 2)) { 3 | 4 | } 5 | if (arg0 != 1) { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/mult-by-two/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern f32 D_4100E0; 2 | extern f64 D_4100E8; 3 | 4 | void test(void) { 5 | D_4100E0 *= 2.0f; 6 | D_4100E8 *= 2.0; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(struct A *a, s32 b, s16 c) { 2 | a->x = 2; 3 | a->y = (s16) b; 4 | a->z = c; 5 | a->w = b + c; 6 | } 7 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/c_files/empty.h: -------------------------------------------------------------------------------- 1 | #define PERFECTLY 2 | #define NORMAL 3 | #define TO 4 | #define HAVE 5 | #define HEADER 6 | #define WITH 7 | #define ONLY 8 | #define DEFINES 9 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/X11/Xlib.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | #include "_X11_fake_defines.h" 4 | #include "_X11_fake_typedefs.h" 5 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_return/orig.c: -------------------------------------------------------------------------------- 1 | int test(int a, int b, int c, int d) { 2 | if ((a || b) && (c || d)) { 3 | return a + b; 4 | } 5 | return c + d; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/duplicated-early-returns/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | beqz $a0, .yes 3 | nop 4 | b .no 5 | li $v0, 0 6 | .yes: 7 | li $v0, 1 8 | .no: 9 | jr $ra 10 | nop 11 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-offset/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100F0; 2 | 3 | void *test(void *arg0) { 4 | D_4100F0 = arg0->unk12348; 5 | return arg0 + 0x12348; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-offset/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100E0; 2 | 3 | void *test(void *arg0) { 4 | D_4100E0 = arg0->unk12348; 5 | return arg0 + 0x12348; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-offset/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern s32 glob; 2 | 3 | s32 test(void *arg0) { 4 | glob = arg0->unk12348; 5 | return arg0 + 0x10000 + 0x2348; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-prevent/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu $t0, $a0, 1 3 | beqz $a2, .skip 4 | move $v0, $t0 5 | addiu $t0, $a0, 2 6 | .skip: 7 | jr $ra 8 | sw $t0, ($zero) 9 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(void *arg0, s32 arg1) { 2 | arg0->unk_4 = (s32) (arg0->unk_0 + arg0->unk_4); 3 | M2C_STRUCT_COPY(arg1, arg0, 8); 4 | } 5 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/X11/Intrinsic.h: -------------------------------------------------------------------------------- 1 | #include "_fake_defines.h" 2 | #include "_fake_typedefs.h" 3 | #include "_X11_fake_defines.h" 4 | #include "_X11_fake_typedefs.h" 5 | -------------------------------------------------------------------------------- /tests/end_to_end/duplicated-early-returns/gotos-only.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | beqz $a0, .yes 3 | nop 4 | b .no 5 | li $v0, 0 6 | .yes: 7 | li $v0, 1 8 | .no: 9 | jr $ra 10 | nop 11 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-member-address/manual-out.c: -------------------------------------------------------------------------------- 1 | ? foo(s8 *); /* extern */ 2 | 3 | void test(struct A *a) { 4 | foo(&a->b); 5 | } 6 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/orig.c: -------------------------------------------------------------------------------- 1 | int test(int arg0, int arg1) { 2 | // Dummy variable, so the stack has non-zero size 3 | int x = 0; 4 | return &arg1 - &arg0; 5 | } 6 | -------------------------------------------------------------------------------- /tests/end_to_end/conditional-moves/manual-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg2) { 2 | s32 temp_a2; 3 | 4 | temp_a2 = (arg2 <= 0) ? 1 : arg2; 5 | return (temp_a2 < 6) ? temp_a2 : 5; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division-by-two/s32.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | move $t9, $a0 3 | srl $v0, $t9, 0x1f 4 | addu $v0, $t9, $v0 5 | sra $v0, $v0, 1 6 | jr $ra 7 | nop 8 | -------------------------------------------------------------------------------- /tests/end_to_end/test/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* static */ 2 | extern s32 foo; 3 | 4 | void test(void) { 5 | bar(); 6 | foo = 4; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/test/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* static */ 2 | extern s32 foo; 3 | 4 | void test(void) { 5 | bar(); 6 | foo = 4; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/delay-slot-branch/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | beqz $a1, .skip 3 | .loop: 4 | addiu $a0, $a0, -1 5 | bnez $a0, .loop 6 | nop 7 | .skip: 8 | jr $ra 9 | move $v0, $a0 10 | -------------------------------------------------------------------------------- /tests/end_to_end/branch-likely-general/manual-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0) { 2 | if (arg0 == 0) { 3 | *NULL = 0; 4 | } else { 5 | *NULL = 1; 6 | } 7 | *NULL = 2; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/duplicated-early-returns/gotos-only-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | if (arg0 == 0) { 3 | goto block_2; 4 | } 5 | return 0; 6 | block_2: 7 | return 1; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division/irix-g-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --function test_s8 --function test_s16 --function test_s32_div --function test_s32_mod --function test_u32_div --function test_u32_mod 2 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division/irix-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --function test_s8 --function test_s16 --function test_s32_div --function test_s32_mod --function test_u32_div --function test_u32_mod 2 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return2/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 x; 2 | 3 | void test(void) { 4 | if (x != 2) { 5 | loop_2: 6 | x = 1; 7 | goto loop_2; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/conditional-moves/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | li $a1,1 3 | slt $a0,$zero,$a2 4 | movz $a2,$a1,$a0 5 | li $v0,5 6 | slti $v1,$a2,6 7 | jr $ra 8 | movn $v0,$a2,$v1 9 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(u32 *arg0) { 2 | u32 temp_r1; 3 | 4 | temp_r1 = *arg0; 5 | *arg0 = (u32) ((s32) (temp_r1 + (temp_r1 >> 0x1F)) >> 1); 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/if_postdec/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100F0; 2 | 3 | s32 test(void) { 4 | D_4100F0 -= 1; 5 | if (D_4100F0 < 1) { 6 | return 4; 7 | } 8 | return 6; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | s32 sp4; 3 | 4 | sp4 = 0; 5 | if (arg0 != 0) { 6 | sp4 = 1; 7 | } 8 | return sp4; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/ppc-void-out.c: -------------------------------------------------------------------------------- 1 | ? foo(); /* extern */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 0) { 5 | foo(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | s32 spC; 3 | s32 sp8; 4 | 5 | sp8 = arg0; 6 | spC = arg1; 7 | return (s32) (&spC - &sp8) / 4; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy/orig.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | int buf[100]; 3 | } a, b; 4 | struct B { 5 | char buf[100]; 6 | }; 7 | void test(struct B *c, struct B *d) { 8 | a = b; 9 | *c = *d; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/test/irix-g-out.c: -------------------------------------------------------------------------------- 1 | ? func_004000B0(); /* static */ 2 | extern s32 D_410100; 3 | 4 | void test(void) { 5 | func_004000B0(); 6 | D_410100 = 4; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return2/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern s32 x; 2 | 3 | void test(void) { 4 | loop_1: 5 | if ((s32) x != 2) { 6 | x = 1; 7 | goto loop_1; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/if_postdec/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100E0; 2 | 3 | s32 test(void) { 4 | D_4100E0 -= 1; 5 | if (D_4100E0 <= 0) { 6 | return 4; 7 | } 8 | return 6; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/test/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | ? func_004000B0(); /* static */ 2 | extern s32 D_4100E0; 3 | 4 | void test(void) { 5 | func_004000B0(); 6 | D_4100E0 = 4; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/arguments/orig.c: -------------------------------------------------------------------------------- 1 | int globali; 2 | float globalf; 3 | 4 | void test(float f1, int i1, float f2, int i2, float f3, int i3) { 5 | globalf = f1 + f2 + f3; 6 | globali = i1 + i2 + i3; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/branch-likely-general/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | beqzl $a0, .label 3 | sw $zero, ($zero) 4 | li $t1, 1 5 | sw $t1, ($zero) 6 | .label: 7 | li $t2, 2 8 | sw $t2, ($zero) 9 | jr $ra 10 | nop 11 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division/agbcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --function test_s8 --function test_s16 --function test_s32_div --function test_s32_mod --function test_u32_div --function test_u32_mod --target gba 2 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division/gcc-o2-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --function func_00400098 --function func_004003A8 --function func_004007C0 --function func_00400F48 --function func_00401AA0 --function func_00401FC4 2 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(u32 *arg0) { 2 | u32 temp_r2; 3 | 4 | temp_r2 = *arg0; 5 | *arg0 = temp_r2 - (((s32) (temp_r2 + (temp_r2 >> 0x1F)) >> 1) * 2); 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/large-struct-offset/orig.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | char a[0x12345]; 3 | int b; 4 | }; 5 | 6 | int glob; 7 | 8 | int *test(struct A *a) { 9 | glob = a->b; 10 | return &a->b; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | s32 var_v1; 3 | 4 | var_v1 = 0; 5 | if (arg0 != 0) { 6 | var_v1 = 1; 7 | } 8 | return var_v1; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/conditional-use-out.c: -------------------------------------------------------------------------------- 1 | ? foo(?); /* extern */ 2 | 3 | void test(void) { 4 | if ((1 != 0) && (1 != 0)) { 5 | foo(4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/irix-g-out.c: -------------------------------------------------------------------------------- 1 | Blah *test(Blah *b, Blah *b2) { 2 | s32 sp4; 3 | 4 | sp4 = b->a + b->b; 5 | b->b = sp4; 6 | b2->a = b->a; 7 | b2->b = b->b; 8 | return b; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return2/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100F0; 2 | 3 | void test(void) { 4 | loop_0: 5 | if (D_4100F0 != 2) { 6 | D_4100F0 = 1; 7 | goto loop_0; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return2/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100E0; 2 | 3 | void test(void) { 4 | loop_1: 5 | if (D_4100E0 != 2) { 6 | D_4100E0 = 1; 7 | goto loop_1; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --function test_s8 --function test_s16 --function test_s32_div --function test_s32_mod --function test_u32_div --function test_u32_mod --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division/mwcc27-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --context orig.c --function test_s8 --function test_s16 --function test_s32_div --function test_s32_mod --function test_u32_div --function test_u32_mod --target ppc-mwcc-c 2 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/orig.c: -------------------------------------------------------------------------------- 1 | typedef int int_t; 2 | 3 | int_t foo(int x, int_t *y) { 4 | return x + *y; 5 | } 6 | 7 | int_t test(int x, int_t *y) { 8 | return foo(x, &x) + foo(x, y) + foo(*y, y); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/union_override/test-out.c: -------------------------------------------------------------------------------- 1 | s32 test(struct TestStruct *arg0, s32 arg1) { 2 | s32 temp_v0; 3 | 4 | temp_v0 = arg0->data.int_field; 5 | arg0->data.int_field = arg1; 6 | return temp_v0; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-samevalue-replacement/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | beqz $a0, .a 3 | nop 4 | jal fun 5 | nop 6 | lui $v0, 1 7 | b .b 8 | nop 9 | .a: 10 | lui $v0, 1 11 | .b: 12 | ori $v0, $v0, 2 13 | jr $ra 14 | nop 15 | -------------------------------------------------------------------------------- /tests/end_to_end/seb-seh/seb-mwcc-out.c: -------------------------------------------------------------------------------- 1 | s8 foo(s8); /* extern */ 2 | 3 | s8 test(s32 arg0) { 4 | s32 sp10; 5 | 6 | sp10 = arg0; 7 | return (s8) (foo((s8) sp10) + 1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/seb-seh/seh-mwcc-out.c: -------------------------------------------------------------------------------- 1 | s16 foo(s16); /* extern */ 2 | 3 | s16 test(s32 arg0) { 4 | s32 sp10; 5 | 6 | sp10 = arg0; 7 | return (s16) (foo((s16) sp10) + 1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/abi-float-regs/orig.c: -------------------------------------------------------------------------------- 1 | float test(unsigned int y) { 2 | double ret = 1.0; 3 | unsigned int i; 4 | 5 | for (i = y; i != 0; i--) { 6 | ret *= i; 7 | } 8 | 9 | return ret; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/irix-g-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 x, s16* y, s32 z, s8* r, s16* s, s32* t, s32* u) { 2 | s32* sp1C; 3 | 4 | sp1C = NULL; 5 | loop_1: 6 | sp1C = foo(sp1C, y, t); 7 | goto loop_1; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-samevalue-replacement/manual-out.c: -------------------------------------------------------------------------------- 1 | ? fun(); /* extern */ 2 | 3 | s32 test(s32 arg0) { 4 | if (arg0 != 0) { 5 | fun(); 6 | } 7 | return 0x10002; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/asm-arith/test-out.c: -------------------------------------------------------------------------------- 1 | extern ? sym; 2 | 3 | void test(void) { 4 | *NULL = 1; 5 | *(s32 *)0x10 = 0; 6 | *(s32 *)0x20 = 0; 7 | *(s32 *)0x40 = 0; 8 | *NULL = 0x50; 9 | sym.unk8 = 0; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/float-conversions/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern f64 dbl; 2 | extern f32 flt; 3 | extern u32 u; 4 | 5 | void test(void) { 6 | u = (u32) flt; 7 | u = (u32) dbl; 8 | dbl = (f64) u; 9 | flt = (f32) u; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/mwcc-o4p.s: -------------------------------------------------------------------------------- 1 | .include "macros.inc" 2 | 3 | .section .text # 0x0 - 0x8 4 | 5 | .global test 6 | test: 7 | /* 00000000 00000000 7C 63 20 F8 */ nor r3, r3, r4 8 | /* 00000004 00000004 4E 80 00 20 */ blr 9 | 10 | -------------------------------------------------------------------------------- /tests/end_to_end/tail-call/tail-call-ps2.s: -------------------------------------------------------------------------------- 1 | test: 2 | addiu $sp, $sp, -0x10 3 | sd $ra, 0x0($sp) 4 | jal foo 5 | nop 6 | ld $ra, 0x0($sp) 7 | j bar 8 | addiu $sp, $sp, 0x10 9 | nop 10 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0, s32 *arg1) { 2 | s32 sp1C; 3 | s32 sp18; 4 | 5 | sp18 = func_00400090(arg0, arg1); 6 | sp1C = func_00400090(arg0, &arg0); 7 | func_00400090(*arg1, arg1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 x, s16* y, s32 z, s8* r, s16* s, s32* t, s32* u) { 2 | s32* var_r0; 3 | 4 | var_r0 = NULL; 5 | loop_1: 6 | var_r0 = foo(var_r0, y, t); 7 | goto loop_1; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 x, s16 *y, s32 z, s8 *r, s16 *s, s32 *t, s32 *u) { 2 | s32 *var_s0; 3 | 4 | var_s0 = NULL; 5 | loop_1: 6 | var_s0 = foo(var_s0, y, t); 7 | goto loop_1; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 x, s16 *y, s32 z, s8 *r, s16 *s, s32 *t, s32 *u) { 2 | s32 *var_r3; 3 | 4 | var_r3 = NULL; 5 | loop_1: 6 | var_r3 = foo(var_r3, y, t); 7 | goto loop_1; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-type/orig.c: -------------------------------------------------------------------------------- 1 | void foo(void **a, void **b) { 2 | *a = *b; 3 | } 4 | 5 | void test(void *a, void *b) { 6 | a = &a; 7 | b = &b; 8 | 9 | foo(a, b); 10 | a = b; 11 | foo(a, b); 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/return-float/irix-g-out.c: -------------------------------------------------------------------------------- 1 | f32 test(f32 arg0) { 2 | f32 var_f14; 3 | 4 | if (arg0 != 0.0f) { 5 | var_f14 = 15.0f; 6 | } else { 7 | var_f14 = arg0; 8 | } 9 | return var_f14; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | void *test(void *arg0, void *arg1) { 2 | arg0->unk_4 = (s32) (arg0->unk_0 + arg0->unk_4); 3 | arg1->unk_0 = (s32) arg0->unk_0; 4 | arg1->unk_4 = (s32) arg0->unk_4; 5 | return arg0; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/tail-call/tail-call-ps2-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* extern */ 2 | ? foo(); /* extern */ 3 | 4 | void test(void) { 5 | foo(); 6 | bar(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_return/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { 2 | if (((arg0 != 0) || (arg1 != 0)) && ((arg2 != 0) || (arg3 != 0))) { 3 | return arg0 + arg1; 4 | } 5 | return arg2 + arg3; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_return/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { 2 | if (((arg0 != 0) || (arg1 != 0)) && ((arg2 != 0) || (arg3 != 0))) { 3 | return arg0 + arg1; 4 | } 5 | return arg2 + arg3; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_return/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { 2 | if (((arg0 != 0) || (arg1 != 0)) && ((arg2 != 0) || (arg3 != 0))) { 3 | return arg0 + arg1; 4 | } 5 | return arg2 + arg3; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/andor_return/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { 2 | if (((arg0 != 0) || (arg1 != 0)) && ((arg2 != 0) || (arg3 != 0))) { 3 | return arg0 + arg1; 4 | } 5 | return arg2 + arg3; 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/division/mwcc-o4p.s: -------------------------------------------------------------------------------- 1 | .include "macros.inc" 2 | 3 | .section .text # 0x0 - 0x8 4 | 5 | .global test 6 | test: 7 | /* 00000000 00000000 7C 63 23 D6 */ divw r3, r3, r4 8 | /* 00000004 00000004 4E 80 00 20 */ blr 9 | 10 | -------------------------------------------------------------------------------- /tests/end_to_end/loop-selfassign-phi/orig.c: -------------------------------------------------------------------------------- 1 | 2 | int foo(int x); 3 | 4 | void test(int x) { 5 | for (;;) { 6 | if (x > 2) { 7 | x = foo(x); 8 | } 9 | } 10 | } 11 | 12 | int foo(int x) { return x; } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/arguments/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100F0; 2 | extern f32 D_4100F4; 3 | 4 | void test(f32 arg0, s32 arg1, f32 arg2, s32 arg3, f32 arg4, s32 arg5) { 5 | D_4100F4 = arg0 + arg2 + arg4; 6 | D_4100F0 = arg1 + arg3 + arg5; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/arguments/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_4100E0; 2 | extern f32 D_4100E4; 3 | 4 | void test(f32 arg0, s32 arg1, f32 arg2, s32 arg3, f32 arg4, s32 arg5) { 5 | D_4100E4 = arg0 + arg2 + arg4; 6 | D_4100E0 = arg1 + arg3 + arg5; 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/branch-likely-one-instruction/manual-out.c: -------------------------------------------------------------------------------- 1 | s32 test(void) { 2 | s32 var_a0; 3 | 4 | var_a0 = *(s32 *)0x8009A600 == 3; 5 | if (*(s8 *)0x800B0F15 == 5) { 6 | var_a0 = 1; 7 | } 8 | return var_a0; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/cpp_vtables/mwcc-o4p-flags.txt: -------------------------------------------------------------------------------- 1 | --target ppc-mwcc-c++ --function compute__FR7Derivedi --function method__4BaseFi --function static_method__4BaseFi --function virtual_method__7DerivedFi --function __ct__7DerivedFi --function __ct__4BaseFv 2 | -------------------------------------------------------------------------------- /tests/end_to_end/float-fn/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | f64 blah(); /* static */ 2 | ? blahf(); /* static */ 3 | 4 | f32 test(void) { 5 | blahf(); 6 | return (f32) blah(); 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/if_postdec/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 glob; 2 | 3 | s32 test(void) { 4 | s32 temp_r2; 5 | 6 | temp_r2 = glob; 7 | glob -= 1; 8 | if (temp_r2 > 0) { 9 | return 6; 10 | } 11 | return 4; 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/rodata-literals/orig.c: -------------------------------------------------------------------------------- 1 | float a; 2 | double b, c; 3 | const char *d; 4 | 5 | void test(void) { 6 | a = 1.2f; 7 | b = 13.0; 8 | c = 1.4e10; 9 | d = "\"hello\"\n\x01"; 10 | "world /* comment */ #"; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? memcpy(? *, ? *, s32); /* extern */ 2 | extern ? a; 3 | extern ? b; 4 | 5 | void test(? *arg0, ? *arg1) { 6 | memcpy(&a, &b, 0x190); 7 | memcpy(arg0, arg1, 0x64); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/trapuv/irix-o2-trapuv-out.c: -------------------------------------------------------------------------------- 1 | ? func_004000DC(s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | // code compiled with -trapuv 5 | func_004000DC(arg0 + 1); 6 | func_004000DC(arg0 + 2); 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/irix-g-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0, s32 *arg1) { 2 | s32 temp_s0; 3 | s32 temp_s1; 4 | 5 | temp_s1 = func_00400090(arg0, arg1); 6 | temp_s0 = func_00400090(arg0, &arg0); 7 | func_00400090(*arg1, arg1); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/arguments/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern f32 globalf; 2 | extern s32 globali; 3 | 4 | void test(s32 arg0, s32 arg1, s32 arg2, f32 farg0, f32 farg1, f32 farg2) { 5 | globali = arg0 + (arg1 + arg2); 6 | globalf = farg2 + (farg0 + farg1); 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/float-conversions/orig.c: -------------------------------------------------------------------------------- 1 | volatile float flt; 2 | volatile double dbl; 3 | volatile unsigned u; 4 | 5 | void test(void) { 6 | u = (unsigned)flt; 7 | u = (unsigned)dbl; 8 | dbl = (double)u; 9 | flt = (float)u; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/ida/handwritten-out.c: -------------------------------------------------------------------------------- 1 | extern ? symbol; 2 | 3 | s32 test(void) { 4 | s32 temp_v0; 5 | 6 | temp_v0 = symbol.unk0 + 4; 7 | symbol.unk0 = (s32) symbol.unk4; 8 | return temp_v0 + (&symbol + 8)->unk4 + symbol.unk4; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(struct A *a, s32 b, s16 c) { 2 | u16 temp_r2; 3 | 4 | temp_r2 = (u16) c; 5 | a->x = 2; 6 | a->y = (s16) b; 7 | a->z = (s16) temp_r2; 8 | a->w = (s16) temp_r2 + b; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/float-fn/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | f32 func_004000BC(); /* static */ 2 | f64 func_004000C4(f64); /* static */ 3 | 4 | f32 test(void) { 5 | return (f32) func_004000C4((f64) func_004000BC()); 6 | } 7 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern f32 globalf; 2 | extern s32 globali; 3 | 4 | f32 test(s32 arg0, s32 arg1, f32 farg0, f32 farg1) { 5 | globali = (s32) farg0; 6 | globalf = (f32) arg0; 7 | return (f32) (arg1 + 3) + (farg1 + 5.0f); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/struct/orig.c: -------------------------------------------------------------------------------- 1 | struct Blah { 2 | int a, b; 3 | }; 4 | 5 | typedef struct Blah Blah; 6 | 7 | struct Blah *test(struct Blah *b, Blah *b2) { 8 | int c = b->a + b->b; 9 | b->b = c; 10 | *b2 = *b; 11 | return b; 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 bar(f32 x); /* static */ 2 | extern s32 (*glob2)(f32); 3 | 4 | void test(void) { 5 | glob = foo; 6 | glob = bar; 7 | glob2 = foo; 8 | glob2 = bar; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 bar(f32 x); /* extern */ 2 | extern s32 (*glob2)(f32); 3 | 4 | void test(void) { 5 | glob = foo; 6 | glob = bar; 7 | glob2 = foo; 8 | glob2 = bar; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 bar(f32 x); /* static */ 2 | extern s32 (*glob2)(f32); 3 | 4 | void test(void) { 5 | glob = foo; 6 | glob = bar; 7 | glob2 = foo; 8 | glob2 = bar; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-division-by-two/s16.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | move $v0, $a0 3 | sll $v0, $v0, 0x10 4 | sra $v1, $v0, 0x10 5 | srl $v0, $v0, 0x1f 6 | addu $v1, $v1, $v0 7 | sra $v1, $v1, 1 8 | jr $ra 9 | move $v0, $v1 10 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float/orig.c: -------------------------------------------------------------------------------- 1 | int globali; 2 | float globalf; 3 | 4 | float test(float f1, int i1, float f2, unsigned i2) { 5 | globali = (int)f1; 6 | globalf = (float)i1; 7 | i2 += 3; 8 | f2 += 5.0f; 9 | return (float)i2 + f2; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/loop-selfassign-phi/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 func_004000D8(s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | loop_1: 5 | if (arg0 >= 3) { 6 | arg0 = func_004000D8(arg0); 7 | } 8 | goto loop_1; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs2/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? foo(s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | foo(3); 7 | return; 8 | } 9 | foo(4); 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-type/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? foo(? *); /* static */ 2 | 3 | void test(? *arg4) { 4 | unksp0 = &unksp0; 5 | arg4 = &arg4; 6 | foo(); 7 | unksp0 = arg4; 8 | foo((? *) arg4); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/store-casts/orig.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | char pad[4]; 3 | void (*fptr)(void); 4 | short x, y, z, w; 5 | }; 6 | void test(struct A *a, int b, short c) { 7 | a->x = 2; 8 | a->y = b; 9 | a->z = c; 10 | a->w = b + c; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/tail-call/non-tail-call.s: -------------------------------------------------------------------------------- 1 | test: 2 | addiu $sp, $sp, -0x10 3 | sd $ra, 0x0($sp) 4 | jal foo 5 | nop 6 | ld $ra, 0x0($sp) 7 | j loc_bar 8 | addiu $sp, $sp, 0x10 9 | loc_bar: 10 | jr $ra 11 | nop 12 | -------------------------------------------------------------------------------- /tests/end_to_end/float-branch-evalonce/orig.c: -------------------------------------------------------------------------------- 1 | float x; 2 | void test(void) { 3 | float y = x; 4 | x = 5; 5 | if (y < 0) { 6 | x = 6; 7 | } 8 | 9 | y = x; 10 | x = 3; 11 | if (!(y < 0)) { 12 | x = 7; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/fn-write-reordering/orig.c: -------------------------------------------------------------------------------- 1 | 2 | int foo(void); 3 | void bar(int); 4 | 5 | int global; 6 | 7 | void test(void) { 8 | int x = foo(); 9 | global = 1; 10 | bar(x); 11 | } 12 | 13 | int foo(void) { return 1; } 14 | void bar(int x) {} 15 | -------------------------------------------------------------------------------- /tests/end_to_end/if_postdec/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern s32 glob; 2 | 3 | s32 test(void) { 4 | s32 temp_cr0_lt; 5 | 6 | temp_cr0_lt = (s32) glob < 1; 7 | glob -= 1; 8 | if (temp_cr0_lt != 0) { 9 | return 4; 10 | } 11 | return 6; 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/known_called_function/orig.c: -------------------------------------------------------------------------------- 1 | int* foo(int* x, short* y, int* t) { return x; } 2 | 3 | void test(int x, short* y, int z, char* r, short* s, int* t, long* u) { 4 | int* ptr = (void*) 0; 5 | for (;;) { 6 | ptr = foo(ptr, y, t); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/orig.c: -------------------------------------------------------------------------------- 1 | int test(int length) { 2 | int i = 0; 3 | 4 | while (i < length) { 5 | if (i == 5) { 6 | i *= 2; 7 | } else { 8 | i += 4; 9 | } 10 | } 11 | 12 | return i; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/ps2/manual_mwcc-out.c: -------------------------------------------------------------------------------- 1 | ? func2__FiPPc(s32, ?); /* extern */ 2 | ? func__Fv(); /* extern */ 3 | 4 | void test(s32 arg0, ? arg1) { 5 | func__Fv(); 6 | func2__FiPPc(arg0, arg1); 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/signed-conversion/orig.c: -------------------------------------------------------------------------------- 1 | volatile int glob; 2 | void test(int x) { 3 | glob = (char)x; 4 | glob = (char)(x * 2); 5 | glob = (char)(x * 3); 6 | glob = (short)x; 7 | glob = (short)(x * 2); 8 | glob = (short)(x * 3); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/unsized-pointers/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | lw $v1, 4($a0) 3 | addiu $v0, $v1, 1 4 | lw $v1, 4($a1) 5 | addu $v0, $v0, $v1 6 | addiu $v1, $a1, 1 7 | addu $v0, $v0, $v1 8 | jr $ra 9 | nop 10 | -------------------------------------------------------------------------------- /tests/end_to_end/var-prevent-bug/manual-out.c: -------------------------------------------------------------------------------- 1 | extern s8 gChar; 2 | 3 | void test(void) { 4 | s8 *var_v0; 5 | 6 | var_v0 = &gChar; 7 | gChar = 0; 8 | do { 9 | var_v0 += 1; 10 | var_v0->unk-1 = 0; 11 | } while (0 != 0); 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/ps2/manual-out.c: -------------------------------------------------------------------------------- 1 | ? foo(void *, ? *, s32, s32); /* extern */ 2 | 3 | void test(s32 arg2, s32 arg3) { 4 | ? sp4; 5 | s32 temp_a2; 6 | 7 | temp_a2 = arg2 * 2; 8 | foo(sp, &sp4, temp_a2, arg3 + (temp_a2 * 2)); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-struct/test.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | lui $s1, %hi(glob2) 3 | addiu $s1, %lo(glob2) 4 | lui $s0, %hi(glob) 5 | addiu $s0, %lo(glob) 6 | sw $s0, ($s1) 7 | addiu $s2, $s0, 0xC 8 | sw $s2, ($s1) 9 | lh $v0, 0x100($s0) 10 | jr $ra 11 | nop 12 | -------------------------------------------------------------------------------- /tests/end_to_end/comparison/orig.c: -------------------------------------------------------------------------------- 1 | 2 | volatile int global; 3 | 4 | void test(int a, int b, int c) { 5 | global = (a == b); 6 | global = (a != c); 7 | global = (a < b); 8 | global = (a <= b); 9 | global = (a == 0); 10 | global = (b != 0); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/float-fn/orig.c: -------------------------------------------------------------------------------- 1 | float blahf(float x); 2 | double blah(double x); 3 | 4 | float test(float x) { 5 | x = blahf(x); 6 | x = (float) blah(x); 7 | return x; 8 | } 9 | 10 | float blahf(float x) { return x; } 11 | double blah(double x) { return x; } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/ptr-inference/orig.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | int x; 3 | float y; 4 | char z; 5 | }; 6 | 7 | void foo(signed** ptr1, struct A **ptr2) {} 8 | 9 | void test(void) { 10 | signed* var1; 11 | struct A* var2; 12 | 13 | foo(&var1, &var2); 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_410130; 2 | extern f32 D_410134; 3 | 4 | f32 test(f32 arg0, s32 arg1, f32 arg2, s32 arg3) { 5 | D_410130 = (s32) arg0; 6 | D_410134 = (f32) arg1; 7 | arg2 += 5.0f; 8 | return (f32) (arg3 + 3) + arg2; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/loop/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0, s32 arg1) { 2 | s32 var_r2; 3 | 4 | var_r2 = 0; 5 | if (arg1 > 0) { 6 | do { 7 | *(arg0 + var_r2) = 0; 8 | var_r2 += 1; 9 | } while (var_r2 < arg1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/circular-phis2-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* extern */ 2 | 3 | void test(void) { 4 | bar(); 5 | do { 6 | if (1 != 0) { 7 | bar(); 8 | } 9 | } while ((1 < 1) < 0); 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/loop/agbcc-o0-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0, s32 arg1, s32 arg4) { 2 | unksp0 = arg0; 3 | unksp4 = arg1; 4 | arg4 = 0; 5 | loop_1: 6 | if (arg4 < unksp4) { 7 | *(unksp0 + arg4) = 0; 8 | arg4 += 1; 9 | goto loop_1; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/mwcc-o4p.s: -------------------------------------------------------------------------------- 1 | .include "macros.inc" 2 | 3 | .section .text # 0x0 - 0x4 4 | 5 | .global test 6 | test: 7 | /* 00000000 00000000 48 00 00 00 */ b test 8 | 9 | .section .sbss # 0x0 - 0x4 10 | 11 | .global x 12 | x: 13 | .word 0x00000000 14 | 15 | -------------------------------------------------------------------------------- /tests/end_to_end/eabi64/eabi64-int-float-args-out.c: -------------------------------------------------------------------------------- 1 | ? func_with_args(?, ?, ?, ?); /* extern */ 2 | ? no_args_func(); /* extern */ 3 | 4 | void test(void) { 5 | no_args_func(); 6 | func_with_args(1, 2, 0x40000000, 0x3F800000); 7 | } 8 | -------------------------------------------------------------------------------- /tests/end_to_end/int-float-doublelit/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern f32 globalf; 2 | extern s32 globali; 3 | 4 | f32 test(s32 arg0, s32 arg1, f32 farg0, f64 farg1) { 5 | globali = (s32) farg0; 6 | globalf = (f32) arg0; 7 | return (f32) (arg1 + 3) + (f32) ((f64) (f32) (farg1 + 5.0) + 5.3); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/jump-into-loop/orig.c: -------------------------------------------------------------------------------- 1 | void foo(int); 2 | int test(int x) { 3 | goto label; 4 | 5 | while (x < 4) { 6 | foo(x); 7 | x++; 8 | label: 9 | foo(x); 10 | x *= 2; 11 | } 12 | 13 | return x; 14 | } 15 | 16 | void foo(int x) {} 17 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs/orig.c: -------------------------------------------------------------------------------- 1 | void foo(int x); 2 | void test(int x) { 3 | if (x == 7) { 4 | foo(1); 5 | } else { 6 | foo(2); 7 | if (x == 8) { 8 | foo(3); 9 | } 10 | foo(4); 11 | } 12 | } 13 | 14 | void foo(int x) {} 15 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs2/orig.c: -------------------------------------------------------------------------------- 1 | void foo(int x); 2 | void test(int x) { 3 | if (x == 7) { 4 | foo(1); 5 | if (x == 8) { 6 | foo(2); 7 | } 8 | foo(3); 9 | } else { 10 | foo(4); 11 | } 12 | } 13 | 14 | void foo(int x) {} 15 | -------------------------------------------------------------------------------- /tests/end_to_end/flexible-array-members/orig.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | int x; 3 | int ys[]; 4 | }; 5 | 6 | struct B { 7 | int x, y; 8 | }; 9 | 10 | struct C { 11 | int x; 12 | struct B bs[]; 13 | }; 14 | 15 | int test(struct A *a, struct C *c, int i) { 16 | return a->ys[i] + c->bs[i].y; 17 | } 18 | -------------------------------------------------------------------------------- /tests/end_to_end/fn-write-reordering/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* static */ 2 | ? foo(); /* static */ 3 | extern s32 global; 4 | 5 | void test(void) { 6 | foo(); 7 | global = 1; 8 | bar(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/fn-write-reordering/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* static */ 2 | ? foo(); /* static */ 3 | extern s32 global; 4 | 5 | void test(void) { 6 | foo(); 7 | global = 1; 8 | bar(); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-prevent/manual-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg2) { 2 | s32 temp_v0; 3 | s32 var_t0; 4 | 5 | var_t0 = arg0 + 1; 6 | temp_v0 = var_t0; 7 | if (arg2 != 0) { 8 | var_t0 = arg0 + 2; 9 | } 10 | *NULL = var_t0; 11 | return temp_v0; 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/var-prevent-bug/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | lui $v0, %hi(gChar) 3 | addiu $v0, $v0, %lo(gChar) 4 | sb $zero, ($v0) 5 | .loop: 6 | addiu $v0, $v0, 1 7 | sb $zero, -1($v0) 8 | bnez $zero, .loop 9 | nop 10 | jr $ra 11 | nop 12 | -------------------------------------------------------------------------------- /tests/end_to_end/arrays/orig.c: -------------------------------------------------------------------------------- 1 | short globalArray[5]; 2 | 3 | struct S { 4 | int a; 5 | int b[5]; 6 | }; 7 | 8 | int test(int index, int* argArray, struct S *s) { 9 | char stackArray[] = "hello"; 10 | return (int)stackArray[index] * argArray[index] + globalArray[index] + s->b[index]; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/incbin/manual-out.c: -------------------------------------------------------------------------------- 1 | /* 2 | Unable to find README.md in any of 1 search paths 3 | */ 4 | static s32 foo[2] = { 0x01020304, 0x05060708 }; /* const */ 5 | static s32 bar = 0x05060708; /* const */ 6 | 7 | s32 test(void) { 8 | return *foo + bar; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/return-float/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 __eqsf2(s32, s32); /* extern */ 2 | 3 | s32 test(s32 arg0) { 4 | s32 var_r1; 5 | 6 | var_r1 = 0x41700000; 7 | if (__eqsf2(arg0, 0) == 0) { 8 | var_r1 = arg0; 9 | } 10 | return var_r1; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/weird-asm/test-out.c: -------------------------------------------------------------------------------- 1 | Warning: missing "jr $ra" in last block of test (jumptarget_label). 2 | 3 | extern s32 more special; 4 | static s16 special !@#$%^chars[2] = { 0, 0x1234 }; /* const */ 5 | 6 | void *test(void) { 7 | return &special !@#$%^chars[0x1233FFFF] + more special; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/float-fn/irix-g-out.c: -------------------------------------------------------------------------------- 1 | f32 func_004000DC(f32); /* static */ 2 | f64 func_004000F4(f64); /* static */ 3 | 4 | f32 test(f32 arg0) { 5 | arg0 = func_004000DC(arg0); 6 | arg0 = (f32) func_004000F4((f64) arg0); 7 | return arg0; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | orr r0, r0, r1 11 | mvn r0, r0 12 | bx lr 13 | .Lfe1: 14 | .size test,.Lfe1-test 15 | -------------------------------------------------------------------------------- /tests/end_to_end/division/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | push {lr} 11 | bl __divsi3 12 | pop {pc} 13 | .Lfe1: 14 | .size test,.Lfe1-test 15 | -------------------------------------------------------------------------------- /tests/end_to_end/doubles/orig.c: -------------------------------------------------------------------------------- 1 | double global; 2 | 3 | double test(double a, int b, double c) { 4 | double d = a * b + a / c, e; 5 | d -= 7; 6 | if (d < c || d == c || d > 9.0) { 7 | e = 5.0; 8 | } else { 9 | e = 6.0f; 10 | } 11 | global = e; 12 | return e; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/union_override/test.s: -------------------------------------------------------------------------------- 1 | .set noat 2 | .set noreorder 3 | 4 | glabel test 5 | /* 000000 00400000 8C820000 */ lw $v0, 0($a0) # Load from struct->data (offset 0) 6 | /* 000004 00400004 03E00008 */ jr $ra 7 | /* 000008 00400008 AC850000 */ sw $a1, 0($a0) # Store to struct->data (offset 0) 8 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | void test(struct A *a, s32 b) { 2 | glob = (s32) a->array[b]; 3 | glob = (s32) &a->array[b]; 4 | glob = a->array2[b].x; 5 | glob = (s32) &a->array2[b].x; 6 | glob = a[b].y; 7 | glob = a->array2[3].x; 8 | glob = (s32) &a->array2[3].x; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_nested/orig.c: -------------------------------------------------------------------------------- 1 | int test(int length) { 2 | int i = 0; 3 | int k = 0; 4 | 5 | while (i < length) { 6 | int j = 0; 7 | while (j < length) { 8 | k += (i * j); 9 | j++; 10 | } 11 | i++; 12 | } 13 | 14 | return k; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? foo(s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | return; 7 | } 8 | foo(2); 9 | if (arg0 == 8) { 10 | foo(3); 11 | } 12 | foo(4); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? foo(?); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | return; 7 | } 8 | foo(2); 9 | if (arg0 == 8) { 10 | foo(3); 11 | } 12 | foo(4); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/ps2/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu $sp,$sp,-48 3 | sq $ra,32($sp) 4 | move $a0,$sp 5 | ori $a1,$sp,0x4 6 | li $t4,2 7 | mult $a2,$a2,$t4 8 | mtlo $a3 9 | madd $a2,$t4 10 | jal foo 11 | mflo $a3 12 | lq $ra,32($sp) 13 | jr $ra 14 | addiu $sp,$sp,48 15 | -------------------------------------------------------------------------------- /tests/end_to_end/rlwimi/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern u8 x; 2 | extern u8 y; 3 | 4 | void test(void *arg0) { 5 | x = (((((-2 & x) | (arg0->unk0 & 1)) & ~2) | ((arg0->unk1 & 1) * 2)) & ~0x7C) | ((arg0->unk2 & 0x1F) * 4); 6 | x = (s16) ((0xFFFFF07F & (u16) x) | ((arg0->unk3 & 0x1F) << 7)); 7 | y = (y | 1) & ~2; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/arrays/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern ? D_400130; 2 | extern ? D_410140; 3 | 4 | s32 test(s32 arg0, s32 arg1, s32 arg2) { 5 | sp->unk0 = (s32) D_400130.unk0; 6 | sp->unk4 = (u16) D_400130.unk4; 7 | return (arg2 + (arg0 * 4))->unk4 + ((*(sp + arg0) * *(arg1 + (arg0 * 4))) + *(&D_410140 + (arg0 * 2))); 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/comparison/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_410100; 2 | 3 | void test(s32 arg0, s32 arg1, s32 arg2) { 4 | D_410100 = arg0 == arg1; 5 | D_410100 = arg0 != arg2; 6 | D_410100 = arg0 < arg1; 7 | D_410100 = (arg1 < arg0) ^ 1; 8 | D_410100 = arg0 == 0; 9 | D_410100 = arg1 != 0; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/delay-slot-branch/manual-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0, s32 arg1) { 2 | s32 var_a0; 3 | 4 | var_a0 = arg0; 5 | if (arg1 != 0) { 6 | do { 7 | var_a0 -= 1; 8 | } while (var_a0 != 0); 9 | } else { 10 | var_a0 -= 1; 11 | } 12 | return var_a0; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-type/irix-g-out.c: -------------------------------------------------------------------------------- 1 | ? func_00400090(? *, ? *); /* static */ 2 | 3 | void test(? *arg0, ? *arg1) { 4 | arg0 = &arg0; 5 | arg1 = &arg1; 6 | func_00400090((? *) arg0, (? *) arg1); 7 | arg0 = (? *) arg1; 8 | func_00400090((? *) arg0, (? *) arg1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/signed-conversion/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 glob; 2 | 3 | void test(u8 arg0) { 4 | glob = (s32) arg0; 5 | glob = (s32) (u8) (arg0 * 2); 6 | glob = (s32) (u8) (arg0 * 3); 7 | glob = (s32) (s16) arg0; 8 | glob = (s32) (s16) (arg0 * 2); 9 | glob = (s32) (s16) (arg0 * 3); 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/empty-if/manual.s: -------------------------------------------------------------------------------- 1 | .set noat # allow manual use of $at 2 | .set noreorder # don't insert nops after branches 3 | 4 | glabel test 5 | li $t0, 1 6 | li $t1, 2 7 | beq $a0, $t0, .skip 8 | nop 9 | beq $a1, $t1, .skip 10 | nop 11 | .skip: 12 | beq $a0, $t0, .skip2 13 | nop 14 | .skip2: 15 | jr $ra 16 | nop 17 | -------------------------------------------------------------------------------- /tests/end_to_end/loop-selfassign-phi/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 foo(); /* static */ 2 | 3 | void test(s32 arg0) { 4 | s32 var_r0; 5 | 6 | var_r0 = arg0; 7 | loop_1: 8 | if (var_r0 <= 2) { 9 | goto loop_1; 10 | } 11 | var_r0 = foo(); 12 | goto loop_1; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/loop-selfassign-phi/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 foo(); /* static */ 2 | 3 | void test(s32 arg0) { 4 | s32 var_r3; 5 | 6 | var_r3 = arg0; 7 | loop_1: 8 | if (var_r3 <= 2) { 9 | goto loop_1; 10 | } 11 | var_r3 = foo(); 12 | goto loop_1; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0) { 2 | s32 var_r0; 3 | 4 | var_r0 = 0; 5 | loop_1: 6 | if (var_r0 < arg0) { 7 | if (var_r0 == 5) { 8 | var_r0 = 0xA; 9 | } else { 10 | var_r0 += 4; 11 | } 12 | goto loop_1; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-output2/test.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | li $a3, 0 3 | .loop: 4 | addiu $a2, $a3, 1 5 | lw $v0, 4($a2) 6 | lw $a3, ($zero) 7 | beqz $a0, .skip 8 | nop 9 | lw v0, 4(a2) 10 | .skip: 11 | bnez $a0, .loop 12 | nop 13 | jr $ra 14 | nop 15 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-type/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | ? func_00400090(? *, ? *); /* static */ 2 | 3 | void test(? *arg0, ? *arg1) { 4 | arg0 = &arg0; 5 | arg1 = &arg1; 6 | func_00400090((? *) &arg0, (? *) &arg1); 7 | arg0 = (? *) arg1; 8 | func_00400090((? *) arg1, (? *) arg1); 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/rodata-literals/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern f32 D_410130; 2 | extern f64 D_410138; 3 | extern f64 D_410140; 4 | extern ? *D_410148; 5 | 6 | void test(void) { 7 | D_410130 = 1.2f; 8 | D_410138 = 13.0; 9 | D_410140 = 14000000000.0; 10 | D_410148 = "\"hello\"\n\x01\0world /* comment */ #"; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/rodata-literals/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern f32 D_410120; 2 | extern f64 D_410128; 3 | extern f64 D_410130; 4 | extern ? *D_410138; 5 | 6 | void test(void) { 7 | D_410120 = 1.2f; 8 | D_410128 = 13.0; 9 | D_410130 = 14000000000.0; 10 | D_410138 = "\"hello\"\n\x01\0world /* comment */ #"; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/arguments/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 __addsf3(s32, s32); /* extern */ 2 | extern s32 globalf; 3 | extern s32 globali; 4 | 5 | void test(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { 6 | globalf = __addsf3(__addsf3(arg0, arg2), arg4); 7 | globali = arg1 + arg3 + arg5; 8 | } 9 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(struct A *a, s32 b) { 2 | glob = (s32) a->array[b]; 3 | glob = (s32) &a->array[b]; 4 | glob = *(&a->array2[0].x + (b * 8)); 5 | glob = (s32) &a->array2[b].x; 6 | glob = a[b].y; 7 | glob = a->array2[3].x; 8 | glob = (s32) &a->array2[3].x; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-sqrtf/with-trunc.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu $sp,$sp,-0x18 3 | sqrt.s $f0,$f12 4 | c.eq.s $f0,$f0 5 | nop 6 | bc1t .label_20 7 | sw $ra,0x10($sp) 8 | jal sqrtf 9 | nop 10 | .label_20 11 | lw $ra, 0x10($sp) 12 | trunc.w.s $f2, $f0 13 | mfc1 $v0, $f2 14 | jr $ra 15 | addiu $sp,$sp,0x18 16 | nop -------------------------------------------------------------------------------- /tests/end_to_end/int-float-doublelit/orig.c: -------------------------------------------------------------------------------- 1 | int globali; 2 | float globalf; 3 | 4 | float test(float f1, int i1, float f2, unsigned i2) { 5 | globali = (int)f1; 6 | globalf = (float)i1; 7 | i2 += 3; 8 | f2 += 5.0; 9 | f2 += 0.0; 10 | f2 += 0.0f; 11 | f2 += 5.3; 12 | return (float)i2 + f2; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/load-types/orig.c: -------------------------------------------------------------------------------- 1 | signed char a; 2 | unsigned char b; 3 | signed short c; 4 | unsigned short d; 5 | signed int e; 6 | unsigned int f; 7 | 8 | int ar[6]; 9 | 10 | void test(void) { 11 | ar[0] = a; 12 | ar[1] = b; 13 | ar[2] = c; 14 | ar[3] = d; 15 | ar[4] = e; 16 | ar[5] = f; 17 | } 18 | -------------------------------------------------------------------------------- /tests/end_to_end/loop/irix-g-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 arg0, s32 arg1) { 2 | s32 sp4; 3 | s32 temp_t9; 4 | 5 | sp4 = 0; 6 | if (arg1 > 0) { 7 | do { 8 | *(arg0 + sp4) = 0; 9 | temp_t9 = sp4 + 1; 10 | sp4 = temp_t9; 11 | } while (temp_t9 < arg1); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/context_3.c: -------------------------------------------------------------------------------- 1 | struct square { 2 | shape_t shape; 3 | float width; 4 | float height; 5 | }; 6 | 7 | struct circle { 8 | shape_t shape; 9 | float radius; 10 | }; 11 | 12 | struct triangle { 13 | shape_t shape; 14 | struct vec2 db; 15 | struct vec2 dc; 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs2/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? foo(?); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | if (arg0 == 8) { 7 | foo(2); 8 | } 9 | foo(3); 10 | return; 11 | } 12 | foo(4); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 foo(s32, s32 *); /* static */ 2 | 3 | void test(s32 arg0, s32 *arg1) { 4 | s32 temp_r4; 5 | s32 temp_r6; 6 | 7 | unksp0 = arg0; 8 | temp_r4 = foo(arg0, &unksp0); 9 | temp_r6 = foo(unksp0, arg1); 10 | foo(*arg1, arg1); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/union_override_samesize/test.s: -------------------------------------------------------------------------------- 1 | .set noat 2 | .set noreorder 3 | 4 | glabel test 5 | /* 000000 00400000 8C820000 */ lw $v0, 0($a0) # Load first field 6 | /* 000004 00400004 8C830004 */ lw $v1, 4($a0) # Load second field 7 | /* 000008 00400008 03E00008 */ jr $ra 8 | /* 00000C 0040000C 00000000 */ nop 9 | -------------------------------------------------------------------------------- /tests/end_to_end/ida/handwritten.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | 3 | la $v0, symbol 4 | lw $v0, ($v0) 5 | 6 | la $v1, symbol + 8 7 | lw $v1, 4($v1) 8 | 9 | # same as addition 10 | la $v0, 4($v0) 11 | 12 | lw $a0, symbol 13 | 14 | lw $a1, symbol+4 15 | 16 | sw $a1, symbol 17 | 18 | addu $v0, $v1 19 | addu $v0, $a1 20 | 21 | jr $ra 22 | nop 23 | -------------------------------------------------------------------------------- /tests/end_to_end/if-bitand/orig.c: -------------------------------------------------------------------------------- 1 | volatile int glob; 2 | 3 | void test(void) { 4 | if (glob & 0x1) glob = 0; 5 | if (glob & 0x10000) glob = 0; 6 | if (glob & 0x80000000) glob = 0; 7 | if ((glob & 0x1) != 0) glob = 0; 8 | if ((glob & 0x10000) != 0) glob = 0; 9 | if ((glob & 0x80000000) != 0) glob = 0; 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs3/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? foo(s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | foo(3); 7 | return; 8 | } 9 | foo(4); 10 | if (arg0 == 9) { 11 | foo(5); 12 | } 13 | foo(6); 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs4/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? foo(s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | foo(3); 7 | return; 8 | } 9 | foo(4); 10 | if (arg0 == 9) { 11 | foo(5); 12 | } 13 | foo(6); 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/no-ifs-early-returns/orig.c: -------------------------------------------------------------------------------- 1 | struct A { 2 | int x; 3 | }; 4 | 5 | int test(struct A *a, struct A *b) { 6 | switch (a->x) { 7 | case 8: 8 | b->x += a->x; 9 | break; 10 | case 15: 11 | b->x -= a->x; 12 | break; 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/phis-1/manual-out.c: -------------------------------------------------------------------------------- 1 | void *foo(); /* extern */ 2 | 3 | void test(void) { 4 | void *sp10C; 5 | void *temp_t1; 6 | 7 | temp_t1 = foo(); 8 | if (*NULL == 0) { 9 | sp10C = temp_t1; 10 | } 11 | temp_t1->unk3 = 0; 12 | temp_t1->unk4 = 0; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/typedef/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 foo(s32, s32 *); /* static */ 2 | 3 | void test(s32 arg0, s32 *arg1) { 4 | s32 sp8; 5 | s32 temp_r30; 6 | s32 temp_r31; 7 | 8 | sp8 = arg0; 9 | temp_r30 = foo(arg0); 10 | temp_r31 = foo(arg0, &sp8); 11 | foo(*arg1, arg1); 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/loop-selfassign-phi/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 func_004000F4(s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | s32 var_s0; 5 | 6 | var_s0 = arg0; 7 | loop_1: 8 | if (var_s0 < 3) { 9 | goto loop_1; 10 | } 11 | var_s0 = func_004000F4(var_s0); 12 | goto loop_1; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/context_2.c: -------------------------------------------------------------------------------- 1 | // Use typedefs in this file to mix things up 2 | 3 | typedef enum { 4 | SHAPE_SQUARE, 5 | SHAPE_CIRCLE, 6 | SHAPE_TRIANGLE 7 | } shape_type_t; 8 | 9 | typedef struct { 10 | shape_type_t type; 11 | struct vec2 origin; 12 | } shape_t; 13 | 14 | float test(shape_t *s); 15 | -------------------------------------------------------------------------------- /tests/end_to_end/rodata-literals/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern f32 a; 2 | extern f64 b; 3 | extern f64 c; 4 | extern ? *d; 5 | static ? $$25; /* unable to generate initializer: unknown type */ 6 | 7 | void test(void) { 8 | a = 1.2f; 9 | b = 13.0; 10 | c = 14000000000.0; 11 | d = &$$25; 12 | } 13 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/c_files/example_c_file.c: -------------------------------------------------------------------------------- 1 | char tav = 'b'; 2 | char* moral = "ain't I \\\"\\\t\" a nice string?\"\""; 3 | char* comment_inside = "but you will /* see it */!!!!"; 4 | char* i_have_newlines = "line one\nline two\nline three"; 5 | 6 | int main() 7 | { 8 | auto char* multi = "a multi"; 9 | } 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer2/orig.c: -------------------------------------------------------------------------------- 1 | int (*volatile glob)(float); 2 | int (*volatile glob2)(float); 3 | int foo(float x); 4 | int bar(float x); 5 | 6 | void test(void) { 7 | glob = foo; 8 | glob = bar; 9 | glob2 = foo; 10 | glob2 = bar; 11 | } 12 | 13 | int foo(float x) { return 1; } 14 | int bar(float x) { return 2; } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/nor/irix-o2.s: -------------------------------------------------------------------------------- 1 | .set noat # allow manual use of $at 2 | .set noreorder # don't insert nops after branches 3 | 4 | 5 | glabel test 6 | /* 000090 00400090 03E00008 */ jr $ra 7 | /* 000094 00400094 00851027 */ nor $v0, $a0, $a1 8 | 9 | /* 000098 00400098 00000000 */ nop 10 | /* 00009C 0040009C 00000000 */ nop 11 | -------------------------------------------------------------------------------- /tests/end_to_end/signed-conversion/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_410140; 2 | 3 | void test(s8 arg0) { 4 | D_410140 = (s32) arg0; 5 | D_410140 = (s32) (s8) (arg0 * 2); 6 | D_410140 = (s32) (s8) (arg0 * 3); 7 | D_410140 = (s32) (s16) arg0; 8 | D_410140 = (s32) (s16) (arg0 * 2); 9 | D_410140 = (s32) (s16) (arg0 * 3); 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern ? D_410150; 2 | extern ? D_4102E0; 3 | 4 | void test(void *arg0, void *arg1) { 5 | M2C_MEMCPY_ALIGNED(&D_410150, &D_4102E0, 0x18C); 6 | D_410150.unk18C = (s32) D_4102E0.unk18C; 7 | M2C_MEMCPY_UNALIGNED(arg0, arg1, 0x60); 8 | arg0->unk60 = (unaligned s32) arg1->unk60; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/asm-arith/test.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | li $a0, sym1 3 | sw $a0, ($zero) 4 | sw $zero, sym2($zero) 5 | .set sym3, 0x20 6 | sym4 = 0x20 7 | sw $zero, sym3($zero) 8 | sw $zero, (sym3 * 2)($zero) 9 | li $a0, ((sym4 * 2) + 0x10) 10 | sw $a0, ($zero) 11 | lui $a0, %hi(sym + (2 + 6)) 12 | sw $zero, %lo(sym + (2 + 6))($a0) 13 | jr $ra 14 | nop 15 | -------------------------------------------------------------------------------- /tests/end_to_end/fn-write-reordering/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 func_004000F0(); /* static */ 2 | ? func_00400108(s32); /* static */ 3 | extern s32 D_410120; 4 | 5 | void test(void) { 6 | s32 sp1C; 7 | 8 | sp1C = func_004000F0(); 9 | D_410120 = 1; 10 | func_00400108(sp1C); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/ir-pattern-input/manual.s: -------------------------------------------------------------------------------- 1 | .global test 2 | test: 3 | stwu r1, -0x30(r1) 4 | 5 | lfs f2, myfloat@sda21(r2) 6 | 7 | fneg f1, f2 8 | cmpwi r3, 7 9 | beq .done 10 | 11 | fctiwz f4, f1 12 | fadds f1, f2, f2 13 | stfd f4, 0x28(r1) 14 | lwz r0, 0x2c(r1) 15 | stw r0, myint@sda21(r2) 16 | .done: 17 | 18 | addi r1, r1, 0x30 19 | blr 20 | -------------------------------------------------------------------------------- /tests/end_to_end/jump-into-loop/irix-g-out.c: -------------------------------------------------------------------------------- 1 | ? func_0040010C(s32); /* static */ 2 | 3 | s32 test(s32 arg0) { 4 | loop_3: 5 | func_0040010C(arg0); 6 | arg0 *= 2; 7 | if (arg0 < 4) { 8 | func_0040010C(arg0); 9 | arg0 += 1; 10 | goto loop_3; 11 | } 12 | return arg0; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | s32 var_r4; 3 | 4 | var_r4 = 0; 5 | loop_4: 6 | if (var_r4 < arg0) { 7 | if (var_r4 == 5) { 8 | var_r4 *= 2; 9 | } else { 10 | var_r4 += 4; 11 | } 12 | goto loop_4; 13 | } 14 | return var_r4; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/struct-copy/irix-o2-mips1-out.c: -------------------------------------------------------------------------------- 1 | extern ? D_410160; 2 | extern ? D_4102F0; 3 | 4 | void test(void *arg0, void *arg1) { 5 | M2C_MEMCPY_ALIGNED(&D_410160, &D_4102F0, 0x18C); 6 | D_410160.unk18C = (s32) D_4102F0.unk18C; 7 | M2C_MEMCPY_UNALIGNED(arg0, arg1, 0x60); 8 | arg0->unk60 = (unaligned s32) arg1->unk60; 9 | } 10 | -------------------------------------------------------------------------------- /tests/end_to_end/incbin/manual.s: -------------------------------------------------------------------------------- 1 | .section .rodata 2 | foo: 3 | .incbin "test.bin" 4 | 5 | bar: 6 | .incbin "test.bin", 4, 4 7 | 8 | baz: 9 | .incbin "README.md" 10 | 11 | .section .text 12 | glabel test 13 | lui $a0, %hi(foo) 14 | lw $a0, %lo(foo)($a0) 15 | lui $a1, %hi(bar) 16 | lw $a1, %lo(bar)($a1) 17 | addu $v0, $a0, $a1 18 | jr $ra 19 | nop 20 | -------------------------------------------------------------------------------- /tests/end_to_end/branch-likely-one-instruction/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | lui $v0, 0x800a 3 | lw $v0, -0x5a00($v0) 4 | lui $v1, 0x800b 5 | lb $v1, 0xf15($v1) 6 | xori $v0, $v0, 3 7 | sltiu $a0, $v0, 1 8 | addiu $v0, $zero, 5 9 | beql $v1, $v0, .L8004416C 10 | addiu $a0, $zero, 1 11 | .L8004416C: 12 | jr $ra 13 | daddu $v0, $a0, $zero 14 | 15 | -------------------------------------------------------------------------------- /tests/end_to_end/enums/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | enum my_enum test(enum my_enum x) { 2 | switch (x) { /* irregular */ 3 | case ZERO: 4 | return array->unk0; 5 | case TWO_TOO: 6 | return array[1]; 7 | case THREE: 8 | return array[2]; 9 | default: 10 | return ZERO; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/fn-write-reordering/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 func_004000E4(); /* static */ 2 | ? func_004000EC(s32); /* static */ 3 | extern s32 D_410100; 4 | 5 | void test(void) { 6 | s32 temp_v0; 7 | 8 | temp_v0 = func_004000E4(); 9 | D_410100 = 1; 10 | func_004000EC(temp_v0); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | s32 sp4; 3 | 4 | sp4 = 0; 5 | if (sp4 < arg0) { 6 | do { 7 | if (sp4 == 5) { 8 | sp4 *= 2; 9 | } else { 10 | sp4 += 4; 11 | } 12 | } while (sp4 < arg0); 13 | } 14 | return sp4; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/circular-phis-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* extern */ 2 | 3 | void test(void) { 4 | s32 var_v0; 5 | 6 | bar(); 7 | var_v0 = 4; 8 | do { 9 | if (1 != 0) { 10 | bar(); 11 | var_v0 = 5; 12 | } 13 | } while ((var_v0 > 1) < 0); 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/ir-pattern-input/manual-out.c: -------------------------------------------------------------------------------- 1 | extern f32 myfloat; 2 | extern s32 myint; 3 | 4 | f32 test(s32 arg0) { 5 | f32 temp_f1; 6 | f32 var_f1; 7 | 8 | var_f1 = -myfloat; 9 | if (arg0 != 7) { 10 | temp_f1 = var_f1; 11 | var_f1 = 2.0f * myfloat; 12 | myint = (s32) temp_f1; 13 | } 14 | return var_f1; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/phis-1/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu $sp, $sp, -0x110 3 | jal foo 4 | nop 5 | move $t1, $v0 6 | lbu $t0, ($zero) 7 | bnez $t0, .L0043D650 8 | nop 9 | sw $t1, 0x10c($sp) 10 | lw $t1, 0x10c($sp) 11 | .L0043D650: 12 | sb $zero, 3($t1) 13 | sb $zero, 4($t1) 14 | jr $ra 15 | addiu $sp, $sp, 0x110 16 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | add r1, r0, #0 11 | neg r0, r1 12 | orr r0, r0, r1 13 | lsr r0, r0, #31 14 | bx lr 15 | .Lfe1: 16 | .size test,.Lfe1-test 17 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/irix-g-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 *x) { 2 | s8 sp2F; 3 | s32 *sp28; 4 | s32 sp24; 5 | 6 | sp2F = (s8) x->unk0; 7 | sp28 = x + 0x28; 8 | sp24 = x->unk190; 9 | sp2F += *func_00400090(&sp2F); 10 | sp28 = func_00400090(&sp28); 11 | sp24 += *func_00400090(&sp24); 12 | return *sp28 + sp2F + sp24; 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs/irix-g-out.c: -------------------------------------------------------------------------------- 1 | ? func_004000FC(?); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | func_004000FC(1); 6 | } else { 7 | func_004000FC(2); 8 | if (arg0 == 8) { 9 | func_004000FC(3); 10 | } 11 | func_004000FC(4); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | ? func_004000F0(?, s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | func_004000F0(1, arg0); 6 | return; 7 | } 8 | func_004000F0(2, arg0); 9 | if (arg0 == 8) { 10 | func_004000F0(3, arg0); 11 | } 12 | func_004000F0(4); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs2/irix-g-out.c: -------------------------------------------------------------------------------- 1 | ? func_004000FC(?); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | func_004000FC(1); 6 | if (arg0 == 8) { 7 | func_004000FC(2); 8 | } 9 | func_004000FC(3); 10 | } else { 11 | func_004000FC(4); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/conditional-use.s: -------------------------------------------------------------------------------- 1 | # a conditional use should still count as a use 2 | glabel test 3 | addiu $sp, $sp, -0x30 4 | sw $ra, 0x2C($sp) 5 | li $v0, 4 6 | li $v1, 1 7 | beqz $v1, .skip 8 | nop 9 | beqz $v1, .skip 10 | nop 11 | move $a0, $v0 12 | jal foo 13 | nop 14 | .skip: 15 | lw $ra, 0x2C($sp) 16 | jr $ra 17 | addiu $sp, $sp, 0x30 18 | -------------------------------------------------------------------------------- /tests/end_to_end/abs-sqrt/orig.c: -------------------------------------------------------------------------------- 1 | float fabsf(float x); 2 | double fabs(double x); 3 | float sqrtf(float x); 4 | double sqrt(double x); 5 | #pragma intrinsic (fabsf) 6 | #pragma intrinsic (fabs) 7 | #pragma intrinsic (sqrtf) 8 | #pragma intrinsic (sqrt) 9 | 10 | float test(float a) { 11 | double r = (double)sqrtf(fabsf(a)); 12 | return (float)sqrt(fabs(r)); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/load-types/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern u8 a; 2 | extern ? ar; 3 | extern u8 b; 4 | extern s16 c; 5 | extern u16 d; 6 | extern s32 e; 7 | extern s32 f; 8 | 9 | void test(void) { 10 | ar.unk0 = (s32) (s8) a; 11 | ar.unk4 = (s32) b; 12 | ar.unk8 = (s32) c; 13 | ar.unkC = (s32) d; 14 | ar.unk10 = (s32) e; 15 | ar.unk14 = (s32) f; 16 | } 17 | -------------------------------------------------------------------------------- /tests/end_to_end/load-types/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern u8 a; 2 | extern u8 b; 3 | extern s16 c; 4 | extern u16 d; 5 | extern s32 e; 6 | extern s32 f; 7 | static ? ar; 8 | 9 | void test(void) { 10 | ar.unk0 = (s32) (s8) a; 11 | ar.unk4 = (s32) b; 12 | ar.unk8 = (s32) c; 13 | ar.unkC = (s32) d; 14 | ar.unk10 = (s32) e; 15 | ar.unk14 = (s32) f; 16 | } 17 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern s32 *D_410140; 2 | 3 | void test(struct A *a, s32 b) { 4 | D_410140 = a->array[b]; 5 | D_410140 = (s32 *) &a->array[b]; 6 | D_410140 = (s32 *) a->array2[b].x; 7 | D_410140 = &a->array2[b].x; 8 | D_410140 = (s32 *) a[b].y; 9 | D_410140 = (s32 *) a->array2[3].x; 10 | D_410140 = &a->array2[3].x; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/arrays/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern ? D_400120; 2 | extern ? D_410130; 3 | 4 | s32 test(s32 arg0, s32 arg1, s32 arg2) { 5 | s32 temp_v1; 6 | 7 | sp->unk0 = (s32) D_400120.unk0; 8 | temp_v1 = arg0 * 4; 9 | sp->unk4 = (u16) D_400120.unk4; 10 | return (arg2 + temp_v1)->unk4 + (*(sp + arg0) * *(arg1 + temp_v1)) + *(&D_410130 + (arg0 * 2)); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/custom-return/orig.c: -------------------------------------------------------------------------------- 1 | typedef unsigned short u16; 2 | u16 foo(int x); 3 | 4 | int glob; 5 | 6 | int test(void) { 7 | unsigned short temp = foo(1); 8 | if (temp != 0) { 9 | return temp; 10 | } 11 | 12 | if (glob != 123) 13 | return foo(2); 14 | else 15 | return foo(3); 16 | } 17 | 18 | u16 foo(int x) { return 1; } 19 | -------------------------------------------------------------------------------- /tests/end_to_end/loop_with_if/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 arg0) { 2 | s32 var_v1; 3 | 4 | var_v1 = 0; 5 | if (arg0 > 0) { 6 | do { 7 | if (var_v1 == 5) { 8 | var_v1 *= 2; 9 | } else { 10 | var_v1 += 4; 11 | } 12 | } while (var_v1 < arg0); 13 | } 14 | return var_v1; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs3/orig.c: -------------------------------------------------------------------------------- 1 | void foo(int x); 2 | void test(int x) { 3 | if (x == 7) { 4 | foo(1); 5 | if (x == 8) { 6 | foo(2); 7 | } 8 | foo(3); 9 | } else { 10 | foo(4); 11 | if (x == 9) { 12 | foo(5); 13 | } 14 | foo(6); 15 | } 16 | } 17 | 18 | void foo(int x) {} 19 | -------------------------------------------------------------------------------- /tests/end_to_end/array-access/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 *D_410110; 2 | 3 | void test(struct A *a, s32 b) { 4 | D_410110 = a->array[b]; 5 | D_410110 = (s32 *) &a->array[b]; 6 | D_410110 = (s32 *) a->array2[b].x; 7 | D_410110 = &a->array2[b].x; 8 | D_410110 = (s32 *) a[b].y; 9 | D_410110 = (s32 *) a->array2[3].x; 10 | D_410110 = &a->array2[3].x; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/custom-return/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | u16 foo(?); /* static */ 2 | extern s32 glob; 3 | 4 | u16 test(void) { 5 | u16 temp_r3; 6 | 7 | temp_r3 = foo(1); 8 | if (temp_r3 != 0) { 9 | return temp_r3; 10 | } 11 | if ((s32) glob != 0x7B) { 12 | return foo(2); 13 | } 14 | return foo(3); 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/function-pointer/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | push {lr} 11 | add r2, r0, #0 12 | add r0, r1, #0 13 | bl _call_via_r2 14 | add r0, r0, #1 15 | pop {pc} 16 | .Lfe1: 17 | .size test,.Lfe1-test 18 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs2/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | ? func_004000F0(?, s32); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | func_004000F0(1, arg0); 6 | if (arg0 == 8) { 7 | func_004000F0(2, arg0); 8 | } 9 | func_004000F0(3); 10 | return; 11 | } 12 | func_004000F0(4, arg0); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/circular-phis-ctx-out.c: -------------------------------------------------------------------------------- 1 | ? bar(); /* extern */ 2 | 3 | s32 test(void) { 4 | s32 var_v0; 5 | 6 | bar(); 7 | var_v0 = 4; 8 | do { 9 | if (1 != 0) { 10 | bar(); 11 | var_v0 = 5; 12 | } 13 | } while ((var_v0 > 1) < 0); 14 | return var_v0; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 *x) { 2 | s8 sp14; 3 | s32 *sp10; 4 | s32 spC; 5 | 6 | sp10 = x + 0x28; 7 | sp14 = (s8) x->unk0; 8 | spC = x->unk190; 9 | sp14 = (u8) sp14 + *func_00400090(&sp14); 10 | sp10 = func_00400090(&sp10); 11 | spC += *func_00400090(&spC); 12 | return (s8) (u8) sp14 + (*sp10 + spC); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/arrays/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? memcpy(? *, ? *, s32); /* extern */ 2 | extern ? globalArray; 3 | 4 | s32 test(s32 arg0, s32 arg1, s32 arg2) { 5 | s32 temp_r2; 6 | 7 | memcpy(&unksp0, "hello", 6); 8 | temp_r2 = arg0 * 4; 9 | return (*(temp_r2 + arg1) * *(&unksp0 + arg0)) + *((arg0 * 2) + &globalArray) + *(arg2 + 4 + temp_r2); 10 | } 11 | -------------------------------------------------------------------------------- /tests/end_to_end/branch-likely-b/manual.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | 3 | li $t1, 1 4 | 5 | b .label 6 | sw $zero, ($zero) 7 | 8 | b .label 9 | sw $zero, ($zero) 10 | 11 | sw $zero, ($zero) 12 | .label: 13 | 14 | b .label2 15 | nop 16 | .label2: 17 | 18 | b .label3 19 | sw $zero, ($t1) 20 | 21 | b .label4 22 | sw $zero, ($t1) 23 | .label3: 24 | 25 | nop 26 | .label4: 27 | jr $ra 28 | nop 29 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | ldr r1, [r0] 11 | lsr r2, r1, #31 12 | add r1, r1, r2 13 | asr r1, r1, #1 14 | str r1, [r0] 15 | bx lr 16 | .Lfe1: 17 | .size test,.Lfe1-test 18 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-output/test.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | li $t1, 0 3 | .loop: 4 | beq $a0, $zero, .alt2 5 | nop 6 | move $at, $a1 7 | lw $t2, 1($at) 8 | b .done 9 | nop 10 | .alt2: 11 | lw $t2, 1($a1) 12 | .done: 13 | addu $t1, $t1, $t2 14 | li $a1, 0 15 | bnez $t1, .loop 16 | nop 17 | jr $ra 18 | nop 19 | -------------------------------------------------------------------------------- /tests/end_to_end/rlwimi/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern u8 x; 2 | extern u8 y; 3 | 4 | void test(void *arg0) { 5 | x = (x & ~0x80) | ((arg0->unk0 << 7) & 0x80); 6 | x = (x & ~0x40) | ((arg0->unk1 << 6) & 0x40); 7 | x = (x & ~0x3E) | ((arg0->unk2 << 1) & 0x3E); 8 | y |= 0x80; 9 | x = (s16) (((u16) x & ~0x1F0) | (((s8) arg0->unk3 << 4) & 0x1F0)); 10 | y &= ~0x40; 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/signed-conversion/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 D_410110; 2 | 3 | void test(s8 arg0) { 4 | s8 temp_v0; 5 | 6 | temp_v0 = arg0 * 2; 7 | D_410110 = (s32) arg0; 8 | D_410110 = (s32) temp_v0; 9 | D_410110 = (s32) (s8) (arg0 * 3); 10 | D_410110 = (s32) (s16) arg0; 11 | D_410110 = (s32) (s16) temp_v0; 12 | D_410110 = (s32) (s16) (arg0 * 3); 13 | } 14 | -------------------------------------------------------------------------------- /tests/end_to_end/union_override/ctx.h: -------------------------------------------------------------------------------- 1 | // Test context with a union that has multiple fields of the same size 2 | typedef int s32; 3 | typedef float f32; 4 | 5 | union TestUnion { 6 | f32 float_field; 7 | void *ptr_field; 8 | s32 int_field; 9 | }; 10 | 11 | struct TestStruct { 12 | union TestUnion data; 13 | }; 14 | 15 | s32 test(struct TestStruct *arg0, s32 arg1); 16 | -------------------------------------------------------------------------------- /tests/end_to_end/rodata-literals/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | extern s32 a; 2 | extern ? b; 3 | extern ? c; 4 | extern ? d; 5 | 6 | void test(void) { 7 | ? *temp_r2; 8 | 9 | a = 0x3F99999A; 10 | b.unk0 = &c; 11 | b.unk4 = &d; 12 | temp_r2 = "\"hello\"\n\x01"; 13 | temp_r2->unk0 = (s32) .L3.unk18; 14 | temp_r2->unk4 = (s32) .L3.unk1C; 15 | *.L3.unk20 = .L3.unk24; 16 | } 17 | -------------------------------------------------------------------------------- /tests/end_to_end/sqrt/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 __mulsf3(s32, s32); /* extern */ 2 | s32 __subsf3(s32, s32); /* extern */ 3 | 4 | void test(s32 arg0) { 5 | s32 temp_r5; 6 | 7 | temp_r5 = 0x5F3759DF - (arg0 >> 1); 8 | __mulsf3(temp_r5, __subsf3(0x3FC00000, __mulsf3(__mulsf3(__mulsf3(arg0, 0x3F000000), temp_r5), temp_r5))); 9 | } 10 | -------------------------------------------------------------------------------- /m2c/error.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from dataclasses import dataclass 3 | from typing import NoReturn 4 | 5 | 6 | @dataclass 7 | class DecompFailure(Exception): 8 | message: str 9 | 10 | def __str__(self) -> str: 11 | return self.message 12 | 13 | 14 | def static_assert_unreachable(x: NoReturn) -> NoReturn: 15 | raise Exception(f"Unreachable: {repr(x)}") 16 | -------------------------------------------------------------------------------- /tests/end_to_end/custom-return/irix-g-out.c: -------------------------------------------------------------------------------- 1 | u16 func_0040012C(?); /* static */ 2 | extern s32 D_410150; 3 | 4 | u16 test(void) { 5 | u16 sp1E; 6 | 7 | sp1E = func_0040012C(1); 8 | if (sp1E != 0) { 9 | return sp1E; 10 | } 11 | if (D_410150 != 0x7B) { 12 | return func_0040012C(2); 13 | } 14 | return func_0040012C(3); 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/float-branch-evalonce/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern f32 x; 2 | 3 | void test(void) { 4 | s32 temp_cr0_lt; 5 | s32 temp_cr0_lt_2; 6 | 7 | temp_cr0_lt = x < 0.0f; 8 | x = 5.0f; 9 | if (temp_cr0_lt != 0) { 10 | x = 6.0f; 11 | } 12 | temp_cr0_lt_2 = x < 0.0f; 13 | x = 3.0f; 14 | if (temp_cr0_lt_2 == 0) { 15 | x = 7.0f; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/end_to_end/gcc-sqrtf/with-mov.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu $sp,$sp,-0x18 3 | sqrt.s $f2,$f12 4 | c.eq.s $f2,$f2 5 | nop 6 | bc1t .label_24 7 | sw $ra,0x10($sp) 8 | jal sqrtf 9 | nop 10 | mov.s $f2,$f0 11 | .label_24 12 | lui $at,0x3f00 13 | mtc1 $at,$f0 14 | nop 15 | mul.s $f0,$f2,$f0 16 | nop 17 | lw $ra,0x10($sp) 18 | jr $ra 19 | addiu $sp,$sp,0x18 20 | nop -------------------------------------------------------------------------------- /tests/end_to_end/multiple_context/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 __addsf3(f32, s32); /* extern */ 2 | 3 | f32 test(shape_t *s) { 4 | s32 temp_r0; 5 | 6 | temp_r0 = s->type; 7 | if ((temp_r0 != SHAPE_CIRCLE) && ((u32) temp_r0 >= 1U) && (temp_r0 != SHAPE_TRIANGLE)) { 8 | return 0.0f; 9 | } 10 | return (bitwise f32) __addsf3(s->origin.x, s->unkC); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_none/mwcc-o4p.s: -------------------------------------------------------------------------------- 1 | .include "macros.inc" 2 | 3 | .section .text # 0x0 - 0x14 4 | 5 | .global test 6 | test: 7 | /* 00000000 00000000 2C 03 00 00 */ cmpwi r3, 0 8 | /* 00000004 00000004 38 60 00 00 */ li r3, 0 9 | /* 00000008 00000008 4D 82 00 20 */ beqlr 10 | /* 0000000C 0000000C 38 60 00 01 */ li r3, 1 11 | /* 00000010 00000010 4E 80 00 20 */ blr 12 | 13 | -------------------------------------------------------------------------------- /tests/end_to_end/seb-seh/seb-mwcc.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu sp,sp,-0x20 3 | sw ra,0xc(sp) 4 | sw s0,8(sp) 5 | sw a0,0x10(sp) 6 | lw v0,0x10(sp) 7 | seb a0,v0 8 | jal foo 9 | nop 10 | seb v0,v0 11 | addiu v0,v0,1 12 | seb v0,v0 13 | seb s0,v0 14 | move v0,s0 15 | lw ra,0xc(sp) 16 | lw s0,8(sp) 17 | addiu sp,sp,0x20 18 | jr ra 19 | nop 20 | -------------------------------------------------------------------------------- /tests/end_to_end/seb-seh/seh-mwcc.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu sp,sp,-0x20 3 | sw ra,0xc(sp) 4 | sw s0,8(sp) 5 | sw a0,0x10(sp) 6 | lw v0,0x10(sp) 7 | seh a0,v0 8 | jal foo 9 | nop 10 | seh v0,v0 11 | addiu v0,v0,1 12 | seh v0,v0 13 | seh s0,v0 14 | move v0,s0 15 | lw ra,0xc(sp) 16 | lw s0,8(sp) 17 | addiu sp,sp,0x20 18 | jr ra 19 | nop 20 | -------------------------------------------------------------------------------- /tests/end_to_end/stack_reference/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | add sp, sp, #-8 11 | str r0, [sp, #4] 12 | str r1, [sp] 13 | mov r0, #1 14 | neg r0, r0 15 | add sp, sp, #8 16 | bx lr 17 | .Lfe1: 18 | .size test,.Lfe1-test 19 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/orig.c: -------------------------------------------------------------------------------- 1 | void *func_00400090(void * x) { 2 | return x; 3 | } 4 | 5 | int test(int *x) { 6 | char a; 7 | int *b; 8 | int c; 9 | 10 | a = x[0]; 11 | b = &x[10]; 12 | c = x[100]; 13 | 14 | a += *(char *) func_00400090(&a); 15 | b = func_00400090(&b); 16 | c += *(int *) func_00400090(&c); 17 | 18 | return a + *b + c; 19 | } 20 | -------------------------------------------------------------------------------- /m2c_pycparser/README: -------------------------------------------------------------------------------- 1 | Vendored copy of https://github.com/eliben/pycparser, with some patches to accept various C syntax extensions. 2 | Upstream commit: b5c6024ff01346b194e43435af71a210b1e8e2ae ("Update _ast_gen.py to be in sync with c_ast.py (#582)", Sep 16 2025) 3 | 4 | Changes inspired by https://github.com/inducer/pycparserext. 5 | 6 | To update lextab/yacctab: `rm -f *tab.py && python3 _build_tables.py` 7 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs3/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? foo(?); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | if (arg0 == 8) { 7 | foo(2); 8 | } 9 | foo(3); 10 | return; 11 | } 12 | foo(4); 13 | if (arg0 == 9) { 14 | foo(5); 15 | } 16 | foo(6); 17 | } 18 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs4/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? foo(?); /* static */ 2 | 3 | void test(s32 arg0) { 4 | if (arg0 == 7) { 5 | foo(1); 6 | if (arg0 == 8) { 7 | foo(2); 8 | } 9 | foo(3); 10 | return; 11 | } 12 | foo(4); 13 | if (arg0 == 9) { 14 | foo(5); 15 | } 16 | foo(6); 17 | } 18 | -------------------------------------------------------------------------------- /tests/end_to_end/signed-conversion/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | extern s32 glob; 2 | 3 | void test(s8 arg0) { 4 | s8 temp_r5; 5 | s8 temp_r6; 6 | 7 | temp_r5 = arg0 * 2; 8 | glob = (s32) arg0; 9 | temp_r6 = arg0 * 3; 10 | glob = (s32) temp_r5; 11 | glob = (s32) temp_r6; 12 | glob = (s32) (s16) arg0; 13 | glob = (s32) (s16) temp_r5; 14 | glob = (s32) (s16) temp_r6; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 *x, s32 arg4) { 2 | s32 temp_r2; 3 | 4 | unksp0 = x->unk0; 5 | unksp4 = x + 0x28; 6 | arg4 = x->unk190; 7 | unksp0 = (u8) (*func_00400090(&unksp0) + unksp0); 8 | unksp4 = func_00400090(&unksp4); 9 | temp_r2 = arg4 + *func_00400090(&arg4); 10 | arg4 = temp_r2; 11 | return unksp0 + *unksp4 + temp_r2; 12 | } 13 | -------------------------------------------------------------------------------- /tests/end_to_end/doubles/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern f64 D_410180; 2 | 3 | f64 test(f64 arg0, s32 arg2, f64 arg4) { 4 | f64 sp8; 5 | f64 sp0; 6 | 7 | sp8 = ((f64) arg2 * arg0) + (arg0 / arg4); 8 | sp8 -= 7.0; 9 | if ((sp8 < arg4) || (sp8 == arg4) || (sp8 > 9.0)) { 10 | sp0 = 5.0; 11 | } else { 12 | sp0 = 6.0; 13 | } 14 | D_410180 = sp0; 15 | return sp0; 16 | } 17 | -------------------------------------------------------------------------------- /tests/end_to_end/no-ifs-early-returns/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | void test(s32 *arg0, s32 *arg1) { 2 | s32 temp_v1; 3 | 4 | temp_v1 = *arg0; 5 | if (temp_v1 == 8) { 6 | goto block_3; 7 | } 8 | if (temp_v1 == 0xF) { 9 | goto block_4; 10 | } 11 | return; 12 | block_3: 13 | *arg1 += temp_v1; 14 | return; 15 | block_4: 16 | *arg1 -= temp_v1; 17 | return; 18 | } 19 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_all/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | push {lr} 11 | cmp r0, #0 12 | bne .L3 @cond_branch 13 | mov r0, #0 14 | b .L5 15 | .L3: 16 | mov r0, #1 17 | .L5: 18 | pop {pc} 19 | .Lfe1: 20 | .size test,.Lfe1-test 21 | -------------------------------------------------------------------------------- /tests/end_to_end/premature_returns_one/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | push {lr} 11 | cmp r0, #0 12 | bne .L3 @cond_branch 13 | mov r0, #0 14 | b .L4 15 | .L3: 16 | mov r0, #1 17 | .L4: 18 | pop {pc} 19 | .Lfe1: 20 | .size test,.Lfe1-test 21 | -------------------------------------------------------------------------------- /tests/end_to_end/recursive-type/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? foo(? *, ? *); /* static */ 2 | 3 | void test(? *arg0, ? *arg1) { 4 | ? *spC; 5 | ? *sp8; /* compiler-managed */ 6 | 7 | sp8 = arg0; 8 | spC = arg1; 9 | sp8 = &sp8; 10 | spC = &spC; 11 | foo(&sp8, spC); 12 | sp8 = spC; 13 | foo((? *) sp8, spC); 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/division-by-power-of-two/mwcc-o4p.s: -------------------------------------------------------------------------------- 1 | .include "macros.inc" 2 | 3 | .section .text # 0x0 - 0x14 4 | 5 | .global test 6 | test: 7 | /* 00000000 00000000 80 03 00 00 */ lwz r0, 0(r3) 8 | /* 00000004 00000004 7C 00 0E 70 */ srawi r0, r0, 1 9 | /* 00000008 00000008 7C 00 01 94 */ addze r0, r0 10 | /* 0000000C 0000000C 90 03 00 00 */ stw r0, 0(r3) 11 | /* 00000010 00000010 4E 80 00 20 */ blr 12 | 13 | -------------------------------------------------------------------------------- /tests/end_to_end/nested_ifs4/orig.c: -------------------------------------------------------------------------------- 1 | void foo(int x); 2 | void test(int x) { 3 | if (x == 7) { 4 | foo(1); 5 | if (x == 8) { 6 | foo(2); 7 | } 8 | foo(3); 9 | return; 10 | } else { 11 | foo(4); 12 | if (x == 9) { 13 | foo(5); 14 | } 15 | foo(6); 16 | return; 17 | } 18 | } 19 | 20 | void foo(int x) {} 21 | -------------------------------------------------------------------------------- /tests/end_to_end/return-detection/circular-phis-ctx.s: -------------------------------------------------------------------------------- 1 | glabel test 2 | addiu $sp, $sp, -0x30 3 | sw $ra, 0x2C($sp) 4 | sw $s0, 0x28($sp) 5 | jal bar 6 | nop 7 | li $v0, 4 8 | li $s0, 1 9 | .again: 10 | beqz $s0, .skip 11 | nop 12 | jal bar 13 | nop 14 | li $v0, 5 15 | .skip: 16 | slt $at, $s0, $v0 17 | bltz $at, .again 18 | nop 19 | lw $ra, 0x2C($sp) 20 | lw $s0, 0x28($sp) 21 | jr $ra 22 | addiu $sp, $sp, 0x30 23 | -------------------------------------------------------------------------------- /tests/end_to_end/custom-return/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 func_0040010C(?); /* static */ 2 | extern s32 D_410120; 3 | 4 | s32 test(void) { 5 | s32 temp_v0; 6 | 7 | temp_v0 = func_0040010C(1); 8 | if (temp_v0 != 0) { 9 | return temp_v0 & 0xFFFF; 10 | } 11 | if (D_410120 != 0x7B) { 12 | return func_0040010C(2); 13 | } 14 | return func_0040010C(3); 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/float-branch-evalonce/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | extern f32 D_410120; 2 | 3 | void test(void) { 4 | s32 temp_cond; 5 | s32 temp_cond_2; 6 | 7 | temp_cond = D_410120 < 0.0f; 8 | D_410120 = 5.0f; 9 | if (temp_cond) { 10 | D_410120 = 6.0f; 11 | } 12 | temp_cond_2 = D_410120 < 0.0f; 13 | D_410120 = 3.0f; 14 | if (!temp_cond_2) { 15 | D_410120 = 7.0f; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/end_to_end/rlwimi/orig.c: -------------------------------------------------------------------------------- 1 | struct foo { 2 | int a: 1; 3 | unsigned int b: 1; 4 | int c: 5; 5 | unsigned int d: 5; 6 | }; 7 | 8 | struct foo x; 9 | struct foo y; 10 | 11 | int test(char * ptr) { 12 | // Bitfield assignment 13 | x.a = ptr[0]; 14 | x.b = ptr[1]; 15 | x.c = ptr[2]; 16 | x.d = ptr[3]; 17 | 18 | // Flag setting/clearing 19 | y.a = 1; 20 | y.b = 0; 21 | } 22 | -------------------------------------------------------------------------------- /tests/end_to_end/void_pointers/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | s32 test(s32 *x) { 2 | s8 sp27; 3 | s32 *sp20; 4 | s32 sp1C; 5 | s32 temp_t4; 6 | 7 | sp20 = x + 0x28; 8 | sp27 = (s8) x->unk0; 9 | sp1C = x->unk190; 10 | sp27 += *func_00400090(&sp27); 11 | sp20 = func_00400090(&sp20); 12 | temp_t4 = sp1C + *func_00400090(&sp1C); 13 | sp1C = temp_t4; 14 | return *sp20 + sp27 + temp_t4; 15 | } 16 | -------------------------------------------------------------------------------- /tests/end_to_end/abs-sqrt/mwcc-o4p-out.c: -------------------------------------------------------------------------------- 1 | ? fabs(); /* extern */ 2 | ? fabsf(); /* extern */ 3 | f64 sqrt(); /* extern */ 4 | ? sqrtf(); /* extern */ 5 | 6 | f32 test(void) { 7 | fabsf(); 8 | sqrtf(); 9 | fabs(); 10 | return (f32) sqrt(); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/enums/irix-o2-out.c: -------------------------------------------------------------------------------- 1 | enum my_enum array[4] = { THREE, TWO_TOO, TWO_TOO, ZERO }; /* const */ 2 | 3 | enum my_enum test(enum my_enum x) { 4 | switch (x) { /* irregular */ 5 | case ZERO: 6 | return *array; 7 | case TWO_TOO: 8 | return *array; 9 | case THREE: 10 | return *array; 11 | default: 12 | return ZERO; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/end_to_end/float-fn/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? __extendsfdf2(); /* extern */ 2 | ? __truncdfsf2(); /* extern */ 3 | ? blah(); /* static */ 4 | ? blahf(); /* static */ 5 | 6 | void test(void) { 7 | blahf(); 8 | __extendsfdf2(); 9 | blah(); 10 | __truncdfsf2(); 11 | } 12 | -------------------------------------------------------------------------------- /tests/end_to_end/modulo-by-power-of-two/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | ldr r2, [r0] 11 | lsr r1, r2, #31 12 | add r1, r2, r1 13 | asr r1, r1, #1 14 | lsl r1, r1, #1 15 | sub r1, r2, r1 16 | str r1, [r0] 17 | bx lr 18 | .Lfe1: 19 | .size test,.Lfe1-test 20 | -------------------------------------------------------------------------------- /tests/end_to_end/phi-recursive-struct/test-out.c: -------------------------------------------------------------------------------- 1 | ? foo(s16); /* extern */ 2 | 3 | void test(void) { 4 | SomeStruct *var_s0; 5 | s32 var_s1; 6 | 7 | var_s1 = 0; 8 | var_s0 = &glob; 9 | do { 10 | if (*NULL == 0) { 11 | foo(var_s0->unk2004); 12 | } 13 | var_s1 += 1; 14 | var_s0 += 0xC; 15 | } while (var_s1 < 5); 16 | } 17 | -------------------------------------------------------------------------------- /m2c_pycparser/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import sys 3 | 4 | sys.path.insert(0, '..') 5 | from m2c_pycparser import parse_file, c_generator 6 | 7 | fname = "test.c" if len(sys.argv) < 2 else sys.argv[1] 8 | 9 | # ast = c_parser.CParser().parse(src) 10 | ast = parse_file( 11 | fname, 12 | use_cpp=True, 13 | # debug=True, 14 | ) 15 | # ast.show() 16 | # print(c_generator.CGenerator().visit(ast)) 17 | print(ast) 18 | -------------------------------------------------------------------------------- /tests/end_to_end/float-conversions/irix-g-out.c: -------------------------------------------------------------------------------- 1 | extern f32 D_410250; 2 | extern f64 D_410258; 3 | extern u32 D_410260; 4 | 5 | void test(void) { 6 | f64 var_f18; 7 | 8 | D_410260 = (u32) D_410250; 9 | D_410260 = (u32) D_410258; 10 | var_f18 = (f64) D_410260; 11 | if ((s32) D_410260 < 0) { 12 | var_f18 += 4294967296.0; 13 | } 14 | D_410258 = var_f18; 15 | D_410250 = (f32) D_410260; 16 | } 17 | -------------------------------------------------------------------------------- /tests/end_to_end/jump-into-loop/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | ? foo(s32); /* static */ 2 | 3 | s32 test(s32 arg0) { 4 | s32 temp_r4; 5 | s32 var_r4; 6 | 7 | var_r4 = arg0; 8 | loop_2: 9 | foo(var_r4); 10 | temp_r4 = var_r4 * 2; 11 | if (temp_r4 <= 3) { 12 | foo(temp_r4); 13 | var_r4 = temp_r4 + 1; 14 | goto loop_2; 15 | } 16 | return temp_r4; 17 | } 18 | -------------------------------------------------------------------------------- /tests/end_to_end/unreachable-return/agbcc-o2.s: -------------------------------------------------------------------------------- 1 | @ Generated by gcc 2.9-arm-000512 for Thumb/elf 2 | .code 16 3 | .gcc2_compiled.: 4 | .text 5 | .align 2, 0 6 | .globl test 7 | .type test,function 8 | .thumb_func 9 | test: 10 | push {lr} 11 | ldr r1, .L6 12 | mov r0, #1 13 | .L3: 14 | str r0, [r1] 15 | b .L3 16 | .L7: 17 | .align 2, 0 18 | .L6: 19 | .word x 20 | .Lfe1: 21 | .size test,.Lfe1-test 22 | .comm x, 4 @ 4 23 | -------------------------------------------------------------------------------- /m2c_pycparser/tests/fake_libc_include/X11/_X11_fake_defines.h: -------------------------------------------------------------------------------- 1 | #ifndef _X11_FAKE_DEFINES_H 2 | #define _X11_FAKE_DEFINES_H 3 | 4 | #define Atom CARD32 5 | #define Bool int 6 | #define KeySym CARD32 7 | #define Pixmap CARD32 8 | #define Time CARD32 9 | #define _XFUNCPROTOBEGIN 10 | #define _XFUNCPROTOEND 11 | #define _Xconst const 12 | 13 | #define _X_RESTRICT_KYWD 14 | #define Cardinal unsigned int 15 | #define Boolean int 16 | #endif 17 | -------------------------------------------------------------------------------- /tests/end_to_end/enums/agbcc-o2-out.c: -------------------------------------------------------------------------------- 1 | enum my_enum array[4] = { THREE, TWO_TOO, TWO_TOO, ZERO }; /* const */ 2 | 3 | enum my_enum test(enum my_enum x) { 4 | switch (x) { /* irregular */ 5 | case ZERO: 6 | return array->unk0; 7 | case TWO_TOO: 8 | return array[1]; 9 | case THREE: 10 | return array[2]; 11 | default: 12 | return ZERO; 13 | } 14 | } 15 | --------------------------------------------------------------------------------