Millions of mourners have gathered in Tehran as Iran holds the state funeral of Ayatollah Ali Khamenei, with delegations from more than 100 countries attending the ceremonies.