def xor_vec(in_val, mask_vec):
    """
        Returns the XOR of bits from the result of masking bin_vec with the
        mask vector mask_vec.
    """
    and_val = in_val & mask_vec
    return (bin(and_val).count('1') % 2)