Yes, a C compiler will do something special for some library functions. However for my library, I can use higher level abstractions to implement my algorithms etc. and benefit from the optimisations well.

And yes, one can write somewhat generic C code, which can be in lines as well, but that's not as high level abstracted code (i.e. not type safe, but around void pointers)