The complexity of optimization beyond convexity