Explain code in plain English

Explain what this code does, line by line, for a beginner: [PASTE]. Then list anything that looks risky or confusing.