If one used the bathroom prior to saying an after blessing for food which blessing is to be recited first?
If one ate an item that requires an after blessing [such as Borei Nefashos or even Birchas Hamazon] and forgot to say the blessing and urinated [or defecated] and then remembered to say the blessing, he is to precede the blessing of Asher Yatzar and only afterwards recite the after blessing for the food [or drink].
Asher Yatzar is recited prior to an after blessing over food or drink.
 Admur 7:7; repeated in 165:2 with slight changes; based on Rashal 97 brought in M”A 165:3; Beir Heiytiv 7:1; So rules also Olas Tamid 7:1; Soles Belula 7:2; Elya Raba 7:2; Rav Akiva Eiger; Ruach Chaim 7:1; Ben Ish Chaiy Vayeitzei 13; Kaf Hachaim 7:1; M”B 7:2
 Borei Nefashos versus other after blessing: In 165:2 Admur writes: “One who ate something which obligates him to recite “Boreh Nefashos Rabos” as an after blessing.” In 7:7 however he simply writes “an after blessing” and does not mention Borei Nefashos. In the Rashal, which is the source of the ruling, Bore Nefashos is mentioned. The Ketzos Hashulchan 60 footnote 21 addresses this point saying that in truth by all after blessings, including Al Hamichya, precedence is given to Asher Yatzar. Perhaps however Admur emphasized Boreh Nefashos to teach us that even by after blessings that receive complete Hesech Hadaas through one leaving the room, precedence is still given to Asher Yatzar. [ibid] Alternatively perhaps the novelty is that although Boreh Nefashos is said more often than Al Hamichya, nevertheless in comparison to Asher Yatzar it is said less often and hence is said after Asher Yatzar.
 Kaf Hachaim 7:1 based on Ruach Chaim ibid and so is implied from Admur 7:7 which does not differentiate between after blessings; So also concludes Piskeiy Teshuvos 165:2 [stating that so is the custom]; Yechaveh Daas 3:15; Shieilas Shaul 22
Other Opinions: Rav Akiva Eiger 7:1 questions that perhaps Birchas Hamazon is to precede Asher Yatzar being it is a Biblical obligation. He concludes with a Tzaruch Iyun. However, the Kaf Hachaim ibid rules one is to precede Asher Yatzar as he may come to forget to say it afterwards. Piskeiy Teshuvos ibid brings from Shaagas Aryeh 22 that a Biblical Mitzvah never has precedence over a Rabbinical Mitzvah, as a Rabbinical Mitzvah is considered like voluntary. Vetzaruch Iyun as accordingly one should be able to choose to precede Birchas Hamazon if he wants.
 The reason: The reason for this is because Asher Yatzar is said more often [than this specific after blessing] and the rule is that one always precedes a more often Mitzvah over a less frequent one. [Admur 7:7 and 165:2] Meaning that although it is possible that after blessings as a whole are said more often than Asher Yatzar, when one compares a specific after blessing to Asher Yatzar, Asher Yatzar is said more often. This way of understanding Admur would also help explain why he mentions “Bore Nefashos” in 165:2 as explained in the previous footnote.
Other reasons: The Olas Tamid ibid gives an alternative reason saying that since Asher Yatzar is said after any amount of urination or defecation, while an after blessing is only said after a Revius or Kezayis, therefore it receives precedence. Kaf Hachaim 7:1 says that we say Asher Yatzar first because one may come to forget.