Repair a swap that exchanges only local pointer copies

The function below is intended to exchange caller ints but fails. Explain its actual effect using a caller/callee diagram. Repair it so valid pointed-to ints are swapped; define null arguments to cause a no-op. Ensure swap(&x, &x) is safe. Explain why the temporary should be an int rather than a pointer.

void swap(int *a, int *b) {
    int *temp = a;
    a = b;
    b = temp;
}
/* Caller: int x = 2, y = 7; swap(&x, &y); */

