https://medlineplus.gov/ency/article/000394.htm
Magnesium and potasium main but not only function is to regulate heart beat. Lack of them might lead to arrhythmia and other complications.
Not sure about muscle loss.