A general bahadur representation of M-estimators and its application to linear regression with nonstochastic designs