Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Identification of a lossless Algorithm

7 views
Skip to first unread message

JohnConnor

unread,
Dec 8, 2009, 8:15:25 PM12/8/09
to
Hi everybody,
I'm actually trying to find what is the algorithm that is used during
the decompression of one file...
It seems to be like LZO but not sure....
Is there somebody that can help me on this?
Thanks
-------------------------------------------

#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;
}
}
}

Gautier write-only

unread,
Dec 10, 2009, 3:51:51 AM12/10/09
to
Too easy! Try the one below. Cheers, G.
__________________
#include <stdio.h>

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);}

JohnConnor

unread,
Dec 10, 2009, 5:47:42 AM12/10/09
to
On 10 déc, 09:51, Gautier write-only <gautier_niou...@hotmail.com>
wrote:

Funny ^^

Message has been deleted

Gautier write-only

unread,
Dec 10, 2009, 7:09:46 PM12/10/09
to
On 10 déc, 20:27, "xtof.pernod":
> I don't remember which year it won the IOCCC, but, did someone
> figured out the underlying algorithm ?

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.

Mark Adler

unread,
Dec 12, 2009, 10:02:08 PM12/12/09
to
On 2009-12-10 00:51:51 -0800, Gautier write-only

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 Adler

unread,
Dec 13, 2009, 5:30:34 AM12/13/09
to
For the curious, I have put a somewhat unobfuscated xmas.c here:

http://zlib.net/xmas-plain.c

Mark

Phil Carmody

unread,
Dec 13, 2009, 8:51:50 AM12/13/09
to
Mark Adler <mad...@alumni.caltech.edu> writes:
> For the curious, I have put a somewhat unobfuscated xmas.c here:
>
> http://zlib.net/xmas-plain.c

Many thanks for that, Mark!

Phil
--
Any true emperor never needs to wear clothes. -- Devany on r.a.s.f1

Message has been deleted
0 new messages