1. Best results come from no optimization flag. However, if you must use optimization flags, use the lowest possible level. Optimizers change code in manners that make checking for errors more difficult.
2. Discover documentation is available here - http://docs.oracle.com/cd/E24457_01/html/E22000/index.html.
Generally if you see address in 0xff... range it is a stack area (local variables), other addresses are generally heap (returned by malloc).
Sometimes breaking up a line of code into multiple lines helps with analysis.