; 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::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 }
%"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 }

; 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: mustprogress uwtable
define dso_local noundef ptr @_ZN4juce19MidiMessageSequence8addEventERKNS_11MidiMessageEd(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(20) %1, double noundef %2) #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = 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
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %12 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32) #7
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN4juce19MidiMessageSequence15MidiEventHolderC1ERKNS_11MidiMessageE(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(20) %13)
          to label %14 unwind label %37

14:                                               ; preds = %3
  store ptr %12, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef double @_ZNK4juce11MidiMessage12getTimeStampEv(ptr noundef nonnull align 8 dereferenceable(20) %15) #6
  %17 = load double, ptr %6, align 8, !tbaa !9
  %18 = fadd double %17, %16
  store double %18, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.juce::MidiMessageSequence::MidiEventHolder", ptr %19, i32 0, i32 0
  %21 = load double, ptr %6, align 8, !tbaa !9
  call void @_ZN4juce11MidiMessage12setTimeStampEd(ptr noundef nonnull align 8 dereferenceable(20) %20, double noundef %21) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %22 = getelementptr inbounds %"class.juce::MidiMessageSequence", ptr %11, i32 0, i32 0
  %23 = call noundef i32 @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %22) #6
  store i32 %23, ptr %10, align 4, !tbaa !11
  br label %24

24:                                               ; preds = %41, %14
  %25 = load i32, ptr %10, align 4, !tbaa !11
  %26 = add nsw i32 %25, -1
  store i32 %26, ptr %10, align 4, !tbaa !11
  %27 = icmp sge i32 %26, 0
  br i1 %27, label %28, label %42

28:                                               ; preds = %24
  %29 = getelementptr inbounds %"class.juce::MidiMessageSequence", ptr %11, i32 0, i32 0
  %30 = load i32, ptr %10, align 4, !tbaa !11
  %31 = call noundef ptr @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %29, i32 noundef %30) #6
  %32 = getelementptr inbounds %"class.juce::MidiMessageSequence::MidiEventHolder", ptr %31, i32 0, i32 0
  %33 = call noundef double @_ZNK4juce11MidiMessage12getTimeStampEv(ptr noundef nonnull align 8 dereferenceable(20) %32) #6
  %34 = load double, ptr %6, align 8, !tbaa !9
  %35 = fcmp ole double %33, %34
  br i1 %35, label %36, label %41

36:                                               ; preds = %28
  br label %42

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

41:                                               ; preds = %28
  br label %24, !llvm.loop !13

42:                                               ; preds = %36, %24
  %43 = getelementptr inbounds %"class.juce::MidiMessageSequence", ptr %11, i32 0, i32 0
  %44 = load i32, ptr %10, align 4, !tbaa !11
  %45 = add nsw i32 %44, 1
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = call noundef ptr @_ZN4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE6insertEiPS2_(ptr noundef nonnull align 8 dereferenceable(20) %43, i32 noundef %45, ptr noundef %46) #6
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret ptr %48

49:                                               ; preds = %37
  %50 = load ptr, ptr %8, align 8
  %51 = load i32, ptr %9, align 4
  %52 = insertvalue { ptr, i32 } poison, ptr %50, 0
  %53 = insertvalue { ptr, i32 } %52, i32 %51, 1
  resume { ptr, i32 } %53
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20)) #5 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) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE6insertEiPS2_(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef, ptr noundef) #4 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 = { 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 = { 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 #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: mustprogress uwtable
define dso_local noundef nonnull ptr @_ZN4juce19MidiMessageSequence8addEventERKNS_11MidiMessageEd(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(20) %1, double noundef %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = tail call noalias noundef nonnull dereferenceable(32) ptr @_Znwm(i64 noundef 32) #5
  invoke void @_ZN4juce19MidiMessageSequence15MidiEventHolderC1ERKNS_11MidiMessageE(ptr noundef nonnull align 8 dereferenceable(32) %4, ptr noundef nonnull align 8 dereferenceable(20) %1)
          to label %5 unwind label %16

5:                                                ; preds = %3
  %6 = tail call noundef double @_ZNK4juce11MidiMessage12getTimeStampEv(ptr noundef nonnull align 8 dereferenceable(20) %1) #6
  %7 = fadd double %6, %2
  tail call void @_ZN4juce11MidiMessage12setTimeStampEd(ptr noundef nonnull align 8 dereferenceable(20) %4, double noundef %7) #6
  %8 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %0) #6
  br label %9

9:                                                ; preds = %11, %5
  %.0 = phi i32 [ %8, %5 ], [ %12, %11 ]
  %10 = icmp sgt i32 %.0, 0
  br i1 %10, label %11, label %18

11:                                               ; preds = %9
  %12 = add nsw i32 %.0, -1
  %13 = tail call noundef ptr @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %0, i32 noundef %12) #6
  %14 = tail call noundef double @_ZNK4juce11MidiMessage12getTimeStampEv(ptr noundef nonnull align 8 dereferenceable(20) %13) #6
  %15 = fcmp ugt double %14, %7
  br i1 %15, label %9, label %18, !llvm.loop !5

16:                                               ; preds = %3
  %17 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 32) #7
  resume { ptr, i32 } %17

18:                                               ; preds = %11, %9
  %19 = tail call noundef ptr @_ZN4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE6insertEiPS2_(ptr noundef nonnull align 8 dereferenceable(20) %0, i32 noundef %.0, ptr noundef nonnull %4) #6
  ret ptr %4
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20)) local_unnamed_addr #4 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 #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce10OwnedArrayINS_19MidiMessageSequence15MidiEventHolderENS_20DummyCriticalSectionEE6insertEiPS2_(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef, ptr noundef) local_unnamed_addr #3 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 = { 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 #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 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }
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,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass