;;-*-Lisp-*-
(in-package goal)

;; definition for function tie-init-buffers
;; INFO: Return type mismatch int vs none.
(defun tie-init-buffers ((arg0 dma-buffer))
  (let ((gp-0 (-> *display* frames (-> *display* on-screen) frame bucket-group 9)))
    (when (!= gp-0 (-> gp-0 last))
      (let* ((s5-0 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s4-1 (-> s5-0 base))
             )
        (tie-init-engine
          s5-0
          (new 'static 'gs-test :atst (gs-atest not-equal) :zte #x1 :ztst (gs-ztest greater-equal))
          0
          )
        (let ((v1-8 (the-as object (-> s5-0 base))))
          (set! (-> (the-as dma-packet v1-8) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-0 next)))
          (set! (-> (the-as dma-packet v1-8) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet v1-8) vif1) (new 'static 'vif-tag))
          (set! (-> s5-0 base) (&+ (the-as pointer v1-8) 16))
          )
        (set! (-> gp-0 next) (the-as uint s4-1))
        )
      )
    )
  (let ((gp-1 (-> *display* frames (-> *display* on-screen) frame bucket-group 9)))
    (when (!= gp-1 (-> gp-1 last))
      (let* ((s4-2 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s5-1 (-> s4-2 base))
             )
        (tie-end-buffer s4-2)
        (let ((v1-19 (-> s4-2 base)))
          (let ((a0-17 (the-as object (-> s4-2 base))))
            (set! (-> (the-as dma-packet a0-17) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
            (set! (-> (the-as dma-packet a0-17) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a0-17) vif1) (new 'static 'vif-tag))
            (set! (-> s4-2 base) (&+ (the-as pointer a0-17) 16))
            )
          (set! (-> (the-as (pointer uint32) (-> gp-1 last)) 1) (the-as uint s5-1))
          (set! (-> gp-1 last) (the-as (pointer dma-tag) v1-19))
          )
        )
      )
    )
  (let ((gp-2 (-> *display* frames (-> *display* on-screen) frame bucket-group 16)))
    (when (!= gp-2 (-> gp-2 last))
      (let* ((s5-2 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s4-4 (-> s5-2 base))
             )
        (tie-init-engine
          s5-2
          (new 'static 'gs-test :atst (gs-atest not-equal) :zte #x1 :ztst (gs-ztest greater-equal))
          0
          )
        (let ((v1-28 (the-as object (-> s5-2 base))))
          (set! (-> (the-as dma-packet v1-28) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-2 next)))
          (set! (-> (the-as dma-packet v1-28) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet v1-28) vif1) (new 'static 'vif-tag))
          (set! (-> s5-2 base) (&+ (the-as pointer v1-28) 16))
          )
        (set! (-> gp-2 next) (the-as uint s4-4))
        )
      )
    )
  (let ((gp-3 (-> *display* frames (-> *display* on-screen) frame bucket-group 16)))
    (when (!= gp-3 (-> gp-3 last))
      (let* ((s4-5 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s5-3 (-> s4-5 base))
             )
        (tie-end-buffer s4-5)
        (let ((v1-39 (-> s4-5 base)))
          (let ((a0-36 (the-as object (-> s4-5 base))))
            (set! (-> (the-as dma-packet a0-36) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
            (set! (-> (the-as dma-packet a0-36) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a0-36) vif1) (new 'static 'vif-tag))
            (set! (-> s4-5 base) (&+ (the-as pointer a0-36) 16))
            )
          (set! (-> (the-as (pointer uint32) (-> gp-3 last)) 1) (the-as uint s5-3))
          (set! (-> gp-3 last) (the-as (pointer dma-tag) v1-39))
          )
        )
      )
    )
  (let ((gp-4 (-> *display* frames (-> *display* on-screen) frame bucket-group 8)))
    (when (!= gp-4 (-> gp-4 last))
      (let* ((s5-4 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s4-7 (-> s5-4 base))
             )
        (tie-near-init-engine
          s5-4
          (new 'static 'gs-test
            :ate #x1
            :atst (gs-atest greater-equal)
            :aref #x26
            :zte #x1
            :ztst (gs-ztest greater-equal)
            )
          0
          )
        (let ((v1-48 (the-as object (-> s5-4 base))))
          (set! (-> (the-as dma-packet v1-48) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-4 next)))
          (set! (-> (the-as dma-packet v1-48) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet v1-48) vif1) (new 'static 'vif-tag))
          (set! (-> s5-4 base) (&+ (the-as pointer v1-48) 16))
          )
        (set! (-> gp-4 next) (the-as uint s4-7))
        )
      )
    )
  (let ((gp-5 (-> *display* frames (-> *display* on-screen) frame bucket-group 8)))
    (when (!= gp-5 (-> gp-5 last))
      (let* ((s4-8 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s5-5 (-> s4-8 base))
             )
        (tie-near-end-buffer s4-8)
        (let ((v1-59 (-> s4-8 base)))
          (let ((a0-55 (the-as object (-> s4-8 base))))
            (set! (-> (the-as dma-packet a0-55) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
            (set! (-> (the-as dma-packet a0-55) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a0-55) vif1) (new 'static 'vif-tag))
            (set! (-> s4-8 base) (&+ (the-as pointer a0-55) 16))
            )
          (set! (-> (the-as (pointer uint32) (-> gp-5 last)) 1) (the-as uint s5-5))
          (set! (-> gp-5 last) (the-as (pointer dma-tag) v1-59))
          )
        )
      )
    )
  (let ((gp-6 (-> *display* frames (-> *display* on-screen) frame bucket-group 15)))
    (when (!= gp-6 (-> gp-6 last))
      (let* ((s5-6 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s4-10 (-> s5-6 base))
             )
        (tie-near-init-engine
          s5-6
          (new 'static 'gs-test
            :ate #x1
            :atst (gs-atest greater-equal)
            :aref #x26
            :zte #x1
            :ztst (gs-ztest greater-equal)
            )
          0
          )
        (let ((v1-68 (the-as object (-> s5-6 base))))
          (set! (-> (the-as dma-packet v1-68) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-6 next)))
          (set! (-> (the-as dma-packet v1-68) vif0) (new 'static 'vif-tag))
          (set! (-> (the-as dma-packet v1-68) vif1) (new 'static 'vif-tag))
          (set! (-> s5-6 base) (&+ (the-as pointer v1-68) 16))
          )
        (set! (-> gp-6 next) (the-as uint s4-10))
        )
      )
    )
  (let ((gp-7 (-> *display* frames (-> *display* on-screen) frame bucket-group 15)))
    (when (!= gp-7 (-> gp-7 last))
      (let* ((s4-11 (-> *display* frames (-> *display* on-screen) frame global-buf))
             (s5-7 (-> s4-11 base))
             )
        (tie-near-end-buffer s4-11)
        (let ((v1-79 (-> s4-11 base)))
          (let ((a0-74 (the-as object (-> s4-11 base))))
            (set! (-> (the-as dma-packet a0-74) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
            (set! (-> (the-as dma-packet a0-74) vif0) (new 'static 'vif-tag))
            (set! (-> (the-as dma-packet a0-74) vif1) (new 'static 'vif-tag))
            (set! (-> s4-11 base) (&+ (the-as pointer a0-74) 16))
            )
          (set! (-> (the-as (pointer uint32) (-> gp-7 last)) 1) (the-as uint s5-7))
          (set! (-> gp-7 last) (the-as (pointer dma-tag) v1-79))
          )
        )
      )
    )
  0
  (none)
  )

;; definition of type tie-instance-debug
(deftype tie-instance-debug (structure)
  ((max-instance uint32  :offset-assert   0)
   (min-instance uint32  :offset-assert   4)
   )
  :method-count-assert 9
  :size-assert         #x8
  :flag-assert         #x900000008
  )

;; definition for method 3 of type tie-instance-debug
(defmethod inspect tie-instance-debug ((obj tie-instance-debug))
  (format #t "[~8x] ~A~%" obj 'tie-instance-debug)
  (format #t "~Tmax-instance: ~D~%" (-> obj max-instance))
  (format #t "~Tmin-instance: ~D~%" (-> obj min-instance))
  obj
  )

;; definition for symbol *tie*, type tie-instance-debug
(define *tie* (new 'global 'tie-instance-debug))

;; definition for function tie-debug-between
(defun tie-debug-between ((arg0 uint) (arg1 uint))
  (set! (-> *instance-tie-work* test-id) arg1)
  (set! (-> *instance-tie-work* test-id2) arg0)
  arg0
  )

;; definition for function tie-debug-one
(defun tie-debug-one ((arg0 uint) (arg1 uint))
  (set! (-> *instance-tie-work* test-id) (+ arg1 -1 arg0))
  (set! (-> *instance-tie-work* test-id2) arg0)
  arg0
  )

;; definition for function walk-tie-generic-prototypes
;; INFO: Return type mismatch symbol vs none.
(defun walk-tie-generic-prototypes ()
  (none)
  )

;; definition for symbol *pke-hack*, type vector
(define *pke-hack* (new 'global 'vector))

;; definition for function draw-inline-array-instance-tie
;; ERROR: function was not converted to expressions. Cannot decompile.

;; definition for function draw-inline-array-prototype-tie-generic-asm
;; ERROR: function was not converted to expressions. Cannot decompile.

;; definition for function draw-inline-array-prototype-tie-asm
;; ERROR: function was not converted to expressions. Cannot decompile.

;; definition for function draw-inline-array-prototype-tie-near-asm
;; ERROR: function was not converted to expressions. Cannot decompile.

;; definition for method 9 of type drawable-tree-instance-tie
;; INFO: this function exists in multiple non-identical object files
(defmethod login drawable-tree-instance-tie ((obj drawable-tree-instance-tie))
  (if (nonzero? (-> obj prototypes prototype-array-tie))
      (login (-> obj prototypes prototype-array-tie))
      )
  (dotimes (s5-0 (-> obj length))
    (login (-> obj data s5-0))
    )
  obj
  )

;; definition for function draw-drawable-tree-instance-tie
;; INFO: Used lq/sq
;; INFO: Return type mismatch int vs none.
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr0, r0]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr1, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, a0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr0]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr1]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr0, r0]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr1, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, a0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr0]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr1]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr0, r0]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr1, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, a0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr0]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr1]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr0, r0]
;; ERROR: Unsupported inline assembly instruction kind - [mtpc pcr1, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, a0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mtc0 Perf, r0]
;; ERROR: Unsupported inline assembly instruction kind - [sync.l]
;; ERROR: Unsupported inline assembly instruction kind - [sync.p]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr0]
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr1]
(defun draw-drawable-tree-instance-tie ((arg0 drawable-tree-instance-tie) (arg1 level))
  (local-vars
    (a0-31 int)
    (a0-33 int)
    (a0-46 int)
    (a0-48 int)
    (a0-62 int)
    (a0-64 int)
    (a0-82 int)
    (a0-84 int)
    (sv-16 int)
    )
  (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near tie generic))
    (set! (-> *instance-tie-work* first-generic-prototype) (the-as uint 0))
    (set! (-> *instance-tie-work* wind-vectors) (-> arg0 prototypes wind-vectors))
    (let ((s4-0 (+ (-> arg0 length) -1)))
      (when (nonzero? s4-0)
        (dotimes (s3-0 s4-0)
          (let* ((v1-10 (-> arg0 data s3-0))
                 (a0-5 (-> arg0 data (+ s3-0 1)))
                 (a1-2 (/ (-> (the-as drawable-inline-array-node v1-10) data 0 id) 8))
                 (a0-7 (/ (-> (the-as drawable-inline-array-node a0-5) data 0 id) 8))
                 (a1-4 (+ a1-2 #x38b0 #x70000000))
                 (a0-9 (+ a0-7 #x38b0 #x70000000))
                 )
            (draw-node-cull
              (the-as pointer a0-9)
              (the-as pointer a1-4)
              (-> (the-as drawable-inline-array-node v1-10) data)
              (-> (the-as drawable-inline-array-node v1-10) length)
              )
            )
          )
        )
      (let* ((v1-16 (-> arg0 data s4-0))
             (s4-1 (-> arg0 prototypes prototype-array-tie))
             (s5-1 (-> s4-1 length))
             )
        (dotimes (a0-11 s5-1)
          (let ((a1-7 (-> s4-1 array-data a0-11)))
            (set! (-> a1-7 next-clear) (the-as uint128 0))
            (set! (-> a1-7 generic-count-clear) (the-as uint128 0))
            (set! (-> a1-7 generic-next-clear) (the-as uint128 0))
            )
          0
          )
        (let* ((s1-0 (-> (the-as drawable-inline-array-instance-tie v1-16) data))
               (s0-0 (&-> (the-as terrain-context #x70000000) work background vis-list (/ (-> s1-0 0 id) 8)))
               (s3-1 (-> *display* frames (-> *display* on-screen) frame global-buf))
               )
          (set! sv-16 (-> (the-as drawable-inline-array-node v1-16) length))
          (when (nonzero? sv-16)
            (let* ((v1-21 (logand (the-as int *gsf-buffer*) 8191))
                   (v1-23
                     (logand (the-as int (&- (logand (the-as int (&-> (-> s4-1 data) -512)) 8191) (the-as uint v1-21))) 8191)
                     )
                   )
              (set! *instance-tie-work-copy* (the-as instance-tie-work (+ (the-as int *gsf-buffer*) v1-23)))
              )
            (let ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
              (quad-copy! (the-as pointer *instance-tie-work-copy*) (the-as pointer *instance-tie-work*) 28)
              (set! (-> *instance-tie-work-copy* wait-to-spr) (the-as uint 0))
              (set! (-> *instance-tie-work-copy* wait-from-spr) (the-as uint 0))
              (let* ((v1-32 (-> *perf-stats* data 9))
                     (a0-28 (-> v1-32 ctrl))
                     )
                (+! (-> v1-32 count) 1)
                (b! (zero? a0-28) cfg-12 :delay (nop!))
                (.mtc0 Perf r0)
                (.sync.l)
                (.sync.p)
                (.mtpc pcr0 r0)
                (.mtpc pcr1 r0)
                (.sync.l)
                (.sync.p)
                (.mtc0 Perf a0-28)
                )
              (.sync.l)
              (.sync.p)
              (label cfg-12)
              0
              (let ((t9-2 draw-inline-array-instance-tie)
                    (a3-1 s3-1)
                    )
                (t9-2 s0-0 s1-0 sv-16 a3-1)
                )
              (let ((v1-35 (-> *perf-stats* data 9)))
                (b! (zero? (-> v1-35 ctrl)) cfg-14 :delay (nop!))
                (.mtc0 Perf r0)
                (.sync.l)
                (.sync.p)
                (.mfpc a0-31 pcr0)
                (+! (-> v1-35 accum0) a0-31)
                (.mfpc a0-33 pcr1)
                (+! (-> v1-35 accum1) a0-33)
                )
              (label cfg-14)
              0
              (update-wait-stats
                (-> *perf-stats* data 9)
                (the-as uint 0)
                (-> *instance-tie-work-copy* wait-to-spr)
                (-> *instance-tie-work-copy* wait-from-spr)
                )
              (let ((v1-42 (-> *instance-tie-work-copy* min-dist quad)))
                (set! (-> *instance-tie-work* min-dist quad) v1-42)
                )
              (set! (-> *instance-tie-work* flags) (-> *instance-tie-work-copy* flags))
              (let ((a0-38 *dma-mem-usage*))
                (when (nonzero? a0-38)
                  (set! (-> a0-38 length) (max 10 (-> a0-38 length)))
                  (set! (-> a0-38 data 9 name) "tie-fragment")
                  (+! (-> a0-38 data 9 count) 1)
                  (+! (-> a0-38 data 9 used)
                      (&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s2-0))
                      )
                  (set! (-> a0-38 data 9 total) (-> a0-38 data 9 used))
                  )
                )
              )
            (when (logtest? *vu1-enable-user* (vu1-renderer-mask generic))
              (when (logtest? (-> *instance-tie-work* flags) 2)
                (let ((s2-1 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
                  (set! (-> *prototype-tie-work* generic-wait-to-spr) (the-as uint 0))
                  (set! (-> *prototype-tie-work* generic-wait-from-spr) (the-as uint 0))
                  (set! (-> *instance-tie-work* first-generic-prototype) (the-as uint (-> s3-1 base)))
                  (let* ((v1-60 (-> *perf-stats* data 10))
                         (a0-43 (-> v1-60 ctrl))
                         )
                    (+! (-> v1-60 count) 1)
                    (b! (zero? a0-43) cfg-20 :delay (nop!))
                    (.mtc0 Perf r0)
                    (.sync.l)
                    (.sync.p)
                    (.mtpc pcr0 r0)
                    (.mtpc pcr1 r0)
                    (.sync.l)
                    (.sync.p)
                    (.mtc0 Perf a0-43)
                    )
                  (.sync.l)
                  (.sync.p)
                  (label cfg-20)
                  0
                  (draw-inline-array-prototype-tie-generic-asm s3-1 s5-1 s4-1)
                  (let ((v1-63 (-> *perf-stats* data 10)))
                    (b! (zero? (-> v1-63 ctrl)) cfg-22 :delay (nop!))
                    (.mtc0 Perf r0)
                    (.sync.l)
                    (.sync.p)
                    (.mfpc a0-46 pcr0)
                    (+! (-> v1-63 accum0) a0-46)
                    (.mfpc a0-48 pcr1)
                    (+! (-> v1-63 accum1) a0-48)
                    )
                  (label cfg-22)
                  0
                  (update-wait-stats
                    (-> *perf-stats* data 10)
                    (the-as uint 0)
                    (-> *prototype-tie-work* generic-wait-to-spr)
                    (-> *prototype-tie-work* generic-wait-from-spr)
                    )
                  (let ((a0-51 *dma-mem-usage*))
                    (when (nonzero? a0-51)
                      (set! (-> a0-51 length) (max 18 (-> a0-51 length)))
                      (set! (-> a0-51 data 17 name) "tie-generic")
                      (+! (-> a0-51 data 17 count) 1)
                      (+! (-> a0-51 data 17 used)
                          (&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s2-1))
                          )
                      (set! (-> a0-51 data 17 total) (-> a0-51 data 17 used))
                      )
                    )
                  )
                )
              )
            (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie))
              (let ((s3-2 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
                (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie))
                  (let* ((s1-1 (-> *display* frames (-> *display* on-screen) frame global-buf))
                         (s2-2 (-> s1-1 base))
                         )
                    (set! (-> *prototype-tie-work* wait-to-spr) (the-as uint 0))
                    (set! (-> *prototype-tie-work* wait-from-spr) (the-as uint 0))
                    (let* ((v1-85 (-> *perf-stats* data 11))
                           (a0-59 (-> v1-85 ctrl))
                           )
                      (+! (-> v1-85 count) 1)
                      (b! (zero? a0-59) cfg-28 :delay (nop!))
                      (.mtc0 Perf r0)
                      (.sync.l)
                      (.sync.p)
                      (.mtpc pcr0 r0)
                      (.mtpc pcr1 r0)
                      (.sync.l)
                      (.sync.p)
                      (.mtc0 Perf a0-59)
                      )
                    (.sync.l)
                    (.sync.p)
                    (label cfg-28)
                    0
                    (draw-inline-array-prototype-tie-asm s1-1 s5-1 s4-1)
                    (let ((v1-88 (-> *perf-stats* data 11)))
                      (b! (zero? (-> v1-88 ctrl)) cfg-30 :delay (nop!))
                      (.mtc0 Perf r0)
                      (.sync.l)
                      (.sync.p)
                      (.mfpc a0-62 pcr0)
                      (+! (-> v1-88 accum0) a0-62)
                      (.mfpc a0-64 pcr1)
                      (+! (-> v1-88 accum1) a0-64)
                      )
                    (label cfg-30)
                    0
                    (update-wait-stats
                      (-> *perf-stats* data 11)
                      (the-as uint 0)
                      (-> *prototype-tie-work* wait-to-spr)
                      (-> *prototype-tie-work* wait-from-spr)
                      )
                    (let ((a3-11 (-> s1-1 base)))
                      (let ((v1-94 (the-as object (-> s1-1 base))))
                        (set! (-> (the-as dma-packet v1-94) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
                        (set! (-> (the-as dma-packet v1-94) vif0) (new 'static 'vif-tag))
                        (set! (-> (the-as dma-packet v1-94) vif1) (new 'static 'vif-tag))
                        (set! (-> s1-1 base) (&+ (the-as pointer v1-94) 16))
                        )
                      (dma-bucket-insert-tag
                        (-> *display* frames (-> *display* on-screen) frame bucket-group)
                        (the-as bucket-id (if (zero? (-> arg1 index))
                                              9
                                              16
                                              )
                                )
                        s2-2
                        (the-as (pointer dma-tag) a3-11)
                        )
                      )
                    )
                  )
                (let ((v1-100 *dma-mem-usage*))
                  (when (nonzero? v1-100)
                    (set! (-> v1-100 length) (max 10 (-> v1-100 length)))
                    (set! (-> v1-100 data 9 name) "tie-fragment")
                    (+! (-> v1-100 data 9 count) 1)
                    (+! (-> v1-100 data 9 used)
                        (&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s3-2))
                        )
                    (set! (-> v1-100 data 9 total) (-> v1-100 data 9 used))
                    )
                  )
                )
              )
            (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near))
              (let ((s3-3 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
                (let* ((s1-2 (-> *display* frames (-> *display* on-screen) frame global-buf))
                       (s2-3 (-> s1-2 base))
                       )
                  (set! (-> *prototype-tie-work* near-wait-to-spr) (the-as uint 0))
                  (set! (-> *prototype-tie-work* near-wait-from-spr) (the-as uint 0))
                  (let* ((v1-114 (-> *perf-stats* data 12))
                         (a0-79 (-> v1-114 ctrl))
                         )
                    (+! (-> v1-114 count) 1)
                    (b! (zero? a0-79) cfg-39 :delay (nop!))
                    (.mtc0 Perf r0)
                    (.sync.l)
                    (.sync.p)
                    (.mtpc pcr0 r0)
                    (.mtpc pcr1 r0)
                    (.sync.l)
                    (.sync.p)
                    (.mtc0 Perf a0-79)
                    )
                  (.sync.l)
                  (.sync.p)
                  (label cfg-39)
                  0
                  (draw-inline-array-prototype-tie-near-asm s1-2 s5-1 s4-1)
                  (let ((v1-117 (-> *perf-stats* data 12)))
                    (b! (zero? (-> v1-117 ctrl)) cfg-41 :delay (nop!))
                    (.mtc0 Perf r0)
                    (.sync.l)
                    (.sync.p)
                    (.mfpc a0-82 pcr0)
                    (+! (-> v1-117 accum0) a0-82)
                    (.mfpc a0-84 pcr1)
                    (+! (-> v1-117 accum1) a0-84)
                    )
                  (label cfg-41)
                  0
                  (update-wait-stats
                    (-> *perf-stats* data 12)
                    (the-as uint 0)
                    (-> *prototype-tie-work* near-wait-to-spr)
                    (-> *prototype-tie-work* near-wait-from-spr)
                    )
                  (let ((a3-16 (-> s1-2 base)))
                    (let ((v1-123 (the-as object (-> s1-2 base))))
                      (set! (-> (the-as dma-packet v1-123) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
                      (set! (-> (the-as dma-packet v1-123) vif0) (new 'static 'vif-tag))
                      (set! (-> (the-as dma-packet v1-123) vif1) (new 'static 'vif-tag))
                      (set! (-> s1-2 base) (&+ (the-as pointer v1-123) 16))
                      )
                    (dma-bucket-insert-tag
                      (-> *display* frames (-> *display* on-screen) frame bucket-group)
                      (the-as bucket-id (if (zero? (-> arg1 index))
                                            8
                                            15
                                            )
                              )
                      s2-3
                      (the-as (pointer dma-tag) a3-16)
                      )
                    )
                  )
                (let ((a0-92 *dma-mem-usage*))
                  (when (nonzero? a0-92)
                    (set! (-> a0-92 length) (max 16 (-> a0-92 length)))
                    (set! (-> a0-92 data 15 name) "tie-near")
                    (+! (-> a0-92 data 15 count) 1)
                    (+! (-> a0-92 data 15 used)
                        (&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s3-3))
                        )
                    (set! (-> a0-92 data 15 total) (-> a0-92 data 15 used))
                    )
                  )
                )
              )
            )
          )
        )
      )
    0
    )
  (set! (-> arg1 closest-object 5) (-> *instance-tie-work* min-dist x))
  0
  (none)
  )

;; definition for method 10 of type drawable-tree-instance-tie
;; INFO: Return type mismatch drawable-tree-instance-tie vs none.
(defmethod draw drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 drawable-tree-instance-tie) (arg1 display-frame))
  (let* ((v1-1 (-> *background-work* tie-tree-count))
         (a1-2 (-> (the-as terrain-context #x70000000) bsp lev-index))
         (a1-5 (-> *level* level a1-2))
         )
    (set! (-> *background-work* tie-trees v1-1) obj)
    (set! (-> *background-work* tie-levels v1-1) a1-5)
    )
  (+! (-> *background-work* tie-tree-count) 1)
  (none)
  )

;; definition for method 14 of type drawable-tree-instance-tie
;; INFO: Return type mismatch symbol vs none.
(defmethod collect-stats drawable-tree-instance-tie ((obj drawable-tree-instance-tie))
  (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near tie generic))
    (-> obj data (+ (-> obj length) -1))
    (let ((v1-8 (-> obj prototypes prototype-array-tie)))
      (dotimes (a0-1 (-> v1-8 length))
        (let ((a1-2 (-> v1-8 array-data a0-1)))
          (when (logtest? *vu1-enable-user* (vu1-renderer-mask generic))
            (let ((a2-3 0)
                  (a3-0 3)
                  )
              (while (>= a3-0 a2-3)
                (let ((t0-2 (-> a1-2 generic-count a2-3))
                      (t2-0 (-> a1-2 geometry-override a2-3))
                      )
                  (when (nonzero? t0-2)
                    (let ((t1-3 (the-as object (-> t2-0 data)))
                          (t2-1 (-> t2-0 length))
                          )
                      (+! (-> *terrain-stats* tie-generic groups) 1)
                      (+! (-> *terrain-stats* tie-generic fragments) t2-1)
                      (+! (-> *terrain-stats* tie-generic instances) t0-2)
                      (dotimes (t3-9 t2-1)
                        (let ((t5-0 (* (-> (the-as tie-fragment t1-3) num-tris) t0-2))
                              (t4-5 (* (-> (the-as tie-fragment t1-3) num-dverts) t0-2))
                              )
                          (+! (-> *terrain-stats* tie-generic tris) t5-0)
                          (+! (-> *terrain-stats* tie-generic dverts) t4-5)
                          )
                        (set! t1-3 (&+ (the-as tie-fragment t1-3) 64))
                        )
                      )
                    )
                  )
                (+! a2-3 1)
                )
              )
            )
          (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie))
            (let ((a2-9 1)
                  (a3-1 3)
                  )
              (while (>= a3-1 a2-9)
                (let ((t0-6 (-> a1-2 count a2-9))
                      (t2-2 (-> a1-2 geometry-override a2-9))
                      )
                  (when (nonzero? t0-6)
                    (let ((t1-8 (the-as object (-> t2-2 data)))
                          (t2-3 (-> t2-2 length))
                          )
                      (+! (-> *terrain-stats* tie groups) 1)
                      (+! (-> *terrain-stats* tie fragments) t2-3)
                      (+! (-> *terrain-stats* tie instances) t0-6)
                      (dotimes (t3-19 t2-3)
                        (let ((t5-5 (* (-> (the-as tie-fragment t1-8) num-tris) t0-6))
                              (t4-12 (* (-> (the-as tie-fragment t1-8) num-dverts) t0-6))
                              )
                          (+! (-> *terrain-stats* tie tris) t5-5)
                          (+! (-> *terrain-stats* tie dverts) t4-12)
                          )
                        (set! t1-8 (&+ (the-as tie-fragment t1-8) 64))
                        )
                      )
                    )
                  )
                (+! a2-9 1)
                )
              )
            )
          (when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near))
            (let ((a2-14 (-> a1-2 count 0))
                  (a3-2 (-> a1-2 geometry-override 0))
                  )
              (when (nonzero? a2-14)
                (let ((a1-3 (the-as object (-> a3-2 data)))
                      (a3-3 (-> a3-2 length))
                      )
                  (+! (-> *terrain-stats* tie-near groups) 1)
                  (+! (-> *terrain-stats* tie-near fragments) a3-3)
                  (+! (-> *terrain-stats* tie-near instances) a2-14)
                  (dotimes (t0-19 a3-3)
                    (let ((t2-4 (* (-> (the-as tie-fragment a1-3) num-tris) a2-14))
                          (t1-15 (* (-> (the-as tie-fragment a1-3) num-dverts) a2-14))
                          )
                      (+! (-> *terrain-stats* tie-near tris) t2-4)
                      (+! (-> *terrain-stats* tie-near dverts) t1-15)
                      )
                    (set! a1-3 (&+ (the-as tie-fragment a1-3) 64))
                    )
                  )
                )
              )
            )
          )
        )
      )
    )
  (none)
  )

