Best Use & Engineering Application Guide

Engineering Category: Lossless Wire & Structural Compression

Best Use in Production: Zero-allocation integer bit-packing, variable-length encoding, and stream framing for sovereign wire protocols.

When to Select This Capsule: Holds the #1 Equivalence Crown across 2 functionally identical implementations (fastest verified hardware _rdtsc). Sub-10-cycle hardware kernel (290457/40000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.

Snap-Circuit Wiring Role: Signed/Unsigned Bridge Adapter `(i64)->u64` — converts between bipolar wave/PCM domains and unsigned packed bitstreams.

Hardware _rdtsc: 290457/40000 cycles/op
Latency: 39401/20000 ns/op
Throughput: 20000000/39401 ops/us
Compiled ELF64 .text: 121 B (31 x86_64 insns)
C64 64KB RAM Budget: 557/65536 (557 B source)
Ternary Vote: + (score 1) | Salience: 89785/1014
Pure-Rust Capsule Source Code (557 B)
pub const fn st_golf_pcm16_to_mulaw_lzcnt_u64(pcm_sample: i64) -> u64 {
    let clamped = if pcm_sample > 32767 {
        32767
    } else if pcm_sample < -32768 {
        -32768
    } else {
        pcm_sample
    };
    let sign: u64 = if clamped < 0 { 0x80 } else { 0x00 };
    let mag = if clamped < 0 { -clamped } else { clamped };
    let biased = ((if mag > 32635 { 32635 } else { mag }) + 132) as u64;
    let exp = (56 - biased.leading_zeros()) as u64;
    let mantissa = (biased >> (exp + 3)) & 0x0F;
    (!(sign | (exp << 4) | mantissa)) & 0xFF
}
rustc -C opt-level=3 x86_64 Disassembly (121 B .text / 31 insns)
st_golf_pcm16_to_mulaw_lzcnt_u64:
    cmp    rdi, -32767
    mov    rax, -32768
    cmovge    rax, rdi
    cmp    rax, 32767
    mov    ecx, 32767
    cmovl    rcx, rax
    mov    rdx, rdi
    shr    rdx, 63
    shl    edx, 7
    mov    rax, rcx
    neg    rax
    test    rdi, rdi
    cmovns    rax, rcx
    cmp    rax, 32635
    mov    esi, 32635
    cmovb    rsi, rax
    add    rsi, 132
    bsr    rax, rsi
    xor    rax, 63
    mov    cl, 59
    sub    cl, al
    shr    rsi, cl
    and    esi, 15
    shl    eax, 4
    mov    ecx, 128
    sub    ecx, eax
    movzx    eax, cl
    or    eax, edx
    or    rax, rsi
    xor    rax, 255
    ret

Head-to-Head Functional Equivalence Class Peers (2 Implementation(s) Matching 64 Test Vectors)

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#50st_golf_pcm16_to_mulaw_lzcnt_u64 (THIS CAPSULE)
domain: liquid-rust | id: e1ae68c20f12dfc47abe90395536d4ec
290457/40000 cyc/op39401/20000 ns/op20000000/39401 ops/us121 B .text (31 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz
#1690liquid_pcm16_to_mulaw
domain: liquid-rust | id: ec976a9db0b9a84affdfa0ce4e01ccdc
2875011/80000 cyc/op958337/80000 ns/op80000000/958337 ops/us185 B .text (45 insns)+ (1)aye-core-8b @ 432Hz