; LLVM IR from xhub/reshop :: gui/external/imgui (imgui_widgets)

; 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.ImGuiSelectionExternalStorage = type { ptr, ptr }
%struct.ImGuiMultiSelectIO = type { %struct.ImVector.41, i64, i64, i8, i8, i32 }
%struct.ImVector.41 = type { i32, i32, ptr }
%struct.ImGuiSelectionRequest = type { i32, i8, i8, i64, i64 }

@.str.2 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.187 = external hidden unnamed_addr constant [23 x i8], align 1
@__PRETTY_FUNCTION__._ZN29ImGuiSelectionExternalStorage13ApplyRequestsEP18ImGuiMultiSelectIO = external hidden unnamed_addr constant [72 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN29ImGuiSelectionExternalStorage13ApplyRequestsEP18ImGuiMultiSelectIO(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  %13 = getelementptr inbounds %struct.ImGuiSelectionExternalStorage, ptr %12, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  br label %19

17:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.187, ptr noundef @.str.2, i32 noundef 8222, ptr noundef @__PRETTY_FUNCTION__._ZN29ImGuiSelectionExternalStorage13ApplyRequestsEP18ImGuiMultiSelectIO) #4
  unreachable

18:                                               ; No predecessors!
  br label %19

19:                                               ; preds = %18, %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ImGuiMultiSelectIO, ptr %20, i32 0, i32 0
  store ptr %21, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call noundef ptr @_ZN8ImVectorI21ImGuiSelectionRequestE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %22)
  store ptr %23, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call noundef ptr @_ZN8ImVectorI21ImGuiSelectionRequestE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %24)
  store ptr %25, ptr %7, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %88, %19
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = icmp ne ptr %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %91

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %32, ptr %9, align 8, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !11
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %57

37:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !16
  br label %38

38:                                               ; preds = %53, %37
  %39 = load i32, ptr %10, align 4, !tbaa !16
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ImGuiMultiSelectIO, ptr %40, i32 0, i32 5
  %42 = load i32, ptr %41, align 4, !tbaa !18
  %43 = icmp slt i32 %39, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  store i32 4, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %56

45:                                               ; preds = %38
  %46 = getelementptr inbounds %struct.ImGuiSelectionExternalStorage, ptr %12, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = load i32, ptr %10, align 4, !tbaa !16
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %49, i32 0, i32 1
  %51 = load i8, ptr %50, align 4, !tbaa !21, !range !22, !noundef !23
  %52 = trunc i8 %51 to i1
  call void %47(ptr noundef %12, i32 noundef %48, i1 noundef zeroext %52)
  br label %53

53:                                               ; preds = %45
  %54 = load i32, ptr %10, align 4, !tbaa !16
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %10, align 4, !tbaa !16
  br label %38, !llvm.loop !24

56:                                               ; preds = %44
  br label %57

57:                                               ; preds = %56, %31
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !11
  %61 = icmp eq i32 %60, 2
  br i1 %61, label %62, label %87

62:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %63, i32 0, i32 3
  %65 = load i64, ptr %64, align 8, !tbaa !26
  %66 = trunc i64 %65 to i32
  store i32 %66, ptr %11, align 4, !tbaa !16
  br label %67

67:                                               ; preds = %83, %62
  %68 = load i32, ptr %11, align 4, !tbaa !16
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %69, i32 0, i32 4
  %71 = load i64, ptr %70, align 8, !tbaa !27
  %72 = trunc i64 %71 to i32
  %73 = icmp sle i32 %68, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %67
  store i32 7, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %86

75:                                               ; preds = %67
  %76 = getelementptr inbounds %struct.ImGuiSelectionExternalStorage, ptr %12, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !9
  %78 = load i32, ptr %11, align 4, !tbaa !16
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %79, i32 0, i32 1
  %81 = load i8, ptr %80, align 4, !tbaa !21, !range !22, !noundef !23
  %82 = trunc i8 %81 to i1
  call void %77(ptr noundef %12, i32 noundef %78, i1 noundef zeroext %82)
  br label %83

83:                                               ; preds = %75
  %84 = load i32, ptr %11, align 4, !tbaa !16
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %11, align 4, !tbaa !16
  br label %67, !llvm.loop !28

86:                                               ; preds = %74
  br label %87

87:                                               ; preds = %86, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %88

88:                                               ; preds = %87
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %89, i32 1
  store ptr %90, ptr %6, align 8, !tbaa !5
  br label %26

91:                                               ; preds = %30
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 = { 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 = { noreturn nounwind }
attributes #5 = { 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, !6, i64 8}
!10 = !{!"_ZTS29ImGuiSelectionExternalStorage", !6, i64 0, !6, i64 8}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS21ImGuiSelectionRequest", !13, i64 0, !14, i64 4, !7, i64 5, !15, i64 8, !15, i64 16}
!13 = !{!"_ZTS25ImGuiSelectionRequestType", !7, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!19, !17, i64 36}
!19 = !{!"_ZTS18ImGuiMultiSelectIO", !20, i64 0, !15, i64 16, !15, i64 24, !14, i64 32, !14, i64 33, !17, i64 36}
!20 = !{!"_ZTS8ImVectorI21ImGuiSelectionRequestE", !17, i64 0, !17, i64 4, !6, i64 8}
!21 = !{!12, !14, i64 4}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!12, !15, i64 8}
!27 = !{!12, !15, i64 16}
!28 = distinct !{!28, !25}


