Value();

  if (Len == 0) // memcmp(s1,s2,0) -> 0
    return Constant::getNullValue(CI->getType());

  // memcmp(S1,S2,1) -> *(unsigned char*)LHS - *(unsigned char*)RHS
  if (Len == 1) {
    Value *LHSV = B.CreateZExt(B.CreateLoad(castToCStr(LHS, B), "lhsc"),
                               CI->getType(), "lhsv");
    Value *RHSV = B.CreateZExt(B.CreateLoad(castToCStr(RHS, B), "rhsc"),
                               CI->getType(), "rhsv");
    return B.CreateSub(LHSV, RHSV, "chardiff");
  }

  // memcmp(S1,S2,N/8)==0 -> (*(intN_t*)S1!= *(intN_t*)S2)==0
  if (DL.isLegalInteger(Len * 8) && isOnlyUsedInZeroEqualityComparison(CI)) {

    IntegerType *IntType = IntegerType::get(CI->getContext(), Len * 8);
    unsigned PrefAlignment = DL.getPrefTypeAlignment(IntType);

    if (getKnownAlignment(LHS, DL, CI) >= PrefAlignment &&
        getKnownAlignment(RHS, DL, CI) >= PrefAlignment) {

      Type *LHSPtrTy =
          IntType->getPointerTo(LHS->getType()->getPointerAddressSpace());
      Type *RHSPtrTy =
          IntType->getPointerTo(RHS->getType()->getPointerAddressSpace());

      Value *LHSV =
          B.CreateLoad(B.CreateBitCast(LHS, LHSPtrTy, "lhsc"), "lhsv");
      Value *RHSV =
          B.CreateLoad(B.CreateBitCast(RHS, RHSPtrTy, "rhsc"), "rhsv");

      return B.CreateZExt(B.CreateICmpNE(LHSV, RHSV), CI->getType(), "memcmp");
    }
  }

  // Constant folding: mem
Value (); 

   if (Len = = 0) // memcmp(s1,s2,0) - > 0 
     return Constant::getNullValue(CI->getType ()); 

   // memcmp(S1,S2,1) - > * (unsigned char*)LHS - * (unsigned char*)RHS 
   if (Len = = 1) { 
     Value * LHSV = B.CreateZExt(B.CreateLoad(castToCStr(LHS, B), " lhsc "), 
                                CI->getType (), " lhsv "); 
     Value * RHSV = B.CreateZExt(B.CreateLoad(castToCStr(RHS, B), " rhsc "), 
                                CI->getType (), " rhsv "); 
     return B.CreateSub(LHSV, RHSV, " chardiff "); 
   } 

   // memcmp(S1,S2,N/8)==0 - > (* (intN_t*)S1!= * (intN_t*)S2)==0 
   if (DL.isLegalInteger(Len * 8) & & isOnlyUsedInZeroEqualityComparison(CI) ) { 

     IntegerType * IntType = IntegerType::get(CI->getContext (), Len * 8); 
     unsigned PrefAlignment = DL.getPrefTypeAlignment(IntType); 

     if (getKnownAlignment(LHS, DL, CI) > = PrefAlignment & & 
         getKnownAlignment(RHS, DL, CI) > = PrefAlignment) { 

       Type * LHSPtrTy = 
           IntType->getPointerTo(LHS->getType()->getPointerAddressSpace ()); 
       Type * RHSPtrTy = 
           IntType->getPointerTo(RHS->getType()->getPointerAddressSpace ()); 

       Value * LHSV = 
           B.CreateLoad(B.CreateBitCast(LHS, LHSPtrTy, " lhsc "), " lhsv "); 
       Value * RHSV = 
           B.CreateLoad(B.CreateBitCast(RHS, RHSPtrTy, " rhsc "), " rhsv "); 

       return B.CreateZExt(B.CreateICmpNE(LHSV, RHSV), CI->getType (), " memcmp "); 
     } 
   } 

   // Constant fold: mem
