v15i107: International Obfuscated C Code Contest, Part03/07

Rich Salz rsalz at uunet.uu.net
Wed Aug 3 06:38:22 AEST 1988


Submitted-by: Landon Curt Noll <chongo at uts.amdahl.com>
Posting-number: Volume 15, Issue 107
Archive-name: ioccc/part03

# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# 
# ./1984/Makefile ./1984/README ./1984/anonymous.c ./1984/anonymous.hint
# ./1984/decot.c ./1984/decot.hint ./1984/laman.c ./1984/laman.hint
# ./1984/mullender.c ./1984/mullender.hint ./1984/rules

echo x - ./1984/Makefile
sed -e 's/^X//' > "./1984/Makefile" << '//E*O*F ./1984/Makefile//'
X# %W% %G% %U%
X#
X# 1984 makefile
X
XSHELL=/bin/sh
XWINNERS=anonymous laman decot mullender
X
Xall: ${WINNERS}
X
Xanonymous: anonymous.c
X	cc $? -o $@
Xlaman: laman.c
X	cc $? -o $@
Xdecot: decot.c
X	cc $? -o $@ -lm
Xmullender: mullender.c
X	cc $? -o $@
X
Xclean:
X	rm -f core
Xclobber: clean
X	rm -f ${WINNERS}
X
Xinstall: all
X	@echo are you kidding'??'
//E*O*F ./1984/Makefile//

echo x - ./1984/README
sed -e 's/^X//' > "./1984/README" << '//E*O*F ./1984/README//'
XIn 1984, the first contest was held.  The name of the contest was simply
X``Obfuscated C Code Contest''.
X
XRestrictions against machine dependent code were not in the rules in 1984.
XThe source file size restriction was only 512 bytes.  Rules and results
Xwere posted to net.lang.c and net.unix-wizards.
//E*O*F ./1984/README//

echo x - ./1984/anonymous.c
sed -e 's/^X//' > "./1984/anonymous.c" << '//E*O*F ./1984/anonymous.c//'
Xint i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
Xo, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
//E*O*F ./1984/anonymous.c//

echo x - ./1984/anonymous.hint
sed -e 's/^X//' > "./1984/anonymous.hint" << '//E*O*F ./1984/anonymous.hint//'
XAnonymous entry: <?!?> Dishonorable mention
X
XThe author was too embarrassed that he/she could write such trash, so I
Xpromised to protect their identity.  I will say that the author of this
Xprogram has a well known connection with the C programming language.
X
XThis program is a unique variation on the age old "Hello, world"
Xprogram.  What reads like a read may be written like a write!
//E*O*F ./1984/anonymous.hint//

echo x - ./1984/decot.c
sed -e 's/^X//' > "./1984/decot.c" << '//E*O*F ./1984/decot.c//'
X#define x =
X#define double(a,b) int
X#define char k['a']
X#define union static struct
X
Xextern int floor;
Xdouble (x1, y1) b,
Xchar x {sizeof(
X    double(%s,%D)(*)())
X,};
Xstruct tag{int x0,*xO;}
X
X*main(i, dup, signal) {
X{
X  for(signal=0;*k *x * __FILE__ *i;) do {
X   (printf(&*"'\",x);	/*\n\\", (*((double(tag,u)(*)())&floor))(i)));
X	goto _0;
X
X_O: while (!(char <<x - dup)) {	/*/*\*/
X	union tag u x{4};
X  }
X}
X
X
Xwhile(b x 3, i); {
Xchar x b,i;
X  _0:if(b&&k+
X  sin(signal)		/ *    ((main) (b)-> xO));/*}
X  ;
X}
X
X*/}}}
//E*O*F ./1984/decot.c//

