Rafsanjani gave up on Assad very openly only days after the latter used chemical weapons on his own people while the rest of the Iranian regime still tried to blame Sunni terrorists.
Assad already wasn’t popular in Iran. He’s not a real Shia, he is very secular, he and his party is Baathist, under his regime torture and disappearances are widespread. Obviously he is responsible for the bulk of the civilians killed in Syria; tens of thousands of them. And, the civil war in Syria is terribly divisive. Iran pretends to be a democracy that listens to the people instead of killing them by the thousands. Also most Shia in Iran heed Iraqi Ayatollah Sistani and the religious authorities in Najaf, Iraq instead of to the regime-friendly Qom, Iran Ayatollahs. How is that relevant? The Najaf Majra Council is opposed to Shia fighting on behalf of Assad (Qom in favour).
The war has cost Iran over $8 billion; probably much more when considering the aid to Hezbollah, the invisible funding of the IRGC Qods force adn the propping up of Syrian irregular forces. Iran doesn’t really have that money with the sanctions regime pressing down. Iranians never were happy that so much money is going to Assad, that the only returns are hundreds of dead Qods force fighters. Qods and Hezbollah never were meant to suppress an uprising or battle Islamic fighters. “Qods” stands for Jerusalem. Qods and Hezbollah were supposed to battle Zionists.
Against this background, Assad gassed his own civilian population. This caused outrage the world over, but even more so in Iran which was subject to massive chemical attacks in the war against Saddam Hussein. Especially the veterans of that war, many of whom experienced chemical weapons first or 2nd hand and many of whom fill the highest ranks in the security apparatus of Iran, consider use of chemical weapons a cardinal sin. When it sank in who despite the rhetoric, was responsible, Rafsanjani came forward. And he is central to the new power structure in Iran. It was his endorsement that got Rohani elected.
Iran wants to negotiate a Syria exit. It wants to secure minority interests, it wants to secure Hezbollah. It must secure Assad’s chemical weapons as does the entire planet with them. In fact, the world needs Iran and Hezbollah to help secure Assad’s chemical weapons stockpile. It gives Iran a fantastic trump card to play, nobody else is on the ground, nobody else can push the Syrian regime around effectively and nobody else can insist Assad leave.
Nuclear weapons? I doubt the Iranians will seriously talk about them, as long as they can control the chemical weapons inspections and removal regime and the force balance in Syria they can always easily change the subject.