One step to the left, one step to the right. Hmmm… This small code snippet seems to do something within loops. Try to figure out WHAT it is doing and please: provide a C++ or pseudo code of your analysis! Manual decompilation rocks!

[EXERCISE 0011] Time Shift
Published: December 15, 2009Posted in: The Binary Auditor™ Short Exercises
here’s what i got from it
variables
a,i
while i > -1{
if i < 6 {a = a SHL 1}
else {
i = 0;
while i < 4 {
a = a SHR 1}
exit;
}
a is the constant 1 stored in the code, eax will always return 0 and the var_4 will always return 0×04
i optimized the code to be something like this:
for i = 0 to 10
if i < 6{a = a*2;}
else{a = a/2;}
Pseudo code:
var_4=1;
var_8=0;
while(var_8<6)
{
var_4=var_4*2;
var_8++;
}
var_8=0;
while(var_8<4)
{
var_4=var_4/2;
var_8++;
}
exit;
var_4 goes from 1 to 64 then back down to 4 as its final value
mazuki’s optimized code is probably the actual source.