Renderingen-US

Rust

HIR projection. The package product path compiles this through Cargo.

Part of the HIR lane. Every panel below is compiler output.

How to read it#

Close to one-for-one with the source. That is the point of this emitter: generated Rust is meant to be read and reviewed, so it keeps the shape of the Faber it came from rather than expanding into something unrecognisable.

Measured support#

CapableAnalyzableCoverage
37337899%

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.

CategoryTerms
Keywords — application lane<a id="atomic"></a>atomic
Operators — application lane·, ↦
Types, intrinsics & meta<a id="f16"></a>f16

Typed tensors#

Builds two shaped matrices, multiplies them, and reduces the product to a scalar. Exercises shape-bearing types and a reduction.

Faber source

reader locale
faber convert --to en — English reader surface
main {
    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 Faber
incipit {
    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 — Vietnamese
bắ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
}

Rust — 10 lines in, 21 out (2.1×)

// Generated by radix - do not edit
// Requires the faber language-runtime crate (add to Cargo.toml):
//   faber = { path = "../faber" }  # adjust path for your layout

// SCR-09 recorded suppressions: identifier/literal fidelity, plan-directed
// casts and parameter passing, library-shaped artifact items.
#![allow(non_camel_case_types, non_snake_case, dead_code, clippy::unreadable_literal, clippy::cast_lossless, clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::needless_pass_by_value)]

mod host_register;

fn main() {
    host_register::install_or_exit();
    let flat_a: Vec<f32> = vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
    let flat_b: Vec<f32> = vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0];
    let seed: faber::Tensor<f32> /* tensor<f32, []> */ = faber::Tensor::vacua();
    let a: faber::Tensor<f32> /* tensor<f32, [2, 3]> */ = faber::Tensor::<f32>::structa(flat_a, &{ let t28 = &vec![2, 3]; t28.iter().copied().map(|value| value as i64).collect::<Vec<i64>>() }).expect("tensor structa element count does not match shape");
    let b: faber::Tensor<f32> /* tensor<f32, [3, 4]> */ = faber::Tensor::<f32>::structa(flat_b, &{ let t35 = &vec![3, 4]; t35.iter().copied().map(|value| value as i64).collect::<Vec<i64>>() }).expect("tensor structa element count does not match shape");
    let product: faber::Tensor<f32> /* tensor<f32, [2, 4]> */ = { let t40 = &a; t40.matmul(&(b)) }.expect("tensor matmul failed");
    let mean: f32 = { let t44 = &product; let c44: f32 = t44.planata().iter().map(|x| *x as f32).sum(); c44 / t44.element_count() as f32 };
    println!("{}", faber::display_fractus(mean));
}

The error channel#

A function that may fail, and a caller that catches. Shows how the ⇥ channel becomes each target's own error idiom.

Faber source

reader locale
faber convert --to en — English reader surface
fn divide(int a, int b) → int ⇥ string {
    if b ≡ 0 {
        throw "division by zero"
    }
    return a / b
}

main {
    do {
        print divide(10, 2)
    }
    catch err {
        warn err
    }
}
faber convert --to la — canonical Faber
functio divide(numerus a, numerus b) → numerus ⇥ textus {
    si b ≡ 0 {
        iace "division by zero"
    }
    redde a / b
}

incipit {
    fac {
        nota divide(10, 2)
    }
    cape err {
        mone err
    }
}
faber convert --to th-TH — Thai
ฟังก์ชัน divide(จำนวน a, จำนวน b) → จำนวน ⇥ ข้อความ {
    ถ้า b ≡ 0 {
        โยน "division by zero"
    }
    คืน a / b
}

เริ่ม {
    ทำ {
        บันทึก divide(10, 2)
    }
    จับ err {
        เตือน err
    }
}
faber convert --to zh-Hans — Simplified Chinese
函数 divide(整数 a, 整数 b) → 整数 ⇥ 文本 {
    如果 b ≡ 0 {
        抛错 "division by zero"
    }
    返回 a / b
}

入口 {
    执行 {
        显示 divide(10, 2)
    }
    捕获 err {
        警告 err
    }
}
faber convert --to zh-Hant — Traditional Chinese
函式 divide(整數 a, 整數 b) → 整數 ⇥ 文字 {
    若 b ≡ 0 {
        拋出 "division by zero"
    }
    傳回 a / b
}

入口 {
    執行 {
        註記 divide(10, 2)
    }
    捕捉 err {
        警告 err
    }
}
faber convert --to vi — Vietnamese
hàm divide(số a, số b) → số ⇥ văn_bản {
    nếu b ≡ 0 {
        ném "division by zero"
    }
    trả a / b
}

bắt_đầu {
    làm {
        ghi_chú divide(10, 2)
    }
    bắt err {
        cảnh_báo err
    }
}
faber convert --to ar — Arabic
دالة divide(عدد a, عدد b) → عدد ⇥ نص {
    إذا b ≡ 0 {
        ارم "division by zero"
    }
    أعد a / b
}

بداية {
    افعل {
        اعرض divide(10, 2)
    }
    التقط err {
        نبه err
    }
}
faber convert --to hi — Hindi
फलन divide(संख्या a, संख्या b) → संख्या ⇥ पाठ {
    यदि b ≡ 0 {
        इधरफेंको "division by zero"
    }
    लौटाओ a / b
}

आरंभ {
    करो {
        दिखाओ divide(10, 2)
    }
    पकड़ो err {
        चेताओ err
    }
}

Rust — 13 lines in, 206 out (15.8×)

// Generated by radix - do not edit
// Requires the faber language-runtime crate (add to Cargo.toml):
//   faber = { path = "../faber" }  # adjust path for your layout

// SCR-09 recorded suppressions: identifier/literal fidelity, plan-directed
// casts and parameter passing, library-shaped artifact items.
#![allow(non_camel_case_types, non_snake_case, dead_code, clippy::unreadable_literal, clippy::cast_lossless, clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::needless_pass_by_value)]

const fn __faber_approx_int(a: i128, b: i128) -> bool {
    // `const fn`: class `static` fields are Rust associated consts, and `Ord::max` is not const.
    let (a_abs, b_abs) = (a.abs(), b.abs());
    let larger = if a_abs >= b_abs { a_abs } else { b_abs };
    1_000_000_000 * (a - b).abs() <= larger
}

fn __faber_int(value: Option<i128>) -> i128 {
    match value {
        Some(value) if (-9_223_372_036_854_775_808..=18_446_744_073_709_551_615).contains(&value) => value,
        _ => panic!("numerus overflow"),
    }
}

fn __faber_fit<T: TryFrom<i128>>(value: i128) -> T {
    T::try_from(value).unwrap_or_else(|_| panic!("numerus overflow"))
}

fn __faber_pow(base: i128, exponent: i128) -> i128 {
    if exponent < 0 {
        panic!("numerus potentia failed: negative exponent");
    }
    let mut accumulator: i128 = 1;
    let mut base = base;
    let mut exponent = exponent;
    while exponent > 0 {
        if exponent % 2 != 0 {
            accumulator = __faber_int(accumulator.checked_mul(base));
        }
        exponent /= 2;
        if exponent > 0 {
            base = __faber_int(base.checked_mul(base));
        }
    }
    accumulator
}

fn __faber_div(a: i128, b: i128) -> i128 {
    if b == 0 {
        panic!("numerus division failed");
    }
    let quotient = a / b;
    if a % b != 0 && ((a < 0) != (b < 0)) { quotient - 1 } else { quotient }
}

fn __faber_rem(a: i128, b: i128) -> i128 {
    a - b * __faber_div(a, b)
}

fn __faber_shl(value: i128, count: i128) -> i128 {
    if count < 0 {
        panic!("negative shift count");
    }
    if value == 0 {
        return 0;
    }
    if count > 64 {
        panic!("numerus overflow");
    }
    __faber_int(value.checked_mul(1_i128 << count))
}

fn __faber_shr(value: i128, count: i128) -> i128 {
    if count < 0 {
        panic!("negative shift count");
    }
    if count >= 127 {
        if value < 0 { -1 } else { 0 }
    } else {
        value >> count
    }
}

