Since my previous question, I have discovered recently that I had ADHD, and possibly a form of Asperger syndrome, which perfectly explain my past difficulties. This has been quite a shock and gave me hope that with treatment (which I will start soon) and newfound motivation, I can improve my academic results dramatically.
My opinion for now is that the plan that gives me the best chances would be to get a second master's degree containing more theory (in machine learning) compared to my current one (computer engineering, lots of software development with some data science courses). I have my sights on the university I did an exchange in, which is quite well-regarded and better-ranked than my current one.
My results have had ups and downs over the years, and would be clearly insufficient without a very good justification, which I believe my mental health problems to be. I can easily get a written proof of my recent ADHD diagnosis, and also have a written record of a depression I have suffered from during my exchange. I don't plan to use these as an argument for admission, but providing that I get better results in the next semester after getting medical help, I am hoping that the admission committee won't disqualify me instantly based on my past results, and give more importance to the next semester.
One additional difficulty is that the next semester is the last semester of courses in my current degree, so I won't have another occasion to get good results. I worry that getting good grades in that semester could be insufficient to offset my less-than-stellar record.
Is a very late mental disorder diagnosis followed by a significant improvement in results likely to save my applications to selective programs? Should I lower my ambitions for the moment?