I have a Samsung Galaxy S II model smartphone. GT-I9100 is the exact model number 1, mentioning it since I saw here:
that there are variants with slightly different model numbers (such as GT-I9100G) and correspondingly slightly different hardware features.
1 That exact model number (GT-I9100) shows both while it boots up, and also when you go to Settings -> About Phone.
(Sorry for the slightly long question, but I have tried to make it as clear as possible.)
A while ago it suddenly stopped booting properly. Before that it was working fine for over 2 years. I had bought it used; not sure if that has anything to do with the problem, but after I first bought it, it almost never had any problem for those 2 or so years, except for one issue: it sometimes used to shut down automatically, without my doing anything. But powering it on again, always resulted in it working normally again. I asked the dealer from whom I bought it, about this issue, and he said it was a known issue in that model.
Now, whenever I power it on, it only goes up to the initial Samsung splash screen (with a big stylized S in the middle of the screen), with the model number GT-I9100 on the right side of the screen, then only the big S for a bit, then again the big S with the words "Samsung Galaxy S II" below it , then hangs at the point, indefinitely. Also, while in this hung state (which can only be stopped by removing the battery), it intermittently a) flashes the big S a little brighter, and then b) makes two short beeps. Events a) and b) keep repeating at intervals, of maybe a minute or two. The phone also gets a little heated, maybe due to the big S getting brighter (and then dimmer).
 Image of phone in that state is at bottom of this post.
I would like to know how to do the following:
Fix it so that it boots fully and works normally. I would like to preserve the data on it, such as contacts, etc., but in the worst case, I'm okay with losing all the data, as long as I can get the phone working again. (I have an older Samsung Android phone which I using as of now, and I had saved most of my important contacts in my Google account, not in the phone or SIM.)
I would like to know how to flash and root it, maybe with CyanogenMod or a similar OS. I heard from a friend that by doing that, the battery charge lasts for longer, due to no unwanted apps or services running, apart from the fact that a flashed and rooted phone can be used for more things, such as sshing into a server where I have an account, or getting a Linux console on the phone (which would be cool and useful, even if I could only run a subset of Linux commands).
I will search the net for steps for flashing and rooting it, but would like to know if anyone has any general guidelines for that.
If I need to give any more information for any one to suggest solutions, please let me know.