def rrx(a, b, carry):
    """Rotate right with extend (Use carry as a 33rd bit)
    Returns (result, carry)
    """
    b &= 31
    a = (a & 0xffffffff) | ((carry & 1) << 32)
    a = (a >> b) | (a << (33 - b))
    return (a & 0xffffffff, 1 & (a >> 32))