It seems that replacing the do while loop with

Code:
while( x > 1 )
{
    (x & 1) && ( a += y );
    y <<= 1;
    x >>= 1;
}
I didn't think it would have been so I didn't even bother testing it, however its a fair bit faster.