Fix all GCC optimization errors

Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>