Add C version for short lists, option for unique ends