Nonsmooth Optimization Analysis and Algorithms With Applications to Optimal Control