Not sleeping well because of pain pooping

My LO has been crying in pain last couple days (mostly during her night sleeps) in pain as she tries to pass gas or poops. Any suggestions to help her do this and sleep better?