simplified asap and alap C implementation