@fraczak/k 6.10.3 → 6.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/DOCS/FILE_FORMATS.md +51 -16
  3. package/Examples/arithmetics.k +222 -110
  4. package/Examples/karatsuba-mult.k +215 -0
  5. package/Examples/poly.k +14 -5
  6. package/backends/arm64/scripts/run-tests.mjs +16 -0
  7. package/backends/llvm/bin/k-llvm-build.mjs +40 -14
  8. package/backends/llvm/bin/k-llvm-compile.mjs +29 -12
  9. package/backends/llvm/runtime/krt.c +10 -10
  10. package/backends/llvm/runtime/krt.h +6 -1
  11. package/backends/llvm/scripts/run-tests.mjs +16 -0
  12. package/backends/llvm/src/cli.mjs +1 -1
  13. package/backends/llvm/src/executable.mjs +36 -0
  14. package/backends/llvm/src/kvm2llvm.mjs +10 -4
  15. package/backends/llvm/tests/integration.sh +11 -0
  16. package/backends/llvm/tests/test-llvm.mjs +15 -1
  17. package/backends/wasm/scripts/run-tests.mjs +16 -0
  18. package/browser/shims/fs.mjs +12 -7
  19. package/browser/vfs-data.mjs +7 -10
  20. package/core.k +25 -18
  21. package/harness/suites/poly.mjs +1 -1
  22. package/package.json +2 -1
  23. package/repl-codecs.mjs +6 -3
  24. package/scripts/benchmark-idempotency.mjs +27 -0
  25. package/scripts/benchmark.mjs +51 -0
  26. package/scripts/build-repl-html.mjs +28 -10
  27. package/scripts/generate-dependency-graph.mjs +25 -1
  28. package/scripts/perf-ieee.mjs +75 -0
  29. package/scripts/perf-int.mjs +67 -0
  30. package/scripts/perf-multiplication.mjs +644 -0
  31. package/scripts/perf-poly.mjs +68 -1
  32. package/scripts/render-benchmark.mjs +25 -0
  33. package/scripts/run-tests.mjs +19 -0
  34. package/tests/test-arithmetics.mjs +96 -0
  35. package/tests/test-karatsuba.mjs +133 -0
  36. package/tests/test-repl-html.mjs +23 -6
@@ -1,21 +1,18 @@
1
1
  // Auto-generated by scripts/build-repl-html.mjs - DO NOT EDIT MANUALLY
2
2
  export const vfsData = {
3
3
  "backends/wasm/runtime.wat": "(module\n (memory (export \"memory\") 1)\n\n ;; Start allocation at byte offset 1024 to leave a safety margin and avoid returning 0 (nullptr)\n (global $arena_free (export \"arena_free\") (mut i32) (i32.const 1024))\n ;; Maximum address of the currently allocated pages (1 page = 64KB)\n (global $arena_max (export \"arena_max\") (mut i32) (i32.const 65536))\n ;; Out-of-memory status flags\n (global $oom_flag (export \"oom_flag\") (mut i32) (i32.const 0))\n (global $oom_size (export \"oom_size\") (mut i32) (i32.const 0))\n\n ;; Bump allocator function: aligns allocation size to 8 bytes, grows memory if needed, and returns the pointer\n (func $alloc (export \"alloc\") (param $size i32) (result i32)\n (local $old_free i32)\n (local $new_free i32)\n (local $pages_needed i32)\n (local $grow_res i32)\n\n ;; Check if size exceeds maximum allocatable size\n local.get $size\n i32.const -8\n i32.gt_u\n if\n i32.const 1\n global.set $oom_flag\n local.get $size\n global.set $oom_size\n unreachable\n end\n\n ;; 1. Align size to 8 bytes: size = (size + 7) & ~8\n local.get $size\n i32.const 7\n i32.add\n i32.const -8\n i32.and\n local.set $size\n\n ;; Get current free pointer\n global.get $arena_free\n local.set $old_free\n\n ;; Calculate proposed new free pointer\n local.get $old_free\n local.get $size\n i32.add\n local.set $new_free\n\n ;; Check for 32-bit unsigned overflow\n local.get $new_free\n local.get $old_free\n i32.lt_u\n if\n i32.const 1\n global.set $oom_flag\n local.get $size\n global.set $oom_size\n unreachable\n end\n\n ;; 2. Check if we exceed current memory size\n local.get $new_free\n global.get $arena_max\n i32.gt_u\n if\n ;; Calculate how many additional pages we need to grow\n local.get $new_free\n global.get $arena_max\n i32.sub\n i32.const 65535\n i32.add\n i32.const 65536\n i32.div_u\n local.set $pages_needed\n\n ;; Try to grow memory by $pages_needed\n local.get $pages_needed\n memory.grow\n local.set $grow_res\n\n ;; If grow returns -1, we are out of memory\n local.get $grow_res\n i32.const -1\n i32.eq\n if\n i32.const 1\n global.set $oom_flag\n local.get $size\n global.set $oom_size\n unreachable\n end\n\n ;; Update arena_max: arena_max = arena_max + pages_needed * 65536\n global.get $arena_max\n local.get $pages_needed\n i32.const 65536\n i32.mul\n i32.add\n global.set $arena_max\n end\n\n ;; 3. Perform the allocation\n local.get $new_free\n global.set $arena_free\n\n local.get $old_free\n )\n\n ;; Return a checkpoint that can be restored after a temporary result is consumed.\n (func $arena_mark (export \"arena_mark\") (result i32)\n global.get $arena_free\n )\n\n ;; Bulk-free allocations made after a checkpoint. Memory pages remain available for reuse.\n (func $arena_reset (export \"arena_reset\") (param $mark i32)\n local.get $mark\n i32.const 1024\n i32.lt_u\n if\n unreachable\n end\n\n local.get $mark\n global.get $arena_free\n i32.gt_u\n if\n unreachable\n end\n\n local.get $mark\n global.set $arena_free\n )\n\n ;; Compaction staging globals\n (global $compact_buf_start (mut i32) (i32.const 0))\n (global $compact_buf_free (mut i32) (i32.const 0))\n\n ;; Ensure memory capacity in staging buffer\n (func $ensure_buf_capacity (param $size i32)\n (local $needed i32)\n (local $pages i32)\n (local $grow_res i32)\n\n global.get $compact_buf_free\n local.get $size\n i32.add\n local.set $needed\n\n ;; Check for 32-bit overflow\n local.get $needed\n global.get $compact_buf_free\n i32.lt_u\n if\n i32.const 1\n global.set $oom_flag\n local.get $size\n global.set $oom_size\n unreachable\n end\n\n local.get $needed\n global.get $arena_max\n i32.gt_u\n if\n local.get $needed\n global.get $arena_max\n i32.sub\n i32.const 65535\n i32.add\n i32.const 65536\n i32.div_u\n local.set $pages\n\n local.get $pages\n memory.grow\n local.set $grow_res\n\n local.get $grow_res\n i32.const -1\n i32.eq\n if\n i32.const 1\n global.set $oom_flag\n local.get $size\n global.set $oom_size\n unreachable\n end\n\n global.get $arena_max\n local.get $pages\n i32.const 65536\n i32.mul\n i32.add\n global.set $arena_max\n end\n )\n\n ;; Initialize compaction staging buffer at current arena top\n (func $compact_start (export \"compact_start\")\n global.get $arena_free\n global.set $compact_buf_start\n global.get $arena_free\n global.set $compact_buf_free\n )\n\n ;; Compact an object graph reachable from $root down toward $mark\n (func $compact_obj (export \"compact_obj\") (param $root i32) (param $mark i32) (result i32)\n (local $curr i32)\n (local $first_final i32)\n (local $prev_dest i32)\n (local $dest i32)\n (local $final_ptr i32)\n (local $tag i32)\n (local $payload i32)\n (local $size i32)\n (local $alignedSize i32)\n (local $N i32)\n (local $i i32)\n (local $offsetVal i32)\n (local $fieldPtr i32)\n (local $child_final i32)\n\n local.get $root\n local.set $curr\n i32.const 0\n local.set $prev_dest\n\n (block $break_chain\n (loop $chain_loop\n ;; 1. Check null / empty\n local.get $curr\n i32.eqz\n if\n local.get $prev_dest\n if\n local.get $prev_dest\n i32.const 0\n i32.store offset=8\n end\n br $break_chain\n end\n\n ;; 2. Check if < mark\n local.get $curr\n local.get $mark\n i32.lt_u\n if\n local.get $prev_dest\n if\n local.get $prev_dest\n local.get $curr\n i32.store offset=8\n end\n local.get $first_final\n i32.eqz\n if\n local.get $curr\n local.set $first_final\n end\n br $break_chain\n end\n\n ;; 3. Check if forwarded\n local.get $curr\n i32.load offset=0\n local.set $size\n\n local.get $size\n i32.const -1\n i32.eq\n if\n local.get $curr\n i32.load offset=4\n local.set $final_ptr\n local.get $prev_dest\n if\n local.get $prev_dest\n local.get $final_ptr\n i32.store offset=8\n end\n local.get $first_final\n i32.eqz\n if\n local.get $final_ptr\n local.set $first_final\n end\n br $break_chain\n end\n\n ;; 4. Compute final_ptr = mark + (compact_buf_free - compact_buf_start)\n local.get $mark\n global.get $compact_buf_free\n global.get $compact_buf_start\n i32.sub\n i32.add\n local.set $final_ptr\n\n local.get $first_final\n i32.eqz\n if\n local.get $final_ptr\n local.set $first_final\n end\n\n ;; If prev_dest != 0, patch its payload to final_ptr\n local.get $prev_dest\n if\n local.get $prev_dest\n local.get $final_ptr\n i32.store offset=8\n end\n\n ;; 5. Check if Variant (size == 12)\n local.get $size\n i32.const 12\n i32.eq\n if\n i32.const 16\n call $ensure_buf_capacity\n\n local.get $curr\n i32.load offset=4\n local.set $tag\n local.get $curr\n i32.load offset=8\n local.set $payload\n\n local.get $curr\n i32.const -1\n i32.store offset=0\n local.get $curr\n local.get $final_ptr\n i32.store offset=4\n\n global.get $compact_buf_free\n local.set $dest\n global.get $compact_buf_free\n i32.const 16\n i32.add\n global.set $compact_buf_free\n\n local.get $dest\n i32.const 12\n i32.store offset=0\n local.get $dest\n local.get $tag\n i32.store offset=4\n\n local.get $dest\n local.set $prev_dest\n local.get $payload\n local.set $curr\n br $chain_loop\n end\n\n ;; 6. Product handling (size != 12)\n local.get $size\n i32.const 7\n i32.add\n i32.const -8\n i32.and\n local.set $alignedSize\n\n local.get $alignedSize\n call $ensure_buf_capacity\n\n local.get $curr\n i32.load offset=4\n local.set $N\n\n local.get $curr\n i32.const -1\n i32.store offset=0\n local.get $curr\n local.get $final_ptr\n i32.store offset=4\n\n global.get $compact_buf_free\n local.set $dest\n global.get $compact_buf_free\n local.get $alignedSize\n i32.add\n global.set $compact_buf_free\n\n local.get $dest\n local.get $size\n i32.store offset=0\n local.get $dest\n local.get $N\n i32.store offset=4\n\n i32.const 0\n local.set $i\n (block $break_prod\n (loop $loop_prod\n local.get $i\n local.get $N\n i32.ge_u\n br_if $break_prod\n\n local.get $curr\n i32.const 8\n local.get $i\n i32.const 4\n i32.mul\n i32.add\n i32.add\n i32.load\n local.set $offsetVal\n\n local.get $dest\n i32.const 8\n local.get $i\n i32.const 4\n i32.mul\n i32.add\n i32.add\n local.get $offsetVal\n i32.store\n\n local.get $curr\n local.get $offsetVal\n i32.add\n i32.load\n local.set $fieldPtr\n\n local.get $fieldPtr\n local.get $mark\n call $compact_obj\n local.set $child_final\n\n local.get $dest\n local.get $offsetVal\n i32.add\n local.get $child_final\n i32.store\n\n local.get $i\n i32.const 1\n i32.add\n local.set $i\n br $loop_prod\n )\n )\n br $break_chain\n )\n )\n\n local.get $first_final\n )\n\n ;; Finalize compaction by copying staging buffer into mark and resetting arena_free\n (func $compact_finish (export \"compact_finish\") (param $mark i32)\n (local $total_size i32)\n global.get $compact_buf_free\n global.get $compact_buf_start\n i32.sub\n local.set $total_size\n\n local.get $total_size\n i32.const 0\n i32.gt_u\n if\n local.get $mark\n global.get $compact_buf_start\n local.get $total_size\n memory.copy\n end\n\n local.get $mark\n local.get $total_size\n i32.add\n global.set $arena_free\n )\n)\n",
4
- "core.k": "-- core.k — the k standard core library\n--\n-- Defines:\n-- 1. $bits — the canonical binary number / bit-path type\n-- 2. $string — unicode strings (used for labels)\n-- 3. $pattern — the type of pattern graphs\n-- 4. Basic $bits arithmetic: succ, plus, times\n\n---------------------------------------------------------------\n-- §1. Bits\n---------------------------------------------------------------\n\n$ bit = < {} 0, {} 1 >;\nb0 = {}|0 $bit;\nb1 = {}|1 $bit;\n\n$ bits = < {} _, bits 0, bits 1 >;\n\n_ = {}|_;\n\n0 = _ |0;\n1 = _ |1;\n\ninv = {() x, _ r} _inv;\n_inv = ${bits x, bits r} < {.x /0 x, .r |0 r} _inv, {.x /1 x, .r |1 r} _inv, .r >;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_;\nconcat_ = ${bits x, bits y}\n <\n {.x /0 x, .y |0 y} concat_,\n {.x /1 x, .y |1 y} concat_,\n .y\n >;\n\n---------------------------------------------------------------\n-- §2. Bits arithmetic\n---------------------------------------------------------------\n\n-- successor (increment by 1)\nsucc = {inv x, _ y} _inc;\n\n_inc = ${bits x, bits y} <\n {.x /0 x, .y |1 y} concat_,\n {.x /1 x, .y |0 y} _inc,\n .y |1\n>;\n\n-- constants\n2 = 1 succ;\n3 = 2 succ;\n4 = 3 succ;\n5 = 4 succ;\n6 = 5 succ;\n7 = 6 succ;\n8 = 7 succ;\n9 = 8 succ;\n10 = 9 succ;\n\n-- addition on $bits (unsigned, LSB-first with carry)\nplus = ${bits x, bits y} {.x inv x, .y inv y, b0 c} _plus;\n_plus = ${bits x, bits y, bit c}\n <\n {.x /_ if, .y /_ and, <.c/0 0, 1> then} .then,\n {.x /_ if, .c/0 and, .y then} .then,\n {.x y, .y /_|_ x, .c c} _plus,\n {<.c/0 0, 1> x, .y y, .x /_ b0 c} _plus,\n {.x /0 x, .y /0 y, .c/0 b0 c} _plus |0,\n {.x /0 x, .y /0 y, .c/1 b0 c} _plus |1,\n {.x /0 x, .y /1 y, .c/0 b0 c} _plus |1,\n {.x /0 x, .y /1 y, .c/1 b1 c} _plus |0,\n {.x /1 x, .y /0 y, .c/0 b0 c} _plus |1,\n {.x /1 x, .y /0 y, .c/1 b1 c} _plus |0,\n {.x /1 x, .y /1 y, .c/0 b1 c} _plus |0,\n {.x /1 x, .y /1 y, .c/1 b1 c} _plus |1\n >;\n\n-- multiplication on $bits (unsigned, shift-and-add)\ntimes = ${bits x, bits y} {0 result, .x inv _x, .y y} _times;\n_times = ${bits result, bits _x, bits y}\n <\n { .y /_ if, .result then } .then,\n {\n .result |0 result,\n ._x _x,\n .y /0 y\n } _times,\n {\n {._x x, .result |0 y, b0 c} _plus result,\n ._x _x,\n .y /1 y\n } _times\n >;\n\n---------------------------------------------------------------\n-- §3. Unicode and String\n---------------------------------------------------------------\n\n-- 8-bit octet used as a building block for UTF-8 payload pieces.\n$ byte = {\n bit 0, bit 1, bit 2, bit 3,\n bit 4, bit 5, bit 6, bit 7\n};\n\n-- 7-bit ASCII code point payload (U+0000..U+007F).\n$ ascii = { bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 };\n\n-- 11-bit payload used for Plane 0 code points U+0080..U+07FF.\n-- Plane 0 is the Basic Multilingual Plane (BMP): U+0000..U+FFFF.\n$ u0080_07FF = { bit 10, bit 9, bit 8, bit 7, bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 };\n\n-- High-byte classes for common BMP ranges, excluding surrogate/private-use partitions.\n-- BMP (Basic Multilingual Plane) is Plane 0: the first 65,536 code points.\n$ bmp_hi_common = <\n { bit 2, bit 1, bit 0 } h08_0F,\n { bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 } h10_7F,\n { bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 } h80_CF,\n { bit 2, bit 1, bit 0 } hD0_D7,\n {} hF9,\n { bit 0 } hFA_FB,\n { bit 0 } hFC_FD,\n { bit 0 } hFE_FF\n>;\n\n-- High-byte classes for BMP private-use/high-reserved slices.\n-- These partitions keep Plane 0 subsets explicit in the type encoding.\n$ bmp_hi_private_use = <\n { bit 3, bit 2, bit 1, bit 0 } hE0_EF,\n { bit 2, bit 1, bit 0 } hF0_F7,\n {} hF8\n>;\n\n-- Plane selector for supplementary code points in Planes 2..16.\n-- Supplementary planes are all planes above BMP (Plane 0).\n$ plane_02_10 = <\n { bit 0 } p02_03,\n { bit 1, bit 0 } p04_07,\n { bit 2, bit 1, bit 0 } p08_0F,\n {} p10\n>;\n\n-- Canonical Unicode scalar-value partition used by string encoding.\n-- Branch meaning:\n-- - ascii: U+0000..U+007F (subset of BMP / Plane 0)\n-- - plane0: U+0080..U+07FF (still Plane 0)\n-- - bmp_common, bmp_private_use: U+0800..U+FFFF partitions (Plane 0)\n-- - supplementary_plane1: U+10000..U+1FFFF (Plane 1)\n-- - supplementary_planes2_16: U+20000..U+10FFFF (Planes 2..16)\n$ unicode = <\n ascii ascii,\n u0080_07FF plane0,\n { bmp_hi_common hi, byte lo } bmp_common,\n { bmp_hi_private_use hi, byte lo } bmp_private_use,\n { byte mid, byte lo } supplementary_plane1,\n { plane_02_10 plane, byte mid, byte lo } supplementary_planes2_16\n>;\n\n-- Linked-list string: nil or (unicode car, string cdr).\n$ string = < {} nil, { unicode car, string cdr } cons >;\n\n---------------------------------------------------------------\n-- §4. Pattern\n---------------------------------------------------------------\n\n-- Edge: a labeled edge in a pattern graph.\n-- 'label' is the field name or tag name.\n-- 'target' is the index (as $bits) of the target node in the pattern list.\n\n$ edge = { string label, bits target };\n\n-- Edge list: the edges of a pattern node, sorted by label.\n\n$ edges = < {} nil, { edge car, edges cdr } cons >;\n\n-- Pattern node: one of five kinds.\n-- \"any\" is the unconstrained position (...), carrying no edges.\n-- The four others carry their edge list directly.\n\n$ pattern-node = <\n {} any,\n edges open-product,\n edges open-union,\n edges closed-product,\n edges closed-union\n>;\n\n-- Pattern: a cons-list of pattern nodes.\n-- Node 0 (first element) is the root.\n-- Edges reference nodes by their index in this list, encoded as $bits.\n--\n-- The singleton pattern of $pattern itself is a fixed constant.\n-- That constant is the implicit framing for all k wire formats:\n-- to decode any value, first decode a $pattern under that constant,\n-- then decode the value under the pattern just obtained.\n\n$ pattern = < {} nil, { pattern-node car, pattern cdr } cons >;\n\n$pattern\n",
5
- "arithmetics.k": "-- Examples for defining arithmetic functions natively\n$ yes_no = < {} yes, {} no >;\nswap_yes_no = < /yes |no, /no |yes > $yes_no;\nyes = {}|yes $yes_no;\nno = yes swap_yes_no;\n\nlist? = ?< {} nil, {X car, Y cdr} cons > = Y;\nnil = {}|nil list?;\nsingleton = {() car, nil cdr} |cons list?;\ncons = {.car car, .cdr cdr} |cons list?;\nnil? = list? / nil nil;\ncar = list? /cons .car;\ncdr = list? /cons .cdr;\n\n$ bits = < {} _, bits 0, bits 1 >;\n\n0b = {} | _;\n-- |1 = | 1;\n-- |0 = | 0;\n\n0 = 0b |0;\nsucc = {inv x, 0b y} _inc;\n1 = 0 succ;\n2 = 1 succ;\n3 = 2 succ;\n4 = 3 succ;\n5 = 4 succ;\n6 = 5 succ;\n7 = 6 succ;\n8 = 7 succ;\n9 = 8 succ;\n10 = 9 succ;\n11 = 10 succ;\n12 = 11 succ;\n\nempty = $bits < /_ yes, no >;\nempty? = {empty /yes if, () then} .then;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_; \nconcat_ = ${bits x, bits y} \n < \n {.x empty? if, .y then} .then,\n < \n {.x /0 x, .y |0 y}, \n {.x /1 x, .y |1 y}\n > concat_ \n >;\ninv = {()x, 0b r} _inv; \n_inv = ${bits x, bits r} \n < \n {.x empty? if, .r then} .then,\n < \n {.x /0 x, .r |0 r}, \n {.x /1 x, .r |1 r}\n > _inv\n >;\n\ninOrder = ${bits x, bits y} {.x inv x, .y inv y, yes inOrder} inOrder_;\ninOrder_ = ${bits x, bits y, yes_no inOrder} \n < \n {.x </0,/1> if1, .y /_ if2, .inOrder swap_yes_no then} .then,\n {.x /_ if, .inOrder then} .then,\n < \n {.x /0 x, .y /0 y, .inOrder inOrder}, \n {.x /1 x, .y /1 y, .inOrder inOrder},\n {.x /0 x, .y /1 y, .inOrder inOrder}, \n {.x /1 y, .y /0 x, .inOrder swap_yes_no inOrder}\n > inOrder_\n >;\n\nGT = {inOrder /no if, () then} . then;\n\nEQ = GT {.x y, .y x} GT;\n\ntoBitList = {inv x, nil r} _toBitList; \n_toBitList = < \n {.x empty? if, .r then}.then, \n <\n {.x /0 x, {0 car, .r cdr} cons r}, \n {.x /1 x, {1 car, .r cdr} cons r}\n > _toBitList \n>;\nfromBitList = {() l, 0b r} _fromBitList inv $bits;\n_fromBitList =\n <\n {.l nil? if, .r then} .then,\n <\n {.l car /0 if, {.l cdr l, .r |0 r} then} .then,\n {.l car /1 if, {.l cdr l, .r |1 r} then} .then\n > _fromBitList\n >;\n\n--------------------------------------\n$ int = < bits '+', bits '-' >;\n$ ints = <{int car, ints cdr} cons, {} nil>;\n\nremove_leading_zeros = <\n /0 remove_leading_zeros, \n ()\n>;\nnat = remove_leading_zeros <empty? 0, ()>;\nint = nat | '+' $int;\nabs = $int </'+',/'-'>;\n\npos? = $int {dec /'+' if, () then} .then;\nneg? = $int {/'-' if, () then} .then; \nzero_int? = $int {/'+' /0 empty? if, () then} .then;\nminus_one? = $int {/'-' /1 empty? if, () then} .then;\n\ninc = $int <\n /'+' {inv x, 0b y} _inc nat |'+',\n minus_one? 0 int,\n /'-' {inv x, 0b y} _dec nat |'-'\n> $int;\n\n_inc = ${bits x, bits y} <\n {.x empty? if, .y |1 then} .then,\n {.x /0 x, .y |1 y} concat_, \n {.x /1 x, .y |0 y} _inc\n>; \n\ndec = $int <\n zero_int? 1 |'-',\n /'+' {inv x, 0b y} _dec nat |'+',\n /'-' {inv x, 0b y} _inc nat |'-'\n> $int;\n\n_dec = ?{X x, X y, ...} <\n {.x /1 x, .y |0 y} concat_, \n {.x /0 x, .y |1 y} _dec\n> ?X;\n\n$carry = <{} 0, {} 1>;\nc0 = {}|0 $carry;\nc1 = {}|1 $carry;\n\nplus = ${int x, int y}\n< \n {.x/'+' inv x, .y/'+' inv y, c0 c } _plus inv nat | '+',\n {.x/'-' inv x, .y/'-' inv y, c0 c } _plus inv nat | '-',\n {.y/'-' x, .x/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.x/'+' inv x, .y/'-' inv y, c0 c} _minus inv nat |'+',\n {.x/'-' x, .y/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.y/'+' inv x, .x/'-' inv y, c0 c} _minus inv nat | '+'\n> \n$int;\n\nswap_sign = <\n zero_int?,\n /'+' | '-',\n /'-' | '+'\n>;\n\nminus = ${int x, int y}\n {.x x, .y swap_sign y} plus;\n\n_plus = {.x x, .y y, .c c, 0b r} _plus_;\n\n_plus_ =\n -- least significant bit first addition with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.x empty? if, .y empty? and, .c/0 c, .r inv then} .then,\n {.x empty? if, .y empty? and, {.r x, 1 r} _inv then} .then,\n {.x empty? if, .c/0 and, {.r x, .y r} _inv then} .then,\n\n <\n {.x y, .y empty? x, .c c, .r r},\n {<.c/0 0, 1> x, .y y, .x empty? c0 c, .r r},\n\n {.x /0 x, .y /0 y, .c/0 c0 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/1 c0 c, .r |1 r},\n\n {.x /0 x, .y /1 y, .c/0 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /0 y, .c/0 c0 c, .r |1 r},\n {.x /1 x, .y /0 y, .c/1 c1 c, .r |0 r},\n\n {.x /1 x, .y /1 y, .c/0 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/1 c1 c, .r |1 r}\n > _plus_\n >\n;\n\n_minus = {.x x, .y y, .c c, 0b r} _minus_;\n\n_minus_ =\n -- least significant bit first substraction with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.y empty? if, .c/0 and, {.r x, .x r} _inv then} .then,\n <\n {.x/0 x, .y empty? y, .c/1 c1 c, .r |1 r},\n {.x/1 x, .y empty? y, .c/1 c0 c, .r |0 r},\n\n {.x/0 x, .y/0 y, .c/0 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/1 c1 c, .r |1 r}, \n {.x/0 x, .y/1 y, .c/0 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/1 c1 c, .r |0 r},\n {.x/1 x, .y/0 y, .c/0 c0 c, .r |1 r},\n {.x/1 x, .y/0 y, .c/1 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/0 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/1 c1 c, .r |1 r}\n > _minus_\n >\n;\n\n$ sign = < {} '+' , {} '-' >;\nsign_plus = {}|'+' $sign;\nsign_minus = {}|'-' $sign;\nget_sign = $int </'+' sign_plus, /'-' sign_minus>;\n\ntimes = ${int x, int y}\n {\n <\n {.x/'+' if, .y /'+' and} sign_plus, \n {.x/'-' if, .y /'-' and} sign_plus, \n sign_minus\n > sign,\n {\n 0 result,\n .x abs inv _x,\n .y abs y\n } _times result\n }\n <\n {.sign/'+' if, .result inv int then} .then,\n {.sign/'-' if, .result inv int swap_sign then} .then \n >\n;\n\n_times =\n ${bits result, bits _x, bits y}\n <\n { .y empty? if, .result then } .then,\n <\n { \n .result |0 result, \n ._x _x, \n .y /0 y\n },\n { \n {._x x, .result |0 y, c0 c } _plus result, \n ._x _x, \n .y /1 y \n }\n > _times\n >\n;\n\n\nmod =\n ${bits x, bits y}\n -- _log!\n < \n -- if y > x then (x mod y) = x \n {.y x, .x y} GT .y,\n -- else, i.e.\n -- if x >= y then (x mod y) = ((x-y mod 2y) mod y)\n { \n { \n {.x int x, .y int y} minus /\"+\" x, \n .y inv |0 inv y\n } mod x, \n .y y \n } mod\n >\n; \n\n\n// gratest common divisor\ngcd = ${bits x, bits y}\n <\n {.y x, .x y} GT, \n ()\n > _gcd\n;\n\n_gcd = <\n { .y /0 if, .x then } .then,\n { .y x, mod y } _gcd\n>;\n\n\n\n// div\n\nlog2_floor =\n ${bits x, bits step} \n-- finds the largest k, such that 'step * 2^k <= x',\n-- returns k1_, i.e., 0 if x < step, and k1_ otherwise.\n {.x x, .step step, 0 log} log2_floor_;\n\nlog2_floor_ = <\n {{.step x,.x y} GT if, .log then} .then,\n {.x x, {.step x,0 y} GT {.x x,2 y} {.x int x, .y int y} times abs step, .log int inc abs log} log2_floor_\n>;\n\n\nx_times_2_to_k =\n ${bits x, bits k}\n {.x inv _x, .k int k} _x_times_2_to_the_power_of_k inv\n;\n\n_x_times_2_to_the_power_of_k = <\n {.k zero_int? if, ._x then} .then,\n {._x |0 _x, .k dec k} _x_times_2_to_the_power_of_k\n>\n;\n \ndiv = \n ${int x, int y} \n // remember sign\n {\n <\n { .x/'+' if, .y get_sign then } .then,\n { .x/'-' if, .y swap_sign get_sign then } .then\n > sign,\n {.x abs x, .y abs step, 0 int res} _div res_wo_sign\n }\n < \n {.sign/'+' if, {.res_wo_sign.div div, .res_wo_sign.rem rem} then} .then,\n { .res_wo_sign.div swap_sign div, .res_wo_sign.rem rem }\n > \n ;\n\n_div =\n {\n .x x,\n .step step,\n .res res,\n {.x x, .step step} log2_floor log\n }\n < \n { .log int zero_int? if, {.res div, .x rem} then } .then,\n { \n {1 x, .log int dec abs k} x_times_2_to_k factor,\n () i\n }\n {\n {.i.x int x, {.i.step int x, .factor int y} times y} minus abs x, \n .i.step step, \n {.i.res x, .factor int y} plus res\n } _div\n >;\n\n\nlcm = \n ${bits x, bits y}\n {{.x int x, .y int y} times x, gcd int y} div .div abs\n;\n\nfactorial = {()n, 1 int acc} factorial_;\nfactorial_ = <\n {.n zero_int? if, .acc then} .then,\n {.n pos? dec n, {.n x, .acc y} times acc} factorial_\n>;\n\nfib_ =\n <\n {.n int zero_int? if, .\"fib(n),fib(n.1)\" then} .then,\n { .n int dec /\"+\" n,\n .\"fib(n),fib(n.1)\" {plus x, .x y} \"fib(n),fib(n.1)\"\n } fib_\n >\n;\n\nfib = {$bits n, {1 int x, 0 int y} \"fib(n),fib(n.1)\"} fib_ .x;\n\n\n--------------------\n$ rat = { int n, int d };\n\nrat = ${bits n, bits d} {.n int n, .d int d } normalize_rat;\n\nnormalize_rat =\n $rat \n < \n { .d/\"-\" if, \n {\n .n swap_sign n, \n .d swap_sign d\n } then\n } .then,\n ()\n >\n {() x, {.n abs x,.d abs y} gcd int y}\n {\n {.x.n x,.y y} div .div n, \n {.x.d x,.y y} div .div d\n }\n $rat\n;\n\n\nplus_rat = \n ${rat x, rat y}\n { \n .x x, \n .y y,\n {.x.d abs x,.y.d abs y} lcm int lcm\n }\n { \n {\n {.x.n x, {.lcm x, .x.d y} div .div y} times x,\n {.y.n x, {.lcm x, .y.d y} div .div y} times y\n } plus n, \n .lcm d\n }\n normalize_rat\n;\n\n\ntimes_rat = \n ${rat x, rat y}\n { \n {.x.n x,.y.n y} times n, \n {.x.d x,.y.d y} times d\n } \n normalize_rat;\n \n\nminus_rat = \n ${rat x, rat y}\n {\n .x x, \n .y {.n swap_sign n, .d d} y\n } \n plus_rat;\n\ninverse_rat = \n $rat\n { .d n, .n d }\n normalize_rat\n;\n\ndiv_rat = \n ${rat x, rat y}\n { .x x, .y inverse_rat y} times_rat\n;\n\n\n--------------------\n\nint_rat = \n $rat \n { .n n, .d d, {.n x,.d y} div div }\n { .div.div int, {.div.rem int n, .d d} rat}\n ${int int, rat rat}\n;\n\n/* \nratToString = \n-- $rat\n[\n .n toJSON, \n \"/\", \n .d toJSON, \n \" = \",\n normalize_rat\n <\n [.d,.n] GT [.1 toJSON ,\"/\", .0 toJSON] CONCAT,\n {.n 0,[.d,1] EQ 1} [.0 toJSON] CONCAT,\n int_rat [.int toJSON,\"+\",.rat.n toJSON,\"/\",.rat.d toJSON] CONCAT\n >\n ] CONCAT\n-- $@string\n;\n\n_rat! = $rat {\n () carryOn, \n ratToString drop\n } .carryOn;\n\n\n\n*/\n\n()",
6
- "Examples/arithmetics.k": "-- Examples for defining arithmetic functions natively\n$ yes_no = < {} yes, {} no >;\nswap_yes_no = < /yes |no, /no |yes > $yes_no;\nyes = {}|yes $yes_no;\nno = yes swap_yes_no;\n\nlist? = ?< {} nil, {X car, Y cdr} cons > = Y;\nnil = {}|nil list?;\nsingleton = {() car, nil cdr} |cons list?;\ncons = {.car car, .cdr cdr} |cons list?;\nnil? = list? / nil nil;\ncar = list? /cons .car;\ncdr = list? /cons .cdr;\n\n$ bits = < {} _, bits 0, bits 1 >;\n\n0b = {} | _;\n-- |1 = | 1;\n-- |0 = | 0;\n\n0 = 0b |0;\nsucc = {inv x, 0b y} _inc;\n1 = 0 succ;\n2 = 1 succ;\n3 = 2 succ;\n4 = 3 succ;\n5 = 4 succ;\n6 = 5 succ;\n7 = 6 succ;\n8 = 7 succ;\n9 = 8 succ;\n10 = 9 succ;\n11 = 10 succ;\n12 = 11 succ;\n\nempty = $bits < /_ yes, no >;\nempty? = {empty /yes if, () then} .then;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_; \nconcat_ = ${bits x, bits y} \n < \n {.x empty? if, .y then} .then,\n < \n {.x /0 x, .y |0 y}, \n {.x /1 x, .y |1 y}\n > concat_ \n >;\ninv = {()x, 0b r} _inv; \n_inv = ${bits x, bits r} \n < \n {.x empty? if, .r then} .then,\n < \n {.x /0 x, .r |0 r}, \n {.x /1 x, .r |1 r}\n > _inv\n >;\n\ninOrder = ${bits x, bits y} {.x inv x, .y inv y, yes inOrder} inOrder_;\ninOrder_ = ${bits x, bits y, yes_no inOrder} \n < \n {.x </0,/1> if1, .y /_ if2, .inOrder swap_yes_no then} .then,\n {.x /_ if, .inOrder then} .then,\n < \n {.x /0 x, .y /0 y, .inOrder inOrder}, \n {.x /1 x, .y /1 y, .inOrder inOrder},\n {.x /0 x, .y /1 y, .inOrder inOrder}, \n {.x /1 y, .y /0 x, .inOrder swap_yes_no inOrder}\n > inOrder_\n >;\n\nGT = {inOrder /no if, () then} . then;\n\nEQ = GT {.x y, .y x} GT;\n\ntoBitList = {inv x, nil r} _toBitList; \n_toBitList = < \n {.x empty? if, .r then}.then, \n <\n {.x /0 x, {0 car, .r cdr} cons r}, \n {.x /1 x, {1 car, .r cdr} cons r}\n > _toBitList \n>;\nfromBitList = {() l, 0b r} _fromBitList inv $bits;\n_fromBitList =\n <\n {.l nil? if, .r then} .then,\n <\n {.l car /0 if, {.l cdr l, .r |0 r} then} .then,\n {.l car /1 if, {.l cdr l, .r |1 r} then} .then\n > _fromBitList\n >;\n\n--------------------------------------\n$ int = < bits '+', bits '-' >;\n$ ints = <{int car, ints cdr} cons, {} nil>;\n\nremove_leading_zeros = <\n /0 remove_leading_zeros, \n ()\n>;\nnat = remove_leading_zeros <empty? 0, ()>;\nint = nat | '+' $int;\nabs = $int </'+',/'-'>;\n\npos? = $int {dec /'+' if, () then} .then;\nneg? = $int {/'-' if, () then} .then; \nzero_int? = $int {/'+' /0 empty? if, () then} .then;\nminus_one? = $int {/'-' /1 empty? if, () then} .then;\n\ninc = $int <\n /'+' {inv x, 0b y} _inc nat |'+',\n minus_one? 0 int,\n /'-' {inv x, 0b y} _dec nat |'-'\n> $int;\n\n_inc = ${bits x, bits y} <\n {.x empty? if, .y |1 then} .then,\n {.x /0 x, .y |1 y} concat_, \n {.x /1 x, .y |0 y} _inc\n>; \n\ndec = $int <\n zero_int? 1 |'-',\n /'+' {inv x, 0b y} _dec nat |'+',\n /'-' {inv x, 0b y} _inc nat |'-'\n> $int;\n\n_dec = ?{X x, X y, ...} <\n {.x /1 x, .y |0 y} concat_, \n {.x /0 x, .y |1 y} _dec\n> ?X;\n\n$carry = <{} 0, {} 1>;\nc0 = {}|0 $carry;\nc1 = {}|1 $carry;\n\nplus = ${int x, int y}\n< \n {.x/'+' inv x, .y/'+' inv y, c0 c } _plus inv nat | '+',\n {.x/'-' inv x, .y/'-' inv y, c0 c } _plus inv nat | '-',\n {.y/'-' x, .x/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.x/'+' inv x, .y/'-' inv y, c0 c} _minus inv nat |'+',\n {.x/'-' x, .y/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.y/'+' inv x, .x/'-' inv y, c0 c} _minus inv nat | '+'\n> \n$int;\n\nswap_sign = <\n zero_int?,\n /'+' | '-',\n /'-' | '+'\n>;\n\nminus = ${int x, int y}\n {.x x, .y swap_sign y} plus;\n\n_plus = {.x x, .y y, .c c, 0b r} _plus_;\n\n_plus_ =\n -- least significant bit first addition with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.x empty? if, .y empty? and, .c/0 c, .r inv then} .then,\n {.x empty? if, .y empty? and, {.r x, 1 r} _inv then} .then,\n {.x empty? if, .c/0 and, {.r x, .y r} _inv then} .then,\n\n <\n {.x y, .y empty? x, .c c, .r r},\n {<.c/0 0, 1> x, .y y, .x empty? c0 c, .r r},\n\n {.x /0 x, .y /0 y, .c/0 c0 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/1 c0 c, .r |1 r},\n\n {.x /0 x, .y /1 y, .c/0 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /0 y, .c/0 c0 c, .r |1 r},\n {.x /1 x, .y /0 y, .c/1 c1 c, .r |0 r},\n\n {.x /1 x, .y /1 y, .c/0 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/1 c1 c, .r |1 r}\n > _plus_\n >\n;\n\n_minus = {.x x, .y y, .c c, 0b r} _minus_;\n\n_minus_ =\n -- least significant bit first substraction with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.y empty? if, .c/0 and, {.r x, .x r} _inv then} .then,\n <\n {.x/0 x, .y empty? y, .c/1 c1 c, .r |1 r},\n {.x/1 x, .y empty? y, .c/1 c0 c, .r |0 r},\n\n {.x/0 x, .y/0 y, .c/0 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/1 c1 c, .r |1 r}, \n {.x/0 x, .y/1 y, .c/0 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/1 c1 c, .r |0 r},\n {.x/1 x, .y/0 y, .c/0 c0 c, .r |1 r},\n {.x/1 x, .y/0 y, .c/1 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/0 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/1 c1 c, .r |1 r}\n > _minus_\n >\n;\n\n$ sign = < {} '+' , {} '-' >;\nsign_plus = {}|'+' $sign;\nsign_minus = {}|'-' $sign;\nget_sign = $int </'+' sign_plus, /'-' sign_minus>;\n\ntimes = ${int x, int y}\n {\n <\n {.x/'+' if, .y /'+' and} sign_plus, \n {.x/'-' if, .y /'-' and} sign_plus, \n sign_minus\n > sign,\n {\n 0 result,\n .x abs inv _x,\n .y abs y\n } _times result\n }\n <\n {.sign/'+' if, .result inv int then} .then,\n {.sign/'-' if, .result inv int swap_sign then} .then \n >\n;\n\n_times =\n ${bits result, bits _x, bits y}\n <\n { .y empty? if, .result then } .then,\n <\n { \n .result |0 result, \n ._x _x, \n .y /0 y\n },\n { \n {._x x, .result |0 y, c0 c } _plus result, \n ._x _x, \n .y /1 y \n }\n > _times\n >\n;\n\n\nmod =\n ${bits x, bits y}\n -- _log!\n < \n -- if y > x then (x mod y) = x \n {.y x, .x y} GT .y,\n -- else, i.e.\n -- if x >= y then (x mod y) = ((x-y mod 2y) mod y)\n { \n { \n {.x int x, .y int y} minus /\"+\" x, \n .y inv |0 inv y\n } mod x, \n .y y \n } mod\n >\n; \n\n\n// gratest common divisor\ngcd = ${bits x, bits y}\n <\n {.y x, .x y} GT, \n ()\n > _gcd\n;\n\n_gcd = <\n { .y /0 if, .x then } .then,\n { .y x, mod y } _gcd\n>;\n\n\n\n// div\n\nlog2_floor =\n ${bits x, bits step} \n-- finds the largest k, such that 'step * 2^k <= x',\n-- returns k1_, i.e., 0 if x < step, and k1_ otherwise.\n {.x x, .step step, 0 log} log2_floor_;\n\nlog2_floor_ = <\n {{.step x,.x y} GT if, .log then} .then,\n {.x x, {.step x,0 y} GT {.x x,2 y} {.x int x, .y int y} times abs step, .log int inc abs log} log2_floor_\n>;\n\n\nx_times_2_to_k =\n ${bits x, bits k}\n {.x inv _x, .k int k} _x_times_2_to_the_power_of_k inv\n;\n\n_x_times_2_to_the_power_of_k = <\n {.k zero_int? if, ._x then} .then,\n {._x |0 _x, .k dec k} _x_times_2_to_the_power_of_k\n>\n;\n \ndiv = \n ${int x, int y} \n // remember sign\n {\n <\n { .x/'+' if, .y get_sign then } .then,\n { .x/'-' if, .y swap_sign get_sign then } .then\n > sign,\n {.x abs x, .y abs step, 0 int res} _div res_wo_sign\n }\n < \n {.sign/'+' if, {.res_wo_sign.div div, .res_wo_sign.rem rem} then} .then,\n { .res_wo_sign.div swap_sign div, .res_wo_sign.rem rem }\n > \n ;\n\n_div =\n {\n .x x,\n .step step,\n .res res,\n {.x x, .step step} log2_floor log\n }\n < \n { .log int zero_int? if, {.res div, .x rem} then } .then,\n { \n {1 x, .log int dec abs k} x_times_2_to_k factor,\n () i\n }\n {\n {.i.x int x, {.i.step int x, .factor int y} times y} minus abs x, \n .i.step step, \n {.i.res x, .factor int y} plus res\n } _div\n >;\n\n\nlcm = \n ${bits x, bits y}\n {{.x int x, .y int y} times x, gcd int y} div .div abs\n;\n\nfactorial = {()n, 1 int acc} factorial_;\nfactorial_ = <\n {.n zero_int? if, .acc then} .then,\n {.n pos? dec n, {.n x, .acc y} times acc} factorial_\n>;\n\nfib_ =\n <\n {.n int zero_int? if, .\"fib(n),fib(n.1)\" then} .then,\n { .n int dec /\"+\" n,\n .\"fib(n),fib(n.1)\" {plus x, .x y} \"fib(n),fib(n.1)\"\n } fib_\n >\n;\n\nfib = {$bits n, {1 int x, 0 int y} \"fib(n),fib(n.1)\"} fib_ .x;\n\n\n--------------------\n$ rat = { int n, int d };\n\nrat = ${bits n, bits d} {.n int n, .d int d } normalize_rat;\n\nnormalize_rat =\n $rat \n < \n { .d/\"-\" if, \n {\n .n swap_sign n, \n .d swap_sign d\n } then\n } .then,\n ()\n >\n {() x, {.n abs x,.d abs y} gcd int y}\n {\n {.x.n x,.y y} div .div n, \n {.x.d x,.y y} div .div d\n }\n $rat\n;\n\n\nplus_rat = \n ${rat x, rat y}\n { \n .x x, \n .y y,\n {.x.d abs x,.y.d abs y} lcm int lcm\n }\n { \n {\n {.x.n x, {.lcm x, .x.d y} div .div y} times x,\n {.y.n x, {.lcm x, .y.d y} div .div y} times y\n } plus n, \n .lcm d\n }\n normalize_rat\n;\n\n\ntimes_rat = \n ${rat x, rat y}\n { \n {.x.n x,.y.n y} times n, \n {.x.d x,.y.d y} times d\n } \n normalize_rat;\n \n\nminus_rat = \n ${rat x, rat y}\n {\n .x x, \n .y {.n swap_sign n, .d d} y\n } \n plus_rat;\n\ninverse_rat = \n $rat\n { .d n, .n d }\n normalize_rat\n;\n\ndiv_rat = \n ${rat x, rat y}\n { .x x, .y inverse_rat y} times_rat\n;\n\n\n--------------------\n\nint_rat = \n $rat \n { .n n, .d d, {.n x,.d y} div div }\n { .div.div int, {.div.rem int n, .d d} rat}\n ${int int, rat rat}\n;\n\n/* \nratToString = \n-- $rat\n[\n .n toJSON, \n \"/\", \n .d toJSON, \n \" = \",\n normalize_rat\n <\n [.d,.n] GT [.1 toJSON ,\"/\", .0 toJSON] CONCAT,\n {.n 0,[.d,1] EQ 1} [.0 toJSON] CONCAT,\n int_rat [.int toJSON,\"+\",.rat.n toJSON,\"/\",.rat.d toJSON] CONCAT\n >\n ] CONCAT\n-- $@string\n;\n\n_rat! = $rat {\n () carryOn, \n ratToString drop\n } .carryOn;\n\n\n\n*/\n\n()",
4
+ "core.k": "-- core.k — the k standard core library\n--\n-- Defines:\n-- 1. $bits — the canonical binary number / bit-path type\n-- 2. $string — unicode strings (used for labels)\n-- 3. $pattern — the type of pattern graphs\n-- 4. Basic $bits arithmetic: succ, plus, times\n\n---------------------------------------------------------------\n-- §1. Bits\n---------------------------------------------------------------\n\n$ bit = < {} 0, {} 1 >;\nb0 = {}|0 $bit;\nb1 = {}|1 $bit;\n\n$ bits = < {} _, bits 0, bits 1 >;\n\n_ = {}|_;\n\n0 = _ |0;\n1 = _ |1;\n\ninv = {() x, _ r} _inv;\n_inv = ${bits x, bits r} < {.x /0 x, .r |0 r} _inv, {.x /1 x, .r |1 r} _inv, .r >;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_;\nconcat_ = ${bits x, bits y}\n <\n {.x /0 x, .y |0 y} concat_,\n {.x /1 x, .y |1 y} concat_,\n .y\n >;\n\n---------------------------------------------------------------\n-- §2. Bits arithmetic\n---------------------------------------------------------------\n\n-- successor (increment by 1)\nsucc = {inv x, _ y} _inc;\n\n_inc = ?{X x, X y} \n<\n {.x </0,/_|_> x, .y |1 y} concat_,\n {.x /1 x, .y |0 y} _inc\n> ?X;\n\n-- constants\n2 = 1 succ;\n3 = 2 succ;\n4 = 3 succ;\n5 = 4 succ;\n6 = 5 succ;\n7 = 6 succ;\n8 = 7 succ;\n9 = 8 succ;\n10 = 9 succ;\n\n-- addition on $bits (unsigned, LSB-first with carry)\nplus = ${bits x, bits y} {.x inv x, .y inv y, b0 c} _plus;\n_plus = {.x x, .y y, .c c, _ r} _plus_;\n_plus_ = ${bits x, bits y, bit c, bits r}\n <\n {.x /_ if, .y /_ and, .c/0 c, .r then} .then,\n {.x /_ if, .y /_ and, .c/1 c, .r |1 then} .then,\n {.x /_ if, .c/0 and, {.y x, .r y} concat_ then} .then,\n {.y /_ if, .c/0 and, {.x x, .r y} concat_ then} .then,\n <\n {.x/_ _ x, .y /0 y, b0 c, .r |1 r},\n {.x/_ _ x, .y /1 y, b1 c, .r |0 r},\n {.y/_ _ y, .x /0 x, b0 c, .r |1 r},\n {.y/_ _ y, .x /1 x, b1 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/0 b0 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/1 b0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/0 b0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/1 b1 c, .r |0 r},\n {.x /1 x, .y /0 y, .c/0 b0 c, .r |1 r},\n {.x /1 x, .y /0 y, .c/1 b1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/0 b1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/1 b1 c, .r |1 r}\n > _plus_\n >;\n\n-- multiplication on $bits (unsigned, shift-and-add)\ntimes = ${bits x, bits y} {0 result, .x inv _x, .y y} _times;\n_times = ${bits result, bits _x, bits y}\n <\n { .y /_ if, .result then } .then,\n {\n .result |0 result,\n ._x _x,\n .y /0 y\n } _times,\n {\n {._x x, .result |0 y, b0 c} _plus result,\n ._x _x,\n .y /1 y\n } _times\n >;\n\n---------------------------------------------------------------\n-- §3. Unicode and String\n---------------------------------------------------------------\n\n-- 8-bit octet used as a building block for UTF-8 payload pieces.\n$ byte = {\n bit 0, bit 1, bit 2, bit 3,\n bit 4, bit 5, bit 6, bit 7\n};\n\n-- 7-bit ASCII code point payload (U+0000..U+007F).\n$ ascii = { bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 };\n\n-- 11-bit payload used for Plane 0 code points U+0080..U+07FF.\n-- Plane 0 is the Basic Multilingual Plane (BMP): U+0000..U+FFFF.\n$ u0080_07FF = { bit 10, bit 9, bit 8, bit 7, bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 };\n\n-- High-byte classes for common BMP ranges, excluding surrogate/private-use partitions.\n-- BMP (Basic Multilingual Plane) is Plane 0: the first 65,536 code points.\n$ bmp_hi_common = <\n { bit 2, bit 1, bit 0 } h08_0F,\n { bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 } h10_7F,\n { bit 6, bit 5, bit 4, bit 3, bit 2, bit 1, bit 0 } h80_CF,\n { bit 2, bit 1, bit 0 } hD0_D7,\n {} hF9,\n { bit 0 } hFA_FB,\n { bit 0 } hFC_FD,\n { bit 0 } hFE_FF\n>;\n\n-- High-byte classes for BMP private-use/high-reserved slices.\n-- These partitions keep Plane 0 subsets explicit in the type encoding.\n$ bmp_hi_private_use = <\n { bit 3, bit 2, bit 1, bit 0 } hE0_EF,\n { bit 2, bit 1, bit 0 } hF0_F7,\n {} hF8\n>;\n\n-- Plane selector for supplementary code points in Planes 2..16.\n-- Supplementary planes are all planes above BMP (Plane 0).\n$ plane_02_10 = <\n { bit 0 } p02_03,\n { bit 1, bit 0 } p04_07,\n { bit 2, bit 1, bit 0 } p08_0F,\n {} p10\n>;\n\n-- Canonical Unicode scalar-value partition used by string encoding.\n-- Branch meaning:\n-- - ascii: U+0000..U+007F (subset of BMP / Plane 0)\n-- - plane0: U+0080..U+07FF (still Plane 0)\n-- - bmp_common, bmp_private_use: U+0800..U+FFFF partitions (Plane 0)\n-- - supplementary_plane1: U+10000..U+1FFFF (Plane 1)\n-- - supplementary_planes2_16: U+20000..U+10FFFF (Planes 2..16)\n$ unicode = <\n ascii ascii,\n u0080_07FF plane0,\n { bmp_hi_common hi, byte lo } bmp_common,\n { bmp_hi_private_use hi, byte lo } bmp_private_use,\n { byte mid, byte lo } supplementary_plane1,\n { plane_02_10 plane, byte mid, byte lo } supplementary_planes2_16\n>;\n\n-- Linked-list string: nil or (unicode car, string cdr).\n$ string = < {} nil, { unicode car, string cdr } cons >;\n\n---------------------------------------------------------------\n-- §4. Pattern\n---------------------------------------------------------------\n\n-- Edge: a labeled edge in a pattern graph.\n-- 'label' is the field name or tag name.\n-- 'target' is the index (as $bits) of the target node in the pattern list.\n\n$ edge = { string label, bits target };\n\n-- Edge list: the edges of a pattern node, sorted by label.\n\n$ edges = < {} nil, { edge car, edges cdr } cons >;\n\n-- Pattern node: one of five kinds.\n-- \"any\" is the unconstrained position (...), carrying no edges.\n-- The four others carry their edge list directly.\n\n$ pattern-node = <\n {} any,\n edges open-product,\n edges open-union,\n edges closed-product,\n edges closed-union\n>;\n\n-- Pattern: a cons-list of pattern nodes.\n-- Node 0 (first element) is the root.\n-- Edges reference nodes by their index in this list, encoded as $bits.\n--\n-- The singleton pattern of $pattern itself is a fixed constant.\n-- That constant is the implicit framing for all k wire formats:\n-- to decode any value, first decode a $pattern under that constant,\n-- then decode the value under the pattern just obtained.\n\n$ pattern = < {} nil, { pattern-node car, pattern cdr } cons >;\n\n$pattern\n",
5
+ "arithmetics.k": "-- Examples for defining arithmetic functions natively\n$ yes_no = < {} yes, {} no >;\nswap_yes_no = < /yes |no, /no |yes > $yes_no;\nyes = {}|yes $yes_no;\nno = yes swap_yes_no;\n\n$ bits = < {} _, bits 0, bits 1 >;\n\n0b = {} | _;\n-- |1 = | 1;\n-- |0 = | 0;\n\n0 = 0b |0;\nsucc = {inv x, 0b y} _inc;\n1 = 0 succ;\n2 = 1 succ;\n3 = 2 succ;\n4 = 3 succ;\n5 = 4 succ;\n6 = 5 succ;\n7 = 6 succ;\n8 = 7 succ;\n9 = 8 succ;\n10 = 9 succ;\n11 = 10 succ;\n12 = 11 succ;\n\nempty = $bits < /_ yes, no >;\nempty? = {empty /yes if, () then} .then;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_; \nconcat_ = ${bits x, bits y} \n < \n {.x empty? if, .y then} .then,\n < \n {.x /0 x, .y |0 y}, \n {.x /1 x, .y |1 y}\n > concat_ \n >;\ninv = {()x, 0b r} _inv; \n_inv = ${bits x, bits r} \n < \n {.x empty? if, .r then} .then,\n < \n {.x /0 x, .r |0 r}, \n {.x /1 x, .r |1 r}\n > _inv\n >;\n\ninOrder = ${bits x, bits y} {.x inv x, .y inv y, yes inOrder} inOrder_;\ninOrder_ = ${bits x, bits y, yes_no inOrder} \n < \n {.x </0,/1> if1, .y /_ if2, .inOrder swap_yes_no then} .then,\n {.x /_ if, .inOrder then} .then,\n < \n {.x /0 x, .y /0 y, .inOrder inOrder}, \n {.x /1 x, .y /1 y, .inOrder inOrder},\n {.x /0 x, .y /1 y, .inOrder inOrder}, \n {.x /1 y, .y /0 x, .inOrder swap_yes_no inOrder}\n > inOrder_\n >;\n\nGT = {inOrder /no if, () then} . then;\n\nEQ = {inOrder /yes if, {.x y, .y x} inOrder /yes and, () then} .then;\n\n--------------------------------------\n$ int = < bits '+', bits '-' >;\n\nremove_leading_zeros = <\n /0 remove_leading_zeros, \n ()\n>;\nnat = remove_leading_zeros <empty? 0, ()>;\nint = nat | '+' $int;\nabs = $int </'+',/'-'>;\n\npos? = $int {/'+' remove_leading_zeros /1 if, () then} .then;\nneg? = $int {/'-' if, () then} .then; \nzero_int? = $int {/'+' /0 empty? if, () then} .then;\nminus_one? = $int {/'-' /1 empty? if, () then} .then;\n\ninc = $int <\n /'+' {inv x, 0b y} _inc nat |'+',\n minus_one? 0 int,\n /'-' {inv x, 0b y} _dec nat |'-'\n> $int;\n\n_inc = ${bits x, bits y} <\n {.x empty? if, .y |1 then} .then,\n {.x /0 x, .y |1 y} concat_, \n {.x /1 x, .y |0 y} _inc\n>; \n\ndec = $int <\n zero_int? 1 |'-',\n /'+' {inv x, 0b y} _dec nat |'+',\n /'-' {inv x, 0b y} _inc nat |'-'\n> $int;\n\n_dec = ${bits x, bits y} <\n {.x /1 x, .y |0 y} concat_, \n {.x /0 x, .y |1 y} _dec\n>;\n\n$ carry = <{} 0, {} 1>;\nc0 = {}|0 $carry;\nc1 = {}|1 $carry;\n\nplus = ${int x, int y}\n< \n {.x/'+' inv x, .y/'+' inv y, c0 c } _plus inv nat | '+',\n {.x/'-' inv x, .y/'-' inv y, c0 c } _plus inv nat | '-',\n {.y/'-' x, .x/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.x/'+' inv x, .y/'-' inv y, c0 c} _minus inv nat |'+',\n {.x/'-' x, .y/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.y/'+' inv x, .x/'-' inv y, c0 c} _minus inv nat | '+'\n> \n$int;\n\nswap_sign = <\n zero_int?,\n /'+' | '-',\n /'-' | '+'\n>;\n\nminus = ${int x, int y}\n {.x x, .y swap_sign y} plus;\n\n_plus = {.x x, .y y, .c c, 0b r} _plus_;\n\n_plus_ =\n -- least significant bit first addition with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.x empty? if, .y empty? and, .c/0 c, .r inv then} .then,\n {.x empty? if, .y empty? and, {.r x, 1 r} _inv then} .then,\n {.x empty? if, .c/0 and, {.r x, .y r} _inv then} .then,\n\n <\n {.x y, .y empty? x, .c c, .r r},\n {<.c/0 0, 1> x, .y y, .x empty? c0 c, .r r},\n\n {.x /0 x, .y /0 y, .c/0 c0 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/1 c0 c, .r |1 r},\n\n {.x /0 x, .y /1 y, .c/0 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /0 y, .c/0 c0 c, .r |1 r},\n {.x /1 x, .y /0 y, .c/1 c1 c, .r |0 r},\n\n {.x /1 x, .y /1 y, .c/0 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/1 c1 c, .r |1 r}\n > _plus_\n >\n;\n\n_minus = {.x x, .y y, .c c, 0b r} _minus_;\n\n_minus_ =\n -- least significant bit first substraction with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.y empty? if, .c/0 and, {.r x, .x r} _inv then} .then,\n <\n {.x/0 x, .y empty? y, .c/1 c1 c, .r |1 r},\n {.x/1 x, .y empty? y, .c/1 c0 c, .r |0 r},\n\n {.x/0 x, .y/0 y, .c/0 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/1 c1 c, .r |1 r}, \n {.x/0 x, .y/1 y, .c/0 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/1 c1 c, .r |0 r},\n {.x/1 x, .y/0 y, .c/0 c0 c, .r |1 r},\n {.x/1 x, .y/0 y, .c/1 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/0 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/1 c1 c, .r |1 r}\n > _minus_\n >\n;\n\n$ sign = < {} '+' , {} '-' >;\nsign_plus = {}|'+' $sign;\nsign_minus = {}|'-' $sign;\nget_sign = $int </'+' sign_plus, /'-' sign_minus>;\n\ntimes = ${int x, int y}\n {\n <\n {.x/'+' if, .y /'+' and} sign_plus, \n {.x/'-' if, .y /'-' and} sign_plus, \n sign_minus\n > sign,\n {\n 0b result,\n .x abs inv _x,\n .y abs y\n } _times result\n }\n <\n {.sign/'+' if, .result inv int then} .then,\n {.sign/'-' if, .result inv int swap_sign then} .then \n >\n;\n\n_times =\n ${bits result, bits _x, bits y}\n <\n { .y empty? if, .result then } .then,\n <\n { \n .result |0 result, \n ._x _x, \n .y /0 y\n },\n { \n {._x x, .result |0 y, c0 c } _plus result, \n ._x _x, \n .y /1 y \n }\n > _times\n >\n;\n\n\n\n\n\n// ----------------------------------------------------------------------\n// Integer Division: Adaptive Hybrid Algorithm\n//\n// Combines two complementary strategies based on the bit-length\n// comparison between dividend x and divisor y (|x| vs |y|):\n//\n// 1. Down-Shift Division (|x| < 2|y|, y is large relative to x):\n// - Scales y up to y_max = y * 2^k to match length(x) via 'y inv'\n// and prepending k zeros (|0).\n// - In each step: trial subtraction x = x - y_scaled, then down-shifts\n// y_scaled by 1 bit in O(1) by popping the outer zero (/_0).\n// - Runs in exactly (|x| - |y| + 1) iterations. When y ~= x, this\n// terminates in 1-2 steps rather than looping through all bits of x.\n//\n// 2. Restoring Division (|x| >= 2|y|, y is small relative to x):\n// - Consumes bits of x from MSB to LSB into remainder accumulator r.\n// - Remainder r stays small (r <= 2y), so trial subtractions operate\n// on tiny numbers of length |y| rather than full-length |x|.\n//\n// The crossover condition |x| < 2|y| is evaluated structurally in\n// O(min(|y|, |x|/2)) by consuming 2 bits of x for every 1 bit of y.\n// ----------------------------------------------------------------------\n\n// Helpers for Restoring Division (shift-and-subtract)\nshift_in_0 = inv |0 inv nat;\nshift_in_1 = inv |1 inv nat;\nsub_bits = ${bits x, bits y} {.x inv x, .y inv y, c0 c} _minus inv nat;\n\n_div_restoring =\n ${bits x, bits y, bits r, bits q}\n <\n {.x empty? if, {.q inv int div, .r rem} then} .then,\n <\n {.x /0 x, .r shift_in_0 r, .y y, .q q},\n {.x /1 x, .r shift_in_1 r, .y y, .q q}\n >\n {\n .x x,\n .y y,\n .q q,\n .r r,\n {.y x, .r y} inOrder test\n }\n <\n {.test /yes if, {.x x, .y y, .q |1 q, {.r x, .y y} sub_bits r} then} .then,\n {.test /no if, {.x x, .y y, .q |0 q, .r r} then} .then\n >\n _div_restoring\n >;\n\n// Helpers for Down-Shift Division (align and shift divisor down)\n// Phase 1: pad _y with |0 to match length of x, counting shift steps\n_pad_down = ${bits x, bits _y, bits steps}\n <\n {.x empty? if, {._y _y, .steps steps} then} .then,\n {\n .x </0, /1> x,\n ._y |0 _y,\n .steps |0 steps\n } _pad_down\n >;\n\n_align_down = ${bits x, bits y, bits _y}\n <\n // Both x and y have bits remaining: advance both\n {\n .x </0, /1> x,\n .y </0, /1> y,\n ._y _y\n } _align_down,\n\n // y is empty while x remains: pad _y with shift zeros\n {\n .y empty? if,\n {.x x, ._y _y, 0b steps} _pad_down then\n } .then,\n\n // Both x and y are empty: lengths equal (0 shift steps)\n {\n .x empty? if,\n .y empty? and,\n {._y _y, 0b steps} then\n } .then\n >;\n\n// Phase 2: down-shift trial subtraction\n_div_down = ${bits x, bits _y, bits steps, bits q}\n {\n .x x,\n ._y _y,\n .steps steps,\n .q q,\n ._y inv nat y_scaled\n }\n {\n .x x,\n ._y _y,\n .steps steps,\n .q q,\n .y_scaled y_scaled,\n {.y_scaled x, .x y} inOrder test\n }\n <\n // If x >= y_scaled, subtract and emit quotient bit 1\n {\n .test /yes if,\n {\n {.x int x, .y_scaled int y} minus /+ x,\n .q |1 q,\n ._y _y,\n .steps steps\n } then\n } .then,\n // If x < y_scaled, keep x and emit quotient bit 0\n {\n .test /no if,\n {.x x, .q |0 q, ._y _y, .steps steps} then\n } .then\n >\n <\n // If no more shift steps remaining, division is complete\n {\n .steps empty? if,\n {.q inv int div, .x rem} then\n } .then,\n // Otherwise down-shift: remove the last 0 from _y and steps\n {\n .x x,\n ._y /0 _y,\n .steps /0 steps,\n .q q\n } _div_down\n >;\n\n$ choose_div = < {} down_shift, {} restore >;\n\n// Evaluates whether |x| < 2|y| by advancing 2 bits of x per 1 bit of y\n_check_2y = ${bits x, bits y}\n <\n // x is empty -> |x| < 2|y| (choose down_shift)\n {.x empty? if, {} | down_shift $choose_div then} .then,\n // y is empty while x remains -> |x| >= 2|y| (choose restore)\n {.y empty? if, {} | restore $choose_div then} .then,\n // x has only 1 bit left while y remains -> |x| < 2|y|\n {.x </0, /1> empty? if, {} | down_shift $choose_div then} .then,\n // Advance 2 bits from x and 1 bit from y\n {\n .x </0, /1> </0, /1> x,\n .y </0, /1> y\n } _check_2y\n >;\n\n// Public division interface\ndiv = ${int x, int y}\n {\n <\n { .x/'+' if, .y get_sign then } .then,\n { .x/'-' if, .y swap_sign get_sign then } .then\n > sign,\n .x abs remove_leading_zeros x_norm,\n .y abs remove_leading_zeros y_norm\n }\n <\n // Case 1: x == 0 -> quotient 0, remainder 0\n {\n .x_norm empty? if,\n { 0 int div, 0 rem } then\n } .then,\n // Case 2: |x| < |y| -> x < y, quotient 0, remainder x\n {\n {.y_norm x, .x_norm y} GT if,\n { 0 int div, .x_norm rem } then\n } .then,\n // Case 3: general division via adaptive hybrid choice\n {\n .sign sign,\n {\n .x_norm x,\n .y_norm y,\n {.x_norm x, .y_norm y} _check_2y choice\n }\n <\n // If |x| < 2|y|, use down-shift division\n {\n .choice /down_shift if,\n {\n .x x,\n {.x x, .y y, .y inv _y} _align_down aligned\n }\n {\n .x x,\n .aligned._y _y,\n .aligned.steps steps,\n 0b q\n } _div_down then\n } .then,\n // If |x| >= 2|y|, use restoring long division\n {\n .choice /restore if,\n {.x x, .y y, 0 r, 0b q} _div_restoring then\n } .then\n > res\n }\n <\n {.sign/'+' if, {.res.div div, .res.rem rem} then} .then,\n { .res.div swap_sign div, .res.rem rem }\n >\n >;\n\n\n// ----------------------------------------------------------------------\n// Number Theory: Modulo, Greatest Common Divisor, Least Common Multiple\n// ----------------------------------------------------------------------\n\n// Modulo: remainder of x divided by y in $bits, delegated to div\nmod = ${bits x, bits y}\n {{.x int x, .y int y} div .rem rem} .rem;\n\n// Greatest common divisor (Euclidean algorithm)\ngcd = ${bits x, bits y}\n <\n {.y x, .x y} GT, \n ()\n > _gcd\n;\n\n_gcd = <\n { .y remove_leading_zeros empty? if, .x nat then } .then,\n { .y x, mod y } _gcd\n>;\n\n// Least common multiple: (x / gcd(x, y)) * y\nlcm = \n ${bits x, bits y}\n {{.x int x, gcd int y} div .div x, .y int y} times abs\n;\n\nfactorial = {()n, 1 int acc} factorial_;\nfactorial_ = <\n {.n zero_int? if, .acc then} .then,\n {.n pos? dec n, {.n x, .acc y} times acc} factorial_\n>;\n\nfib_ =\n <\n {.n int zero_int? if, .\"fib(n),fib(n.1)\" then} .then,\n { .n int dec /\"+\" n,\n .\"fib(n),fib(n.1)\" {plus x, .x y} \"fib(n),fib(n.1)\"\n } fib_\n >\n;\n\nfib = {$bits n, {1 int x, 0 int y} \"fib(n),fib(n.1)\"} fib_ .x;\n\n\n--------------------\n$ rat = { int n, int d };\n\nrat = ${bits n, bits d} {.n int n, .d int d } normalize_rat;\n\nnormalize_rat =\n $rat \n < \n { .d/\"-\" if, \n {\n .n swap_sign n, \n .d swap_sign d\n } then\n } .then,\n ()\n >\n {() x, {.n abs x,.d abs y} gcd int y}\n {\n {.x.n x,.y y} div .div n, \n {.x.d x,.y y} div .div d\n }\n $rat\n;\n\n\nplus_rat = \n ${rat x, rat y}\n { \n .x x, \n .y y,\n {.x.d abs x,.y.d abs y} lcm int lcm\n }\n { \n {\n {.x.n x, {.lcm x, .x.d y} div .div y} times x,\n {.y.n x, {.lcm x, .y.d y} div .div y} times y\n } plus n, \n .lcm d\n }\n normalize_rat\n;\n\n\ntimes_rat = \n ${rat x, rat y}\n { \n {.x.n x,.y.n y} times n, \n {.x.d x,.y.d y} times d\n } \n normalize_rat;\n \n\nminus_rat = \n ${rat x, rat y}\n {\n .x x, \n .y {.n swap_sign n, .d d} y\n } \n plus_rat;\n\ninverse_rat = \n $rat\n { .d n, .n d }\n normalize_rat\n;\n\ndiv_rat = \n ${rat x, rat y}\n { .x x, .y inverse_rat y} times_rat\n;\n\n\n--------------------\n\nint_rat = \n $rat \n { .n n, .d d, {.n x,.d y} div div }\n { .div.div int, {.div.rem int n, .d d} rat}\n ${int int, rat rat}\n;\n\n/* \nratToString = \n-- $rat\n[\n .n toJSON, \n \"/\", \n .d toJSON, \n \" = \",\n normalize_rat\n <\n [.d,.n] GT [.1 toJSON ,\"/\", .0 toJSON] CONCAT,\n {.n 0,[.d,1] EQ 1} [.0 toJSON] CONCAT,\n int_rat [.int toJSON,\"+\",.rat.n toJSON,\"/\",.rat.d toJSON] CONCAT\n >\n ] CONCAT\n-- $@string\n;\n\n_rat! = $rat {\n () carryOn, \n ratToString drop\n } .carryOn;\n\n\n\n*/\n\n()",
6
+ "Examples/arithmetics.k": "-- Examples for defining arithmetic functions natively\n$ yes_no = < {} yes, {} no >;\nswap_yes_no = < /yes |no, /no |yes > $yes_no;\nyes = {}|yes $yes_no;\nno = yes swap_yes_no;\n\n$ bits = < {} _, bits 0, bits 1 >;\n\n0b = {} | _;\n-- |1 = | 1;\n-- |0 = | 0;\n\n0 = 0b |0;\nsucc = {inv x, 0b y} _inc;\n1 = 0 succ;\n2 = 1 succ;\n3 = 2 succ;\n4 = 3 succ;\n5 = 4 succ;\n6 = 5 succ;\n7 = 6 succ;\n8 = 7 succ;\n9 = 8 succ;\n10 = 9 succ;\n11 = 10 succ;\n12 = 11 succ;\n\nempty = $bits < /_ yes, no >;\nempty? = {empty /yes if, () then} .then;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_; \nconcat_ = ${bits x, bits y} \n < \n {.x empty? if, .y then} .then,\n < \n {.x /0 x, .y |0 y}, \n {.x /1 x, .y |1 y}\n > concat_ \n >;\ninv = {()x, 0b r} _inv; \n_inv = ${bits x, bits r} \n < \n {.x empty? if, .r then} .then,\n < \n {.x /0 x, .r |0 r}, \n {.x /1 x, .r |1 r}\n > _inv\n >;\n\ninOrder = ${bits x, bits y} {.x inv x, .y inv y, yes inOrder} inOrder_;\ninOrder_ = ${bits x, bits y, yes_no inOrder} \n < \n {.x </0,/1> if1, .y /_ if2, .inOrder swap_yes_no then} .then,\n {.x /_ if, .inOrder then} .then,\n < \n {.x /0 x, .y /0 y, .inOrder inOrder}, \n {.x /1 x, .y /1 y, .inOrder inOrder},\n {.x /0 x, .y /1 y, .inOrder inOrder}, \n {.x /1 y, .y /0 x, .inOrder swap_yes_no inOrder}\n > inOrder_\n >;\n\nGT = {inOrder /no if, () then} . then;\n\nEQ = {inOrder /yes if, {.x y, .y x} inOrder /yes and, () then} .then;\n\n--------------------------------------\n$ int = < bits '+', bits '-' >;\n\nremove_leading_zeros = <\n /0 remove_leading_zeros, \n ()\n>;\nnat = remove_leading_zeros <empty? 0, ()>;\nint = nat | '+' $int;\nabs = $int </'+',/'-'>;\n\npos? = $int {/'+' remove_leading_zeros /1 if, () then} .then;\nneg? = $int {/'-' if, () then} .then; \nzero_int? = $int {/'+' /0 empty? if, () then} .then;\nminus_one? = $int {/'-' /1 empty? if, () then} .then;\n\ninc = $int <\n /'+' {inv x, 0b y} _inc nat |'+',\n minus_one? 0 int,\n /'-' {inv x, 0b y} _dec nat |'-'\n> $int;\n\n_inc = ${bits x, bits y} <\n {.x empty? if, .y |1 then} .then,\n {.x /0 x, .y |1 y} concat_, \n {.x /1 x, .y |0 y} _inc\n>; \n\ndec = $int <\n zero_int? 1 |'-',\n /'+' {inv x, 0b y} _dec nat |'+',\n /'-' {inv x, 0b y} _inc nat |'-'\n> $int;\n\n_dec = ${bits x, bits y} <\n {.x /1 x, .y |0 y} concat_, \n {.x /0 x, .y |1 y} _dec\n>;\n\n$ carry = <{} 0, {} 1>;\nc0 = {}|0 $carry;\nc1 = {}|1 $carry;\n\nplus = ${int x, int y}\n< \n {.x/'+' inv x, .y/'+' inv y, c0 c } _plus inv nat | '+',\n {.x/'-' inv x, .y/'-' inv y, c0 c } _plus inv nat | '-',\n {.y/'-' x, .x/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.x/'+' inv x, .y/'-' inv y, c0 c} _minus inv nat |'+',\n {.x/'-' x, .y/'+' y} GT {.x inv x, .y inv y, c0 c} _minus inv nat | '-',\n {.y/'+' inv x, .x/'-' inv y, c0 c} _minus inv nat | '+'\n> \n$int;\n\nswap_sign = <\n zero_int?,\n /'+' | '-',\n /'-' | '+'\n>;\n\nminus = ${int x, int y}\n {.x x, .y swap_sign y} plus;\n\n_plus = {.x x, .y y, .c c, 0b r} _plus_;\n\n_plus_ =\n -- least significant bit first addition with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.x empty? if, .y empty? and, .c/0 c, .r inv then} .then,\n {.x empty? if, .y empty? and, {.r x, 1 r} _inv then} .then,\n {.x empty? if, .c/0 and, {.r x, .y r} _inv then} .then,\n\n <\n {.x y, .y empty? x, .c c, .r r},\n {<.c/0 0, 1> x, .y y, .x empty? c0 c, .r r},\n\n {.x /0 x, .y /0 y, .c/0 c0 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/1 c0 c, .r |1 r},\n\n {.x /0 x, .y /1 y, .c/0 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /0 y, .c/0 c0 c, .r |1 r},\n {.x /1 x, .y /0 y, .c/1 c1 c, .r |0 r},\n\n {.x /1 x, .y /1 y, .c/0 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/1 c1 c, .r |1 r}\n > _plus_\n >\n;\n\n_minus = {.x x, .y y, .c c, 0b r} _minus_;\n\n_minus_ =\n -- least significant bit first substraction with carry\n ${bits x, bits y, carry c, bits r}\n <\n {.y empty? if, .c/0 and, {.r x, .x r} _inv then} .then,\n <\n {.x/0 x, .y empty? y, .c/1 c1 c, .r |1 r},\n {.x/1 x, .y empty? y, .c/1 c0 c, .r |0 r},\n\n {.x/0 x, .y/0 y, .c/0 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/1 c1 c, .r |1 r}, \n {.x/0 x, .y/1 y, .c/0 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/1 c1 c, .r |0 r},\n {.x/1 x, .y/0 y, .c/0 c0 c, .r |1 r},\n {.x/1 x, .y/0 y, .c/1 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/0 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/1 c1 c, .r |1 r}\n > _minus_\n >\n;\n\n$ sign = < {} '+' , {} '-' >;\nsign_plus = {}|'+' $sign;\nsign_minus = {}|'-' $sign;\nget_sign = $int </'+' sign_plus, /'-' sign_minus>;\n\ntimes = ${int x, int y}\n {\n <\n {.x/'+' if, .y /'+' and} sign_plus, \n {.x/'-' if, .y /'-' and} sign_plus, \n sign_minus\n > sign,\n {\n 0b result,\n .x abs inv _x,\n .y abs y\n } _times result\n }\n <\n {.sign/'+' if, .result inv int then} .then,\n {.sign/'-' if, .result inv int swap_sign then} .then \n >\n;\n\n_times =\n ${bits result, bits _x, bits y}\n <\n { .y empty? if, .result then } .then,\n <\n { \n .result |0 result, \n ._x _x, \n .y /0 y\n },\n { \n {._x x, .result |0 y, c0 c } _plus result, \n ._x _x, \n .y /1 y \n }\n > _times\n >\n;\n\n\n\n\n\n// ----------------------------------------------------------------------\n// Integer Division: Adaptive Hybrid Algorithm\n//\n// Combines two complementary strategies based on the bit-length\n// comparison between dividend x and divisor y (|x| vs |y|):\n//\n// 1. Down-Shift Division (|x| < 2|y|, y is large relative to x):\n// - Scales y up to y_max = y * 2^k to match length(x) via 'y inv'\n// and prepending k zeros (|0).\n// - In each step: trial subtraction x = x - y_scaled, then down-shifts\n// y_scaled by 1 bit in O(1) by popping the outer zero (/_0).\n// - Runs in exactly (|x| - |y| + 1) iterations. When y ~= x, this\n// terminates in 1-2 steps rather than looping through all bits of x.\n//\n// 2. Restoring Division (|x| >= 2|y|, y is small relative to x):\n// - Consumes bits of x from MSB to LSB into remainder accumulator r.\n// - Remainder r stays small (r <= 2y), so trial subtractions operate\n// on tiny numbers of length |y| rather than full-length |x|.\n//\n// The crossover condition |x| < 2|y| is evaluated structurally in\n// O(min(|y|, |x|/2)) by consuming 2 bits of x for every 1 bit of y.\n// ----------------------------------------------------------------------\n\n// Helpers for Restoring Division (shift-and-subtract)\nshift_in_0 = inv |0 inv nat;\nshift_in_1 = inv |1 inv nat;\nsub_bits = ${bits x, bits y} {.x inv x, .y inv y, c0 c} _minus inv nat;\n\n_div_restoring =\n ${bits x, bits y, bits r, bits q}\n <\n {.x empty? if, {.q inv int div, .r rem} then} .then,\n <\n {.x /0 x, .r shift_in_0 r, .y y, .q q},\n {.x /1 x, .r shift_in_1 r, .y y, .q q}\n >\n {\n .x x,\n .y y,\n .q q,\n .r r,\n {.y x, .r y} inOrder test\n }\n <\n {.test /yes if, {.x x, .y y, .q |1 q, {.r x, .y y} sub_bits r} then} .then,\n {.test /no if, {.x x, .y y, .q |0 q, .r r} then} .then\n >\n _div_restoring\n >;\n\n// Helpers for Down-Shift Division (align and shift divisor down)\n// Phase 1: pad _y with |0 to match length of x, counting shift steps\n_pad_down = ${bits x, bits _y, bits steps}\n <\n {.x empty? if, {._y _y, .steps steps} then} .then,\n {\n .x </0, /1> x,\n ._y |0 _y,\n .steps |0 steps\n } _pad_down\n >;\n\n_align_down = ${bits x, bits y, bits _y}\n <\n // Both x and y have bits remaining: advance both\n {\n .x </0, /1> x,\n .y </0, /1> y,\n ._y _y\n } _align_down,\n\n // y is empty while x remains: pad _y with shift zeros\n {\n .y empty? if,\n {.x x, ._y _y, 0b steps} _pad_down then\n } .then,\n\n // Both x and y are empty: lengths equal (0 shift steps)\n {\n .x empty? if,\n .y empty? and,\n {._y _y, 0b steps} then\n } .then\n >;\n\n// Phase 2: down-shift trial subtraction\n_div_down = ${bits x, bits _y, bits steps, bits q}\n {\n .x x,\n ._y _y,\n .steps steps,\n .q q,\n ._y inv nat y_scaled\n }\n {\n .x x,\n ._y _y,\n .steps steps,\n .q q,\n .y_scaled y_scaled,\n {.y_scaled x, .x y} inOrder test\n }\n <\n // If x >= y_scaled, subtract and emit quotient bit 1\n {\n .test /yes if,\n {\n {.x int x, .y_scaled int y} minus /+ x,\n .q |1 q,\n ._y _y,\n .steps steps\n } then\n } .then,\n // If x < y_scaled, keep x and emit quotient bit 0\n {\n .test /no if,\n {.x x, .q |0 q, ._y _y, .steps steps} then\n } .then\n >\n <\n // If no more shift steps remaining, division is complete\n {\n .steps empty? if,\n {.q inv int div, .x rem} then\n } .then,\n // Otherwise down-shift: remove the last 0 from _y and steps\n {\n .x x,\n ._y /0 _y,\n .steps /0 steps,\n .q q\n } _div_down\n >;\n\n$ choose_div = < {} down_shift, {} restore >;\n\n// Evaluates whether |x| < 2|y| by advancing 2 bits of x per 1 bit of y\n_check_2y = ${bits x, bits y}\n <\n // x is empty -> |x| < 2|y| (choose down_shift)\n {.x empty? if, {} | down_shift $choose_div then} .then,\n // y is empty while x remains -> |x| >= 2|y| (choose restore)\n {.y empty? if, {} | restore $choose_div then} .then,\n // x has only 1 bit left while y remains -> |x| < 2|y|\n {.x </0, /1> empty? if, {} | down_shift $choose_div then} .then,\n // Advance 2 bits from x and 1 bit from y\n {\n .x </0, /1> </0, /1> x,\n .y </0, /1> y\n } _check_2y\n >;\n\n// Public division interface\ndiv = ${int x, int y}\n {\n <\n { .x/'+' if, .y get_sign then } .then,\n { .x/'-' if, .y swap_sign get_sign then } .then\n > sign,\n .x abs remove_leading_zeros x_norm,\n .y abs remove_leading_zeros y_norm\n }\n <\n // Case 1: x == 0 -> quotient 0, remainder 0\n {\n .x_norm empty? if,\n { 0 int div, 0 rem } then\n } .then,\n // Case 2: |x| < |y| -> x < y, quotient 0, remainder x\n {\n {.y_norm x, .x_norm y} GT if,\n { 0 int div, .x_norm rem } then\n } .then,\n // Case 3: general division via adaptive hybrid choice\n {\n .sign sign,\n {\n .x_norm x,\n .y_norm y,\n {.x_norm x, .y_norm y} _check_2y choice\n }\n <\n // If |x| < 2|y|, use down-shift division\n {\n .choice /down_shift if,\n {\n .x x,\n {.x x, .y y, .y inv _y} _align_down aligned\n }\n {\n .x x,\n .aligned._y _y,\n .aligned.steps steps,\n 0b q\n } _div_down then\n } .then,\n // If |x| >= 2|y|, use restoring long division\n {\n .choice /restore if,\n {.x x, .y y, 0 r, 0b q} _div_restoring then\n } .then\n > res\n }\n <\n {.sign/'+' if, {.res.div div, .res.rem rem} then} .then,\n { .res.div swap_sign div, .res.rem rem }\n >\n >;\n\n\n// ----------------------------------------------------------------------\n// Number Theory: Modulo, Greatest Common Divisor, Least Common Multiple\n// ----------------------------------------------------------------------\n\n// Modulo: remainder of x divided by y in $bits, delegated to div\nmod = ${bits x, bits y}\n {{.x int x, .y int y} div .rem rem} .rem;\n\n// Greatest common divisor (Euclidean algorithm)\ngcd = ${bits x, bits y}\n <\n {.y x, .x y} GT, \n ()\n > _gcd\n;\n\n_gcd = <\n { .y remove_leading_zeros empty? if, .x nat then } .then,\n { .y x, mod y } _gcd\n>;\n\n// Least common multiple: (x / gcd(x, y)) * y\nlcm = \n ${bits x, bits y}\n {{.x int x, gcd int y} div .div x, .y int y} times abs\n;\n\nfactorial = {()n, 1 int acc} factorial_;\nfactorial_ = <\n {.n zero_int? if, .acc then} .then,\n {.n pos? dec n, {.n x, .acc y} times acc} factorial_\n>;\n\nfib_ =\n <\n {.n int zero_int? if, .\"fib(n),fib(n.1)\" then} .then,\n { .n int dec /\"+\" n,\n .\"fib(n),fib(n.1)\" {plus x, .x y} \"fib(n),fib(n.1)\"\n } fib_\n >\n;\n\nfib = {$bits n, {1 int x, 0 int y} \"fib(n),fib(n.1)\"} fib_ .x;\n\n\n--------------------\n$ rat = { int n, int d };\n\nrat = ${bits n, bits d} {.n int n, .d int d } normalize_rat;\n\nnormalize_rat =\n $rat \n < \n { .d/\"-\" if, \n {\n .n swap_sign n, \n .d swap_sign d\n } then\n } .then,\n ()\n >\n {() x, {.n abs x,.d abs y} gcd int y}\n {\n {.x.n x,.y y} div .div n, \n {.x.d x,.y y} div .div d\n }\n $rat\n;\n\n\nplus_rat = \n ${rat x, rat y}\n { \n .x x, \n .y y,\n {.x.d abs x,.y.d abs y} lcm int lcm\n }\n { \n {\n {.x.n x, {.lcm x, .x.d y} div .div y} times x,\n {.y.n x, {.lcm x, .y.d y} div .div y} times y\n } plus n, \n .lcm d\n }\n normalize_rat\n;\n\n\ntimes_rat = \n ${rat x, rat y}\n { \n {.x.n x,.y.n y} times n, \n {.x.d x,.y.d y} times d\n } \n normalize_rat;\n \n\nminus_rat = \n ${rat x, rat y}\n {\n .x x, \n .y {.n swap_sign n, .d d} y\n } \n plus_rat;\n\ninverse_rat = \n $rat\n { .d n, .n d }\n normalize_rat\n;\n\ndiv_rat = \n ${rat x, rat y}\n { .x x, .y inverse_rat y} times_rat\n;\n\n\n--------------------\n\nint_rat = \n $rat \n { .n n, .d d, {.n x,.d y} div div }\n { .div.div int, {.div.rem int n, .d d} rat}\n ${int int, rat rat}\n;\n\n/* \nratToString = \n-- $rat\n[\n .n toJSON, \n \"/\", \n .d toJSON, \n \" = \",\n normalize_rat\n <\n [.d,.n] GT [.1 toJSON ,\"/\", .0 toJSON] CONCAT,\n {.n 0,[.d,1] EQ 1} [.0 toJSON] CONCAT,\n int_rat [.int toJSON,\"+\",.rat.n toJSON,\"/\",.rat.d toJSON] CONCAT\n >\n ] CONCAT\n-- $@string\n;\n\n_rat! = $rat {\n () carryOn, \n ratToString drop\n } .carryOn;\n\n\n\n*/\n\n()",
7
7
  "ieee.k": "// Primitive bit domains used throughout floating-point encodings.\n// IEEE-754 double-precision building blocks: bit-level domains, flag enums,\n// and ripple-carry arithmetic helpers reused across add/sub/mul/div.\n$bit = < {} 0, {} 1 >;\n$sign = < {} +, {} - >;\n\n// Small utility products for pairing bits or signs.\n$bit_pair = {bit x, bit y};\n$sign_pair = {sign x, sign y};\n\n// Comparator states and result lattice (accounts for NaN unordered case).\n$cmp_state = <{} eq, {} gt, {} lt>;\n$cmp = <{} eq_exact, {} eq_zero, {} gt, {} lt, {} unordered_nan>;\n\n// IEEE-754 double fields: 11-bit exponent and 52-bit fraction.\n$exp11 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10};\n$frac52 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51};\n\n// Logical view of a double plus rounding/exception flag enums per op.\n$float64 = {sign sign, exp11 exponent, frac52 fraction};\n$flags_add = <{} none, {} invalid, {} overflow, {} underflow, {} inexact>;\n$flags_sub = <{} none, {} invalid, {} overflow, {} underflow, {} inexact>;\n$flags_mul = <{} none, {} invalid, {} overflow, {} underflow, {} inexact>;\n$flags_div = <{} none, {} invalid, {} div_by_zero, {} overflow, {} underflow, {} inexact>;\n\n// Bundles pairing an arithmetic result with its raised flags.\n$add_result = {float64 result, flags_add flags};\n$sub_result = {float64 result, flags_sub flags};\n$mul_result = {float64 result, flags_mul flags};\n$div_result = {float64 result, flags_div flags};\n\n// Common products for operand pairs and extended significands.\n$float_pair = {float64 x, float64 y};\n$sig53 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51, bit 52};\n$sig56 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51, bit 52, bit 53, bit 54, bit 55};\n// Helper shapes for ripple-carry adders and small shifts.\n$exp_sum = {exp11 sum, bit carry};\n$sig56_sum = {sig56 sum, bit carry};\n$adder_out = {bit sum, bit carry};\n$shift6 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5};\n\n// Pairings used during exponent/fraction comparisons.\n$exp_pair = {exp11 x, exp11 y};\n$frac_pair = {frac52 x, frac52 y};\n\n// Comparator pipelines carry current state alongside bit pairs.\n$cmp_step_in = {bit_pair bits, cmp_state state};\n$cmp_exp_ctx = {exp_pair pair, cmp_state state};\n$cmp_frac_ctx = {frac_pair pair, cmp_state state};\n\n// Canonical bit literals for convenience.\n0 = {} |0 $bit;\n1 = {} |1 $bit;\n\n// Flag constructors for exception enums.\nnone = {} |none;\ninvalid = {} |invalid;\noverflow = {} |overflow;\nunderflow = {} |underflow;\ninexact = {} |inexact;\ndiv_by_zero = {} |div_by_zero;\n\n// Primitive boolean operators and a 3-input XOR helper.\nnot_bit = $bit </0 1, 0>;\nor_bit = $bit_pair <.x/1 1, .y/1 1, 0> $bit;\nand_bit = $bit_pair <.x/0 0, .y/0 0, 1> $bit;\nxor_bit = $bit_pair <{.x/0 if, .y then} .then, .y not_bit> $bit;\nxor_abc = ${bit a, bit b, bit c}\n {{.a x, .b y} xor_bit x, .c y} xor_bit;\n\n// Single-bit full adder: sum plus carry-out.\nfull_adder = ${bit a, bit b, bit c_in}\n {\n {.a a, .b b, .c_in c} xor_abc sum,\n {\n {.a x, .b y} and_bit x,\n {{.a x, .b y} xor_bit x, .c_in y} and_bit y\n } or_bit carry\n } $adder_out;\n\n// Bitwise inversion across the 11-bit exponent field.\nexp11_not = $exp11 {\n .0 not_bit 0,\n .1 not_bit 1,\n .2 not_bit 2,\n .3 not_bit 3,\n .4 not_bit 4,\n .5 not_bit 5,\n .6 not_bit 6,\n .7 not_bit 7,\n .8 not_bit 8,\n .9 not_bit 9,\n .10 not_bit 10\n} $exp11;\n\n// Ripple-carry add for two exp11 fields with an incoming carry.\nexp11_add_cin = ${exp11 x, exp11 y, bit c_in}\n {\n .x x,\n .y y,\n .c_in c_in,\n {.x .0 a, .y .0 b, .c_in c_in} full_adder fa0\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n {.x .1 a, .y .1 b, .fa0.carry c_in} full_adder fa1\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n {.x .2 a, .y .2 b, .fa1.carry c_in} full_adder fa2\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n {.x .3 a, .y .3 b, .fa2.carry c_in} full_adder fa3\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n {.x .4 a, .y .4 b, .fa3.carry c_in} full_adder fa4\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n {.x .5 a, .y .5 b, .fa4.carry c_in} full_adder fa5\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n {.x .6 a, .y .6 b, .fa5.carry c_in} full_adder fa6\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n {.x .7 a, .y .7 b, .fa6.carry c_in} full_adder fa7\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n {.x .8 a, .y .8 b, .fa7.carry c_in} full_adder fa8\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n {.x .9 a, .y .9 b, .fa8.carry c_in} full_adder fa9\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n {.x .10 a, .y .10 b, .fa9.carry c_in} full_adder fa10\n }\n {\n {.fa0.sum 0, .fa1.sum 1, .fa2.sum 2, .fa3.sum 3, .fa4.sum 4, .fa5.sum 5, .fa6.sum 6, .fa7.sum 7, .fa8.sum 8, .fa9.sum 9, .fa10.sum 10} sum,\n .fa10.carry carry\n } $exp_sum;\n\n// Unsigned add of two exp11 values; exposes carry-out.\nexp11_add = ${exp11 x, exp11 y} {.x x, .y y, 0 c_in} exp11_add_cin $exp_sum;\n\n// Two's-complement subtract for exp11 (x - y).\nexp11_sub = ${exp11 x, exp11 y}\n {.x x, (.y exp11_not) y, 1 c_in}\n exp11_add_cin\n $exp_sum;\n\n// Convenience projection: subtract and return only the exponent sum.\nexp11_sub_sum = ${exp11 x, exp11 y}\n {.x x, .y y} exp11_sub .sum\n $exp11;\n\n// Bitwise inversion over a 56-bit significand slice.\nsig56_not = $sig56 {\n .0 not_bit 0,\n .1 not_bit 1,\n .2 not_bit 2,\n .3 not_bit 3,\n .4 not_bit 4,\n .5 not_bit 5,\n .6 not_bit 6,\n .7 not_bit 7,\n .8 not_bit 8,\n .9 not_bit 9,\n .10 not_bit 10,\n .11 not_bit 11,\n .12 not_bit 12,\n .13 not_bit 13,\n .14 not_bit 14,\n .15 not_bit 15,\n .16 not_bit 16,\n .17 not_bit 17,\n .18 not_bit 18,\n .19 not_bit 19,\n .20 not_bit 20,\n .21 not_bit 21,\n .22 not_bit 22,\n .23 not_bit 23,\n .24 not_bit 24,\n .25 not_bit 25,\n .26 not_bit 26,\n .27 not_bit 27,\n .28 not_bit 28,\n .29 not_bit 29,\n .30 not_bit 30,\n .31 not_bit 31,\n .32 not_bit 32,\n .33 not_bit 33,\n .34 not_bit 34,\n .35 not_bit 35,\n .36 not_bit 36,\n .37 not_bit 37,\n .38 not_bit 38,\n .39 not_bit 39,\n .40 not_bit 40,\n .41 not_bit 41,\n .42 not_bit 42,\n .43 not_bit 43,\n .44 not_bit 44,\n .45 not_bit 45,\n .46 not_bit 46,\n .47 not_bit 47,\n .48 not_bit 48,\n .49 not_bit 49,\n .50 not_bit 50,\n .51 not_bit 51,\n .52 not_bit 52,\n .53 not_bit 53,\n .54 not_bit 54,\n .55 not_bit 55\n} $sig56;\n\n// 56-bit ripple-carry add with optional incoming carry.\n// 14-bit ripple-carry adder\n$sig14 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10, bit 11, bit 12, bit 13};\n$sig14_sum = {sig14 sum, bit carry};\nsig14_add_cin = ${sig14 x, sig14 y, bit c_in}\n {\n .x x,\n .y y,\n .c_in c_in,\n {.x .0 a, .y .0 b, .c_in c_in} full_adder fa0\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n {.x .1 a, .y .1 b, .fa0.carry c_in} full_adder fa1\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n {.x .2 a, .y .2 b, .fa1.carry c_in} full_adder fa2\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n {.x .3 a, .y .3 b, .fa2.carry c_in} full_adder fa3\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n {.x .4 a, .y .4 b, .fa3.carry c_in} full_adder fa4\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n {.x .5 a, .y .5 b, .fa4.carry c_in} full_adder fa5\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n {.x .6 a, .y .6 b, .fa5.carry c_in} full_adder fa6\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n {.x .7 a, .y .7 b, .fa6.carry c_in} full_adder fa7\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n {.x .8 a, .y .8 b, .fa7.carry c_in} full_adder fa8\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n {.x .9 a, .y .9 b, .fa8.carry c_in} full_adder fa9\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n {.x .10 a, .y .10 b, .fa9.carry c_in} full_adder fa10\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n .fa10 fa10,\n {.x .11 a, .y .11 b, .fa10.carry c_in} full_adder fa11\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n .fa10 fa10,\n .fa11 fa11,\n {.x .12 a, .y .12 b, .fa11.carry c_in} full_adder fa12\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n .fa10 fa10,\n .fa11 fa11,\n .fa12 fa12,\n {.x .13 a, .y .13 b, .fa12.carry c_in} full_adder fa13\n }\n {\n {.fa0.sum 0, .fa1.sum 1, .fa2.sum 2, .fa3.sum 3, .fa4.sum 4, .fa5.sum 5, .fa6.sum 6, .fa7.sum 7, .fa8.sum 8, .fa9.sum 9, .fa10.sum 10, .fa11.sum 11, .fa12.sum 12, .fa13.sum 13} sum,\n .fa13.carry carry\n } $sig14_sum;\n\n// 56-bit adder composed of 4x 14-bit adders\nsig56_add_cin = ${sig56 x, sig56 y, bit c_in}\n {\n .x x,\n .y y,\n {\n {.x .0 0, .x .1 1, .x .2 2, .x .3 3, .x .4 4, .x .5 5, .x .6 6, .x .7 7, .x .8 8, .x .9 9, .x .10 10, .x .11 11, .x .12 12, .x .13 13} x,\n {.y .0 0, .y .1 1, .y .2 2, .y .3 3, .y .4 4, .y .5 5, .y .6 6, .y .7 7, .y .8 8, .y .9 9, .y .10 10, .y .11 11, .y .12 12, .y .13 13} y,\n .c_in c_in\n } sig14_add_cin b0\n }\n {\n .x x,\n .y y,\n .b0 b0,\n {\n {.x .14 0, .x .15 1, .x .16 2, .x .17 3, .x .18 4, .x .19 5, .x .20 6, .x .21 7, .x .22 8, .x .23 9, .x .24 10, .x .25 11, .x .26 12, .x .27 13} x,\n {.y .14 0, .y .15 1, .y .16 2, .y .17 3, .y .18 4, .y .19 5, .y .20 6, .y .21 7, .y .22 8, .y .23 9, .y .24 10, .y .25 11, .y .26 12, .y .27 13} y,\n .b0.carry c_in\n } sig14_add_cin b1\n }\n {\n .x x,\n .y y,\n .b0 b0,\n .b1 b1,\n {\n {.x .28 0, .x .29 1, .x .30 2, .x .31 3, .x .32 4, .x .33 5, .x .34 6, .x .35 7, .x .36 8, .x .37 9, .x .38 10, .x .39 11, .x .40 12, .x .41 13} x,\n {.y .28 0, .y .29 1, .y .30 2, .y .31 3, .y .32 4, .y .33 5, .y .34 6, .y .35 7, .y .36 8, .y .37 9, .y .38 10, .y .39 11, .y .40 12, .y .41 13} y,\n .b1.carry c_in\n } sig14_add_cin b2\n }\n {\n .b0 b0,\n .b1 b1,\n .b2 b2,\n {\n {.x .42 0, .x .43 1, .x .44 2, .x .45 3, .x .46 4, .x .47 5, .x .48 6, .x .49 7, .x .50 8, .x .51 9, .x .52 10, .x .53 11, .x .54 12, .x .55 13} x,\n {.y .42 0, .y .43 1, .y .44 2, .y .45 3, .y .46 4, .y .47 5, .y .48 6, .y .49 7, .y .50 8, .y .51 9, .y .52 10, .y .53 11, .y .54 12, .y .55 13} y,\n .b2.carry c_in\n } sig14_add_cin b3\n }\n {\n {\n .b0.sum.0 0, .b0.sum.1 1, .b0.sum.2 2, .b0.sum.3 3, .b0.sum.4 4, .b0.sum.5 5, .b0.sum.6 6, .b0.sum.7 7, .b0.sum.8 8, .b0.sum.9 9, .b0.sum.10 10, .b0.sum.11 11, .b0.sum.12 12, .b0.sum.13 13,\n .b1.sum.0 14, .b1.sum.1 15, .b1.sum.2 16, .b1.sum.3 17, .b1.sum.4 18, .b1.sum.5 19, .b1.sum.6 20, .b1.sum.7 21, .b1.sum.8 22, .b1.sum.9 23, .b1.sum.10 24, .b1.sum.11 25, .b1.sum.12 26, .b1.sum.13 27,\n .b2.sum.0 28, .b2.sum.1 29, .b2.sum.2 30, .b2.sum.3 31, .b2.sum.4 32, .b2.sum.5 33, .b2.sum.6 34, .b2.sum.7 35, .b2.sum.8 36, .b2.sum.9 37, .b2.sum.10 38, .b2.sum.11 39, .b2.sum.12 40, .b2.sum.13 41,\n .b3.sum.0 42, .b3.sum.1 43, .b3.sum.2 44, .b3.sum.3 45, .b3.sum.4 46, .b3.sum.5 47, .b3.sum.6 48, .b3.sum.7 49, .b3.sum.8 50, .b3.sum.9 51, .b3.sum.10 52, .b3.sum.11 53, .b3.sum.12 54, .b3.sum.13 55\n } sum,\n .b3.carry carry\n } $sig56_sum;\nsig56_add = ${sig56 x, sig56 y} {.x x, .y y, 0 c_in} sig56_add_cin $sig56_sum;\n\n// Two's-complement subtract for sig56 (x - y).\nsig56_sub = ${sig56 x, sig56 y}\n {.x x, (.y sig56_not) y, 1 c_in}\n sig56_add_cin\n $sig56_sum;\n\n// Convenience projection: subtract and return only the significand sum.\nsig56_sub_sum = ${sig56 x, sig56 y}\n {.x x, .y y} sig56_sub .sum\n $sig56;\n\n// Compare sig56 >= by inspecting subtract carry.\nsig56_ge_bit = ${sig56 x, sig56 y}\n {.x x, .y y} sig56_sub .carry\n $bit;\n\n// 1-bit mux controlled by sel.\nmux_bit = ${bit sel, bit a, bit b}\n <\n {.sel 0? if, .a then} .then,\n {.sel 1? if, .b then} .then\n > $bit;\n\n# --- sig112 helpers (mul/div) ------------------------------------------------\n// Wide 112-bit slice used for intermediate mul/div significands.\n$sig112 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19, bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29, bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39, bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49, bit 50, bit 51, bit 52, bit 53, bit 54, bit 55, bit 56, bit 57, bit 58, bit 59, bit 60, bit 61, bit 62, bit 63, bit 64, bit 65, bit 66, bit 67, bit 68, bit 69, bit 70, bit 71, bit 72, bit 73, bit 74, bit 75, bit 76, bit 77, bit 78, bit 79, bit 80, bit 81, bit 82, bit 83, bit 84, bit 85, bit 86, bit 87, bit 88, bit 89, bit 90, bit 91, bit 92, bit 93, bit 94, bit 95, bit 96, bit 97, bit 98, bit 99, bit 100, bit 101, bit 102, bit 103, bit 104, bit 105, bit 106, bit 107, bit 108, bit 109, bit 110, bit 111};\n// Helper shape: sum and carry for wide 112-bit arithmetic.\n$sig112_sum = {sig112 sum, bit carry};\n// Bitwise inversion across the 112-bit extended significand.\nsig112_not = $sig112 {\n .0 not_bit 0,\n .1 not_bit 1,\n .2 not_bit 2,\n .3 not_bit 3,\n .4 not_bit 4,\n .5 not_bit 5,\n .6 not_bit 6,\n .7 not_bit 7,\n .8 not_bit 8,\n .9 not_bit 9,\n .10 not_bit 10,\n .11 not_bit 11,\n .12 not_bit 12,\n .13 not_bit 13,\n .14 not_bit 14,\n .15 not_bit 15,\n .16 not_bit 16,\n .17 not_bit 17,\n .18 not_bit 18,\n .19 not_bit 19,\n .20 not_bit 20,\n .21 not_bit 21,\n .22 not_bit 22,\n .23 not_bit 23,\n .24 not_bit 24,\n .25 not_bit 25,\n .26 not_bit 26,\n .27 not_bit 27,\n .28 not_bit 28,\n .29 not_bit 29,\n .30 not_bit 30,\n .31 not_bit 31,\n .32 not_bit 32,\n .33 not_bit 33,\n .34 not_bit 34,\n .35 not_bit 35,\n .36 not_bit 36,\n .37 not_bit 37,\n .38 not_bit 38,\n .39 not_bit 39,\n .40 not_bit 40,\n .41 not_bit 41,\n .42 not_bit 42,\n .43 not_bit 43,\n .44 not_bit 44,\n .45 not_bit 45,\n .46 not_bit 46,\n .47 not_bit 47,\n .48 not_bit 48,\n .49 not_bit 49,\n .50 not_bit 50,\n .51 not_bit 51,\n .52 not_bit 52,\n .53 not_bit 53,\n .54 not_bit 54,\n .55 not_bit 55,\n .56 not_bit 56,\n .57 not_bit 57,\n .58 not_bit 58,\n .59 not_bit 59,\n .60 not_bit 60,\n .61 not_bit 61,\n .62 not_bit 62,\n .63 not_bit 63,\n .64 not_bit 64,\n .65 not_bit 65,\n .66 not_bit 66,\n .67 not_bit 67,\n .68 not_bit 68,\n .69 not_bit 69,\n .70 not_bit 70,\n .71 not_bit 71,\n .72 not_bit 72,\n .73 not_bit 73,\n .74 not_bit 74,\n .75 not_bit 75,\n .76 not_bit 76,\n .77 not_bit 77,\n .78 not_bit 78,\n .79 not_bit 79,\n .80 not_bit 80,\n .81 not_bit 81,\n .82 not_bit 82,\n .83 not_bit 83,\n .84 not_bit 84,\n .85 not_bit 85,\n .86 not_bit 86,\n .87 not_bit 87,\n .88 not_bit 88,\n .89 not_bit 89,\n .90 not_bit 90,\n .91 not_bit 91,\n .92 not_bit 92,\n .93 not_bit 93,\n .94 not_bit 94,\n .95 not_bit 95,\n .96 not_bit 96,\n .97 not_bit 97,\n .98 not_bit 98,\n .99 not_bit 99,\n .100 not_bit 100,\n .101 not_bit 101,\n .102 not_bit 102,\n .103 not_bit 103,\n .104 not_bit 104,\n .105 not_bit 105,\n .106 not_bit 106,\n .107 not_bit 107,\n .108 not_bit 108,\n .109 not_bit 109,\n .110 not_bit 110,\n .111 not_bit 111\n} $sig112;\n// 112-bit ripple-carry add with optional incoming carry.\n// 112-bit adder composed of 2x 56-bit adders\nsig112_add_cin = ${sig112 x, sig112 y, bit c_in}\n {\n .x x,\n .y y,\n {\n {.x .0 0, .x .1 1, .x .2 2, .x .3 3, .x .4 4, .x .5 5, .x .6 6, .x .7 7, .x .8 8, .x .9 9, .x .10 10, .x .11 11, .x .12 12, .x .13 13, .x .14 14, .x .15 15, .x .16 16, .x .17 17, .x .18 18, .x .19 19, .x .20 20, .x .21 21, .x .22 22, .x .23 23, .x .24 24, .x .25 25, .x .26 26, .x .27 27, .x .28 28, .x .29 29, .x .30 30, .x .31 31, .x .32 32, .x .33 33, .x .34 34, .x .35 35, .x .36 36, .x .37 37, .x .38 38, .x .39 39, .x .40 40, .x .41 41, .x .42 42, .x .43 43, .x .44 44, .x .45 45, .x .46 46, .x .47 47, .x .48 48, .x .49 49, .x .50 50, .x .51 51, .x .52 52, .x .53 53, .x .54 54, .x .55 55} x,\n {.y .0 0, .y .1 1, .y .2 2, .y .3 3, .y .4 4, .y .5 5, .y .6 6, .y .7 7, .y .8 8, .y .9 9, .y .10 10, .y .11 11, .y .12 12, .y .13 13, .y .14 14, .y .15 15, .y .16 16, .y .17 17, .y .18 18, .y .19 19, .y .20 20, .y .21 21, .y .22 22, .y .23 23, .y .24 24, .y .25 25, .y .26 26, .y .27 27, .y .28 28, .y .29 29, .y .30 30, .y .31 31, .y .32 32, .y .33 33, .y .34 34, .y .35 35, .y .36 36, .y .37 37, .y .38 38, .y .39 39, .y .40 40, .y .41 41, .y .42 42, .y .43 43, .y .44 44, .y .45 45, .y .46 46, .y .47 47, .y .48 48, .y .49 49, .y .50 50, .y .51 51, .y .52 52, .y .53 53, .y .54 54, .y .55 55} y,\n .c_in c_in\n } sig56_add_cin b0\n }\n {\n .b0 b0,\n {\n {.x .56 0, .x .57 1, .x .58 2, .x .59 3, .x .60 4, .x .61 5, .x .62 6, .x .63 7, .x .64 8, .x .65 9, .x .66 10, .x .67 11, .x .68 12, .x .69 13, .x .70 14, .x .71 15, .x .72 16, .x .73 17, .x .74 18, .x .75 19, .x .76 20, .x .77 21, .x .78 22, .x .79 23, .x .80 24, .x .81 25, .x .82 26, .x .83 27, .x .84 28, .x .85 29, .x .86 30, .x .87 31, .x .88 32, .x .89 33, .x .90 34, .x .91 35, .x .92 36, .x .93 37, .x .94 38, .x .95 39, .x .96 40, .x .97 41, .x .98 42, .x .99 43, .x .100 44, .x .101 45, .x .102 46, .x .103 47, .x .104 48, .x .105 49, .x .106 50, .x .107 51, .x .108 52, .x .109 53, .x .110 54, .x .111 55} x,\n {.y .56 0, .y .57 1, .y .58 2, .y .59 3, .y .60 4, .y .61 5, .y .62 6, .y .63 7, .y .64 8, .y .65 9, .y .66 10, .y .67 11, .y .68 12, .y .69 13, .y .70 14, .y .71 15, .y .72 16, .y .73 17, .y .74 18, .y .75 19, .y .76 20, .y .77 21, .y .78 22, .y .79 23, .y .80 24, .y .81 25, .y .82 26, .y .83 27, .y .84 28, .y .85 29, .y .86 30, .y .87 31, .y .88 32, .y .89 33, .y .90 34, .y .91 35, .y .92 36, .y .93 37, .y .94 38, .y .95 39, .y .96 40, .y .97 41, .y .98 42, .y .99 43, .y .100 44, .y .101 45, .y .102 46, .y .103 47, .y .104 48, .y .105 49, .y .106 50, .y .107 51, .y .108 52, .y .109 53, .y .110 54, .y .111 55} y,\n .b0.carry c_in\n } sig56_add_cin b1\n }\n {\n {\n .b0.sum.0 0, .b0.sum.1 1, .b0.sum.2 2, .b0.sum.3 3, .b0.sum.4 4, .b0.sum.5 5, .b0.sum.6 6, .b0.sum.7 7, .b0.sum.8 8, .b0.sum.9 9, .b0.sum.10 10, .b0.sum.11 11, .b0.sum.12 12, .b0.sum.13 13, .b0.sum.14 14, .b0.sum.15 15, .b0.sum.16 16, .b0.sum.17 17, .b0.sum.18 18, .b0.sum.19 19, .b0.sum.20 20, .b0.sum.21 21, .b0.sum.22 22, .b0.sum.23 23, .b0.sum.24 24, .b0.sum.25 25, .b0.sum.26 26, .b0.sum.27 27, .b0.sum.28 28, .b0.sum.29 29, .b0.sum.30 30, .b0.sum.31 31, .b0.sum.32 32, .b0.sum.33 33, .b0.sum.34 34, .b0.sum.35 35, .b0.sum.36 36, .b0.sum.37 37, .b0.sum.38 38, .b0.sum.39 39, .b0.sum.40 40, .b0.sum.41 41, .b0.sum.42 42, .b0.sum.43 43, .b0.sum.44 44, .b0.sum.45 45, .b0.sum.46 46, .b0.sum.47 47, .b0.sum.48 48, .b0.sum.49 49, .b0.sum.50 50, .b0.sum.51 51, .b0.sum.52 52, .b0.sum.53 53, .b0.sum.54 54, .b0.sum.55 55,\n .b1.sum.0 56, .b1.sum.1 57, .b1.sum.2 58, .b1.sum.3 59, .b1.sum.4 60, .b1.sum.5 61, .b1.sum.6 62, .b1.sum.7 63, .b1.sum.8 64, .b1.sum.9 65, .b1.sum.10 66, .b1.sum.11 67, .b1.sum.12 68, .b1.sum.13 69, .b1.sum.14 70, .b1.sum.15 71, .b1.sum.16 72, .b1.sum.17 73, .b1.sum.18 74, .b1.sum.19 75, .b1.sum.20 76, .b1.sum.21 77, .b1.sum.22 78, .b1.sum.23 79, .b1.sum.24 80, .b1.sum.25 81, .b1.sum.26 82, .b1.sum.27 83, .b1.sum.28 84, .b1.sum.29 85, .b1.sum.30 86, .b1.sum.31 87, .b1.sum.32 88, .b1.sum.33 89, .b1.sum.34 90, .b1.sum.35 91, .b1.sum.36 92, .b1.sum.37 93, .b1.sum.38 94, .b1.sum.39 95, .b1.sum.40 96, .b1.sum.41 97, .b1.sum.42 98, .b1.sum.43 99, .b1.sum.44 100, .b1.sum.45 101, .b1.sum.46 102, .b1.sum.47 103, .b1.sum.48 104, .b1.sum.49 105, .b1.sum.50 106, .b1.sum.51 107, .b1.sum.52 108, .b1.sum.53 109, .b1.sum.54 110, .b1.sum.55 111\n } sum,\n .b1.carry carry\n } $sig112_sum;\nsig112_add = ${sig112 x, sig112 y} {.x x, .y y, 0 c_in} sig112_add_cin $sig112_sum;\n\nsig112_sub = ${sig112 x, sig112 y}\n {.x x, (.y sig112_not) y, 1 c_in}\n sig112_add_cin\n $sig112_sum;\nsig112_zero = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15, 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31, 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47, 0 48, 0 49, 0 50, 0 51, 0 52, 0 53, 0 54, 0 55, 0 56, 0 57, 0 58, 0 59, 0 60, 0 61, 0 62, 0 63, 0 64, 0 65, 0 66, 0 67, 0 68, 0 69, 0 70, 0 71, 0 72, 0 73, 0 74, 0 75, 0 76, 0 77, 0 78, 0 79, 0 80, 0 81, 0 82, 0 83, 0 84, 0 85, 0 86, 0 87, 0 88, 0 89, 0 90, 0 91, 0 92, 0 93, 0 94, 0 95, 0 96, 0 97, 0 98, 0 99, 0 100, 0 101, 0 102, 0 103, 0 104, 0 105, 0 106, 0 107, 0 108, 0 109, 0 110, 0 111} $sig112;\nsig112_shift_left1 = $sig112\n {\n 0 0,\n .0 1,\n .1 2,\n .2 3,\n .3 4,\n .4 5,\n .5 6,\n .6 7,\n .7 8,\n .8 9,\n .9 10,\n .10 11,\n .11 12,\n .12 13,\n .13 14,\n .14 15,\n .15 16,\n .16 17,\n .17 18,\n .18 19,\n .19 20,\n .20 21,\n .21 22,\n .22 23,\n .23 24,\n .24 25,\n .25 26,\n .26 27,\n .27 28,\n .28 29,\n .29 30,\n .30 31,\n .31 32,\n .32 33,\n .33 34,\n .34 35,\n .35 36,\n .36 37,\n .37 38,\n .38 39,\n .39 40,\n .40 41,\n .41 42,\n .42 43,\n .43 44,\n .44 45,\n .45 46,\n .46 47,\n .47 48,\n .48 49,\n .49 50,\n .50 51,\n .51 52,\n .52 53,\n .53 54,\n .54 55,\n .55 56,\n .56 57,\n .57 58,\n .58 59,\n .59 60,\n .60 61,\n .61 62,\n .62 63,\n .63 64,\n .64 65,\n .65 66,\n .66 67,\n .67 68,\n .68 69,\n .69 70,\n .70 71,\n .71 72,\n .72 73,\n .73 74,\n .74 75,\n .75 76,\n .76 77,\n .77 78,\n .78 79,\n .79 80,\n .80 81,\n .81 82,\n .82 83,\n .83 84,\n .84 85,\n .85 86,\n .86 87,\n .87 88,\n .88 89,\n .89 90,\n .90 91,\n .91 92,\n .92 93,\n .93 94,\n .94 95,\n .95 96,\n .96 97,\n .97 98,\n .98 99,\n .99 100,\n .100 101,\n .101 102,\n .102 103,\n .103 104,\n .104 105,\n .105 106,\n .106 107,\n .107 108,\n .108 109,\n .109 110,\n .110 111\n } $sig112;\nsig112_shift_right1 = $sig112\n {\n .1 0,\n .2 1,\n .3 2,\n .4 3,\n .5 4,\n .6 5,\n .7 6,\n .8 7,\n .9 8,\n .10 9,\n .11 10,\n .12 11,\n .13 12,\n .14 13,\n .15 14,\n .16 15,\n .17 16,\n .18 17,\n .19 18,\n .20 19,\n .21 20,\n .22 21,\n .23 22,\n .24 23,\n .25 24,\n .26 25,\n .27 26,\n .28 27,\n .29 28,\n .30 29,\n .31 30,\n .32 31,\n .33 32,\n .34 33,\n .35 34,\n .36 35,\n .37 36,\n .38 37,\n .39 38,\n .40 39,\n .41 40,\n .42 41,\n .43 42,\n .44 43,\n .45 44,\n .46 45,\n .47 46,\n .48 47,\n .49 48,\n .50 49,\n .51 50,\n .52 51,\n .53 52,\n .54 53,\n .55 54,\n .56 55,\n .57 56,\n .58 57,\n .59 58,\n .60 59,\n .61 60,\n .62 61,\n .63 62,\n .64 63,\n .65 64,\n .66 65,\n .67 66,\n .68 67,\n .69 68,\n .70 69,\n .71 70,\n .72 71,\n .73 72,\n .74 73,\n .75 74,\n .76 75,\n .77 76,\n .78 77,\n .79 78,\n .80 79,\n .81 80,\n .82 81,\n .83 82,\n .84 83,\n .85 84,\n .86 85,\n .87 86,\n .88 87,\n .89 88,\n .90 89,\n .91 90,\n .92 91,\n .93 92,\n .94 93,\n .95 94,\n .96 95,\n .97 96,\n .98 97,\n .99 98,\n .100 99,\n .101 100,\n .102 101,\n .103 102,\n .104 103,\n .105 104,\n .106 105,\n .107 106,\n .108 107,\n .109 108,\n .110 109,\n .111 110,\n 0 111\n } $sig112;\nsig112_from_sig56 = $sig56\n {\n .0 0,\n .1 1,\n .2 2,\n .3 3,\n .4 4,\n .5 5,\n .6 6,\n .7 7,\n .8 8,\n .9 9,\n .10 10,\n .11 11,\n .12 12,\n .13 13,\n .14 14,\n .15 15,\n .16 16,\n .17 17,\n .18 18,\n .19 19,\n .20 20,\n .21 21,\n .22 22,\n .23 23,\n .24 24,\n .25 25,\n .26 26,\n .27 27,\n .28 28,\n .29 29,\n .30 30,\n .31 31,\n .32 32,\n .33 33,\n .34 34,\n .35 35,\n .36 36,\n .37 37,\n .38 38,\n .39 39,\n .40 40,\n .41 41,\n .42 42,\n .43 43,\n .44 44,\n .45 45,\n .46 46,\n .47 47,\n .48 48,\n .49 49,\n .50 50,\n .51 51,\n .52 52,\n .53 53,\n .54 54,\n .55 55,\n 0 56,\n 0 57,\n 0 58,\n 0 59,\n 0 60,\n 0 61,\n 0 62,\n 0 63,\n 0 64,\n 0 65,\n 0 66,\n 0 67,\n 0 68,\n 0 69,\n 0 70,\n 0 71,\n 0 72,\n 0 73,\n 0 74,\n 0 75,\n 0 76,\n 0 77,\n 0 78,\n 0 79,\n 0 80,\n 0 81,\n 0 82,\n 0 83,\n 0 84,\n 0 85,\n 0 86,\n 0 87,\n 0 88,\n 0 89,\n 0 90,\n 0 91,\n 0 92,\n 0 93,\n 0 94,\n 0 95,\n 0 96,\n 0 97,\n 0 98,\n 0 99,\n 0 100,\n 0 101,\n 0 102,\n 0 103,\n 0 104,\n 0 105,\n 0 106,\n 0 107,\n 0 108,\n 0 109,\n 0 110,\n 0 111\n } $sig112;\nsig112_from_sig56_shift55 = $sig56\n {\n 0 0,\n 0 1,\n 0 2,\n 0 3,\n 0 4,\n 0 5,\n 0 6,\n 0 7,\n 0 8,\n 0 9,\n 0 10,\n 0 11,\n 0 12,\n 0 13,\n 0 14,\n 0 15,\n 0 16,\n 0 17,\n 0 18,\n 0 19,\n 0 20,\n 0 21,\n 0 22,\n 0 23,\n 0 24,\n 0 25,\n 0 26,\n 0 27,\n 0 28,\n 0 29,\n 0 30,\n 0 31,\n 0 32,\n 0 33,\n 0 34,\n 0 35,\n 0 36,\n 0 37,\n 0 38,\n 0 39,\n 0 40,\n 0 41,\n 0 42,\n 0 43,\n 0 44,\n 0 45,\n 0 46,\n 0 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n .0 55,\n .1 56,\n .2 57,\n .3 58,\n .4 59,\n .5 60,\n .6 61,\n .7 62,\n .8 63,\n .9 64,\n .10 65,\n .11 66,\n .12 67,\n .13 68,\n .14 69,\n .15 70,\n .16 71,\n .17 72,\n .18 73,\n .19 74,\n .20 75,\n .21 76,\n .22 77,\n .23 78,\n .24 79,\n .25 80,\n .26 81,\n .27 82,\n .28 83,\n .29 84,\n .30 85,\n .31 86,\n .32 87,\n .33 88,\n .34 89,\n .35 90,\n .36 91,\n .37 92,\n .38 93,\n .39 94,\n .40 95,\n .41 96,\n .42 97,\n .43 98,\n .44 99,\n .45 100,\n .46 101,\n .47 102,\n .48 103,\n .49 104,\n .50 105,\n .51 106,\n .52 107,\n .53 108,\n .54 109,\n .55 110,\n 0 111\n } $sig112;\nsig112_low56 = $sig112\n {\n .0 0,\n .1 1,\n .2 2,\n .3 3,\n .4 4,\n .5 5,\n .6 6,\n .7 7,\n .8 8,\n .9 9,\n .10 10,\n .11 11,\n .12 12,\n .13 13,\n .14 14,\n .15 15,\n .16 16,\n .17 17,\n .18 18,\n .19 19,\n .20 20,\n .21 21,\n .22 22,\n .23 23,\n .24 24,\n .25 25,\n .26 26,\n .27 27,\n .28 28,\n .29 29,\n .30 30,\n .31 31,\n .32 32,\n .33 33,\n .34 34,\n .35 35,\n .36 36,\n .37 37,\n .38 38,\n .39 39,\n .40 40,\n .41 41,\n .42 42,\n .43 43,\n .44 44,\n .45 45,\n .46 46,\n .47 47,\n .48 48,\n .49 49,\n .50 50,\n .51 51,\n .52 52,\n .53 53,\n .54 54,\n .55 55\n } $sig56;\nsig112_low56_any1 = $sig112\n sig112_low56 sig56_any1\n $bit;\nsig112_any1 = $sig112\n {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit x, .17 y} or_bit x, .18 y} or_bit x, .19 y} or_bit x, .20 y} or_bit x, .21 y} or_bit x, .22 y} or_bit x, .23 y} or_bit x, .24 y} or_bit x, .25 y} or_bit x, .26 y} or_bit x, .27 y} or_bit x, .28 y} or_bit x, .29 y} or_bit x, .30 y} or_bit x, .31 y} or_bit x, .32 y} or_bit x, .33 y} or_bit x, .34 y} or_bit x, .35 y} or_bit x, .36 y} or_bit x, .37 y} or_bit x, .38 y} or_bit x, .39 y} or_bit x, .40 y} or_bit x, .41 y} or_bit x, .42 y} or_bit x, .43 y} or_bit x, .44 y} or_bit x, .45 y} or_bit x, .46 y} or_bit x, .47 y} or_bit x, .48 y} or_bit x, .49 y} or_bit x, .50 y} or_bit x, .51 y} or_bit x, .52 y} or_bit x, .53 y} or_bit x, .54 y} or_bit x, .55 y} or_bit x, .56 y} or_bit x, .57 y} or_bit x, .58 y} or_bit x, .59 y} or_bit x, .60 y} or_bit x, .61 y} or_bit x, .62 y} or_bit x, .63 y} or_bit x, .64 y} or_bit x, .65 y} or_bit x, .66 y} or_bit x, .67 y} or_bit x, .68 y} or_bit x, .69 y} or_bit x, .70 y} or_bit x, .71 y} or_bit x, .72 y} or_bit x, .73 y} or_bit x, .74 y} or_bit x, .75 y} or_bit x, .76 y} or_bit x, .77 y} or_bit x, .78 y} or_bit x, .79 y} or_bit x, .80 y} or_bit x, .81 y} or_bit x, .82 y} or_bit x, .83 y} or_bit x, .84 y} or_bit x, .85 y} or_bit x, .86 y} or_bit x, .87 y} or_bit x, .88 y} or_bit x, .89 y} or_bit x, .90 y} or_bit x, .91 y} or_bit x, .92 y} or_bit x, .93 y} or_bit x, .94 y} or_bit x, .95 y} or_bit x, .96 y} or_bit x, .97 y} or_bit x, .98 y} or_bit x, .99 y} or_bit x, .100 y} or_bit x, .101 y} or_bit x, .102 y} or_bit x, .103 y} or_bit x, .104 y} or_bit x, .105 y} or_bit x, .106 y} or_bit x, .107 y} or_bit x, .108 y} or_bit x, .109 y} or_bit x, .110 y} or_bit x, .111 y} or_bit\n $bit;\nmux_sig112 = ${bit sel, sig112 a, sig112 b}\n {\n {.sel sel, .a .0 a, .b .0 b} mux_bit 0,\n {.sel sel, .a .1 a, .b .1 b} mux_bit 1,\n {.sel sel, .a .2 a, .b .2 b} mux_bit 2,\n {.sel sel, .a .3 a, .b .3 b} mux_bit 3,\n {.sel sel, .a .4 a, .b .4 b} mux_bit 4,\n {.sel sel, .a .5 a, .b .5 b} mux_bit 5,\n {.sel sel, .a .6 a, .b .6 b} mux_bit 6,\n {.sel sel, .a .7 a, .b .7 b} mux_bit 7,\n {.sel sel, .a .8 a, .b .8 b} mux_bit 8,\n {.sel sel, .a .9 a, .b .9 b} mux_bit 9,\n {.sel sel, .a .10 a, .b .10 b} mux_bit 10,\n {.sel sel, .a .11 a, .b .11 b} mux_bit 11,\n {.sel sel, .a .12 a, .b .12 b} mux_bit 12,\n {.sel sel, .a .13 a, .b .13 b} mux_bit 13,\n {.sel sel, .a .14 a, .b .14 b} mux_bit 14,\n {.sel sel, .a .15 a, .b .15 b} mux_bit 15,\n {.sel sel, .a .16 a, .b .16 b} mux_bit 16,\n {.sel sel, .a .17 a, .b .17 b} mux_bit 17,\n {.sel sel, .a .18 a, .b .18 b} mux_bit 18,\n {.sel sel, .a .19 a, .b .19 b} mux_bit 19,\n {.sel sel, .a .20 a, .b .20 b} mux_bit 20,\n {.sel sel, .a .21 a, .b .21 b} mux_bit 21,\n {.sel sel, .a .22 a, .b .22 b} mux_bit 22,\n {.sel sel, .a .23 a, .b .23 b} mux_bit 23,\n {.sel sel, .a .24 a, .b .24 b} mux_bit 24,\n {.sel sel, .a .25 a, .b .25 b} mux_bit 25,\n {.sel sel, .a .26 a, .b .26 b} mux_bit 26,\n {.sel sel, .a .27 a, .b .27 b} mux_bit 27,\n {.sel sel, .a .28 a, .b .28 b} mux_bit 28,\n {.sel sel, .a .29 a, .b .29 b} mux_bit 29,\n {.sel sel, .a .30 a, .b .30 b} mux_bit 30,\n {.sel sel, .a .31 a, .b .31 b} mux_bit 31,\n {.sel sel, .a .32 a, .b .32 b} mux_bit 32,\n {.sel sel, .a .33 a, .b .33 b} mux_bit 33,\n {.sel sel, .a .34 a, .b .34 b} mux_bit 34,\n {.sel sel, .a .35 a, .b .35 b} mux_bit 35,\n {.sel sel, .a .36 a, .b .36 b} mux_bit 36,\n {.sel sel, .a .37 a, .b .37 b} mux_bit 37,\n {.sel sel, .a .38 a, .b .38 b} mux_bit 38,\n {.sel sel, .a .39 a, .b .39 b} mux_bit 39,\n {.sel sel, .a .40 a, .b .40 b} mux_bit 40,\n {.sel sel, .a .41 a, .b .41 b} mux_bit 41,\n {.sel sel, .a .42 a, .b .42 b} mux_bit 42,\n {.sel sel, .a .43 a, .b .43 b} mux_bit 43,\n {.sel sel, .a .44 a, .b .44 b} mux_bit 44,\n {.sel sel, .a .45 a, .b .45 b} mux_bit 45,\n {.sel sel, .a .46 a, .b .46 b} mux_bit 46,\n {.sel sel, .a .47 a, .b .47 b} mux_bit 47,\n {.sel sel, .a .48 a, .b .48 b} mux_bit 48,\n {.sel sel, .a .49 a, .b .49 b} mux_bit 49,\n {.sel sel, .a .50 a, .b .50 b} mux_bit 50,\n {.sel sel, .a .51 a, .b .51 b} mux_bit 51,\n {.sel sel, .a .52 a, .b .52 b} mux_bit 52,\n {.sel sel, .a .53 a, .b .53 b} mux_bit 53,\n {.sel sel, .a .54 a, .b .54 b} mux_bit 54,\n {.sel sel, .a .55 a, .b .55 b} mux_bit 55,\n {.sel sel, .a .56 a, .b .56 b} mux_bit 56,\n {.sel sel, .a .57 a, .b .57 b} mux_bit 57,\n {.sel sel, .a .58 a, .b .58 b} mux_bit 58,\n {.sel sel, .a .59 a, .b .59 b} mux_bit 59,\n {.sel sel, .a .60 a, .b .60 b} mux_bit 60,\n {.sel sel, .a .61 a, .b .61 b} mux_bit 61,\n {.sel sel, .a .62 a, .b .62 b} mux_bit 62,\n {.sel sel, .a .63 a, .b .63 b} mux_bit 63,\n {.sel sel, .a .64 a, .b .64 b} mux_bit 64,\n {.sel sel, .a .65 a, .b .65 b} mux_bit 65,\n {.sel sel, .a .66 a, .b .66 b} mux_bit 66,\n {.sel sel, .a .67 a, .b .67 b} mux_bit 67,\n {.sel sel, .a .68 a, .b .68 b} mux_bit 68,\n {.sel sel, .a .69 a, .b .69 b} mux_bit 69,\n {.sel sel, .a .70 a, .b .70 b} mux_bit 70,\n {.sel sel, .a .71 a, .b .71 b} mux_bit 71,\n {.sel sel, .a .72 a, .b .72 b} mux_bit 72,\n {.sel sel, .a .73 a, .b .73 b} mux_bit 73,\n {.sel sel, .a .74 a, .b .74 b} mux_bit 74,\n {.sel sel, .a .75 a, .b .75 b} mux_bit 75,\n {.sel sel, .a .76 a, .b .76 b} mux_bit 76,\n {.sel sel, .a .77 a, .b .77 b} mux_bit 77,\n {.sel sel, .a .78 a, .b .78 b} mux_bit 78,\n {.sel sel, .a .79 a, .b .79 b} mux_bit 79,\n {.sel sel, .a .80 a, .b .80 b} mux_bit 80,\n {.sel sel, .a .81 a, .b .81 b} mux_bit 81,\n {.sel sel, .a .82 a, .b .82 b} mux_bit 82,\n {.sel sel, .a .83 a, .b .83 b} mux_bit 83,\n {.sel sel, .a .84 a, .b .84 b} mux_bit 84,\n {.sel sel, .a .85 a, .b .85 b} mux_bit 85,\n {.sel sel, .a .86 a, .b .86 b} mux_bit 86,\n {.sel sel, .a .87 a, .b .87 b} mux_bit 87,\n {.sel sel, .a .88 a, .b .88 b} mux_bit 88,\n {.sel sel, .a .89 a, .b .89 b} mux_bit 89,\n {.sel sel, .a .90 a, .b .90 b} mux_bit 90,\n {.sel sel, .a .91 a, .b .91 b} mux_bit 91,\n {.sel sel, .a .92 a, .b .92 b} mux_bit 92,\n {.sel sel, .a .93 a, .b .93 b} mux_bit 93,\n {.sel sel, .a .94 a, .b .94 b} mux_bit 94,\n {.sel sel, .a .95 a, .b .95 b} mux_bit 95,\n {.sel sel, .a .96 a, .b .96 b} mux_bit 96,\n {.sel sel, .a .97 a, .b .97 b} mux_bit 97,\n {.sel sel, .a .98 a, .b .98 b} mux_bit 98,\n {.sel sel, .a .99 a, .b .99 b} mux_bit 99,\n {.sel sel, .a .100 a, .b .100 b} mux_bit 100,\n {.sel sel, .a .101 a, .b .101 b} mux_bit 101,\n {.sel sel, .a .102 a, .b .102 b} mux_bit 102,\n {.sel sel, .a .103 a, .b .103 b} mux_bit 103,\n {.sel sel, .a .104 a, .b .104 b} mux_bit 104,\n {.sel sel, .a .105 a, .b .105 b} mux_bit 105,\n {.sel sel, .a .106 a, .b .106 b} mux_bit 106,\n {.sel sel, .a .107 a, .b .107 b} mux_bit 107,\n {.sel sel, .a .108 a, .b .108 b} mux_bit 108,\n {.sel sel, .a .109 a, .b .109 b} mux_bit 109,\n {.sel sel, .a .110 a, .b .110 b} mux_bit 110,\n {.sel sel, .a .111 a, .b .111 b} mux_bit 111\n } $sig112;\nsig112_add_if = ${sig112 acc, sig112 add, bit sel}\n {\n .acc acc,\n .add add,\n .sel sel,\n {.acc x, .add y} sig112_add sum\n }\n {\n .acc acc,\n .sum sum,\n .sel sel,\n {.sel sel, .acc a, .sum.sum b} mux_sig112 out\n }\n .out $sig112;\nsig56_mul_unsigned = ${sig56 x, sig56 y}\n {\n (.x sig112_from_sig56) add,\n () sig112_zero acc,\n .y y\n }\n {\n .y y,\n {.acc acc, .add add, .y .0 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .1 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .2 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .3 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .4 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .5 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .6 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .7 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .8 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .9 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .10 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .11 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .12 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .13 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .14 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .15 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .16 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .17 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .18 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .19 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .20 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .21 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .22 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .23 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .24 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .25 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .26 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .27 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .28 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .29 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .30 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .31 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .32 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .33 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .34 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .35 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .36 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .37 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .38 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .39 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .40 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .41 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .42 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .43 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .44 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .45 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .46 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .47 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .48 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .49 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .50 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .51 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .52 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .53 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .54 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .55 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n .acc\n $sig112;\nsig56_div_unsigned = ${sig56 x, sig56 y}\n {\n (.x sig112_from_sig56_shift55) rem0,\n (.y sig112_from_sig56_shift55) div0\n }\n {\n .rem0 rem0,\n .div0 div0,\n {.rem0 x, .div0 y} sig112_sub sub55\n }\n {\n {.sub55.carry sel, .rem0 a, .sub55.sum b} mux_sig112 rem1,\n (.div0 sig112_shift_right1) div1,\n .sub55.carry b55\n }\n {\n .rem1 rem1,\n .div1 div1,\n .b55 b55,\n {.rem1 x, .div1 y} sig112_sub sub54\n }\n {\n .b55 b55,\n {.sub54.carry sel, .rem1 a, .sub54.sum b} mux_sig112 rem2,\n (.div1 sig112_shift_right1) div2,\n .sub54.carry b54\n }\n {\n .rem2 rem2,\n .div2 div2,\n .b55 b55,\n .b54 b54,\n {.rem2 x, .div2 y} sig112_sub sub53\n }\n {\n .b55 b55,\n .b54 b54,\n {.sub53.carry sel, .rem2 a, .sub53.sum b} mux_sig112 rem3,\n (.div2 sig112_shift_right1) div3,\n .sub53.carry b53\n }\n {\n .rem3 rem3,\n .div3 div3,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n {.rem3 x, .div3 y} sig112_sub sub52\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n {.sub52.carry sel, .rem3 a, .sub52.sum b} mux_sig112 rem4,\n (.div3 sig112_shift_right1) div4,\n .sub52.carry b52\n }\n {\n .rem4 rem4,\n .div4 div4,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n {.rem4 x, .div4 y} sig112_sub sub51\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n {.sub51.carry sel, .rem4 a, .sub51.sum b} mux_sig112 rem5,\n (.div4 sig112_shift_right1) div5,\n .sub51.carry b51\n }\n {\n .rem5 rem5,\n .div5 div5,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n {.rem5 x, .div5 y} sig112_sub sub50\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n {.sub50.carry sel, .rem5 a, .sub50.sum b} mux_sig112 rem6,\n (.div5 sig112_shift_right1) div6,\n .sub50.carry b50\n }\n {\n .rem6 rem6,\n .div6 div6,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n {.rem6 x, .div6 y} sig112_sub sub49\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n {.sub49.carry sel, .rem6 a, .sub49.sum b} mux_sig112 rem7,\n (.div6 sig112_shift_right1) div7,\n .sub49.carry b49\n }\n {\n .rem7 rem7,\n .div7 div7,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n {.rem7 x, .div7 y} sig112_sub sub48\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n {.sub48.carry sel, .rem7 a, .sub48.sum b} mux_sig112 rem8,\n (.div7 sig112_shift_right1) div8,\n .sub48.carry b48\n }\n {\n .rem8 rem8,\n .div8 div8,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n {.rem8 x, .div8 y} sig112_sub sub47\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n {.sub47.carry sel, .rem8 a, .sub47.sum b} mux_sig112 rem9,\n (.div8 sig112_shift_right1) div9,\n .sub47.carry b47\n }\n {\n .rem9 rem9,\n .div9 div9,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n {.rem9 x, .div9 y} sig112_sub sub46\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n {.sub46.carry sel, .rem9 a, .sub46.sum b} mux_sig112 rem10,\n (.div9 sig112_shift_right1) div10,\n .sub46.carry b46\n }\n {\n .rem10 rem10,\n .div10 div10,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n {.rem10 x, .div10 y} sig112_sub sub45\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n {.sub45.carry sel, .rem10 a, .sub45.sum b} mux_sig112 rem11,\n (.div10 sig112_shift_right1) div11,\n .sub45.carry b45\n }\n {\n .rem11 rem11,\n .div11 div11,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n {.rem11 x, .div11 y} sig112_sub sub44\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n {.sub44.carry sel, .rem11 a, .sub44.sum b} mux_sig112 rem12,\n (.div11 sig112_shift_right1) div12,\n .sub44.carry b44\n }\n {\n .rem12 rem12,\n .div12 div12,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n {.rem12 x, .div12 y} sig112_sub sub43\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n {.sub43.carry sel, .rem12 a, .sub43.sum b} mux_sig112 rem13,\n (.div12 sig112_shift_right1) div13,\n .sub43.carry b43\n }\n {\n .rem13 rem13,\n .div13 div13,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n {.rem13 x, .div13 y} sig112_sub sub42\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n {.sub42.carry sel, .rem13 a, .sub42.sum b} mux_sig112 rem14,\n (.div13 sig112_shift_right1) div14,\n .sub42.carry b42\n }\n {\n .rem14 rem14,\n .div14 div14,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n {.rem14 x, .div14 y} sig112_sub sub41\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n {.sub41.carry sel, .rem14 a, .sub41.sum b} mux_sig112 rem15,\n (.div14 sig112_shift_right1) div15,\n .sub41.carry b41\n }\n {\n .rem15 rem15,\n .div15 div15,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n {.rem15 x, .div15 y} sig112_sub sub40\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n {.sub40.carry sel, .rem15 a, .sub40.sum b} mux_sig112 rem16,\n (.div15 sig112_shift_right1) div16,\n .sub40.carry b40\n }\n {\n .rem16 rem16,\n .div16 div16,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n {.rem16 x, .div16 y} sig112_sub sub39\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n {.sub39.carry sel, .rem16 a, .sub39.sum b} mux_sig112 rem17,\n (.div16 sig112_shift_right1) div17,\n .sub39.carry b39\n }\n {\n .rem17 rem17,\n .div17 div17,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n {.rem17 x, .div17 y} sig112_sub sub38\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n {.sub38.carry sel, .rem17 a, .sub38.sum b} mux_sig112 rem18,\n (.div17 sig112_shift_right1) div18,\n .sub38.carry b38\n }\n {\n .rem18 rem18,\n .div18 div18,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n {.rem18 x, .div18 y} sig112_sub sub37\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n {.sub37.carry sel, .rem18 a, .sub37.sum b} mux_sig112 rem19,\n (.div18 sig112_shift_right1) div19,\n .sub37.carry b37\n }\n {\n .rem19 rem19,\n .div19 div19,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n {.rem19 x, .div19 y} sig112_sub sub36\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n {.sub36.carry sel, .rem19 a, .sub36.sum b} mux_sig112 rem20,\n (.div19 sig112_shift_right1) div20,\n .sub36.carry b36\n }\n {\n .rem20 rem20,\n .div20 div20,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n {.rem20 x, .div20 y} sig112_sub sub35\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n {.sub35.carry sel, .rem20 a, .sub35.sum b} mux_sig112 rem21,\n (.div20 sig112_shift_right1) div21,\n .sub35.carry b35\n }\n {\n .rem21 rem21,\n .div21 div21,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n {.rem21 x, .div21 y} sig112_sub sub34\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n {.sub34.carry sel, .rem21 a, .sub34.sum b} mux_sig112 rem22,\n (.div21 sig112_shift_right1) div22,\n .sub34.carry b34\n }\n {\n .rem22 rem22,\n .div22 div22,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n {.rem22 x, .div22 y} sig112_sub sub33\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n {.sub33.carry sel, .rem22 a, .sub33.sum b} mux_sig112 rem23,\n (.div22 sig112_shift_right1) div23,\n .sub33.carry b33\n }\n {\n .rem23 rem23,\n .div23 div23,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n {.rem23 x, .div23 y} sig112_sub sub32\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n {.sub32.carry sel, .rem23 a, .sub32.sum b} mux_sig112 rem24,\n (.div23 sig112_shift_right1) div24,\n .sub32.carry b32\n }\n {\n .rem24 rem24,\n .div24 div24,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n {.rem24 x, .div24 y} sig112_sub sub31\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n {.sub31.carry sel, .rem24 a, .sub31.sum b} mux_sig112 rem25,\n (.div24 sig112_shift_right1) div25,\n .sub31.carry b31\n }\n {\n .rem25 rem25,\n .div25 div25,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n {.rem25 x, .div25 y} sig112_sub sub30\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n {.sub30.carry sel, .rem25 a, .sub30.sum b} mux_sig112 rem26,\n (.div25 sig112_shift_right1) div26,\n .sub30.carry b30\n }\n {\n .rem26 rem26,\n .div26 div26,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n {.rem26 x, .div26 y} sig112_sub sub29\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n {.sub29.carry sel, .rem26 a, .sub29.sum b} mux_sig112 rem27,\n (.div26 sig112_shift_right1) div27,\n .sub29.carry b29\n }\n {\n .rem27 rem27,\n .div27 div27,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n {.rem27 x, .div27 y} sig112_sub sub28\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n {.sub28.carry sel, .rem27 a, .sub28.sum b} mux_sig112 rem28,\n (.div27 sig112_shift_right1) div28,\n .sub28.carry b28\n }\n {\n .rem28 rem28,\n .div28 div28,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n {.rem28 x, .div28 y} sig112_sub sub27\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n {.sub27.carry sel, .rem28 a, .sub27.sum b} mux_sig112 rem29,\n (.div28 sig112_shift_right1) div29,\n .sub27.carry b27\n }\n {\n .rem29 rem29,\n .div29 div29,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n {.rem29 x, .div29 y} sig112_sub sub26\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n {.sub26.carry sel, .rem29 a, .sub26.sum b} mux_sig112 rem30,\n (.div29 sig112_shift_right1) div30,\n .sub26.carry b26\n }\n {\n .rem30 rem30,\n .div30 div30,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n {.rem30 x, .div30 y} sig112_sub sub25\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n {.sub25.carry sel, .rem30 a, .sub25.sum b} mux_sig112 rem31,\n (.div30 sig112_shift_right1) div31,\n .sub25.carry b25\n }\n {\n .rem31 rem31,\n .div31 div31,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n {.rem31 x, .div31 y} sig112_sub sub24\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n {.sub24.carry sel, .rem31 a, .sub24.sum b} mux_sig112 rem32,\n (.div31 sig112_shift_right1) div32,\n .sub24.carry b24\n }\n {\n .rem32 rem32,\n .div32 div32,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n {.rem32 x, .div32 y} sig112_sub sub23\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n {.sub23.carry sel, .rem32 a, .sub23.sum b} mux_sig112 rem33,\n (.div32 sig112_shift_right1) div33,\n .sub23.carry b23\n }\n {\n .rem33 rem33,\n .div33 div33,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n {.rem33 x, .div33 y} sig112_sub sub22\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n {.sub22.carry sel, .rem33 a, .sub22.sum b} mux_sig112 rem34,\n (.div33 sig112_shift_right1) div34,\n .sub22.carry b22\n }\n {\n .rem34 rem34,\n .div34 div34,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n {.rem34 x, .div34 y} sig112_sub sub21\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n {.sub21.carry sel, .rem34 a, .sub21.sum b} mux_sig112 rem35,\n (.div34 sig112_shift_right1) div35,\n .sub21.carry b21\n }\n {\n .rem35 rem35,\n .div35 div35,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n {.rem35 x, .div35 y} sig112_sub sub20\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n {.sub20.carry sel, .rem35 a, .sub20.sum b} mux_sig112 rem36,\n (.div35 sig112_shift_right1) div36,\n .sub20.carry b20\n }\n {\n .rem36 rem36,\n .div36 div36,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n {.rem36 x, .div36 y} sig112_sub sub19\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n {.sub19.carry sel, .rem36 a, .sub19.sum b} mux_sig112 rem37,\n (.div36 sig112_shift_right1) div37,\n .sub19.carry b19\n }\n {\n .rem37 rem37,\n .div37 div37,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n {.rem37 x, .div37 y} sig112_sub sub18\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n {.sub18.carry sel, .rem37 a, .sub18.sum b} mux_sig112 rem38,\n (.div37 sig112_shift_right1) div38,\n .sub18.carry b18\n }\n {\n .rem38 rem38,\n .div38 div38,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n {.rem38 x, .div38 y} sig112_sub sub17\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n {.sub17.carry sel, .rem38 a, .sub17.sum b} mux_sig112 rem39,\n (.div38 sig112_shift_right1) div39,\n .sub17.carry b17\n }\n {\n .rem39 rem39,\n .div39 div39,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n {.rem39 x, .div39 y} sig112_sub sub16\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n {.sub16.carry sel, .rem39 a, .sub16.sum b} mux_sig112 rem40,\n (.div39 sig112_shift_right1) div40,\n .sub16.carry b16\n }\n {\n .rem40 rem40,\n .div40 div40,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n {.rem40 x, .div40 y} sig112_sub sub15\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n {.sub15.carry sel, .rem40 a, .sub15.sum b} mux_sig112 rem41,\n (.div40 sig112_shift_right1) div41,\n .sub15.carry b15\n }\n {\n .rem41 rem41,\n .div41 div41,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n {.rem41 x, .div41 y} sig112_sub sub14\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n {.sub14.carry sel, .rem41 a, .sub14.sum b} mux_sig112 rem42,\n (.div41 sig112_shift_right1) div42,\n .sub14.carry b14\n }\n {\n .rem42 rem42,\n .div42 div42,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n {.rem42 x, .div42 y} sig112_sub sub13\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n {.sub13.carry sel, .rem42 a, .sub13.sum b} mux_sig112 rem43,\n (.div42 sig112_shift_right1) div43,\n .sub13.carry b13\n }\n {\n .rem43 rem43,\n .div43 div43,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n {.rem43 x, .div43 y} sig112_sub sub12\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n {.sub12.carry sel, .rem43 a, .sub12.sum b} mux_sig112 rem44,\n (.div43 sig112_shift_right1) div44,\n .sub12.carry b12\n }\n {\n .rem44 rem44,\n .div44 div44,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n {.rem44 x, .div44 y} sig112_sub sub11\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n {.sub11.carry sel, .rem44 a, .sub11.sum b} mux_sig112 rem45,\n (.div44 sig112_shift_right1) div45,\n .sub11.carry b11\n }\n {\n .rem45 rem45,\n .div45 div45,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n {.rem45 x, .div45 y} sig112_sub sub10\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n {.sub10.carry sel, .rem45 a, .sub10.sum b} mux_sig112 rem46,\n (.div45 sig112_shift_right1) div46,\n .sub10.carry b10\n }\n {\n .rem46 rem46,\n .div46 div46,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n {.rem46 x, .div46 y} sig112_sub sub9\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n {.sub9.carry sel, .rem46 a, .sub9.sum b} mux_sig112 rem47,\n (.div46 sig112_shift_right1) div47,\n .sub9.carry b9\n }\n {\n .rem47 rem47,\n .div47 div47,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n {.rem47 x, .div47 y} sig112_sub sub8\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n {.sub8.carry sel, .rem47 a, .sub8.sum b} mux_sig112 rem48,\n (.div47 sig112_shift_right1) div48,\n .sub8.carry b8\n }\n {\n .rem48 rem48,\n .div48 div48,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n {.rem48 x, .div48 y} sig112_sub sub7\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n {.sub7.carry sel, .rem48 a, .sub7.sum b} mux_sig112 rem49,\n (.div48 sig112_shift_right1) div49,\n .sub7.carry b7\n }\n {\n .rem49 rem49,\n .div49 div49,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n {.rem49 x, .div49 y} sig112_sub sub6\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n {.sub6.carry sel, .rem49 a, .sub6.sum b} mux_sig112 rem50,\n (.div49 sig112_shift_right1) div50,\n .sub6.carry b6\n }\n {\n .rem50 rem50,\n .div50 div50,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n {.rem50 x, .div50 y} sig112_sub sub5\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n {.sub5.carry sel, .rem50 a, .sub5.sum b} mux_sig112 rem51,\n (.div50 sig112_shift_right1) div51,\n .sub5.carry b5\n }\n {\n .rem51 rem51,\n .div51 div51,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n {.rem51 x, .div51 y} sig112_sub sub4\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n {.sub4.carry sel, .rem51 a, .sub4.sum b} mux_sig112 rem52,\n (.div51 sig112_shift_right1) div52,\n .sub4.carry b4\n }\n {\n .rem52 rem52,\n .div52 div52,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n {.rem52 x, .div52 y} sig112_sub sub3\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n {.sub3.carry sel, .rem52 a, .sub3.sum b} mux_sig112 rem53,\n (.div52 sig112_shift_right1) div53,\n .sub3.carry b3\n }\n {\n .rem53 rem53,\n .div53 div53,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n {.rem53 x, .div53 y} sig112_sub sub2\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n {.sub2.carry sel, .rem53 a, .sub2.sum b} mux_sig112 rem54,\n (.div53 sig112_shift_right1) div54,\n .sub2.carry b2\n }\n {\n .rem54 rem54,\n .div54 div54,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n .b2 b2,\n {.rem54 x, .div54 y} sig112_sub sub1\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n .b2 b2,\n {.sub1.carry sel, .rem54 a, .sub1.sum b} mux_sig112 rem55,\n .sub1.carry b1\n }\n {\n .rem55 rem55,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n .b2 b2,\n .b1 b1,\n (.rem55 sig112_any1) sticky\n }\n {\n .rem55 rem,\n .sticky sticky,\n {.b55 55, .b54 54, .b53 53, .b52 52, .b51 51, .b50 50, .b49 49, .b48 48, .b47 47, .b46 46, .b45 45, .b44 44, .b43 43, .b42 42, .b41 41, .b40 40, .b39 39, .b38 38, .b37 37, .b36 36, .b35 35, .b34 34, .b33 33, .b32 32, .b31 31, .b30 30, .b29 29, .b28 28, .b27 27, .b26 26, .b25 25, .b24 24, .b23 23, .b22 22, .b21 21, .b20 20, .b19 19, .b18 18, .b17 17, .b16 16, .b15 15, .b14 14, .b13 13, .b12 12, .b11 11, .b10 10, .b9 9, .b8 8, .b7 7, .b6 6, .b5 5, .b4 4, .b3 3, .b2 2, .b1 1, .sticky 0} sig\n }\n .sig $sig56;\nsig56_from_sig112_shift55 = $sig112\n {\n .110 55,\n .109 54,\n .108 53,\n .107 52,\n .106 51,\n .105 50,\n .104 49,\n .103 48,\n .102 47,\n .101 46,\n .100 45,\n .99 44,\n .98 43,\n .97 42,\n .96 41,\n .95 40,\n .94 39,\n .93 38,\n .92 37,\n .91 36,\n .90 35,\n .89 34,\n .88 33,\n .87 32,\n .86 31,\n .85 30,\n .84 29,\n .83 28,\n .82 27,\n .81 26,\n .80 25,\n .79 24,\n .78 23,\n .77 22,\n .76 21,\n .75 20,\n .74 19,\n .73 18,\n .72 17,\n .71 16,\n .70 15,\n .69 14,\n .68 13,\n .67 12,\n .66 11,\n .65 10,\n .64 9,\n .63 8,\n .62 7,\n .61 6,\n .60 5,\n .59 4,\n .58 3,\n .57 2,\n .56 1,\n sig112_low56_any1 0\n } $sig56;\nsig56_from_sig112_shift56 = $sig112\n {\n .111 55,\n .110 54,\n .109 53,\n .108 52,\n .107 51,\n .106 50,\n .105 49,\n .104 48,\n .103 47,\n .102 46,\n .101 45,\n .100 44,\n .99 43,\n .98 42,\n .97 41,\n .96 40,\n .95 39,\n .94 38,\n .93 37,\n .92 36,\n .91 35,\n .90 34,\n .89 33,\n .88 32,\n .87 31,\n .86 30,\n .85 29,\n .84 28,\n .83 27,\n .82 26,\n .81 25,\n .80 24,\n .79 23,\n .78 22,\n .77 21,\n .76 20,\n .75 19,\n .74 18,\n .73 17,\n .72 16,\n .71 15,\n .70 14,\n .69 13,\n .68 12,\n .67 11,\n .66 10,\n .65 9,\n .64 8,\n .63 7,\n .62 6,\n .61 5,\n .60 4,\n .59 3,\n .58 2,\n .57 1,\n { .56 x, sig112_low56_any1 y } or_bit 0\n } $sig56;\n\nshift_right_sig56_1 = $sig56\n {\n {.0 x, .1 y} or_bit 0,\n .2 1,\n .3 2,\n .4 3,\n .5 4,\n .6 5,\n .7 6,\n .8 7,\n .9 8,\n .10 9,\n .11 10,\n .12 11,\n .13 12,\n .14 13,\n .15 14,\n .16 15,\n .17 16,\n .18 17,\n .19 18,\n .20 19,\n .21 20,\n .22 21,\n .23 22,\n .24 23,\n .25 24,\n .26 25,\n .27 26,\n .28 27,\n .29 28,\n .30 29,\n .31 30,\n .32 31,\n .33 32,\n .34 33,\n .35 34,\n .36 35,\n .37 36,\n .38 37,\n .39 38,\n .40 39,\n .41 40,\n .42 41,\n .43 42,\n .44 43,\n .45 44,\n .46 45,\n .47 46,\n .48 47,\n .49 48,\n .50 49,\n .51 50,\n .52 51,\n .53 52,\n .54 53,\n .55 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_2 = $sig56\n {\n {{.0 x, .1 y} or_bit x, .2 y} or_bit 0,\n .3 1,\n .4 2,\n .5 3,\n .6 4,\n .7 5,\n .8 6,\n .9 7,\n .10 8,\n .11 9,\n .12 10,\n .13 11,\n .14 12,\n .15 13,\n .16 14,\n .17 15,\n .18 16,\n .19 17,\n .20 18,\n .21 19,\n .22 20,\n .23 21,\n .24 22,\n .25 23,\n .26 24,\n .27 25,\n .28 26,\n .29 27,\n .30 28,\n .31 29,\n .32 30,\n .33 31,\n .34 32,\n .35 33,\n .36 34,\n .37 35,\n .38 36,\n .39 37,\n .40 38,\n .41 39,\n .42 40,\n .43 41,\n .44 42,\n .45 43,\n .46 44,\n .47 45,\n .48 46,\n .49 47,\n .50 48,\n .51 49,\n .52 50,\n .53 51,\n .54 52,\n .55 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_4 = $sig56\n {\n {{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit 0,\n .5 1,\n .6 2,\n .7 3,\n .8 4,\n .9 5,\n .10 6,\n .11 7,\n .12 8,\n .13 9,\n .14 10,\n .15 11,\n .16 12,\n .17 13,\n .18 14,\n .19 15,\n .20 16,\n .21 17,\n .22 18,\n .23 19,\n .24 20,\n .25 21,\n .26 22,\n .27 23,\n .28 24,\n .29 25,\n .30 26,\n .31 27,\n .32 28,\n .33 29,\n .34 30,\n .35 31,\n .36 32,\n .37 33,\n .38 34,\n .39 35,\n .40 36,\n .41 37,\n .42 38,\n .43 39,\n .44 40,\n .45 41,\n .46 42,\n .47 43,\n .48 44,\n .49 45,\n .50 46,\n .51 47,\n .52 48,\n .53 49,\n .54 50,\n .55 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_8 = $sig56\n {\n {{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit 0,\n .9 1,\n .10 2,\n .11 3,\n .12 4,\n .13 5,\n .14 6,\n .15 7,\n .16 8,\n .17 9,\n .18 10,\n .19 11,\n .20 12,\n .21 13,\n .22 14,\n .23 15,\n .24 16,\n .25 17,\n .26 18,\n .27 19,\n .28 20,\n .29 21,\n .30 22,\n .31 23,\n .32 24,\n .33 25,\n .34 26,\n .35 27,\n .36 28,\n .37 29,\n .38 30,\n .39 31,\n .40 32,\n .41 33,\n .42 34,\n .43 35,\n .44 36,\n .45 37,\n .46 38,\n .47 39,\n .48 40,\n .49 41,\n .50 42,\n .51 43,\n .52 44,\n .53 45,\n .54 46,\n .55 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_16 = $sig56\n {\n {{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit 0,\n .17 1,\n .18 2,\n .19 3,\n .20 4,\n .21 5,\n .22 6,\n .23 7,\n .24 8,\n .25 9,\n .26 10,\n .27 11,\n .28 12,\n .29 13,\n .30 14,\n .31 15,\n .32 16,\n .33 17,\n .34 18,\n .35 19,\n .36 20,\n .37 21,\n .38 22,\n .39 23,\n .40 24,\n .41 25,\n .42 26,\n .43 27,\n .44 28,\n .45 29,\n .46 30,\n .47 31,\n .48 32,\n .49 33,\n .50 34,\n .51 35,\n .52 36,\n .53 37,\n .54 38,\n .55 39,\n 0 40,\n 0 41,\n 0 42,\n 0 43,\n 0 44,\n 0 45,\n 0 46,\n 0 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_32 = $sig56\n {\n {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit x, .17 y} or_bit x, .18 y} or_bit x, .19 y} or_bit x, .20 y} or_bit x, .21 y} or_bit x, .22 y} or_bit x, .23 y} or_bit x, .24 y} or_bit x, .25 y} or_bit x, .26 y} or_bit x, .27 y} or_bit x, .28 y} or_bit x, .29 y} or_bit x, .30 y} or_bit x, .31 y} or_bit x, .32 y} or_bit 0,\n .33 1,\n .34 2,\n .35 3,\n .36 4,\n .37 5,\n .38 6,\n .39 7,\n .40 8,\n .41 9,\n .42 10,\n .43 11,\n .44 12,\n .45 13,\n .46 14,\n .47 15,\n .48 16,\n .49 17,\n .50 18,\n .51 19,\n .52 20,\n .53 21,\n .54 22,\n .55 23,\n 0 24,\n 0 25,\n 0 26,\n 0 27,\n 0 28,\n 0 29,\n 0 30,\n 0 31,\n 0 32,\n 0 33,\n 0 34,\n 0 35,\n 0 36,\n 0 37,\n 0 38,\n 0 39,\n 0 40,\n 0 41,\n 0 42,\n 0 43,\n 0 44,\n 0 45,\n 0 46,\n 0 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nmux_sig56 = ${bit sel, sig56 a, sig56 b}\n {\n {.sel sel, .a .0 a, .b .0 b} mux_bit 0,\n {.sel sel, .a .1 a, .b .1 b} mux_bit 1,\n {.sel sel, .a .2 a, .b .2 b} mux_bit 2,\n {.sel sel, .a .3 a, .b .3 b} mux_bit 3,\n {.sel sel, .a .4 a, .b .4 b} mux_bit 4,\n {.sel sel, .a .5 a, .b .5 b} mux_bit 5,\n {.sel sel, .a .6 a, .b .6 b} mux_bit 6,\n {.sel sel, .a .7 a, .b .7 b} mux_bit 7,\n {.sel sel, .a .8 a, .b .8 b} mux_bit 8,\n {.sel sel, .a .9 a, .b .9 b} mux_bit 9,\n {.sel sel, .a .10 a, .b .10 b} mux_bit 10,\n {.sel sel, .a .11 a, .b .11 b} mux_bit 11,\n {.sel sel, .a .12 a, .b .12 b} mux_bit 12,\n {.sel sel, .a .13 a, .b .13 b} mux_bit 13,\n {.sel sel, .a .14 a, .b .14 b} mux_bit 14,\n {.sel sel, .a .15 a, .b .15 b} mux_bit 15,\n {.sel sel, .a .16 a, .b .16 b} mux_bit 16,\n {.sel sel, .a .17 a, .b .17 b} mux_bit 17,\n {.sel sel, .a .18 a, .b .18 b} mux_bit 18,\n {.sel sel, .a .19 a, .b .19 b} mux_bit 19,\n {.sel sel, .a .20 a, .b .20 b} mux_bit 20,\n {.sel sel, .a .21 a, .b .21 b} mux_bit 21,\n {.sel sel, .a .22 a, .b .22 b} mux_bit 22,\n {.sel sel, .a .23 a, .b .23 b} mux_bit 23,\n {.sel sel, .a .24 a, .b .24 b} mux_bit 24,\n {.sel sel, .a .25 a, .b .25 b} mux_bit 25,\n {.sel sel, .a .26 a, .b .26 b} mux_bit 26,\n {.sel sel, .a .27 a, .b .27 b} mux_bit 27,\n {.sel sel, .a .28 a, .b .28 b} mux_bit 28,\n {.sel sel, .a .29 a, .b .29 b} mux_bit 29,\n {.sel sel, .a .30 a, .b .30 b} mux_bit 30,\n {.sel sel, .a .31 a, .b .31 b} mux_bit 31,\n {.sel sel, .a .32 a, .b .32 b} mux_bit 32,\n {.sel sel, .a .33 a, .b .33 b} mux_bit 33,\n {.sel sel, .a .34 a, .b .34 b} mux_bit 34,\n {.sel sel, .a .35 a, .b .35 b} mux_bit 35,\n {.sel sel, .a .36 a, .b .36 b} mux_bit 36,\n {.sel sel, .a .37 a, .b .37 b} mux_bit 37,\n {.sel sel, .a .38 a, .b .38 b} mux_bit 38,\n {.sel sel, .a .39 a, .b .39 b} mux_bit 39,\n {.sel sel, .a .40 a, .b .40 b} mux_bit 40,\n {.sel sel, .a .41 a, .b .41 b} mux_bit 41,\n {.sel sel, .a .42 a, .b .42 b} mux_bit 42,\n {.sel sel, .a .43 a, .b .43 b} mux_bit 43,\n {.sel sel, .a .44 a, .b .44 b} mux_bit 44,\n {.sel sel, .a .45 a, .b .45 b} mux_bit 45,\n {.sel sel, .a .46 a, .b .46 b} mux_bit 46,\n {.sel sel, .a .47 a, .b .47 b} mux_bit 47,\n {.sel sel, .a .48 a, .b .48 b} mux_bit 48,\n {.sel sel, .a .49 a, .b .49 b} mux_bit 49,\n {.sel sel, .a .50 a, .b .50 b} mux_bit 50,\n {.sel sel, .a .51 a, .b .51 b} mux_bit 51,\n {.sel sel, .a .52 a, .b .52 b} mux_bit 52,\n {.sel sel, .a .53 a, .b .53 b} mux_bit 53,\n {.sel sel, .a .54 a, .b .54 b} mux_bit 54,\n {.sel sel, .a .55 a, .b .55 b} mux_bit 55\n } $sig56;\n\nshift_right_sig56 = ${sig56 x, shift6 s}\n {.x x, .s s, (.x shift_right_sig56_1) sh1}\n {.s s, {.s .0 sel, .x a, .sh1 b} mux_sig56 st1}\n {.s s, .st1 st1, (.st1 shift_right_sig56_2) sh2}\n {.s s, {.s .1 sel, .st1 a, .sh2 b} mux_sig56 st2}\n {.s s, .st2 st2, (.st2 shift_right_sig56_4) sh4}\n {.s s, {.s .2 sel, .st2 a, .sh4 b} mux_sig56 st3}\n {.s s, .st3 st3, (.st3 shift_right_sig56_8) sh8}\n {.s s, {.s .3 sel, .st3 a, .sh8 b} mux_sig56 st4}\n {.s s, .st4 st4, (.st4 shift_right_sig56_16) sh16}\n {.s s, {.s .4 sel, .st4 a, .sh16 b} mux_sig56 st5}\n {.s s, .st5 st5, (.st5 shift_right_sig56_32) sh32}\n {.s s, {.s .5 sel, .st5 a, .sh32 b} mux_sig56 st6}\n .st6 $sig56;\n\n$norm_left = {sig56 sig, exp11 exp};\n\nmux_exp11 = ${bit sel, exp11 a, exp11 b}\n {\n {.sel sel, .a .0 a, .b .0 b} mux_bit 0,\n {.sel sel, .a .1 a, .b .1 b} mux_bit 1,\n {.sel sel, .a .2 a, .b .2 b} mux_bit 2,\n {.sel sel, .a .3 a, .b .3 b} mux_bit 3,\n {.sel sel, .a .4 a, .b .4 b} mux_bit 4,\n {.sel sel, .a .5 a, .b .5 b} mux_bit 5,\n {.sel sel, .a .6 a, .b .6 b} mux_bit 6,\n {.sel sel, .a .7 a, .b .7 b} mux_bit 7,\n {.sel sel, .a .8 a, .b .8 b} mux_bit 8,\n {.sel sel, .a .9 a, .b .9 b} mux_bit 9,\n {.sel sel, .a .10 a, .b .10 b} mux_bit 10\n } $exp11;\n\nexp1 = {} {1 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10} $exp11;\n\n# exponent = 1023 (bias): 0b01111111111\nexp_1023 = {}\n { 0 10,\n 1 9, 1 8, 1 7, 1 6, 1 5, 1 4, 1 3, 1 2, 1 1, 1 0\n } $exp11;\n\nexp11_add_sum = ${exp11 x, exp11 y}\n {.x x, .y y} exp11_add .sum\n $exp11;\n\nexp11_inc = $exp11\n {() x, () exp1 y} exp11_add_sum\n $exp11;\n\nexp11_dec = $exp11\n {() x, () exp1 y} exp11_sub_sum\n $exp11;\n\nexp_nonzero_bit = $exp11\n <\n {zero_exponent? if, 0 then} .then,\n 1\n > $bit;\n\nshift_left_sig56_1 = $sig56\n {\n 0 0,\n .0 1,\n .1 2,\n .2 3,\n .3 4,\n .4 5,\n .5 6,\n .6 7,\n .7 8,\n .8 9,\n .9 10,\n .10 11,\n .11 12,\n .12 13,\n .13 14,\n .14 15,\n .15 16,\n .16 17,\n .17 18,\n .18 19,\n .19 20,\n .20 21,\n .21 22,\n .22 23,\n .23 24,\n .24 25,\n .25 26,\n .26 27,\n .27 28,\n .28 29,\n .29 30,\n .30 31,\n .31 32,\n .32 33,\n .33 34,\n .34 35,\n .35 36,\n .36 37,\n .37 38,\n .38 39,\n .39 40,\n .40 41,\n .41 42,\n .42 43,\n .43 44,\n .44 45,\n .45 46,\n .46 47,\n .47 48,\n .48 49,\n .49 50,\n .50 51,\n .51 52,\n .52 53,\n .53 54,\n .54 55\n } $sig56;\n\nsig56_any1 = $sig56\n {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit x, .17 y} or_bit x, .18 y} or_bit x, .19 y} or_bit x, .20 y} or_bit x, .21 y} or_bit x, .22 y} or_bit x, .23 y} or_bit x, .24 y} or_bit x, .25 y} or_bit x, .26 y} or_bit x, .27 y} or_bit x, .28 y} or_bit x, .29 y} or_bit x, .30 y} or_bit x, .31 y} or_bit x, .32 y} or_bit x, .33 y} or_bit x, .34 y} or_bit x, .35 y} or_bit x, .36 y} or_bit x, .37 y} or_bit x, .38 y} or_bit x, .39 y} or_bit x, .40 y} or_bit x, .41 y} or_bit x, .42 y} or_bit x, .43 y} or_bit x, .44 y} or_bit x, .45 y} or_bit x, .46 y} or_bit x, .47 y} or_bit x, .48 y} or_bit x, .49 y} or_bit x, .50 y} or_bit x, .51 y} or_bit x, .52 y} or_bit x, .53 y} or_bit x, .54 y} or_bit x, .55 y} or_bit\n $bit;\n\nsig56_zero_bit = $sig56\n <\n {sig56_any1 /0 if, 1 then} .then,\n 0\n > $bit;\n\nfrac52_from_sig56 = $sig56\n { .3 0, .4 1, .5 2, .6 3, .7 4, .8 5, .9 6, .10 7, .11 8, .12 9,\n .13 10, .14 11, .15 12, .16 13, .17 14, .18 15, .19 16, .20 17, .21 18, .22 19,\n .23 20, .24 21, .25 22, .26 23, .27 24, .28 25, .29 26, .30 27, .31 28, .32 29,\n .33 30, .34 31, .35 32, .36 33, .37 34, .38 35, .39 36, .40 37, .41 38, .42 39,\n .43 40, .44 41, .45 42, .46 43, .47 44, .48 45, .49 46, .50 47, .51 48, .52 49,\n .53 50, .54 51 }\n $frac52;\n\nnormalize_left_step = $norm_left\n {\n .sig sig,\n .exp exp,\n (.sig shift_left_sig56_1) sh,\n (.exp exp11_dec) exp_dec,\n (.exp exp_nonzero_bit) exp_nz,\n .sig .55 msb\n }\n {\n .sig sig,\n .exp exp,\n .sh sh,\n .exp_dec exp_dec,\n .exp_nz exp_nz,\n (.msb not_bit) msb0\n }\n {\n .sig sig,\n .exp exp,\n .exp_dec exp_dec,\n .msb0 msb0,\n .exp_nz exp_nz,\n .sh sh,\n {.msb0 x, .exp_nz y} and_bit shift_en\n }\n {\n .exp exp,\n .sh sh,\n .exp_dec exp_dec,\n .shift_en shift_en,\n {.shift_en sel, .sig a, .sh b} mux_sig56 sig_out\n }\n {\n .exp_dec exp_dec,\n .shift_en shift_en,\n .sig_out sig_out,\n {.shift_en sel, .exp a, .exp_dec b} mux_exp11 exp_out\n }\n { .sig_out sig, .exp_out exp }\n $norm_left;\n\nnormalize_left = $norm_left\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n $norm_left;\n\n\nshift6_from_exp11 = $exp11\n {\n {{{{.6 x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit high,\n .0 b0, .1 b1, .2 b2, .3 b3, .4 b4, .5 b5\n }\n <\n {.high 1? if, {1 0, 1 1, 1 2, 1 3, 1 4, 1 5} then} .then,\n {.high 0? if, {.b0 0, .b1 1, .b2 2, .b3 3, .b4 4, .b5 5} then} .then\n >\n $shift6;\n\nsig56_from_float64 = $float64\n <\n {.exponent zero_exponent? if,\n {\n 0 55,\n .fraction .51 54,\n .fraction .50 53,\n .fraction .49 52,\n .fraction .48 51,\n .fraction .47 50,\n .fraction .46 49,\n .fraction .45 48,\n .fraction .44 47,\n .fraction .43 46,\n .fraction .42 45,\n .fraction .41 44,\n .fraction .40 43,\n .fraction .39 42,\n .fraction .38 41,\n .fraction .37 40,\n .fraction .36 39,\n .fraction .35 38,\n .fraction .34 37,\n .fraction .33 36,\n .fraction .32 35,\n .fraction .31 34,\n .fraction .30 33,\n .fraction .29 32,\n .fraction .28 31,\n .fraction .27 30,\n .fraction .26 29,\n .fraction .25 28,\n .fraction .24 27,\n .fraction .23 26,\n .fraction .22 25,\n .fraction .21 24,\n .fraction .20 23,\n .fraction .19 22,\n .fraction .18 21,\n .fraction .17 20,\n .fraction .16 19,\n .fraction .15 18,\n .fraction .14 17,\n .fraction .13 16,\n .fraction .12 15,\n .fraction .11 14,\n .fraction .10 13,\n .fraction .9 12,\n .fraction .8 11,\n .fraction .7 10,\n .fraction .6 9,\n .fraction .5 8,\n .fraction .4 7,\n .fraction .3 6,\n .fraction .2 5,\n .fraction .1 4,\n .fraction .0 3,\n 0 2, 0 1, 0 0\n } then} .then,\n { {\n 1 55,\n .fraction .51 54,\n .fraction .50 53,\n .fraction .49 52,\n .fraction .48 51,\n .fraction .47 50,\n .fraction .46 49,\n .fraction .45 48,\n .fraction .44 47,\n .fraction .43 46,\n .fraction .42 45,\n .fraction .41 44,\n .fraction .40 43,\n .fraction .39 42,\n .fraction .38 41,\n .fraction .37 40,\n .fraction .36 39,\n .fraction .35 38,\n .fraction .34 37,\n .fraction .33 36,\n .fraction .32 35,\n .fraction .31 34,\n .fraction .30 33,\n .fraction .29 32,\n .fraction .28 31,\n .fraction .27 30,\n .fraction .26 29,\n .fraction .25 28,\n .fraction .24 27,\n .fraction .23 26,\n .fraction .22 25,\n .fraction .21 24,\n .fraction .20 23,\n .fraction .19 22,\n .fraction .18 21,\n .fraction .17 20,\n .fraction .16 19,\n .fraction .15 18,\n .fraction .14 17,\n .fraction .13 16,\n .fraction .12 15,\n .fraction .11 14,\n .fraction .10 13,\n .fraction .9 12,\n .fraction .8 11,\n .fraction .7 10,\n .fraction .6 9,\n .fraction .5 8,\n .fraction .4 7,\n .fraction .3 6,\n .fraction .2 5,\n .fraction .1 4,\n .fraction .0 3,\n 0 2, 0 1, 0 0\n } then} .then\n > $sig56;\n\nexp11_max = $exp_pair\n <\n {gt_exponent? if, .x then} .then,\n {lt_exponent? if, .y then} .then,\n {eq_exponent? if, .x then} .then\n > $exp11;\n\nexp11_abs_diff = $exp_pair\n <\n {gt_exponent? if, {.x x, .y y} exp11_sub_sum then} .then,\n {lt_exponent? if, {.y x, .x y} exp11_sub_sum then} .then,\n {eq_exponent? if, exp0 then} .then\n > $exp11;\n\nexp11_adjust = $exp11\n {exp_nonzero_bit sel, exp1 a, () b}\n mux_exp11\n $exp11;\n\nexp_gt_bit = $exp_pair\n <\n {cmp_exponent /gt if, 1 then} .then,\n 0\n > $bit;\n\nexp_lt_bit = $exp_pair\n <\n {cmp_exponent /lt if, 1 then} .then,\n 0\n > $bit;\n\nmag_gt_bit = $float_pair\n <\n {gt_magnitude_float64? if, 1 then} .then,\n 0\n > $bit;\n\nmag_eq_bit = $float_pair\n <\n {{.x .exponent x, .y .exponent y} eq_exponent? ife,\n {.x .fraction x, .y .fraction y} eq_fraction? iff,\n 1 then} .then,\n 0\n > $bit;\n\nsig56_shift_right_carry = ${sig56 sum, bit carry}\n {\n .sum sum,\n .carry carry,\n {.sum .1 x, .sum .0 y} or_bit bit0\n }\n {\n .carry 55,\n .sum .55 54,\n .sum .54 53,\n .sum .53 52,\n .sum .52 51,\n .sum .51 50,\n .sum .50 49,\n .sum .49 48,\n .sum .48 47,\n .sum .47 46,\n .sum .46 45,\n .sum .45 44,\n .sum .44 43,\n .sum .43 42,\n .sum .42 41,\n .sum .41 40,\n .sum .40 39,\n .sum .39 38,\n .sum .38 37,\n .sum .37 36,\n .sum .36 35,\n .sum .35 34,\n .sum .34 33,\n .sum .33 32,\n .sum .32 31,\n .sum .31 30,\n .sum .30 29,\n .sum .29 28,\n .sum .28 27,\n .sum .27 26,\n .sum .26 25,\n .sum .25 24,\n .sum .24 23,\n .sum .23 22,\n .sum .22 21,\n .sum .21 20,\n .sum .20 19,\n .sum .19 18,\n .sum .18 17,\n .sum .17 16,\n .sum .16 15,\n .sum .15 14,\n .sum .14 13,\n .sum .13 12,\n .sum .12 11,\n .sum .11 10,\n .sum .10 9,\n .sum .9 8,\n .sum .8 7,\n .sum .7 6,\n .sum .6 5,\n .sum .5 4,\n .sum .4 3,\n .sum .3 2,\n .sum .2 1,\n .bit0 0\n } $sig56;\n\nsig56_drop_grs = $sig56\n {\n 0 0,\n 0 1,\n 0 2,\n .3 3,\n .4 4,\n .5 5,\n .6 6,\n .7 7,\n .8 8,\n .9 9,\n .10 10,\n .11 11,\n .12 12,\n .13 13,\n .14 14,\n .15 15,\n .16 16,\n .17 17,\n .18 18,\n .19 19,\n .20 20,\n .21 21,\n .22 22,\n .23 23,\n .24 24,\n .25 25,\n .26 26,\n .27 27,\n .28 28,\n .29 29,\n .30 30,\n .31 31,\n .32 32,\n .33 33,\n .34 34,\n .35 35,\n .36 36,\n .37 37,\n .38 38,\n .39 39,\n .40 40,\n .41 41,\n .42 42,\n .43 43,\n .44 44,\n .45 45,\n .46 46,\n .47 47,\n .48 48,\n .49 49,\n .50 50,\n .51 51,\n .52 52,\n .53 53,\n .54 54,\n .55 55\n } $sig56;\n\nsig56_ulp = {} { 0 0, 0 1, 0 2, 1 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15, 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31, 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47, 0 48, 0 49, 0 50, 0 51, 0 52, 0 53, 0 54, 0 55 } $sig56;\n\nflags_add_from_bits = ${bit overflow, bit underflow, bit inexact}\n <\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_add;\n\nflags_sub_from_bits = ${bit overflow, bit underflow, bit inexact}\n <\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_sub;\n\nflags_mul_from_bits = ${bit overflow, bit underflow, bit inexact}\n <\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_mul;\n\nflags_div_from_bits = ${bit overflow, bit underflow, bit inexact, bit div_by_zero}\n <\n {.div_by_zero 1? if, div_by_zero then} .then,\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_div;\n\nflags_sub_from_add = $flags_add\n <\n {/none if, none then} .then,\n {/invalid if, invalid then} .then,\n {/overflow if, overflow then} .then,\n {/underflow if, underflow then} .then,\n {/inexact if, inexact then} .then\n > $flags_sub;\n\nexp_all_ones_bit = $exp11\n <\n {all_ones_exponent? if, 1 then} .then,\n 0\n > $bit;\n\nexp_zero_bit = $exp11\n <\n {zero_exponent? if, 1 then} .then,\n 0\n > $bit;\n\nunderflow_bit_of = ${exp11 exp, bit inexact}\n <\n {.exp zero_exponent? ife, .inexact 1? ifi, 1 then} .then,\n 0\n > $bit;\n\n\n$round_in = {sig56 sig, exp11 exp};\n$round_out = {sig56 sig, exp11 exp, bit inexact};\n\nsign_eq_bit = $sign_pair\n <\n {eq_sign? if, 1 then} .then,\n 0\n > $bit;\n\nmux_sign = ${bit sel, sign a, sign b}\n <\n {.sel 0? if, .a then} .then,\n {.sel 1? if, .b then} .then\n > $sign;\n\nround_sig56 = $round_in\n {\n .sig sig,\n .exp exp,\n .sig .2 guard,\n .sig .1 round,\n .sig .0 sticky\n }\n {\n .sig sig,\n .exp exp,\n .guard guard,\n .round round,\n .sticky sticky,\n {.guard x, {{.round x, .sticky y} or_bit x, .sig .3 y} or_bit y} and_bit inc,\n {.guard x, {.round x, .sticky y} or_bit y} or_bit inexact\n }\n {\n .sig sig,\n .exp exp,\n .inc inc,\n .inexact inexact,\n (.sig sig56_drop_grs) trunc,\n () sig56_ulp ulp\n }\n {\n .exp exp,\n .inc inc,\n .inexact inexact,\n .trunc trunc,\n .ulp ulp,\n {.trunc x, .ulp y} sig56_add sum1\n }\n {\n .exp exp,\n .inc inc,\n .inexact inexact,\n .trunc trunc,\n .sum1 sum1,\n {.inc sel, .trunc a, .sum1.sum b} mux_sig56 sig_inc,\n .sum1.carry carry_inc,\n (.exp exp11_inc) exp_inc\n }\n {\n .sig_inc sig_inc,\n .exp exp,\n .inexact inexact,\n .carry_inc carry_inc,\n .exp_inc exp_inc,\n {.carry_inc sel, .sig_inc a, {.sig_inc sum, .carry_inc carry} sig56_shift_right_carry b} mux_sig56 sig_out,\n {.carry_inc sel, .exp a, .exp_inc b} mux_exp11 exp_out\n }\n { .sig_out sig, .exp_out exp, .inexact inexact }\n $round_out;\n\n\n\n+ = {} |+ $sign;\n- = {} |- $sign;\n\neq = {} |eq $cmp_state;\ngt = {} |gt $cmp_state;\nlt = {} |lt $cmp_state;\n\neq_exact_cmp = {} |eq_exact $cmp;\neq_zero_cmp = {} |eq_zero $cmp;\ngt_cmp = {} |gt $cmp;\nlt_cmp = {} |lt $cmp;\nunordered_nan_cmp = {} |unordered_nan $cmp;\n\n0? = $bit {/0 if, () then} .then $bit;\n1? = $bit {/1 if, () then} .then $bit;\n\n+? = $sign {/+ if, () then} .then $sign;\n-? = $sign {/- if, () then} .then $sign;\n\neq_bit? = $bit_pair\n <\n {.x 0? ifx, .y 0? ify, () then} .then,\n {.x 1? ifx, .y 1? ify, () then} .then\n > $bit_pair;\n\ngt_bit? = $bit_pair\n {.x 1? ifx, .y 0? ify, () then} .then\n $bit_pair;\n\nlt_bit? = $bit_pair\n {.x 0? ifx, .y 1? ify, () then} .then\n $bit_pair;\n\neq_sign? = $sign_pair\n <\n {.x +? ifx, .y +? ify, () then} .then,\n {.x -? ifx, .y -? ify, () then} .then\n > $sign_pair;\n\nzero_exponent? = $exp11\n {.0 0? if0, .1 0? if1, .2 0? if2, .3 0? if3, .4 0? if4, .5 0? if5, .6 0? if6, .7 0? if7, .8 0? if8, .9 0? if9, .10 0? if10, () then} .then\n $exp11;\n\nall_ones_exponent? = $exp11\n {.0 1? if0, .1 1? if1, .2 1? if2, .3 1? if3, .4 1? if4, .5 1? if5, .6 1? if6, .7 1? if7, .8 1? if8, .9 1? if9, .10 1? if10, () then} .then\n $exp11;\n\nnot_all_ones_exponent? = $exp11\n {<.10 0?, .9 0?, .8 0?, .7 0?, .6 0?, .5 0?, .4 0?, .3 0?, .2 0?, .1 0?, .0 0?> if, () then} .then\n $exp11;\n\nzero_fraction? = $frac52\n {.51 0? if51, .50 0? if50, .49 0? if49, .48 0? if48, .47 0? if47, .46 0? if46, .45 0? if45, .44 0? if44, .43 0? if43, .42 0? if42,\n .41 0? if41, .40 0? if40, .39 0? if39, .38 0? if38, .37 0? if37, .36 0? if36, .35 0? if35, .34 0? if34, .33 0? if33, .32 0? if32,\n .31 0? if31, .30 0? if30, .29 0? if29, .28 0? if28, .27 0? if27, .26 0? if26, .25 0? if25, .24 0? if24, .23 0? if23, .22 0? if22,\n .21 0? if21, .20 0? if20, .19 0? if19, .18 0? if18, .17 0? if17, .16 0? if16, .15 0? if15, .14 0? if14, .13 0? if13, .12 0? if12,\n .11 0? if11, .10 0? if10, .9 0? if9, .8 0? if8, .7 0? if7, .6 0? if6, .5 0? if5, .4 0? if4, .3 0? if3, .2 0? if2, .1 0? if1, .0 0? if0,\n () then} .then\n $frac52;\n\nnonzero_fraction? = $frac52\n {<.51 1?, .50 1?, .49 1?, .48 1?, .47 1?, .46 1?, .45 1?, .44 1?, .43 1?, .42 1?,\n .41 1?, .40 1?, .39 1?, .38 1?, .37 1?, .36 1?, .35 1?, .34 1?, .33 1?, .32 1?,\n .31 1?, .30 1?, .29 1?, .28 1?, .27 1?, .26 1?, .25 1?, .24 1?, .23 1?, .22 1?,\n .21 1?, .20 1?, .19 1?, .18 1?, .17 1?, .16 1?, .15 1?, .14 1?, .13 1?, .12 1?,\n .11 1?, .10 1?, .9 1?, .8 1?, .7 1?, .6 1?, .5 1?, .4 1?, .3 1?, .2 1?, .1 1?, .0 1?> if, () then} .then\n $frac52;\n\nnan_float64? = $float64\n {.exponent all_ones_exponent? ife, .fraction nonzero_fraction? iff, () then} .then\n $float64;\n\ninf_float64? = $float64\n {.exponent all_ones_exponent? ife, .fraction zero_fraction? iff, () then} .then\n $float64;\n\nfinite_float64? = $float64\n {.exponent not_all_ones_exponent? ife, () then} .then\n $float64;\n\nordered_float64? = $float64\n <finite_float64?, inf_float64?>\n $float64;\n\nzero_float64? = $float64\n {.exponent zero_exponent? ife, .fraction zero_fraction? iff, () then} .then\n $float64;\n\ncmp_step = $cmp_step_in\n <\n {.state /gt if, gt then} .then,\n {.state /lt if, lt then} .then,\n {.state /eq if,\n <\n {.bits gt_bit? if, gt then} .then,\n {.bits lt_bit? if, lt then} .then,\n {.bits eq_bit? if, eq then} .then\n > then\n } .then\n > $cmp_state;\n\nstepE10 = $cmp_exp_ctx {{.state state, {.pair .x .10 x, .pair .y .10 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE9 = $cmp_exp_ctx {{.state state, {.pair .x .9 x, .pair .y .9 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE8 = $cmp_exp_ctx {{.state state, {.pair .x .8 x, .pair .y .8 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE7 = $cmp_exp_ctx {{.state state, {.pair .x .7 x, .pair .y .7 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE6 = $cmp_exp_ctx {{.state state, {.pair .x .6 x, .pair .y .6 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE5 = $cmp_exp_ctx {{.state state, {.pair .x .5 x, .pair .y .5 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE4 = $cmp_exp_ctx {{.state state, {.pair .x .4 x, .pair .y .4 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE3 = $cmp_exp_ctx {{.state state, {.pair .x .3 x, .pair .y .3 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE2 = $cmp_exp_ctx {{.state state, {.pair .x .2 x, .pair .y .2 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE1 = $cmp_exp_ctx {{.state state, {.pair .x .1 x, .pair .y .1 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE0 = $cmp_exp_ctx {{.state state, {.pair .x .0 x, .pair .y .0 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\n\ncmp_exponent = $exp_pair\n {eq state, () pair} $cmp_exp_ctx\n stepE10 stepE9 stepE8 stepE7 stepE6 stepE5 stepE4 stepE3 stepE2 stepE1 stepE0\n .state\n $cmp_state;\n\ngt_exponent? = $exp_pair {cmp_exponent /gt if, () then} .then $exp_pair;\neq_exponent? = $exp_pair {cmp_exponent /eq if, () then} .then $exp_pair;\nlt_exponent? = $exp_pair {cmp_exponent /lt if, () then} .then $exp_pair;\n\nstepF51 = $cmp_frac_ctx {{.state state, {.pair .x .51 x, .pair .y .51 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF50 = $cmp_frac_ctx {{.state state, {.pair .x .50 x, .pair .y .50 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF49 = $cmp_frac_ctx {{.state state, {.pair .x .49 x, .pair .y .49 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF48 = $cmp_frac_ctx {{.state state, {.pair .x .48 x, .pair .y .48 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF47 = $cmp_frac_ctx {{.state state, {.pair .x .47 x, .pair .y .47 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF46 = $cmp_frac_ctx {{.state state, {.pair .x .46 x, .pair .y .46 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF45 = $cmp_frac_ctx {{.state state, {.pair .x .45 x, .pair .y .45 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF44 = $cmp_frac_ctx {{.state state, {.pair .x .44 x, .pair .y .44 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF43 = $cmp_frac_ctx {{.state state, {.pair .x .43 x, .pair .y .43 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF42 = $cmp_frac_ctx {{.state state, {.pair .x .42 x, .pair .y .42 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF41 = $cmp_frac_ctx {{.state state, {.pair .x .41 x, .pair .y .41 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF40 = $cmp_frac_ctx {{.state state, {.pair .x .40 x, .pair .y .40 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF39 = $cmp_frac_ctx {{.state state, {.pair .x .39 x, .pair .y .39 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF38 = $cmp_frac_ctx {{.state state, {.pair .x .38 x, .pair .y .38 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF37 = $cmp_frac_ctx {{.state state, {.pair .x .37 x, .pair .y .37 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF36 = $cmp_frac_ctx {{.state state, {.pair .x .36 x, .pair .y .36 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF35 = $cmp_frac_ctx {{.state state, {.pair .x .35 x, .pair .y .35 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF34 = $cmp_frac_ctx {{.state state, {.pair .x .34 x, .pair .y .34 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF33 = $cmp_frac_ctx {{.state state, {.pair .x .33 x, .pair .y .33 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF32 = $cmp_frac_ctx {{.state state, {.pair .x .32 x, .pair .y .32 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF31 = $cmp_frac_ctx {{.state state, {.pair .x .31 x, .pair .y .31 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF30 = $cmp_frac_ctx {{.state state, {.pair .x .30 x, .pair .y .30 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF29 = $cmp_frac_ctx {{.state state, {.pair .x .29 x, .pair .y .29 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF28 = $cmp_frac_ctx {{.state state, {.pair .x .28 x, .pair .y .28 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF27 = $cmp_frac_ctx {{.state state, {.pair .x .27 x, .pair .y .27 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF26 = $cmp_frac_ctx {{.state state, {.pair .x .26 x, .pair .y .26 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF25 = $cmp_frac_ctx {{.state state, {.pair .x .25 x, .pair .y .25 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF24 = $cmp_frac_ctx {{.state state, {.pair .x .24 x, .pair .y .24 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF23 = $cmp_frac_ctx {{.state state, {.pair .x .23 x, .pair .y .23 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF22 = $cmp_frac_ctx {{.state state, {.pair .x .22 x, .pair .y .22 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF21 = $cmp_frac_ctx {{.state state, {.pair .x .21 x, .pair .y .21 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF20 = $cmp_frac_ctx {{.state state, {.pair .x .20 x, .pair .y .20 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF19 = $cmp_frac_ctx {{.state state, {.pair .x .19 x, .pair .y .19 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF18 = $cmp_frac_ctx {{.state state, {.pair .x .18 x, .pair .y .18 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF17 = $cmp_frac_ctx {{.state state, {.pair .x .17 x, .pair .y .17 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF16 = $cmp_frac_ctx {{.state state, {.pair .x .16 x, .pair .y .16 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF15 = $cmp_frac_ctx {{.state state, {.pair .x .15 x, .pair .y .15 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF14 = $cmp_frac_ctx {{.state state, {.pair .x .14 x, .pair .y .14 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF13 = $cmp_frac_ctx {{.state state, {.pair .x .13 x, .pair .y .13 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF12 = $cmp_frac_ctx {{.state state, {.pair .x .12 x, .pair .y .12 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF11 = $cmp_frac_ctx {{.state state, {.pair .x .11 x, .pair .y .11 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF10 = $cmp_frac_ctx {{.state state, {.pair .x .10 x, .pair .y .10 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF9 = $cmp_frac_ctx {{.state state, {.pair .x .9 x, .pair .y .9 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF8 = $cmp_frac_ctx {{.state state, {.pair .x .8 x, .pair .y .8 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF7 = $cmp_frac_ctx {{.state state, {.pair .x .7 x, .pair .y .7 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF6 = $cmp_frac_ctx {{.state state, {.pair .x .6 x, .pair .y .6 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF5 = $cmp_frac_ctx {{.state state, {.pair .x .5 x, .pair .y .5 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF4 = $cmp_frac_ctx {{.state state, {.pair .x .4 x, .pair .y .4 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF3 = $cmp_frac_ctx {{.state state, {.pair .x .3 x, .pair .y .3 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF2 = $cmp_frac_ctx {{.state state, {.pair .x .2 x, .pair .y .2 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF1 = $cmp_frac_ctx {{.state state, {.pair .x .1 x, .pair .y .1 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF0 = $cmp_frac_ctx {{.state state, {.pair .x .0 x, .pair .y .0 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\n\ncmp_fraction = $frac_pair\n {eq state, () pair} $cmp_frac_ctx\n stepF51 stepF50 stepF49 stepF48 stepF47 stepF46 stepF45 stepF44 stepF43 stepF42 stepF41 stepF40 stepF39 stepF38 stepF37 stepF36 stepF35 stepF34 stepF33 stepF32 stepF31 stepF30\n stepF29 stepF28 stepF27 stepF26 stepF25 stepF24 stepF23 stepF22 stepF21 stepF20 stepF19 stepF18 stepF17 stepF16 stepF15 stepF14 stepF13 stepF12 stepF11 stepF10 stepF9 stepF8 stepF7 stepF6 stepF5 stepF4 stepF3 stepF2 stepF1 stepF0\n .state\n $cmp_state;\n\ngt_fraction? = $frac_pair {cmp_fraction /gt if, () then} .then $frac_pair;\neq_fraction? = $frac_pair {cmp_fraction /eq if, () then} .then $frac_pair;\n\ngt_magnitude_float64? = $float_pair\n <\n {{.x .exponent x, .y .exponent y} gt_exponent? if, () then} .then,\n {{.x .exponent x, .y .exponent y} eq_exponent? ife, {.x .fraction x, .y .fraction y} gt_fraction? iff, () then} .then\n > $float_pair;\n\ncmp_float64 = $float_pair\n <\n {<.x nan_float64?, .y nan_float64?> if, unordered_nan_cmp then} .then,\n {.x zero_float64? ifx, .y zero_float64? ify, eq_zero_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify,\n {.x .sign x, .y .sign y} eq_sign? ifs,\n {.x .exponent x, .y .exponent y} eq_exponent? ife,\n {.x .fraction x, .y .fraction y} eq_fraction? iff,\n eq_exact_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign +? ifsx, .y .sign -? ifsy, gt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign -? ifsx, .y .sign +? ifsy, lt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign +? ifsx, .y .sign +? ifsy, gt_magnitude_float64? ifm, gt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign +? ifsx, .y .sign +? ifsy, {.y x, .x y} gt_magnitude_float64? ifm, lt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign -? ifsx, .y .sign -? ifsy, {.y x, .x y} gt_magnitude_float64? ifm, gt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign -? ifsx, .y .sign -? ifsy, gt_magnitude_float64? ifm, lt_cmp then} .then\n > $cmp;\n\neq_float64? = $float_pair {<cmp_float64 /eq_zero, cmp_float64 /eq_exact> if, () then} .then $float_pair;\ngt_float64? = $float_pair {cmp_float64 /gt if, () then} .then $float_pair;\nlt_float64? = $float_pair {cmp_float64 /lt if, () then} .then $float_pair;\nle_float64? = $float_pair {<cmp_float64 /lt, cmp_float64 /eq_zero, cmp_float64 /eq_exact> if, () then} .then $float_pair;\nge_float64? = $float_pair {<cmp_float64 /gt, cmp_float64 /eq_zero, cmp_float64 /eq_exact> if, () then} .then $float_pair;\n\nexp0 = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10} $exp11;\nexp_all1 = {} {1 0, 1 1, 1 2, 1 3, 1 4, 1 5, 1 6, 1 7, 1 8, 1 9, 1 10} $exp11;\n\nfrac0 = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31,\n 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47,\n 0 48, 0 49, 0 50, 0 51} $frac52;\n\nfrac_lsb1 = {} {1 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31,\n 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47,\n 0 48, 0 49, 0 50, 0 51} $frac52;\n\npos_zero = {} {+ sign, exp0 exponent, frac0 fraction} $float64;\nneg_zero = {} {- sign, exp0 exponent, frac0 fraction} $float64;\n\npos_inf = {} {+ sign, exp_all1 exponent, frac0 fraction} $float64;\nneg_inf = {} {- sign, exp_all1 exponent, frac0 fraction} $float64;\n\nqnan = {} {+ sign, exp_all1 exponent, frac_lsb1 fraction} $float64;\n\nflip_sign = $sign\n <\n {+? if, {} |- $sign then} .then,\n {-? if, {} |+ $sign then} .then\n > $sign;\n\nxor_sign = $sign_pair\n <\n {.x +? ifx, .y +? ify, {} |+ $sign then} .then,\n {.x +? ifx, .y -? ify, {} |- $sign then} .then,\n {.x -? ifx, .y +? ify, {} |- $sign then} .then,\n {.x -? ifx, .y -? ify, {} |+ $sign then} .then\n > $sign;\n\nopp_sign? = $sign_pair\n <\n {.x +? ifx, .y -? ify, () then} .then,\n {.x -? ifx, .y +? ify, () then} .then\n > $sign_pair;\n\ninf_of_sign = $sign\n <\n {+? if, pos_inf then} .then,\n {-? if, neg_inf then} .then\n > $float64;\n\nzero_of_sign = $sign\n <\n {+? if, pos_zero then} .then,\n {-? if, neg_zero then} .then\n > $float64;\n\nnegate_float64 = $float64\n {.sign flip_sign sign, .exponent exponent, .fraction fraction}\n $float64;\n\npair_signs = $float_pair\n {.x .sign x, .y .sign y}\n $sign_pair;\n\nxor_sign_of_pair = $float_pair\n pair_signs xor_sign\n $sign;\n\nopp_signs_of_pair? = $float_pair\n pair_signs opp_sign?\n $sign_pair;\n\ninf_from_pair_sign = $float_pair\n xor_sign_of_pair inf_of_sign\n $float64;\n\nzero_from_pair_sign = $float_pair\n xor_sign_of_pair zero_of_sign\n $float64;\n\nadd_float64 = $float_pair\n float64_add\n .result\n $float64;\n\n$add_same_in = {sig56 x, sig56 y, exp11 exp, sign sign};\n$add_same_out = {sig56 sig, exp11 exp, bit inexact, bit overflow, bit underflow, sign sign};\n$sub_same_in = {sig56 big, sig56 small, exp11 exp, sign sign};\n$sub_same_out = {sig56 sig, exp11 exp, bit inexact, bit overflow, bit underflow, sign sign};\n\nfloat64_from_parts = ${sign sign, exp11 exponent, sig56 sig}\n {.sign sign, .exponent exponent, (.sig frac52_from_sig56) fraction}\n $float64;\n\nadd_same_sign = $add_same_in\n {\n .exp exp,\n .sign sign,\n {.x x, .y y} sig56_add sum1\n }\n {\n .exp exp,\n .sign sign,\n .sum1 sum1,\n (.exp exp11_inc) exp_inc\n }\n {\n .sign sign,\n {.sum1.carry sel, .exp a, .exp_inc b} mux_exp11 exp_pre,\n {.sum1.carry sel, .sum1.sum a, {.sum1.sum sum, .sum1.carry carry} sig56_shift_right_carry b} mux_sig56 sig_pre\n }\n {\n .sign sign,\n .sig_pre sig_pre,\n .exp_pre exp_pre,\n { .sig_pre sig, .exp_pre exp } round_sig56 round_out\n }\n {\n .sign sign,\n .round_out .sig sig_round,\n .round_out .exp exp_round,\n .round_out .inexact inexact\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n (.exp_round exp_all_ones_bit) overflow,\n { .exp_round exp, .inexact inexact} underflow_bit_of underflow\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n .overflow overflow,\n .underflow underflow,\n {.overflow x, .inexact y} or_bit inexact_final\n }\n { .sig_round sig, .exp_round exp, .inexact_final inexact, .overflow overflow, .underflow underflow, .sign sign }\n $add_same_out;\n\nsub_same_sign = $sub_same_in\n {\n .exp exp,\n .sign sign,\n {.big x, .small y} sig56_sub_sum diff\n }\n {\n .exp exp,\n .sign sign,\n .diff diff,\n { .diff sig, .exp exp } normalize_left norm\n }\n {\n .sign sign,\n .norm norm,\n .norm .sig sig_norm,\n .norm .exp exp_norm\n }\n {\n .sign sign,\n .sig_norm sig_norm,\n .exp_norm exp_norm,\n { .sig_norm sig, .exp_norm exp } round_sig56 round_out\n }\n {\n .sign sign,\n .round_out .sig sig_round,\n .round_out .exp exp_round,\n .round_out .inexact inexact\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n (.exp_round exp_all_ones_bit) overflow,\n { .exp_round exp, .inexact inexact} underflow_bit_of underflow\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n .overflow overflow,\n .underflow underflow,\n {.overflow x, .inexact y} or_bit inexact_final\n }\n { .sig_round sig, .exp_round exp, .inexact_final inexact, .overflow overflow, .underflow underflow, .sign sign }\n $sub_same_out;\n\nfloat64_add_finite = $float_pair\n {\n .x x,\n .y y,\n (.x sig56_from_float64) sigx,\n (.y sig56_from_float64) sigy,\n {.x .exponent x, .y .exponent y} exp_pair,\n {.x .sign x, .y .sign y} sign_pair,\n .x .sign sign_x,\n .y .sign sign_y,\n {.x x, .y y} mag_gt_bit mag_gt,\n {.x x, .y y} mag_eq_bit mag_eq\n }\n {\n .sigx sigx,\n .sigy sigy,\n (.exp_pair exp11_max) exp_max,\n (.exp_pair exp11_abs_diff) exp_diff,\n (.exp_pair exp_gt_bit) exp_gt,\n (.exp_pair exp_lt_bit) exp_lt,\n (.sign_pair sign_eq_bit) sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq\n }\n {\n .sigx sigx,\n .sigy sigy,\n .exp_max exp_max,\n (.exp_diff shift6_from_exp11) shamt,\n .exp_gt exp_gt,\n .exp_lt exp_lt,\n .sign_eq sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq\n }\n {\n .sigx sigx,\n .sigy sigy,\n .exp_max exp_max,\n .exp_gt exp_gt,\n .exp_lt exp_lt,\n .sign_eq sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq,\n {.sigx x, .shamt s} shift_right_sig56 shx,\n {.sigy x, .shamt s} shift_right_sig56 shy\n }\n {\n .exp_max exp_max,\n .sign_eq sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq,\n {.exp_lt sel, .sigx a, .shx b} mux_sig56 sigx_al,\n {.exp_gt sel, .sigy a, .shy b} mux_sig56 sigy_al\n }\n <\n {.sign_eq 1? if,\n {\n .sign_x sign_x,\n {.sigx_al x, .sigy_al y, .exp_max exp, .sign_x sign} add_same_sign out\n }\n {\n .sign_x sign_x,\n .out out,\n .out .sig sig_round,\n .out .exp exp_round,\n .out .inexact inexact,\n .out .overflow overflow,\n .out .underflow underflow\n }\n {\n .sign_x sign_x,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n {.overflow overflow, .underflow underflow, .inexact inexact} flags_add_from_bits flags,\n (.sign_x inf_of_sign) inf_res\n }\n {\n .flags flags,\n .overflow overflow,\n .inf_res inf_res,\n {.sign_x sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res\n }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > then} .then,\n {.sign_eq 0? if,\n <\n {.mag_eq 1? if, {pos_zero result, none flags} then} .then,\n {.mag_eq 0? if,\n {\n .exp_max exp_max,\n {.mag_gt sel, .sigy_al a, .sigx_al b} mux_sig56 big,\n {.mag_gt sel, .sigx_al a, .sigy_al b} mux_sig56 small,\n {.mag_gt sel, .sign_y a, .sign_x b} mux_sign sign_out\n }\n {\n .sign_out sign_out,\n {.big big, .small small, .exp_max exp, .sign_out sign} sub_same_sign out\n }\n {\n .sign_out sign_out,\n .out out,\n .out .sig sig_round,\n .out .exp exp_round,\n .out .inexact inexact,\n .out .overflow overflow,\n .out .underflow underflow\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n {.overflow overflow, .underflow underflow, .inexact inexact} flags_add_from_bits flags,\n (.sign_out inf_of_sign) inf_res\n }\n {\n .flags flags,\n .overflow overflow,\n .inf_res inf_res,\n {.sign_out sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res\n }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > then} .then\n > then} .then\n > $add_result;\n\nfloat64_add = $float_pair\n <\n {.x nan_float64? ifx, {qnan result, none flags} then} .then,\n {.y nan_float64? ify, {qnan result, none flags} then} .then,\n {.x inf_float64? ifx, .y inf_float64? ify, opp_signs_of_pair? ifs, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, {.x result, none flags} then} .then,\n {.y inf_float64? ify, {.y result, none flags} then} .then,\n {.x zero_float64? ifx, .y zero_float64? ify, {pos_zero result, none flags} then} .then,\n {.x zero_float64? ifx, {.y result, none flags} then} .then,\n {.y zero_float64? ify, {.x result, none flags} then} .then,\n {.x finite_float64? ifx, .y finite_float64? ify, float64_add_finite then} .then\n > $add_result;\n\nnegate_y_pair = $float_pair\n {.x x, (.y negate_float64) y}\n $float_pair;\n\nsub_float64 = $float_pair\n negate_y_pair\n add_float64\n $float64;\n\nfloat64_sub = $float_pair\n negate_y_pair\n float64_add\n { .result result, (.flags flags_sub_from_add) flags }\n $sub_result;\n\nfloat64_mul_finite = $float_pair\n { {.x x, .y y} args }\n { .args args, {.args .x .sign x, .args .y .sign y} xor_sign sign_out }\n { .args args, .sign_out sign_out, .args .x .exponent exp_x }\n { .args args, .sign_out sign_out, .exp_x exp_x, .args .y .exponent exp_y }\n { .args args, .sign_out sign_out, .exp_x exp_x, .exp_y exp_y, {.exp_x x, .exp_y y} exp11_add_sum exp_sum }\n { .args args, .sign_out sign_out, .exp_sum exp_sum, (.args .x sig56_from_float64) sigx }\n { .sign_out sign_out, .exp_sum exp_sum, .sigx sigx, (.args .y sig56_from_float64) sigy }\n { .sign_out sign_out, .sigx sigx, .sigy sigy, .exp_sum exp_sum, {.exp_sum x, () exp_1023 y} exp11_sub_sum exp_pre }\n { .sign_out sign_out, .exp_pre exp_pre, .sigx sigx, .sigy sigy, {.sigx x, .sigy y} sig56_mul_unsigned prod }\n { .sign_out sign_out, .exp_pre exp_pre, .prod prod, .prod .111 msb111 }\n { .sign_out sign_out, .exp_pre exp_pre, .prod prod, .msb111 msb111, (.exp_pre exp11_inc) exp_inc }\n { .sign_out sign_out, .exp_pre exp_pre, .prod prod, .msb111 msb111, .exp_inc exp_inc, (.prod sig56_from_sig112_shift55) sig_pre0 }\n { .sign_out sign_out, .exp_pre exp_pre, .msb111 msb111, .exp_inc exp_inc, .sig_pre0 sig_pre0, (.prod sig56_from_sig112_shift56) sig_pre1 }\n { .sign_out sign_out, .msb111 msb111, .exp_pre exp_pre, .exp_inc exp_inc, .sig_pre0 sig_pre0, .sig_pre1 sig_pre1, {.msb111 sel, .exp_pre a, .exp_inc b} mux_exp11 exp_norm }\n { .sign_out sign_out, .exp_norm exp_norm, .msb111 msb111, .sig_pre0 sig_pre0, .sig_pre1 sig_pre1, {.msb111 sel, .sig_pre0 a, .sig_pre1 b} mux_sig56 sig_pre }\n { .sign_out sign_out, .exp_norm exp_norm, .sig_pre sig_pre, { .sig_pre sig, .exp_norm exp } round_sig56 round_out }\n { .sign_out sign_out, .round_out round_out, .round_out .sig sig_round }\n { .sign_out sign_out, .round_out round_out, .sig_round sig_round, .round_out .exp exp_round }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .round_out .inexact inexact }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .inexact inexact, (.exp_round exp_all_ones_bit) overflow }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .inexact inexact, { .exp_round exp, .inexact inexact} underflow_bit_of underflow }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .underflow underflow, .inexact inexact, {.overflow x, .inexact y} or_bit inexact_final }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .underflow underflow, .inexact_final inexact_final, {.overflow overflow, .underflow underflow, .inexact_final inexact} flags_mul_from_bits flags }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .flags flags, (.sign_out inf_of_sign) inf_res }\n { .overflow overflow, .flags flags, .inf_res inf_res, {.sign_out sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res }\n { .overflow overflow, .flags flags, .inf_res inf_res, .float_res float_res }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > $mul_result;\n\nfloat64_mul = $float_pair\n <\n {.x nan_float64? ifx, {qnan result, none flags} then} .then,\n {.y nan_float64? ify, {qnan result, none flags} then} .then,\n {.x inf_float64? ifx, .y zero_float64? ify, {qnan result, invalid flags} then} .then,\n {.x zero_float64? ifx, .y inf_float64? ify, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, .y ordered_float64? ify, {inf_from_pair_sign result, none flags} then} .then,\n {.y inf_float64? ify, .x ordered_float64? ifx, {inf_from_pair_sign result, none flags} then} .then,\n {.x zero_float64? ifx, .y ordered_float64? ify, {zero_from_pair_sign result, none flags} then} .then,\n {.y zero_float64? ify, .x ordered_float64? ifx, {zero_from_pair_sign result, none flags} then} .then,\n {.x finite_float64? ifx, .y finite_float64? ify, float64_mul_finite then} .then\n > $mul_result;\n\nmul_float64 = $float_pair\n float64_mul\n .result\n $float64;\n\nfloat64_div_finite = $float_pair\n {\n (.x sig56_from_float64) sigx,\n (.y sig56_from_float64) sigy,\n {.x .sign x, .y .sign y} xor_sign sign_out,\n {.x .exponent x, .y .exponent y} exp11_sub_sum exp_diff\n }\n {\n .sign_out sign_out,\n .sigx sigx,\n .sigy sigy,\n {.exp_diff x, () exp_1023 y} exp11_add_sum exp_pre\n }\n {\n .sign_out sign_out,\n .exp_pre exp_pre,\n {.sigx x, .sigy y} sig56_div_unsigned quot\n }\n {\n .sign_out sign_out,\n .exp_pre exp_pre,\n .quot quot,\n .quot .55 msb55,\n (.exp_pre exp11_dec) exp_dec,\n (.quot shift_left_sig56_1) quot_sh\n }\n {\n .sign_out sign_out,\n {.msb55 sel, .exp_dec a, .exp_pre b} mux_exp11 exp_adj,\n {.msb55 sel, .quot_sh a, .quot b} mux_sig56 sig_pre\n }\n {\n .sign_out sign_out,\n .exp_adj exp_adj,\n .sig_pre sig_pre,\n { .sig_pre sig, .exp_adj exp } round_sig56 round_out\n }\n {\n .sign_out sign_out,\n .round_out .sig sig_round,\n .round_out .exp exp_round,\n .round_out .inexact inexact\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n (.exp_round exp_all_ones_bit) overflow\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n .overflow overflow,\n { .exp_round exp, .inexact inexact} underflow_bit_of underflow\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n .underflow underflow,\n .inexact inexact,\n {.overflow x, .inexact y} or_bit inexact_final\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n .underflow underflow,\n .inexact_final inexact_final,\n {0 div_by_zero, .overflow overflow, .underflow underflow, .inexact_final inexact} flags_div_from_bits flags,\n (.sign_out inf_of_sign) inf_res,\n {.sign_out sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res\n }\n {\n .flags flags,\n .overflow overflow,\n .inf_res inf_res,\n .float_res float_res\n }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > $div_result;\n\nfloat64_div = $float_pair\n <\n {.x nan_float64? ifx, {qnan result, none flags} then} .then,\n {.y nan_float64? ify, {qnan result, none flags} then} .then,\n {.x zero_float64? ifx, .y zero_float64? ify, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, .y inf_float64? ify, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, .y ordered_float64? ify, {inf_from_pair_sign result, none flags} then} .then,\n {.x ordered_float64? ifx, .y inf_float64? ify, {zero_from_pair_sign result, none flags} then} .then,\n {.x ordered_float64? ifx, .y zero_float64? ify, {inf_from_pair_sign result, div_by_zero flags} then} .then,\n {.x zero_float64? ifx, .y ordered_float64? ify, {zero_from_pair_sign result, none flags} then} .then,\n {.x finite_float64? ifx, .y finite_float64? ify, float64_div_finite then} .then\n > $div_result;\n\ndiv_float64 = $float_pair\n float64_div\n .result\n $float64;\n\n# -----------------------------------------------------------------------------\n# Public API\n# -----------------------------------------------------------------------------\n# Operations return a product with:\n# result : float64\n# flags : operation-specific exception flags\n#\n# Use `add .result`, `mul .result`, etc. when only the numeric result is needed.\n\nadd = float64_add;\nsub = float64_sub;\nmul = float64_mul;\ndiv = float64_div;\n\ncmp = cmp_float64;\neq? = eq_float64?;\nlt? = lt_float64?;\nle? = le_float64?;\ngt? = gt_float64?;\nge? = ge_float64?;\n\nneg = negate_float64;\n\n# --- useful float64 constants (IEEE-754 binary64) ---\n\n# 1.0 exponent = 1023 = 0b01111111111\nexp_1 = {} {1 0, 1 1, 1 2, 1 3, 1 4, 1 5, 1 6, 1 7, 1 8, 1 9, 0 10} $exp11;\n\n# 10.0 exponent = 1026 = 1023 + 3 = 0b10000000010\nexp_10 = {} {0 0, 1 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 1 10} $exp11;\n\n# 10.0 significand = 1.01b => fraction bit 50 = 1 (2^-2), everything else 0\nfrac_10 = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31,\n 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47,\n 0 48, 0 49, 1 50, 0 51} $frac52;\n\n# signed zeros (aliases)\n0f = pos_zero;\n-0f = neg_zero;\n\n# 1.0, -1.0, 10.0\n1f = {} {+ sign, exp_1 exponent, frac0 fraction} $float64;\n-1f = {} {- sign, exp_1 exponent, frac0 fraction} $float64;\n10f = {} {+ sign, exp_10 exponent, frac_10 fraction} $float64;\n\n()\n\n/*\n-- TESTS --\n# -----------------------------------------------------------------------------\n# Extra constants (finite) for comparisons\n# -----------------------------------------------------------------------------\n\n# exponent = 1024: 0b10000000000\nexp_1024 = {}\n { 1 10,\n 0 9, 0 8, 0 7, 0 6, 0 5, 0 4, 0 3, 0 2, 0 1, 0 0\n } $exp11;\n\n# exponent = 1056: 0b10000100000 (10^10 range)\nexp_1e10 = {}\n { 0 0, 0 1, 0 2, 0 3, 0 4, 1 5, 0 6, 0 7, 0 8, 0 9, 1 10 } $exp11;\n\nfrac_1e10 = {}\n { 0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 1 29, 0 30, 0 31,\n 1 32, 1 33, 1 34, 1 35, 1 36, 0 37, 1 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 1 45, 0 46, 1 47,\n 0 48, 1 49, 0 50, 0 51 } $frac52;\n\nfrac_1e10_p1 = {}\n { 0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 1 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 1 29, 0 30, 0 31,\n 1 32, 1 33, 1 34, 1 35, 1 36, 0 37, 1 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 1 45, 0 46, 1 47,\n 0 48, 1 49, 0 50, 0 51 } $frac52;\n\none = {+ sign, exp_1023 exponent, frac0 fraction} $float64;\ntwo = {+ sign, exp_1024 exponent, frac0 fraction} $float64;\nneg_one = {- sign, exp_1023 exponent, frac0 fraction} $float64;\nten_billion = {+ sign, exp_1e10 exponent, frac_1e10 fraction} $float64;\nten_billion_p1 = {+ sign, exp_1e10 exponent, frac_1e10_p1 fraction} $float64;\n\n# smallest positive subnormal: exponent=0, fraction LSB=1\npos_denorm_min = {+ sign, exp0 exponent, frac_lsb1 fraction} $float64;\nneg_denorm_min = {- sign, exp0 exponent, frac_lsb1 fraction} $float64;\n\n# -----------------------------------------------------------------------------\n# Expanded test product (make sure THIS is the last expression in the file)\n# -----------------------------------------------------------------------------\n\n{\n # --- bit ops --------------------------------------------------------------\n 0 not_bit not_bit_0,\n 1 not_bit not_bit_1,\n {0 x, 0 y} xor_bit xor_00,\n {0 x, 1 y} xor_bit xor_01,\n {1 x, 0 y} xor_bit xor_10,\n {1 x, 1 y} xor_bit xor_11,\n\n # --- cmp_float64 -----------------------------------------------------------\n ({pos_zero x, neg_zero y} cmp_float64) cmp_pz_nz,\n ({neg_zero x, pos_zero y} cmp_float64) cmp_nz_pz,\n ({pos_zero x, pos_zero y} cmp_float64) cmp_pz_pz,\n ({neg_zero x, neg_zero y} cmp_float64) cmp_nz_nz,\n\n ({pos_zero x, pos_inf y} cmp_float64) cmp_pz_pinf,\n ({pos_zero x, neg_inf y} cmp_float64) cmp_pz_ninf,\n ({neg_zero x, pos_inf y} cmp_float64) cmp_nz_pinf,\n ({neg_zero x, neg_inf y} cmp_float64) cmp_nz_ninf,\n\n ({pos_inf x, pos_zero y} cmp_float64) cmp_pinf_pz,\n ({neg_inf x, pos_zero y} cmp_float64) cmp_ninf_pz,\n\n ({pos_inf x, neg_inf y} cmp_float64) cmp_pinf_ninf,\n ({neg_inf x, pos_inf y} cmp_float64) cmp_ninf_pinf,\n ({pos_inf x, pos_inf y} cmp_float64) cmp_pinf_pinf,\n ({neg_inf x, neg_inf y} cmp_float64) cmp_ninf_ninf,\n\n ({qnan x, pos_zero y} cmp_float64) cmp_qnan_pz,\n ({pos_zero x, qnan y} cmp_float64) cmp_pz_qnan,\n ({qnan x, qnan y} cmp_float64) cmp_qnan_qnan,\n ({qnan x, pos_inf y} cmp_float64) cmp_qnan_pinf,\n ({pos_inf x, qnan y} cmp_float64) cmp_pinf_qnan,\n\n # --- add_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} add_float64) add_qnan_pz,\n ({pos_zero x, qnan y} add_float64) add_pz_qnan,\n ({qnan x, qnan y} add_float64) add_qnan_qnan,\n\n ({pos_inf x, neg_inf y} add_float64) add_pinf_ninf,\n ({neg_inf x, pos_inf y} add_float64) add_ninf_pinf,\n\n ({pos_inf x, pos_zero y} add_float64) add_pinf_pz,\n ({pos_inf x, neg_zero y} add_float64) add_pinf_nz,\n ({neg_inf x, pos_zero y} add_float64) add_ninf_pz,\n ({neg_inf x, neg_zero y} add_float64) add_ninf_nz,\n\n ({pos_zero x, pos_inf y} add_float64) add_pz_pinf,\n ({neg_zero x, pos_inf y} add_float64) add_nz_pinf,\n ({pos_zero x, neg_inf y} add_float64) add_pz_ninf,\n ({neg_zero x, neg_inf y} add_float64) add_nz_ninf,\n\n ({pos_zero x, neg_zero y} add_float64) add_pz_nz,\n ({neg_zero x, pos_zero y} add_float64) add_nz_pz,\n ({pos_zero x, pos_zero y} add_float64) add_pz_pz,\n ({neg_zero x, neg_zero y} add_float64) add_nz_nz,\n\n ({one x, one y} float64_add) add_one_one,\n ({ten_billion x, one y} float64_add) add_1e10_1,\n ({ten_billion_p1 x, one y} float64_add) add_1e10p1_1,\n\n # --- sub_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} sub_float64) sub_qnan_pz,\n ({pos_zero x, qnan y} sub_float64) sub_pz_qnan,\n\n ({pos_zero x, pos_zero y} sub_float64) sub_pz_pz,\n ({pos_zero x, neg_zero y} sub_float64) sub_pz_nz,\n ({neg_zero x, pos_zero y} sub_float64) sub_nz_pz,\n ({neg_zero x, neg_zero y} sub_float64) sub_nz_nz,\n\n ({pos_inf x, pos_inf y} sub_float64) sub_pinf_pinf,\n ({pos_inf x, neg_inf y} sub_float64) sub_pinf_ninf,\n ({neg_inf x, pos_inf y} sub_float64) sub_ninf_pinf,\n ({neg_inf x, neg_inf y} sub_float64) sub_ninf_ninf,\n\n # --- mul_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} mul_float64) mul_qnan_pz,\n ({pos_zero x, qnan y} mul_float64) mul_pz_qnan,\n\n ({pos_inf x, pos_inf y} mul_float64) mul_pinf_pinf,\n ({pos_inf x, neg_inf y} mul_float64) mul_pinf_ninf,\n ({neg_inf x, pos_inf y} mul_float64) mul_ninf_pinf,\n ({neg_inf x, neg_inf y} mul_float64) mul_ninf_ninf,\n\n ({pos_inf x, pos_zero y} mul_float64) mul_pinf_pz,\n ({pos_inf x, neg_zero y} mul_float64) mul_pinf_nz,\n ({neg_inf x, pos_zero y} mul_float64) mul_ninf_pz,\n ({neg_inf x, neg_zero y} mul_float64) mul_ninf_nz,\n\n ({pos_zero x, pos_inf y} mul_float64) mul_pz_pinf,\n ({neg_zero x, pos_inf y} mul_float64) mul_nz_pinf,\n ({pos_zero x, neg_inf y} mul_float64) mul_pz_ninf,\n ({neg_zero x, neg_inf y} mul_float64) mul_nz_ninf,\n\n ({pos_zero x, pos_zero y} mul_float64) mul_pz_pz,\n ({pos_zero x, neg_zero y} mul_float64) mul_pz_nz,\n ({neg_zero x, pos_zero y} mul_float64) mul_nz_pz,\n ({neg_zero x, neg_zero y} mul_float64) mul_nz_nz,\n ({one x, one y} float64_mul) mul_one_one_flags,\n ({two x, two y} float64_mul) mul_two_two_flags,\n\n # --- div_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} div_float64) div_qnan_pz,\n ({pos_zero x, qnan y} div_float64) div_pz_qnan,\n\n ({pos_zero x, pos_zero y} div_float64) div_pz_pz,\n ({pos_zero x, neg_zero y} div_float64) div_pz_nz,\n ({neg_zero x, pos_zero y} div_float64) div_nz_pz,\n ({neg_zero x, neg_zero y} div_float64) div_nz_nz,\n\n ({pos_inf x, pos_inf y} div_float64) div_pinf_pinf,\n ({pos_inf x, neg_inf y} div_float64) div_pinf_ninf,\n ({neg_inf x, pos_inf y} div_float64) div_ninf_pinf,\n ({neg_inf x, neg_inf y} div_float64) div_ninf_ninf,\n\n ({pos_inf x, pos_zero y} div_float64) div_pinf_pz,\n ({pos_inf x, neg_zero y} div_float64) div_pinf_nz,\n ({neg_inf x, pos_zero y} div_float64) div_ninf_pz,\n ({neg_inf x, neg_zero y} div_float64) div_ninf_nz,\n\n ({pos_zero x, pos_inf y} div_float64) div_pz_pinf,\n ({neg_zero x, pos_inf y} div_float64) div_nz_pinf,\n ({pos_zero x, neg_inf y} div_float64) div_pz_ninf,\n ({neg_zero x, neg_inf y} div_float64) div_nz_ninf,\n ({two x, one y} float64_div) div_two_one_flags,\n ({one x, two y} float64_div) div_one_two_flags,\n ({one x, pos_zero y} float64_div) div_one_pz_flags\n}\n*/ \n",
8
8
  "Examples/ieee.k": "// Primitive bit domains used throughout floating-point encodings.\n// IEEE-754 double-precision building blocks: bit-level domains, flag enums,\n// and ripple-carry arithmetic helpers reused across add/sub/mul/div.\n$bit = < {} 0, {} 1 >;\n$sign = < {} +, {} - >;\n\n// Small utility products for pairing bits or signs.\n$bit_pair = {bit x, bit y};\n$sign_pair = {sign x, sign y};\n\n// Comparator states and result lattice (accounts for NaN unordered case).\n$cmp_state = <{} eq, {} gt, {} lt>;\n$cmp = <{} eq_exact, {} eq_zero, {} gt, {} lt, {} unordered_nan>;\n\n// IEEE-754 double fields: 11-bit exponent and 52-bit fraction.\n$exp11 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10};\n$frac52 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51};\n\n// Logical view of a double plus rounding/exception flag enums per op.\n$float64 = {sign sign, exp11 exponent, frac52 fraction};\n$flags_add = <{} none, {} invalid, {} overflow, {} underflow, {} inexact>;\n$flags_sub = <{} none, {} invalid, {} overflow, {} underflow, {} inexact>;\n$flags_mul = <{} none, {} invalid, {} overflow, {} underflow, {} inexact>;\n$flags_div = <{} none, {} invalid, {} div_by_zero, {} overflow, {} underflow, {} inexact>;\n\n// Bundles pairing an arithmetic result with its raised flags.\n$add_result = {float64 result, flags_add flags};\n$sub_result = {float64 result, flags_sub flags};\n$mul_result = {float64 result, flags_mul flags};\n$div_result = {float64 result, flags_div flags};\n\n// Common products for operand pairs and extended significands.\n$float_pair = {float64 x, float64 y};\n$sig53 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51, bit 52};\n$sig56 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51, bit 52, bit 53, bit 54, bit 55};\n// Helper shapes for ripple-carry adders and small shifts.\n$exp_sum = {exp11 sum, bit carry};\n$sig56_sum = {sig56 sum, bit carry};\n$adder_out = {bit sum, bit carry};\n$shift6 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5};\n\n// Pairings used during exponent/fraction comparisons.\n$exp_pair = {exp11 x, exp11 y};\n$frac_pair = {frac52 x, frac52 y};\n\n// Comparator pipelines carry current state alongside bit pairs.\n$cmp_step_in = {bit_pair bits, cmp_state state};\n$cmp_exp_ctx = {exp_pair pair, cmp_state state};\n$cmp_frac_ctx = {frac_pair pair, cmp_state state};\n\n// Canonical bit literals for convenience.\n0 = {} |0 $bit;\n1 = {} |1 $bit;\n\n// Flag constructors for exception enums.\nnone = {} |none;\ninvalid = {} |invalid;\noverflow = {} |overflow;\nunderflow = {} |underflow;\ninexact = {} |inexact;\ndiv_by_zero = {} |div_by_zero;\n\n// Primitive boolean operators and a 3-input XOR helper.\nnot_bit = $bit </0 1, 0>;\nor_bit = $bit_pair <.x/1 1, .y/1 1, 0> $bit;\nand_bit = $bit_pair <.x/0 0, .y/0 0, 1> $bit;\nxor_bit = $bit_pair <{.x/0 if, .y then} .then, .y not_bit> $bit;\nxor_abc = ${bit a, bit b, bit c}\n {{.a x, .b y} xor_bit x, .c y} xor_bit;\n\n// Single-bit full adder: sum plus carry-out.\nfull_adder = ${bit a, bit b, bit c_in}\n {\n {.a a, .b b, .c_in c} xor_abc sum,\n {\n {.a x, .b y} and_bit x,\n {{.a x, .b y} xor_bit x, .c_in y} and_bit y\n } or_bit carry\n } $adder_out;\n\n// Bitwise inversion across the 11-bit exponent field.\nexp11_not = $exp11 {\n .0 not_bit 0,\n .1 not_bit 1,\n .2 not_bit 2,\n .3 not_bit 3,\n .4 not_bit 4,\n .5 not_bit 5,\n .6 not_bit 6,\n .7 not_bit 7,\n .8 not_bit 8,\n .9 not_bit 9,\n .10 not_bit 10\n} $exp11;\n\n// Ripple-carry add for two exp11 fields with an incoming carry.\nexp11_add_cin = ${exp11 x, exp11 y, bit c_in}\n {\n .x x,\n .y y,\n .c_in c_in,\n {.x .0 a, .y .0 b, .c_in c_in} full_adder fa0\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n {.x .1 a, .y .1 b, .fa0.carry c_in} full_adder fa1\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n {.x .2 a, .y .2 b, .fa1.carry c_in} full_adder fa2\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n {.x .3 a, .y .3 b, .fa2.carry c_in} full_adder fa3\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n {.x .4 a, .y .4 b, .fa3.carry c_in} full_adder fa4\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n {.x .5 a, .y .5 b, .fa4.carry c_in} full_adder fa5\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n {.x .6 a, .y .6 b, .fa5.carry c_in} full_adder fa6\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n {.x .7 a, .y .7 b, .fa6.carry c_in} full_adder fa7\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n {.x .8 a, .y .8 b, .fa7.carry c_in} full_adder fa8\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n {.x .9 a, .y .9 b, .fa8.carry c_in} full_adder fa9\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n {.x .10 a, .y .10 b, .fa9.carry c_in} full_adder fa10\n }\n {\n {.fa0.sum 0, .fa1.sum 1, .fa2.sum 2, .fa3.sum 3, .fa4.sum 4, .fa5.sum 5, .fa6.sum 6, .fa7.sum 7, .fa8.sum 8, .fa9.sum 9, .fa10.sum 10} sum,\n .fa10.carry carry\n } $exp_sum;\n\n// Unsigned add of two exp11 values; exposes carry-out.\nexp11_add = ${exp11 x, exp11 y} {.x x, .y y, 0 c_in} exp11_add_cin $exp_sum;\n\n// Two's-complement subtract for exp11 (x - y).\nexp11_sub = ${exp11 x, exp11 y}\n {.x x, (.y exp11_not) y, 1 c_in}\n exp11_add_cin\n $exp_sum;\n\n// Convenience projection: subtract and return only the exponent sum.\nexp11_sub_sum = ${exp11 x, exp11 y}\n {.x x, .y y} exp11_sub .sum\n $exp11;\n\n// Bitwise inversion over a 56-bit significand slice.\nsig56_not = $sig56 {\n .0 not_bit 0,\n .1 not_bit 1,\n .2 not_bit 2,\n .3 not_bit 3,\n .4 not_bit 4,\n .5 not_bit 5,\n .6 not_bit 6,\n .7 not_bit 7,\n .8 not_bit 8,\n .9 not_bit 9,\n .10 not_bit 10,\n .11 not_bit 11,\n .12 not_bit 12,\n .13 not_bit 13,\n .14 not_bit 14,\n .15 not_bit 15,\n .16 not_bit 16,\n .17 not_bit 17,\n .18 not_bit 18,\n .19 not_bit 19,\n .20 not_bit 20,\n .21 not_bit 21,\n .22 not_bit 22,\n .23 not_bit 23,\n .24 not_bit 24,\n .25 not_bit 25,\n .26 not_bit 26,\n .27 not_bit 27,\n .28 not_bit 28,\n .29 not_bit 29,\n .30 not_bit 30,\n .31 not_bit 31,\n .32 not_bit 32,\n .33 not_bit 33,\n .34 not_bit 34,\n .35 not_bit 35,\n .36 not_bit 36,\n .37 not_bit 37,\n .38 not_bit 38,\n .39 not_bit 39,\n .40 not_bit 40,\n .41 not_bit 41,\n .42 not_bit 42,\n .43 not_bit 43,\n .44 not_bit 44,\n .45 not_bit 45,\n .46 not_bit 46,\n .47 not_bit 47,\n .48 not_bit 48,\n .49 not_bit 49,\n .50 not_bit 50,\n .51 not_bit 51,\n .52 not_bit 52,\n .53 not_bit 53,\n .54 not_bit 54,\n .55 not_bit 55\n} $sig56;\n\n// 56-bit ripple-carry add with optional incoming carry.\n// 14-bit ripple-carry adder\n$sig14 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10, bit 11, bit 12, bit 13};\n$sig14_sum = {sig14 sum, bit carry};\nsig14_add_cin = ${sig14 x, sig14 y, bit c_in}\n {\n .x x,\n .y y,\n .c_in c_in,\n {.x .0 a, .y .0 b, .c_in c_in} full_adder fa0\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n {.x .1 a, .y .1 b, .fa0.carry c_in} full_adder fa1\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n {.x .2 a, .y .2 b, .fa1.carry c_in} full_adder fa2\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n {.x .3 a, .y .3 b, .fa2.carry c_in} full_adder fa3\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n {.x .4 a, .y .4 b, .fa3.carry c_in} full_adder fa4\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n {.x .5 a, .y .5 b, .fa4.carry c_in} full_adder fa5\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n {.x .6 a, .y .6 b, .fa5.carry c_in} full_adder fa6\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n {.x .7 a, .y .7 b, .fa6.carry c_in} full_adder fa7\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n {.x .8 a, .y .8 b, .fa7.carry c_in} full_adder fa8\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n {.x .9 a, .y .9 b, .fa8.carry c_in} full_adder fa9\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n {.x .10 a, .y .10 b, .fa9.carry c_in} full_adder fa10\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n .fa10 fa10,\n {.x .11 a, .y .11 b, .fa10.carry c_in} full_adder fa11\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n .fa10 fa10,\n .fa11 fa11,\n {.x .12 a, .y .12 b, .fa11.carry c_in} full_adder fa12\n }\n {\n .x x,\n .y y,\n .fa0 fa0,\n .fa1 fa1,\n .fa2 fa2,\n .fa3 fa3,\n .fa4 fa4,\n .fa5 fa5,\n .fa6 fa6,\n .fa7 fa7,\n .fa8 fa8,\n .fa9 fa9,\n .fa10 fa10,\n .fa11 fa11,\n .fa12 fa12,\n {.x .13 a, .y .13 b, .fa12.carry c_in} full_adder fa13\n }\n {\n {.fa0.sum 0, .fa1.sum 1, .fa2.sum 2, .fa3.sum 3, .fa4.sum 4, .fa5.sum 5, .fa6.sum 6, .fa7.sum 7, .fa8.sum 8, .fa9.sum 9, .fa10.sum 10, .fa11.sum 11, .fa12.sum 12, .fa13.sum 13} sum,\n .fa13.carry carry\n } $sig14_sum;\n\n// 56-bit adder composed of 4x 14-bit adders\nsig56_add_cin = ${sig56 x, sig56 y, bit c_in}\n {\n .x x,\n .y y,\n {\n {.x .0 0, .x .1 1, .x .2 2, .x .3 3, .x .4 4, .x .5 5, .x .6 6, .x .7 7, .x .8 8, .x .9 9, .x .10 10, .x .11 11, .x .12 12, .x .13 13} x,\n {.y .0 0, .y .1 1, .y .2 2, .y .3 3, .y .4 4, .y .5 5, .y .6 6, .y .7 7, .y .8 8, .y .9 9, .y .10 10, .y .11 11, .y .12 12, .y .13 13} y,\n .c_in c_in\n } sig14_add_cin b0\n }\n {\n .x x,\n .y y,\n .b0 b0,\n {\n {.x .14 0, .x .15 1, .x .16 2, .x .17 3, .x .18 4, .x .19 5, .x .20 6, .x .21 7, .x .22 8, .x .23 9, .x .24 10, .x .25 11, .x .26 12, .x .27 13} x,\n {.y .14 0, .y .15 1, .y .16 2, .y .17 3, .y .18 4, .y .19 5, .y .20 6, .y .21 7, .y .22 8, .y .23 9, .y .24 10, .y .25 11, .y .26 12, .y .27 13} y,\n .b0.carry c_in\n } sig14_add_cin b1\n }\n {\n .x x,\n .y y,\n .b0 b0,\n .b1 b1,\n {\n {.x .28 0, .x .29 1, .x .30 2, .x .31 3, .x .32 4, .x .33 5, .x .34 6, .x .35 7, .x .36 8, .x .37 9, .x .38 10, .x .39 11, .x .40 12, .x .41 13} x,\n {.y .28 0, .y .29 1, .y .30 2, .y .31 3, .y .32 4, .y .33 5, .y .34 6, .y .35 7, .y .36 8, .y .37 9, .y .38 10, .y .39 11, .y .40 12, .y .41 13} y,\n .b1.carry c_in\n } sig14_add_cin b2\n }\n {\n .b0 b0,\n .b1 b1,\n .b2 b2,\n {\n {.x .42 0, .x .43 1, .x .44 2, .x .45 3, .x .46 4, .x .47 5, .x .48 6, .x .49 7, .x .50 8, .x .51 9, .x .52 10, .x .53 11, .x .54 12, .x .55 13} x,\n {.y .42 0, .y .43 1, .y .44 2, .y .45 3, .y .46 4, .y .47 5, .y .48 6, .y .49 7, .y .50 8, .y .51 9, .y .52 10, .y .53 11, .y .54 12, .y .55 13} y,\n .b2.carry c_in\n } sig14_add_cin b3\n }\n {\n {\n .b0.sum.0 0, .b0.sum.1 1, .b0.sum.2 2, .b0.sum.3 3, .b0.sum.4 4, .b0.sum.5 5, .b0.sum.6 6, .b0.sum.7 7, .b0.sum.8 8, .b0.sum.9 9, .b0.sum.10 10, .b0.sum.11 11, .b0.sum.12 12, .b0.sum.13 13,\n .b1.sum.0 14, .b1.sum.1 15, .b1.sum.2 16, .b1.sum.3 17, .b1.sum.4 18, .b1.sum.5 19, .b1.sum.6 20, .b1.sum.7 21, .b1.sum.8 22, .b1.sum.9 23, .b1.sum.10 24, .b1.sum.11 25, .b1.sum.12 26, .b1.sum.13 27,\n .b2.sum.0 28, .b2.sum.1 29, .b2.sum.2 30, .b2.sum.3 31, .b2.sum.4 32, .b2.sum.5 33, .b2.sum.6 34, .b2.sum.7 35, .b2.sum.8 36, .b2.sum.9 37, .b2.sum.10 38, .b2.sum.11 39, .b2.sum.12 40, .b2.sum.13 41,\n .b3.sum.0 42, .b3.sum.1 43, .b3.sum.2 44, .b3.sum.3 45, .b3.sum.4 46, .b3.sum.5 47, .b3.sum.6 48, .b3.sum.7 49, .b3.sum.8 50, .b3.sum.9 51, .b3.sum.10 52, .b3.sum.11 53, .b3.sum.12 54, .b3.sum.13 55\n } sum,\n .b3.carry carry\n } $sig56_sum;\nsig56_add = ${sig56 x, sig56 y} {.x x, .y y, 0 c_in} sig56_add_cin $sig56_sum;\n\n// Two's-complement subtract for sig56 (x - y).\nsig56_sub = ${sig56 x, sig56 y}\n {.x x, (.y sig56_not) y, 1 c_in}\n sig56_add_cin\n $sig56_sum;\n\n// Convenience projection: subtract and return only the significand sum.\nsig56_sub_sum = ${sig56 x, sig56 y}\n {.x x, .y y} sig56_sub .sum\n $sig56;\n\n// Compare sig56 >= by inspecting subtract carry.\nsig56_ge_bit = ${sig56 x, sig56 y}\n {.x x, .y y} sig56_sub .carry\n $bit;\n\n// 1-bit mux controlled by sel.\nmux_bit = ${bit sel, bit a, bit b}\n <\n {.sel 0? if, .a then} .then,\n {.sel 1? if, .b then} .then\n > $bit;\n\n# --- sig112 helpers (mul/div) ------------------------------------------------\n// Wide 112-bit slice used for intermediate mul/div significands.\n$sig112 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19, bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29, bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39, bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49, bit 50, bit 51, bit 52, bit 53, bit 54, bit 55, bit 56, bit 57, bit 58, bit 59, bit 60, bit 61, bit 62, bit 63, bit 64, bit 65, bit 66, bit 67, bit 68, bit 69, bit 70, bit 71, bit 72, bit 73, bit 74, bit 75, bit 76, bit 77, bit 78, bit 79, bit 80, bit 81, bit 82, bit 83, bit 84, bit 85, bit 86, bit 87, bit 88, bit 89, bit 90, bit 91, bit 92, bit 93, bit 94, bit 95, bit 96, bit 97, bit 98, bit 99, bit 100, bit 101, bit 102, bit 103, bit 104, bit 105, bit 106, bit 107, bit 108, bit 109, bit 110, bit 111};\n// Helper shape: sum and carry for wide 112-bit arithmetic.\n$sig112_sum = {sig112 sum, bit carry};\n// Bitwise inversion across the 112-bit extended significand.\nsig112_not = $sig112 {\n .0 not_bit 0,\n .1 not_bit 1,\n .2 not_bit 2,\n .3 not_bit 3,\n .4 not_bit 4,\n .5 not_bit 5,\n .6 not_bit 6,\n .7 not_bit 7,\n .8 not_bit 8,\n .9 not_bit 9,\n .10 not_bit 10,\n .11 not_bit 11,\n .12 not_bit 12,\n .13 not_bit 13,\n .14 not_bit 14,\n .15 not_bit 15,\n .16 not_bit 16,\n .17 not_bit 17,\n .18 not_bit 18,\n .19 not_bit 19,\n .20 not_bit 20,\n .21 not_bit 21,\n .22 not_bit 22,\n .23 not_bit 23,\n .24 not_bit 24,\n .25 not_bit 25,\n .26 not_bit 26,\n .27 not_bit 27,\n .28 not_bit 28,\n .29 not_bit 29,\n .30 not_bit 30,\n .31 not_bit 31,\n .32 not_bit 32,\n .33 not_bit 33,\n .34 not_bit 34,\n .35 not_bit 35,\n .36 not_bit 36,\n .37 not_bit 37,\n .38 not_bit 38,\n .39 not_bit 39,\n .40 not_bit 40,\n .41 not_bit 41,\n .42 not_bit 42,\n .43 not_bit 43,\n .44 not_bit 44,\n .45 not_bit 45,\n .46 not_bit 46,\n .47 not_bit 47,\n .48 not_bit 48,\n .49 not_bit 49,\n .50 not_bit 50,\n .51 not_bit 51,\n .52 not_bit 52,\n .53 not_bit 53,\n .54 not_bit 54,\n .55 not_bit 55,\n .56 not_bit 56,\n .57 not_bit 57,\n .58 not_bit 58,\n .59 not_bit 59,\n .60 not_bit 60,\n .61 not_bit 61,\n .62 not_bit 62,\n .63 not_bit 63,\n .64 not_bit 64,\n .65 not_bit 65,\n .66 not_bit 66,\n .67 not_bit 67,\n .68 not_bit 68,\n .69 not_bit 69,\n .70 not_bit 70,\n .71 not_bit 71,\n .72 not_bit 72,\n .73 not_bit 73,\n .74 not_bit 74,\n .75 not_bit 75,\n .76 not_bit 76,\n .77 not_bit 77,\n .78 not_bit 78,\n .79 not_bit 79,\n .80 not_bit 80,\n .81 not_bit 81,\n .82 not_bit 82,\n .83 not_bit 83,\n .84 not_bit 84,\n .85 not_bit 85,\n .86 not_bit 86,\n .87 not_bit 87,\n .88 not_bit 88,\n .89 not_bit 89,\n .90 not_bit 90,\n .91 not_bit 91,\n .92 not_bit 92,\n .93 not_bit 93,\n .94 not_bit 94,\n .95 not_bit 95,\n .96 not_bit 96,\n .97 not_bit 97,\n .98 not_bit 98,\n .99 not_bit 99,\n .100 not_bit 100,\n .101 not_bit 101,\n .102 not_bit 102,\n .103 not_bit 103,\n .104 not_bit 104,\n .105 not_bit 105,\n .106 not_bit 106,\n .107 not_bit 107,\n .108 not_bit 108,\n .109 not_bit 109,\n .110 not_bit 110,\n .111 not_bit 111\n} $sig112;\n// 112-bit ripple-carry add with optional incoming carry.\n// 112-bit adder composed of 2x 56-bit adders\nsig112_add_cin = ${sig112 x, sig112 y, bit c_in}\n {\n .x x,\n .y y,\n {\n {.x .0 0, .x .1 1, .x .2 2, .x .3 3, .x .4 4, .x .5 5, .x .6 6, .x .7 7, .x .8 8, .x .9 9, .x .10 10, .x .11 11, .x .12 12, .x .13 13, .x .14 14, .x .15 15, .x .16 16, .x .17 17, .x .18 18, .x .19 19, .x .20 20, .x .21 21, .x .22 22, .x .23 23, .x .24 24, .x .25 25, .x .26 26, .x .27 27, .x .28 28, .x .29 29, .x .30 30, .x .31 31, .x .32 32, .x .33 33, .x .34 34, .x .35 35, .x .36 36, .x .37 37, .x .38 38, .x .39 39, .x .40 40, .x .41 41, .x .42 42, .x .43 43, .x .44 44, .x .45 45, .x .46 46, .x .47 47, .x .48 48, .x .49 49, .x .50 50, .x .51 51, .x .52 52, .x .53 53, .x .54 54, .x .55 55} x,\n {.y .0 0, .y .1 1, .y .2 2, .y .3 3, .y .4 4, .y .5 5, .y .6 6, .y .7 7, .y .8 8, .y .9 9, .y .10 10, .y .11 11, .y .12 12, .y .13 13, .y .14 14, .y .15 15, .y .16 16, .y .17 17, .y .18 18, .y .19 19, .y .20 20, .y .21 21, .y .22 22, .y .23 23, .y .24 24, .y .25 25, .y .26 26, .y .27 27, .y .28 28, .y .29 29, .y .30 30, .y .31 31, .y .32 32, .y .33 33, .y .34 34, .y .35 35, .y .36 36, .y .37 37, .y .38 38, .y .39 39, .y .40 40, .y .41 41, .y .42 42, .y .43 43, .y .44 44, .y .45 45, .y .46 46, .y .47 47, .y .48 48, .y .49 49, .y .50 50, .y .51 51, .y .52 52, .y .53 53, .y .54 54, .y .55 55} y,\n .c_in c_in\n } sig56_add_cin b0\n }\n {\n .b0 b0,\n {\n {.x .56 0, .x .57 1, .x .58 2, .x .59 3, .x .60 4, .x .61 5, .x .62 6, .x .63 7, .x .64 8, .x .65 9, .x .66 10, .x .67 11, .x .68 12, .x .69 13, .x .70 14, .x .71 15, .x .72 16, .x .73 17, .x .74 18, .x .75 19, .x .76 20, .x .77 21, .x .78 22, .x .79 23, .x .80 24, .x .81 25, .x .82 26, .x .83 27, .x .84 28, .x .85 29, .x .86 30, .x .87 31, .x .88 32, .x .89 33, .x .90 34, .x .91 35, .x .92 36, .x .93 37, .x .94 38, .x .95 39, .x .96 40, .x .97 41, .x .98 42, .x .99 43, .x .100 44, .x .101 45, .x .102 46, .x .103 47, .x .104 48, .x .105 49, .x .106 50, .x .107 51, .x .108 52, .x .109 53, .x .110 54, .x .111 55} x,\n {.y .56 0, .y .57 1, .y .58 2, .y .59 3, .y .60 4, .y .61 5, .y .62 6, .y .63 7, .y .64 8, .y .65 9, .y .66 10, .y .67 11, .y .68 12, .y .69 13, .y .70 14, .y .71 15, .y .72 16, .y .73 17, .y .74 18, .y .75 19, .y .76 20, .y .77 21, .y .78 22, .y .79 23, .y .80 24, .y .81 25, .y .82 26, .y .83 27, .y .84 28, .y .85 29, .y .86 30, .y .87 31, .y .88 32, .y .89 33, .y .90 34, .y .91 35, .y .92 36, .y .93 37, .y .94 38, .y .95 39, .y .96 40, .y .97 41, .y .98 42, .y .99 43, .y .100 44, .y .101 45, .y .102 46, .y .103 47, .y .104 48, .y .105 49, .y .106 50, .y .107 51, .y .108 52, .y .109 53, .y .110 54, .y .111 55} y,\n .b0.carry c_in\n } sig56_add_cin b1\n }\n {\n {\n .b0.sum.0 0, .b0.sum.1 1, .b0.sum.2 2, .b0.sum.3 3, .b0.sum.4 4, .b0.sum.5 5, .b0.sum.6 6, .b0.sum.7 7, .b0.sum.8 8, .b0.sum.9 9, .b0.sum.10 10, .b0.sum.11 11, .b0.sum.12 12, .b0.sum.13 13, .b0.sum.14 14, .b0.sum.15 15, .b0.sum.16 16, .b0.sum.17 17, .b0.sum.18 18, .b0.sum.19 19, .b0.sum.20 20, .b0.sum.21 21, .b0.sum.22 22, .b0.sum.23 23, .b0.sum.24 24, .b0.sum.25 25, .b0.sum.26 26, .b0.sum.27 27, .b0.sum.28 28, .b0.sum.29 29, .b0.sum.30 30, .b0.sum.31 31, .b0.sum.32 32, .b0.sum.33 33, .b0.sum.34 34, .b0.sum.35 35, .b0.sum.36 36, .b0.sum.37 37, .b0.sum.38 38, .b0.sum.39 39, .b0.sum.40 40, .b0.sum.41 41, .b0.sum.42 42, .b0.sum.43 43, .b0.sum.44 44, .b0.sum.45 45, .b0.sum.46 46, .b0.sum.47 47, .b0.sum.48 48, .b0.sum.49 49, .b0.sum.50 50, .b0.sum.51 51, .b0.sum.52 52, .b0.sum.53 53, .b0.sum.54 54, .b0.sum.55 55,\n .b1.sum.0 56, .b1.sum.1 57, .b1.sum.2 58, .b1.sum.3 59, .b1.sum.4 60, .b1.sum.5 61, .b1.sum.6 62, .b1.sum.7 63, .b1.sum.8 64, .b1.sum.9 65, .b1.sum.10 66, .b1.sum.11 67, .b1.sum.12 68, .b1.sum.13 69, .b1.sum.14 70, .b1.sum.15 71, .b1.sum.16 72, .b1.sum.17 73, .b1.sum.18 74, .b1.sum.19 75, .b1.sum.20 76, .b1.sum.21 77, .b1.sum.22 78, .b1.sum.23 79, .b1.sum.24 80, .b1.sum.25 81, .b1.sum.26 82, .b1.sum.27 83, .b1.sum.28 84, .b1.sum.29 85, .b1.sum.30 86, .b1.sum.31 87, .b1.sum.32 88, .b1.sum.33 89, .b1.sum.34 90, .b1.sum.35 91, .b1.sum.36 92, .b1.sum.37 93, .b1.sum.38 94, .b1.sum.39 95, .b1.sum.40 96, .b1.sum.41 97, .b1.sum.42 98, .b1.sum.43 99, .b1.sum.44 100, .b1.sum.45 101, .b1.sum.46 102, .b1.sum.47 103, .b1.sum.48 104, .b1.sum.49 105, .b1.sum.50 106, .b1.sum.51 107, .b1.sum.52 108, .b1.sum.53 109, .b1.sum.54 110, .b1.sum.55 111\n } sum,\n .b1.carry carry\n } $sig112_sum;\nsig112_add = ${sig112 x, sig112 y} {.x x, .y y, 0 c_in} sig112_add_cin $sig112_sum;\n\nsig112_sub = ${sig112 x, sig112 y}\n {.x x, (.y sig112_not) y, 1 c_in}\n sig112_add_cin\n $sig112_sum;\nsig112_zero = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15, 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31, 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47, 0 48, 0 49, 0 50, 0 51, 0 52, 0 53, 0 54, 0 55, 0 56, 0 57, 0 58, 0 59, 0 60, 0 61, 0 62, 0 63, 0 64, 0 65, 0 66, 0 67, 0 68, 0 69, 0 70, 0 71, 0 72, 0 73, 0 74, 0 75, 0 76, 0 77, 0 78, 0 79, 0 80, 0 81, 0 82, 0 83, 0 84, 0 85, 0 86, 0 87, 0 88, 0 89, 0 90, 0 91, 0 92, 0 93, 0 94, 0 95, 0 96, 0 97, 0 98, 0 99, 0 100, 0 101, 0 102, 0 103, 0 104, 0 105, 0 106, 0 107, 0 108, 0 109, 0 110, 0 111} $sig112;\nsig112_shift_left1 = $sig112\n {\n 0 0,\n .0 1,\n .1 2,\n .2 3,\n .3 4,\n .4 5,\n .5 6,\n .6 7,\n .7 8,\n .8 9,\n .9 10,\n .10 11,\n .11 12,\n .12 13,\n .13 14,\n .14 15,\n .15 16,\n .16 17,\n .17 18,\n .18 19,\n .19 20,\n .20 21,\n .21 22,\n .22 23,\n .23 24,\n .24 25,\n .25 26,\n .26 27,\n .27 28,\n .28 29,\n .29 30,\n .30 31,\n .31 32,\n .32 33,\n .33 34,\n .34 35,\n .35 36,\n .36 37,\n .37 38,\n .38 39,\n .39 40,\n .40 41,\n .41 42,\n .42 43,\n .43 44,\n .44 45,\n .45 46,\n .46 47,\n .47 48,\n .48 49,\n .49 50,\n .50 51,\n .51 52,\n .52 53,\n .53 54,\n .54 55,\n .55 56,\n .56 57,\n .57 58,\n .58 59,\n .59 60,\n .60 61,\n .61 62,\n .62 63,\n .63 64,\n .64 65,\n .65 66,\n .66 67,\n .67 68,\n .68 69,\n .69 70,\n .70 71,\n .71 72,\n .72 73,\n .73 74,\n .74 75,\n .75 76,\n .76 77,\n .77 78,\n .78 79,\n .79 80,\n .80 81,\n .81 82,\n .82 83,\n .83 84,\n .84 85,\n .85 86,\n .86 87,\n .87 88,\n .88 89,\n .89 90,\n .90 91,\n .91 92,\n .92 93,\n .93 94,\n .94 95,\n .95 96,\n .96 97,\n .97 98,\n .98 99,\n .99 100,\n .100 101,\n .101 102,\n .102 103,\n .103 104,\n .104 105,\n .105 106,\n .106 107,\n .107 108,\n .108 109,\n .109 110,\n .110 111\n } $sig112;\nsig112_shift_right1 = $sig112\n {\n .1 0,\n .2 1,\n .3 2,\n .4 3,\n .5 4,\n .6 5,\n .7 6,\n .8 7,\n .9 8,\n .10 9,\n .11 10,\n .12 11,\n .13 12,\n .14 13,\n .15 14,\n .16 15,\n .17 16,\n .18 17,\n .19 18,\n .20 19,\n .21 20,\n .22 21,\n .23 22,\n .24 23,\n .25 24,\n .26 25,\n .27 26,\n .28 27,\n .29 28,\n .30 29,\n .31 30,\n .32 31,\n .33 32,\n .34 33,\n .35 34,\n .36 35,\n .37 36,\n .38 37,\n .39 38,\n .40 39,\n .41 40,\n .42 41,\n .43 42,\n .44 43,\n .45 44,\n .46 45,\n .47 46,\n .48 47,\n .49 48,\n .50 49,\n .51 50,\n .52 51,\n .53 52,\n .54 53,\n .55 54,\n .56 55,\n .57 56,\n .58 57,\n .59 58,\n .60 59,\n .61 60,\n .62 61,\n .63 62,\n .64 63,\n .65 64,\n .66 65,\n .67 66,\n .68 67,\n .69 68,\n .70 69,\n .71 70,\n .72 71,\n .73 72,\n .74 73,\n .75 74,\n .76 75,\n .77 76,\n .78 77,\n .79 78,\n .80 79,\n .81 80,\n .82 81,\n .83 82,\n .84 83,\n .85 84,\n .86 85,\n .87 86,\n .88 87,\n .89 88,\n .90 89,\n .91 90,\n .92 91,\n .93 92,\n .94 93,\n .95 94,\n .96 95,\n .97 96,\n .98 97,\n .99 98,\n .100 99,\n .101 100,\n .102 101,\n .103 102,\n .104 103,\n .105 104,\n .106 105,\n .107 106,\n .108 107,\n .109 108,\n .110 109,\n .111 110,\n 0 111\n } $sig112;\nsig112_from_sig56 = $sig56\n {\n .0 0,\n .1 1,\n .2 2,\n .3 3,\n .4 4,\n .5 5,\n .6 6,\n .7 7,\n .8 8,\n .9 9,\n .10 10,\n .11 11,\n .12 12,\n .13 13,\n .14 14,\n .15 15,\n .16 16,\n .17 17,\n .18 18,\n .19 19,\n .20 20,\n .21 21,\n .22 22,\n .23 23,\n .24 24,\n .25 25,\n .26 26,\n .27 27,\n .28 28,\n .29 29,\n .30 30,\n .31 31,\n .32 32,\n .33 33,\n .34 34,\n .35 35,\n .36 36,\n .37 37,\n .38 38,\n .39 39,\n .40 40,\n .41 41,\n .42 42,\n .43 43,\n .44 44,\n .45 45,\n .46 46,\n .47 47,\n .48 48,\n .49 49,\n .50 50,\n .51 51,\n .52 52,\n .53 53,\n .54 54,\n .55 55,\n 0 56,\n 0 57,\n 0 58,\n 0 59,\n 0 60,\n 0 61,\n 0 62,\n 0 63,\n 0 64,\n 0 65,\n 0 66,\n 0 67,\n 0 68,\n 0 69,\n 0 70,\n 0 71,\n 0 72,\n 0 73,\n 0 74,\n 0 75,\n 0 76,\n 0 77,\n 0 78,\n 0 79,\n 0 80,\n 0 81,\n 0 82,\n 0 83,\n 0 84,\n 0 85,\n 0 86,\n 0 87,\n 0 88,\n 0 89,\n 0 90,\n 0 91,\n 0 92,\n 0 93,\n 0 94,\n 0 95,\n 0 96,\n 0 97,\n 0 98,\n 0 99,\n 0 100,\n 0 101,\n 0 102,\n 0 103,\n 0 104,\n 0 105,\n 0 106,\n 0 107,\n 0 108,\n 0 109,\n 0 110,\n 0 111\n } $sig112;\nsig112_from_sig56_shift55 = $sig56\n {\n 0 0,\n 0 1,\n 0 2,\n 0 3,\n 0 4,\n 0 5,\n 0 6,\n 0 7,\n 0 8,\n 0 9,\n 0 10,\n 0 11,\n 0 12,\n 0 13,\n 0 14,\n 0 15,\n 0 16,\n 0 17,\n 0 18,\n 0 19,\n 0 20,\n 0 21,\n 0 22,\n 0 23,\n 0 24,\n 0 25,\n 0 26,\n 0 27,\n 0 28,\n 0 29,\n 0 30,\n 0 31,\n 0 32,\n 0 33,\n 0 34,\n 0 35,\n 0 36,\n 0 37,\n 0 38,\n 0 39,\n 0 40,\n 0 41,\n 0 42,\n 0 43,\n 0 44,\n 0 45,\n 0 46,\n 0 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n .0 55,\n .1 56,\n .2 57,\n .3 58,\n .4 59,\n .5 60,\n .6 61,\n .7 62,\n .8 63,\n .9 64,\n .10 65,\n .11 66,\n .12 67,\n .13 68,\n .14 69,\n .15 70,\n .16 71,\n .17 72,\n .18 73,\n .19 74,\n .20 75,\n .21 76,\n .22 77,\n .23 78,\n .24 79,\n .25 80,\n .26 81,\n .27 82,\n .28 83,\n .29 84,\n .30 85,\n .31 86,\n .32 87,\n .33 88,\n .34 89,\n .35 90,\n .36 91,\n .37 92,\n .38 93,\n .39 94,\n .40 95,\n .41 96,\n .42 97,\n .43 98,\n .44 99,\n .45 100,\n .46 101,\n .47 102,\n .48 103,\n .49 104,\n .50 105,\n .51 106,\n .52 107,\n .53 108,\n .54 109,\n .55 110,\n 0 111\n } $sig112;\nsig112_low56 = $sig112\n {\n .0 0,\n .1 1,\n .2 2,\n .3 3,\n .4 4,\n .5 5,\n .6 6,\n .7 7,\n .8 8,\n .9 9,\n .10 10,\n .11 11,\n .12 12,\n .13 13,\n .14 14,\n .15 15,\n .16 16,\n .17 17,\n .18 18,\n .19 19,\n .20 20,\n .21 21,\n .22 22,\n .23 23,\n .24 24,\n .25 25,\n .26 26,\n .27 27,\n .28 28,\n .29 29,\n .30 30,\n .31 31,\n .32 32,\n .33 33,\n .34 34,\n .35 35,\n .36 36,\n .37 37,\n .38 38,\n .39 39,\n .40 40,\n .41 41,\n .42 42,\n .43 43,\n .44 44,\n .45 45,\n .46 46,\n .47 47,\n .48 48,\n .49 49,\n .50 50,\n .51 51,\n .52 52,\n .53 53,\n .54 54,\n .55 55\n } $sig56;\nsig112_low56_any1 = $sig112\n sig112_low56 sig56_any1\n $bit;\nsig112_any1 = $sig112\n {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit x, .17 y} or_bit x, .18 y} or_bit x, .19 y} or_bit x, .20 y} or_bit x, .21 y} or_bit x, .22 y} or_bit x, .23 y} or_bit x, .24 y} or_bit x, .25 y} or_bit x, .26 y} or_bit x, .27 y} or_bit x, .28 y} or_bit x, .29 y} or_bit x, .30 y} or_bit x, .31 y} or_bit x, .32 y} or_bit x, .33 y} or_bit x, .34 y} or_bit x, .35 y} or_bit x, .36 y} or_bit x, .37 y} or_bit x, .38 y} or_bit x, .39 y} or_bit x, .40 y} or_bit x, .41 y} or_bit x, .42 y} or_bit x, .43 y} or_bit x, .44 y} or_bit x, .45 y} or_bit x, .46 y} or_bit x, .47 y} or_bit x, .48 y} or_bit x, .49 y} or_bit x, .50 y} or_bit x, .51 y} or_bit x, .52 y} or_bit x, .53 y} or_bit x, .54 y} or_bit x, .55 y} or_bit x, .56 y} or_bit x, .57 y} or_bit x, .58 y} or_bit x, .59 y} or_bit x, .60 y} or_bit x, .61 y} or_bit x, .62 y} or_bit x, .63 y} or_bit x, .64 y} or_bit x, .65 y} or_bit x, .66 y} or_bit x, .67 y} or_bit x, .68 y} or_bit x, .69 y} or_bit x, .70 y} or_bit x, .71 y} or_bit x, .72 y} or_bit x, .73 y} or_bit x, .74 y} or_bit x, .75 y} or_bit x, .76 y} or_bit x, .77 y} or_bit x, .78 y} or_bit x, .79 y} or_bit x, .80 y} or_bit x, .81 y} or_bit x, .82 y} or_bit x, .83 y} or_bit x, .84 y} or_bit x, .85 y} or_bit x, .86 y} or_bit x, .87 y} or_bit x, .88 y} or_bit x, .89 y} or_bit x, .90 y} or_bit x, .91 y} or_bit x, .92 y} or_bit x, .93 y} or_bit x, .94 y} or_bit x, .95 y} or_bit x, .96 y} or_bit x, .97 y} or_bit x, .98 y} or_bit x, .99 y} or_bit x, .100 y} or_bit x, .101 y} or_bit x, .102 y} or_bit x, .103 y} or_bit x, .104 y} or_bit x, .105 y} or_bit x, .106 y} or_bit x, .107 y} or_bit x, .108 y} or_bit x, .109 y} or_bit x, .110 y} or_bit x, .111 y} or_bit\n $bit;\nmux_sig112 = ${bit sel, sig112 a, sig112 b}\n {\n {.sel sel, .a .0 a, .b .0 b} mux_bit 0,\n {.sel sel, .a .1 a, .b .1 b} mux_bit 1,\n {.sel sel, .a .2 a, .b .2 b} mux_bit 2,\n {.sel sel, .a .3 a, .b .3 b} mux_bit 3,\n {.sel sel, .a .4 a, .b .4 b} mux_bit 4,\n {.sel sel, .a .5 a, .b .5 b} mux_bit 5,\n {.sel sel, .a .6 a, .b .6 b} mux_bit 6,\n {.sel sel, .a .7 a, .b .7 b} mux_bit 7,\n {.sel sel, .a .8 a, .b .8 b} mux_bit 8,\n {.sel sel, .a .9 a, .b .9 b} mux_bit 9,\n {.sel sel, .a .10 a, .b .10 b} mux_bit 10,\n {.sel sel, .a .11 a, .b .11 b} mux_bit 11,\n {.sel sel, .a .12 a, .b .12 b} mux_bit 12,\n {.sel sel, .a .13 a, .b .13 b} mux_bit 13,\n {.sel sel, .a .14 a, .b .14 b} mux_bit 14,\n {.sel sel, .a .15 a, .b .15 b} mux_bit 15,\n {.sel sel, .a .16 a, .b .16 b} mux_bit 16,\n {.sel sel, .a .17 a, .b .17 b} mux_bit 17,\n {.sel sel, .a .18 a, .b .18 b} mux_bit 18,\n {.sel sel, .a .19 a, .b .19 b} mux_bit 19,\n {.sel sel, .a .20 a, .b .20 b} mux_bit 20,\n {.sel sel, .a .21 a, .b .21 b} mux_bit 21,\n {.sel sel, .a .22 a, .b .22 b} mux_bit 22,\n {.sel sel, .a .23 a, .b .23 b} mux_bit 23,\n {.sel sel, .a .24 a, .b .24 b} mux_bit 24,\n {.sel sel, .a .25 a, .b .25 b} mux_bit 25,\n {.sel sel, .a .26 a, .b .26 b} mux_bit 26,\n {.sel sel, .a .27 a, .b .27 b} mux_bit 27,\n {.sel sel, .a .28 a, .b .28 b} mux_bit 28,\n {.sel sel, .a .29 a, .b .29 b} mux_bit 29,\n {.sel sel, .a .30 a, .b .30 b} mux_bit 30,\n {.sel sel, .a .31 a, .b .31 b} mux_bit 31,\n {.sel sel, .a .32 a, .b .32 b} mux_bit 32,\n {.sel sel, .a .33 a, .b .33 b} mux_bit 33,\n {.sel sel, .a .34 a, .b .34 b} mux_bit 34,\n {.sel sel, .a .35 a, .b .35 b} mux_bit 35,\n {.sel sel, .a .36 a, .b .36 b} mux_bit 36,\n {.sel sel, .a .37 a, .b .37 b} mux_bit 37,\n {.sel sel, .a .38 a, .b .38 b} mux_bit 38,\n {.sel sel, .a .39 a, .b .39 b} mux_bit 39,\n {.sel sel, .a .40 a, .b .40 b} mux_bit 40,\n {.sel sel, .a .41 a, .b .41 b} mux_bit 41,\n {.sel sel, .a .42 a, .b .42 b} mux_bit 42,\n {.sel sel, .a .43 a, .b .43 b} mux_bit 43,\n {.sel sel, .a .44 a, .b .44 b} mux_bit 44,\n {.sel sel, .a .45 a, .b .45 b} mux_bit 45,\n {.sel sel, .a .46 a, .b .46 b} mux_bit 46,\n {.sel sel, .a .47 a, .b .47 b} mux_bit 47,\n {.sel sel, .a .48 a, .b .48 b} mux_bit 48,\n {.sel sel, .a .49 a, .b .49 b} mux_bit 49,\n {.sel sel, .a .50 a, .b .50 b} mux_bit 50,\n {.sel sel, .a .51 a, .b .51 b} mux_bit 51,\n {.sel sel, .a .52 a, .b .52 b} mux_bit 52,\n {.sel sel, .a .53 a, .b .53 b} mux_bit 53,\n {.sel sel, .a .54 a, .b .54 b} mux_bit 54,\n {.sel sel, .a .55 a, .b .55 b} mux_bit 55,\n {.sel sel, .a .56 a, .b .56 b} mux_bit 56,\n {.sel sel, .a .57 a, .b .57 b} mux_bit 57,\n {.sel sel, .a .58 a, .b .58 b} mux_bit 58,\n {.sel sel, .a .59 a, .b .59 b} mux_bit 59,\n {.sel sel, .a .60 a, .b .60 b} mux_bit 60,\n {.sel sel, .a .61 a, .b .61 b} mux_bit 61,\n {.sel sel, .a .62 a, .b .62 b} mux_bit 62,\n {.sel sel, .a .63 a, .b .63 b} mux_bit 63,\n {.sel sel, .a .64 a, .b .64 b} mux_bit 64,\n {.sel sel, .a .65 a, .b .65 b} mux_bit 65,\n {.sel sel, .a .66 a, .b .66 b} mux_bit 66,\n {.sel sel, .a .67 a, .b .67 b} mux_bit 67,\n {.sel sel, .a .68 a, .b .68 b} mux_bit 68,\n {.sel sel, .a .69 a, .b .69 b} mux_bit 69,\n {.sel sel, .a .70 a, .b .70 b} mux_bit 70,\n {.sel sel, .a .71 a, .b .71 b} mux_bit 71,\n {.sel sel, .a .72 a, .b .72 b} mux_bit 72,\n {.sel sel, .a .73 a, .b .73 b} mux_bit 73,\n {.sel sel, .a .74 a, .b .74 b} mux_bit 74,\n {.sel sel, .a .75 a, .b .75 b} mux_bit 75,\n {.sel sel, .a .76 a, .b .76 b} mux_bit 76,\n {.sel sel, .a .77 a, .b .77 b} mux_bit 77,\n {.sel sel, .a .78 a, .b .78 b} mux_bit 78,\n {.sel sel, .a .79 a, .b .79 b} mux_bit 79,\n {.sel sel, .a .80 a, .b .80 b} mux_bit 80,\n {.sel sel, .a .81 a, .b .81 b} mux_bit 81,\n {.sel sel, .a .82 a, .b .82 b} mux_bit 82,\n {.sel sel, .a .83 a, .b .83 b} mux_bit 83,\n {.sel sel, .a .84 a, .b .84 b} mux_bit 84,\n {.sel sel, .a .85 a, .b .85 b} mux_bit 85,\n {.sel sel, .a .86 a, .b .86 b} mux_bit 86,\n {.sel sel, .a .87 a, .b .87 b} mux_bit 87,\n {.sel sel, .a .88 a, .b .88 b} mux_bit 88,\n {.sel sel, .a .89 a, .b .89 b} mux_bit 89,\n {.sel sel, .a .90 a, .b .90 b} mux_bit 90,\n {.sel sel, .a .91 a, .b .91 b} mux_bit 91,\n {.sel sel, .a .92 a, .b .92 b} mux_bit 92,\n {.sel sel, .a .93 a, .b .93 b} mux_bit 93,\n {.sel sel, .a .94 a, .b .94 b} mux_bit 94,\n {.sel sel, .a .95 a, .b .95 b} mux_bit 95,\n {.sel sel, .a .96 a, .b .96 b} mux_bit 96,\n {.sel sel, .a .97 a, .b .97 b} mux_bit 97,\n {.sel sel, .a .98 a, .b .98 b} mux_bit 98,\n {.sel sel, .a .99 a, .b .99 b} mux_bit 99,\n {.sel sel, .a .100 a, .b .100 b} mux_bit 100,\n {.sel sel, .a .101 a, .b .101 b} mux_bit 101,\n {.sel sel, .a .102 a, .b .102 b} mux_bit 102,\n {.sel sel, .a .103 a, .b .103 b} mux_bit 103,\n {.sel sel, .a .104 a, .b .104 b} mux_bit 104,\n {.sel sel, .a .105 a, .b .105 b} mux_bit 105,\n {.sel sel, .a .106 a, .b .106 b} mux_bit 106,\n {.sel sel, .a .107 a, .b .107 b} mux_bit 107,\n {.sel sel, .a .108 a, .b .108 b} mux_bit 108,\n {.sel sel, .a .109 a, .b .109 b} mux_bit 109,\n {.sel sel, .a .110 a, .b .110 b} mux_bit 110,\n {.sel sel, .a .111 a, .b .111 b} mux_bit 111\n } $sig112;\nsig112_add_if = ${sig112 acc, sig112 add, bit sel}\n {\n .acc acc,\n .add add,\n .sel sel,\n {.acc x, .add y} sig112_add sum\n }\n {\n .acc acc,\n .sum sum,\n .sel sel,\n {.sel sel, .acc a, .sum.sum b} mux_sig112 out\n }\n .out $sig112;\nsig56_mul_unsigned = ${sig56 x, sig56 y}\n {\n (.x sig112_from_sig56) add,\n () sig112_zero acc,\n .y y\n }\n {\n .y y,\n {.acc acc, .add add, .y .0 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .1 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .2 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .3 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .4 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .5 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .6 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .7 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .8 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .9 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .10 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .11 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .12 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .13 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .14 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .15 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .16 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .17 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .18 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .19 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .20 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .21 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .22 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .23 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .24 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .25 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .26 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .27 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .28 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .29 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .30 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .31 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .32 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .33 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .34 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .35 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .36 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .37 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .38 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .39 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .40 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .41 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .42 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .43 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .44 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .45 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .46 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .47 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .48 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .49 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .50 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .51 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .52 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .53 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .54 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n {\n .y y,\n {.acc acc, .add add, .y .55 sel} sig112_add_if acc,\n (.add sig112_shift_left1) add\n }\n .acc\n $sig112;\nsig56_div_unsigned = ${sig56 x, sig56 y}\n {\n (.x sig112_from_sig56_shift55) rem0,\n (.y sig112_from_sig56_shift55) div0\n }\n {\n .rem0 rem0,\n .div0 div0,\n {.rem0 x, .div0 y} sig112_sub sub55\n }\n {\n {.sub55.carry sel, .rem0 a, .sub55.sum b} mux_sig112 rem1,\n (.div0 sig112_shift_right1) div1,\n .sub55.carry b55\n }\n {\n .rem1 rem1,\n .div1 div1,\n .b55 b55,\n {.rem1 x, .div1 y} sig112_sub sub54\n }\n {\n .b55 b55,\n {.sub54.carry sel, .rem1 a, .sub54.sum b} mux_sig112 rem2,\n (.div1 sig112_shift_right1) div2,\n .sub54.carry b54\n }\n {\n .rem2 rem2,\n .div2 div2,\n .b55 b55,\n .b54 b54,\n {.rem2 x, .div2 y} sig112_sub sub53\n }\n {\n .b55 b55,\n .b54 b54,\n {.sub53.carry sel, .rem2 a, .sub53.sum b} mux_sig112 rem3,\n (.div2 sig112_shift_right1) div3,\n .sub53.carry b53\n }\n {\n .rem3 rem3,\n .div3 div3,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n {.rem3 x, .div3 y} sig112_sub sub52\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n {.sub52.carry sel, .rem3 a, .sub52.sum b} mux_sig112 rem4,\n (.div3 sig112_shift_right1) div4,\n .sub52.carry b52\n }\n {\n .rem4 rem4,\n .div4 div4,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n {.rem4 x, .div4 y} sig112_sub sub51\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n {.sub51.carry sel, .rem4 a, .sub51.sum b} mux_sig112 rem5,\n (.div4 sig112_shift_right1) div5,\n .sub51.carry b51\n }\n {\n .rem5 rem5,\n .div5 div5,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n {.rem5 x, .div5 y} sig112_sub sub50\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n {.sub50.carry sel, .rem5 a, .sub50.sum b} mux_sig112 rem6,\n (.div5 sig112_shift_right1) div6,\n .sub50.carry b50\n }\n {\n .rem6 rem6,\n .div6 div6,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n {.rem6 x, .div6 y} sig112_sub sub49\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n {.sub49.carry sel, .rem6 a, .sub49.sum b} mux_sig112 rem7,\n (.div6 sig112_shift_right1) div7,\n .sub49.carry b49\n }\n {\n .rem7 rem7,\n .div7 div7,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n {.rem7 x, .div7 y} sig112_sub sub48\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n {.sub48.carry sel, .rem7 a, .sub48.sum b} mux_sig112 rem8,\n (.div7 sig112_shift_right1) div8,\n .sub48.carry b48\n }\n {\n .rem8 rem8,\n .div8 div8,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n {.rem8 x, .div8 y} sig112_sub sub47\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n {.sub47.carry sel, .rem8 a, .sub47.sum b} mux_sig112 rem9,\n (.div8 sig112_shift_right1) div9,\n .sub47.carry b47\n }\n {\n .rem9 rem9,\n .div9 div9,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n {.rem9 x, .div9 y} sig112_sub sub46\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n {.sub46.carry sel, .rem9 a, .sub46.sum b} mux_sig112 rem10,\n (.div9 sig112_shift_right1) div10,\n .sub46.carry b46\n }\n {\n .rem10 rem10,\n .div10 div10,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n {.rem10 x, .div10 y} sig112_sub sub45\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n {.sub45.carry sel, .rem10 a, .sub45.sum b} mux_sig112 rem11,\n (.div10 sig112_shift_right1) div11,\n .sub45.carry b45\n }\n {\n .rem11 rem11,\n .div11 div11,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n {.rem11 x, .div11 y} sig112_sub sub44\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n {.sub44.carry sel, .rem11 a, .sub44.sum b} mux_sig112 rem12,\n (.div11 sig112_shift_right1) div12,\n .sub44.carry b44\n }\n {\n .rem12 rem12,\n .div12 div12,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n {.rem12 x, .div12 y} sig112_sub sub43\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n {.sub43.carry sel, .rem12 a, .sub43.sum b} mux_sig112 rem13,\n (.div12 sig112_shift_right1) div13,\n .sub43.carry b43\n }\n {\n .rem13 rem13,\n .div13 div13,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n {.rem13 x, .div13 y} sig112_sub sub42\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n {.sub42.carry sel, .rem13 a, .sub42.sum b} mux_sig112 rem14,\n (.div13 sig112_shift_right1) div14,\n .sub42.carry b42\n }\n {\n .rem14 rem14,\n .div14 div14,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n {.rem14 x, .div14 y} sig112_sub sub41\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n {.sub41.carry sel, .rem14 a, .sub41.sum b} mux_sig112 rem15,\n (.div14 sig112_shift_right1) div15,\n .sub41.carry b41\n }\n {\n .rem15 rem15,\n .div15 div15,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n {.rem15 x, .div15 y} sig112_sub sub40\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n {.sub40.carry sel, .rem15 a, .sub40.sum b} mux_sig112 rem16,\n (.div15 sig112_shift_right1) div16,\n .sub40.carry b40\n }\n {\n .rem16 rem16,\n .div16 div16,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n {.rem16 x, .div16 y} sig112_sub sub39\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n {.sub39.carry sel, .rem16 a, .sub39.sum b} mux_sig112 rem17,\n (.div16 sig112_shift_right1) div17,\n .sub39.carry b39\n }\n {\n .rem17 rem17,\n .div17 div17,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n {.rem17 x, .div17 y} sig112_sub sub38\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n {.sub38.carry sel, .rem17 a, .sub38.sum b} mux_sig112 rem18,\n (.div17 sig112_shift_right1) div18,\n .sub38.carry b38\n }\n {\n .rem18 rem18,\n .div18 div18,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n {.rem18 x, .div18 y} sig112_sub sub37\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n {.sub37.carry sel, .rem18 a, .sub37.sum b} mux_sig112 rem19,\n (.div18 sig112_shift_right1) div19,\n .sub37.carry b37\n }\n {\n .rem19 rem19,\n .div19 div19,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n {.rem19 x, .div19 y} sig112_sub sub36\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n {.sub36.carry sel, .rem19 a, .sub36.sum b} mux_sig112 rem20,\n (.div19 sig112_shift_right1) div20,\n .sub36.carry b36\n }\n {\n .rem20 rem20,\n .div20 div20,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n {.rem20 x, .div20 y} sig112_sub sub35\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n {.sub35.carry sel, .rem20 a, .sub35.sum b} mux_sig112 rem21,\n (.div20 sig112_shift_right1) div21,\n .sub35.carry b35\n }\n {\n .rem21 rem21,\n .div21 div21,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n {.rem21 x, .div21 y} sig112_sub sub34\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n {.sub34.carry sel, .rem21 a, .sub34.sum b} mux_sig112 rem22,\n (.div21 sig112_shift_right1) div22,\n .sub34.carry b34\n }\n {\n .rem22 rem22,\n .div22 div22,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n {.rem22 x, .div22 y} sig112_sub sub33\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n {.sub33.carry sel, .rem22 a, .sub33.sum b} mux_sig112 rem23,\n (.div22 sig112_shift_right1) div23,\n .sub33.carry b33\n }\n {\n .rem23 rem23,\n .div23 div23,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n {.rem23 x, .div23 y} sig112_sub sub32\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n {.sub32.carry sel, .rem23 a, .sub32.sum b} mux_sig112 rem24,\n (.div23 sig112_shift_right1) div24,\n .sub32.carry b32\n }\n {\n .rem24 rem24,\n .div24 div24,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n {.rem24 x, .div24 y} sig112_sub sub31\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n {.sub31.carry sel, .rem24 a, .sub31.sum b} mux_sig112 rem25,\n (.div24 sig112_shift_right1) div25,\n .sub31.carry b31\n }\n {\n .rem25 rem25,\n .div25 div25,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n {.rem25 x, .div25 y} sig112_sub sub30\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n {.sub30.carry sel, .rem25 a, .sub30.sum b} mux_sig112 rem26,\n (.div25 sig112_shift_right1) div26,\n .sub30.carry b30\n }\n {\n .rem26 rem26,\n .div26 div26,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n {.rem26 x, .div26 y} sig112_sub sub29\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n {.sub29.carry sel, .rem26 a, .sub29.sum b} mux_sig112 rem27,\n (.div26 sig112_shift_right1) div27,\n .sub29.carry b29\n }\n {\n .rem27 rem27,\n .div27 div27,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n {.rem27 x, .div27 y} sig112_sub sub28\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n {.sub28.carry sel, .rem27 a, .sub28.sum b} mux_sig112 rem28,\n (.div27 sig112_shift_right1) div28,\n .sub28.carry b28\n }\n {\n .rem28 rem28,\n .div28 div28,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n {.rem28 x, .div28 y} sig112_sub sub27\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n {.sub27.carry sel, .rem28 a, .sub27.sum b} mux_sig112 rem29,\n (.div28 sig112_shift_right1) div29,\n .sub27.carry b27\n }\n {\n .rem29 rem29,\n .div29 div29,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n {.rem29 x, .div29 y} sig112_sub sub26\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n {.sub26.carry sel, .rem29 a, .sub26.sum b} mux_sig112 rem30,\n (.div29 sig112_shift_right1) div30,\n .sub26.carry b26\n }\n {\n .rem30 rem30,\n .div30 div30,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n {.rem30 x, .div30 y} sig112_sub sub25\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n {.sub25.carry sel, .rem30 a, .sub25.sum b} mux_sig112 rem31,\n (.div30 sig112_shift_right1) div31,\n .sub25.carry b25\n }\n {\n .rem31 rem31,\n .div31 div31,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n {.rem31 x, .div31 y} sig112_sub sub24\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n {.sub24.carry sel, .rem31 a, .sub24.sum b} mux_sig112 rem32,\n (.div31 sig112_shift_right1) div32,\n .sub24.carry b24\n }\n {\n .rem32 rem32,\n .div32 div32,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n {.rem32 x, .div32 y} sig112_sub sub23\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n {.sub23.carry sel, .rem32 a, .sub23.sum b} mux_sig112 rem33,\n (.div32 sig112_shift_right1) div33,\n .sub23.carry b23\n }\n {\n .rem33 rem33,\n .div33 div33,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n {.rem33 x, .div33 y} sig112_sub sub22\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n {.sub22.carry sel, .rem33 a, .sub22.sum b} mux_sig112 rem34,\n (.div33 sig112_shift_right1) div34,\n .sub22.carry b22\n }\n {\n .rem34 rem34,\n .div34 div34,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n {.rem34 x, .div34 y} sig112_sub sub21\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n {.sub21.carry sel, .rem34 a, .sub21.sum b} mux_sig112 rem35,\n (.div34 sig112_shift_right1) div35,\n .sub21.carry b21\n }\n {\n .rem35 rem35,\n .div35 div35,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n {.rem35 x, .div35 y} sig112_sub sub20\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n {.sub20.carry sel, .rem35 a, .sub20.sum b} mux_sig112 rem36,\n (.div35 sig112_shift_right1) div36,\n .sub20.carry b20\n }\n {\n .rem36 rem36,\n .div36 div36,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n {.rem36 x, .div36 y} sig112_sub sub19\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n {.sub19.carry sel, .rem36 a, .sub19.sum b} mux_sig112 rem37,\n (.div36 sig112_shift_right1) div37,\n .sub19.carry b19\n }\n {\n .rem37 rem37,\n .div37 div37,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n {.rem37 x, .div37 y} sig112_sub sub18\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n {.sub18.carry sel, .rem37 a, .sub18.sum b} mux_sig112 rem38,\n (.div37 sig112_shift_right1) div38,\n .sub18.carry b18\n }\n {\n .rem38 rem38,\n .div38 div38,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n {.rem38 x, .div38 y} sig112_sub sub17\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n {.sub17.carry sel, .rem38 a, .sub17.sum b} mux_sig112 rem39,\n (.div38 sig112_shift_right1) div39,\n .sub17.carry b17\n }\n {\n .rem39 rem39,\n .div39 div39,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n {.rem39 x, .div39 y} sig112_sub sub16\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n {.sub16.carry sel, .rem39 a, .sub16.sum b} mux_sig112 rem40,\n (.div39 sig112_shift_right1) div40,\n .sub16.carry b16\n }\n {\n .rem40 rem40,\n .div40 div40,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n {.rem40 x, .div40 y} sig112_sub sub15\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n {.sub15.carry sel, .rem40 a, .sub15.sum b} mux_sig112 rem41,\n (.div40 sig112_shift_right1) div41,\n .sub15.carry b15\n }\n {\n .rem41 rem41,\n .div41 div41,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n {.rem41 x, .div41 y} sig112_sub sub14\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n {.sub14.carry sel, .rem41 a, .sub14.sum b} mux_sig112 rem42,\n (.div41 sig112_shift_right1) div42,\n .sub14.carry b14\n }\n {\n .rem42 rem42,\n .div42 div42,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n {.rem42 x, .div42 y} sig112_sub sub13\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n {.sub13.carry sel, .rem42 a, .sub13.sum b} mux_sig112 rem43,\n (.div42 sig112_shift_right1) div43,\n .sub13.carry b13\n }\n {\n .rem43 rem43,\n .div43 div43,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n {.rem43 x, .div43 y} sig112_sub sub12\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n {.sub12.carry sel, .rem43 a, .sub12.sum b} mux_sig112 rem44,\n (.div43 sig112_shift_right1) div44,\n .sub12.carry b12\n }\n {\n .rem44 rem44,\n .div44 div44,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n {.rem44 x, .div44 y} sig112_sub sub11\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n {.sub11.carry sel, .rem44 a, .sub11.sum b} mux_sig112 rem45,\n (.div44 sig112_shift_right1) div45,\n .sub11.carry b11\n }\n {\n .rem45 rem45,\n .div45 div45,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n {.rem45 x, .div45 y} sig112_sub sub10\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n {.sub10.carry sel, .rem45 a, .sub10.sum b} mux_sig112 rem46,\n (.div45 sig112_shift_right1) div46,\n .sub10.carry b10\n }\n {\n .rem46 rem46,\n .div46 div46,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n {.rem46 x, .div46 y} sig112_sub sub9\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n {.sub9.carry sel, .rem46 a, .sub9.sum b} mux_sig112 rem47,\n (.div46 sig112_shift_right1) div47,\n .sub9.carry b9\n }\n {\n .rem47 rem47,\n .div47 div47,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n {.rem47 x, .div47 y} sig112_sub sub8\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n {.sub8.carry sel, .rem47 a, .sub8.sum b} mux_sig112 rem48,\n (.div47 sig112_shift_right1) div48,\n .sub8.carry b8\n }\n {\n .rem48 rem48,\n .div48 div48,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n {.rem48 x, .div48 y} sig112_sub sub7\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n {.sub7.carry sel, .rem48 a, .sub7.sum b} mux_sig112 rem49,\n (.div48 sig112_shift_right1) div49,\n .sub7.carry b7\n }\n {\n .rem49 rem49,\n .div49 div49,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n {.rem49 x, .div49 y} sig112_sub sub6\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n {.sub6.carry sel, .rem49 a, .sub6.sum b} mux_sig112 rem50,\n (.div49 sig112_shift_right1) div50,\n .sub6.carry b6\n }\n {\n .rem50 rem50,\n .div50 div50,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n {.rem50 x, .div50 y} sig112_sub sub5\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n {.sub5.carry sel, .rem50 a, .sub5.sum b} mux_sig112 rem51,\n (.div50 sig112_shift_right1) div51,\n .sub5.carry b5\n }\n {\n .rem51 rem51,\n .div51 div51,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n {.rem51 x, .div51 y} sig112_sub sub4\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n {.sub4.carry sel, .rem51 a, .sub4.sum b} mux_sig112 rem52,\n (.div51 sig112_shift_right1) div52,\n .sub4.carry b4\n }\n {\n .rem52 rem52,\n .div52 div52,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n {.rem52 x, .div52 y} sig112_sub sub3\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n {.sub3.carry sel, .rem52 a, .sub3.sum b} mux_sig112 rem53,\n (.div52 sig112_shift_right1) div53,\n .sub3.carry b3\n }\n {\n .rem53 rem53,\n .div53 div53,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n {.rem53 x, .div53 y} sig112_sub sub2\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n {.sub2.carry sel, .rem53 a, .sub2.sum b} mux_sig112 rem54,\n (.div53 sig112_shift_right1) div54,\n .sub2.carry b2\n }\n {\n .rem54 rem54,\n .div54 div54,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n .b2 b2,\n {.rem54 x, .div54 y} sig112_sub sub1\n }\n {\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n .b2 b2,\n {.sub1.carry sel, .rem54 a, .sub1.sum b} mux_sig112 rem55,\n .sub1.carry b1\n }\n {\n .rem55 rem55,\n .b55 b55,\n .b54 b54,\n .b53 b53,\n .b52 b52,\n .b51 b51,\n .b50 b50,\n .b49 b49,\n .b48 b48,\n .b47 b47,\n .b46 b46,\n .b45 b45,\n .b44 b44,\n .b43 b43,\n .b42 b42,\n .b41 b41,\n .b40 b40,\n .b39 b39,\n .b38 b38,\n .b37 b37,\n .b36 b36,\n .b35 b35,\n .b34 b34,\n .b33 b33,\n .b32 b32,\n .b31 b31,\n .b30 b30,\n .b29 b29,\n .b28 b28,\n .b27 b27,\n .b26 b26,\n .b25 b25,\n .b24 b24,\n .b23 b23,\n .b22 b22,\n .b21 b21,\n .b20 b20,\n .b19 b19,\n .b18 b18,\n .b17 b17,\n .b16 b16,\n .b15 b15,\n .b14 b14,\n .b13 b13,\n .b12 b12,\n .b11 b11,\n .b10 b10,\n .b9 b9,\n .b8 b8,\n .b7 b7,\n .b6 b6,\n .b5 b5,\n .b4 b4,\n .b3 b3,\n .b2 b2,\n .b1 b1,\n (.rem55 sig112_any1) sticky\n }\n {\n .rem55 rem,\n .sticky sticky,\n {.b55 55, .b54 54, .b53 53, .b52 52, .b51 51, .b50 50, .b49 49, .b48 48, .b47 47, .b46 46, .b45 45, .b44 44, .b43 43, .b42 42, .b41 41, .b40 40, .b39 39, .b38 38, .b37 37, .b36 36, .b35 35, .b34 34, .b33 33, .b32 32, .b31 31, .b30 30, .b29 29, .b28 28, .b27 27, .b26 26, .b25 25, .b24 24, .b23 23, .b22 22, .b21 21, .b20 20, .b19 19, .b18 18, .b17 17, .b16 16, .b15 15, .b14 14, .b13 13, .b12 12, .b11 11, .b10 10, .b9 9, .b8 8, .b7 7, .b6 6, .b5 5, .b4 4, .b3 3, .b2 2, .b1 1, .sticky 0} sig\n }\n .sig $sig56;\nsig56_from_sig112_shift55 = $sig112\n {\n .110 55,\n .109 54,\n .108 53,\n .107 52,\n .106 51,\n .105 50,\n .104 49,\n .103 48,\n .102 47,\n .101 46,\n .100 45,\n .99 44,\n .98 43,\n .97 42,\n .96 41,\n .95 40,\n .94 39,\n .93 38,\n .92 37,\n .91 36,\n .90 35,\n .89 34,\n .88 33,\n .87 32,\n .86 31,\n .85 30,\n .84 29,\n .83 28,\n .82 27,\n .81 26,\n .80 25,\n .79 24,\n .78 23,\n .77 22,\n .76 21,\n .75 20,\n .74 19,\n .73 18,\n .72 17,\n .71 16,\n .70 15,\n .69 14,\n .68 13,\n .67 12,\n .66 11,\n .65 10,\n .64 9,\n .63 8,\n .62 7,\n .61 6,\n .60 5,\n .59 4,\n .58 3,\n .57 2,\n .56 1,\n sig112_low56_any1 0\n } $sig56;\nsig56_from_sig112_shift56 = $sig112\n {\n .111 55,\n .110 54,\n .109 53,\n .108 52,\n .107 51,\n .106 50,\n .105 49,\n .104 48,\n .103 47,\n .102 46,\n .101 45,\n .100 44,\n .99 43,\n .98 42,\n .97 41,\n .96 40,\n .95 39,\n .94 38,\n .93 37,\n .92 36,\n .91 35,\n .90 34,\n .89 33,\n .88 32,\n .87 31,\n .86 30,\n .85 29,\n .84 28,\n .83 27,\n .82 26,\n .81 25,\n .80 24,\n .79 23,\n .78 22,\n .77 21,\n .76 20,\n .75 19,\n .74 18,\n .73 17,\n .72 16,\n .71 15,\n .70 14,\n .69 13,\n .68 12,\n .67 11,\n .66 10,\n .65 9,\n .64 8,\n .63 7,\n .62 6,\n .61 5,\n .60 4,\n .59 3,\n .58 2,\n .57 1,\n { .56 x, sig112_low56_any1 y } or_bit 0\n } $sig56;\n\nshift_right_sig56_1 = $sig56\n {\n {.0 x, .1 y} or_bit 0,\n .2 1,\n .3 2,\n .4 3,\n .5 4,\n .6 5,\n .7 6,\n .8 7,\n .9 8,\n .10 9,\n .11 10,\n .12 11,\n .13 12,\n .14 13,\n .15 14,\n .16 15,\n .17 16,\n .18 17,\n .19 18,\n .20 19,\n .21 20,\n .22 21,\n .23 22,\n .24 23,\n .25 24,\n .26 25,\n .27 26,\n .28 27,\n .29 28,\n .30 29,\n .31 30,\n .32 31,\n .33 32,\n .34 33,\n .35 34,\n .36 35,\n .37 36,\n .38 37,\n .39 38,\n .40 39,\n .41 40,\n .42 41,\n .43 42,\n .44 43,\n .45 44,\n .46 45,\n .47 46,\n .48 47,\n .49 48,\n .50 49,\n .51 50,\n .52 51,\n .53 52,\n .54 53,\n .55 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_2 = $sig56\n {\n {{.0 x, .1 y} or_bit x, .2 y} or_bit 0,\n .3 1,\n .4 2,\n .5 3,\n .6 4,\n .7 5,\n .8 6,\n .9 7,\n .10 8,\n .11 9,\n .12 10,\n .13 11,\n .14 12,\n .15 13,\n .16 14,\n .17 15,\n .18 16,\n .19 17,\n .20 18,\n .21 19,\n .22 20,\n .23 21,\n .24 22,\n .25 23,\n .26 24,\n .27 25,\n .28 26,\n .29 27,\n .30 28,\n .31 29,\n .32 30,\n .33 31,\n .34 32,\n .35 33,\n .36 34,\n .37 35,\n .38 36,\n .39 37,\n .40 38,\n .41 39,\n .42 40,\n .43 41,\n .44 42,\n .45 43,\n .46 44,\n .47 45,\n .48 46,\n .49 47,\n .50 48,\n .51 49,\n .52 50,\n .53 51,\n .54 52,\n .55 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_4 = $sig56\n {\n {{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit 0,\n .5 1,\n .6 2,\n .7 3,\n .8 4,\n .9 5,\n .10 6,\n .11 7,\n .12 8,\n .13 9,\n .14 10,\n .15 11,\n .16 12,\n .17 13,\n .18 14,\n .19 15,\n .20 16,\n .21 17,\n .22 18,\n .23 19,\n .24 20,\n .25 21,\n .26 22,\n .27 23,\n .28 24,\n .29 25,\n .30 26,\n .31 27,\n .32 28,\n .33 29,\n .34 30,\n .35 31,\n .36 32,\n .37 33,\n .38 34,\n .39 35,\n .40 36,\n .41 37,\n .42 38,\n .43 39,\n .44 40,\n .45 41,\n .46 42,\n .47 43,\n .48 44,\n .49 45,\n .50 46,\n .51 47,\n .52 48,\n .53 49,\n .54 50,\n .55 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_8 = $sig56\n {\n {{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit 0,\n .9 1,\n .10 2,\n .11 3,\n .12 4,\n .13 5,\n .14 6,\n .15 7,\n .16 8,\n .17 9,\n .18 10,\n .19 11,\n .20 12,\n .21 13,\n .22 14,\n .23 15,\n .24 16,\n .25 17,\n .26 18,\n .27 19,\n .28 20,\n .29 21,\n .30 22,\n .31 23,\n .32 24,\n .33 25,\n .34 26,\n .35 27,\n .36 28,\n .37 29,\n .38 30,\n .39 31,\n .40 32,\n .41 33,\n .42 34,\n .43 35,\n .44 36,\n .45 37,\n .46 38,\n .47 39,\n .48 40,\n .49 41,\n .50 42,\n .51 43,\n .52 44,\n .53 45,\n .54 46,\n .55 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_16 = $sig56\n {\n {{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit 0,\n .17 1,\n .18 2,\n .19 3,\n .20 4,\n .21 5,\n .22 6,\n .23 7,\n .24 8,\n .25 9,\n .26 10,\n .27 11,\n .28 12,\n .29 13,\n .30 14,\n .31 15,\n .32 16,\n .33 17,\n .34 18,\n .35 19,\n .36 20,\n .37 21,\n .38 22,\n .39 23,\n .40 24,\n .41 25,\n .42 26,\n .43 27,\n .44 28,\n .45 29,\n .46 30,\n .47 31,\n .48 32,\n .49 33,\n .50 34,\n .51 35,\n .52 36,\n .53 37,\n .54 38,\n .55 39,\n 0 40,\n 0 41,\n 0 42,\n 0 43,\n 0 44,\n 0 45,\n 0 46,\n 0 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nshift_right_sig56_32 = $sig56\n {\n {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit x, .17 y} or_bit x, .18 y} or_bit x, .19 y} or_bit x, .20 y} or_bit x, .21 y} or_bit x, .22 y} or_bit x, .23 y} or_bit x, .24 y} or_bit x, .25 y} or_bit x, .26 y} or_bit x, .27 y} or_bit x, .28 y} or_bit x, .29 y} or_bit x, .30 y} or_bit x, .31 y} or_bit x, .32 y} or_bit 0,\n .33 1,\n .34 2,\n .35 3,\n .36 4,\n .37 5,\n .38 6,\n .39 7,\n .40 8,\n .41 9,\n .42 10,\n .43 11,\n .44 12,\n .45 13,\n .46 14,\n .47 15,\n .48 16,\n .49 17,\n .50 18,\n .51 19,\n .52 20,\n .53 21,\n .54 22,\n .55 23,\n 0 24,\n 0 25,\n 0 26,\n 0 27,\n 0 28,\n 0 29,\n 0 30,\n 0 31,\n 0 32,\n 0 33,\n 0 34,\n 0 35,\n 0 36,\n 0 37,\n 0 38,\n 0 39,\n 0 40,\n 0 41,\n 0 42,\n 0 43,\n 0 44,\n 0 45,\n 0 46,\n 0 47,\n 0 48,\n 0 49,\n 0 50,\n 0 51,\n 0 52,\n 0 53,\n 0 54,\n 0 55\n } $sig56;\n\nmux_sig56 = ${bit sel, sig56 a, sig56 b}\n {\n {.sel sel, .a .0 a, .b .0 b} mux_bit 0,\n {.sel sel, .a .1 a, .b .1 b} mux_bit 1,\n {.sel sel, .a .2 a, .b .2 b} mux_bit 2,\n {.sel sel, .a .3 a, .b .3 b} mux_bit 3,\n {.sel sel, .a .4 a, .b .4 b} mux_bit 4,\n {.sel sel, .a .5 a, .b .5 b} mux_bit 5,\n {.sel sel, .a .6 a, .b .6 b} mux_bit 6,\n {.sel sel, .a .7 a, .b .7 b} mux_bit 7,\n {.sel sel, .a .8 a, .b .8 b} mux_bit 8,\n {.sel sel, .a .9 a, .b .9 b} mux_bit 9,\n {.sel sel, .a .10 a, .b .10 b} mux_bit 10,\n {.sel sel, .a .11 a, .b .11 b} mux_bit 11,\n {.sel sel, .a .12 a, .b .12 b} mux_bit 12,\n {.sel sel, .a .13 a, .b .13 b} mux_bit 13,\n {.sel sel, .a .14 a, .b .14 b} mux_bit 14,\n {.sel sel, .a .15 a, .b .15 b} mux_bit 15,\n {.sel sel, .a .16 a, .b .16 b} mux_bit 16,\n {.sel sel, .a .17 a, .b .17 b} mux_bit 17,\n {.sel sel, .a .18 a, .b .18 b} mux_bit 18,\n {.sel sel, .a .19 a, .b .19 b} mux_bit 19,\n {.sel sel, .a .20 a, .b .20 b} mux_bit 20,\n {.sel sel, .a .21 a, .b .21 b} mux_bit 21,\n {.sel sel, .a .22 a, .b .22 b} mux_bit 22,\n {.sel sel, .a .23 a, .b .23 b} mux_bit 23,\n {.sel sel, .a .24 a, .b .24 b} mux_bit 24,\n {.sel sel, .a .25 a, .b .25 b} mux_bit 25,\n {.sel sel, .a .26 a, .b .26 b} mux_bit 26,\n {.sel sel, .a .27 a, .b .27 b} mux_bit 27,\n {.sel sel, .a .28 a, .b .28 b} mux_bit 28,\n {.sel sel, .a .29 a, .b .29 b} mux_bit 29,\n {.sel sel, .a .30 a, .b .30 b} mux_bit 30,\n {.sel sel, .a .31 a, .b .31 b} mux_bit 31,\n {.sel sel, .a .32 a, .b .32 b} mux_bit 32,\n {.sel sel, .a .33 a, .b .33 b} mux_bit 33,\n {.sel sel, .a .34 a, .b .34 b} mux_bit 34,\n {.sel sel, .a .35 a, .b .35 b} mux_bit 35,\n {.sel sel, .a .36 a, .b .36 b} mux_bit 36,\n {.sel sel, .a .37 a, .b .37 b} mux_bit 37,\n {.sel sel, .a .38 a, .b .38 b} mux_bit 38,\n {.sel sel, .a .39 a, .b .39 b} mux_bit 39,\n {.sel sel, .a .40 a, .b .40 b} mux_bit 40,\n {.sel sel, .a .41 a, .b .41 b} mux_bit 41,\n {.sel sel, .a .42 a, .b .42 b} mux_bit 42,\n {.sel sel, .a .43 a, .b .43 b} mux_bit 43,\n {.sel sel, .a .44 a, .b .44 b} mux_bit 44,\n {.sel sel, .a .45 a, .b .45 b} mux_bit 45,\n {.sel sel, .a .46 a, .b .46 b} mux_bit 46,\n {.sel sel, .a .47 a, .b .47 b} mux_bit 47,\n {.sel sel, .a .48 a, .b .48 b} mux_bit 48,\n {.sel sel, .a .49 a, .b .49 b} mux_bit 49,\n {.sel sel, .a .50 a, .b .50 b} mux_bit 50,\n {.sel sel, .a .51 a, .b .51 b} mux_bit 51,\n {.sel sel, .a .52 a, .b .52 b} mux_bit 52,\n {.sel sel, .a .53 a, .b .53 b} mux_bit 53,\n {.sel sel, .a .54 a, .b .54 b} mux_bit 54,\n {.sel sel, .a .55 a, .b .55 b} mux_bit 55\n } $sig56;\n\nshift_right_sig56 = ${sig56 x, shift6 s}\n {.x x, .s s, (.x shift_right_sig56_1) sh1}\n {.s s, {.s .0 sel, .x a, .sh1 b} mux_sig56 st1}\n {.s s, .st1 st1, (.st1 shift_right_sig56_2) sh2}\n {.s s, {.s .1 sel, .st1 a, .sh2 b} mux_sig56 st2}\n {.s s, .st2 st2, (.st2 shift_right_sig56_4) sh4}\n {.s s, {.s .2 sel, .st2 a, .sh4 b} mux_sig56 st3}\n {.s s, .st3 st3, (.st3 shift_right_sig56_8) sh8}\n {.s s, {.s .3 sel, .st3 a, .sh8 b} mux_sig56 st4}\n {.s s, .st4 st4, (.st4 shift_right_sig56_16) sh16}\n {.s s, {.s .4 sel, .st4 a, .sh16 b} mux_sig56 st5}\n {.s s, .st5 st5, (.st5 shift_right_sig56_32) sh32}\n {.s s, {.s .5 sel, .st5 a, .sh32 b} mux_sig56 st6}\n .st6 $sig56;\n\n$norm_left = {sig56 sig, exp11 exp};\n\nmux_exp11 = ${bit sel, exp11 a, exp11 b}\n {\n {.sel sel, .a .0 a, .b .0 b} mux_bit 0,\n {.sel sel, .a .1 a, .b .1 b} mux_bit 1,\n {.sel sel, .a .2 a, .b .2 b} mux_bit 2,\n {.sel sel, .a .3 a, .b .3 b} mux_bit 3,\n {.sel sel, .a .4 a, .b .4 b} mux_bit 4,\n {.sel sel, .a .5 a, .b .5 b} mux_bit 5,\n {.sel sel, .a .6 a, .b .6 b} mux_bit 6,\n {.sel sel, .a .7 a, .b .7 b} mux_bit 7,\n {.sel sel, .a .8 a, .b .8 b} mux_bit 8,\n {.sel sel, .a .9 a, .b .9 b} mux_bit 9,\n {.sel sel, .a .10 a, .b .10 b} mux_bit 10\n } $exp11;\n\nexp1 = {} {1 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10} $exp11;\n\n# exponent = 1023 (bias): 0b01111111111\nexp_1023 = {}\n { 0 10,\n 1 9, 1 8, 1 7, 1 6, 1 5, 1 4, 1 3, 1 2, 1 1, 1 0\n } $exp11;\n\nexp11_add_sum = ${exp11 x, exp11 y}\n {.x x, .y y} exp11_add .sum\n $exp11;\n\nexp11_inc = $exp11\n {() x, () exp1 y} exp11_add_sum\n $exp11;\n\nexp11_dec = $exp11\n {() x, () exp1 y} exp11_sub_sum\n $exp11;\n\nexp_nonzero_bit = $exp11\n <\n {zero_exponent? if, 0 then} .then,\n 1\n > $bit;\n\nshift_left_sig56_1 = $sig56\n {\n 0 0,\n .0 1,\n .1 2,\n .2 3,\n .3 4,\n .4 5,\n .5 6,\n .6 7,\n .7 8,\n .8 9,\n .9 10,\n .10 11,\n .11 12,\n .12 13,\n .13 14,\n .14 15,\n .15 16,\n .16 17,\n .17 18,\n .18 19,\n .19 20,\n .20 21,\n .21 22,\n .22 23,\n .23 24,\n .24 25,\n .25 26,\n .26 27,\n .27 28,\n .28 29,\n .29 30,\n .30 31,\n .31 32,\n .32 33,\n .33 34,\n .34 35,\n .35 36,\n .36 37,\n .37 38,\n .38 39,\n .39 40,\n .40 41,\n .41 42,\n .42 43,\n .43 44,\n .44 45,\n .45 46,\n .46 47,\n .47 48,\n .48 49,\n .49 50,\n .50 51,\n .51 52,\n .52 53,\n .53 54,\n .54 55\n } $sig56;\n\nsig56_any1 = $sig56\n {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{.0 x, .1 y} or_bit x, .2 y} or_bit x, .3 y} or_bit x, .4 y} or_bit x, .5 y} or_bit x, .6 y} or_bit x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit x, .11 y} or_bit x, .12 y} or_bit x, .13 y} or_bit x, .14 y} or_bit x, .15 y} or_bit x, .16 y} or_bit x, .17 y} or_bit x, .18 y} or_bit x, .19 y} or_bit x, .20 y} or_bit x, .21 y} or_bit x, .22 y} or_bit x, .23 y} or_bit x, .24 y} or_bit x, .25 y} or_bit x, .26 y} or_bit x, .27 y} or_bit x, .28 y} or_bit x, .29 y} or_bit x, .30 y} or_bit x, .31 y} or_bit x, .32 y} or_bit x, .33 y} or_bit x, .34 y} or_bit x, .35 y} or_bit x, .36 y} or_bit x, .37 y} or_bit x, .38 y} or_bit x, .39 y} or_bit x, .40 y} or_bit x, .41 y} or_bit x, .42 y} or_bit x, .43 y} or_bit x, .44 y} or_bit x, .45 y} or_bit x, .46 y} or_bit x, .47 y} or_bit x, .48 y} or_bit x, .49 y} or_bit x, .50 y} or_bit x, .51 y} or_bit x, .52 y} or_bit x, .53 y} or_bit x, .54 y} or_bit x, .55 y} or_bit\n $bit;\n\nsig56_zero_bit = $sig56\n <\n {sig56_any1 /0 if, 1 then} .then,\n 0\n > $bit;\n\nfrac52_from_sig56 = $sig56\n { .3 0, .4 1, .5 2, .6 3, .7 4, .8 5, .9 6, .10 7, .11 8, .12 9,\n .13 10, .14 11, .15 12, .16 13, .17 14, .18 15, .19 16, .20 17, .21 18, .22 19,\n .23 20, .24 21, .25 22, .26 23, .27 24, .28 25, .29 26, .30 27, .31 28, .32 29,\n .33 30, .34 31, .35 32, .36 33, .37 34, .38 35, .39 36, .40 37, .41 38, .42 39,\n .43 40, .44 41, .45 42, .46 43, .47 44, .48 45, .49 46, .50 47, .51 48, .52 49,\n .53 50, .54 51 }\n $frac52;\n\nnormalize_left_step = $norm_left\n {\n .sig sig,\n .exp exp,\n (.sig shift_left_sig56_1) sh,\n (.exp exp11_dec) exp_dec,\n (.exp exp_nonzero_bit) exp_nz,\n .sig .55 msb\n }\n {\n .sig sig,\n .exp exp,\n .sh sh,\n .exp_dec exp_dec,\n .exp_nz exp_nz,\n (.msb not_bit) msb0\n }\n {\n .sig sig,\n .exp exp,\n .exp_dec exp_dec,\n .msb0 msb0,\n .exp_nz exp_nz,\n .sh sh,\n {.msb0 x, .exp_nz y} and_bit shift_en\n }\n {\n .exp exp,\n .sh sh,\n .exp_dec exp_dec,\n .shift_en shift_en,\n {.shift_en sel, .sig a, .sh b} mux_sig56 sig_out\n }\n {\n .exp_dec exp_dec,\n .shift_en shift_en,\n .sig_out sig_out,\n {.shift_en sel, .exp a, .exp_dec b} mux_exp11 exp_out\n }\n { .sig_out sig, .exp_out exp }\n $norm_left;\n\nnormalize_left = $norm_left\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n normalize_left_step\n $norm_left;\n\n\nshift6_from_exp11 = $exp11\n {\n {{{{.6 x, .7 y} or_bit x, .8 y} or_bit x, .9 y} or_bit x, .10 y} or_bit high,\n .0 b0, .1 b1, .2 b2, .3 b3, .4 b4, .5 b5\n }\n <\n {.high 1? if, {1 0, 1 1, 1 2, 1 3, 1 4, 1 5} then} .then,\n {.high 0? if, {.b0 0, .b1 1, .b2 2, .b3 3, .b4 4, .b5 5} then} .then\n >\n $shift6;\n\nsig56_from_float64 = $float64\n <\n {.exponent zero_exponent? if,\n {\n 0 55,\n .fraction .51 54,\n .fraction .50 53,\n .fraction .49 52,\n .fraction .48 51,\n .fraction .47 50,\n .fraction .46 49,\n .fraction .45 48,\n .fraction .44 47,\n .fraction .43 46,\n .fraction .42 45,\n .fraction .41 44,\n .fraction .40 43,\n .fraction .39 42,\n .fraction .38 41,\n .fraction .37 40,\n .fraction .36 39,\n .fraction .35 38,\n .fraction .34 37,\n .fraction .33 36,\n .fraction .32 35,\n .fraction .31 34,\n .fraction .30 33,\n .fraction .29 32,\n .fraction .28 31,\n .fraction .27 30,\n .fraction .26 29,\n .fraction .25 28,\n .fraction .24 27,\n .fraction .23 26,\n .fraction .22 25,\n .fraction .21 24,\n .fraction .20 23,\n .fraction .19 22,\n .fraction .18 21,\n .fraction .17 20,\n .fraction .16 19,\n .fraction .15 18,\n .fraction .14 17,\n .fraction .13 16,\n .fraction .12 15,\n .fraction .11 14,\n .fraction .10 13,\n .fraction .9 12,\n .fraction .8 11,\n .fraction .7 10,\n .fraction .6 9,\n .fraction .5 8,\n .fraction .4 7,\n .fraction .3 6,\n .fraction .2 5,\n .fraction .1 4,\n .fraction .0 3,\n 0 2, 0 1, 0 0\n } then} .then,\n { {\n 1 55,\n .fraction .51 54,\n .fraction .50 53,\n .fraction .49 52,\n .fraction .48 51,\n .fraction .47 50,\n .fraction .46 49,\n .fraction .45 48,\n .fraction .44 47,\n .fraction .43 46,\n .fraction .42 45,\n .fraction .41 44,\n .fraction .40 43,\n .fraction .39 42,\n .fraction .38 41,\n .fraction .37 40,\n .fraction .36 39,\n .fraction .35 38,\n .fraction .34 37,\n .fraction .33 36,\n .fraction .32 35,\n .fraction .31 34,\n .fraction .30 33,\n .fraction .29 32,\n .fraction .28 31,\n .fraction .27 30,\n .fraction .26 29,\n .fraction .25 28,\n .fraction .24 27,\n .fraction .23 26,\n .fraction .22 25,\n .fraction .21 24,\n .fraction .20 23,\n .fraction .19 22,\n .fraction .18 21,\n .fraction .17 20,\n .fraction .16 19,\n .fraction .15 18,\n .fraction .14 17,\n .fraction .13 16,\n .fraction .12 15,\n .fraction .11 14,\n .fraction .10 13,\n .fraction .9 12,\n .fraction .8 11,\n .fraction .7 10,\n .fraction .6 9,\n .fraction .5 8,\n .fraction .4 7,\n .fraction .3 6,\n .fraction .2 5,\n .fraction .1 4,\n .fraction .0 3,\n 0 2, 0 1, 0 0\n } then} .then\n > $sig56;\n\nexp11_max = $exp_pair\n <\n {gt_exponent? if, .x then} .then,\n {lt_exponent? if, .y then} .then,\n {eq_exponent? if, .x then} .then\n > $exp11;\n\nexp11_abs_diff = $exp_pair\n <\n {gt_exponent? if, {.x x, .y y} exp11_sub_sum then} .then,\n {lt_exponent? if, {.y x, .x y} exp11_sub_sum then} .then,\n {eq_exponent? if, exp0 then} .then\n > $exp11;\n\nexp11_adjust = $exp11\n {exp_nonzero_bit sel, exp1 a, () b}\n mux_exp11\n $exp11;\n\nexp_gt_bit = $exp_pair\n <\n {cmp_exponent /gt if, 1 then} .then,\n 0\n > $bit;\n\nexp_lt_bit = $exp_pair\n <\n {cmp_exponent /lt if, 1 then} .then,\n 0\n > $bit;\n\nmag_gt_bit = $float_pair\n <\n {gt_magnitude_float64? if, 1 then} .then,\n 0\n > $bit;\n\nmag_eq_bit = $float_pair\n <\n {{.x .exponent x, .y .exponent y} eq_exponent? ife,\n {.x .fraction x, .y .fraction y} eq_fraction? iff,\n 1 then} .then,\n 0\n > $bit;\n\nsig56_shift_right_carry = ${sig56 sum, bit carry}\n {\n .sum sum,\n .carry carry,\n {.sum .1 x, .sum .0 y} or_bit bit0\n }\n {\n .carry 55,\n .sum .55 54,\n .sum .54 53,\n .sum .53 52,\n .sum .52 51,\n .sum .51 50,\n .sum .50 49,\n .sum .49 48,\n .sum .48 47,\n .sum .47 46,\n .sum .46 45,\n .sum .45 44,\n .sum .44 43,\n .sum .43 42,\n .sum .42 41,\n .sum .41 40,\n .sum .40 39,\n .sum .39 38,\n .sum .38 37,\n .sum .37 36,\n .sum .36 35,\n .sum .35 34,\n .sum .34 33,\n .sum .33 32,\n .sum .32 31,\n .sum .31 30,\n .sum .30 29,\n .sum .29 28,\n .sum .28 27,\n .sum .27 26,\n .sum .26 25,\n .sum .25 24,\n .sum .24 23,\n .sum .23 22,\n .sum .22 21,\n .sum .21 20,\n .sum .20 19,\n .sum .19 18,\n .sum .18 17,\n .sum .17 16,\n .sum .16 15,\n .sum .15 14,\n .sum .14 13,\n .sum .13 12,\n .sum .12 11,\n .sum .11 10,\n .sum .10 9,\n .sum .9 8,\n .sum .8 7,\n .sum .7 6,\n .sum .6 5,\n .sum .5 4,\n .sum .4 3,\n .sum .3 2,\n .sum .2 1,\n .bit0 0\n } $sig56;\n\nsig56_drop_grs = $sig56\n {\n 0 0,\n 0 1,\n 0 2,\n .3 3,\n .4 4,\n .5 5,\n .6 6,\n .7 7,\n .8 8,\n .9 9,\n .10 10,\n .11 11,\n .12 12,\n .13 13,\n .14 14,\n .15 15,\n .16 16,\n .17 17,\n .18 18,\n .19 19,\n .20 20,\n .21 21,\n .22 22,\n .23 23,\n .24 24,\n .25 25,\n .26 26,\n .27 27,\n .28 28,\n .29 29,\n .30 30,\n .31 31,\n .32 32,\n .33 33,\n .34 34,\n .35 35,\n .36 36,\n .37 37,\n .38 38,\n .39 39,\n .40 40,\n .41 41,\n .42 42,\n .43 43,\n .44 44,\n .45 45,\n .46 46,\n .47 47,\n .48 48,\n .49 49,\n .50 50,\n .51 51,\n .52 52,\n .53 53,\n .54 54,\n .55 55\n } $sig56;\n\nsig56_ulp = {} { 0 0, 0 1, 0 2, 1 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15, 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31, 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47, 0 48, 0 49, 0 50, 0 51, 0 52, 0 53, 0 54, 0 55 } $sig56;\n\nflags_add_from_bits = ${bit overflow, bit underflow, bit inexact}\n <\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_add;\n\nflags_sub_from_bits = ${bit overflow, bit underflow, bit inexact}\n <\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_sub;\n\nflags_mul_from_bits = ${bit overflow, bit underflow, bit inexact}\n <\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_mul;\n\nflags_div_from_bits = ${bit overflow, bit underflow, bit inexact, bit div_by_zero}\n <\n {.div_by_zero 1? if, div_by_zero then} .then,\n {.overflow 1? if, overflow then} .then,\n {.underflow 1? if, underflow then} .then,\n {.inexact 1? if, inexact then} .then,\n none\n > $flags_div;\n\nflags_sub_from_add = $flags_add\n <\n {/none if, none then} .then,\n {/invalid if, invalid then} .then,\n {/overflow if, overflow then} .then,\n {/underflow if, underflow then} .then,\n {/inexact if, inexact then} .then\n > $flags_sub;\n\nexp_all_ones_bit = $exp11\n <\n {all_ones_exponent? if, 1 then} .then,\n 0\n > $bit;\n\nexp_zero_bit = $exp11\n <\n {zero_exponent? if, 1 then} .then,\n 0\n > $bit;\n\nunderflow_bit_of = ${exp11 exp, bit inexact}\n <\n {.exp zero_exponent? ife, .inexact 1? ifi, 1 then} .then,\n 0\n > $bit;\n\n\n$round_in = {sig56 sig, exp11 exp};\n$round_out = {sig56 sig, exp11 exp, bit inexact};\n\nsign_eq_bit = $sign_pair\n <\n {eq_sign? if, 1 then} .then,\n 0\n > $bit;\n\nmux_sign = ${bit sel, sign a, sign b}\n <\n {.sel 0? if, .a then} .then,\n {.sel 1? if, .b then} .then\n > $sign;\n\nround_sig56 = $round_in\n {\n .sig sig,\n .exp exp,\n .sig .2 guard,\n .sig .1 round,\n .sig .0 sticky\n }\n {\n .sig sig,\n .exp exp,\n .guard guard,\n .round round,\n .sticky sticky,\n {.guard x, {{.round x, .sticky y} or_bit x, .sig .3 y} or_bit y} and_bit inc,\n {.guard x, {.round x, .sticky y} or_bit y} or_bit inexact\n }\n {\n .sig sig,\n .exp exp,\n .inc inc,\n .inexact inexact,\n (.sig sig56_drop_grs) trunc,\n () sig56_ulp ulp\n }\n {\n .exp exp,\n .inc inc,\n .inexact inexact,\n .trunc trunc,\n .ulp ulp,\n {.trunc x, .ulp y} sig56_add sum1\n }\n {\n .exp exp,\n .inc inc,\n .inexact inexact,\n .trunc trunc,\n .sum1 sum1,\n {.inc sel, .trunc a, .sum1.sum b} mux_sig56 sig_inc,\n .sum1.carry carry_inc,\n (.exp exp11_inc) exp_inc\n }\n {\n .sig_inc sig_inc,\n .exp exp,\n .inexact inexact,\n .carry_inc carry_inc,\n .exp_inc exp_inc,\n {.carry_inc sel, .sig_inc a, {.sig_inc sum, .carry_inc carry} sig56_shift_right_carry b} mux_sig56 sig_out,\n {.carry_inc sel, .exp a, .exp_inc b} mux_exp11 exp_out\n }\n { .sig_out sig, .exp_out exp, .inexact inexact }\n $round_out;\n\n\n\n+ = {} |+ $sign;\n- = {} |- $sign;\n\neq = {} |eq $cmp_state;\ngt = {} |gt $cmp_state;\nlt = {} |lt $cmp_state;\n\neq_exact_cmp = {} |eq_exact $cmp;\neq_zero_cmp = {} |eq_zero $cmp;\ngt_cmp = {} |gt $cmp;\nlt_cmp = {} |lt $cmp;\nunordered_nan_cmp = {} |unordered_nan $cmp;\n\n0? = $bit {/0 if, () then} .then $bit;\n1? = $bit {/1 if, () then} .then $bit;\n\n+? = $sign {/+ if, () then} .then $sign;\n-? = $sign {/- if, () then} .then $sign;\n\neq_bit? = $bit_pair\n <\n {.x 0? ifx, .y 0? ify, () then} .then,\n {.x 1? ifx, .y 1? ify, () then} .then\n > $bit_pair;\n\ngt_bit? = $bit_pair\n {.x 1? ifx, .y 0? ify, () then} .then\n $bit_pair;\n\nlt_bit? = $bit_pair\n {.x 0? ifx, .y 1? ify, () then} .then\n $bit_pair;\n\neq_sign? = $sign_pair\n <\n {.x +? ifx, .y +? ify, () then} .then,\n {.x -? ifx, .y -? ify, () then} .then\n > $sign_pair;\n\nzero_exponent? = $exp11\n {.0 0? if0, .1 0? if1, .2 0? if2, .3 0? if3, .4 0? if4, .5 0? if5, .6 0? if6, .7 0? if7, .8 0? if8, .9 0? if9, .10 0? if10, () then} .then\n $exp11;\n\nall_ones_exponent? = $exp11\n {.0 1? if0, .1 1? if1, .2 1? if2, .3 1? if3, .4 1? if4, .5 1? if5, .6 1? if6, .7 1? if7, .8 1? if8, .9 1? if9, .10 1? if10, () then} .then\n $exp11;\n\nnot_all_ones_exponent? = $exp11\n {<.10 0?, .9 0?, .8 0?, .7 0?, .6 0?, .5 0?, .4 0?, .3 0?, .2 0?, .1 0?, .0 0?> if, () then} .then\n $exp11;\n\nzero_fraction? = $frac52\n {.51 0? if51, .50 0? if50, .49 0? if49, .48 0? if48, .47 0? if47, .46 0? if46, .45 0? if45, .44 0? if44, .43 0? if43, .42 0? if42,\n .41 0? if41, .40 0? if40, .39 0? if39, .38 0? if38, .37 0? if37, .36 0? if36, .35 0? if35, .34 0? if34, .33 0? if33, .32 0? if32,\n .31 0? if31, .30 0? if30, .29 0? if29, .28 0? if28, .27 0? if27, .26 0? if26, .25 0? if25, .24 0? if24, .23 0? if23, .22 0? if22,\n .21 0? if21, .20 0? if20, .19 0? if19, .18 0? if18, .17 0? if17, .16 0? if16, .15 0? if15, .14 0? if14, .13 0? if13, .12 0? if12,\n .11 0? if11, .10 0? if10, .9 0? if9, .8 0? if8, .7 0? if7, .6 0? if6, .5 0? if5, .4 0? if4, .3 0? if3, .2 0? if2, .1 0? if1, .0 0? if0,\n () then} .then\n $frac52;\n\nnonzero_fraction? = $frac52\n {<.51 1?, .50 1?, .49 1?, .48 1?, .47 1?, .46 1?, .45 1?, .44 1?, .43 1?, .42 1?,\n .41 1?, .40 1?, .39 1?, .38 1?, .37 1?, .36 1?, .35 1?, .34 1?, .33 1?, .32 1?,\n .31 1?, .30 1?, .29 1?, .28 1?, .27 1?, .26 1?, .25 1?, .24 1?, .23 1?, .22 1?,\n .21 1?, .20 1?, .19 1?, .18 1?, .17 1?, .16 1?, .15 1?, .14 1?, .13 1?, .12 1?,\n .11 1?, .10 1?, .9 1?, .8 1?, .7 1?, .6 1?, .5 1?, .4 1?, .3 1?, .2 1?, .1 1?, .0 1?> if, () then} .then\n $frac52;\n\nnan_float64? = $float64\n {.exponent all_ones_exponent? ife, .fraction nonzero_fraction? iff, () then} .then\n $float64;\n\ninf_float64? = $float64\n {.exponent all_ones_exponent? ife, .fraction zero_fraction? iff, () then} .then\n $float64;\n\nfinite_float64? = $float64\n {.exponent not_all_ones_exponent? ife, () then} .then\n $float64;\n\nordered_float64? = $float64\n <finite_float64?, inf_float64?>\n $float64;\n\nzero_float64? = $float64\n {.exponent zero_exponent? ife, .fraction zero_fraction? iff, () then} .then\n $float64;\n\ncmp_step = $cmp_step_in\n <\n {.state /gt if, gt then} .then,\n {.state /lt if, lt then} .then,\n {.state /eq if,\n <\n {.bits gt_bit? if, gt then} .then,\n {.bits lt_bit? if, lt then} .then,\n {.bits eq_bit? if, eq then} .then\n > then\n } .then\n > $cmp_state;\n\nstepE10 = $cmp_exp_ctx {{.state state, {.pair .x .10 x, .pair .y .10 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE9 = $cmp_exp_ctx {{.state state, {.pair .x .9 x, .pair .y .9 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE8 = $cmp_exp_ctx {{.state state, {.pair .x .8 x, .pair .y .8 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE7 = $cmp_exp_ctx {{.state state, {.pair .x .7 x, .pair .y .7 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE6 = $cmp_exp_ctx {{.state state, {.pair .x .6 x, .pair .y .6 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE5 = $cmp_exp_ctx {{.state state, {.pair .x .5 x, .pair .y .5 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE4 = $cmp_exp_ctx {{.state state, {.pair .x .4 x, .pair .y .4 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE3 = $cmp_exp_ctx {{.state state, {.pair .x .3 x, .pair .y .3 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE2 = $cmp_exp_ctx {{.state state, {.pair .x .2 x, .pair .y .2 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE1 = $cmp_exp_ctx {{.state state, {.pair .x .1 x, .pair .y .1 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\nstepE0 = $cmp_exp_ctx {{.state state, {.pair .x .0 x, .pair .y .0 y} bits} cmp_step state, .pair pair} $cmp_exp_ctx;\n\ncmp_exponent = $exp_pair\n {eq state, () pair} $cmp_exp_ctx\n stepE10 stepE9 stepE8 stepE7 stepE6 stepE5 stepE4 stepE3 stepE2 stepE1 stepE0\n .state\n $cmp_state;\n\ngt_exponent? = $exp_pair {cmp_exponent /gt if, () then} .then $exp_pair;\neq_exponent? = $exp_pair {cmp_exponent /eq if, () then} .then $exp_pair;\nlt_exponent? = $exp_pair {cmp_exponent /lt if, () then} .then $exp_pair;\n\nstepF51 = $cmp_frac_ctx {{.state state, {.pair .x .51 x, .pair .y .51 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF50 = $cmp_frac_ctx {{.state state, {.pair .x .50 x, .pair .y .50 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF49 = $cmp_frac_ctx {{.state state, {.pair .x .49 x, .pair .y .49 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF48 = $cmp_frac_ctx {{.state state, {.pair .x .48 x, .pair .y .48 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF47 = $cmp_frac_ctx {{.state state, {.pair .x .47 x, .pair .y .47 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF46 = $cmp_frac_ctx {{.state state, {.pair .x .46 x, .pair .y .46 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF45 = $cmp_frac_ctx {{.state state, {.pair .x .45 x, .pair .y .45 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF44 = $cmp_frac_ctx {{.state state, {.pair .x .44 x, .pair .y .44 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF43 = $cmp_frac_ctx {{.state state, {.pair .x .43 x, .pair .y .43 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF42 = $cmp_frac_ctx {{.state state, {.pair .x .42 x, .pair .y .42 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF41 = $cmp_frac_ctx {{.state state, {.pair .x .41 x, .pair .y .41 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF40 = $cmp_frac_ctx {{.state state, {.pair .x .40 x, .pair .y .40 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF39 = $cmp_frac_ctx {{.state state, {.pair .x .39 x, .pair .y .39 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF38 = $cmp_frac_ctx {{.state state, {.pair .x .38 x, .pair .y .38 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF37 = $cmp_frac_ctx {{.state state, {.pair .x .37 x, .pair .y .37 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF36 = $cmp_frac_ctx {{.state state, {.pair .x .36 x, .pair .y .36 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF35 = $cmp_frac_ctx {{.state state, {.pair .x .35 x, .pair .y .35 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF34 = $cmp_frac_ctx {{.state state, {.pair .x .34 x, .pair .y .34 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF33 = $cmp_frac_ctx {{.state state, {.pair .x .33 x, .pair .y .33 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF32 = $cmp_frac_ctx {{.state state, {.pair .x .32 x, .pair .y .32 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF31 = $cmp_frac_ctx {{.state state, {.pair .x .31 x, .pair .y .31 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF30 = $cmp_frac_ctx {{.state state, {.pair .x .30 x, .pair .y .30 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF29 = $cmp_frac_ctx {{.state state, {.pair .x .29 x, .pair .y .29 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF28 = $cmp_frac_ctx {{.state state, {.pair .x .28 x, .pair .y .28 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF27 = $cmp_frac_ctx {{.state state, {.pair .x .27 x, .pair .y .27 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF26 = $cmp_frac_ctx {{.state state, {.pair .x .26 x, .pair .y .26 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF25 = $cmp_frac_ctx {{.state state, {.pair .x .25 x, .pair .y .25 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF24 = $cmp_frac_ctx {{.state state, {.pair .x .24 x, .pair .y .24 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF23 = $cmp_frac_ctx {{.state state, {.pair .x .23 x, .pair .y .23 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF22 = $cmp_frac_ctx {{.state state, {.pair .x .22 x, .pair .y .22 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF21 = $cmp_frac_ctx {{.state state, {.pair .x .21 x, .pair .y .21 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF20 = $cmp_frac_ctx {{.state state, {.pair .x .20 x, .pair .y .20 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF19 = $cmp_frac_ctx {{.state state, {.pair .x .19 x, .pair .y .19 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF18 = $cmp_frac_ctx {{.state state, {.pair .x .18 x, .pair .y .18 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF17 = $cmp_frac_ctx {{.state state, {.pair .x .17 x, .pair .y .17 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF16 = $cmp_frac_ctx {{.state state, {.pair .x .16 x, .pair .y .16 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF15 = $cmp_frac_ctx {{.state state, {.pair .x .15 x, .pair .y .15 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF14 = $cmp_frac_ctx {{.state state, {.pair .x .14 x, .pair .y .14 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF13 = $cmp_frac_ctx {{.state state, {.pair .x .13 x, .pair .y .13 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF12 = $cmp_frac_ctx {{.state state, {.pair .x .12 x, .pair .y .12 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF11 = $cmp_frac_ctx {{.state state, {.pair .x .11 x, .pair .y .11 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF10 = $cmp_frac_ctx {{.state state, {.pair .x .10 x, .pair .y .10 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF9 = $cmp_frac_ctx {{.state state, {.pair .x .9 x, .pair .y .9 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF8 = $cmp_frac_ctx {{.state state, {.pair .x .8 x, .pair .y .8 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF7 = $cmp_frac_ctx {{.state state, {.pair .x .7 x, .pair .y .7 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF6 = $cmp_frac_ctx {{.state state, {.pair .x .6 x, .pair .y .6 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF5 = $cmp_frac_ctx {{.state state, {.pair .x .5 x, .pair .y .5 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF4 = $cmp_frac_ctx {{.state state, {.pair .x .4 x, .pair .y .4 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF3 = $cmp_frac_ctx {{.state state, {.pair .x .3 x, .pair .y .3 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF2 = $cmp_frac_ctx {{.state state, {.pair .x .2 x, .pair .y .2 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF1 = $cmp_frac_ctx {{.state state, {.pair .x .1 x, .pair .y .1 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\nstepF0 = $cmp_frac_ctx {{.state state, {.pair .x .0 x, .pair .y .0 y} bits} cmp_step state, .pair pair} $cmp_frac_ctx;\n\ncmp_fraction = $frac_pair\n {eq state, () pair} $cmp_frac_ctx\n stepF51 stepF50 stepF49 stepF48 stepF47 stepF46 stepF45 stepF44 stepF43 stepF42 stepF41 stepF40 stepF39 stepF38 stepF37 stepF36 stepF35 stepF34 stepF33 stepF32 stepF31 stepF30\n stepF29 stepF28 stepF27 stepF26 stepF25 stepF24 stepF23 stepF22 stepF21 stepF20 stepF19 stepF18 stepF17 stepF16 stepF15 stepF14 stepF13 stepF12 stepF11 stepF10 stepF9 stepF8 stepF7 stepF6 stepF5 stepF4 stepF3 stepF2 stepF1 stepF0\n .state\n $cmp_state;\n\ngt_fraction? = $frac_pair {cmp_fraction /gt if, () then} .then $frac_pair;\neq_fraction? = $frac_pair {cmp_fraction /eq if, () then} .then $frac_pair;\n\ngt_magnitude_float64? = $float_pair\n <\n {{.x .exponent x, .y .exponent y} gt_exponent? if, () then} .then,\n {{.x .exponent x, .y .exponent y} eq_exponent? ife, {.x .fraction x, .y .fraction y} gt_fraction? iff, () then} .then\n > $float_pair;\n\ncmp_float64 = $float_pair\n <\n {<.x nan_float64?, .y nan_float64?> if, unordered_nan_cmp then} .then,\n {.x zero_float64? ifx, .y zero_float64? ify, eq_zero_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify,\n {.x .sign x, .y .sign y} eq_sign? ifs,\n {.x .exponent x, .y .exponent y} eq_exponent? ife,\n {.x .fraction x, .y .fraction y} eq_fraction? iff,\n eq_exact_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign +? ifsx, .y .sign -? ifsy, gt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign -? ifsx, .y .sign +? ifsy, lt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign +? ifsx, .y .sign +? ifsy, gt_magnitude_float64? ifm, gt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign +? ifsx, .y .sign +? ifsy, {.y x, .x y} gt_magnitude_float64? ifm, lt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign -? ifsx, .y .sign -? ifsy, {.y x, .x y} gt_magnitude_float64? ifm, gt_cmp then} .then,\n {.x ordered_float64? ifx, .y ordered_float64? ify, .x .sign -? ifsx, .y .sign -? ifsy, gt_magnitude_float64? ifm, lt_cmp then} .then\n > $cmp;\n\neq_float64? = $float_pair {<cmp_float64 /eq_zero, cmp_float64 /eq_exact> if, () then} .then $float_pair;\ngt_float64? = $float_pair {cmp_float64 /gt if, () then} .then $float_pair;\nlt_float64? = $float_pair {cmp_float64 /lt if, () then} .then $float_pair;\nle_float64? = $float_pair {<cmp_float64 /lt, cmp_float64 /eq_zero, cmp_float64 /eq_exact> if, () then} .then $float_pair;\nge_float64? = $float_pair {<cmp_float64 /gt, cmp_float64 /eq_zero, cmp_float64 /eq_exact> if, () then} .then $float_pair;\n\nexp0 = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10} $exp11;\nexp_all1 = {} {1 0, 1 1, 1 2, 1 3, 1 4, 1 5, 1 6, 1 7, 1 8, 1 9, 1 10} $exp11;\n\nfrac0 = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31,\n 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47,\n 0 48, 0 49, 0 50, 0 51} $frac52;\n\nfrac_lsb1 = {} {1 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31,\n 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47,\n 0 48, 0 49, 0 50, 0 51} $frac52;\n\npos_zero = {} {+ sign, exp0 exponent, frac0 fraction} $float64;\nneg_zero = {} {- sign, exp0 exponent, frac0 fraction} $float64;\n\npos_inf = {} {+ sign, exp_all1 exponent, frac0 fraction} $float64;\nneg_inf = {} {- sign, exp_all1 exponent, frac0 fraction} $float64;\n\nqnan = {} {+ sign, exp_all1 exponent, frac_lsb1 fraction} $float64;\n\nflip_sign = $sign\n <\n {+? if, {} |- $sign then} .then,\n {-? if, {} |+ $sign then} .then\n > $sign;\n\nxor_sign = $sign_pair\n <\n {.x +? ifx, .y +? ify, {} |+ $sign then} .then,\n {.x +? ifx, .y -? ify, {} |- $sign then} .then,\n {.x -? ifx, .y +? ify, {} |- $sign then} .then,\n {.x -? ifx, .y -? ify, {} |+ $sign then} .then\n > $sign;\n\nopp_sign? = $sign_pair\n <\n {.x +? ifx, .y -? ify, () then} .then,\n {.x -? ifx, .y +? ify, () then} .then\n > $sign_pair;\n\ninf_of_sign = $sign\n <\n {+? if, pos_inf then} .then,\n {-? if, neg_inf then} .then\n > $float64;\n\nzero_of_sign = $sign\n <\n {+? if, pos_zero then} .then,\n {-? if, neg_zero then} .then\n > $float64;\n\nnegate_float64 = $float64\n {.sign flip_sign sign, .exponent exponent, .fraction fraction}\n $float64;\n\npair_signs = $float_pair\n {.x .sign x, .y .sign y}\n $sign_pair;\n\nxor_sign_of_pair = $float_pair\n pair_signs xor_sign\n $sign;\n\nopp_signs_of_pair? = $float_pair\n pair_signs opp_sign?\n $sign_pair;\n\ninf_from_pair_sign = $float_pair\n xor_sign_of_pair inf_of_sign\n $float64;\n\nzero_from_pair_sign = $float_pair\n xor_sign_of_pair zero_of_sign\n $float64;\n\nadd_float64 = $float_pair\n float64_add\n .result\n $float64;\n\n$add_same_in = {sig56 x, sig56 y, exp11 exp, sign sign};\n$add_same_out = {sig56 sig, exp11 exp, bit inexact, bit overflow, bit underflow, sign sign};\n$sub_same_in = {sig56 big, sig56 small, exp11 exp, sign sign};\n$sub_same_out = {sig56 sig, exp11 exp, bit inexact, bit overflow, bit underflow, sign sign};\n\nfloat64_from_parts = ${sign sign, exp11 exponent, sig56 sig}\n {.sign sign, .exponent exponent, (.sig frac52_from_sig56) fraction}\n $float64;\n\nadd_same_sign = $add_same_in\n {\n .exp exp,\n .sign sign,\n {.x x, .y y} sig56_add sum1\n }\n {\n .exp exp,\n .sign sign,\n .sum1 sum1,\n (.exp exp11_inc) exp_inc\n }\n {\n .sign sign,\n {.sum1.carry sel, .exp a, .exp_inc b} mux_exp11 exp_pre,\n {.sum1.carry sel, .sum1.sum a, {.sum1.sum sum, .sum1.carry carry} sig56_shift_right_carry b} mux_sig56 sig_pre\n }\n {\n .sign sign,\n .sig_pre sig_pre,\n .exp_pre exp_pre,\n { .sig_pre sig, .exp_pre exp } round_sig56 round_out\n }\n {\n .sign sign,\n .round_out .sig sig_round,\n .round_out .exp exp_round,\n .round_out .inexact inexact\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n (.exp_round exp_all_ones_bit) overflow,\n { .exp_round exp, .inexact inexact} underflow_bit_of underflow\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n .overflow overflow,\n .underflow underflow,\n {.overflow x, .inexact y} or_bit inexact_final\n }\n { .sig_round sig, .exp_round exp, .inexact_final inexact, .overflow overflow, .underflow underflow, .sign sign }\n $add_same_out;\n\nsub_same_sign = $sub_same_in\n {\n .exp exp,\n .sign sign,\n {.big x, .small y} sig56_sub_sum diff\n }\n {\n .exp exp,\n .sign sign,\n .diff diff,\n { .diff sig, .exp exp } normalize_left norm\n }\n {\n .sign sign,\n .norm norm,\n .norm .sig sig_norm,\n .norm .exp exp_norm\n }\n {\n .sign sign,\n .sig_norm sig_norm,\n .exp_norm exp_norm,\n { .sig_norm sig, .exp_norm exp } round_sig56 round_out\n }\n {\n .sign sign,\n .round_out .sig sig_round,\n .round_out .exp exp_round,\n .round_out .inexact inexact\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n (.exp_round exp_all_ones_bit) overflow,\n { .exp_round exp, .inexact inexact} underflow_bit_of underflow\n }\n {\n .sign sign,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n .overflow overflow,\n .underflow underflow,\n {.overflow x, .inexact y} or_bit inexact_final\n }\n { .sig_round sig, .exp_round exp, .inexact_final inexact, .overflow overflow, .underflow underflow, .sign sign }\n $sub_same_out;\n\nfloat64_add_finite = $float_pair\n {\n .x x,\n .y y,\n (.x sig56_from_float64) sigx,\n (.y sig56_from_float64) sigy,\n {.x .exponent x, .y .exponent y} exp_pair,\n {.x .sign x, .y .sign y} sign_pair,\n .x .sign sign_x,\n .y .sign sign_y,\n {.x x, .y y} mag_gt_bit mag_gt,\n {.x x, .y y} mag_eq_bit mag_eq\n }\n {\n .sigx sigx,\n .sigy sigy,\n (.exp_pair exp11_max) exp_max,\n (.exp_pair exp11_abs_diff) exp_diff,\n (.exp_pair exp_gt_bit) exp_gt,\n (.exp_pair exp_lt_bit) exp_lt,\n (.sign_pair sign_eq_bit) sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq\n }\n {\n .sigx sigx,\n .sigy sigy,\n .exp_max exp_max,\n (.exp_diff shift6_from_exp11) shamt,\n .exp_gt exp_gt,\n .exp_lt exp_lt,\n .sign_eq sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq\n }\n {\n .sigx sigx,\n .sigy sigy,\n .exp_max exp_max,\n .exp_gt exp_gt,\n .exp_lt exp_lt,\n .sign_eq sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq,\n {.sigx x, .shamt s} shift_right_sig56 shx,\n {.sigy x, .shamt s} shift_right_sig56 shy\n }\n {\n .exp_max exp_max,\n .sign_eq sign_eq,\n .sign_x sign_x,\n .sign_y sign_y,\n .mag_gt mag_gt,\n .mag_eq mag_eq,\n {.exp_lt sel, .sigx a, .shx b} mux_sig56 sigx_al,\n {.exp_gt sel, .sigy a, .shy b} mux_sig56 sigy_al\n }\n <\n {.sign_eq 1? if,\n {\n .sign_x sign_x,\n {.sigx_al x, .sigy_al y, .exp_max exp, .sign_x sign} add_same_sign out\n }\n {\n .sign_x sign_x,\n .out out,\n .out .sig sig_round,\n .out .exp exp_round,\n .out .inexact inexact,\n .out .overflow overflow,\n .out .underflow underflow\n }\n {\n .sign_x sign_x,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n {.overflow overflow, .underflow underflow, .inexact inexact} flags_add_from_bits flags,\n (.sign_x inf_of_sign) inf_res\n }\n {\n .flags flags,\n .overflow overflow,\n .inf_res inf_res,\n {.sign_x sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res\n }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > then} .then,\n {.sign_eq 0? if,\n <\n {.mag_eq 1? if, {pos_zero result, none flags} then} .then,\n {.mag_eq 0? if,\n {\n .exp_max exp_max,\n {.mag_gt sel, .sigy_al a, .sigx_al b} mux_sig56 big,\n {.mag_gt sel, .sigx_al a, .sigy_al b} mux_sig56 small,\n {.mag_gt sel, .sign_y a, .sign_x b} mux_sign sign_out\n }\n {\n .sign_out sign_out,\n {.big big, .small small, .exp_max exp, .sign_out sign} sub_same_sign out\n }\n {\n .sign_out sign_out,\n .out out,\n .out .sig sig_round,\n .out .exp exp_round,\n .out .inexact inexact,\n .out .overflow overflow,\n .out .underflow underflow\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n {.overflow overflow, .underflow underflow, .inexact inexact} flags_add_from_bits flags,\n (.sign_out inf_of_sign) inf_res\n }\n {\n .flags flags,\n .overflow overflow,\n .inf_res inf_res,\n {.sign_out sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res\n }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > then} .then\n > then} .then\n > $add_result;\n\nfloat64_add = $float_pair\n <\n {.x nan_float64? ifx, {qnan result, none flags} then} .then,\n {.y nan_float64? ify, {qnan result, none flags} then} .then,\n {.x inf_float64? ifx, .y inf_float64? ify, opp_signs_of_pair? ifs, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, {.x result, none flags} then} .then,\n {.y inf_float64? ify, {.y result, none flags} then} .then,\n {.x zero_float64? ifx, .y zero_float64? ify, {pos_zero result, none flags} then} .then,\n {.x zero_float64? ifx, {.y result, none flags} then} .then,\n {.y zero_float64? ify, {.x result, none flags} then} .then,\n {.x finite_float64? ifx, .y finite_float64? ify, float64_add_finite then} .then\n > $add_result;\n\nnegate_y_pair = $float_pair\n {.x x, (.y negate_float64) y}\n $float_pair;\n\nsub_float64 = $float_pair\n negate_y_pair\n add_float64\n $float64;\n\nfloat64_sub = $float_pair\n negate_y_pair\n float64_add\n { .result result, (.flags flags_sub_from_add) flags }\n $sub_result;\n\nfloat64_mul_finite = $float_pair\n { {.x x, .y y} args }\n { .args args, {.args .x .sign x, .args .y .sign y} xor_sign sign_out }\n { .args args, .sign_out sign_out, .args .x .exponent exp_x }\n { .args args, .sign_out sign_out, .exp_x exp_x, .args .y .exponent exp_y }\n { .args args, .sign_out sign_out, .exp_x exp_x, .exp_y exp_y, {.exp_x x, .exp_y y} exp11_add_sum exp_sum }\n { .args args, .sign_out sign_out, .exp_sum exp_sum, (.args .x sig56_from_float64) sigx }\n { .sign_out sign_out, .exp_sum exp_sum, .sigx sigx, (.args .y sig56_from_float64) sigy }\n { .sign_out sign_out, .sigx sigx, .sigy sigy, .exp_sum exp_sum, {.exp_sum x, () exp_1023 y} exp11_sub_sum exp_pre }\n { .sign_out sign_out, .exp_pre exp_pre, .sigx sigx, .sigy sigy, {.sigx x, .sigy y} sig56_mul_unsigned prod }\n { .sign_out sign_out, .exp_pre exp_pre, .prod prod, .prod .111 msb111 }\n { .sign_out sign_out, .exp_pre exp_pre, .prod prod, .msb111 msb111, (.exp_pre exp11_inc) exp_inc }\n { .sign_out sign_out, .exp_pre exp_pre, .prod prod, .msb111 msb111, .exp_inc exp_inc, (.prod sig56_from_sig112_shift55) sig_pre0 }\n { .sign_out sign_out, .exp_pre exp_pre, .msb111 msb111, .exp_inc exp_inc, .sig_pre0 sig_pre0, (.prod sig56_from_sig112_shift56) sig_pre1 }\n { .sign_out sign_out, .msb111 msb111, .exp_pre exp_pre, .exp_inc exp_inc, .sig_pre0 sig_pre0, .sig_pre1 sig_pre1, {.msb111 sel, .exp_pre a, .exp_inc b} mux_exp11 exp_norm }\n { .sign_out sign_out, .exp_norm exp_norm, .msb111 msb111, .sig_pre0 sig_pre0, .sig_pre1 sig_pre1, {.msb111 sel, .sig_pre0 a, .sig_pre1 b} mux_sig56 sig_pre }\n { .sign_out sign_out, .exp_norm exp_norm, .sig_pre sig_pre, { .sig_pre sig, .exp_norm exp } round_sig56 round_out }\n { .sign_out sign_out, .round_out round_out, .round_out .sig sig_round }\n { .sign_out sign_out, .round_out round_out, .sig_round sig_round, .round_out .exp exp_round }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .round_out .inexact inexact }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .inexact inexact, (.exp_round exp_all_ones_bit) overflow }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .inexact inexact, { .exp_round exp, .inexact inexact} underflow_bit_of underflow }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .underflow underflow, .inexact inexact, {.overflow x, .inexact y} or_bit inexact_final }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .underflow underflow, .inexact_final inexact_final, {.overflow overflow, .underflow underflow, .inexact_final inexact} flags_mul_from_bits flags }\n { .sign_out sign_out, .sig_round sig_round, .exp_round exp_round, .overflow overflow, .flags flags, (.sign_out inf_of_sign) inf_res }\n { .overflow overflow, .flags flags, .inf_res inf_res, {.sign_out sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res }\n { .overflow overflow, .flags flags, .inf_res inf_res, .float_res float_res }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > $mul_result;\n\nfloat64_mul = $float_pair\n <\n {.x nan_float64? ifx, {qnan result, none flags} then} .then,\n {.y nan_float64? ify, {qnan result, none flags} then} .then,\n {.x inf_float64? ifx, .y zero_float64? ify, {qnan result, invalid flags} then} .then,\n {.x zero_float64? ifx, .y inf_float64? ify, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, .y ordered_float64? ify, {inf_from_pair_sign result, none flags} then} .then,\n {.y inf_float64? ify, .x ordered_float64? ifx, {inf_from_pair_sign result, none flags} then} .then,\n {.x zero_float64? ifx, .y ordered_float64? ify, {zero_from_pair_sign result, none flags} then} .then,\n {.y zero_float64? ify, .x ordered_float64? ifx, {zero_from_pair_sign result, none flags} then} .then,\n {.x finite_float64? ifx, .y finite_float64? ify, float64_mul_finite then} .then\n > $mul_result;\n\nmul_float64 = $float_pair\n float64_mul\n .result\n $float64;\n\nfloat64_div_finite = $float_pair\n {\n (.x sig56_from_float64) sigx,\n (.y sig56_from_float64) sigy,\n {.x .sign x, .y .sign y} xor_sign sign_out,\n {.x .exponent x, .y .exponent y} exp11_sub_sum exp_diff\n }\n {\n .sign_out sign_out,\n .sigx sigx,\n .sigy sigy,\n {.exp_diff x, () exp_1023 y} exp11_add_sum exp_pre\n }\n {\n .sign_out sign_out,\n .exp_pre exp_pre,\n {.sigx x, .sigy y} sig56_div_unsigned quot\n }\n {\n .sign_out sign_out,\n .exp_pre exp_pre,\n .quot quot,\n .quot .55 msb55,\n (.exp_pre exp11_dec) exp_dec,\n (.quot shift_left_sig56_1) quot_sh\n }\n {\n .sign_out sign_out,\n {.msb55 sel, .exp_dec a, .exp_pre b} mux_exp11 exp_adj,\n {.msb55 sel, .quot_sh a, .quot b} mux_sig56 sig_pre\n }\n {\n .sign_out sign_out,\n .exp_adj exp_adj,\n .sig_pre sig_pre,\n { .sig_pre sig, .exp_adj exp } round_sig56 round_out\n }\n {\n .sign_out sign_out,\n .round_out .sig sig_round,\n .round_out .exp exp_round,\n .round_out .inexact inexact\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n (.exp_round exp_all_ones_bit) overflow\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .inexact inexact,\n .overflow overflow,\n { .exp_round exp, .inexact inexact} underflow_bit_of underflow\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n .underflow underflow,\n .inexact inexact,\n {.overflow x, .inexact y} or_bit inexact_final\n }\n {\n .sign_out sign_out,\n .sig_round sig_round,\n .exp_round exp_round,\n .overflow overflow,\n .underflow underflow,\n .inexact_final inexact_final,\n {0 div_by_zero, .overflow overflow, .underflow underflow, .inexact_final inexact} flags_div_from_bits flags,\n (.sign_out inf_of_sign) inf_res,\n {.sign_out sign, .exp_round exponent, (.sig_round frac52_from_sig56) fraction} float_res\n }\n {\n .flags flags,\n .overflow overflow,\n .inf_res inf_res,\n .float_res float_res\n }\n <\n {.overflow 1? if, {.inf_res result, .flags flags} then} .then,\n {.overflow 0? if, {.float_res result, .flags flags} then} .then\n > $div_result;\n\nfloat64_div = $float_pair\n <\n {.x nan_float64? ifx, {qnan result, none flags} then} .then,\n {.y nan_float64? ify, {qnan result, none flags} then} .then,\n {.x zero_float64? ifx, .y zero_float64? ify, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, .y inf_float64? ify, {qnan result, invalid flags} then} .then,\n {.x inf_float64? ifx, .y ordered_float64? ify, {inf_from_pair_sign result, none flags} then} .then,\n {.x ordered_float64? ifx, .y inf_float64? ify, {zero_from_pair_sign result, none flags} then} .then,\n {.x ordered_float64? ifx, .y zero_float64? ify, {inf_from_pair_sign result, div_by_zero flags} then} .then,\n {.x zero_float64? ifx, .y ordered_float64? ify, {zero_from_pair_sign result, none flags} then} .then,\n {.x finite_float64? ifx, .y finite_float64? ify, float64_div_finite then} .then\n > $div_result;\n\ndiv_float64 = $float_pair\n float64_div\n .result\n $float64;\n\n# -----------------------------------------------------------------------------\n# Public API\n# -----------------------------------------------------------------------------\n# Operations return a product with:\n# result : float64\n# flags : operation-specific exception flags\n#\n# Use `add .result`, `mul .result`, etc. when only the numeric result is needed.\n\nadd = float64_add;\nsub = float64_sub;\nmul = float64_mul;\ndiv = float64_div;\n\ncmp = cmp_float64;\neq? = eq_float64?;\nlt? = lt_float64?;\nle? = le_float64?;\ngt? = gt_float64?;\nge? = ge_float64?;\n\nneg = negate_float64;\n\n# --- useful float64 constants (IEEE-754 binary64) ---\n\n# 1.0 exponent = 1023 = 0b01111111111\nexp_1 = {} {1 0, 1 1, 1 2, 1 3, 1 4, 1 5, 1 6, 1 7, 1 8, 1 9, 0 10} $exp11;\n\n# 10.0 exponent = 1026 = 1023 + 3 = 0b10000000010\nexp_10 = {} {0 0, 1 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 1 10} $exp11;\n\n# 10.0 significand = 1.01b => fraction bit 50 = 1 (2^-2), everything else 0\nfrac_10 = {} {0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 0 29, 0 30, 0 31,\n 0 32, 0 33, 0 34, 0 35, 0 36, 0 37, 0 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 0 45, 0 46, 0 47,\n 0 48, 0 49, 1 50, 0 51} $frac52;\n\n# signed zeros (aliases)\n0f = pos_zero;\n-0f = neg_zero;\n\n# 1.0, -1.0, 10.0\n1f = {} {+ sign, exp_1 exponent, frac0 fraction} $float64;\n-1f = {} {- sign, exp_1 exponent, frac0 fraction} $float64;\n10f = {} {+ sign, exp_10 exponent, frac_10 fraction} $float64;\n\n()\n\n/*\n-- TESTS --\n# -----------------------------------------------------------------------------\n# Extra constants (finite) for comparisons\n# -----------------------------------------------------------------------------\n\n# exponent = 1024: 0b10000000000\nexp_1024 = {}\n { 1 10,\n 0 9, 0 8, 0 7, 0 6, 0 5, 0 4, 0 3, 0 2, 0 1, 0 0\n } $exp11;\n\n# exponent = 1056: 0b10000100000 (10^10 range)\nexp_1e10 = {}\n { 0 0, 0 1, 0 2, 0 3, 0 4, 1 5, 0 6, 0 7, 0 8, 0 9, 1 10 } $exp11;\n\nfrac_1e10 = {}\n { 0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 0 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 1 29, 0 30, 0 31,\n 1 32, 1 33, 1 34, 1 35, 1 36, 0 37, 1 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 1 45, 0 46, 1 47,\n 0 48, 1 49, 0 50, 0 51 } $frac52;\n\nfrac_1e10_p1 = {}\n { 0 0, 0 1, 0 2, 0 3, 0 4, 0 5, 0 6, 0 7, 0 8, 0 9, 0 10, 0 11, 0 12, 0 13, 0 14, 0 15,\n 0 16, 0 17, 0 18, 1 19, 0 20, 0 21, 0 22, 0 23, 0 24, 0 25, 0 26, 0 27, 0 28, 1 29, 0 30, 0 31,\n 1 32, 1 33, 1 34, 1 35, 1 36, 0 37, 1 38, 0 39, 0 40, 0 41, 0 42, 0 43, 0 44, 1 45, 0 46, 1 47,\n 0 48, 1 49, 0 50, 0 51 } $frac52;\n\none = {+ sign, exp_1023 exponent, frac0 fraction} $float64;\ntwo = {+ sign, exp_1024 exponent, frac0 fraction} $float64;\nneg_one = {- sign, exp_1023 exponent, frac0 fraction} $float64;\nten_billion = {+ sign, exp_1e10 exponent, frac_1e10 fraction} $float64;\nten_billion_p1 = {+ sign, exp_1e10 exponent, frac_1e10_p1 fraction} $float64;\n\n# smallest positive subnormal: exponent=0, fraction LSB=1\npos_denorm_min = {+ sign, exp0 exponent, frac_lsb1 fraction} $float64;\nneg_denorm_min = {- sign, exp0 exponent, frac_lsb1 fraction} $float64;\n\n# -----------------------------------------------------------------------------\n# Expanded test product (make sure THIS is the last expression in the file)\n# -----------------------------------------------------------------------------\n\n{\n # --- bit ops --------------------------------------------------------------\n 0 not_bit not_bit_0,\n 1 not_bit not_bit_1,\n {0 x, 0 y} xor_bit xor_00,\n {0 x, 1 y} xor_bit xor_01,\n {1 x, 0 y} xor_bit xor_10,\n {1 x, 1 y} xor_bit xor_11,\n\n # --- cmp_float64 -----------------------------------------------------------\n ({pos_zero x, neg_zero y} cmp_float64) cmp_pz_nz,\n ({neg_zero x, pos_zero y} cmp_float64) cmp_nz_pz,\n ({pos_zero x, pos_zero y} cmp_float64) cmp_pz_pz,\n ({neg_zero x, neg_zero y} cmp_float64) cmp_nz_nz,\n\n ({pos_zero x, pos_inf y} cmp_float64) cmp_pz_pinf,\n ({pos_zero x, neg_inf y} cmp_float64) cmp_pz_ninf,\n ({neg_zero x, pos_inf y} cmp_float64) cmp_nz_pinf,\n ({neg_zero x, neg_inf y} cmp_float64) cmp_nz_ninf,\n\n ({pos_inf x, pos_zero y} cmp_float64) cmp_pinf_pz,\n ({neg_inf x, pos_zero y} cmp_float64) cmp_ninf_pz,\n\n ({pos_inf x, neg_inf y} cmp_float64) cmp_pinf_ninf,\n ({neg_inf x, pos_inf y} cmp_float64) cmp_ninf_pinf,\n ({pos_inf x, pos_inf y} cmp_float64) cmp_pinf_pinf,\n ({neg_inf x, neg_inf y} cmp_float64) cmp_ninf_ninf,\n\n ({qnan x, pos_zero y} cmp_float64) cmp_qnan_pz,\n ({pos_zero x, qnan y} cmp_float64) cmp_pz_qnan,\n ({qnan x, qnan y} cmp_float64) cmp_qnan_qnan,\n ({qnan x, pos_inf y} cmp_float64) cmp_qnan_pinf,\n ({pos_inf x, qnan y} cmp_float64) cmp_pinf_qnan,\n\n # --- add_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} add_float64) add_qnan_pz,\n ({pos_zero x, qnan y} add_float64) add_pz_qnan,\n ({qnan x, qnan y} add_float64) add_qnan_qnan,\n\n ({pos_inf x, neg_inf y} add_float64) add_pinf_ninf,\n ({neg_inf x, pos_inf y} add_float64) add_ninf_pinf,\n\n ({pos_inf x, pos_zero y} add_float64) add_pinf_pz,\n ({pos_inf x, neg_zero y} add_float64) add_pinf_nz,\n ({neg_inf x, pos_zero y} add_float64) add_ninf_pz,\n ({neg_inf x, neg_zero y} add_float64) add_ninf_nz,\n\n ({pos_zero x, pos_inf y} add_float64) add_pz_pinf,\n ({neg_zero x, pos_inf y} add_float64) add_nz_pinf,\n ({pos_zero x, neg_inf y} add_float64) add_pz_ninf,\n ({neg_zero x, neg_inf y} add_float64) add_nz_ninf,\n\n ({pos_zero x, neg_zero y} add_float64) add_pz_nz,\n ({neg_zero x, pos_zero y} add_float64) add_nz_pz,\n ({pos_zero x, pos_zero y} add_float64) add_pz_pz,\n ({neg_zero x, neg_zero y} add_float64) add_nz_nz,\n\n ({one x, one y} float64_add) add_one_one,\n ({ten_billion x, one y} float64_add) add_1e10_1,\n ({ten_billion_p1 x, one y} float64_add) add_1e10p1_1,\n\n # --- sub_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} sub_float64) sub_qnan_pz,\n ({pos_zero x, qnan y} sub_float64) sub_pz_qnan,\n\n ({pos_zero x, pos_zero y} sub_float64) sub_pz_pz,\n ({pos_zero x, neg_zero y} sub_float64) sub_pz_nz,\n ({neg_zero x, pos_zero y} sub_float64) sub_nz_pz,\n ({neg_zero x, neg_zero y} sub_float64) sub_nz_nz,\n\n ({pos_inf x, pos_inf y} sub_float64) sub_pinf_pinf,\n ({pos_inf x, neg_inf y} sub_float64) sub_pinf_ninf,\n ({neg_inf x, pos_inf y} sub_float64) sub_ninf_pinf,\n ({neg_inf x, neg_inf y} sub_float64) sub_ninf_ninf,\n\n # --- mul_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} mul_float64) mul_qnan_pz,\n ({pos_zero x, qnan y} mul_float64) mul_pz_qnan,\n\n ({pos_inf x, pos_inf y} mul_float64) mul_pinf_pinf,\n ({pos_inf x, neg_inf y} mul_float64) mul_pinf_ninf,\n ({neg_inf x, pos_inf y} mul_float64) mul_ninf_pinf,\n ({neg_inf x, neg_inf y} mul_float64) mul_ninf_ninf,\n\n ({pos_inf x, pos_zero y} mul_float64) mul_pinf_pz,\n ({pos_inf x, neg_zero y} mul_float64) mul_pinf_nz,\n ({neg_inf x, pos_zero y} mul_float64) mul_ninf_pz,\n ({neg_inf x, neg_zero y} mul_float64) mul_ninf_nz,\n\n ({pos_zero x, pos_inf y} mul_float64) mul_pz_pinf,\n ({neg_zero x, pos_inf y} mul_float64) mul_nz_pinf,\n ({pos_zero x, neg_inf y} mul_float64) mul_pz_ninf,\n ({neg_zero x, neg_inf y} mul_float64) mul_nz_ninf,\n\n ({pos_zero x, pos_zero y} mul_float64) mul_pz_pz,\n ({pos_zero x, neg_zero y} mul_float64) mul_pz_nz,\n ({neg_zero x, pos_zero y} mul_float64) mul_nz_pz,\n ({neg_zero x, neg_zero y} mul_float64) mul_nz_nz,\n ({one x, one y} float64_mul) mul_one_one_flags,\n ({two x, two y} float64_mul) mul_two_two_flags,\n\n # --- div_float64 -----------------------------------------------------------\n ({qnan x, pos_zero y} div_float64) div_qnan_pz,\n ({pos_zero x, qnan y} div_float64) div_pz_qnan,\n\n ({pos_zero x, pos_zero y} div_float64) div_pz_pz,\n ({pos_zero x, neg_zero y} div_float64) div_pz_nz,\n ({neg_zero x, pos_zero y} div_float64) div_nz_pz,\n ({neg_zero x, neg_zero y} div_float64) div_nz_nz,\n\n ({pos_inf x, pos_inf y} div_float64) div_pinf_pinf,\n ({pos_inf x, neg_inf y} div_float64) div_pinf_ninf,\n ({neg_inf x, pos_inf y} div_float64) div_ninf_pinf,\n ({neg_inf x, neg_inf y} div_float64) div_ninf_ninf,\n\n ({pos_inf x, pos_zero y} div_float64) div_pinf_pz,\n ({pos_inf x, neg_zero y} div_float64) div_pinf_nz,\n ({neg_inf x, pos_zero y} div_float64) div_ninf_pz,\n ({neg_inf x, neg_zero y} div_float64) div_ninf_nz,\n\n ({pos_zero x, pos_inf y} div_float64) div_pz_pinf,\n ({neg_zero x, pos_inf y} div_float64) div_nz_pinf,\n ({pos_zero x, neg_inf y} div_float64) div_pz_ninf,\n ({neg_zero x, neg_inf y} div_float64) div_nz_ninf,\n ({two x, one y} float64_div) div_two_one_flags,\n ({one x, two y} float64_div) div_one_two_flags,\n ({one x, pos_zero y} float64_div) div_one_pz_flags\n}\n*/ \n",
9
- "poly.k": "-- Examples/poly.k: Polymorphic list functions in k\n-- Uses list constructors/destructors from Examples/list.k\n-- and arbitrary-precision integer representations from Examples/arithmetics.k.\n\n-- Decrement an integer and normalize its representation (stripping leading zeros)\npred_int = dec /'+' nat | '+';\n\n-- Concatenate two lists: {xs, ys} -> list\nconcat = {.xs reverse xs, .ys acc} _reverse;\n\n-- Reverse a list: xs -> list\nreverse = {() xs, nil acc} _reverse;\n_reverse = <\n {.xs cdr xs, {.xs car car, .acc cdr} cons acc} _reverse,\n .acc\n>;\n\n-- Length of a list: xs -> int\nlength = {() xs, 0 int acc} _length;\n_length = <\n {.xs /nil if, .acc then} .then,\n {.xs cdr xs, .acc inc acc} _length\n>;\n\n-- Get N-th element of a list (0-indexed): {n, xs} -> element\nget_nth = <\n {.n zero_int? if, .xs car then} .then,\n {.n pred_int n, .xs cdr xs} get_nth\n>;\n\n-- Split list at index N: {n, xs} -> {first, second}\nsplit_by = {.n n, .xs xs, nil acc} _split_by;\n_split_by = <\n {.n zero_int? if, {.acc reverse first, .xs second} then} .then,\n {.xs /nil if, {.acc reverse first, nil second} then} .then,\n {.n pred_int n, .xs cdr xs, {.xs car car, .acc cdr} cons acc} _split_by\n>;\n\n-- Take the first N elements of a list: {n, xs} -> list\ntake = split_by .first;\n\n-- Drop the first N elements of a list: {n, xs} -> list\ndrop = <\n {.n zero_int? if, .xs then} .then,\n {.xs /nil if, nil then} .then,\n {.n pred_int n, .xs cdr xs} drop\n>;\n\n-- Repeat element X, N times: {n, x} -> list\nrepeat = {.n n, .x x, nil acc} _repeat;\n_repeat = <\n {.n zero_int? if, .acc then} .then,\n {.n pred_int n, .x x, {.x car, .acc cdr} cons acc} _repeat\n>;\n\n-- Append an element to the end of a list: {x, xs} -> list\nappend = {.xs xs, {.x car, nil cdr} cons ys} concat;\n\n-- Zip two lists into a list of {x, y} pairs: {xs, ys} -> list\nzip = <\n {.xs /nil if, nil then} .then,\n {.ys /nil if, nil then} .then,\n {\n {.xs car x, .ys car y} car,\n {.xs cdr xs, .ys cdr ys} zip cdr\n } cons\n>;\n\n-- Gen list of intgers: n -> [0, 1, ..., n]\ngen_list = {() n, nil list} gen_list_; \ngen_list_ = <\n {.n neg? if, .list then} .then, \n {.n dec n, {.n car, .list cdr} cons list} gen_list_\n>;\n\n-- Identity filter on {x, y} when x is greater than y: ?{X x, X y}=Y -> ?Y\ngt? =\n <\n {.x/- if1, .y/+ if2, () then} .then,\n {{.x/- y, .y/- x} GT if, () then} .then,\n {{.x/+ x, .y/+ y} GT if, () then} .then\n >\n;\n\n-- Split list into two halves by alternating elements: xs -> {first, second}\nsplit = {() xs, nil first, nil second} _split;\n_split = <\n {.xs /nil if, {.first first, .second second} then} .then,\n {.xs cdr /nil if, {{.xs car car, .first cdr} cons first, .second second} then} .then,\n {.xs cdr cdr xs, {.xs car car, .first cdr} cons first, {.xs cdr car car, .second cdr} cons second} _split\n>;\n\n-- Merge two sorted lists: {xs, ys} -> list\nmerge = <\n {.xs /nil if, .ys then} .then,\n {.ys /nil if, .xs then} .then,\n {\n {.xs car x, .ys car y} gt? if,\n {.ys car car, {.xs xs, .ys cdr ys} merge cdr} cons then\n } .then,\n {.xs car car, {.xs cdr xs, .ys ys} merge cdr} cons\n>;\n\n-- Sort a list in ascending order (merge sort): xs -> list\nsort = list? <\n /nil nil,\n /cons <\n {.cdr /nil if, .car singleton then} .then,\n |cons split {.first sort xs, .second sort ys} merge\n >\n> list?;\n\n\n",
10
- "Examples/poly.k": "-- Examples/poly.k: Polymorphic list functions in k\n-- Uses list constructors/destructors from Examples/list.k\n-- and arbitrary-precision integer representations from Examples/arithmetics.k.\n\n-- Decrement an integer and normalize its representation (stripping leading zeros)\npred_int = dec /'+' nat | '+';\n\n-- Concatenate two lists: {xs, ys} -> list\nconcat = {.xs reverse xs, .ys acc} _reverse;\n\n-- Reverse a list: xs -> list\nreverse = {() xs, nil acc} _reverse;\n_reverse = <\n {.xs cdr xs, {.xs car car, .acc cdr} cons acc} _reverse,\n .acc\n>;\n\n-- Length of a list: xs -> int\nlength = {() xs, 0 int acc} _length;\n_length = <\n {.xs /nil if, .acc then} .then,\n {.xs cdr xs, .acc inc acc} _length\n>;\n\n-- Get N-th element of a list (0-indexed): {n, xs} -> element\nget_nth = <\n {.n zero_int? if, .xs car then} .then,\n {.n pred_int n, .xs cdr xs} get_nth\n>;\n\n-- Split list at index N: {n, xs} -> {first, second}\nsplit_by = {.n n, .xs xs, nil acc} _split_by;\n_split_by = <\n {.n zero_int? if, {.acc reverse first, .xs second} then} .then,\n {.xs /nil if, {.acc reverse first, nil second} then} .then,\n {.n pred_int n, .xs cdr xs, {.xs car car, .acc cdr} cons acc} _split_by\n>;\n\n-- Take the first N elements of a list: {n, xs} -> list\ntake = split_by .first;\n\n-- Drop the first N elements of a list: {n, xs} -> list\ndrop = <\n {.n zero_int? if, .xs then} .then,\n {.xs /nil if, nil then} .then,\n {.n pred_int n, .xs cdr xs} drop\n>;\n\n-- Repeat element X, N times: {n, x} -> list\nrepeat = {.n n, .x x, nil acc} _repeat;\n_repeat = <\n {.n zero_int? if, .acc then} .then,\n {.n pred_int n, .x x, {.x car, .acc cdr} cons acc} _repeat\n>;\n\n-- Append an element to the end of a list: {x, xs} -> list\nappend = {.xs xs, {.x car, nil cdr} cons ys} concat;\n\n-- Zip two lists into a list of {x, y} pairs: {xs, ys} -> list\nzip = <\n {.xs /nil if, nil then} .then,\n {.ys /nil if, nil then} .then,\n {\n {.xs car x, .ys car y} car,\n {.xs cdr xs, .ys cdr ys} zip cdr\n } cons\n>;\n\n-- Gen list of intgers: n -> [0, 1, ..., n]\ngen_list = {() n, nil list} gen_list_; \ngen_list_ = <\n {.n neg? if, .list then} .then, \n {.n dec n, {.n car, .list cdr} cons list} gen_list_\n>;\n\n-- Identity filter on {x, y} when x is greater than y: ?{X x, X y}=Y -> ?Y\ngt? =\n <\n {.x/- if1, .y/+ if2, () then} .then,\n {{.x/- y, .y/- x} GT if, () then} .then,\n {{.x/+ x, .y/+ y} GT if, () then} .then\n >\n;\n\n-- Split list into two halves by alternating elements: xs -> {first, second}\nsplit = {() xs, nil first, nil second} _split;\n_split = <\n {.xs /nil if, {.first first, .second second} then} .then,\n {.xs cdr /nil if, {{.xs car car, .first cdr} cons first, .second second} then} .then,\n {.xs cdr cdr xs, {.xs car car, .first cdr} cons first, {.xs cdr car car, .second cdr} cons second} _split\n>;\n\n-- Merge two sorted lists: {xs, ys} -> list\nmerge = <\n {.xs /nil if, .ys then} .then,\n {.ys /nil if, .xs then} .then,\n {\n {.xs car x, .ys car y} gt? if,\n {.ys car car, {.xs xs, .ys cdr ys} merge cdr} cons then\n } .then,\n {.xs car car, {.xs cdr xs, .ys ys} merge cdr} cons\n>;\n\n-- Sort a list in ascending order (merge sort): xs -> list\nsort = list? <\n /nil nil,\n /cons <\n {.cdr /nil if, .car singleton then} .then,\n |cons split {.first sort xs, .second sort ys} merge\n >\n> list?;\n\n\n",
11
- "json.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/runtime/unicode-string.mjs\nvar UNIT = Value.product({});\nvar BIT0 = Value.variant(\"0\", UNIT);\nvar BIT1 = Value.variant(\"1\", UNIT);\nfunction bitValue(bit) {\n return bit === 0 ? BIT0 : BIT1;\n}\nfunction requireProduct(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction bitsProduct(width, n) {\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue(n >> i & 1);\n }\n return Value.product(product);\n}\nfunction parseBitsProduct(value, maxBit, where) {\n const product = requireProduct(value, where);\n let n = 0;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1 | (entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction byteProduct(n) {\n return bitsProduct(8, n);\n}\nfunction parseByteProduct(value, where) {\n return parseBitsProduct(value, 7, where);\n}\nfunction encodeBmpCommonHi(hi) {\n if (hi >= 8 && hi <= 15) return Value.variant(\"h08_0F\", bitsProduct(3, hi - 8));\n if (hi >= 16 && hi <= 127) return Value.variant(\"h10_7F\", bitsProduct(7, hi - 16));\n if (hi >= 128 && hi <= 207) return Value.variant(\"h80_CF\", bitsProduct(7, hi - 128));\n if (hi >= 208 && hi <= 215) return Value.variant(\"hD0_D7\", bitsProduct(3, hi - 208));\n if (hi === 249) return Value.variant(\"hF9\", UNIT);\n if (hi >= 250 && hi <= 251) return Value.variant(\"hFA_FB\", bitsProduct(1, hi - 250));\n if (hi >= 252 && hi <= 253) return Value.variant(\"hFC_FD\", bitsProduct(1, hi - 252));\n if (hi >= 254 && hi <= 255) return Value.variant(\"hFE_FF\", bitsProduct(1, hi - 254));\n throw new Error(`Unsupported BMP common hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpCommonHi(value) {\n const v = requireVariant(value, \"bmp_common.hi\");\n if (v.tag === \"h08_0F\") return 8 + parseBitsProduct(v.value, 2, \"h08_0F\");\n if (v.tag === \"h10_7F\") return 16 + parseBitsProduct(v.value, 6, \"h10_7F\");\n if (v.tag === \"h80_CF\") return 128 + parseBitsProduct(v.value, 6, \"h80_CF\");\n if (v.tag === \"hD0_D7\") return 208 + parseBitsProduct(v.value, 2, \"hD0_D7\");\n if (v.tag === \"hF9\") return 249;\n if (v.tag === \"hFA_FB\") return 250 + parseBitsProduct(v.value, 0, \"hFA_FB\");\n if (v.tag === \"hFC_FD\") return 252 + parseBitsProduct(v.value, 0, \"hFC_FD\");\n if (v.tag === \"hFE_FF\") return 254 + parseBitsProduct(v.value, 0, \"hFE_FF\");\n throw new Error(`Unsupported bmp_common.hi tag: ${v.tag}`);\n}\nfunction encodeBmpPrivateHi(hi) {\n if (hi >= 224 && hi <= 239) return Value.variant(\"hE0_EF\", bitsProduct(4, hi - 224));\n if (hi >= 240 && hi <= 247) return Value.variant(\"hF0_F7\", bitsProduct(3, hi - 240));\n if (hi === 248) return Value.variant(\"hF8\", UNIT);\n throw new Error(`Unsupported BMP private-use hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpPrivateHi(value) {\n const v = requireVariant(value, \"bmp_private_use.hi\");\n if (v.tag === \"hE0_EF\") return 224 + parseBitsProduct(v.value, 3, \"hE0_EF\");\n if (v.tag === \"hF0_F7\") return 240 + parseBitsProduct(v.value, 2, \"hF0_F7\");\n if (v.tag === \"hF8\") return 248;\n throw new Error(`Unsupported bmp_private_use.hi tag: ${v.tag}`);\n}\nfunction encodePlane2To16(plane) {\n if (plane >= 2 && plane <= 3) return Value.variant(\"p02_03\", bitsProduct(1, plane - 2));\n if (plane >= 4 && plane <= 7) return Value.variant(\"p04_07\", bitsProduct(2, plane - 4));\n if (plane >= 8 && plane <= 15) return Value.variant(\"p08_0F\", bitsProduct(3, plane - 8));\n if (plane === 16) return Value.variant(\"p10\", UNIT);\n throw new Error(`Plane out of range for supplementary_planes2_16: ${plane}`);\n}\nfunction decodePlane2To16(value) {\n const v = requireVariant(value, \"supplementary_planes2_16.plane\");\n if (v.tag === \"p02_03\") return 2 + parseBitsProduct(v.value, 0, \"p02_03\");\n if (v.tag === \"p04_07\") return 4 + parseBitsProduct(v.value, 1, \"p04_07\");\n if (v.tag === \"p08_0F\") return 8 + parseBitsProduct(v.value, 2, \"p08_0F\");\n if (v.tag === \"p10\") return 16;\n throw new Error(`Unsupported supplementary plane tag: ${v.tag}`);\n}\nfunction codePointToUnicodeValue(cp) {\n if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {\n throw new Error(`Code point out of Unicode range: ${cp}`);\n }\n if (cp >= 55296 && cp <= 57343) {\n throw new Error(`Surrogate code point is not a scalar value: U+${cp.toString(16).toUpperCase()}`);\n }\n if (cp <= 127) {\n return Value.variant(\"ascii\", bitsProduct(7, cp));\n }\n if (cp <= 2047) {\n return Value.variant(\"plane0\", bitsProduct(11, cp));\n }\n if (cp <= 65535) {\n const hi = cp >> 8 & 255;\n const lo2 = cp & 255;\n if (hi >= 224 && hi <= 248) {\n return Value.variant(\"bmp_private_use\", Value.product({ hi: encodeBmpPrivateHi(hi), lo: byteProduct(lo2) }));\n }\n return Value.variant(\"bmp_common\", Value.product({ hi: encodeBmpCommonHi(hi), lo: byteProduct(lo2) }));\n }\n const mid = cp >> 8 & 255;\n const lo = cp & 255;\n if (cp <= 131071) {\n return Value.variant(\"supplementary_plane1\", Value.product({\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n }\n const plane = cp >> 16;\n return Value.variant(\"supplementary_planes2_16\", Value.product({\n plane: encodePlane2To16(plane),\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n}\nfunction unicodeValueToCodePoint(value) {\n const v = requireVariant(value, \"unicode\");\n if (v.tag === \"ascii\") return parseBitsProduct(v.value, 6, \"ascii\");\n if (v.tag === \"plane0\") return parseBitsProduct(v.value, 10, \"plane0\");\n if (v.tag === \"bmp_common\") {\n const p = requireProduct(v.value, \"bmp_common\");\n return decodeBmpCommonHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_common.lo\");\n }\n if (v.tag === \"bmp_private_use\") {\n const p = requireProduct(v.value, \"bmp_private_use\");\n return decodeBmpPrivateHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_private_use.lo\");\n }\n if (v.tag === \"supplementary_plane1\") {\n const p = requireProduct(v.value, \"supplementary_plane1\");\n return 1 << 16 | parseByteProduct(p.mid, \"supplementary_plane1.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_plane1.lo\");\n }\n if (v.tag === \"supplementary_planes2_16\") {\n const p = requireProduct(v.value, \"supplementary_planes2_16\");\n return decodePlane2To16(p.plane) << 16 | parseByteProduct(p.mid, \"supplementary_planes2_16.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_planes2_16.lo\");\n }\n throw new Error(`Unsupported unicode tag: ${v.tag}`);\n}\nfunction textToStringValue(text) {\n let out = Value.variant(\"nil\", UNIT);\n const chars = Array.from(text);\n for (let i = chars.length - 1; i >= 0; i--) {\n const cp = chars[i].codePointAt(0);\n out = Value.variant(\"cons\", Value.product({\n car: codePointToUnicodeValue(cp),\n cdr: out\n }));\n }\n return out;\n}\nfunction stringValueToText(value) {\n let out = \"\";\n let cursor = value;\n while (true) {\n const list = requireVariant(cursor, \"string\");\n if (list.tag === \"nil\") {\n requireProduct(list.value, \"string.nil\");\n return out;\n }\n if (list.tag !== \"cons\") {\n throw new Error(`Unsupported string list tag: ${list.tag}`);\n }\n const pair = requireProduct(list.value, \"string.cons\");\n out += String.fromCodePoint(unicodeValueToCodePoint(pair.car));\n cursor = pair.cdr;\n }\n}\n\n// codecs/string-codec.mjs\nvar STRING_PATTERN_PROPERTY_LIST = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$bits1 = { bit 0 };\n$bits2 = { bit 0, bit 1 };\n$bits3 = { bit 0, bit 1, bit 2 };\n$bits4 = { bit 0, bit 1, bit 2, bit 3 };\n$bits7 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6 };\n$bits8 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7 };\n$bits11 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10 };\n\n$bmp_common_hi = <\n bits3 h08_0F,\n bits7 h10_7F,\n bits7 h80_CF,\n bits3 hD0_D7,\n {} hF9,\n bits1 hFA_FB,\n bits1 hFC_FD,\n bits1 hFE_FF\n>;\n$bmp_common = { bmp_common_hi hi, bits8 lo };\n\n$bmp_private_hi = <\n bits4 hE0_EF,\n bits3 hF0_F7,\n {} hF8\n>;\n$bmp_private_use = { bmp_private_hi hi, bits8 lo };\n\n$plane2_16 = <\n bits1 p02_03,\n bits2 p04_07,\n bits3 p08_0F,\n {} p10\n>;\n$supplementary_planes2_16 = { plane2_16 plane, bits8 mid, bits8 lo };\n$supplementary_plane1 = { bits8 mid, bits8 lo };\n\n$unicode_scalar = <\n bits7 ascii,\n bits11 plane0,\n bmp_common bmp_common,\n bmp_private_use bmp_private_use,\n supplementary_plane1 supplementary_plane1,\n supplementary_planes2_16 supplementary_planes2_16\n>;\n\n?< {} nil, { $unicode_scalar car, str cdr } cons > = str\n`);\n\n// codecs/ieee.mjs\nvar doc = `\nIEEE 754 64-bit float codec.\n\nParses decimal floats, Infinity, -Infinity, NaN to 64-bit IEEE products.\n`;\nvar FLOAT64_PATTERN = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$sign = < {} \"+\", {} \"-\" >;\n$exp11 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10};\n$frac52 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51};\n$float64 = {sign sign, exp11 exponent, frac52 fraction};\n?$float64\n`);\nvar UNIT2 = Value.product({});\nfunction bitValue2(bit) {\n return Value.variant(bit === 0 ? \"0\" : \"1\", UNIT2);\n}\nfunction bitsProduct2(width, value) {\n const big = BigInt(value);\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue2(Number(big >> BigInt(i) & 1n));\n }\n return Value.product(product);\n}\nvar floatView = new DataView(new ArrayBuffer(8));\nfunction encodeNumberToValue(number) {\n floatView.setFloat64(0, number, false);\n const bits = floatView.getBigUint64(0, false);\n const sign = Number(bits >> 63n & 1n);\n const exponent = Number(bits >> 52n & 0x7ffn);\n const fraction = bits & (1n << 52n) - 1n;\n return Value.product({\n sign: Value.variant(sign === 0 ? \"+\" : \"-\", UNIT2),\n exponent: bitsProduct2(11, exponent),\n fraction: bitsProduct2(52, fraction)\n });\n}\nfunction requireProduct2(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant2(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction parseBitsProduct2(value, maxBit, where) {\n const product = requireProduct2(value, where);\n let n = 0n;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant2(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1n | BigInt(entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction decodeValueToNumber(value) {\n const product = requireProduct2(value, \"float64\");\n const sign = requireVariant2(product.sign, \"float64.sign\");\n if (sign.tag !== \"+\" && sign.tag !== \"-\") {\n throw new Error(`float64.sign: expected + or -, got ${sign.tag}`);\n }\n const exponent = parseBitsProduct2(product.exponent, 10, \"float64.exponent\");\n const fraction = parseBitsProduct2(product.fraction, 51, \"float64.fraction\");\n const bits = BigInt(sign.tag === \"-\" ? 1 : 0) << 63n | exponent << 52n | fraction;\n floatView.setBigUint64(0, bits, false);\n return floatView.getFloat64(0, false);\n}\nfunction parseFloatText(text) {\n const trimmed = text.trim();\n if (trimmed === \"\") {\n throw new Error(\"Expected a floating-point literal\");\n }\n if (/^[+-]?nan$/i.test(trimmed)) return NaN;\n if (/^[+]?inf(inity)?$/i.test(trimmed)) return Infinity;\n if (/^[-](inf|infinity)$/i.test(trimmed)) return -Infinity;\n const n = Number(trimmed);\n if (Number.isNaN(n)) {\n throw new Error(`Invalid float literal ${JSON.stringify(trimmed)}`);\n }\n return n;\n}\nfunction printFloatText(n) {\n if (Number.isNaN(n)) return \"NaN\";\n if (n === Infinity) return \"Infinity\";\n if (n === -Infinity) return \"-Infinity\";\n if (Object.is(n, -0)) return \"-0\";\n return String(n);\n}\nfunction parse(text) {\n const n = parseFloatText(text);\n const value = encodeNumberToValue(n);\n return withPattern(value, FLOAT64_PATTERN);\n}\nfunction print(value) {\n return printFloatText(decodeValueToNumber(value));\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\n\n// codecs/json-codec.mjs\nvar UNIT3 = Value.product({});\nvar BOOL_PATTERN = patternFromFilter(\"?< {} false, {} true >\");\nvar NULL_PATTERN = patternFromFilter(\"?< {} null >\");\nfunction requireProduct3(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction fromJsonValue(value) {\n if (value === null) {\n return Value.variant(\"null\", UNIT3);\n }\n if (typeof value === \"boolean\") {\n return Value.variant(value ? \"true\" : \"false\", UNIT3);\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new Error(\"JSON numbers must be finite\");\n }\n return encodeNumberToValue(value);\n }\n if (typeof value === \"string\") {\n return textToStringValue(value);\n }\n if (Array.isArray(value)) {\n return Value.product(\n value.reduce((product, item, index) => {\n product[String(index)] = fromJsonValue(item);\n return product;\n }, {})\n );\n }\n if (value && typeof value === \"object\") {\n return Value.product(\n Object.keys(value).reduce((product, key) => {\n product[key] = fromJsonValue(value[key]);\n return product;\n }, {})\n );\n }\n throw new Error(`Unsupported JSON value: ${value}`);\n}\nfunction composePattern(kind, entries) {\n const result = [[kind, []]];\n for (const [label, childPattern] of entries) {\n const offset = result.length;\n result[0][1].push([label, offset]);\n for (const [childKind, childEdges] of childPattern) {\n result.push([\n childKind,\n childEdges.map(([edgeLabel, target]) => [edgeLabel, target + offset])\n ]);\n }\n }\n return result;\n}\nfunction patternFromJsonValue(value) {\n if (value === null) return NULL_PATTERN;\n if (typeof value === \"boolean\") return BOOL_PATTERN;\n if (typeof value === \"number\") return FLOAT64_PATTERN;\n if (typeof value === \"string\") return STRING_PATTERN_PROPERTY_LIST;\n if (Array.isArray(value)) {\n return composePattern(\n \"closed-product\",\n value.map((item, index) => [String(index), patternFromJsonValue(item)])\n );\n }\n if (value && typeof value === \"object\") {\n return composePattern(\n \"closed-product\",\n Object.keys(value).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((key) => [key, patternFromJsonValue(value[key])])\n );\n }\n throw new Error(`Unsupported JSON value: ${value}`);\n}\nfunction toJsonValue(value) {\n if (isVariant(value)) {\n if (value.tag === \"null\") {\n requireProduct3(value.value, \"json.null\");\n return null;\n }\n if (value.tag === \"true\") {\n requireProduct3(value.value, \"json.true\");\n return true;\n }\n if (value.tag === \"false\") {\n requireProduct3(value.value, \"json.false\");\n return false;\n }\n return stringValueToText(value);\n }\n const product = requireProduct3(value, \"json.value\");\n const keys = Object.keys(product);\n const isArray = keys.every((key, index) => key === String(index));\n if (isArray) {\n return keys.map((key) => {\n const child = product[key];\n if (isVariant(child)) return toJsonValue(child);\n if (isProduct(child)) {\n try {\n return decodeValueToNumber(child);\n } catch {\n }\n }\n return toJsonValue(child);\n });\n }\n const numberKeys = [\"exponent\", \"fraction\", \"sign\"];\n if (keys.length === numberKeys.length && numberKeys.every((key) => key in product)) {\n return decodeValueToNumber(value);\n }\n try {\n return stringValueToText(value);\n } catch {\n }\n return keys.reduce((result, key) => {\n result[key] = toJsonValue(product[key]);\n return result;\n }, {});\n}\n\n// codecs/json.mjs\nvar doc2 = `\nJSON codec (RFC 8259).\n\nTranslates JSON data to/from self-describing enveloped k values.\n`;\nfunction parse2(text) {\n const json = JSON.parse(text);\n const value = fromJsonValue(json);\n const pattern = patternFromJsonValue(json);\n return withPattern(value, pattern);\n}\nfunction print2(value) {\n return JSON.stringify(toJsonValue(value));\n}\nrunCodecCLI(import.meta.url, { parse: parse2, print: print2, doc: doc2 });\nexport {\n doc2 as doc,\n parse2 as parse,\n print2 as print\n};\n",
9
+ "poly.k": "-- Examples/poly.k: Polymorphic list functions in k\n-- Uses arbitrary-precision integers from Examples/arithmetics.k.\n\n-- List constructors and destructors\nlist? = ?< {} nil, {X car, Y cdr} cons > = Y;\nnil = {} | nil list?;\nsingleton = {() car, nil cdr} | cons list?;\ncons = {.car car, .cdr cdr} | cons list?;\nnil? = list? / nil nil;\ncar = list? /cons .car;\ncdr = list? /cons .cdr;\n\n-- Decrement an integer and normalize (stripping leading zeros)\npred_int = dec /'+' nat | '+';\n\n-- Concatenate two lists: {xs, ys} -> list\nconcat = {.xs reverse xs, .ys acc} _reverse;\n\n-- Reverse a list: xs -> list\nreverse = {() xs, nil acc} _reverse;\n_reverse = <\n {.xs cdr xs, {.xs car car, .acc cdr} cons acc} _reverse,\n .acc\n>;\n\n-- Length of a list: xs -> int\nlength = {() xs, 0 int acc} _length;\n_length = <\n {.xs /nil if, .acc then} .then,\n {.xs cdr xs, .acc inc acc} _length\n>;\n\n-- Get N-th element of a list (0-indexed): {n, xs} -> element\nget_nth = <\n {.n zero_int? if, .xs car then} .then,\n {.n pred_int n, .xs cdr xs} get_nth\n>;\n\n-- Split list at index N: {n, xs} -> {first, second}\nsplit_by = {.n n, .xs xs, nil acc} _split_by;\n_split_by = <\n {.n zero_int? if, {.acc reverse first, .xs second} then} .then,\n {.xs /nil if, {.acc reverse first, nil second} then} .then,\n {.n pred_int n, .xs cdr xs, {.xs car car, .acc cdr} cons acc} _split_by\n>;\n\n-- Take the first N elements of a list: {n, xs} -> list\ntake = split_by .first;\n\n-- Drop the first N elements of a list: {n, xs} -> list\ndrop = <\n {.n zero_int? if, .xs then} .then,\n {.xs /nil if, nil then} .then,\n {.n pred_int n, .xs cdr xs} drop\n>;\n\n-- Repeat element X, N times: {n, x} -> list\nrepeat = {.n n, .x x, nil acc} _repeat;\n_repeat = <\n {.n zero_int? if, .acc then} .then,\n {.n pred_int n, .x x, {.x car, .acc cdr} cons acc} _repeat\n>;\n\n-- Append an element to the end of a list: {x, xs} -> list\nappend = {.xs xs, {.x car, nil cdr} cons ys} concat;\n\n-- Zip two lists into a list of {x, y} pairs: {xs, ys} -> list\nzip = <\n {.xs /nil if, nil then} .then,\n {.ys /nil if, nil then} .then,\n {\n {.xs car x, .ys car y} car,\n {.xs cdr xs, .ys cdr ys} zip cdr\n } cons\n>;\n\n-- Gen list of intgers: n -> [0, 1, ..., n]\ngen_list = {() n, nil list} gen_list_; \ngen_list_ = <\n {.n neg? if, .list then} .then, \n {.n dec n, {.n car, .list cdr} cons list} gen_list_\n>;\n\n-- Identity filter on {x, y} when x is greater than y: ?{X x, X y}=Y -> ?Y\ngt? =\n <\n {.x/- if1, .y/+ if2, () then} .then,\n {{.x/- y, .y/- x} GT if, () then} .then,\n {{.x/+ x, .y/+ y} GT if, () then} .then\n >\n;\n\n-- Split list into two halves by alternating elements:\n-- xs -> {first, second}\nsplit = {() xs, nil first, nil second} _split;\n_split = <\n {.xs /nil if, {.first first, .second second} then} .then,\n {.xs cdr /nil if, {{.xs car car, .first cdr} cons first, .second second} then} .then,\n {.xs cdr cdr xs, {.xs car car, .first cdr} cons first, {.xs cdr car car, .second cdr} cons second} _split\n>;\n\n-- Merge two sorted lists: {xs, ys} -> list\nmerge = <\n {.xs /nil if, .ys then} .then,\n {.ys /nil if, .xs then} .then,\n {\n {.xs car x, .ys car y} gt? if,\n {.ys car car, {.xs xs, .ys cdr ys} merge cdr} cons then\n } .then,\n {.xs car car, {.xs cdr xs, .ys ys} merge cdr} cons\n>;\n\n-- Sort a list in ascending order (merge sort): xs -> list\nsort = list? <\n /nil nil,\n /cons <\n {.cdr /nil if, .car singleton then} .then,\n |cons split {.first sort xs, .second sort ys} merge\n >\n> list?;\n\n\n",
10
+ "Examples/poly.k": "-- Examples/poly.k: Polymorphic list functions in k\n-- Uses arbitrary-precision integers from Examples/arithmetics.k.\n\n-- List constructors and destructors\nlist? = ?< {} nil, {X car, Y cdr} cons > = Y;\nnil = {} | nil list?;\nsingleton = {() car, nil cdr} | cons list?;\ncons = {.car car, .cdr cdr} | cons list?;\nnil? = list? / nil nil;\ncar = list? /cons .car;\ncdr = list? /cons .cdr;\n\n-- Decrement an integer and normalize (stripping leading zeros)\npred_int = dec /'+' nat | '+';\n\n-- Concatenate two lists: {xs, ys} -> list\nconcat = {.xs reverse xs, .ys acc} _reverse;\n\n-- Reverse a list: xs -> list\nreverse = {() xs, nil acc} _reverse;\n_reverse = <\n {.xs cdr xs, {.xs car car, .acc cdr} cons acc} _reverse,\n .acc\n>;\n\n-- Length of a list: xs -> int\nlength = {() xs, 0 int acc} _length;\n_length = <\n {.xs /nil if, .acc then} .then,\n {.xs cdr xs, .acc inc acc} _length\n>;\n\n-- Get N-th element of a list (0-indexed): {n, xs} -> element\nget_nth = <\n {.n zero_int? if, .xs car then} .then,\n {.n pred_int n, .xs cdr xs} get_nth\n>;\n\n-- Split list at index N: {n, xs} -> {first, second}\nsplit_by = {.n n, .xs xs, nil acc} _split_by;\n_split_by = <\n {.n zero_int? if, {.acc reverse first, .xs second} then} .then,\n {.xs /nil if, {.acc reverse first, nil second} then} .then,\n {.n pred_int n, .xs cdr xs, {.xs car car, .acc cdr} cons acc} _split_by\n>;\n\n-- Take the first N elements of a list: {n, xs} -> list\ntake = split_by .first;\n\n-- Drop the first N elements of a list: {n, xs} -> list\ndrop = <\n {.n zero_int? if, .xs then} .then,\n {.xs /nil if, nil then} .then,\n {.n pred_int n, .xs cdr xs} drop\n>;\n\n-- Repeat element X, N times: {n, x} -> list\nrepeat = {.n n, .x x, nil acc} _repeat;\n_repeat = <\n {.n zero_int? if, .acc then} .then,\n {.n pred_int n, .x x, {.x car, .acc cdr} cons acc} _repeat\n>;\n\n-- Append an element to the end of a list: {x, xs} -> list\nappend = {.xs xs, {.x car, nil cdr} cons ys} concat;\n\n-- Zip two lists into a list of {x, y} pairs: {xs, ys} -> list\nzip = <\n {.xs /nil if, nil then} .then,\n {.ys /nil if, nil then} .then,\n {\n {.xs car x, .ys car y} car,\n {.xs cdr xs, .ys cdr ys} zip cdr\n } cons\n>;\n\n-- Gen list of intgers: n -> [0, 1, ..., n]\ngen_list = {() n, nil list} gen_list_; \ngen_list_ = <\n {.n neg? if, .list then} .then, \n {.n dec n, {.n car, .list cdr} cons list} gen_list_\n>;\n\n-- Identity filter on {x, y} when x is greater than y: ?{X x, X y}=Y -> ?Y\ngt? =\n <\n {.x/- if1, .y/+ if2, () then} .then,\n {{.x/- y, .y/- x} GT if, () then} .then,\n {{.x/+ x, .y/+ y} GT if, () then} .then\n >\n;\n\n-- Split list into two halves by alternating elements:\n-- xs -> {first, second}\nsplit = {() xs, nil first, nil second} _split;\n_split = <\n {.xs /nil if, {.first first, .second second} then} .then,\n {.xs cdr /nil if, {{.xs car car, .first cdr} cons first, .second second} then} .then,\n {.xs cdr cdr xs, {.xs car car, .first cdr} cons first, {.xs cdr car car, .second cdr} cons second} _split\n>;\n\n-- Merge two sorted lists: {xs, ys} -> list\nmerge = <\n {.xs /nil if, .ys then} .then,\n {.ys /nil if, .xs then} .then,\n {\n {.xs car x, .ys car y} gt? if,\n {.ys car car, {.xs xs, .ys cdr ys} merge cdr} cons then\n } .then,\n {.xs car car, {.xs cdr xs, .ys ys} merge cdr} cons\n>;\n\n-- Sort a list in ascending order (merge sort): xs -> list\nsort = list? <\n /nil nil,\n /cons <\n {.cdr /nil if, .car singleton then} .then,\n |cons split {.first sort xs, .second sort ys} merge\n >\n> list?;\n\n\n",
11
+ "karatsuba-mult.k": "-- Karatsuba multiplication O(n^1.585)\n-- Self-contained and minimal implementation\n-- for arbitrary-precision integers\n\n$ yes_no = < {} yes, {} no >;\nyes = {} | yes $yes_no;\nno = {} | no $yes_no;\n\n$ bits = < {} _, bits 0, bits 1 >;\n0b = {} | _;\n0 = 0b |0;\n1 = 0b |1;\n\n$ unat = < {} _, unat 1 >;\n0u = {} | _ $unat;\n\nempty = $bits < /_ yes, no >;\nempty? = {empty /yes if, () then} .then;\n\ninv = {()x, 0b r} _inv;\n_inv = ${bits x, bits r}\n<\n {.x empty? if, .r then} .then,\n <\n {.x /0 x, .r |0 r},\n {.x /1 x, .r |1 r}\n > _inv\n>;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_;\nconcat_ = ${bits x, bits y}\n<\n {.x empty? if, .y then} .then,\n <\n {.x /0 x, .y |0 y},\n {.x /1 x, .y |1 y}\n > concat_\n>;\n\nremove_leading_zeros = < /0 remove_leading_zeros, () >;\nnat = remove_leading_zeros <empty? 0, ()>;\n\n$ int = < bits '+', bits '-' >;\nint = nat | '+' $int;\nabs = $int </'+', /'-'>;\n\n$ sign = < {} '+', {} '-' >;\nsign_plus = {} | '+' $sign;\nsign_minus = {} | '-' $sign;\nswap_sign = < /'+' | '-', /'-' | '+' >;\n\n$ carry = < {} 0, {} 1 >;\nc0 = {} | 0 $carry;\nc1 = {} | 1 $carry;\n\n_plus = {.x x, .y y, .c c, 0b r} _plus_;\n_plus_ = ${bits x, bits y, carry c, bits r}\n<\n {.x empty? if, .y empty? and, .c/0 c, .r inv then} .then,\n {.x empty? if, .y empty? and, {.r x, 1 r} _inv then} .then,\n {.x empty? if, .c/0 and, {.r x, .y r} _inv then} .then,\n <\n {.x y, .y empty? x, .c c, .r r},\n {<.c/0 0, 1> x, .y y, .x empty? c0 c, .r r},\n {.x /0 x, .y /0 y, .c/0 c0 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/1 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/0 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /0 y, .c/0 c0 c, .r |1 r},\n {.x /1 x, .y /0 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/0 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/1 c1 c, .r |1 r}\n > _plus_\n>;\n\n_minus = {.x x, .y y, .c c, 0b r} _minus_;\n_minus_ = ${bits x, bits y, carry c, bits r}\n<\n {.y empty? if, .c/0 and, {.r x, .x r} _inv then} .then,\n <\n {.x/0 x, .y empty? y, .c/1 c1 c, .r |1 r},\n {.x/1 x, .y empty? y, .c/1 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/0 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/1 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/0 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/1 c1 c, .r |0 r},\n {.x/1 x, .y/0 y, .c/0 c0 c, .r |1 r},\n {.x/1 x, .y/0 y, .c/1 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/0 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/1 c1 c, .r |1 r}\n > _minus_\n>;\n\nplus_bits = ${bits x, bits y} {.x inv x, .y inv y, c0 c} _plus inv nat;\nminus_bits = ${bits x, bits y} {.x inv x, .y inv y, c0 c} _minus inv nat;\n\n_times = ${bits result, bits _x, bits y}\n<\n {.y empty? if, .result then} .then,\n <\n {.result |0 result, ._x _x, .y /0 y},\n {{._x x, .result |0 y, c0 c} _plus result, ._x _x, .y /1 y}\n > _times\n>;\ntimes_bits = ${bits x, bits y} {0 result, .x inv _x, .y y} _times inv nat;\n\nunat_to_zeros = $unat < /_ 0b, /1 unat_to_zeros |0 > $bits;\nunat_to_double_zeros = $unat\n < /_ 0b, /1 unat_to_double_zeros |0 |0 > $bits;\n\n_peel2 = < </0,/1> </0,/1>, </0,/1>, () >;\n_half_unat = ${bits x, bits y, unat m}\n<\n {.x empty? if, .y empty? and, .m then} .then,\n {.x _peel2 x, .y _peel2 y, .m |1 m} _half_unat\n>;\nhalf_unat = {.x x, .y y, 0u m} _half_unat;\n\n_split_rev_u = ${bits x_rev, unat m, bits low}\n<\n {.m /_ if, {.low nat low, .x_rev inv nat high} then} .then,\n {.x_rev empty? if, {.low nat low, 0 high} then} .then,\n <\n {.x_rev /0 x_rev, .m /1 m, .low |0 low},\n {.x_rev /1 x_rev, .m /1 m, .low |1 low}\n > _split_rev_u\n>;\nsplit_at = {.x inv x_rev, .m m, 0b low} _split_rev_u;\n\nat_least_256_u? = <\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n yes, no\n>;\n\nshift_bits_u = ${bits val, unat m}\n<\n {.val empty? if, 0b then} .then,\n {.val x, .m unat_to_zeros y} concat\n>;\n\nshift2_bits_u = ${bits val, unat m}\n<\n {.val empty? if, 0b then} .then,\n {.val x, .m unat_to_double_zeros y} concat\n>;\n\n_karatsuba = ${bits x, bits y}\n<\n -- Base case: if m < 256 (< 512 bits), fall back to times_bits\n {{.x x, .y y} half_unat m, .x x, .y y}\n <\n {\n .m at_least_256_u? /no if,\n {.x x, .y y} times_bits then\n } .then,\n -- Recursive Karatsuba:\n {\n {.x x, .m m} split_at sx,\n {.y x, .m m} split_at sy,\n .m m\n }\n {\n {.sx.high x, .sy.high y} _karatsuba z2,\n {.sx.low x, .sy.low y} _karatsuba z0,\n {\n {.sx.high x, .sx.low y} plus_bits x,\n {.sy.high x, .sy.low y} plus_bits y\n } _karatsuba z_sum,\n .m m\n }\n {\n .z2 z2,\n .z0 z0,\n {{.z_sum x, .z2 y} minus_bits x, .z0 y} minus_bits z1,\n .m m\n }\n {\n {.z2 val, .m m} shift2_bits_u z2_s,\n {.z1 val, .m m} shift_bits_u z1_s,\n .z0 z0\n }\n {{.z2_s x, .z1_s y} plus_bits x, .z0 y} plus_bits\n >\n>;\n\nkaratsuba = ${int x, int y}\n{\n <\n {.x/'+' if, .y /'+' and} sign_plus,\n {.x/'-' if, .y /'-' and} sign_plus,\n sign_minus\n > sign,\n {.x abs x, .y abs y} _karatsuba result\n}\n<\n {.sign/'+' if, .result int then} .then,\n {.sign/'-' if, .result int swap_sign then} .then\n>;\n\n()\n",
12
+ "Examples/karatsuba-mult.k": "-- Karatsuba multiplication O(n^1.585)\n-- Self-contained and minimal implementation\n-- for arbitrary-precision integers\n\n$ yes_no = < {} yes, {} no >;\nyes = {} | yes $yes_no;\nno = {} | no $yes_no;\n\n$ bits = < {} _, bits 0, bits 1 >;\n0b = {} | _;\n0 = 0b |0;\n1 = 0b |1;\n\n$ unat = < {} _, unat 1 >;\n0u = {} | _ $unat;\n\nempty = $bits < /_ yes, no >;\nempty? = {empty /yes if, () then} .then;\n\ninv = {()x, 0b r} _inv;\n_inv = ${bits x, bits r}\n<\n {.x empty? if, .r then} .then,\n <\n {.x /0 x, .r |0 r},\n {.x /1 x, .r |1 r}\n > _inv\n>;\n\nconcat = ${bits x, bits y} {.x inv x, .y y} concat_;\nconcat_ = ${bits x, bits y}\n<\n {.x empty? if, .y then} .then,\n <\n {.x /0 x, .y |0 y},\n {.x /1 x, .y |1 y}\n > concat_\n>;\n\nremove_leading_zeros = < /0 remove_leading_zeros, () >;\nnat = remove_leading_zeros <empty? 0, ()>;\n\n$ int = < bits '+', bits '-' >;\nint = nat | '+' $int;\nabs = $int </'+', /'-'>;\n\n$ sign = < {} '+', {} '-' >;\nsign_plus = {} | '+' $sign;\nsign_minus = {} | '-' $sign;\nswap_sign = < /'+' | '-', /'-' | '+' >;\n\n$ carry = < {} 0, {} 1 >;\nc0 = {} | 0 $carry;\nc1 = {} | 1 $carry;\n\n_plus = {.x x, .y y, .c c, 0b r} _plus_;\n_plus_ = ${bits x, bits y, carry c, bits r}\n<\n {.x empty? if, .y empty? and, .c/0 c, .r inv then} .then,\n {.x empty? if, .y empty? and, {.r x, 1 r} _inv then} .then,\n {.x empty? if, .c/0 and, {.r x, .y r} _inv then} .then,\n <\n {.x y, .y empty? x, .c c, .r r},\n {<.c/0 0, 1> x, .y y, .x empty? c0 c, .r r},\n {.x /0 x, .y /0 y, .c/0 c0 c, .r |0 r},\n {.x /0 x, .y /0 y, .c/1 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/0 c0 c, .r |1 r},\n {.x /0 x, .y /1 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /0 y, .c/0 c0 c, .r |1 r},\n {.x /1 x, .y /0 y, .c/1 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/0 c1 c, .r |0 r},\n {.x /1 x, .y /1 y, .c/1 c1 c, .r |1 r}\n > _plus_\n>;\n\n_minus = {.x x, .y y, .c c, 0b r} _minus_;\n_minus_ = ${bits x, bits y, carry c, bits r}\n<\n {.y empty? if, .c/0 and, {.r x, .x r} _inv then} .then,\n <\n {.x/0 x, .y empty? y, .c/1 c1 c, .r |1 r},\n {.x/1 x, .y empty? y, .c/1 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/0 c0 c, .r |0 r},\n {.x/0 x, .y/0 y, .c/1 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/0 c1 c, .r |1 r},\n {.x/0 x, .y/1 y, .c/1 c1 c, .r |0 r},\n {.x/1 x, .y/0 y, .c/0 c0 c, .r |1 r},\n {.x/1 x, .y/0 y, .c/1 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/0 c0 c, .r |0 r},\n {.x/1 x, .y/1 y, .c/1 c1 c, .r |1 r}\n > _minus_\n>;\n\nplus_bits = ${bits x, bits y} {.x inv x, .y inv y, c0 c} _plus inv nat;\nminus_bits = ${bits x, bits y} {.x inv x, .y inv y, c0 c} _minus inv nat;\n\n_times = ${bits result, bits _x, bits y}\n<\n {.y empty? if, .result then} .then,\n <\n {.result |0 result, ._x _x, .y /0 y},\n {{._x x, .result |0 y, c0 c} _plus result, ._x _x, .y /1 y}\n > _times\n>;\ntimes_bits = ${bits x, bits y} {0 result, .x inv _x, .y y} _times inv nat;\n\nunat_to_zeros = $unat < /_ 0b, /1 unat_to_zeros |0 > $bits;\nunat_to_double_zeros = $unat\n < /_ 0b, /1 unat_to_double_zeros |0 |0 > $bits;\n\n_peel2 = < </0,/1> </0,/1>, </0,/1>, () >;\n_half_unat = ${bits x, bits y, unat m}\n<\n {.x empty? if, .y empty? and, .m then} .then,\n {.x _peel2 x, .y _peel2 y, .m |1 m} _half_unat\n>;\nhalf_unat = {.x x, .y y, 0u m} _half_unat;\n\n_split_rev_u = ${bits x_rev, unat m, bits low}\n<\n {.m /_ if, {.low nat low, .x_rev inv nat high} then} .then,\n {.x_rev empty? if, {.low nat low, 0 high} then} .then,\n <\n {.x_rev /0 x_rev, .m /1 m, .low |0 low},\n {.x_rev /1 x_rev, .m /1 m, .low |1 low}\n > _split_rev_u\n>;\nsplit_at = {.x inv x_rev, .m m, 0b low} _split_rev_u;\n\nat_least_256_u? = <\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1 /1\n yes, no\n>;\n\nshift_bits_u = ${bits val, unat m}\n<\n {.val empty? if, 0b then} .then,\n {.val x, .m unat_to_zeros y} concat\n>;\n\nshift2_bits_u = ${bits val, unat m}\n<\n {.val empty? if, 0b then} .then,\n {.val x, .m unat_to_double_zeros y} concat\n>;\n\n_karatsuba = ${bits x, bits y}\n<\n -- Base case: if m < 256 (< 512 bits), fall back to times_bits\n {{.x x, .y y} half_unat m, .x x, .y y}\n <\n {\n .m at_least_256_u? /no if,\n {.x x, .y y} times_bits then\n } .then,\n -- Recursive Karatsuba:\n {\n {.x x, .m m} split_at sx,\n {.y x, .m m} split_at sy,\n .m m\n }\n {\n {.sx.high x, .sy.high y} _karatsuba z2,\n {.sx.low x, .sy.low y} _karatsuba z0,\n {\n {.sx.high x, .sx.low y} plus_bits x,\n {.sy.high x, .sy.low y} plus_bits y\n } _karatsuba z_sum,\n .m m\n }\n {\n .z2 z2,\n .z0 z0,\n {{.z_sum x, .z2 y} minus_bits x, .z0 y} minus_bits z1,\n .m m\n }\n {\n {.z2 val, .m m} shift2_bits_u z2_s,\n {.z1 val, .m m} shift_bits_u z1_s,\n .z0 z0\n }\n {{.z2_s x, .z1_s y} plus_bits x, .z0 y} plus_bits\n >\n>;\n\nkaratsuba = ${int x, int y}\n{\n <\n {.x/'+' if, .y /'+' and} sign_plus,\n {.x/'-' if, .y /'-' and} sign_plus,\n sign_minus\n > sign,\n {.x abs x, .y abs y} _karatsuba result\n}\n<\n {.sign/'+' if, .result int then} .then,\n {.sign/'-' if, .result int swap_sign then} .then\n>;\n\n()\n",
12
13
  "codecs/json.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/runtime/unicode-string.mjs\nvar UNIT = Value.product({});\nvar BIT0 = Value.variant(\"0\", UNIT);\nvar BIT1 = Value.variant(\"1\", UNIT);\nfunction bitValue(bit) {\n return bit === 0 ? BIT0 : BIT1;\n}\nfunction requireProduct(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction bitsProduct(width, n) {\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue(n >> i & 1);\n }\n return Value.product(product);\n}\nfunction parseBitsProduct(value, maxBit, where) {\n const product = requireProduct(value, where);\n let n = 0;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1 | (entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction byteProduct(n) {\n return bitsProduct(8, n);\n}\nfunction parseByteProduct(value, where) {\n return parseBitsProduct(value, 7, where);\n}\nfunction encodeBmpCommonHi(hi) {\n if (hi >= 8 && hi <= 15) return Value.variant(\"h08_0F\", bitsProduct(3, hi - 8));\n if (hi >= 16 && hi <= 127) return Value.variant(\"h10_7F\", bitsProduct(7, hi - 16));\n if (hi >= 128 && hi <= 207) return Value.variant(\"h80_CF\", bitsProduct(7, hi - 128));\n if (hi >= 208 && hi <= 215) return Value.variant(\"hD0_D7\", bitsProduct(3, hi - 208));\n if (hi === 249) return Value.variant(\"hF9\", UNIT);\n if (hi >= 250 && hi <= 251) return Value.variant(\"hFA_FB\", bitsProduct(1, hi - 250));\n if (hi >= 252 && hi <= 253) return Value.variant(\"hFC_FD\", bitsProduct(1, hi - 252));\n if (hi >= 254 && hi <= 255) return Value.variant(\"hFE_FF\", bitsProduct(1, hi - 254));\n throw new Error(`Unsupported BMP common hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpCommonHi(value) {\n const v = requireVariant(value, \"bmp_common.hi\");\n if (v.tag === \"h08_0F\") return 8 + parseBitsProduct(v.value, 2, \"h08_0F\");\n if (v.tag === \"h10_7F\") return 16 + parseBitsProduct(v.value, 6, \"h10_7F\");\n if (v.tag === \"h80_CF\") return 128 + parseBitsProduct(v.value, 6, \"h80_CF\");\n if (v.tag === \"hD0_D7\") return 208 + parseBitsProduct(v.value, 2, \"hD0_D7\");\n if (v.tag === \"hF9\") return 249;\n if (v.tag === \"hFA_FB\") return 250 + parseBitsProduct(v.value, 0, \"hFA_FB\");\n if (v.tag === \"hFC_FD\") return 252 + parseBitsProduct(v.value, 0, \"hFC_FD\");\n if (v.tag === \"hFE_FF\") return 254 + parseBitsProduct(v.value, 0, \"hFE_FF\");\n throw new Error(`Unsupported bmp_common.hi tag: ${v.tag}`);\n}\nfunction encodeBmpPrivateHi(hi) {\n if (hi >= 224 && hi <= 239) return Value.variant(\"hE0_EF\", bitsProduct(4, hi - 224));\n if (hi >= 240 && hi <= 247) return Value.variant(\"hF0_F7\", bitsProduct(3, hi - 240));\n if (hi === 248) return Value.variant(\"hF8\", UNIT);\n throw new Error(`Unsupported BMP private-use hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpPrivateHi(value) {\n const v = requireVariant(value, \"bmp_private_use.hi\");\n if (v.tag === \"hE0_EF\") return 224 + parseBitsProduct(v.value, 3, \"hE0_EF\");\n if (v.tag === \"hF0_F7\") return 240 + parseBitsProduct(v.value, 2, \"hF0_F7\");\n if (v.tag === \"hF8\") return 248;\n throw new Error(`Unsupported bmp_private_use.hi tag: ${v.tag}`);\n}\nfunction encodePlane2To16(plane) {\n if (plane >= 2 && plane <= 3) return Value.variant(\"p02_03\", bitsProduct(1, plane - 2));\n if (plane >= 4 && plane <= 7) return Value.variant(\"p04_07\", bitsProduct(2, plane - 4));\n if (plane >= 8 && plane <= 15) return Value.variant(\"p08_0F\", bitsProduct(3, plane - 8));\n if (plane === 16) return Value.variant(\"p10\", UNIT);\n throw new Error(`Plane out of range for supplementary_planes2_16: ${plane}`);\n}\nfunction decodePlane2To16(value) {\n const v = requireVariant(value, \"supplementary_planes2_16.plane\");\n if (v.tag === \"p02_03\") return 2 + parseBitsProduct(v.value, 0, \"p02_03\");\n if (v.tag === \"p04_07\") return 4 + parseBitsProduct(v.value, 1, \"p04_07\");\n if (v.tag === \"p08_0F\") return 8 + parseBitsProduct(v.value, 2, \"p08_0F\");\n if (v.tag === \"p10\") return 16;\n throw new Error(`Unsupported supplementary plane tag: ${v.tag}`);\n}\nfunction codePointToUnicodeValue(cp) {\n if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {\n throw new Error(`Code point out of Unicode range: ${cp}`);\n }\n if (cp >= 55296 && cp <= 57343) {\n throw new Error(`Surrogate code point is not a scalar value: U+${cp.toString(16).toUpperCase()}`);\n }\n if (cp <= 127) {\n return Value.variant(\"ascii\", bitsProduct(7, cp));\n }\n if (cp <= 2047) {\n return Value.variant(\"plane0\", bitsProduct(11, cp));\n }\n if (cp <= 65535) {\n const hi = cp >> 8 & 255;\n const lo2 = cp & 255;\n if (hi >= 224 && hi <= 248) {\n return Value.variant(\"bmp_private_use\", Value.product({ hi: encodeBmpPrivateHi(hi), lo: byteProduct(lo2) }));\n }\n return Value.variant(\"bmp_common\", Value.product({ hi: encodeBmpCommonHi(hi), lo: byteProduct(lo2) }));\n }\n const mid = cp >> 8 & 255;\n const lo = cp & 255;\n if (cp <= 131071) {\n return Value.variant(\"supplementary_plane1\", Value.product({\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n }\n const plane = cp >> 16;\n return Value.variant(\"supplementary_planes2_16\", Value.product({\n plane: encodePlane2To16(plane),\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n}\nfunction unicodeValueToCodePoint(value) {\n const v = requireVariant(value, \"unicode\");\n if (v.tag === \"ascii\") return parseBitsProduct(v.value, 6, \"ascii\");\n if (v.tag === \"plane0\") return parseBitsProduct(v.value, 10, \"plane0\");\n if (v.tag === \"bmp_common\") {\n const p = requireProduct(v.value, \"bmp_common\");\n return decodeBmpCommonHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_common.lo\");\n }\n if (v.tag === \"bmp_private_use\") {\n const p = requireProduct(v.value, \"bmp_private_use\");\n return decodeBmpPrivateHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_private_use.lo\");\n }\n if (v.tag === \"supplementary_plane1\") {\n const p = requireProduct(v.value, \"supplementary_plane1\");\n return 1 << 16 | parseByteProduct(p.mid, \"supplementary_plane1.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_plane1.lo\");\n }\n if (v.tag === \"supplementary_planes2_16\") {\n const p = requireProduct(v.value, \"supplementary_planes2_16\");\n return decodePlane2To16(p.plane) << 16 | parseByteProduct(p.mid, \"supplementary_planes2_16.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_planes2_16.lo\");\n }\n throw new Error(`Unsupported unicode tag: ${v.tag}`);\n}\nfunction textToStringValue(text) {\n let out = Value.variant(\"nil\", UNIT);\n const chars = Array.from(text);\n for (let i = chars.length - 1; i >= 0; i--) {\n const cp = chars[i].codePointAt(0);\n out = Value.variant(\"cons\", Value.product({\n car: codePointToUnicodeValue(cp),\n cdr: out\n }));\n }\n return out;\n}\nfunction stringValueToText(value) {\n let out = \"\";\n let cursor = value;\n while (true) {\n const list = requireVariant(cursor, \"string\");\n if (list.tag === \"nil\") {\n requireProduct(list.value, \"string.nil\");\n return out;\n }\n if (list.tag !== \"cons\") {\n throw new Error(`Unsupported string list tag: ${list.tag}`);\n }\n const pair = requireProduct(list.value, \"string.cons\");\n out += String.fromCodePoint(unicodeValueToCodePoint(pair.car));\n cursor = pair.cdr;\n }\n}\n\n// codecs/string-codec.mjs\nvar STRING_PATTERN_PROPERTY_LIST = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$bits1 = { bit 0 };\n$bits2 = { bit 0, bit 1 };\n$bits3 = { bit 0, bit 1, bit 2 };\n$bits4 = { bit 0, bit 1, bit 2, bit 3 };\n$bits7 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6 };\n$bits8 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7 };\n$bits11 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10 };\n\n$bmp_common_hi = <\n bits3 h08_0F,\n bits7 h10_7F,\n bits7 h80_CF,\n bits3 hD0_D7,\n {} hF9,\n bits1 hFA_FB,\n bits1 hFC_FD,\n bits1 hFE_FF\n>;\n$bmp_common = { bmp_common_hi hi, bits8 lo };\n\n$bmp_private_hi = <\n bits4 hE0_EF,\n bits3 hF0_F7,\n {} hF8\n>;\n$bmp_private_use = { bmp_private_hi hi, bits8 lo };\n\n$plane2_16 = <\n bits1 p02_03,\n bits2 p04_07,\n bits3 p08_0F,\n {} p10\n>;\n$supplementary_planes2_16 = { plane2_16 plane, bits8 mid, bits8 lo };\n$supplementary_plane1 = { bits8 mid, bits8 lo };\n\n$unicode_scalar = <\n bits7 ascii,\n bits11 plane0,\n bmp_common bmp_common,\n bmp_private_use bmp_private_use,\n supplementary_plane1 supplementary_plane1,\n supplementary_planes2_16 supplementary_planes2_16\n>;\n\n?< {} nil, { $unicode_scalar car, str cdr } cons > = str\n`);\n\n// codecs/ieee.mjs\nvar doc = `\nIEEE 754 64-bit float codec.\n\nParses decimal floats, Infinity, -Infinity, NaN to 64-bit IEEE products.\n`;\nvar FLOAT64_PATTERN = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$sign = < {} \"+\", {} \"-\" >;\n$exp11 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10};\n$frac52 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51};\n$float64 = {sign sign, exp11 exponent, frac52 fraction};\n?$float64\n`);\nvar UNIT2 = Value.product({});\nfunction bitValue2(bit) {\n return Value.variant(bit === 0 ? \"0\" : \"1\", UNIT2);\n}\nfunction bitsProduct2(width, value) {\n const big = BigInt(value);\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue2(Number(big >> BigInt(i) & 1n));\n }\n return Value.product(product);\n}\nvar floatView = new DataView(new ArrayBuffer(8));\nfunction encodeNumberToValue(number) {\n floatView.setFloat64(0, number, false);\n const bits = floatView.getBigUint64(0, false);\n const sign = Number(bits >> 63n & 1n);\n const exponent = Number(bits >> 52n & 0x7ffn);\n const fraction = bits & (1n << 52n) - 1n;\n return Value.product({\n sign: Value.variant(sign === 0 ? \"+\" : \"-\", UNIT2),\n exponent: bitsProduct2(11, exponent),\n fraction: bitsProduct2(52, fraction)\n });\n}\nfunction requireProduct2(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant2(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction parseBitsProduct2(value, maxBit, where) {\n const product = requireProduct2(value, where);\n let n = 0n;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant2(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1n | BigInt(entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction decodeValueToNumber(value) {\n const product = requireProduct2(value, \"float64\");\n const sign = requireVariant2(product.sign, \"float64.sign\");\n if (sign.tag !== \"+\" && sign.tag !== \"-\") {\n throw new Error(`float64.sign: expected + or -, got ${sign.tag}`);\n }\n const exponent = parseBitsProduct2(product.exponent, 10, \"float64.exponent\");\n const fraction = parseBitsProduct2(product.fraction, 51, \"float64.fraction\");\n const bits = BigInt(sign.tag === \"-\" ? 1 : 0) << 63n | exponent << 52n | fraction;\n floatView.setBigUint64(0, bits, false);\n return floatView.getFloat64(0, false);\n}\nfunction parseFloatText(text) {\n const trimmed = text.trim();\n if (trimmed === \"\") {\n throw new Error(\"Expected a floating-point literal\");\n }\n if (/^[+-]?nan$/i.test(trimmed)) return NaN;\n if (/^[+]?inf(inity)?$/i.test(trimmed)) return Infinity;\n if (/^[-](inf|infinity)$/i.test(trimmed)) return -Infinity;\n const n = Number(trimmed);\n if (Number.isNaN(n)) {\n throw new Error(`Invalid float literal ${JSON.stringify(trimmed)}`);\n }\n return n;\n}\nfunction printFloatText(n) {\n if (Number.isNaN(n)) return \"NaN\";\n if (n === Infinity) return \"Infinity\";\n if (n === -Infinity) return \"-Infinity\";\n if (Object.is(n, -0)) return \"-0\";\n return String(n);\n}\nfunction parse(text) {\n const n = parseFloatText(text);\n const value = encodeNumberToValue(n);\n return withPattern(value, FLOAT64_PATTERN);\n}\nfunction print(value) {\n return printFloatText(decodeValueToNumber(value));\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\n\n// codecs/json-codec.mjs\nvar UNIT3 = Value.product({});\nvar BOOL_PATTERN = patternFromFilter(\"?< {} false, {} true >\");\nvar NULL_PATTERN = patternFromFilter(\"?< {} null >\");\nfunction requireProduct3(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction fromJsonValue(value) {\n if (value === null) {\n return Value.variant(\"null\", UNIT3);\n }\n if (typeof value === \"boolean\") {\n return Value.variant(value ? \"true\" : \"false\", UNIT3);\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw new Error(\"JSON numbers must be finite\");\n }\n return encodeNumberToValue(value);\n }\n if (typeof value === \"string\") {\n return textToStringValue(value);\n }\n if (Array.isArray(value)) {\n return Value.product(\n value.reduce((product, item, index) => {\n product[String(index)] = fromJsonValue(item);\n return product;\n }, {})\n );\n }\n if (value && typeof value === \"object\") {\n return Value.product(\n Object.keys(value).reduce((product, key) => {\n product[key] = fromJsonValue(value[key]);\n return product;\n }, {})\n );\n }\n throw new Error(`Unsupported JSON value: ${value}`);\n}\nfunction composePattern(kind, entries) {\n const result = [[kind, []]];\n for (const [label, childPattern] of entries) {\n const offset = result.length;\n result[0][1].push([label, offset]);\n for (const [childKind, childEdges] of childPattern) {\n result.push([\n childKind,\n childEdges.map(([edgeLabel, target]) => [edgeLabel, target + offset])\n ]);\n }\n }\n return result;\n}\nfunction patternFromJsonValue(value) {\n if (value === null) return NULL_PATTERN;\n if (typeof value === \"boolean\") return BOOL_PATTERN;\n if (typeof value === \"number\") return FLOAT64_PATTERN;\n if (typeof value === \"string\") return STRING_PATTERN_PROPERTY_LIST;\n if (Array.isArray(value)) {\n return composePattern(\n \"closed-product\",\n value.map((item, index) => [String(index), patternFromJsonValue(item)])\n );\n }\n if (value && typeof value === \"object\") {\n return composePattern(\n \"closed-product\",\n Object.keys(value).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((key) => [key, patternFromJsonValue(value[key])])\n );\n }\n throw new Error(`Unsupported JSON value: ${value}`);\n}\nfunction toJsonValue(value) {\n if (isVariant(value)) {\n if (value.tag === \"null\") {\n requireProduct3(value.value, \"json.null\");\n return null;\n }\n if (value.tag === \"true\") {\n requireProduct3(value.value, \"json.true\");\n return true;\n }\n if (value.tag === \"false\") {\n requireProduct3(value.value, \"json.false\");\n return false;\n }\n return stringValueToText(value);\n }\n const product = requireProduct3(value, \"json.value\");\n const keys = Object.keys(product);\n const isArray = keys.every((key, index) => key === String(index));\n if (isArray) {\n return keys.map((key) => {\n const child = product[key];\n if (isVariant(child)) return toJsonValue(child);\n if (isProduct(child)) {\n try {\n return decodeValueToNumber(child);\n } catch {\n }\n }\n return toJsonValue(child);\n });\n }\n const numberKeys = [\"exponent\", \"fraction\", \"sign\"];\n if (keys.length === numberKeys.length && numberKeys.every((key) => key in product)) {\n return decodeValueToNumber(value);\n }\n try {\n return stringValueToText(value);\n } catch {\n }\n return keys.reduce((result, key) => {\n result[key] = toJsonValue(product[key]);\n return result;\n }, {});\n}\n\n// codecs/json.mjs\nvar doc2 = `\nJSON codec (RFC 8259).\n\nTranslates JSON data to/from self-describing enveloped k values.\n`;\nfunction parse2(text) {\n const json = JSON.parse(text);\n const value = fromJsonValue(json);\n const pattern = patternFromJsonValue(json);\n return withPattern(value, pattern);\n}\nfunction print2(value) {\n return JSON.stringify(toJsonValue(value));\n}\nrunCodecCLI(import.meta.url, { parse: parse2, print: print2, doc: doc2 });\nexport {\n doc2 as doc,\n parse2 as parse,\n print2 as print\n};\n",
13
- "utf8.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/runtime/unicode-string.mjs\nvar UNIT = Value.product({});\nvar BIT0 = Value.variant(\"0\", UNIT);\nvar BIT1 = Value.variant(\"1\", UNIT);\nfunction bitValue(bit) {\n return bit === 0 ? BIT0 : BIT1;\n}\nfunction requireProduct(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction bitsProduct(width, n) {\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue(n >> i & 1);\n }\n return Value.product(product);\n}\nfunction parseBitsProduct(value, maxBit, where) {\n const product = requireProduct(value, where);\n let n = 0;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1 | (entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction byteProduct(n) {\n return bitsProduct(8, n);\n}\nfunction parseByteProduct(value, where) {\n return parseBitsProduct(value, 7, where);\n}\nfunction encodeBmpCommonHi(hi) {\n if (hi >= 8 && hi <= 15) return Value.variant(\"h08_0F\", bitsProduct(3, hi - 8));\n if (hi >= 16 && hi <= 127) return Value.variant(\"h10_7F\", bitsProduct(7, hi - 16));\n if (hi >= 128 && hi <= 207) return Value.variant(\"h80_CF\", bitsProduct(7, hi - 128));\n if (hi >= 208 && hi <= 215) return Value.variant(\"hD0_D7\", bitsProduct(3, hi - 208));\n if (hi === 249) return Value.variant(\"hF9\", UNIT);\n if (hi >= 250 && hi <= 251) return Value.variant(\"hFA_FB\", bitsProduct(1, hi - 250));\n if (hi >= 252 && hi <= 253) return Value.variant(\"hFC_FD\", bitsProduct(1, hi - 252));\n if (hi >= 254 && hi <= 255) return Value.variant(\"hFE_FF\", bitsProduct(1, hi - 254));\n throw new Error(`Unsupported BMP common hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpCommonHi(value) {\n const v = requireVariant(value, \"bmp_common.hi\");\n if (v.tag === \"h08_0F\") return 8 + parseBitsProduct(v.value, 2, \"h08_0F\");\n if (v.tag === \"h10_7F\") return 16 + parseBitsProduct(v.value, 6, \"h10_7F\");\n if (v.tag === \"h80_CF\") return 128 + parseBitsProduct(v.value, 6, \"h80_CF\");\n if (v.tag === \"hD0_D7\") return 208 + parseBitsProduct(v.value, 2, \"hD0_D7\");\n if (v.tag === \"hF9\") return 249;\n if (v.tag === \"hFA_FB\") return 250 + parseBitsProduct(v.value, 0, \"hFA_FB\");\n if (v.tag === \"hFC_FD\") return 252 + parseBitsProduct(v.value, 0, \"hFC_FD\");\n if (v.tag === \"hFE_FF\") return 254 + parseBitsProduct(v.value, 0, \"hFE_FF\");\n throw new Error(`Unsupported bmp_common.hi tag: ${v.tag}`);\n}\nfunction encodeBmpPrivateHi(hi) {\n if (hi >= 224 && hi <= 239) return Value.variant(\"hE0_EF\", bitsProduct(4, hi - 224));\n if (hi >= 240 && hi <= 247) return Value.variant(\"hF0_F7\", bitsProduct(3, hi - 240));\n if (hi === 248) return Value.variant(\"hF8\", UNIT);\n throw new Error(`Unsupported BMP private-use hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpPrivateHi(value) {\n const v = requireVariant(value, \"bmp_private_use.hi\");\n if (v.tag === \"hE0_EF\") return 224 + parseBitsProduct(v.value, 3, \"hE0_EF\");\n if (v.tag === \"hF0_F7\") return 240 + parseBitsProduct(v.value, 2, \"hF0_F7\");\n if (v.tag === \"hF8\") return 248;\n throw new Error(`Unsupported bmp_private_use.hi tag: ${v.tag}`);\n}\nfunction encodePlane2To16(plane) {\n if (plane >= 2 && plane <= 3) return Value.variant(\"p02_03\", bitsProduct(1, plane - 2));\n if (plane >= 4 && plane <= 7) return Value.variant(\"p04_07\", bitsProduct(2, plane - 4));\n if (plane >= 8 && plane <= 15) return Value.variant(\"p08_0F\", bitsProduct(3, plane - 8));\n if (plane === 16) return Value.variant(\"p10\", UNIT);\n throw new Error(`Plane out of range for supplementary_planes2_16: ${plane}`);\n}\nfunction decodePlane2To16(value) {\n const v = requireVariant(value, \"supplementary_planes2_16.plane\");\n if (v.tag === \"p02_03\") return 2 + parseBitsProduct(v.value, 0, \"p02_03\");\n if (v.tag === \"p04_07\") return 4 + parseBitsProduct(v.value, 1, \"p04_07\");\n if (v.tag === \"p08_0F\") return 8 + parseBitsProduct(v.value, 2, \"p08_0F\");\n if (v.tag === \"p10\") return 16;\n throw new Error(`Unsupported supplementary plane tag: ${v.tag}`);\n}\nfunction codePointToUnicodeValue(cp) {\n if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {\n throw new Error(`Code point out of Unicode range: ${cp}`);\n }\n if (cp >= 55296 && cp <= 57343) {\n throw new Error(`Surrogate code point is not a scalar value: U+${cp.toString(16).toUpperCase()}`);\n }\n if (cp <= 127) {\n return Value.variant(\"ascii\", bitsProduct(7, cp));\n }\n if (cp <= 2047) {\n return Value.variant(\"plane0\", bitsProduct(11, cp));\n }\n if (cp <= 65535) {\n const hi = cp >> 8 & 255;\n const lo2 = cp & 255;\n if (hi >= 224 && hi <= 248) {\n return Value.variant(\"bmp_private_use\", Value.product({ hi: encodeBmpPrivateHi(hi), lo: byteProduct(lo2) }));\n }\n return Value.variant(\"bmp_common\", Value.product({ hi: encodeBmpCommonHi(hi), lo: byteProduct(lo2) }));\n }\n const mid = cp >> 8 & 255;\n const lo = cp & 255;\n if (cp <= 131071) {\n return Value.variant(\"supplementary_plane1\", Value.product({\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n }\n const plane = cp >> 16;\n return Value.variant(\"supplementary_planes2_16\", Value.product({\n plane: encodePlane2To16(plane),\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n}\nfunction unicodeValueToCodePoint(value) {\n const v = requireVariant(value, \"unicode\");\n if (v.tag === \"ascii\") return parseBitsProduct(v.value, 6, \"ascii\");\n if (v.tag === \"plane0\") return parseBitsProduct(v.value, 10, \"plane0\");\n if (v.tag === \"bmp_common\") {\n const p = requireProduct(v.value, \"bmp_common\");\n return decodeBmpCommonHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_common.lo\");\n }\n if (v.tag === \"bmp_private_use\") {\n const p = requireProduct(v.value, \"bmp_private_use\");\n return decodeBmpPrivateHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_private_use.lo\");\n }\n if (v.tag === \"supplementary_plane1\") {\n const p = requireProduct(v.value, \"supplementary_plane1\");\n return 1 << 16 | parseByteProduct(p.mid, \"supplementary_plane1.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_plane1.lo\");\n }\n if (v.tag === \"supplementary_planes2_16\") {\n const p = requireProduct(v.value, \"supplementary_planes2_16\");\n return decodePlane2To16(p.plane) << 16 | parseByteProduct(p.mid, \"supplementary_planes2_16.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_planes2_16.lo\");\n }\n throw new Error(`Unsupported unicode tag: ${v.tag}`);\n}\nfunction textToStringValue(text) {\n let out = Value.variant(\"nil\", UNIT);\n const chars = Array.from(text);\n for (let i = chars.length - 1; i >= 0; i--) {\n const cp = chars[i].codePointAt(0);\n out = Value.variant(\"cons\", Value.product({\n car: codePointToUnicodeValue(cp),\n cdr: out\n }));\n }\n return out;\n}\nfunction stringValueToText(value) {\n let out = \"\";\n let cursor = value;\n while (true) {\n const list = requireVariant(cursor, \"string\");\n if (list.tag === \"nil\") {\n requireProduct(list.value, \"string.nil\");\n return out;\n }\n if (list.tag !== \"cons\") {\n throw new Error(`Unsupported string list tag: ${list.tag}`);\n }\n const pair = requireProduct(list.value, \"string.cons\");\n out += String.fromCodePoint(unicodeValueToCodePoint(pair.car));\n cursor = pair.cdr;\n }\n}\n\n// codecs/string-codec.mjs\nvar STRING_PATTERN_PROPERTY_LIST = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$bits1 = { bit 0 };\n$bits2 = { bit 0, bit 1 };\n$bits3 = { bit 0, bit 1, bit 2 };\n$bits4 = { bit 0, bit 1, bit 2, bit 3 };\n$bits7 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6 };\n$bits8 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7 };\n$bits11 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10 };\n\n$bmp_common_hi = <\n bits3 h08_0F,\n bits7 h10_7F,\n bits7 h80_CF,\n bits3 hD0_D7,\n {} hF9,\n bits1 hFA_FB,\n bits1 hFC_FD,\n bits1 hFE_FF\n>;\n$bmp_common = { bmp_common_hi hi, bits8 lo };\n\n$bmp_private_hi = <\n bits4 hE0_EF,\n bits3 hF0_F7,\n {} hF8\n>;\n$bmp_private_use = { bmp_private_hi hi, bits8 lo };\n\n$plane2_16 = <\n bits1 p02_03,\n bits2 p04_07,\n bits3 p08_0F,\n {} p10\n>;\n$supplementary_planes2_16 = { plane2_16 plane, bits8 mid, bits8 lo };\n$supplementary_plane1 = { bits8 mid, bits8 lo };\n\n$unicode_scalar = <\n bits7 ascii,\n bits11 plane0,\n bmp_common bmp_common,\n bmp_private_use bmp_private_use,\n supplementary_plane1 supplementary_plane1,\n supplementary_planes2_16 supplementary_planes2_16\n>;\n\n?< {} nil, { $unicode_scalar car, str cdr } cons > = str\n`);\n\n// codecs/utf8.mjs\nvar doc = `\nUTF-8 text codec.\n\nEncodes/decodes text strings to/from the canonical k string pattern.\n`;\nfunction parse(text) {\n const value = textToStringValue(text);\n return withPattern(value, STRING_PATTERN_PROPERTY_LIST);\n}\nfunction print(value) {\n return stringValueToText(value);\n}\nrunCodecCLI(import.meta.url, { parse, print, doc, addNewline: false });\nexport {\n doc,\n parse,\n print\n};\n",
14
14
  "codecs/utf8.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/runtime/unicode-string.mjs\nvar UNIT = Value.product({});\nvar BIT0 = Value.variant(\"0\", UNIT);\nvar BIT1 = Value.variant(\"1\", UNIT);\nfunction bitValue(bit) {\n return bit === 0 ? BIT0 : BIT1;\n}\nfunction requireProduct(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction bitsProduct(width, n) {\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue(n >> i & 1);\n }\n return Value.product(product);\n}\nfunction parseBitsProduct(value, maxBit, where) {\n const product = requireProduct(value, where);\n let n = 0;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1 | (entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction byteProduct(n) {\n return bitsProduct(8, n);\n}\nfunction parseByteProduct(value, where) {\n return parseBitsProduct(value, 7, where);\n}\nfunction encodeBmpCommonHi(hi) {\n if (hi >= 8 && hi <= 15) return Value.variant(\"h08_0F\", bitsProduct(3, hi - 8));\n if (hi >= 16 && hi <= 127) return Value.variant(\"h10_7F\", bitsProduct(7, hi - 16));\n if (hi >= 128 && hi <= 207) return Value.variant(\"h80_CF\", bitsProduct(7, hi - 128));\n if (hi >= 208 && hi <= 215) return Value.variant(\"hD0_D7\", bitsProduct(3, hi - 208));\n if (hi === 249) return Value.variant(\"hF9\", UNIT);\n if (hi >= 250 && hi <= 251) return Value.variant(\"hFA_FB\", bitsProduct(1, hi - 250));\n if (hi >= 252 && hi <= 253) return Value.variant(\"hFC_FD\", bitsProduct(1, hi - 252));\n if (hi >= 254 && hi <= 255) return Value.variant(\"hFE_FF\", bitsProduct(1, hi - 254));\n throw new Error(`Unsupported BMP common hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpCommonHi(value) {\n const v = requireVariant(value, \"bmp_common.hi\");\n if (v.tag === \"h08_0F\") return 8 + parseBitsProduct(v.value, 2, \"h08_0F\");\n if (v.tag === \"h10_7F\") return 16 + parseBitsProduct(v.value, 6, \"h10_7F\");\n if (v.tag === \"h80_CF\") return 128 + parseBitsProduct(v.value, 6, \"h80_CF\");\n if (v.tag === \"hD0_D7\") return 208 + parseBitsProduct(v.value, 2, \"hD0_D7\");\n if (v.tag === \"hF9\") return 249;\n if (v.tag === \"hFA_FB\") return 250 + parseBitsProduct(v.value, 0, \"hFA_FB\");\n if (v.tag === \"hFC_FD\") return 252 + parseBitsProduct(v.value, 0, \"hFC_FD\");\n if (v.tag === \"hFE_FF\") return 254 + parseBitsProduct(v.value, 0, \"hFE_FF\");\n throw new Error(`Unsupported bmp_common.hi tag: ${v.tag}`);\n}\nfunction encodeBmpPrivateHi(hi) {\n if (hi >= 224 && hi <= 239) return Value.variant(\"hE0_EF\", bitsProduct(4, hi - 224));\n if (hi >= 240 && hi <= 247) return Value.variant(\"hF0_F7\", bitsProduct(3, hi - 240));\n if (hi === 248) return Value.variant(\"hF8\", UNIT);\n throw new Error(`Unsupported BMP private-use hi byte: 0x${hi.toString(16)}`);\n}\nfunction decodeBmpPrivateHi(value) {\n const v = requireVariant(value, \"bmp_private_use.hi\");\n if (v.tag === \"hE0_EF\") return 224 + parseBitsProduct(v.value, 3, \"hE0_EF\");\n if (v.tag === \"hF0_F7\") return 240 + parseBitsProduct(v.value, 2, \"hF0_F7\");\n if (v.tag === \"hF8\") return 248;\n throw new Error(`Unsupported bmp_private_use.hi tag: ${v.tag}`);\n}\nfunction encodePlane2To16(plane) {\n if (plane >= 2 && plane <= 3) return Value.variant(\"p02_03\", bitsProduct(1, plane - 2));\n if (plane >= 4 && plane <= 7) return Value.variant(\"p04_07\", bitsProduct(2, plane - 4));\n if (plane >= 8 && plane <= 15) return Value.variant(\"p08_0F\", bitsProduct(3, plane - 8));\n if (plane === 16) return Value.variant(\"p10\", UNIT);\n throw new Error(`Plane out of range for supplementary_planes2_16: ${plane}`);\n}\nfunction decodePlane2To16(value) {\n const v = requireVariant(value, \"supplementary_planes2_16.plane\");\n if (v.tag === \"p02_03\") return 2 + parseBitsProduct(v.value, 0, \"p02_03\");\n if (v.tag === \"p04_07\") return 4 + parseBitsProduct(v.value, 1, \"p04_07\");\n if (v.tag === \"p08_0F\") return 8 + parseBitsProduct(v.value, 2, \"p08_0F\");\n if (v.tag === \"p10\") return 16;\n throw new Error(`Unsupported supplementary plane tag: ${v.tag}`);\n}\nfunction codePointToUnicodeValue(cp) {\n if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {\n throw new Error(`Code point out of Unicode range: ${cp}`);\n }\n if (cp >= 55296 && cp <= 57343) {\n throw new Error(`Surrogate code point is not a scalar value: U+${cp.toString(16).toUpperCase()}`);\n }\n if (cp <= 127) {\n return Value.variant(\"ascii\", bitsProduct(7, cp));\n }\n if (cp <= 2047) {\n return Value.variant(\"plane0\", bitsProduct(11, cp));\n }\n if (cp <= 65535) {\n const hi = cp >> 8 & 255;\n const lo2 = cp & 255;\n if (hi >= 224 && hi <= 248) {\n return Value.variant(\"bmp_private_use\", Value.product({ hi: encodeBmpPrivateHi(hi), lo: byteProduct(lo2) }));\n }\n return Value.variant(\"bmp_common\", Value.product({ hi: encodeBmpCommonHi(hi), lo: byteProduct(lo2) }));\n }\n const mid = cp >> 8 & 255;\n const lo = cp & 255;\n if (cp <= 131071) {\n return Value.variant(\"supplementary_plane1\", Value.product({\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n }\n const plane = cp >> 16;\n return Value.variant(\"supplementary_planes2_16\", Value.product({\n plane: encodePlane2To16(plane),\n mid: byteProduct(mid),\n lo: byteProduct(lo)\n }));\n}\nfunction unicodeValueToCodePoint(value) {\n const v = requireVariant(value, \"unicode\");\n if (v.tag === \"ascii\") return parseBitsProduct(v.value, 6, \"ascii\");\n if (v.tag === \"plane0\") return parseBitsProduct(v.value, 10, \"plane0\");\n if (v.tag === \"bmp_common\") {\n const p = requireProduct(v.value, \"bmp_common\");\n return decodeBmpCommonHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_common.lo\");\n }\n if (v.tag === \"bmp_private_use\") {\n const p = requireProduct(v.value, \"bmp_private_use\");\n return decodeBmpPrivateHi(p.hi) << 8 | parseByteProduct(p.lo, \"bmp_private_use.lo\");\n }\n if (v.tag === \"supplementary_plane1\") {\n const p = requireProduct(v.value, \"supplementary_plane1\");\n return 1 << 16 | parseByteProduct(p.mid, \"supplementary_plane1.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_plane1.lo\");\n }\n if (v.tag === \"supplementary_planes2_16\") {\n const p = requireProduct(v.value, \"supplementary_planes2_16\");\n return decodePlane2To16(p.plane) << 16 | parseByteProduct(p.mid, \"supplementary_planes2_16.mid\") << 8 | parseByteProduct(p.lo, \"supplementary_planes2_16.lo\");\n }\n throw new Error(`Unsupported unicode tag: ${v.tag}`);\n}\nfunction textToStringValue(text) {\n let out = Value.variant(\"nil\", UNIT);\n const chars = Array.from(text);\n for (let i = chars.length - 1; i >= 0; i--) {\n const cp = chars[i].codePointAt(0);\n out = Value.variant(\"cons\", Value.product({\n car: codePointToUnicodeValue(cp),\n cdr: out\n }));\n }\n return out;\n}\nfunction stringValueToText(value) {\n let out = \"\";\n let cursor = value;\n while (true) {\n const list = requireVariant(cursor, \"string\");\n if (list.tag === \"nil\") {\n requireProduct(list.value, \"string.nil\");\n return out;\n }\n if (list.tag !== \"cons\") {\n throw new Error(`Unsupported string list tag: ${list.tag}`);\n }\n const pair = requireProduct(list.value, \"string.cons\");\n out += String.fromCodePoint(unicodeValueToCodePoint(pair.car));\n cursor = pair.cdr;\n }\n}\n\n// codecs/string-codec.mjs\nvar STRING_PATTERN_PROPERTY_LIST = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$bits1 = { bit 0 };\n$bits2 = { bit 0, bit 1 };\n$bits3 = { bit 0, bit 1, bit 2 };\n$bits4 = { bit 0, bit 1, bit 2, bit 3 };\n$bits7 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6 };\n$bits8 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7 };\n$bits11 = { bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10 };\n\n$bmp_common_hi = <\n bits3 h08_0F,\n bits7 h10_7F,\n bits7 h80_CF,\n bits3 hD0_D7,\n {} hF9,\n bits1 hFA_FB,\n bits1 hFC_FD,\n bits1 hFE_FF\n>;\n$bmp_common = { bmp_common_hi hi, bits8 lo };\n\n$bmp_private_hi = <\n bits4 hE0_EF,\n bits3 hF0_F7,\n {} hF8\n>;\n$bmp_private_use = { bmp_private_hi hi, bits8 lo };\n\n$plane2_16 = <\n bits1 p02_03,\n bits2 p04_07,\n bits3 p08_0F,\n {} p10\n>;\n$supplementary_planes2_16 = { plane2_16 plane, bits8 mid, bits8 lo };\n$supplementary_plane1 = { bits8 mid, bits8 lo };\n\n$unicode_scalar = <\n bits7 ascii,\n bits11 plane0,\n bmp_common bmp_common,\n bmp_private_use bmp_private_use,\n supplementary_plane1 supplementary_plane1,\n supplementary_planes2_16 supplementary_planes2_16\n>;\n\n?< {} nil, { $unicode_scalar car, str cdr } cons > = str\n`);\n\n// codecs/utf8.mjs\nvar doc = `\nUTF-8 text codec.\n\nEncodes/decodes text strings to/from the canonical k string pattern.\n`;\nfunction parse(text) {\n const value = textToStringValue(text);\n return withPattern(value, STRING_PATTERN_PROPERTY_LIST);\n}\nfunction print(value) {\n return stringValueToText(value);\n}\nrunCodecCLI(import.meta.url, { parse, print, doc, addNewline: false });\nexport {\n doc,\n parse,\n print\n};\n",
15
- "int.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/int.mjs\nvar doc = `\nDecimal integers and integer lists.\n\nSyntax:\n Decimal integer (e.g. 42, -15) or bracketed integer list (e.g. [0, 1, 2], []).\n`;\nvar INT_PATTERN = patternFromFilter('?< <bits 0, bits 1, {} _>=bits \"+\", bits \"-\">');\nvar INT_LIST_PATTERN = patternFromFilter(\n '$ bits = < bits 0, bits 1, {} _ >; $ int = < bits \"+\", bits \"-\" >; ?< {} nil, { $int car, list cdr } cons > = list'\n);\nfunction buildBits(n) {\n const bitChars = n === 0n ? [\"0\"] : n.toString(2).split(\"\");\n let v = Value.variant(\"_\", Value.product({}));\n for (let i = bitChars.length - 1; i >= 0; i--) {\n v = Value.variant(bitChars[i], v);\n }\n return v;\n}\nfunction parseIntStr(str) {\n str = str.trim();\n let sign = \"+\";\n if (str[0] === \"-\") {\n sign = \"-\";\n str = str.slice(1).replace(/\\s+/g, \"\");\n } else if (str[0] === \"+\") {\n str = str.slice(1).replace(/\\s+/g, \"\");\n }\n if (!/^(0|[1-9][0-9]*)$/.test(str)) {\n throw new Error(`Invalid integer syntax: ${JSON.stringify(str)}`);\n }\n const n = BigInt(str);\n if (n === 0n) sign = \"+\";\n return Value.variant(sign, buildBits(n));\n}\nfunction parseIntListStr(str) {\n str = str.trim();\n if (!str.startsWith(\"[\") || !str.endsWith(\"]\")) {\n throw new Error(`Invalid integer list syntax: ${JSON.stringify(str)}`);\n }\n const inner = str.slice(1, -1).trim();\n if (inner === \"\") {\n return Value.variant(\"nil\", Value.product({}));\n }\n const parts = inner.split(\",\");\n const items = parts.map((part) => parseIntStr(part));\n let result = Value.variant(\"nil\", Value.product({}));\n for (let i = items.length - 1; i >= 0; i--) {\n result = Value.variant(\"cons\", Value.product({\n car: items[i],\n cdr: result\n }));\n }\n return result;\n}\nfunction parse(str) {\n str = str.trim();\n const raw = str.startsWith(\"[\") ? parseIntListStr(str) : parseIntStr(str);\n const pattern = isVariant(raw) && (raw.tag === \"nil\" || raw.tag === \"cons\") ? INT_LIST_PATTERN : INT_PATTERN;\n return withPattern(raw, pattern);\n}\nfunction printSingleInt(value) {\n if (!isVariant(value) || value.tag !== \"+\" && value.tag !== \"-\") {\n throw new Error(\"Not a valid k int value\");\n }\n const sign = value.tag;\n let bits = \"\";\n let node = value.value;\n while (isVariant(node) && node.tag !== \"_\") {\n bits += node.tag;\n node = node.value;\n }\n const n = bits === \"\" ? 0n : BigInt(\"0b\" + bits);\n const digits = n.toString(10);\n if (n === 0n) return \"0\";\n return (sign === \"-\" ? \"-\" : \"\") + digits;\n}\nfunction printIntList(value) {\n const items = [];\n let node = value;\n while (isVariant(node) && node.tag === \"cons\") {\n const product = isProduct(node.value) ? node.value.product : null;\n if (!product || !product.car || !product.cdr) {\n throw new Error(\"Invalid list cons node\");\n }\n items.push(printSingleInt(product.car));\n node = product.cdr;\n }\n if (!isVariant(node) || node.tag !== \"nil\") {\n throw new Error(\"Not a valid k int list: does not terminate in nil\");\n }\n return `[${items.join(\",\")}]`;\n}\nfunction print(value) {\n if (isVariant(value)) {\n if (value.tag === \"nil\" || value.tag === \"cons\") {\n return printIntList(value);\n }\n if (value.tag === \"+\" || value.tag === \"-\") {\n return printSingleInt(value);\n }\n }\n throw new Error(\"Not a valid k int or int list value\");\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\nexport {\n INT_LIST_PATTERN,\n INT_PATTERN,\n doc,\n parse,\n parseIntListStr,\n parseIntStr,\n print\n};\n",
16
15
  "codecs/int.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/int.mjs\nvar doc = `\nDecimal integers and integer lists.\n\nSyntax:\n Decimal integer (e.g. 42, -15) or bracketed integer list (e.g. [0, 1, 2], []).\n`;\nvar INT_PATTERN = patternFromFilter('?< <bits 0, bits 1, {} _>=bits \"+\", bits \"-\">');\nvar INT_LIST_PATTERN = patternFromFilter(\n '$ bits = < bits 0, bits 1, {} _ >; $ int = < bits \"+\", bits \"-\" >; ?< {} nil, { $int car, list cdr } cons > = list'\n);\nfunction buildBits(n) {\n const bitChars = n === 0n ? [\"0\"] : n.toString(2).split(\"\");\n let v = Value.variant(\"_\", Value.product({}));\n for (let i = bitChars.length - 1; i >= 0; i--) {\n v = Value.variant(bitChars[i], v);\n }\n return v;\n}\nfunction parseIntStr(str) {\n str = str.trim();\n let sign = \"+\";\n if (str[0] === \"-\") {\n sign = \"-\";\n str = str.slice(1).replace(/\\s+/g, \"\");\n } else if (str[0] === \"+\") {\n str = str.slice(1).replace(/\\s+/g, \"\");\n }\n if (!/^(0|[1-9][0-9]*)$/.test(str)) {\n throw new Error(`Invalid integer syntax: ${JSON.stringify(str)}`);\n }\n const n = BigInt(str);\n if (n === 0n) sign = \"+\";\n return Value.variant(sign, buildBits(n));\n}\nfunction parseIntListStr(str) {\n str = str.trim();\n if (!str.startsWith(\"[\") || !str.endsWith(\"]\")) {\n throw new Error(`Invalid integer list syntax: ${JSON.stringify(str)}`);\n }\n const inner = str.slice(1, -1).trim();\n if (inner === \"\") {\n return Value.variant(\"nil\", Value.product({}));\n }\n const parts = inner.split(\",\");\n const items = parts.map((part) => parseIntStr(part));\n let result = Value.variant(\"nil\", Value.product({}));\n for (let i = items.length - 1; i >= 0; i--) {\n result = Value.variant(\"cons\", Value.product({\n car: items[i],\n cdr: result\n }));\n }\n return result;\n}\nfunction parse(str) {\n str = str.trim();\n const raw = str.startsWith(\"[\") ? parseIntListStr(str) : parseIntStr(str);\n const pattern = isVariant(raw) && (raw.tag === \"nil\" || raw.tag === \"cons\") ? INT_LIST_PATTERN : INT_PATTERN;\n return withPattern(raw, pattern);\n}\nfunction printSingleInt(value) {\n if (!isVariant(value) || value.tag !== \"+\" && value.tag !== \"-\") {\n throw new Error(\"Not a valid k int value\");\n }\n const sign = value.tag;\n let bits = \"\";\n let node = value.value;\n while (isVariant(node) && node.tag !== \"_\") {\n bits += node.tag;\n node = node.value;\n }\n const n = bits === \"\" ? 0n : BigInt(\"0b\" + bits);\n const digits = n.toString(10);\n if (n === 0n) return \"0\";\n return (sign === \"-\" ? \"-\" : \"\") + digits;\n}\nfunction printIntList(value) {\n const items = [];\n let node = value;\n while (isVariant(node) && node.tag === \"cons\") {\n const product = isProduct(node.value) ? node.value.product : null;\n if (!product || !product.car || !product.cdr) {\n throw new Error(\"Invalid list cons node\");\n }\n items.push(printSingleInt(product.car));\n node = product.cdr;\n }\n if (!isVariant(node) || node.tag !== \"nil\") {\n throw new Error(\"Not a valid k int list: does not terminate in nil\");\n }\n return `[${items.join(\",\")}]`;\n}\nfunction print(value) {\n if (isVariant(value)) {\n if (value.tag === \"nil\" || value.tag === \"cons\") {\n return printIntList(value);\n }\n if (value.tag === \"+\" || value.tag === \"-\") {\n return printSingleInt(value);\n }\n }\n throw new Error(\"Not a valid k int or int list value\");\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\nexport {\n INT_LIST_PATTERN,\n INT_PATTERN,\n doc,\n parse,\n parseIntListStr,\n parseIntStr,\n print\n};\n",
17
- "unit.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/unit.mjs\nvar doc = `\nUnit codec for {}.\n\nTranslates the empty product {} to/from binary pattern+value stream.\n`;\nvar UNIT_PATTERN = patternFromFilter(\"?{}\");\nfunction parse() {\n return withPattern(Value.product({}), UNIT_PATTERN);\n}\nfunction print(value) {\n if (!isProduct(value) || Object.keys(value.product).length !== 0) {\n throw new Error(\"Input is not a unit value\");\n }\n return \"{}\";\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\nexport {\n UNIT_PATTERN,\n doc,\n parse,\n print\n};\n",
18
16
  "codecs/unit.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/unit.mjs\nvar doc = `\nUnit codec for {}.\n\nTranslates the empty product {} to/from binary pattern+value stream.\n`;\nvar UNIT_PATTERN = patternFromFilter(\"?{}\");\nfunction parse() {\n return withPattern(Value.product({}), UNIT_PATTERN);\n}\nfunction print(value) {\n if (!isProduct(value) || Object.keys(value.product).length !== 0) {\n throw new Error(\"Input is not a unit value\");\n }\n return \"{}\";\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\nexport {\n UNIT_PATTERN,\n doc,\n parse,\n print\n};\n",
19
- "ieee.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/ieee.mjs\nvar doc = `\nIEEE 754 64-bit float codec.\n\nParses decimal floats, Infinity, -Infinity, NaN to 64-bit IEEE products.\n`;\nvar FLOAT64_PATTERN = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$sign = < {} \"+\", {} \"-\" >;\n$exp11 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10};\n$frac52 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51};\n$float64 = {sign sign, exp11 exponent, frac52 fraction};\n?$float64\n`);\nvar UNIT = Value.product({});\nfunction bitValue(bit) {\n return Value.variant(bit === 0 ? \"0\" : \"1\", UNIT);\n}\nfunction bitsProduct(width, value) {\n const big = BigInt(value);\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue(Number(big >> BigInt(i) & 1n));\n }\n return Value.product(product);\n}\nvar floatView = new DataView(new ArrayBuffer(8));\nfunction encodeNumberToValue(number) {\n floatView.setFloat64(0, number, false);\n const bits = floatView.getBigUint64(0, false);\n const sign = Number(bits >> 63n & 1n);\n const exponent = Number(bits >> 52n & 0x7ffn);\n const fraction = bits & (1n << 52n) - 1n;\n return Value.product({\n sign: Value.variant(sign === 0 ? \"+\" : \"-\", UNIT),\n exponent: bitsProduct(11, exponent),\n fraction: bitsProduct(52, fraction)\n });\n}\nfunction requireProduct(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction parseBitsProduct(value, maxBit, where) {\n const product = requireProduct(value, where);\n let n = 0n;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1n | BigInt(entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction decodeValueToNumber(value) {\n const product = requireProduct(value, \"float64\");\n const sign = requireVariant(product.sign, \"float64.sign\");\n if (sign.tag !== \"+\" && sign.tag !== \"-\") {\n throw new Error(`float64.sign: expected + or -, got ${sign.tag}`);\n }\n const exponent = parseBitsProduct(product.exponent, 10, \"float64.exponent\");\n const fraction = parseBitsProduct(product.fraction, 51, \"float64.fraction\");\n const bits = BigInt(sign.tag === \"-\" ? 1 : 0) << 63n | exponent << 52n | fraction;\n floatView.setBigUint64(0, bits, false);\n return floatView.getFloat64(0, false);\n}\nfunction parseFloatText(text) {\n const trimmed = text.trim();\n if (trimmed === \"\") {\n throw new Error(\"Expected a floating-point literal\");\n }\n if (/^[+-]?nan$/i.test(trimmed)) return NaN;\n if (/^[+]?inf(inity)?$/i.test(trimmed)) return Infinity;\n if (/^[-](inf|infinity)$/i.test(trimmed)) return -Infinity;\n const n = Number(trimmed);\n if (Number.isNaN(n)) {\n throw new Error(`Invalid float literal ${JSON.stringify(trimmed)}`);\n }\n return n;\n}\nfunction printFloatText(n) {\n if (Number.isNaN(n)) return \"NaN\";\n if (n === Infinity) return \"Infinity\";\n if (n === -Infinity) return \"-Infinity\";\n if (Object.is(n, -0)) return \"-0\";\n return String(n);\n}\nfunction parse(text) {\n const n = parseFloatText(text);\n const value = encodeNumberToValue(n);\n return withPattern(value, FLOAT64_PATTERN);\n}\nfunction print(value) {\n return printFloatText(decodeValueToNumber(value));\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\nexport {\n FLOAT64_PATTERN,\n decodeValueToNumber,\n doc,\n encodeNumberToValue,\n parse,\n print\n};\n",
20
17
  "codecs/ieee.mjs": "#!/usr/bin/env node\n\n// Value.mjs\nvar nameRE = /^[a-zA-Z0-9_+-][a-zA-Z0-9_?!+-]*$/;\nfunction pLabel(label) {\n return nameRE.test(label) ? `${label}` : `${JSON.stringify(label)}`;\n}\nfunction isObject(value) {\n return value !== null && typeof value === \"object\";\n}\nfunction isProduct(value) {\n return isObject(value) && value.type === \"{}\" && isObject(value.product) && !Array.isArray(value.product);\n}\nfunction isVariant(value) {\n return isObject(value) && value.type === \"<>\" && typeof value.tag === \"string\" && Object.hasOwn(value, \"value\");\n}\nfunction toVector(m) {\n let vector = [];\n for (let i = 0; i < Object.keys(m).length; i++) {\n if (m[i] === void 0) {\n vector = [];\n break;\n }\n vector.push(m[i]);\n }\n return vector;\n}\nfunction withPattern(value, pattern) {\n if (!pattern) return value;\n if (value.pattern === pattern) return value;\n if (isProduct(value)) return Value.product(value.product, pattern);\n if (isVariant(value)) return Value.variant(value.tag, value.value, pattern);\n return value;\n}\nvar Value = class _Value {\n constructor(fields) {\n Object.assign(this, fields);\n }\n static product(product, pattern = null) {\n return new _Value({ type: \"{}\", pattern, product });\n }\n static variant(tag, value, pattern = null) {\n return new _Value({ type: \"<>\", pattern, tag, value });\n }\n toString() {\n if (isVariant(this)) {\n const tags = [];\n let curr = this;\n while (isVariant(curr)) {\n tags.push(pLabel(curr.tag));\n curr = curr.value;\n }\n const base = curr ? curr.toString() : \"\";\n return tags.length === 0 ? base : `${base}|${tags.reverse().join(\"|\")}`;\n }\n if (isProduct(this)) {\n return `{${Object.entries(this.product).map(([k, v]) => `${JSON.stringify(k)}:${v.toString()}`).join(\",\")}}`;\n }\n return String(this.type);\n }\n toJSON() {\n if (isVariant(this)) {\n if (isProduct(this.value) && Object.keys(this.value.product).length === 0) {\n return this.tag;\n }\n return { [this.tag]: this.value.toJSON() };\n }\n if (!isProduct(this)) return { type: this.type };\n let vector = toVector(this.product);\n if (vector.length > 0) return vector;\n return this.product;\n }\n};\n\n// codec-sdk-shim:./runtime/codec-sdk.mjs\nfunction runCodecCLI() {\n}\nfunction patternFromFilter(script, options) {\n if (typeof globalThis !== \"undefined\" && typeof globalThis.patternFromFilter === \"function\") {\n return globalThis.patternFromFilter(script, options);\n }\n throw new Error(\"patternFromFilter is not available in browser environment\");\n}\n\n// codecs/ieee.mjs\nvar doc = `\nIEEE 754 64-bit float codec.\n\nParses decimal floats, Infinity, -Infinity, NaN to 64-bit IEEE products.\n`;\nvar FLOAT64_PATTERN = patternFromFilter(`\n$bit = < {} 0, {} 1 >;\n$sign = < {} \"+\", {} \"-\" >;\n$exp11 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9, bit 10};\n$frac52 = {bit 0, bit 1, bit 2, bit 3, bit 4, bit 5, bit 6, bit 7, bit 8, bit 9,\n bit 10, bit 11, bit 12, bit 13, bit 14, bit 15, bit 16, bit 17, bit 18, bit 19,\n bit 20, bit 21, bit 22, bit 23, bit 24, bit 25, bit 26, bit 27, bit 28, bit 29,\n bit 30, bit 31, bit 32, bit 33, bit 34, bit 35, bit 36, bit 37, bit 38, bit 39,\n bit 40, bit 41, bit 42, bit 43, bit 44, bit 45, bit 46, bit 47, bit 48, bit 49,\n bit 50, bit 51};\n$float64 = {sign sign, exp11 exponent, frac52 fraction};\n?$float64\n`);\nvar UNIT = Value.product({});\nfunction bitValue(bit) {\n return Value.variant(bit === 0 ? \"0\" : \"1\", UNIT);\n}\nfunction bitsProduct(width, value) {\n const big = BigInt(value);\n const product = {};\n for (let i = width - 1; i >= 0; i--) {\n product[String(i)] = bitValue(Number(big >> BigInt(i) & 1n));\n }\n return Value.product(product);\n}\nvar floatView = new DataView(new ArrayBuffer(8));\nfunction encodeNumberToValue(number) {\n floatView.setFloat64(0, number, false);\n const bits = floatView.getBigUint64(0, false);\n const sign = Number(bits >> 63n & 1n);\n const exponent = Number(bits >> 52n & 0x7ffn);\n const fraction = bits & (1n << 52n) - 1n;\n return Value.product({\n sign: Value.variant(sign === 0 ? \"+\" : \"-\", UNIT),\n exponent: bitsProduct(11, exponent),\n fraction: bitsProduct(52, fraction)\n });\n}\nfunction requireProduct(value, where) {\n if (!isProduct(value)) {\n throw new Error(`${where}: expected Product`);\n }\n return value.product;\n}\nfunction requireVariant(value, where) {\n if (!isVariant(value)) {\n throw new Error(`${where}: expected Variant`);\n }\n return value;\n}\nfunction parseBitsProduct(value, maxBit, where) {\n const product = requireProduct(value, where);\n let n = 0n;\n for (let i = maxBit; i >= 0; i--) {\n const entry = requireVariant(product[String(i)], `${where}.bit${i}`);\n if (entry.tag !== \"0\" && entry.tag !== \"1\") {\n throw new Error(`${where}.bit${i}: expected tag 0 or 1`);\n }\n n = n << 1n | BigInt(entry.tag === \"1\" ? 1 : 0);\n }\n return n;\n}\nfunction decodeValueToNumber(value) {\n const product = requireProduct(value, \"float64\");\n const sign = requireVariant(product.sign, \"float64.sign\");\n if (sign.tag !== \"+\" && sign.tag !== \"-\") {\n throw new Error(`float64.sign: expected + or -, got ${sign.tag}`);\n }\n const exponent = parseBitsProduct(product.exponent, 10, \"float64.exponent\");\n const fraction = parseBitsProduct(product.fraction, 51, \"float64.fraction\");\n const bits = BigInt(sign.tag === \"-\" ? 1 : 0) << 63n | exponent << 52n | fraction;\n floatView.setBigUint64(0, bits, false);\n return floatView.getFloat64(0, false);\n}\nfunction parseFloatText(text) {\n const trimmed = text.trim();\n if (trimmed === \"\") {\n throw new Error(\"Expected a floating-point literal\");\n }\n if (/^[+-]?nan$/i.test(trimmed)) return NaN;\n if (/^[+]?inf(inity)?$/i.test(trimmed)) return Infinity;\n if (/^[-](inf|infinity)$/i.test(trimmed)) return -Infinity;\n const n = Number(trimmed);\n if (Number.isNaN(n)) {\n throw new Error(`Invalid float literal ${JSON.stringify(trimmed)}`);\n }\n return n;\n}\nfunction printFloatText(n) {\n if (Number.isNaN(n)) return \"NaN\";\n if (n === Infinity) return \"Infinity\";\n if (n === -Infinity) return \"-Infinity\";\n if (Object.is(n, -0)) return \"-0\";\n return String(n);\n}\nfunction parse(text) {\n const n = parseFloatText(text);\n const value = encodeNumberToValue(n);\n return withPattern(value, FLOAT64_PATTERN);\n}\nfunction print(value) {\n return printFloatText(decodeValueToNumber(value));\n}\nrunCodecCLI(import.meta.url, { parse, print, doc });\nexport {\n FLOAT64_PATTERN,\n decodeValueToNumber,\n doc,\n encodeNumberToValue,\n parse,\n print\n};\n"
21
18
  };