; 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 }
%"struct.juce::UndoManager::ActionSet" = type { %"class.juce::OwnedArray.44", %"class.juce::String", %"class.juce::Time" }
%"class.juce::OwnedArray.44" = type { %"class.juce::ArrayAllocationBase.45", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.45" = type <{ %"class.juce::HeapBlock.46", i32, [4 x i8] }>
%"class.juce::HeapBlock.46" = type { ptr }
%"class.juce::Time" = type { i64 }

; 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
declare dso_local noundef ptr @_ZNK4juce11UndoManager13getCurrentSetEv(ptr noundef nonnull align 8 dereferenceable(130)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK4juce11UndoManager33getNumActionsInCurrentTransactionEv(ptr noundef nonnull align 8 dereferenceable(130) %0) #1 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"class.juce::UndoManager", ptr %6, i32 0, i32 8
  %8 = load i8, ptr %7, align 8, !tbaa !9, !range !26, !noundef !27
  %9 = trunc i8 %8 to i1
  br i1 %9, label %22, label %10

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %11 = call noundef ptr @_ZNK4juce11UndoManager13getCurrentSetEv(ptr noundef nonnull align 8 dereferenceable(130) %6) #3
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %18

14:                                               ; preds = %10
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.juce::UndoManager::ActionSet", ptr %15, i32 0, i32 0
  %17 = call noundef i32 @_ZNK4juce10OwnedArrayINS_14UndoableActionENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %16) #3
  store i32 %17, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %19

18:                                               ; preds = %10
  store i32 0, ptr %5, align 4
  br label %19

19:                                               ; preds = %18, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %20 = load i32, ptr %5, align 4
  switch i32 %20, label %25 [
    i32 0, label %21
    i32 1, label %23
  ]

21:                                               ; preds = %19
  br label %22

22:                                               ; preds = %21, %1
  store i32 0, ptr %2, align 4
  br label %23

23:                                               ; preds = %22, %19
  %24 = load i32, ptr %2, align 4
  ret i32 %24

25:                                               ; preds = %19
  unreachable
}

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, !25, i64 128}
!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 = !{i8 0, i8 2}
!27 = !{}


; 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
declare dso_local noundef ptr @_ZNK4juce11UndoManager13getCurrentSetEv(ptr noundef nonnull align 8 dereferenceable(130)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK4juce11UndoManager33getNumActionsInCurrentTransactionEv(ptr noundef nonnull align 8 dereferenceable(130) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 128
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !25, !noundef !26
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %.thread, label %5

5:                                                ; preds = %1
  %6 = tail call noundef ptr @_ZNK4juce11UndoManager13getCurrentSetEv(ptr noundef nonnull align 8 dereferenceable(130) %0) #2
  %.not.not = icmp eq ptr %6, null
  br i1 %.not.not, label %.thread, label %7

7:                                                ; preds = %5
  %8 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_14UndoableActionENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %6) #2
  br label %.thread

.thread:                                          ; preds = %5, %1, %7
  %.1 = phi i32 [ %8, %7 ], [ 0, %1 ], [ 0, %5 ]
  ret i32 %.1
}

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, !24, i64 128}
!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 = !{i8 0, i8 2}
!26 = !{}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass