Skip to content

Instantly share code, notes, and snippets.

@christianparpart
Created September 22, 2010 14:23
Show Gist options
  • Save christianparpart/591757 to your computer and use it in GitHub Desktop.
Save christianparpart/591757 to your computer and use it in GitHub Desktop.
define i8* @_strcasestr(i8* %haystack, i8* nocapture %needle) nounwind readonly {
; <label>:0
%1 = tail call i64 @strlen(i8* %haystack) ; <i64> [#uses=1]
%2 = trunc i64 %1 to i32 ; <i32> [#uses=1]
%3 = tail call i64 @strlen(i8* %needle) ; <i64> [#uses=1]
%4 = trunc i64 %3 to i32 ; <i32> [#uses=2]
%5 = icmp slt i32 %2, %4 ; <i1> [#uses=1]
br i1 %5, label %.loopexit, label %.preheader
.preheader: ; preds = %0
%6 = sext i32 %4 to i64 ; <i64> [#uses=1]
br label %7
; <label>:7 ; preds = %.preheader, %16
%indvar = phi i64 [ 0, %.preheader ], [ %indvar.next, %16 ] ; <i64> [#uses=2]
%.01 = getelementptr i8* %haystack, i64 %indvar ; <i8*> [#uses=3]
%8 = load i8* %.01 ; <i8> [#uses=2]
%9 = icmp eq i8 %8, 0 ; <i1> [#uses=1]
br i1 %9, label %.loopexit, label %10
; <label>:10 ; preds = %7
%11 = load i8* %needle ; <i8> [#uses=1]
%12 = icmp eq i8 %8, %11 ; <i1> [#uses=1]
br i1 %12, label %13, label %16
; <label>:13 ; preds = %10
%14 = tail call i32 @strncasecmp(i8* %.01, i8* %needle, i64 %6) nounwind readonly ; <i32> [#uses=1]
%15 = icmp eq i32 %14, 0 ; <i1> [#uses=1]
br i1 %15, label %.loopexit, label %16
; <label>:16 ; preds = %13, %10
%indvar.next = add i64 %indvar, 1 ; <i64> [#uses=1]
br label %7
.loopexit: ; preds = %7, %13, %0
%.0 = phi i8* [ null, %0 ], [ null, %7 ], [ %.01, %13 ] ; <i8*> [#uses=1]
ret i8* %.0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment