(PROCLAIM '(OPTIMIZE SPEED SAFETY DEBUG))
(PROVIDE "compiler")

(DECLAIM (FTYPE (FUNCTION (|%Triple| |%Mode|) (|%Maybe| |%Triple|)) |coerce|))

(DECLAIM (FTYPE (FUNCTION (|%Triple| |%Mode|) (|%Maybe| |%Triple|)) |convert|))

(DECLAIM
 (FTYPE (FUNCTION (|%Form| |%Mode| |%Env|) (|%Maybe| |%Triple|)) |comp|))

(DECLAIM
 (FTYPE (FUNCTION (|%Form| |%Mode| |%Env|) (|%Maybe| |%Triple|)) |compOrCroak|))

(DECLAIM
 (FTYPE (FUNCTION (|%Form| |%Env|) (|%Maybe| |%Triple|))
  |compCompilerPredicate|))

(DECLAIM
 (FTYPE (FUNCTION (|%List| |%Short|) (|%SimpleArray| |%Short|))
  |checkCallingConvention|))

(DEFUN |applyMapping| (|bfVar#13| |m| |e| |ml|)
  (PROG (|op'| |nprefix| |form| |argl'| |LETTMP#1| |ml'| |pairlis| |argl| |op|)
    (DECLARE
     (SPECIAL |$form| |$op| |$prefix| |$formalArgList|
      |$FormalMapVariableList|))
    (RETURN
     (PROGN
      (SETQ |op| (CAR |bfVar#13|))
      (SETQ |argl| (CDR |bfVar#13|))
      (COND ((NOT (EQL (LENGTH |argl|) (- (LENGTH |ml|) 1))) NIL)
            ((|isCategoryForm| (CAR |ml|) |e|)
             (PROGN
              (SETQ |pairlis|
                      (LET ((|bfVar#3| NIL)
                            (|bfVar#1| |argl|)
                            (|a| NIL)
                            (|bfVar#2| |$FormalMapVariableList|)
                            (|v| NIL))
                        (LOOP
                         (COND
                          ((OR (ATOM |bfVar#1|)
                               (PROGN (SETQ |a| (CAR |bfVar#1|)) NIL)
                               (ATOM |bfVar#2|)
                               (PROGN (SETQ |v| (CAR |bfVar#2|)) NIL))
                           (RETURN (NREVERSE |bfVar#3|)))
                          ('T
                           (SETQ |bfVar#3| (CONS (CONS |v| |a|) |bfVar#3|))))
                         (SETQ |bfVar#1| (CDR |bfVar#1|))
                         (SETQ |bfVar#2| (CDR |bfVar#2|)))))
              (SETQ |ml'| (SUBLIS |pairlis| |ml|))
              (SETQ |argl'|
                      (LET ((|bfVar#6| NIL)
                            (|bfVar#4| |argl|)
                            (|x| NIL)
                            (|bfVar#5| (CDR |ml'|))
                            (|m'| NIL))
                        (LOOP
                         (COND
                          ((OR (ATOM |bfVar#4|)
                               (PROGN (SETQ |x| (CAR |bfVar#4|)) NIL)
                               (ATOM |bfVar#5|)
                               (PROGN (SETQ |m'| (CAR |bfVar#5|)) NIL))
                           (RETURN (NREVERSE |bfVar#6|)))
                          ('T
                           (SETQ |bfVar#6|
                                   (CONS
                                    (CAR
                                     (PROGN
                                      (SETQ |LETTMP#1|
                                              (OR (|comp| |x| |m'| |e|)
                                                  (RETURN '|failed|)))
                                      (SETQ |e| (CADDR |LETTMP#1|))
                                      |LETTMP#1|))
                                    |bfVar#6|))))
                         (SETQ |bfVar#4| (CDR |bfVar#4|))
                         (SETQ |bfVar#5| (CDR |bfVar#5|)))))
              (COND ((EQ |argl'| '|failed|) (RETURN NIL)))
              (SETQ |form| (CONS |op| |argl'|))
              (|convert| (LIST |form| (CAR |ml'|) |e|) |m|)))
            ('T
             (PROGN
              (SETQ |argl'|
                      (LET ((|bfVar#9| NIL)
                            (|bfVar#7| |argl|)
                            (|x| NIL)
                            (|bfVar#8| (CDR |ml|))
                            (|m'| NIL))
                        (LOOP
                         (COND
                          ((OR (ATOM |bfVar#7|)
                               (PROGN (SETQ |x| (CAR |bfVar#7|)) NIL)
                               (ATOM |bfVar#8|)
                               (PROGN (SETQ |m'| (CAR |bfVar#8|)) NIL))
                           (RETURN (NREVERSE |bfVar#9|)))
                          ('T
                           (SETQ |bfVar#9|
                                   (CONS
                                    (CAR
                                     (PROGN
                                      (SETQ |LETTMP#1|
                                              (OR (|comp| |x| |m'| |e|)
                                                  (RETURN '|failed|)))
                                      (SETQ |e| (CADDR |LETTMP#1|))
                                      |LETTMP#1|))
                                    |bfVar#9|))))
                         (SETQ |bfVar#7| (CDR |bfVar#7|))
                         (SETQ |bfVar#8| (CDR |bfVar#8|)))))
              (COND ((EQ |argl'| '|failed|) (RETURN NIL)))
              (SETQ |form|
                      (COND
                       ((AND (NOT (|member| |op| |$formalArgList|))
                             (ATOM |op|)
                             (NOT (|get| |op| '|value| |e|)))
                        (PROGN
                         (SETQ |nprefix|
                                 (OR |$prefix|
                                     (|getAbbreviation| |$op|
                                      (LENGTH (CDR |$form|)))))
                         (SETQ |op'|
                                 (INTERN
                                  (STRCONC (|encodeItem| |nprefix|) '|;|
                                   (|encodeItem| |op|))))
                         (CONS |op'| (APPEND |argl'| (CONS '$ NIL)))))
                       ('T
                        (CONS '|call|
                              (CONS (LIST '|applyFun| |op|) |argl'|)))))
              (SETQ |pairlis|
                      (LET ((|bfVar#12| NIL)
                            (|bfVar#10| |argl'|)
                            (|a| NIL)
                            (|bfVar#11| |$FormalMapVariableList|)
                            (|v| NIL))
                        (LOOP
                         (COND
                          ((OR (ATOM |bfVar#10|)
                               (PROGN (SETQ |a| (CAR |bfVar#10|)) NIL)
                               (ATOM |bfVar#11|)
                               (PROGN (SETQ |v| (CAR |bfVar#11|)) NIL))
                           (RETURN (NREVERSE |bfVar#12|)))
                          ('T
                           (SETQ |bfVar#12| (CONS (CONS |v| |a|) |bfVar#12|))))
                         (SETQ |bfVar#10| (CDR |bfVar#10|))
                         (SETQ |bfVar#11| (CDR |bfVar#11|)))))
              (|convert| (LIST |form| (SUBLIS |pairlis| (CAR |ml|)) |e|)
               |m|))))))))

