; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode (juce_audio_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::MidiMessageSequence" = type { %"class.juce::OwnedArray.35" }
%"class.juce::OwnedArray.35" = type { %"class.juce::ArrayAllocationBase.36", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.36" = type <{ %"class.juce::HeapBlock.37", i32, [4 x i8] }>
%"class.juce::HeapBlock.37" = type { ptr }
%"class.juce::MidiMessageSequence::MidiEventHolder" = type { %"class.juce::MidiMessage", ptr }
%"class.juce::MidiMessage" = type <{ %"union.juce::MidiMessage::PackedData", double, i32, [4 x i8] }>
%"union.juce::MidiMessage::PackedData" = type { ptr }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce19MidiMessageSequence11addSequenceERKS0_d(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, double noundef %2) #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  %12 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %13

13:                                               ; preds = %35, %3
  %14 = load i32, ptr %7, align 4, !tbaa !11
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.juce::MidiMessageSequence", ptr %15, i32 0, i32 0
  %17 = call noundef i32 @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %16) #6
  %18 = icmp slt i32 %14, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %42

20:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.juce::MidiMessageSequence", ptr %21, i32 0, i32 0
  %23 = load i32, ptr %7, align 4, !tbaa !11
  %24 = call noundef ptr @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %22, i32 noundef %23) #6
  %25 = getelementptr inbounds %"class.juce::MidiMessageSequence::MidiEventHolder", ptr %24, i32 0, i32 0
  store ptr %25, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %26 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32) #7
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  invoke void @_ZN4juce19MidiMessageSequence15MidiEventHolderC1ERKNS_11MidiMessageE(ptr noundef nonnull align 8 dereferenceable(32) %26, ptr noundef nonnull align 8 dereferenceable(20) %27)
          to label %28 unwind label %38

28:                                               ; preds = %20
  store ptr %26, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.juce::MidiMessageSequence::MidiEventHolder", ptr %29, i32 0, i32 0
  %31 = load double, ptr %6, align 8, !tbaa !9
  call void @_ZN4juce11MidiMessage14addToTimeStampEd(ptr noundef nonnull align 8 dereferenceable(20) %30, double noundef %31) #6
  %32 = getelementptr inbounds %"class.juce::MidiMessageSequence", ptr %12, i32 0, i32 0
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = call noundef ptr @_ZN4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE3addEPS2_(ptr noundef nonnull align 8 dereferenceable(20) %32, ptr noundef %33) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %35

35:                                               ; preds = %28
  %36 = load i32, ptr %7, align 4, !tbaa !11
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %7, align 4, !tbaa !11
  br label %13, !llvm.loop !13

38:                                               ; preds = %20
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %10, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %11, align 4
  call void @_ZdlPvm(ptr noundef %26, i64 noundef 32) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %43

42:                                               ; preds = %19
  call void @_ZN4juce19MidiMessageSequence4sortEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #6
  ret void

43:                                               ; preds = %38
  %44 = load ptr, ptr %10, align 8
  %45 = load i32, ptr %11, align 4
  %46 = insertvalue { ptr, i32 } poison, ptr %44, 0
  %47 = insertvalue { ptr, i32 } %46, i32 %45, 1
  resume { ptr, i32 } %47
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce11MidiMessage14addToTimeStampEd(ptr noundef nonnull align 8 dereferenceable(20), double noundef) #5 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce19MidiMessageSequence4sortEv(ptr noundef nonnull align 8 dereferenceable(24)) #5 align 2

declare void @_ZN4juce19MidiMessageSequence15MidiEventHolderC1ERKNS_11MidiMessageE(ptr, ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { 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 #4 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce19MidiMessageSequence11addSequenceERKS0_d(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, double noundef %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %1) #5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %8, %3
  tail call void @_ZN4juce19MidiMessageSequence4sortEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  ret void

.lr.ph:                                           ; preds = %3, %8
  %.011 = phi i32 [ %10, %8 ], [ 0, %3 ]
  %6 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %1, i32 noundef %.011) #5
  %7 = tail call noalias noundef nonnull dereferenceable(32) ptr @_Znwm(i64 noundef 32) #6
  invoke void @_ZN4juce19MidiMessageSequence15MidiEventHolderC1ERKNS_11MidiMessageE(ptr noundef nonnull align 8 dereferenceable(32) %7, ptr noundef nonnull align 8 dereferenceable(20) %6)
          to label %8 unwind label %13

8:                                                ; preds = %.lr.ph
  tail call void @_ZN4juce11MidiMessage14addToTimeStampEd(ptr noundef nonnull align 8 dereferenceable(20) %7, double noundef %2) #5
  %9 = tail call noundef ptr @_ZN4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE3addEPS2_(ptr noundef nonnull align 8 dereferenceable(20) %0, ptr noundef nonnull %7) #5
  %10 = add nuw nsw i32 %.011, 1
  %11 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %1) #5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !5

13:                                               ; preds = %.lr.ph
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 32) #7
  resume { ptr, i32 } %14
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce11MidiMessage14addToTimeStampEd(ptr noundef nonnull align 8 dereferenceable(20), double noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE3addEPS2_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4juce19MidiMessageSequence4sortEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

declare void @_ZN4juce19MidiMessageSequence15MidiEventHolderC1ERKNS_11MidiMessageE(ptr, ptr) local_unnamed_addr

attributes #0 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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