Annotation of 41BSD/lib/libmp/gcd.c, revision 1.1.1.1

1.1       root        1: #include <mp.h>
                      2: gcd(a,b,c) MINT *a,*b,*c;
                      3: {      MINT x,y,z,w;
                      4:        x.len=y.len=z.len=w.len=0;
                      5:        move(a,&x);
                      6:        move(b,&y);
                      7:        while(y.len!=0)
                      8:        {       mdiv(&x,&y,&w,&z);
                      9:                move(&y,&x);
                     10:                move(&z,&y);
                     11:        }
                     12:        move(&x,c);
                     13:        xfree(&x);
                     14:        xfree(&y);
                     15:        xfree(&z);
                     16:        xfree(&w);
                     17:        return;
                     18: }
                     19: invert(a, b, c) MINT *a, *b, *c;
                     20: {      MINT x, y, z, w, Anew, Aold;
                     21:        int i = 0;
                     22:        x.len = y.len = z.len = w.len = Aold.len = 0;
                     23:        Anew.len = 1;
                     24:        Anew.val = xalloc(1);
                     25:        *Anew.val = 1;
                     26:        move(b, &x);
                     27:        move(a, &y);
                     28:        while(y.len != 0)
                     29:        {       mdiv(&x, &y, &w, &z);
                     30:                move(&Anew, &x);
                     31:                mult(&w, &Anew, &Anew);
                     32:                madd(&Anew, &Aold, &Anew);
                     33:                move(&x, &Aold);
                     34:                move(&y, &x);
                     35:                move(&z, &y);
                     36:                i++;
                     37:        }
                     38:        move(&Aold, c);
                     39:        if( (i&01) == 0) msub(b, c, c);
                     40:        xfree(&x);
                     41:        xfree(&y);
                     42:        xfree(&z);
                     43:        xfree(&w);
                     44:        xfree(&Aold);
                     45:        xfree(&Anew);
                     46: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.