; 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.2 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.187 = external hidden unnamed_addr constant [23 x i8], align 1
@__PRETTY_FUNCTION__._ZN29ImGuiSelectionExternalStorage13ApplyRequestsEP18ImGuiMultiSelectIO = external hidden unnamed_addr constant [72 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN29ImGuiSelectionExternalStorage13ApplyRequestsEP18ImGuiMultiSelectIO(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.187, ptr noundef nonnull @.str.2, i32 noundef 8222, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN29ImGuiSelectionExternalStorage13ApplyRequestsEP18ImGuiMultiSelectIO) #3
  unreachable

6:                                                ; preds = %2
  %7 = tail call noundef ptr @_ZN8ImVectorI21ImGuiSelectionRequestE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %8 = tail call noundef ptr @_ZN8ImVectorI21ImGuiSelectionRequestE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %1)
  %.not2228 = icmp eq ptr %7, %8
  br i1 %.not2228, label %._crit_edge, label %.lr.ph31

.lr.ph31:                                         ; preds = %6
  %9 = getelementptr inbounds i8, ptr %1, i64 36
  br label %10

._crit_edge:                                      ; preds = %.loopexit, %6
  ret void

10:                                               ; preds = %.lr.ph31, %.loopexit
  %.02129 = phi ptr [ %7, %.lr.ph31 ], [ %40, %.loopexit ]
  %11 = load i32, ptr %.02129, align 8, !tbaa !10
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %.preheader, label %thread-pre-split

.preheader:                                       ; preds = %10
  %13 = load i32, ptr %9, align 4, !tbaa !15
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %15 = getelementptr inbounds i8, ptr %.02129, i64 4
  br label %16

16:                                               ; preds = %.lr.ph, %16
  %.02024 = phi i32 [ 0, %.lr.ph ], [ %20, %16 ]
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i8, ptr %15, align 4, !tbaa !19, !range !20, !noundef !21
  %19 = trunc nuw i8 %18 to i1
  tail call void %17(ptr noundef nonnull %0, i32 noundef %.02024, i1 noundef zeroext %19)
  %20 = add nuw nsw i32 %.02024, 1
  %21 = load i32, ptr %9, align 4, !tbaa !15
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %16, label %thread-pre-split.loopexit, !llvm.loop !22

thread-pre-split.loopexit:                        ; preds = %16
  %.pr.pre = load i32, ptr %.02129, align 8, !tbaa !10
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %thread-pre-split.loopexit, %10
  %23 = phi i32 [ %11, %10 ], [ %.pr.pre, %thread-pre-split.loopexit ]
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %25, label %.loopexit

25:                                               ; preds = %thread-pre-split
  %26 = getelementptr inbounds i8, ptr %.02129, i64 8
  %27 = load i64, ptr %26, align 8, !tbaa !24
  %28 = trunc i64 %27 to i32
  %29 = getelementptr inbounds i8, ptr %.02129, i64 16
  %30 = load i64, ptr %29, align 8, !tbaa !25
  %31 = trunc i64 %30 to i32
  %.not2325 = icmp sgt i32 %28, %31
  br i1 %.not2325, label %.loopexit, label %.lr.ph27

.lr.ph27:                                         ; preds = %25
  %32 = getelementptr inbounds i8, ptr %.02129, i64 4
  br label %33

33:                                               ; preds = %.lr.ph27, %33
  %.026 = phi i32 [ %28, %.lr.ph27 ], [ %37, %33 ]
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load i8, ptr %32, align 4, !tbaa !19, !range !20, !noundef !21
  %36 = trunc nuw i8 %35 to i1
  tail call void %34(ptr noundef nonnull %0, i32 noundef %.026, i1 noundef zeroext %36)
  %37 = add nsw i32 %.026, 1
  %38 = load i64, ptr %29, align 8, !tbaa !25
  %39 = trunc i64 %38 to i32
  %.not23.not = icmp slt i32 %.026, %39
  br i1 %.not23.not, label %33, label %.loopexit, !llvm.loop !26

.loopexit:                                        ; preds = %33, %.preheader, %25, %thread-pre-split
  %40 = getelementptr inbounds i8, ptr %.02129, i64 24
  %.not22 = icmp eq ptr %40, %8
  br i1 %.not22, label %._crit_edge, label %10
}

attributes #0 = { noreturn nounwind "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" }
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 = { noreturn 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, !7, i64 8}
!6 = !{!"_ZTS29ImGuiSelectionExternalStorage", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTS21ImGuiSelectionRequest", !12, i64 0, !13, i64 4, !8, i64 5, !14, i64 8, !14, i64 16}
!12 = !{!"_ZTS25ImGuiSelectionRequestType", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"long long", !8, i64 0}
!15 = !{!16, !18, i64 36}
!16 = !{!"_ZTS18ImGuiMultiSelectIO", !17, i64 0, !14, i64 16, !14, i64 24, !13, i64 32, !13, i64 33, !18, i64 36}
!17 = !{!"_ZTS8ImVectorI21ImGuiSelectionRequestE", !18, i64 0, !18, i64 4, !7, i64 8}
!18 = !{!"int", !8, i64 0}
!19 = !{!11, !13, i64 4}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!11, !14, i64 8}
!25 = !{!11, !14, i64 16}
!26 = distinct !{!26, !23}


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