Best Use & Engineering Application Guide

Engineering Category: Exact Integer Number Theory & Transcendentals

Best Use in Production: Hardware-verified modular arithmetic, integer roots, and combinatorial invariants for exact rational math engines and cryptographic primitives.

When to Select This Capsule: Verified baseline member of a 2-capsule Equivalence Class; useful as a reference or cross-validation peer. Multi-step compute kernel (135541833/200000 cyc/op); best used at frame, block, or batch aggregation boundaries.

Snap-Circuit Wiring Role: 2-to-1 Binary Combiner / Join Stage `(i64,i64)->i64` — ideal for merging two upstream DAG branches, dot products, or pairwise rank fusion.

Hardware _rdtsc: 135541833/200000 cycles/op
Latency: 4034011/12500 ns/op
Throughput: 12500000/4034011 ops/us
Compiled ELF64 .text: 148 B (48 x86_64 insns)
C64 64KB RAM Budget: 147/32768 (294 B source)
Ternary Vote: + (score 1) | Salience: 235985/3432
Pure-Rust Capsule Source Code (294 B)
pub const fn gcd_i64(mut a: i64, mut b: i64) -> i64 {
    if a < 0 {
        a = a.saturating_neg();
    }
    if b < 0 {
        b = b.saturating_neg();
    }
    while b != 0 {
        let r = a % b;
        a = b;
        b = r;
    }
    if a == 0 {
        1
    } else {
        a
    }
}
rustc -C opt-level=3 x86_64 Disassembly (148 B .text / 48 insns)
gcd_i64:
    mov    rax, rdi
    test    rdi, rdi
    js    .LBB7_1
    test    rsi, rsi
    js    .LBB7_3
.LBB7_4:
    test    rsi, rsi
    jne    .LBB7_5
    jmp    .LBB7_9
.LBB7_1:
    xor    ecx, ecx
    mov    rdx, rax
    neg    rdx
    setns    cl
    movabs    rdx, 9223372036854775807
    add    rdx, rcx
    neg    rax
    cmovo    rax, rdx
    test    rsi, rsi
    jns    .LBB7_4
.LBB7_3:
    xor    ecx, ecx
    mov    rdx, rsi
    neg    rdx
    setns    cl
    movabs    rdx, 9223372036854775807
    add    rdx, rcx
    neg    rsi
    cmovo    rsi, rdx
    test    rsi, rsi
    jne    .LBB7_5
    jmp    .LBB7_9
.LBB7_7:
    xor    edx, edx
    div    rsi
    mov    rax, rsi
    mov    rsi, rdx
    test    rdx, rdx
    je    .LBB7_9
.LBB7_5:
    mov    rcx, rax
    or    rcx, rsi
    shr    rcx, 32
    jne    .LBB7_7
    xor    edx, edx
    div    esi
    mov    rax, rsi
    mov    rsi, rdx
    test    rdx, rdx
    jne    .LBB7_5
.LBB7_9:
    cmp    rax, 1
    adc    rax, 0
    ret

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#2030gcd_binary_i64
domain: math | id: bbf489200f39dd46b16954913d96fbe1
27215567/100000 cyc/op1063207/12500 ns/op12500000/1063207 ops/us201 B .text (53 insns)+ (1)aye::Peter+Omni(0+1)::aarch64 @ 432Hz
#2043gcd_i64 (THIS CAPSULE)
domain: gemini-diary-x86_64 | id: db0770ddd3c0c6bf15e56d0aafbede66
135541833/200000 cyc/op4034011/12500 ns/op12500000/4034011 ops/us148 B .text (48 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz