Examples
This section walks through several real PVM programs. For each example we show:
- The original source code (WAT or AssemblyScript)
- Basic metadata about the compiled binary
- The decompiled pseudo-code output
- Where available, the LLM-refined output with better variable names
The examples go from simple to more complex:
- Branch Table – a small WAT program with
switch/casestyle branching - Fibonacci (WAT) – classic fibonacci in WebAssembly text format
- Fibonacci (AssemblyScript) – same algorithm compiled from AssemblyScript, shows how a higher-level language compiles differently
- Control Flow – a larger example with
if/else,while, nestedforloops, andbreak - JAM Fuzzy Service – a real-world Rust JAM service (~142 KB, 63 functions, no source available)
- Ananas – a real-world AssemblyScript JAM service (~442 KB, 189 functions, source on GitHub)
The next examples show more complex patterns:
- Functions (AssemblyScript) – multiple helper functions (add, factorial, square-in-loop), all inlined by the compiler
- Linked List (AssemblyScript) – heap-allocated linked list with recursive traversal
- Game of Life (AssemblyScript) – Conway’s Game of Life on a 16x16 grid, aggressive inlining
- Host Call Log (WAT) – minimal host call example using
ecallifor logging - Fibonacci (as-lan) – fibonacci from a full AssemblyScript framework (~38 KB, 18 functions)
Each example can be reproduced by running the decompiler on files from the examples/compiled/ directory.