Ideally each Stack Exchange site is designed to have a unique scope and focus, though there will inevitably be some overlap between some sites at the edges of said scope. There is also overlap where a new site is proposed to cover a specific topic that itis partially covered by an existing site.
However, for Stack Overflow and Code Review the sites are meant to be largely distinct. At one level you could say that Stack Overflow is for broken code ("why doesn't this work", "why does this give the wrong result?" etc.) as well as for certain "how do I do this?" type questions. However, Code Review explicitly states that you must have working code, as their primary goal is to make code "better" (eg. faster, use less memory, etc.)
There could be ana case made for posting code that needs speeding"speeding up" on Stack Overflow as it fails to meet a performance target - which can be interpreted as broken code ("The answer arrives too late to be useful" - thank's to @BenVoigt for pointing that one out).
However, basically, if you have working code but want to make it better post on Code Review.
However, if you have broken code post on Stack Overflow.