MSVC: provide getopt implementation
This is an alternative to !340 (closed). Instead of dropping getopt, this imports a getopt implementation into our tree for MSVC.
Technically, this doesn't make sense without !344 (merged), but since this is a bit involved, I figured this could deserve its own merge-request. The code won't be possible to trigger until !344 (merged) lands, though.