First: This wouldn't be a war like Afghanistan or Iraq, because the US would most likely only be concerned with destroying the Iranian military and forcing them out of the strait of Hormuz. This would be largely an air war, and the US would likely suffer very few casualties as a result. We could destroy their navy, inflict massive military casualties, and cripple their ability to project force into the strait without more than a few boots on the ground, and most likely this is how it would go.
Second: None of that matters, because Iran does not gain from a war with the US. It would be an absolute disaster for their people and it would likely force their government out of power. The reason that they're doing this is because Ahmadinejad needs a scapegoat in order to keep his popularity up, and calling out the US and Israel at every opportunity is a lot easier than dealing with real issues. Hes been doing it for years, the only reason hes making more noise now is because his popularity is dwindling.