performance improvement: using read()/write() instead of scanf()/fprintf(), fixing pointer bug, making compatible with GNU CC