fn __faber_store<T: TryFrom<i128>>(value: i128, at: &str, inferred: &str) -> T {
    T::try_from(value).unwrap_or_else(|_| {
        let ty = std::any::type_name::<T>();
        let note = if value < 0 && ty.starts_with('u') {
            " (a negative value cannot be stored in an unsigned slot)"
        } else {
            ""
        };
        panic!("{value} does not fit in `{ty}` ({at}){inferred}{note}")
    })
}

fn __faber_cmp_int_float(int: i128, float: f64) -> Option<std::cmp::Ordering> {
    use std::cmp::Ordering;
    if float.is_nan() {
        return None;
    }
    const LIMIT: f64 = 170_141_183_460_469_231_731_687_303_715_884_105_728.0;
    if float >= LIMIT {
        return Some(Ordering::Less);
    }
    if float <= -LIMIT {
        return Some(Ordering::Greater);
    }
    let whole = float.trunc();
    match int.cmp(&(whole as i128)) {
        Ordering::Equal => {
            let fraction = float - whole;
            Some(if fraction > 0.0 {
                Ordering::Less
            } else if fraction < 0.0 {
                Ordering::Greater
            } else {
                Ordering::Equal
            })
        }
        other => Some(other),
    }
}

fn __faber_cmp_scaled_float(scaled: i128, scale: i128, float: f64) -> Option<std::cmp::Ordering> {
    use std::cmp::Ordering;
    if float.is_nan() {
        return None;
    }
    const HUGE: f64 = 170_141_183_460_469_231_731_687_303_715_884_105_728.0;
    if float >= HUGE {
        return Some(Ordering::Less);
    }
    if float <= -HUGE {
        return Some(Ordering::Greater);
    }
    if float < 0.0 {
        if let Some(negated) = 0i128.checked_sub(scaled) {
            return __faber_cmp_scaled_float(negated, scale, -float).map(Ordering::reverse);
        }
    }
    let floor = float.floor();
    let fraction = float - floor;
    let whole = floor as i128;
    let quotient = __faber_div(scaled, scale);
    let remainder = __faber_rem(scaled, scale);
    match quotient.cmp(&whole) {
        Ordering::Equal => {}
        other => return Some(other),
    }
    if fraction == 0.0 {
        return Some(if remainder == 0 { Ordering::Equal } else { Ordering::Greater });
    }
    if remainder == 0 {
        return Some(Ordering::Less);
    }
    let bits = fraction.to_bits();
    let exponent = ((bits >> 52) & 0x7ff) as i32;
    let (mantissa, shift) = if exponent == 0 {
        ((bits & ((1 << 52) - 1)) as u128, 1074_u32)
    } else {
        ((((bits & ((1 << 52) - 1)) | (1 << 52)) as u128), (1075 - exponent) as u32)
    };
    let remainder = remainder.unsigned_abs();
    let scale = scale.unsigned_abs();
    let left_bits = (128 - remainder.leading_zeros()) + shift;
    let right_bits = (128 - mantissa.leading_zeros()) + (128 - scale.leading_zeros());
    if left_bits > right_bits {
        return Some(Ordering::Greater);
    }
    if left_bits + 1 < right_bits {
        return Some(Ordering::Less);
    }
    let left = match shift {
        0 => (0u128, remainder),
        1..=127 => (remainder >> (128 - shift), remainder << shift),
        128 => (remainder, 0),
        _ => (remainder << (shift - 128), 0),
    };
    let mask = u64::MAX as u128;
    let (a_hi, a_lo) = (mantissa >> 64, mantissa & mask);
    let (b_hi, b_lo) = (scale >> 64, scale & mask);
    let low = a_lo * b_lo;
    let mid1 = a_hi * b_lo;
    let mid2 = a_lo * b_hi;
    let (mid, carry) = mid1.overflowing_add(mid2);
    let (low_sum, carry_low) = low.overflowing_add(mid << 64);
    let high = a_hi * b_hi + (mid >> 64) + ((carry as u128) << 64) + (carry_low as u128);
    Some(left.cmp(&(high, low_sum)))
}

