Ground state structures of intermetallic compounds: A first-principles Ising model