To answer your questions:
For the builtin comparisons, you’ll need to look at the OCaml repository, under the runtime directory - for example, here’s the compare function (and equal etc. below it): ocaml/runtime/compare.c at bf777c514f700154a7e08a584a19d0b79bc8d999 · ocaml/ocaml · GitHub.
For interfacing with C, the OCaml manual has a pretty self-enclosed guide on writing low-level bindings which should provide all you need: OCaml - Interfacing C with OCaml
Real world OCaml also has a section on using Ctypes, which is a library that provides a slightly more high-level interface for writing bindings: Foreign Function Interface - Real World OCaml.
That being said, echoing @yawaramin, writing yet another stdlib might not be a good idea. If you really want to, it might also be worthwhile checking out the existing stdlib replacements/enhancements first (containers, core, batteries) to see if there are any idioms you want to adopt.