The 21st International Obfuscated C Code Contest(IOCCC) officially launched the winning source code. IOCCC requires contestants to write the most creative and the most obfuscated C codes with the size limited to 4kb and less Work of each participant is impressive. The winners, including one French, one Korean, five Americans, one Belgian, one Israeli, one British, four Japanese and one Chinese.
Here we list some codes:
Seonghoon Kang from Korea- Decodes spelled out numbers
long long n,u,m,b;main(e,r)char **r;{f\
or(;n++||(e=getchar()|32)>=0;b="ynwtsflrabg"[n%=11]-e?b:b*8+
n)for(r=b%64-25;e<47&&b;b/=8)for(n=19;n;n["1+DIY/.K430x9\
G(kC["]-42&255^b||(m+=n>15?n:n>9?m%u*~-u:~(int)r?n+
!(int)r*16:n*16,b=0))u=1ll<<6177%n--*4;printf("%llx\n",m);}
John Tromp from US - Lambda interpreter
Int L[A],m,b,*D=A,
*c,*a=L,C,*U=L,u;s
(_){u--&&s(a=*a);}
char*B,I,O;S(){b=b
--?b:m|read(0,&I,1
)-1;return~I>>b&1;
}k(l,u){for(;l<=u;
U-L<A?*U++=46^l++[
"-,&,,/.--/,:-,'/"
".-,-,,/.-,*,//..,"
]:exit(5));}p(Int*m){
return!*U?*m=S()?U++,!S
()?m[1]=p(++U),2:3:1,p(U)
:S()?U+=2:p(U[1]++),U-m;}x(
c){k(7*!b,9);*U++=b&&S();c&&x
(b);}d(Int*l){--l[1]||d(l[d(*l),
*l=B,B=l,2]);}main(e){for(k(10,33
),a[4]-=m=e-2&7,a[23]=p(U),b=0;;e-2
?e?e-3?s(D=a),C=a [3],++1[a=a[2]],d(
D):c?D=c,c=*D,*D= a,a=D:exit(L[C+1])
:C--<23?C=u+m&1?O =O+O|C&1,9:write(m
||(O=C+28),&O,1)+ 1:(S(),x(0<b++?k(0,
6),U[-5]=96:0)):( D=B?B:calloc(4,X))
?B=*D,*D=c,c=D,D[ 2]=a,a[++D[1]]++,D
[3]=++C+u:exit(6) )e=L[C++],u=L[C];}
Don Yang from US - Encodes text as a C program
#include<stdio.h>
typedef unsigned int _;_ d,b,
#define i(I1,Il,lI)if(Il){lI;}else{I1;}
I[256], n,y,a,r,u,k,o
,L,l[ 256],O,K[
/**/ #define\
q(g) g char\
*C, *Q,c[\
]= "KfW"\
"" "Ww|"\
/* 'UU!\
% NYA!\
*/ "Z}"\
";fRo?JtJaV<x4@*?R?&JV1" ".s"\
"{Fyj2_;khB1xQ5oxm~mS@B|(pa>oRU" "Ro"\
"nB}h@o?)d.X)NSTIUCz7@%",*s[]={c,"#en" "di"\
"f/*}||1;\n__DATA__\40*/\n\n#ifndef\40q\n#d" "ef"\
"ine\x20q\n#include<stdio.h>\ntypedef\40unsign" "e"\
"d\x20int\x20_;_\x20K[]={\n#include\40__FILE__\n#u" "n"\
"def q","0},L,O,l[256],I[256],n,y,a,r,u,k,o;"#g"char" "*"\
"S,s[]=\"",c,c,"\";int main(){X();for(S=s+*K;*S>37;){for" "(o"\
"=0;o<5;o++)r=r*85+(83+*S++)%89;r","^=*x();for(o=0;o<4;o++" ")"\
"{s[O++]=r&255;r>>=8;}}return!fwrite(s,O-*S%5,1,stdout);}\n" "#"\
"endif",c},S[256]="#ifdef/*\n'true'\40or\40q{\nexec\40head\40" "-"\
"8\40$0\n};for(open$O,$0;<$O>;print\40if$f){$f|=/^$/;}q{*/q",/* */z;
256];q(_*x(){if(!L--){y+=++a;for(o=0;o<256;y=l[o++]=I[255&(k>>10 )]+u
){n^=(o&1)?n>>(( o& 2)?16:6):n<<((o&2)?2:13);u=I[o];k=I[o]=I[255& (u>>
2)]+(n+=I[(o+128) & 255]) +y;}L=255;}return&l[L];}_*X(){for(O=0 ;256
>O;I[O++]=0);for(O = 0; sizeof(K)/sizeof( _)> O;O++)I[O&255] ^=K[
O];for(n=y=a=L=O=0 ;O<1<<24;++ O)x( );r=O=0x0; return&O;})int/*^^*/ main
(int p,char**P){FILE* Z=fopen(p> (+ 1)?P[01 ] :"/dev/urandom", "rb"
);i(;,Z,O=fread(K,256 ,4,Z);/*P */ fclose(Z))X();for(p=b=d =O=
0;O<256;K[O++]=0)*K=+ 86;for(O =1;12> O;K[O++]=*x());X(); for
(C=Q=S;r-8;){i(*C++=34, (r-4&&r -5)||C- S ,;)z=Q[p++];i(;,z !=
32||r-3,i(i(C+=sprintf(( C), "%uU" ",",K[b++]);i(d=1;C =S
;i(d=02,b-12,;),b%6,;),r-1 ,i(b= fread(c,1,4,stdin);i (p
=O=0,b,for(d=O=0;O<04;O++)d +=(c[O]&255)<<(8*O);d ^=
*x();for(p=5;p;c[--p]=O<32?O+ 95:O+6){O=d%85;d/=85;} O=
5)i(d=0,b<4,c[O++]=b?b-1?b-2?36: 37:33:35 ;d=2)c[O]=0,r-4,i(i (d= 2
|d,C!=S+6,*C++=(*x()%34)+93;p--),r -5,*s= C;d|=2) )),z ,i(*C++ =92 ,
z-63||C [-1]-63||C>S+76,;)*C++=z))i( ;,d>1,d= d-2 ;Q=s[r] ;i( ;
,r<3|| r>5,d=1;i(;,r-1, *C=0)C=S) i(;, r-4, p=0)++ r) i(*(C++ )=
34,r <4||r>5|| C<S+ 78,;)i (*C++=0;d=1; C=S ,r<3 || r>
5 ||C<S+ 79,; )i(;,d, puts (
S); d=0 )} return
0;}
Qiming HOU from China - Syntax highlighter
#include <stdio.h>
#include <string.h>
#define Q(B,q,b) s=j[B]; e=*s; *s=0; printf(q,b,b,b); *s=e; H=s;
#define W(a,b) r[O].c=a,r[O].f=b,O++
#define X(B) { int y=A; B; A=y; }
#define R return
#define M 1<<18
#define If char
#define fi "%s"
#define IF for
#define FI "r"
#define long
#define do
typedef struct { int c,(*f)(); If*t,*h; } T; T*a,*r; int I[M],c[M]={'\0'} ,n
,N,i do,p ; char*s,*H,*z[M],f[M],o[M ],*_ [M ],**l =_ ,e ; int O=6,A='\5',x=5
,y='\0',g=2;k(p){a[p+2].h=H; R p+2; } S(p){ a[I[n++]=a[p].c>>8].h=H; return ~
p-'\1';}J(p){R~a[p].c>>8;}C(){ A=O; W(O+1<<8,J); } B(p){ c[g+'\1']=O;C(do);c[
g+='\2']='\0';R 1;}h(p){ Z(p); r[O-3].c+=256; R 1; } V(){ *I=n='\1'; for(; *a
->t; do ){do a->t=a[1].h=s; IF(i=N=0; i<n; i++){ p=I[i]; H=a[p ]do.h;for(; p>
0&&a[do p].t-s;){a[p].h&&a[p].h-H>0&&(H=a[p].h);e=a[p].c;a[p].t=s;p=do e&&e-*
s?p+'\1':~a[p].f(p);}p<0&&(I[N++]=~p);}n=N;s++;}}U(p){X(D(p)); c[g+='\2']=O ;
return Z(p); } d(p){ C(); W(0,k); W(0,J); R 1 ; } q (p ){ C (); X (for(;*++s
!='\"'; )F(p); ); return 1; } Z(p){ r[A].c =O +1 <<'\10'; r [A ].f =do J ;
{ int y=A; W(O+*"\2void"<<8 ,J ); C (); W (y*1 + "signed" [ 6 ] +1 <<'\10',S
do )do ; } return '\1';} F(p){ R*s?C(),*s==*"\\&" long&&*++do s do ==
'n'&&(*do s =*"\nextern"),W (*s ,k ),W ( (4+5)["volatile*"],J),'\1' :'\0';
} E(p){ int V =*"\0float"; C (); X(s++;V=(*s++==*"^double");c[g+=long 2]long=
0;s-=!V;for(; *s!="]int"[0];s++){e=*s;s+=2*(s[1]==*"-for" ); s=s;for(;e<=do*s
; e++){long C(); V?W(e,J):(W(e,k),W(0,J),U(p)); } } d(p); V||(W('\0',J)); D(p
); ); return 1; } j(p){ If*r=z[a[p].c>>8],**D=l; IF(; l-_&&l [-*"\2$"]-H>=0&&
(l [-*"\1do"]!=s||l[-2]!=H||r-l[-3]<=0); )l -=3 ; l ==_ ||l [-*"\1if("] -H <=
0 * !"\0auto"?*l++=r,*l++=H,*l++=s,l:(l=D); R 0; } L(p){ W(A +*"\1for"<<8,S);
R 1+*"\0while"; } Y (p ){ z [y ]do=++do s do; s=strchr (s ,*"\nshort");W(y++
<< *"\btypedef",j); r [x ].c =O long<<'\10'; r [x ].f =S ; do x =O do ; C (
); return '\1'; } D (p ){ r [c [g ]].c =O <<8 ; c [g ]='\0';A=c[--do g]; --
g; return *"\1switch"; } T b [ 12 + (M) + 321 ]={ {'\0','\0',"-"},{'*',Z } ,
{ '+',L},{ '\"',q} ,{ '['long ,E } ,{ 70-94+ do '@'do ,B } ,{ ')',D } do,{124
,U},
{46,d}
,{32
,Y},
{63,h},{
0,F},{0,0, "Make a contract with me"
},{'('*32,S}
,{'\0',k},{0,J, "and become a magical girl! "
},{'@'*4,J},{0,J
},{'@',0} };main
( int B,If**j){ a
=b;if(B>=3){s=f;r=
b+'\14'; f[fread(f,1,
M,fopen(j[1],FI))]=0;
V(); W(0,J); IF(i=0;
i<y;i++){*strchr(z[i
],10)=0;}o[fread(s
=o,1,M,fopen(j[2
],FI))]=0; a=r
;V(); H=o;
IF( j=_;j!=l; j+=3 ){Q
(1,fi,H);Q(2,*j,j[1]);
}printf(fi,H);}R 0;}
Best use of cocoa - Bronze award
Daniel Vik from US - Steganography
#include <stdio.h>
#include <string.h>
#include "zlib.h"
int
i,j,k,l
,m,n,Q,W,H,
B,Z,Y,X,O=1<<24
; char*A[999],x[
1<<24],z[1<<24],
s[1<<24],t[2<<24
],w[2<<24],*E;
uLong N; FILE
*f ; int main(
int c,char**v){
unsigned char**V
=(unsigned char
**)v; for(m=0;
c==-11&&m<H
; m++, (*v)
+=m%3==0&&
(B&4) ,V[4]
++) n=m%W,
l=n?l:*(*V
)++,*V[4]=
!(B&2)&&
n%3?V[4
][-1]:
(i=
n<3?0:
V[4][-3],j
=m/W?V[4][-W
]:0,Z=k=!(m/W)
||n<3?0:V[4][-3
-W],*(*V)+++(l?l
-1?l-2?l-3?(X=j-
Z,X=X>0?X:-X,Y=i-
Z,Y=Y>0?Y:-Y,Z=i+j
-Z-Z,Z=Z>0?Z:-Z,X>Y
||X>Z?Y >Z?k:j:i):
(i+j) /2:j:i:0));
for( E=t+O; *v-1[v]
&&c== -16; ++*v)n=**v,n
-62? n-60?n -91?n-93||!
m|| !*E?* v:(*v=A[--m+9
]): (A[9+ m++]=*v-1):--E
:++ E ,n-43?n-44?n-45?
n- 46 ?0:putchar(*E):--*E
:(* E= getchar()):++*E; for(;
7< -c &&11>-c&&*v!=5[v]; ++*v)
**V =c +8?c+9?*V[1]++<<6|56:**V|~3
&*V [1] ++:**V>>6; for(; m<n*2; m+=2)c
+18? c+19 ?0:(V[1][m/8]+=(*V[0] ++-56)>>m
%8) :(* V[1]++=V[0][m/8]<<m%8 ); return !
c?c: c>0 ?n=main(-7,(Q=**++v,N=0x49444154,*A
=s+4, main (-128 ,A),A[1]=*++v,A [4]=z,*A=x,A))
,c=A[ 6] -x- 12,Q-101?main(-19,(main(-10,(A[5]=
t+n, *A= t, A[1]=z,A)),*A=t,A [1]=w,A)):main(-9,(
main( -8 ,((n=main(-7,(A[1] =*++v,A[4]=t,*A=s+4,
A)))<0 ? main (-18,(n= -n,*A=s,A[1]=t,A)):0,A[
5]=t+n ,*A= t,A) ),*A=t, A[1]=z,A)),98-Q?E=memcmp(
w,s,4 )? n+= main(-22 ,(*A=z,A[1 ]=t,A[2]=t+n
,A)), N=n= main (-23,(*A=t, A[1]=z,A[2 ]=z+n,A)),
memmove (x+ c+n+12 ,x+c,12),memcpy(x+c+8,t, n),main(-128
,(*A= x+c +4,A)) ,N=crc32( 0,memcpy(x +c+4,s,4),n
+4), main (-128, (*A=x+c+ n+12,A)),n +=c+24,x:(n=
strlen (w +4),w+4),fwrite(E ,1,n,stdout): main(-16,(*A=w,
A[1]=w +H, A)) :-c>31?main(c+=32 ,(*--*v=N,N>>=8,v)):-++c<4?(-c)
[*V]+256*main(c,v ):c+23?c+22?c+21?c+6?c+5?c+4?0:(N=O,uncompress(*v=s+4,&N
,v[3],v[2]-v[3] ),main(c-7,v),H):(n-=l=main(-4,v)+12,5[*v]-68?(v[6]=(*v+=
l)):(memcpy(v[2],*v+8,l-12),v[2]+=l-12,memmove(*v,*v+l,n)),main(c-(n>8),v))
:(n= main(-24,v),main(-4,v)-0x89504e47?-H:main(c,(*v+=16,W=main(-4,v)*3,*v
+= 4,H=main(-4,v)*W,B=(*v)[5],(*v)[5]=2,N=crc32(0,*v- 8,17),*v+=
13 ,main(-128,v),v[3]=v[2]=w+O,*v-=21,v))):(* *v=0,memcpy
(++*v ,v[1],W),*v+=W,v[1]+=W, 1+main((v[1]
!=v[2]) *--c,v)):(N=O
,compress(*v,&N, v[1],v[2]-v[1]),N):(f=
fopen(v[1],"rb"))?fclose((n=fread(*v,1,O,f),f)),
n[*v]=0,n:(strcpy(*v,v[1]),0); }
Most elementary use of C - Silver award
Tsukasa Hamano from Japan - PDF with little dancing men
#define \
D(s)"<<"#s">>"
#define q(s)p(#s)
#define S " endobj "
#define Y "endstream"S
#include <stdio.h>
#define o(s) b[s]=_;\
p("%u 0 obj",s);
#define E for (c=d;c < 123;c++)
#define DANCE "trailer "D\
(/Root 3 0 R /Size %d) "\nstartxref %u %%%%EOF\n*/"
#define p(s, ...) _+=printf(s, ##__VA_ARGS__)
#define C "<</Type/Page /Parent %d %d R /Resources <<\
/ProcSet[ /PDF/Text]/Font <</U"D(/Subtype/Type1/BaseFont\
/Courier) " /T<</Subtype/Type3 /FontBBox[0 0 10 10]/FontMatrix[\
%f 0 0 %f 0 0]/FirstChar %d/LastChar %d/Encoding<</Differences[%d"
typedef int N;typedef char*Nyan;typedef char A;N a,b[64],d=65,_,v
[32]={84,0,64,282,90,74,330,85,93,173,167,176,80,208,81,13,7,87
,160,346,32,128,170,218,16,26}; Nyan w[]={"+*-(,&-&","+*,&-&"
,"+*.&/&","+*/*/+","+*())'('" ,"+**&)&","+*(&'&","+*'*'+",
"","+,./","+,-,./","+--,+*" ,"","+,(/","+,),(/","+-),+*"
,"10 0 d0 ","8 7 2 2 re " ,"+*+.'`'@'mi +/+/(mi"};Nyan
nyan(Nyan _,N y,A n){
N g=v[~-y%32];Nyan
s=w[g>>n&3|n*2];
for(a=0;*_=*s++;
a++,_++,*_++=32)
{*_+=*_-32?10:0;
if(a%2&&*_/16==3
){if(g>>8)*_=105-*_;
_++;*_++=32;*_=~-a&&a-13
?108:109;}}return n?n-9?nyan
(_,y,n-2):_:nyan(_+=~y&' '?sprintf
(_,17[w]):0,y,9);}N main(N c){A e[256];
p("/*%%PDF-1.3%%*/")-2;q(#include<stdio.h>\n);
q(#define o *_++&& *_-41\n#define);p(" endstream ");q
(main(){for(;*_++; *_-40?:putchar(o?*_:o?10:41));\n)
;q(#define endobj return 0;}\n);q(typedef int ET;/)
;q(*);o(1)*b=~(p(D (/Length 2 0 R)"stream\n"))
;for(p("BT 12 818" " Td/%c 12 Tf 12 TL%%%c/"
"static char*_=\"" " \\\n",7[v],*v/2);c=
getchar(),~c;c-10? p("/%c 12 Tf(\\%o)"
"Tj",v[~-c%' '<25[ v]&&!~-(~-c/'@')?0
:7],c):(p("()'"))) ;p("%%\";\nET ");*
b-=~_;p(Y"/*");E{a =nyan(e+sprintf(e,
16[w]),c,6)-e;o(c- 59)p(D(/Length %d)
"stream\n%s"Y,a,e) ;}o(2)p(" %u"S,*b);
o(3)p(D(/Pages 4 0 R)S);o(4)p(D(/Count
1/MediaBox[0 0 595 842]/Kids[5 0 R])S)
;o(5)p(C,4,0,6e-2, 6e-2f,d,122,d);E p(
"/%c",~-c/6+~14?c: d);q(]>>/CharProcs<<)
;E if(~-c/6+~14)p( "/%c %d 0 R",c,c+~58);
for(q(>>/Widths[), c=59;--c;p(" 10"));a=p
("]>>>>>>/Contents 1 0 R>>"S);for(p("xref\
0 %d ",--d);c<d;p("%010u\
%05d n ",*(c+++b),NULL));
return!(p(DANCE,d,a));}
Balanced use of obfuscation - Gold award
Adar Zeitak from Isarel - Brace matcher
#include <stdio.h>
#include <stdlib.h>
#define s(_)sizeof(_)
#define n void*
#define z(_)_,_,_
#define x (s*)__
#define y (s*)_
#define h C(y,y)
#define o &d
#define t() (p)
#define w(_)_,_
typedef n (*(*(*(*p)(n,n))(n,n))(n,n))(n,n);
typedef struct s { struct s* a ; struct s* UNUSED; } s;
typedef struct t { struct s* UNUSED; struct s* a ; } *t;
n __(n _,n __) { return _;}n _(n _,n __){return __; }
typedef unsigned char e;
#define _(_)((*_).a)
s*
w,
a={x ,x},
b={x ,y},
c={y,x},d={y,y};s l[]={&b,&d,w (w(w(w(w(w(&d)))))),w(&d),&c,&d,w(w(w(
&d))),&c,w(&b),&d,&a,z(&d),z(w (w(w(w(w(&d)))))),&b,&b,w(&d),&a,&b,w(&
d), z(w
(w( w(w
(&d))))),w(w(w(&d))), &b,&c,&d, &d,&a,&c ,w(w(&d)), &c,z(&b) ,w(&d),w(&a)
};s* C(s* a, s* b) {s* _=malloc(s(s));_(_)=a;_((t)_)=b;return _;}e k2=s(l
);p f(p
a,p b)
{ e k;s d;p v,r, q,i,C,c,u,g,m=t( )
_ ( _(_(w)));C=t() _(_(&l[fread(&k,s(e )
,s ( e),stdin)]));v =C(_,__);d=l[k=(e )
C ( k2,k)];c=(u=a( b,_),i=(t()_((t )
_ ( _(w))))(_,_(_(o)) ),(a(_(_((t)o)),(t( )
_ ( _((t)o)))(_,__) ))(b(_((t)_((t)o) )
, ( t()_((t)_((t)o))) (_,__)),_));{p a=t( )
_ ( (t)_(o));{p b= C(_,i(u(_,__),_) )
; { p u=C(_,(t()_(_(o) ))(_,__));_(_(_(w)) )
= ( s*)i(__,_(_( _(w))));r=b(m(c,_ )
,C ( m(_,(t()_(( t)_(_(w))))(_,__) )
, ( f)));v=b(_,v);i =b(a(_,__),_);g=(b )
( a(m(c(_,__),__ ),_),_);q=u(_((t )
_ ( o)),_)((t()_( (t)_(_(w))))((t( )
_ ( _((t)o)))(_(_((t )_(w))),(t()_(_((t )
_ ( w))))(_,__))( _,__),_)(_,__),_ )
;_ ( _((t)_(w))) = (s*)u(_((t)_(o)),_ )
( (t()_((t)_(_(w)))) (_,__),_)(_(_((t)o) )
,_ ( _((t)_(w))));} }_((t)_(_(w)))=(s* )
q ( a=(t()_((t)_(_(w))) )(_,__),_((t)_(_(w))) )
; fwrite((k=k,&k2) ,s(e),u(_,g)(s(e )
, ( e)s(s[s(s[s(s[s (s)])])])),stdout )
; fwrite((k2=k,&k) ,s(e),u(__,g)(s(e )
, ( e)s(s[s(s[s(s[s (s)])])])),stdout )
;_ ( _(_((t)w)))=(s*) u((t()_(_(_((t)w))) )
( _,__),_(_(_((t)w ))));_(_((t)_(w)) )
= ( s*)q(a(_(_((t) o)),_(_((t)_(w))) )
,_ ( _((t)_(w))));} _((t)_(_((t)w)))=(s* )
( t()_(_(_((t)w))) )(_((t)_(_((t)w)) )
,u ( (t()_((t)_(_(( t)w))))(_,__),_((t )
_ ( _((t)w)))));g =u((q=u(C(__,(t( )
_ ( _(_((t)w))))(_((t )_(_((t)w))),_)),_) )
( _,__),g);v=g( __,i(u(_,i(f,_) )
( _(_((t)o)),_( (t)_((t)o))),v) )
,r= q(_
,g( f,i
(v(f,(_(_(_(w)))=(s*)m,_)),r)));return q(_,v)(r(g(__,a),g(__,b)),r);}
int main
(){w=C(C(h,h),C(h,h));return printf((e*)f(_,_)("OK\n","\n ^ Error\n"
"" ))
;}
Reference : http://www.guokr.com/post/364973/