#include <stdio.h>

#define is_unsigned(n) ((n) >= 0 && ((n)-(n)-1) >= 0)

#define TclGetUInt1AtPtr(p) \
    ((unsigned int) *(p))

#define TclGetInt4AtPtr(p)                                              \
    (((int) (TclGetUInt1AtPtr(p) << 24)) |				\
		     (*((p)+1) << 16) |				\
		     (*((p)+2) <<  8) |				\
		     (*((p)+3)))

int
main (void) {
        // Baseline
        printf("12 -> U:%d\n", is_unsigned(12));
        printf("12U -> U:%d\n", is_unsigned(12U));
        printf("-12 -> U:%d\n", is_unsigned(-12));

        unsigned char * pc = (unsigned char*)main;

        unsigned char bytes[] = {0xFF,0xFF,0xFD,0xBC};
        printf("int(bytes): %d U:%d\n", TclGetInt4AtPtr(bytes),
               is_unsigned(TclGetInt4AtPtr(bytes)));

        printf("ptr: %p + int(bytes) -> %p (diff:%lld)\n",
               pc, pc + TclGetInt4AtPtr(bytes),
               (long long) ((pc + TclGetInt4AtPtr(bytes)) - pc));

        return 0;
}
