c/c++ obfuscator

These are a few of basic steps of flattening program structures.

Rewriting while

Rewrite any

 while(E){B;}

like

{
 lab1: if (!E) goto lab3;
 {B;}
 lab2: goto lab1;
 lab3:
 }

replace any ‘continue’ with ‘goto lab1’
replace any ‘break’ with ‘goto lab3’

Rewriting for

Then rewrite all

for(E1;E2;E3){B;}

like

{
 E1;
 lab1: if (!E2) goto lab3;
 {B;}
 lab2: E3; goto lab1;
 lab3:
 }

replace any ‘continue’ with ‘goto lab1’
replace any ‘break’ with ‘goto lab3’

Rewriting if

Then rewrite all

 if(E){B;}

like

if (!E) goto lab2;
 {
 B;
 }
 lab2: