		/*    regexec.c
		 */
		
		/*
		 * "One Ring to rule them all, One Ring to find them..."
		 */
		
		/* This file contains functions for executing a regular expression.  See
		 * also regcomp.c which funnily enough, contains functions for compiling
		 * a regular expression.
		 *
		 * This file is also copied at build time to ext/re/re_exec.c, where
		 * it's built with -DPERL_EXT_RE_BUILD -DPERL_EXT_RE_DEBUG -DPERL_EXT.
		 * This causes the main functions to be compiled under new names and with
		 * debugging support added, which makes "use re 'debug'" work.
		 
		 */
		
		/* NOTE: this is derived from Henry Spencer's regexp code, and should not
		 * confused with the original package (see point 3 below).  Thanks, Henry!
		 */
		
		/* Additional note: this code is very heavily munged from Henry's version
		 * in places.  In some spots I've traded clarity for efficiency, so don't
		 * blame Henry for some of the lack of readability.
		 */
		
		/* The names of the functions have been changed from regcomp and
		 * regexec to  pregcomp and pregexec in order to avoid conflicts
		 * with the POSIX routines of the same names.
		*/
		
		#ifdef PERL_EXT_RE_BUILD
		/* need to replace pregcomp et al, so enable that */
		#  ifndef PERL_IN_XSUB_RE
		#    define PERL_IN_XSUB_RE
		#  endif
		/* need access to debugger hooks */
		#  if defined(PERL_EXT_RE_DEBUG) && !defined(DEBUGGING)
		#    define DEBUGGING
		#  endif
		#endif
		
		#ifdef PERL_IN_XSUB_RE
		/* We *really* need to overwrite these symbols: */
		#  define Perl_regexec_flags my_regexec
		#  define Perl_regdump my_regdump
		#  define Perl_regprop my_regprop
		#  define Perl_re_intuit_start my_re_intuit_start
		/* *These* symbols are masked to allow static link. */
		#  define Perl_pregexec my_pregexec
		#  define Perl_reginitcolors my_reginitcolors
		#  define Perl_regclass_swash my_regclass_swash
		
		#  define PERL_NO_GET_CONTEXT
		#endif
		
		/*
		 * pregcomp and pregexec -- regsub and regerror are not used in perl
		 *
		 *	Copyright (c) 1986 by University of Toronto.
		 *	Written by Henry Spencer.  Not derived from licensed software.
		 *
		 *	Permission is granted to anyone to use this software for any
		 *	purpose on any computer system, and to redistribute it freely,
		 *	subject to the following restrictions:
		 *
		 *	1. The author is not responsible for the consequences of use of
		 *		this software, no matter how awful, even if they arise
		 *		from defects in it.
		 *
		 *	2. The origin of this software must not be misrepresented, either
		 *		by explicit claim or by omission.
		 *
		 *	3. Altered versions must be plainly marked as such, and must not
		 *		be misrepresented as being the original software.
		 *
		 ****    Alterations to Henry's code are...
		 ****
		 ****    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
		 ****    2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others
		 ****
		 ****    You may distribute under the terms of either the GNU General Public
		 ****    License or the Artistic License, as specified in the README file.
		 *
		 * Beware that some of this code is subtly aware of the way operator
		 * precedence is structured in regular expressions.  Serious changes in
		 * regular-expression syntax might require a total rethink.
		 */
		#include "EXTERN.h"
		#define PERL_IN_REGEXEC_C
		#include "perl.h"
		
		#include "regcomp.h"
		
		#define RF_tainted	1		/* tainted information used? */
		#define RF_warned	2		/* warned about big count? */
		#define RF_evaled	4		/* Did an EVAL with setting? */
		#define RF_utf8		8		/* String contains multibyte chars? */
		
		#define UTF ((PL_reg_flags & RF_utf8) != 0)
		
		#define RS_init		1		/* eval environment created */
		#define RS_set		2		/* replsv value is set */
		
		#ifndef STATIC
		#define	STATIC	static
		#endif
		
		#define REGINCLASS(p,c)  (ANYOF_FLAGS(p) ? reginclass(p,c,0,0) : ANYOF_BITMAP_TEST(p,*(c)))
		
		/*
		 * Forwards.
		 */
		
		#define CHR_SVLEN(sv) (do_utf8 ? sv_len_utf8(sv) : SvCUR(sv))
		#define CHR_DIST(a,b) (PL_reg_match_utf8 ? utf8_distance(a,b) : a - b)
		
		#define reghop_c(pos,off) ((char*)reghop((U8*)pos, off))
		#define reghopmaybe_c(pos,off) ((char*)reghopmaybe((U8*)pos, off))
		#define HOP(pos,off) (PL_reg_match_utf8 ? reghop((U8*)pos, off) : (U8*)(pos + off))
		#define HOPMAYBE(pos,off) (PL_reg_match_utf8 ? reghopmaybe((U8*)pos, off) : (U8*)(pos + off))
		#define HOPc(pos,off) ((char*)HOP(pos,off))
		#define HOPMAYBEc(pos,off) ((char*)HOPMAYBE(pos,off))
		
		#define HOPBACK(pos, off) (		\
		    (PL_reg_match_utf8)			\
			? reghopmaybe((U8*)pos, -off)	\
		    : (pos - off >= PL_bostr)		\
			? (U8*)(pos - off)		\
		    : (U8*)NULL				\
		)
		#define HOPBACKc(pos, off) (char*)HOPBACK(pos, off)
		
		#define reghop3_c(pos,off,lim) ((char*)reghop3((U8*)pos, off, (U8*)lim))
		#define reghopmaybe3_c(pos,off,lim) ((char*)reghopmaybe3((U8*)pos, off, (U8*)lim))
		#define HOP3(pos,off,lim) (PL_reg_match_utf8 ? reghop3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
		#define HOPMAYBE3(pos,off,lim) (PL_reg_match_utf8 ? reghopmaybe3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
		#define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
		#define HOPMAYBE3c(pos,off,lim) ((char*)HOPMAYBE3(pos,off,lim))
		
		#define LOAD_UTF8_CHARCLASS(class,str) STMT_START { \
		    if (!CAT2(PL_utf8_,class)) { bool ok; ENTER; save_re_context(); ok=CAT2(is_utf8_,class)((const U8*)str); assert(ok); LEAVE; } } STMT_END
		#define LOAD_UTF8_CHARCLASS_ALNUM() LOAD_UTF8_CHARCLASS(alnum,"a")
		#define LOAD_UTF8_CHARCLASS_DIGIT() LOAD_UTF8_CHARCLASS(digit,"0")
		#define LOAD_UTF8_CHARCLASS_SPACE() LOAD_UTF8_CHARCLASS(space," ")
		#define LOAD_UTF8_CHARCLASS_MARK()  LOAD_UTF8_CHARCLASS(mark, "\xcd\x86")
		
		/* for use after a quantifier and before an EXACT-like node -- japhy */
		#define JUMPABLE(rn) ( \
		    OP(rn) == OPEN || OP(rn) == CLOSE || OP(rn) == EVAL || \
		    OP(rn) == SUSPEND || OP(rn) == IFMATCH || \
		    OP(rn) == PLUS || OP(rn) == MINMOD || \
		    (PL_regkind[(U8)OP(rn)] == CURLY && ARG1(rn) > 0) \
		)
		
		#define HAS_TEXT(rn) ( \
		    PL_regkind[(U8)OP(rn)] == EXACT || PL_regkind[(U8)OP(rn)] == REF \
		)
		
		/*
		  Search for mandatory following text node; for lookahead, the text must
		  follow but for lookbehind (rn->flags != 0) we skip to the next step.
		*/
		#define FIND_NEXT_IMPT(rn) STMT_START { \
		    while (JUMPABLE(rn)) \
			if (OP(rn) == SUSPEND || PL_regkind[(U8)OP(rn)] == CURLY) \
			    rn = NEXTOPER(NEXTOPER(rn)); \
			else if (OP(rn) == PLUS) \
			    rn = NEXTOPER(rn); \
			else if (OP(rn) == IFMATCH) \
			    rn = (rn->flags == 0) ? NEXTOPER(NEXTOPER(rn)) : rn + ARG(rn); \
			else rn += NEXT_OFF(rn); \
		} STMT_END 
		
		static void restore_pos(pTHX_ void *arg);
		
		STATIC CHECKPOINT
		S_regcppush(pTHX_ I32 parenfloor)
     1215116    {
     1215116        const int retval = PL_savestack_ix;
		#define REGCP_PAREN_ELEMS 4
     1215116        const int paren_elems_to_push = (PL_regsize - parenfloor) * REGCP_PAREN_ELEMS;
     1215116        int p;
		
     1215116        if (paren_elems_to_push < 0)
      ######    	Perl_croak(aTHX_ "panic: paren_elems_to_push < 0");
		
		#define REGCP_OTHER_ELEMS 6
     1215116        SSGROW(paren_elems_to_push + REGCP_OTHER_ELEMS);
     1393949        for (p = PL_regsize; p > parenfloor; p--) {
		/* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */
      178833    	SSPUSHINT(PL_regendp[p]);
      178833    	SSPUSHINT(PL_regstartp[p]);
      178833    	SSPUSHPTR(PL_reg_start_tmp[p]);
      178833    	SSPUSHINT(p);
		    }
		/* REGCP_OTHER_ELEMS are pushed in any case, parentheses or no. */
     1215116        SSPUSHINT(PL_regsize);
     1215116        SSPUSHINT(*PL_reglastparen);
     1215116        SSPUSHINT(*PL_reglastcloseparen);
     1215116        SSPUSHPTR(PL_reginput);
		#define REGCP_FRAME_ELEMS 2
		/* REGCP_FRAME_ELEMS are part of the REGCP_OTHER_ELEMS and
		 * are needed for the regexp context stack bookkeeping. */
     1215116        SSPUSHINT(paren_elems_to_push + REGCP_OTHER_ELEMS - REGCP_FRAME_ELEMS);
     1215116        SSPUSHINT(SAVEt_REGCONTEXT); /* Magic cookie. */
		
     1215116        return retval;
		}
		
		/* These are needed since we do not localize EVAL nodes: */
		#  define REGCP_SET(cp)  DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,		\
					     "  Setting an EVAL scope, savestack=%"IVdf"\n",	\
					     (IV)PL_savestack_ix)); cp = PL_savestack_ix
		
		#  define REGCP_UNWIND(cp)  DEBUG_EXECUTE_r(cp != PL_savestack_ix ?		\
						PerlIO_printf(Perl_debug_log,		\
						"  Clearing an EVAL scope, savestack=%"IVdf"..%"IVdf"\n", \
						(IV)(cp), (IV)PL_savestack_ix) : 0); regcpblow(cp)
		
		STATIC char *
		S_regcppop(pTHX)
      679222    {
      679222        I32 i;
      679222        U32 paren = 0;
      679222        char *input;
		
      679222        GET_RE_DEBUG_FLAGS_DECL;
		
		    /* Pop REGCP_OTHER_ELEMS before the parentheses loop starts. */
      679222        i = SSPOPINT;
      679222        assert(i == SAVEt_REGCONTEXT); /* Check that the magic cookie is there. */
      679222        i = SSPOPINT; /* Parentheses elements to pop. */
      679222        input = (char *) SSPOPPTR;
      679222        *PL_reglastcloseparen = SSPOPINT;
      679222        *PL_reglastparen = SSPOPINT;
      679222        PL_regsize = SSPOPINT;
		
		    /* Now restore the parentheses context. */
      799840        for (i -= (REGCP_OTHER_ELEMS - REGCP_FRAME_ELEMS);
			 i > 0; i -= REGCP_PAREN_ELEMS) {
      120618    	I32 tmps;
      120618    	paren = (U32)SSPOPINT;
      120618    	PL_reg_start_tmp[paren] = (char *) SSPOPPTR;
      120618    	PL_regstartp[paren] = SSPOPINT;
      120618    	tmps = SSPOPINT;
      120618    	if (paren <= *PL_reglastparen)
       23876    	    PL_regendp[paren] = tmps;
			DEBUG_EXECUTE_r(
			    PerlIO_printf(Perl_debug_log,
					  "     restoring \\%"UVuf" to %"IVdf"(%"IVdf")..%"IVdf"%s\n",
					  (UV)paren, (IV)PL_regstartp[paren],
					  (IV)(PL_reg_start_tmp[paren] - PL_bostr),
					  (IV)PL_regendp[paren],
					  (paren > *PL_reglastparen ? "(no)" : ""));
      120618    	);
		    }
		    DEBUG_EXECUTE_r(
			if ((I32)(*PL_reglastparen + 1) <= PL_regnpar) {
			    PerlIO_printf(Perl_debug_log,
					  "     restoring \\%"IVdf"..\\%"IVdf" to undef\n",
					  (IV)(*PL_reglastparen + 1), (IV)PL_regnpar);
			}
      679222        );
		#if 1
		    /* It would seem that the similar code in regtry()
		     * already takes care of this, and in fact it is in
		     * a better location to since this code can #if 0-ed out
		     * but the code in regtry() is needed or otherwise tests
		     * requiring null fields (pat.t#187 and split.t#{13,14}
		     * (as of patchlevel 7877)  will fail.  Then again,
		     * this code seems to be necessary or otherwise
		     * building DynaLoader will fail:
		     * "Error: '*' not in typemap in DynaLoader.xs, line 164"
		     * --jhi */
     1743941        for (paren = *PL_reglastparen + 1; (I32)paren <= PL_regnpar; paren++) {
     1064719    	if ((I32)paren > PL_regsize)
      988140    	    PL_regstartp[paren] = -1;
     1064719    	PL_regendp[paren] = -1;
		    }
		#endif
      679222        return input;
		}
		
		STATIC char *
		S_regcp_set_to(pTHX_ I32 ss)
        5544    {
        5544        const I32 tmp = PL_savestack_ix;
		
        5544        PL_savestack_ix = ss;
        5544        regcppop();
        5544        PL_savestack_ix = tmp;
        5544        return Nullch;
		}
		
		typedef struct re_cc_state
		{
		    I32 ss;
		    regnode *node;
		    struct re_cc_state *prev;
		    CURCUR *cc;
		    regexp *re;
		} re_cc_state;
		
		#define regcpblow(cp) LEAVE_SCOPE(cp)	/* Ignores regcppush()ed data. */
		
		#define TRYPAREN(paren, n, input) {				\
		    if (paren) {						\
			if (n) {						\
			    PL_regstartp[paren] = HOPc(input, -1) - PL_bostr;	\
			    PL_regendp[paren] = input - PL_bostr;		\
			}							\
			else							\
			    PL_regendp[paren] = -1;				\
		    }								\
		    if (regmatch(next))						\
			sayYES;							\
		    if (paren && n)						\
			PL_regendp[paren] = -1;					\
		}
		
		
		/*
		 * pregexec and friends
		 */
		
		/*
		 - pregexec - match a regexp against a string
		 */
		I32
		Perl_pregexec(pTHX_ register regexp *prog, char *stringarg, register char *strend,
			 char *strbeg, I32 minend, SV *screamer, U32 nosave)
		/* strend: pointer to null at end of string */
		/* strbeg: real beginning of string */
		/* minend: end of match must be >=minend after stringarg. */
		/* nosave: For optimizations. */
      ######    {
      ######        return
			regexec_flags(prog, stringarg, strend, strbeg, minend, screamer, NULL,
				      nosave ? 0 : REXEC_COPY_STR);
		}
		
		STATIC void
		S_cache_re(pTHX_ regexp *prog)
    11716568    {
    11716568        PL_regprecomp = prog->precomp;		/* Needed for FAIL. */
		#ifdef DEBUGGING
    11716568        PL_regprogram = prog->program;
		#endif
    11716568        PL_regnpar = prog->nparens;
    11716568        PL_regdata = prog->data;
    11716568        PL_reg_re = prog;
		}
		
		/*
		 * Need to implement the following flags for reg_anch:
		 *
		 * USE_INTUIT_NOML		- Useful to call re_intuit_start() first
		 * USE_INTUIT_ML
		 * INTUIT_AUTORITATIVE_NOML	- Can trust a positive answer
		 * INTUIT_AUTORITATIVE_ML
		 * INTUIT_ONCE_NOML		- Intuit can match in one location only.
		 * INTUIT_ONCE_ML
		 *
		 * Another flag for this function: SECOND_TIME (so that float substrs
		 * with giant delta may be not rechecked).
		 */
		
		/* Assumptions: if ANCH_GPOS, then strpos is anchored. XXXX Check GPOS logic */
		
		/* If SCREAM, then SvPVX_const(sv) should be compatible with strpos and strend.
		   Otherwise, only SvCUR(sv) is used to get strbeg. */
		
		/* XXXX We assume that strpos is strbeg unless sv. */
		
		/* XXXX Some places assume that there is a fixed substring.
			An update may be needed if optimizer marks as "INTUITable"
			RExen without fixed substrings.  Similarly, it is assumed that
			lengths of all the strings are no more than minlen, thus they
			cannot come from lookahead.
			(Or minlen should take into account lookahead.) */
		
		/* A failure to find a constant substring means that there is no need to make
		   an expensive call to REx engine, thus we celebrate a failure.  Similarly,
		   finding a substring too deep into the string means that less calls to
		   regtry() should be needed.
		
		   REx compiler's optimizer found 4 possible hints:
			a) Anchored substring;
			b) Fixed substring;
			c) Whether we are anchored (beginning-of-line or \G);
			d) First node (of those at offset 0) which may distingush positions;
		   We use a)b)d) and multiline-part of c), and try to find a position in the
		   string which does not contradict any of them.
		 */
		
		/* Most of decisions we do here should have been done at compile time.
		   The nodes of the REx which we used for the search should have been
		   deleted from the finite automaton. */
		
		char *
		Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
				     char *strend, U32 flags, re_scream_pos_data *data)
     4555374    {
     4555374        register I32 start_shift = 0;
		    /* Should be nonnegative! */
     4555374        register I32 end_shift   = 0;
     4555374        register char *s;
     4555374        register SV *check;
     4555374        char *strbeg;
     4555374        char *t;
     4555374        const int do_utf8 = sv ? SvUTF8(sv) : 0;	/* if no sv we have to assume bytes */
     4555374        I32 ml_anch;
     4555374        register char *other_last = Nullch;	/* other substr checked before this */
     4555374        char *check_at = Nullch;		/* check substr found at this pos */
     4555374        const I32 multiline = prog->reganch & PMf_MULTILINE;
		#ifdef DEBUGGING
     4555374        char *i_strpos = strpos;
     4555374        SV *dsv = PERL_DEBUG_PAD_ZERO(0);
		#endif
		
     4555374        GET_RE_DEBUG_FLAGS_DECL;
		
     4555374        RX_MATCH_UTF8_set(prog,do_utf8);
		
     4555374        if (prog->reganch & ROPT_UTF8) {
			DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
        2085    			      "UTF-8 regex...\n"));
        2085    	PL_reg_flags |= RF_utf8;
		    }
		
		    DEBUG_EXECUTE_r({
			 const char *s   = PL_reg_match_utf8 ?
			                 sv_uni_display(dsv, sv, 60, UNI_DISPLAY_REGEX) :
			                 strpos;
			 const int   len = PL_reg_match_utf8 ?
			                 strlen(s) : strend - strpos;
			 if (!PL_colorset)
			      reginitcolors();
			 if (PL_reg_match_utf8)
			     DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
						   "UTF-8 target...\n"));
			 PerlIO_printf(Perl_debug_log,
				       "%sGuessing start of match, REx%s \"%s%.60s%s%s\" against \"%s%.*s%s%s\"...\n",
				       PL_colors[4], PL_colors[5], PL_colors[0],
				       prog->precomp,
				       PL_colors[1],
				       (strlen(prog->precomp) > 60 ? "..." : ""),
				       PL_colors[0],
				       (int)(len > 60 ? 60 : len),
				       s, PL_colors[1],
				       (len > 60 ? "..." : "")
			      );
     4555374        });
		
		    /* CHR_DIST() would be more correct here but it makes things slow. */
     4555374        if (prog->minlen > strend - strpos) {
			DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
       93641    			      "String too short... [re_intuit_start]\n"));
      ######    	goto fail;
		    }
     4461733        strbeg = (sv && SvPOK(sv)) ? strend - SvCUR(sv) : strpos;
     4461733        PL_regeol = strend;
     4461733        if (do_utf8) {
        4977    	if (!prog->check_utf8 && prog->check_substr)
          89    	    to_utf8_substr(prog);
        4977    	check = prog->check_utf8;
		    } else {
     4456756    	if (!prog->check_substr && prog->check_utf8)
          19    	    to_byte_substr(prog);
     4456756    	check = prog->check_substr;
		    }
     4461733       if (check == &PL_sv_undef) {
			DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
           2    		"Non-utf string cannot match utf check string\n"));
      ######    	goto fail;
		    }
     4461731        if (prog->reganch & ROPT_ANCH) {	/* Match at beg-of-str or after \n */
     2624230    	ml_anch = !( (prog->reganch & ROPT_ANCH_SINGLE)
				     || ( (prog->reganch & ROPT_ANCH_BOL)
					  && !multiline ) );	/* Check after \n? */
		
     2624230    	if (!ml_anch) {
     2551524    	  if ( !(prog->reganch & (ROPT_ANCH_GPOS /* Checked by the caller */
						  | ROPT_IMPLICIT)) /* not a real BOL */
			       /* SvCUR is not set on references: SvRV and SvPVX_const overlap */
			       && sv && !SvROK(sv)
			       && (strpos != strbeg)) {
          14    	      DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Not at start...\n"));
      ######    	      goto fail;
			  }
     2551510    	  if (prog->check_offset_min == prog->check_offset_max &&
			      !(prog->reganch & ROPT_CANY_SEEN)) {
			    /* Substring at constant offset from beg-of-str... */
     1283680    	    I32 slen;
		
     1283680    	    s = HOP3c(strpos, prog->check_offset_min, strend);
     1283680    	    if (SvTAIL(check)) {
       17998    		slen = SvCUR(check);	/* >= 1 */
		
       17998    		if ( strend - s > slen || strend - s < slen - 1
				     || (strend - s == slen && strend[-1] != '\n')) {
        3142    		    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "String too long...\n"));
      ######    		    goto fail_finish;
				}
				/* Now should match s[0..slen-2] */
       14856    		slen--;
       14856    		if (slen && (*SvPVX_const(check) != *s
					     || (slen > 1
						 && memNE(SvPVX_const(check), s, slen)))) {
				  report_neq:
     1078513    		    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "String not equal...\n"));
      ######    		    goto fail_finish;
				}
			    }
     1265682    	    else if (*SvPVX_const(check) != *s
				     || ((slen = SvCUR(check)) > 1
					 && memNE(SvPVX_const(check), s, slen)))
     1340536    		goto report_neq;
     1340536    	    goto success_at_start;
			  }
			}
			/* Match is anchored, but substr is not anchored wrt beg-of-str. */
     1340536    	s = strpos;
     1340536    	start_shift = prog->check_offset_min; /* okay to underestimate on CC */
     1340536    	end_shift = prog->minlen - start_shift -
			    CHR_SVLEN(check) + (SvTAIL(check) != 0);
     1340536    	if (!ml_anch) {
     1267830    	    const I32 end = prog->check_offset_max + CHR_SVLEN(check)
     1267830    					 - (SvTAIL(check) != 0);
     1267830    	    const I32 eshift = CHR_DIST((U8*)strend, (U8*)s) - end;
		
     1267830    	    if (end_shift < eshift)
      120985    		end_shift = eshift;
			}
		    }
		    else {				/* Can match at random position */
     1837501    	ml_anch = 0;
     1837501    	s = strpos;
     1837501    	start_shift = prog->check_offset_min; /* okay to underestimate on CC */
			/* Should be nonnegative! */
     1837501    	end_shift = prog->minlen - start_shift -
			    CHR_SVLEN(check) + (SvTAIL(check) != 0);
		    }
		
		#ifdef DEBUGGING	/* 7/99: reports of failure (with the older version) */
     3178037        if (end_shift < 0)
      ######    	Perl_croak(aTHX_ "panic: end_shift");
		#endif
		
		  restart:
		    /* Find a possible match in the region s..strend by looking for
		       the "check" substring in the region corrected by start/end_shift. */
     3193413        if (flags & REXEC_SCREAM) {
          17    	I32 p = -1;			/* Internal iterator of scream. */
          17    	I32 * const pp = data ? data->scream_pos : &p;
		
          17    	if (PL_screamfirst[BmRARE(check)] >= 0
			    || ( BmRARE(check) == '\n'
				 && (BmPREVIOUS(check) == SvCUR(check) - 1)
				 && SvTAIL(check) ))
          17    	    s = screaminstr(sv, check,
					    start_shift + (s - strbeg), end_shift, pp, 0);
			else
          17    	    goto fail_finish;
			/* we may be pointing at the wrong string */
          17    	if (s && RX_MATCH_COPIED(prog))
           4    	    s = strbeg + (s - SvPVX_const(sv));
          17    	if (data)
           2    	    *data->scream_olds = s;
		    }
     3193396        else if (prog->reganch & ROPT_CANY_SEEN)
        3735    	s = fbm_instr((U8*)(s + start_shift),
				      (U8*)(strend - end_shift),
				      check, multiline ? FBMrf_MULTILINE : 0);
		    else
     3189661    	s = fbm_instr(HOP3(s, start_shift, strend),
				      HOP3(strend, -end_shift, strbeg),
				      check, multiline ? FBMrf_MULTILINE : 0);
		
		    /* Update the count-of-usability, remove useless subpatterns,
			unshift s.  */
		
		    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "%s %s substr \"%s%.*s%s\"%s%s",
					  (s ? "Found" : "Did not find"),
					  (check == (do_utf8 ? prog->anchored_utf8 : prog->anchored_substr) ? "anchored" : "floating"),
					  PL_colors[0],
					  (int)(SvCUR(check) - (SvTAIL(check)!=0)),
					  SvPVX_const(check),
					  PL_colors[1], (SvTAIL(check) ? "$" : ""),
     3193413    			  (s ? " at offset " : "...\n") ) );
		
     3193413        if (!s)
     1255756    	goto fail_finish;
		
     1937657        check_at = s;
		
		    /* Finish the diagnostic message */
     1937657        DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "%ld...\n", (long)(s - i_strpos)) );
		
		    /* Got a candidate.  Check MBOL anchoring, and the *other* substr.
		       Start with the other substr.
		       XXXX no SCREAM optimization yet - and a very coarse implementation
		       XXXX /ttx+/ results in anchored="ttx", floating="x".  floating will
				*always* match.  Probably should be marked during compile...
		       Probably it is right to do no SCREAM here...
		     */
		
     1937657        if (do_utf8 ? (prog->float_utf8 && prog->anchored_utf8) : (prog->float_substr && prog->anchored_substr)) {
			/* Take into account the "other" substring. */
			/* XXXX May be hopelessly wrong for UTF... */
      435932    	if (!other_last)
      435406    	    other_last = strpos;
      435932    	if (check == (do_utf8 ? prog->float_utf8 : prog->float_substr)) {
			  do_other_anchored:
			    {
      190642    		char *last = HOP3c(s, -start_shift, strbeg), *last1, *last2;
      190642    		char *s1 = s;
      190642    		SV* must;
		
      190642    		t = s - prog->check_offset_max;
      190642    		if (s - strpos > prog->check_offset_max  /* signed-corrected t > strpos */
				    && (!do_utf8
					|| ((t = reghopmaybe3_c(s, -(prog->check_offset_max), strpos))
					    && t > strpos)))
				    /* EMPTY */;
				else
      190571    		    t = strpos;
      190642    		t = HOP3c(t, prog->anchored_offset, strend);
      190642    		if (t < other_last)	/* These positions already checked */
         452    		    t = other_last;
      190642    		last2 = last1 = HOP3c(strend, -prog->minlen, strbeg);
      190642    		if (last < last1)
      188328    		    last1 = last;
		 /* XXXX It is not documented what units *_offsets are in.  Assume bytes.  */
				/* On end-of-str: see comment below. */
      190642    		must = do_utf8 ? prog->anchored_utf8 : prog->anchored_substr;
      190642    		if (must == &PL_sv_undef) {
           1    		    s = (char*)NULL;
           1    		    DEBUG_EXECUTE_r(must = prog->anchored_utf8);	/* for debug */
				}
				else
      190641    		    s = fbm_instr(
					(unsigned char*)t,
					HOP3(HOP3(last1, prog->anchored_offset, strend)
						+ SvCUR(must), -(SvTAIL(must)!=0), strbeg),
					must,
					multiline ? FBMrf_MULTILINE : 0
				    );
				DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
					"%s anchored substr \"%s%.*s%s\"%s",
					(s ? "Found" : "Contradicts"),
					PL_colors[0],
					  (int)(SvCUR(must)
					  - (SvTAIL(must)!=0)),
					  SvPVX_const(must),
      190642    			  PL_colors[1], (SvTAIL(must) ? "$" : "")));
      190642    		if (!s) {
        1977    		    if (last1 >= last2) {
					DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
         130    						", giving up...\n"));
      ######    			goto fail_finish;
				    }
				    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
					", trying floating at offset %ld...\n",
        1847    			(long)(HOP3c(s1, 1, strend) - i_strpos)));
        1847    		    other_last = HOP3c(last1, prog->anchored_offset+1, strend);
        1847    		    s = HOP3c(last, 1, strend);
        1847    		    goto restart;
				}
				else {
				    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, " at offset %ld...\n",
      188665    			  (long)(s - i_strpos)));
      188665    		    t = HOP3c(s, -prog->anchored_offset, strbeg);
      188665    		    other_last = HOP3c(s, 1, strend);
      188665    		    s = s1;
      188665    		    if (t == strpos)
       14695    			goto try_at_start;
      245349    		    goto try_at_offset;
				}
			    }
			}
			else {		/* Take into account the floating substring. */
      245349    	    char *last, *last1;
      245349    	    char *s1 = s;
      245349    	    SV* must;
		
      245349    	    t = HOP3c(s, -start_shift, strbeg);
      245349    	    last1 = last =
				HOP3c(strend, -prog->minlen + prog->float_min_offset, strbeg);
      245349    	    if (CHR_DIST((U8*)last, (U8*)t) > prog->float_max_offset)
         189    		last = HOP3c(t, prog->float_max_offset, strend);
      245349    	    s = HOP3c(t, prog->float_min_offset, strend);
      245349    	    if (s < other_last)
          10    		s = other_last;
		 /* XXXX It is not documented what units *_offsets are in.  Assume bytes.  */
      245349    	    must = do_utf8 ? prog->float_utf8 : prog->float_substr;
			    /* fbm_instr() takes into account exact value of end-of-str
			       if the check is SvTAIL(ed).  Since false positives are OK,
			       and end-of-str is not later than strend we are OK. */
      245349    	    if (must == &PL_sv_undef) {
           1    		s = (char*)NULL;
           1    		DEBUG_EXECUTE_r(must = prog->float_utf8);	/* for debug message */
			    }
			    else
      245348    		s = fbm_instr((unsigned char*)s,
					      (unsigned char*)last + SvCUR(must)
						  - (SvTAIL(must)!=0),
					      must, multiline ? FBMrf_MULTILINE : 0);
			    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "%s floating substr \"%s%.*s%s\"%s",
				    (s ? "Found" : "Contradicts"),
				    PL_colors[0],
				      (int)(SvCUR(must) - (SvTAIL(must)!=0)),
				      SvPVX_const(must),
      245349    		      PL_colors[1], (SvTAIL(must) ? "$" : "")));
      245349    	    if (!s) {
        1367    		if (last1 == last) {
				    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
        1289    					    ", giving up...\n"));
      ######    		    goto fail_finish;
				}
				DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
				    ", trying anchored starting at offset %ld...\n",
          78    		    (long)(s1 + 1 - i_strpos)));
          78    		other_last = last;
          78    		s = HOP3c(t, 1, strend);
          78    		goto restart;
			    }
			    else {
				DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, " at offset %ld...\n",
      243982    		      (long)(s - i_strpos)));
      243982    		other_last = s; /* Fix this later. --Hugo */
      243982    		s = s1;
      243982    		if (t == strpos)
        5141    		    goto try_at_start;
     1501725    		goto try_at_offset;
			    }
			}
		    }
		
     1501725        t = s - prog->check_offset_max;
     1501725        if (s - strpos > prog->check_offset_max  /* signed-corrected t > strpos */
		        && (!do_utf8
			    || ((t = reghopmaybe3_c(s, -prog->check_offset_max, strpos))
				 && t > strpos))) {
			/* Fixed substring is found far enough so that the match
			   cannot start at strpos. */
		      try_at_offset:
      762180    	if (ml_anch && t[-1] != '\n') {
			    /* Eventually fbm_*() should handle this, but often
			       anchored_offset is not 0, so this check will not be wasted. */
			    /* XXXX In the code below we prefer to look for "^" even in
			       presence of anchored substrings.  And we search even
			       beyond the found float position.  These pessimizations
			       are historical artefacts only.  */
			  find_anchor:
      996765    	    while (t < strend - prog->minlen) {
      996601    		if (*t == '\n') {
       20039    		    if (t < check_at - prog->check_offset_min) {
       12972    			if (do_utf8 ? prog->anchored_utf8 : prog->anchored_substr) {
					    /* Since we moved from the found position,
					       we definitely contradict the found anchored
					       substr.  Due to the above check we do not
					       contradict "check" substr.
					       Thus we can arrive here only if check substr
					       is float.  Redo checking for "other"=="fixed".
					     */
           1    			    strpos = t + 1;			
					    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Found /%s^%s/m at offset %ld, rescanning for anchored from offset %ld...\n",
           1    				PL_colors[0], PL_colors[1], (long)(strpos - i_strpos), (long)(strpos - i_strpos + prog->anchored_offset)));
      ######    			    goto do_other_anchored;
					}
					/* We don't contradict the found floating substring. */
					/* XXXX Why not check for STCLASS? */
       12971    			s = t + 1;
					DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Found /%s^%s/m at offset %ld...\n",
       12971    			    PL_colors[0], PL_colors[1], (long)(s - i_strpos)));
      ######    			goto set_useful;
				    }
				    /* Position contradicts check-string */
				    /* XXXX probably better to look for check-string
				       than for "\n", so one should lower the limit for t? */
				    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Found /%s^%s/m, restarting lookup for check-string at offset %ld...\n",
        7067    			PL_colors[0], PL_colors[1], (long)(t + 1 - i_strpos)));
        7067    		    other_last = strpos = s = t + 1;
        7067    		    goto restart;
				}
      976562    		t++;
			    }
			    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Did not find /%s^%s/m...\n",
         164    			PL_colors[0], PL_colors[1]));
      ######    	    goto fail_finish;
			}
			else {
			    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Starting position does not contradict /%s^%s/m...\n",
      744622    			PL_colors[0], PL_colors[1]));
			}
      744622    	s = t;
		      set_useful:
      757593    	++BmUSEFUL(do_utf8 ? prog->check_utf8 : prog->check_substr);	/* hooray/5 */
		    }
		    else {
			/* The found string does not prohibit matching at strpos,
			   - no optimization of calling REx engine can be performed,
			   unless it was an MBOL and we are not after MBOL,
			   or a future STCLASS check will fail this. */
		      try_at_start:
			/* Even in this situation we may use MBOL flag if strpos is offset
			   wrt the start of the string. */
     1183035    	if (ml_anch && sv && !SvROK(sv)	/* See prev comment on SvROK */
			    && (strpos != strbeg) && strpos[-1] != '\n'
			    /* May be due to an implicit anchor of m{.*foo}  */
			    && !(prog->reganch & ROPT_IMPLICIT))
			{
        2645    	    t = strpos;
        2645    	    goto find_anchor;
			}
			DEBUG_EXECUTE_r( if (ml_anch)
			    PerlIO_printf(Perl_debug_log, "Position at offset %ld does not contradict /%s^%s/m...\n",
					(long)(strpos - i_strpos), PL_colors[0], PL_colors[1]);
     1180390    	);
		      success_at_start:
     1382415    	if (!(prog->reganch & ROPT_NAUGHTY)	/* XXXX If strpos moved? */
			    && (do_utf8 ? (
				prog->check_utf8		/* Could be deleted already */
				&& --BmUSEFUL(prog->check_utf8) < 0
				&& (prog->check_utf8 == prog->float_utf8)
			    ) : (
				prog->check_substr		/* Could be deleted already */
				&& --BmUSEFUL(prog->check_substr) < 0
				&& (prog->check_substr == prog->float_substr)
			    )))
			{
			    /* If flags & SOMETHING - do not do it many times on the same match */
         600    	    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "... Disabling check substring...\n"));
         600    	    SvREFCNT_dec(do_utf8 ? prog->check_utf8 : prog->check_substr);
         600    	    if (do_utf8 ? prog->check_substr : prog->check_utf8)
           5    		SvREFCNT_dec(do_utf8 ? prog->check_substr : prog->check_utf8);
         600    	    prog->check_substr = prog->check_utf8 = Nullsv;	/* disable */
         600    	    prog->float_substr = prog->float_utf8 = Nullsv;	/* clear */
         600    	    check = Nullsv;			/* abort */
         600    	    s = strpos;
			    /* XXXX This is a remnant of the old implementation.  It
			            looks wasteful, since now INTUIT can use many
			            other heuristics. */
         600    	    prog->reganch &= ~RE_USE_INTUIT;
			}
			else
     1381815    	    s = strpos;
		    }
		
		    /* Last resort... */
		    /* XXXX BmUSEFUL already changed, maybe multiple change is meaningful... */
     2140008        if (prog->regstclass) {
			/* minlen == 0 is possible if regstclass is \b or \B,
			   and the fixed substr is ''$.
			   Since minlen is already taken into account, s+1 is before strend;
			   accidentally, minlen >= 1 guaranties no false positives at s + 1
			   even for \b or \B.  But (minlen? 1 : 0) below assumes that
			   regstclass does not come from lookahead...  */
			/* If regstclass takes bytelength more than 1: If charlength==1, OK.
			   This leaves EXACTF only, which is dealt with in find_byclass().  */
      594787            const U8* str = (U8*)STRING(prog->regstclass);
      594787            const int cl_l = (PL_regkind[(U8)OP(prog->regstclass)] == EXACT
				    ? CHR_DIST(str+STR_LEN(prog->regstclass), str)
      594787    		    : 1);
      594787    	const char * const endpos = (prog->anchored_substr || prog->anchored_utf8 || ml_anch)
				? HOP3c(s, (prog->minlen ? cl_l : 0), strend)
				: (prog->float_substr || prog->float_utf8
				   ? HOP3c(HOP3c(check_at, -start_shift, strbeg),
					   cl_l, strend)
      594787    		   : strend);
		
      594787    	t = s;
      594787    	cache_re(prog);
      594787            s = find_byclass(prog, prog->regstclass, s, endpos, 1);
      594787    	if (!s) {
		#ifdef DEBUGGING
       33286    	    const char *what = 0;
		#endif
       33286    	    if (endpos == strend) {
				DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
        9478    				"Could not match STCLASS...\n") );
      ######    		goto fail;
			    }
			    DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
       23808    				   "This position contradicts STCLASS...\n") );
       23808    	    if ((prog->reganch & ROPT_ANCH) && !ml_anch)
        5269    		goto fail;
			    /* Contradict one of substrings */
       18539    	    if (prog->anchored_substr || prog->anchored_utf8) {
         862    		if ((do_utf8 ? prog->anchored_utf8 : prog->anchored_substr) == check) {
         797    		    DEBUG_EXECUTE_r( what = "anchored" );
				  hop_and_restart:
        7636    		    s = HOP3c(t, 1, strend);
        7636    		    if (s + start_shift + end_shift > strend) {
					/* XXXX Should be taken into account earlier? */
					DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
        1252    					       "Could not match STCLASS...\n") );
      ######    			goto fail;
				    }
        6384    		    if (!check)
      ######    			goto giveup;
				    DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
						"Looking for %s substr starting at offset %ld...\n",
        6384    				 what, (long)(s + start_shift - i_strpos)) );
      ######    		    goto restart;
				}
				/* Have both, check_string is floating */
          65    		if (t + start_shift >= check_at) /* Contradicts floating=check */
           7    		    goto retry_floating_check;
				/* Recheck anchored substring, but not floating... */
          58    		s = check_at;
          58    		if (!check)
      ######    		    goto giveup;
				DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
					  "Looking for anchored substr starting at offset %ld...\n",
          58    			  (long)(other_last - i_strpos)) );
      ######    		goto do_other_anchored;
			    }
			    /* Another way we could have checked stclass at the
		               current position only: */
       17677    	    if (ml_anch) {
       10845    		s = t = t + 1;
       10845    		if (!check)
           2    		    goto giveup;
				DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log,
					  "Looking for /%s^%s/m starting at offset %ld...\n",
       10843    			  PL_colors[0], PL_colors[1], (long)(t - i_strpos)) );
      ######    		goto try_at_offset;
			    }
        6832    	    if (!(do_utf8 ? prog->float_utf8 : prog->float_substr))	/* Could have been deleted */
      ######    		goto fail;
			    /* Check is floating subtring. */
			  retry_floating_check:
        6839    	    t = check_at - start_shift;
        6839    	    DEBUG_EXECUTE_r( what = "floating" );
      ######    	    goto hop_and_restart;
			}
      561501    	if (t != s) {
		            DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
					"By STCLASS: moving %ld --> %ld\n",
		                                  (long)(t - i_strpos), (long)(s - i_strpos))
      151445                       );
		        }
		        else {
		            DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
		                                  "Does not contradict STCLASS...\n"); 
      410056                       );
		        }
		    }
		  giveup:
		    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "%s%s:%s match at offset %ld\n",
					  PL_colors[4], (check ? "Guessed" : "Giving up"),
     2106724    			  PL_colors[5], (long)(s - i_strpos)) );
     2106724        return s;
		
		  fail_finish:				/* Substring not found */
     2338994        if (prog->check_substr || prog->check_utf8)		/* could be removed already */
     2338994    	BmUSEFUL(do_utf8 ? prog->check_utf8 : prog->check_substr) += 5; /* hooray */
		  fail:
		    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "%sMatch rejected by optimizer%s\n",
     2448650    			  PL_colors[4], PL_colors[5]));
     2448650        return Nullch;
		}
		
		/* We know what class REx starts with.  Try to find this position... */
		STATIC char *
		S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32 norun)
     5597636    {
			dVAR;
     5597636    	const I32 doevery = (prog->reganch & ROPT_SKIP) == 0;
     5597636    	char *m;
     5597636    	STRLEN ln;
     5597636    	STRLEN lnc;
     5597636    	register STRLEN uskip;
     5597636    	unsigned int c1;
     5597636    	unsigned int c2;
     5597636    	char *e;
     5597636    	register I32 tmp = 1;	/* Scratch variable? */
     5597636    	register const bool do_utf8 = PL_reg_match_utf8;
		
			/* We know what class it must start with. */
     5597636    	switch (OP(c)) {
			case ANYOF:
     3342502    	    if (do_utf8) {
     1188325    		 while (s + (uskip = UTF8SKIP(s)) <= strend) {
     1188136    		      if ((ANYOF_FLAGS(c) & ANYOF_UNICODE) ||
					  !UTF8_IS_INVARIANT((U8)s[0]) ?
					  reginclass(c, (U8*)s, 0, do_utf8) :
					  REGINCLASS(c, (U8*)s)) {
        4142    			   if (tmp && (norun || regtry(prog, s)))
           4    				goto got_it;
					   else
           4    				tmp = doevery;
				      }
				      else 
     1183994    			   tmp = 1;
     1183998    		      s += uskip;
				 }
			    }
			    else {
     9410736    		 while (s < strend) {
     7602014    		      STRLEN skip = 1;
		
     7602014    		      if (REGINCLASS(c, (U8*)s) ||
					  (ANYOF_FOLD_SHARP_S(c, s, strend) &&
					   /* The assignment of 2 is intentional:
					    * for the folded sharp s, the skip is 2. */
					   (skip = SHARP_S_SKIP))) {
     1971618    			   if (tmp && (norun || regtry(prog, s)))
      442165    				goto got_it;
					   else
      442165    				tmp = doevery;
				      }
				      else 
     5630396    			   tmp = 1;
     6072561    		      s += skip;
				 }
			    }
          35    	    break;
			case CANY:
          35    	    while (s < strend) {
          35    	        if (tmp && (norun || regtry(prog, s)))
      ######    		    goto got_it;
				else
      ######    		    tmp = doevery;
      ######    		s++;
			    }
       25271    	    break;
			case EXACTF:
       25271    	    m   = STRING(c);
       25271    	    ln  = STR_LEN(c);	/* length to match in octets/bytes */
       25271    	    lnc = (I32) ln;	/* length to match in characters */
       25271    	    if (UTF) {
        5925    	        STRLEN ulen1, ulen2;
        5925    		U8 *sm = (U8 *) m;
        5925    		U8 tmpbuf1[UTF8_MAXBYTES_CASE+1];
        5925    		U8 tmpbuf2[UTF8_MAXBYTES_CASE+1];
		
        5925    		to_utf8_lower((U8*)m, tmpbuf1, &ulen1);
        5925    		to_utf8_upper((U8*)m, tmpbuf2, &ulen2);
		
        5925    		c1 = utf8n_to_uvchr(tmpbuf1, UTF8_MAXBYTES_CASE, 
						    0, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY);
        5925    		c2 = utf8n_to_uvchr(tmpbuf2, UTF8_MAXBYTES_CASE,
						    0, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY);
        5925    		lnc = 0;
       18113    		while (sm < ((U8 *) m + ln)) {
       12188    		    lnc++;
       12188    		    sm += UTF8SKIP(sm);
				}
			    }
			    else {
       19346    		c1 = *(U8*)m;
       19346    		c2 = PL_fold[c1];
			    }
       19346    	    goto do_exactf;
			case EXACTFL:
     1696824    	    m   = STRING(c);
     1696824    	    ln  = STR_LEN(c);
     1696824    	    lnc = (I32) ln;
     1696824    	    c1 = *(U8*)m;
     1696824    	    c2 = PL_fold_locale[c1];
			  do_exactf:
     1722095    	    e = HOP3c(strend, -((I32)lnc), s);
		
     1722095    	    if (norun && e < s)
      ######    		e = s;			/* Due to minlen logic of intuit() */
		
			    /* The idea in the EXACTF* cases is to first find the
			     * first character of the EXACTF* node and then, if
			     * necessary, case-insensitively compare the full
			     * text of the node.  The c1 and c2 are the first
			     * characters (though in Unicode it gets a bit
			     * more complicated because there are more cases
			     * than just upper and lower: one needs to use
			     * the so-called folding case for case-insensitive
			     * matching (called "loose matching" in Unicode).
			     * ibcmp_utf8() will do just that. */
		
     1722095    	    if (do_utf8) {
        5931    	        UV c, f;
        5931    	        U8 tmpbuf [UTF8_MAXBYTES+1];
        5931    		STRLEN len, foldlen;
				
        5931    		if (c1 == c2) {
				    /* Upper and lower of 1st char are equal -
				     * probably not a "letter". */
        5894    		    while (s <= e) {
        5893    		        c = utf8n_to_uvchr((U8*)s, UTF8_MAXBYTES, &len,
							   ckWARN(WARN_UTF8) ?
							   0 : UTF8_ALLOW_ANY);
        5893    			if ( c == c1
					     && (ln == len ||
						 ibcmp_utf8(s, (char **)0, 0,  do_utf8,
							    m, (char **)0, ln, (bool)UTF))
					     && (norun || regtry(prog, s)) )
           1    			    goto got_it;
					else {
           1    			     U8 foldbuf[UTF8_MAXBYTES_CASE+1];
           1    			     uvchr_to_utf8(tmpbuf, c);
           1    			     f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
           1    			     if ( f != c
						  && (f == c1 || f == c2)
						  && (ln == foldlen ||
						      !ibcmp_utf8((char *) foldbuf,
								  (char **)0, foldlen, do_utf8,
								  m,
								  (char **)0, ln, (bool)UTF))
						  && (norun || regtry(prog, s)) )
           1    				  goto got_it;
					}
           1    			s += len;
				    }
				}
				else {
          47    		    while (s <= e) {
          46    		      c = utf8n_to_uvchr((U8*)s, UTF8_MAXBYTES, &len,
							   ckWARN(WARN_UTF8) ?
							   0 : UTF8_ALLOW_ANY);
		
					/* Handle some of the three Greek sigmas cases.
					 * Note that not all the possible combinations
					 * are handled here: some of them are handled
					 * by the standard folding rules, and some of
					 * them (the character class or ANYOF cases)
					 * are handled during compiletime in
					 * regexec.c:S_regclass(). */
          46    			if (c == (UV)UNICODE_GREEK_CAPITAL_LETTER_SIGMA ||
					    c == (UV)UNICODE_GREEK_SMALL_LETTER_FINAL_SIGMA)
           6    			    c = (UV)UNICODE_GREEK_SMALL_LETTER_SIGMA;
		
          46    			if ( (c == c1 || c == c2)
					     && (ln == len ||
						 ibcmp_utf8(s, (char **)0, 0,  do_utf8,
							    m, (char **)0, ln, (bool)UTF))
					     && (norun || regtry(prog, s)) )
          12    			    goto got_it;
					else {
          12    			     U8 foldbuf[UTF8_MAXBYTES_CASE+1];
          12    			     uvchr_to_utf8(tmpbuf, c);
          12    			     f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
          12    			     if ( f != c
						  && (f == c1 || f == c2)
						  && (ln == foldlen ||
						      !ibcmp_utf8((char *) foldbuf,
								  (char **)0, foldlen, do_utf8,
								  m,
								  (char **)0, ln, (bool)UTF))
						  && (norun || regtry(prog, s)) )
           9    				  goto got_it;
					}
           9    			s += len;
				    }
				}
			    }
			    else {
     1716164    		if (c1 == c2)
       54779    		    while (s <= e) {
       53393    			if ( *(U8*)s == c1
					     && (ln == 1 || !(OP(c) == EXACTF
							      ? ibcmp(s, m, ln)
							      : ibcmp_locale(s, m, ln)))
					     && (norun || regtry(prog, s)) )
       52919    			    goto got_it;
       52919    			s++;
				    }
				else
     1769337    		    while (s <= e) {
     1753178    			if ( (*(U8*)s == c1 || *(U8*)s == c2)
					     && (ln == 1 || !(OP(c) == EXACTF
							      ? ibcmp(s, m, ln)
							      : ibcmp_locale(s, m, ln)))
					     && (norun || regtry(prog, s)) )
       55033    			    goto got_it;
       55033    			s++;
				    }
			    }
           8    	    break;
			case BOUNDL:
           8    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case BOUND:
       21426    	    if (do_utf8) {
          11    		if (s == PL_bostr)
          10    		    tmp = '\n';
				else {
           1    		    U8 *r = reghop3((U8*)s, -1, (U8*)PL_bostr);
				
           1    		    tmp = utf8n_to_uvchr(r, UTF8SKIP(r), 0, 0);
				}
          11    		tmp = ((OP(c) == BOUND ?
					isALNUM_uni(tmp) : isALNUM_LC_uvchr(UNI_TO_NATIVE(tmp))) != 0);
          11    		LOAD_UTF8_CHARCLASS_ALNUM();
          22    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
          13    		    if (tmp == !(OP(c) == BOUND ?
						 swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8) :
						 isALNUM_LC_utf8((U8*)s)))
				    {
          11    			tmp = !tmp;
          11    			if ((norun || regtry(prog, s)))
          11    			    goto got_it;
				    }
          11    		    s += uskip;
				}
			    }
			    else {
       21415    		tmp = (s != PL_bostr) ? UCHARAT(s - 1) : '\n';
       21415    		tmp = ((OP(c) == BOUND ? isALNUM(tmp) : isALNUM_LC(tmp)) != 0);
      127818    		while (s < strend) {
      115967    		    if (tmp ==
					!(OP(c) == BOUND ? isALNUM(*s) : isALNUM_LC(*s))) {
       38613    			tmp = !tmp;
       38613    			if ((norun || regtry(prog, s)))
      106403    			    goto got_it;
				    }
      106403    		    s++;
				}
			    }
       11860    	    if ((!prog->minlen && tmp) && (norun || regtry(prog, s)))
      ######    		goto got_it;
      ######    	    break;
			case NBOUNDL:
      ######    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case NBOUND:
         111    	    if (do_utf8) {
      ######    		if (s == PL_bostr)
      ######    		    tmp = '\n';
				else {
      ######    		    U8 *r = reghop3((U8*)s, -1, (U8*)PL_bostr);
				
      ######    		    tmp = utf8n_to_uvchr(r, UTF8SKIP(r), 0, 0);
				}
      ######    		tmp = ((OP(c) == NBOUND ?
					isALNUM_uni(tmp) : isALNUM_LC_uvchr(UNI_TO_NATIVE(tmp))) != 0);
      ######    		LOAD_UTF8_CHARCLASS_ALNUM();
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (tmp == !(OP(c) == NBOUND ?
						 swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8) :
						 isALNUM_LC_utf8((U8*)s)))
      ######    			tmp = !tmp;
      ######    		    else if ((norun || regtry(prog, s)))
      ######    			goto got_it;
      ######    		    s += uskip;
				}
			    }
			    else {
         111    		tmp = (s != PL_bostr) ? UCHARAT(s - 1) : '\n';
         111    		tmp = ((OP(c) == NBOUND ?
					isALNUM(tmp) : isALNUM_LC(tmp)) != 0);
         147    		while (s < strend) {
         117    		    if (tmp ==
					!(OP(c) == NBOUND ? isALNUM(*s) : isALNUM_LC(*s)))
          36    			tmp = !tmp;
          81    		    else if ((norun || regtry(prog, s)))
          36    			goto got_it;
          36    		    s++;
				}
			    }
          30    	    if ((!prog->minlen && !tmp) && (norun || regtry(prog, s)))
        1214    		goto got_it;
        1214    	    break;
			case ALNUM:
        1214    	    if (do_utf8) {
         139    		LOAD_UTF8_CHARCLASS_ALNUM();
         239    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
         143    		    if (swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8)) {
          43    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
         100    			tmp = 1;
         100    		    s += uskip;
				}
			    }
			    else {
        1821    		while (s < strend) {
        1351    		    if (isALNUM(*s)) {
         663    			if (tmp && (norun || regtry(prog, s)))
          58    			    goto got_it;
					else
          58    			    tmp = doevery;
				    }
				    else
         688    			tmp = 1;
         746    		    s++;
				}
			    }
      176394    	    break;
			case ALNUML:
      176394    	    PL_reg_flags |= RF_tainted;
      176394    	    if (do_utf8) {
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (isALNUM_LC_utf8((U8*)s)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
      275188    		while (s < strend) {
      176396    		    if (isALNUM_LC(*s)) {
       77602    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
       98794    			tmp = 1;
       98794    		    s++;
				}
			    }
      124421    	    break;
			case NALNUM:
      124421    	    if (do_utf8) {
           2    		LOAD_UTF8_CHARCLASS_ALNUM();
          15    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
          13    		    if (!swash_fetch(PL_utf8_alnum, (U8*)s, do_utf8)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
          13    			tmp = 1;
          13    		    s += uskip;
				}
			    }
			    else {
      930036    		while (s < strend) {
      820609    		    if (!isALNUM(*s)) {
       14992    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      805617    			tmp = 1;
      805617    		    s++;
				}
			    }
       47451    	    break;
			case NALNUML:
       47451    	    PL_reg_flags |= RF_tainted;
       47451    	    if (do_utf8) {
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (!isALNUM_LC_utf8((U8*)s)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
       72399    		while (s < strend) {
       47912    		    if (!isALNUM_LC(*s)) {
       22964    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
       24948    			tmp = 1;
       24948    		    s++;
				}
			    }
      142455    	    break;
			case SPACE:
      142455    	    if (do_utf8) {
           1    		LOAD_UTF8_CHARCLASS_SPACE();
           1    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
           1    		    if (*s == ' ' || swash_fetch(PL_utf8_space,(U8*)s, do_utf8)) {
           1    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
     2223340    		while (s < strend) {
     2162061    		    if (isSPACE(*s)) {
      205662    			if (tmp && (norun || regtry(prog, s)))
      124487    			    goto got_it;
					else
      124487    			    tmp = doevery;
				    }
				    else
     1956399    			tmp = 1;
     2080886    		    s++;
				}
			    }
         573    	    break;
			case SPACEL:
         573    	    PL_reg_flags |= RF_tainted;
         573    	    if (do_utf8) {
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (*s == ' ' || isSPACE_LC_utf8((U8*)s)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
        9216    		while (s < strend) {
        8983    		    if (isSPACE_LC(*s)) {
        1617    			if (tmp && (norun || regtry(prog, s)))
        1277    			    goto got_it;
					else
        1277    			    tmp = doevery;
				    }
				    else
        7366    			tmp = 1;
        8643    		    s++;
				}
			    }
       14785    	    break;
			case NSPACE:
       14785    	    if (do_utf8) {
           2    		LOAD_UTF8_CHARCLASS_SPACE();
           2    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
           2    		    if (!(*s == ' ' || swash_fetch(PL_utf8_space,(U8*)s, do_utf8))) {
           2    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
       28135    		while (s < strend) {
       27406    		    if (!isSPACE(*s)) {
       14054    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
       13352    			tmp = 1;
       13352    		    s++;
				}
			    }
           1    	    break;
			case NSPACEL:
           1    	    PL_reg_flags |= RF_tainted;
           1    	    if (do_utf8) {
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (!(*s == ' ' || isSPACE_LC_utf8((U8*)s))) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
           1    		while (s < strend) {
           1    		    if (!isSPACE_LC(*s)) {
           1    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s++;
				}
			    }
        2891    	    break;
			case DIGIT:
        2891    	    if (do_utf8) {
           1    		LOAD_UTF8_CHARCLASS_DIGIT();
           1    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
           1    		    if (swash_fetch(PL_utf8_digit,(U8*)s, do_utf8)) {
           1    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
        8462    		while (s < strend) {
        7652    		    if (isDIGIT(*s)) {
        2096    			if (tmp && (norun || regtry(prog, s)))
          16    			    goto got_it;
					else
          16    			    tmp = doevery;
				    }
				    else
        5556    			tmp = 1;
        5572    		    s++;
				}
			    }
      ######    	    break;
			case DIGITL:
      ######    	    PL_reg_flags |= RF_tainted;
      ######    	    if (do_utf8) {
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (isDIGIT_LC_utf8((U8*)s)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
      ######    		while (s < strend) {
      ######    		    if (isDIGIT_LC(*s)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s++;
				}
			    }
        1282    	    break;
			case NDIGIT:
        1282    	    if (do_utf8) {
      ######    		LOAD_UTF8_CHARCLASS_DIGIT();
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (!swash_fetch(PL_utf8_digit,(U8*)s, do_utf8)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
        3465    		while (s < strend) {
        2709    		    if (!isDIGIT(*s)) {
         526    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
        2183    			tmp = 1;
        2183    		    s++;
				}
			    }
      ######    	    break;
			case NDIGITL:
      ######    	    PL_reg_flags |= RF_tainted;
      ######    	    if (do_utf8) {
      ######    		while (s + (uskip = UTF8SKIP(s)) <= strend) {
      ######    		    if (!isDIGIT_LC_utf8((U8*)s)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s += uskip;
				}
			    }
			    else {
      ######    		while (s < strend) {
      ######    		    if (!isDIGIT_LC(*s)) {
      ######    			if (tmp && (norun || regtry(prog, s)))
      ######    			    goto got_it;
					else
      ######    			    tmp = doevery;
				    }
				    else
      ######    			tmp = 1;
      ######    		    s++;
				}
			    }
      ######    	    break;
			default:
      ######    	    Perl_croak(aTHX_ "panic: unknown regstclass %d", (int)OP(c));
     2135429    	    break;
			}
     2135429    	return 0;
		      got_it:
     3462207    	return s;
		}
		
		/*
		 - regexec_flags - match a regexp against a string
		 */
		I32
		Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *strend,
			      char *strbeg, I32 minend, SV *sv, void *data, U32 flags)
		/* strend: pointer to null at end of string */
		/* strbeg: real beginning of string */
		/* minend: end of match must be >=minend after stringarg. */
		/* data: May be used for some additional optimizations. */
		/* nosave: For optimizations. */
    11094673    {
    11094673        register char *s;
    11094673        register regnode *c;
    11094673        register char *startpos = stringarg;
    11094673        I32 minlen;		/* must match at least this many chars */
    11094673        I32 dontbother = 0;	/* how many characters not to try at end */
    11094673        I32 end_shift = 0;			/* Same for the end. */		/* CC */
    11094673        I32 scream_pos = -1;		/* Internal iterator of scream. */
    11094673        char *scream_olds;
    11094673        SV* oreplsv = GvSV(PL_replgv);
    11094673        const bool do_utf8 = DO_UTF8(sv);
    11094673        const I32 multiline = prog->reganch & PMf_MULTILINE;
		#ifdef DEBUGGING
    11094673        SV *dsv0 = PERL_DEBUG_PAD_ZERO(0);
    11094673        SV *dsv1 = PERL_DEBUG_PAD_ZERO(1);
		#endif
		
    11094673        GET_RE_DEBUG_FLAGS_DECL;
		
    11094673        PERL_UNUSED_ARG(data);
    11094673        RX_MATCH_UTF8_set(prog,do_utf8);
		
    11094673        PL_regcc = 0;
		
    11094673        cache_re(prog);
		#ifdef DEBUGGING
    11094673        PL_regnarrate = DEBUG_r_TEST;
		#endif
		
		    /* Be paranoid... */
    11094673        if (prog == NULL || startpos == NULL) {
      ######    	Perl_croak(aTHX_ "NULL regexp parameter");
    11094673    	return 0;
		    }
		
    11094673        minlen = prog->minlen;
    11094673        if (strend - startpos < minlen) {
		        DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
      139799    			      "String too short [regexec_flags]...\n"));
      ######    	goto phooey;
		    }
		
		    /* Check validity of program. */
    10954874        if (UCHARAT(prog->program) != REG_MAGIC) {
      ######    	Perl_croak(aTHX_ "corrupted regexp program");
		    }
		
    10954874        PL_reg_flags = 0;
    10954874        PL_reg_eval_set = 0;
    10954874        PL_reg_maxiter = 0;
		
    10954874        if (prog->reganch & ROPT_UTF8)
        7724    	PL_reg_flags |= RF_utf8;
		
		    /* Mark beginning of line for ^ and lookbehind. */
    10954874        PL_regbol = startpos;
    10954874        PL_bostr  = strbeg;
    10954874        PL_reg_sv = sv;
		
		    /* Mark end of line for $ (and such) */
    10954874        PL_regeol = strend;
		
		    /* see how far we have to get to not match where we matched before */
    10954874        PL_regtill = startpos+minend;
		
		    /* We start without call_cc context.  */
    10954874        PL_reg_call_cc = 0;
		
		    /* If there is a "must appear" string, look for it. */
    10954874        s = startpos;
		
    10954874        if (prog->reganch & ROPT_GPOS_SEEN) { /* Need to have PL_reg_ganch */
      974702    	MAGIC *mg;
		
      974702    	if (flags & REXEC_IGNOREPOS)	/* Means: check only at start */
      440733    	    PL_reg_ganch = startpos;
      533969    	else if (sv && SvTYPE(sv) >= SVt_PVMG
				  && SvMAGIC(sv)
				  && (mg = mg_find(sv, PERL_MAGIC_regex_global))
				  && mg->mg_len >= 0) {
          47    	    PL_reg_ganch = strbeg + mg->mg_len;	/* Defined pos() */
          47    	    if (prog->reganch & ROPT_ANCH_GPOS) {
          22    	        if (s > PL_reg_ganch)
      ######    		    goto phooey;
          22    		s = PL_reg_ganch;
			    }
			}
			else				/* pos() not defined */
      533922    	    PL_reg_ganch = strbeg;
		    }
		
    10954874        if (!(flags & REXEC_CHECKED) && (prog->check_substr != Nullsv || prog->check_utf8 != Nullsv)) {
      696064    	re_scream_pos_data d;
		
      696064    	d.scream_olds = &scream_olds;
      696064    	d.scream_pos = &scream_pos;
      696064    	s = re_intuit_start(prog, sv, s, strend, flags, &d);
      696064    	if (!s) {
      135194    	    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Not present...\n"));
      ######    	    goto phooey;	/* not present */
			}
		    }
		
		    DEBUG_EXECUTE_r({
			const char * const s0   = UTF
			    ? pv_uni_display(dsv0, (U8*)prog->precomp, prog->prelen, 60,
					  UNI_DISPLAY_REGEX)
			    : prog->precomp;
			const int len0 = UTF ? SvCUR(dsv0) : prog->prelen;
			const char * const s1 = do_utf8 ? sv_uni_display(dsv1, sv, 60,
							       UNI_DISPLAY_REGEX) : startpos;
			const int len1 = do_utf8 ? SvCUR(dsv1) : strend - startpos;
			 if (!PL_colorset)
			     reginitcolors();
			 PerlIO_printf(Perl_debug_log,
				       "%sMatching REx%s \"%s%*.*s%s%s\" against \"%s%.*s%s%s\"\n",
				       PL_colors[4], PL_colors[5], PL_colors[0],
				       len0, len0, s0,
				       PL_colors[1],
				       len0 > 60 ? "..." : "",
				       PL_colors[0],
				       (int)(len1 > 60 ? 60 : len1),
				       s1, PL_colors[1],
				       (len1 > 60 ? "..." : "")
			      );
    10819680        });
		
		    /* Simplest case:  anchored match need be tried only once. */
		    /*  [unless only anchor is BOL and multiline is set] */
    10819680        if (prog->reganch & (ROPT_ANCH & ~ROPT_ANCH_GPOS)) {
     3521359    	if (s == startpos && regtry(prog, startpos))
     1879531    	    goto got_it;
     1641828    	else if (multiline || (prog->reganch & ROPT_IMPLICIT)
				 || (prog->reganch & ROPT_ANCH_MBOL)) /* XXXX SBOL? */
			{
      447852    	    char *end;
		
      447852    	    if (minlen)
      442132    		dontbother = minlen - 1;
      447852    	    end = HOP3c(strend, -dontbother, strbeg) - 1;
			    /* for multiline we only have to try after newlines */
      447852    	    if (prog->check_substr || prog->check_utf8) {
       16950    		if (s == startpos)
        2094    		    goto after_try;
       19520    		while (1) {
       19520    		    if (regtry(prog, s))
       14919    			goto got_it;
				  after_try:
        6695    		    if (s >= end)
      ######    			goto phooey;
        6695    		    if (prog->reganch & RE_USE_INTUIT) {
        6695    			s = re_intuit_start(prog, sv, s + 1, strend, flags, NULL);
        6695    			if (!s)
        2031    			    goto phooey;
				    }
				    else
      ######    			s++;
				}		
			    } else {
      430902    		if (s > startpos)
      ######    		    s--;
     1567958    		while (s < end) {
     1514301    		    if (*s++ == '\n') {	/* don't need PL_utf8skip here */
      381362    			if (regtry(prog, s))
      377245    			    goto got_it;
				    }
				}		
			    }
			}
     7298321    	goto phooey;
     7298321        } else if (prog->reganch & ROPT_ANCH_GPOS) {
      974521    	if (regtry(prog, PL_reg_ganch))
      895459    	    goto got_it;
     6323800    	goto phooey;
		    }
		
		    /* Messy cases:  unanchored match. */
     6323800        if ((prog->anchored_substr || prog->anchored_utf8) && prog->reganch & ROPT_SKIP) {
			/* we have /x+whatever/ */
			/* it must be a one character string (XXXX Except UTF?) */
       57159    	char ch;
		#ifdef DEBUGGING
       57159    	int did_match = 0;
		#endif
       57159    	if (!(do_utf8 ? prog->anchored_utf8 : prog->anchored_substr))
           2    	    do_utf8 ? to_utf8_substr(prog) : to_byte_substr(prog);
       57159    	ch = SvPVX_const(do_utf8 ? prog->anchored_utf8 : prog->anchored_substr)[0];
		
       57159    	if (do_utf8) {
           2    	    while (s < strend) {
           2    		if (*s == ch) {
           2    		    DEBUG_EXECUTE_r( did_match = 1 );
           2    		    if (regtry(prog, s)) goto got_it;
      ######    		    s += UTF8SKIP(s);
      ######    		    while (s < strend && *s == ch)
      ######    			s += UTF8SKIP(s);
				}
      ######    		s += UTF8SKIP(s);
			    }
			}
			else {
      208614    	    while (s < strend) {
      208059    		if (*s == ch) {
       60518    		    DEBUG_EXECUTE_r( did_match = 1 );
       60518    		    if (regtry(prog, s)) goto got_it;
        3916    		    s++;
        6128    		    while (s < strend && *s == ch)
        2212    			s++;
				}
      151457    		s++;
			    }
			}
			DEBUG_EXECUTE_r(if (!did_match)
				PerlIO_printf(Perl_debug_log,
		                                  "Did not find anchored character...\n")
         555                   );
		    }
     6266641        else if (prog->anchored_substr != Nullsv
			      || prog->anchored_utf8 != Nullsv
			      || ((prog->float_substr != Nullsv || prog->float_utf8 != Nullsv)
				  && prog->float_max_offset < strend - s)) {
      765282    	SV *must;
      765282    	I32 back_max;
      765282    	I32 back_min;
      765282    	char *last;
      765282    	char *last1;		/* Last position checked before */
		#ifdef DEBUGGING
      765282    	int did_match = 0;
		#endif
      765282    	if (prog->anchored_substr || prog->anchored_utf8) {
      763003    	    if (!(do_utf8 ? prog->anchored_utf8 : prog->anchored_substr))
          63    		do_utf8 ? to_utf8_substr(prog) : to_byte_substr(prog);
      763003    	    must = do_utf8 ? prog->anchored_utf8 : prog->anchored_substr;
      763003    	    back_max = back_min = prog->anchored_offset;
			} else {
        2279    	    if (!(do_utf8 ? prog->float_utf8 : prog->float_substr))
      ######    		do_utf8 ? to_utf8_substr(prog) : to_byte_substr(prog);
        2279    	    must = do_utf8 ? prog->float_utf8 : prog->float_substr;
        2279    	    back_max = prog->float_max_offset;
        2279    	    back_min = prog->float_min_offset;
			}
      765282    	if (must == &PL_sv_undef)
			    /* could not downgrade utf8 check substring, so must fail */
           4    	    goto phooey;
		
      765278    	last = HOP3c(strend,	/* Cannot start after this */
					  -(I32)(CHR_SVLEN(must)
						 - (SvTAIL(must) != 0) + back_min), strbeg);
		
      765278    	if (s > PL_bostr)
      681912    	    last1 = HOPc(s, -1);
			else
       83366    	    last1 = s - 1;	/* bogus */
		
			/* XXXX check_substr already used to find "s", can optimize if
			   check_substr==must. */
      765278    	scream_pos = -1;
      765278    	dontbother = end_shift;
      765278    	strend = HOPc(strend, -dontbother);
     1140301    	while ( (s <= last) &&
				((flags & REXEC_SCREAM)
				 ? (s = screaminstr(sv, must, HOP3c(s, back_min, strend) - strbeg,
						    end_shift, &scream_pos, 0))
				 : (s = fbm_instr((unsigned char*)HOP3(s, back_min, strend),
						  (unsigned char*)strend, must,
						  multiline ? FBMrf_MULTILINE : 0))) ) {
			    /* we may be pointing at the wrong string */
     1066268    	    if ((flags & REXEC_SCREAM) && RX_MATCH_COPIED(prog))
           3    		s = strbeg + (s - SvPVX_const(sv));
     1066268    	    DEBUG_EXECUTE_r( did_match = 1 );
     1066268    	    if (HOPc(s, -back_max) > last1) {
     1064471    		last1 = HOPc(s, -back_min);
     1064471    		s = HOPc(s, -back_max);
			    }
			    else {
        1797    		char *t = (last1 >= PL_bostr) ? HOPc(last1, 1) : last1 + 1;
		
        1797    		last1 = HOPc(s, -back_min);
        1797    		s = t;		
			    }
     1066268    	    if (do_utf8) {
        1412    		while (s <= last1) {
        1391    		    if (regtry(prog, s))
        1370    			goto got_it;
          21    		    s += UTF8SKIP(s);
				}
			    }
			    else {
     1440266    		while (s <= last1) {
     1065264    		    if (regtry(prog, s))
      689875    			goto got_it;
      375389    		    s++;
				}
			    }
			}
			DEBUG_EXECUTE_r(if (!did_match)
		                    PerlIO_printf(Perl_debug_log, 
		                                  "Did not find %s substr \"%s%.*s%s\"%s...\n",
					      ((must == prog->anchored_substr || must == prog->anchored_utf8)
					       ? "anchored" : "floating"),
					      PL_colors[0],
					      (int)(SvCUR(must) - (SvTAIL(must)!=0)),
					      SvPVX_const(must),
		                                  PL_colors[1], (SvTAIL(must) ? "$" : ""))
       74033                   );
      ######    	goto phooey;
		    }
     5501359        else if ((c = prog->regstclass)) {
     5002849    	if (minlen) {
     5002847    	    I32 op = (U8)OP(prog->regstclass);
			    /* don't bother with what can't match */
     5002847    	    if (PL_regkind[op] != EXACT && op != CANY)
     3286196    	        strend = HOPc(strend, -(minlen - 1));
			}
			DEBUG_EXECUTE_r({
			    SV *prop = sv_newmortal();
			    const char *s0;
			    const char *s1;
			    int len0;
			    int len1;
		
			    regprop(prop, c);
			    s0 = UTF ?
			      pv_uni_display(dsv0, (U8*)SvPVX_const(prop), SvCUR(prop), 60,
					     UNI_DISPLAY_REGEX) :
			      SvPVX_const(prop);
			    len0 = UTF ? SvCUR(dsv0) : SvCUR(prop);
			    s1 = UTF ?
			      sv_uni_display(dsv1, sv, 60, UNI_DISPLAY_REGEX) : s;
			    len1 = UTF ? SvCUR(dsv1) : strend - s;
			    PerlIO_printf(Perl_debug_log,
					  "Matching stclass \"%*.*s\" against \"%*.*s\"\n",
					  len0, len0, s0,
					  len1, len1, s1);
     5002849    	});
     5002849            if (find_byclass(prog, c, s, strend, 0))
     2900706    	    goto got_it;
     2102143    	DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "Contradicts stclass...\n"));
		    }
		    else {
      498510    	dontbother = 0;
      498510    	if (prog->float_substr != Nullsv || prog->float_utf8 != Nullsv) {
			    /* Trim the end. */
       76982    	    char *last;
       76982    	    SV* float_real;
		
       76982    	    if (!(do_utf8 ? prog->float_utf8 : prog->float_substr))
      ######    		do_utf8 ? to_utf8_substr(prog) : to_byte_substr(prog);
       76982    	    float_real = do_utf8 ? prog->float_utf8 : prog->float_substr;
		
       76982    	    if (flags & REXEC_SCREAM) {
      ######    		last = screaminstr(sv, float_real, s - strbeg,
						   end_shift, &scream_pos, 1); /* last one */
      ######    		if (!last)
      ######    		    last = scream_olds; /* Only one occurrence. */
				/* we may be pointing at the wrong string */
      ######    		else if (RX_MATCH_COPIED(prog))
      ######    		    s = strbeg + (s - SvPVX_const(sv));
			    }
			    else {
       76982    		STRLEN len;
       76982                    const char * const little = SvPV_const(float_real, len);
		
       76982    		if (SvTAIL(float_real)) {
       12644    		    if (memEQ(strend - len + 1, little, len - 1))
       12644    			last = strend - len + 1;
      ######    		    else if (!multiline)
      ######    			last = memEQ(strend - len, little, len)
					    ? strend - len : Nullch;
				    else
       64338    			goto find_last;
				} else {
				  find_last:
       64338    		    if (len)
       64338    			last = rninstr(s, strend, little, little + len);
				    else
      ######    			last = strend;	/* matching "$" */
				}
			    }
       76982    	    if (last == NULL) {
				DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log,
						      "%sCan't trim the tail, match fails (should not happen)%s\n",
      ######    				      PL_colors[4], PL_colors[5]));
      ######    		goto phooey; /* Should not happen! */
			    }
       76982    	    dontbother = strend - last + prog->float_min_offset;
			}
      498510    	if (minlen && (dontbother < minlen))
      251067    	    dontbother = minlen - 1;
      498510    	strend -= dontbother; 		   /* this one's always in bytes! */
			/* We don't know much -- general case. */
      498510    	if (do_utf8) {
       34533    	    for (;;) {
       32419    		if (regtry(prog, s))
       30294    		    goto got_it;
        2125    		if (s >= strend)
          11    		    break;
        2114    		s += UTF8SKIP(s);
			    };
			}
			else {
     4180984    	    do {
     4180984    		if (regtry(prog, s))
      357468    		    goto got_it;
     3823515    	    } while (s++ < strend);
			}
		    }
		
		    /* Failure. */
     7203471        goto phooey;
		
		got_it:
     7203471        RX_MATCH_TAINTED_set(prog, PL_reg_flags & RF_tainted);
		
     7203471        if (PL_reg_eval_set) {
			/* Preserve the current value of $^R */
        3206    	if (oreplsv != GvSV(PL_replgv))
         306    	    sv_setsv(oreplsv, GvSV(PL_replgv));/* So that when GvSV(replgv) is
								  restored, the value remains
								  the same. */
        3206    	restore_pos(aTHX_ 0);
		    }
		
		    /* make sure $`, $&, $', and $digit will work later */
     7203471        if ( !(flags & REXEC_NOT_FIRST) ) {
     6811398    	RX_MATCH_COPY_FREE(prog);
     6811398    	if (flags & REXEC_COPY_STR) {
     3398779    	    I32 i = PL_regeol - startpos + (stringarg - strbeg);
		#ifdef PERL_OLD_COPY_ON_WRITE
			    if ((SvIsCOW(sv)
				 || (SvFLAGS(sv) & CAN_COW_MASK) == CAN_COW_FLAGS)) {
				if (DEBUG_C_TEST) {
				    PerlIO_printf(Perl_debug_log,
						  "Copy on write: regexp capture, type %d\n",
						  (int) SvTYPE(sv));
				}
				prog->saved_copy = sv_setsv_cow(prog->saved_copy, sv);
				prog->subbeg = (char *)SvPVX_const(prog->saved_copy);
				assert (SvPOKp(prog->saved_copy));
			    } else
		#endif
			    {
     3398779    		RX_MATCH_COPIED_on(prog);
     3398779    		s = savepvn(strbeg, i);
     3398779    		prog->subbeg = s;
			    }
     3398779    	    prog->sublen = i;
			}
			else {
     3412619    	    prog->subbeg = strbeg;
     3412619    	    prog->sublen = PL_regeol - strbeg;	/* strend may have been modified */
			}
		    }
		
     7203471        return 1;
		
		phooey:
		    DEBUG_EXECUTE_r(PerlIO_printf(Perl_debug_log, "%sMatch failed%s\n",
     3891201    			  PL_colors[4], PL_colors[5]));
     3891201        if (PL_reg_eval_set)
         609    	restore_pos(aTHX_ 0);
     3891201        return 0;
		}
		
		/*
		 - regtry - try match at specific point
		 */
		STATIC I32			/* 0 failure, 1 success */
		S_regtry(pTHX_ regexp *prog, char *startpos)
    13711296    {
    13711296        register I32 i;
    13711296        register I32 *sp;
    13711296        register I32 *ep;
    13711296        CHECKPOINT lastcp;
    13711296        GET_RE_DEBUG_FLAGS_DECL;
		
		#ifdef DEBUGGING
    13711296        PL_regindent = 0;	/* XXXX Not good when matches are reenterable... */
		#endif
    13711296        if ((prog->reganch & ROPT_EVAL_SEEN) && !PL_reg_eval_set) {
        3820    	MAGIC *mg;
		
        3820    	PL_reg_eval_set = RS_init;
			DEBUG_EXECUTE_r(DEBUG_s(
			    PerlIO_printf(Perl_debug_log, "  setting stack tmpbase at %"IVdf"\n",
					  (IV)(PL_stack_sp - PL_stack_base));
        3820    	    ));
        3820    	SAVEI32(cxstack[cxstack_ix].blk_oldsp);
        3820    	cxstack[cxstack_ix].blk_oldsp = PL_stack_sp - PL_stack_base;
			/* Otherwise OP_NEXTSTATE will free whatever on stack now.  */
        3820    	SAVETMPS;
			/* Apparently this is not needed, judging by wantarray. */
			/* SAVEI8(cxstack[cxstack_ix].blk_gimme);
			   cxstack[cxstack_ix].blk_gimme = G_SCALAR; */
		
        3820    	if (PL_reg_sv) {
			    /* Make $_ available to executed code. */
        3820    	    if (PL_reg_sv != DEFSV) {
        3103    		SAVE_DEFSV;
        3103    		DEFSV = PL_reg_sv;
			    }
			
        3820    	    if (!(SvTYPE(PL_reg_sv) >= SVt_PVMG && SvMAGIC(PL_reg_sv)
				  && (mg = mg_find(PL_reg_sv, PERL_MAGIC_regex_global)))) {
				/* prepare for quick setting of pos */
        2403    		sv_magic(PL_reg_sv, (SV*)0,
					PERL_MAGIC_regex_global, Nullch, 0);
        2403    		mg = mg_find(PL_reg_sv, PERL_MAGIC_regex_global);
        2403    		mg->mg_len = -1;
			    }
        3820    	    PL_reg_magic    = mg;
        3820    	    PL_reg_oldpos   = mg->mg_len;
        3820    	    SAVEDESTRUCTOR_X(restore_pos, 0);
		        }
        3820            if (!PL_reg_curpm) {
          86    	    Newz(22, PL_reg_curpm, 1, PMOP);
		#ifdef USE_ITHREADS
		            {
		                SV* repointer = newSViv(0);
		                /* so we know which PL_regex_padav element is PL_reg_curpm */
		                SvFLAGS(repointer) |= SVf_BREAK;
		                av_push(PL_regex_padav,repointer);
		                PL_reg_curpm->op_pmoffset = av_len(PL_regex_padav);
		                PL_regex_pad = AvARRAY(PL_regex_padav);
		            }
		#endif      
		        }
        3820    	PM_SETRE(PL_reg_curpm, prog);
        3820    	PL_reg_oldcurpm = PL_curpm;
        3820    	PL_curpm = PL_reg_curpm;
        3820    	if (RX_MATCH_COPIED(prog)) {
			    /*  Here is a serious problem: we cannot rewrite subbeg,
				since it may be needed if this match fails.  Thus
				$` inside (?{}) could fail... */
        2460    	    PL_reg_oldsaved = prog->subbeg;
        2460    	    PL_reg_oldsavedlen = prog->sublen;
		#ifdef PERL_OLD_COPY_ON_WRITE
			    PL_nrs = prog->saved_copy;
		#endif
        2460    	    RX_MATCH_COPIED_off(prog);
			}
			else
        1360    	    PL_reg_oldsaved = Nullch;
        3820    	prog->subbeg = PL_bostr;
        3820    	prog->sublen = PL_regeol - PL_bostr; /* strend may have been modified */
		    }
    13711296        prog->startp[0] = startpos - PL_bostr;
    13711296        PL_reginput = startpos;
    13711296        PL_regstartp = prog->startp;
    13711296        PL_regendp = prog->endp;
    13711296        PL_reglastparen = &prog->lastparen;
    13711296        PL_reglastcloseparen = &prog->lastcloseparen;
    13711296        prog->lastparen = 0;
    13711296        prog->lastcloseparen = 0;
    13711296        PL_regsize = 0;
    13711296        DEBUG_EXECUTE_r(PL_reg_starttry = startpos);
    13711296        if (PL_reg_start_tmpl <= prog->nparens) {
       52353    	PL_reg_start_tmpl = prog->nparens*3/2 + 3;
       52353            if(PL_reg_start_tmp)
        8495                Renew(PL_reg_start_tmp, PL_reg_start_tmpl, char*);
		        else
       43858                New(22, PL_reg_start_tmp, PL_reg_start_tmpl, char*);
		    }
		
		    /* XXXX What this code is doing here?!!!  There should be no need
		       to do this again and again, PL_reglastparen should take care of
		       this!  --ilya*/
		
		    /* Tests pat.t#187 and split.t#{13,14} seem to depend on this code.
		     * Actually, the code in regcppop() (which Ilya may be meaning by
		     * PL_reglastparen), is not needed at all by the test suite
		     * (op/regexp, op/pat, op/split), but that code is needed, oddly
		     * enough, for building DynaLoader, or otherwise this
		     * "Error: '*' not in typemap in DynaLoader.xs, line 164"
		     * will happen.  Meanwhile, this code *is* needed for the
		     * above-mentioned test suite tests to succeed.  The common theme
		     * on those tests seems to be returning null fields from matches.
		     * --jhi */
		#if 1
    13711296        sp = prog->startp;
    13711296        ep = prog->endp;
    13711296        if (prog->nparens) {
    13824751    	for (i = prog->nparens; i > (I32)*PL_reglastparen; i--) {
     8775065    	    *++sp = -1;
     8775065    	    *++ep = -1;
			}
		    }
		#endif
    13711296        REGCP_SET(lastcp);
    13711296        if (regmatch(prog->program + 1)) {
     7203471    	prog->endp[0] = PL_reginput - PL_bostr;
     7203471    	return 1;
		    }
     6507824        REGCP_UNWIND(lastcp);
     6507824        return 0;
		}
		
		#define RE_UNWIND_BRANCH	1
		#define RE_UNWIND_BRANCHJ	2
		
		union re_unwind_t;
		
		typedef struct {		/* XX: makes sense to enlarge it... */
		    I32 type;
		    I32 prev;
		    CHECKPOINT lastcp;
		} re_unwind_generic_t;
		
		typedef struct {
		    I32 type;
		    I32 prev;
		    CHECKPOINT lastcp;
		    I32 lastparen;
		    regnode *next;
		    char *locinput;
		    I32 nextchr;
		#ifdef DEBUGGING
		    int regindent;
		#endif
		} re_unwind_branch_t;
		
		typedef union re_unwind_t {
		    I32 type;
		    re_unwind_generic_t generic;
		    re_unwind_branch_t branch;
		} re_unwind_t;
		
		#define sayYES goto yes
		#define sayNO goto no
		#define sayNO_ANYOF goto no_anyof
		#define sayYES_FINAL goto yes_final
		#define sayYES_LOUD  goto yes_loud
		#define sayNO_FINAL  goto no_final
		#define sayNO_SILENT goto do_no
		#define saySAME(x) if (x) goto yes; else goto no
		
		#define POSCACHE_SUCCESS 0	/* caching success rather than failure */
		#define POSCACHE_SEEN 1		/* we know what we're caching */
		#define POSCACHE_START 2	/* the real cache: this bit maps to pos 0 */
		#define CACHEsayYES STMT_START { \
		    if (cache_offset | cache_bit) { \
			if (!(PL_reg_poscache[0] & (1<<POSCACHE_SEEN))) \
			    PL_reg_poscache[0] |= (1<<POSCACHE_SUCCESS) || (1<<POSCACHE_SEEN); \
		        else if (!(PL_reg_poscache[0] & (1<<POSCACHE_SUCCESS))) { \
			    /* cache records failure, but this is success */ \
			    DEBUG_r( \
				PerlIO_printf(Perl_debug_log, \
				    "%*s  (remove success from failure cache)\n", \
				    REPORT_CODE_OFF+PL_regindent*2, "") \
			    ); \
			    PL_reg_poscache[cache_offset] &= ~(1<<cache_bit); \
			} \
		    } \
		    sayYES; \
		} STMT_END
		#define CACHEsayNO STMT_START { \
		    if (cache_offset | cache_bit) { \
			if (!(PL_reg_poscache[0] & (1<<POSCACHE_SEEN))) \
			    PL_reg_poscache[0] |= (1<<POSCACHE_SEEN); \
		        else if ((PL_reg_poscache[0] & (1<<POSCACHE_SUCCESS))) { \
			    /* cache records success, but this is failure */ \
			    DEBUG_r( \
				PerlIO_printf(Perl_debug_log, \
				    "%*s  (remove failure from success cache)\n", \
				    REPORT_CODE_OFF+PL_regindent*2, "") \
			    ); \
			    PL_reg_poscache[cache_offset] &= ~(1<<cache_bit); \
			} \
		    } \
		    sayNO; \
		} STMT_END
		
		/* this is used to determine how far from the left messages like
		   'failed...' are printed. Currently 29 makes these messages line
		   up with the opcode they refer to. Earlier perls used 25 which
		   left these messages outdented making reviewing a debug output
		   quite difficult.
		*/
		#define REPORT_CODE_OFF 29
		
		
		/* Make sure there is a test for this +1 options in re_tests */
		#define TRIE_INITAL_ACCEPT_BUFFLEN 4;
		
		#define TRIE_CHECK_STATE_IS_ACCEPTING STMT_START {                       \
		    if ( trie->states[ state ].wordnum ) {                               \
			if ( !accepted ) {                                               \
			    ENTER;                                                       \
			    SAVETMPS;                                                    \
			    bufflen = TRIE_INITAL_ACCEPT_BUFFLEN ;                       \
			    sv_accept_buff=NEWSV( 1234,                                  \
			      bufflen * sizeof(reg_trie_accepted) - 1 );                 \
			    SvCUR_set( sv_accept_buff, sizeof(reg_trie_accepted) );      \
			    SvPOK_on( sv_accept_buff );                                  \
			    sv_2mortal( sv_accept_buff );                                \
			    accept_buff = (reg_trie_accepted*)SvPV_nolen( sv_accept_buff );\
			} else {                                                         \
			    if ( accepted >= bufflen ) {                                 \
			        bufflen *= 2;                                            \
			        accept_buff =(reg_trie_accepted*)SvGROW( sv_accept_buff, \
			            bufflen * sizeof(reg_trie_accepted) );               \
			    }                                                            \
			    SvCUR_set( sv_accept_buff,SvCUR( sv_accept_buff )            \
			        + sizeof( reg_trie_accepted ) );                         \
			}                                                                \
			accept_buff[ accepted ].wordnum = trie->states[ state ].wordnum; \
			accept_buff[ accepted ].endpos = uc;                             \
			++accepted;                                                      \
		    } } STMT_END
		
		#define TRIE_HANDLE_CHAR STMT_START {                                   \
		        if ( uvc < 256 ) {                                              \
		            charid = trie->charmap[ uvc ];                              \
		        } else {                                                        \
		            charid = 0;                                                 \
		            if( trie->widecharmap ) {                                   \
		            SV** svpp = (SV**)NULL;                                     \
		            svpp = hv_fetch( trie->widecharmap, (char*)&uvc,            \
		        		  sizeof( UV ), 0 );                            \
		            if ( svpp ) {                                               \
		        	charid = (U16)SvIV( *svpp );                            \
		                }                                                       \
		            }                                                           \
		        }                                                               \
		        if ( charid &&                                                  \
		             ( base + charid > trie->uniquecharcount ) &&               \
		             ( base + charid - 1 - trie->uniquecharcount < trie->lasttrans) && \
		             trie->trans[ base + charid - 1 - trie->uniquecharcount ].check == state ) \
		        {                                                               \
		            state = trie->trans[ base + charid - 1 - trie->uniquecharcount ].next;     \
		        } else {                                                        \
		            state = 0;                                                  \
		        }                                                               \
		        uc += len;                                                      \
		    } STMT_END
		
		/*
		 - regmatch - main matching routine
		 *
		 * Conceptually the strategy is simple:  check to see whether the current
		 * node matches, call self recursively to see whether the rest matches,
		 * and then act accordingly.  In practice we make some effort to avoid
		 * recursion, in particular by going through "ordinary" nodes (that don't
		 * need to know whether the rest of the match failed) by a loop instead of
		 * by recursion.
		 */
		/* [lwall] I've hoisted the register declarations to the outer block in order to
		 * maybe save a little bit of pushing and popping on the stack.  It also takes
		 * advantage of machines that use a register save mask on subroutine entry.
		 */
		STATIC I32			/* 0 failure, 1 success */
		S_regmatch(pTHX_ regnode *prog)
    28953002    {
		    dVAR;
    28953002        register regnode *scan;	/* Current node. */
    28953002        regnode *next;		/* Next node. */
    28953002        regnode *inner;		/* Next node in internal branch. */
    28953002        register I32 nextchr;	/* renamed nextchr - nextchar colides with
						   function of same name */
    28953002        register I32 n;		/* no or next */
    28953002        register I32 ln = 0;	/* len or last */
    28953002        register char *s = Nullch;	/* operand or save */
    28953002        register char *locinput = PL_reginput;
    28953002        register I32 c1 = 0, c2 = 0, paren;	/* case fold search, parenth */
    28953002        int minmod = 0, sw = 0, logical = 0;
    28953002        I32 unwind = 0;
		
		    /* used by the trie code */
    28953002        SV                 *sv_accept_buff = 0;  /* accepting states we have traversed */
    28953002        reg_trie_accepted  *accept_buff = 0;     /* "" */
    28953002        reg_trie_data      *trie;                /* what trie are we using right now */
    28953002        U32 accepted = 0;                        /* how many accepting states we have seen*/
		
		#if 0
		    I32 firstcp = PL_savestack_ix;
		#endif
    28953002        const register bool do_utf8 = PL_reg_match_utf8;
		#ifdef DEBUGGING
    28953002        SV *dsv0 = PERL_DEBUG_PAD_ZERO(0);
    28953002        SV *dsv1 = PERL_DEBUG_PAD_ZERO(1);
    28953002        SV *dsv2 = PERL_DEBUG_PAD_ZERO(2);
		
    28953002        SV *re_debug_flags = NULL;
		#endif
		
    28953002        GET_RE_DEBUG_FLAGS;
		
		#ifdef DEBUGGING
    28953002        PL_regindent++;
		#endif
		
		
		    /* Note that nextchr is a byte even in UTF */
    28953002        nextchr = UCHARAT(locinput);
    28953002        scan = prog;
    63107958        while (scan != NULL) {
		
		        DEBUG_EXECUTE_r( {
			    SV *prop = sv_newmortal();
			    const int docolor = *PL_colors[0];
			    const int taill = (docolor ? 10 : 7); /* 3 chars for "> <" */
			    int l = (PL_regeol - locinput) > taill ? taill : (PL_regeol - locinput);
			    /* The part of the string before starttry has one color
			       (pref0_len chars), between starttry and current
			       position another one (pref_len - pref0_len chars),
			       after the current position the third one.
			       We assume that pref0_len <= pref_len, otherwise we
			       decrease pref0_len.  */
			    int pref_len = (locinput - PL_bostr) > (5 + taill) - l
				? (5 + taill) - l : locinput - PL_bostr;
			    int pref0_len;
		
			    while (do_utf8 && UTF8_IS_CONTINUATION(*(U8*)(locinput - pref_len)))
				pref_len++;
			    pref0_len = pref_len  - (locinput - PL_reg_starttry);
			    if (l + pref_len < (5 + taill) && l < PL_regeol - locinput)
				l = ( PL_regeol - locinput > (5 + taill) - pref_len
				      ? (5 + taill) - pref_len : PL_regeol - locinput);
			    while (do_utf8 && UTF8_IS_CONTINUATION(*(U8*)(locinput + l)))
				l--;
			    if (pref0_len < 0)
				pref0_len = 0;
			    if (pref0_len > pref_len)
				pref0_len = pref_len;
			    regprop(prop, scan);
			    {
			      const char * const s0 =
				do_utf8 && OP(scan) != CANY ?
				pv_uni_display(dsv0, (U8*)(locinput - pref_len),
					       pref0_len, 60, UNI_DISPLAY_REGEX) :
				locinput - pref_len;
			      const int len0 = do_utf8 ? strlen(s0) : pref0_len;
			      const char * const s1 = do_utf8 && OP(scan) != CANY ?
				pv_uni_display(dsv1, (U8*)(locinput - pref_len + pref0_len),
					       pref_len - pref0_len, 60, UNI_DISPLAY_REGEX) :
				locinput - pref_len + pref0_len;
			      const int len1 = do_utf8 ? strlen(s1) : pref_len - pref0_len;
			      const char * const s2 = do_utf8 && OP(scan) != CANY ?
				pv_uni_display(dsv2, (U8*)locinput,
					       PL_regeol - locinput, 60, UNI_DISPLAY_REGEX) :
				locinput;
			      const int len2 = do_utf8 ? strlen(s2) : l;
			      PerlIO_printf(Perl_debug_log,
					    "%4"IVdf" <%s%.*s%s%s%.*s%s%s%s%.*s%s>%*s|%3"IVdf":%*s%s\n",
					    (IV)(locinput - PL_bostr),
					    PL_colors[4],
					    len0, s0,
					    PL_colors[5],
					    PL_colors[2],
					    len1, s1,
					    PL_colors[3],
					    (docolor ? "" : "> <"),
					    PL_colors[0],
					    len2, s2,
					    PL_colors[1],
					    15 - l - pref_len + 1,
					    "",
					    (IV)(scan - PL_regprogram), PL_regindent*2, "",
					    SvPVX_const(prop));
			    }
    63107958    	});
		
    63107958    	next = scan + NEXT_OFF(scan);
    63107958    	if (next == scan)
    10473303    	    next = NULL;
		
    63107958    	switch (OP(scan)) {
			case BOL:
     4164077    	    if (locinput == PL_bostr)
			    {
				/* regtill = regbol; */
     3026145    		break;
			    }
      929551    	    sayNO;
			case MBOL:
      929551    	    if (locinput == PL_bostr ||
				((nextchr || locinput < PL_regeol) && locinput[-1] == '\n'))
			    {
       43150    		break;
			    }
       43150    	    sayNO;
			case SBOL:
       43150    	    if (locinput == PL_bostr)
       37509    		break;
      978427    	    sayNO;
			case GPOS:
      978427    	    if (locinput == PL_reg_ganch)
      974706    		break;
         911    	    sayNO;
			case EOL:
         911    		goto seol;
			case MEOL:
         911    	    if ((nextchr || locinput < PL_regeol) && nextchr != '\n')
          79    		sayNO;
     1345196    	    break;
			case SEOL:
			  seol:
     1345196    	    if ((nextchr || locinput < PL_regeol) && nextchr != '\n')
      730887    		sayNO;
      614309    	    if (PL_regeol - locinput > 1)
         610    		sayNO;
      129257    	    break;
			case EOS:
      129257    	    if (PL_regeol != locinput)
       89583    		sayNO;
       26157    	    break;
			case SANY:
       26157    	    if (!nextchr && locinput >= PL_regeol)
      ######    		sayNO;
       26157     	    if (do_utf8) {
          25    	        locinput += PL_utf8skip[nextchr];
          25    		if (locinput > PL_regeol)
      ######     		    sayNO;
          25     		nextchr = UCHARAT(locinput);
		 	    }
		 	    else
       26132     		nextchr = UCHARAT(++locinput);
       26132    	    break;
			case CANY:
          67    	    if (!nextchr && locinput >= PL_regeol)
      ######    		sayNO;
          67    	    nextchr = UCHARAT(++locinput);
          67    	    break;
			case REG_ANY:
       92793    	    if ((!nextchr && locinput >= PL_regeol) || nextchr == '\n')
       92640    		sayNO;
       92640    	    if (do_utf8) {
       30015    		locinput += PL_utf8skip[nextchr];
       30015    		if (locinput > PL_regeol)
      ######    		    sayNO;
       30015    		nextchr = UCHARAT(locinput);
			    }
			    else
       62625    		nextchr = UCHARAT(++locinput);
       62625    	    break;
		
		
		
			/*
			   traverse the TRIE keeping track of all accepting states
			   we transition through until we get to a failing node.
		
			   we use two slightly different pieces of code to handle
			   the traversal depending on whether its case sensitive or
			   not. we reuse the accept code however. (this should probably
			   be turned into a macro.)
		
			*/
			case TRIEF:
			case TRIEFL:
			    {
		
       11982    		const U32 uniflags = ckWARN( WARN_UTF8 ) ? 0 : UTF8_ALLOW_ANY;
       11982    		U8 *uc = ( U8* )locinput;
       11982    		U32 state = 1;
       11982    		U16 charid = 0;
       11982    		U32 base = 0;
       11982    		UV uvc = 0;
       11982    		STRLEN len = 0;
       11982    		STRLEN foldlen = 0;
       11982    		U8 *uscan = (U8*)NULL;
       11982    		STRLEN bufflen=0;
       11982    		accepted = 0;
		
       11982    		trie = (reg_trie_data*)PL_regdata->data[ ARG( scan ) ];
		
       29707    		while ( state && uc <= (U8*)PL_regeol ) {
		
       17725    		    TRIE_CHECK_STATE_IS_ACCEPTING;
		
       17725    		    base = trie->states[ state ].trans.base;
		
				    DEBUG_TRIE_EXECUTE_r(
					        PerlIO_printf( Perl_debug_log,
					            "%*s  %sState: %4"UVxf", Base: %4"UVxf", Accepted: %4"UVxf" ",
					            REPORT_CODE_OFF + PL_regindent * 2, "", PL_colors[4],
					            (UV)state, (UV)base, (UV)accepted );
       17725    		    );
		
       17725    		    if ( base ) {
		
       16653    			if ( do_utf8 || UTF ) {
         128    			    if ( foldlen>0 ) {
           5    				uvc = utf8n_to_uvuni( uscan, UTF8_MAXLEN, &len, uniflags );
           5    				foldlen -= len;
           5    				uscan += len;
           5    				len=0;
					    } else {
         123    				U8 foldbuf[ UTF8_MAXBYTES_CASE + 1 ];
         123    				uvc = utf8n_to_uvuni( (U8*)uc, UTF8_MAXLEN, &len, uniflags );
         123    				uvc = to_uni_fold( uvc, foldbuf, &foldlen );
         123    				foldlen -= UNISKIP( uvc );
         123    				uscan = foldbuf + UNISKIP( uvc );
					    }
					} else {
       16525    			    uvc = (UV)*uc;
       16525    			    len = 1;
					}
		
       16653    			TRIE_HANDLE_CHAR;
		
				    } else {
        1072    			state = 0;
				    }
				    DEBUG_TRIE_EXECUTE_r(
				        PerlIO_printf( Perl_debug_log,
				            "Charid:%3x CV:%4"UVxf" After State: %4"UVxf"%s\n",
				            charid, uvc, (UV)state, PL_colors[5] );
       17725    		    );
				}
       11982    		if ( !accepted ) {
       10575    		   sayNO;
				} else {
      315460    		    goto TrieAccept;
				}
			    }
			    /* unreached codepoint: we jump into the middle of the next case
			       from previous if blocks */
			case TRIE:
			    {
      315460    		const U32 uniflags = ckWARN( WARN_UTF8 ) ? 0 : UTF8_ALLOW_ANY;
      315460    		U8 *uc = (U8*)locinput;
      315460    		U32 state = 1;
      315460    		U16 charid = 0;
      315460    		U32 base = 0;
      315460    		UV uvc = 0;
      315460    		STRLEN len = 0;
      315460    		STRLEN bufflen = 0;
      315460    		accepted = 0;
		
      315460    		trie = (reg_trie_data*)PL_regdata->data[ ARG( scan ) ];
		
      737722    		while ( state && uc <= (U8*)PL_regeol ) {
		
      422262    		    TRIE_CHECK_STATE_IS_ACCEPTING;
		
      422262    		    base = trie->states[ state ].trans.base;
		
				    DEBUG_TRIE_EXECUTE_r(
					    PerlIO_printf( Perl_debug_log,
					        "%*s  %sState: %4"UVxf", Base: %4"UVxf", Accepted: %4"UVxf" ",
					        REPORT_CODE_OFF + PL_regindent * 2, "", PL_colors[4],
					        (UV)state, (UV)base, (UV)accepted );
      422262    		    );
		
      422262    		    if ( base ) {
		
      401723    			if ( do_utf8 || UTF ) {
        1873    			    uvc = utf8n_to_uvuni( (U8*)uc, UTF8_MAXLEN, &len, uniflags );
					} else {
      399850    			    uvc = (U32)*uc;
      399850    			    len = 1;
					}
		
      401723                            TRIE_HANDLE_CHAR;
		
				    } else {
       20539    			state = 0;
				    }
				    DEBUG_TRIE_EXECUTE_r(
					    PerlIO_printf( Perl_debug_log,
					        "Charid:%3x CV:%4"UVxf" After State: %4"UVxf"%s\n",
					        charid, uvc, (UV)state, PL_colors[5] );
      422262    		    );
				}
      315460    		if ( !accepted ) {
      290835    		   sayNO;
				}
			    }
		
		
			    /*
			       There was at least one accepting state that we
			       transitioned through. Presumably the number of accepting
			       states is going to be low, typically one or two. So we
			       simply scan through to find the one with lowest wordnum.
			       Once we find it, we swap the last state into its place
			       and decrement the size. We then try to match the rest of
			       the pattern at the point where the word ends, if we
			       succeed then we end the loop, otherwise the loop
			       eventually terminates once all of the accepting states
			       have been tried.
			    */
			TrieAccept:
			    {
       26032    		int gotit = 0;
		
       26032    		if ( accepted == 1 ) {
				    DEBUG_EXECUTE_r({
		                        SV **tmp = av_fetch( trie->words, accept_buff[ 0 ].wordnum-1, 0 );
		       	                PerlIO_printf( Perl_debug_log,
					    "%*s  %sonly one match : #%d <%s>%s\n",
					    REPORT_CODE_OFF+PL_regindent*2, "", PL_colors[4],
		        		    accept_buff[ 0 ].wordnum,
		        		    tmp ? SvPV_nolen_const( *tmp ) : "not compiled under -Dr",
		        		    PL_colors[5] );
       24524    		    });
       24524    		    PL_reginput = (char *)accept_buff[ 0 ].endpos;
				    /* in this case we free tmps/leave before we call regmatch
				       as we wont be using accept_buff again. */
       24524    		    FREETMPS;
       24524    		    LEAVE;
       24524    		    gotit = regmatch( scan + NEXT_OFF( scan ) );
				} else {
		                    DEBUG_EXECUTE_r(
		                        PerlIO_printf( Perl_debug_log,"%*s  %sgot %"IVdf" possible matches%s\n",
		                            REPORT_CODE_OFF + PL_regindent * 2, "", PL_colors[4], (IV)accepted,
		                            PL_colors[5] );
        1508                        );
        5128    		    while ( !gotit && accepted-- ) {
        3620    			U32 best = 0;
        3620    			U32 cur;
        9506    			for( cur = 1 ; cur <= accepted ; cur++ ) {
					    DEBUG_TRIE_EXECUTE_r(
					        PerlIO_printf( Perl_debug_log,
					            "%*s  %sgot %"IVdf" (%d) as best, looking at %"IVdf" (%d)%s\n",
					            REPORT_CODE_OFF + PL_regindent * 2, "", PL_colors[4],
					            (IV)best, accept_buff[ best ].wordnum, (IV)cur,
					            accept_buff[ cur ].wordnum, PL_colors[5] );
        5886    			    );
		
        5886    			    if ( accept_buff[ cur ].wordnum < accept_buff[ best ].wordnum )
        2424    				    best = cur;
					}
					DEBUG_EXECUTE_r({
				            SV **tmp = av_fetch( trie->words, accept_buff[ best ].wordnum - 1, 0 );
		    			    PerlIO_printf( Perl_debug_log, "%*s  %strying alternation #%d <%s> at 0x%p%s\n",
		    			        REPORT_CODE_OFF+PL_regindent*2, "", PL_colors[4],
		    			        accept_buff[best].wordnum,
		        		        tmp ? SvPV_nolen_const( *tmp ) : "not compiled under -Dr",scan,
		        		        PL_colors[5] );
        3620    			});
        3620    			if ( best<accepted ) {
        1592    			    reg_trie_accepted tmp = accept_buff[ best ];
        1592    			    accept_buff[ best ] = accept_buff[ accepted ];
        1592    			    accept_buff[ accepted ] = tmp;
        1592    			    best = accepted;
					}
        3620    			PL_reginput = (char *)accept_buff[ best ].endpos;
		
		                        /* 
		                           as far as I can tell we only need the SAVETMPS/FREETMPS 
		                           for re's with EVAL in them but I'm leaving them in for 
		                           all until I can be sure.
		                         */
        3620    			SAVETMPS;
        3620    			gotit = regmatch( scan + NEXT_OFF( scan ) ) ;
        3620    			FREETMPS;
				    }
        1508    		    FREETMPS;
        1508    		    LEAVE;
				}
				
       26032    		if ( gotit ) {
       24925    		    sayYES;
				} else {
     6811226    		    sayNO;
				}
			    }
			    /* unreached codepoint */
			case EXACT:
     6811226    	    s = STRING(scan);
     6811226    	    ln = STR_LEN(scan);
     6811226    	    if (do_utf8 != UTF) {
				/* The target and the pattern have differing utf8ness. */
        5781    		char *l = locinput;
        5781    		const char *e = s + ln;
		
        5781    		if (do_utf8) {
				    /* The target is utf8, the pattern is not utf8. */
       12364    		    while (s < e) {
        9278    			STRLEN ulen;
        9278    			if (l >= PL_regeol)
           8    			     sayNO;
        9270    			if (NATIVE_TO_UNI(*(U8*)s) !=
					    utf8n_to_uvuni((U8*)l, UTF8_MAXBYTES, &ulen,
							   ckWARN(WARN_UTF8) ?
							   0 : UTF8_ALLOW_ANY))
        2604    			     sayNO;
        6666    			l += ulen;
        6666    			s ++;
				    }
				}
				else {
				    /* The target is not utf8, the pattern is utf8. */
         292    		    while (s < e) {
         243    			STRLEN ulen;
         243    			if (l >= PL_regeol)
           3    			    sayNO;
         240    			if (NATIVE_TO_UNI(*((U8*)l)) !=
					    utf8n_to_uvuni((U8*)s, UTF8_MAXBYTES, &ulen,
							   ckWARN(WARN_UTF8) ?
							   0 : UTF8_ALLOW_ANY))
          31    			    sayNO;
         209    			s += ulen;
         209    			l ++;
				    }
				}
        3135    		locinput = l;
        3135    		nextchr = UCHARAT(locinput);
        3135    		break;
			    }
			    /* The target and the pattern have the same utf8ness. */
			    /* Inline the first character, for speed. */
     6805445    	    if (UCHARAT(s) != nextchr)
     2767374    		sayNO;
     4038071    	    if (PL_regeol - locinput < ln)
        1566    		sayNO;
     4036505    	    if (ln > 1 && memNE(s, locinput, ln))
      403101    		sayNO;
     3633404    	    locinput += ln;
     3633404    	    nextchr = UCHARAT(locinput);
     3633404    	    break;
			case EXACTFL:
     1696542    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case EXACTF:
     1824337    	    s = STRING(scan);
     1824337    	    ln = STR_LEN(scan);
		
     1824337    	    if (do_utf8 || UTF) {
			      /* Either target or the pattern are utf8. */
        8907    		char *l = locinput;
        8907    		char *e = PL_regeol;
		
        8907    		if (ibcmp_utf8(s, 0,  ln, (bool)UTF,
					       l, &e, 0,  do_utf8)) {
				     /* One more case for the sharp s:
				      * pack("U0U*", 0xDF) =~ /ss/i,
				      * the 0xC3 0x9F are the UTF-8
				      * byte sequence for the U+00DF. */
          15    		     if (!(do_utf8 &&
					   toLOWER(s[0]) == 's' &&
					   ln >= 2 &&
					   toLOWER(s[1]) == 's' &&
					   (U8)l[0] == 0xC3 &&
					   e - l >= 2 &&
					   (U8)l[1] == 0x9F))
        8892    			  sayNO;
				}
        8892    		locinput = e;
        8892    		nextchr = UCHARAT(locinput);
        8892    		break;
			    }
		
			    /* Neither the target and the pattern are utf8. */
		
			    /* Inline the first character, for speed. */
     1815430    	    if (UCHARAT(s) != nextchr &&
				UCHARAT(s) != ((OP(scan) == EXACTF)
					       ? PL_fold : PL_fold_locale)[nextchr])
      107856    		sayNO;
     1707574    	    if (PL_regeol - locinput < ln)
         355    		sayNO;
     1707219    	    if (ln > 1 && (OP(scan) == EXACTF
					   ? ibcmp(s, locinput, ln)
					   : ibcmp_locale(s, locinput, ln)))
     1705025    		sayNO;
     1705025    	    locinput += ln;
     1705025    	    nextchr = UCHARAT(locinput);
     1705025    	    break;
			case ANYOF:
     4437711    	    if (do_utf8) {
       22504    	        STRLEN inclasslen = PL_regeol - locinput;
		
       22504    	        if (!reginclass(scan, (U8*)locinput, &inclasslen, do_utf8))
        2370    		    sayNO_ANYOF;
       20134    		if (locinput >= PL_regeol)
           3    		    sayNO;
       20131    		locinput += inclasslen ? inclasslen : UTF8SKIP(locinput);
       20131    		nextchr = UCHARAT(locinput);
       20131    		break;
			    }
			    else {
     4415207    		if (nextchr < 0)
      ######    		    nextchr = UCHARAT(locinput);
     4415207    		if (!REGINCLASS(scan, (U8*)locinput))
     1051159    		    sayNO_ANYOF;
     2956545    		if (!nextchr && locinput >= PL_regeol)
       31328    		    sayNO;
     2925217    		nextchr = UCHARAT(++locinput);
     2925217    		break;
			    }
			no_anyof:
			    /* If we might have the case of the German sharp s
			     * in a casefolding Unicode character class. */
		
     1461032    	    if (ANYOF_FOLD_SHARP_S(scan, locinput, PL_regeol)) {
           2    		 locinput += SHARP_S_SKIP;
           2    		 nextchr = UCHARAT(locinput);
			    }
			    else
       77601    		 sayNO;
       77601    	    break;
			case ALNUML:
       77601    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case ALNUM:
       84447    	    if (!nextchr)
           2    		sayNO;
       84445    	    if (do_utf8) {
          35    		LOAD_UTF8_CHARCLASS_ALNUM();
          35    		if (!(OP(scan) == ALNUM
				      ? swash_fetch(PL_utf8_alnum, (U8*)locinput, do_utf8)
				      : isALNUM_LC_utf8((U8*)locinput)))
				{
      ######    		    sayNO;
				}
          35    		locinput += PL_utf8skip[nextchr];
          35    		nextchr = UCHARAT(locinput);
          35    		break;
			    }
       84410    	    if (!(OP(scan) == ALNUM
				  ? isALNUM(nextchr) : isALNUM_LC(nextchr)))
       84323    		sayNO;
       84323    	    nextchr = UCHARAT(++locinput);
       84323    	    break;
			case NALNUML:
       22964    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case NALNUM:
       59276    	    if (!nextchr && locinput >= PL_regeol)
          96    		sayNO;
       59180    	    if (do_utf8) {
      ######    		LOAD_UTF8_CHARCLASS_ALNUM();
      ######    		if (OP(scan) == NALNUM
				    ? swash_fetch(PL_utf8_alnum, (U8*)locinput, do_utf8)
				    : isALNUM_LC_utf8((U8*)locinput))
				{
      ######    		    sayNO;
				}
      ######    		locinput += PL_utf8skip[nextchr];
      ######    		nextchr = UCHARAT(locinput);
      ######    		break;
			    }
       59180    	    if (OP(scan) == NALNUM
				? isALNUM(nextchr) : isALNUM_LC(nextchr))
       41624    		sayNO;
       41624    	    nextchr = UCHARAT(++locinput);
       41624    	    break;
			case BOUNDL:
			case NBOUNDL:
         128    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case BOUND:
			case NBOUND:
			    /* was last char in word? */
      416361    	    if (do_utf8) {
          14    		if (locinput == PL_bostr)
          10    		    ln = '\n';
				else {
           4    		    const U8 * const r = reghop3((U8*)locinput, -1, (U8*)PL_bostr);
				
           4    		    ln = utf8n_to_uvchr(r, UTF8SKIP(r), 0, 0);
				}
          14    		if (OP(scan) == BOUND || OP(scan) == NBOUND) {
          14    		    ln = isALNUM_uni(ln);
          14    		    LOAD_UTF8_CHARCLASS_ALNUM();
          14    		    n = swash_fetch(PL_utf8_alnum, (U8*)locinput, do_utf8);
				}
				else {
      ######    		    ln = isALNUM_LC_uvchr(UNI_TO_NATIVE(ln));
      ######    		    n = isALNUM_LC_utf8((U8*)locinput);
				}
			    }
			    else {
      416347    		ln = (locinput != PL_bostr) ?
				    UCHARAT(locinput - 1) : '\n';
      416347    		if (OP(scan) == BOUND || OP(scan) == NBOUND) {
      416219    		    ln = isALNUM(ln);
      416219    		    n = isALNUM(nextchr);
				}
				else {
         128    		    ln = isALNUM_LC(ln);
         128    		    n = isALNUM_LC(nextchr);
				}
			    }
      416361    	    if (((!ln) == (!n)) == (OP(scan) == BOUND ||
						    OP(scan) == BOUNDL))
      189276    		    sayNO;
        7681    	    break;
			case SPACEL:
        7681    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case SPACE:
      224272    	    if (!nextchr)
         350    		sayNO;
      223922    	    if (do_utf8) {
           4    		if (UTF8_IS_CONTINUED(nextchr)) {
           4    		    LOAD_UTF8_CHARCLASS_SPACE();
           4    		    if (!(OP(scan) == SPACE
					  ? swash_fetch(PL_utf8_space, (U8*)locinput, do_utf8)
					  : isSPACE_LC_utf8((U8*)locinput)))
				    {
      ######    			sayNO;
				    }
           4    		    locinput += PL_utf8skip[nextchr];
           4    		    nextchr = UCHARAT(locinput);
           4    		    break;
				}
      ######    		if (!(OP(scan) == SPACE
				      ? isSPACE(nextchr) : isSPACE_LC(nextchr)))
      ######    		    sayNO;
      ######    		nextchr = UCHARAT(++locinput);
			    }
			    else {
      223918    		if (!(OP(scan) == SPACE
				      ? isSPACE(nextchr) : isSPACE_LC(nextchr)))
        5471    		    sayNO;
      117258    		nextchr = UCHARAT(++locinput);
			    }
      117258    	    break;
			case NSPACEL:
        4947    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case NSPACE:
      109241    	    if (!nextchr && locinput >= PL_regeol)
          94    		sayNO;
      109147    	    if (do_utf8) {
           3    		LOAD_UTF8_CHARCLASS_SPACE();
           3    		if (OP(scan) == NSPACE
				    ? swash_fetch(PL_utf8_space, (U8*)locinput, do_utf8)
				    : isSPACE_LC_utf8((U8*)locinput))
				{
           3    		    sayNO;
				}
           3    		locinput += PL_utf8skip[nextchr];
           3    		nextchr = UCHARAT(locinput);
           3    		break;
			    }
      109144    	    if (OP(scan) == NSPACE
				? isSPACE(nextchr) : isSPACE_LC(nextchr))
       95889    		sayNO;
       95889    	    nextchr = UCHARAT(++locinput);
       95889    	    break;
			case DIGITL:
      ######    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case DIGIT:
       63233    	    if (!nextchr)
           6    		sayNO;
       63227    	    if (do_utf8) {
           2    		LOAD_UTF8_CHARCLASS_DIGIT();
           2    		if (!(OP(scan) == DIGIT
				      ? swash_fetch(PL_utf8_digit, (U8*)locinput, do_utf8)
				      : isDIGIT_LC_utf8((U8*)locinput)))
				{
      ######    		    sayNO;
				}
           1    		locinput += PL_utf8skip[nextchr];
           1    		nextchr = UCHARAT(locinput);
           1    		break;
			    }
       63225    	    if (!(OP(scan) == DIGIT
				  ? isDIGIT(nextchr) : isDIGIT_LC(nextchr)))
      ######    		sayNO;
        3877    	    nextchr = UCHARAT(++locinput);
        3877    	    break;
			case NDIGITL:
      ######    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
			case NDIGIT:
         526    	    if (!nextchr && locinput >= PL_regeol)
      ######    		sayNO;
         526    	    if (do_utf8) {
      ######    		LOAD_UTF8_CHARCLASS_DIGIT();
      ######    		if (OP(scan) == NDIGIT
				    ? swash_fetch(PL_utf8_digit, (U8*)locinput, do_utf8)
				    : isDIGIT_LC_utf8((U8*)locinput))
				{
      ######    		    sayNO;
				}
      ######    		locinput += PL_utf8skip[nextchr];
      ######    		nextchr = UCHARAT(locinput);
      ######    		break;
			    }
         526    	    if (OP(scan) == NDIGIT
				? isDIGIT(nextchr) : isDIGIT_LC(nextchr))
         526    		sayNO;
         526    	    nextchr = UCHARAT(++locinput);
         526    	    break;
			case CLUMP:
          11    	    if (locinput >= PL_regeol)
      ######    		sayNO;
          11    	    if  (do_utf8) {
           7    		LOAD_UTF8_CHARCLASS_MARK();
           7    		if (swash_fetch(PL_utf8_mark,(U8*)locinput, do_utf8))
      ######    		    sayNO;
           7    		locinput += PL_utf8skip[nextchr];
          10    		while (locinput < PL_regeol &&
				       swash_fetch(PL_utf8_mark,(U8*)locinput, do_utf8))
           3    		    locinput += UTF8SKIP(locinput);
           7    		if (locinput > PL_regeol)
      ######    		    sayNO;
			    } 
			    else
           4    	       locinput++;
          11    	    nextchr = UCHARAT(locinput);
          11    	    break;
			case REFFL:
      ######    	    PL_reg_flags |= RF_tainted;
			    /* FALL THROUGH */
		        case REF:
			case REFF:
        7136    	    n = ARG(scan);  /* which paren pair */
        7136    	    ln = PL_regstartp[n];
        7136    	    PL_reg_leftiter = PL_reg_maxiter;		/* Void cache */
        7136    	    if ((I32)*PL_reglastparen < n || ln == -1)
        6686    		sayNO;			/* Do not match unless seen CLOSEn. */
        6686    	    if (ln == PL_regendp[n])
          10    		break;
		
        6676    	    s = PL_bostr + ln;
        6676    	    if (do_utf8 && OP(scan) != REF) {	/* REF can do byte comparison */
      ######    		char *l = locinput;
      ######    		const char *e = PL_bostr + PL_regendp[n];
				/*
				 * Note that we can't do the "other character" lookup trick as
				 * in the 8-bit case (no pun intended) because in Unicode we
				 * have to map both upper and title case to lower case.
				 */
      ######    		if (OP(scan) == REFF) {
      ######    		    while (s < e) {
      ######    			STRLEN ulen1, ulen2;
      ######    			U8 tmpbuf1[UTF8_MAXBYTES_CASE+1];
      ######    			U8 tmpbuf2[UTF8_MAXBYTES_CASE+1];
		
      ######    			if (l >= PL_regeol)
      ######    			    sayNO;
      ######    			toLOWER_utf8((U8*)s, tmpbuf1, &ulen1);
      ######    			toLOWER_utf8((U8*)l, tmpbuf2, &ulen2);
      ######    			if (ulen1 != ulen2 || memNE((char *)tmpbuf1, (char *)tmpbuf2, ulen1))
      ######    			    sayNO;
      ######    			s += ulen1;
      ######    			l += ulen2;
				    }
				}
      ######    		locinput = l;
      ######    		nextchr = UCHARAT(locinput);
      ######    		break;
			    }
		
			    /* Inline the first character, for speed. */
        6676    	    if (UCHARAT(s) != nextchr &&
				(OP(scan) == REF ||
				 (UCHARAT(s) != ((OP(scan) == REFF
						  ? PL_fold : PL_fold_locale)[nextchr]))))
        2280    		sayNO;
        2280    	    ln = PL_regendp[n] - ln;
        2280    	    if (locinput + ln > PL_regeol)
         110    		sayNO;
        2170    	    if (ln > 1 && (OP(scan) == REF
					   ? memNE(s, locinput, ln)
					   : (OP(scan) == REFF
					      ? ibcmp(s, locinput, ln)
					      : ibcmp_locale(s, locinput, ln))))
        2170    		sayNO;
        2170    	    locinput += ln;
        2170    	    nextchr = UCHARAT(locinput);
        2170    	    break;
		
			case NOTHING:
			case TAIL:
       10629    	    break;
			case BACK:
       10629    	    break;
			case EVAL:
			{
       10629    	    dSP;
       10629    	    OP_4tree *oop = PL_op;
       10629    	    COP *ocurcop = PL_curcop;
       10629    	    PAD *old_comppad;
       10629    	    SV *ret;
       10629    	    struct regexp *oreg = PL_reg_re;
			
       10629    	    n = ARG(scan);
       10629    	    PL_op = (OP_4tree*)PL_regdata->data[n];
       10629    	    DEBUG_EXECUTE_r( PerlIO_printf(Perl_debug_log, "  re_eval 0x%"UVxf"\n", PTR2UV(PL_op)) );
       10629    	    PAD_SAVE_LOCAL(old_comppad, (PAD*)PL_regdata->data[n + 2]);
       10629    	    PL_regendp[0] = PL_reg_magic->mg_len = locinput - PL_bostr;
		
			    {
       10629    		SV **before = SP;
       10629    		CALLRUNOPS(aTHX);			/* Scalar context. */
       10628    		SPAGAIN;
       10628    		if (SP == before)
      ######    		    ret = &PL_sv_undef;   /* protect against empty (?{}) blocks. */
				else {
       10628    		    ret = POPs;
       10628    		    PUTBACK;
				}
			    }
		
       10628    	    PL_op = oop;
       10628    	    PAD_RESTORE_LOCAL(old_comppad);
       10628    	    PL_curcop = ocurcop;
       10628    	    if (logical) {
       10099    		if (logical == 2) {	/* Postponed subexpression. */
        9905    		    regexp *re;
        9905    		    MAGIC *mg = Null(MAGIC*);
        9905    		    re_cc_state state;
        9905    		    CHECKPOINT cp, lastcp;
        9905                        int toggleutf;
        9905    		    register SV *sv;
		
        9905    		    if(SvROK(ret) && SvSMAGICAL(sv = SvRV(ret)))
        8492    			mg = mg_find(sv, PERL_MAGIC_qr);
        1413    		    else if (SvSMAGICAL(ret)) {
          11    			if (SvGMAGICAL(ret))
           4    			    sv_unmagic(ret, PERL_MAGIC_qr);
					else
           7    			    mg = mg_find(ret, PERL_MAGIC_qr);
				    }
		
        9905    		    if (mg) {
        8498    			re = (regexp *)mg->mg_obj;
        8498    			(void)ReREFCNT_inc(re);
				    }
				    else {
        1407    			STRLEN len;
        1407    			const char *t = SvPV_const(ret, len);
        1407    			PMOP pm;
        1407    			char * const oprecomp = PL_regprecomp;
        1407    			const I32 osize = PL_regsize;
        1407    			const I32 onpar = PL_regnpar;
		
        1407    			Zero(&pm, 1, PMOP);
        1407                            if (DO_UTF8(ret)) pm.op_pmdynflags |= PMdf_DYN_UTF8;
        1407    			re = CALLREGCOMP(aTHX_ (char*)t, (char*)t + len, &pm);
        1407    			if (!(SvFLAGS(ret)
					      & (SVs_TEMP | SVs_PADTMP | SVf_READONLY
						| SVs_GMG)))
           6    			    sv_magic(ret,(SV*)ReREFCNT_inc(re),
							PERL_MAGIC_qr,0,0);
        1407    			PL_regprecomp = oprecomp;
        1407    			PL_regsize = osize;
        1407    			PL_regnpar = onpar;
				    }
				    DEBUG_EXECUTE_r(
					PerlIO_printf(Perl_debug_log,
						      "Entering embedded \"%s%.60s%s%s\"\n",
						      PL_colors[0],
						      re->precomp,
						      PL_colors[1],
						      (strlen(re->precomp) > 60 ? "..." : ""))
        9905    			);
        9905    		    state.node = next;
        9905    		    state.prev = PL_reg_call_cc;
        9905    		    state.cc = PL_regcc;
        9905    		    state.re = PL_reg_re;
		
        9905    		    PL_regcc = 0;
				
        9905    		    cp = regcppush(0);	/* Save *all* the positions. */
        9905    		    REGCP_SET(lastcp);
        9905    		    cache_re(re);
        9905    		    state.ss = PL_savestack_ix;
        9905    		    *PL_reglastparen = 0;
        9905    		    *PL_reglastcloseparen = 0;
        9905    		    PL_reg_call_cc = &state;
        9905    		    PL_reginput = locinput;
        9905    		    toggleutf = ((PL_reg_flags & RF_utf8) != 0) ^
						((re->reganch & ROPT_UTF8) != 0);
        9905    		    if (toggleutf) PL_reg_flags ^= RF_utf8;
		
				    /* XXXX This is too dramatic a measure... */
        9905    		    PL_reg_maxiter = 0;
		
        9905    		    if (regmatch(re->program + 1)) {
					/* Even though we succeeded, we need to restore
					   global variables, since we may be wrapped inside
					   SUSPEND, thus the match may be not finished yet. */
		
					/* XXXX Do this only if SUSPENDed? */
        4319    			PL_reg_call_cc = state.prev;
        4319    			PL_regcc = state.cc;
        4319    			PL_reg_re = state.re;
        4319    			cache_re(PL_reg_re);
        4319    			if (toggleutf) PL_reg_flags ^= RF_utf8;
		
					/* XXXX This is too dramatic a measure... */
        4319    			PL_reg_maxiter = 0;
		
					/* These are needed even if not SUSPEND. */
        4319    			ReREFCNT_dec(re);
        4319    			regcpblow(cp);
        4319    			sayYES;
				    }
        5586    		    ReREFCNT_dec(re);
        5586    		    REGCP_UNWIND(lastcp);
        5586    		    regcppop();
        5586    		    PL_reg_call_cc = state.prev;
        5586    		    PL_regcc = state.cc;
        5586    		    PL_reg_re = state.re;
        5586    		    cache_re(PL_reg_re);
        5586    		    if (toggleutf) PL_reg_flags ^= RF_utf8;
		
				    /* XXXX This is too dramatic a measure... */
        5586    		    PL_reg_maxiter = 0;
		
        5586    		    logical = 0;
        5586    		    sayNO;
				}
         194    		sw = SvTRUE(ret);
         194    		logical = 0;
			    }
			    else {
         529    		sv_setsv(save_scalar(PL_replgv), ret);
         529    		cache_re(oreg);
			    }
         529    	    break;
			}
			case OPEN:
     7139107    	    n = ARG(scan);  /* which paren pair */
     7139107    	    PL_reg_start_tmp[n] = locinput;
     7139107    	    if (n > PL_regsize)
     6305872    		PL_regsize = n;
     6305872    	    break;
			case CLOSE:
     5823937    	    n = ARG(scan);  /* which paren pair */
     5823937    	    PL_regstartp[n] = PL_reg_start_tmp[n] - PL_bostr;
     5823937    	    PL_regendp[n] = locinput - PL_bostr;
     5823937    	    if (n > (I32)*PL_reglastparen)
     4773465    		*PL_reglastparen = n;
     5823937    	    *PL_reglastcloseparen = n;
     5823937    	    break;
			case GROUPP:
         380    	    n = ARG(scan);  /* which paren pair */
         380    	    sw = ((I32)*PL_reglastparen >= n && PL_regendp[n] != -1);
         380    	    break;
			case IFTHEN:
         634    	    PL_reg_leftiter = PL_reg_maxiter;		/* Void cache */
         634    	    if (sw)
         306    		next = NEXTOPER(NEXTOPER(scan));
			    else {
         328    		next = scan + ARG(scan);
         328    		if (OP(next) == IFTHEN) /* Fake one. */
         170    		    next = NEXTOPER(NEXTOPER(next));
			    }
         170    	    break;
			case LOGICAL:
       10159    	    logical = scan->flags;
       10159    	    break;
		/*******************************************************************
		 PL_regcc contains infoblock about the innermost (...)* loop, and
		 a pointer to the next outer infoblock.
		
		 Here is how Y(A)*Z is processed (if it is compiled into CURLYX/WHILEM):
		
		   1) After matching X, regnode for CURLYX is processed;
		
		   2) This regnode creates infoblock on the stack, and calls
		      regmatch() recursively with the starting point at WHILEM node;
		
		   3) Each hit of WHILEM node tries to match A and Z (in the order
		      depending on the current iteration, min/max of {min,max} and
		      greediness).  The information about where are nodes for "A"
		      and "Z" is read from the infoblock, as is info on how many times "A"
		      was already matched, and greediness.
		
		   4) After A matches, the same WHILEM node is hit again.
		
		   5) Each time WHILEM is hit, PL_regcc is the infoblock created by CURLYX
		      of the same pair.  Thus when WHILEM tries to match Z, it temporarily
		      resets PL_regcc, since this Y(A)*Z can be a part of some other loop:
		      as in (Y(A)*Z)*.  If Z matches, the automaton will hit the WHILEM node
		      of the external loop.
		
		 Currently present infoblocks form a tree with a stem formed by PL_curcc
		 and whatever it mentions via ->next, and additional attached trees
		 corresponding to temporarily unset infoblocks as in "5" above.
		
		 In the following picture infoblocks for outer loop of
		 (Y(A)*?Z)*?T are denoted O, for inner I.  NULL starting block
		 is denoted by x.  The matched string is YAAZYAZT.  Temporarily postponed
		 infoblocks are drawn below the "reset" infoblock.
		
		 In fact in the picture below we do not show failed matches for Z and T
		 by WHILEM blocks.  [We illustrate minimal matches, since for them it is
		 more obvious *why* one needs to *temporary* unset infoblocks.]
		
		  Matched	REx position	InfoBlocks	Comment
		  		(Y(A)*?Z)*?T	x
		  		Y(A)*?Z)*?T	x <- O
		  Y		(A)*?Z)*?T	x <- O
		  Y		A)*?Z)*?T	x <- O <- I
		  YA		)*?Z)*?T	x <- O <- I
		  YA		A)*?Z)*?T	x <- O <- I
		  YAA		)*?Z)*?T	x <- O <- I
		  YAA		Z)*?T		x <- O		# Temporary unset I
						     I
		
		  YAAZ		Y(A)*?Z)*?T	x <- O
						     I
		
		  YAAZY		(A)*?Z)*?T	x <- O
						     I
		
		  YAAZY		A)*?Z)*?T	x <- O <- I
						     I
		
		  YAAZYA	)*?Z)*?T	x <- O <- I	
						     I
		
		  YAAZYA	Z)*?T		x <- O		# Temporary unset I
						     I,I
		
		  YAAZYAZ	)*?T		x <- O
						     I,I
		
		  YAAZYAZ	T		x		# Temporary unset O
						O
						I,I
		
		  YAAZYAZT			x
						O
						I,I
		 *******************************************************************/
			case CURLYX: {
     1170519    		CURCUR cc;
     1170519    		CHECKPOINT cp = PL_savestack_ix;
				/* No need to save/restore up to this paren */
     1170519    		I32 parenfloor = scan->flags;
		
     1170519    		if (OP(PREVOPER(next)) == NOTHING) /* LONGJMP */
          12    		    next += ARG(next);
     1170519    		cc.oldcc = PL_regcc;
     1170519    		PL_regcc = &cc;
				/* XXXX Probably it is better to teach regpush to support
				   parenfloor > PL_regsize... */
     1170519    		if (parenfloor > (I32)*PL_reglastparen)
      236255    		    parenfloor = *PL_reglastparen; /* Pessimization... */
     1170519    		cc.parenfloor = parenfloor;
     1170519    		cc.cur = -1;
     1170519    		cc.min = ARG1(scan);
     1170519    		cc.max  = ARG2(scan);
     1170519    		cc.scan = NEXTOPER(scan) + EXTRA_STEP_2ARGS;
     1170519    		cc.next = next;
     1170519    		cc.minmod = minmod;
     1170519    		cc.lastloc = 0;
     1170519    		PL_reginput = locinput;
     1170519    		n = regmatch(PREVOPER(next));	/* start on the WHILEM */
     1170519    		regcpblow(cp);
     1170519    		PL_regcc = cc.oldcc;
     1170519    		saySAME(n);
			    }
			    /* NOT REACHED */
			case WHILEM: {
				/*
				 * This is really hard to understand, because after we match
				 * what we're trying to match, we must make sure th