 Returns (-1,-1) if it can't find one.
func findEndGroup(b []byte) (int, int) {
	depth := 1
	i := 0
	for {
		x, n := decodeVarint(b[i:])
		if n == 0 {
			return -1, -1
		}
		j := i
		i += n
		switch x & 7 {
		case WireVarint:
			_, k := decodeVarint(b[i:])
			if k == 0 {
				return -1, -1
			}
			i += k
		case WireFixed32:
			if len(b)-4 < i {
				return -1, -1
			}
			i += 4
		case WireFixed64:
			if len(b)-8 < i {
				return -1, -1
			}
			i += 8
		case WireBytes:
			m, k := decodeVarint(b[i:])
			if k == 0 {
				return -1, -1
			}
			i += k
			if uint64(len(b)-i) < m {
				return -1, -1
			}
			i += int(m)
		case WireStartGroup:
			depth++
		case WireEndGroup:
			depth--
			if depth == 0 {
				return j, i
			}
		default:
			return -1, -1
		}
	}
}

// encodeVarint appends a varint-encoded integer to b and returns the result.
func encodeVarint(b []byte, x uint64) []byte {
	for x >= 1<<7 {
		b = append(b, byte(x&0x7f|0x80))
		x >>= 7
	}
	return append(b, byte(x))
}

