modify C sample code to distinguish all code sources and fix errors