"Good code" is not well defined and your example shows this perfectly. LMDBs codebase is absolutely horrendous when your quality criterias for good code are Readability and Maintainability. But it's a perfect masterpiece if your quality criteria are Performance and Efficiency.
Most modern Software should be written with the first two in mind, but for a DBMS, the latter are way more important.
Yes, that's exactly the point. AI is terrible at writing code unsupervised, but it's amazing as a supportive tool for real devs!