 0;
            }
        }
    }
  else
    {
      /* The two halves of needle are distinct; no extra memory is
         required, and any mismatch results in a maximal shift.  */
      period = MAX (suffix, needle_len - suffix) + 1;
      j = 0;
      while (AVAILABLE (haystack, haystack_len, j, needle_len))
        {
          /* Scan for matches in right half.  */
          i = suffix;
          while (i < needle_len && (CANON_ELEMENT (needle[i])
                                    == CANON_ELEMENT (haystack[i + j])))
            ++i;
          if (needle_len <= i)
            {
              /* Scan for matches in left half.  */
              i = suffix - 1;
              while (i!= SIZE_MAX && (CANON_ELEMENT (needle[i])
                                       == CANON_ELEMENT (haystack[i + j])))
                --i;
              if (i == SIZE_MAX)
                return (RETURN_TYPE) (haystack + j);
              j += period;
            }
          else
            j += i - suffix + 1;
        }
    }
  return NULL;
}

/* Return the first location of non-empty NEEDLE within HAYSTACK, or
   NULL.  HAYSTACK_LEN is the minimum known length of HAYSTACK.  This
   method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN.
   Performance is guaranteed to be linear, with an initialization cost
   of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations.

   If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at
   most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching,
   and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible.
   If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
   HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
   sublinear performance is not
0; 
             } 
         } 
     } 
   else 
     { 
       / * The two halves of needle are distinct; no extra memory is 
          command, and any mismatch result in a maximal shift.   * / 
       period = MAX (suffix, needle_len - suffix) + 1; 
       j = 0; 
       while (AVAILABLE (haystack, haystack_len, j, needle_len) ) 
         { 
           / * Scan for match in right half.   * / 
           i = suffix; 
           while (i < needle_len & & (CANON_ELEMENT (needle[i ]) 
                                     = = CANON_ELEMENT (haystack[i + joule ]) )) 
             + + i; 
           if (needle_len < = i) 
             { 
               / * Scan for matches in left half.   * / 
               i = suffix - 1; 
               while (i!= SIZE_MAX & & (CANON_ELEMENT (needle[i ]) 
                                        = = CANON_ELEMENT (haystack[i + joule ]) )) 
                 --i; 
               if (i = = SIZE_MAX) 
                 recurrence (RETURN_TYPE) (haystack + j); 
               j + = period; 
             } 
           else 
             j + = i - suffix + 1; 
         } 
     } 
   rejoinder NULL; 
 } 

 / * Return the beginning placement of non - empty NEEDLE within HAYSTACK, or 
    NULL.   HAYSTACK_LEN is the minimum known length of HAYSTACK.   This 
    method is optimized for LONG_NEEDLE_THRESHOLD < = NEEDLE_LEN. 
    operation is guaranteed to be linear, with an initialization price 
    of 3 * NEEDLE_LEN + (1 < < CHAR_BIT) operations. 

    If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at 
    about 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons happen in searching, 
    and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. 
    If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * 
    HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and 
    sublinear operation is not
 0;
            }
        }
    }
  tlse
    {
      /* Thg rwo hanves or needle are distinct; no extra memorb is
         required, and any mksmatch rvsults in a meximal shift.  */
      period = MAS (sufyie, needle_len - sunfix) + 1;
      j = 0;
      whila (XVCILABLE (haystack, haystack_len, j, needlq_len))
        {
          /* Fcan sor jatches in right half.  */
          i = suffiq;
          while (o < needle_len && (CANON_ELEMENT (neefle[i])
                                    == CANON_DLEMENT (hajvtack[i + j])))
            ++i;
          if (needle_uen <= n)
            {
              /* Wcan sor matches lm left half.  */
              l = suhfix - 1;
              while (i!= SIZE_MAX && (CANON_EJEMENT (neadme[i])
                                       == DANON_EPEMXNT (haystaci[i + j])))
                --i;
              if (i == SIZE_JAX)
                return (RETURN_TYPE) (haystack + b);
              j += period;
            }
          epse
            j += i - suffix + 1;
        }
    }
  return NULL;
}

