
(/VERSIONCHECK 2) 

(DEFUN |INMODGCD;reduction;BPRBP;1| (|u| |p| $)
  (COND
    ((SPADCALL |p| (|spadConstant| $ 10) (QREFELT $ 13)) |u|)
    ('T
     (SPADCALL (CONS #'|INMODGCD;reduction;BPRBP;1!0| (VECTOR $ |p|))
         |u| (QREFELT $ 16))))) 

(DEFUN |INMODGCD;reduction;BPRBP;1!0| (|#1| $$)
  (SPADCALL |#1| (QREFELT $$ 1) (QREFELT (QREFELT $$ 0) 14))) 

(DEFUN |INMODGCD;reduction;BPRBP;2| (|u| |p| $)
  (COND
    ((SPADCALL |p| (|spadConstant| $ 10) (QREFELT $ 13)) |u|)
    ('T
     (SPADCALL (CONS #'|INMODGCD;reduction;BPRBP;2!0| (VECTOR $ |p|))
         |u| (QREFELT $ 16))))) 

(DEFUN |INMODGCD;reduction;BPRBP;2!0| (|#1| $$)
  (SPADCALL |#1| (QREFELT $$ 1) (QREFELT (QREFELT $$ 0) 18))) 

(DEFUN |INMODGCD;modularGcdPrimitive;LBP;3| (|listf| $)
  (PROG (|f| #0=#:G1855 |g|)
    (RETURN
      (SEQ (COND
             ((NULL |listf|) (|spadConstant| $ 11))
             ('T
              (SEQ (LETT |g| (|SPADfirst| |listf|)
                         . #1=(|INMODGCD;modularGcdPrimitive;LBP;3|))
                   (SEQ (LETT |f| NIL . #1#)
                        (LETT #0# (CDR |listf|) . #1#) G190
                        (COND
                          ((OR (ATOM #0#)
                               (PROGN (LETT |f| (CAR #0#) . #1#) NIL)
                               (NULL (< 0
                                      (SPADCALL |g| (QREFELT $ 24)))))
                           (GO G191)))
                        (SEQ (EXIT (COND
                                     ((COND
                                        ((SPADCALL |f| (QREFELT $ 21))
                                         'NIL)
                                        ('T 'T))
                                      (LETT |g|
                                       (|INMODGCD;modGcdPrimitive| |g|
                                        |f| $) . #1#)))))
                        (LETT #0# (CDR #0#) . #1#) (GO G190) G191
                        (EXIT NIL))
                   (EXIT |g|)))))))) 

(DEFUN |INMODGCD;modularGcd;LBP;4| (|listf| $)
  (PROG (#0=#:G1879 #1=#:G1858 #2=#:G1856 #3=#:G1857 |mdeg| |minpol1|
            #4=#:G1880 #5=#:G1881 #6=#:G1882 #7=#:G1883 |listdeg|
            #8=#:G1884 #9=#:G1885 |listCont| |contgcd| #10=#:G1886 |cf|
            #11=#:G1888 |f| #12=#:G1887 #13=#:G1863 |minpol| |ans|)
    (RETURN
      (SEQ (LETT |listf|
                 (SPADCALL (|spadConstant| $ 11) |listf|
                     (QREFELT $ 27))
                 . #14=(|INMODGCD;modularGcd;LBP;4|))
           (EXIT (COND
                   ((NULL |listf|) (|spadConstant| $ 11))
                   ((EQL (LENGTH |listf|) 1) (|SPADfirst| |listf|))
                   ('T
                    (SEQ (LETT |minpol| (|spadConstant| $ 29) . #14#)
                         (LETT |mdeg|
                               (PROGN
                                 (LETT #3# NIL . #14#)
                                 (SEQ (LETT |f| NIL . #14#)
                                      (LETT #0# |listf| . #14#) G190
                                      (COND
                                        ((OR (ATOM #0#)
                                          (PROGN
                                            (LETT |f| (CAR #0#) . #14#)
                                            NIL))
                                         #15=(GO G191)))
                                      (SEQ
                                       (EXIT
                                        (PROGN
                                          (LETT #1#
                                           (SPADCALL |f|
                                            (QREFELT $ 30)) . #14#)
                                          (COND
                                            (#3#
                                             (LETT #2#
                                              (MIN #2# #1#) . #14#))
                                            ('T
                                             (PROGN
                                               (LETT #2# #1# . #14#)
                                               (LETT #3# 'T . #14#)))))))
                                      (LETT #0# (CDR #0#) . #14#)
                                      #16=(GO G190) G191 (EXIT NIL))
                                 (COND
                                   (#3# #2#)
                                   ('T (|IdentityError| '|min|)))) . #14#)
                         (COND
                           ((< 0 |mdeg|)
                            (SEQ (LETT |minpol1|
                                       (SPADCALL (|spadConstant| $ 28)
                                        |mdeg| (QREFELT $ 33)) . #14#)
                                 (LETT |listf|
                                       (PROGN
                                         (LETT #4# NIL . #14#)
                                         (SEQ (LETT |f| NIL . #14#)
                                          (LETT #5# |listf| . #14#)
                                          G190
                                          (COND
                                            ((OR (ATOM #5#)
                                              (PROGN
                                                (LETT |f|
                                                 (CAR #5#) . #14#)
                                                NIL))
                                             #15#))
                                          (SEQ
                                           (EXIT
                                            (LETT #4#
                                             (CONS
                                              (PROG2
                                               (LETT #13#
                                                (SPADCALL |f| |minpol1|
                                                 (QREFELT $ 35)) . #14#)
                                               (QCDR #13#)
                                                (|check-union|
                                                 (QEQCAR #13# 0)
                                                 (QREFELT $ 7) #13#))
                                              #4#) . #14#)))
                                          (LETT #5# (CDR #5#) . #14#)
                                          #16# G191
                                          (EXIT (NREVERSE0 #4#)))) . #14#)
                                 (EXIT (LETT |minpol|
                                        (SPADCALL |minpol| |minpol1|
                                         (QREFELT $ 36)) . #14#)))))
                         (LETT |listdeg|
                               (PROGN
                                 (LETT #6# NIL . #14#)
                                 (SEQ (LETT |f| NIL . #14#)
                                      (LETT #7# |listf| . #14#) G190
                                      (COND
                                        ((OR (ATOM #7#)
                                          (PROGN
                                            (LETT |f| (CAR #7#) . #14#)
                                            NIL))
                                         #15#))
                                      (SEQ
                                       (EXIT
                                        (LETT #6#
                                         (CONS
                                          (SPADCALL |f| (QREFELT $ 24))
                                          #6#) . #14#)))
                                      (LETT #7# (CDR #7#) . #14#) #16#
                                      G191 (EXIT (NREVERSE0 #6#)))) . #14#)
                         (LETT |listCont|
                               (PROGN
                                 (LETT #8# NIL . #14#)
                                 (SEQ (LETT |f| NIL . #14#)
                                      (LETT #9# |listf| . #14#) G190
                                      (COND
                                        ((OR (ATOM #9#)
                                          (PROGN
                                            (LETT |f| (CAR #9#) . #14#)
                                            NIL))
                                         #15#))
                                      (SEQ
                                       (EXIT
                                        (LETT #8#
                                         (CONS
                                          (SPADCALL |f| (QREFELT $ 37))
                                          #8#) . #14#)))
                                      (LETT #9# (CDR #9#) . #14#) #16#
                                      G191 (EXIT (NREVERSE0 #8#)))) . #14#)
                         (LETT |contgcd|
                               (SPADCALL |listCont| (QREFELT $ 39)) . #14#)
                         (LETT |listf|
                               (PROGN
                                 (LETT #10# NIL . #14#)
                                 (SEQ (LETT |cf| NIL . #14#)
                                      (LETT #11# |listCont| . #14#)
                                      (LETT |f| NIL . #14#)
                                      (LETT #12# |listf| . #14#) G190
                                      (COND
                                        ((OR (ATOM #12#)
                                          (PROGN
                                            (LETT |f|
                                             (CAR #12#) . #14#)
                                            NIL)
                                          (ATOM #11#)
                                          (PROGN
                                            (LETT |cf|
                                             (CAR #11#) . #14#)
                                            NIL))
                                         #15#))
                                      (SEQ
                                       (EXIT
                                        (LETT #10#
                                         (CONS
                                          (PROG2
                                           (LETT #13#
                                            (SPADCALL |f| |cf|
                                             (QREFELT $ 40)) . #14#)
                                           (QCDR #13#)
                                            (|check-union|
                                             (QEQCAR #13# 0)
                                             (QREFELT $ 7) #13#))
                                          #10#) . #14#)))
                                      (LETT #12#
                                       (PROG1 (CDR #12#)
                                         (LETT #11# (CDR #11#) . #14#)) . #14#)
                                      #16# G191
                                      (EXIT (NREVERSE0 #10#)))) . #14#)
                         (LETT |minpol|
                               (SPADCALL |contgcd| |minpol|
                                   (QREFELT $ 41)) . #14#)
                         (LETT |ans|
                               (COND
                                 ((SPADCALL (|spadConstant| $ 29)
                                      |listf| (QREFELT $ 42))
                                  (|spadConstant| $ 29))
                                 ((SPADCALL 1 |listdeg| (QREFELT $ 44))
                                  (|INMODGCD;lincase| |listdeg| |listf|
                                      $))
                                 ('T (SPADCALL |listf| (QREFELT $ 26)))) . #14#)
                         (EXIT (SPADCALL |minpol| |ans| (QREFELT $ 36))))))))))) 

(DEFUN |INMODGCD;lincase| (|listdeg| |listf| $)
  (PROG (|n| |g| |f| #0=#:G1896 |f1| #1=#:G1895)
    (RETURN
      (SEQ (EXIT (SEQ (LETT |n| (SPADCALL 1 |listdeg| (QREFELT $ 47))
                            . #2=(|INMODGCD;lincase|))
                      (LETT |g|
                            (SPADCALL |listf| |n| (QREFELT $ 48)) . #2#)
                      (SEQ (LETT |f| NIL . #2#)
                           (LETT #0# |listf| . #2#) G190
                           (COND
                             ((OR (ATOM #0#)
                                  (PROGN
                                    (LETT |f| (CAR #0#) . #2#)
                                    NIL))
                              (GO G191)))
                           (SEQ (LETT |f1|
                                      (SPADCALL |f| |g| (QREFELT $ 35)) . #2#)
                                (EXIT (COND
                                        ((QEQCAR |f1| 1)
                                         (PROGN
                                           (LETT #1#
                                            (|spadConstant| $ 29) . #2#)
                                           (GO #1#))))))
                           (LETT #0# (CDR #0#) . #2#) (GO G190) G191
                           (EXIT NIL))
                      (EXIT |g|)))
           #1# (EXIT #1#))))) 

(DEFUN |INMODGCD;test| (|f| |g| |d| $)
  (PROG (|d0|)
    (RETURN
      (SEQ (LETT |d0| (SPADCALL |d| 0 (QREFELT $ 49)) |INMODGCD;test|)
           (EXIT (COND
                   ((OR (QEQCAR (SPADCALL
                                    (SPADCALL |f| 0 (QREFELT $ 49))
                                    |d0| (QREFELT $ 50))
                                1)
                        (OR (QEQCAR (SPADCALL
                                     (SPADCALL |g| 0 (QREFELT $ 49))
                                     |d0| (QREFELT $ 50))
                                    1)
                            (OR (QEQCAR (SPADCALL |f| |d|
                                         (QREFELT $ 35))
                                        1)
                                (QEQCAR (SPADCALL |g| |d|
                                         (QREFELT $ 35))
                                        1))))
                    'NIL)
                   ('T 'T))))))) 

(DEFUN |INMODGCD;modGcdPrimitive| (|f| |g| $)
  (PROG (|df| |dg| |lcf| |lcg| |lcd| |bound| |prime| |fp| |gp| |dgp|
              |lcdp| |ldp| |dp| |correction| |cont| #0=#:G1911 |ans|
              |correctionFactor| |soFarModulus| |soFar| |testdeg|
              |result| #1=#:G1928)
    (RETURN
      (SEQ (EXIT (SEQ (LETT |df| (SPADCALL |f| (QREFELT $ 24))
                            . #2=(|INMODGCD;modGcdPrimitive|))
                      (LETT |dg| (SPADCALL |g| (QREFELT $ 24)) . #2#)
                      (LETT |lcf| (SPADCALL |f| (QREFELT $ 51)) . #2#)
                      (LETT |lcg| (SPADCALL |g| (QREFELT $ 51)) . #2#)
                      (LETT |lcd|
                            (SPADCALL |lcf| |lcg| (QREFELT $ 52)) . #2#)
                      (LETT |prime| (QREFELT $ 8) . #2#)
                      (LETT |bound|
                            (|INMODGCD;mbound| |f| |g| $) . #2#)
                      (SEQ G190
                           (COND
                             ((NULL (SPADCALL
                                     (SPADCALL |lcd| |prime|
                                      (QREFELT $ 18))
                                     (QREFELT $ 53)))
                              #3=(GO G191)))
                           (SEQ (EXIT (LETT |prime|
                                       (SPADCALL |prime| |bound|
                                        (QREFELT $ 9)) . #2#)))
                           NIL #4=(GO G190) G191 (EXIT NIL))
                      (LETT |soFar|
                            (SPADCALL
                                (SPADCALL
                                    (SPADCALL |f| |prime|
                                     (QREFELT $ 54))
                                    (SPADCALL |g| |prime|
                                     (QREFELT $ 54))
                                    (QREFELT $ 55))
                                (QREFELT $ 56)) . #2#)
                      (LETT |testdeg|
                            (SPADCALL |soFar| (QREFELT $ 24)) . #2#)
                      (EXIT (COND
                              ((ZEROP |testdeg|)
                               (PROGN
                                 (LETT #1# (|spadConstant| $ 29) . #2#)
                                 (GO #1#)))
                              ('T
                               (SEQ (LETT |ldp|
                                     (SEQ
                                      (LETT |lcdp|
                                       (SPADCALL |soFar|
                                        (QREFELT $ 51)) . #2#)
                                      (EXIT
                                       (COND
                                         ((SPADCALL |lcdp|
                                           (|spadConstant| $ 28)
                                           (QREFELT $ 13))
                                          (SPADCALL
                                           (SPADCALL |lcd|
                                            (QREFELT $ 57))
                                           |prime| (QREFELT $ 54)))
                                         ('T
                                          (SPADCALL
                                           (SPADCALL
                                            (SPADCALL
                                             (|INMODGCD;modInverse|
                                              |lcdp| |prime| $)
                                             |lcd| (QREFELT $ 58))
                                            (QREFELT $ 57))
                                           |prime| (QREFELT $ 54)))))) . #2#)
                                    (LETT |soFar|
                                     (SPADCALL
                                      (SPADCALL
                                       (SPADCALL
                                        (SPADCALL |ldp| (QREFELT $ 56))
                                        |soFar| (QREFELT $ 36))
                                       |prime| (QREFELT $ 54))
                                      (QREFELT $ 56)) . #2#)
                                    (LETT |soFarModulus| |prime| . #2#)
                                    (EXIT
                                     (SEQ G190 (COND ((NULL 'T) #3#))
                                      (SEQ
                                       (LETT |prime|
                                        (SPADCALL |prime| |bound|
                                         (QREFELT $ 9)) . #2#)
                                       (EXIT
                                        (COND
                                          ((SPADCALL
                                            (SPADCALL |lcd| |prime|
                                             (QREFELT $ 18))
                                            (|spadConstant| $ 10)
                                            (QREFELT $ 13))
                                           "next prime")
                                          ('T
                                           (SEQ
                                            (LETT |fp|
                                             (SPADCALL |f| |prime|
                                              (QREFELT $ 54)) . #2#)
                                            (LETT |gp|
                                             (SPADCALL |g| |prime|
                                              (QREFELT $ 54)) . #2#)
                                            (LETT |dp|
                                             (SPADCALL |fp| |gp|
                                              (QREFELT $ 55)) . #2#)
                                            (LETT |dgp|
                                             (SPADCALL |dp|
                                              (QREFELT $ 59)) . #2#)
                                            (COND
                                              ((EQL |dgp| 0)
                                               (PROGN
                                                 (LETT #1#
                                                  (|spadConstant| $ 29) . #2#)
                                                 (GO #1#))))
                                            (COND
                                              ((EQL |dgp| |dg|)
                                               (COND
                                                 ((NULL
                                                   (QEQCAR
                                                    (SPADCALL |f| |g|
                                                     (QREFELT $ 35))
                                                    1))
                                                  (PROGN
                                                    (LETT #1#
                                                     |g| . #2#)
                                                    (GO #1#))))))
                                            (COND
                                              ((EQL |dgp| |df|)
                                               (COND
                                                 ((NULL
                                                   (QEQCAR
                                                    (SPADCALL |g| |f|
                                                     (QREFELT $ 35))
                                                    1))
                                                  (PROGN
                                                    (LETT #1#
                                                     |f| . #2#)
                                                    (GO #1#))))))
                                            (EXIT
                                             (COND
                                               ((< |testdeg| |dgp|)
                                                "next prime")
                                               ('T
                                                (SEQ
                                                 (LETT |ldp|
                                                  (SEQ
                                                   (LETT |lcdp|
                                                    (SPADCALL
                                                     (SPADCALL |dp|
                                                      (QREFELT $ 56))
                                                     (QREFELT $ 51)) . #2#)
                                                   (EXIT
                                                    (COND
                                                      ((SPADCALL |lcdp|
                                                        (|spadConstant|
                                                         $ 28)
                                                        (QREFELT $ 13))
                                                       (SPADCALL
                                                        (SPADCALL |lcd|
                                                         (QREFELT $ 57))
                                                        |prime|
                                                        (QREFELT $ 54)))
                                                      ('T
                                                       (SPADCALL
                                                        (SPADCALL
                                                         (SPADCALL
                                                          (|INMODGCD;modInverse|
                                                           |lcdp|
                                                           |prime| $)
                                                          |lcd|
                                                          (QREFELT $
                                                           58))
                                                         (QREFELT $ 57))
                                                        |prime|
                                                        (QREFELT $ 54)))))) . #2#)
                                                 (LETT |dp|
                                                  (SPADCALL |ldp| |dp|
                                                   (QREFELT $ 60)) . #2#)
                                                 (EXIT
                                                  (COND
                                                    ((EQL |dgp|
                                                      |testdeg|)
                                                     (SEQ
                                                      (LETT
                                                       |correction|
                                                       (SPADCALL
                                                        (SPADCALL
                                                         (SPADCALL
                                                          (SPADCALL
                                                           |dp|
                                                           (QREFELT $
                                                            56))
                                                          |soFar|
                                                          (QREFELT $
                                                           61))
                                                         |prime|
                                                         (QREFELT $ 54))
                                                        (QREFELT $ 56)) . #2#)
                                                      (EXIT
                                                       (COND
                                                         ((SPADCALL
                                                           |correction|
                                                           (QREFELT $
                                                            21))
                                                          (SEQ
                                                           (LETT |ans|
                                                            (SPADCALL
                                                             (SPADCALL
                                                              (SPADCALL
                                                               (SPADCALL
                                                                |lcd|
                                                                (QREFELT
                                                                 $ 57))
                                                               |soFar|
                                                               (QREFELT
                                                                $ 36))
                                                              |soFarModulus|
                                                              (QREFELT
                                                               $ 54))
                                                             (QREFELT $
                                                              56)) . #2#)
                                                           (LETT |cont|
                                                            (SPADCALL
                                                             |ans|
                                                             (QREFELT $
                                                              37)) . #2#)
                                                           (LETT |ans|
                                                            (PROG2
                                                             (LETT #0#
                                                              (SPADCALL
                                                               |ans|
                                                               |cont|
                                                               (QREFELT
                                                                $ 40)) . #2#)
                                                             (QCDR #0#)
                                                              (|check-union|
                                                               (QEQCAR
                                                                #0# 0)
                                                               (QREFELT
                                                                $ 7)
                                                               #0#)) . #2#)
                                                           (EXIT
                                                            (COND
                                                              ((|INMODGCD;test|
                                                                |f| |g|
                                                                |ans|
                                                                $)
                                                               (PROGN
                                                                 (LETT
                                                                  #1#
                                                                  |ans| . #2#)
                                                                 (GO
                                                                  #1#)))
                                                              ('T
                                                               (LETT
                                                                |soFarModulus|
                                                                (SPADCALL
                                                                 |soFarModulus|
                                                                 |prime|
                                                                 (QREFELT
                                                                  $ 58)) . #2#))))))
                                                         ('T
                                                          (SEQ
                                                           (LETT
                                                            |correctionFactor|
                                                            (|INMODGCD;modInverse|
                                                             (SPADCALL
                                                              |soFarModulus|
                                                              |prime|
                                                              (QREFELT
                                                               $ 18))
                                                             |prime| $) . #2#)
                                                           (LETT
                                                            |soFar|
                                                            (SPADCALL
                                                             |soFar|
                                                             (SPADCALL
                                                              |soFarModulus|
                                                              (SPADCALL
                                                               |correctionFactor|
                                                               |correction|
                                                               (QREFELT
                                                                $ 41))
                                                              (QREFELT
                                                               $ 41))
                                                             (QREFELT $
                                                              62)) . #2#)
                                                           (LETT
                                                            |soFarModulus|
                                                            (SPADCALL
                                                             |soFarModulus|
                                                             |prime|
                                                             (QREFELT $
                                                              58)) . #2#)
                                                           (EXIT
                                                            (LETT
                                                             |soFar|
                                                             (SPADCALL
                                                              (SPADCALL
                                                               |soFar|
                                                               |soFarModulus|
                                                               (QREFELT
                                                                $ 54))
                                                              (QREFELT
                                                               $ 56)) . #2#))))))))
                                                    ((< |dgp|
                                                      |testdeg|)
                                                     (SEQ
                                                      (LETT
                                                       |soFarModulus|
                                                       |prime| . #2#)
                                                      (LETT |soFar|
                                                       (SPADCALL |dp|
                                                        (QREFELT $ 56)) . #2#)
                                                      (EXIT
                                                       (LETT |testdeg|
                                                        |dgp| . #2#))))
                                                    ((NULL
                                                      (QREFELT $ 20))
                                                     (COND
                                                       ((< 1
                                                         (SPADCALL
                                                          |prime|
                                                          (QREFELT $
                                                           66)))
                                                        (SEQ
                                                         (LETT |result|
                                                          (SPADCALL
                                                           |dp|
                                                           (QREFELT $
                                                            56)) . #2#)
                                                         (EXIT
                                                          (COND
                                                            ((|INMODGCD;test|
                                                              |f| |g|
                                                              |result|
                                                              $)
                                                             (PROGN
                                                               (LETT
                                                                #1#
                                                                |result| . #2#)
                                                               (GO #1#))))))))))))))))))))
                                      NIL #4# G191 (EXIT NIL)))))))))
           #1# (EXIT #1#))))) 

(DEFUN |INMODGCD;merge| (|p| |q| $)
  (COND
    ((SPADCALL |p| |q| (QREFELT $ 13)) (CONS 0 |p|))
    ((SPADCALL |p| (|spadConstant| $ 10) (QREFELT $ 13)) (CONS 0 |q|))
    ((SPADCALL |q| (|spadConstant| $ 10) (QREFELT $ 13)) (CONS 0 |p|))
    ('T (CONS 1 "failed")))) 

(DEFUN |INMODGCD;modInverse| (|c| |p| $)
  (PROG (#0=#:G1939)
    (RETURN
      (QCAR (PROG2 (LETT #0#
                         (SPADCALL |c| |p| (|spadConstant| $ 28)
                             (QREFELT $ 69))
                         |INMODGCD;modInverse|)
                   (QCDR #0#)
              (|check-union| (QEQCAR #0# 0)
                  (|Record| (|:| |coef1| (QREFELT $ 6))
                      (|:| |coef2| (QREFELT $ 6)))
                  #0#)))))) 

(DEFUN |INMODGCD;exactquo| (|u| |v| |p| $)
  (PROG (|invlcv| |r|)
    (RETURN
      (SEQ (LETT |invlcv|
                 (|INMODGCD;modInverse| (SPADCALL |v| (QREFELT $ 51))
                     |p| $)
                 . #0=(|INMODGCD;exactquo|))
           (LETT |r|
                 (SPADCALL |u|
                     (SPADCALL (SPADCALL |invlcv| |v| (QREFELT $ 41))
                         |p| (QREFELT $ 17))
                     (QREFELT $ 71)) . #0#)
           (COND
             ((NULL (SPADCALL (SPADCALL (QCDR |r|) |p| (QREFELT $ 17))
                        (|spadConstant| $ 11) (QREFELT $ 72)))
              (EXIT (CONS 1 "failed"))))
           (EXIT (CONS 0
                       (SPADCALL
                           (SPADCALL |invlcv| (QCAR |r|)
                               (QREFELT $ 41))
                           |p| (QREFELT $ 17)))))))) 

(DEFUN |INMODGCD;height| (|f| $)
  (PROG (|degf| |cc| #0=#:G1955 #1=#:G1952 #2=#:G1950 #3=#:G1951)
    (RETURN
      (SEQ (LETT |degf| (SPADCALL |f| (QREFELT $ 24))
                 . #4=(|INMODGCD;height|))
           (EXIT (PROGN
                   (LETT #3# NIL . #4#)
                   (SEQ (LETT |cc| NIL . #4#)
                        (LETT #0# (SPADCALL |f| (QREFELT $ 74)) . #4#)
                        G190
                        (COND
                          ((OR (ATOM #0#)
                               (PROGN (LETT |cc| (CAR #0#) . #4#) NIL))
                           (GO G191)))
                        (SEQ (EXIT (PROGN
                                     (LETT #1#
                                      (SPADCALL |cc| (QREFELT $ 66)) . #4#)
                                     (COND
                                       (#3#
                                        (LETT #2# (MAX #2# #1#) . #4#))
                                       ('T
                                        (PROGN
                                          (LETT #2# #1# . #4#)
                                          (LETT #3# 'T . #4#)))))))
                        (LETT #0# (CDR #0#) . #4#) (GO G190) G191
                        (EXIT NIL))
                   (COND (#3# #2#) ('T (|IdentityError| '|max|))))))))) 

(DEFUN |INMODGCD;mbound| (|f| |g| $)
  (PROG (|hf| |hg|)
    (RETURN
      (SEQ (LETT |hf| (|INMODGCD;height| |f| $)
                 . #0=(|INMODGCD;mbound|))
           (LETT |hg| (|INMODGCD;height| |g| $) . #0#)
           (EXIT (SPADCALL 2 (MIN |hf| |hg|) (QREFELT $ 76))))))) 

(DEFUN |InnerModularGcd| (&REST #0=#:G1958)
  (PROG ()
    (RETURN
      (PROG (#1=#:G1959)
        (RETURN
          (COND
            ((LETT #1#
                   (|lassocShiftWithFunction| (|devaluateList| #0#)
                       (HGET |$ConstructorCache| '|InnerModularGcd|)
                       '|domainEqualList|)
                   . #2=(|InnerModularGcd|))
             (|CDRwithIncrement| #1#))
            ('T
             (UNWIND-PROTECT
               (PROG1 (APPLY (|function| |InnerModularGcd;|) #0#)
                 (LETT #1# T . #2#))
               (COND
                 ((NOT #1#)
                  (HREM |$ConstructorCache| '|InnerModularGcd|))))))))))) 

(DEFUN |InnerModularGcd;| (|#1| |#2| |#3| |#4|)
  (PROG (DV$1 DV$2 DV$3 DV$4 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|InnerModularGcd|))
        (LETT DV$2 (|devaluate| |#2|) . #0#)
        (LETT DV$3 (|devaluate| |#3|) . #0#)
        (LETT DV$4 (|devaluate| |#4|) . #0#)
        (LETT |dv$|
              (LIST '|InnerModularGcd| DV$1 DV$2 DV$3 DV$4) . #0#)
        (LETT $ (GETREFV 77) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache| '|InnerModularGcd|
            (LIST DV$1 DV$2 DV$3 DV$4) (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        (QSETREFV $ 7 |#2|)
        (QSETREFV $ 8 |#3|)
        (QSETREFV $ 9 |#4|)
        (COND
          ((|HasCategory| |#1| '(|IntegerNumberSystem|))
           (QSETREFV $ 17
               (CONS (|dispatchFunction| |INMODGCD;reduction;BPRBP;1|)
                     $)))
          ('T
           (QSETREFV $ 17
               (CONS (|dispatchFunction| |INMODGCD;reduction;BPRBP;2|)
                     $))))
        (QSETREFV $ 19
            (|EuclideanModularRing| |#1| |#2| |#1| (ELT $ 17)
                (CONS (|function| |INMODGCD;merge|) $)
                (CONS (|function| |INMODGCD;exactquo|) $)))
        (QSETREFV $ 20 (|HasCategory| |#1| '(|CharacteristicZero|)))
        $)))) 

(MAKEPROP '|InnerModularGcd| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
             (|local| |#3|) (|local| |#4|) (0 . |Zero|) (4 . |Zero|)
             (|Boolean|) (8 . =) (14 . |symmetricRemainder|)
             (|Mapping| 6 6) (20 . |map|) (26 . |reduction|)
             (32 . |rem|) 'FP '|zeroChar| (38 . |zero?|) (43 . |Zero|)
             (|NonNegativeInteger|) (47 . |degree|) (|List| 7)
             |INMODGCD;modularGcdPrimitive;LBP;3| (52 . |remove!|)
             (58 . |One|) (62 . |One|) (66 . |minimumDegree|)
             (|EuclideanModularRing| 6 7 6 '|reduction| '|merge|
                 '|exactquo|)
             (71 . |Zero|) (75 . |monomial|) (|Union| $ '"failed")
             (81 . |exquo|) (87 . *) (93 . |content|) (|List| $)
             (98 . |gcd|) (103 . |exquo|) (109 . *) (115 . |member?|)
             (|List| 23) (121 . |member?|) |INMODGCD;modularGcd;LBP;4|
             (|Integer|) (127 . |position|) (133 . |elt|)
             (139 . |coefficient|) (145 . |exquo|)
             (151 . |leadingCoefficient|) (156 . |gcd|) (162 . |zero?|)
             (167 . |reduce|) (173 . |gcd|) (179 . |coerce|)
             (184 . |coerce|) (189 . *) (195 . |euclideanSize|)
             (200 . *) (206 . -) (212 . +) (218 . |One|)
             (|Fraction| 46) (222 . |One|) (226 . |euclideanSize|)
             (|Record| (|:| |coef1| $) (|:| |coef2| $))
             (|Union| 67 '"failed") (231 . |extendedEuclidean|)
             (|Record| (|:| |quotient| $) (|:| |remainder| $))
             (238 . |monicDivide|) (244 . =) (|List| 6)
             (250 . |coefficients|) (|PositiveInteger|) (255 . *))
          '#(|reduction| 261 |modularGcdPrimitive| 267 |modularGcd|
             272)
          'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 76
                                '(0 6 0 10 0 7 0 11 2 6 12 0 0 13 2 6 0
                                  0 0 14 2 7 0 15 0 16 2 0 7 7 6 17 2 6
                                  0 0 0 18 1 7 12 0 21 0 19 0 22 1 7 23
                                  0 24 2 25 0 7 0 27 0 6 0 28 0 7 0 29
                                  1 7 23 0 30 0 31 0 32 2 7 0 6 23 33 2
                                  7 34 0 0 35 2 7 0 0 0 36 1 7 6 0 37 1
                                  6 0 38 39 2 7 34 0 6 40 2 7 0 6 0 41
                                  2 25 12 7 0 42 2 43 12 23 0 44 2 43
                                  46 23 0 47 2 25 7 0 46 48 2 7 6 0 23
                                  49 2 6 34 0 0 50 1 7 6 0 51 2 6 0 0 0
                                  52 1 6 12 0 53 2 19 0 7 6 54 2 19 0 0
                                  0 55 1 19 7 0 56 1 7 0 6 57 2 6 0 0 0
                                  58 1 19 23 0 59 2 19 0 0 0 60 2 7 0 0
                                  0 61 2 7 0 0 0 62 0 19 0 63 0 64 0 65
                                  1 6 23 0 66 3 6 68 0 0 0 69 2 7 70 0
                                  0 71 2 7 12 0 0 72 1 7 73 0 74 2 23 0
                                  75 0 76 2 0 7 7 6 17 1 0 7 25 26 1 0
                                  7 25 45)))))
          '|lookupComplete|)) 
