Reverse Engineering challenge #87.

Tags: X86 L3 .

This is one of the hardest ever exercises at this website. What does this code do?

Hint: the function has been copypasted from the guts of GCC, but in fact, it is present almost in all modern compilers, though, in different forms, but calculating the same value(s). Its function is highly important.

Second hint: f(f(x))=x.

Optimizing GCC 5.4 x86


f:
        mov     edx, 31
        mov     eax, 1
.L2:
        imul    eax, edi
        imul    edi, edi
        sub     edx, 1
        jne     .L2
        ret

More challenges: challenges.re; about solutions: challenges.re/#Solutions.