Swapping without 3rd variable
I found one of the way to swap two numbers without using 3rd temp variable,

But I couldn't understand **the logic behind this swapping.** 

    #include <stdio.h>
     
    int main() {
            int a = 10;
            int b = 5;
            printf("Swapping");
            a = b - ~a - 1;             // Step 1
            b = a + ~b + 1;             // Step 2
            a = a + ~b + 1;             // Step 3
            printf("a: %d, b: %d",a,b); // Prints a:5, b:10
            return 0;
            }

Can anybody explain it step by step ?
Swapping without 3rd variable
===

I found one of the way to swap two numbers without using 3rd temp variable,

But I couldn't understand **the logic behind this swapping.** 

    #include <stdio.h>
     
    int main() {
            int a = 10;
            int b = 5;
            printf("Swapping");
            a = b - ~a - 1;             // Step 1
            b = a + ~b + 1;             // Step 2
            a = a + ~b + 1;             // Step 3
            printf("a: %d, b: %d",a,b); // Prints a:5, b:10
            return 0;
            }

Can anybody explain it step by step ?