# A user enclave in Vibe (e4-user-enclaves.md EU1, EU2): two cells that point at each
# other, which ownership forbids and an enclave allows, its references private to it
from verada import *

enclave()


@dataclass
class _Node:
    value: int
    next: Ref[_Node] | None = None


def pair_sum(a: int, b: int) -> int:
    requires(0 <= a and a <= 1000 and 0 <= b and b <= 1000)
    x = Ref(_Node(value=a))
    y = Ref(_Node(value=b, next=x))
    x.next = y
    total = x.value + x.next.value
    x.next = None
    del y
    del x
    return total
