# Which instruction yields atomicity in this expression that makes the result 2?

int x = y = z = 0;

---------       --------
x = y + z       y = 1
z = 2


Which gives the following sets of output

$$\begin{array}{ccc}1&2&3\\ T1 : x = y + z&T2 : y = 1&T2 : y = 1\\T2 : y = 1&T2 : z = 2&T1 : x = y + z\\T2 : z = 2&T1 : x = y + z&T2 : z = 2\end{array}$$

Translating the $x=y+z$ expression to machine code gives

load r1; y
store r3;


However according to some notes I read going down the path of

T1 : load r1, y
T2 : y = 1
z = 2

I cannot seem to understand how the author came to result that $x=2$.
The point you are missing is that in thread $y$ is loaded into $r1$ and that any subsequent changes to $y$ will not affect the value stored in $r1$. Thus, the value in $r1$ is $0$ even after statement $y=1$. From this it is easy to see that the result is $x=2$.