; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/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.31, i32, [4 x i8] }>
%struct.ImVector.31 = type { i32, i32, ptr }
%"struct.ImGuiTextFilter::ImGuiTextRange" = type { ptr, ptr }

@.str.16 = 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15ImGuiTextFilter14ImGuiTextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 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) #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 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 @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE5emptyEv(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 %84

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.16, 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 = %73, %19
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %11, i32 0, i32 1
  %23 = getelementptr inbounds %struct.ImVector.31, 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 %76

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 @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEEixEi(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 @_ZNK15ImGuiTextFilter14ImGuiTextRange5emptyEv(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 %70

34:                                               ; preds = %27
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %37, i64 0
  %39 = load i8, ptr %38, align 1, !tbaa !16
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 45
  br i1 %41, label %42, label %56

42:                                               ; preds = %34
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !14
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %49, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef %43, ptr noundef %44, ptr noundef %48, ptr noundef %51)
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %42
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %70

55:                                               ; preds = %42
  br label %69

56:                                               ; preds = %34
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !14
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.ImGuiTextFilter::ImGuiTextRange", ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  %65 = call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef %57, ptr noundef %58, ptr noundef %61, ptr noundef %64)
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %56
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %70

68:                                               ; preds = %56
  br label %69

69:                                               ; preds = %68, %55
  store i32 0, ptr %9, align 4
  br label %70

70:                                               ; preds = %69, %67, %54, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %71 = load i32, ptr %9, align 4
  switch i32 %71, label %76 [
    i32 0, label %72
    i32 4, label %73
  ]

72:                                               ; preds = %70
  br label %73

73:                                               ; preds = %72, %70
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %8, align 4, !tbaa !9
  br label %20, !llvm.loop !18

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

78:                                               ; preds = %76
  %79 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %11, i32 0, i32 2
  %80 = load i32, ptr %79, align 8, !tbaa !20
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %78
  store i1 true, ptr %4, align 1
  br label %84

83:                                               ; preds = %78
  store i1 false, ptr %4, align 1
  br label %84

84:                                               ; preds = %83, %82, %76, %14
  %85 = load i1, ptr %4, align 1
  ret i1 %85

86:                                               ; preds = %76
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE5emptyEv(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 @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #3 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 = { 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 = { 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 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE", !10, i64 0, !10, i64 4, !6, i64 8}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTSN15ImGuiTextFilter14ImGuiTextRangeE", !6, i64 0, !6, i64 8}
!16 = !{!7, !7, i64 0}
!17 = !{!15, !6, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!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.16 = 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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK15ImGuiTextFilter14ImGuiTextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #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) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 256
  %5 = tail call noundef zeroext i1 @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEE5emptyEv(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.16, 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, %23
  %.01930 = phi i32 [ %24, %23 ], [ 0, %6 ]
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %.01930)
  %10 = tail call noundef zeroext i1 @_ZNK15ImGuiTextFilter14ImGuiTextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  br i1 %10, label %23, label %11

11:                                               ; preds = %.lr.ph
  %12 = load ptr, ptr %9, align 8, !tbaa !12
  %13 = load i8, ptr %12, align 1, !tbaa !14
  %.not31.not = icmp ne i8 %13, 45
  br i1 %.not31.not, label %19, label %14

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

19:                                               ; preds = %11
  %20 = getelementptr inbounds i8, ptr %9, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = tail call noundef ptr @_Z9ImStristrPKcS0_S0_S0_(ptr noundef nonnull %spec.store.select, ptr noundef %2, ptr noundef nonnull %12, ptr noundef %21)
  %.not20 = icmp eq ptr %22, null
  br i1 %.not20, label %23, label %.loopexit

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

._crit_edge:                                      ; preds = %23, %6
  %26 = getelementptr inbounds i8, ptr %0, i64 272
  %27 = load i32, ptr %26, align 8, !tbaa !18
  %28 = icmp eq i32 %27, 0
  br label %.loopexit

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNK8ImVectorIN15ImGuiTextFilter14ImGuiTextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #2 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 = { 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 = { 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 = !{!7, !7, i64 0}
!15 = !{!13, !11, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !10, i64 272}


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