// RoundUpToGiB rounds up given quantity upto chunks of GiB
763717
func RoundUpToGiB(size resource.Quantity) int64 {
	requestBytes := size.Value()
	return roundUpSize(requestBytes, GiB)
}
71453
func logBaseTwo(x uint64) uint64 {
	if x == 0 {
		return 0
	}
	ct := uint64(0)
	for x != 0 {
		x >>= 1
		ct += 1
	}
	return ct - 1
}
344852
func writeBlob(data []byte, buf *bytes.Buffer) (int, error) {
	// Add the size of the blob
	dlen := int32(len(data))
	if err := binary.Write(buf, binary.BigEndian, dlen); err != nil {
		return 0, err
	}

	// Write the data
	if _, err := buf.Write(data); err != nil {
		return 0, nil
	}

	// Add padding bytes if necessary
	numPadBytes := padBytesNeeded(len(data))
	if numPadBytes > 0 {
		padBytes := make([]byte, numPadBytes)
		n, err := buf.Write(padBytes)
		if err != nil {
			return 0, err
		}
		numPadBytes = n
	}

	return 4 + len(data) + numPadBytes, nil
}
866244
func (api *ProductDiskAPI) FilterMultiBy(key string, value interface{}) *ProductDiskAPI {
	api.filterBy(key, value, true)
	return api
}
1026654
func EncodeGob(obj map[interface{}]interface{}) ([]byte, error) {
	for _, v := range obj {
		gob.Register(v)
	}
	buf := bytes.NewBuffer(nil)
	enc := gob.NewEncoder(buf)
	err := enc.Encode(obj)
	if err != nil {
		return []byte(""), err
	}
	return buf.Bytes(), nil
}
718879
func RoundUpToMiB(size resource.Quantity) int64 {
	requestBytes := size.Value()
	return roundUpSize(requestBytes, MiB)
}
1155218
func BuildBasicFilter(block *wire.MsgBlock, prevOutScripts [][]byte) (*gcs.Filter, error) {
	blockHash := block.BlockHash()
	b := WithKeyHash(&blockHash)

	// If the filter had an issue with the specified key, then we force it
	// to bubble up here by calling the Key() function.
	_, err := b.Key()
	if err != nil {
		return nil, err
	}

	// In order to build a basic filter, we'll range over the entire block,
	// adding each whole script itself.
	for _, tx := range block.Transactions {
		// For each output in a transaction, we'll add each of the
		// individual data pushes within the script.
		for _, txOut := range tx.TxOut {
			if len(txOut.PkScript) == 0 {
				continue
			}

			// In order to allow the filters to later be committed
			// to within an OP_RETURN output, we ignore all
			// OP_RETURNs to avoid a circular dependency.
			if txOut.PkScript[0] == txscript.OP_RETURN {
				continue
			}

			b.AddEntry(txOut.PkScript)
		}
	}

	// In the second pass, we'll also add all the prevOutScripts
	// individually as elements.
	for _, prevScript := range prevOutScripts {
		if len(prevScript) == 0 {
			continue
		}

		b.AddEntry(prevScript)
	}

	return b.Build()
}
899394
func (pdbg *Pdbg) Pdbgf(format string, args ...interface{}) string {
	return pdbg.pdbgfw(format, pdbg.Err(), args...)
}
523780
func (window *Window) SetGrab(grabbed bool) {
	C.SDL_SetWindowGrab(window.cptr(), C.SDL_bool((Btoi(grabbed))))
}
146663
func CopyBitPB(bitmap C.MMBitmapRef) bool {
	abool := C.bitmap_copy_to_pboard(bitmap)
	gbool := bool(abool)

	return gbool
}
647230
func (gi Instance) RootDiskGB() uint64 {
	if gi.spec == nil {
		return 0
	}
	attached := gi.RootDisk()
	return uint64(attached.InitializeParams.DiskSizeGb)
}
635592
func (v qrCodeVersion) numBitsToPadToCodeword(numDataBits int) int {
	if numDataBits == v.numDataBits() {
		return 0
	}

	return (8 - numDataBits%8) % 8
}
238479
func RoundUpToMiBInt(size resource.Quantity) (int, error) {
	requestBytes := size.Value()
	return roundUpSizeInt(requestBytes, MiB)
}
586088
func (b geoBox) round() (lat, lng float64) {
	x := maxDecimalPower(b.maxLat - b.minLat)
	lat = math.Ceil(b.minLat/x) * x
	x = maxDecimalPower(b.maxLng - b.minLng)
	lng = math.Ceil(b.minLng/x) * x
	return
}
1047486
func GuidToBigInt(guid string) (*big.Int, error) {
	if !ValidGuidHex(guid) {
		return nil, fmt.Errorf("Not a valid Guid: %v\n", guid)
	}
	bi := big.NewInt(0)
	bi.SetString(rxHyphen.ReplaceAllString(guid, ""), 16)
	return bi, nil
}
521498
func (l *Logger) Dbgf(format string, va ...interface{}) error {
	return l.logMsg(nil, LEVEL_DBG, format, va...)
}
774492
func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error) {
	// Convert to btcec input format with 'recovery id' v at the beginning.
	btcsig := make([]byte, 65)
	btcsig[0] = sig[64] + 27
	copy(btcsig[1:], sig)

	pub, _, err := btcec.RecoverCompact(btcec.S256(), btcsig, hash)
	return (*ecdsa.PublicKey)(pub), err
}