What are the S_* constants? How did you get them loaded?
> if ($size < 200 && (($mode & (S_IFREG | S_IFLNK)) == S_IFREG) )
A DeMorgan equivalent should be:
if ($size < 200 && $mode & S_IFREG )
But that doesn't seem to be saying what you claim that it's doing.