echo x - ./1984/decot.hint
sed -e 's/^X//' > "./1984/decot.hint" << '//E*O*F ./1984/decot.hint//'
XSecond place award: <hpda!hpdsd!decot> Dave Decot
X
XCompile with:
X
X	cc decot.c -o decot -lm
X
XNOTE: Some new compilers disliked line 15 of the source, so we changed it from:
X
X  for(signal=0;*k * x * __FILE__ *i;) do {
X
Xto:
X
X  for(signal=0;*k *x * __FILE__ *i;) do {
X
XThis program prints out a string of garbage.
X
XThe judges also offer this one comment: understand comments!
//E*O*F ./1984/decot.hint//

echo x - ./1984/laman.c
sed -e 's/^X//' > "./1984/laman.c" << '//E*O*F ./1984/laman.c//'
Xa[900];		b;c;d=1		;e=1;f;		g;h;O;		main(k,
Xl)char*		*l;{g=		atoi(*		++l);		for(k=
X0;k*k<		g;b=k		++>>1)		;for(h=		0;h*h<=
Xg;++h);		--h;c=(		(h+=g>h		*(h+1))		-1)>>1;
Xwhile(d		<=g){		++O;for		(f=0;f<		O&&d<=g
X;++f)a[		b<<5|c]		=d++,b+=	e;for(		f=0;f<O
X&&d<=g;		++f)a[b		<<5|c]=		d++,c+=		e;e= -e
X;}for(c		=0;c<h;		++c){		for(b=0		;b<k;++
Xb){if(b		<k/2)a[		b<<5|c]		^=a[(k		-(b+1))
X<<5|c]^=	a[b<<5		|c]^=a[		(k-(b+1		))<<5|c]
X;printf(	a[b<<5|c	]?"%-4d"	:"    "		,a[b<<5
X|c]);}		putchar(	'\n');}}	/*Mike		Laman*/
//E*O*F ./1984/laman.c//

echo x - ./1984/laman.hint
sed -e 's/^X//' > "./1984/laman.hint" << '//E*O*F ./1984/laman.hint//'
XThird place: <sdcsvax!laman> Mike Laman
X
XNOTE: Some new compilers dislike lines 6 and 10 of the source, so we changed
Xthem from:
X
X;++f)a[		b<<5|c]		=d++,b+		=e;for(		f=0;f<O
X<<5|c]^		=a[b<<5		|c]^=a[		(k-(b+1		))<<5|c]
X
Xto:
X
X;++f)a[		b<<5|c]		=d++,b+=	e;for(		f=0;f<O
X<<5|c]^=	a[b<<5		|c]^=a[		(k-(b+1		))<<5|c]
X
XI hope you have the C beautifier! The program accepts ONE positive
Xargument.  Seeing is believing, so try things like:
X
X	laman 4
X	laman 9
X	laman 16
X
XThis code should run you in circles.
//E*O*F ./1984/laman.hint//

echo x - ./1984/mullender.c
sed -e 's/^X//' > "./1984/mullender.c" << '//E*O*F ./1984/mullender.c//'
Xshort main[] = {
X	277, 04735, -4129, 25, 0, 477, 1019, 0xbef, 0, 12800,
X	-113, 21119, 0x52d7, -1006, -7151, 0, 0x4bc, 020004,
X	14880, 10541, 2056, 04010, 4548, 3044, -6716, 0x9,
X	4407, 6, 5568, 1, -30460, 0, 0x9, 5570, 512, -30419,
X	0x7e82, 0760, 6, 0, 4, 02400, 15, 0, 4, 1280, 4, 0,
X	4, 0, 0, 0, 0x8, 0, 4, 0, ',', 0, 12, 0, 4, 0, '#',
X	0, 020, 0, 4, 0, 30, 0, 026, 0, 0x6176, 120, 25712,
X	'p', 072163, 'r', 29303, 29801, 'e'
X};
//E*O*F ./1984/mullender.c//

echo x - ./1984/mullender.hint
sed -e 's/^X//' > "./1984/mullender.hint" << '//E*O*F ./1984/mullender.hint//'
XThe Grand Prize: <vu44!{sjoerd,cogito}> Sjoerd Mullender & Robbert van Renesse
X
XWithout question, this C program is the most obfuscated C program that
Xhas ever been received!  Like all great contest entries, they result
Xin a change of rules for the following year.  To prevent a flood of
Xsimilar programs, we requested that programs be non machine specific.
X
XThis program was selected for the 1987 t-shirt collection.
X
XNOTE: If your machine is not a Vax-11 or pdp-11, this program will
X      not execute correctly.  In later years, machine dependent
X      code was discouraged.
X
XThe C startup routine (via crt0.o) transfers control to a location
Xnamed main.  In this case, main just happens to be in the data area.
XThe array of shorts, which has been further obfuscated by use of
Xdifferent data types, just happens to form a meaningful set of PDP-11
Xand Vax instructions.  The first word is a PDP-11 branch instruction
Xthat branches to the rest of the PDP code.  On the Vax main is called with
Xthe calls instruction which uses the first word of the subroutine as a
Xmask of registers to be saved.  So on the Vax the first word can be anything.
XThe real Vax code starts with the second word.  This small program
Xmakes direct calls to the write() Unix system call to produce a
Xmessage on the screen.  Can you guess what is printed?  We knew you
Xcouldn't!  :-)
//E*O*F ./1984/mullender.hint//

echo x - ./1984/rules
sed -e 's/^X//' > "./1984/rules" << '//E*O*F ./1984/rules//'
XI'm sure you have all seen gross, or down right structurally obscene C
Xsource code before.  Some people who deal with various parts of the
XUN*X  source wonder if some folks try rather hard to produce such
Xdown right smelly code.
X
XNow you have the chance to compete with the worst C hackers around
Xby sending in your own obfuscated C program.  Just follow the contest
Xrules below:
X		1) the source file must be no more than 512 bytes long
X
X		2) mail your source to:    hplabs!nsc!chongo
X		   no later than April 11, 1984.  entries posted to
X		   the net will NOT be accepted.  please give your
X		   letter the subject of: obfuscated C code contest.
X
X		3) winning entries will be posted to net.lang.c after
X		   April 12, 1894.  (thats the prize folks)
X
X		4) indicate your net address in the text of your
X		   entry, this will be used to give credit unless
X		   you indicate that you want to remain anonymous.
X
X		5) entries must be of original work.  (dont send anything
X		   that might upset Big Brother Bell)  all entries are
X		   public domain.  (who would want to own them anyway?!)
X
XEntries will be judged for: violations of structured programming, non-clarity,
Xand use of "by the K&R book" C. (use of local mods to C are not encouraged)
Xextra credit if they can be compiled using the 4.2BSD C compiler on our VAX 780,
Xbut dont let the lack of a 780 or 4.2 discourage you!
X
Xchongo <flames about the contest will be kindly #ifdef'ed out> /\CC/\
X
XUN*X is a trademark of Usenet Hackers Anonymous
X
XWARNING: The rules and mailing address for the contest change from year
X         to year.  Be sure that you consult the current set of rules
X	 before submitting entries.
//E*O*F ./1984/rules//

echo Possible errors detected by \'wc\' [hopefully none]:
temp=/tmp/shar$$
trap "rm -f $temp; exit" 0 1 2 3 15
cat > $temp <<\!!!
 25  55  331  Makefile
 6  48  300  README
 2  4  123  anonymous.c
 8  66  386  anonymous.hint
 32  77  509  decot.c
 17  61  372  decot.hint
 12  62  510  laman.c
 21  76  499  laman.hint
 10  86  431  mullender.c
 25  234  1357  mullender.hint
 38  284  1666  rules
 196  1053  6484  total
!!!
wc  ./1984/Makefile ./1984/README ./1984/anonymous.c ./1984/anonymous.hint ./1984/decot.c ./1984/decot.hint ./1984/laman.c ./1984/laman.hint ./1984/mullender.c ./1984/mullender.hint ./1984/rules | sed 's=[^ ]*/==' | diff -b $temp -
exit 0

-- 
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.



More information about the Comp.lang.c mailing list