How to avoid code duplication in a function?

I don't know why none of the usual suspects have asked this yet: could you post the offending code?