This fascinating piece of code was featured in the very first (1984) edition of the International Obfuscated C Code Contest:
http://www.ioccc.org/years.html#1984 (decot)
After clearing through the debris of preprocessor abuse and unused code caused by a goto and some sneaky comments, you end up with the following surviving code (please correct me if I am wrong!):
#include <stdio.h> //used to suppress warnings
#include <math.h> //used to suppress warnings
extern int fl00r; //renamed to not clash with floor from math.h - unless it's part of the trickery???
int b, k['a'] = {
sizeof(int(*)()),
};
struct tag {int x0,*xO;}
*main(int i, int dup, int signal) { //int added to suppress warnings
for(signal=0;*k *= * __FILE__ *i;) {
printf(&*"'\",=); /*\n\\", (*((int(*)())&fl00r))(i)); //see line 3
if(b&&k+sin(signal)/ * ((main) (b)-> xO));
}
}
There is a single compiler error left to conquer:
decot.c: In function 'main':
decot.c:12:28: error: too few arguments to function 'main'
12 | if(b&&k+sin(signal)/ * ((main) (b)-> xO));
| ^
decot.c:9:2: note: declared here
9 | *main(int i, int dup, int signal) {
| ^~~~
I suspect that the way compilers worked back in the day meant that you could somehow call main with just 1 argument even though it was specifically defined with 3 as in this case.
Is this accurate? Am I missing something? What are the least changes necessary to enable this code to compile nowadays?
I used GCC 9.2.0 with the suggested build command in the Makefile.
Thanks in advance and apologies if I have missed something very obvious!