Updated C version to comply more with asm