(mod (block_decompresser_program (historical_blocks_tree))

  (defconstant local_deserialize_mod
    ;; this monstrosity is the assembly output of `chialisp_deserialisation.clsp`
    ;; it's pasted in here because the compiler doesn't yet support nested `mod`
    ;; my apologies -- RK

    (a (q 5 (a 62 (c 2 (c 5 ()))))
      (c (q ((-1 . 127) -33 . -65) ((a (i (= 11 (q . -128)) (q 4 () (c 5 ())) (q 2 (i (>s 11 24) (q 2 26 (c 2 (c (a (i (>s 11 28) (q 2 (i (>s 11 20) (q 8) (q 4 (concat (logand (q . 31) 11) (substr 5 () (q . 1))) (c (substr 5 (q . 1)) ()))) 1) (q 4 (logand (q . 63) 11) (c 5 ()))) 1) ()))) (q 4 11 (c 5 ()))) 1)) 1) 4 (substr 21 () 9) (c (substr 21 9) ())) (c (c 5 19) (c 43 ())) (a 22 (c 2 (c 9 (c (a 62 (c 2 (c 21 ()))) ())))) 2 (i (= (substr 5 () (q . 1)) 16) (q 2 46 (c 2 (c (a 62 (c 2 (c (substr 5 (q . 1)) ()))) ()))) (q 2 18 (c 2 (c (substr 5 (q . 1)) (c (substr 5 () (q . 1)) ()))))) 1)
    1))
  )

  (defun sha256tree
    (TREE)
    (if (l TREE)
        (sha256 2 (sha256tree (f TREE)) (sha256tree (r TREE)))
        (sha256 1 TREE)
    )
  )

  (defun process_coin_spend ((parent puzzle amount solution . spend_level_extras))
    (c parent (c (sha256tree puzzle) (c amount (c (a puzzle solution) spend_level_extras))))
  )

  (defun recurse (coin_spends)
    (if coin_spends
        (c (process_coin_spend (f coin_spends)) (recurse (r coin_spends)))
        0
    )
  )

  (defun process-decompressor ((coin_spends . block-level-extras))
    (c (recurse coin_spends) block-level-extras)
  )

(process-decompressor (a block_decompresser_program (list local_deserialize_mod historical_blocks_tree))))
)
