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

%"struct.juce::MPENote" = type <{ i16, i8, i8, %"class.juce::MPEValue", %"class.juce::MPEValue", %"class.juce::MPEValue", %"class.juce::MPEValue", %"class.juce::MPEValue", double, i32, [4 x i8] }>
%"class.juce::MPEValue" = type { i32 }
%"class.juce::GenericScopedLock" = type { ptr }
%"class.juce::MPESynthesiser" = type { %"struct.juce::MPESynthesiserBase.base", %"class.juce::OwnedArray.72", i8, %"class.juce::CriticalSection" }
%"struct.juce::MPESynthesiserBase.base" = type <{ %"class.juce::MPEInstrument::Listener", %"class.juce::ScopedPointer", %"class.juce::CriticalSection", double, i32, i8 }>
%"class.juce::MPEInstrument::Listener" = type { ptr }
%"class.juce::ScopedPointer" = type { ptr }
%"class.juce::OwnedArray.72" = type { %"class.juce::ArrayAllocationBase.73", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.73" = type <{ %"class.juce::HeapBlock.74", i32, [4 x i8] }>
%"class.juce::HeapBlock.74" = type { ptr }
%"class.juce::CriticalSection" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce19MPESynthesiserVoice22isCurrentlyPlayingNoteENS_7MPENoteE(ptr noundef nonnull align 8 dereferenceable(60), ptr noundef byval(%"struct.juce::MPENote") align 8) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce14MPESynthesiser9stopVoiceEPNS_19MPESynthesiserVoiceENS_7MPENoteEb(ptr noundef nonnull align 8 dereferenceable(144), ptr noundef, ptr noundef byval(%"struct.juce::MPENote") align 8, i1 noundef zeroext) #4 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce14MPESynthesiser12noteReleasedENS_7MPENoteE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef byval(%"struct.juce::MPENote") align 8 %1) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca %"class.juce::GenericScopedLock", align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.juce::MPENote", align 8
  %8 = alloca %"struct.juce::MPENote", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %12 = getelementptr inbounds %"class.juce::MPESynthesiser", ptr %11, i32 0, i32 3
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(40) %12) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %13 = getelementptr inbounds %"class.juce::MPESynthesiser", ptr %11, i32 0, i32 1
  %14 = call noundef i32 @_ZNK4juce10OwnedArrayINS_19MPESynthesiserVoiceENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %13) #5
  store i32 %14, ptr %5, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %33, %2
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = add nsw i32 %16, -1
  store i32 %17, ptr %5, align 4, !tbaa !9
  %18 = icmp sge i32 %17, 0
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %34

20:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %21 = getelementptr inbounds %"class.juce::MPESynthesiser", ptr %11, i32 0, i32 1
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = call noundef ptr @_ZNK4juce10OwnedArrayINS_19MPESynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %21, i32 noundef %22) #5
  store ptr %23, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %1, i64 40, i1 false), !tbaa.struct !11
  %25 = call noundef zeroext i1 @_ZNK4juce19MPESynthesiserVoice22isCurrentlyPlayingNoteENS_7MPENoteE(ptr noundef nonnull align 8 dereferenceable(60) %24, ptr noundef byval(%"struct.juce::MPENote") align 8 %7) #5
  br i1 %25, label %26, label %33

26:                                               ; preds = %20
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %1, i64 40, i1 false), !tbaa.struct !11
  invoke void @_ZN4juce14MPESynthesiser9stopVoiceEPNS_19MPESynthesiserVoiceENS_7MPENoteEb(ptr noundef nonnull align 8 dereferenceable(144) %11, ptr noundef %27, ptr noundef byval(%"struct.juce::MPENote") align 8 %8, i1 noundef zeroext true)
          to label %28 unwind label %29

28:                                               ; preds = %26
  br label %33

29:                                               ; preds = %26
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %9, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %35

33:                                               ; preds = %28, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %15, !llvm.loop !19

34:                                               ; preds = %19
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  ret void

35:                                               ; preds = %29
  %36 = load ptr, ptr %9, align 8
  %37 = load i32, ptr %10, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{i64 0, i64 2, !12, i64 2, i64 1, !14, i64 3, i64 1, !14, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 8, !15, i64 32, i64 4, !17}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"_ZTSN4juce7MPENote8KeyStateE", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%"struct.juce::MPENote" = type <{ i16, i8, i8, %"class.juce::MPEValue", %"class.juce::MPEValue", %"class.juce::MPEValue", %"class.juce::MPEValue", %"class.juce::MPEValue", double, i32, [4 x i8] }>
%"class.juce::MPEValue" = type { i32 }
%"class.juce::GenericScopedLock" = type { ptr }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4juce19MPESynthesiserVoice22isCurrentlyPlayingNoteENS_7MPENoteE(ptr noundef nonnull align 8 dereferenceable(60), ptr noundef byval(%"struct.juce::MPENote") align 8) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce14MPESynthesiser9stopVoiceEPNS_19MPESynthesiserVoiceENS_7MPENoteEb(ptr noundef nonnull align 8 dereferenceable(144), ptr noundef, ptr noundef byval(%"struct.juce::MPENote") align 8, i1 noundef zeroext) local_unnamed_addr #3 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce14MPESynthesiser12noteReleasedENS_7MPENoteE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr nocapture noundef readonly byval(%"struct.juce::MPENote") align 8 %1) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.juce::GenericScopedLock", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %4 = getelementptr inbounds i8, ptr %0, i64 104
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(40) %4) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = call noundef i32 @_ZNK4juce10OwnedArrayINS_19MPESynthesiserVoiceENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %5) #4
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %14, %2
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret void

.lr.ph:                                           ; preds = %2, %14
  %.in = phi i32 [ %8, %14 ], [ %6, %2 ]
  %8 = add nsw i32 %.in, -1
  %9 = call noundef ptr @_ZNK4juce10OwnedArrayINS_19MPESynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %5, i32 noundef %8) #4
  %10 = call noundef zeroext i1 @_ZNK4juce19MPESynthesiserVoice22isCurrentlyPlayingNoteENS_7MPENoteE(ptr noundef nonnull align 8 dereferenceable(60) %9, ptr noundef nonnull byval(%"struct.juce::MPENote") align 8 %1) #4
  br i1 %10, label %11, label %14

11:                                               ; preds = %.lr.ph
  invoke void @_ZN4juce14MPESynthesiser9stopVoiceEPNS_19MPESynthesiserVoiceENS_7MPENoteEb(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull %9, ptr noundef nonnull byval(%"struct.juce::MPENote") align 8 %1, i1 noundef zeroext true)
          to label %14 unwind label %12

12:                                               ; preds = %11
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  resume { ptr, i32 } %13

14:                                               ; preds = %11, %.lr.ph
  %15 = icmp ugt i32 %.in, 1
  br i1 %15, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass