I am aware of two techniques for flipping a bool:

```
x = !x

```

and

```
x ^= 1

```

I prefer the second, in the same way that I prefer x++ over x+=1 over x=x+1.

But are they guaranteed to produce the same Assembly code?

And if not, is there some rationale to favour one over the other?