Iranian President Hassan Rouhani defied the US in a speech marking the 40th anniversary of the Islamic Republic.