mod host_register;

fn divide(a: i64, b: i64) -> Result<i64, String> {
    if b == 0 {
        return Err(String::from("division by zero"));
    }Ok(__faber_store::<i64>(__faber_div(a as i128, b as i128), "return", ""))
}

fn main() {
    host_register::install_or_exit();
    match { let ok: Result<(), String> = 'fac_result: {
    loop {
        println!("{}", match divide(10, 2) { Ok(fac_value) => fac_value, Err(fac_err) => break 'fac_result Err(fac_err) });
    break;
    }Ok(())
    }; ok } { Ok(ok) => ok, Err(err) => {
        eprintln!("{err}");
        ()} }}

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)
}

Rust — 12 lines in, 203 out (16.9×)

// Generated by radix - do not edit
// Requires the faber language-runtime crate (add to Cargo.toml):
//   faber = { path = "../faber" }  # adjust path for your layout

// SCR-09 recorded suppressions: identifier/literal fidelity, plan-directed
// casts and parameter passing, library-shaped artifact items.
#![allow(non_camel_case_types, non_snake_case, dead_code, clippy::unreadable_literal, clippy::cast_lossless, clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_sign_loss, clippy::cast_precision_loss, clippy::needless_pass_by_value)]

const fn __faber_approx_int(a: i128, b: i128) -> bool {
    // `const fn`: class `static` fields are Rust associated consts, and `Ord::max` is not const.
    let (a_abs, b_abs) = (a.abs(), b.abs());
    let larger = if a_abs >= b_abs { a_abs } else { b_abs };
    1_000_000_000 * (a - b).abs() <= larger
}

fn __faber_int(value: Option<i128>) -> i128 {
    match value {
        Some(value) if (-9_223_372_036_854_775_808..=18_446_744_073_709_551_615).contains(&value) => value,
        _ => panic!("numerus overflow"),
    }
}

fn __faber_fit<T: TryFrom<i128>>(value: i128) -> T {
    T::try_from(value).unwrap_or_else(|_| panic!("numerus overflow"))
}

fn __faber_pow(base: i128, exponent: i128) -> i128 {
    if exponent < 0 {
        panic!("numerus potentia failed: negative exponent");
    }
    let mut accumulator: i128 = 1;
    let mut base = base;
    let mut exponent = exponent;
    while exponent > 0 {
        if exponent % 2 != 0 {
            accumulator = __faber_int(accumulator.checked_mul(base));
        }
        exponent /= 2;
        if exponent > 0 {
            base = __faber_int(base.checked_mul(base));
        }
    }
    accumulator
}

fn __faber_div(a: i128, b: i128) -> i128 {
    if b == 0 {
        panic!("numerus division failed");
    }
    let quotient = a / b;
    if a % b != 0 && ((a < 0) != (b < 0)) { quotient - 1 } else { quotient }
}

fn __faber_rem(a: i128, b: i128) -> i128 {
    a - b * __faber_div(a, b)
}

fn __faber_shl(value: i128, count: i128) -> i128 {
    if count < 0 {
        panic!("negative shift count");
    }
    if value == 0 {
        return 0;
    }
    if count > 64 {
        panic!("numerus overflow");
    }
    __faber_int(value.checked_mul(1_i128 << count))
}

fn __faber_shr(value: i128, count: i128) -> i128 {
    if count < 0 {
        panic!("negative shift count");
    }
    if count >= 127 {
        if value < 0 { -1 } else { 0 }
    } else {
        value >> count
    }
}

fn __faber_store<T: TryFrom<i128>>(value: i128, at: &str, inferred: &str) -> T {
    T::try_from(value).unwrap_or_else(|_| {
        let ty = std::any::type_name::<T>();
        let note = if value < 0 && ty.starts_with('u') {
            " (a negative value cannot be stored in an unsigned slot)"
        } else {
            ""
        };
        panic!("{value} does not fit in `{ty}` ({at}){inferred}{note}")
    })
}

