To writhe (verb): to twist, wring, or contort (a part of the body)
From the Proto-Germanic *wrīþaną, meaning twist or turn.
Agony (noun): extreme mental or physical suffering, particularly that of Jesus Christ in the Garden of Gethsemane.
Derived from the Greek agonia, meaning struggle for victory, or in a more general sense, exercise or gymnastics.

eurogamer.net/articles/2015-06-10-neymar-is-on-the-pes-2016-box
Evolution of meaning to include sense of pain so severe as to cause struggling occurred around the turn of the 17th century.