
(/VERSIONCHECK 2) 

(DEFUN |DLP;shanksDiscLogAlgorithm;2MNniU;1| (|logbase| |c| |p| $)
  (PROG (|limit| #0=#:G1840 |l| |n| |exptable| #1=#:G1825 #2=#:G1841
                 |end| |b| |i| |rho| |found| |disclog| |a|)
    (RETURN
      (SEQ (LETT |limit| 30
                 . #3=(|DLP;shanksDiscLogAlgorithm;2MNniU;1|))
           (EXIT (COND
                   ((< |p| |limit|)
                    (SEQ (LETT |a| (|spadConstant| $ 7) . #3#)
                         (LETT |disclog| 0 . #3#)
                         (LETT |found| 'NIL . #3#)
                         (SEQ (LETT |i| 0 . #3#)
                              (LETT #0# (- |p| 1) . #3#) G190
                              (COND
                                ((OR (QSGREATERP |i| #0#)
                                     (NULL
                                      (COND (|found| 'NIL) ('T 'T))))
                                 #4=(GO G191)))
                              (SEQ (EXIT
                                    (COND
                                      ((SPADCALL |a| |c| (QREFELT $ 9))
                                       (SEQ (LETT |disclog| |i| . #3#)
                                        (EXIT (LETT |found| 'T . #3#))))
                                      ('T
                                       (LETT |a|
                                        (SPADCALL |a| |logbase|
                                         (QREFELT $ 10)) . #3#)))))
                              (LETT |i| (QSADD1 |i|) . #3#)
                              #5=(GO G190) G191 (EXIT NIL))
                         (EXIT (COND
                                 (|found| (CONS 0 |disclog|))
                                 (#6='T
                                  (SEQ (SPADCALL
                                        "discreteLog: second argument not in cyclic group generated by first argument"
                                        (QREFELT $ 14))
                                       (EXIT (CONS 1 "failed"))))))))
                   (#6#
                    (SEQ (LETT |l| (INTEGER-LENGTH |p|) . #3#)
                         (COND
                           ((ODDP |l|)
                            (LETT |n|
                                  (ASH |p| (- (QUOTIENT2 |l| 2))) . #3#))
                           ('T
                            (LETT |n| (ASH 1 (QUOTIENT2 |l| 2)) . #3#)))
                         (LETT |a| (|spadConstant| $ 7) . #3#)
                         (LETT |exptable|
                               (SPADCALL (QREFELT $ 16)) . #3#)
                         (SEQ (LETT |i| 0 . #3#)
                              (LETT #2#
                                    (PROG1 (LETT #1# (- |n| 1) . #3#)
                                      (|check-subtype| (>= #1# 0)
                                       '(|NonNegativeInteger|) #1#)) . #3#)
                              G190 (COND ((QSGREATERP |i| #2#) #4#))
                              (SEQ (SPADCALL
                                    (CONS (SPADCALL |a| (QREFELT $ 18))
                                     |i|)
                                    |exptable| (QREFELT $ 20))
                                   (EXIT
                                    (LETT |a|
                                     (SPADCALL |a| |logbase|
                                      (QREFELT $ 10)) . #3#)))
                              (LETT |i| (QSADD1 |i|) . #3#) #5# G191
                              (EXIT NIL))
                         (LETT |found| 'NIL . #3#)
                         (LETT |end| (QUOTIENT2 (- |p| 1) |n|) . #3#)
                         (LETT |disclog| 0 . #3#) (LETT |a| |c| . #3#)
                         (LETT |b|
                               (SPADCALL |logbase| (- |n|)
                                   (QREFELT $ 22)) . #3#)
                         (SEQ (LETT |i| 0 . #3#) G190
                              (COND
                                ((OR (QSGREATERP |i| |end|)
                                     (NULL
                                      (COND (|found| 'NIL) ('T 'T))))
                                 #4#))
                              (SEQ (LETT |rho|
                                    (SPADCALL
                                     (SPADCALL |a| (QREFELT $ 18))
                                     |exptable| (QREFELT $ 24)) . #3#)
                                   (EXIT
                                    (COND
                                      ((QEQCAR |rho| 0)
                                       (SEQ (LETT |found| 'T . #3#)
                                        (EXIT
                                         (LETT |disclog|
                                          (+ (* |n| |i|) (QCDR |rho|)) . #3#))))
                                      ('T
                                       (LETT |a|
                                        (SPADCALL |a| |b|
                                         (QREFELT $ 10)) . #3#)))))
                              (LETT |i| (QSADD1 |i|) . #3#) #5# G191
                              (EXIT NIL))
                         (EXIT (COND
                                 (|found| (CONS 0 |disclog|))
                                 (#6#
                                  (SEQ (SPADCALL
                                        "discreteLog: second argument not in cyclic group generated by first argument"
                                        (QREFELT $ 14))
                                       (EXIT (CONS 1 "failed")))))))))))))) 

(DEFUN |DiscreteLogarithmPackage| (#0=#:G1842)
  (PROG ()
    (RETURN
      (PROG (#1=#:G1843)
        (RETURN
          (COND
            ((LETT #1#
                   (|lassocShiftWithFunction| (LIST (|devaluate| #0#))
                       (HGET |$ConstructorCache|
                             '|DiscreteLogarithmPackage|)
                       '|domainEqualList|)
                   . #2=(|DiscreteLogarithmPackage|))
             (|CDRwithIncrement| #1#))
            ('T
             (UNWIND-PROTECT
               (PROG1 (|DiscreteLogarithmPackage;| #0#)
                 (LETT #1# T . #2#))
               (COND
                 ((NOT #1#)
                  (HREM |$ConstructorCache|
                        '|DiscreteLogarithmPackage|))))))))))) 

(DEFUN |DiscreteLogarithmPackage;| (|#1|)
  (PROG (DV$1 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|)
              . #0=(|DiscreteLogarithmPackage|))
        (LETT |dv$| (LIST '|DiscreteLogarithmPackage| DV$1) . #0#)
        (LETT $ (GETREFV 27) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache| '|DiscreteLogarithmPackage|
            (LIST DV$1) (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 6 |#1|)
        $)))) 

(MAKEPROP '|DiscreteLogarithmPackage| '|infovec|
    (LIST '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (0 . |One|)
             (|Boolean|) (4 . =) (10 . *) (|Void|) (|String|)
             (|OutputForm|) (16 . |messagePrint|) (|Table| 17 25)
             (21 . |table|) (|PositiveInteger|) (25 . |lookup|)
             (|Record| (|:| |key| 17) (|:| |entry| 25))
             (30 . |insert!|) (|Integer|) (36 . **)
             (|Union| 25 '"failed") (42 . |search|)
             (|NonNegativeInteger|)
             |DLP;shanksDiscLogAlgorithm;2MNniU;1|)
          '#(|shanksDiscLogAlgorithm| 48) 'NIL
          (CONS (|makeByteWordVec2| 1 'NIL)
                (CONS '#()
                      (CONS '#()
                            (|makeByteWordVec2| 26
                                '(0 6 0 7 2 6 8 0 0 9 2 6 0 0 0 10 1 13
                                  11 12 14 0 15 0 16 1 6 17 0 18 2 15 0
                                  19 0 20 2 6 0 0 21 22 2 15 23 17 0 24
                                  3 0 23 6 6 25 26)))))
          '|lookupComplete|)) 
