Differentiable Optimization of Generalized Nondecomposable Functions using Linear Programs