When should I make the beracha of al netilas yadayim in the morning in the following scenarios?
A)Wake at 5:15, use the bathroom, leave the house at 5:40 learn in shul until 6:00
B)Wake at 5:00, use the bathroom, leave the house at 5:25, learn in shul for 35 minutes, use the bathroom again & then daven
A) Straight after using the bathroom (together with Asher Yatzar and Elokai Neshamah). If the time (5:15) is before alos hashachar, you should wash again before after alos hashachar, without a berachah.
B) There are two valid options. Mishnah Berurah writes that the correct procedure (based on Chayei Adam) is to only recite al netilas yadayim after you use the bathroom again. However, Mishnah Berurah himself notes that the custom of many is to recite the blessing immediately after using the bathroom (the first time), and, based on the majority of poskim, this is the ruling given by Kenei Bosem (2:3).
Sources: See Biur Halachah 4, s.v. ve’afilu, based on Chayei Adam; as others have noted, Chayei Adam can be interpreted differently, so that it would not be in opposition to other poskim; see also Mishnah Berurah 6:8-9. Concerning using the bathroom for gedolim or ketanim, see Mishnah Berurah 4:30 (and Biur Halachah s.v. Ve’alaihu); 6:11 [this is something of a point of difficulty in Mishnah Berurah]. Mishnah Berurah 6:9 concedes that one is permitted to follow the ruling of Shaarei Teshuvah (and others) and to make the berachah immediately upon washing after using the bathroom.