Help optimizing a function

So, what is the trouble?
Lots of important code missing from your post.
I note in the function get_array_max_value(), max_value is not initialized to anything. Is that what you intended?