Create a Common Lisp macro for the following transformation. Before code:
(defclause from (initial-value &key to by while (using ''+)) "Iterates from a given initial value to an optional maximum. Every iteration increments/decrements the value applying the <using> function (by default +) to the previous value and <by> (by default 1 or -1, depending on whether to >= from or not). Similarly, the <while> function is used to determine if <to> has been reached or surpassed. <while> is a function of two arguments, the current value and the value of <to>, and as soon as it returns false, the loop is terminated. <while> defaults to a function that returns true only if <to> has been specified and, letting cur be the current value, (<= (min to from) cur (max to from))." (let* ((diff (gensym "FROM-DIFF")) (to-evaled (gensym "FROM-TO")) (initial-evaled (gensym "FROM-FROM")) (while (or while (when to `(lambda (cur to &aux (from ,initial-evaled)) (let ((max (max to from)) (min (min to from))) (<= min cur max))))))) (list (make-simple-iteration :var to-evaled :init to) (make-simple-iteration :var initial-evaled :init initial-value) (make-simple-iteration :var diff :init (if by by `(if ,to-evaled (let ((signum (signum (- ,to-evaled ,initial-evaled)))) (if (zerop signum) +1 signum)) +1))) (make-initialization :form `(when (and ,to-evaled (not (zerop (- ,to-evaled ,initial-evaled))) (not (= (signum (- ,to-evaled ,initial-evaled)) (signum ,diff)))) (terminate))) (make-simple-iteration :init initial-evaled :step `(funcall ,using ,*iteration-variable* ,diff) :postcondition (when while `(funcall ,while ,*iteration-variable* ,to-evaled))))))

What needs to change: Macro call that should be transformed by defclause

Macro definition:
(defmacro defclause (name arglist &body body)
  "Same as cl:defmacro, but additionally records <name> in *clauses* as a known clause macro."
  `(progn
     (defmacro ,name ,arglist ,@body)
     (pushnew ',name *clauses*)))

Macroexpansion:
(progn (defmacro from (initial-value &key to by while (using (quote (quote +)))) "Iterates from a given initial value to an optional maximum. Every iteration increments/decrements the value applying the <using> function (by default +) to the previous value and <by> (by default 1 or -1, depending on whether to >= from or not). Similarly, the <while> function is used to determine if <to> has been reached or surpassed. <while> is a function of two arguments, the current value and the value of <to>, and as soon as it returns false, the loop is terminated. <while> defaults to a function that returns true only if <to> has been specified and, letting cur be the current value, (<= (min to from) cur (max to from))." (let* ((diff (gensym "FROM-DIFF")) (to-evaled (gensym "FROM-TO")) (initial-evaled (gensym "FROM-FROM")) (while (or while (when to (sb-int:quasiquote (lambda (cur to &aux (from #S(sb-impl::comma :expr initial-evaled :kind 0))) (let ((max (max to from)) (min (min to from))) (<= min cur max)))))))) (list (make-simple-iteration :var to-evaled :init to) (make-simple-iteration :var initial-evaled :init initial-value) (make-simple-iteration :var diff :init (if by by (sb-int:quasiquote (if #S(sb-impl::comma :expr to-evaled :kind 0) (let ((signum (signum (- #S(sb-impl::comma :expr to-evaled :kind 0) #S(sb-impl::comma :expr initial-evaled :kind 0))))) (if (zerop signum) 1 signum)) 1)))) (make-initialization :form (sb-int:quasiquote (when (and #S(sb-impl::comma :expr to-evaled :kind 0) (not (zerop (- #S(sb-impl::comma :expr to-evaled :kind 0) #S(sb-impl::comma :expr initial-evaled :kind 0)))) (not (= (signum (- #S(sb-impl::comma :expr to-evaled :kind 0) #S(sb-impl::comma :expr initial-evaled :kind 0))) (signum #S(sb-impl::comma :expr diff :kind 0))))) (terminate)))) (make-simple-iteration :init initial-evaled :step (sb-int:quasiquote (funcall #S(sb-impl::comma :expr using :kind 0) #S(sb-impl::comma :expr *iteration-variable* :kind 0) #S(sb-impl::comma :expr diff :kind 0))) :postcondition (when while (sb-int:quasiquote (funcall #S(sb-impl::comma :expr while :kind 0) #S(sb-impl::comma :expr *iteration-variable* :kind 0) #S(sb-impl::comma :expr to-evaled :kind 0)))))))) (pushnew (quote from) *clauses*))