void swap(unsigned* a, unsigned* b) { *a = *a + *b; *b = *a - *b; *a = *a - *b; }
clang: https://godbolt.org/z/5PEMTrxba
gcc: https://godbolt.org/z/7j8h4zo4v
* wrapping is well-defined behavior for unsigned integers; signed integer wrapping is UB, but is not used here.
* the equations (that a & b cancel each other out, resulting in the swap) hold even when done in a mod N ring.