// deriveClonePoint returns a clone of the src parameter.
4177
func deriveClonePoint(src *Point) *Point {
	if src == nil {
		return nil
	}
	dst := new(Point)
	deriveDeepCopy_6(dst, src)
	return dst
}
1371316
func (c *ContivClient) EndpointInspect(endpointID string) (*EndpointInspect, error) {
	// build key and URL
	keyStr := endpointID
	url := c.baseURL + "/api/v1/inspect/endpoints/" + keyStr + "/"

	// http get the object
	var obj EndpointInspect
	err := c.httpGet(url, &obj)
	if err != nil {
		log.Debugf("Error getting endpoint %+v. Err: %v", keyStr, err)
		return nil, err
	}

	return &obj, nil
}
1022864
func (s *ScopedKeyManager) deriveKeyFromPath(ns walletdb.ReadBucket, account, branch,
	index uint32, private bool) (*hdkeychain.ExtendedKey, error) {

	// Look up the account key information.
	acctInfo, err := s.loadAccountInfo(ns, account)
	if err != nil {
		return nil, err
	}

	return s.deriveKey(acctInfo, branch, index, private)
}
1357813
func (env *sessionEnviron) DeriveAvailabilityZones(ctx context.ProviderCallContext, args environs.StartInstanceParams) ([]string, error) {
	if args.Placement != "" {
		// args.Placement will always be a zone name or empty.
		placement, err := env.parsePlacement(ctx, args.Placement)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if placement.Name() != "" {
			return []string{placement.Name()}, nil
		}
	}
	return nil, nil
}
631270
func (ci CellID) rawPoint() r3.Vector {
	face, si, ti := ci.faceSiTi()
	return faceUVToXYZ(face, stToUV((0.5/maxSize)*float64(si)), stToUV((0.5/maxSize)*float64(ti)))
}
853898
func deriveCompare(this, that []*MyStruct) int {
	if this == nil {
		if that == nil {
			return 0
		}
		return -1
	}
	if that == nil {
		return 1
	}
	if len(this) != len(that) {
		if len(this) < len(that) {
			return -1
		}
		return 1
	}
	for i := 0; i < len(this); i++ {
		if c := deriveCompare_(this[i], that[i]); c != 0 {
			return c
		}
	}
	return 0
}
64309
func deriveJoin(in <-chan (<-chan int)) <-chan int {
	out := make(chan int)
	go func() {
		wait := sync.WaitGroup{}
		for c := range in {
			wait.Add(1)
			res := c
			go func() {
				for r := range res {
					out <- r
				}
				wait.Done()
			}()
		}
		wait.Wait()
		close(out)
	}()
	return out
}
758692
func (h *vaultHook) deriveVaultToken() (token string, exit bool) {
	attempts := 0
	for {
		tokens, err := h.client.DeriveToken(h.alloc, []string{h.taskName})
		if err == nil {
			return tokens[h.taskName], false
		}

		// Check if this is a server side error
		if structs.IsServerSide(err) {
			h.logger.Error("failed to derive Vault token", "error", err, "server_side", true)
			h.lifecycle.Kill(h.ctx,
				structs.NewTaskEvent(structs.TaskKilling).
					SetFailsTask().
					SetDisplayMessage(fmt.Sprintf("Vault: server failed to derive vault token: %v", err)))
			return "", true
		}

		// Check if we can't recover from the error
		if !structs.IsRecoverable(err) {
			h.logger.Error("failed to derive Vault token", "error", err, "recoverable", false)
			h.lifecycle.Kill(h.ctx,
				structs.NewTaskEvent(structs.TaskKilling).
					SetFailsTask().
					SetDisplayMessage(fmt.Sprintf("Vault: failed to derive vault token: %v", err)))
			return "", true
		}

		// Handle the retry case
		backoff := (1 << (2 * uint64(attempts))) * vaultBackoffBaseline
		if backoff > vaultBackoffLimit {
			backoff = vaultBackoffLimit
		}
		h.logger.Error("failed to derive Vault token", "error", err, "recoverable", true, "backoff", backoff)

		attempts++

		// Wait till retrying
		select {
		case <-h.ctx.Done():
			return "", true
		case <-time.After(backoff):
		}
	}
}
1139102
func DeriveLoginKeypair(ctx context.Context, secret []byte, salt *base64url.Value) (
	*LoginKeypair, error) {

	key, err := deriveHash(ctx, secret, salt.String())
	if err != nil {
		return nil, err
	}

	err = ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}

	r := bytes.NewReader(key[224:]) // Use last 32 bytes of 256 to derive key
	pubKey, privKey, err := ed25519.GenerateKey(r)
	if err != nil {
		return nil, err
	}

	err = ctxutil.ErrIfDone(ctx)
	if err != nil {
		return nil, err
	}

	keypair := &LoginKeypair{
		public:  pubKey,
		private: privKey,
		salt:    salt,
	}
	return keypair, nil
}
912915
func deriveToError(err error, f func(vers string) (major int, minor int, ok bool)) func(vers string) (int, int, error) {
	return func(vers string) (int, int, error) {
		out0, out1, success := f(vers)
		if success {
			return out0, out1, nil
		}
		return out0, out1, err
	}
}
388258
func deriveCloneMultiPolygon(src *MultiPolygon) *MultiPolygon {
	if src == nil {
		return nil
	}
	dst := new(MultiPolygon)
	deriveDeepCopy_5(dst, src)
	return dst
}
989812
func deriveCloneLineString(src *LineString) *LineString {
	if src == nil {
		return nil
	}
	dst := new(LineString)
	deriveDeepCopy_2(dst, src)
	return dst
}
1217776
func deriveCompose(f0 func(string) (*http.Response, error), f1 func(*http.Response) ([]byte, error), f2 func([]byte) (*user, error), f3 func(*user) (*newUser, error), f4 func(interface{}) ([]byte, error), f5 func([]byte) (*http.Response, error)) func(string) (*http.Response, error) {
	return func(v_0_0 string) (*http.Response, error) {
		v_1_0, err0 := f0(v_0_0)
		if err0 != nil {
			return nil, err0
		}
		v_2_0, err1 := f1(v_1_0)
		if err1 != nil {
			return nil, err1
		}
		v_3_0, err2 := f2(v_2_0)
		if err2 != nil {
			return nil, err2
		}
		v_4_0, err3 := f3(v_3_0)
		if err3 != nil {
			return nil, err3
		}
		v_5_0, err4 := f4(v_4_0)
		if err4 != nil {
			return nil, err4
		}
		v_6_0, err5 := f5(v_5_0)
		if err5 != nil {
			return nil, err5
		}
		return v_6_0, nil
	}
}
240809
func NewCloner() *Cloner {
	c := &Cloner{
		deepCopyFuncs:          map[reflect.Type]reflect.Value{},
		generatedDeepCopyFuncs: map[reflect.Type]reflect.Value{},
	}
	if err := c.RegisterDeepCopyFunc(byteSliceDeepCopy); err != nil {
		// If one of the deep-copy functions is malformed, detect it immediately.
		panic(err)
	}
	return c
}
1155906
func NormalizePoint(x []float64) {

	var sum float64
	for i := range x {
		sum += x[i] * x[i]
	}

	mag := math.Sqrt(sum)

	for i := range x {
		if math.IsInf(x[i]/mag, 0) || math.IsNaN(x[i]/mag) {
			// fallback to zero when dividing by 0
			x[i] = 0
			continue
		}

		x[i] /= mag
	}
}
1218871
func deriveUnion(this, that []*Person) []*Person {
	for i, v := range that {
		if !deriveContains(this, v) {
			this = append(this, that[i])
		}
	}
	return this
}
24066
func derivePipeline(f func(lines []string) <-chan string, g func(line string) <-chan int) func([]string) <-chan int {
	return func(a []string) <-chan int {
		b := f(a)
		return deriveJoin(deriveFmap(g, b))
	}
}