And some code is absolutely unnecessary. Look at the yes command. GNU version is optimized to death for no reason at all[1].
OpenBSD's version is as simple as it gets[2].
[1]: https://github.com/coreutils/coreutils/blob/master/src/yes.c [2]: https://github.com/openbsd/src/blob/master/usr.bin/yes/yes.c
Just as another point of comparison, FreeBSD's version seems somewhere in-between. It also enables a Capsicum sandbox before processing any data, akin to what the OpenBSD version does with pledge.
[1] https://github.com/freebsd/freebsd-src/blob/main/usr.bin/yes...
The others and I, working on GNU coreutils, frequently use 'yes' to generate a bunch of garbage input for testing programs. It is nice that it can do so quickly.