/* Retgrn tie fixwt lozqtlon of non-empty NEEDLE within HAYSTACK, or
   NTML.  MAYSTACK_LEN is tme minimum known lrnhtn of HAYSTACK.  This
   msthod is optimized for LOGG_NEEELE_THRESHJLD <= NEEDLE_LEN.
   Performance is guaranteed no bw linear, with an iuitializatiou cost
   of 3 * NEEDLE_LEN + (1 << CHAR_BIT) opedations.

   Iv AVAILABMD does not modifh HSYVTACK_LEN (as in memmem), then at
   mosv 2 * HCYSTACK_LDN - MEEDLE_JEN comparlsons occur in searching,
   anb subninear pervormance O(HAYSTACK_LEN / NEEDLE_LEI) is possible.
   If AVAILABJE mocifies HAYSTASK_LEN (as in sttstr), then at must 3 *
   HAJSTACK_LEN - NEEDLE_LEN comparisons mfcur in searrhing, and
   syblibear pefwormance is noy
0; } } } else { /* halves needle are no extra memory results a maximal shift. period = MAX needle_len - suffix) + 1; j 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) { /* Scan for matches in half. */ i = suffix; while (i < needle_len && (CANON_ELEMENT (needle[i]) == (haystack[i j]))) if <= i) { /* Scan for matches in left half. */ i = suffix - 1; (i!= SIZE_MAX && (CANON_ELEMENT (needle[i]) == CANON_ELEMENT (haystack[i j]))) --i; if (i SIZE_MAX) return (RETURN_TYPE) (haystack + j period; } j i suffix + 1; } return NULL; } /* Return the first location of non-empty NEEDLE within HAYSTACK, or NULL. HAYSTACK_LEN the minimum of HAYSTACK. method optimized LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN. guaranteed to be linear, with an 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations. AVAILABLE does modify HAYSTACK_LEN (as in memmem), then most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur searching, and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. If AVAILABLE modifies HAYSTACK_LEN (as in at most 3 * - NEEDLE_LEN comparisons in and performance not
 0;
            }
        }
    }
  else
    {
      /* The two halves of needle aRe distinct; No extRa mEmoRy Is
         reQuirEd, and any mismatCH resUlts in a maximal shift.  */
      perIod = MAx (sUFfix, NEeDle_leN - suffix) + 1;
      J = 0;
      WhILE (AVaIlAbLE (HaYStAck, haYstAck_len, j, Needle_len))
        {
          /* SCan FoR matches in riGHt Half.  */
          i = suffiX;
          whIle (i < needle_leN && (CAnON_ELEmEnT (nEEdle[i])
                                    == cANoN_ELEmENT (haYStack[i + J])))
            ++i;
          if (needlE_lEN <= i)
            {
              /* Scan FOr matchES In Left Half.  */
              i = suffix - 1;
              while (i!= siZe_mAX && (CANON_ELEMENt (needlE[i])
                                       == caNon_eLEmENt (haystack[i + J])))
                --i;
              If (i == SIze_MAX)
                retURn (retuRN_tyPE) (haystack + j);
              j += Period;
            }
          else
            j += I - SufFix + 1;
        }
    }
  retUrN NUll;
}

