Tehran hit out at Washington and Riyadh as tens of thousands attend funerals for those slain in the first attacks in Iran claimed by the Islamic State group.