
(/VERSIONCHECK 2) 

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

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

(DEFUN |BALFACT;balSqfr| (|a| |n| |l| $)
  (PROG (|b| |f| #0=#:G1836 #1=#:G1833 #2=#:G1831 #3=#:G1832)
    (RETURN
      (SEQ (LETT |b| (|SPADfirst| |l|) . #4=(|BALFACT;balSqfr|))
           (EXIT (COND
                   ((NULL (CDR |l|))
                    (|BALFACT;balSqfr1| |a| |n| |b| $))
                   ('T
                    (PROGN
                      (LETT #3# NIL . #4#)
                      (SEQ (LETT |f| NIL . #4#)
                           (LETT #0#
                                 (SPADCALL
                                     (|BALFACT;balSqfr| |a| |n|
                                      (CDR |l|) $)
                                     (QREFELT $ 25)) . #4#)
                           G190
                           (COND
                             ((OR (ATOM #0#)
                                  (PROGN
                                    (LETT |f| (CAR #0#) . #4#)
                                    NIL))
                              (GO G191)))
                           (SEQ (EXIT (PROGN
                                        (LETT #1#
                                         (|BALFACT;balSqfr1| (QCAR |f|)
                                          |n| |b| $) . #4#)
                                        (COND
                                          (#3#
                                           (LETT #2#
                                            (SPADCALL #2# #1#
                                             (QREFELT $ 22)) . #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 (|spadConstant| $ 26))))))))))) 

(DEFUN |BALFACT;balancedFactorisation;UPLF;4| (|a| |l| $)
  (PROG (|ll| |sa| |f| #0=#:G1845 #1=#:G1841 #2=#:G1839 #3=#:G1840)
    (RETURN
      (SEQ (COND
             ((NULL (LETT |ll|
                          (SPADCALL
                              (CONS #'|BALFACT;balancedFactorisation;UPLF;4!0|
                                    $)
                              |l| (QREFELT $ 33))
                          . #4=(|BALFACT;balancedFactorisation;UPLF;4|)))
              (|error| "balancedFactorisation: 2nd argument is empty or all 0"))
             ('T
              (SEQ (LETT |sa| (SPADCALL |a| (QREFELT $ 35)) . #4#)
                   (EXIT (SPADCALL (SPADCALL |sa| (QREFELT $ 36))
                             (PROGN
                               (LETT #3# NIL . #4#)
                               (SEQ (LETT |f| NIL . #4#)
                                    (LETT #0#
                                     (SPADCALL |sa| (QREFELT $ 25)) . #4#)
                                    G190
                                    (COND
                                      ((OR (ATOM #0#)
                                        (PROGN
                                          (LETT |f| (CAR #0#) . #4#)
                                          NIL))
                                       (GO G191)))
                                    (SEQ
                                     (EXIT
                                      (PROGN
                                        (LETT #1#
                                         (|BALFACT;balSqfr| (QCAR |f|)
                                          (QCDR |f|) |ll| $) . #4#)
                                        (COND
                                          (#3#
                                           (LETT #2#
                                            (SPADCALL #2# #1#
                                             (QREFELT $ 22)) . #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 (|spadConstant| $ 26))))
                             (QREFELT $ 37)))))))))) 

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

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

(DEFUN |BalancedFactorisation;| (|#1| |#2|)
  (PROG (DV$1 DV$2 |dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT DV$1 (|devaluate| |#1|) . #0=(|BalancedFactorisation|))
        (LETT DV$2 (|devaluate| |#2|) . #0#)
        (LETT |dv$| (LIST '|BalancedFactorisation| DV$1 DV$2) . #0#)
        (LETT $ (GETREFV 38) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|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|)) 
