rewriteCLikeFileToASimplerFile

Dear all,
I am interested in the rewriting function of Clang.
Now I have a simple C-like syntax.The syntax and semantic is detailed.
The question is how to translate the inputting C file into the new file written by C-like language?

Here is an example:
The inputting program is
///////////////////////////////////
int main(){
int i;
i = 0;
if(i > 1){
i ++;
}
else{
i --;
}
return 0;
}
//////////////////////////////////

The outputting program is wished to be
//////////////////////////////////////////
int main(){
int i;
i = 0;
if(i > 1){
i ++;
}
endif;
else{
i --;
}
endelse;
return 0;
}

///////////////////////////////////////////

/cheers.
/by Redder.