{"slug": "neurastheniacc-llm-based-c-wasm-compiler-you-didn-t-need", "title": "Neurastheniacc: LLM-based C->WASM compiler you didn't need", "summary": "A developer released neurastheniacc, an open-source C-to-WASM compiler that uses a local Qwen large language model to handle the C-to-WAT pass, then parses the generated WAT with the `wat` crate and builds it with `wasmi`. The compiler supports only a restricted C subset — one function returning `uint32_t` with exactly two `uint32_t` parameters, no pointers, arrays, loops, recursion or function calls — and caps programs at 32 KiB, 4096 Qwen tokens and 48 nesting levels, with up to 3 retry turns by default when the model emits invalid WAT. On first run neurastheniacc downloads roughly 2.75 GB of Qwen3.5-4B-Q4_K_M weights (the `qwen-low` default) or about 16.5 GB for the 27B `qwen-high` model, running inference locally via llama-cpp-2 with no API keys required.", "body_md": "A groundbreaking C -> WASM compiler wielding the unbridled power of LLMs!!\n\n`neurastheniacc` compiles a restricted subset of C down into WASM. It follows the usual two-pass approach: first from C to readable WAT, then from WAT to WASM bytecode. However, there's a trailblazing advance that distinguishes `neurastheniacc` from all previous (lesser? (∩￢з￢)) WASM compilers: **the C->WAT pass is handled purely by an LLM.**\n\nWith `neurastheniacc`, you can finally alchemize money directly into performance, without any need for pesky intermediaries like \"compiler expertise\"! If you're unsatisfied with the defaults' results, try any of the following:\n\n- Use a larger Qwen, merely costing more GPU compute!\n- Extend the token limits, reasoning budget, or allowed retries, merely costing more execution time!\n- Build your own stochastically optimizing compiler: run `neurastheniacc` in a loop 100 times, and pick the best output!\n- Or for the real sickoes, finetune your own C->WAT model and provide a custom GGUF! (Please wash your hands afterward.)\n\n```\n# plz builb (๑•́ ω •̀๑)\ncargo build --release --locked --bin neurastheniacc\n\n# First use downloads ~2.75 GB of Qwen weights, then compiles.\n./target/release/neurastheniacc compile examples/mix.c -o mix.wasm\n\n# Invoke the exported function in a standard Wasm runtime.\nwasmtime run --invoke mix mix.wasm 3 5\n```\n\n`neurastheniacc` is fully local. On first run, it downloads a Qwen GGUF and caches it. Inference is then provided during compilation by [llama-cpp-2](https://crates.io/crates/llama-cpp-2). No API keys or calls to inference providers required.\n\nDuring compilation, `neurastheniacc` validates that your C code is supported, provides your code to Qwen, and asks it nicely to translate it into valid WAT. We then take Qwen's lovingly tensor-crafted WAT (just like wire mother used to make!) and attempt to parse in with [wat](https://crates.io/crates/wat) and build it with [wasmi](https://crates.io/crates/wasmi). What happens if, Lord forbid, the model should generate invalid WAT? Never fear: a simple harness provides the current state and parser feedback back to Qwen for another attempt, with up to 3 turns allowed by default.\n\n`neurastheniacc` supports this astonishingly flexible program structure: One C function, returning `uint32_t`, with exactly two `uint32_t` parameters. An optional `#include <stdint.h>` is graciously accepted for your convenience.\n\nThis luxurious subset of C features is provided, that you might write the programs of your dreams:\n\n- Initialized `uint32_t` locals, assignments, nested blocks and variable shadowing.\n- `+` ,`-` ,`*` ,`&` ,`|` ,`^` , unary`~` , unary`+` and unary`-` .\n- Line and block comments.\n- `<<` and`>>` , with a literal shift value from`0u` to`31u` .\n- Braced `if` /`else` . All paths must return. If conditions may include:\n  - Unsigned comparisons (`==` ,`!=` ,`<` ,`<=` ,`>` ,`>=` )\n  - Integer truthiness\n- Unsigned comparisons (\n- Decimal and hexadecimal 32-bit integer literals with an explicit `u` or`U` suffix.\n- Returns, including early returns.\n\nThese extraneous C features *aren't* supported, and will surely be missed by nobody:\n\n- Pointers, allocation, and casting\n- Arrays\n- Loops, recursion, and `else if`\n- Function calls\n- Frivolous mathemetics such as division, remainder, increment/decrement, or negative numbers\n- Globals\n- Ternaries, or logical operators in general really\n- Compound assignment, comparison expressions used as values\n- Macros\n- Probably a lot of other stuff\n- Don't even *think* about trigraphs, IOCCC pervert.\n\nYour program must be no larger than 32 KiB and 4096 Qwen tokens. You may not use more than 48 levels of nesting.\n\n```\n# Select a model: (default: qwen-low)\n# - `qwen-low` (Qwen3.5-4B-Q4_K_M, 4B, ~2.75GB)\n# - `qwen-high` (Qwen3.8-27B-UD-Q4_K_M.gguf, 27B, ~16.5GB)\n# - or whatever local GGUF your little heart desires\n./target/release/neurastheniacc compile examples/mix.c --model qwen-low\n./target/release/neurastheniacc compile examples/mix.c --model qwen-high\n./target/release/neurastheniacc compile examples/mix.c --model /path/to/model.gguf\n\n# Enable thinking. Only supported with bundled Qwens. (default: disabled)\n./target/release/neurastheniacc compile examples/mix.c \\\n  --qwen-thinking=true\n\n# Increase the context or per-attempt token budget.\n./target/release/neurastheniacc compile examples/mix.c \\\n  --context 16384 --max-tokens 4096\n\n# Set limit for compilation attempts. (default: 3)\n./target/release/neurastheniacc compile examples/mix.c --attempts 5 --verbose\n\n# Print diagnostics.\n./target/release/neurastheniacc compile examples/mix.c --verbose\n\n# Run on CPU with however many threads.\n./target/release/neurastheniacc compile examples/mix.c --gpu-layers 0 --threads 8\n\n# Download a Qwen to a custom cache, then compile offline.\n./target/release/neurastheniacc fetch --model qwen-low --cache-dir .models\n./target/release/neurastheniacc compile examples/mix.c \\\n  --model qwen-low --cache-dir .models --offline\n```\n\nRun `./target/release/neurastheniacc compile --help` for all options and defaults.\n\nThe `neurastheniacc-bench` executable runs a benchmark on the compiler. Eight standard fixtures are provided, alongside as many randomly generated fixtures as your body can handle. Each fixture is run through `neurastheniacc` with all logs and outputs preserved. For all fixtures that successfully compile to WASM, the resulting executable is proptested against a Clang build of the original C. If we get the same outputs from both `neurastheniacc` and Clang across a wide set of random inputs, then we consider it a successful compilation! °˖✧◝(⁰▿⁰)◜✧˖°\n\n```\n# bliud\ncargo build --release --locked --bin neurastheniacc-bench\n\n# Run a benchmark with 32 fixtures, 24 of 'em generated\n./target/release/neurastheniacc-bench bench --model qwen-low \\\n  --generated 24 --seed 20261014 --out-dir benchmarks/my-benchmark\n```\n\n| Model | Thinking | Pass rate | WAT syntax errors | Wasm validation errors | Semantic mismatches | Token limits | Runtime | \n|---|---|---|---|---|---|---|---|\n| Qwen3.5-4B | Off | 71.9% (23/32) | 6 | 1 | 2 | 0 | 2m 13s | \n| Qwen3.5-4B | On | 21.9% (7/32) | 0 | 0 | 0 | 25 | 3h 41m 48s | \n| Qwen3.8-27B | Off | 96.9% (31/32) | 0 | 0 | 1 | 0 | 4m 39s | \n| Qwen3.8-27B | On | 100% (32/32) | 0 | 0 | 0 | 0 | 43m 11s | \n\nEach run used Metal on Apple Silicon, with greedy decoding and five retries. Thinking-off runs allowed 8,192 tokens context and 1,536 tokens output budget. Thinking-on runs allowed 16,384 tokens context and 8,192 tokens output budget.\n\n'tis the best kind of joke– an executable joke.\n\nWould love to know, please do write my doctor a memo if ya figure it out.\n\nYou better believe I tried. Didn't work at all well with small local models.\n\nThe Nix shell provides the full toolchain needed to develop the project: Rust, Cargo, rustfmt, Clippy, rust-analyzer, Clang/libclang, CMake, and Wasmtime. A healthy state of delirium provides your motivation for attempting.\n\n`neurastheniacc` so far has only been tested on macOS with Apple Silicon. It... might work on Linux? Probably not very fast, though. On Mac inference uses Metal, on Linux it uses your poor overheating CPU. **You** (yes, you!) could probably improve this by contribbing CUDA or something, if you enjoy turning the wheel of samsara.\n\nEnter the pinned development environment manually, run checks, and build:\n\n```\n# duild\nnix develop\n\n# Run checks\ncargo fmt --all -- --check\ncargo clippy --workspace --all-targets --locked -- -D warnings\ncargo test --workspace --locked\n\n# Build the compiler\ncargo build --workspace --release --locked --bins\n```\n\n", "url": "https://wpnews.pro/news/neurastheniacc-llm-based-c-wasm-compiler-you-didn-t-need", "canonical_source": "https://github.com/vivshaw/neurastheniacc", "published_at": "2026-10-18 19:20:47+00:00", "updated_at": "2026-10-18 19:49:16.478287+00:00", "lang": "en", "topics": ["large-language-models", "developer-tools", "ai-tools", "artificial-intelligence"], "entities": ["neurastheniacc", "Qwen", "Qwen3.5-4B-Q4_K_M", "Qwen3.8-27B-UD-Q4_K_M", "llama-cpp-2", "wasmi", "WebAssembly"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/neurastheniacc-llm-based-c-wasm-compiler-you-didn-t-need", "markdown": "https://wpnews.pro/news/neurastheniacc-llm-based-c-wasm-compiler-you-didn-t-need.md", "text": "https://wpnews.pro/news/neurastheniacc-llm-based-c-wasm-compiler-you-didn-t-need.txt", "jsonld": "https://wpnews.pro/news/neurastheniacc-llm-based-c-wasm-compiler-you-didn-t-need.jsonld"}}