; LLVM IR from mirohs/gc :: util (contains)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.String = type { ptr, i32, i32 }

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @contains(ptr %0, i64 %1, ptr %2, i64 %3) #1 {
  %5 = alloca i1, align 1
  %6 = alloca %struct.String, align 8
  %7 = alloca %struct.String, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 0
  store ptr %0, ptr %11, align 8
  %12 = getelementptr inbounds { ptr, i64 }, ptr %6, i32 0, i32 1
  store i64 %1, ptr %12, align 8
  %13 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 0
  store ptr %2, ptr %13, align 8
  %14 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 1
  store i64 %3, ptr %14, align 8
  %15 = getelementptr inbounds %struct.String, ptr %6, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 1
  %18 = load i32, ptr %17, align 8, !tbaa !5
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  br label %54

21:                                               ; preds = %4
  %22 = getelementptr inbounds %struct.String, ptr %6, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !5
  %24 = add nsw i32 %23, 1
  %25 = zext i32 %24 to i64
  %26 = call ptr @llvm.stacksave.p0()
  store ptr %26, ptr %8, align 8
  %27 = alloca i8, i64 %25, align 16
  store i64 %25, ptr %9, align 8
  %28 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !5
  %30 = add nsw i32 %29, 1
  %31 = zext i32 %30 to i64
  %32 = alloca i8, i64 %31, align 16
  store i64 %31, ptr %10, align 8
  %33 = getelementptr inbounds %struct.String, ptr %6, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.String, ptr %6, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !5
  %37 = sext i32 %36 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %27, ptr align 1 %34, i64 %37, i1 false)
  %38 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !5
  %42 = sext i32 %41 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %32, ptr align 1 %39, i64 %42, i1 false)
  %43 = getelementptr inbounds %struct.String, ptr %6, i32 0, i32 1
  %44 = load i32, ptr %43, align 8, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i8, ptr %27, i64 %45
  store i8 0, ptr %46, align 1, !tbaa !12
  %47 = getelementptr inbounds %struct.String, ptr %7, i32 0, i32 1
  %48 = load i32, ptr %47, align 8, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %32, i64 %49
  store i8 0, ptr %50, align 1, !tbaa !12
  %51 = call ptr @strstr(ptr noundef %27, ptr noundef %32) #4
  %52 = icmp ne ptr %51, null
  store i1 %52, ptr %5, align 1
  %53 = load ptr, ptr %8, align 8
  call void @llvm.stackrestore.p0(ptr %53)
  br label %54

54:                                               ; preds = %21, %20
  %55 = load i1, ptr %5, align 1
  ret i1 %55
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strstr(ptr noundef, ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !10, i64 8}
!6 = !{!"String", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!8, !8, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress nofree nounwind willreturn uwtable
define dso_local zeroext i1 @contains(ptr nocapture readonly %0, i64 %1, ptr nocapture readonly %2, i64 %3) local_unnamed_addr #1 {
  %.sroa.25.8.extract.trunc = trunc i64 %1 to i32
  %.sroa.2.8.extract.trunc = trunc i64 %3 to i32
  %5 = icmp slt i32 %.sroa.25.8.extract.trunc, %.sroa.2.8.extract.trunc
  br i1 %5, label %20, label %6

6:                                                ; preds = %4
  %7 = add i64 %1, 1
  %8 = and i64 %7, 4294967295
  %9 = tail call ptr @llvm.stacksave.p0()
  %10 = alloca i8, i64 %8, align 16
  %11 = add i64 %3, 1
  %12 = and i64 %11, 4294967295
  %13 = alloca i8, i64 %12, align 16
  %sext = shl i64 %1, 32
  %14 = ashr exact i64 %sext, 32
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %10, ptr align 1 %0, i64 %14, i1 false)
  %sext11 = shl i64 %3, 32
  %15 = ashr exact i64 %sext11, 32
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %13, ptr align 1 %2, i64 %15, i1 false)
  %16 = getelementptr inbounds i8, ptr %10, i64 %14
  store i8 0, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %13, i64 %15
  store i8 0, ptr %17, align 1, !tbaa !5
  %18 = call ptr @strstr(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) %13) #4
  %19 = icmp ne ptr %18, null
  call void @llvm.stackrestore.p0(ptr %9)
  br label %20

20:                                               ; preds = %4, %6
  %.0 = phi i1 [ %19, %6 ], [ false, %4 ]
  ret i1 %.0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strstr(ptr noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass