Here is an example to see the difference between simple code and optimized code: http://stackoverflow.com/a/11227902/1396264https://stackoverflow.com/a/11227902/1396264
towards the end of the answer he just Replaces:
if (data[c] >= 128)
sum += data[c];
with:
int t = (data[c] - 128) >> 31;
sum += ~t & data[c];
To be fair I have no idea what the if statement has been replaced with but as the answerer says its some bitwise operations giving the same result (I'm just going to take his word for it).
This executes in less than a quarter of the original time (11.54sec vs 2.5sec)