; LLVM IR from Eukky/TRender :: lib/imgui/imgui.ll (ZNK15ImGuiTextFilter10PassFilterEPKcS1_)

; 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.ImGuiTextFilter = type <{ [256 x i8], %class.ImVector.19, i32, [4 x i8] }>
%class.ImVector.19 = type { i32, i32, ptr }

@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZNK15ImGuiTextFilter9TextRange5frontEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK15ImGuiTextFilter10PassFilterEPKcS1_(ptr noundef nonnull align 8 dereferenceable(276) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %11, i32 0, i32 1
  %13 = call noundef zeroext i1 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store i1 true, ptr %4, align 1
  br label %77

15:                                               ; preds = %3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  store ptr @.str.4, ptr %6, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %18, %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %66, %19
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %11, i32 0, i32 1
  %23 = getelementptr inbounds %class.ImVector.19, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !11
  %25 = icmp ne i32 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  store i32 2, ptr %9, align 4
  br label %69

27:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %28 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %11, i32 0, i32 1
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %28, i32 noundef %29)
  store ptr %30, ptr %10, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = call noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %31)
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  store i32 4, ptr %9, align 4
  br label %63

34:                                               ; preds = %27
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = call noundef signext i8 @_ZNK15ImGuiTextFilter9TextRange5frontEv(ptr noundef nonnull align 8 dereferenceable(16) %35)
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 %37, 45
  br i1 %38, label %39, label %51

39:                                               ; preds = %34
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %42)
  %44 = getelementptr inbounds i8, ptr %43, i64 1
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %45)
  %47 = call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef %40, ptr noundef %41, ptr noundef %44, ptr noundef %46)
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %50

49:                                               ; preds = %39
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %63

50:                                               ; preds = %39
  br label %62

51:                                               ; preds = %34
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %54)
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %56)
  %58 = call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef %52, ptr noundef %53, ptr noundef %55, ptr noundef %57)
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %61

60:                                               ; preds = %51
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %63

61:                                               ; preds = %51
  br label %62

62:                                               ; preds = %61, %50
  store i32 0, ptr %9, align 4
  br label %63

63:                                               ; preds = %62, %60, %49, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %64 = load i32, ptr %9, align 4
  switch i32 %64, label %69 [
    i32 0, label %65
    i32 4, label %66
  ]

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65, %63
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %8, align 4, !tbaa !9
  br label %20, !llvm.loop !14

69:                                               ; preds = %63, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %70 = load i32, ptr %9, align 4
  switch i32 %70, label %79 [
    i32 2, label %71
    i32 1, label %77
  ]

71:                                               ; preds = %69
  %72 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %11, i32 0, i32 2
  %73 = load i32, ptr %72, align 8, !tbaa !16
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %71
  store i1 true, ptr %4, align 1
  br label %77

76:                                               ; preds = %71
  store i1 false, ptr %4, align 1
  br label %77

77:                                               ; preds = %76, %75, %69, %14
  %78 = load i1, ptr %4, align 1
  ret i1 %78

79:                                               ; preds = %69
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK15ImGuiTextFilter9TextRange5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { mustprogress 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 #3 = { inlinehint mustprogress 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 #4 = { nounwind }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 256}
!12 = !{!"_ZTS15ImGuiTextFilter", !7, i64 0, !13, i64 256, !10, i64 272}
!13 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter9TextRangeEE", !10, i64 0, !10, i64 4, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!12, !10, i64 272}


; 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"

@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef signext i8 @_ZNK15ImGuiTextFilter9TextRange5frontEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK15ImGuiTextFilter10PassFilterEPKcS1_(ptr noundef nonnull align 8 dereferenceable(276) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 256
  %5 = tail call noundef zeroext i1 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  br i1 %5, label %.loopexit, label %6

6:                                                ; preds = %3
  %7 = icmp eq ptr %1, null
  %spec.store.select = select i1 %7, ptr @.str.4, ptr %1
  %8 = load i32, ptr %4, align 8, !tbaa !5
  %.not29 = icmp eq i32 %8, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6, %21
  %.01930 = phi i32 [ %22, %21 ], [ 0, %6 ]
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %.01930)
  %10 = tail call noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  br i1 %10, label %21, label %11

11:                                               ; preds = %.lr.ph
  %12 = tail call noundef signext i8 @_ZNK15ImGuiTextFilter9TextRange5frontEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  %.not31.not = icmp ne i8 %12, 45
  %13 = tail call noundef ptr @_ZNK15ImGuiTextFilter9TextRange5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  br i1 %.not31.not, label %18, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %13, i64 1
  %16 = tail call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  %17 = tail call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef nonnull %spec.store.select, ptr noundef %2, ptr noundef nonnull %15, ptr noundef %16)
  %.not21 = icmp eq ptr %17, null
  br i1 %.not21, label %21, label %.loopexit

18:                                               ; preds = %11
  %19 = tail call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  %20 = tail call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef nonnull %spec.store.select, ptr noundef %2, ptr noundef %13, ptr noundef %19)
  %.not20 = icmp eq ptr %20, null
  br i1 %.not20, label %21, label %.loopexit

21:                                               ; preds = %14, %18, %.lr.ph
  %22 = add nuw nsw i32 %.01930, 1
  %23 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %22, %23
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %21, %6
  %24 = getelementptr inbounds i8, ptr %0, i64 272
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = icmp eq i32 %25, 0
  br label %.loopexit

.loopexit:                                        ; preds = %18, %14, %._crit_edge, %3
  %.3 = phi i1 [ true, %3 ], [ %26, %._crit_edge ], [ %.not31.not, %14 ], [ %.not31.not, %18 ]
  ret i1 %.3
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK15ImGuiTextFilter9TextRange5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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 #1 = { inlinehint mustprogress 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" }

!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 256}
!6 = !{!"_ZTS15ImGuiTextFilter", !7, i64 0, !9, i64 256, !10, i64 272}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter9TextRangeEE", !10, i64 0, !10, i64 4, !11, i64 8}
!10 = !{!"int", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!6, !10, i64 272}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass