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

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

; 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: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15ImGuiTextFilter5BuildEv(ptr noundef nonnull align 8 dereferenceable(276) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"struct.ImGuiTextFilter::TextRange", align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 1
  call void @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16) %6, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #6
  %7 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 0
  %8 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %9 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 0
  %10 = getelementptr inbounds [256 x i8], ptr %9, i64 0, i64 0
  %11 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 0
  %12 = getelementptr inbounds [256 x i8], ptr %11, i64 0, i64 0
  %13 = call i64 @strlen(ptr noundef %12) #7
  %14 = getelementptr inbounds i8, ptr %10, i64 %13
  call void @_ZN15ImGuiTextFilter9TextRangeC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef %8, ptr noundef %14)
  %15 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 1
  call void @_ZN15ImGuiTextFilter9TextRange5splitEcR8ImVectorIS0_E(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 noundef signext 44, ptr noundef nonnull align 8 dereferenceable(16) %15)
  %16 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 2
  store i32 0, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !13
  br label %17

17:                                               ; preds = %45, %1
  %18 = load i32, ptr %4, align 4, !tbaa !13
  %19 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 1
  %20 = getelementptr inbounds %class.ImVector.19, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !14
  %22 = icmp ne i32 %18, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %48

24:                                               ; preds = %17
  %25 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 1
  %26 = load i32, ptr %4, align 4, !tbaa !13
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %25, i32 noundef %26)
  call void @_ZN15ImGuiTextFilter9TextRange11trim_blanksEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
  %28 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 1
  %29 = load i32, ptr %4, align 4, !tbaa !13
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %28, i32 noundef %29)
  %31 = call noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %30)
  br i1 %31, label %32, label %33

32:                                               ; preds = %24
  br label %45

33:                                               ; preds = %24
  %34 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 1
  %35 = load i32, ptr %4, align 4, !tbaa !13
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %34, i32 noundef %35)
  %37 = call noundef signext i8 @_ZNK15ImGuiTextFilter9TextRange5frontEv(ptr noundef nonnull align 8 dereferenceable(16) %36)
  %38 = sext i8 %37 to i32
  %39 = icmp ne i32 %38, 45
  br i1 %39, label %40, label %44

40:                                               ; preds = %33
  %41 = getelementptr inbounds %struct.ImGuiTextFilter, ptr %5, i32 0, i32 2
  %42 = load i32, ptr %41, align 8, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %41, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %40, %33
  br label %45

45:                                               ; preds = %44, %32
  %46 = load i32, ptr %4, align 4, !tbaa !13
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !13
  br label %17, !llvm.loop !15

48:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #6
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN15ImGuiTextFilter9TextRangeC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #4 align 2

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 272}
!10 = !{!"_ZTS15ImGuiTextFilter", !7, i64 0, !11, i64 256, !12, i64 272}
!11 = !{!"_ZTS8ImVectorIN15ImGuiTextFilter9TextRangeEE", !12, i64 0, !12, i64 4, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 256}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

%"struct.ImGuiTextFilter::TextRange" = type { ptr, ptr }

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15ImGuiTextFilter5BuildEv(ptr noundef nonnull align 8 dereferenceable(276) %0) local_unnamed_addr #2 align 2 {
  %2 = alloca %"struct.ImGuiTextFilter::TextRange", align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 256
  tail call void @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #6
  %4 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #7
  %5 = getelementptr inbounds i8, ptr %0, i64 %4
  call void @_ZN15ImGuiTextFilter9TextRangeC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull %0, ptr noundef nonnull %5)
  call void @_ZN15ImGuiTextFilter9TextRange5splitEcR8ImVectorIS0_E(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 noundef signext 44, ptr noundef nonnull align 8 dereferenceable(16) %3)
  %6 = getelementptr inbounds i8, ptr %0, i64 272
  store i32 0, ptr %6, align 8, !tbaa !5
  %7 = load i32, ptr %3, align 8, !tbaa !12
  %.not6 = icmp eq i32 %7, 0
  br i1 %.not6, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %17, %1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #6
  ret void

.lr.ph:                                           ; preds = %1, %17
  %.07 = phi i32 [ %18, %17 ], [ 0, %1 ]
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.07)
  call void @_ZN15ImGuiTextFilter9TextRange11trim_blanksEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.07)
  %10 = call noundef zeroext i1 @_ZNK15ImGuiTextFilter9TextRange5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %9)
  br i1 %10, label %17, label %11

11:                                               ; preds = %.lr.ph
  %12 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN8ImVectorIN15ImGuiTextFilter9TextRangeEEixEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.07)
  %13 = call noundef signext i8 @_ZNK15ImGuiTextFilter9TextRange5frontEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %.not5 = icmp eq i8 %13, 45
  br i1 %.not5, label %17, label %14

14:                                               ; preds = %11
  %15 = load i32, ptr %6, align 8, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %6, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %11, %14, %.lr.ph
  %18 = add nuw nsw i32 %.07, 1
  %19 = load i32, ptr %3, align 8, !tbaa !12
  %.not = icmp eq i32 %18, %19
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN15ImGuiTextFilter9TextRange5splitEcR8ImVectorIS0_E(ptr noundef nonnull align 8 dereferenceable(16), i8 noundef signext, ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN15ImGuiTextFilter9TextRangeC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) unnamed_addr #4 align 2

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { 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 272}
!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 = !{!6, !10, i64 256}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass