moved c_lib code into R_package