// which is one of "src", "dest", or "thirdleg"
773804
func (c *syncCmd) storageFromParam(which storageType, val string) (blobserver.Storage, error) {
	var httpClient *http.Client

	if val == "" {
		switch which {
		case storageThird:
			return nil, nil
		case storageSource:
			discl := c.discoClient()
			src, err := discl.BlobRoot()
			if err != nil {
				return nil, fmt.Errorf("Failed to discover source server's blob path: %v", err)
			}
			val = src
			httpClient = discl.HTTPClient()
		}
		if val == "" {
			return nil, cmdmain.UsageError("No --" + string(which) + " flag value specified")
		}
	}
	if which == storageDest && val == "stdout" {
		return nil, nil
	}
	if looksLikePath(val) {
		disk, err := localdisk.New(val)
		if err != nil {
			return nil, fmt.Errorf("Interpreted --%v=%q as a local disk path, but got error: %v", which, val, err)
		}
		c.oneIsDisk = true
		return disk, nil
	}
	cl, err := client.New(client.OptionServer(val), client.OptionInsecure(c.insecureTLS))
	if err != nil {
		return nil, fmt.Errorf("creating client for %q: %v", val, err)
	}
	if httpClient != nil {
		cl.SetHTTPClient(httpClient)
	}
	if err := cl.SetupAuth(); err != nil {
		return nil, fmt.Errorf("could not setup auth for connecting to %v: %v", val, err)
	}
	cl.Verbose = *cmdmain.FlagVerbose
	cl.Logger = log.New(cmdmain.Stderr, "", log.LstdFlags)
	serverKeyID, err := cl.ServerKeyID()
	if err != nil && err != client.ErrNoSigning {
		fmt.Fprintf(cmdmain.Stderr, "Failed to discover keyId for server %v: %v", val, err)
	} else {
		if which == storageSource {
			c.srcKeyID = serverKeyID
		} else if which == storageDest {
			c.destKeyID = serverKeyID
		}
	}
	return cl, nil
}
716710
func (fTr *flagTracker) short(field reflect.StructField, flagName string) (letter string, err error) {
	if short, ok := field.Tag.Lookup("short"); ok {
		if short == "" {
			return "", nil // explicitly set to no shorthand
		}
		runeVal, width := utf8.DecodeRuneInString(short)
		if runeVal == utf8.RuneError || width > 1 {
			return "", fmt.Errorf("'%s' is not a valid single ascii character.", short)
		}
		if _, ok := fTr.shorts[runeVal]; ok {
			return "", fmt.Errorf("'%s' has already been used.", short)
		}
		fTr.shorts[runeVal] = struct{}{}
		return short, nil
	}
	for _, chr := range flagName {
		if _, ok := fTr.shorts[chr]; ok {
			continue
		}
		// TODO if the lowercase version of first letter is taken, try upper case and vice versa
		if unicode.IsLetter(chr) {
			fTr.shorts[chr] = struct{}{}
			return string(chr), nil
		}
	}
	return "", nil // no shorthand char available, but that's ok
}
66706
func (d *Context) PcompileLstringFilename(flags uint, src string, lenght int) error {
	__src__ := C.CString(src)
	result := int(C._duk_pcompile_lstring_filename(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(lenght)))
	C.free(unsafe.Pointer(__src__))
	return d.castStringToError(result)
}
148665
func (d *Decoder) stereo3() {
	// The standard is fairly vague on this step, and the reference
	// implementation is garbage. So this function may or may not be correct,
	// but at least it's correct enough to pass the compliance test.

	if d.mode != ModeJointStereo || d.modeExtension == 0 {
		return
	}

	ms, intensity := d.modeExtension&2 != 0, d.modeExtension&1 != 0

	for gr := 0; gr < 2; gr++ {
		longLow, longHigh := 0, 22
		shortLow, shortHigh := 0, 13
		if d.blockType[gr][1] == 2 {
			if d.mixedBlockFlag[gr][1] == 1 {
				longHigh = 8
				shortLow = 3
			} else {
				longLow = 22
			}
		} else {
			shortLow = 13
		}

		zeroPartStartS := [3]int{shortLow, shortLow, shortLow}
		nonzeroShort := false
		for window := 0; window < 3; window++ {
		sfbShort:
			for sfb := shortHigh - 1; sfb >= shortLow; sfb-- {
				low := scfBandsS[d.samplingFreq][sfb]
				length := scfBandsS[d.samplingFreq][sfb+1] - low
				winLow := 3*low + window*length
				winHigh := winLow + length
				for f := winLow; f < winHigh; f++ {
					if d.huffmanData[gr][1][f] != 0 {
						zeroPartStartS[window] = sfb + 1
						nonzeroShort = true
						break sfbShort
					}
				}
			}
		}

		zeroPartStartL := longLow
		if nonzeroShort {
			zeroPartStartL = longHigh
		} else {
		sfbLong:
			for sfb := longHigh - 1; sfb >= longLow; sfb-- {
				low := scfBandsL[d.samplingFreq][sfb]
				high := scfBandsL[d.samplingFreq][sfb+1]
				for f := low; f < high; f++ {
					if d.huffmanData[gr][1][f] != 0 {
						zeroPartStartL = sfb + 1
						break sfbLong
					}
				}
			}
		}

		for window := 0; window < 3; window++ {
			for sfb := shortLow; sfb < shortHigh; sfb++ {
				low := scfBandsS[d.samplingFreq][sfb]
				length := scfBandsS[d.samplingFreq][sfb+1] - low
				winLow := 3*low + window*length
				winHigh := winLow + length
				isPos := sfb
				if isPos == 12 {
					isPos = 11
				}
				isPos = d.scalefacS[gr][1][isPos][window]
				if intensity && sfb >= zeroPartStartS[window] && isPos < 7 {
					L := intensityFactors[isPos]
					R := 1 - L
					for f := winLow; f < winHigh; f++ {
						d.huffmanData[gr][1][f] = R * d.huffmanData[gr][0][f]
						d.huffmanData[gr][0][f] *= L
					}
				} else if ms {
					for f := winLow; f < winHigh; f++ {
						M, S := d.huffmanData[gr][0][f], d.huffmanData[gr][1][f]
						d.huffmanData[gr][0][f] = (M + S) / sqrt2
						d.huffmanData[gr][1][f] = (M - S) / sqrt2
					}
				}
			}
		}

		for sfb := longLow; sfb < longHigh; sfb++ {
			low := scfBandsL[d.samplingFreq][sfb]
			high := scfBandsL[d.samplingFreq][sfb+1]
			isPos := sfb
			if isPos == 21 {
				isPos = 20
			}
			isPos = d.scalefacL[gr][1][isPos]
			if intensity && sfb >= zeroPartStartL && isPos < 7 {
				L := intensityFactors[isPos]
				R := 1 - L
				for f := low; f < high; f++ {
					d.huffmanData[gr][1][f] = R * d.huffmanData[gr][0][f]
					d.huffmanData[gr][0][f] *= L
				}
			} else if ms {
				for f := low; f < high; f++ {
					M, S := d.huffmanData[gr][0][f], d.huffmanData[gr][1][f]
					d.huffmanData[gr][0][f] = (M + S) / sqrt2
					d.huffmanData[gr][1][f] = (M - S) / sqrt2
				}
			}
		}
	}
}
1179568
func doIsStdLib(path string) bool {
	i := strings.Index(path, "/")
	if i < 0 {
		i = len(path)
	}

	return !strings.Contains(path[:i], ".")
}
309345
func lowerFirst(s string) string {
	if s == "" {
		return ""
	}
	r, n := utf8.DecodeRuneInString(s)
	return string(unicode.ToLower(r)) + s[n:]
}
534885
func (f *simpleField) decl(g *Generator, mc *msgCtx) {
	g.P(f.comment, Annotate(mc.message.file, f.fullPath, f.goName), "\t", f.goType, "\t`", f.tags, "`", f.deprecated)
}
365179
func Uint32Slice(src []uint32) []*uint32 {
	dst := make([]*uint32, len(src))
	for i := 0; i < len(src); i++ {
		dst[i] = &(src[i])
	}
	return dst
}
1073740
func main() {
	cmd.RootCmd.DisableAutoGenTag = true
	identity := func(s string) string {
		return fmt.Sprintf(`{{< relref "docs/%s" >}}`, s)
	}
	emptyStr := func(s string) string { return "" }
	doc.GenMarkdownTreeCustom(cmd.RootCmd, "./", emptyStr, identity)
}
257167
func KeyMatch3Func(args ...interface{}) (interface{}, error) {
	name1 := args[0].(string)
	name2 := args[1].(string)

	return bool(KeyMatch3(name1, name2)), nil
}
705706
func main() {
	if len(os.Args) != 2 {
		stderr("usage: %s [main|sidekick|preStart|postStop]", os.Args[0])
		os.Exit(64)
	}
	mode := os.Args[1]
	var res results
	switch strings.ToLower(mode) {
	case "main":
		res = validateMain()
	case "sidekick":
		res = validateSidekick()
	case "prestart":
		res = validatePrestart()
	case "poststop":
		res = validatePoststop()
	default:
		stderr("unrecognized mode: %s", mode)
		os.Exit(64)
	}
	if len(res) == 0 {
		fmt.Printf("%s OK\n", mode)
		os.Exit(0)
	}
	fmt.Printf("%s FAIL\n", mode)
	for _, err := range res {
		fmt.Fprintln(os.Stderr, "==>", err)
	}
	os.Exit(1)
}
958790
func (g *Globber) getEsc(chunk string) (r rune, nchunk string, err error) {
	if len(chunk) == 0 || chunk[0] == '-' || chunk[0] == g.config.RangeEnd {
		err = ErrBadPattern
		return
	}
	if chunk[0] == '\\' {
		chunk = chunk[1:]
		if len(chunk) == 0 {
			err = ErrBadPattern
			return
		}
	}
	r, n := utf8.DecodeRuneInString(chunk)
	if r == utf8.RuneError && n == 1 {
		err = ErrBadPattern
	}
	nchunk = chunk[n:]
	if len(nchunk) == 0 {
		err = ErrBadPattern
	}
	return
}
1244421
func threeSigFigs(v float64) string {
	if v >= 1e11 {
		return fmt.Sprintf("%dB", int(math.Round(v/1e9)))
	} else if v >= 1e10 {
		return fmt.Sprintf("%.1fB", math.Round(v/1e8)/10)
	} else if v >= 1e9 {
		return fmt.Sprintf("%.2fB", math.Round(v/1e7)/1e2)
	} else if v >= 1e8 {
		return fmt.Sprintf("%dM", int(math.Round(v/1e6)))
	} else if v >= 1e7 {
		return fmt.Sprintf("%.1fM", math.Round(v/1e5)/10)
	} else if v >= 1e6 {
		return fmt.Sprintf("%.2fM", math.Round(v/1e4)/1e2)
	} else if v >= 1e5 {
		return fmt.Sprintf("%dk", int(math.Round(v/1e3)))
	} else if v >= 1e4 {
		return fmt.Sprintf("%.1fk", math.Round(v/100)/10)
	} else if v >= 1e3 {
		return fmt.Sprintf("%.2fk", math.Round(v/10)/1e2)
	} else if v >= 100 {
		return fmt.Sprintf("%d", int(math.Round(v)))
	} else if v >= 10 {
		return fmt.Sprintf("%.1f", math.Round(v*10)/10)
	} else if v >= 1 {
		return fmt.Sprintf("%.2f", math.Round(v*1e2)/1e2)
	} else if v >= 0.1 {
		return fmt.Sprintf("%.3f", math.Round(v*1e3)/1e3)
	} else if v >= 0.01 {
		return fmt.Sprintf("%.4f", math.Round(v*1e4)/1e4)
	} else if v >= 0.001 {
		return fmt.Sprintf("%.5f", math.Round(v*1e5)/1e5)
	} else if v >= 0.0001 {
		return fmt.Sprintf("%.6f", math.Round(v*1e6)/1e6)
	} else if v >= 0.00001 {
		return fmt.Sprintf("%.7f", math.Round(v*1e7)/1e7)
	} else if v == 0 {
		return "0"
	}
	return fmt.Sprintf("%.8f", math.Round(v*1e8)/1e8)
}
932911
func main() {
	args := map[string]string{}
	gp := geopattern.URIimage(args)
	fmt.Println(gp)
}
1114437
func TypeStrDelay(str string, delay int) {
	cstr := C.CString(str)
	cdelay := C.size_t(delay)
	C.type_string_delayed(cstr, cdelay)

	C.free(unsafe.Pointer(cstr))
}
93743
func fill(src, dest interface{}) (err error) {
	defer func() {
		if r := recover(); r != nil {
			d := reflect.TypeOf(dest)
			s := reflect.TypeOf(src)
			err = fmt.Errorf("the fill destination should be a pointer to a `%s`, but you used a `%s`", s, d)
		}
	}()

	reflect.ValueOf(dest).Elem().Set(reflect.ValueOf(src))

	return err
}
498909
func CopyExact(dest interface{}, src interface{}) {
	dV := reflect.ValueOf(dest)
	sV := reflect.ValueOf(src)
	if dV.Kind() == reflect.Ptr {
		dV = dV.Elem()
	}
	if dV.Kind() == reflect.Array && !dV.CanAddr() {
		panic(fmt.Sprintf("dest not addressable: %T", dest))
	}
	if sV.Kind() == reflect.Ptr {
		sV = sV.Elem()
	}
	if sV.Kind() == reflect.String {
		sV = sV.Convert(reflect.SliceOf(dV.Type().Elem()))
	}
	if !sV.IsValid() {
		panic("invalid source, probably nil")
	}
	if dV.Len() != sV.Len() {
		panic(fmt.Sprintf("dest len (%d) != src len (%d)", dV.Len(), sV.Len()))
	}
	if dV.Len() != reflect.Copy(dV, sV) {
		panic("dammit")
	}
}