Apple profit falls 22 percent but beats gloomy expectations