; LLVM IR from hadryansalles/Luz :: deps/imgui (imgui_impl_vulkan)

; 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.ImGuiPlatformIO = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.ImVector.12, %struct.ImVector.13 }
%struct.ImVector.12 = type { i32, i32, ptr }
%struct.ImVector.13 = type { i32, i32, ptr }
%struct.ImGuiViewport = type <{ i32, i32, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, float, i32, ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, [4 x i8] }>
%struct.ImVec2 = type { float, float }
%struct.ImGui_ImplVulkan_ViewportData = type { i8, %struct.ImGui_ImplVulkanH_Window, %struct.ImGui_ImplVulkan_WindowRenderBuffers }
%struct.ImGui_ImplVulkanH_Window = type { i32, i32, ptr, ptr, %struct.VkSurfaceFormatKHR, i32, ptr, ptr, i8, i8, %union.VkClearValue, i32, i32, i32, i32, ptr, ptr }
%struct.VkSurfaceFormatKHR = type { i32, i32 }
%union.VkClearValue = type { %union.VkClearColorValue }
%union.VkClearColorValue = type { [4 x float] }
%struct.ImGui_ImplVulkan_WindowRenderBuffers = 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: mustprogress uwtable
define dso_local void @_Z50ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffersP10VkDevice_TPK21VkAllocationCallbacks(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %8 = call noundef nonnull align 8 dereferenceable(216) ptr @_ZN5ImGui13GetPlatformIOEv()
  store ptr %8, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %33, %2
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ImGuiPlatformIO, ptr %11, i32 0, i32 24
  %13 = getelementptr inbounds %struct.ImVector.13, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = icmp slt i32 %10, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %36

17:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ImGuiPlatformIO, ptr %18, i32 0, i32 24
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8ImVectorIP13ImGuiViewportEixEi(ptr noundef nonnull align 8 dereferenceable(16) %19, i32 noundef %20)
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ImGuiViewport, ptr %22, i32 0, i32 9
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  store ptr %24, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %32

27:                                               ; preds = %17
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ImGui_ImplVulkan_ViewportData, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z43ImGui_ImplVulkan_DestroyWindowRenderBuffersP10VkDevice_TP36ImGui_ImplVulkan_WindowRenderBuffersPK21VkAllocationCallbacks(ptr noundef %28, ptr noundef %30, ptr noundef %31)
  br label %32

32:                                               ; preds = %27, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !20

36:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z43ImGui_ImplVulkan_DestroyWindowRenderBuffersP10VkDevice_TP36ImGui_ImplVulkan_WindowRenderBuffersPK21VkAllocationCallbacks(ptr noundef, ptr noundef, ptr noundef) #1

declare noundef nonnull align 8 dereferenceable(216) ptr @_ZN5ImGui13GetPlatformIOEv() #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN8ImVectorIP13ImGuiViewportEixEi(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 = { "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 200}
!12 = !{!"_ZTS15ImGuiPlatformIO", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !13, i64 184, !14, i64 200}
!13 = !{!"_ZTS8ImVectorI20ImGuiPlatformMonitorE", !10, i64 0, !10, i64 4, !6, i64 8}
!14 = !{!"_ZTS8ImVectorIP13ImGuiViewportE", !10, i64 0, !10, i64 4, !6, i64 8}
!15 = !{!16, !6, i64 56}
!16 = !{!"_ZTS13ImGuiViewport", !10, i64 0, !10, i64 4, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !18, i64 40, !10, i64 44, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !19, i64 88, !19, i64 89, !19, i64 90, !19, i64 91}
!17 = !{!"_ZTS6ImVec2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local void @_Z50ImGui_ImplVulkanH_DestroyAllViewportsRenderBuffersP10VkDevice_TPK21VkAllocationCallbacks(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call noundef nonnull align 8 dereferenceable(216) ptr @_ZN5ImGui13GetPlatformIOEv()
  %4 = getelementptr inbounds i8, ptr %3, i64 200
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %13, %2
  ret void

.lr.ph:                                           ; preds = %2, %13
  %.09 = phi i32 [ %14, %13 ], [ 0, %2 ]
  %7 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN8ImVectorIP13ImGuiViewportEixEi(ptr noundef nonnull align 8 dereferenceable(16) %4, i32 noundef %.09)
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %8, i64 56
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %13, label %11

11:                                               ; preds = %.lr.ph
  %12 = getelementptr inbounds i8, ptr %10, i64 120
  tail call void @_Z43ImGui_ImplVulkan_DestroyWindowRenderBuffersP10VkDevice_TP36ImGui_ImplVulkan_WindowRenderBuffersPK21VkAllocationCallbacks(ptr noundef %0, ptr noundef nonnull %12, ptr noundef %1)
  br label %13

13:                                               ; preds = %11, %.lr.ph
  %14 = add nuw nsw i32 %.09, 1
  %15 = load i32, ptr %4, align 8, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !19
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z43ImGui_ImplVulkan_DestroyWindowRenderBuffersP10VkDevice_TP36ImGui_ImplVulkan_WindowRenderBuffersPK21VkAllocationCallbacks(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare noundef nonnull align 8 dereferenceable(216) ptr @_ZN5ImGui13GetPlatformIOEv() local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN8ImVectorIP13ImGuiViewportEixEi(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 = { "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, !11, i64 200}
!6 = !{!"_ZTS15ImGuiPlatformIO", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !10, i64 184, !12, i64 200}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS8ImVectorI20ImGuiPlatformMonitorE", !11, i64 0, !11, i64 4, !7, i64 8}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_ZTS8ImVectorIP13ImGuiViewportE", !11, i64 0, !11, i64 4, !7, i64 8}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !7, i64 56}
!15 = !{!"_ZTS13ImGuiViewport", !11, i64 0, !11, i64 4, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !17, i64 40, !11, i64 44, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !18, i64 88, !18, i64 89, !18, i64 90, !18, i64 91}
!16 = !{!"_ZTS6ImVec2", !17, i64 0, !17, i64 4}
!17 = !{!"float", !8, i64 0}
!18 = !{!"bool", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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