WebAssembly text
WAT emission from the same MIR.
Part of the MIR lane. Every panel below is compiler output.
How to read it#
A stack machine, so the arithmetic reads inside out. Useful as a check on what actually crosses into a sandboxed runtime.
Measured support#
| Capable | Analyzable | Coverage |
|---|---|---|
| 263 | 373 | 71% |
From the target matrix: how many corpus exempla lower to this target. Coverage is not a quality score — an emitter can lower a term and still erase a distinction.
Not fully supported#
Terms the matrix records as partial, planned, or unsupported for this target. A term here is a measured gap, not an omission.
| Category | Terms |
|---|---|
| Keywords — systems lane | <a id="ad"></a>call, <a id="atomic"></a>atomic, <a id="clausura"></a>lambda, <a id="est"></a>is, <a id="ex"></a>from, <a id="functio"></a>fn, <a id="genus"></a>class, <a id="iace"></a>throw, <a id="implet"></a>implements, <a id="importa"></a>import, <a id="instans"></a>instant, <a id="itera"></a>for, <a id="lista"></a>list, <a id="matrix"></a>matrix, <a id="numerus"></a>int, <a id="octeti"></a>bytes, <a id="requirit"></a>require, <a id="reice"></a>reject, <a id="tabula"></a>map, <a id="tensor"></a>tensor, <a id="vector"></a>vector |
| Operators — systems lane | ·, ×, ⊗, ⊙, →, ⇥, ![, !., !(, ↦, ∈, ?[, ?., ?(, ⊘ |
Typed tensors#
Builds two shaped matrices, multiplies them, and reduces the product to a scalar. Exercises shape-bearing types and a reduction.
Faber source
faber convert --to en — English reader surfacemain {
const list<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
const list<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
const tf32[] seed ← empty
const tf32[2, 3] a ← seed.from_flat(flat_a, [2, 3])
const tf32[3, 4] b ← seed.from_flat(flat_b, [3, 4])
const tf32[2, 4] product ← a.matmul(b)
const f32 mean ← product.mean()
print mean
}faber convert --to la — canonical Faberincipit {
fixum lista<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
fixum lista<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
fixum tf32[] seed ← vacua
fixum tf32[2, 3] a ← seed.strue(flat_a, [2, 3])
fixum tf32[3, 4] b ← seed.strue(flat_b, [3, 4])
fixum tf32[2, 4] product ← a.matmul(b)
fixum f32 mean ← product.media()
nota mean
}faber convert --to th-TH — Thaiเริ่ม {
คงที่ รายการ<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
คงที่ รายการ<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
คงที่ tf32[] seed ← เซตว่าง
คงที่ tf32[2, 3] a ← seed.สร้างจากข้อมูลแบน(flat_a, [2, 3])
คงที่ tf32[3, 4] b ← seed.สร้างจากข้อมูลแบน(flat_b, [3, 4])
คงที่ tf32[2, 4] product ← a.คูณเมทริกซ์(b)
คงที่ f32 mean ← product.ค่าเฉลี่ย()
บันทึก mean
}faber convert --to zh-Hans — Simplified Chinese入口 {
常量 列表<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
常量 列表<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
常量 tf32[] seed ← 空集
常量 tf32[2, 3] a ← seed.由扁平构造(flat_a, [2, 3])
常量 tf32[3, 4] b ← seed.由扁平构造(flat_b, [3, 4])
常量 tf32[2, 4] product ← a.矩阵乘法(b)
常量 f32 mean ← product.均值()
显示 mean
}faber convert --to zh-Hant — Traditional Chinese入口 {
定值 列表<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
定值 列表<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
定值 tf32[] seed ← 空集
定值 tf32[2, 3] a ← seed.由扁平建構(flat_a, [2, 3])
定值 tf32[3, 4] b ← seed.由扁平建構(flat_b, [3, 4])
定值 tf32[2, 4] product ← a.矩陣乘法(b)
定值 f32 mean ← product.平均值()
註記 mean
}faber convert --to vi — Vietnamesebắt_đầu {
hằng danh_sách<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
hằng danh_sách<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
hằng tf32[] seed ← tập_rỗng
hằng tf32[2, 3] a ← seed.dựng_từ_phẳng(flat_a, [2, 3])
hằng tf32[3, 4] b ← seed.dựng_từ_phẳng(flat_b, [3, 4])
hằng tf32[2, 4] product ← a.nhân_ma_trận(b)
hằng f32 mean ← product.trung_bình()
ghi_chú mean
}faber convert --to ar — Arabicبداية {
ثابت قائمة<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
ثابت قائمة<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
ثابت tf32[] seed ← فارغ
ثابت tf32[2, 3] a ← seed.ابن_من_مسطح(flat_a, [2, 3])
ثابت tf32[3, 4] b ← seed.ابن_من_مسطح(flat_b, [3, 4])
ثابت tf32[2, 4] product ← a.ضرب_المصفوفات(b)
ثابت f32 mean ← product.المتوسط()
اعرض mean
}faber convert --to hi — Hindiआरंभ {
स्थिर सूची<f32> flat_a ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
स्थिर सूची<f32> flat_b ← [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]
स्थिर tf32[] seed ← खाली
स्थिर tf32[2, 3] a ← seed.समतल_से_बनाओ(flat_a, [2, 3])
स्थिर tf32[3, 4] b ← seed.समतल_से_बनाओ(flat_b, [3, 4])
स्थिर tf32[2, 4] product ← a.आव्यूह_गुणन(b)
स्थिर f32 mean ← product.माध्य()
दिखाओ mean
}WebAssembly text — 10 lines in, 104 out (10.4×)
;; Generated by radix MIR WASM text probe - experimental artifact.
(module
(import "faber_rt_v1" "__faber_rt_v1_array_new" (func $__faber_rt_v1_array_new__construct (param i32) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_array_push" (func $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (param i32 i64) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_tensor_new" (func $__faber_rt_v1_tensor_new__construct (param i32) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_tensor_from_flat" (func $__faber_rt_v1_tensor_from_flat__tensor_from_flat_3_aggregate_aggregate_aggregate_to_aggregate (param i32 i32 i32) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_tensor_matmul" (func $__faber_rt_v1_tensor_matmul__tensor_matmul_2_aggregate_aggregate_to_aggregate (param i32 i32) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_tensor_mean" (func $__faber_rt_v1_tensor_mean__tensor_mean_1_aggregate_to_f64 (param i32) (result f64)))
(import "faber_rt_v1" "__faber_rt_v1_diagnostic_nota_f64" (func $__faber_rt_v1_diagnostic_nota_f64 (param f64)))
(func $main (export "incipit")
(local $l0 i32)
(local $l1 i32)
(local $l2 i32)
(local $l3 i32)
(local $l4 i32)
(local $l5 i32)
(local $l6 f64)
(local $t0 f64)
(local $t1 f64)
(local $t2 f64)
(local $t3 f64)
(local $t4 f64)
(local $t5 f64)
(local $t6 i32)
(local $t7 f64)
(local $t8 f64)
(local $t9 f64)
(local $t10 f64)
(local $t11 f64)
(local $t12 f64)
(local $t13 f64)
(local $t14 f64)
(local $t15 f64)
(local $t16 f64)
(local $t17 f64)
(local $t18 f64)
(local $t19 i32)
(local $t20 i32)
(local $t21 i32)
(local $t22 i32)
(local $t23 i32)
(local $t24 i32)
(local $t25 i32)
(local $t26 f64)
(local.set $t0 (f64.const 1.0))
(local.set $t1 (f64.const 2.0))
(local.set $t2 (f64.const 3.0))
(local.set $t3 (f64.const 4.0))
(local.set $t4 (f64.const 5.0))
(local.set $t5 (f64.const 6.0))
(local.set $t6 (call $__faber_rt_v1_array_new__construct (i32.const 6)))
(local.set $t6 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t6) (i64.reinterpret_f64 (local.get $t0))))
(local.set $t6 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t6) (i64.reinterpret_f64 (local.get $t1))))
(local.set $t6 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t6) (i64.reinterpret_f64 (local.get $t2))))
(local.set $t6 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t6) (i64.reinterpret_f64 (local.get $t3))))
(local.set $t6 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t6) (i64.reinterpret_f64 (local.get $t4))))
(local.set $t6 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t6) (i64.reinterpret_f64 (local.get $t5))))
(local.set $l0 (local.get $t6))
(local.set $t7 (f64.const 1.0))
(local.set $t8 (f64.const 2.0))
(local.set $t9 (f64.const 3.0))
(local.set $t10 (f64.const 4.0))
(local.set $t11 (f64.const 5.0))
(local.set $t12 (f64.const 6.0))
(local.set $t13 (f64.const 7.0))
(local.set $t14 (f64.const 8.0))
(local.set $t15 (f64.const 9.0))
(local.set $t16 (f64.const 10.0))
(local.set $t17 (f64.const 11.0))
(local.set $t18 (f64.const 12.0))
(local.set $t19 (call $__faber_rt_v1_array_new__construct (i32.const 6)))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t7))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t8))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t9))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t10))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t11))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t12))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t13))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t14))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t15))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t16))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t17))))
(local.set $t19 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t19) (i64.reinterpret_f64 (local.get $t18))))
(local.set $l1 (local.get $t19))
(local.set $t20 (call $__faber_rt_v1_tensor_new__construct (i32.const 6)))
(local.set $l2 (local.get $t20))
(local.set $t21 (call $__faber_rt_v1_array_new__construct (i32.const 4)))
(local.set $t21 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t21) (i64.const 2)))
(local.set $t21 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t21) (i64.const 3)))
(local.set $t22 (call $__faber_rt_v1_tensor_from_flat__tensor_from_flat_3_aggregate_aggregate_aggregate_to_aggregate (local.get $l2) (local.get $l0) (local.get $t21)))
(local.set $l3 (local.get $t22))
(local.set $t23 (call $__faber_rt_v1_array_new__construct (i32.const 4)))
(local.set $t23 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t23) (i64.const 3)))
(local.set $t23 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t23) (i64.const 4)))
(local.set $t24 (call $__faber_rt_v1_tensor_from_flat__tensor_from_flat_3_aggregate_aggregate_aggregate_to_aggregate (local.get $l2) (local.get $l1) (local.get $t23)))
(local.set $l4 (local.get $t24))
(local.set $t25 (call $__faber_rt_v1_tensor_matmul__tensor_matmul_2_aggregate_aggregate_to_aggregate (local.get $l3) (local.get $l4)))
(local.set $l5 (local.get $t25))
(local.set $t26 (call $__faber_rt_v1_tensor_mean__tensor_mean_1_aggregate_to_f64 (local.get $l5)))
(local.set $l6 (local.get $t26))
(call $__faber_rt_v1_diagnostic_nota_f64 (local.get $l6))
(return)
)
)The error channel#
A function that may fail, and a caller that catches. Shows how the ⇥ channel becomes each target's own error idiom.
WebAssembly text does not lower this scenario. That is a measured gap, not an omission — the emitter rejects it rather than producing something that would not run.
Collections and iteration#
A list folded to a total with for from. The plainest possible read on how loops lower.
Faber source
fn sum(list<int> numeri) → int {
var int total ← 0
for from numeri const n {
total ← total + n
}
return total
}
main {
const list<int> valores ← [1, 2, 3, 4, 5]
print sum(valores)
}WebAssembly text — 12 lines in, 428 out (35.7×)
;; Generated by radix MIR WASM text probe - experimental artifact.
(module
(import "faber_rt_v1" "__faber_rt_v1_array_new" (func $__faber_rt_v1_array_new__construct (param i32) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_array_push" (func $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (param i32 i64) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_array_get" (func $__faber_rt_v1_array_get__index_2_aggregate_i64_to_i64 (param i32 i64) (result i64)))
(import "faber_rt_v1" "__faber_rt_v1_array_length" (func $__faber_rt_v1_array_length__length_1_aggregate_to_i64 (param i32) (result i64)))
(import "faber_rt_v1" "__faber_rt_v1_diagnostic_nota_i64" (func $__faber_rt_v1_diagnostic_nota_i64 (param i64)))
(import "faber_rt_v1" "__faber_rt_v1_assert_message" (func $__faber_rt_v1_assert_message (param i32 i32)))
(import "faber_rt_v1" "__faber_rt_v1_format_i64" (func $__faber_rt_v1_format_i64 (param i32 i64) (result i32)))
(import "faber_rt_v1" "__faber_rt_v1_format_i64_i64" (func $__faber_rt_v1_format_i64_i64 (param i32 i64 i64) (result i32)))
(memory (export "memory") 1)
(data (i32.const 0) "fractus to numerus conversion out of range")
(data (i32.const 42) "modulus division failed")
(data (i32.const 65) "negative shift count")
(data (i32.const 85) "numerus division failed")
(data (i32.const 108) "numerus overflow")
(data (i32.const 124) "numerus to numerus conversion out of range")
(data (i32.const 166) "\C2\A7 does not fit in `i64` (assignment to `total`)")
(data (i32.const 214) "\C2\A7\C2\A7 does not fit in `i64` (assignment to `total`)")
(data (i32.const 264) "\00\00\00\00\00\00\00\00\2A\00\00\00\00\00\00\00\2A\00\00\00\17\00\00\00\00\00\00\00\41\00\00\00\14\00\00\00\00\00\00\00\55\00\00\00\17\00\00\00\00\00\00\00\6C\00\00\00\10\00\00\00\00\00\00\00\7C\00\00\00\2A\00\00\00\00\00\00\00\A6\00\00\00\30\00\00\00\00\00\00\00\D6\00\00\00\32\00\00\00")
(global (export "__faber_rt_v1_literal_table_ptr") i32 (i32.const 264))
(global (export "__faber_rt_v1_literal_table_count") i32 (i32.const 8))
(func $sum (export "summa") (param $l0 i32) (result i64)
(local $l1 i64)
(local $l2 i64)
(local $l3 i64)
(local $t0 i64)
(local $t1 i32)
(local $t2 i64)
(local $t2_x i64)
(local $t2_h i32)
(local $t3 i64)
(local $t4 i64)
(local $t4_x i64)
(local $t4_h i32)
(local $p0 i32)
(local.set $p0 (i32.const 0))
(loop $dispatch
(if (i32.eq (local.get $p0) (i32.const 0))
(then
(local.set $l1 (i64.const 0))
(local.set $l2 (i64.const 0))
(local.set $t0 (call $__faber_rt_v1_array_length__length_1_aggregate_to_i64 (local.get $l0)))
(local.set $p0 (i32.const 1))
(br $dispatch)
)
)
(if (i32.eq (local.get $p0) (i32.const 1))
(then
;; v2 = (i64.lt_s (local.get $l2) (local.get $t0))
(local.set $t1 (i64.lt_s (local.get $l2) (local.get $t0)))
(if (local.get $t1)
(then
(local.set $p0 (i32.const 2))
(br $dispatch)
)
(else
(local.set $p0 (i32.const 4))
(br $dispatch)
)
)
)
)
(if (i32.eq (local.get $p0) (i32.const 2))
(then
(local.set $l3 (call $__faber_rt_v1_array_get__index_2_aggregate_i64_to_i64 (local.get $l0) (local.get $l2)))
;; v4 = (call $faber_x_bin (i32.const 0) (local.get $l1) (i32.const 0) (local.get $l3) (i32.const 0) (i32.const 0) (i32.const 1))
(local.set $t2_x (call $faber_x_bin (i32.const 0) (local.get $l1) (i32.const 0) (local.get $l3) (i32.const 0) (i32.const 0) (i32.const 1)))
(local.set $t2_h (global.get $faber_x_hi))
(local.set $t3 (call $faber_x_store_t (local.get $t2_x) (local.get $t2_h) (i32.const 64) (i32.const 1) (i32.const 6) (i32.const 7) (i32.const 6)))
(local.set $l1 (local.get $t3))
(local.set $p0 (i32.const 3))
(br $dispatch)
)
)
(if (i32.eq (local.get $p0) (i32.const 3))
(then
;; v6 = (call $faber_x_bin (i32.const 0) (local.get $l2) (i32.const 0) (i64.const 1) (i32.const 0) (i32.const 0) (i32.const 1))
(local.set $t4_x (call $faber_x_bin (i32.const 0) (local.get $l2) (i32.const 0) (i64.const 1) (i32.const 0) (i32.const 0) (i32.const 1)))
(local.set $t4_h (global.get $faber_x_hi))
(local.set $l2 (call $faber_x_store (local.get $t4_x) (local.get $t4_h) (i32.const 64) (i32.const 1) (i32.const 0)))
(local.set $p0 (i32.const 1))
(br $dispatch)
)
)
(if (i32.eq (local.get $p0) (i32.const 4))
(then
(return (local.get $l1))
)
)
(unreachable)
)
(unreachable)
)
(func $main (export "incipit")
(local $l0 i32)
(local $t0 i32)
(local $t1 i64)
(local.set $t0 (call $__faber_rt_v1_array_new__construct (i32.const 4)))
(local.set $t0 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t0) (i64.const 1)))
(local.set $t0 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t0) (i64.const 2)))
(local.set $t0 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t0) (i64.const 3)))
(local.set $t0 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t0) (i64.const 4)))
(local.set $t0 (call $__faber_rt_v1_array_push__construct_2_aggregate_i64_to_aggregate (local.get $t0) (i64.const 5)))
(local.set $l0 (local.get $t0))
(local.set $t1 (call $sum (local.get $l0)))
(call $__faber_rt_v1_diagnostic_nota_i64 (local.get $t1))
(return)
)
(global $faber_x_hi (mut i32) (i32.const 0))
(func $faber_x_neg (param $a i64) (param $u i32) (result i32)
(i32.and (i32.eqz (local.get $u)) (i64.lt_s (local.get $a) (i64.const 0))))
(func $faber_x_mag (param $a i64) (param $u i32) (result i64)
(if (result i64) (call $faber_x_neg (local.get $a) (local.get $u))
(then (i64.sub (i64.const 0) (local.get $a)))
(else (local.get $a))))
(func $faber_x_pack (param $mag i64) (param $neg i32) (param $rbits i32) (param $rsigned i32) (result i64)
(local $limit i64)
(if (i64.eqz (local.get $mag)) (then (local.set $neg (i32.const 0))))
(if (i32.eqz (local.get $rbits))
(then
(if (local.get $neg)
(then
(if (i64.gt_u (local.get $mag) (i64.const -9223372036854775808)) (then (call $faber_x_trap (i32.const 0)) (unreachable)))
(global.set $faber_x_hi (i32.const 0))
(return (i64.sub (i64.const 0) (local.get $mag)))))
(global.set $faber_x_hi (i64.lt_s (local.get $mag) (i64.const 0)))
(return (local.get $mag))))
(if (local.get $neg)
(then
(if (i32.eqz (local.get $rsigned)) (then (call $faber_x_range_fail (local.get $mag) (local.get $neg)) (unreachable)))
(if (i64.gt_u (local.get $mag)
(i64.shl (i64.const 1) (i64.extend_i32_u (i32.sub (local.get $rbits) (i32.const 1)))))
(then (call $faber_x_range_fail (local.get $mag) (local.get $neg)) (unreachable)))
(return (i64.sub (i64.const 0) (local.get $mag)))))
(if (i32.and (i32.eq (local.get $rbits) (i32.const 64)) (local.get $rsigned))
(then (if (i64.lt_s (local.get $mag) (i64.const 0)) (then (call $faber_x_range_fail (local.get $mag) (local.get $neg)) (unreachable))))
(else
(if (i32.lt_u (local.get $rbits) (i32.const 64))
(then
(local.set $limit
(i64.sub
(i64.shl (i64.const 1) (i64.extend_i32_u (i32.sub (local.get $rbits) (local.get $rsigned))))
(i64.const 1)))
(if (i64.gt_u (local.get $mag) (local.get $limit)) (then (call $faber_x_range_fail (local.get $mag) (local.get $neg)) (unreachable)))))))
(local.get $mag))
(func $faber_x_bin (param $op i32) (param $a i64) (param $au i32) (param $b i64) (param $bu i32) (param $rbits i32) (param $rsigned i32) (result i64)
(local $an i32) (local $bn i32) (local $am i64) (local $bm i64) (local $m i64) (local $n i32)
(local $q i64) (local $r i64) (local $ahi i64) (local $bhi i64) (local $hi i64) (local $lo i64)
(local.set $an (call $faber_x_neg (local.get $a) (local.get $au)))
(local.set $bn (call $faber_x_neg (local.get $b) (local.get $bu)))
(local.set $am (call $faber_x_mag (local.get $a) (local.get $au)))
(local.set $bm (call $faber_x_mag (local.get $b) (local.get $bu)))
(if (i32.le_u (local.get $op) (i32.const 1))
(then
(if (i32.eq (local.get $op) (i32.const 1)) (then (local.set $bn (i32.eqz (local.get $bn)))))
(if (i32.eq (local.get $an) (local.get $bn))
(then
(local.set $m (i64.add (local.get $am) (local.get $bm)))
(if (i64.lt_u (local.get $m) (local.get $am)) (then (call $faber_x_trap (i32.const 0)) (unreachable)))
(local.set $n (local.get $an)))
(else
(if (i64.ge_u (local.get $am) (local.get $bm))
(then
(local.set $m (i64.sub (local.get $am) (local.get $bm)))
(local.set $n (local.get $an)))
(else
(local.set $m (i64.sub (local.get $bm) (local.get $am)))
(local.set $n (local.get $bn))))))
(return (call $faber_x_pack (local.get $m) (local.get $n) (local.get $rbits) (local.get $rsigned)))))
(if (i32.eq (local.get $op) (i32.const 2))
(then
(if (i32.and (i64.ne (local.get $am) (i64.const 0)) (i64.ne (local.get $bm) (i64.const 0)))
(then
(if (i64.gt_u (local.get $am) (i64.div_u (i64.const -1) (local.get $bm)))
(then (call $faber_x_trap (i32.const 0)) (unreachable)))))
(return (call $faber_x_pack (i64.mul (local.get $am) (local.get $bm))
(i32.xor (local.get $an) (local.get $bn)) (local.get $rbits) (local.get $rsigned)))))
(if (i32.or (i32.eq (local.get $op) (i32.const 3)) (i32.eq (local.get $op) (i32.const 4)))
(then
(if (i64.eqz (local.get $bm)) (then (call $faber_x_trap (i32.const 1)) (unreachable)))
(local.set $q (i64.div_u (local.get $am) (local.get $bm)))
(local.set $r (i64.rem_u (local.get $am) (local.get $bm)))
(if (i32.eq (local.get $op) (i32.const 3))
(then
(local.set $n (i32.xor (local.get $an) (local.get $bn)))
(if (i32.and (local.get $n) (i64.ne (local.get $r) (i64.const 0)))
(then (local.set $q (i64.add (local.get $q) (i64.const 1)))))
(return (call $faber_x_pack (local.get $q) (local.get $n) (local.get $rbits) (local.get $rsigned))))
(else
(if (i64.eqz (local.get $r))
(then (return (call $faber_x_pack (i64.const 0) (i32.const 0) (local.get $rbits) (local.get $rsigned)))))
(if (i32.eq (local.get $an) (local.get $bn))
(then (return (call $faber_x_pack (local.get $r) (local.get $bn) (local.get $rbits) (local.get $rsigned)))))
(return (call $faber_x_pack (i64.sub (local.get $bm) (local.get $r)) (local.get $bn)
(local.get $rbits) (local.get $rsigned)))))))
(if (i32.and (i32.ge_u (local.get $op) (i32.const 5)) (i32.le_u (local.get $op) (i32.const 7)))
(then
(local.set $ahi (select (i64.const 0) (i64.shr_s (local.get $a) (i64.const 63)) (local.get $au)))
(local.set $bhi (select (i64.const 0) (i64.shr_s (local.get $b) (i64.const 63)) (local.get $bu)))
(if (i32.eq (local.get $op) (i32.const 5))
(then
(local.set $lo (i64.and (local.get $a) (local.get $b)))
(local.set $hi (i64.and (local.get $ahi) (local.get $bhi))))
(else
(if (i32.eq (local.get $op) (i32.const 6))
(then
(local.set $lo (i64.or (local.get $a) (local.get $b)))
(local.set $hi (i64.or (local.get $ahi) (local.get $bhi))))
(else
(local.set $lo (i64.xor (local.get $a) (local.get $b)))
(local.set $hi (i64.xor (local.get $ahi) (local.get $bhi)))))))
(if (i64.eqz (local.get $hi))
(then (return (call $faber_x_pack (local.get $lo) (i32.const 0) (local.get $rbits) (local.get $rsigned)))))
(if (i32.and (i64.eq (local.get $hi) (i64.const -1)) (i64.lt_s (local.get $lo) (i64.const 0)))
(then (return (call $faber_x_pack (i64.sub (i64.const 0) (local.get $lo)) (i32.const 1)
(local.get $rbits) (local.get $rsigned)))))
(call $faber_x_trap (i32.const 0)) (unreachable)))
(if (i32.ge_u (local.get $op) (i32.const 8))
(then
(if (local.get $bn) (then (call $faber_x_trap (i32.const 2)) (unreachable)))
(if (i32.eq (local.get $op) (i32.const 8))
(then
(if (i64.eqz (local.get $am))
(then (return (call $faber_x_pack (i64.const 0) (i32.const 0) (local.get $rbits) (local.get $rsigned)))))
(if (i64.ge_u (local.get $bm) (i64.const 64)) (then (call $faber_x_trap (i32.const 0)) (unreachable)))
(local.set $m (i64.shl (local.get $am) (local.get $bm)))
(if (i64.ne (i64.shr_u (local.get $m) (local.get $bm)) (local.get $am)) (then (call $faber_x_trap (i32.const 0)) (unreachable)))
(return (call $faber_x_pack (local.get $m) (local.get $an) (local.get $rbits) (local.get $rsigned))))
(else
(if (i32.eqz (local.get $an))
(then
(return (call $faber_x_pack
(select (i64.const 0) (i64.shr_u (local.get $am) (local.get $bm))
(i64.ge_u (local.get $bm) (i64.const 64)))
(i32.const 0) (local.get $rbits) (local.get $rsigned))))
(else
(if (i64.ge_u (local.get $bm) (i64.const 64))
(then (return (call $faber_x_pack (i64.const 1) (i32.const 1) (local.get $rbits) (local.get $rsigned)))))
(return (call $faber_x_pack
(i64.add (i64.shr_u (i64.sub (local.get $am) (i64.const 1)) (local.get $bm)) (i64.const 1))
(i32.const 1) (local.get $rbits) (local.get $rsigned)))))))))
(unreachable))
(func $faber_x_un (param $op i32) (param $a i64) (param $au i32) (param $rbits i32) (param $rsigned i32) (result i64)
(local $an i32) (local $am i64)
(local.set $an (call $faber_x_neg (local.get $a) (local.get $au)))
(local.set $am (call $faber_x_mag (local.get $a) (local.get $au)))
(if (i32.eqz (local.get $op))
(then (return (call $faber_x_pack (local.get $am) (i32.eqz (local.get $an)) (local.get $rbits) (local.get $rsigned)))))
(if (local.get $an)
(then (return (call $faber_x_pack (i64.sub (local.get $am) (i64.const 1)) (i32.const 0) (local.get $rbits) (local.get $rsigned)))))
(if (i64.eq (local.get $am) (i64.const -1)) (then (call $faber_x_trap (i32.const 0)) (unreachable)))
(call $faber_x_pack (i64.add (local.get $am) (i64.const 1)) (i32.const 1) (local.get $rbits) (local.get $rsigned)))
(func $faber_x_clamp (param $m i64) (param $n i32) (param $ovf i32) (param $rbits i32) (param $rsigned i32) (result i64)
(local $lim i64)
(if (i32.and (local.get $n) (i64.ne (local.get $m) (i64.const 0)))
(then
(if (i32.eqz (local.get $rsigned)) (then (return (i64.const 0))))
(local.set $lim
(i64.shl (i64.const 1) (i64.extend_i32_u (i32.sub (local.get $rbits) (i32.const 1)))))
(if (i32.or (local.get $ovf) (i64.gt_u (local.get $m) (local.get $lim)))
(then (return (i64.sub (i64.const 0) (local.get $lim)))))
(return (i64.sub (i64.const 0) (local.get $m)))))
(if (local.get $rsigned)
(then
(local.set $lim
(i64.sub
(i64.shl (i64.const 1) (i64.extend_i32_u (i32.sub (local.get $rbits) (i32.const 1))))
(i64.const 1))))
(else
(if (i32.eq (local.get $rbits) (i32.const 64))
(then (local.set $lim (i64.const -1)))
(else
(local.set $lim
(i64.sub (i64.shl (i64.const 1) (i64.extend_i32_u (local.get $rbits))) (i64.const 1)))))))
(if (i32.or (local.get $ovf) (i64.gt_u (local.get $m) (local.get $lim)))
(then (return (local.get $lim))))
(local.get $m))
(func $faber_x_sbin (param $op i32) (param $a i64) (param $au i32) (param $b i64) (param $bu i32) (param $rbits i32) (param $rsigned i32) (result i64)
(local $an i32) (local $bn i32) (local $am i64) (local $bm i64) (local $m i64) (local $n i32)
(local $ovf i32) (local $q i64) (local $r i64)
(local.set $an (call $faber_x_neg (local.get $a) (local.get $au)))
(local.set $bn (call $faber_x_neg (local.get $b) (local.get $bu)))
(local.set $am (call $faber_x_mag (local.get $a) (local.get $au)))
(local.set $bm (call $faber_x_mag (local.get $b) (local.get $bu)))
(if (i32.le_u (local.get $op) (i32.const 1))
(then
(if (i32.eq (local.get $op) (i32.const 1)) (then (local.set $bn (i32.eqz (local.get $bn)))))
(if (i32.eq (local.get $an) (local.get $bn))
(then
(local.set $m (i64.add (local.get $am) (local.get $bm)))
(if (i64.lt_u (local.get $m) (local.get $am))
(then (local.set $ovf (i32.const 1)) (local.set $m (i64.const 1))))
(local.set $n (local.get $an)))
(else
(if (i64.ge_u (local.get $am) (local.get $bm))
(then
(local.set $m (i64.sub (local.get $am) (local.get $bm)))
(local.set $n (local.get $an)))
(else
(local.set $m (i64.sub (local.get $bm) (local.get $am)))
(local.set $n (local.get $bn))))))
(return (call $faber_x_clamp (local.get $m) (local.get $n) (local.get $ovf) (local.get $rbits) (local.get $rsigned)))))
(if (i32.eq (local.get $op) (i32.const 2))
(then
(local.set $m (i64.mul (local.get $am) (local.get $bm)))
(if (i32.and (i64.ne (local.get $am) (i64.const 0)) (i64.ne (local.get $bm) (i64.const 0)))
(then
(if (i64.gt_u (local.get $am) (i64.div_u (i64.const -1) (local.get $bm)))
(then (local.set $ovf (i32.const 1)) (local.set $m (i64.const 1))))))
(return (call $faber_x_clamp (local.get $m) (i32.xor (local.get $an) (local.get $bn)) (local.get $ovf) (local.get $rbits) (local.get $rsigned)))))
(if (i64.eqz (local.get $bm)) (then (call $faber_x_trap (i32.const 1)) (unreachable)))
(local.set $q (i64.div_u (local.get $am) (local.get $bm)))
(local.set $r (i64.rem_u (local.get $am) (local.get $bm)))
(if (i32.eq (local.get $op) (i32.const 3))
(then
(local.set $n (i32.xor (local.get $an) (local.get $bn)))
(if (i32.and (local.get $n) (i64.ne (local.get $r) (i64.const 0)))
(then (local.set $q (i64.add (local.get $q) (i64.const 1)))))
(return (call $faber_x_clamp (local.get $q) (local.get $n) (i32.const 0) (local.get $rbits) (local.get $rsigned)))))
(if (i64.eqz (local.get $r))
(then (return (i64.const 0))))
(if (i32.eq (local.get $an) (local.get $bn))
(then (return (call $faber_x_clamp (local.get $r) (local.get $bn) (i32.const 0) (local.get $rbits) (local.get $rsigned)))))
(call $faber_x_clamp (i64.sub (local.get $bm) (local.get $r)) (local.get $bn) (i32.const 0) (local.get $rbits) (local.get $rsigned)))
(func $faber_x_store (param $v i64) (param $vu i32) (param $rbits i32) (param $rsigned i32) (param $policy i32) (result i64)
(if (i32.eq (local.get $policy) (i32.const 1))
(then
(if (i32.lt_u (local.get $rbits) (i32.const 64))
(then
(if (local.get $rsigned)
(then (return (i64.shr_s
(i64.shl (local.get $v) (i64.extend_i32_u (i32.sub (i32.const 64) (local.get $rbits))))
(i64.extend_i32_u (i32.sub (i32.const 64) (local.get $rbits)))))))
(return (i64.and (local.get $v)
(i64.sub (i64.shl (i64.const 1) (i64.extend_i32_u (local.get $rbits))) (i64.const 1))))))
(return (local.get $v))))
(if (i32.eq (local.get $policy) (i32.const 2))
(then
(return (call $faber_x_clamp (call $faber_x_mag (local.get $v) (local.get $vu))
(call $faber_x_neg (local.get $v) (local.get $vu)) (i32.const 0) (local.get $rbits) (local.get $rsigned)))))
(call $faber_x_pack (call $faber_x_mag (local.get $v) (local.get $vu))
(call $faber_x_neg (local.get $v) (local.get $vu)) (local.get $rbits) (local.get $rsigned)))
(func $faber_x_cmp (param $a i64) (param $au i32) (param $b i64) (param $bu i32) (result i32)
(local $an i32) (local $bn i32)
(local.set $an (call $faber_x_neg (local.get $a) (local.get $au)))
(local.set $bn (call $faber_x_neg (local.get $b) (local.get $bu)))
(if (i32.ne (local.get $an) (local.get $bn))
(then (return (select (i32.const -1) (i32.const 1) (local.get $an)))))
(if (local.get $an)
(then
(if (i64.lt_s (local.get $a) (local.get $b)) (then (return (i32.const -1))))
(return (i64.gt_s (local.get $a) (local.get $b)))))
(if (i64.lt_u (local.get $a) (local.get $b)) (then (return (i32.const -1))))
(i64.gt_u (local.get $a) (local.get $b)))
(func $faber_x_cmpf (param $a i64) (param $au i32) (param $f f64) (result i32)
(local $whole f64) (local $frac f64) (local $wbits i64) (local $wu i32) (local $c i32)
(if (f64.ne (local.get $f) (local.get $f)) (then (return (i32.const 2))))
(if (f64.ge (local.get $f) (f64.const 18446744073709551616)) (then (return (i32.const -1))))
(if (f64.lt (local.get $f) (f64.const -9223372036854775808)) (then (return (i32.const 1))))
(local.set $whole (f64.trunc (local.get $f)))
(local.set $frac (f64.sub (local.get $f) (local.get $whole)))
(if (f64.ge (local.get $whole) (f64.const 9223372036854775808))
(then
(local.set $wbits (i64.trunc_f64_u (local.get $whole)))
(local.set $wu (i32.const 1)))
(else
(local.set $wbits (i64.trunc_f64_s (local.get $whole)))))
(local.set $c (call $faber_x_cmp (local.get $a) (local.get $au) (local.get $wbits) (local.get $wu)))
(if (local.get $c) (then (return (local.get $c))))
(if (f64.gt (local.get $frac) (f64.const 0)) (then (return (i32.const -1))))
(select (i32.const 1) (i32.const 0) (f64.lt (local.get $frac) (f64.const 0))))
(global $faber_x_site (mut i32) (i32.const -1))
(global $faber_x_site_big (mut i32) (i32.const -1))
(global $faber_x_site_neg (mut i32) (i32.const -1))
(func $faber_x_store_t (param $v i64) (param $vu i32) (param $rbits i32) (param $rsigned i32) (param $tpl i32) (param $big i32) (param $negtpl i32) (result i64)
(local $r i64)
(global.set $faber_x_site (local.get $tpl))
(global.set $faber_x_site_big (local.get $big))
(global.set $faber_x_site_neg (local.get $negtpl))
(local.set $r (call $faber_x_store (local.get $v) (local.get $vu) (local.get $rbits) (local.get $rsigned) (i32.const 0)))
(global.set $faber_x_site (i32.const -1))
(local.get $r))
(func $faber_x_conv (param $v i64) (param $vu i32) (param $rbits i32) (param $rsigned i32) (result i64)
(local $r i64)
(global.set $faber_x_site (i32.const -2))
(local.set $r (call $faber_x_store (local.get $v) (local.get $vu) (local.get $rbits) (local.get $rsigned) (i32.const 0)))
(global.set $faber_x_site (i32.const -1))
(local.get $r))
(func $faber_x_f2i (param $f f64) (param $rbits i32) (param $rsigned i32) (result i64)
(local $t f64) (local $half f64)
(if (f64.ne (local.get $f) (local.get $f))
(then (call $faber_x_trap (i32.const 4)) (unreachable)))
(local.set $t (f64.trunc (local.get $f)))
(local.set $half
(f64.convert_i64_u (i64.shl (i64.const 1) (i64.extend_i32_u (i32.sub (local.get $rbits) (i32.const 1))))))
(if (local.get $rsigned)
(then
(if (i32.or (f64.lt (local.get $t) (f64.neg (local.get $half))) (f64.ge (local.get $t) (local.get $half)))
(then (call $faber_x_trap (i32.const 4)) (unreachable)))
(return (i64.trunc_f64_s (local.get $t)))))
(if (i32.or (f64.lt (local.get $t) (f64.const 0)) (f64.ge (local.get $t) (f64.mul (local.get $half) (f64.const 2))))
(then (call $faber_x_trap (i32.const 4)) (unreachable)))
(i64.trunc_f64_u (local.get $t)))
(func $faber_x_trap (param $k i32)
(if (i32.eq (local.get $k) (i32.const 0)) (then (call $__faber_rt_v1_assert_message (i32.const 0) (i32.const 4))))
(if (i32.eq (local.get $k) (i32.const 1)) (then (call $__faber_rt_v1_assert_message (i32.const 0) (i32.const 3))))
(if (i32.eq (local.get $k) (i32.const 2)) (then (call $__faber_rt_v1_assert_message (i32.const 0) (i32.const 2))))
(if (i32.eq (local.get $k) (i32.const 3)) (then (call $__faber_rt_v1_assert_message (i32.const 0) (i32.const 5))))
(if (i32.eq (local.get $k) (i32.const 4)) (then (call $__faber_rt_v1_assert_message (i32.const 0) (i32.const 0))))
(if (i32.eq (local.get $k) (i32.const 5)) (then (call $__faber_rt_v1_assert_message (i32.const 0) (i32.const 1))))
(unreachable))
(func $faber_x_range_fail (param $mag i64) (param $neg i32)
(local $h i32)
(if (i32.eq (global.get $faber_x_site) (i32.const -2))
(then (call $faber_x_trap (i32.const 3))))
(if (i32.lt_s (global.get $faber_x_site) (i32.const 0))
(then (call $faber_x_trap (i32.const 0))))
(if (local.get $neg)
(then (local.set $h (call $__faber_rt_v1_format_i64 (global.get $faber_x_site_neg) (i64.sub (i64.const 0) (local.get $mag)))))
(else
(if (i64.lt_s (local.get $mag) (i64.const 0))
(then (local.set $h (call $__faber_rt_v1_format_i64_i64 (global.get $faber_x_site_big) (i64.div_u (local.get $mag) (i64.const 10)) (i64.rem_u (local.get $mag) (i64.const 10)))))
(else (local.set $h (call $__faber_rt_v1_format_i64 (global.get $faber_x_site) (local.get $mag)))))))
(call $__faber_rt_v1_assert_message (i32.const 0) (local.get $h))
(unreachable))
)---