public static Int64 Decode(DecodeBuffer input) { // This was difficult to get right, translated from https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/wire_format_lite.h var n = UnsignedVlq.Decode(input); return((Int64)((n >> 1) ^ (~(n & 1) + 1))); }