fn __faber_cmp_int_float(int: i128, float: f64) -> Option<std::cmp::Ordering> {
    use std::cmp::Ordering;
    if float.is_nan() {
        return None;
    }
    const LIMIT: f64 = 170_141_183_460_469_231_731_687_303_715_884_105_728.0;
    if float >= LIMIT {
        return Some(Ordering::Less);
    }
    if float <= -LIMIT {
        return Some(Ordering::Greater);
    }
    let whole = float.trunc();
    match int.cmp(&(whole as i128)) {
        Ordering::Equal => {
            let fraction = float - whole;
            Some(if fraction > 0.0 {
                Ordering::Less
            } else if fraction < 0.0 {
                Ordering::Greater
            } else {
                Ordering::Equal
            })
        }
        other => Some(other),
    }
}

fn __faber_cmp_scaled_float(scaled: i128, scale: i128, float: f64) -> Option<std::cmp::Ordering> {
    use std::cmp::Ordering;
    if float.is_nan() {
        return None;
    }
    const HUGE: f64 = 170_141_183_460_469_231_731_687_303_715_884_105_728.0;
    if float >= HUGE {
        return Some(Ordering::Less);
    }
    if float <= -HUGE {
        return Some(Ordering::Greater);
    }
    if float < 0.0 {
        if let Some(negated) = 0i128.checked_sub(scaled) {
            return __faber_cmp_scaled_float(negated, scale, -float).map(Ordering::reverse);
        }
    }
    let floor = float.floor();
    let fraction = float - floor;
    let whole = floor as i128;
    let quotient = __faber_div(scaled, scale);
    let remainder = __faber_rem(scaled, scale);
    match quotient.cmp(&whole) {
        Ordering::Equal => {}
        other => return Some(other),
    }
    if fraction == 0.0 {
        return Some(if remainder == 0 { Ordering::Equal } else { Ordering::Greater });
    }
    if remainder == 0 {
        return Some(Ordering::Less);
    }
    let bits = fraction.to_bits();
    let exponent = ((bits >> 52) & 0x7ff) as i32;
    let (mantissa, shift) = if exponent == 0 {
        ((bits & ((1 << 52) - 1)) as u128, 1074_u32)
    } else {
        ((((bits & ((1 << 52) - 1)) | (1 << 52)) as u128), (1075 - exponent) as u32)
    };
    let remainder = remainder.unsigned_abs();
    let scale = scale.unsigned_abs();
    let left_bits = (128 - remainder.leading_zeros()) + shift;
    let right_bits = (128 - mantissa.leading_zeros()) + (128 - scale.leading_zeros());
    if left_bits > right_bits {
        return Some(Ordering::Greater);
    }
    if left_bits + 1 < right_bits {
        return Some(Ordering::Less);
    }
    let left = match shift {
        0 => (0u128, remainder),
        1..=127 => (remainder >> (128 - shift), remainder << shift),
        128 => (remainder, 0),
        _ => (remainder << (shift - 128), 0),
    };
    let mask = u64::MAX as u128;
    let (a_hi, a_lo) = (mantissa >> 64, mantissa & mask);
    let (b_hi, b_lo) = (scale >> 64, scale & mask);
    let low = a_lo * b_lo;
    let mid1 = a_hi * b_lo;
    let mid2 = a_lo * b_hi;
    let (mid, carry) = mid1.overflowing_add(mid2);
    let (low_sum, carry_low) = low.overflowing_add(mid << 64);
    let high = a_hi * b_hi + (mid >> 64) + ((carry as u128) << 64) + (carry_low as u128);
    Some(left.cmp(&(high, low_sum)))
}

mod host_register;

fn sum(numeri: Vec<i64>) -> i64 {
    let mut total: i64 = 0;
    for i1000002 in &(numeri) {
        let n = i1000002.clone();
        total = __faber_store::<i64>(__faber_int(i128::checked_add(total as i128, n as i128)), "assignment to `total`", "");
    }total
}

fn main() {
    host_register::install_or_exit();
    let valores: Vec<i64> = vec![1, 2, 3, 4, 5];
    println!("{}", sum(valores.clone()));
}

---

All targets · Measured support per term