;;; XXX Note:
;;; For this to really be taken into consideration,
;;; enter it at the REPL before issuing COMPILE-FILE.
(declaim (optimize (speed 3) (safety 0) (debug 0)))


(defparameter *global* 10)
(declaim (type fixnum *global*))

(defun count-1 ()
  (loop
     for i of-type fixnum from 1 to *global*
     collect i))

;;; ecl_plus() is still invoked in this case
(defun count-2 ()
  (declare (fixnum *global*))
  (loop
     for i of-type fixnum from 1 to 10
     collect (the fixnum (+ *global* i))))


(let ((shared 10))
  (declare (type fixnum shared))

  (defun count-3 ()
    (loop
       for i of-type fixnum from 1 to shared
       collect i))

  ;;; Inline C + !
  (defun count-4 ()
    (loop
       for i of-type fixnum from 1 to 10
       collect (the fixnum (+ shared i)))))



(defun function-1 ()
  nil)

(defun test-1 ()
  (loop
     for i of-type fixnum from 0 to 100000
     do (function-1)))

(defun test-2 ()
  (flet ((function-2 ()
	   nil))
    (loop
       for i of-type fixnum from 0 to 100000
       do (function-2))))
