Anatomy of the AGN in NGC 5548. I. A global model for the broadband spectral energy distribution