Anyway, you are missing a third option. Imprisonment does not have to be about either rehabilitation or punishment. It could also, or even instead, be about detainment and isolation. In other words, you can imprison somebody not out of some sort of desire to "get back at them", and not with any hope of correcting their behavior, but merely to make sure they cannot injure people again.
Consider the case of Charles Manson: That guy is way too far gone to ever really hope that he can be rehabilitated. There is no fixing that guy; the US prison system couldn't do it, the Norwegian system couldn't do it, no "Manhattan Project of Psychiatry" could do it. Even so, that doesn't mean that the only option left is to ensure that he lives in relative misery the rest of his nature life. We could allow him to live the rest of his life out in relative comfort, so long as we never allow him to be free to harm others again.
Where we cannot 'fix', we obviously need to detain and isolate, but doing that for the safety of the public is sufficient motivation. We don't need to do that out of a desire to 'punish'. (Unless you buy into "such punishments act as a deterrent")