My thoughts on preventing Iran-Iraq War
To avert the Iran-Iraq War, you have to butterfly away the perception that Iran's military has been gutted by the Revolution because Iraq wouldn't have dared take on the Iranian military at full strength with access to US/UK resupply.
Keep in mind, Saddam Hussein had several dogs in the fight -
One- he knew the Saudi and other Gulf States didn't want Shi'a revolutions popping up, propped up by the Iranians and were perfectly willing to throw money at him to squash the Iranians.
Two- the deliberately vague boundaries of the Shatt-al-Arab made him think, hey, now that neither Iran or the UK ain't looking, time to take what should be theirs as they saw it.
Three, he thought the ethnic Arabs of Khuzistan where 80% of Iran's oil happens to be would rise up in rebellion and join their Iraqi brothers if they just kicked down the door.
To avoid that required several PODs, say the Iranian military cooperates in arresting SAVAK and other Shah puppets and generally not firing on revolutionary activists during the lead-up to the Shah's abdication more or less what we saw in the fall of Ceausescu.
They "convince" SCIRI (the ayatollahs) to take a moral advisory role in a provisional government and convince what would be the Basij and Revolutionary Guards to wear Iranian Army or police uniforms under secular chain of command instead of be beholden to any religious or political party. They had the weaponry and tactics but not the political will to do so from my very sketchy reading of the lead-up to the Revolution, mostly James Clavell's Whirlwind.
I see it as very difficult IMO, b/c the Iranian military was selected for loyalty to the Shah and technical proficiency, not political leadership AND both the Shah and the ayatollahs were terrified/very scornful any strains of Ataturkism in the Iranian military.
With AH you run into all kinds of PODs where faction A could and SHOULD have done something sane and effective but was ideologically ASB for them.
FWIW the fundamentalist ayatollahs under Khomeini were politically very savvy in coming out on top of the rugby scrum of Tudeh (Communist) activists, social democratic activists and other religious factions in the revolutionary mix after the Shah abdicated.
They were a dog's breakfast in running a war and an economy but great at forming and maintaining the social consensus that an Islamic republic was worth attempting.
I'd have liked to see the secular and religious players in the Revolution establish a republic where democracy and pluralism flourish, where the economic growth spurred by oil is shared more equally and the economy diversified, Iran shares fully in the technological and social trends of the latter 20th century.
I think of Turkey, Iran, and several other countries forming a free trade union in the area that helps stimulate their economies and decrease tensions considerably instead of a paranoid pariah state prompting everyone in the area to gear up and repress the Shi'a populations under Sunni elites' control that's distorted the Middle east and especially Persian Gulf States' politics for the last thirty years.