I’d say no. Programming safely requires non-trivial transformation in code and a radical change in style, which afaik cannot be easily done automated.
Do you think that there’s any chance to convert from this to this? It requires understanding of the algorithm and a thorough rewrite. Automated tools can only generate the former one because it must not change C’s crooked semantics.
Nobody has mentioned that Guix is readily available on NixOS right now? Add a line to your config and it’s ready to go. Compatible with everything else.