Reciting Birchas Hatorah prior to learning if woke up in middle of the night:
If one slept [a standard sleep] and woke up prior to dawn, while it is still night, [then if it is past midnight] he must recite Birchas Hatorah prior to learning Torah. He may not learn Torah prior to doing so. He is not to repeat the blessing again after Alos, or any time that day, until the following morning. [If it is still prior to midnight then he may continue learning Torah, and is not to say a blessing beforehand. Likewise, if one only slept a temporary sleep then he may continue learning without a blessing until daybreak or until he awakens from a standard sleep. He may not say the blessing of Birchas Hatorah prior to Alos in such a case.]
If plan to return to sleep: See Q&A!
One must recite Birchas Hatorah prior to learning Torah at night before Alos if all the following conditions apply:
1. He woke up from a standard sleep.
2. He woke up past midnight.
If one woke up before midnight, or woke up after midnight but after a temporary sleep, then he is not required to recite Birchas Hatorah prior to learning Torah at night before Alos.
Q&A if plan to return to sleep
If one woke up at night from a standard sleep and plans to learn and return to sleep again after learning, is the blessing to be said after awakening the first time?
If he planned to sleep for the night and happened to awaken in middle of the night, then he is to recite the blessing after awakening the first time, [if he woke up past midnight]. If however he went to sleep with intent to awaken in middle of the night in order to learn, then some Poskim rule he is to recite the blessing after awakening the first time, [if he woke up past midnight]. Others rule the blessing is to be recited after awakening the second time. Others rule the blessing is to be recited twice, once after awakening the first time and again after awakening the second time. According to all if one does not plan to return to sleep a standard sleep, or will not do so until after Alos, then he is to say the blessing after awakening the first time. [Practically, one should recite the blessing after the first time he awakens past midnight and not recite it again the second time.]
Q&A on prayer
If one woke up in middle of the night and remembered he did not yet Daven Maariv, should he recite Birchas Hatorah prior to doing so?
If it is prior to midnight, a blessing is not recited. If he woke up past midnight, then if he slept a standard sleep [as defined above], he is to recite Birchas Hatorah. This applies even if he plans to go to sleep a set sleep prior to Alos. Likewise he is to wash his hands with a blessing upon awakening, prior to Davening.
Q&A on definition of standard sleep
What is the definition of a standard sleep versus a temporary sleep?
A standard sleep refers to one who went to sleep for the night following his normal custom. Thus, if one went to sleep on a bed for a period of at least thirty minutes it is considered a standard sleep, and he is to recite Birchas Hatorah upon awakening past midnight. If, however, one slept on a chair and the like then even if he slept for many hours it is considered a temporary sleep, and a blessing is not recited.
If one fell asleep on the couch and the like, and then woke up, prior to Alos, must he recite Birchas Hatorah prior to learning?
If it is prior to midnight, a blessing is not recited. If one woke up past midnight then some rule a blessing is not to be recited even if he slept for many hours, being that it is considered a temporary sleep, unless it is common for that person to sleep on his couch at night.
If one fell asleep on his bed at night is he to recite Birchas Hatorah upon awakening?
If it is prior to midnight, a blessing is not recited. If one woke up past midnight, then if he slept for many hours, a blessing is to be recited prior to learning Torah. This applies even if one plans to return to sleep after learning. Nevertheless, in such a case, many Poskim rule that the blessing is only to be said upon awakening the second time, as explained above.
If one slept in his chair, such as one who is traveling on a plain or bus overnight, is he to recite Birchas Hatorah upon awakening before Alos?
If he is unable to sleep in a bed that night, and hence this is his only available form of sleep, then if he slept for thirty minutes, and awakened past midnight, he is to recite Birchas Hatorah prior to learning. If he plans to return to sleep again before Alos, then this is subject to the dispute explained in the previous Q&A.
Q&A on midnight
If one awoke before midnight must the blessing be said after midnight before learning?
If one slept a standard sleep [as defined above] and awakened before midnight, some Poskim rule he is to wait until midnight and then recite the blessing.
If one recited Birchas Hatorah after awakening prior to midnight what is the law?
The blessing is not to be repeated again until the next day.
 Admur 47:7 “When one sleeps a standard sleep and awakens prior to Alos Hashachar then according to all opinions he must say the blessing.”; 47:8 “One who wakes up prior to morning in order to learn Torah says Birchas HaTorah”; Siddur Admur “Whoever sleeps at night says the blessing upon waking up from midnight and onward”; Michaber 47:13 “One who wakes up prior to morning in order to learn Torah says Birchas HaTorah”
 Admur 47:7 that if one only slept a temporary sleep then [according to all opinions] he would not be required to recite the blessing, until Alos [No mention of this is made in Admur 47:8 or in the Siddur]; Birchas Habayis 34:8; Kaf Hachaim 47:27, 29; Piskeiy Teshuvos 47:15. See Q&A for exact definition.
 Siddur Admur; Peri Chadash 46; 47:13; Ketzos Hashulchan 5:8. The Siddur mentions midnight also regarding Al Netilas Yadayim and the morning blessings.
