#include "m.h" typedef struct{b32 a, b, c;} p64; p64 H, r; acc m, s, q; te * head, * tail; static uchar rn[16] = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}; static b32 arBy(uchar x){return rn[x>>4] | rn[x&15]<<4;} #if L #define rBy arBy b32 rW(b32 w) {return rBy(w>>24) | rBy(w>>16)<<8 | rBy(w>>8)<<16 | rBy(w)<<24;} #else static uchar rBy(uchar x){return x;} b32 rW(b32 C w){return w;} #endif void rev(char * C b, int C c){int j; if(Ebug) for(j = 0; ja[i], (ss-1-i)*32);} void pbw(b32 C x, int C o){int i; for(i=0; i<32; ++i) if(x>>(31-i) & 1) fprintf(out,"x%d ", o+31-i);} static void pp64(p64 C * C x) {pbw(x->a, 64); pbw(x->b, 32); pbw(x->c, 0);} static void nb(int C a){sla(m, acl); sla(s, acl); sla(q, acl); m[acl-1] += a; if(a) {s[acl-1-B/32] ^= 1; s[acl-2] ^= r.b; s[acl-1] ^= r.c;} if(s[acl-1-B/32]&1){q[acl-1] |= 1; s[acl-1-B/32] ^= 1; s[acl-B/32] ^= H.b; s[acl+1-B/32] ^= H.c;}} static void cl(){zacc(m); zacc(s); zacc(q);} static te * at(){te * p = (te *)core(sizeof(te)*256, "Table"); return p;} static void pacc(b32 C * C v){int i; for(i=0; ia != 1) bitch("Specialized divide!\n"); {int i; for(i=0; i<=B-P; ++i) {sl(q); if(i) sl(n); if(n->a[0]) {q->a[ss-1] |= 1; n->a[0]=0; n->a[1] ^= d->b; n->a[2] ^= d->c;}}} n->a[ss-2] = n->a[1]>>(64-P); n->a[ss-1] = n->a[2]>>(64-P)|n->a[1]<<(P-32); n->a[1] = n->a[2] = 0;} void init(){fprintf(out, "Ebug=%d, L=%d, LM_siz=%ld\n", Ebug, L, (b32)LM_siz); {b32 C o = 1; int C LittleEnd = *(char *)&o; if(LittleEnd^L^Ebug) {fprintf(out, "Code is not designed to work with above" " combination for %s endian machines.\n", LittleEnd?"little":"big"); exit(0);}} finit(); init_FM(); if(B%32) bitch("B must be a multiple of 32.\n"); H.a=1; H.b=0x2748e740; H.c=0x32b20433 << (64-P); {str st, Q; cl(); zstr(&st); st.a[ss-1-B/32] = 1; divide(&st, &Q, &H); if(0){pt("H="); pp64(&H); pt("Q="); pstr(&Q);} r.a = 0; r.b = st.a[ss-2]; r.c = st.a[ss-1];} if(0){pt("r="); pp64(&r);} {head = at(); tail = at(); {int i; for(i=0; i<256; ++i) {cl(); {int j; for(j=0; j<8; ++j) nb(i>>(7-j)&1);} head[rBy(i)].l = rW(s[acl-2]); head[rBy(i)].r = rW(s[acl-1]); tail[rBy(m[acl-1]&255)].l = rW(s[acl-B/32]); tail[rBy(m[acl-1]&255)].r = rW(s[acl-B/32+1] | q[acl-1]);}} if(0){fprintf(out,"\n i head[i] tail[i]\n"); {int i; for(i = 0; i<256; ++i) fprintf(out, "%3d %08lx%08lx %08lx%08lx\n", i, head[i].l, head[i].r, tail[i].l, tail[i].r);}}}}