Obviously that will be slow, so probably do some kind of gradient descent, or perhaps depending on what the parameters are there may be a closed-form solution, I don't know.
Yes the result will be subtly different but it's just a starting point.
Start by adjusting the black levels and the exposure. This is where the histogram can help to visualize how much you are adjusting (if you have one). As the exposure goes up, you can adjust the highlights to recover some of the areas trying to blow out. As you pull the black level down, you can recover some of the details getting crushed using with the shadows adjustment. You can then adjust the contrast/saturation/warmth/tint as needed. The order of adjustments in the iOS Photos editor pretty much follow that order.