added asm and gmp optimizations