I think this line is borked -- I think the NA proxy is not doing the correct thing here. E.g. it's seeing `1 == NA` and returning `TRUE` there.

Could work around this by checking `input[i] == NA_INTEGER`, but this should be fixed.