Reimplement insert trigger in C