It is clearly mentioned in a few answers here that a pre-issued visa is not an entry permission but a permission to travel to a port of entry and request that permission. So the person at immigration will not ‘override the embassy’s decision’ but rather ‘come to a different conclusion in their own decision’. For example, on the United States CBP website it says
Issuance of a visa does not guarantee entry to the United States. A visa simply indicates that a U.S. consular officer at an American embassy or consulate has reviewed the application and that officer has determined that the individual is eligible to enter the country for a specific purpose. The CBP Officer at the port-of-entry will conduct an inspection to determine if the individual is eligible for admission under U.S. immigration law. (source)
In most if not all countries, the decision of whether to let somebody enter the country or not is down to the immigration officer inspecting your documents at the immigration check (and maybe that officer’s supervisor). This means that you can still be refused if:
- people from your country generally don’t need visas
- there is a visa waiver agreement or similar for certain conditions requiring nationals of your country to submit certain information but not actually issuing a visa and you are eligible
- nationals of your country typically obtain visas on arrival and there is nothing prohibiting you from getting one
- you applied for and got granted a visa which is valid during your intended travel dates
One example for the last bullet point (unfortunately from the Schengen zone, not the US) is ‘https://travel.stackexchange.com/q/58468’ Therein, OP was denied entry to Germany because they could not satisfy the immigration officers that they wanted to leave (in a nutshell: OP had a flight from Germany home but no flight from Portugal to Germany).
Now of course, if you submitted all your documents in a timely manner and the embassy does decide to grant you a visa, then probabilities have suddenly drastically changed. In the overwhelming majority of cases, those applying for entry with a valid visa are let in — because the difficult cases are usually identified and weeded out at the visa application stage by rejecting them.
In your case, you mention that a previous trip to Iran is the basis of your uncertainty. The US embassy will have ample time to investigate your backgrounds and the details of that trip based on the documents you provide. If they come to the conclusion that you are admissable despite the Iran trip, that is very strong grounds for the immigration officer to consider that part handled and not make it affect his position.
It still bears repeating though, that it is all and entirely up to the immigration officer on duty and their superiors whether you are let in or not.