Other opinions: There is no mention of midnight made in the Shulchan Aruch with exception to the blessing of Hanosein Lasechvi Bina. [47:9] See Kaf Hachaim 46:49 and 47:29 in name of Mekubalim that one is to recite all the morning blessings from after midnight. However from the letter of the law he allows the blessing to be said before midnight. Furthermore, regarding Birchas Hatorah, he explicitly writes that it may be said prior to midnight although suggests and recommends saying get close to midnight; So also rules Ben Ish Chaiy Vayeishev 12
 Admur 47:7 ibid; Admur 47:8 ibid; Siddur Admur ibid; Michaber ibid; Tur 47 in name of Rosh; M”A 47:13; Tosafus Brachos 11b; Rosh Brachos ibid and Teshuvos Kelal 4:1; Shibulei Haleket 5; Iggur Tefila 1; Terumos Hadeshen 2:123;
Does this apply according to all opinions? This ruling applies according to both opinions [mentioned in 47:7] as even according to the second opinion which rules Birchas Hatorah is similar to Birchas Hashachar, which is only said once in the morning, nevertheless even Birchas Hashachar can be said prior to Alos, as soon as he awakens. [Admur 47:7]
 Admur 47:8 “He is not required to repeat the blessing in shul even if he is the Chazan who is leading the prayers”; 46:8; 6:4; Michaber 47:13; Rosh Brachos 1:13; Tosafus Rabbeinu Yehuda Brachos ibid; Rashba Brachos ibid; Hagahaos Maimanis Tefila 7 Chaf; See Tehila Ledavid 47:7
 Implication of Admur 47:7 [that if one only slept a temporary sleep then he would not be required to recite the blessing, until Alos; No mention of this is made in Admur 47:8 or in the Siddur]; Birchas Habayis 34:8; Kaf Hachaim 47:27; Piskeiy Teshuvos 47:15; See Q&A for exact definition.
