...

/

GDB Disassembly Output – Optimization

GDB Disassembly Output – Optimization

Learn how to compile, load, and execute the GDB disassembly program with code optimization.

Disassembly in the optimization mode

Let’s review the disassembly generated by compiling the program in the optimization mode. We will revisit the source code first and review the flags needed to trigger the optimization.

Source code

The source code of the arithmetic program is given below:

Press + to interact
int a, b;
int main(int argc, char* argv[])
{
a = 1;
b = 1;
b = b + a;
++a;
b = b * a;
return 0;
}

The flowchart below shows the working of the source code:

Compilation

We can add certain flags for optimizing the code while compiling our source file. A flag, -O, is used for the optimization of code, and -O1 is an optimization flag that further optimizes the code size and execution ...

Access this course and 1400+ top-rated courses and projects.