
(/VERSIONCHECK 2) 

(DEFUN |DIOSP;dioSolve;ER;1| (|eq| $)
  (PROG (|vars| #1=#:G693 |x| #2=#:G692 |ihs| |hs| |sol| |graph| |mon| |c|
         #3=#:G691 |n| |p|)
    (RETURN
     (SEQ
      (LETT |p|
            (SPADCALL (SPADCALL |eq| (QREFELT $ 8))
                      (SPADCALL |eq| (QREFELT $ 9)) (QREFELT $ 10))
            . #4=(|DIOSP;dioSolve;ER;1|))
      (LETT |n| (SPADCALL |p| (QREFELT $ 12)) . #4#)
      (COND
       ((OR (EQL |n| 0) (< 1 |n|))
        (EXIT (|error| "a linear Diophantine equation is expected"))))
      (LETT |mon| NIL . #4#) (LETT |c| 0 . #4#)
      (SEQ (LETT |x| NIL . #4#) (LETT #3# (SPADCALL |p| (QREFELT $ 14)) . #4#)
           G190
           (COND
            ((OR (ATOM #3#) (PROGN (LETT |x| (CAR #3#) . #4#) NIL))
             #5=(GO G191)))
           (SEQ
            (EXIT
             (COND
              ((SPADCALL |x| (QREFELT $ 16))
               (LETT |c| (SPADCALL |x| (QREFELT $ 18)) . #4#))
              ('T (LETT |mon| (CONS |x| |mon|) . #4#)))))
           (LETT #3# (CDR #3#) . #4#) #6=(GO G190) G191 (EXIT NIL))
      (LETT |graph| (|DIOSP;initializeGraph| |mon| |c| $) . #4#)
      (LETT |sol| (SPADCALL (QVELT |graph| 1) (QREFELT $ 20)) . #4#)
      (LETT |hs|
            (|DIOSP;findSolutions| |sol| (QVELT |graph| 2) 1 1 |graph| 'T $)
            . #4#)
      (LETT |ihs|
            (COND ((EQL |c| 0) (LIST |sol|))
                  (#7='T
                   (|DIOSP;findSolutions| |sol| (+ (QVELT |graph| 2) |c|) 1 1
                    |graph| 'NIL $)))
            . #4#)
      (LETT |vars|
            (PROGN
             (LETT #2# NIL . #4#)
             (SEQ (LETT |x| NIL . #4#) (LETT #1# |mon| . #4#) G190
                  (COND
                   ((OR (ATOM #1#) (PROGN (LETT |x| (CAR #1#) . #4#) NIL))
                    #5#))
                  (SEQ
                   (EXIT
                    (LETT #2#
                          (CONS (|SPADfirst| (SPADCALL |x| (QREFELT $ 22)))
                                #2#)
                          . #4#)))
                  (LETT #1# (CDR #1#) . #4#) #6# G191 (EXIT (NREVERSE0 #2#))))
            . #4#)
      (EXIT
       (VECTOR |vars|
               (COND ((NULL |ihs|) (CONS 1 "failed")) (#7# (CONS 0 |ihs|)))
               |hs|)))))) 

(DEFUN |DIOSP;initializeGraph| (|mon| |c| $)
  (PROG (|i| #1=#:G704 #2=#:G703 |n| |m| |k| |coeffs| #3=#:G702 |x| #4=#:G701)
    (RETURN
     (SEQ
      (LETT |coeffs|
            (SPADCALL
             (PROGN
              (LETT #4# NIL . #5=(|DIOSP;initializeGraph|))
              (SEQ (LETT |x| NIL . #5#) (LETT #3# |mon| . #5#) G190
                   (COND
                    ((OR (ATOM #3#) (PROGN (LETT |x| (CAR #3#) . #5#) NIL))
                     #6=(GO G191)))
                   (SEQ
                    (EXIT
                     (LETT #4#
                           (CONS (|SPADfirst| (SPADCALL |x| (QREFELT $ 27)))
                                 #4#)
                           . #5#)))
                   (LETT #3# (CDR #3#) . #5#) #7=(GO G190) G191
                   (EXIT (NREVERSE0 #4#))))
             (QREFELT $ 29))
            . #5#)
      (LETT |k| (QVSIZE |coeffs|) . #5#)
      (LETT |m| (MIN |c| (SPADCALL (ELT $ 30) |coeffs| (QREFELT $ 32))) . #5#)
      (LETT |n| (MAX |c| (SPADCALL (ELT $ 33) |coeffs| (QREFELT $ 32))) . #5#)
      (EXIT
       (VECTOR
        (PROGN
         (LETT #2# (GETREFV (QSADD1 (- |n| |m|))) . #5#)
         (SEQ (LETT #1# 0 . #5#) (LETT |i| |m| . #5#) G190
              (COND ((> |i| |n|) #6#))
              (SEQ
               (EXIT
                (SETELT #2# #1#
                        (|DIOSP;createNode| |i| |coeffs| |k| (- 1 |m|) $))))
              (LETT |i| (PROG1 (+ |i| 1) (LETT #1# (QSADD1 #1#) . #5#)) . #5#)
              #7# G191 (EXIT NIL))
         #2#)
        |k| (- 1 |m|))))))) 

(DEFUN |DIOSP;createNode| (|ind| |coeffs| |k| |zeroNode| $)
  (PROG (#1=#:G707 #2=#:G706 |i| |v|)
    (RETURN
     (SEQ (LETT |v| (SPADCALL |k| (QREFELT $ 34)) . #3=(|DIOSP;createNode|))
          (SEQ (LETT |i| 1 . #3#) G190 (COND ((QSGREATERP |i| |k|) (GO G191)))
               (SEQ
                (EXIT
                 (COND
                  ((< 0 |ind|)
                   (SEQ
                    (EXIT
                     (COND
                      ((< (SPADCALL |coeffs| |i| (QREFELT $ 35)) 0)
                       (PROGN
                        (LETT #2#
                              (SPADCALL |v| |i|
                                        (+ (+ |zeroNode| |ind|)
                                           (SPADCALL |coeffs| |i|
                                                     (QREFELT $ 35)))
                                        (QREFELT $ 36))
                              . #3#)
                        (GO #2#)))))
                    #2# (EXIT #2#)))
                  ('T
                   (SEQ
                    (EXIT
                     (COND
                      ((< 0 (SPADCALL |coeffs| |i| (QREFELT $ 35)))
                       (PROGN
                        (LETT #1#
                              (SPADCALL |v| |i|
                                        (+ (+ |zeroNode| |ind|)
                                           (SPADCALL |coeffs| |i|
                                                     (QREFELT $ 35)))
                                        (QREFELT $ 36))
                              . #3#)
                        (GO #1#)))))
                    #1# (EXIT #1#))))))
               (LETT |i| (QSADD1 |i|) . #3#) (GO G190) G191 (EXIT NIL))
          (EXIT (CONS |v| 'T)))))) 

(DEFUN |DIOSP;findSolutions| (|sol| |ind| |m| |n| |graph| |flag| $)
  (PROG (|sols| |s| |x| #1=#:G726 |i| |k| |v| |node|)
    (RETURN
     (SEQ (LETT |sols| NIL . #2=(|DIOSP;findSolutions|))
          (LETT |node| (SPADCALL (QVELT |graph| 0) |ind| (QREFELT $ 39)) . #2#)
          (EXIT
           (COND
            ((QCDR |node|)
             (SEQ (PROGN (RPLACD |node| 'NIL) (QCDR |node|))
                  (LETT |v| (QCAR |node|) . #2#)
                  (LETT |k|
                        (COND ((< |ind| (QVELT |graph| 2)) |m|) (#3='T |n|))
                        . #2#)
                  (SEQ (LETT |i| |k| . #2#) (LETT #1# (QVELT |graph| 1) . #2#)
                       G190 (COND ((> |i| #1#) (GO G191)))
                       (SEQ
                        (LETT |x| (SPADCALL |sol| |i| (QREFELT $ 40)) . #2#)
                        (EXIT
                         (COND
                          ((< 0 (SPADCALL |v| |i| (QREFELT $ 35)))
                           (SEQ (SPADCALL |sol| |i| (+ |x| 1) (QREFELT $ 41))
                                (EXIT
                                 (COND
                                  ((EQL (SPADCALL |v| |i| (QREFELT $ 35))
                                        (QVELT |graph| 2))
                                   (COND
                                    ((|DIOSP;verifyMinimality| |sol| |graph|
                                      |flag| $)
                                     (SEQ
                                      (LETT |sols|
                                            (CONS
                                             (SPADCALL |sol| (QREFELT $ 42))
                                             |sols|)
                                            . #2#)
                                      (EXIT
                                       (SPADCALL |sol| |i| |x|
                                                 (QREFELT $ 41)))))
                                    ('T
                                     (SPADCALL |sol| |i| |x| (QREFELT $ 41)))))
                                  ('T
                                   (SEQ
                                    (LETT |s|
                                          (COND
                                           ((< |ind| (QVELT |graph| 2))
                                            (|DIOSP;findSolutions| |sol|
                                             (SPADCALL |v| |i| (QREFELT $ 35))
                                             |i| |n| |graph| |flag| $))
                                           ('T
                                            (|DIOSP;findSolutions| |sol|
                                             (SPADCALL |v| |i| (QREFELT $ 35))
                                             |m| |i| |graph| |flag| $)))
                                          . #2#)
                                    (LETT |sols| (APPEND |s| |sols|) . #2#)
                                    (EXIT
                                     (SPADCALL |sol| |i| |x|
                                               (QREFELT $ 41))))))))))))
                       (LETT |i| (+ |i| 1) . #2#) (GO G190) G191 (EXIT NIL))
                  (PROGN (RPLACD |node| 'T) (QCDR |node|)) (EXIT |sols|)))
            (#3# |sols|))))))) 

(DEFUN |DIOSP;verifyMinimality| (|sol| |graph| |flag| $)
  (PROG (#1=#:G729 |x| |i|)
    (RETURN
     (SEQ
      (COND
       (|flag|
        (SEQ (LETT |i| 1 . #2=(|DIOSP;verifyMinimality|))
             (SEQ G190
                  (COND
                   ((NULL (EQL (SPADCALL |sol| |i| (QREFELT $ 40)) 0))
                    (GO G191)))
                  (SEQ (EXIT (LETT |i| (+ |i| 1) . #2#))) NIL (GO G190) G191
                  (EXIT NIL))
             (LETT |x| (SPADCALL |sol| |i| (QREFELT $ 40)) . #2#)
             (SPADCALL |sol| |i|
                       (PROG1 (LETT #1# (- |x| 1) . #2#)
                         (|check-subtype| (>= #1# 0) '(|NonNegativeInteger|)
                                          #1#))
                       (QREFELT $ 41))
             (LETT |flag|
                   (|DIOSP;verifySolution| |sol| (QVELT |graph| 2) 1 1 |graph|
                    $)
                   . #2#)
             (SPADCALL |sol| |i| |x| (QREFELT $ 41)) (EXIT |flag|)))
       ('T (|DIOSP;verifySolution| |sol| (QVELT |graph| 2) 1 1 |graph| $))))))) 

(DEFUN |DIOSP;verifySolution| (|sol| |ind| |m| |n| |graph| $)
  (PROG (#1=#:G740 |flag| #2=#:G735 |x| #3=#:G745 |i| |k| |v| |node|)
    (RETURN
     (SEQ (LETT |flag| 'T . #4=(|DIOSP;verifySolution|))
          (LETT |node| (SPADCALL (QVELT |graph| 0) |ind| (QREFELT $ 39)) . #4#)
          (LETT |v| (QCAR |node|) . #4#)
          (LETT |k| (COND ((< |ind| (QVELT |graph| 2)) |m|) ('T |n|)) . #4#)
          (SEQ (LETT |i| |k| . #4#) (LETT #3# (QVELT |graph| 1) . #4#) G190
               (COND ((OR (> |i| #3#) (NULL |flag|)) (GO G191)))
               (SEQ (LETT |x| (SPADCALL |sol| |i| (QREFELT $ 40)) . #4#)
                    (EXIT
                     (COND
                      ((< 0 |x|)
                       (SEQ
                        (EXIT
                         (COND
                          ((< 0 (SPADCALL |v| |i| (QREFELT $ 35)))
                           (PROGN
                            (LETT #1#
                                  (SEQ
                                   (SPADCALL |sol| |i|
                                             (PROG1 (LETT #2# (- |x| 1) . #4#)
                                               (|check-subtype| (>= #2# 0)
                                                                '(|NonNegativeInteger|)
                                                                #2#))
                                             (QREFELT $ 41))
                                   (EXIT
                                    (COND
                                     ((EQL (SPADCALL |v| |i| (QREFELT $ 35))
                                           (QVELT |graph| 2))
                                      (SEQ (LETT |flag| 'NIL . #4#)
                                           (EXIT
                                            (SPADCALL |sol| |i| |x|
                                                      (QREFELT $ 41)))))
                                     ('T
                                      (SEQ
                                       (LETT |flag|
                                             (COND
                                              ((< |ind| (QVELT |graph| 2))
                                               (|DIOSP;verifySolution| |sol|
                                                (SPADCALL |v| |i|
                                                          (QREFELT $ 35))
                                                |i| |n| |graph| $))
                                              ('T
                                               (|DIOSP;verifySolution| |sol|
                                                (SPADCALL |v| |i|
                                                          (QREFELT $ 35))
                                                |m| |i| |graph| $)))
                                             . #4#)
                                       (EXIT
                                        (SPADCALL |sol| |i| |x|
                                                  (QREFELT $ 41))))))))
                                  . #4#)
                            (GO #1#)))))
                        #1# (EXIT #1#))))))
               (LETT |i| (+ |i| 1) . #4#) (GO G190) G191 (EXIT NIL))
          (EXIT |flag|))))) 

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

(DEFUN |DiophantineSolutionPackage;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|DiophantineSolutionPackage|)
            . #1=(|DiophantineSolutionPackage|))
      (LETT $ (GETREFV 43) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|DiophantineSolutionPackage| NIL
                  (CONS 1 $))
      (|stuffDomainSlots| $)
      $)))) 

(MAKEPROP '|DiophantineSolutionPackage| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|Polynomial| 17) (|Equation| 6)
              (0 . |lhs|) (5 . |rhs|) (10 . -) (|NonNegativeInteger|)
              (16 . |totalDegree|) (|List| $) (21 . |monomials|) (|Boolean|)
              (26 . |ground?|) (|Integer|) (31 . |ground|) (|Vector| 11)
              (36 . |zero|) (|List| (|Symbol|)) (41 . |variables|)
              (|Union| (|List| 19) '"failed")
              (|Record| (|:| |varOrder| 21) (|:| |inhom| 23)
                        (|:| |hom| (|List| 19)))
              |DIOSP;dioSolve;ER;1| (|List| 17) (46 . |coefficients|)
              (|Vector| 17) (51 . |vector|) (56 . |min|) (|Mapping| 17 17 17)
              (62 . |reduce|) (68 . |max|) (74 . |zero|) (79 . |elt|)
              (85 . |setelt|) (|Record| (|:| |vert| 28) (|:| |free| 15))
              (|Vector| 37) (92 . |elt|) (98 . |elt|) (104 . |setelt|)
              (111 . |copy|))
           '#(|dioSolve| 116) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 42
                                                 '(1 7 6 0 8 1 7 6 0 9 2 6 0 0
                                                   0 10 1 6 11 0 12 1 6 13 0 14
                                                   1 6 15 0 16 1 6 17 0 18 1 19
                                                   0 11 20 1 6 21 0 22 1 6 26 0
                                                   27 1 28 0 26 29 2 17 0 0 0
                                                   30 2 28 17 31 0 32 2 17 0 0
                                                   0 33 1 28 0 11 34 2 28 17 0
                                                   17 35 3 28 17 0 17 17 36 2
                                                   38 37 0 17 39 2 19 11 0 17
                                                   40 3 19 11 0 17 11 41 1 19 0
                                                   0 42 1 0 24 7 25)))))
           '|lookupComplete|)) 

(MAKEPROP '|DiophantineSolutionPackage| 'NILADIC T) 
