
(/VERSIONCHECK 2) 

(DEFUN |BALFACT;balancedFactorisation;2UPF;1| (|a| |b| $)
  (SPADCALL |a| (LIST |b|) (QREFELT $ 10))) 

(DEFUN |BALFACT;balSqfr1| (|a| |n| |b| $)
  (PROG (#1=#:G670 |fa| |g|)
    (RETURN
     (SEQ
      (LETT |g| (SPADCALL |a| |b| (QREFELT $ 12)) . #2=(|BALFACT;balSqfr1|))
      (LETT |fa|
            (SPADCALL
             (PROG2
                 (LETT #1# (SPADCALL |a| |g| (QREFELT $ 14)) . #2#)
                 (QCDR #1#)
               (|check-union| (QEQCAR #1# 0) (QREFELT $ 7) #1#))
             |n| (QREFELT $ 16))
            . #2#)
      (EXIT
       (COND ((SPADCALL |g| (QREFELT $ 18)) |fa|)
             ('T
              (SPADCALL |fa|
                        (|BALFACT;balSqfr1| |g| |n|
                         (PROG2
                             (LETT #1#
                                   (SPADCALL |b|
                                             (SPADCALL |g|
                                                       (SPADCALL |b| |g|
                                                                 (QREFELT $
                                                                          20))
                                                       (QREFELT $ 21))
                                             (QREFELT $ 14))
                                   . #2#)
                             (QCDR #1#)
                           (|check-union| (QEQCAR #1# 0) (QREFELT $ 7) #1#))
                         $)
                        (QREFELT $ 22))))))))) 

(DEFUN |BALFACT;balSqfr| (|a| |n| |l| $)
  (PROG (#1=#:G678 #2=#:G677 #3=#:G679 #4=#:G682 |f| |b|)
    (RETURN
     (SEQ (LETT |b| (|SPADfirst| |l|) . #5=(|BALFACT;balSqfr|))
          (EXIT
           (COND ((NULL (CDR |l|)) (|BALFACT;balSqfr1| |a| |n| |b| $))
                 (#6='T
                  (PROGN
                   (LETT #1# NIL . #5#)
                   (SEQ (LETT |f| NIL . #5#)
                        (LETT #4#
                              (SPADCALL (|BALFACT;balSqfr| |a| |n| (CDR |l|) $)
                                        (QREFELT $ 25))
                              . #5#)
                        G190
                        (COND
                         ((OR (ATOM #4#)
                              (PROGN (LETT |f| (CAR #4#) . #5#) NIL))
                          (GO G191)))
                        (SEQ
                         (EXIT
                          (PROGN
                           (LETT #3# (|BALFACT;balSqfr1| (QCAR |f|) |n| |b| $)
                                 . #5#)
                           (COND
                            (#1#
                             (LETT #2# (SPADCALL #2# #3# (QREFELT $ 22))
                                   . #5#))
                            ('T
                             (PROGN
                              (LETT #2# #3# . #5#)
                              (LETT #1# 'T . #5#)))))))
                        (LETT #4# (CDR #4#) . #5#) (GO G190) G191 (EXIT NIL))
                   (COND (#1# #2#) (#6# (|spadConstant| $ 26))))))))))) 

(DEFUN |BALFACT;balancedFactorisation;UPLF;4| (|a| |l| $)
  (PROG (#1=#:G686 #2=#:G685 #3=#:G687 #4=#:G691 |f| |sa| |ll|)
    (RETURN
     (SEQ
      (COND
       ((NULL
         (LETT |ll|
               (SPADCALL (CONS #'|BALFACT;balancedFactorisation;UPLF;4!0| $)
                         |l| (QREFELT $ 33))
               . #5=(|BALFACT;balancedFactorisation;UPLF;4|)))
        (|error| "balancedFactorisation: 2nd argument is empty or all 0"))
       (#6='T
        (SEQ (LETT |sa| (SPADCALL |a| (QREFELT $ 35)) . #5#)
             (EXIT
              (SPADCALL (SPADCALL |sa| (QREFELT $ 36))
                        (PROGN
                         (LETT #1# NIL . #5#)
                         (SEQ (LETT |f| NIL . #5#)
                              (LETT #4# (SPADCALL |sa| (QREFELT $ 25)) . #5#)
                              G190
                              (COND
                               ((OR (ATOM #4#)
                                    (PROGN (LETT |f| (CAR #4#) . #5#) NIL))
                                (GO G191)))
                              (SEQ
                               (EXIT
                                (PROGN
                                 (LETT #3#
                                       (|BALFACT;balSqfr| (QCAR |f|) (QCDR |f|)
                                        |ll| $)
                                       . #5#)
                                 (COND
                                  (#1#
                                   (LETT #2# (SPADCALL #2# #3# (QREFELT $ 22))
                                         . #5#))
                                  ('T
                                   (PROGN
                                    (LETT #2# #3# . #5#)
                                    (LETT #1# 'T . #5#)))))))
                              (LETT #4# (CDR #4#) . #5#) (GO G190) G191
                              (EXIT NIL))
                         (COND (#1# #2#) (#6# (|spadConstant| $ 26))))
                        (QREFELT $ 37)))))))))) 

(DEFUN |BALFACT;balancedFactorisation;UPLF;4!0| (|z1| $)
  (COND
   ((SPADCALL |z1| (|spadConstant| $ 28) (QREFELT $ 29)) (|spadConstant| $ 30))
   ('T (|spadConstant| $ 31)))) 

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

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

(MAKEPROP '|BalancedFactorisation| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|local| |#1|) (|local| |#2|)
              (|Factored| 7) (|List| 7) |BALFACT;balancedFactorisation;UPLF;4|
              |BALFACT;balancedFactorisation;2UPF;1| (0 . |gcd|)
              (|Union| $ '"failed") (6 . |exquo|) (|Integer|)
              (12 . |sqfrFactor|) (|Boolean|) (18 . |ground?|)
              (|NonNegativeInteger|) (23 . |order|) (29 . ^) (35 . *)
              (|Record| (|:| |factor| 7) (|:| |exponent| 15)) (|List| 23)
              (41 . |factors|) (46 . |One|) (50 . |Zero|) (54 . |Zero|)
              (58 . =) (64 . |false|) (68 . |true|) (|Mapping| 17 7)
              (72 . |select|) (|Factored| $) (78 . |squareFree|) (83 . |unit|)
              (88 . *))
           '#(|balancedFactorisation| 94) 'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 37
                                                 '(2 7 0 0 0 12 2 7 13 0 0 14 2
                                                   8 0 7 15 16 1 7 17 0 18 2 7
                                                   19 0 0 20 2 7 0 0 19 21 2 8
                                                   0 0 0 22 1 8 24 0 25 0 8 0
                                                   26 0 6 0 27 0 7 0 28 2 7 17
                                                   0 0 29 0 17 0 30 0 17 0 31 2
                                                   9 0 32 0 33 1 7 34 0 35 1 8
                                                   7 0 36 2 8 0 7 0 37 2 0 8 7
                                                   9 10 2 0 8 7 7 11)))))
           '|lookupComplete|)) 
