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

; 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::ScopedValueSetter" = type <{ ptr, i8, [7 x i8] }>
%"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 }

declare i32 @__gxx_personality_v0(...)

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

declare void @_ZN4juce17ChangeBroadcaster17sendChangeMessageEv(ptr noundef nonnull align 8 dereferenceable(56)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce11UndoManager19beginNewTransactionEv(ptr noundef nonnull align 8 dereferenceable(130)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce11UndoManager10getNextSetEv(ptr noundef nonnull align 8 dereferenceable(130)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17ScopedValueSetterIbEC2ERbb(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17ScopedValueSetterIbED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce11UndoManager4redoEv(ptr noundef nonnull align 8 dereferenceable(130) %0) #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.juce::ScopedValueSetter", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %10 = call noundef ptr @_ZNK4juce11UndoManager10getNextSetEv(ptr noundef nonnull align 8 dereferenceable(130) %9) #4
  store ptr %10, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %30

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  %14 = getelementptr inbounds %"class.juce::UndoManager", ptr %9, i32 0, i32 9
  call void @_ZN4juce17ScopedValueSetterIbEC2ERbb(ptr noundef nonnull align 8 dereferenceable(9) %5, ptr noundef nonnull align 1 dereferenceable(1) %14, i1 noundef zeroext true)
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = invoke noundef zeroext i1 @_ZNK4juce11UndoManager9ActionSet7performEv(ptr noundef nonnull align 8 dereferenceable(40) %15)
          to label %17 unwind label %22

17:                                               ; preds = %13
  br i1 %16, label %18, label %26

18:                                               ; preds = %17
  %19 = getelementptr inbounds %"class.juce::UndoManager", ptr %9, i32 0, i32 7
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %19, align 4, !tbaa !9
  br label %28

22:                                               ; preds = %28, %26, %13
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %6, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %7, align 4
  call void @_ZN4juce17ScopedValueSetterIbED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %36

26:                                               ; preds = %17
  invoke void @_ZN4juce11UndoManager16clearUndoHistoryEv(ptr noundef nonnull align 8 dereferenceable(130) %9)
          to label %27 unwind label %22

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27, %18
  call void @_ZN4juce11UndoManager19beginNewTransactionEv(ptr noundef nonnull align 8 dereferenceable(130) %9) #4
  invoke void @_ZN4juce17ChangeBroadcaster17sendChangeMessageEv(ptr noundef nonnull align 8 dereferenceable(56) %9)
          to label %29 unwind label %22

29:                                               ; preds = %28
  store i1 true, ptr %2, align 1
  store i32 1, ptr %8, align 4
  call void @_ZN4juce17ScopedValueSetterIbED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  br label %31

30:                                               ; preds = %1
  store i32 0, ptr %8, align 4
  br label %31

31:                                               ; preds = %30, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %32 = load i32, ptr %8, align 4
  switch i32 %32, label %41 [
    i32 0, label %33
    i32 1, label %34
  ]

33:                                               ; preds = %31
  store i1 false, ptr %2, align 1
  br label %34

34:                                               ; preds = %33, %31
  %35 = load i1, ptr %2, align 1
  ret i1 %35

36:                                               ; preds = %22
  %37 = load ptr, ptr %6, align 8
  %38 = load i32, ptr %7, align 4
  %39 = insertvalue { ptr, i32 } poison, ptr %37, 0
  %40 = insertvalue { ptr, i32 } %39, i32 %38, 1
  resume { ptr, i32 } %40

41:                                               ; preds = %31
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce11UndoManager9ActionSet7performEv(ptr noundef nonnull align 8 dereferenceable(40)) #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 = { "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 = { 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, !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}


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

%"class.juce::ScopedValueSetter" = type <{ ptr, i8, [7 x i8] }>

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce11UndoManager16clearUndoHistoryEv(ptr noundef nonnull align 8 dereferenceable(130)) local_unnamed_addr #1 align 2

declare void @_ZN4juce17ChangeBroadcaster17sendChangeMessageEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce11UndoManager19beginNewTransactionEv(ptr noundef nonnull align 8 dereferenceable(130)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce11UndoManager10getNextSetEv(ptr noundef nonnull align 8 dereferenceable(130)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17ScopedValueSetterIbEC2ERbb(ptr noundef nonnull align 8 dereferenceable(9), ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17ScopedValueSetterIbED2Ev(ptr noundef nonnull align 8 dereferenceable(9)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4juce11UndoManager4redoEv(ptr noundef nonnull align 8 dereferenceable(130) %0) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.juce::ScopedValueSetter", align 8
  %3 = tail call noundef ptr @_ZNK4juce11UndoManager10getNextSetEv(ptr noundef nonnull align 8 dereferenceable(130) %0) #4
  %.not = icmp ne ptr %3, null
  br i1 %.not, label %4, label %17

4:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 129
  call void @_ZN4juce17ScopedValueSetterIbEC2ERbb(ptr noundef nonnull align 8 dereferenceable(9) %2, ptr noundef nonnull align 1 dereferenceable(1) %5, i1 noundef zeroext true)
  %6 = invoke noundef zeroext i1 @_ZNK4juce11UndoManager9ActionSet7performEv(ptr noundef nonnull align 8 dereferenceable(40) %3)
          to label %7 unwind label %12

7:                                                ; preds = %4
  br i1 %6, label %8, label %14

8:                                                ; preds = %7
  %9 = getelementptr inbounds i8, ptr %0, i64 124
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr %9, align 4, !tbaa !5
  br label %15

12:                                               ; preds = %15, %14, %4
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce17ScopedValueSetterIbED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  resume { ptr, i32 } %13

14:                                               ; preds = %7
  invoke void @_ZN4juce11UndoManager16clearUndoHistoryEv(ptr noundef nonnull align 8 dereferenceable(130) %0)
          to label %15 unwind label %12

15:                                               ; preds = %14, %8
  call void @_ZN4juce11UndoManager19beginNewTransactionEv(ptr noundef nonnull align 8 dereferenceable(130) %0) #4
  invoke void @_ZN4juce17ChangeBroadcaster17sendChangeMessageEv(ptr noundef nonnull align 8 dereferenceable(56) %0)
          to label %16 unwind label %12

16:                                               ; preds = %15
  call void @_ZN4juce17ScopedValueSetterIbED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %2) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #4
  br label %17

17:                                               ; preds = %1, %16
  ret i1 %.not
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce11UndoManager9ActionSet7performEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 = { 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, !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}


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