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

; 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::UndoManager" = type <{ %"class.juce::ChangeBroadcaster", %"class.juce::OwnedArray.38", %"class.juce::OwnedArray.38", %"class.juce::String", i32, i32, i32, i32, i8, i8, [6 x i8] }>
%"class.juce::ChangeBroadcaster" = type { ptr, %"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback", %"class.juce::ListenerList.32" }
%"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback" = type { %"class.juce::AsyncUpdater", ptr }
%"class.juce::AsyncUpdater" = type { ptr, %"class.juce::ReferenceCountedObjectPtr" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }
%"class.juce::ListenerList.32" = type { %"class.juce::Array.33" }
%"class.juce::Array.33" = type { %"class.juce::ArrayAllocationBase.34", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.34" = type <{ %"class.juce::HeapBlock.35", i32, [4 x i8] }>
%"class.juce::HeapBlock.35" = type { ptr }
%"class.juce::OwnedArray.38" = type { %"class.juce::ArrayAllocationBase.39", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.39" = type <{ %"class.juce::HeapBlock.40", i32, [4 x i8] }>
%"class.juce::HeapBlock.40" = type { ptr }
%"class.juce::String" = type { %"class.juce::CharPointer_UTF8" }
%"class.juce::CharPointer_UTF8" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce11UndoManager29dropOldTransactionsIfTooLargeEv(ptr noundef nonnull align 8 dereferenceable(130) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  br label %4

4:                                                ; preds = %34, %1
  %5 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 7
  %6 = load i32, ptr %5, align 4, !tbaa !9
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %8, label %20

8:                                                ; preds = %4
  %9 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 4
  %10 = load i32, ptr %9, align 8, !tbaa !26
  %11 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 5
  %12 = load i32, ptr %11, align 4, !tbaa !27
  %13 = icmp sgt i32 %10, %12
  br i1 %13, label %14, label %20

14:                                               ; preds = %8
  %15 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 1
  %16 = call noundef i32 @_ZNK4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %15) #2
  %17 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 6
  %18 = load i32, ptr %17, align 8, !tbaa !28
  %19 = icmp sgt i32 %16, %18
  br label %20

20:                                               ; preds = %14, %8, %4
  %21 = phi i1 [ false, %8 ], [ false, %4 ], [ %19, %14 ]
  br i1 %21, label %22, label %35

22:                                               ; preds = %20
  %23 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 1
  %24 = call noundef ptr @_ZNK4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE8getFirstEv(ptr noundef nonnull align 8 dereferenceable(20) %23) #2
  %25 = call noundef i32 @_ZNK4juce11UndoManager9ActionSet12getTotalSizeEv(ptr noundef nonnull align 8 dereferenceable(40) %24)
  %26 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 4
  %27 = load i32, ptr %26, align 8, !tbaa !26
  %28 = sub nsw i32 %27, %25
  store i32 %28, ptr %26, align 8, !tbaa !26
  %29 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 1
  call void @_ZN4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE6removeEib(ptr noundef nonnull align 8 dereferenceable(20) %29, i32 noundef 0, i1 noundef zeroext true)
  %30 = getelementptr inbounds %"class.juce::UndoManager", ptr %3, i32 0, i32 7
  %31 = load i32, ptr %30, align 4, !tbaa !9
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr %30, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %22
  br label %34

34:                                               ; preds = %33
  br label %4, !llvm.loop !29

35:                                               ; preds = %20
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK4juce11UndoManager9ActionSet12getTotalSizeEv(ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE6removeEib(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef, i1 noundef zeroext) #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE8getFirstEv(ptr noundef nonnull align 8 dereferenceable(20)) #1 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !19, i64 124}
!10 = !{!"_ZTSN4juce11UndoManagerE", !11, i64 0, !20, i64 56, !20, i64 80, !23, i64 104, !19, i64 112, !19, i64 116, !19, i64 120, !19, i64 124, !25, i64 128, !25, i64 129}
!11 = !{!"_ZTSN4juce17ChangeBroadcasterE", !12, i64 8, !15, i64 32}
!12 = !{!"_ZTSN4juce17ChangeBroadcaster25ChangeBroadcasterCallbackE", !13, i64 0, !6, i64 16}
!13 = !{!"_ZTSN4juce12AsyncUpdaterE", !14, i64 8}
!14 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_12AsyncUpdater19AsyncUpdaterMessageEEE", !6, i64 0}
!15 = !{!"_ZTSN4juce12ListenerListINS_14ChangeListenerENS_5ArrayIPS1_NS_20DummyCriticalSectionELi0EEEEE", !16, i64 0}
!16 = !{!"_ZTSN4juce5ArrayIPNS_14ChangeListenerENS_20DummyCriticalSectionELi0EEE", !17, i64 0, !19, i64 16}
!17 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_14ChangeListenerENS_20DummyCriticalSectionEEE", !18, i64 0, !19, i64 8}
!18 = !{!"_ZTSN4juce9HeapBlockIPNS_14ChangeListenerELb0EEE", !6, i64 0}
!19 = !{!"int", !7, i64 0}
!20 = !{!"_ZTSN4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEEE", !21, i64 0, !19, i64 16}
!21 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_11UndoManager9ActionSetENS_20DummyCriticalSectionEEE", !22, i64 0, !19, i64 8}
!22 = !{!"_ZTSN4juce9HeapBlockIPNS_11UndoManager9ActionSetELb0EEE", !6, i64 0}
!23 = !{!"_ZTSN4juce6StringE", !24, i64 0}
!24 = !{!"_ZTSN4juce16CharPointer_UTF8E", !6, i64 0}
!25 = !{!"bool", !7, i64 0}
!26 = !{!10, !19, i64 112}
!27 = !{!10, !19, i64 116}
!28 = !{!10, !19, i64 120}
!29 = distinct !{!29, !30}
!30 = !{!"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 @_ZN4juce11UndoManager29dropOldTransactionsIfTooLargeEv(ptr noundef nonnull align 8 dereferenceable(130) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 112
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = getelementptr inbounds i8, ptr %0, i64 124
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 116
  %8 = getelementptr inbounds i8, ptr %0, i64 120
  br label %9

9:                                                ; preds = %.lr.ph, %17
  %10 = load i32, ptr %2, align 8, !tbaa !25
  %11 = load i32, ptr %7, align 4, !tbaa !26
  %12 = icmp sgt i32 %10, %11
  br i1 %12, label %13, label %.critedge

13:                                               ; preds = %9
  %14 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #2
  %15 = load i32, ptr %8, align 8, !tbaa !27
  %16 = icmp sgt i32 %14, %15
  br i1 %16, label %17, label %.critedge

17:                                               ; preds = %13
  %18 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE8getFirstEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #2
  %19 = tail call noundef i32 @_ZNK4juce11UndoManager9ActionSet12getTotalSizeEv(ptr noundef nonnull align 8 dereferenceable(40) %18)
  %20 = load i32, ptr %2, align 8, !tbaa !25
  %21 = sub nsw i32 %20, %19
  store i32 %21, ptr %2, align 8, !tbaa !25
  tail call void @_ZN4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE6removeEib(ptr noundef nonnull align 8 dereferenceable(20) %3, i32 noundef 0, i1 noundef zeroext true)
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr %4, align 4, !tbaa !5
  %24 = icmp sgt i32 %22, 1
  br i1 %24, label %9, label %.critedge, !llvm.loop !28

.critedge:                                        ; preds = %13, %17, %9, %1
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK4juce11UndoManager9ActionSet12getTotalSizeEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE6removeEib(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef, i1 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEE8getFirstEv(ptr noundef nonnull align 8 dereferenceable(20)) local_unnamed_addr #1 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, !18, i64 124}
!6 = !{!"_ZTSN4juce11UndoManagerE", !7, i64 0, !19, i64 56, !19, i64 80, !22, i64 104, !18, i64 112, !18, i64 116, !18, i64 120, !18, i64 124, !24, i64 128, !24, i64 129}
!7 = !{!"_ZTSN4juce17ChangeBroadcasterE", !8, i64 8, !14, i64 32}
!8 = !{!"_ZTSN4juce17ChangeBroadcaster25ChangeBroadcasterCallbackE", !9, i64 0, !11, i64 16}
!9 = !{!"_ZTSN4juce12AsyncUpdaterE", !10, i64 8}
!10 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_12AsyncUpdater19AsyncUpdaterMessageEEE", !11, i64 0}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSN4juce12ListenerListINS_14ChangeListenerENS_5ArrayIPS1_NS_20DummyCriticalSectionELi0EEEEE", !15, i64 0}
!15 = !{!"_ZTSN4juce5ArrayIPNS_14ChangeListenerENS_20DummyCriticalSectionELi0EEE", !16, i64 0, !18, i64 16}
!16 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_14ChangeListenerENS_20DummyCriticalSectionEEE", !17, i64 0, !18, i64 8}
!17 = !{!"_ZTSN4juce9HeapBlockIPNS_14ChangeListenerELb0EEE", !11, i64 0}
!18 = !{!"int", !12, i64 0}
!19 = !{!"_ZTSN4juce10OwnedArrayINS_11UndoManager9ActionSetENS_20DummyCriticalSectionEEE", !20, i64 0, !18, i64 16}
!20 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_11UndoManager9ActionSetENS_20DummyCriticalSectionEEE", !21, i64 0, !18, i64 8}
!21 = !{!"_ZTSN4juce9HeapBlockIPNS_11UndoManager9ActionSetELb0EEE", !11, i64 0}
!22 = !{!"_ZTSN4juce6StringE", !23, i64 0}
!23 = !{!"_ZTSN4juce16CharPointer_UTF8E", !11, i64 0}
!24 = !{!"bool", !12, i64 0}
!25 = !{!6, !18, i64 112}
!26 = !{!6, !18, i64 116}
!27 = !{!6, !18, i64 120}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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