An implicit multifunction theorem for the hemiregularity of mappings with application to constrained optimization