#include <stdio.h>
#include <stdlib.h>
unsigned int rand32bit(void){
unsigned int i, x, r = 0;
if (x & 0x4000) {
r += 0;
}
else {
r += 1;
}
for (i = 0; i<31; i++){
if (x & 0x4000) {
r <<= 1; r += 0;
}
else {
r <<= 1; r += 1;
}
}
return r;
}
int main()
{
int i;
printf("RAND_MAX=%x\n", RAND_MAX
); for (i = 0; i < 10; i++) {
rand32bit();
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnVuc2lnbmVkIGludCByYW5kMzJiaXQodm9pZCl7CgoJdW5zaWduZWQgaW50IGksIHgsIHIgPSAwOwoKCXggPSByYW5kKCk7CglpZiAoeCAmIDB4NDAwMCkgewoJCXIgKz0gMDsKCQlwdXRjaGFyKCcwJyk7Cgl9CgllbHNlIHsKCQlyICs9IDE7CgkJcHV0Y2hhcignMScpOwoJfQoKCWZvciAoaSA9IDA7IGk8MzE7IGkrKyl7CgkJeCA9IHJhbmQoKTsKCQlpZiAoeCAmIDB4NDAwMCkgewoJCQlyIDw8PSAxOyByICs9IDA7CgkJCXB1dGNoYXIoJzAnKTsKCQl9CgkJZWxzZSB7CgkJCXIgPDw9IDE7IHIgKz0gMTsKCQkJcHV0Y2hhcignMScpOwoJCX0KCX0KCglwdXRjaGFyKCdcbicpOwoJcmV0dXJuIHI7Cn0KCmludCBtYWluKCkKewoJaW50IGk7CglwcmludGYoIlJBTkRfTUFYPSV4XG4iLCBSQU5EX01BWCk7Cglmb3IgKGkgPSAwOyBpIDwgMTA7IGkrKykgewoJCXJhbmQzMmJpdCgpOwoJfQoJcmV0dXJuIDA7Cn0K