#include <stdio.h>

/* Number of bits in inttype_MAX, or in any (1<<b)-1 where 0 <= b < 3E+10 */
#define IMAX_BITS(m) ((m) /((m)%0x3fffffffL+1) /0x3fffffffL %0x3fffffffL *30 \
                  + (m)%0x3fffffffL /((m)%31+1)/31%31*5 + 4-12/((m)%31+3))
#define UNSIGNED_BIT IMAX_BITS((unsigned)-1)

int main(void) {
	unsigned x = 4711;
	
	unsigned mask = 1U << (UNSIGNED_BIT - 1); // most significant bit
	while (mask && !(x&mask)) mask >>= 1; // ignore leading zeros
	if (mask) // still bits to process ?
	{
		for (; mask; mask >>= 1)
		{
			// output '0' or '1'
			// !! normalizes the result of the bitwise and to 0 or 1
			putchar('0' + !!(x&mask));
		}
	}
	else putchar('0'); // if only 0 bits found, output 0
	
	putchar('\n');
	
	return 0;
}
