Question came up in a reverse engineering class. The prof asked this question. I mean, in the grand scheme of things, while loops == for loops, I don't have a problem with that.

IDA Pro book... Google... not seeing anything online here.

So why does IDA pro never produce for loops in its pseudocode generator?

  • Why the downvote? How is this question off-topic? Wrong tags?
    – avgvstvs
    Apr 1, 2014 at 12:04
  • 2
    The question as stated is presented as an "obvious" fact without any evidence.
    – Igor Skochinsky
    Apr 1, 2014 at 13:37
  • I wanted to say usually it produces do while loops.
    – LUser
    Feb 18, 2021 at 10:49

2 Answers 2


Just because you haven't seem them does not mean they don't exist. In my experience the decompiler produces for loops all the time.

EDIT: Here's just one example:

                 xor     edx, edx
                 jmp     short loc_804B52B

                 mov     al, [edi+edx]
                 mov     [ebx+edx], al
                 inc     edx

                 cmp     edx, esi
                 jl      short loc_804B524


  for ( i = 0; i < a2; ++i )
    *(_BYTE *)(v2 + i) = *(_BYTE *)(a1 + i);
  • Well, for the record the question came up in a reversing class, and no one had the answer. The prof asked the question.
    – avgvstvs
    Apr 1, 2014 at 12:08
  • Well, the current question definitely does not mention it came from "the prof". Maybe you should rephrase your question and describe the full context.
    – Igor Skochinsky
    Apr 1, 2014 at 13:05
  • I updated the context accordingly.
    – avgvstvs
    Apr 1, 2014 at 13:11
  • Would it be possible for you to provide an assembly blob that should be interpreted correctly as a for loop?
    – avgvstvs
    Apr 1, 2014 at 13:17

The decompiler can produce for loops.

It uses the Ctree statement element cit_for and the Ctree expression cfor_t to represent these code constructs in the decompilation graph.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.