Converted Xsetup script to C