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

; 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
define dso_local void @_ZN5ImGui22MultiSelectAddSetRangeEP24ImGuiMultiSelectTempDatabixx(ptr noundef %0, i1 noundef zeroext %1, i32 noundef %2, i64 noundef %3, i64 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.ImGuiSelectionRequest, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  %14 = zext i1 %1 to i8
  store i8 %14, ptr %7, align 1, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !11
  store i64 %3, ptr %9, align 8, !tbaa !13
  store i64 %4, ptr %10, align 8, !tbaa !13
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ImGuiMultiSelectTempData, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.ImGuiMultiSelectIO, ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds %struct.ImVector.41, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !15
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %75

21:                                               ; preds = %5
  %22 = load i64, ptr %9, align 8, !tbaa !13
  %23 = load i64, ptr %10, align 8, !tbaa !13
  %24 = icmp eq i64 %22, %23
  br i1 %24, label %25, label %75

25:                                               ; preds = %21
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ImGuiMultiSelectTempData, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %27, align 4, !tbaa !21
  %29 = and i32 %28, 4
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %75

31:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ImGuiMultiSelectTempData, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.ImGuiMultiSelectIO, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.ImVector.41, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ImGuiMultiSelectTempData, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.ImGuiMultiSelectIO, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.ImVector.41, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 8, !tbaa !15
  %42 = sub nsw i32 %41, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %36, i64 %43
  store ptr %44, ptr %11, align 8, !tbaa !5
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !23
  %48 = icmp eq i32 %47, 2
  br i1 %48, label %49, label %71

49:                                               ; preds = %31
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %50, i32 0, i32 4
  %52 = load i64, ptr %51, align 8, !tbaa !26
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ImGuiMultiSelectTempData, ptr %53, i32 0, i32 6
  %55 = load i64, ptr %54, align 8, !tbaa !27
  %56 = icmp eq i64 %52, %55
  br i1 %56, label %57, label %71

57:                                               ; preds = %49
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %58, i32 0, i32 1
  %60 = load i8, ptr %59, align 4, !tbaa !28, !range !29, !noundef !30
  %61 = trunc i8 %60 to i1
  %62 = zext i1 %61 to i32
  %63 = load i8, ptr %7, align 1, !tbaa !9, !range !29, !noundef !30
  %64 = trunc i8 %63 to i1
  %65 = zext i1 %64 to i32
  %66 = icmp eq i32 %62, %65
  br i1 %66, label %67, label %71

67:                                               ; preds = %57
  %68 = load i64, ptr %10, align 8, !tbaa !13
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %69, i32 0, i32 4
  store i64 %68, ptr %70, align 8, !tbaa !26
  store i32 1, ptr %12, align 4
  br label %72

71:                                               ; preds = %57, %49, %31
  store i32 0, ptr %12, align 4
  br label %72

72:                                               ; preds = %71, %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  %73 = load i32, ptr %12, align 4
  switch i32 %73, label %106 [
    i32 0, label %74
    i32 1, label %105
  ]

74:                                               ; preds = %72
  br label %75

75:                                               ; preds = %74, %25, %21, %5
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  %76 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %13, i32 0, i32 0
  store i32 2, ptr %76, align 8, !tbaa !23
  %77 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %13, i32 0, i32 1
  %78 = load i8, ptr %7, align 1, !tbaa !9, !range !29, !noundef !30
  %79 = trunc i8 %78 to i1
  %80 = zext i1 %79 to i8
  store i8 %80, ptr %77, align 4, !tbaa !28
  %81 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %13, i32 0, i32 2
  %82 = load i32, ptr %8, align 4, !tbaa !11
  %83 = trunc i32 %82 to i8
  store i8 %83, ptr %81, align 1, !tbaa !31
  %84 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %13, i32 0, i32 3
  %85 = load i32, ptr %8, align 4, !tbaa !11
  %86 = icmp sgt i32 %85, 0
  br i1 %86, label %87, label %89

87:                                               ; preds = %75
  %88 = load i64, ptr %9, align 8, !tbaa !13
  br label %91

89:                                               ; preds = %75
  %90 = load i64, ptr %10, align 8, !tbaa !13
  br label %91

91:                                               ; preds = %89, %87
  %92 = phi i64 [ %88, %87 ], [ %90, %89 ]
  store i64 %92, ptr %84, align 8, !tbaa !32
  %93 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %13, i32 0, i32 4
  %94 = load i32, ptr %8, align 4, !tbaa !11
  %95 = icmp sgt i32 %94, 0
  br i1 %95, label %96, label %98

96:                                               ; preds = %91
  %97 = load i64, ptr %10, align 8, !tbaa !13
  br label %100

98:                                               ; preds = %91
  %99 = load i64, ptr %9, align 8, !tbaa !13
  br label %100

100:                                              ; preds = %98, %96
  %101 = phi i64 [ %97, %96 ], [ %99, %98 ]
  store i64 %101, ptr %93, align 8, !tbaa !26
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.ImGuiMultiSelectTempData, ptr %102, i32 0, i32 0
  %104 = getelementptr inbounds %struct.ImGuiMultiSelectIO, ptr %103, i32 0, i32 0
  call void @_ZN8ImVectorI21ImGuiSelectionRequestE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %104, ptr noundef nonnull align 8 dereferenceable(24) %13)
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  br label %105

105:                                              ; preds = %100, %72
  ret void

106:                                              ; preds = %72
  unreachable
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorI21ImGuiSelectionRequestE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(24)) #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 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!16, !12, i64 0}
!16 = !{!"_ZTS24ImGuiMultiSelectTempData", !17, i64 0, !6, i64 40, !12, i64 48, !12, i64 52, !19, i64 56, !19, i64 64, !14, i64 72, !12, i64 80, !12, i64 84, !7, i64 88, !10, i64 89, !10, i64 90, !10, i64 91, !10, i64 92, !10, i64 93, !10, i64 94}
!17 = !{!"_ZTS18ImGuiMultiSelectIO", !18, i64 0, !14, i64 16, !14, i64 24, !10, i64 32, !10, i64 33, !12, i64 36}
!18 = !{!"_ZTS8ImVectorI21ImGuiSelectionRequestE", !12, i64 0, !12, i64 4, !6, i64 8}
!19 = !{!"_ZTS6ImVec2", !20, i64 0, !20, i64 4}
!20 = !{!"float", !7, i64 0}
!21 = !{!16, !12, i64 52}
!22 = !{!16, !6, i64 8}
!23 = !{!24, !25, i64 0}
!24 = !{!"_ZTS21ImGuiSelectionRequest", !25, i64 0, !10, i64 4, !7, i64 5, !14, i64 8, !14, i64 16}
!25 = !{!"_ZTS25ImGuiSelectionRequestType", !7, i64 0}
!26 = !{!24, !14, i64 16}
!27 = !{!16, !14, i64 72}
!28 = !{!24, !10, i64 4}
!29 = !{i8 0, i8 2}
!30 = !{}
!31 = !{!24, !7, i64 5}
!32 = !{!24, !14, i64 8}


; 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.ImGuiSelectionRequest = type { i32, i8, i8, i64, i64 }

; 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 uwtable
define dso_local void @_ZN5ImGui22MultiSelectAddSetRangeEP24ImGuiMultiSelectTempDatabixx(ptr noundef %0, i1 noundef zeroext %1, i32 noundef %2, i64 noundef %3, i64 noundef %4) local_unnamed_addr #1 {
  %6 = alloca %struct.ImGuiSelectionRequest, align 8
  %7 = zext i1 %1 to i8
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %9 = icmp sgt i32 %8, 0
  %10 = icmp eq i64 %3, %4
  %or.cond = and i1 %10, %9
  br i1 %or.cond, label %11, label %.thread

