#include <stdio.h>
#include <memory.h>
void printbits(unsigned int x);
unsigned rightrot(unsigned x, int n);
int main(void){
int i;
unsigned int x = 0xFF30;
printbits(x);
for(i = 1; i < 16; i++)
printbits(rightrot(x, i));
return 0;
}
unsigned rightrot(unsigned x, int n){
while(n > 0){
if(x&1){
x = x >> 1;
x |= (1 << 16);
}else x = x >> 1;
n--;
}
return x;
}
void printbits(unsigned int x){
int i;
int mask = 0x1;
for(i = 15; i >= 0; i--){
printf("%d", (x >> i) & mask);
if((i % 4) == 0) putchar(' ');
}
putchar('\n');
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtZW1vcnkuaD4KCnZvaWQgcHJpbnRiaXRzKHVuc2lnbmVkIGludCB4KTsKdW5zaWduZWQgcmlnaHRyb3QodW5zaWduZWQgeCwgaW50IG4pOwoKCmludCBtYWluKHZvaWQpewoJaW50IGk7Cgl1bnNpZ25lZCBpbnQgeCA9IDB4RkYzMDsKCQoJcHJpbnRiaXRzKHgpOwoJCglmb3IoaSA9IDE7IGkgPCAxNjsgaSsrKQoJCXByaW50Yml0cyhyaWdodHJvdCh4LCBpKSk7CgkKIAlyZXR1cm4gMDsKfQoKdW5zaWduZWQgcmlnaHRyb3QodW5zaWduZWQgeCwgaW50IG4pewoJd2hpbGUobiA+IDApewoJCWlmKHgmMSl7CgkJCXggPSB4ID4+IDE7CgkJCXggfD0gKDEgPDwgMTYpOwoJCX1lbHNlIHggPSB4ID4+IDE7CgkJbi0tOwoJfQoJcmV0dXJuIHg7Cn0KCnZvaWQgcHJpbnRiaXRzKHVuc2lnbmVkIGludCB4KXsKCWludCBpOwoJaW50IG1hc2sgPSAweDE7CgkKCWZvcihpID0gMTU7IGkgPj0gMDsgaS0tKXsKCQlwcmludGYoIiVkIiwgKHggPj4gaSkgJiBtYXNrKTsKCQlpZigoaSAlIDQpID09IDApIHB1dGNoYXIoJyAnKTsKCX0KCXB1dGNoYXIoJ1xuJyk7Cn0=