; LLVM IR from DarrenSweeney/3D-Physics-Engine :: Physics Engine/Imgui/imgui.ll (ZNK15ImGuiTextFilter10PassFilterEPKc)

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

@.str.8 = 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

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

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

12:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  br label %72

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  store ptr @.str.8, ptr %5, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %16, %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %61, %17
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %9, i32 0, i32 1
  %21 = call noundef i64 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %20)
  %22 = icmp ne i64 %19, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  store i32 2, ptr %7, align 4
  br label %64

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %25 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %9, i32 0, i32 1
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %26)
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = call noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %28)
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  store i32 4, ptr %7, align 4
  br label %58

31:                                               ; preds = %24
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = call noundef signext i8 @_ZNK15ImGuiTextFilter9TextRange5frontEv(ptr noundef nonnull align 8 dereferenceable(16) %32)
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 45
  br i1 %35, label %36, label %47

36:                                               ; preds = %31
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %38)
  %40 = getelementptr inbounds i8, ptr %39, i64 1
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %41)
  %43 = call noundef ptr @_ZL9ImStristrPKcS0_S0_(ptr noundef %37, ptr noundef %40, ptr noundef %42)
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %46

45:                                               ; preds = %36
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %58

46:                                               ; preds = %36
  br label %57

47:                                               ; preds = %31
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %49)
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %51)
  %53 = call noundef ptr @_ZL9ImStristrPKcS0_S0_(ptr noundef %48, ptr noundef %50, ptr noundef %52)
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %56

55:                                               ; preds = %47
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %58

56:                                               ; preds = %47
  br label %57

57:                                               ; preds = %56, %46
  store i32 0, ptr %7, align 4
  br label %58

58:                                               ; preds = %57, %55, %45, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %59 = load i32, ptr %7, align 4
  switch i32 %59, label %64 [
    i32 0, label %60
    i32 4, label %61
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60, %58
  %62 = load i64, ptr %6, align 8, !tbaa !9
  %63 = add i64 %62, 1
  store i64 %63, ptr %6, align 8, !tbaa !9
  br label %18, !llvm.loop !11

64:                                               ; preds = %58, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %65 = load i32, ptr %7, align 4
  switch i32 %65, label %74 [
    i32 2, label %66
    i32 1, label %72
  ]

66:                                               ; preds = %64
  %67 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %9, i32 0, i32 2
  %68 = load i32, ptr %67, align 8, !tbaa !13
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %66
  store i1 true, ptr %3, align 1
  br label %72

71:                                               ; preds = %66
  store i1 false, ptr %3, align 1
  br label %72

72:                                               ; preds = %71, %70, %64, %12
  %73 = load i1, ptr %3, align 1
  ret i1 %73

74:                                               ; preds = %64
  unreachable
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL9ImStristrPKcS0_S0_(ptr noundef, ptr noundef, ptr noundef) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 = { 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 #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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !16, i64 280}
!14 = !{!"_ZTS15ImGuiTextFilter", !7, i64 0, !15, i64 256, !16, i64 280}
!15 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter9TextRangeEE", !10, i64 0, !10, i64 8, !6, i64 16}
!16 = !{!"int", !7, 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"

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

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

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

5:                                                ; preds = %2
  %6 = icmp eq ptr %1, null
  %spec.store.select = select i1 %6, ptr @.str.8, ptr %1
  %7 = tail call noundef i64 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  %.not27 = icmp eq i64 %7, 0
  br i1 %.not27, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %20
  %.01728 = phi i64 [ %21, %20 ], [ 0, %5 ]
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %.01728)
  %9 = tail call noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  br i1 %9, label %20, label %10

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

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %12, i64 1
  %15 = tail call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %16 = tail call noundef ptr @_ZL9ImStristrPKcS0_S0_(ptr noundef nonnull %spec.store.select, ptr noundef nonnull %14, ptr noundef %15)
  %.not19 = icmp eq ptr %16, null
  br i1 %.not19, label %20, label %.loopexit

17:                                               ; preds = %10
  %18 = tail call noundef ptr @_ZNK15ImGuiTextFilter9TextRange3endEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %19 = tail call noundef ptr @_ZL9ImStristrPKcS0_S0_(ptr noundef nonnull %spec.store.select, ptr noundef %12, ptr noundef %18)
  %.not18 = icmp eq ptr %19, null
  br i1 %.not18, label %20, label %.loopexit

20:                                               ; preds = %13, %17, %.lr.ph
  %21 = add i64 %.01728, 1
  %22 = tail call noundef i64 @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  %.not = icmp eq i64 %21, %22
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %20, %5
  %23 = getelementptr inbounds i8, ptr %0, i64 280
  %24 = load i32, ptr %23, align 8, !tbaa !7
  %25 = icmp eq i32 %24, 0
  br label %.loopexit

.loopexit:                                        ; preds = %17, %13, %._crit_edge, %2
  %.3 = phi i1 [ true, %2 ], [ %25, %._crit_edge ], [ %.not29.not, %13 ], [ %.not29.not, %17 ]
  ret i1 %.3
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter9TextRangeEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL9ImStristrPKcS0_S0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

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


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