Many quadrupeds are capable of power efficient gaits, especially trot and gallop, thanks to their flexible trunk. The oscillations of the system that includes the backbone, the tendons and musculature, store and release elastic energy, helping a smooth deceleration and a fast acceleration of the hindquarters and forequarters, which improves the dynamics of running and its energy efficiency. Forelegs and hindlegs play a key role in generating the bending moment in the trunk. In this paper we present our studies aimed at modeling and reproducing such phenomena for efficient quadrupedal robot locomotion. We propose a model, called mass-mass-spring model, that overcomes the limitation of existing models, and demonstrate that it allows studying how the masses of the legs generate a flexing force that helps the natural bending of the trunk during gallop. We apply our model to six animals, that adopt two different galloping patterns (called transverse and rotatory), and compare their energy efficiency.