11:                                               ; preds = %5
  %12 = getelementptr inbounds i8, ptr %0, i64 52
  %13 = load i32, ptr %12, align 4, !tbaa !17
  %14 = and i32 %13, 4
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %.thread

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !18
  %19 = zext nneg i32 %8 to i64
  %20 = getelementptr %struct.ImGuiSelectionRequest, ptr %18, i64 %19
  %21 = getelementptr i8, ptr %20, i64 -24
  %22 = load i32, ptr %21, align 8, !tbaa !19
  %23 = icmp eq i32 %22, 2
  br i1 %23, label %24, label %.thread

24:                                               ; preds = %16
  %25 = getelementptr i8, ptr %20, i64 -8
  %26 = load i64, ptr %25, align 8, !tbaa !22
  %27 = getelementptr inbounds i8, ptr %0, i64 72
  %28 = load i64, ptr %27, align 8, !tbaa !23
  %29 = icmp eq i64 %26, %28
  br i1 %29, label %30, label %.thread

30:                                               ; preds = %24
  %31 = getelementptr i8, ptr %20, i64 -20
  %32 = load i8, ptr %31, align 4, !tbaa !24, !range !25, !noundef !26
  %33 = icmp eq i8 %32, %7
  br i1 %33, label %34, label %.thread

34:                                               ; preds = %30
  store i64 %3, ptr %25, align 8, !tbaa !22
  br label %43

.thread:                                          ; preds = %16, %24, %30, %11, %5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  store i32 2, ptr %6, align 8, !tbaa !19
  %35 = getelementptr inbounds i8, ptr %6, i64 4
  store i8 %7, ptr %35, align 4, !tbaa !24
  %36 = getelementptr inbounds i8, ptr %6, i64 5
  %37 = trunc i32 %2 to i8
  store i8 %37, ptr %36, align 1, !tbaa !27
  %38 = getelementptr inbounds i8, ptr %6, i64 8
  %39 = icmp sgt i32 %2, 0
  %40 = select i1 %39, i64 %3, i64 %4
  store i64 %40, ptr %38, align 8, !tbaa !28
  %41 = getelementptr inbounds i8, ptr %6, i64 16
  %42 = select i1 %39, i64 %4, i64 %3
  store i64 %42, ptr %41, align 8, !tbaa !22
  call void @_ZN8ImVectorI21ImGuiSelectionRequestE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(24) %6)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  br label %43

43:                                               ; preds = %34, %.thread
  ret void
}

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

attributes #0 = { mustprogress 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 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, !9, i64 0}
!6 = !{!"_ZTS24ImGuiMultiSelectTempData", !7, i64 0, !12, i64 40, !9, i64 48, !9, i64 52, !15, i64 56, !15, i64 64, !13, i64 72, !9, i64 80, !9, i64 84, !10, i64 88, !14, i64 89, !14, i64 90, !14, i64 91, !14, i64 92, !14, i64 93, !14, i64 94}
!7 = !{!"_ZTS18ImGuiMultiSelectIO", !8, i64 0, !13, i64 16, !13, i64 24, !14, i64 32, !14, i64 33, !9, i64 36}
!8 = !{!"_ZTS8ImVectorI21ImGuiSelectionRequestE", !9, i64 0, !9, i64 4, !12, i64 8}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"any pointer", !10, i64 0}
!13 = !{!"long long", !10, i64 0}
!14 = !{!"bool", !10, i64 0}
!15 = !{!"_ZTS6ImVec2", !16, i64 0, !16, i64 4}
!16 = !{!"float", !10, i64 0}
!17 = !{!6, !9, i64 52}
!18 = !{!6, !12, i64 8}
!19 = !{!20, !21, i64 0}
!20 = !{!"_ZTS21ImGuiSelectionRequest", !21, i64 0, !14, i64 4, !10, i64 5, !13, i64 8, !13, i64 16}
!21 = !{!"_ZTS25ImGuiSelectionRequestType", !10, i64 0}
!22 = !{!20, !13, i64 16}
!23 = !{!6, !13, i64 72}
!24 = !{!20, !14, i64 4}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!20, !10, i64 5}
!28 = !{!20, !13, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass