Optimize functions by generating and analyzing compiler assembly output. Use when asked to optimize a function, analyze generated assembly, or improve performance by examining what the compiler produces.
Optimize functions by analyzing compiler-generated assembly. This replicates the workflow of godbolt.org locally.
Create a standalone file with the function to optimize. Export it to prevent inlining:
export fn targetFunction(x: i64) i64 {
// function body
}
__attribute__((noinline)) int targetFunction(int x) {
// function body
}
# Zig
zig build-obj src/target.zig -femit-asm -fno-emit-bin -O ReleaseFast
# C/C++ (clang)
clang -S -O3 -fno-inline -o target.s target.c
# Rust
rustc --emit=asm -C opt-level=3 target.rs
# Find the assembly file
find . -name "*.s" -newer src/target.zig
# Find function boundaries
grep -n "_targetFunction" output.s
# Count instructions
sed -n 'START,ENDp' output.s | grep -E '^\s+\w' | wc -l
Read through the assembly looking for:
Make a targeted change, regenerate assembly, compare instruction counts.
Always benchmark—fewer instructions ≠ always faster:
zig build-exe bench.zig -O ReleaseFast -o bench_v1
time ./bench_v1
Keep assembly outputs for comparison: function_v1.s, function_v2.s, etc.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer