Higher order Glaeser inequalities and optimal regularity of roots of real functions