#include <stdio.h>
#include <memory.h>
void printb(unsigned int x);
int bitcount(unsigned x);
int bitcount2(unsigned x);
int main(void){
int i;
unsigned int x = 0xFF30;
printb(x);
return 0;
}
int bitcount(unsigned x){
int b;
for(b = 0; x != 0; x >>= 1)
if(x&1)
b++;
return b;
}
int bitcount2(unsigned x){
int b = 0;
while(x > 0)
if(x &= (x-1))
b++;
return b;
}
void printb(unsigned int x){
int i;
int mask = 0x1;
for(i = 15; i >= 0; i--){
printf("%d", (x
>> i
) & mask
); }
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtZW1vcnkuaD4KCnZvaWQgcHJpbnRiKHVuc2lnbmVkIGludCB4KTsKaW50IGJpdGNvdW50KHVuc2lnbmVkIHgpOwppbnQgYml0Y291bnQyKHVuc2lnbmVkIHgpOwoKCmludCBtYWluKHZvaWQpewoJaW50IGk7Cgl1bnNpZ25lZCBpbnQgeCA9IDB4RkYzMDsKCQoJcHJpbnRiKHgpOwoJcHJpbnRmKCIlZFxuIiwgYml0Y291bnQoeCkpOwoJcHJpbnRmKCIlZFxuIiwgYml0Y291bnQyKHgpKTsKCQoJCiAJcmV0dXJuIDA7Cn0KCmludCBiaXRjb3VudCh1bnNpZ25lZCB4KXsKCWludCBiOwoJCglmb3IoYiA9IDA7IHggIT0gMDsgeCA+Pj0gMSkKCQlpZih4JjEpCgkJCWIrKzsKCXJldHVybiBiOwp9CgppbnQgYml0Y291bnQyKHVuc2lnbmVkIHgpewoJaW50IGIgPSAwOwoJCgl3aGlsZSh4ID4gMCkKCQlpZih4ICY9ICh4LTEpKQoJCQliKys7CglyZXR1cm4gYjsKfQoKdm9pZCBwcmludGIodW5zaWduZWQgaW50IHgpewoJaW50IGk7CglpbnQgbWFzayA9IDB4MTsKCQoJZm9yKGkgPSAxNTsgaSA+PSAwOyBpLS0pewoJCXByaW50ZigiJWQiLCAoeCA+PiBpKSAmIG1hc2spOwoJCWlmKChpICUgNCkgPT0gMCkgcHV0Y2hhcignICcpOwoJfQoJcHV0Y2hhcignXG4nKTsKfQ==