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: Verified baseline member of a 4-capsule Equivalence Class; useful as a reference or cross-validation peer. Low-latency L1-resident kernel (3886171/200000 cyc/op); well-suited for high-frequency pipeline stages.

Snap-Circuit Wiring Role: Slice Ingress / Scanner Stage `(&[u8])->u64` — digests raw byte buffers into scalar tokens or checksums.

Hardware _rdtsc: 3886171/200000 cycles/op
Latency: 3701653/400000 ns/op
Throughput: 400000000/3701653 ops/us
Compiled ELF64 .text: 153 B (42 x86_64 insns)
C64 64KB RAM Budget: 417/65536 (417 B source)
Ternary Vote: + (score 1) | Salience: 18625/228
Pure-Rust Capsule Source Code (417 B)
pub fn xor_fold_scalar(bytes: &[u8]) -> u64 {
    let full_words_len = bytes.len() & !7usize;
    let mut acc: u64 = 0;
    let mut i = 0usize;
    while i < full_words_len {
        acc ^= (bytes[i] as u64) << ((i & 7) * 8);
        i += 1;
    }
    while i < bytes.len() {
        acc ^= bytes[i] as u64;
        i += 1;
    }
    core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst);
    acc
}
rustc -C opt-level=3 x86_64 Disassembly (153 B .text / 42 insns)
xor_fold_scalar:
    movabs    rdx, 9223372036854775800
    and    rdx, rsi
    je    .LBB7_1
    mov    r8d, 24
    xor    eax, eax
    xor    r9d, r9d
.LBB7_6:
    movzx    r10d, byte ptr [rdi + r9]
    lea    ecx, [r8 - 24]
    and    cl, 32
    shl    r10, cl
    xor    r10, rax
    movzx    eax, byte ptr [rdi + r9 + 1]
    lea    ecx, [r8 - 16]
    and    cl, 40
    shl    rax, cl
    movzx    r11d, byte ptr [rdi + r9 + 2]
    lea    ecx, [r8 - 8]
    and    cl, 48
    shl    r11, cl
    xor    r11, rax
    xor    r11, r10
    movzx    eax, byte ptr [rdi + r9 + 3]
    mov    ecx, r8d
    and    cl, 56
    shl    rax, cl
    xor    rax, r11
    add    r9, 4
    add    r8, 32
    cmp    rdx, r9
    jne    .LBB7_6
    cmp    rdx, rsi
    je    .LBB7_4
.LBB7_3:
    movzx    ecx, byte ptr [rdi + rdx]
    xor    rax, rcx
    inc    rdx
    cmp    rdx, rsi
    jb    .LBB7_3
.LBB7_4:
    ret
.LBB7_1:
    xor    eax, eax
    cmp    rdx, rsi
    jne    .LBB7_3
    jmp    .LBB7_4

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#1637wupz_xor_fold
domain: smart-tree | id: b1b0f9a58585ab9287dc3d2acdbc79f6
277647/20000 cyc/op2644609/400000 ns/op400000000/2644609 ops/us442 B .text (105 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz
#1648reference_fold
domain: smart-tree | id: 6ba1e9237f06ee601d37cac7ed14f659
1554087/100000 cyc/op370067/50000 ns/op50000000/370067 ops/us192 B .text (58 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz
#1674wupz_xor_fold_bytes
domain: 8b-is-x86_64 | id: 6062182496ead4dfeef2de489087d5e2
91627/5000 cyc/op698261/80000 ns/op80000000/698261 ops/us512 B .text (121 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz
#1677xor_fold_scalar (THIS CAPSULE)
domain: smart-tree | id: 578a8eb4d4145dde7f6c8b036ac555f7
3886171/200000 cyc/op3701653/400000 ns/op400000000/3701653 ops/us153 B .text (42 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz