; 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 nounwind uwtable
define dso_local noundef i32 @_ZNK4juce21ModalComponentManager21getNumModalComponentsEv(ptr noundef nonnull align 8 dereferenceable(48) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %23, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = getelementptr inbounds %"class.juce::ModalComponentManager", ptr %5, i32 0, i32 2
  %9 = call noundef i32 @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %8) #3
  %10 = icmp slt i32 %7, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %26

12:                                               ; preds = %6
  %13 = getelementptr inbounds %"class.juce::ModalComponentManager", ptr %5, i32 0, i32 2
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = call noundef ptr @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %13, i32 noundef %14) #3
  %16 = getelementptr inbounds %"class.juce::ModalComponentManager::ModalItem", ptr %15, i32 0, i32 5
  %17 = load i8, ptr %16, align 4, !tbaa !11, !range !26, !noundef !27
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %22

19:                                               ; preds = %12
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %3, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %19, %12
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !28

26:                                               ; preds = %11
  %27 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 %27
}

; 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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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, !20, i64 108}
!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 = !{i8 0, i8 2}
!27 = !{}
!28 = distinct !{!28, !29}
!29 = !{!"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 nounwind uwtable
define dso_local noundef i32 @_ZNK4juce21ModalComponentManager21getNumModalComponentsEv(ptr noundef nonnull align 8 dereferenceable(48) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %2) #2
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.05.lcssa = phi i32 [ 0, %1 ], [ %spec.select, %.lr.ph ]
  ret i32 %.05.lcssa

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.07 = phi i32 [ %9, %.lr.ph ], [ 0, %1 ]
  %.056 = phi i32 [ %spec.select, %.lr.ph ], [ 0, %1 ]
  %5 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %2, i32 noundef %.07) #2
  %6 = getelementptr inbounds i8, ptr %5, i64 108
  %7 = load i8, ptr %6, align 4, !tbaa !5, !range !24, !noundef !25
  %8 = zext nneg i8 %7 to i32
  %spec.select = add nuw nsw i32 %.056, %8
  %9 = add nuw nsw i32 %.07, 1
  %10 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %2) #2
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.lr.ph, label %._crit_edge, !llvm.loop !26
}

; 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

attributes #0 = { 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 #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, !18, i64 108}
!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 = !{i8 0, i8 2}
!25 = !{}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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