When using the quil-to-native-quil RPC handler with protoquil: true, the resulting compiled program will have non-"protoquil" parts stripped out of it. This is achieved by app's process-program function. The compile_protoquil C function does not do the same.
One option I can think of is to move the process-program logic into a new "transform" pass in cl-quil where it will be available to quilc's RPC server and C library, rather than duplicating the code into both.