The problem is that wait_for sends the main() function into a wait state as well, of which you are aware, and then after wait_for a new variable with the same name and value is "allocated" (check their pointers with printf).
The solution or workaround rather is to better not use wait whenever you can in my opinion (or make it a global variable/ object if you have to).