; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_gui_basics)

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

%"class.juce::ModalComponentManager" = type { %"class.juce::AsyncUpdater", %"class.juce::DeletedAtShutdown", %"class.juce::OwnedArray.61" }
%"class.juce::AsyncUpdater" = type { ptr, %"class.juce::ReferenceCountedObjectPtr.15" }
%"class.juce::ReferenceCountedObjectPtr.15" = type { ptr }
%"class.juce::DeletedAtShutdown" = type { ptr }
%"class.juce::OwnedArray.61" = type { %"class.juce::ArrayAllocationBase.62", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.62" = type <{ %"class.juce::HeapBlock.63", i32, [4 x i8] }>
%"class.juce::HeapBlock.63" = type { ptr }
%"class.juce::ModalComponentManager::ModalItem" = type <{ %"class.juce::ComponentMovementWatcher.base", [4 x i8], ptr, %"class.juce::OwnedArray.90", i32, i8, i8, [2 x i8] }>
%"class.juce::ComponentMovementWatcher.base" = type <{ %"class.juce::ComponentListener", %"class.juce::WeakReference", i32, [4 x i8], %"class.juce::Array", i8, i8, [2 x i8], %"class.juce::Rectangle" }>
%"class.juce::ComponentListener" = type { ptr }
%"class.juce::WeakReference" = type { %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }
%"class.juce::Array" = type { %"class.juce::ArrayAllocationBase", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase" = type <{ %"class.juce::HeapBlock", i32, [4 x i8] }>
%"class.juce::HeapBlock" = type { ptr }
%"class.juce::Rectangle" = type { %"class.juce::Point", i32, i32 }
%"class.juce::Point" = type { i32, i32 }
%"class.juce::OwnedArray.90" = type { %"class.juce::ArrayAllocationBase.91", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.91" = type <{ %"class.juce::HeapBlock.92", i32, [4 x i8] }>
%"class.juce::HeapBlock.92" = type { 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 @_ZN4juce21ModalComponentManager8endModalEPNS_9ComponentEi(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %10 = getelementptr inbounds %"class.juce::ModalComponentManager", ptr %9, i32 0, i32 2
  %11 = call noundef i32 @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %10) #3
  store i32 %11, ptr %7, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %31, %3
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr %7, align 4, !tbaa !9
  %15 = icmp sge i32 %14, 0
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %32

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %18 = getelementptr inbounds %"class.juce::ModalComponentManager", ptr %9, i32 0, i32 2
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = call noundef ptr @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %18, i32 noundef %19) #3
  store ptr %20, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.juce::ModalComponentManager::ModalItem", ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = icmp eq ptr %23, %24
  br i1 %25, label %26, label %31

26:                                               ; preds = %17
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.juce::ModalComponentManager::ModalItem", ptr %28, i32 0, i32 4
  store i32 %27, ptr %29, align 8, !tbaa !26
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN4juce21ModalComponentManager9ModalItem6cancelEv(ptr noundef nonnull align 8 dereferenceable(110) %30)
  br label %31

31:                                               ; preds = %26, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %12, !llvm.loop !27

32:                                               ; preds = %16
  ret void
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce21ModalComponentManager9ModalItem6cancelEv(ptr noundef nonnull align 8 dereferenceable(110)) #1 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 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 = { 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, !6, i64 72}
!12 = !{!"_ZTSN4juce21ModalComponentManager9ModalItemE", !13, i64 0, !6, i64 72, !23, i64 80, !10, i64 104, !20, i64 108, !20, i64 109}
!13 = !{!"_ZTSN4juce24ComponentMovementWatcherE", !14, i64 0, !15, i64 8, !10, i64 16, !17, i64 24, !20, i64 48, !20, i64 49, !21, i64 52}
!14 = !{!"_ZTSN4juce17ComponentListenerE"}
!15 = !{!"_ZTSN4juce13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEEE", !16, i64 0}
!16 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE13SharedPointerEEE", !6, i64 0}
!17 = !{!"_ZTSN4juce5ArrayIPNS_9ComponentENS_20DummyCriticalSectionELi0EEE", !18, i64 0, !10, i64 16}
!18 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_9ComponentENS_20DummyCriticalSectionEEE", !19, i64 0, !10, i64 8}
!19 = !{!"_ZTSN4juce9HeapBlockIPNS_9ComponentELb0EEE", !6, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTSN4juce9RectangleIiEE", !22, i64 0, !10, i64 8, !10, i64 12}
!22 = !{!"_ZTSN4juce5PointIiEE", !10, i64 0, !10, i64 4}
!23 = !{!"_ZTSN4juce10OwnedArrayINS_21ModalComponentManager8CallbackENS_20DummyCriticalSectionEEE", !24, i64 0, !10, i64 16}
!24 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_21ModalComponentManager8CallbackENS_20DummyCriticalSectionEEE", !25, i64 0, !10, i64 8}
!25 = !{!"_ZTSN4juce9HeapBlockIPNS_21ModalComponentManager8CallbackELb0EEE", !6, i64 0}
!26 = !{!12, !10, i64 104}
!27 = distinct !{!27, !28}
!28 = !{!"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 @_ZN4juce21ModalComponentManager8endModalEPNS_9ComponentEi(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef readnone %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %4) #2
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %14, %3
  ret void

.lr.ph:                                           ; preds = %3, %14
  %.in = phi i32 [ %7, %14 ], [ %5, %3 ]
  %7 = add nsw i32 %.in, -1
  %8 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %4, i32 noundef %7) #2
  %9 = getelementptr inbounds i8, ptr %8, i64 72
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = icmp eq ptr %10, %1
  br i1 %11, label %12, label %14

12:                                               ; preds = %.lr.ph
  %13 = getelementptr inbounds i8, ptr %8, i64 104
  store i32 %2, ptr %13, align 8, !tbaa !24
  tail call void @_ZN4juce21ModalComponentManager9ModalItem6cancelEv(ptr noundef nonnull align 8 dereferenceable(110) %8)
  br label %14

14:                                               ; preds = %12, %.lr.ph
  %15 = icmp ugt i32 %.in, 1
  br i1 %15, label %.lr.ph, label %._crit_edge, !llvm.loop !25
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce21ModalComponentManager9ModalItem6cancelEv(ptr noundef nonnull align 8 dereferenceable(110)) local_unnamed_addr #0 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 = { 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 = { 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, !11, i64 72}
!6 = !{!"_ZTSN4juce21ModalComponentManager9ModalItemE", !7, i64 0, !11, i64 72, !21, i64 80, !14, i64 104, !18, i64 108, !18, i64 109}
!7 = !{!"_ZTSN4juce24ComponentMovementWatcherE", !8, i64 0, !9, i64 8, !14, i64 16, !15, i64 24, !18, i64 48, !18, i64 49, !19, i64 52}
!8 = !{!"_ZTSN4juce17ComponentListenerE"}
!9 = !{!"_ZTSN4juce13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEEE", !10, i64 0}
!10 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_13WeakReferenceINS_9ComponentENS_22ReferenceCountedObjectEE13SharedPointerEEE", !11, i64 0}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"int", !12, i64 0}
!15 = !{!"_ZTSN4juce5ArrayIPNS_9ComponentENS_20DummyCriticalSectionELi0EEE", !16, i64 0, !14, i64 16}
!16 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_9ComponentENS_20DummyCriticalSectionEEE", !17, i64 0, !14, i64 8}
!17 = !{!"_ZTSN4juce9HeapBlockIPNS_9ComponentELb0EEE", !11, i64 0}
!18 = !{!"bool", !12, i64 0}
!19 = !{!"_ZTSN4juce9RectangleIiEE", !20, i64 0, !14, i64 8, !14, i64 12}
!20 = !{!"_ZTSN4juce5PointIiEE", !14, i64 0, !14, i64 4}
!21 = !{!"_ZTSN4juce10OwnedArrayINS_21ModalComponentManager8CallbackENS_20DummyCriticalSectionEEE", !22, i64 0, !14, i64 16}
!22 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_21ModalComponentManager8CallbackENS_20DummyCriticalSectionEEE", !23, i64 0, !14, i64 8}
!23 = !{!"_ZTSN4juce9HeapBlockIPNS_21ModalComponentManager8CallbackELb0EEE", !11, i64 0}
!24 = !{!6, !14, i64 104}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


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