It could be any of the possiblities you mention but that's also a classic sign of impacted anal glands. If the diarrhoea smelled really bad (or not) "shooting" the anal glands is also a symptom. The diarrhoea and the yelping and straining could be related, sort of opposite extremes of the same problem. It can be sporadic. Be sure to tell the Vet.