def gray_to_binary(gray_value):
    """Convert a Gray-code value to binary.

    :param gray_value: Gray-code value
    :type gray_value: int
    :returns: Value in regular encoding.
    :rtype: int
    """
    mask = gray_value >> 1
    while mask != 0:
        gray_value = gray_value ^ mask
        mask = mask >> 1
    return int(gray_value)