Lion Cipher Lab

Watch what a compiler does to a C function: read your own program's assembly, plain and optimised

Why it matters

Reverse engineering means working out what a program does when you do not have its source. Every reverse engineering tool, from a debugger to a decompiler, is showing you the compiler's output read backwards. If you have watched a compiler turn your own code into assembly, you know what the shapes mean: how an if looks, how a loop looks, how a function call looks. That makes unknown programs a lot less intimidating. You also learn the honest limits: names of variables and comments are gone, and an optimiser can rearrange almost everything.

What you'll learn

Steps in this lab

  1. The idea: compilers are translators, analysts translate back
  2. Write three tiny functions
  3. Ask the compiler for its assembly
  4. The cast list: five kinds of instruction
  5. Read scale: arithmetic and a return
  6. Read biggest: how an if looks
  7. Read sum_to: how a loop looks
  8. Disassemble the real program with objdump
  9. Turn the optimiser on and compare
  10. What a pro does differently, and when not to do this by hand
  11. Clean up

Open the full interactive lab →

Keep learning