#define COPY \
{ \
*(out++) = *(in++); \
}
#define COPY2 \
{ \
*(out++) = *((char *) r6); \
r6++; \
}
int load(unsigned char **in, unsigned int *r11)
{
/*~~~~*/
int ret;
/*~~~~*/
if(((*r11) & 0x3FFFFFFF) == 0)
{
/
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned char *data = *in;
unsigned int num = (data[0]) + (data[1] << 8) + (data[2] << 16) +
(data[3] << 24); //
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*in) = (*in) + 4;
ret = (num & 0x80000000) ? 1 : 0;
(*r11) = ((*r11) & 0xC0000000) ? num * 2 + 1 : num * 2;
}
else
{
ret = ((*r11) & 0x40000000) ? 1 : 0;
(*r11) = (*r11) << 2;
}
return ret;
}
int sub_4742603C(unsigned char *in, unsigned char *out)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned char *out_save = out;
unsigned int r11 = 0x40000000;
unsigned int r10;
int i;
int j;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
while(1)
{
i = 1;
while(load(&in, &r11))
{
for(j = 0; j < i; j++)
{
COPY;
}
if(r11 & 0x80000000)
{
for(j = 0; j < i; j++)
{
COPY;
}
}
i = i * 2;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int r6 = *(in++);
/*~~~~~~~~~~~~~~~~~~~~~~~~~*/
if(r6 & 0x80)
{
r6 = r6 & (~0x80);
/*~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned int r4 = *(in++);
/*~~~~~~~~~~~~~~~~~~~~~~~~~*/
r6 = r4 + (r6 << 8);
if(r6 == 0) return out - out_save;
else
{
r10 = r6;
r6 = out - r6;
COPY2;
COPY2;
COPY2;
}
}
else
{
if(r6 == 0)
{
// Continue the copy
r6 = r10;
r6 = out - r6;
COPY2;
COPY2;
COPY2;
}
else
{
if(r6 >= 16)
{
r6 = r6 * 2 - 16;
}
r6 = out - r6;
COPY2;
COPY2;
}
}
i = 1;
while(r11 & 0x80000000)
{
for(j = 0; j < i; j++)
{
COPY2;
}
if(load(&in, &r11))
{
for(j = 0; j < i; j++)
{
COPY2;
}
}
i = i * 2;
}
}
}
main(t,_,a)
char *a;
{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a
)&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,
t,"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:t<-50?_==*a ?putchar(a[31]):main(-65,_,a+1):main((*a == '/')+t,_,a\
+1 ):0<t?main ( 2, 2 , "%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}
Seems to be the 1988 winner, look for "xmas.c".
I kind of remember having read about its compression method - sure
some web page tells about it.
G.
That is awesome! Picking that apart was a great exercise in reviewing
my precedence of C operators.
The program generates the very repetitive twelve nights of christmas
song. So the compression method is effectively LZ77, repeating strings
of text. The string in the last two lines is just a substitution code
for the long string in the middle. The string in the middle translated
is:
On the
/first/second/third/fourth/fifth/sixth/seventh/eighth/ninth/tenth/eleventh/twelfth/
day of Christmas my true love gave to me
/twelve drummers drumming, /eleven pipers piping, /ten lords a-leaping,
/nine ladies dancing, /eight maids a-milking, /seven swans a-swimming,
/six geese a-laying, /five gold rings;
/four calling birds, /three french hens, /two turtle doves
and /a partridge in a pear tree.
/
where the slashes are used as markers for emitting the strings.
Mark
Mark
Many thanks for that, Mark!
Phil
--
Any true emperor never needs to wear clothes. -- Devany on r.a.s.f1