make a version before take of memory
Merge branch 'master' of https://github.com/lalalah/Compilers-PS4
modify for state reference counting