The AR-15 (M4 variant) is a great weapon. Ammo is plentiful, rate of fire is good, ease of use, alot of accessories and spare parts, and is an easy rifle to maintain. The only drawbacks in my book to the round, is it certain conditions, and at distance, it can tend to be a bit under powered. Not a bad rifle to have in capable hands by any means.
I like the AK for the same reasons, plus it has more punch, and you can treat it like an ex-wife and it will still shoot. In a serious situation where weapon maintenance might not happen for extended periods of time, you can't go wrong with the AK. You can drop that baby in the swamp, drain the barrel and come out fighting. It can take real word abuses that would cause other rifles to malfunction.
As far as inside 50 yards or closer, if I had the choice I would definitely grab a "combat" shotgun. Nothing is more effective, or easier to use, especially in conditions where careful, scoped aiming may not be an option. The short barreled shotty is probably my first grab in home invasion situation. There are semi-auto "drum" fed models, short barreled, pistol gripped, and will hold a box of alternating slug, 00, or whatever you want to feed it. Hard to go wrong there.