; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorI21ImGuiSelectionRequestE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui20MultiSelectAddSetAllEP24ImGuiMultiSelectTempDatab(ptr noundef %0, i1 noundef zeroext %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca %struct.ImGuiSelectionRequest, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = zext i1 %1 to i8
  store i8 %6, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #3
  %7 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %5, i32 0, i32 0
  store i32 1, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %5, i32 0, i32 1
  %9 = load i8, ptr %4, align 1, !tbaa !9, !range !15, !noundef !16
  %10 = trunc i8 %9 to i1
  %11 = zext i1 %10 to i8
  store i8 %11, ptr %8, align 4, !tbaa !17
  %12 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %5, i32 0, i32 2
  store i8 0, ptr %12, align 1, !tbaa !18
  %13 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %5, i32 0, i32 3
  store i64 -1, ptr %13, align 8, !tbaa !19
  %14 = getelementptr inbounds %struct.ImGuiSelectionRequest, ptr %5, i32 0, i32 4
  store i64 -1, ptr %14, align 8, !tbaa !20
  %15 = load ptr, ptr %3, 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
  call void @_ZN8ImVectorI21ImGuiSelectionRequestE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16) %17, i32 noundef 0)
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ImGuiMultiSelectTempData, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %struct.ImGuiMultiSelectIO, ptr %19, i32 0, i32 0
  call void @_ZN8ImVectorI21ImGuiSelectionRequestE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #3
  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)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !13, i64 0}
!12 = !{!"_ZTS21ImGuiSelectionRequest", !13, i64 0, !10, i64 4, !7, i64 5, !14, i64 8, !14, i64 16}
!13 = !{!"_ZTS25ImGuiSelectionRequestType", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !10, i64 4}
!18 = !{!12, !7, i64 5}
!19 = !{!12, !14, i64 8}
!20 = !{!12, !14, i64 16}


; 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: inlinehint mustprogress uwtable
declare dso_local void @_ZN8ImVectorI21ImGuiSelectionRequestE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5ImGui20MultiSelectAddSetAllEP24ImGuiMultiSelectTempDatab(ptr noundef nonnull %0, i1 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = alloca %struct.ImGuiSelectionRequest, align 8
  %4 = zext i1 %1 to i8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  store i32 1, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 4
  store i8 %4, ptr %5, align 4, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %3, i64 5
  store i8 0, ptr %6, align 1, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %7, i8 -1, i64 16, i1 false)
  tail call void @_ZN8ImVectorI21ImGuiSelectionRequestE6resizeEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef 0)
  call void @_ZN8ImVectorI21ImGuiSelectionRequestE9push_backERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(24) %3)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  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 #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 0}
!6 = !{!"_ZTS21ImGuiSelectionRequest", !7, i64 0, !10, i64 4, !8, i64 5, !11, i64 8, !11, i64 16}
!7 = !{!"_ZTS25ImGuiSelectionRequestType", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!6, !10, i64 4}
!13 = !{!6, !8, i64 5}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass