First-principles statistical mechanics of structural stability of intermetallic compounds.