By default, gcc will try to lower the time it takes to compile your code; in other words, gcc optimizes for compilation time.
However, gcc can also optimize for execution time to get your code to run faster. The gcc compiler includes three levels of optimization, which you can use by adding the optimization flag to your compilation command: -O1 -O2 -O3
Now that you have optimized your histogram filter code, go back and try compiling the program with the level three flag. See how much the compiler can help you speed up your code.
Here is the command for compiling with level three optimization: