home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume15 / ioccc / part06 < prev    next >
Encoding:
Internet Message Format  |  1988-08-11  |  23.4 KB

  1. Subject:  v15i110:  International Obfuscated C Code Contest, Part06/07
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Landon Curt Noll <chongo@uts.amdahl.com>
  7. Posting-number: Volume 15, Issue 110
  8. Archive-name: ioccc/part06
  9.  
  10. # This is a shell archive.  Remove anything before this line, then
  11. # unpack it by saving it in a file and typing "sh file".  (Files
  12. # unpacked will be owned by you and have default permissions.)
  13. #
  14. # This archive contains:
  15. # ./1987/Makefile ./1987/README ./1987/biggar.c ./1987/biggar.hint
  16. # ./1987/heckbert.c ./1987/heckbert.hint ./1987/hines.c ./1987/hines.hint
  17. # ./1987/korn.c ./1987/korn.hint ./1987/lievaart.c ./1987/lievaart.hint
  18. # ./1987/lievaart2.c ./1987/rules ./1987/wall.c ./1987/wall.hint
  19. # ./1987/westley.c ./1987/westley.hint
  20.  
  21. echo x - ./1987/Makefile
  22. sed -e 's/^X//' > "./1987/Makefile" << '//E*O*F ./1987/Makefile//'
  23. X# %W% %G% %U%
  24. X#
  25. X# 1987 makefile
  26. X
  27. XSHELL=/bin/sh
  28. XWINNERS=heckbert wall westley hines korn biggar lievaart lievaart2
  29. X
  30. X# for System V style systems
  31. XOPSYS=-Dindex=strchr
  32. X# for BSD style systems
  33. X#OPSYS=
  34. X
  35. Xall: ${WINNERS}
  36. X
  37. Xheckbert: heckbert.c
  38. X    cc ${OPSYS} $? -o $@
  39. Xwall: wall.c
  40. X    cc $? -o $@
  41. Xwestley: westley.c
  42. X    cc $? -o $@
  43. Xhines: hines.c
  44. X    cc $? -o $@
  45. Xkorn: korn.c
  46. X    cc $? -o $@
  47. Xbiggar: biggar.c
  48. X    cc -DC="R>0" -DI="if(T)O" -DO="c=write(1,&c,1);" \
  49. X        -DP="main(){X}" -DR="read(0,&c,1)" -DT="c!=015" \
  50. X        -DW="while(C)I" -DX="char c;W" $? -o $@
  51. Xlievaart: lievaart.c
  52. X    cc $? -o $@
  53. X# not an official entry
  54. Xlievaart2: lievaart2.c
  55. X    cc $? -o $@
  56. X
  57. Xclean:
  58. X    rm -f core
  59. Xclobber: clean
  60. X    rm -f ${WINNERS}
  61. Xinstall: all
  62. X    @echo are you kidding'??'
  63. //E*O*F ./1987/Makefile//
  64.  
  65. echo x - ./1987/README
  66. sed -e 's/^X//' > "./1987/README" << '//E*O*F ./1987/README//'
  67. X1987 marked the "The Fourth International Obfuscated C Code Contest"
  68. X
  69. XThe rules for 1987 suggested even more categories than in 1986.  Hints
  70. Xfor what to do and not to do were also given in the rules.  For
  71. Xexample, a simple excessive abuse of /lib/cpp was discouraged unless
  72. Xthe abuse was unusual.  The mailboxes for the contest were moved from
  73. Xnsc to amdahl.  The practice of posting a preliminary set of rules for
  74. Xthe next year was started this year.
  75. X
  76. XRules and results were posted to comp.lang.c, comp.unix.wizards with
  77. Xan announcement in news.announce.important.  Micro/Systems Journal
  78. Xpublished the 1987 winners.  Mark Horton included a version of the 1987
  79. Xwinners in an appendix of his C book.  The first announcement of
  80. Xwinners at the Summer 87 Usenix was helped by a small fly that
  81. Xdanced all over the foils.
  82. //E*O*F ./1987/README//
  83.  
  84. echo x - ./1987/biggar.c
  85. sed -e 's/^X//' > "./1987/biggar.c" << '//E*O*F ./1987/biggar.c//'
  86. XP;
  87. //E*O*F ./1987/biggar.c//
  88.  
  89. echo x - ./1987/biggar.hint
  90. sed -e 's/^X//' > "./1987/biggar.hint" << '//E*O*F ./1987/biggar.hint//'
  91. XBest Abuse of the Rules: <sdcrdcf!markb> Mark Biggar
  92. X
  93. X    Mark Biggar
  94. X    UNiSYS - System Development Group, Santa Monica
  95. X    2525 Colorado AV MD 91-01
  96. X    Santa Monica, CA
  97. X    90406
  98. X
  99. XCompile with:
  100. X
  101. X    cc -DC="R>0" -DI="if(T)O" -DO="c=write(1,&c,1);" -DP="main(){X}"\
  102. X    -DR="read(0,&c,1)" -DT="c!=015" -DW="while(C)I" -DX="char c;W" markb.c
  103. X
  104. XPasses BSD and UTS lint.  At least one version of lint is thrown into
  105. Xan infinite loop by this entry.
  106. X
  107. XTry:  ... | markb | od -c    (remember to compile as indicated above)
  108. X
  109. XBy changing the compile line you can make this program do anything you
  110. Xwant.  This is a very efficient way to transfer source, though it
  111. Xincreases the size of Makefiles.
  112. X
  113. XWith only slight variations, this program can be set to many uses.
  114. XConsider how easy it would be to release Un*x source in this form;
  115. Xso what if the make files grow a little!  :-) 
  116. X
  117. XOne vendor's lint got hung in an infinite loop over this entry!
  118. X
  119. XFYI:  We will let Mark get away with this truly sick entry this time, but 
  120. X      for the future on we have placed a limit on the size of a compile line.
  121. X
  122. XAlso see our comment in Larry Wall's entry regarding Mark's contribution.
  123. //E*O*F ./1987/biggar.hint//
  124.  
  125. echo x - ./1987/heckbert.c
  126. sed -e 's/^X//' > "./1987/heckbert.c" << '//E*O*F ./1987/heckbert.c//'
  127. X#include <ctype.h>
  128. X#include <stdio.h>
  129. X#define _ define
  130. X#_ A putchar
  131. X#_ B return
  132. X#_ C index
  133. Xchar*r,c[300001],*d=">=<=!===||&&->++-->><<",*i,*l,*j,*m,*k,*n,*h,*y;e,u=1,v,w,
  134. Xf=1,p,s,x;main(a,b)char**b;{p=a>1?atoi(b[1]):79;r=c+read(0,j=l=i=c,300000);v=g(
  135. Xj,&m);for(k=m;v!=2;j=k,m=n,v=w,k=m){w=g(k,&n);if(v==1&&m-j==1&&*j==35)e&&A(10),
  136. Xe=f=0;if(!f&&v==3&&(char*)C(j,10)<m)A(10),e=0,f=1;else if(v>2&&(u||w)&&(f||u)&&
  137. X(l-i>1||*i!=61||n-k>1||!C("-*&",*k)))continue;else if(v==3)if(f&&e+1+n-k>p&&e)A
  138. X(10),e=0;else A(32),e++;else{if(f&&e+m-j>p&&e)A(10),e=0;e+=m-j;k=j;while(k<m)A(
  139. X*k++);}i=j;l=m;u=v;}e&&A(10);}g(j,m)char*j,**m;{if(j>=r)B*m=j,2;s=isdigit(*j)||
  140. X*j==46&&isdigit(j[1]);for(h=j;h<r;h++)if(!isalnum(*h)&&*h!=95&&(!s||*h!=46)&&(!
  141. Xs||h[-1]!=101&&h[-1]!=69||!C("+-",*h)))break;if(h>j)B*m=h,0;x=1;for(h=j;h<r&&C(
  142. X" \t\n",*h);h++);if(h>j)h--,x=3;if(*j==34||*j==39)for(h=j+1;h<r&&*h!=*j;h++)if(
  143. X*h==92)h++;for(y=d;*y&&strncmp(y,j,2);y+=2);if(*y)h=j+1;if(!strncmp("/*",j,2)){
  144. Xh=j+2;while(*++h!=42||*++h!=47);x=4;}*m=h+1;B x;}
  145. //E*O*F ./1987/heckbert.c//
  146.  
  147. echo x - ./1987/heckbert.hint
  148. sed -e 's/^X//' > "./1987/heckbert.hint" << '//E*O*F ./1987/heckbert.hint//'
  149. XBest Obfuscator of Programs: <pixar!ph> Paul Heckbert
  150. X
  151. X    Paul Heckbert
  152. X    Pixar
  153. X
  154. XTry: ph 40 < ph.c > foo.c; cc foo.c -o ph
  155. X     ph 20 < a_C_prog.c > bar.c; cc bar.c
  156. X
  157. XThe judges used this program to fold up very long lines which the
  158. XBSD fold(1) was unable to process.  This program has been added
  159. Xto the contest tool chest.
  160. X
  161. XOn System V systems, compile with: -Dindex=strchr.
  162. XTo compile on a 16 bit machine, change 300000's to 30000.
  163. //E*O*F ./1987/heckbert.hint//
  164.  
  165. echo x - ./1987/hines.c
  166. sed -e 's/^X//' > "./1987/hines.c" << '//E*O*F ./1987/hines.c//'
  167. X#include <stdio.h>
  168. X#include <malloc.h>
  169. Xmain(togo,toog)
  170. Xint togo;
  171. Xchar *toog[];
  172. X{char *ogto,   tgoo[80];FILE  *ogot;  int    oogt=0, ootg,  otog=79,
  173. Xottg=1;if (    togo==  ottg)   goto   gogo;  goto    goog;  ggot:
  174. Xif (   fgets(  tgoo,   otog,   ogot)) goto   gtgo;   goto   gott;
  175. Xgtot:  exit(); ogtg: ++oogt;   goto   ogoo;  togg:   if (   ootg > 0)
  176. Xgoto   oggt;   goto    ggot;   ogog:  if (  !ogot)   goto   gogo;
  177. Xgoto   ggto;   gtto:   printf( "%d    goto   \'s\n", oogt); goto
  178. Xgtot;  oggt:   if (   !memcmp( ogto, "goto", 4))     goto   otgg;
  179. Xgoto   gooo;   gogo:   exit(   ottg); tggo:  ootg=   strlen(tgoo);
  180. Xgoto   tgog;   oogo: --ootg;   goto   togg;  gooo: ++ogto;  goto
  181. Xoogo;  gott:   fclose( ogot);  goto   gtto;  otgg:   ogto=  ogto +3;
  182. Xgoto   ogtg;   tgog:   ootg-=4;goto   togg;  gtgo:   ogto=  tgoo;
  183. Xgoto   tggo;   ogoo:   ootg-=3;goto   gooo;  goog:   ogot=  fopen(
  184. Xtoog[  ottg],  "r");   goto    ogog;  ggto:  ogto=   tgoo;  goto
  185. Xggot;}
  186. //E*O*F ./1987/hines.c//
  187.  
  188. echo x - ./1987/hines.hint
  189. sed -e 's/^X//' > "./1987/hines.hint" << '//E*O*F ./1987/hines.hint//'
  190. XWorst Style: <grebyn!avalon> Spencer Hines
  191. X
  192. X    Spencer Hines
  193. X    OnLine Computer Systems
  194. X    4200 Farragut Street
  195. X    Hyattsville, MD
  196. X    20781
  197. X    USA
  198. X
  199. XTry:  avalon avalon.c
  200. X
  201. XThis program was designed to maximize the bother function for
  202. Xstructured programmers.  This program takes goto statements to their
  203. Xlogical conclusion.  The layout and choice of names are classic.
  204. X
  205. XWe consider this to be a beautiful counter-example for Frank Rubin's
  206. Xletter to ACM form titled: `` "GOTO Considered Harmful" Considered Harmful ''.
  207. XSee the Communications of the ACM, March 1987, Page 195-196.
  208. //E*O*F ./1987/hines.hint//
  209.  
  210. echo x - ./1987/korn.c
  211. sed -e 's/^X//' > "./1987/korn.c" << '//E*O*F ./1987/korn.c//'
  212. X    main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}
  213. //E*O*F ./1987/korn.c//
  214.  
  215. echo x - ./1987/korn.hint
  216. sed -e 's/^X//' > "./1987/korn.hint" << '//E*O*F ./1987/korn.hint//'
  217. XBest One Liner: <ulysses!dgk> David Korn
  218. X
  219. X    David Korn
  220. X    AT&T Bell Labs
  221. X    MH 3C-526B, AT&T Bell Labs
  222. X    Murray Hill, NJ
  223. X    07974
  224. X    USA
  225. X
  226. XThe Judges believe that this is the best one line entry ever received.
  227. XCompile on a UN*X system, or at least using a C implementation that
  228. Xfakes it.  Very few people are able to determine what this program
  229. Xdoes by visual inspection.  I suggest that you stop reading this
  230. Xsection right now and see if you are one of the few people who can.
  231. X
  232. XSeveral points are important to understand in this program:
  233. X
  234. X    1) What is the symbol `unix' and what is its value in the program?
  235. X       Clearly `unix' is not a function, and since `unix' is not declared
  236. X       to be a data type (such as int, char, struct foo, enum, ...)
  237. X       what must `unix' be?
  238. X
  239. X    2) What is the value of the symbol "have"?  (hint: the value is
  240. X       NOT 4 characters, or 'h', or a string)  Consider the fact that:
  241. X
  242. X        char *x;
  243. X
  244. X      defines a pointer to a character (i.e. an address), and that
  245. X      the `=' assigns things is compatible types.  Since:
  246. X
  247. X            x = "have";
  248. X
  249. X      is legal C, what type of value is "have"?
  250. X
  251. X    3) Note that the following expressions yield the same value:
  252. X
  253. X        x[3]    *(x+3)      *(3+x)
  254. X
  255. X       since addition is communitive.  What can be said about the value:
  256. X
  257. X        3[x]
  258. X
  259. XDavid Korn's /bin/ksh provides us with a greatly improved version of
  260. Xthe /bin/sh.  The source for v7's /bin/sh greatly inspired this contest.
  261. //E*O*F ./1987/korn.hint//
  262.  
  263. echo x - ./1987/lievaart.c
  264. sed -e 's/^X//' > "./1987/lievaart.c" << '//E*O*F ./1987/lievaart.c//'
  265. X#define D define
  266. X#D Y return
  267. X#D R for
  268. X#D e while
  269. X#D I printf
  270. X#D l int
  271. X#D C y=v+111;H(x,v)*y++= *x
  272. X#D H(a,b)R(a=b+11;a<b+89;a++)
  273. X#D s(a)t=scanf("%d",&a)
  274. Xl V[1100],u,r[]={-1,-11,-10,-9,1,11,10,9},h[]={11,18,81,88},ih[]={22,27,72,77},
  275. Xbz,lv=60,*x,*y,m,t;S(d,v,f,a,b)l*v;{l c=0,*n=v+100,bw=d<u-1?a:-9000,w,z,i,zb,q=
  276. X3-f;if(d>u){R(w=i=0;i<4;i++)w+=(m=v[h[i]])==f?300:m==q?-300:(t=v[ih[i]])==f?-50
  277. X:t==q?50:0;return w;}H(z,0){if(GZ(v,z,f,100)){c++;w= -S(d+1,n,q,-b,-bw);if(w>bw
  278. X){zb=z;bw=w;if(w>=b||w>=8003)Y w;}}}if(!c){bz=0;C;Y-S(d+1,n,q,-b,-bw);}bz=zb;Y
  279. Xd>=u-1?bw+(c<<3):bw;}main(){R(;t<1100;t+=100)R(m=0;m<100;m++)V[t+m]=m<11||m>88
  280. X||(m+1)%10<2?3:0;V[44]=V[55]=1;V[45]=V[54]=2;I("Level:");s(u);e(lv>0){do{I("Yo\
  281. Xu:");s(m);}e(!GZ(V,m,2,0)&&m!=99);if(m!=99)lv--;if(lv<15&&u<10)u+=2;I("Wait\n")
  282. X;I("Value:%d\n",S(0,V,1,-9000,9000));I("move: %d\n",(lv-=GZ(V,bz,1,0),bz));}}GZ
  283. X(v,z,f,o)l*v;{l*j,q=3-f,g=0,i,h,*k=v+z;if(*k==0)R(i=7;i>=0;i--){j=k+(h=r[i]);e(
  284. X*j==q)j+=h;if(*j==f&&j-h!=k){if(!g){g=1;C;}e(j!=k)*((j-=h)+o)=f;}}Y g;}
  285. //E*O*F ./1987/lievaart.c//
  286.  
  287. echo x - ./1987/lievaart.hint
  288. sed -e 's/^X//' > "./1987/lievaart.hint" << '//E*O*F ./1987/lievaart.hint//'
  289. XGrand Prize: <botter!rblieva> Roemer B. Lievaart
  290. X
  291. X    Roemer B. Lievaart
  292. X    VU Informatica
  293. X    Churchilllaan 173-IV
  294. X    Amsterdam, The Netherlands
  295. X
  296. XWe believe that you too will be amazed at just how much power Mr. Lievaart
  297. Xpacked into 1024 bytes!
  298. X
  299. XThis Plays the game of reversi (Othello)!  Compile and run.  It then
  300. Xasks for a playing level. Enter 0-10 (easy-hard).  It then asks for
  301. Xyour move. A move is a number within 11-88, or a 99 to pass.  Illegal
  302. Xmoves (except for an illegal pass) are rejected.  Then the computer
  303. Xdoes its move (or a 0 to pass), until the board is full.  It plays
  304. Xrather well, for such a small program!  Lievaart had to leave out the
  305. Xboard printing routine, so you'll have to take a real game board to
  306. Xplay it. ...  Also due to space-limitations (the rules for 1987 had a
  307. Xlimit of 1024 byes), Lievaart took out the passing-handler, which
  308. Xmakes its ending-game rather poor.  But further it knows all the
  309. Xrules, uses alpha-beta pruning, and it plays f.i. on mobility(!).
  310. XMost important: it can play a pretty good game of Reversi!
  311. X
  312. XThe Author was kind enough to supply the fully functional version of the
  313. Xprogram.  The file lievaart2.c contains what the program would have
  314. Xbeen without the size restriction.  This version has the full end game 
  315. Xlogic and displays the board after each move!
  316. //E*O*F ./1987/lievaart.hint//
  317.  
  318. echo x - ./1987/lievaart2.c
  319. sed -e 's/^X//' > "./1987/lievaart2.c" << '//E*O*F ./1987/lievaart2.c//'
  320. X#define D define
  321. X#D Y return
  322. X#D R for
  323. X#D e while
  324. X#D I printf
  325. X#D l int
  326. X#D W if
  327. X#D C y=v+111;H(x,v)*y++= *x
  328. X#D H(a,b)R(a=b+11;a<b+89;a++)
  329. X#D s(a)t=scanf("%d",&a)
  330. X#D U Z I
  331. X#D Z I("123\
  332. X45678\n");H(x,V){putchar(".XO"[*x]);W((x-V)%10==8){x+=2;I("%d\n",(x-V)/10-1);}}
  333. Xl V[1600],u,r[]={-1,-11,-10,-9,1,11,10,9},h[]={11,18,81,88},ih[]={22,27,72,77},
  334. Xbz,lv=60,*x,*y,m,t;S(d,v,f,_,a,b)l*v;{l c=0,*n=v+100,j=d<u-1?a:-9000,w,z,i,g,q=
  335. X3-f;W(d>u){R(w=i=0;i<4;i++)w+=(m=v[h[i]])==f?300:m==q?-300:(t=v[ih[i]])==f?-50:
  336. Xt==q?50:0;Y w;}H(z,0){W(E(v,z,f,100)){c++;w= -S(d+1,n,q,0,-b,-j);W(w>j){g=bz=z;
  337. Xj=w;W(w>=b||w>=8003)Y w;}}}W(!c){g=0;W(_){H(x,v)c+= *x==f?1:*x==3-f?-1:0;Y c>0?
  338. X8000+c:c-8000;}C;j= -S(d+1,n,q,1,-b,-j);}bz=g;Y d>=u-1?j+(c<<3):j;}main(){R(;t<
  339. X1600;t+=100)R(m=0;m<100;m++)V[t+m]=m<11||m>88||(m+1)%10<2?3:0;I("Level:");V[44]
  340. X=V[55]=1;V[45]=V[54]=2;s(u);e(lv>0){Z do{I("You:");s(m);}e(!E(V,m,2,0)&&m!=99);
  341. XW(m!=99)lv--;W(lv<15&&u<10)u+=2;U("Wait\n");I("Value:%d\n",S(0,V,1,0,-9000,9000
  342. X));I("move: %d\n",(lv-=E(V,bz,1,0),bz));}}E(v,z,f,o)l*v;{l*j,q=3-f,g=0,i,w,*k=v
  343. X+z;W(*k==0)R(i=7;i>=0;i--){j=k+(w=r[i]);e(*j==q)j+=w;W(*j==f&&j-w!=k){W(!g){g=1
  344. X;C;}e(j!=k)*((j-=w)+o)=f;}}Y g;}
  345. //E*O*F ./1987/lievaart2.c//
  346.  
  347. echo x - ./1987/rules
  348. sed -e 's/^X//' > "./1987/rules" << '//E*O*F ./1987/rules//'
  349. XWARNING: The rules and mailing address for the contest change from year
  350. X         to year.  Be sure that you consult the current set of rules
  351. X     before submitting entries.
  352. X------------------------------------------------------------------------------
  353. X
  354. XSubject: 4th International Obfuscated C Code Contest Rules
  355. XNewsgroups: comp.lang.c,comp.unix.wizards
  356. XKeywords: rules,1987,obfuscate,contest
  357. X
  358. XGOALS OF THE CONTEST:
  359. X
  360. X    * To write the most Obscure/Obfuscated C program under the rules below.
  361. X    * To show what should NOT be done in C programs.
  362. X    * To provide a safe forum for poor C code.  :-)
  363. X
  364. XRULES:
  365. X    1) The source must be 1024 characters long or less.  NO EXCEPTIONS!
  366. X
  367. X    2) To help us process your entries, we ask that you submit entries
  368. X       in the following format:   (please include the --- lines)
  369. X
  370. X---start of header items---
  371. Xname:
  372. Xorg:
  373. Xemail address:
  374. Xpostal address:
  375. Xenvironment:
  376. Xremarks:
  377. X---start of entry---
  378. XX    <place obfuscated source of 1024 characters or less here>
  379. XX    <add a leading X to each line to avoid problems with mailers>
  380. XX    <leading X's do not count toward the source character count>
  381. XX    <the first X of each source line will be removed prior to compilation>
  382. XX    <newlines count as 1 character>
  383. XX    <assume a standard 8 character tab stop>
  384. X---end of entry---
  385. X
  386. X    3) Regarding the header items:
  387. X
  388. X        * All header items except 'remark' are optional.  If you do not
  389. X          wish to answer an item, indicate so by the string:   ***NONE***
  390. X          Any text outside of the above format will be kept confidential.
  391. X
  392. X        * You can remain anonymous.   If the name item is:  ***ANONYMOUS***
  393. X          all items except the 'remarks' item will not be relased.
  394. X
  395. X        * Indicate the name of your Company or School in the 'org' item.
  396. X
  397. X        * The 'email address' item asks for a network path from a major
  398. X          site (such as amdahl) to your mailbox.
  399. X
  400. X        * If you give a 'postal address', please include your Country.
  401. X
  402. X        * Give the machine and operating system (i.e., Un*x version) on
  403. X          which your program ran.
  404. X
  405. X        * The 'remarks' item is not optional.  Please indicate:
  406. X        - how to execute or compile if something special is required
  407. X        - type of input or argument needed, if applicable
  408. X        - what this program does
  409. X        - any other remarks you wish to make
  410. X
  411. X        * If you need more than one line on a header item, place
  412. X          tab or space characters at the beginning of each additional line.
  413. X
  414. X    4) The entry should be written in a common C. (K&R + common extensions)
  415. X
  416. X    5) The program must be of original work.  All programs must be
  417. X       in the public domain.  All copyrighted programs will be rejected.
  418. X
  419. X    6) Entries must be received before 30-May-87 0:00 GMT.
  420. X       Email your entries to:
  421. X       
  422. X            ...!amdahl!obfuscate
  423. X
  424. X       Amdahl talks to hplabs, decwrl, pyramid, seismo and cbosgd.
  425. X       We will attempt to Email a confirmation of receipt of contest
  426. X       entries, however since Email is not reliable you may not receive it.
  427. X       People are encouraged to submit entries via Email, however
  428. X       one may mail entries the following postal address:
  429. X
  430. X        Landon Curt Noll
  431. X        Amdahl Corp.
  432. X        1250 E. Arques Ave.   M/S 316
  433. X        P.O. Box 3470
  434. X        Sunnyvale, CA
  435. X        94088-3470
  436. X        U.S.A.
  437. X
  438. X      Write the words: "International Obfuscated C Code Contest" near the
  439. X      bottom left corner of the envelope.
  440. X
  441. X    8) Contest entries sent in by post should indicate where TAB characters
  442. X       are to be placed, otherwise space characters will be assumed.  Each
  443. X       line will be assumed to contain a newline character.  The leading
  444. X       'X' will serve to indicate where each source line starts.
  445. X
  446. X    9) Each person may submit up to 5 entries.  Multiple entries must
  447. X       be sent in separate Email letters or postal envelopes.
  448. X
  449. X    10) People are encouraged to examine winners of the previous
  450. X        contests.  A copy of these entries was posted to mod.sources
  451. X        on or about 12-Mar-87.  Contact the mod.sources moderator
  452. X        if you missed that article.  Keep in mind that rules change from
  453. X        year to year, so some winning entries may not be valid
  454. X        entries this year.  Also what was unique and novel one
  455. X        year can get 'old' the next year.
  456. X
  457. X
  458. XANNOUNCEMENT OF WINNERS:
  459. X
  460. X    * First announcement will be at the Summer 87 Usenix BOF.
  461. X
  462. X    * An announcement will be posted to mod.announce near
  463. X      mid June 1987 stating to which newsgroup the winners
  464. X      have been posted.
  465. X
  466. X    * An article containing the winning entries will be published
  467. X      in a future issue of the "Micro/Systems Journal".
  468. X
  469. X    * Winners receive international fame and flames!  :-)
  470. X
  471. X
  472. XJUDGING:
  473. X    Awards will be given to the best entry in a number of categories.
  474. X    The actual category list will vary depending on the types of entries
  475. X    we receive.  At the moment, we are considering using the following:
  476. X
  477. X        * The best small one line program
  478. X        * The most obscure algorithm
  479. X        * The worst abuse of the C preprocessor  (note warnings below)
  480. X        * The strangest source layout
  481. X        * The most useful obfuscated program
  482. X        * <anything else so strange that it deserves an award>
  483. X
  484. X    Extra points will be given for programs which:
  485. X
  486. X        * pass lint without complaint
  487. X        * do something quasi-interesting
  488. X        * are portable
  489. X        * are unique in their obfuscation style
  490. X        * are concise
  491. X
  492. X    Points will be taken away for programs that:
  493. X
  494. X        * are very hardware or Un*x version specific
  495. X        * dump core or have compiler warnings
  496. X          (we won't take points away if you warn us in the remark item)
  497. X        * fail to compile
  498. X        * obfuscate only by overuse of #defines
  499. X          (you should do this ONLY if your use is unusual)
  500. X        * are similar to previous winners
  501. X        * are similar to previous losers  :-)
  502. X
  503. X    The Judging will be done by Landon Noll and Larry Bassel.  
  504. X    Comments & questions (not entries) about the contest can be Emailed to:
  505. X
  506. X             ...!amdahl!judges
  507. X
  508. Xchongo <Landon Curt Noll> /\cc/\
  509. XLarry Bassel
  510. //E*O*F ./1987/rules//
  511.  
  512. echo x - ./1987/wall.c
  513. sed -e 's/^X//' > "./1987/wall.c" << '//E*O*F ./1987/wall.c//'
  514. X#define iv 4 
  515. X#define v ;(void
  516. X#define XI(xi)int xi[iv*'V'];
  517. X#define L(c,l,i)c(){d(l);m(i);}
  518. X#include <stdio.h>
  519. Xint*cc,c,i,ix='\t',exit(),X='\n'*'\d';XI(VI)XI(xi)extern(*vi[])(),(*
  520. Xsignal())();char*V,cm,D['x'],M='\n',I,*gets();L(MV,V,(c+='d',ix))m(x){v)
  521. Xsignal(X/'I',vi[x]);}d(x)char*x;{v)write(i,x,i);}L(MC,V,M+I)xv(){c>=i?m(
  522. Xc/M/M+M):(d(&M),m(cm));}L(mi,V+cm,M)L(md,V,M)MM(){c=c*M%X;V-=cm;m(ix);}
  523. XLXX(){gets(D)||(vi[iv])();c=atoi(D);while(c>=X){c-=X;d("m");}V="ivxlcdm"
  524. X+iv;m(ix);}LV(){c-=c;while((i=cc[*D=getchar()])>-I)i?(c?(c<i&&l(-c-c,
  525. X"%d"),l(i,"+%d")):l(i,"(%d")):(c&&l(M,")"),l(*D,"%c")),c=i;c&&l(X,")"),l
  526. X(-i,"%c");m(iv-!(i&I));}L(ml,V,'\f')li(){m(cm+!isatty(i=I));}ii(){m(c=cm
  527. X= ++I)v)pipe(VI);cc=xi+cm++;for(V="jWYmDEnX";*V;V++)xi[*V^' ']=c,xi[*V++]
  528. X=c,c*=M,xi[*V^' ']=xi[*V]=c>>I;cc[-I]-=ix v)close(*VI);cc[M]-=M;}main(){
  529. X(*vi)();for(;v)write(VI[I],V,M));}l(xl,lx)char*lx;{v)printf(lx,xl)v)
  530. Xfflush(stdout);}L(xx,V+I,(c-=X/cm,ix))int(*vi[])()={ii,li,LXX,LV,exit,l,
  531. Xd,l,d,xv,MM,md,MC,ml,MV,xx,xx,xx,xx,MV,mi};
  532. //E*O*F ./1987/wall.c//
  533.  
  534. echo x - ./1987/wall.hint
  535. sed -e 's/^X//' > "./1987/wall.hint" << '//E*O*F ./1987/wall.hint//'
  536. XMost Useful Obfuscation: <sdcrdcf!lwall> Larry Wall
  537. X
  538. X    Larry Wall
  539. X    Unisys - System Development Group Santa Monica
  540. X    9132 Kester Ave
  541. X    Panorama City, CA  91402  USA
  542. X
  543. XTry:    lwall | bc | lwall
  544. Xinput:    x*x
  545. Xinput:    c^2
  546. X
  547. XAlso try:  lwall | bc   and   lwall | cat
  548. X
  549. XWhat we found amazing was how the flow of control was transferred
  550. Xbetween subroutines.  Careful inspection will show that the array of
  551. Xpointers to functions named `vi' refers to functions which seem to not
  552. Xbe directly called.  Even so, these pointers to functions are being
  553. Xused as an argument to signal.  Can you determine why this is being
  554. Xdone and how it is being exploited?
  555. X
  556. XSome compilers complained about this file, so we changed: '=++I' to '= ++I'.
  557. //E*O*F ./1987/wall.hint//
  558.  
  559. echo x - ./1987/westley.c
  560. sed -e 's/^X//' > "./1987/westley.c" << '//E*O*F ./1987/westley.c//'
  561. X                char rahc
  562. X                   [ ]
  563. X                    =
  564. X                  "\n/"
  565. X                    ,
  566. X                redivider
  567. X                   [ ]
  568. X                    =
  569. X               "Able was I ere I saw elbA"
  570. X                    ,
  571. X                    *
  572. X                 deliver,reviled
  573. X                    =
  574. X                   1+1
  575. X                    ,
  576. X                   niam ; main
  577. X                   ( )
  578. X                  {/*\}
  579. X                   \*/
  580. X                 int tni
  581. X                    =
  582. X                   0x0
  583. X                    ,
  584. X                 rahctup,putchar
  585. X                   ( )
  586. X                   ,LACEDx0 = 0xDECAL,
  587. X                rof ; for
  588. X                 (;(int) (tni);)
  589. X                   (int) (tni)
  590. X              = reviled ; deliver =
  591. X                redivider
  592. X                    ;
  593. Xfor ((int)(tni)++,++reviled;reviled* *deliver;deliver++,++(int)(tni)) rof
  594. X                        =
  595. X                 (int) -1- (tni)
  596. X                  ;reviled--;--deliver;
  597. X                 (tni)  =  (int)
  598. X              - 0xDECAL + LACEDx0 -
  599. X                rof ; for
  600. X       (reviled--,(int)--(tni);(int) (tni);(int)--(tni),--deliver)
  601. X                rahctup = putchar
  602. X               (reviled* *deliver)
  603. X                    ;
  604. X                rahctup * putchar
  605. X                ((char) * (rahc))
  606. X                    ;
  607. X                   /*\
  608. X                  {\*/}
  609. //E*O*F ./1987/westley.c//
  610.  
  611. echo x - ./1987/westley.hint
  612. sed -e 's/^X//' > "./1987/westley.hint" << '//E*O*F ./1987/westley.hint//'
  613. XBest Layout: <starfire!merlyn> Brian Westley
  614. X
  615. X    Brian Westley (aka Merlyn Leroy on usenet)
  616. X    Starfire Consulting
  617. X    1121 Hamline Ave. N. #17
  618. X    St. Paul, MN
  619. X    55108
  620. X    USA
  621. X
  622. XPutchar must exist in the C library and not just as a macro.
  623. XIf it fails to compile, add the line:  #include <stdio.h>  at the
  624. Xtop of the program.
  625. X
  626. XLine by line symmetry performed better than any C beautifier.  Think
  627. Xof if it as a C ink blot.  :-)
  628. //E*O*F ./1987/westley.hint//
  629.  
  630. echo Possible errors detected by \'wc\' [hopefully none]:
  631. temp=/tmp/shar$$
  632. trap "rm -f $temp; exit" 0 1 2 3 15
  633. cat > $temp <<\!!!
  634.  40  112  726  Makefile
  635.  15  136  816  README
  636.  1  1  3  biggar.c
  637.  32  191  1141  biggar.hint
  638.  18  33  1021  heckbert.c
  639.  14  76  430  heckbert.hint
  640.  19  130  953  hines.c
  641.  18  82  565  hines.hint
  642.  1  3  70  korn.c
  643.  44  242  1401  korn.hint
  644.  20  44  1022  lievaart.c
  645.  27  224  1303  lievaart.hint
  646.  25  61  1175  lievaart2.c
  647.  161  917  5745  rules
  648.  18  30  1021  wall.c
  649.  21  120  708  wall.hint
  650.  48  93  908  westley.c
  651.  15  73  412  westley.hint
  652.  537  2568  19420  total
  653. !!!
  654. wc  ./1987/Makefile ./1987/README ./1987/biggar.c ./1987/biggar.hint ./1987/heckbert.c ./1987/heckbert.hint ./1987/hines.c ./1987/hines.hint ./1987/korn.c ./1987/korn.hint ./1987/lievaart.c ./1987/lievaart.hint ./1987/lievaart2.c ./1987/rules ./1987/wall.c ./1987/wall.hint ./1987/westley.c ./1987/westley.hint | sed 's=[^ ]*/==' | diff -b $temp -
  655. exit 0
  656.  
  657.