It sounds like you pulled a muscle near a rib I have busted up a few ribs,in my life ,sailing, they can be darn painful,and nothing to do for them, I put a crepe bandage firmly round it, or a back support ...however as you have had a nasty cough I think you should speak to your Doctor who may want an Xray just to be safe ..good luck