The gcc option -O enables different levels of optimization. Use -O0 to disable them and use -S to output assembly. -O3 is the highest level of optimization.
Starting with gcc 4.8 the optimization level -Og is available. It enables optimizations that do not interfere with debugging and is the recommended default for the standard edit-compile-debug cycle.
To change the dialect of the assembly to either intel or att use -masm=intel or -masm=att.
You can also enable certain optimizations manually with -fname.
Have a look at the gcc manual for much more.