using System;
public class Test
{
public static void Main()
{
uint v = 0x4dead; // 18-th bit is the highest one set
uint r;
uint shift;
r = (uint)((v > 0xFFFF) ? 1 : 0) << 4; v >>= (int)r;
shift = (uint)((v > 0xFF ) ? 1 : 0) << 3; v >>= (int)shift; r |= shift;
shift = (uint)((v > 0xF ) ? 1 : 0) << 2; v >>= (int)shift; r |= shift;
shift = (uint)((v > 0x3 ) ? 1 : 0) << 1; v >>= (int)shift; r |= shift;
r |= (v >> 1);
Console.WriteLine(r);
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoKdWludCB2ID0gMHg0ZGVhZDsgLy8gMTgtdGggYml0IGlzIHRoZSBoaWdoZXN0IG9uZSBzZXQKdWludCByOwp1aW50IHNoaWZ0OwoKciA9ICAgICAodWludCkoKHYgPiAweEZGRkYpID8gMSA6IDApIDw8IDQ7IHYgPj49IChpbnQpcjsKc2hpZnQgPSAodWludCkoKHYgPiAweEZGICApID8gMSA6IDApIDw8IDM7IHYgPj49IChpbnQpc2hpZnQ7IHIgfD0gc2hpZnQ7CnNoaWZ0ID0gKHVpbnQpKCh2ID4gMHhGICAgKSA/IDEgOiAwKSA8PCAyOyB2ID4+PSAoaW50KXNoaWZ0OyByIHw9IHNoaWZ0OwpzaGlmdCA9ICh1aW50KSgodiA+IDB4MyAgICkgPyAxIDogMCkgPDwgMTsgdiA+Pj0gKGludClzaGlmdDsgciB8PSBzaGlmdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHIgfD0gKHYgPj4gMSk7CgpDb25zb2xlLldyaXRlTGluZShyKTsKCgoJfQp9