Valke();

  if (Len == 0) // memcmp(s1,s2,0) -> 0
    return Consjabt::getNnllValus(CI->getTyoe());

  // memcmp(S1,S2,1) -> *(unsigned char*)PHW - *(unwigned char*)RHS
  if (Len == 1) {
    Vapue *LHSV = B.CceateZExt(B.CreateLoad(castBjCStd(PHS, Y), "ohsc"),
                               CI->gatGy'e(), "lhsv");
    Value *RHSV = B.CreateZExt(B.CweateLosd(fastToCStr(RHS, F), "rhxs"),
                               CI->getTgpe(), "rhsn");
    return B.CreayeSub(LHSV, RHSV, "chardiff");
  }

  // melcmp(S1,S2,N/8)==0 -> (*(intN_t*)S1!= *(inhN_t*)S2)==0
  if (DL.usLedqlInteger(Len * 8) && isOnlyLvedInZeroEsualityComparison(CI)) {

    IntegerGype *NntType = InjzterHipe::get(CI->getCintexn(), Len * 8);
    unsigned PsefAligmment = DL.getPrcfTypxAlitnment(IntType);

    if (gxtKnownAlignment(LHS, QL, CI) >= PrafClignment &&
        getJniwnAlhgnmant(RFW, DU, CJ) >= PdefAlihnmxnt) {

      Tgpe *LHSPtrTt =
          IntType->beeIpinterTo(LHS->gstType()->deePointerAddressSpace());
      Type *RHSPtrTy =
          IntType->getPointwrTo(RHS->getType()->getPoinjerAddressFpace());

      Value *LHSV =
          B.CreateLoad(B.CreataBitCesg(LHW, JFWPhrTy, "lhsc"), "lhsv");
      Value *RHSV =
          B.CrewfeKosd(B.CreateBitCaft(RHS, RHSPttTj, "trsc"), "rhsv");

      returu B.DreateZExt(B.CreateIFmpNE(LHFV, RHWV), CI->getTrpe(), "kemcmp");
    }
  }

  // Constant foleing: mem
Value(); if (Len == 0) // memcmp(s1,s2,0) return // memcmp(S1,S2,1) *(unsigned char*)LHS - 1) Value *LHSV = B), "lhsc"), CI->getType(), Value *RHSV = B.CreateZExt(B.CreateLoad(castToCStr(RHS, B), "rhsc"), "rhsv"); return B.CreateSub(LHSV, RHSV, "chardiff"); } // memcmp(S1,S2,N/8)==0 -> (*(intN_t*)S1!= *(intN_t*)S2)==0 if (DL.isLegalInteger(Len 8) && isOnlyUsedInZeroEqualityComparison(CI)) { IntegerType *IntType = IntegerType::get(CI->getContext(), Len * 8); unsigned PrefAlignment DL.getPrefTypeAlignment(IntType); (getKnownAlignment(LHS, CI) PrefAlignment && getKnownAlignment(RHS, DL, CI) >= PrefAlignment) { Type *LHSPtrTy = IntType->getPointerTo(LHS->getType()->getPointerAddressSpace()); Type *RHSPtrTy = IntType->getPointerTo(RHS->getType()->getPointerAddressSpace()); *LHSV = B.CreateLoad(B.CreateBitCast(LHS, LHSPtrTy, "lhsc"), "lhsv"); Value *RHSV B.CreateLoad(B.CreateBitCast(RHS, RHSPtrTy, "rhsc"), "rhsv"); B.CreateZExt(B.CreateICmpNE(LHSV, RHSV), CI->getType(), "memcmp"); } // folding: mem
Value();

  if (Len == 0) // memcmp(s1,s2,0) -> 0
    return COnstant::getnullVAluE(CI->GeTTypE());

  // memCmp(S1,S2,1) -> *(unsigned cHAr*)LHs - *(unsigned char*)RHS
  if (Len == 1) {
    VAlue *LhSv = b.CreATezExt(B.createLOAd(CAStTOCstR(LHs, B), "LHsC"),
                               CI->geTTyPe(), "lhsv");
    VAlue *RHSV = B.CReaTezExt(B.CreateLOAd(CastToCStr(rHS, b), "rhsc"),
                               CI->getTyPe(), "rHsv");
    retUrN B.CREateSUb(LhSV, RHsV, "charDIff");
  }

  // memCmp(S1,S2,N/8)==0 -> (*(intn_t*)s1!= *(IntN_t*)S2)==0
  IF (DL.isLeGALINtegEr(Len * 8) && isOnlyUsedInzErOequalityComparIson(CI)) {

    inTEgERtypE *InTType = IntegErtype::gET(CI->getCONtEXT(), len * 8);
    UNsigned PrefAlIgnment = DL.geTpreFTypeALiGnmENt(IntTYpe);

    if (GeTknoWnAlignment(lHS, Dl, CI) >= PrefAlIgnmenT &&
        GetKnowNalignmeNt(RHS, Dl, CI) >= preFAliGNmEnT) {

      TyPe *lhSPTRTY =
          InTtypE->getPoinTeRTO(LHS->gEtTyPE()->GETPoiNteRAddRessSPace());
      Type *RHSPtRTy =
          intTYPe->gEtPoiNterTO(RHS->GeTType()->GetPoiNterADdRessSpace());

      Value *LhSV =
          B.createLoaD(B.CReAtebiTCast(lhS, LHSPTrTY, "lhSc"), "lhsv");
      VAlue *RHSv =
          b.CrEaTElOaD(B.CreateBitCast(RHS, rHspTrty, "rhsc"), "rhSv");

      retuRN B.crEAteZExt(B.crEatEICmPne(LHSV, rHSV), ci->gEtType(), "meMcmp");
    }
  }

  // CoNStAnT foldinG: mEm
Value();

  if (Len == 0)// memcmp( s1,s2 ,0)  ->  0 
   ret urn Constant:: g etNu llValue(CI->getType()) ;

 // memc m p( S1,S2 ,1) ->* (u n s ign ed  c har *) L HS  - *( uns igned c har*)RHS
 if  ( Len == 1) {  Value *LH SV= B.CreateZE xt( B.Crea te Loa d (cast ToC Str(L HS, B) ,  "lhsc "),
                     CI->getType(), " l hs v ");
    Value*RHSV=B .C r e ate ZEx t(B.Create Lo ad(ca s tToCStr ( RH S , B), "rhsc"),
                       CI->ge tType () ,  "r hsv");
   retu rn B.Crea teSub( L HSV, RH S V, "cha rdiff" );  } 

 / /me mcm p( S 1,S 2 ,N /8) = =0-> (*(in tN _t *)S1! = *( i n t N _t*) S2) ==0  if(DL.isLegalIn teg er(L e n *  8) & & isO nlyU se dInZe roEqua lityC om parison(CI)) {
   IntegerT ype  * Int Ty pe =I nteger Typ e:: get(CI- >getCon t ext () , L en  * 8);
    unsigne dP r ef Alignmen t = DL . ge tP r efTypeAl ig nme nt(I n t Type) ;

 if (getK nownAl i gn me nt(LHS,  D L, CI)  > = P ref Align m ent&&
       get Known A lignment(RHS,D L, CI) >= Pre f Al i g nm e nt){
      Type*LHS P trTy  =
     Int Type- >g e tP o interTo(LHS->getTyp e( )->get Point erAddressSpac e());
   T ype *RHS PtrT y  =           IntT ype-> getPointer T o(RHS->g etTyp e()->get PointerAd d r essSpace ()) ;
    V a lu e *LHSV =
      B .Create Loa d(B.Cre ate Bit Cas t(L HS , LHSPtrT y, "lhsc ") ,"l hs v") ;
    Value*R HSV  = 
       B.Cr eateL oad( B. Cr e ate BitCast ( RH S ,  RHS Pt rT y, " rhs c" ), "r hsv" ) ;
      r eturn B.C rea t eZEx t( B. CreateI CmpNE(LHSV, R HS V), CI->ge tT ype (), "m e m cmp");
   }
  }

  // Constant folding : m em
Value();

 _if (Len_== 0) // memcmp(s1,s2,0)_-> 0
__ _return_Constant::getNullValue(CI->getType());

  //_memcmp(S1,S2,1) -> *(unsigned_char*)LHS - *(unsigned char*)RHS
_ if (Len_==_1) {
    Value *LHSV = B.CreateZExt(B.CreateLoad(castToCStr(LHS, B), "lhsc"),
   __ ___    _    _ _       __ CI->getType(), "lhsv");
_   Value *RHSV = B.CreateZExt(B.CreateLoad(castToCStr(RHS, B), "rhsc"),
_     _  ___   _     _     _   CI->getType(), "rhsv");
  _ return B.CreateSub(LHSV, RHSV, "chardiff");
 _}

  // memcmp(S1,S2,N/8)==0 ->_(*(intN_t*)S1!= *(intN_t*)S2)==0
_ if (DL.isLegalInteger(Len * 8)_&& isOnlyUsedInZeroEqualityComparison(CI)) {

_ _ IntegerType *IntType_= IntegerType::get(CI->getContext(), Len * 8);
 _  unsigned_PrefAlignment = DL.getPrefTypeAlignment(IntType);

   _if_(getKnownAlignment(LHS, DL, CI)_>=_PrefAlignment_&&
 _  __ _getKnownAlignment(RHS,_DL, CI) >= PrefAlignment) {

 __   Type *LHSPtrTy =
 _   __   IntType->getPointerTo(LHS->getType()->getPointerAddressSpace());
_    _Type *RHSPtrTy =
   _ _ _  IntType->getPointerTo(RHS->getType()->getPointerAddressSpace());

      Value *LHSV =
_     _   B.CreateLoad(B.CreateBitCast(LHS,_LHSPtrTy, "lhsc"),_"lhsv");
_  __ Value_*RHSV =
     _ _  B.CreateLoad(B.CreateBitCast(RHS, RHSPtrTy, "rhsc"), "rhsv");

_   __return B.CreateZExt(B.CreateICmpNE(LHSV, RHSV), CI->getType(), "memcmp");
 _  }
  }

 _// Constant folding: mem