some pieces of c code, see wiki for more infomation