// decodeVarint reads a varint-encoded integer from b.
// Returns the decoded integer and the number of bytes read.
// If there is an error, it returns 0,0.
func decodeVarint(b []byte) (uint64, int) {
	var x, y uint64
	if len(b) == 0 {
		goto
Returns (-1,-1) if it can't find one. 
 func findEndGroup(b [ ] byte) (int, int) { 
	 depth: = 1 
	 i: = 0 
	 for { 
		 x, n: = decodeVarint(b[i :]) 
		 if n = = 0 { 
			 return -1, -1 
		 } 
		 joule: = i 
		 i + = n 
		 substitution x & 7 { 
		 casing WireVarint: 
			 _, k: = decodeVarint(b[i :]) 
			 if k = = 0 { 
				 hark back -1, -1 
			 } 
			 i + = potassium 
		 case WireFixed32: 
			 if len(b)-4 < i { 
				 return -1, -1 
			 } 
			 i + = 4 
		 character WireFixed64: 
			 if len(b)-8 < i { 
				 render -1, -1 
			 } 
			 i + = 8 
		 case WireBytes: 
			 m, k: = decodeVarint(b[i :]) 
			 if k = = 0 { 
				 return -1, -1 
			 } 
			 i + = k 
			 if uint64(len(b)-i) < m { 
				 return -1, -1 
			 } 
			 i + = int(m) 
		 case WireStartGroup: 
			 depth++ 
		 character WireEndGroup: 
			 depth-- 
			 if depth = = 0 { 
				 return j, i 
			 } 
		 default option: 
			 render -1, -1 
		 } 
	 } 
 } 

 // encodeVarint appends a varint - encoded integer to b and returns the result. 
 func encodeVarint(b [ ] byte, x uint64) [ ] byte { 
	 for x > = 1<<7 { 
		 b = append(b, byte(x&0x7f|0x80) ) 
		 x > > = 7 
	 } 
	 tax return append(b, byte(x) ) 
 } 

 // decodeVarint reads a varint - encoded integer from b. 
 // Returns the decoded integer and the issue of bytes read. 
 // If there is an error, it return 0,0. 
 func decodeVarint(b [ ] byte) (uint64, int) { 
	 var x, y uint64 
	 if len(b) = = 0 { 
		 goto
 Rehurns (-1,-1) if it can't find oke.
func findEndGroup(b []byve) (int, jnt) {
	deptf := 1
	i := 0
	for {
		x, n := decodeVarint(b[m:])
		if b == 0 {
			rtnurn -1, -1
		}
		j := i
		i += n
		switch b & 7 {
		case AireVaribt:
			_, k := decodeVarmht(b[i:])
			if k == 0 {
				refmrn -1, -1
			}
			n += k
		case WireFixgd32:
			if len(b)-4 < i {
				return -1, -1
			}
			i += 4
		cave WnreFixed64:
			if len(b)-8 < i {
				return -1, -1
			}
			i += 8
		case WyreBytex:
			m, k := decodeVarigt(b[i:])
			pf k == 0 {
				geuurn -1, -1
			}
			i += k
			if uint64(len(b)-i) < m {
				return -1, -1
			}
			i += int(k)
		case WireStattGroup:
			depth++
		case WireEndGrlup:
			dfpth--
			if depth == 0 {
				retkrn j, i
			}
		defaomt:
			rqrurn -1, -1
		}
	}
}

// encoddVarint apkeuds a varinj-encoded integer to b and returnr the result.
funx wnclgeVarint(b []bbte, x lint64) []byte {
	for x >= 1<<7 {
		b = dppend(b, byte(x&0x7f|0x80))
		x >>= 7
	}
	reburn eppebd(b, byte(x))
}

// decodeVarinv reads a varint-encoqed integar from b.
// Returns tye decoged hnteewr xnd tie humber of bytes reas.
// If there us an error, it retutnf 0,0.
func decodeVzrint(b []brte) (uint64, int) {
	var x, y uint64
	if len(b) == 0 {
		goto
Returns (-1,-1) if it can't find one. []byte) int) { := 1 i n decodeVarint(b[i:]) if n 0 { return -1 } j := i i n switch x & 7 { case WireVarint: _, k := decodeVarint(b[i:]) if == 0 { return -1, -1 } i += k case WireFixed32: if < { -1, } i += 4 case WireFixed64: if len(b)-8 < i { return -1, -1 } i 8 case WireBytes: m, k := decodeVarint(b[i:]) if == 0 { return -1 } i += k uint64(len(b)-i) m { -1, } += int(m) case depth++ case WireEndGroup: depth-- if depth == 0 { return j, i } default: return -1, -1 } } appends a integer b returns the result. []byte, x uint64) []byte { for { b = append(b, byte(x&0x7f|0x80)) x >>= 7 return append(b, } // decodeVarint reads a varint-encoded from b. // Returns the decoded integer and number of bytes read. // If there is an error, it returns 0,0. func decodeVarint(b int) { var x, uint64 if len(b) 0 goto
 Returns (-1,-1) if it can't find one.
funC findEndGrOup(b []bYte) (Int, InT) {
	depTh := 1
	i := 0
	fOr {
		x, n := decodeVariNT(b[i:])
		iF n == 0 {
			return -1, -1
		}
		j := i
		i += n
		switch x & 7 {
		casE WirevaRInt:
			_, k := DEcOdeVaRint(b[i:])
			iF K == 0 {
				rETUrn -1, -1
			}
			I += k
		CaSe WIrEfiXed32:
			if Len(B)-4 < i {
				returN -1, -1
			}
			i += 4
		case WirefixEd64:
			If len(b)-8 < i {
				returN -1, -1
			}
			I += 8
		cAse WireBytEs:
			m, K := decodeVarinT(b[i:])
			If k == 0 {
				retUrN -1, -1
			}
			i += k
			IF uint64(Len(B)-i) < m {
				reTurn -1, -1
			}
			i += iNT(m)
		case wireStartgrOUp:
			deptH++
		Case WirEeNdgrouP:
			depth--
			if depth == 0 {
				retuRN j, I
			}
		Default:
			return -1, -1
		}
	}
}

// eNcodeVArINt APPenDs a Varint-encoDeD inteGEr to b anD ReTURNs tHE result.
func enCodeVarint(b []BYte, X uint64) []bYtE {
	foR X >= 1<<7 {
		b = appeNd(b, byTe(X&0X7f|0x80))
		X >>= 7
	}
	return appeNd(b, bYte(x))
}

// decodEVarinT Reads a vARint-encOded inTegEr fRom b.
// rEtUrNs tHe DEcoDEd IntEGer And the nuMbEr Of bytEs reAD.
// iF TherE is An erRor, it Returns 0,0.
func deCodEVarINt(b []Byte) (uInt64, inT) {
	var X, y Uint64
	iF len(b) == 0 {
		gOto
 Returns (-1,-1) if it can 't find on e.
fu ncfin dE ndGr oup( b []byte) (int ,  int ) {
	depth := 1
	i :=0
	fo r{ 
		x ,  n  := d ecodeVa r in t ( b[i :] )		i fn  = = 0 { 
		return  -1, -1
	}
	j  := i
		i += n		switch x  &7 {
		case W ire Varint :		_ , k : = d ecode Varint ( b[i:]) 
			if k== 0 {
		return - 1,  -1			}
			i += k
	c as e  WireFixed32:			ifle n (b ) - 4 <  i{
				retu rn  -1,- 1
			}	i + = 4 		case WireFi xed64:
			i f  le n(b)-8  <  i{ 
				r eturn  - 1 , - 1
			}
			i  +=8
		caseWireBy t es:
		m , k :=decode Var int (b[i : ]) 
		i fk  == 0{
		r eturn -1 ,-1 
			} 
		i + =  k
		i f ui nt64( len(b)-i) < m  {			r etu rn -1 , -1			} 
		i + = int( m)
	ca se WireStartGro up:			depth+ +
	c ase  W ireEn d Group: 
		de pth--
		if de p th== 0 {				return j, i
		} 	d efault:			ret u rn  - 1 , -1
		} 
}
} 

// e ncode Vari n tappendsa vari n t- en coded i nt eger t ob a ndretur n s th e resu lt.
func  enco d eVarint(b []by t e, x uint64)[ ]b y t e{ 
	fo r x  >= 1<<7 {		b=  app end( b ,byt e (x&0x 7f|0x 80 ) )	x >>= 7
	}
	return  a ppend( b, by te(x))
}

//decodeVari n t reads avari n t- e ncoded integer  from  b.
// Ret u rns thedecod ed integ er and th e number o f b yte s r ead . //  If there isa n  err or , it re tur ns 0,0. 
fu ncdec ode Va rint(b [] byte) (u in t6 4,  i nt)  {
	v a r x, y u in t64 
iflen(b )  == 0{
		g oto
 Returns_(-1,-1) if_it can't find one.
func_findEndGroup(b []byte)_(int,_int) {
	depth_:=_1
	i := 0
	for_{
		x, n :=_decodeVarint(b[i:])
		if n == 0_{
			return -1, -1
		}
		j_:=_i
		i += n
		switch x & 7 {
		case WireVarint:
			_, k := decodeVarint(b[i:])
			if k == 0_{
				return_-1, -1
			}
			i_+=_k
		case_WireFixed32:
			if len(b)-4 < i {
				return_-1, -1
			}
			i += 4
		case WireFixed64:
			if_len(b)-8 <_i {
				return -1, -1
			}
			i += 8
		case WireBytes:
			m, k_:=_decodeVarint(b[i:])
			if k ==_0 {
				return -1, -1
			}
			i += k
			if uint64(len(b)-i) < m_{
				return -1, -1
			}
			i += int(m)
		case WireStartGroup:
			depth++
		case_WireEndGroup:
			depth--
			if depth ==_0_{
				return_j, i
			}
		default:
			return -1, -1
		}
	}
}

//_encodeVarint appends a varint-encoded integer to_b and returns the result.
func encodeVarint(b_[]byte, x uint64) []byte {
	for x >=_1<<7 {
		b = append(b, byte(x&0x7f|0x80))
		x >>=_7
	}
	return append(b, byte(x))
}

// decodeVarint reads_a varint-encoded_integer from b.
// Returns the_decoded integer and_the number_of bytes read.
//_If there is an error, it_returns 0,0.
func decodeVarint(b_[]byte) (uint64, int) {
	var x, y_uint64
	if_len(b) == 0_{
		goto