Inverse-Compton cooling in Klein–Nishina regime and gamma-ray burst prompt spectrum