Why does the Torah say "bi'Demei [Taharah]" regarding a boy, and "Al Demei" regarding a girl?
Moshav Zekenim citing the Rosh: She always has 33 days of Dam Tohar after a boy, but sometimes she does not have 66 Yemei Tohar after a girl, e.g. if she miscarried during these days. 1
There is no Tum'as Leidah for a miscarriage within Yemei Tohar of a boy, for within 40 days it is not considered a fetus. (PF)
What do we learn from the prefix Vov "v'Im"?
Moshav Zekenim: If she gives birth to a Tumtum or Androginus, amidst Safek she is stringent to observe Tum'ah like Yoledes Nekevah, and Yemei Tohar for a male (they end on day 40, even though she was forbidden amidst Safek until day 15).