make the code clean and compilable for c. also first compile succeed