`if (!(r))`. Right now, ` CHECK_NOT_OOB(end > end_max && end > 0)` gets evaluated as `if (!end > end_max && ...)` which presumably is not what you want.

Also, the line before it is too long (81 characters.) The backslash should preferably go on the 79th column.