Well, i took a bit more time since i never read c++ code (nor its assembly form) but the solution is way easier (and less time consuming) to get than by brute forcing it !
That one simple instruction in the middle of it needed a bit of attention !
very nice