C code of mission 1