The interior loop of netcat_flag_count() (which you've
flagged with "FIXME") is wrong. The (or a list "a")
correct version is:
ret += (c & 1);
c >>= 1;
Now, the *real* problem is that you're using 'char'
'unsigned char'. I suspect that on a machine that makes
'char' equivalent to 'signed char', your version did
something that worked, at least most of the time.
However, on AIX, which uses 'char == unsigned char'
(completely withing the C standard), 'c >> 7' just
throws away the lower 7 bits.