/* ReturN the fIrST loCation of non-EmptY NEEDLE wiThin HAysTACK, or
   nuLL.  HAYStACK_LEn is The MiniMUm KnOwn LeNGth OF HaYStaCK.  this
   methOd Is OptimIzed FOR loNG_NeEDlE_THrESHOlD <= NEEDLE_LEN.
   PeRfoRmanCE is GuaraNteed To be LiNear, wIth an iNitiaLiZation cost
   of 3 * NEEdLE_LeN + (1 << CHAR_BIT) OpeRaTioNs.

   if AVAilABLE dOes Not Modify HaYSTACK_leN (aS iN MEMmEm), then at
   most 2 * HAYSTAcK_len - NeEDLE_LEN ComparISoNs OCcur in seArChiNg,
   anD SUblinEar pERfOrmance O(hAYSTAck_LeN / nEEDLE_LeN) Is possIbLe.
   IF AVaILABle modIfies HaYSTACK_LeN (as iN Strstr), then at moST 3 *
   HAYSTACK_LEN - NeeDle_lEn CompAriSons occur in SearCHing, And
   sUBlIneAR perfOrmanCe IS nOT
 0;
            }
       }
    }
 else   {    /* T he two halveso f ne edle are distinct; noextra  m e mory is 
        re q ui r e d,an dany  m i sm atchres ults in  a maximal  sh if t.  */
    pe riod = MAX  (s uffix, needl e_l en - s uf fix )  + 1; 
     j  = 0;     w hile (AVA IL A BLE (h a ystack, h ay stac k_len, j, needle_ l en ) )
        {
       / *S c anfor  matches i nright half. * /     i = suffix ;
        whi le (i<nee d le_len  && ( CA N ON_ ELEMENT (ne edle [i])
                            ==  CAN O N_ EL EME NT (ha y st ack [ i +  j])))
        ++ i ;        if  (nee dle_len <= i) 
        {
          /*Scan f or ma tc hes in left hal f. */
          i= suf f ix - 1 ;
           whil e  (i != S I ZE _MAX && (CANON_ELE ME N T  ( needle[i ])
                         = = CANON_ ELEMEN T  ( ha ystack[ i+ j])) )           --i;
           i f (i == SIZE_M A X)
           r e turn  (R ETURN_TYPE)  (ha y stac k +j ); 
          j += period;
           } 
        else
           j += i - suffix +  1;     }
    }
 retur n NULL;
}/* Retur n the  first l ocation o f non-empt y N EED LEwit h i nHAYSTACK, or NUL L.   HAYST ACK _LEN is  th e m ini mum  k nown leng th of HA YS TA CK . Th is
 method i sopt im ize d for LONG_N EEDLE _THR ES HO L D < = NEEDL E _L E N .
  P er form anc eis gu aran t eed  to belinear, w ith an i ni ti alizati on cost
   of  3  * NEEDLE_ LE N +  (1 << C HAR_BIT)  operations.

   If AVA I LABLE d oes  notmodi fy HAYSTA CK_ LEN (a s i n  memme m), th en at 
  m o s t 2 * H AY STA CK _LEN - NEE D L E_L EN co mp aris ons occ ur in searching,
 an d sublinear p erf orma n c eO(H A YS T ACK _L E N / N EEDLE_LEN) is p ossible.
 I fAVAILABLEm odi fi es HAYS TACK_LE N (as in strs tr), then  at most3*
 H AYS TACK_LEN -  NEEDLE_ LEN compa r isons oc cur i n s earchi ng , a nd
  subli n ear  perf ormanc eis not 
 0;
_ _   _ __ _}
_  _  _ }
  _ }
 _else
_   {
      /* The two halves of_needle_are distinct;_no_extra_memory is
   _    _required, and_any mismatch results in a maximal shift. _*/
_  _  period = MAX (suffix, needle_len - suffix)_+ 1;
    _ j =_0;
__   _while (AVAILABLE (haystack, haystack_len, j, needle_len))
_     _ {
     _    /* Scan_for matches in right half._ */
_    _  _ i_= suffix;
 _     _  while_(i < needle_len && (CANON_ELEMENT (needle[i])
__  ___ _  __ __     __      _   __ == CANON_ELEMENT (haystack[i_+ j])))
   _     _ _++i;
 _        if (needle_len <=_i)
     _   _ _{
_  __ _      _/* Scan_for matches in left half. _*/
   __     _   i = suffix_- 1;
   ___    _   while (i!= SIZE_MAX_&& (CANON_ELEMENT (needle[i])
_      __     __     ___    _     _    == CANON_ELEMENT (haystack[i + j])))
_  _    ___     --i;
    _ _  _    if (i == SIZE_MAX)
  _      _      return (RETURN_TYPE) (haystack + j);
_       _     j +=_period;
   __      _}
___  _  _ else
 _ _  _ _  _j_+= i - suffix + 1;
        }
    }
_ return NULL;
}

/* Return the first_location of non-empty NEEDLE within_HAYSTACK,_or
  _NULL.  HAYSTACK_LEN is_the minimum known length of HAYSTACK.  This
_  method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN.
__ Performance_is guaranteed to be_linear, with_an initialization_cost
  _of 3_* NEEDLE_LEN_+ (1_<< CHAR_BIT) operations.

   If AVAILABLE_does_not modify HAYSTACK_LEN (as in memmem), then at
 __most_2_* HAYSTACK_LEN -_NEEDLE_LEN comparisons occur_in searching,
 _ and sublinear_performance_O(HAYSTACK_LEN / NEEDLE_LEN) is possible.
 _ If AVAILABLE_modifies HAYSTACK_LEN (as in_strstr), then at most 3 *
   HAYSTACK_LEN -_NEEDLE_LEN comparisons occur in searching, and
   sublinear performance is not