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

  1. Subject:  v15i107:  International Obfuscated C Code Contest, Part03/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 107
  8. Archive-name: ioccc/part03
  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 x - ./1984/Makefile
  20. sed -e 's/^X//' > "./1984/Makefile" << '//E*O*F ./1984/Makefile//'
  21. X# %W% %G% %U%
  22. X#
  23. X# 1984 makefile
  24. X
  25. XSHELL=/bin/sh
  26. XWINNERS=anonymous laman decot mullender
  27. X
  28. Xall: ${WINNERS}
  29. X
  30. Xanonymous: anonymous.c
  31. X    cc $? -o $@
  32. Xlaman: laman.c
  33. X    cc $? -o $@
  34. Xdecot: decot.c
  35. X    cc $? -o $@ -lm
  36. Xmullender: mullender.c
  37. X    cc $? -o $@
  38. X
  39. Xclean:
  40. X    rm -f core
  41. Xclobber: clean
  42. X    rm -f ${WINNERS}
  43. X
  44. Xinstall: all
  45. X    @echo are you kidding'??'
  46. //E*O*F ./1984/Makefile//
  47.  
  48. echo x - ./1984/README
  49. sed -e 's/^X//' > "./1984/README" << '//E*O*F ./1984/README//'
  50. XIn 1984, the first contest was held.  The name of the contest was simply
  51. X``Obfuscated C Code Contest''.
  52. X
  53. XRestrictions against machine dependent code were not in the rules in 1984.
  54. XThe source file size restriction was only 512 bytes.  Rules and results
  55. Xwere posted to net.lang.c and net.unix-wizards.
  56. //E*O*F ./1984/README//
  57.  
  58. echo x - ./1984/anonymous.c
  59. sed -e 's/^X//' > "./1984/anonymous.c" << '//E*O*F ./1984/anonymous.c//'
  60. Xint i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
  61. Xo, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);}
  62. //E*O*F ./1984/anonymous.c//
  63.  
  64. echo x - ./1984/anonymous.hint
  65. sed -e 's/^X//' > "./1984/anonymous.hint" << '//E*O*F ./1984/anonymous.hint//'
  66. XAnonymous entry: <?!?> Dishonorable mention
  67. X
  68. XThe author was too embarrassed that he/she could write such trash, so I
  69. Xpromised to protect their identity.  I will say that the author of this
  70. Xprogram has a well known connection with the C programming language.
  71. X
  72. XThis program is a unique variation on the age old "Hello, world"
  73. Xprogram.  What reads like a read may be written like a write!
  74. //E*O*F ./1984/anonymous.hint//
  75.  
  76. echo x - ./1984/decot.c
  77. sed -e 's/^X//' > "./1984/decot.c" << '//E*O*F ./1984/decot.c//'
  78. X#define x =
  79. X#define double(a,b) int
  80. X#define char k['a']
  81. X#define union static struct
  82. X
  83. Xextern int floor;
  84. Xdouble (x1, y1) b,
  85. Xchar x {sizeof(
  86. X    double(%s,%D)(*)())
  87. X,};
  88. Xstruct tag{int x0,*xO;}
  89. X
  90. X*main(i, dup, signal) {
  91. X{
  92. X  for(signal=0;*k *x * __FILE__ *i;) do {
  93. X   (printf(&*"'\",x);    /*\n\\", (*((double(tag,u)(*)())&floor))(i)));
  94. X    goto _0;
  95. X
  96. X_O: while (!(char <<x - dup)) {    /*/*\*/
  97. X    union tag u x{4};
  98. X  }
  99. X}
  100. X
  101. X
  102. Xwhile(b x 3, i); {
  103. Xchar x b,i;
  104. X  _0:if(b&&k+
  105. X  sin(signal)        / *    ((main) (b)-> xO));/*}
  106. X  ;
  107. X}
  108. X
  109. X*/}}}
  110. //E*O*F ./1984/decot.c//
  111.  
  112. echo x - ./1984/decot.hint
  113. sed -e 's/^X//' > "./1984/decot.hint" << '//E*O*F ./1984/decot.hint//'
  114. XSecond place award: <hpda!hpdsd!decot> Dave Decot
  115. X
  116. XCompile with:
  117. X
  118. X    cc decot.c -o decot -lm
  119. X
  120. XNOTE: Some new compilers disliked line 15 of the source, so we changed it from:
  121. X
  122. X  for(signal=0;*k * x * __FILE__ *i;) do {
  123. X
  124. Xto:
  125. X
  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. Xthem from:
  155. X
  156. X;++f)a[        b<<5|c]        =d++,b+        =e;for(        f=0;f<O
  157. X<<5|c]^        =a[b<<5        |c]^=a[        (k-(b+1        ))<<5|c]
  158. X
  159. Xto:
  160. X
  161. X;++f)a[        b<<5|c]        =d++,b+=    e;for(        f=0;f<O
  162. X<<5|c]^=    a[b<<5        |c]^=a[        (k-(b+1        ))<<5|c]
  163. X
  164. XI hope you have the C beautifier! The program accepts ONE positive
  165. Xargument.  Seeing is believing, so try things like:
  166. X
  167. X    laman 4
  168. X    laman 9
  169. X    laman 16
  170. X
  171. XThis code should run you in circles.
  172. //E*O*F ./1984/laman.hint//
  173.  
  174. echo x - ./1984/mullender.c
  175. sed -e 's/^X//' > "./1984/mullender.c" << '//E*O*F ./1984/mullender.c//'
  176. Xshort main[] = {
  177. X    277, 04735, -4129, 25, 0, 477, 1019, 0xbef, 0, 12800,
  178. X    -113, 21119, 0x52d7, -1006, -7151, 0, 0x4bc, 020004,
  179. X    14880, 10541, 2056, 04010, 4548, 3044, -6716, 0x9,
  180. X    4407, 6, 5568, 1, -30460, 0, 0x9, 5570, 512, -30419,
  181. X    0x7e82, 0760, 6, 0, 4, 02400, 15, 0, 4, 1280, 4, 0,
  182. X    4, 0, 0, 0, 0x8, 0, 4, 0, ',', 0, 12, 0, 4, 0, '#',
  183. X    0, 020, 0, 4, 0, 30, 0, 026, 0, 0x6176, 120, 25712,
  184. X    'p', 072163, 'r', 29303, 29801, 'e'
  185. X};
  186. //E*O*F ./1984/mullender.c//
  187.  
  188. echo x - ./1984/mullender.hint
  189. sed -e 's/^X//' > "./1984/mullender.hint" << '//E*O*F ./1984/mullender.hint//'
  190. XThe Grand Prize: <vu44!{sjoerd,cogito}> Sjoerd Mullender & Robbert van Renesse
  191. X
  192. XWithout question, this C program is the most obfuscated C program that
  193. Xhas ever been received!  Like all great contest entries, they result
  194. Xin a change of rules for the following year.  To prevent a flood of
  195. Xsimilar programs, we requested that programs be non machine specific.
  196. X
  197. XThis program was selected for the 1987 t-shirt collection.
  198. X
  199. XNOTE: If your machine is not a Vax-11 or pdp-11, this program will
  200. X      not execute correctly.  In later years, machine dependent
  201. X      code was discouraged.
  202. X
  203. XThe C startup routine (via crt0.o) transfers control to a location
  204. Xnamed main.  In this case, main just happens to be in the data area.
  205. XThe array of shorts, which has been further obfuscated by use of
  206. Xdifferent data types, just happens to form a meaningful set of PDP-11
  207. Xand Vax instructions.  The first word is a PDP-11 branch instruction
  208. Xthat branches to the rest of the PDP code.  On the Vax main is called with
  209. Xthe calls instruction which uses the first word of the subroutine as a
  210. Xmask of registers to be saved.  So on the Vax the first word can be anything.
  211. XThe real Vax code starts with the second word.  This small program
  212. Xmakes direct calls to the write() Unix system call to produce a
  213. Xmessage on the screen.  Can you guess what is printed?  We knew you
  214. Xcouldn't!  :-)
  215. //E*O*F ./1984/mullender.hint//
  216.  
  217. echo x - ./1984/rules
  218. sed -e 's/^X//' > "./1984/rules" << '//E*O*F ./1984/rules//'
  219. XI'm sure you have all seen gross, or down right structurally obscene C
  220. Xsource code before.  Some people who deal with various parts of the
  221. XUN*X  source wonder if some folks try rather hard to produce such
  222. Xdown right smelly code.
  223. X
  224. XNow you have the chance to compete with the worst C hackers around
  225. Xby sending in your own obfuscated C program.  Just follow the contest
  226. Xrules below:
  227. X        1) the source file must be no more than 512 bytes long
  228. X
  229. X        2) mail your source to:    hplabs!nsc!chongo
  230. X           no later than April 11, 1984.  entries posted to
  231. X           the net will NOT be accepted.  please give your
  232. X           letter the subject of: obfuscated C code contest.
  233. X
  234. X        3) winning entries will be posted to net.lang.c after
  235. X           April 12, 1894.  (thats the prize folks)
  236. X
  237. X        4) indicate your net address in the text of your
  238. X           entry, this will be used to give credit unless
  239. X           you indicate that you want to remain anonymous.
  240. X
  241. X        5) entries must be of original work.  (dont send anything
  242. X           that might upset Big Brother Bell)  all entries are
  243. X           public domain.  (who would want to own them anyway?!)
  244. X
  245. XEntries will be judged for: violations of structured programming, non-clarity,
  246. Xand use of "by the K&R book" C. (use of local mods to C are not encouraged)
  247. Xextra credit if they can be compiled using the 4.2BSD C compiler on our VAX 780,
  248. Xbut dont let the lack of a 780 or 4.2 discourage you!
  249. X
  250. Xchongo <flames about the contest will be kindly #ifdef'ed out> /\CC/\
  251. X
  252. XUN*X is a trademark of Usenet Hackers Anonymous
  253. X
  254. XWARNING: The rules and mailing address for the contest change from year
  255. X         to year.  Be sure that you consult the current set of rules
  256. X     before submitting entries.
  257. //E*O*F ./1984/rules//
  258.  
  259. echo Possible errors detected by \'wc\' [hopefully none]:
  260. temp=/tmp/shar$$
  261. trap "rm -f $temp; exit" 0 1 2 3 15
  262. cat > $temp <<\!!!
  263.  25  55  331  Makefile
  264.  6  48  300  README
  265.  2  4  123  anonymous.c
  266.  8  66  386  anonymous.hint
  267.  32  77  509  decot.c
  268.  17  61  372  decot.hint
  269.  12  62  510  laman.c
  270.  21  76  499  laman.hint
  271.  10  86  431  mullender.c
  272.  25  234  1357  mullender.hint
  273.  38  284  1666  rules
  274.  196  1053  6484  total
  275. !!!
  276. 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 -
  277. exit 0
  278.  
  279.