// Rules ensures c's ChainID is not nil.
340870
func (c *ChainConfig) Rules(num *big.Int) Rules {
	chainID := c.ChainID
	if chainID == nil {
		chainID = new(big.Int)
	}
	return Rules{
		ChainID:          new(big.Int).Set(chainID),
		IsHomestead:      c.IsHomestead(num),
		IsEIP150:         c.IsEIP150(num),
		IsEIP155:         c.IsEIP155(num),
		IsEIP158:         c.IsEIP158(num),
		IsByzantium:      c.IsByzantium(num),
		IsConstantinople: c.IsConstantinople(num),
		IsPetersburg:     c.IsPetersburg(num),
	}
}
1306750
func (s *DataRetrievalPolicy) SetRules(v []*DataRetrievalRule) *DataRetrievalPolicy {
	s.Rules = v
	return s
}
1130077
func doGetAccessRules(targetURL string) (r map[string]string, err *probe.Error) {
	clnt, err := newClient(targetURL)
	if err != nil {
		return map[string]string{}, err.Trace(targetURL)
	}
	return clnt.GetAccessRules()
}
892216
func WalkRules(x interface{}, f func(*Rule) bool) {
	vis := &GenericVisitor{func(x interface{}) bool {
		if r, ok := x.(*Rule); ok {
			return f(r)
		}
		return false
	}}
	Walk(vis, x)
}
919379
func (r Rules) Rule(tag language.Tag) *Rule {
	t := tag
	for {
		if rule := r[t]; rule != nil {
			return rule
		}
		t = t.Parent()
		if t.IsRoot() {
			break
		}
	}
	base, _ := tag.Base()
	baseTag, _ := language.Parse(base.String())
	return r[baseTag]
}
848556
func (rules *Rules) FindRule(path string) (*Rule, error) {
	if path == "" {
		return rules.Rule, nil
	}

	sep := "/"
	segments := strings.Split(path, sep)

	currentRule := rules.Rule
	for _, segment := range segments {
		found := false
		for _, rule := range currentRule.Children {
			if strings.ToLower(rule.Name) == segment {
				currentRule = rule
				found = true
			}
		}
		if found != true {
			return nil, ErrorMap[ErrRuleNotFound]
		}
	}

	return currentRule, nil
}
534057
func (fw *firewallRulesState) AllRules() ([]*FirewallRule, error) {
	coll, closer := fw.st.db().GetCollection(firewallRulesC)
	defer closer()

	var docs []firewallRulesDoc
	err := coll.Find(nil).All(&docs)
	if err != nil {
		return nil, errors.Trace(err)
	}
	result := make([]*FirewallRule, len(docs))
	for i, doc := range docs {
		result[i] = doc.toRule()
	}
	return result, nil
}
416762
func (fcr *FileCustomRule) GetRules() (qrs *rules.Rules, version int64, err error) {
	return fcr.currentRuleSet.Copy(), fcr.currentRuleSetTimestamp, nil
}
677137
func (flf *fileLedgerFactory) ChainIDs() []string {
	chainIDs, err := flf.blkstorageProvider.List()
	if err != nil {
		logger.Panic(err)
	}
	return chainIDs
}
437620
func (r *Rules) GetRules() (rv []Rule) {
	for p := unsafe.Pointer(r.cptr.rules_list_head); (*C.YR_RULE)(p).g_flags&C.RULE_GFLAGS_NULL == 0; p = unsafe.Pointer(uintptr(p) + unsafe.Sizeof(*r.cptr.rules_list_head)) {
		rv = append(rv, Rule{(*C.YR_RULE)(p)})
	}
	return
}
59183
func (r *ChainRouter) BareRule(mo, pattern string, fx RHandler) {
	methods := GetMethods(mo)
	patt := reggy.CreateClassic(pattern)
	cr := &ChainRouta{ClassicMatchMux: patt, Handler: BuildMatchesMethod(methods, fx)}
	r.wg.Lock()
	defer r.wg.Unlock()
	r.paths = append(r.paths, cr)
}
758950
func (runner *runner) EnsureRule(position RulePosition, table Table, chain Chain, args ...string) (bool, error) {
	fullArgs := makeFullArgs(table, chain, args...)

	runner.mu.Lock()
	defer runner.mu.Unlock()

	exists, err := runner.checkRule(table, chain, args...)
	if err != nil {
		return false, err
	}
	if exists {
		return true, nil
	}
	out, err := runner.run(operation(position), fullArgs)
	if err != nil {
		return false, fmt.Errorf("error appending rule: %v: %s", err, out)
	}
	return false, nil
}
1164790
func (rule *Rule) Copy() *Rule {
	cpy := *rule
	cpy.Head = rule.Head.Copy()
	cpy.Body = rule.Body.Copy()
	if cpy.Else != nil {
		cpy.Else = rule.Else.Copy()
	}
	return &cpy
}
157594
func (i *Instance) cgroupChainRules(cfg *ACLInfo) [][]string {

	// Rules for older distros (eg RH 6.9/Ubuntu 14.04), due to absence of
	// cgroup match modules, source ports are used  to trap outgoing traffic.
	if i.isLegacyKernel && (cfg.PUType == common.HostNetworkPU || cfg.PUType == common.HostPU) {
		return i.legacyPuChainRules(
			cfg.ContextID,
			cfg.AppChain,
			cfg.NetChain,
			cfg.CgroupMark,
			cfg.TCPPorts,
			cfg.UDPPorts,
			cfg.ProxyPort,
			cfg.ProxySetName,
			cfg.AppSection,
			cfg.NetSection,
			cfg.PUType,
		)
	}

	tmpl := template.Must(template.New(cgroupCaptureTemplate).Funcs(template.FuncMap{
		"isUDPPorts": func() bool {
			return cfg.UDPPorts != "0"
		},
		"isTCPPorts": func() bool {
			return cfg.TCPPorts != "0"
		},
		"isHostPU": func() bool {
			return cfg.AppSection == HostModeOutput && cfg.NetSection == HostModeInput
		},
	}).Parse(cgroupCaptureTemplate))

	rules, err := extractRulesFromTemplate(tmpl, cfg)
	if err != nil {
		zap.L().Warn("unable to extract rules", zap.Error(err))
	}

	return append(rules, i.proxyRules(cfg)...)
}
160080
func (b *BatchProvider) Delete(table, chain string, rulespec ...string) error {

	b.Lock()
	defer b.Unlock()

	if _, ok := b.batchTables[table]; !ok {
		return b.ipt.Delete(table, chain, rulespec...)
	}

	if _, ok := b.rules[table]; !ok {
		return nil
	}
	if _, ok := b.rules[table][chain]; !ok {
		return nil
	}

	rule := strings.Join(rulespec, " ")

	for index, r := range b.rules[table][chain] {
		if rule == r {
			switch index {
			case 0:
				if len(b.rules[table][chain]) == 1 {
					b.rules[table][chain] = []string{}
				} else {
					b.rules[table][chain] = b.rules[table][chain][1:]
				}
			case len(b.rules[table][chain]) - 1:
				b.rules[table][chain] = b.rules[table][chain][:index]
			default:
				b.rules[table][chain] = append(b.rules[table][chain][:index], b.rules[table][chain][index+1:]...)
			}
			break
		}
	}

	return nil
}
323933
func DefaultRules() Rules {
	rules := Rules{}

	addPluralRules(rules, []string{"bm", "bo", "dz", "id", "ig", "ii", "in", "ja", "jbo", "jv", "jw", "kde", "kea", "km", "ko", "lkt", "lo", "ms", "my", "nqo", "root", "sah", "ses", "sg", "th", "to", "vi", "wo", "yo", "yue", "zh"}, &Rule{
		PluralForms: newPluralFormSet(Other),
		PluralFormFunc: func(ops *Operands) Form {
			return Other
		},
	})
	addPluralRules(rules, []string{"am", "as", "bn", "fa", "gu", "hi", "kn", "mr", "zu"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 0 or n = 1
			if intEqualsAny(ops.I, 0) ||
				ops.NEqualsAny(1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"ff", "fr", "hy", "kab"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 0,1
			if intEqualsAny(ops.I, 0, 1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"pt"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 0..1
			if intInRange(ops.I, 0, 1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"ast", "ca", "de", "en", "et", "fi", "fy", "gl", "ia", "io", "it", "ji", "nl", "pt_PT", "sc", "scn", "sv", "sw", "ur", "yi"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 1 and v = 0
			if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"si"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 0,1 or i = 0 and f = 1
			if ops.NEqualsAny(0, 1) ||
				intEqualsAny(ops.I, 0) && intEqualsAny(ops.F, 1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"ak", "bh", "guw", "ln", "mg", "nso", "pa", "ti", "wa"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 0..1
			if ops.NInRange(0, 1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"tzm"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 0..1 or n = 11..99
			if ops.NInRange(0, 1) ||
				ops.NInRange(11, 99) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"af", "asa", "az", "bem", "bez", "bg", "brx", "ce", "cgg", "chr", "ckb", "dv", "ee", "el", "eo", "es", "eu", "fo", "fur", "gsw", "ha", "haw", "hu", "jgo", "jmc", "ka", "kaj", "kcg", "kk", "kkj", "kl", "ks", "ksb", "ku", "ky", "lb", "lg", "mas", "mgo", "ml", "mn", "nah", "nb", "nd", "ne", "nn", "nnh", "no", "nr", "ny", "nyn", "om", "or", "os", "pap", "ps", "rm", "rof", "rwk", "saq", "sd", "sdh", "seh", "sn", "so", "sq", "ss", "ssy", "st", "syr", "ta", "te", "teo", "tig", "tk", "tn", "tr", "ts", "ug", "uz", "ve", "vo", "vun", "wae", "xh", "xog"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 1
			if ops.NEqualsAny(1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"da"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 1 or t != 0 and i = 0,1
			if ops.NEqualsAny(1) ||
				!intEqualsAny(ops.T, 0) && intEqualsAny(ops.I, 0, 1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"is"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// t = 0 and i % 10 = 1 and i % 100 != 11 or t != 0
			if intEqualsAny(ops.T, 0) && intEqualsAny(ops.I%10, 1) && !intEqualsAny(ops.I%100, 11) ||
				!intEqualsAny(ops.T, 0) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"mk"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) && !intEqualsAny(ops.I%100, 11) ||
				intEqualsAny(ops.F%10, 1) && !intEqualsAny(ops.F%100, 11) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"fil", "tl"}, &Rule{
		PluralForms: newPluralFormSet(One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I, 1, 2, 3) ||
				intEqualsAny(ops.V, 0) && !intEqualsAny(ops.I%10, 4, 6, 9) ||
				!intEqualsAny(ops.V, 0) && !intEqualsAny(ops.F%10, 4, 6, 9) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"lv", "prg"}, &Rule{
		PluralForms: newPluralFormSet(Zero, One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
			if ops.NModEqualsAny(10, 0) ||
				ops.NModInRange(100, 11, 19) ||
				intEqualsAny(ops.V, 2) && intInRange(ops.F%100, 11, 19) {
				return Zero
			}
			// n % 10 = 1 and n % 100 != 11 or v = 2 and f % 10 = 1 and f % 100 != 11 or v != 2 and f % 10 = 1
			if ops.NModEqualsAny(10, 1) && !ops.NModEqualsAny(100, 11) ||
				intEqualsAny(ops.V, 2) && intEqualsAny(ops.F%10, 1) && !intEqualsAny(ops.F%100, 11) ||
				!intEqualsAny(ops.V, 2) && intEqualsAny(ops.F%10, 1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"lag"}, &Rule{
		PluralForms: newPluralFormSet(Zero, One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 0
			if ops.NEqualsAny(0) {
				return Zero
			}
			// i = 0,1 and n != 0
			if intEqualsAny(ops.I, 0, 1) && !ops.NEqualsAny(0) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"ksh"}, &Rule{
		PluralForms: newPluralFormSet(Zero, One, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 0
			if ops.NEqualsAny(0) {
				return Zero
			}
			// n = 1
			if ops.NEqualsAny(1) {
				return One
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"iu", "kw", "naq", "se", "sma", "smi", "smj", "smn", "sms"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 1
			if ops.NEqualsAny(1) {
				return One
			}
			// n = 2
			if ops.NEqualsAny(2) {
				return Two
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"shi"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 0 or n = 1
			if intEqualsAny(ops.I, 0) ||
				ops.NEqualsAny(1) {
				return One
			}
			// n = 2..10
			if ops.NInRange(2, 10) {
				return Few
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"mo", "ro"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 1 and v = 0
			if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
				return One
			}
			// v != 0 or n = 0 or n != 1 and n % 100 = 1..19
			if !intEqualsAny(ops.V, 0) ||
				ops.NEqualsAny(0) ||
				!ops.NEqualsAny(1) && ops.NModInRange(100, 1, 19) {
				return Few
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"bs", "hr", "sh", "sr"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) && !intEqualsAny(ops.I%100, 11) ||
				intEqualsAny(ops.F%10, 1) && !intEqualsAny(ops.F%100, 11) {
				return One
			}
			// v = 0 and i % 10 = 2..4 and i % 100 != 12..14 or f % 10 = 2..4 and f % 100 != 12..14
			if intEqualsAny(ops.V, 0) && intInRange(ops.I%10, 2, 4) && !intInRange(ops.I%100, 12, 14) ||
				intInRange(ops.F%10, 2, 4) && !intInRange(ops.F%100, 12, 14) {
				return Few
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"gd"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Few, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 1,11
			if ops.NEqualsAny(1, 11) {
				return One
			}
			// n = 2,12
			if ops.NEqualsAny(2, 12) {
				return Two
			}
			// n = 3..10,13..19
			if ops.NInRange(3, 10) || ops.NInRange(13, 19) {
				return Few
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"sl"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Few, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// v = 0 and i % 100 = 1
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%100, 1) {
				return One
			}
			// v = 0 and i % 100 = 2
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%100, 2) {
				return Two
			}
			// v = 0 and i % 100 = 3..4 or v != 0
			if intEqualsAny(ops.V, 0) && intInRange(ops.I%100, 3, 4) ||
				!intEqualsAny(ops.V, 0) {
				return Few
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"dsb", "hsb"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Few, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// v = 0 and i % 100 = 1 or f % 100 = 1
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%100, 1) ||
				intEqualsAny(ops.F%100, 1) {
				return One
			}
			// v = 0 and i % 100 = 2 or f % 100 = 2
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%100, 2) ||
				intEqualsAny(ops.F%100, 2) {
				return Two
			}
			// v = 0 and i % 100 = 3..4 or f % 100 = 3..4
			if intEqualsAny(ops.V, 0) && intInRange(ops.I%100, 3, 4) ||
				intInRange(ops.F%100, 3, 4) {
				return Few
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"he", "iw"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 1 and v = 0
			if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
				return One
			}
			// i = 2 and v = 0
			if intEqualsAny(ops.I, 2) && intEqualsAny(ops.V, 0) {
				return Two
			}
			// v = 0 and n != 0..10 and n % 10 = 0
			if intEqualsAny(ops.V, 0) && !ops.NInRange(0, 10) && ops.NModEqualsAny(10, 0) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"cs", "sk"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 1 and v = 0
			if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
				return One
			}
			// i = 2..4 and v = 0
			if intInRange(ops.I, 2, 4) && intEqualsAny(ops.V, 0) {
				return Few
			}
			// v != 0
			if !intEqualsAny(ops.V, 0) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"pl"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// i = 1 and v = 0
			if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
				return One
			}
			// v = 0 and i % 10 = 2..4 and i % 100 != 12..14
			if intEqualsAny(ops.V, 0) && intInRange(ops.I%10, 2, 4) && !intInRange(ops.I%100, 12, 14) {
				return Few
			}
			// v = 0 and i != 1 and i % 10 = 0..1 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 12..14
			if intEqualsAny(ops.V, 0) && !intEqualsAny(ops.I, 1) && intInRange(ops.I%10, 0, 1) ||
				intEqualsAny(ops.V, 0) && intInRange(ops.I%10, 5, 9) ||
				intEqualsAny(ops.V, 0) && intInRange(ops.I%100, 12, 14) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"be"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n % 10 = 1 and n % 100 != 11
			if ops.NModEqualsAny(10, 1) && !ops.NModEqualsAny(100, 11) {
				return One
			}
			// n % 10 = 2..4 and n % 100 != 12..14
			if ops.NModInRange(10, 2, 4) && !ops.NModInRange(100, 12, 14) {
				return Few
			}
			// n % 10 = 0 or n % 10 = 5..9 or n % 100 = 11..14
			if ops.NModEqualsAny(10, 0) ||
				ops.NModInRange(10, 5, 9) ||
				ops.NModInRange(100, 11, 14) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"lt"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n % 10 = 1 and n % 100 != 11..19
			if ops.NModEqualsAny(10, 1) && !ops.NModInRange(100, 11, 19) {
				return One
			}
			// n % 10 = 2..9 and n % 100 != 11..19
			if ops.NModInRange(10, 2, 9) && !ops.NModInRange(100, 11, 19) {
				return Few
			}
			// f != 0
			if !intEqualsAny(ops.F, 0) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"mt"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 1
			if ops.NEqualsAny(1) {
				return One
			}
			// n = 0 or n % 100 = 2..10
			if ops.NEqualsAny(0) ||
				ops.NModInRange(100, 2, 10) {
				return Few
			}
			// n % 100 = 11..19
			if ops.NModInRange(100, 11, 19) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"ru", "uk"}, &Rule{
		PluralForms: newPluralFormSet(One, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// v = 0 and i % 10 = 1 and i % 100 != 11
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) && !intEqualsAny(ops.I%100, 11) {
				return One
			}
			// v = 0 and i % 10 = 2..4 and i % 100 != 12..14
			if intEqualsAny(ops.V, 0) && intInRange(ops.I%10, 2, 4) && !intInRange(ops.I%100, 12, 14) {
				return Few
			}
			// v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 0) ||
				intEqualsAny(ops.V, 0) && intInRange(ops.I%10, 5, 9) ||
				intEqualsAny(ops.V, 0) && intInRange(ops.I%100, 11, 14) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"br"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n % 10 = 1 and n % 100 != 11,71,91
			if ops.NModEqualsAny(10, 1) && !ops.NModEqualsAny(100, 11, 71, 91) {
				return One
			}
			// n % 10 = 2 and n % 100 != 12,72,92
			if ops.NModEqualsAny(10, 2) && !ops.NModEqualsAny(100, 12, 72, 92) {
				return Two
			}
			// n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99
			if (ops.NModInRange(10, 3, 4) || ops.NModEqualsAny(10, 9)) && !(ops.NModInRange(100, 10, 19) || ops.NModInRange(100, 70, 79) || ops.NModInRange(100, 90, 99)) {
				return Few
			}
			// n != 0 and n % 1000000 = 0
			if !ops.NEqualsAny(0) && ops.NModEqualsAny(1000000, 0) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"ga"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 1
			if ops.NEqualsAny(1) {
				return One
			}
			// n = 2
			if ops.NEqualsAny(2) {
				return Two
			}
			// n = 3..6
			if ops.NInRange(3, 6) {
				return Few
			}
			// n = 7..10
			if ops.NInRange(7, 10) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"gv"}, &Rule{
		PluralForms: newPluralFormSet(One, Two, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// v = 0 and i % 10 = 1
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) {
				return One
			}
			// v = 0 and i % 10 = 2
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 2) {
				return Two
			}
			// v = 0 and i % 100 = 0,20,40,60,80
			if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%100, 0, 20, 40, 60, 80) {
				return Few
			}
			// v != 0
			if !intEqualsAny(ops.V, 0) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"ar", "ars"}, &Rule{
		PluralForms: newPluralFormSet(Zero, One, Two, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 0
			if ops.NEqualsAny(0) {
				return Zero
			}
			// n = 1
			if ops.NEqualsAny(1) {
				return One
			}
			// n = 2
			if ops.NEqualsAny(2) {
				return Two
			}
			// n % 100 = 3..10
			if ops.NModInRange(100, 3, 10) {
				return Few
			}
			// n % 100 = 11..99
			if ops.NModInRange(100, 11, 99) {
				return Many
			}
			return Other
		},
	})
	addPluralRules(rules, []string{"cy"}, &Rule{
		PluralForms: newPluralFormSet(Zero, One, Two, Few, Many, Other),
		PluralFormFunc: func(ops *Operands) Form {
			// n = 0
			if ops.NEqualsAny(0) {
				return Zero
			}
			// n = 1
			if ops.NEqualsAny(1) {
				return One
			}
			// n = 2
			if ops.NEqualsAny(2) {
				return Two
			}
			// n = 3
			if ops.NEqualsAny(3) {
				return Few
			}
			// n = 6
			if ops.NEqualsAny(6) {
				return Many
			}
			return Other
		},
	})

	return rules
}
1041348
func ReadRules(rd io.Reader) (*Rules, error) {
	r := &Rules{rules: &rules{}}
	id := callbackData.Put(rd)
	defer callbackData.Delete(id)

	stream := C.YR_STREAM{
		read: C.YR_STREAM_READ_FUNC(C.streamRead),
		// The complaint from go vet about possible misuse of
		// unsafe.Pointer is wrong, see above.
		user_data: id,
	}
	if err := newError(C.yr_rules_load_stream(&stream,
		&(r.rules.cptr))); err != nil {
		return nil, err
	}
	runtime.SetFinalizer(r.rules, (*rules).finalize)
	return r, nil
}