How can I see the assembly code that is generated by a gcc (any flavor) compiler for a C/C++ program?

vehomzzz picture vehomzzz · Aug 30, 2009 · Viewed 25.5k times · Source

I am trying to optimize a lot of multiplications and pointer arithmetics and would like to see what the compiler does underneath when I put in optimization flags.

--Edit--

How to restrict it to a specific function or a code block?

--Edit_2--

How to let gcc generate a less verbose assembly-code?

Answer

P Shved picture P Shved · Aug 30, 2009

Add -S switch to your command line.

Edit: Do not forget that it will place the assembly to the files you specified under -o switch.