home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume14 / ioccc / part02 < prev    next >
Text File  |  1988-03-14  |  8KB  |  241 lines

  1. Subject:  v14i002:  International Obfuscated C Code Contest, Part02/05
  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 14, Issue 2
  8. Archive-name: ioccc/part02
  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. # ./1984/Makefile ./1984/README ./1984/anonymous.c ./1984/anonymous.hint 
  16. # ./1984/decot.c ./1984/decot.hint ./1984/laman.c ./1984/laman.hint 
  17. # ./1984/mullender.c ./1984/mullender.hint ./1984/rules
  18.  
  19. echo mkdir ./1984
  20. mkdir ./1984
  21. echo x - ./1984/Makefile
  22. sed -e 's/^X//' > "./1984/Makefile" << '//E*O*F ./1984/Makefile//'
  23. X# %W% %G% %U%
  24. X#
  25. X# 1984 makefile
  26. X
  27. XSHELL=/bin/sh
  28. XWINNERS=anonymous laman decot mullender
  29. X
  30. Xall: ${WINNERS}
  31. X
  32. Xanonymous: anonymous.c
  33. X    cc $? -o $@
  34. Xlaman: laman.c
  35. X    cc $? -o $@
  36. Xdecot: decot.c
  37. X    cc $? -o $@ -lm
  38. Xmullender: mullender.c
  39. X    cc $? -o $@
  40. X
  41. Xclean:
  42. X    rm -f core
  43. Xclobber: clean
  44. X    rm -f ${WINNERS}
  45. X
  46. Xinstall: all
  47. X    @echo are you kidding'??'
  48. //E*O*F ./1984/Makefile//
  49.  
  50. echo x - ./1984/README
  51. sed -e 's/^X//' > "./1984/README" << '//E*O*F ./1984/README//'
  52. XIn 1984, the first contest was held.  The name of the contest was simply
  53. X``Obfuscated C Code Contest''.
  54. X
  55. XRestrictions against machine dependent code were not in the rules in 1984.
  56. XThe source file size restriction was only 512 bytes.  Rules and results
  57. Xwere posted to net.lang.c and net.unix-wizards.  If anybody has a copy of
  58. Xthe rules for 1984, please Email it to: chongo@amdahl.com.
  59. //E*O*F ./1984/README//
  60.  
  61. echo x - ./1984/anonymous.c
  62. sed -e 's/^X//' > "./1984/anonymous.c" << '//E*O*F ./1984/anonymous.c//'
  63. Xint i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
  64. Xo, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
  65. //E*O*F ./1984/anonymous.c//
  66.  
  67. echo x - ./1984/anonymous.hint
  68. sed -e 's/^X//' > "./1984/anonymous.hint" << '//E*O*F ./1984/anonymous.hint//'
  69. XAnonymous entry: <?!?> Dishonorable mention
  70. X
  71. XThe author was too embarrassed that he/she could write such trash, so I
  72. Xpromised to protect the identity.  I will say that the author of this
  73. Xprogram has a well known connection with the C programming language.
  74. X
  75. XThis program is a unique variation on the age old "Hello, world"
  76. Xprogram.  What reads like a read my be written like a write!
  77. //E*O*F ./1984/anonymous.hint//
  78.  
  79. echo x - ./1984/decot.c
  80. sed -e 's/^X//' > "./1984/decot.c" << '//E*O*F ./1984/decot.c//'
  81. X#define x =
  82. X#define double(a,b) int
  83. X#define char k['a']
  84. X#define union static struct
  85. X
  86. Xextern int floor;
  87. Xdouble (x1, y1) b,
  88. Xchar x {sizeof(
  89. X    double(%s,%D)(*)())
  90. X,};
  91. Xstruct tag{int x0,*xO;}
  92. X
  93. X*main(i, dup, signal) {
  94. X{
  95. X  for(signal=0;*k *x * __FILE__ *i;) do {
  96. X   (printf(&*"'\",x);    /*\n\\", (*((double(tag,u)(*)())&floor))(i)));
  97. X    goto _0;
  98. X
  99. X_O: while (!(char <<x - dup)) {    /*/*\*/
  100. X    union tag u x{4};
  101. X  }
  102. X}
  103. X
  104. X
  105. Xwhile(b x 3, i); {
  106. Xchar x b,i;
  107. X  _0:if(b&&k+
  108. X  sin(signal)        / *    ((main) (b)-> xO));/*}
  109. X  ;
  110. X}
  111. X
  112. X*/}}}
  113. //E*O*F ./1984/decot.c//
  114.  
  115. echo x - ./1984/decot.hint
  116. sed -e 's/^X//' > "./1984/decot.hint" << '//E*O*F ./1984/decot.hint//'
  117. XSecond place award: <hpda!hpdsd!decot> Dave Decot
  118. X
  119. XCompile with:
  120. X
  121. X    cc decot.c -o decot -lm
  122. X
  123. XNOTE: Some new compilers disliked line 15 of the source, so we changed it from:
  124. X  for(signal=0;*k * x * __FILE__ *i;) do {
  125. Xto:
  126. X  for(signal=0;*k *x * __FILE__ *i;) do {
  127. X
  128. XThis program prints out a string of garbage.
  129. X
  130. XThe judges also offer this one comment: understand comments!
  131. //E*O*F ./1984/decot.hint//
  132.  
  133. echo x - ./1984/laman.c
  134. sed -e 's/^X//' > "./1984/laman.c" << '//E*O*F ./1984/laman.c//'
  135. Xa[900];        b;c;d=1        ;e=1;f;        g;h;O;        main(k,
  136. Xl)char*        *l;{g=        atoi(*        ++l);        for(k=
  137. X0;k*k<        g;b=k        ++>>1)        ;for(h=        0;h*h<=
  138. Xg;++h);        --h;c=(        (h+=g>h        *(h+1))        -1)>>1;
  139. Xwhile(d        <=g){        ++O;for        (f=0;f<        O&&d<=g
  140. X;++f)a[        b<<5|c]        =d++,b+=    e;for(        f=0;f<O
  141. X&&d<=g;        ++f)a[b        <<5|c]=        d++,c+=        e;e= -e
  142. X;}for(c        =0;c<h;        ++c){        for(b=0        ;b<k;++
  143. Xb){if(b        <k/2)a[        b<<5|c]        ^=a[(k        -(b+1))
  144. X<<5|c]^=    a[b<<5        |c]^=a[        (k-(b+1        ))<<5|c]
  145. X;printf(    a[b<<5|c    ]?"%-4d"    :"    "        ,a[b<<5
  146. X|c]);}        putchar(    '\n');}}    /*Mike        Laman*/
  147. //E*O*F ./1984/laman.c//
  148.  
  149. echo x - ./1984/laman.hint
  150. sed -e 's/^X//' > "./1984/laman.hint" << '//E*O*F ./1984/laman.hint//'
  151. XThird place: <sdcsvax!laman> Mike Laman
  152. X
  153. XNOTE: Some new compilers dislike lines 6 and 10 of the source, so we changed
  154. Xthen from:
  155. X;++f)a[        b<<5|c]        =d++,b+        =e;for(        f=0;f<O
  156. X<<5|c]^        =a[b<<5        |c]^=a[        (k-(b+1        ))<<5|c]
  157. Xto:
  158. X;++f)a[        b<<5|c]        =d++,b+=    e;for(        f=0;f<O
  159. X<<5|c]^=    a[b<<5        |c]^=a[        (k-(b+1        ))<<5|c]
  160. X
  161. X
  162. XI hope you have the C beautifier! The program accepts ONE positive
  163. Xargument.  Seeing is believing, so try things like:
  164. X
  165. X    laman 4
  166. X    laman 9
  167. X    laman 16
  168. X
  169. XThis code should run you in circles.
  170. //E*O*F ./1984/laman.hint//
  171.  
  172. echo x - ./1984/mullender.c
  173. sed -e 's/^X//' > "./1984/mullender.c" << '//E*O*F ./1984/mullender.c//'
  174. Xshort main[] = {
  175. X    277, 04735, -4129, 25, 0, 477, 1019, 0xbef, 0, 12800,
  176. X    -113, 21119, 0x52d7, -1006, -7151, 0, 0x4bc, 020004,
  177. X    14880, 10541, 2056, 04010, 4548, 3044, -6716, 0x9,
  178. X    4407, 6, 5568, 1, -30460, 0, 0x9, 5570, 512, -30419,
  179. X    0x7e82, 0760, 6, 0, 4, 02400, 15, 0, 4, 1280, 4, 0,
  180. X    4, 0, 0, 0, 0x8, 0, 4, 0, ',', 0, 12, 0, 4, 0, '#',
  181. X    0, 020, 0, 4, 0, 30, 0, 026, 0, 0x6176, 120, 25712,
  182. X    'p', 072163, 'r', 29303, 29801, 'e'
  183. X};
  184. //E*O*F ./1984/mullender.c//
  185.  
  186. echo x - ./1984/mullender.hint
  187. sed -e 's/^X//' > "./1984/mullender.hint" << '//E*O*F ./1984/mullender.hint//'
  188. XThe Grand Prize: <vu44!{sjoerd,cogito}> Sjoerd Mullender & Robbert van Renesse
  189. X
  190. XWithout question, this C program is the most obfuscated C program that
  191. Xhas ever been received!  Like all great contest entries, they result
  192. Xin a change of rules for the following year.  To prevent a flood of
  193. Xsimilar programs, we requested that programs be non machine specific.
  194. X
  195. XThis program was selected for the 1987 t-shirt collection.
  196. X
  197. XNOTE: If your machine is not a Vax-11 or pdp-11, this program will
  198. X      not execute correctly.  In later years, machine dependent
  199. X      code was discouraged.
  200. X
  201. XThe C startup routine (via crt0.o) transfers control to a location
  202. Xnamed main.  In this case, main just happens to be in the data area.
  203. XThe array of shorts, which has been further obfuscated by use of
  204. Xdifferent data types, just happens to form a meaningful set of PDP-11
  205. Xinstructions.  Not only that, Vax-11's can run this program due to
  206. XPDP-11 emulation mode!  (you call that portable?)  This small program
  207. Xmakes direct calls to the write() Unix system call to produce a
  208. Xmessage on the screen.  Can you guess what is printed?  We knew you
  209. Xcouldn't!  :-)
  210. //E*O*F ./1984/mullender.hint//
  211.  
  212. echo x - ./1984/rules
  213. sed -e 's/^X//' > "./1984/rules" << '//E*O*F ./1984/rules//'
  214. XThe 1984 rules were never kept, unless someone has a good archive out there!
  215. X
  216. XWARNING: The rules and mailing address for the contest change from year
  217. X         to year.  Be sure that you consult the current set of rules
  218. X     before submitting entries.
  219. //E*O*F ./1984/rules//
  220.  
  221. echo Possible errors detected by \'wc\' [hopefully none]:
  222. temp=/tmp/shar$$
  223. trap "rm -f $temp; exit" 0 1 2 3 15
  224. cat > $temp <<\!!!
  225.      25     55    331 Makefile
  226.       7     63    385 README
  227.       2      4    123 anonymous.c
  228.       8     66    383 anonymous.hint
  229.      32     77    509 decot.c
  230.      14     61    369 decot.hint
  231.      12     62    510 laman.c
  232.      19     76    497 laman.hint
  233.      10     86    431 mullender.c
  234.      22    187   1134 mullender.hint
  235.       5     41    248 rules
  236.     156    778   4920 total
  237. !!!
  238. 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 -
  239. exit 0
  240.  
  241.