As mentioned in the comments, this is an extremely complex problem if you intend to consider every possible aspect. However, for a general estimation, you can use the relatively simple methods described in this document to begin calculating the effects of air drag on projectiles.
Note that in the document cited, they make the assumption that the air is not moving, and begun their derivation from $f = Dv^2$, and this $v$ was relative to the air and therefore the following equations simply used the velocity of the ball. For the more complex case where the air is moving as well, you will need to account for this change and make sure that the x and y components of the force due to drag are calculated using the relative velocity of the projectile through the now-moving air.
Also worth noting is the fact that if the wind direction changes, the effective footprint of your projectile will change, thus changing $D$ and therefore the force due to drag. If you are willing to make a reasonable approximation for the average footprint of your projectile, however, this will likely yield a result that is accurate enough for your purposes.
Hope this helps!
A couple things, first you are not discussing air resistance correctly. The drag depends on the current velocity, which is a dynamical quantity, not just on the muzzle velocity. You need to use the current velocity at any step of the calculation.
Second, in broad terms, you can think of the problem you face as one of root finding. You have some function $d(\theta)$ that returns the distance travelled as function of theta, and you want to know what argument of $\theta$ will make it equal some special value: $d^*$. You can think of this as finding the root (the place where it crosses zero) of the function
$$ f(\theta) = d(\theta) - d^* $$
And there exist efficient algorithms for doing this without having to check every single value of $\theta$. For this problem in particular, I would recommend the secant method, which is an iterative procedure to give you improved guesses. In this case, it would give you a new guess based on your previous two guesses as:
$$ \theta_n = \frac{ \theta_{n-2} d(\theta_{n-1}) - \theta_{n-1} d(\theta_{n-2}) + d^* ( \theta_{n-1} - \theta_{n-2} ) }{ d(\theta_{n-1}) - d(\theta_{n-2}) } $$
Where $\theta_{n-1}$ is the previous guess at the angle, $\theta_{n-2}$ is the guess before that, and $d(\theta_{n-1})$ and $d(\theta_{n-2})$ were the calculated distances for those angles. You do this iteratively until you've converged, meaning your guess doesn't change much
$$ | \theta_n - \theta_{n-1} | < \epsilon $$
with $\epsilon$ some small number you choose that governs your precision, $10^{-5}$ say.
Now you just have to write a routine $d(\theta)$ that calculates the distance a bullet travels for a given angle and you can find the right angle for any distance in short order.
To help with that, I suggest you use leapfrog integration, or if you prefer, see this se/gamedev answer geared towards programmers.
Best Answer
The extra height will give you more travel time before it strikes the ground, and hence more time to travel horizontally. In an ideal situation, the projectile maintains its horizontal speed until it hits the ground. If the ground is further "down" from where it was fired, it means it will travel further, all else being equal.
As far as the optimal launch angle in this situation, it will be less than 45° as that corresponds to the ideal angle for level ground.
Mathmaticall if the launch height is $h$ above ground, then the time for impact is
$$ t = \sqrt{ \left( \frac{v \sin \theta}{g}\right)^2 + \frac{2 h}{g} } + \frac{v \sin \theta}{g} $$
and so the range is
$$ x = v \cos\theta \sqrt{ \left( \frac{v \sin \theta}{g}\right)^2 + \frac{2 h}{g} } + \frac{v^2 \sin \theta \cos \theta}{g} $$
Now the optimal angle for launch maximizes the range, and it comes out to be (in degrees)
$$ \theta° = 90° - \arctan \left( \sqrt{1+ \frac{2 g h}{v^2}} \right) $$
You can see when $h=0$, the expression above is $\theta° = 90° - \arctan(1) = 45°$. For positive values of $h$ the angle becomes less than 45°.