
(/VERSIONCHECK 2) 

(DEFUN |VECREC2;modInverse| (|c| |p| $)
  (PROG (#1=#:G1804)
    (RETURN
     (QCAR
      (PROG2
          (LETT #1# (SPADCALL |c| |p| 1 (QREFELT $ 10)) |VECREC2;modInverse|)
          (QCDR #1#)
        (|check-union| (QEQCAR #1# 0)
                       (|Record| (|:| |coef1| (|Integer|))
                                 (|:| |coef2| (|Integer|)))
                       #1#)))))) 

(DEFUN |VECREC2;empty;I$;2| (|nint| $)
  (PROG (|intvec| #1=#:G1807)
    (RETURN
     (SEQ
      (LETT |intvec|
            (MAKEARR1
             (PROG1 (LETT #1# |nint| . #2=(|VECREC2;empty;I$;2|))
               (|check-subtype| (>= #1# 0) '(|NonNegativeInteger|) #1#))
             0)
            . #2#)
      (EXIT (VECTOR 1 0 0 |nint| |intvec| (MAKE-ARRAY 0) (MAKE-ARRAY 0))))))) 

(DEFUN |VECREC2;chinese_update;UvI$V;3| (|vec| |p| |statearg| $)
  (PROG (|cor| |ii| #1=#:G1817 |i| |intvec| |mpfact| |nmp| |mpcor| |mpval| |mp|
         |state|)
    (RETURN
     (SEQ (LETT |state| |statearg| . #2=(|VECREC2;chinese_update;UvI$V;3|))
          (LETT |mp| (QVELT |state| 0) . #2#)
          (LETT |mpval| (SPADCALL |mp| |p| (QREFELT $ 12)) . #2#)
          (EXIT
           (COND ((EQL |mpval| 0) (|error| "Duplicate modulus in update"))
                 ('T
                  (SEQ
                   (LETT |mpcor| (|VECREC2;modInverse| |mpval| |p| $) . #2#)
                   (LETT |mpfact| (* |mpcor| |mp|) . #2#)
                   (LETT |nmp| (* |mp| |p|) . #2#)
                   (LETT |mpfact| (SPADCALL |mpfact| |nmp| (QREFELT $ 12))
                         . #2#)
                   (QSETVELT |state| 2 (+ (QVELT |state| 2) 1))
                   (LETT |intvec| (QVELT |state| 4) . #2#)
                   (SEQ (LETT |i| 0 . #2#)
                        (LETT #1# (- (QVELT |state| 3) 1) . #2#) G190
                        (COND ((QSGREATERP |i| #1#) (GO G191)))
                        (SEQ (LETT |ii| (QAREF1 |intvec| |i|) . #2#)
                             (LETT |cor|
                                   (SPADCALL (- (ELT32 |vec| |i|) |ii|) |p|
                                             (QREFELT $ 12))
                                   . #2#)
                             (EXIT
                              (QSETAREF1 |intvec| |i|
                                         (SPADCALL (+ |ii| (* |mpfact| |cor|))
                                                   |nmp| (QREFELT $ 12)))))
                        (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191
                        (EXIT NIL))
                   (EXIT (QSETVELT |state| 0 |nmp|)))))))))) 

(DEFUN |VECREC2;hensel_update;UvI$V;4| (|vec| |p| |statearg| $)
  (PROG (#1=#:G1822 |i| |intvec| |mp| |state|)
    (RETURN
     (SEQ (LETT |state| |statearg| . #2=(|VECREC2;hensel_update;UvI$V;4|))
          (LETT |mp| (QVELT |state| 0) . #2#)
          (LETT |intvec| (QVELT |state| 4) . #2#)
          (SEQ (LETT |i| 0 . #2#) (LETT #1# (- (QVELT |state| 3) 1) . #2#) G190
               (COND ((QSGREATERP |i| #1#) (GO G191)))
               (SEQ
                (EXIT
                 (QSETAREF1 |intvec| |i|
                            (+ (QAREF1 |intvec| |i|)
                               (* (ELT32 |vec| |i|) |mp|)))))
               (LETT |i| (QSADD1 |i|) . #2#) (GO G190) G191 (EXIT NIL))
          (EXIT (QSETVELT |state| 0 (* |p| |mp|))))))) 

(DEFUN |VECREC2;rational_reconstruction;4IU;5| (|x| |y| |i| |j| $)
  (PROG (|r1| |s1| |s0| |tmp| |r0| |qr|)
    (RETURN
     (SEQ (LETT |r0| |y| . #1=(|VECREC2;rational_reconstruction;4IU;5|))
          (LETT |s0| 0 . #1#)
          (LETT |r1| (SPADCALL |x| |y| (QREFELT $ 12)) . #1#)
          (LETT |s1| 1 . #1#)
          (SEQ G190 (COND ((NULL (< |i| |r1|)) (GO G191)))
               (SEQ (LETT |qr| (DIVIDE2 |r0| |r1|) . #1#)
                    (LETT |r0| |r1| . #1#) (LETT |r1| (QCDR |qr|) . #1#)
                    (LETT |tmp| (- |s0| (* (QCAR |qr|) |s1|)) . #1#)
                    (LETT |s0| |s1| . #1#) (EXIT (LETT |s1| |tmp| . #1#)))
               NIL (GO G190) G191 (EXIT NIL))
          (COND
           ((< |s1| 0)
            (SEQ (LETT |s1| (- |s1|) . #1#)
                 (EXIT (LETT |r1| (- |r1|) . #1#)))))
          (EXIT
           (COND
            ((OR (< |j| |s1|) (NULL (EQL (GCD |s1| |y|) 1))) (CONS 1 "failed"))
            ('T (CONS 0 (CONS |r1| |s1|))))))))) 

(DEFUN |VECREC2;rational_reconstruction;$U;6| (|statearg| $)
  (PROG (#1=#:G1868 |cden| |ppr| |pp| |r1| |j| |dens| |nums| #2=#:G1849
         #3=#:G1848 |n| |ok| |bound2| |bound| |j0| |intvec| |modulus| |state|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (LETT |state| |statearg| . #4=(|VECREC2;rational_reconstruction;$U;6|))
        (LETT |modulus| (QVELT |state| 0) . #4#)
        (LETT |intvec| (QVELT |state| 4) . #4#)
        (LETT |j0| (QVELT |state| 1) . #4#)
        (LETT |bound| (QUOTIENT2 (SPADCALL |modulus| (QREFELT $ 21)) 10) . #4#)
        (LETT |bound2| (- |modulus| |bound|) . #4#) (LETT |ok| 'T . #4#)
        (LETT |pp|
              (SPADCALL (QAREF1 |intvec| |j0|) |modulus| |bound| |bound|
                        (QREFELT $ 19))
              . #4#)
        (EXIT
         (COND ((QEQCAR |pp| 1) (CONS 1 "failed"))
               ('T
                (SEQ (LETT |n| (QVELT |state| 3) . #4#)
                     (COND
                      ((SPADCALL (QVELT |state| 5) (QREFELT $ 24))
                       (SEQ
                        (QSETVELT |state| 5
                                  (MAKEARR1
                                   (PROG1 (LETT #3# |n| . #4#)
                                     (|check-subtype| (>= #3# 0)
                                                      '(|NonNegativeInteger|)
                                                      #3#))
                                   0))
                        (EXIT
                         (QSETVELT |state| 6
                                   (MAKEARR1
                                    (PROG1 (LETT #2# |n| . #4#)
                                      (|check-subtype| (>= #2# 0)
                                                       '(|NonNegativeInteger|)
                                                       #2#))
                                    0))))))
                     (LETT |nums| (QVELT |state| 5) . #4#)
                     (LETT |dens| (QVELT |state| 6) . #4#)
                     (LETT |ppr| (QCDR |pp|) . #4#)
                     (QSETAREF1 |nums| |j0| (QCAR |ppr|))
                     (QSETAREF1 |dens| |j0| (QCDR |ppr|))
                     (LETT |cden| (QCDR |ppr|) . #4#) (LETT |j| |j0| . #4#)
                     (EXIT
                      (SEQ G190 NIL
                           (SEQ (LETT |j| (+ |j| 1) . #4#)
                                (COND
                                 ((NULL (< |j| |n|))
                                  (LETT |j| (- |j| |n|) . #4#)))
                                (EXIT
                                 (COND
                                  ((EQL |j| |j0|)
                                   (PROGN
                                    (LETT #1# (CONS 0 (CONS |nums| |dens|))
                                          . #4#)
                                    (GO #1#)))
                                  ('T
                                   (SEQ
                                    (LETT |r1|
                                          (SPADCALL
                                           (* |cden| (QAREF1 |intvec| |j|))
                                           |modulus| (QREFELT $ 12))
                                          . #4#)
                                    (EXIT
                                     (COND
                                      ((< |r1| |bound|)
                                       (SEQ (QSETAREF1 |nums| |j| |r1|)
                                            (EXIT
                                             (QSETAREF1 |dens| |j| |cden|))))
                                      ((< |bound2| |r1|)
                                       (SEQ
                                        (QSETAREF1 |nums| |j|
                                                   (- |r1| |modulus|))
                                        (EXIT (QSETAREF1 |dens| |j| |cden|))))
                                      ('T
                                       (SEQ
                                        (LETT |pp|
                                              (SPADCALL |r1| |modulus| |bound|
                                                        |bound| (QREFELT $ 19))
                                              . #4#)
                                        (EXIT
                                         (COND
                                          ((QEQCAR |pp| 1)
                                           (SEQ (QSETVELT |state| 1 |j|)
                                                (EXIT
                                                 (PROGN
                                                  (LETT #1# (CONS 1 "failed")
                                                        . #4#)
                                                  (GO #1#)))))
                                          ('T
                                           (SEQ (LETT |ppr| (QCDR |pp|) . #4#)
                                                (LETT |cden|
                                                      (* |cden| (QCDR |ppr|))
                                                      . #4#)
                                                (EXIT
                                                 (COND
                                                  ((< |bound| |cden|)
                                                   (SEQ
                                                    (QSETVELT |state| 1 |j|)
                                                    (EXIT
                                                     (PROGN
                                                      (LETT #1#
                                                            (CONS 1 "failed")
                                                            . #4#)
                                                      (GO #1#)))))
                                                  ('T
                                                   (SEQ
                                                    (QSETAREF1 |nums| |j|
                                                               (QCAR |ppr|))
                                                    (EXIT
                                                     (QSETAREF1 |dens| |j|
                                                                |cden|)))))))))))))))))))
                           NIL (GO G190) G191 (EXIT NIL)))))))))
      #1# (EXIT #1#))))) 

(DEFUN |VECREC2;lcm| (|nums| |lo| |hi| $)
  (PROG (|res| |i|)
    (RETURN
     (SEQ (LETT |res| (QAREF1 |nums| |lo|) . #1=(|VECREC2;lcm|))
          (SEQ (LETT |i| (+ |lo| 1) . #1#) G190 (COND ((> |i| |hi|) (GO G191)))
               (SEQ
                (EXIT
                 (LETT |res|
                       (SPADCALL |res| (QAREF1 |nums| |i|) (QREFELT $ 28))
                       . #1#)))
               (LETT |i| (+ |i| 1) . #1#) (GO G190) G191 (EXIT NIL))
          (EXIT |res|))))) 

(DEFUN |VECREC2;gcd| (|nums| |lo| |hi| $)
  (PROG (|res| |i|)
    (RETURN
     (SEQ (LETT |res| (QAREF1 |nums| |lo|) . #1=(|VECREC2;gcd|))
          (SEQ (LETT |i| (+ |lo| 1) . #1#) G190 (COND ((> |i| |hi|) (GO G191)))
               (SEQ (EXIT (LETT |res| (GCD |res| (QAREF1 |nums| |i|)) . #1#)))
               (LETT |i| (+ |i| 1) . #1#) (GO G190) G191 (EXIT NIL))
          (EXIT |res|))))) 

(DEFUN |VECREC2;remove_denoms;V3Pa;9| (|block_offsets| |nums| |dens| $)
  (PROG (#1=#:G1880 |i| |cfactor| |tmpp2| |cden| |hi| |li| |ib| |res| |np|
         |nb|)
    (RETURN
     (SEQ
      (LETT |nb| (QVSIZE |block_offsets|)
            . #2=(|VECREC2;remove_denoms;V3Pa;9|))
      (LETT |np| (QVSIZE |nums|) . #2#) (LETT |res| (MAKEARR1 |np| 0) . #2#)
      (SEQ (LETT |ib| 1 . #2#) G190
           (COND ((QSGREATERP |ib| |nb|) #3=(GO G191)))
           (SEQ
            (LETT |li| (SPADCALL |block_offsets| |ib| (QREFELT $ 30)) . #2#)
            (LETT |hi|
                  (COND ((EQL |ib| |nb|) |np|)
                        ('T
                         (SPADCALL |block_offsets| (+ |ib| 1) (QREFELT $ 30))))
                  . #2#)
            (LETT |hi| (- |hi| 1) . #2#)
            (LETT |cden| (|VECREC2;lcm| |dens| |li| |hi| $) . #2#)
            (SEQ (LETT |i| |li| . #2#) G190 (COND ((> |i| |hi|) #3#))
                 (SEQ
                  (LETT |tmpp2|
                        (PROG2
                            (LETT #1#
                                  (SPADCALL |cden| (QAREF1 |dens| |i|)
                                            (QREFELT $ 32))
                                  . #2#)
                            (QCDR #1#)
                          (|check-union| (QEQCAR #1# 0) (|Integer|) #1#))
                        . #2#)
                  (EXIT (QSETAREF1 |res| |i| (* (QAREF1 |nums| |i|) |tmpp2|))))
                 (LETT |i| (+ |i| 1) . #2#) #4=(GO G190) G191 (EXIT NIL))
            (LETT |cfactor| (|VECREC2;gcd| |res| |li| |hi| $) . #2#)
            (EXIT
             (COND
              ((NULL (EQL |cfactor| 1))
               (SEQ (LETT |i| |li| . #2#) G190 (COND ((> |i| |hi|) #3#))
                    (SEQ
                     (EXIT
                      (QSETAREF1 |res| |i|
                                 (PROG2
                                     (LETT #1#
                                           (SPADCALL (QAREF1 |res| |i|)
                                                     |cfactor| (QREFELT $ 32))
                                           . #2#)
                                     (QCDR #1#)
                                   (|check-union| (QEQCAR #1# 0) (|Integer|)
                                                  #1#)))))
                    (LETT |i| (+ |i| 1) . #2#) #4# G191 (EXIT NIL))))))
           (LETT |ib| (QSADD1 |ib|) . #2#) #4# G191 (EXIT NIL))
      (EXIT |res|))))) 

(DEFUN |VECREC2;reconstruct;$VU;10| (|statearg| |block_offsets| $)
  (PROG (|ppr| #1=#:G1901 |pp|)
    (RETURN
     (SEQ
      (EXIT
       (SEQ
        (LETT |pp| (SPADCALL |statearg| (QREFELT $ 27))
              . #2=(|VECREC2;reconstruct;$VU;10|))
        (EXIT
         (COND
          ((QEQCAR |pp| 1) (PROGN (LETT #1# (CONS 1 "failed") . #2#) (GO #1#)))
          ('T
           (SEQ (LETT |ppr| (QCDR |pp|) . #2#)
                (EXIT
                 (CONS 0
                       (SPADCALL |block_offsets| (QCAR |ppr|) (QCDR |ppr|)
                                 (QREFELT $ 33))))))))))
      #1# (EXIT #1#))))) 

(DEFUN |VectorIntegerReconstructor| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G1903)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|VectorIntegerReconstructor|)
                . #3=(|VectorIntegerReconstructor|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|VectorIntegerReconstructor|
                         (LIST
                          (CONS NIL
                                (CONS 1 (|VectorIntegerReconstructor;|))))))
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#)
              (HREM |$ConstructorCache| '|VectorIntegerReconstructor|))))))))))) 

(DEFUN |VectorIntegerReconstructor;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|VectorIntegerReconstructor|)
            . #1=(|VectorIntegerReconstructor|))
      (LETT $ (GETREFV 36) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|VectorIntegerReconstructor| NIL
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6
                (|Record| (|:| |cmod| (|Integer|)) (|:| |curj| (|Integer|))
                          (|:| |nmods| (|Integer|)) (|:| |nints| (|Integer|))
                          (|:| |ints| (|PrimitiveArray| (|Integer|)))
                          (|:| |numers| (|PrimitiveArray| (|Integer|)))
                          (|:| |denoms| (|PrimitiveArray| (|Integer|)))))
      $)))) 

(MAKEPROP '|VectorIntegerReconstructor| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL '|Rep|
              (|Record| (|:| |coef1| $) (|:| |coef2| $)) (|Union| 7 '"failed")
              (|Integer|) (0 . |extendedEuclidean|) |VECREC2;empty;I$;2|
              (7 . |positiveRemainder|) (|Void|) (|U32Vector|)
              |VECREC2;chinese_update;UvI$V;3| |VECREC2;hensel_update;UvI$V;4|
              (|Record| (|:| |num| 9) (|:| |den| 9)) (|Union| 17 '"failed")
              |VECREC2;rational_reconstruction;4IU;5| (|IntegerRoots| 9)
              (13 . |approxSqrt|) (|Boolean|) (|PrimitiveArray| 9)
              (18 . |empty?|) (|Record| (|:| |numers| 23) (|:| |denoms| 23))
              (|Union| 25 '"failed") |VECREC2;rational_reconstruction;$U;6|
              (23 . |lcm|) (|Vector| 9) (29 . |elt|) (|Union| $ '"failed")
              (35 . |exquo|) |VECREC2;remove_denoms;V3Pa;9|
              (|Union| 23 '"failed") |VECREC2;reconstruct;$VU;10|)
           '#(|remove_denoms| 41 |reconstruct| 48 |rational_reconstruction| 54
              |hensel_update| 67 |empty| 74 |chinese_update| 79)
           'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 35
                                                 '(3 9 8 0 0 0 10 2 9 0 0 0 12
                                                   1 20 9 9 21 1 23 22 0 24 2 9
                                                   0 0 0 28 2 29 9 0 9 30 2 9
                                                   31 0 0 32 3 0 23 29 23 23 33
                                                   2 0 34 0 29 35 1 0 26 0 27 4
                                                   0 18 9 9 9 9 19 3 0 13 14 9
                                                   0 16 1 0 0 9 11 3 0 13 14 9
                                                   0 15)))))
           '|lookupComplete|)) 

(MAKEPROP '|VectorIntegerReconstructor| 'NILADIC T) 
