;;; -*- mode: lisp -*-
;;; $Id: strcat.cmucl,v 1.0 2002/05/03 12:06:00 dada Exp $

(defconstant *string* "hello
")
              
(defun string-concat1 (n)
  (declare (fixnum n))
  (let ((str "")
        (used-len 0)
        (string-leng 0)
        (i (1+ n)))
    (declare (fixnum i used-len string-leng))
    (declare (simple-base-string str))
    (declare (optimize (speed 3) (debug 0) (safety 0)))
    (dotimes (i (1- i) (replace (make-string used-len) str))
      (let ((required-length (+ used-len (length *string*))))
        (if (eq string-leng 0)
            (setq str (make-string required-length)
                  string-leng required-length)
          (if (>; required-length string-leng)
              (let ((new-len (+ string-leng string-leng)))
                (let ((new-str (make-string new-len)))
                  (replace new-str str :end2 used-len)
                  (setq str new-str string-leng new-len)))))
        (replace str *string* :start1 used-len)
        (setq used-len required-length)))))

(let ((n (parse-integer (or (car pop11::poparglist) "1"))))
(format t "~A~%" (length (string-concat1 n))))