Returns min(max(x, min_val), max_val), Results are undefined if min_val > max_val.
See Implementation
Returns min(max(x, min_val), max_val), Results are undefined if min_val > max_val.