;; definition for method 15 of type drawable-tree-instance-tie
;; INFO: Return type mismatch symbol vs none.
(defmethod debug-draw drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 drawable) (arg1 display-frame))
  (-> obj data (+ (-> obj length) -1))
  (let* ((s5-0 (-> obj prototypes prototype-array-tie))
         (s4-0 (-> s5-0 length))
         )
    (dotimes (s3-0 s4-0)
      (let ((a1-1 (-> s5-0 array-data s3-0 geometry-override 0)))
        (debug-draw a1-1 a1-1 arg1)
        )
      )
    )
  (none)
  )

;; definition for method 11 of type drawable-tree-instance-tie
;; INFO: this function exists in multiple non-identical object files
;; INFO: Return type mismatch int vs none.
(defmethod collide-with-box drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-with-box (-> obj data 0) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 12 of type drawable-tree-instance-tie
;; INFO: this function exists in multiple non-identical object files
;; INFO: Return type mismatch int vs none.
(defmethod collide-y-probe drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-y-probe (-> obj data 0) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 13 of type drawable-tree-instance-tie
;; INFO: this function exists in multiple non-identical object files
;; INFO: Return type mismatch int vs none.
(defmethod collide-ray drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-ray (-> obj data 0) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 11 of type drawable-tree-instance-tie
;; INFO: this function exists in multiple non-identical object files
;; INFO: Return type mismatch int vs none.
(defmethod collide-with-box drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-with-box (-> obj data 0) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 12 of type drawable-tree-instance-tie
;; INFO: this function exists in multiple non-identical object files
;; INFO: Return type mismatch int vs none.
(defmethod collide-y-probe drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-y-probe (-> obj data 0) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 13 of type drawable-tree-instance-tie
;; INFO: this function exists in multiple non-identical object files
;; INFO: Return type mismatch int vs none.
(defmethod collide-ray drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-ray (-> obj data 0) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 11 of type drawable-inline-array-instance-tie
;; INFO: Return type mismatch int vs none.
(defmethod collide-with-box drawable-inline-array-instance-tie ((obj drawable-inline-array-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-with-box (the-as instance-tie (-> obj data)) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 12 of type drawable-inline-array-instance-tie
;; INFO: Return type mismatch int vs none.
(defmethod collide-y-probe drawable-inline-array-instance-tie ((obj drawable-inline-array-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-y-probe (the-as instance-tie (-> obj data)) (-> obj length) arg1)
  0
  (none)
  )

;; definition for method 13 of type drawable-inline-array-instance-tie
;; INFO: Return type mismatch int vs none.
(defmethod collide-ray drawable-inline-array-instance-tie ((obj drawable-inline-array-instance-tie) (arg0 int) (arg1 collide-list))
  (collide-ray (the-as instance-tie (-> obj data)) (-> obj length) arg1)
  0
  (none)
  )

;; definition (debug) for function tie-test-cam-restore
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defun-debug tie-test-cam-restore ()
  (let ((a0-0 (new-stack-vector0))
        (a1-0 (new-stack-matrix0))
        )
    (set! (-> a0-0 x) 1246582.6)
    (set! (-> a0-0 y) 57026.02)
    (set! (-> a0-0 z) -490734.78)
    (set! (-> a0-0 w) 1.0)
    (set! (-> a1-0 vector 0 x) -0.9873)
    (set! (-> a1-0 vector 0 y) 0.0)
    (set! (-> a1-0 vector 0 z) -0.1587)
    (set! (-> a1-0 vector 0 w) 0.0)
    (set! (-> a1-0 vector 1 x) 0.0014)
    (set! (-> a1-0 vector 1 y) 0.9999)
    (set! (-> a1-0 vector 1 z) -0.0092)
    (set! (-> a1-0 vector 1 w) 0.0)
    (set! (-> a1-0 vector 2 x) 0.1587)
    (set! (-> a1-0 vector 2 y) -0.0093)
    (set! (-> a1-0 vector 2 z) -0.9872)
    (set! (-> a1-0 vector 2 w) 0.0)
    (set! (-> a1-0 vector 3 x) 0.0)
    (set! (-> a1-0 vector 3 y) 0.0)
    (set! (-> a1-0 vector 3 z) 0.0)
    (set! (-> a1-0 vector 3 w) 1.0)
    (debug-set-camera-pos-rot! a0-0 a1-0)
    )
  (send-event *camera* 'set-fov 11650.845)
  (none)
  )
