Obfuscated Code Unfolded..

What is the first thing that comes to your mind seeing this?

Screenshot of Obfuscated code
Screenshot of Obfuscated code

Seeing the first few lines may remember you of some programming language but what is rest? It made no sense to me too at first and then, slowly, it started unfolding in front of me.

Yes, this program has a pre-processor macro and if one exists in the program, it gets replaced, where-ever it is found in the rest of the program, by its value. Thereby, all the underscores(_) will be replaced by “-F<00||–F-OO–".
Thus during compilation, just after the pre-processor macro is made effective, the program will look like below:

Screenshot of code after preprocessing
Screenshot of code after preprocessing

Now lets unfold the mystery of this simple statement: -F 0(false)
0(false) || 1(true) ==> 1(true)
1(true) || 0(false) ==> 1(true)
1(true) || 1(true) ==> 1(true)

The beauty of || operator is its usability for selective execution of two statements. Consider a complex statement a||b where a and b are expressions or simple statements, b will be executed only if a returns false or 0;

Analyze the code: -F<00||–F-OO–;–F<00||–F-OO–;–F<00||–F-OO–;–F<00||–F-OO–;

At first F is 0, so –F or –0 or 0 is not less than 0, –F-OO- – is executed and – -F is a prefix decrement ie. F's value is decremented by 1 and stored in F before the entire statement is executed, O- – is a postfix decrement operation, ya you guessed it right, decrement will happen after the execution of this statement. Now after semi-colon the statement has a small change, instead of "-F<00||–F-OO–;" it is now "–F<00||–F-OO–;", an extra –ve symbol at front. Remember the value of F and OO is –1 now. Take the statement – -F< 0 ie. -(-(-1))<0 equivalent to –14.0*-(-16)/(-16)/(-16)
=>4.0*16/-16/-16
=>4.0*-1/-16
=>4.0*0.0625
=>0.25

Code for reference:
#define _ -F<00||–F-OO–;
int F=00,OO=00;
main(){
F_OO();
printf("%1.3f\n",4.*-F/OO/OO);
}

F_OO()
{
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}