/*
Returns true if the automaton has any states that cannot be reached
from the initial state or cannot reach an accept state.
Cost is O(numTransitions+numStates).
*/
16120
func hasDeadStates(a *Automaton) bool {
	liveStates := liveStates(a)
	numLive := liveStates.Cardinality()
	numStates := a.numStates()
	assert2(numLive <= int64(numStates), "numLive=%v numStates=%v %v", numLive, numStates, liveStates)
	return numLive < int64(numStates)
}
453802
func isStateCancellable(state string) bool {
	cancellablePhases := []string{
		string(buildv1.BuildPhaseNew),
		string(buildv1.BuildPhasePending),
		string(buildv1.BuildPhaseRunning),
	}
	for _, p := range cancellablePhases {
		if state == strings.ToLower(p) {
			return true
		}
	}
	return false
}
353272
func (a *Automaton) sortedTransitions() [][]*Transition {
	numStates := a.numStates()
	transitions := make([][]*Transition, numStates)
	for s := 0; s < numStates; s++ {
		numTransitions := a.numTransitions(s)
		transitions[s] = make([]*Transition, numTransitions)
		for t := 0; t < numTransitions; t++ {
			transition := newTransition()
			a.transition(s, t, transition)
			transitions[s][t] = transition
		}
	}
	return transitions
}
26196
func newRunAutomaton(a *Automaton, maxInterval int, tablesize bool) *RunAutomaton {
	a = determinize(a)
	size := a.numStates()
	if size < 1 {
		size = 1
	}
	points := a.startPoints()
	nPoints := len(points)
	ans := &RunAutomaton{
		maxInterval: maxInterval,
		automaton:   a,
		points:      points,
		initial:     0,
		size:        size,
		accept:      make([]bool, size),
		transitions: make([]int, size*nPoints),
	}
	for i, _ := range ans.transitions {
		ans.transitions[i] = -1
	}
	for n := 0; n < size; n++ {
		ans.accept[n] = a.IsAccept(n)
		for c, point := range ans.points {
			dest := a.step(n, point)
			assert(dest == -1 || dest < size)
			ans.transitions[n*nPoints+c] = dest
		}
	}
	// Set alphabet table for optimal run performance.
	if tablesize {
		panic("not implemented yet")
	}
	return ans
}
1206041
func (c *ConnReq) State() ConnState {
	c.stateMtx.RLock()
	state := c.state
	c.stateMtx.RUnlock()
	return state
}
908815
func ValidateState(state string) error {
	if !okayStates.Contains(state) {
		supported := okayStates.Values()
		sort.Strings(supported)
		states := strings.Join(supported, `", "`)
		msg := fmt.Sprintf(`status %q not supported; expected one of ["%s"]`, state, states)
		return errors.NewNotValid(nil, msg)
	}
	return nil
}
1285000
func (f *Machine) Allows(b uint8) bool {
	return f.isLegal(f.state, b)
}
493284
func (s *server) State() string {
	s.mutex.RLock()
	defer s.mutex.RUnlock()
	return s.state
}
308493
func (wd *WaitDelay) AdjacentStates() []MachineState {
	if wd.next == nil {
		return nil
	}
	return []MachineState{wd.next}
}
906263
func AutomatonContains(a Automaton, k []byte) bool {
	i := 0
	curr := a.Start()
	for a.CanMatch(curr) && i < len(k) {
		curr = a.Accept(curr, k[i])
		if curr == noneAddr {
			break
		}
		i++
	}
	if i != len(k) {
		return false
	}
	return a.IsMatch(curr)
}
573912
func State(typeOfState int) string {
	if typeOfState == Small {
		return randomFrom(jsonData.StatesSmall)
	}
	return randomFrom(jsonData.States)
}
746470
func (c *Client) State() imap.ConnState {
	c.locker.Lock()
	state := c.state
	c.locker.Unlock()
	return state
}
155826
func (a *AAgent) AllMachineStates() (states []MachineState, err error) {
	states = []MachineState{}

	a.Lock()
	defer a.Unlock()

	for _, m := range a.machines {
		state := MachineState{
			Name:                 m.machine.Name(),
			Version:              m.machine.Version(),
			Path:                 m.machine.Directory(),
			ID:                   m.machine.InstanceID(),
			State:                m.machine.State(),
			StartTimeUTC:         m.machine.StartTime().Unix(),
			AvailableTransitions: m.machine.AvailableTransitions(),
		}

		states = append(states, state)
	}

	return states, nil
}
1063647
func (a *Automaton) createState() int {
	state := len(a.states) / 2
	a.states = append(a.states, -1, 0)
	return state
}
58017
func (a *Automaton) nextTransition(t *Transition) {
	// make sure there is still a transition left
	assert((t.transitionUpto + 3 - a.states[2*t.source]) <= 3*a.states[2*t.source+1])
	t.dest = a.transitions[t.transitionUpto]
	t.min = a.transitions[t.transitionUpto+1]
	t.max = a.transitions[t.transitionUpto+2]
	t.transitionUpto += 3
}
965275
func (L *State) CheckStack(extra int) bool {
	return C.lua_checkstack(L.s, C.int(extra)) != 0
}
1372184
func (a *Automaton) startPoints() []int {
	pointset := make(map[int]bool)
	pointset[MIN_CODE_POINT] = true
	// fmt.Println("getStartPoints")
	for s := 0; s < len(a.states); s += 2 {
		trans := a.states[s]
		limit := trans + 3*a.states[s+1]
		// fmt.Printf("  state=%v trans=%v limit=%v\n", s/2, trans, limit)
		for trans < limit {
			min, max := a.transitions[trans+1], a.transitions[trans+2]
			// fmt.Printf("    min=%v\n", min)
			pointset[min] = true
			if max < unicode.MaxRune {
				pointset[max+1] = true
			}
			trans += 3
		}
	}
	var points []int
	for m, _ := range pointset {
		points = append(points, m)
	}
	sort.Ints(points)
	return points
}