#define EXTERN extern #include "mpd.h" void zprpath ( h ) halfword h ; {/* 30 31 */ halfword p, q ; p = h ; do { q = mem [ p ] .hhfield .v.RH ; if ( ( p == 0 ) || ( q == 0 ) ) { printnl ( 261 ) ; goto lab30 ; } printtwo ( mem [ p + 1 ] .cint , mem [ p + 2 ] .cint ) ; switch ( mem [ p ] .hhfield .b1 ) {case 0 : { if ( mem [ p ] .hhfield .b0 == 4 ) print ( 532 ) ; if ( ( mem [ q ] .hhfield .b0 != 0 ) || ( q != h ) ) q = 0 ; goto lab31 ; } break ; case 1 : { print ( 538 ) ; printtwo ( mem [ p + 5 ] .cint , mem [ p + 6 ] .cint ) ; print ( 537 ) ; if ( mem [ q ] .hhfield .b0 != 1 ) print ( 539 ) ; else printtwo ( mem [ q + 3 ] .cint , mem [ q + 4 ] .cint ) ; goto lab31 ; } break ; case 4 : if ( ( mem [ p ] .hhfield .b0 != 1 ) && ( mem [ p ] .hhfield .b0 != 4 ) ) print ( 532 ) ; break ; case 3 : case 2 : { if ( mem [ p ] .hhfield .b0 == 4 ) print ( 539 ) ; if ( mem [ p ] .hhfield .b1 == 3 ) { print ( 535 ) ; printscaled ( mem [ p + 5 ] .cint ) ; } else { nsincos ( mem [ p + 5 ] .cint ) ; printchar ( 123 ) ; printscaled ( ncos ) ; printchar ( 44 ) ; printscaled ( nsin ) ; } printchar ( 125 ) ; } break ; default: print ( 261 ) ; break ; } if ( mem [ q ] .hhfield .b0 <= 1 ) print ( 533 ) ; else if ( ( mem [ p + 6 ] .cint != 65536L ) || ( mem [ q + 4 ] .cint != 65536L ) ) { print ( 536 ) ; if ( mem [ p + 6 ] .cint < 0 ) print ( 478 ) ; printscaled ( abs ( mem [ p + 6 ] .cint ) ) ; if ( mem [ p + 6 ] .cint != mem [ q + 4 ] .cint ) { print ( 537 ) ; if ( mem [ q + 4 ] .cint < 0 ) print ( 478 ) ; printscaled ( abs ( mem [ q + 4 ] .cint ) ) ; } } lab31: ; p = q ; if ( ( p != h ) || ( mem [ h ] .hhfield .b0 != 0 ) ) { printnl ( 534 ) ; if ( mem [ p ] .hhfield .b0 == 2 ) { nsincos ( mem [ p + 3 ] .cint ) ; printchar ( 123 ) ; printscaled ( ncos ) ; printchar ( 44 ) ; printscaled ( nsin ) ; printchar ( 125 ) ; } else if ( mem [ p ] .hhfield .b0 == 3 ) { print ( 535 ) ; printscaled ( mem [ p + 3 ] .cint ) ; printchar ( 125 ) ; } } } while ( ! ( p == h ) ) ; if ( mem [ h ] .hhfield .b0 != 0 ) print ( 400 ) ; lab30: ; } void zprintpath ( h , s , nuline ) halfword h ; strnumber s ; boolean nuline ; {printdiagnostic ( 540 , s , nuline ) ; println () ; prpath ( h ) ; enddiagnostic ( true ) ; } void zprpen ( h ) halfword h ; {/* 30 */ halfword p, q ; if ( ( h == mem [ h ] .hhfield .v.RH ) ) { print ( 549 ) ; printscaled ( mem [ h + 1 ] .cint ) ; printchar ( 44 ) ; printscaled ( mem [ h + 2 ] .cint ) ; printchar ( 44 ) ; printscaled ( mem [ h + 3 ] .cint - mem [ h + 1 ] .cint ) ; printchar ( 44 ) ; printscaled ( mem [ h + 5 ] .cint - mem [ h + 1 ] .cint ) ; printchar ( 44 ) ; printscaled ( mem [ h + 4 ] .cint - mem [ h + 2 ] .cint ) ; printchar ( 44 ) ; printscaled ( mem [ h + 6 ] .cint - mem [ h + 2 ] .cint ) ; printchar ( 41 ) ; } else { p = h ; do { printtwo ( mem [ p + 1 ] .cint , mem [ p + 2 ] .cint ) ; printnl ( 548 ) ; q = mem [ p ] .hhfield .v.RH ; if ( ( q == 0 ) || ( mem [ q ] .hhfield .lhfield != p ) ) { printnl ( 261 ) ; goto lab30 ; } p = q ; } while ( ! ( p == h ) ) ; print ( 400 ) ; } lab30: ; } void zprintpen ( h , s , nuline ) halfword h ; strnumber s ; boolean nuline ; {printdiagnostic ( 550 , s , nuline ) ; println () ; prpen ( h ) ; enddiagnostic ( true ) ; } scaled zgetpenscale ( p ) halfword p ; {register scaled Result; scaled a, b, c, d ; scaled maxabs ; integer s ; a = mem [ p + 3 ] .cint - mem [ p + 1 ] .cint ; b = mem [ p + 5 ] .cint - mem [ p + 1 ] .cint ; c = mem [ p + 4 ] .cint - mem [ p + 2 ] .cint ; d = mem [ p + 6 ] .cint - mem [ p + 2 ] .cint ; maxabs = abs ( a ) ; if ( abs ( b ) > maxabs ) maxabs = abs ( b ) ; if ( abs ( c ) > maxabs ) maxabs = abs ( c ) ; if ( abs ( d ) > maxabs ) maxabs = abs ( d ) ; s = 64 ; while ( ( maxabs < 268435456L ) && ( s > 1 ) ) { a = a + a ; b = b + b ; c = c + c ; d = d + d ; maxabs = maxabs + maxabs ; s = halfp ( s ) ; } Result = s * squarert ( abs ( takefraction ( a , d ) - takefraction ( b , c ) ) ) ; return(Result) ; } void zprintcompactnode ( p , k ) halfword p ; smallnumber k ; {halfword q ; q = p + k - 1 ; printchar ( 40 ) ; while ( p <= q ) { printscaled ( mem [ p ] .cint ) ; if ( p < q ) printchar ( 44 ) ; incr ( p ) ; } printchar ( 41 ) ; } void zprintobjcolor ( p ) halfword p ; {if ( ( mem [ p + 2 ] .cint > 0 ) || ( mem [ p + 3 ] .cint > 0 ) || ( mem [ p + 4 ] .cint > 0 ) ) { print ( 565 ) ; printcompactnode ( p + 2 , 3 ) ; } } scaled zdashoffset ( h ) halfword h ; {register scaled Result; scaled x ; if ( ( mem [ h ] .hhfield .v.RH == 2 ) || ( mem [ h + 1 ] .cint < 0 ) ) confusion ( 573 ) ; if ( mem [ h + 1 ] .cint == 0 ) x = 0 ; else { x = - (integer) ( mem [ mem [ h ] .hhfield .v.RH + 1 ] .cint % mem [ h + 1 ] .cint ) ; if ( x < 0 ) x = x + mem [ h + 1 ] .cint ; } Result = x ; return(Result) ; } void zprintedges ( h , s , nuline ) halfword h ; strnumber s ; boolean nuline ; {halfword p ; halfword hh, pp ; scaled scf ; boolean oktodash ; printdiagnostic ( 552 , s , nuline ) ; p = h + 7 ; while ( mem [ p ] .hhfield .v.RH != 0 ) { p = mem [ p ] .hhfield .v.RH ; println () ; switch ( mem [ p ] .hhfield .b0 ) {case 1 : { print ( 555 ) ; printobjcolor ( p ) ; printchar ( 58 ) ; println () ; prpath ( mem [ p + 1 ] .hhfield .v.RH ) ; println () ; if ( ( mem [ p + 1 ] .hhfield .lhfield != 0 ) ) { switch ( mem [ p ] .hhfield .b1 ) {case 0 : { print ( 557 ) ; printscaled ( mem [ p + 5 ] .cint ) ; } break ; case 1 : print ( 558 ) ; break ; case 2 : print ( 559 ) ; break ; default: print ( 560 ) ; break ; } print ( 556 ) ; println () ; prpen ( mem [ p + 1 ] .hhfield .lhfield ) ; } } break ; case 2 : { print ( 566 ) ; printobjcolor ( p ) ; printchar ( 58 ) ; println () ; prpath ( mem [ p + 1 ] .hhfield .v.RH ) ; if ( mem [ p + 6 ] .hhfield .v.RH != 0 ) { printnl ( 567 ) ; oktodash = ( mem [ p + 1 ] .hhfield .lhfield == mem [ mem [ p + 1 ] .hhfield .lhfield ] .hhfield .v.RH ) ; if ( ( mem [ p + 7 ] .cint == 0 ) || ! oktodash ) scf = 65536L ; else scf = makescaled ( getpenscale ( mem [ p + 1 ] .hhfield .lhfield ) , mem [ p + 7 ] .cint ) ; hh = mem [ p + 6 ] .hhfield .v.RH ; pp = mem [ hh ] .hhfield .v.RH ; if ( ( pp == 2 ) || ( mem [ hh + 1 ] .cint < 0 ) ) print ( 568 ) ; else { mem [ 3 ] .cint = mem [ pp + 1 ] .cint + mem [ hh + 1 ] .cint ; while ( pp != 2 ) { print ( 569 ) ; printscaled ( takescaled ( mem [ pp + 2 ] .cint - mem [ pp + 1 ] .cint , scf ) ) ; print ( 570 ) ; printscaled ( takescaled ( mem [ mem [ pp ] .hhfield .v.RH + 1 ] .cint - mem [ pp + 2 ] .cint , scf ) ) ; pp = mem [ pp ] .hhfield .v.RH ; if ( pp != 2 ) printchar ( 32 ) ; } print ( 571 ) ; printscaled ( - (integer) takescaled ( dashoffset ( hh ) , scf ) ) ; if ( ! oktodash || ( mem [ hh + 1 ] .cint == 0 ) ) print ( 572 ) ; } } println () ; switch ( mem [ p + 6 ] .hhfield .b0 ) {case 0 : print ( 561 ) ; break ; case 1 : print ( 562 ) ; break ; case 2 : print ( 563 ) ; break ; default: print ( 539 ) ; break ; } print ( 564 ) ; switch ( mem [ p ] .hhfield .b1 ) {case 0 : { print ( 557 ) ; printscaled ( mem [ p + 5 ] .cint ) ; } break ; case 1 : print ( 558 ) ; break ; case 2 : print ( 559 ) ; break ; default: print ( 560 ) ; break ; } print ( 556 ) ; println () ; if ( mem [ p + 1 ] .hhfield .lhfield == 0 ) print ( 261 ) ; else prpen ( mem [ p + 1 ] .hhfield .lhfield ) ; } break ; case 3 : { printchar ( 34 ) ; slowprint ( mem [ p + 1 ] .hhfield .v.RH ) ; print ( 574 ) ; slowprint ( fontname [ mem [ p + 1 ] .hhfield .lhfield ] ) ; printchar ( 34 ) ; println () ; printobjcolor ( p ) ; print ( 575 ) ; printcompactnode ( p + 8 , 6 ) ; } break ; case 4 : { print ( 576 ) ; println () ; prpath ( mem [ p + 1 ] .hhfield .v.RH ) ; } break ; case 6 : print ( 577 ) ; break ; case 5 : { print ( 578 ) ; println () ; prpath ( mem [ p + 1 ] .hhfield .v.RH ) ; } break ; case 7 : print ( 579 ) ; break ; default: { print ( 553 ) ; } break ; } } printnl ( 554 ) ; if ( p != mem [ h + 7 ] .hhfield .lhfield ) print ( 63 ) ; enddiagnostic ( true ) ; } void zprintdependency ( p , t ) halfword p ; smallnumber t ; {/* 10 */ integer v ; halfword pp, q ; pp = p ; while ( true ) { v = abs ( mem [ p + 1 ] .cint ) ; q = mem [ p ] .hhfield .lhfield ; if ( q == 0 ) { if ( ( v != 0 ) || ( p == pp ) ) { if ( mem [ p + 1 ] .cint > 0 ) if ( p != pp ) printchar ( 43 ) ; printscaled ( mem [ p + 1 ] .cint ) ; } goto lab10 ; } if ( mem [ p + 1 ] .cint < 0 ) printchar ( 45 ) ; else if ( p != pp ) printchar ( 43 ) ; if ( t == 17 ) v = roundfraction ( v ) ; if ( v != 65536L ) printscaled ( v ) ; if ( mem [ q ] .hhfield .b0 != 19 ) confusion ( 600 ) ; printvariablename ( q ) ; v = mem [ q + 1 ] .cint % 64 ; while ( v > 0 ) { print ( 601 ) ; v = v - 2 ; } p = mem [ p ] .hhfield .v.RH ; } lab10: ; } void zprintdp ( t , p , verbosity ) smallnumber t ; halfword p ; smallnumber verbosity ; {halfword q ; q = mem [ p ] .hhfield .v.RH ; if ( ( mem [ q ] .hhfield .lhfield == 0 ) || ( verbosity > 0 ) ) printdependency ( p , t ) ; else print ( 814 ) ; } halfword stashcurexp ( ) {register halfword Result; halfword p ; switch ( curtype ) {case 3 : case 5 : case 7 : case 11 : case 9 : case 12 : case 13 : case 14 : case 17 : case 18 : case 19 : p = curexp ; break ; default: { p = getnode ( 2 ) ; mem [ p ] .hhfield .b1 = 14 ; mem [ p ] .hhfield .b0 = curtype ; mem [ p + 1 ] .cint = curexp ; } break ; } curtype = 1 ; mem [ p ] .hhfield .v.RH = 1 ; Result = p ; return(Result) ; } void zunstashcurexp ( p ) halfword p ; {curtype = mem [ p ] .hhfield .b0 ; switch ( curtype ) {case 3 : case 5 : case 7 : case 11 : case 9 : case 12 : case 13 : case 14 : case 17 : case 18 : case 19 : curexp = p ; break ; default: { curexp = mem [ p + 1 ] .cint ; freenode ( p , 2 ) ; } break ; } } void zprintexp ( p , verbosity ) halfword p ; smallnumber verbosity ; {boolean restorecurexp ; smallnumber t ; integer v ; halfword q ; if ( p != 0 ) restorecurexp = false ; else { p = stashcurexp () ; restorecurexp = true ; } t = mem [ p ] .hhfield .b0 ; if ( t < 17 ) v = mem [ p + 1 ] .cint ; else if ( t < 19 ) v = mem [ p + 1 ] .hhfield .v.RH ; switch ( t ) {case 1 : print ( 325 ) ; break ; case 2 : if ( v == 30 ) print ( 348 ) ; else print ( 349 ) ; break ; case 3 : case 5 : case 7 : case 11 : case 9 : case 15 : { printtype ( t ) ; if ( v != 0 ) { printchar ( 32 ) ; while ( ( mem [ v ] .hhfield .b1 == 14 ) && ( v != p ) ) v = mem [ v + 1 ] .cint ; printvariablename ( v ) ; } } break ; case 4 : { printchar ( 34 ) ; slowprint ( v ) ; printchar ( 34 ) ; } break ; case 6 : case 8 : case 10 : if ( verbosity <= 1 ) printtype ( t ) ; else { if ( selector == 7 ) if ( internal [ 12 ] <= 0 ) { selector = 5 ; printtype ( t ) ; print ( 813 ) ; selector = 7 ; } switch ( t ) {case 6 : printpen ( v , 285 , false ) ; break ; case 8 : printpath ( v , 285 , false ) ; break ; case 10 : printedges ( v , 285 , false ) ; break ; } } break ; case 12 : case 13 : case 14 : if ( v == 0 ) printtype ( t ) ; else { printchar ( 40 ) ; q = v + bignodesize [ t ] ; do { if ( mem [ v ] .hhfield .b0 == 16 ) printscaled ( mem [ v + 1 ] .cint ) ; else if ( mem [ v ] .hhfield .b0 == 19 ) printvariablename ( v ) ; else printdp ( mem [ v ] .hhfield .b0 , mem [ v + 1 ] .hhfield .v.RH , verbosity ) ; v = v + 2 ; if ( v != q ) printchar ( 44 ) ; } while ( ! ( v == q ) ) ; printchar ( 41 ) ; } break ; case 16 : printscaled ( v ) ; break ; case 17 : case 18 : printdp ( t , v , verbosity ) ; break ; case 19 : printvariablename ( p ) ; break ; default: confusion ( 812 ) ; break ; } if ( restorecurexp ) unstashcurexp ( p ) ; } void zdisperr ( p , s ) halfword p ; strnumber s ; {if ( interaction == 3 ) ; printnl ( 805 ) ; printexp ( p , 1 ) ; if ( s != 285 ) { printnl ( 263 ) ; print ( s ) ; } } halfword zpplusfq ( p , f , q , t , tt ) halfword p ; integer f ; halfword q ; smallnumber t ; smallnumber tt ; {/* 30 */ register halfword Result; halfword pp, qq ; halfword r, s ; integer threshold ; integer v ; if ( t == 17 ) threshold = 2685 ; else threshold = 8 ; r = memtop - 1 ; pp = mem [ p ] .hhfield .lhfield ; qq = mem [ q ] .hhfield .lhfield ; while ( true ) if ( pp == qq ) if ( pp == 0 ) goto lab30 ; else { if ( tt == 17 ) v = mem [ p + 1 ] .cint + takefraction ( f , mem [ q + 1 ] .cint ) ; else v = mem [ p + 1 ] .cint + takescaled ( f , mem [ q + 1 ] .cint ) ; mem [ p + 1 ] .cint = v ; s = p ; p = mem [ p ] .hhfield .v.RH ; if ( abs ( v ) < threshold ) freenode ( s , 2 ) ; else { if ( abs ( v ) >= 626349397L ) if ( watchcoefs ) { mem [ qq ] .hhfield .b0 = 0 ; fixneeded = true ; } mem [ r ] .hhfield .v.RH = s ; r = s ; } pp = mem [ p ] .hhfield .lhfield ; q = mem [ q ] .hhfield .v.RH ; qq = mem [ q ] .hhfield .lhfield ; } else if ( mem [ pp + 1 ] .cint < mem [ qq + 1 ] .cint ) { if ( tt == 17 ) v = takefraction ( f , mem [ q + 1 ] .cint ) ; else v = takescaled ( f , mem [ q + 1 ] .cint ) ; if ( abs ( v ) > halfp ( threshold ) ) { s = getnode ( 2 ) ; mem [ s ] .hhfield .lhfield = qq ; mem [ s + 1 ] .cint = v ; if ( abs ( v ) >= 626349397L ) if ( watchcoefs ) { mem [ qq ] .hhfield .b0 = 0 ; fixneeded = true ; } mem [ r ] .hhfield .v.RH = s ; r = s ; } q = mem [ q ] .hhfield .v.RH ; qq = mem [ q ] .hhfield .lhfield ; } else { mem [ r ] .hhfield .v.RH = p ; r = p ; p = mem [ p ] .hhfield .v.RH ; pp = mem [ p ] .hhfield .lhfield ; } lab30: if ( t == 17 ) mem [ p + 1 ] .cint = slowadd ( mem [ p + 1 ] .cint , takefraction ( mem [ q + 1 ] .cint , f ) ) ; else mem [ p + 1 ] .cint = slowadd ( mem [ p + 1 ] .cint , takescaled ( mem [ q + 1 ] .cint , f ) ) ; mem [ r ] .hhfield .v.RH = p ; depfinal = p ; Result = mem [ memtop - 1 ] .hhfield .v.RH ; return(Result) ; } halfword zpoverv ( p , v , t0 , t1 ) halfword p ; scaled v ; smallnumber t0 ; smallnumber t1 ; {register halfword Result; halfword r, s ; integer w ; integer threshold ; boolean scalingdown ; if ( t0 != t1 ) scalingdown = true ; else scalingdown = false ; if ( t1 == 17 ) threshold = 1342 ; else threshold = 4 ; r = memtop - 1 ; while ( mem [ p ] .hhfield .lhfield != 0 ) { if ( scalingdown ) if ( abs ( v ) < 524288L ) w = makescaled ( mem [ p + 1 ] .cint , v * 4096 ) ; else w = makescaled ( roundfraction ( mem [ p + 1 ] .cint ) , v ) ; else w = makescaled ( mem [ p + 1 ] .cint , v ) ; if ( abs ( w ) <= threshold ) { s = mem [ p ] .hhfield .v.RH ; freenode ( p , 2 ) ; p = s ; } else { if ( abs ( w ) >= 626349397L ) { fixneeded = true ; mem [ mem [ p ] .hhfield .lhfield ] .hhfield .b0 = 0 ; } mem [ r ] .hhfield .v.RH = p ; r = p ; mem [ p + 1 ] .cint = w ; p = mem [ p ] .hhfield .v.RH ; } } mem [ r ] .hhfield .v.RH = p ; mem [ p + 1 ] .cint = makescaled ( mem [ p + 1 ] .cint , v ) ; Result = mem [ memtop - 1 ] .hhfield .v.RH ; return(Result) ; } void zvaltoobig ( x ) scaled x ; {if ( internal [ 30 ] > 0 ) { { if ( interaction == 3 ) ; printnl ( 263 ) ; print ( 602 ) ; } printscaled ( x ) ; printchar ( 41 ) ; { helpptr = 4 ; helpline [ 3 ] = 603 ; helpline [ 2 ] = 604 ; helpline [ 1 ] = 605 ; helpline [ 0 ] = 606 ; } error () ; } } void zmakeknown ( p , q ) halfword p ; halfword q ; {char t ; mem [ mem [ q ] .hhfield .v.RH + 1 ] .hhfield .lhfield = mem [ p + 1 ] .hhfield .lhfield ; mem [ mem [ p + 1 ] .hhfield .lhfield ] .hhfield .v.RH = mem [ q ] .hhfield .v.RH ; t = mem [ p ] .hhfield .b0 ; mem [ p ] .hhfield .b0 = 16 ; mem [ p + 1 ] .cint = mem [ q + 1 ] .cint ; freenode ( q , 2 ) ; if ( abs ( mem [ p + 1 ] .cint ) >= 268435456L ) valtoobig ( mem [ p + 1 ] .cint ) ; if ( internal [ 2 ] > 0 ) if ( interesting ( p ) ) { begindiagnostic () ; printnl ( 607 ) ; printvariablename ( p ) ; printchar ( 61 ) ; printscaled ( mem [ p + 1 ] .cint ) ; enddiagnostic ( false ) ; } if ( curexp == p ) if ( curtype == t ) { curtype = 16 ; curexp = mem [ p + 1 ] .cint ; freenode ( p , 2 ) ; } } void fixdependencies ( ) {/* 30 */ halfword p, q, r, s, t ; halfword x ; r = mem [ 5 ] .hhfield .v.RH ; s = 0 ; while ( r != 5 ) { t = r ; r = t + 1 ; while ( true ) { q = mem [ r ] .hhfield .v.RH ; x = mem [ q ] .hhfield .lhfield ; if ( x == 0 ) goto lab30 ; if ( mem [ x ] .hhfield .b0 <= 1 ) { if ( mem [ x ] .hhfield .b0 < 1 ) { p = getavail () ; mem [ p ] .hhfield .v.RH = s ; s = p ; mem [ s ] .hhfield .lhfield = x ; mem [ x ] .hhfield .b0 = 1 ; } mem [ q + 1 ] .cint = mem [ q + 1 ] .cint / 4 ; if ( mem [ q + 1 ] .cint == 0 ) { mem [ r ] .hhfield .v.RH = mem [ q ] .hhfield .v.RH ; freenode ( q , 2 ) ; q = r ; } } r = q ; } lab30: ; r = mem [ q ] .hhfield .v.RH ; if ( q == mem [ t + 1 ] .hhfield .v.RH ) makeknown ( t , q ) ; } while ( s != 0 ) { p = mem [ s ] .hhfield .v.RH ; x = mem [ s ] .hhfield .lhfield ; { mem [ s ] .hhfield .v.RH = avail ; avail = s ; ; #ifdef STAT decr ( dynused ) ; #endif /* STAT */ } s = p ; mem [ x ] .hhfield .b0 = 19 ; mem [ x + 1 ] .cint = mem [ x + 1 ] .cint + 2 ; } fixneeded = false ; } void ztossknotlist ( p ) halfword p ; {halfword q ; halfword r ; q = p ; do { r = mem [ q ] .hhfield .v.RH ; freenode ( q , 7 ) ; q = r ; } while ( ! ( q == p ) ) ; } void zflushdashlist ( h ) halfword h ; {halfword p, q ; q = mem [ h ] .hhfield .v.RH ; while ( q != 2 ) { p = q ; q = mem [ q ] .hhfield .v.RH ; freenode ( p , 3 ) ; } mem [ h ] .hhfield .v.RH = 2 ; } halfword ztossgrobject ( p ) halfword p ; {register halfword Result; halfword e ; e = 0 ; switch ( mem [ p ] .hhfield .b0 ) {case 1 : { tossknotlist ( mem [ p + 1 ] .hhfield .v.RH ) ; if ( mem [ p + 1 ] .hhfield .lhfield != 0 ) tossknotlist ( mem [ p + 1 ] .hhfield .lhfield ) ; } break ; case 2 : { tossknotlist ( mem [ p + 1 ] .hhfield .v.RH ) ; if ( mem [ p + 1 ] .hhfield .lhfield != 0 ) tossknotlist ( mem [ p + 1 ] .hhfield .lhfield ) ; e = mem [ p + 6 ] .hhfield .v.RH ; } break ; case 3 : { if ( strref [ mem [ p + 1 ] .hhfield .v.RH ] < 127 ) if ( strref [ mem [ p + 1 ] .hhfield .v.RH ] > 1 ) decr ( strref [ mem [ p + 1 ] .hhfield .v.RH ] ) ; else flushstring ( mem [ p + 1 ] .hhfield .v.RH ) ; } break ; case 4 : case 5 : tossknotlist ( mem [ p + 1 ] .hhfield .v.RH ) ; break ; case 6 : case 7 : ; break ; } freenode ( p , grobjectsize [ mem [ p ] .hhfield .b0 ] ) ; Result = e ; return(Result) ; } void ztossedges ( h ) halfword h ; {halfword p, q ; halfword r ; flushdashlist ( h ) ; q = mem [ h + 7 ] .hhfield .v.RH ; while ( ( q != 0 ) ) { p = q ; q = mem [ q ] .hhfield .v.RH ; r = tossgrobject ( p ) ; if ( r != 0 ) if ( mem [ r ] .hhfield .lhfield == 0 ) tossedges ( r ) ; else decr ( mem [ r ] .hhfield .lhfield ) ; } freenode ( h , 8 ) ; } void zringdelete ( p ) halfword p ; {halfword q ; q = mem [ p + 1 ] .cint ; if ( q != 0 ) if ( q != p ) { while ( mem [ q + 1 ] .cint != p ) q = mem [ q + 1 ] .cint ; mem [ q + 1 ] .cint = mem [ p + 1 ] .cint ; } } void zrecyclevalue ( p ) halfword p ; {/* 30 */ smallnumber t ; integer v ; integer vv ; halfword q, r, s, pp ; t = mem [ p ] .hhfield .b0 ; if ( t < 17 ) v = mem [ p + 1 ] .cint ; switch ( t ) {case 0 : case 1 : case 2 : case 16 : case 15 : ; break ; case 3 : case 5 : case 7 : case 11 : case 9 : ringdelete ( p ) ; break ; case 4 : { if ( strref [ v ] < 127 ) if ( strref [ v ] > 1 ) decr ( strref [ v ] ) ; else flushstring ( v ) ; } break ; case 8 : case 6 : tossknotlist ( v ) ; break ; case 10 : if ( mem [ v ] .hhfield .lhfield == 0 ) tossedges ( v ) ; else decr ( mem [ v ] .hhfield .lhfield ) ; break ; case 14 : case 13 : case 12 : if ( v != 0 ) { q = v + bignodesize [ t ] ; do { q = q - 2 ; recyclevalue ( q ) ; } while ( ! ( q == v ) ) ; freenode ( v , bignodesize [ t ] ) ; } break ; case 17 : case 18 : { q = mem [ p + 1 ] .hhfield .v.RH ; while ( mem [ q ] .hhfield .lhfield != 0 ) q = mem [ q ] .hhfield .v.RH ; mem [ mem [ p + 1 ] .hhfield .lhfield ] .hhfield .v.RH = mem [ q ] .hhfield .v.RH ; mem [ mem [ q ] .hhfield .v.RH + 1 ] .hhfield .lhfield = mem [ p + 1 ] .hhfield .lhfield ; mem [ q ] .hhfield .v.RH = 0 ; flushnodelist ( mem [ p + 1 ] .hhfield .v.RH ) ; } break ; case 19 : { maxc [ 17 ] = 0 ; maxc [ 18 ] = 0 ; maxlink [ 17 ] = 0 ; maxlink [ 18 ] = 0 ; q = mem [ 5 ] .hhfield .v.RH ; while ( q != 5 ) { s = q + 1 ; while ( true ) { r = mem [ s ] .hhfield .v.RH ; if ( mem [ r ] .hhfield .lhfield == 0 ) goto lab30 ; if ( mem [ r ] .hhfield .lhfield != p ) s = r ; else { t = mem [ q ] .hhfield .b0 ; mem [ s ] .hhfield .v.RH = mem [ r ] .hhfield .v.RH ; mem [ r ] .hhfield .lhfield = q ; if ( abs ( mem [ r + 1 ] .cint ) > maxc [ t ] ) { if ( maxc [ t ] > 0 ) { mem [ maxptr [ t ] ] .hhfield .v.RH = maxlink [ t ] ; maxlink [ t ] = maxptr [ t ] ; } maxc [ t ] = abs ( mem [ r + 1 ] .cint ) ; maxptr [ t ] = r ; } else { mem [ r ] .hhfield .v.RH = maxlink [ t ] ; maxlink [ t ] = r ; } } } lab30: q = mem [ r ] .hhfield .v.RH ; } if ( ( maxc [ 17 ] > 0 ) || ( maxc [ 18 ] > 0 ) ) { if ( ( maxc [ 17 ] / 4096 >= maxc [ 18 ] ) ) t = 17 ; else t = 18 ; s = maxptr [ t ] ; pp = mem [ s ] .hhfield .lhfield ; v = mem [ s + 1 ] .cint ; if ( t == 17 ) mem [ s + 1 ] .cint = -268435456L ; else mem [ s + 1 ] .cint = -65536L ; r = mem [ pp + 1 ] .hhfield .v.RH ; mem [ s ] .hhfield .v.RH = r ; while ( mem [ r ] .hhfield .lhfield != 0 ) r = mem [ r ] .hhfield .v.RH ; q = mem [ r ] .hhfield .v.RH ; mem [ r ] .hhfield .v.RH = 0 ; mem [ q + 1 ] .hhfield .lhfield = mem [ pp + 1 ] .hhfield .lhfield ; mem [ mem [ pp + 1 ] .hhfield .lhfield ] .hhfield .v.RH = q ; { mem [ pp ] .hhfield .b0 = 19 ; serialno = serialno + 64 ; mem [ pp + 1 ] .cint = serialno ; } if ( curexp == pp ) if ( curtype == t ) curtype = 19 ; if ( internal [ 2 ] > 0 ) if ( interesting ( p ) ) { begindiagnostic () ; printnl ( 816 ) ; if ( v > 0 ) printchar ( 45 ) ; if ( t == 17 ) vv = roundfraction ( maxc [ 17 ] ) ; else vv = maxc [ 18 ] ; if ( vv != 65536L ) printscaled ( vv ) ; printvariablename ( p ) ; while ( mem [ p + 1 ] .cint % 64 > 0 ) { print ( 601 ) ; mem [ p + 1 ] .cint = mem [ p + 1 ] .cint - 2 ; } if ( t == 17 ) printchar ( 61 ) ; else print ( 817 ) ; printdependency ( s , t ) ; enddiagnostic ( false ) ; } t = 35 - t ; if ( maxc [ t ] > 0 ) { mem [ maxptr [ t ] ] .hhfield .v.RH = maxlink [ t ] ; maxlink [ t ] = maxptr [ t ] ; } if ( t != 17 ) {register integer for_end; t = 17 ; for_end = 18 ; if ( t <= for_end) do { r = maxlink [ t ] ; while ( r != 0 ) { q = mem [ r ] .hhfield .lhfield ; mem [ q + 1 ] .hhfield .v.RH = pplusfq ( mem [ q + 1 ] .hhfield .v.RH , makefraction ( mem [ r + 1 ] .cint , - (integer) v ) , s , t , 17 ) ; if ( mem [ q + 1 ] .hhfield .v.RH == depfinal ) makeknown ( q , depfinal ) ; q = r ; r = mem [ r ] .hhfield .v.RH ; freenode ( q , 2 ) ; } } while ( t++ < for_end ) ; } else { register integer for_end; t = 17 ; for_end = 18 ; if ( t <= for_end) do { r = maxlink [ t ] ; while ( r != 0 ) { q = mem [ r ] .hhfield .lhfield ; if ( t == 17 ) { if ( curexp == q ) if ( curtype == 17 ) curtype = 18 ; mem [ q + 1 ] .hhfield .v.RH = poverv ( mem [ q + 1 ] .hhfield .v.RH , 65536L , 17 , 18 ) ; mem [ q ] .hhfield .b0 = 18 ; mem [ r + 1 ] .cint = roundfraction ( mem [ r + 1 ] .cint ) ; } mem [ q + 1 ] .hhfield .v.RH = pplusfq ( mem [ q + 1 ] .hhfield .v.RH , makescaled ( mem [ r + 1 ] .cint , - (integer) v ) , s , 18 , 18 ) ; if ( mem [ q + 1 ] .hhfield .v.RH == depfinal ) makeknown ( q , depfinal ) ; q = r ; r = mem [ r ] .hhfield .v.RH ; freenode ( q , 2 ) ; } } while ( t++ < for_end ) ; } flushnodelist ( s ) ; if ( fixneeded ) fixdependencies () ; { if ( aritherror ) cleararith () ; } } } break ; case 20 : case 21 : confusion ( 815 ) ; break ; case 22 : case 23 : deletemacref ( mem [ p + 1 ] .cint ) ; break ; } mem [ p ] .hhfield .b0 = 0 ; } void zflushcurexp ( v ) scaled v ; {switch ( curtype ) {case 3 : case 5 : case 7 : case 11 : case 9 : case 12 : case 13 : case 14 : case 17 : case 18 : case 19 : { recyclevalue ( curexp ) ; freenode ( curexp , 2 ) ; } break ; case 4 : { if ( strref [ curexp ] < 127 ) if ( strref [ curexp ] > 1 ) decr ( strref [ curexp ] ) ; else flushstring ( curexp ) ; } break ; case 6 : case 8 : tossknotlist ( curexp ) ; break ; case 10 : if ( mem [ curexp ] .hhfield .lhfield == 0 ) tossedges ( curexp ) ; else decr ( mem [ curexp ] .hhfield .lhfield ) ; break ; default: ; break ; } curtype = 16 ; curexp = v ; } void zflusherror ( v ) scaled v ; {error () ; flushcurexp ( v ) ; } void putgeterror ( ) {backerror () ; getxnext () ; } void zputgetflusherror ( v ) scaled v ; {putgeterror () ; flushcurexp ( v ) ; } void zflushbelowvariable ( p ) halfword p ; {halfword q, r ; if ( mem [ p ] .hhfield .b0 != 21 ) recyclevalue ( p ) ; else { q = mem [ p + 1 ] .hhfield .v.RH ; while ( mem [ q ] .hhfield .b1 == 3 ) { flushbelowvariable ( q ) ; r = q ; q = mem [ q ] .hhfield .v.RH ; freenode ( r , 3 ) ; } r = mem [ p + 1 ] .hhfield .lhfield ; q = mem [ r ] .hhfield .v.RH ; recyclevalue ( r ) ; if ( mem [ p ] .hhfield .b1 <= 1 ) freenode ( r , 2 ) ; else freenode ( r , 3 ) ; do { flushbelowvariable ( q ) ; r = q ; q = mem [ q ] .hhfield .v.RH ; freenode ( r , 3 ) ; } while ( ! ( q == 9 ) ) ; mem [ p ] .hhfield .b0 = 0 ; } } void zflushvariable ( p , t , discardsuffixes ) halfword p ; halfword t ; boolean discardsuffixes ; {/* 10 */ halfword q, r ; halfword n ; while ( t != 0 ) { if ( mem [ p ] .hhfield .b0 != 21 ) goto lab10 ; n = mem [ t ] .hhfield .lhfield ; t = mem [ t ] .hhfield .v.RH ; if ( n == 0 ) { r = p + 1 ; q = mem [ r ] .hhfield .v.RH ; while ( mem [ q ] .hhfield .b1 == 3 ) { flushvariable ( q , t , discardsuffixes ) ; if ( t == 0 ) if ( mem [ q ] .hhfield .b0 == 21 ) r = q ; else { mem [ r ] .hhfield .v.RH = mem [ q ] .hhfield .v.RH ; freenode ( q , 3 ) ; } else r = q ; q = mem [ r ] .hhfield .v.RH ; } } p = mem [ p + 1 ] .hhfield .lhfield ; do { r = p ; p = mem [ p ] .hhfield .v.RH ; } while ( ! ( mem [ p + 2 ] .hhfield .lhfield >= n ) ) ; if ( mem [ p + 2 ] .hhfield .lhfield != n ) goto lab10 ; } if ( discardsuffixes ) flushbelowvariable ( p ) ; else { if ( mem [ p ] .hhfield .b0 == 21 ) p = mem [ p + 1 ] .hhfield .lhfield ; recyclevalue ( p ) ; } lab10: ; } smallnumber zundtype ( p ) halfword p ; {register smallnumber Result; switch ( mem [ p ] .hhfield .b0 ) {case 0 : case 1 : Result = 0 ; break ; case 2 : case 3 : Result = 3 ; break ; case 4 : case 5 : Result = 5 ; break ; case 6 : case 7 : Result = 7 ; break ; case 8 : case 9 : Result = 9 ; break ; case 10 : case 11 : Result = 11 ; break ; case 12 : case 13 : case 14 : case 15 : Result = mem [ p ] .hhfield .b0 ; break ; case 16 : case 17 : case 18 : case 19 : Result = 15 ; break ; } return(Result) ; } void zclearsymbol ( p , saving ) halfword p ; boolean saving ; {halfword q ; q = eqtb [ p ] .v.RH ; switch ( eqtb [ p ] .lhfield % 85 ) {case 13 : case 55 : case 46 : case 51 : if ( ! saving ) deletemacref ( q ) ; break ; case 43 : if ( q != 0 ) if ( saving ) mem [ q ] .hhfield .b1 = 1 ; else { flushbelowvariable ( q ) ; freenode ( q , 2 ) ; } break ; default: ; break ; } eqtb [ p ] = eqtb [ 2371 ] ; } void zsavevariable ( q ) halfword q ; {halfword p ; if ( saveptr != 0 ) { p = getnode ( 2 ) ; mem [ p ] .hhfield .lhfield = q ; mem [ p ] .hhfield .v.RH = saveptr ; mem [ p + 1 ] .hhfield = eqtb [ q ] ; saveptr = p ; } clearsymbol ( q , ( saveptr != 0 ) ) ; } void zsaveinternal ( q ) halfword q ; {halfword p ; if ( saveptr != 0 ) { p = getnode ( 2 ) ; mem [ p ] .hhfield .lhfield = 2371 + q ; mem [ p ] .hhfield .v.RH = saveptr ; mem [ p + 1 ] .cint = internal [ q ] ; saveptr = p ; } } void unsave ( ) {halfword q ; halfword p ; while ( mem [ saveptr ] .hhfield .lhfield != 0 ) { q = mem [ saveptr ] .hhfield .lhfield ; if ( q > 2371 ) { if ( internal [ 7 ] > 0 ) { begindiagnostic () ; printnl ( 531 ) ; print ( intname [ q - ( 2371 ) ] ) ; printchar ( 61 ) ; printscaled ( mem [ saveptr + 1 ] .cint ) ; printchar ( 125 ) ; enddiagnostic ( false ) ; } internal [ q - ( 2371 ) ] = mem [ saveptr + 1 ] .cint ; } else { if ( internal [ 7 ] > 0 ) { begindiagnostic () ; printnl ( 531 ) ; print ( hash [ q ] .v.RH ) ; printchar ( 125 ) ; enddiagnostic ( false ) ; } clearsymbol ( q , false ) ; eqtb [ q ] = mem [ saveptr + 1 ] .hhfield ; if ( eqtb [ q ] .lhfield % 85 == 43 ) { p = eqtb [ q ] .v.RH ; if ( p != 0 ) mem [ p ] .hhfield .b1 = 0 ; } } p = mem [ saveptr ] .hhfield .v.RH ; freenode ( saveptr , 2 ) ; saveptr = p ; } p = mem [ saveptr ] .hhfield .v.RH ; { mem [ saveptr ] .hhfield .v.RH = avail ; avail = saveptr ; ; #ifdef STAT decr ( dynused ) ; #endif /* STAT */ } saveptr = p ; } halfword zcopyknot ( p ) halfword p ; {register halfword Result; halfword q ; char k ; q = getnode ( 7 ) ; {register integer for_end; k = 0 ; for_end = 6 ; if ( k <= for_end) do mem [ q + k ] = mem [ p + k ] ; while ( k++ < for_end ) ; } Result = q ; return(Result) ; } halfword zcopypath ( p ) halfword p ; {register halfword Result; halfword q, pp, qq ; q = copyknot ( p ) ; qq = q ; pp = mem [ p ] .hhfield .v.RH ; while ( pp != p ) { mem [ qq ] .hhfield .v.RH = copyknot ( pp ) ; qq = mem [ qq ] .hhfield .v.RH ; pp = mem [ pp ] .hhfield .v.RH ; } mem [ qq ] .hhfield .v.RH = q ; Result = q ; return(Result) ; } halfword zhtapypoc ( p ) halfword p ; {/* 10 */ register halfword Result; halfword q, pp, qq, rr ; q = getnode ( 7 ) ; qq = q ; pp = p ; while ( true ) { mem [ qq ] .hhfield .b1 = mem [ pp ] .hhfield .b0 ; mem [ qq ] .hhfield .b0 = mem [ pp ] .hhfield .b1 ; mem [ qq + 1 ] .cint = mem [ pp + 1 ] .cint ; mem [ qq + 2 ] .cint = mem [ pp + 2 ] .cint ; mem [ qq + 5 ] .cint = mem [ pp + 3 ] .cint ; mem [ qq + 6 ] .cint = mem [ pp + 4 ] .cint ; mem [ qq + 3 ] .cint = mem [ pp + 5 ] .cint ; mem [ qq + 4 ] .cint = mem [ pp + 6 ] .cint ; if ( mem [ pp ] .hhfield .v.RH == p ) { mem [ q ] .hhfield .v.RH = qq ; pathtail = pp ; Result = q ; goto lab10 ; } rr = getnode ( 7 ) ; mem [ rr ] .hhfield .v.RH = qq ; qq = rr ; pp = mem [ pp ] .hhfield .v.RH ; } lab10: ; return(Result) ; } fraction zcurlratio ( gamma , atension , btension ) scaled gamma ; scaled atension ; scaled btension ; {register fraction Result; fraction alpha, beta, num, denom, ff ; alpha = makefraction ( 65536L , atension ) ; beta = makefraction ( 65536L , btension ) ; if ( alpha <= beta ) { ff = makefraction ( alpha , beta ) ; ff = takefraction ( ff , ff ) ; gamma = takefraction ( gamma , ff ) ; beta = beta / 4096 ; denom = takefraction ( gamma , alpha ) + 196608L - beta ; num = takefraction ( gamma , 805306368L - alpha ) + beta ; } else { ff = makefraction ( beta , alpha ) ; ff = takefraction ( ff , ff ) ; beta = takefraction ( beta , ff ) / 4096 ; denom = takefraction ( gamma , alpha ) + ( ff / 1365 ) - beta ; num = takefraction ( gamma , 805306368L - alpha ) + beta ; } if ( num >= denom + denom + denom + denom ) Result = 1073741824L ; else Result = makefraction ( num , denom ) ; return(Result) ; } void zsetcontrols ( p , q , k ) halfword p ; halfword q ; integer k ; {fraction rr, ss ; scaled lt, rt ; fraction sine ; lt = abs ( mem [ q + 4 ] .cint ) ; rt = abs ( mem [ p + 6 ] .cint ) ; rr = velocity ( st , ct , sf , cf , rt ) ; ss = velocity ( sf , cf , st , ct , lt ) ; if ( ( mem [ p + 6 ] .cint < 0 ) || ( mem [ q + 4 ] .cint < 0 ) ) if ( ( ( st >= 0 ) && ( sf >= 0 ) ) || ( ( st <= 0 ) && ( sf <= 0 ) ) ) { sine = takefraction ( abs ( st ) , cf ) + takefraction ( abs ( sf ) , ct ) ; if ( sine > 0 ) { sine = takefraction ( sine , 268500992L ) ; if ( mem [ p + 6 ] .cint < 0 ) if ( abvscd ( abs ( sf ) , 268435456L , rr , sine ) < 0 ) rr = makefraction ( abs ( sf ) , sine ) ; if ( mem [ q + 4 ] .cint < 0 ) if ( abvscd ( abs ( st ) , 268435456L , ss , sine ) < 0 ) ss = makefraction ( abs ( st ) , sine ) ; } } mem [ p + 5 ] .cint = mem [ p + 1 ] .cint + takefraction ( takefraction ( deltax [ k ] , ct ) - takefraction ( deltay [ k ] , st ) , rr ) ; mem [ p + 6 ] .cint = mem [ p + 2 ] .cint + takefraction ( takefraction ( deltay [ k ] , ct ) + takefraction ( deltax [ k ] , st ) , rr ) ; mem [ q + 3 ] .cint = mem [ q + 1 ] .cint - takefraction ( takefraction ( deltax [ k ] , cf ) + takefraction ( deltay [ k ] , sf ) , ss ) ; mem [ q + 4 ] .cint = mem [ q + 2 ] .cint - takefraction ( takefraction ( deltay [ k ] , cf ) - takefraction ( deltax [ k ] , sf ) , ss ) ; mem [ p ] .hhfield .b1 = 1 ; mem [ q ] .hhfield .b0 = 1 ; } void zsolvechoices ( p , q , n ) halfword p ; halfword q ; halfword n ; {/* 40 10 */ integer k ; halfword r, s, t ; fraction aa, bb, cc, ff, acc ; scaled dd, ee ; scaled lt, rt ; k = 0 ; s = p ; while ( true ) { t = mem [ s ] .hhfield .v.RH ; if ( k == 0 ) switch ( mem [ s ] .hhfield .b1 ) {case 2 : if ( mem [ t ] .hhfield .b0 == 2 ) { aa = narg ( deltax [ 0 ] , deltay [ 0 ] ) ; nsincos ( mem [ p + 5 ] .cint - aa ) ; ct = ncos ; st = nsin ; nsincos ( mem [ q + 3 ] .cint - aa ) ; cf = ncos ; sf = - (integer) nsin ; setcontrols ( p , q , 0 ) ; goto lab10 ; } else { vv [ 0 ] = mem [ s + 5 ] .cint - narg ( deltax [ 0 ] , deltay [ 0 ] ) ; if ( abs ( vv [ 0 ] ) > 188743680L ) if ( vv [ 0 ] > 0 ) vv [ 0 ] = vv [ 0 ] - 377487360L ; else vv [ 0 ] = vv [ 0 ] + 377487360L ; uu [ 0 ] = 0 ; ww [ 0 ] = 0 ; } break ; case 3 : if ( mem [ t ] .hhfield .b0 == 3 ) { mem [ p ] .hhfield .b1 = 1 ; mem [ q ] .hhfield .b0 = 1 ; lt = abs ( mem [ q + 4 ] .cint ) ; rt = abs ( mem [ p + 6 ] .cint ) ; if ( rt == 65536L ) { if ( deltax [ 0 ] >= 0 ) mem [ p + 5 ] .cint = mem [ p + 1 ] .cint + ( ( deltax [ 0 ] + 1 ) / 3 ) ; else mem [ p + 5 ] .cint = mem [ p + 1 ] .cint + ( ( deltax [ 0 ] - 1 ) / 3 ) ; if ( deltay [ 0 ] >= 0 ) mem [ p + 6 ] .cint = mem [ p + 2 ] .cint + ( ( deltay [ 0 ] + 1 ) / 3 ) ; else mem [ p + 6 ] .cint = mem [ p + 2 ] .cint + ( ( deltay [ 0 ] - 1 ) / 3 ) ; } else { ff = makefraction ( 65536L , 3 * rt ) ; mem [ p + 5 ] .cint = mem [ p + 1 ] .cint + takefraction ( deltax [ 0 ] , ff ) ; mem [ p + 6 ] .cint = mem [ p + 2 ] .cint + takefraction ( deltay [ 0 ] , ff ) ; } if ( lt == 65536L ) { if ( deltax [ 0 ] >= 0 ) mem [ q + 3 ] .cint = mem [ q + 1 ] .cint - ( ( deltax [ 0 ] + 1 ) / 3 ) ; else mem [ q + 3 ] .cint = mem [ q + 1 ] .cint - ( ( deltax [ 0 ] - 1 ) / 3 ) ; if ( deltay [ 0 ] >= 0 ) mem [ q + 4 ] .cint = mem [ q + 2 ] .cint - ( ( deltay [ 0 ] + 1 ) / 3 ) ; else mem [ q + 4 ] .cint = mem [ q + 2 ] .cint - ( ( deltay [ 0 ] - 1 ) / 3 ) ; } else { ff = makefraction ( 65536L , 3 * lt ) ; mem [ q + 3 ] .cint = mem [ q + 1 ] .cint - takefraction ( deltax [ 0 ] , ff ) ; mem [ q + 4 ] .cint = mem [ q + 2 ] .cint - takefraction ( deltay [ 0 ] , ff ) ; } goto lab10 ; } else { cc = mem [ s + 5 ] .cint ; lt = abs ( mem [ t + 4 ] .cint ) ; rt = abs ( mem [ s + 6 ] .cint ) ; if ( ( rt == 65536L ) && ( lt == 65536L ) ) uu [ 0 ] = makefraction ( cc + cc + 65536L , cc + 131072L ) ; else uu [ 0 ] = curlratio ( cc , rt , lt ) ; vv [ 0 ] = - (integer) takefraction ( psi [ 1 ] , uu [ 0 ] ) ; ww [ 0 ] = 0 ; } break ; case 4 : { uu [ 0 ] = 0 ; vv [ 0 ] = 0 ; ww [ 0 ] = 268435456L ; } break ; } else switch ( mem [ s ] .hhfield .b0 ) {case 5 : case 4 : { if ( abs ( mem [ r + 6 ] .cint ) == 65536L ) { aa = 134217728L ; dd = 2 * delta [ k ] ; } else { aa = makefraction ( 65536L , 3 * abs ( mem [ r + 6 ] .cint ) - 65536L ) ; dd = takefraction ( delta [ k ] , 805306368L - makefraction ( 65536L , abs ( mem [ r + 6 ] .cint ) ) ) ; } if ( abs ( mem [ t + 4 ] .cint ) == 65536L ) { bb = 134217728L ; ee = 2 * delta [ k - 1 ] ; } else { bb = makefraction ( 65536L , 3 * abs ( mem [ t + 4 ] .cint ) - 65536L ) ; ee = takefraction ( delta [ k - 1 ] , 805306368L - makefraction ( 65536L , abs ( mem [ t + 4 ] .cint ) ) ) ; } cc = 268435456L - takefraction ( uu [ k - 1 ] , aa ) ; dd = takefraction ( dd , cc ) ; lt = abs ( mem [ s + 4 ] .cint ) ; rt = abs ( mem [ s + 6 ] .cint ) ; if ( lt != rt ) if ( lt < rt ) { ff = makefraction ( lt , rt ) ; ff = takefraction ( ff , ff ) ; dd = takefraction ( dd , ff ) ; } else { ff = makefraction ( rt , lt ) ; ff = takefraction ( ff , ff ) ; ee = takefraction ( ee , ff ) ; } ff = makefraction ( ee , ee + dd ) ; uu [ k ] = takefraction ( ff , bb ) ; acc = - (integer) takefraction ( psi [ k + 1 ] , uu [ k ] ) ; if ( mem [ r ] .hhfield .b1 == 3 ) { ww [ k ] = 0 ; vv [ k ] = acc - takefraction ( psi [ 1 ] , 268435456L - ff ) ; } else { ff = makefraction ( 268435456L - ff , cc ) ; acc = acc - takefraction ( psi [ k ] , ff ) ; ff = takefraction ( ff , aa ) ; vv [ k ] = acc - takefraction ( vv [ k - 1 ] , ff ) ; if ( ww [ k - 1 ] == 0 ) ww [ k ] = 0 ; else ww [ k ] = - (integer) takefraction ( ww [ k - 1 ] , ff ) ; } if ( mem [ s ] .hhfield .b0 == 5 ) { aa = 0 ; bb = 268435456L ; do { decr ( k ) ; if ( k == 0 ) k = n ; aa = vv [ k ] - takefraction ( aa , uu [ k ] ) ; bb = ww [ k ] - takefraction ( bb , uu [ k ] ) ; } while ( ! ( k == n ) ) ; aa = makefraction ( aa , 268435456L - bb ) ; theta [ n ] = aa ; vv [ 0 ] = aa ; {register integer for_end; k = 1 ; for_end = n - 1 ; if ( k <= for_end) do vv [ k ] = vv [ k ] + takefraction ( aa , ww [ k ] ) ; while ( k++ < for_end ) ; } goto lab40 ; } } break ; case 3 : { cc = mem [ s + 3 ] .cint ; lt = abs ( mem [ s + 4 ] .cint ) ; rt = abs ( mem [ r + 6 ] .cint ) ; if ( ( rt == 65536L ) && ( lt == 65536L ) ) ff = makefraction ( cc + cc + 65536L , cc + 131072L ) ; else ff = curlratio ( cc , lt , rt ) ; theta [ n ] = - (integer) makefraction ( takefraction ( vv [ n - 1 ] , ff ) , 268435456L - takefraction ( ff , uu [ n - 1 ] ) ) ; goto lab40 ; } break ; case 2 : { theta [ n ] = mem [ s + 3 ] .cint - narg ( deltax [ n - 1 ] , deltay [ n - 1 ] ) ; if ( abs ( theta [ n ] ) > 188743680L ) if ( theta [ n ] > 0 ) theta [ n ] = theta [ n ] - 377487360L ; else theta [ n ] = theta [ n ] + 377487360L ; goto lab40 ; } break ; } r = s ; s = t ; incr ( k ) ; } lab40: { register integer for_end; k = n - 1 ; for_end = 0 ; if ( k >= for_end) do theta [ k ] = vv [ k ] - takefraction ( theta [ k + 1 ] , uu [ k ] ) ; while ( k-- > for_end ) ; } s = p ; k = 0 ; do { t = mem [ s ] .hhfield .v.RH ; nsincos ( theta [ k ] ) ; st = nsin ; ct = ncos ; nsincos ( - (integer) psi [ k + 1 ] - theta [ k + 1 ] ) ; sf = nsin ; cf = ncos ; setcontrols ( s , t , k ) ; incr ( k ) ; s = t ; } while ( ! ( k == n ) ) ; lab10: ; } void zmakechoices ( knots ) halfword knots ; {/* 30 */ halfword h ; halfword p, q ; integer k, n ; halfword s, t ; scaled delx, dely ; fraction sine, cosine ; { if ( aritherror ) cleararith () ; } if ( internal [ 4 ] > 0 ) printpath ( knots , 541 , true ) ; p = knots ; do { q = mem [ p ] .hhfield .v.RH ; if ( mem [ p + 1 ] .cint == mem [ q + 1 ] .cint ) if ( mem [ p + 2 ] .cint == mem [ q + 2 ] .cint ) if ( mem [ p ] .hhfield .b1 > 1 ) { mem [ p ] .hhfield .b1 = 1 ; if ( mem [ p ] .hhfield .b0 == 4 ) { mem [ p ] .hhfield .b0 = 3 ; mem [ p + 3 ] .cint = 65536L ; } mem [ q ] .hhfield .b0 = 1 ; if ( mem [ q ] .hhfield .b1 == 4 ) { mem [ q ] .hhfield .b1 = 3 ; mem [ q + 5 ] .cint = 65536L ; } mem [ p + 5 ] .cint = mem [ p + 1 ] .cint ; mem [ q + 3 ] .cint = mem [ p + 1 ] .cint ; mem [ p + 6 ] .cint = mem [ p + 2 ] .cint ; mem [ q + 4 ] .cint = mem [ p + 2 ] .cint ; } p = q ; } while ( ! ( p == knots ) ) ; h = knots ; while ( true ) { if ( mem [ h ] .hhfield .b0 != 4 ) goto lab30 ; if ( mem [ h ] .hhfield .b1 != 4 ) goto lab30 ; h = mem [ h ] .hhfield .v.RH ; if ( h == knots ) { mem [ h ] .hhfield .b0 = 5 ; goto lab30 ; } } lab30: ; p = h ; do { q = mem [ p ] .hhfield .v.RH ; if ( mem [ p ] .hhfield .b1 >= 2 ) { while ( ( mem [ q ] .hhfield .b0 == 4 ) && ( mem [ q ] .hhfield .b1 == 4 ) ) q = mem [ q ] .hhfield .v.RH ; k = 0 ; s = p ; n = pathsize ; do { t = mem [ s ] .hhfield .v.RH ; deltax [ k ] = mem [ t + 1 ] .cint - mem [ s + 1 ] .cint ; deltay [ k ] = mem [ t + 2 ] .cint - mem [ s + 2 ] .cint ; delta [ k ] = pythadd ( deltax [ k ] , deltay [ k ] ) ; if ( k > 0 ) { sine = makefraction ( deltay [ k - 1 ] , delta [ k - 1 ] ) ; cosine = makefraction ( deltax [ k - 1 ] , delta [ k - 1 ] ) ; psi [ k ] = narg ( takefraction ( deltax [ k ] , cosine ) + takefraction ( deltay [ k ] , sine ) , takefraction ( deltay [ k ] , cosine ) - takefraction ( deltax [ k ] , sine ) ) ; } incr ( k ) ; s = t ; if ( k == pathsize ) overflow ( 546 , pathsize ) ; if ( s == q ) n = k ; } while ( ! ( ( k >= n ) && ( mem [ s ] .hhfield .b0 != 5 ) ) ) ; if ( k == n ) psi [ n ] = 0 ; else psi [ k ] = psi [ 1 ] ; if ( mem [ q ] .hhfield .b0 == 4 ) { delx = mem [ q + 5 ] .cint - mem [ q + 1 ] .cint ; dely = mem [ q + 6 ] .cint - mem [ q + 2 ] .cint ; if ( ( delx == 0 ) && ( dely == 0 ) ) { mem [ q ] .hhfield .b0 = 3 ; mem [ q + 3 ] .cint = 65536L ; } else { mem [ q ] .hhfield .b0 = 2 ; mem [ q + 3 ] .cint = narg ( delx , dely ) ; } } if ( ( mem [ p ] .hhfield .b1 == 4 ) && ( mem [ p ] .hhfield .b0 == 1 ) ) { delx = mem [ p + 1 ] .cint - mem [ p + 3 ] .cint ; dely = mem [ p + 2 ] .cint - mem [ p + 4 ] .cint ; if ( ( delx == 0 ) && ( dely == 0 ) ) { mem [ p ] .hhfield .b1 = 3 ; mem [ p + 5 ] .cint = 65536L ; } else { mem [ p ] .hhfield .b1 = 2 ; mem [ p + 5 ] .cint = narg ( delx , dely ) ; } } solvechoices ( p , q , n ) ; } else if ( mem [ p ] .hhfield .b1 == 0 ) { mem [ p + 5 ] .cint = mem [ p + 1 ] .cint ; mem [ p + 6 ] .cint = mem [ p + 2 ] .cint ; mem [ q + 3 ] .cint = mem [ q + 1 ] .cint ; mem [ q + 4 ] .cint = mem [ q + 2 ] .cint ; } p = q ; } while ( ! ( p == h ) ) ; if ( internal [ 4 ] > 0 ) printpath ( knots , 542 , true ) ; if ( aritherror ) { { if ( interaction == 3 ) ; printnl ( 263 ) ; print ( 543 ) ; } { helpptr = 2 ; helpline [ 1 ] = 544 ; helpline [ 0 ] = 545 ; } putgeterror () ; aritherror = false ; } }