Say P1 starts first and executes statement 1, after that system context switches to P2 (before executing statement 2), and it enters inside if statement, since the flag is still false.
So now both processes are in critical section!! so (i) is true.. (ii) is false
By no way it happens that flag is true and no process’ are inside the if clause, if someone enters the critical section, it will definitely make flag = false. So no deadlock.