Rewrite in pure C