Does this apply according to all opinions? Seemingly. this ruling applies according to both opinions mentioned in Admur 47:7, as even according to the first opinion who rules Birchas Hatorah must be repeated if one slept, only rules this way regarding one who slept a standard sleep, as explicitly stated in Admur 47:7 “So too if he slept on his elbows a temporary sleep it is not considered an interval]. [One cannot imply from the wording of Admur 47:7 “When one sleeps a standard sleep and awakens prior to Alos Hashachar then according to all opinions he must say the blessing” that if he slept a temporary sleep, then it is disputed if he must repeat the blessing, as in truth this is simply coming to contrast day sleep versus night sleep, and not temporary sleep versus standard sleep]. However Tzaruch Iyun, as perhaps according to the second opinion there is room to say that even if one awoke past midnight from a temporary sleep he must now recite Birchas Hatorah for the next day, just like we rule regarding the blessing of Netilas Yadayim [Siddur; See Chapter 4 Halacha 17] and just like no differentiation is made regarding other Birchas Hashachar which is dependent on sleep. [i.e. Elokaiy Neshama] Furthermore Admur himself in the Siddur does not differentiate here at all between a Shinas Keva and Shina Aray! Vetzaruch Iyun.
 See Piskeiy Teshuvos 47:17; Kaf Hachaim 47:27; Shaareiy Teshuvah 47:4
 Piskeiy Teshuvos 47:17 writes that this applies according to all.
 First opinion in M”B 47:29; Birchas Habayis 34:8; Mahrsham 3:337 [brought in Shearim Hametzuyanim Behalacha 7:2]; Peri Megadim 47 A”A 12; opinion brought in Beir Hamayim 1 [brought in Kaf Hachaim 47:27]; Mekubalim brought in Birkeiy Yosef and Shaareiy Teshuvah ibid; Kaf Hachaim 47:29 and 46:49; Shaareiy Teshuvah 47:4 concludes that if one had in mind to exempt the entire days Torah learning then a blessing is not to be repeated after awakening the second time; So rules also Even Yisrael 9:61; In truth the Mahrsham in his conclusion rules to say the blessing twice, as the third opinion above. Nevertheless he does conclude that the first sleep is considered a Shinas Keva and requires a blessing.
 Beir Hamayim 2 brought in Pesech Dvir 47:6 and Kaf Hachaim 47:27; Halichos Shlomo 6:1; Piskeiy Teshuvos 47:17 rules that one is to follow the main sleep, that if the main sleep is the second sleep then the blessing is said after the second time. If the main sleep is the first sleep then it is said after the first time. See Minchas Yitzchak 10:7
 Peri Chadash 46:8; Opinion in Birkeiy Yosef, brought in Shaareiy Teshuvah 47:4; Shaareiy Teshuvah ibid concludes that if one had in mind to exempt the Torah learning only until the next sleep, then a blessing is to be repeated after awakening the second time. M”B 47:29 rules that one who says a blessing twice has not lost out. Mahrsham 3:337 rules one is to say Asher Bachar Banu after the first time and all three blessings after the second time, or vice versa, having in mind to exempt the learning only until the second sleep. So rules also Yabia Omer 8:5; 9:91
 Shaareiy Teshuvah 47:4; Minchas Yitzchak 10:7; This refers to a normal sleep, just like the first time he slept.
 This follows the ruling of Admur in the Siddur which compares the blessing to Birchas Hashachar and does not suspect at all for the second opinion.
 Pischeiy Teshuvah 47 in name of Pnei Ahron; See also Kaf Hachaim 47:27; unlike Piskeiy Teshuvos 47:3 that says one is to have in mind to fulfill his obligation with Ahavas Olam if he plans to return to sleep that night.
 Chayeh Levi 1:2
 See M”B 4:27; See Admur 47:7 which differentiates between sleeping on a bed and on ones arms; Piskeiy Teshuvos 4 footnote 18 and 47:15 and 47:17
 Admur 47:7; It makes no difference whether he slept on his bed or a different bed, and either way it is considered a standard sleep. [Mahrsham 3:337]
 See Admur in Siddur regarding Netilas Yadayim that defines a temporary sleep as even more than 60 breaths. [See Chapter 4 Halacha 17] Some Poskim rule it refers to one who slept on his bed for a period of 2-3 hours. [Makor Chaim of Chavos Yair 47]
 Regarding one who did not change his clothing: Piskeiy Teshuvos ibid writes that it is considered a temporary sleep. [See also Halichos Shlomo 6:2] However the Mahrsham 3:337 writes explicitly that even if one fell asleep in his clothing on his bed, or even a different bed, it is considered a standard sleep and he is to say the blessing, as only one who sleeps on his arms is considered a Shinas Aray.
 Piskeiy Teshuvos ibid; as this is similar to one who sleeps on his arm. Piskeiy Teshuvos ibid adds however that if one planned to sleep in this method for the night, such as one who does not have a bed available, then it is considered a standard sleep for him regarding that night.
 Piskeiy Teshuvos 47:15 footnote 130
 Mahrsham 3:337; Brought in Shearim Hametzuyanim Behalacha 7:2
 Kaf Hachaim 47:29; Ben Ish Chaiy Vayeishev 12; Vetzaruch Iyun if according to Admur one must recite the blessing prior to learning past midnight. Perhaps one may learn prior to reciting the blessing as it is no different than one who slept a standard sleep during the day which may learn Torah all night until Alos. Vetzaruch Iyun.
 Piskeiy Teshuvos 47 footnote 143
 As many Poskim hold the blessings may be recited prior to midnight if one woke up from a standard sleep. [see Kaf Hachaim 47:29] and even according to Admur in the Siddur which mentions midnight, since the reason is not mentioned, we apply the rule of Safek Brachos Lihakel and one may not repeat the blessing.