mv out threads code to c-code