What does that print? (Hint: it's not "have fun"!) David wrote the eponymous Korn shell, which is
widely regarded as much cleaner than the version 7 /bin/sh, so presumably the IOCCC also acts as a
safety valve for the happy hacker.
A 1988 winner was an obfuscated version of cdecl, submitted by programmer Gopi Reddy. Recall that
we needed about 150 lines to program this unobfuscated. The obfuscated code is less than a dozen
lines
#include<stdio.h>
#include<ctype.h>
#define w printf
#define p while
#define t(s) (W=T(s))
charX,B,L,I[99];M,W,V;D(){W==9?(w("`%.s' is
",V,X),t(0)):W==40?
(t(0),D(),t(41)):W==42?(t(0),D(),w("ptr to ")):0;p(W==40?(t(0),
w("func returning "),t(41)):W==91?(t(0)==32?(w("array[0..%d]
of ",
atoi(X)-1),t(0)):w("array of "),t(93)):0);}main(){p(w("input:
"),
B=gets(I))if(t(0)==9)L=X,M=V,t(0),D(),w("%.*s.\n\n",M,L);}T(s)
{if(!s||s==W)
{p(B==9||B==32)B++;X=B;V=0;if(W=isalpha(B)?9:isdigit(B)?32
:*B++)
if(W<33)p(isalnum(*B))B++,V++;}return W;}
This kind of obfuscation, using excessive? and , operators, is a little vieux chapeau now, but at the
time it was novel and the program's conciseness is certainly astonishing. Figur-ing out how it works is
left as an exercise for the reader. (Ha! I've always wanted to say that.) To get you started, there are two
subroutines, T(), which lexes the next token and says whether it is an identifier, number, etc., and
D(), which does the parsing. Try unscrambling it by running it through the preprocessor and
formatting it. Then turn all the? expressions into if statements. Iterate until readable.
The final obfuscated C example is a BASIC interpreter, submitted by University of London graduate
student Diomidis Spinellis and written in about 1,500 characters! It was accompanied by an
instruction manual that explained how to use the interpreter, and provided a sample BASIC program.
Software Dogma
DDS-BASIC Interpreter (Version 1.00)
Immediate commands: