Li-zchus my beloved friend R' Yisrael Daniel ben Shayna Dina for bracha and hatzlacha in everything!!
The Rambam [הלכות קריאת שמע א ט] writes that the time for shma is until chatzos. If the person was negligent and waited until after chaztos to say shma he may read until dawn and the Rabbis only said that one must read until chatzos to distance a person from negligence [to ensure that he reads on time].
The source of the Rambam is the gemara in brachos [9a] that quotes Rabban Gamliel as saying that the Rabbis essentially agree with him that one may read shma until dawn and they only said to read until chatzos, כדי להרחיק אדם מן העבירה - to distance man from sin.
The Kesef Mishna says that the Rambam rules like the Rabbis and he holds that according to them one must only read until chatzos lichatchilah but bi-dieved we have until morning.
However the Shaagas Aryeh [compared by Rav Asher Weiss to a bulldozer - when he doesn't agree with a Rishon he is fearless in his attacks] asked a question on the Kesef Mishna from an explicit gemara [8b] that says that the halacha follows Rabban Gamliel. So why did the Rambam rule like the Rabbis when the gemara says that the halacha is like Rabban Gamliel?
We are thus compelled to say that the Rambam rules like Rabban Gamliel and that even R"G agrees that ideally one should read until chatzos. The argument between him and the Rabbis is whether it is a mitzva bidieved to read even after chatzos. According to the Rabbis, there is no longer a mitzva to read after chatzos. It was uprooted as a mitzva in order to ensure that people read on time. R"G disputes this and contends that even after chatzos there is a mitzva. That explains the position of the Rambam. There is a mitzva lichatchila to read until chatzos but if someone missed it he may still read until dawn.
However we must further understand the position of the Rambam. The gemara says [4b] that in reality "it is R. Gamaliel's view that they [the Rabbis] adopted [that בשכבך means all night], and their reason for saying, UNTIL MIDNIGHT is to keep a man far from transgression. For so it has been taught: The Sages made a fence for their words so that a man, on returning home from the field in the evening, should not say: I shall go home, eat a little, drink a little, sleep a little, and then I shall recite the Shema and the Tefillah, and meanwhile, sleep may overpower him, and as a result he will sleep the whole night. Rather should a man, when returning home from the field in the evening, go to the shul. If [it is not yet time to read shma, then if] he is used to reading Tanach, let him read Tanach, and if he is used to repeating the Mishnah, let him repeat the Mishnah, and then let him recite the Shema and say the Tefillah, [go home] and eat his meal and Bentch. And whosoever transgresses the words of the Sages deserves to die."
From this gemara we see that the two decrees, the איסור of eating before shma and the decree not to read after chatzos stem from the same source כדי להרחיק אדם מן העבירה - to distance man from sin. The Shagas Aryeh roared [like a lion, in simman dalet]: It is clear that if one eats before shma he may still read shma while [according to the Rabbis] if chatzos passed he may no longer read shma. But if both the איסור of eating before shma and reading after chatzos stem from the principle of להרחיק אדם מן העבירה, why do we say that if one ate he may still read but if chatzos passed he may no longer read. They come from the same place and yet one [איסור אכילה] is only lichatchila and the other is even bidieved [ קריאה אחר חצות]!!?
Explains Rav Soloveitchik [שיעורי הרב סי' י]: Tosfos [ד: ד"ה וקורא] explains that the איסור אכילה before shma is NOT a din in the time and mitzva of reading shma but an איסור אכילה. The חלות איסור, the locus of the prohibition, is the eating. If he transgressed this איסור there is no reason he shouldn't read shma. The decree not to read after chatzos is fundamentally different. That is a decree which pigeonholes the VERY TIME OF SHMA. Chazal uprooted the mitzva of shma from all night and established it as a mitzva that ends at chatzos. The MITZVA ITSELF was changed. So if the time of chatzos passed there is no longer a reason to read.
This answers the Shaagas Aryeh's question. Yes, the איסור אכילה and the decree not to read after chatzos are both כדי להרחיק אדם מן העבירה. But they are fundamentally different, thus the איסור אכילה is only lichatchila [because it's a "din" in אכילה not shma] while the decree not to read after chatzos is even bidieved [because Chazal uprooted the mitzva].
The problem is that the Rambam [הלכות תפילה ו,ז] seems to say that the איסור of eating before shma is a "din" in shma. We are concerned that the time will pass so it is forbidden to eat. It is NOT an איסור אכילה as much as it is an איסור for the sake of shma. [The נפקא מינה between Tosfos and Rambam is other activities. According to the Rambam EVERYTHING should be אסור since the concern is that the time will pass. But according to Tosfos only אכילה would be אסור because the decree was tagged איסור אכילה.]
If so the original question of the Shaagas Aryeh is restored - If both the איסור אכילה and the decree not to read after chatzos stem from the same source and have the same rationale, why is one only lichatchila and the other bidieved [according to the Rabbis]?
The answer given by Rav Soloveitchik [in condensed form] is to reformulate our understanding of the איסור אכילה. Yes, indeed, it is a "din" in shma but that doesn't mean that the time for shma is cancelled if one ate. It is a "din" on the "gavra", the gentleman! A person must say shma before he eats in order to ensure that shma is read. This being the case, if one does eat an עבירה has been committed but he may still read shma. This is in contrast to reading after chatzos where that time frame was uprooted by the Rabbis as a mitzva.
This understanding of the איסור אכילה is borne out by the fact that the Rambam writes it NOT in the halachos of the zman krias shma but in the context of other forbidden activities that one must avoid before shma and davening.