// Must be called with f.mut held!
329944
func (f *autoclosedFile) ensureOpen() error {
	if f.fd != nil {
		// File is already open
		return nil
	}

	// We open the file for write only, and create it if it doesn't exist.
	flags := os.O_WRONLY | os.O_CREATE
	if f.opened.IsZero() {
		// This is the first time we are opening the file. We should truncate
		// it to better emulate an os.Create() call.
		flags |= os.O_TRUNC
	} else {
		// The file was already opened once, so we should append to it.
		flags |= os.O_APPEND
	}

	fd, err := os.OpenFile(f.name, flags, 0644)
	if err != nil {
		return err
	}

	f.fd = fd
	f.opened = time.Now()
	return nil
}
306748
func f(r0, r1, r2, r3 *uint32, k0, k1 uint32) {
	k0 ^= *r0
	k1 ^= *r1

	t := sbox4_4404[byte(k0)]
	t ^= sbox3_3033[byte(k0>>8)]
	t ^= sbox2_0222[byte(k0>>16)]
	t ^= sbox1_1110[byte(k0>>24)]
	*r3 ^= (t >> 8) | (t << (32 - 8))

	k0 = t
	k0 ^= sbox1_1110[byte(k1)]
	k0 ^= sbox4_4404[byte(k1>>8)]
	k0 ^= sbox3_3033[byte(k1>>16)]
	k0 ^= sbox2_0222[byte(k1>>24)]

	*r2 ^= k0
	*r3 ^= k0
}
149389
func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string, params ...interface{}) error {
	// Don't crash on a lazy user
	if opts == nil {
		opts = new(CallOpts)
	}
	// Pack the input, call and unpack the results
	input, err := c.abi.Pack(method, params...)
	if err != nil {
		return err
	}
	var (
		msg    = ethereum.CallMsg{From: opts.From, To: &c.address, Data: input}
		ctx    = ensureContext(opts.Context)
		code   []byte
		output []byte
	)
	if opts.Pending {
		pb, ok := c.caller.(PendingContractCaller)
		if !ok {
			return ErrNoPendingState
		}
		output, err = pb.PendingCallContract(ctx, msg)
		if err == nil && len(output) == 0 {
			// Make sure we have a contract to operate on, and bail out otherwise.
			if code, err = pb.PendingCodeAt(ctx, c.address); err != nil {
				return err
			} else if len(code) == 0 {
				return ErrNoCode
			}
		}
	} else {
		output, err = c.caller.CallContract(ctx, msg, opts.BlockNumber)
		if err == nil && len(output) == 0 {
			// Make sure we have a contract to operate on, and bail out otherwise.
			if code, err = c.caller.CodeAt(ctx, c.address, opts.BlockNumber); err != nil {
				return err
			} else if len(code) == 0 {
				return ErrNoCode
			}
		}
	}
	if err != nil {
		return err
	}
	return c.abi.Unpack(result, method, output)
}
383702
func (ctx *Context) SetRequireFunction(f interface{}) int {
	ctx.PushGlobalObject()
	ctx.GetPropString(-1, "Duktape")
	idx := ctx.PushGoFunction(f)
	ctx.PutPropString(-2, "modSearch")
	ctx.Pop()

	return idx
}
1104601
func (s *Statement) CallFunc(f func(*Group)) *Statement {
	g := &Group{
		close:     ")",
		multi:     false,
		name:      "call",
		open:      "(",
		separator: ",",
	}
	f(g)
	*s = append(*s, g)
	return s
}
1029718
func calledFrom() string {
	for i := 2; ; i++ {
		pc, file, line, ok := runtime.Caller(i)
		if !ok {
			return ""
		}
		if !strings.HasSuffix(file, "_test.go") {
			f := runtime.FuncForPC(pc)
			if f != nil && strings.HasPrefix(f.Name(), thisPackage) {
				continue
			}
		}
		return fmt.Sprintf("%s:%d", file, line)
	}
}
260617
func _() {
	var _ Event = (*Absolute)(nil)        // assert *Absolute implements Event
	var _ Event = (*FAbsolute)(nil)       // assert *FAbsolute implements Event
	var _ Event = (*Gauge)(nil)           // assert *Gauge implements Event
	var _ Event = (*FGauge)(nil)          // assert *FGauge implements Event
	var _ Event = (*GaugeDelta)(nil)      // assert *GaugeDelta implements Event
	var _ Event = (*FGaugeDelta)(nil)     // assert *FGaugeDelta implements Event
	var _ Event = (*Increment)(nil)       // assert *Increment implements Event
	var _ Event = (*PrecisionTiming)(nil) // assert *PrecisionTiming implements Event
	var _ Event = (*Timing)(nil)          // assert *Timing implements Event
	var _ Event = (*Total)(nil)           // assert *Total implements Event
}
651064
func (fs *fsImpl) checkInvariants() {
	// INVARIANT: For each k in inodes, k < nextInodeID
	for k, _ := range fs.inodes {
		if !(k < fs.nextInodeID) {
			panic("Unexpectedly large inode ID")
		}
	}
}
700677
func Caller() *Call {
	scope, entry := findScope()
	if scope == nil {
		return nil
	}
	return &Call{
		scope: scope,
		entry: entry,
	}
}
1229452
func (c *Bool) OnValueRemoteUpdate(fn func(bool)) {
	c.OnValueUpdateFromConn(func(conn net.Conn, c *Characteristic, new, old interface{}) {
		fn(new.(bool))
	})
}
837185
func (e *EnsureAttempt) RollForward(c context.Context) (muts []tumble.Mutation, err error) {
	a := model.MakeAttempt(c, e.ID)
	if err = ds.Get(c, a); err != ds.ErrNoSuchEntity {
		return
	}

	if err = ds.Put(c, a); err != nil {
		logging.WithError(err).Errorf(logging.SetField(c, "id", e.ID), "in put")
	}
	muts = append(muts, &ScheduleExecution{e.ID})
	return
}
13474
func (t *TypedFuncs) DecisionFunc(decisionFunc interface{}) DecisionFunc {
	typeCheck(decisionFunc, []string{"*fsm.FSMContext", "*swf.HistoryEvent", t.typeArg()}, []string{"*swf.Decision"})
	return marshalledFunc{reflect.ValueOf(decisionFunc)}.decisionFunc
}
1040665
func golua_callpanicfunction(gostateindex uintptr, id uint) int {
	L1 := getGoState(gostateindex)
	f := L1.registry[id].(LuaGoFunction)
	return f(L1)
}
346032
func (r *Relay) Call(fn string, args ...interface{}) {
	r.exchange.callRelayMethod(r, fn, args...)
}
605901
func callValidate(obj, validateMethod reflect.Value) field.ErrorList {
	args := []reflect.Value{obj}
	ret := validateMethod.Call(args)[0].Interface()

	// This convolution is necessary because nil interfaces won't convert
	// to errors.
	if ret == nil {
		return nil
	}
	return ret.(field.ErrorList)
}
1152843
func (m *Accumulator) PushWithf(fmtstr string, err error, args ...interface{}) {
	if err != nil {
		m.Pushf(fmtstr, append([]interface{}{err}, args...)...)
	}
}
1245784
func (m *Mock) Called(arguments ...interface{}) *MockResult {
	var timeout time.Duration
	defer func() {
		m.mutex.Unlock()
		if timeout > 0 {
			time.Sleep(timeout)
		}
	}()
	m.mutex.Lock()

	pc, _, _, ok := runtime.Caller(1)
	if !ok {
		panic("Could not get the caller information")
	}

	functionPath := runtime.FuncForPC(pc).Name()
	parts := strings.Split(functionPath, ".")
	functionName := parts[len(parts)-1]

	if f := m.find(functionName, arguments...); f != nil {
		// Increase the counter
		f.count++
		f.order = m.order
		m.order++

		if f.call.IsValid() {
			typ := f.call.Type()
			numIn := typ.NumIn()
			numArgs := len(arguments)

			// Assign arguments in order.
			// Not all of them are strictly required.
			values := make([]reflect.Value, numIn)
			for i := 0; i < numIn; i++ {
				if i < numArgs {
					values[i] = reflect.ValueOf(arguments[i])
				} else {
					values[i] = reflect.Zero(typ.In(i))
				}
			}

			if typ.IsVariadic() {
				values = f.call.CallSlice(values)
			} else {
				values = f.call.Call(values)
			}

			f.ReturnValues = []interface{}{}
			for i := range values {
				f.ReturnValues = append(f.ReturnValues, values[i].Interface())
			}
		}

		timeout = f.timeout

		if f.PanicValue != nil {
			panic(f.PanicValue)
		}

		// Return to arguments
		for _, r := range f.ReturnToArguments {
			arg := arguments[r.Argument]
			argTyp := reflect.TypeOf(arg)
			argElem := reflect.ValueOf(arg).Elem()
			typ := reflect.TypeOf(r.Value)
			if typ.Kind() == reflect.Ptr {
				if typ == argTyp {
					// *type vs *type
					argElem.Set(reflect.ValueOf(r.Value).Elem())
				} else {
					// *type vs **type
					argElem.Set(reflect.ValueOf(r.Value))
				}
			} else {
				if typ == argTyp.Elem() {
					// type vs *type
					argElem.Set(reflect.ValueOf(r.Value))
				} else {
					// type vs **type
					value := reflect.New(typ).Elem()
					value.Set(reflect.ValueOf(r.Value))
					argElem.Set(value.Addr())
				}
			}
		}

		return &MockResult{f.ReturnValues}
	}

	var msg string
	if len(arguments) == 0 {
		msg = fmt.Sprintf("Mock call missing for %s()", functionName)
	} else {
		argsStr := pretty.Sprintf("%# v", arguments)
		argsStr = argsStr[15 : len(argsStr)-1]
		msg = fmt.Sprintf("Mock call missing for %s(%s)", functionName, argsStr)
	}
	panic(msg)
}