(define (test -__Arg1 -__Arg2)
  (define (-__Func1)
    (let ((A -__Arg1))
      (if (morally-equal? A -__Arg2)
        (begin
          (pretty-print "Correct: ")
          (pretty-print A)
          (pretty-print "")
          #t)
        (-__Func2))))
  (define (-__Func2)
    (let ((A -__Arg1))
      (let ((B -__Arg2))
        (begin
          (pretty-print "Wrong. Result: ")
          (pretty-print A)
          (pretty-print ". Correct: ")
          (pretty-print B)
          (pretty-print "")
          #f))))
  (-__Func1))
(define (upper-case? -__Arg1)
  (define (-__Func1)
    (let ((S -__Arg1))
      (if (member
            (car (string->list S))
            (string->list "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
        #t
        #f)))
  (-__Func1))
(define (var? -__Arg1)
  (define (-__Func1)
    (let ((A -__Arg1))
      (and (symbol? A)
           (upper-case? (symbol->string A)))))
  (-__Func1))
(define (scheme-symbol? -__Arg1)
  (define (-__Func1)
    (let ((A -__Arg1))
      (and (symbol? A) (not (var? A)))))
  (-__Func1))
(define (with-clean-gensym -__Arg1)
  (define (-__Func1)
    (let ((A -__Arg1))
      (begin (set! *my-gensym-N* 0) (A))))
  (-__Func1))
(define (gensym-from-symbol-and-number -__Arg1 -__Arg2)
  (define (-__Func1)
    (let ((S -__Arg1)) (let ((N -__Arg2)) (<_> S N))))
  (-__Func1))
(define (my-gensym -__Arg1)
  (define (-__Func1)
    (let ((V -__Arg1))
      (begin
        (set! *my-gensym-N* (+ 1 *my-gensym-N*))
        (gensym-from-symbol-and-number V *my-gensym-N*))))
  (-__Func1))
(define (create-varlist)
  (define (-__Func1) '())
  (-__Func1))
(define (cons-varlist -__Arg1 -__Arg2 -__Arg3)
  (define (-__Func1)
    (let ((Var -__Arg1))
      (let ((Value -__Arg2))
        (let ((Varlist -__Arg3))
          `((,Var ,Value) ,@Varlist)))))
  (-__Func1))
(define (varlist-value -__Arg1 -__Arg2)
  (define (-__Func1)
    (if (null? -__Arg2)
      '-__not-in-varlist
      (-__Func2)))
  (define (-__Func2)
    (let ((A -__Arg1))
      (if (pair? -__Arg2)
        (let ((-__MatchCar2 (car -__Arg2))
              (-__MatchCdr3 (cdr -__Arg2)))
          (if (pair? -__MatchCar2)
            (let ((-__MatchCar4 (car -__MatchCar2))
                  (-__MatchCdr5 (cdr -__MatchCar2)))
              (if (equal? A -__MatchCar4)
                (if (pair? -__MatchCdr5)
                  (let ((-__MatchCar6 (car -__MatchCdr5))
                        (-__MatchCdr7 (cdr -__MatchCdr5)))
                    (let ((Value -__MatchCar6))
                      (if (null? -__MatchCdr7) Value (-__Func3))))
                  (-__Func3))
                (-__Func3)))
            (-__Func3)))
        (-__Func3))))
  (define (-__Func3)
    (let ((Var -__Arg1))
      (if (pair? -__Arg2)
        (let ((-__MatchCar8 (car -__Arg2))
              (-__MatchCdr9 (cdr -__Arg2)))
          (let ((Vs -__MatchCdr9)) (varlist-value Var Vs)))
        (error-no-match Main-Func-Name))))
  (-__Func1))
(define (transform-to-check-similarities-0
         -__Arg1
         -__Arg2
         -__Arg3
         -__Arg4)
  (define (-__Func1)
    (let ((R -__Arg1))
      (if (equal? R -__Arg3) R (-__Func2))))
  (define (-__Func2)
    (if (pair? -__Arg1)
      (let ((-__MatchCar10 (car -__Arg1))
            (-__MatchCdr11 (cdr -__Arg1)))
        (if (eq? -__MatchCar10 'if)
          (if (pair? -__MatchCdr11)
            (let ((-__MatchCar12 (car -__MatchCdr11))
                  (-__MatchCdr13 (cdr -__MatchCdr11)))
              (let ((Test -__MatchCar12))
                (if (pair? -__MatchCdr13)
                  (let ((-__MatchCar14 (car -__MatchCdr13))
                        (-__MatchCdr15 (cdr -__MatchCdr13)))
                    (let ((Body -__MatchCar14))
                      (if (pair? -__MatchCdr15)
                        (let ((-__MatchCar16 (car -__MatchCdr15))
                              (-__MatchCdr17 (cdr -__MatchCdr15)))
                          (let ((F -__MatchCar16))
                            (if (null? -__MatchCdr17)
                              (if (equal? F -__Arg2)
                                (let ((R -__Arg3))
                                  (let ((Varlist -__Arg4))
                                    `(if ,Test
                                       ,(transform-to-check-similarities-0
                                          Body
                                          F
                                          R
                                          Varlist)
                                       ,F)))
                                (-__Func3))
                              (-__Func3))))
                        (-__Func3))))
                  (-__Func3))))
            (-__Func3))
          (-__Func3)))
      (-__Func3)))
  (define (-__Func3)
    (if (pair? -__Arg1)
      (let ((-__MatchCar18 (car -__Arg1))
            (-__MatchCdr19 (cdr -__Arg1)))
        (if (eq? -__MatchCar18 'let)
          (if (pair? -__MatchCdr19)
            (let ((-__MatchCar20 (car -__MatchCdr19))
                  (-__MatchCdr21 (cdr -__MatchCdr19)))
              (if (pair? -__MatchCar20)
                (let ((-__MatchCar24 (car -__MatchCar20))
                      (-__MatchCdr25 (cdr -__MatchCar20)))
                  (if (pair? -__MatchCar24)
                    (let ((-__MatchCar26 (car -__MatchCar24))
                          (-__MatchCdr27 (cdr -__MatchCar24)))
                      (let ((Varname -__MatchCar26))
                        (if (pair? -__MatchCdr27)
                          (let ((-__MatchCar28 (car -__MatchCdr27))
                                (-__MatchCdr29 (cdr -__MatchCdr27)))
                            (let ((Value -__MatchCar28))
                              (if (null? -__MatchCdr29)
                                (if (null? -__MatchCdr25)
                                  (if (pair? -__MatchCdr21)
                                    (let ((-__MatchCar22 (car -__MatchCdr21))
                                          (-__MatchCdr23 (cdr -__MatchCdr21)))
                                      (let ((Body -__MatchCar22))
                                        (if (null? -__MatchCdr23)
                                          (let ((F -__Arg2))
                                            (let ((R -__Arg3))
                                              (let ((Varlist -__Arg4))
                                                (let ((Prev-value
                                                        (varlist-value
                                                          Varname
                                                          Varlist)))
                                                  (if (eq? Prev-value
                                                           '-__not-in-varlist)
                                                    `(let ((,Varname ,Value))
                                                       ,(transform-to-check-similarities-0
                                                          Body
                                                          F
                                                          R
                                                          (cons-varlist
                                                            Varname
                                                            Value
                                                            Varlist)))
                                                    `(if (equal?
                                                           ,Varname
                                                           ,Value)
                                                       ,(transform-to-check-similarities-0
                                                          Body
                                                          F
                                                          R
                                                          Varlist)
                                                       ,F))))))
                                          (-__Func4))))
                                    (-__Func4))
                                  (-__Func4))
                                (-__Func4))))
                          (-__Func4))))
                    (-__Func4)))
                (-__Func4)))
            (-__Func4))
          (-__Func4)))
      (-__Func4)))
  (define (-__Func4)
    (if (pair? -__Arg1)
      (let ((-__MatchCar30 (car -__Arg1))
            (-__MatchCdr31 (cdr -__Arg1)))
        (if (eq? -__MatchCar30 'let)
          (if (pair? -__MatchCdr31)
            (let ((-__MatchCar32 (car -__MatchCdr31))
                  (-__MatchCdr33 (cdr -__MatchCdr31)))
              (let ((Vars -__MatchCar32))
                (if (pair? -__MatchCdr33)
                  (let ((-__MatchCar34 (car -__MatchCdr33))
                        (-__MatchCdr35 (cdr -__MatchCdr33)))
                    (let ((Body -__MatchCar34))
                      (if (null? -__MatchCdr35)
                        (let ((F -__Arg2))
                          (let ((R -__Arg3))
                            (let ((Varlist -__Arg4))
                              `(let ,Vars
                                 ,(transform-to-check-similarities-0
                                    Body
                                    F
                                    R
                                    Varlist)))))
                        (error-no-match Main-Func-Name))))
                  (error-no-match Main-Func-Name))))
            (error-no-match Main-Func-Name))
          (error-no-match Main-Func-Name)))
      (error-no-match Main-Func-Name)))
  (-__Func1))
(define (transform-to-check-similarities
         -__Arg1
         -__Arg2
         -__Arg3)
  (define (-__Func1)
    (let ((Body -__Arg1))
      (let ((Failure -__Arg2))
        (let ((Result -__Arg3))
          (transform-to-check-similarities-0
            Body
            Failure
            Result
            (create-varlist))))))
  (-__Func1))
(define (has-pipe -__Arg1)
  (define (-__Func1)
    (let ((M -__Arg1))
      (if (not (pair? M)) #f (-__Func2))))
  (define (-__Func2)
    (if (null? -__Arg1) #f (-__Func3)))
  (define (-__Func3)
    (let ((M -__Arg1))
      (if (eq? (car M) (string->symbol "|"))
        #t
        (-__Func4))))
  (define (-__Func4)
    (let ((M -__Arg1)) (has-pipe (cdr M))))
  (-__Func1))
(define (pipe-to-dot -__Arg1)
  (define (-__Func1)
    (if (null? -__Arg1) '() (-__Func2)))
  (define (-__Func2)
    (let ((M -__Arg1))
      (if (eq? (car M) (string->symbol "|"))
        (cadr M)
        (-__Func3))))
  (define (-__Func3)
    (let ((M -__Arg1))
      (cons (car M) (pipe-to-dot (cdr M)))))
  (-__Func1))
(define (create-single-matcher
         -__Arg1
         -__Arg2
         -__Arg3
         -__Arg4)
  (define (-__Func1)
    (if (null? -__Arg1)
      (if (null? -__Arg2)
        (let ((R -__Arg4)) R)
        (-__Func2))
      (-__Func2)))
  (define (-__Func2)
    (let ((I -__Arg1))
      (if (null? -__Arg2)
        (let ((F -__Arg3))
          (let ((R -__Arg4)) `(if (null? ,I) ,R ,F)))
        (-__Func3))))
  (define (-__Func3)
    (let ((Input-var -__Arg1))
      (let ((Matcher-var -__Arg2))
        (let ((F -__Arg3))
          (let ((R -__Arg4))
            (if (has-pipe Matcher-var)
              (create-single-matcher
                Input-var
                (pipe-to-dot Matcher-var)
                F
                R)
              (-__Func4)))))))
  (define (-__Func4)
    (let ((Input-var -__Arg1))
      (let ((Matcher-var -__Arg2))
        (let ((F -__Arg3))
          (let ((R -__Arg4))
            (if (pair? Matcher-var)
              (let* ((Car-var (my-gensym '-__MatchCar))
                     (Cdr-var (my-gensym '-__MatchCdr))
                     (Inner-Result
                       (create-single-matcher
                         Cdr-var
                         (cdr Matcher-var)
                         F
                         R))
                     (New-Result
                       (create-single-matcher
                         Car-var
                         (car Matcher-var)
                         F
                         Inner-Result)))
                `(if (pair? ,Input-var)
                   (let ((,Car-var (car ,Input-var))
                         (,Cdr-var (cdr ,Input-var)))
                     ,New-Result)
                   ,F))
              (-__Func5)))))))
  (define (-__Func5)
    (let ((Input-var -__Arg1))
      (let ((Matcher-var -__Arg2))
        (let ((F -__Arg3))
          (let ((R -__Arg4))
            (if (var? Matcher-var)
              `(let ((,Matcher-var ,Input-var)) ,R)
              (-__Func6)))))))
  (define (-__Func6)
    (let ((Input-var -__Arg1))
      (let ((Matcher-var -__Arg2))
        (let ((F -__Arg3))
          (let ((R -__Arg4))
            (if (and (symbol? Matcher-var)
                     (string=?
                       "_"
                       (substring (symbol->string Matcher-var) 0 1)))
              R
              (-__Func7)))))))
  (define (-__Func7)
    (let ((Input-var -__Arg1))
      (let ((Matcher-var -__Arg2))
        (let ((F -__Arg3))
          (let ((R -__Arg4))
            (if (scheme-symbol? Matcher-var)
              `(if (eq? ,Input-var ',Matcher-var) ,R ,F)
              (-__Func8)))))))
  (define (-__Func8)
    (let ((Input-var -__Arg1))
      (let ((Matcher-var -__Arg2))
        (let ((F -__Arg3))
          (let ((R -__Arg4))
            (if (string? Matcher-var)
              `(if (string=? ,Input-var ,Matcher-var) ,R ,F)
              (-__Func9)))))))
  (define (-__Func9)
    (let ((Input-var -__Arg1))
      (let ((Matcher-var -__Arg2))
        (let ((F -__Arg3))
          (let ((R -__Arg4))
            `(if (eqv? ,Input-var ,Matcher-var) ,R ,F))))))
  (-__Func1))
(define (create-matcher-matcher-0
         -__Arg1
         -__Arg2
         -__Arg3
         -__Arg4)
  (define (-__Func1)
    (if (null? -__Arg1)
      (if (null? -__Arg2)
        (let ((Result -__Arg4)) Result)
        (-__Func2))
      (-__Func2)))
  (define (-__Func2)
    (if (pair? -__Arg1)
      (let ((-__MatchCar9 (car -__Arg1))
            (-__MatchCdr10 (cdr -__Arg1)))
        (let ((I -__MatchCar9))
          (let ((Is -__MatchCdr10))
            (if (pair? -__Arg2)
              (let ((-__MatchCar7 (car -__Arg2))
                    (-__MatchCdr8 (cdr -__Arg2)))
                (let ((M -__MatchCar7))
                  (let ((Ms -__MatchCdr8))
                    (let ((Failed -__Arg3))
                      (let ((Result -__Arg4))
                        (create-single-matcher
                          I
                          M
                          Failed
                          (create-matcher-matcher-0 Is Ms Failed Result)))))))
              (error-no-match Main-Func-Name)))))
      (error-no-match Main-Func-Name)))
  (-__Func1))
(define (create-matcher-matcher
         -__Arg1
         -__Arg2
         -__Arg3
         -__Arg4)
  (define (-__Func1)
    (let ((Inputs -__Arg1))
      (let ((Matchers -__Arg2))
        (let ((Failure -__Arg3))
          (let ((Result -__Arg4))
            (transform-to-check-similarities
              (create-matcher-matcher-0
                Inputs
                Matchers
                Failure
                Result)
              Failure
              Result))))))
  (-__Func1))
(define (my-list-split-0 -__Arg1 -__Arg2 -__Arg3 -__Arg4)
  (define (-__Func1)
    (let ((Before -__Arg1))
      (if (null? -__Arg2)
        (let ((Where -__Arg3))
          (let ((Func -__Arg4)) (Func Before '())))
        (-__Func2))))
  (define (-__Func2)
    (let ((Before -__Arg1))
      (if (pair? -__Arg2)
        (let ((-__MatchCar1 (car -__Arg2))
              (-__MatchCdr2 (cdr -__Arg2)))
          (let ((Where -__MatchCar1))
            (let ((After -__MatchCdr2))
              (if (equal? Where -__Arg3)
                (let ((Func -__Arg4)) (Func Before After))
                (-__Func3)))))
        (-__Func3))))
  (define (-__Func3)
    (let ((Before -__Arg1))
      (if (pair? -__Arg2)
        (let ((-__MatchCar3 (car -__Arg2))
              (-__MatchCdr4 (cdr -__Arg2)))
          (let ((A -__MatchCar3))
            (let ((After -__MatchCdr4))
              (let ((Where -__Arg3))
                (let ((Func -__Arg4))
                  (my-list-split-0
                    (append Before (list A))
                    After
                    Where
                    Func))))))
        (error-no-match Main-Func-Name))))
  (-__Func1))
(define (my-list-split -__Arg1 -__Arg2 -__Arg3)
  (define (-__Func1)
    (let ((All -__Arg1))
      (let ((Where -__Arg2))
        (let ((Func -__Arg3))
          (my-list-split-0 '() All Where Func)))))
  (-__Func1))
(define (get-matcher-where -__Arg1 -__Arg2)
  (define (-__Func1)
    (if (pair? -__Arg1)
      (let ((-__MatchCar5 (car -__Arg1))
            (-__MatchCdr6 (cdr -__Arg1)))
        (let ((Where -__MatchCar5))
          (if (pair? -__MatchCdr6)
            (let ((-__MatchCar7 (car -__MatchCdr6))
                  (-__MatchCdr8 (cdr -__MatchCdr6)))
              (let ((What -__MatchCar7))
                (let ((Rest -__MatchCdr8))
                  (let ((Kont -__Arg2))
                    (if (eqv? Where :where)
                      (Kont What Rest)
                      (-__Func2))))))
            (-__Func2))))
      (-__Func2)))
  (define (-__Func2)
    (let ((Rest -__Arg1))
      (let ((Kont -__Arg2)) (Kont '-__no_where Rest))))
  (-__Func1))
(define (get-matchers -__Arg1)
  (define (-__Func1)
    (if (null? -__Arg1) '() (-__Func2)))
  (define (-__Func2)
    (let ((All -__Arg1))
      (my-list-split
        All
        ':>
        (lambda (Before After)
          (let ((Result (car After)))
            (get-matcher-where
              (cdr After)
              (lambda (Where Rest)
                `((,Before ,Result ,Where) ,@(get-matchers Rest)))))))))
  (-__Func1))
(define (get-args -__Arg1)
  (define (-__Func1)
    (if (eqv? -__Arg1 0) '() (-__Func2)))
  (define (-__Func2)
    (let ((N -__Arg1))
      (append
        (get-args (- N 1))
        `(,(gensym-from-symbol-and-number '-__Arg N)))))
  (-__Func1))
(define (get-function-names -__Arg1)
  (define (-__Func1)
    (if (eqv? -__Arg1 0) '() (-__Func2)))
  (define (-__Func2)
    (let ((N -__Arg1))
      (append
        (get-function-names (- N 1))
        `((,(gensym-from-symbol-and-number '-__Func N))))))
  (-__Func1))
(define (make-local-func -__Arg1 -__Arg2)
  (define (-__Func1)
    (let ((Name -__Arg1))
      (let ((Body -__Arg2)) `(define ,Name ,Body))))
  (-__Func1))
(define (create-local-funcs-0 -__Arg1 -__Arg2 -__Arg3)
  (define (-__Func1)
    (if (null? -__Arg2)
      (if (pair? -__Arg3)
        (let ((-__MatchCar9 (car -__Arg3))
              (-__MatchCdr10 (cdr -__Arg3)))
          (let ((Error-func -__MatchCar9))
            (if (null? -__MatchCdr10) '() (-__Func2))))
        (-__Func2))
      (-__Func2)))
  (define (-__Func2)
    (let ((Is -__Arg1))
      (if (pair? -__Arg2)
        (let ((-__MatchCar15 (car -__Arg2))
              (-__MatchCdr16 (cdr -__Arg2)))
          (let ((M -__MatchCar15))
            (let ((Ms -__MatchCdr16))
              (if (pair? -__Arg3)
                (let ((-__MatchCar11 (car -__Arg3))
                      (-__MatchCdr12 (cdr -__Arg3)))
                  (let ((F1 -__MatchCar11))
                    (if (pair? -__MatchCdr12)
                      (let ((-__MatchCar13 (car -__MatchCdr12))
                            (-__MatchCdr14 (cdr -__MatchCdr12)))
                        (let ((F2 -__MatchCar13))
                          (let ((Fs -__MatchCdr14))
                            (let* ((Left-side (nth 1 M))
                                   (Right-side (nth 2 M))
                                   (Where (nth 3 M)))
                              `(,(make-local-func
                                   F1
                                   (create-matcher-matcher
                                     Is
                                     Left-side
                                     F2
                                     (if (eq? Where '-__no_where)
                                       Right-side
                                       `(if ,Where ,Right-side ,F2))))
                                ,@(create-local-funcs-0 Is Ms `(,F2 ,@Fs)))))))
                      (error-no-match Main-Func-Name))))
                (error-no-match Main-Func-Name)))))
        (error-no-match Main-Func-Name))))
  (-__Func1))
(define (create-local-funcs -__Arg1 -__Arg2)
  (define (-__Func1)
    (let ((Main-Func-Name -__Arg1))
      (let ((All -__Arg2))
        (let* ((Matchers (get-matchers All))
               (Args (get-args (length (car (car Matchers)))))
               (Function-names
                 (append
                   (get-function-names (length Matchers))
                   `((error-no-match Main-Func-Name)))))
          (create-local-funcs-0
            Args
            Matchers
            Function-names)))))
  (-__Func1))
(define (create-matcher-func -__Arg1 -__Arg2)
  (define (-__Func1)
    (let ((Name -__Arg1))
      (let ((Matchers -__Arg2))
        (let* ((Num-args
                 (my-list-split
                   Matchers
                   ':>
                   (lambda (Before After) (length Before))))
               (Args (get-args Num-args)))
          (append
            '(define)
            `((,Name ,@Args))
            (create-local-funcs (<-> Name) Matchers)
            (get-function-names 1))))))
  (-__Func1))
