; LLVM IR from xhub/reshop :: gui/external/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], %struct.ImVector.36, i32, [4 x i8] }>
%struct.ImVector.36 = type { i32, i32, ptr }
%"struct.ImGuiTextFilter::ImGuiTextRange" = type { ptr, ptr }

@.str.14 = 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 uwtable
declare dso_local noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; 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) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = 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
  %13 = load ptr, ptr %5, align 8
  %14 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds %struct.ImVector.36, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %19

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

19:                                               ; preds = %3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store ptr @.str.14, ptr %7, align 8, !tbaa !5
  store ptr @.str.14, ptr %6, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %22, %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %24 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %13, i32 0, i32 1
  store ptr %24, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = call noundef ptr @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %25)
  store ptr %26, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = call noundef ptr @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
  store ptr %28, ptr %10, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %83, %23
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = icmp ne ptr %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 2, ptr %11, align 4
  br label %86

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %35, ptr %12, align 8, !tbaa !5
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %39, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = icmp eq ptr %38, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %34
  store i32 3, ptr %11, align 4
  br label %80

44:                                               ; preds = %34
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %47, i64 0
  %49 = load i8, ptr %48, align 1, !tbaa !16
  %50 = sext i8 %49 to i32
  %51 = icmp eq i32 %50, 45
  br i1 %51, label %52, label %66

52:                                               ; preds = %44
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = getelementptr inbounds i8, ptr %57, i64 1
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !15
  %62 = call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef %53, ptr noundef %54, ptr noundef %58, ptr noundef %61)
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %65

64:                                               ; preds = %52
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %80

65:                                               ; preds = %52
  br label %79

66:                                               ; preds = %44
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !13
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef %67, ptr noundef %68, ptr noundef %71, ptr noundef %74)
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %78

77:                                               ; preds = %66
  store i1 true, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %80

78:                                               ; preds = %66
  br label %79

79:                                               ; preds = %78, %65
  store i32 0, ptr %11, align 4
  br label %80

80:                                               ; preds = %79, %77, %64, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %81 = load i32, ptr %11, align 4
  switch i32 %81, label %86 [
    i32 0, label %82
    i32 3, label %83
  ]

82:                                               ; preds = %80
  br label %83

83:                                               ; preds = %82, %80
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %84, i32 1
  store ptr %85, ptr %9, align 8, !tbaa !5
  br label %29

86:                                               ; preds = %80, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %87 = load i32, ptr %11, align 4
  switch i32 %87, label %96 [
    i32 2, label %88
    i32 1, label %94
  ]

88:                                               ; preds = %86
  %89 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %13, i32 0, i32 2
  %90 = load i32, ptr %89, align 8, !tbaa !17
  %91 = icmp eq i32 %90, 0
  br i1 %91, label %92, label %93

92:                                               ; preds = %88
  store i1 true, ptr %4, align 1
  br label %94

93:                                               ; preds = %88
  store i1 false, ptr %4, align 1
  br label %94

94:                                               ; preds = %93, %92, %86, %18
  %95 = load i1, ptr %4, align 1
  ret i1 %95

96:                                               ; preds = %86
  unreachable
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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, !12, i64 256}
!10 = !{!"_ZTS15ImGuiTextFilter", !7, i64 0, !11, i64 256, !12, i64 272}
!11 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE", !12, i64 0, !12, i64 4, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSN15ImGuiTextFilter14ImGuiTextRangeE", !6, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !12, 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.14 = external hidden unnamed_addr constant [1 x i8], align 1

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

; 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) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 256
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %.loopexit, label %7

7:                                                ; preds = %3
  %8 = icmp eq ptr %1, null
  %spec.select = select i1 %8, ptr @.str.14, ptr %2
  %spec.select31 = select i1 %8, ptr @.str.14, ptr %1
  %9 = tail call noundef ptr @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %10 = tail call noundef ptr @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %.not39 = icmp eq ptr %9, %10
  br i1 %.not39, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %7, %22
  %.02440 = phi ptr [ %23, %22 ], [ %9, %7 ]
  %11 = load ptr, ptr %.02440, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %.02440, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %14 = icmp eq ptr %11, %13
  br i1 %14, label %22, label %15

15:                                               ; preds = %.lr.ph
  %16 = load i8, ptr %11, align 1, !tbaa !15
  %.not41.not = icmp ne i8 %16, 45
  br i1 %.not41.not, label %20, label %17

17:                                               ; preds = %15
  %18 = getelementptr inbounds i8, ptr %11, i64 1
  %19 = tail call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef nonnull %spec.select31, ptr noundef %spec.select, ptr noundef nonnull %18, ptr noundef %13)
  %.not30 = icmp eq ptr %19, null
  br i1 %.not30, label %22, label %.loopexit

20:                                               ; preds = %15
  %21 = tail call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef nonnull %spec.select31, ptr noundef %spec.select, ptr noundef nonnull %11, ptr noundef %13)
  %.not29 = icmp eq ptr %21, null
  br i1 %.not29, label %22, label %.loopexit

22:                                               ; preds = %17, %20, %.lr.ph
  %23 = getelementptr inbounds i8, ptr %.02440, i64 16
  %.not = icmp eq ptr %23, %10
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

.loopexit:                                        ; preds = %20, %17, %._crit_edge, %3
  %.3 = phi i1 [ true, %3 ], [ %26, %._crit_edge ], [ %.not41.not, %17 ], [ %.not41.not, %20 ]
  ret i1 %.3
}

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

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

attributes #0 = { 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 #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 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE", !10, i64 0, !10, i64 4, !11, i64 8}
!10 = !{!"int", !7, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTSN15ImGuiTextFilter14ImGuiTextRangeE", !11, i64 0, !11, i64 8}
!14 = !{!13, !11, i64 8}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !10, i64 272}


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