Compute it once, use it twice
When the same expression appears more than once and nothing in between can change its value, -O4 computes it once and reuses the result. This is common-subexpression elimination (CSE). It's why a target may contain fewer arithmetic instructions than your source literally spelled out.
Writing the same expensive subexpression twice in one statement would, on a naive compiler, produce two copies of that operation. MWCC at -O4 doesn't: it detects that the two appearances produce the same value (nothing changes between them) and computes it once, reusing the register.
Take fold(int x, int y), which uses x / y twice with a different multiplier:
divw r3, r3, r4 # q = x / y — computed ONCE
mulli r0, r3, 5 # q * 5
add r3, r3, r0 # q + q*5
blr
One divw covers both appearances of x / y; the result in r3 is simply reused. Read the mulli operand to learn what the second use was multiplied by — and the add tells you how the two results were combined.
One precondition: CSE only fires when nothing between the two uses can change the value. An intervening store, a volatile, or a write through a possibly-aliasing pointer all block it, and you'll see the expensive op appear twice. A single divw standing in for two source uses tells you the region was side-effect-free between them — don't over-generalize to loops or pointer writes where the compiler can't prove that.
Now look at the target for reuse:
divw r3, r3, r4 # q = a / b — computed ONCE
mulli r0, r3, 7 # q * ?
add r3, r3, r0 # q + q*?
blr
Your task
Write reuse(int a, int b) to match the assembly above — a single divw whose result feeds both the add and the mulli.