Cameron knew exactly what he was doing - he'd done his research and knew the vote would be close.
Whether he expected remain or leave is irrelevant, both possibilities were planned, and every moment since he announced the referendum has been a calculated charade to expand division and resentment amongst the populace, to exhaust people and grow the apathy that allows the Tories to increase their power and control.
Whether May is in on it or a puppet is irrelevant too, her actions are deliberate, her position as PM kept whilst it's needed, just like the rift in the Conservative party - they'll both be gone in moments when it's deemed beneficial to do so.
^ Can you prove that wrong?