factor out a common peephole stanza