Keeping only the bits you want
Masking throws away the bits you don't care about. AND a number against a mask and only the mask's set bits survive, while everything else collapses to zero. When those set bits lie scattered rather than forming a single run, MWCC falls back to its immediate AND, andi..
Watch n get masked with 0x0A, decimal 10, with bits 1 and 3 set:
andi. r3, r3, 10
blr
Only 16 bits fit in that immediate, which pins andi. to the low half-word and nothing above it. The dot riding on the mnemonic is a separate matter. It writes cr0 as a side effect, and MWCC keeps emitting andi. even where the flags go unread, for the plain reason that PowerPC ships no dotless immediate AND.
(A run of contiguous bits compiles another way, which "Testing Whether a Bit Is Set" covers. Because 0x0A splits its set bits apart, andi. is what you land on.)
The target waits below. Recover the mask from its immediate, then write the C expression that reproduces it.
andi. r3, r3, 18
blr
Your task
Write mask_bits to match the target.