What do I do in situation as on the scheme below?
As you can see flange bolts are just hanging in space.
Do I fill space between cement floor and pipe with new cement and then screw bolts to it?
In the situation where a toilet flange is in the drain pipe through a concrete floor, there does not have to be any bolts holding the flange down.
The pipe will be held tight in the concrete and the flange glued to that.
For your particular situation, I would fill in the gaps with a little cement or even thin set. No bolts are needed except those to hold the toilet. Keep the cement out of those slots.