How to castle two times in a game A simple question: Assuming that I'm playing as White, how can I castle twice in a game?

I've asked myself this question after seeing the following game from Tim Krabbe's chess records "Greatest number of castlings", in which White castles twice.

[Title "Heidenfeld - Kerins, Dublin 1973"]
[FEN ""]

1. e4 e6 2. d4 d5 3. Be3 Nf6 4. e5 Nfd7 5. f4 c5 6. c3 Nc6 7. Nf3 Qb6 8. Qd2 c4 9. Be2 Na5 10. O-O f5 11. Ng5 Be7 12. g4 Bxg5 13. fxg5 Nf8 14. gxf5 exf5 15. Bf3 Be6 16. Qg2 O-O-O 17. Na3 Ng6 18. Qd2 f4 19. Bf2 Bh3 20. Rfb1 Bf5 21. Nc2 h6 22. gxh6 Rxh6 23. Nb4 Qe6 24. Qe2 Ne7 25. b3 Qg6+ 26. Kf1 Bxb1 27. bxc4 dxc4 28. Qb2 Bd3+ 29. Ke1 Be4 30. Qe2 Bxf3 31. Qxf3 Rxh2 32. d5 Qf5 33.O-O-O Rh3 34.Qe2 Rxc3+ 35.Kb2 Rh3 36.d6 Nec6 37.Nxc6 Nxc6 38.e6 Qe5+ 39.Qxe5 Nxe5 40.d7+ Nxd7 0-1
The answer is plain and simple: You cannot castle twice without breaking the rules. The only chance for this thing to happen is that the illegal move (the second castling) stays unnoticed until the game is ended with an accepted outcome.