Demystifying Compiler Optimization – Difference between Visual C++ 2010 and Dev C++

I analyzed some simple source code examples running in visual C++ (without optimization option) and Dev C++. I saw that VC++ code is slightly optimized then DEV C++. The following code shows the difference between function calls on both the compilers.

In visual C++:

push eax

mov ecx, [local.1]

push ecx

call F

Dev C++:

mov DWORD PTR SS:[esp+4], eax

mov ecx, [local.1]

mov DWORD PTR SS:[esp], ecx

call F



Argument 1


Argument 2

We can see that VC++ code is optimized and using PUSH instruction instead of MOV

The difference when turning on optimization option:

I also analyzed some codes by turning on the optimization options, I found very interesting results. I compiled the below code on both the compilers to see the effect of optimization.

int s;

for (int i=3; i< a; i++)

if (a <b)
	printf( " Result is %d",s);

Compiled code:

As you can see in the images that in VC++ results were calculated at the time of compilation, the for loop result is hardcoded into the binary while in DEV C++ we can see the actual for loop which will calculate the value(result) during run time. However from debugging perspective the DEV C++ code is easy to debug because its structure is similar to the source code, Often times optimized code is mangled and not easy to debug.

The following links talks about some optimization techniques used by VC++:

In general, optimization is used for following purposes:

–       Variables are kept in register as long as possible in order to reduce burden of reading/writing from/to memory, increasing processing speed and reducing size of codes

–       JIT optimization

–       Remove dead block

–       Remove nop instruction to reduce size of codes

–       Some more,

If you have seen such interesting things do share your views !

Similar posts
  • Computer Security Tips: Stay Safe Onl... In recent times cyber security has raised the level of awareness and public consciousness as never before. Both large corporations and big organizations try to take care of online security as much as they can. That’s why cyber criminals and hackers have focused more on smaller companies and single entrepreneurs. This awful tendency leads to [...]
  • SecurityXploded Mentorship Programme ... I am writing this blog to share my SecurityXploded Student Mentorship Programme experience with the future students of this programme. My mentorship programme started last year in August when I was in 2nd year of MS at IIIT-Allahabad. I knew about SecurityXploded community since I used to follow their blogs, training programmes and security tools [...]
  • Code Injection and API Hooking Techni... Hooking covers a range of techniques used for many purposes like debugging, monitoring, intercepting messages, extending functionality etc. Hooking is also used by a lot of rootkits to camouflage themselves on the system. Rootkits use various hooking techniques when they have to hide a process, hide a network port, redirect file writes to some different [...]
  • Announcement – SecurityXploded ... From the past two years we are working actively on couple of projects to support the security community. As you all may already know that we have successfully completed our reversing and malware analysis training programme and we are very glad that it was very helpful for everyone. In my opinion the success of any [...]
  • Advanced Malware Analysis Training Se... Here is the quick update on this month’s Local Security meet (SX/Null/G4H/owasp) and our advanced malware training session on (Part 2) Dissecting the HeartBeat  RAT Functionalities   This is part of our FREE ‘Advanced Malware Analysis Training’ series started from Dec 2012.       In this extended session, I explained “Decrypting various Communications Of HeartBeat [...]

Leave a Reply