} while (*nport != low && *nport != high);  step = -step; *nport = cut; do { *nport += step;
} for (*nport = cut - 1; *nport >= low; --(*nport)) {
pf_get_sport(sa_family_t af, u_int8_t proto, struct pf_pool *rpool,    struct pf_addr *saddr, struct pf_addr *daddr, u_int16_t dport,    struct pf_addr *naddr, u_int16_t *nport, u_int16_t low, u_int16_t high){	struct pf_tree_node	key;	struct pf_addr		init_addr;	int			step;	u_int16_t		cut;	bzero(&init_addr, sizeof(init_addr));	if (pf_map_addr(af, rpool, saddr, naddr, &init_addr))		return (1);	do {		key.af = af;		key.proto = proto;		PF_ACPY(&key.addr[0], daddr, key.af);		PF_ACPY(&key.addr[1], naddr, key.af);		key.port[0] = dport;		/*		 * port search; start random, step;		 * similar 2 portloop in in_pcbbind		 */		if (!(proto == IPPROTO_TCP || proto == IPPROTO_UDP)) {			key.port[1] = 0;			if (pf_find_state(&tree_ext_gwy, &key) == NULL)				return (0);		} else if (rpool->opts & PF_POOL_STATICPORT) {			key.port[1] = *nport;			if (pf_find_state(&tree_ext_gwy, &key) == NULL)				return (0);		} else if (low == 0 && high == 0) {			key.port[1] = *nport;			if (pf_find_state(&tree_ext_gwy, &key) == NULL) {				NTOHS(*nport);				return (0);			}		} else if (low == high) {			key.port[1] = htons(low);			if (pf_find_state(&tree_ext_gwy, &key) == NULL) {				*nport = low;				return (0);			}		} else {			if (low < high) {				step = 1;				cut = arc4random() % (1 + high - low) + low;			} else {				step = -1;				cut = arc4random() % (1 + low - high) + high;			}			*nport = cut - step;			do {				*nport += step;				key.port[1] = htons(*nport);				if (pf_find_state(&tree_ext_gwy, &key) == NULL)					return (0);			} while (*nport != low && *nport != high);			step = -step;			*nport = cut;			do {				*nport += step;				key.port[1] = htons(*nport);				if (pf_find_state(&tree_ext_gwy, &key) == NULL)					return (0);			} while (*nport != low && *nport != high);		}		switch (rpool->opts & PF_POOL_TYPEMASK) {		case PF_POOL_RANDOM:		case PF_POOL_ROUNDROBIN:			if (pf_map_addr(af, rpool, saddr, naddr, &init_addr))				return (1);			break;		case PF_POOL_NONE:		case PF_POOL_SRCHASH:		case PF_POOL_BITMASK:		default:			return (1);			break;		}	} while (! PF_AEQ(&init_addr, naddr, af) );	return (1);					/* none available */}