Spin-flop transition in Gd5 Ge4 observed by x-ray resonant magnetic scattering and first-principles calculations of magnetic anisotropy