We can't diagnose here but you might want to try to increase your fiber and water intake. Small sized stools can be indicative of a long transit time in the colon - which results in more water being removed - resulting in hard pellet sized stools. Because its hard to get those stools out of your system it can stress the muscles in that area. The fact that your muscles are actually spasming suggests you should see a doctor about this problem. Good luck!