; 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::GenericScopedLock" = type { ptr }
%"class.juce::Synthesiser" = type { ptr, %"class.juce::CriticalSection", %"class.juce::OwnedArray", %"class.juce::ReferenceCountedArray", [16 x i32], double, i32, i32, i8, i8, [6 x i8], %"class.juce::BigInteger" }
%"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 }
%"class.juce::OwnedArray" = type { %"class.juce::ArrayAllocationBase.3", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.3" = type <{ %"class.juce::HeapBlock.4", i32, [4 x i8] }>
%"class.juce::HeapBlock.4" = type { ptr }
%"class.juce::ReferenceCountedArray" = type { %"class.juce::ArrayAllocationBase.6", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.6" = type <{ %"class.juce::HeapBlock.7", i32, [4 x i8] }>
%"class.juce::HeapBlock.7" = type { ptr }
%"class.juce::BigInteger" = type <{ %"class.juce::HeapBlock.9", [4 x i32], i64, i32, i8, [3 x i8] }>
%"class.juce::HeapBlock.9" = type { ptr }
%"class.juce::SynthesiserVoice" = type { ptr, double, i32, i32, i32, %"class.juce::ReferenceCountedObjectPtr", i8, i8, i8, [5 x i8], %"class.juce::AudioBuffer" }
%"class.juce::ReferenceCountedObjectPtr" = type { ptr }
%"class.juce::AudioBuffer" = type <{ i32, i32, i64, ptr, %"class.juce::HeapBlock.0", [32 x ptr], i8, [7 x i8] }>
%"class.juce::HeapBlock.0" = type { 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce11Synthesiser9stopVoiceEPNS_16SynthesiserVoiceEfb(ptr noundef nonnull align 8 dereferenceable(224), ptr noundef, float noundef, i1 noundef zeroext) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce11Synthesiser20handleSostenutoPedalEib(ptr noundef nonnull align 8 dereferenceable(224) %0, i32 noundef %1, i1 noundef zeroext %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca %"class.juce::GenericScopedLock", align 8
  %8 = alloca i32, align 4
  %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 i32 %1, ptr %5, align 4, !tbaa !9
  %12 = zext i1 %2 to i8
  store i8 %12, ptr %6, align 1, !tbaa !11
  %13 = load ptr, ptr %4, align 8
  br label %14

14:                                               ; preds = %3
  br label %15

15:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %16 = getelementptr inbounds %"class.juce::Synthesiser", ptr %13, i32 0, i32 1
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(40) %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %17 = getelementptr inbounds %"class.juce::Synthesiser", ptr %13, i32 0, i32 2
  %18 = call noundef i32 @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %17) #3
  store i32 %18, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %55, %15
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr %8, align 4, !tbaa !9
  %22 = icmp sge i32 %21, 0
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %56

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %25 = getelementptr inbounds %"class.juce::Synthesiser", ptr %13, i32 0, i32 2
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = call noundef ptr @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %25, i32 noundef %26) #3
  store ptr %27, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = load ptr, ptr %28, align 8, !tbaa !13
  %31 = getelementptr inbounds ptr, ptr %30, i64 13
  %32 = load ptr, ptr %31, align 8
  %33 = invoke noundef zeroext i1 %32(ptr noundef nonnull align 8 dereferenceable(344) %28, i32 noundef %29)
          to label %34 unwind label %41

34:                                               ; preds = %24
  br i1 %33, label %35, label %55

35:                                               ; preds = %34
  %36 = load i8, ptr %6, align 1, !tbaa !11, !range !15, !noundef !16
  %37 = trunc i8 %36 to i1
  br i1 %37, label %38, label %45

38:                                               ; preds = %35
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.juce::SynthesiserVoice", ptr %39, i32 0, i32 8
  store i8 1, ptr %40, align 2, !tbaa !17
  br label %54

41:                                               ; preds = %50, %24
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %10, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %57

45:                                               ; preds = %35
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.juce::SynthesiserVoice", ptr %46, i32 0, i32 8
  %48 = load i8, ptr %47, align 2, !tbaa !17, !range !15, !noundef !16
  %49 = trunc i8 %48 to i1
  br i1 %49, label %50, label %53

50:                                               ; preds = %45
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  invoke void @_ZN4juce11Synthesiser9stopVoiceEPNS_16SynthesiserVoiceEfb(ptr noundef nonnull align 8 dereferenceable(224) %13, ptr noundef %51, float noundef 1.000000e+00, i1 noundef zeroext true)
          to label %52 unwind label %41

52:                                               ; preds = %50
  br label %53

53:                                               ; preds = %52, %45
  br label %54

54:                                               ; preds = %53, %38
  br label %55

55:                                               ; preds = %54, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %19, !llvm.loop !24

56:                                               ; preds = %23
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void

57:                                               ; preds = %41
  %58 = load ptr, ptr %10, align 8
  %59 = load i32, ptr %11, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

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 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !12, i64 42}
!18 = !{!"_ZTSN4juce16SynthesiserVoiceE", !19, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !20, i64 32, !12, i64 40, !12, i64 41, !12, i64 42, !21, i64 48}
!19 = !{!"double", !7, i64 0}
!20 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_16SynthesiserSoundEEE", !6, i64 0}
!21 = !{!"_ZTSN4juce11AudioBufferIfEE", !10, i64 0, !10, i64 4, !22, i64 8, !6, i64 16, !23, i64 24, !7, i64 32, !12, i64 288}
!22 = !{!"long", !7, i64 0}
!23 = !{!"_ZTSN4juce9HeapBlockIcLb1EEE", !6, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"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"

%"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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_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_16SynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce11Synthesiser9stopVoiceEPNS_16SynthesiserVoiceEfb(ptr noundef nonnull align 8 dereferenceable(224), ptr noundef, float noundef, i1 noundef zeroext) local_unnamed_addr #2 align 2

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

.lr.ph:                                           ; preds = %3
  %9 = add nsw i32 %7, -1
  br i1 %2, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %19
  %10 = phi i32 [ %20, %19 ], [ %9, %.lr.ph ]
  %11 = call noundef ptr @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %6, i32 noundef %10) #3
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 104
  %14 = load ptr, ptr %13, align 8
  %15 = invoke noundef zeroext i1 %14(ptr noundef nonnull align 8 dereferenceable(344) %11, i32 noundef %1)
          to label %16 unwind label %.split.us

16:                                               ; preds = %.lr.ph.split.us
  br i1 %15, label %17, label %19

17:                                               ; preds = %16
  %18 = getelementptr inbounds i8, ptr %11, i64 42
  store i8 1, ptr %18, align 2, !tbaa !8
  br label %19

19:                                               ; preds = %17, %16
  %20 = add nsw i32 %10, -1
  %21 = icmp sgt i32 %10, 0
  br i1 %21, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !19

.split.us:                                        ; preds = %.lr.ph.split.us
  %22 = landingpad { ptr, i32 }
          cleanup
  br label %35

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

.lr.ph.split:                                     ; preds = %.lr.ph, %37
  %23 = phi i32 [ %38, %37 ], [ %9, %.lr.ph ]
  %24 = call noundef ptr @_ZNK4juce10OwnedArrayINS_16SynthesiserVoiceENS_20DummyCriticalSectionEE12getUncheckedEi(ptr noundef nonnull align 8 dereferenceable(20) %6, i32 noundef %23) #3
  %25 = load ptr, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 104
  %27 = load ptr, ptr %26, align 8
  %28 = invoke noundef zeroext i1 %27(ptr noundef nonnull align 8 dereferenceable(344) %24, i32 noundef %1)
          to label %29 unwind label %.split

29:                                               ; preds = %.lr.ph.split
  br i1 %28, label %30, label %37

30:                                               ; preds = %29
  %31 = getelementptr inbounds i8, ptr %24, i64 42
  %32 = load i8, ptr %31, align 2, !tbaa !8, !range !21, !noundef !22
  %33 = trunc nuw i8 %32 to i1
  br i1 %33, label %36, label %37

.split:                                           ; preds = %36, %.lr.ph.split
  %34 = landingpad { ptr, i32 }
          cleanup
  br label %35

35:                                               ; preds = %.split.us, %.split
  %.us-phi = phi { ptr, i32 } [ %34, %.split ], [ %22, %.split.us ]
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  resume { ptr, i32 } %.us-phi

36:                                               ; preds = %30
  invoke void @_ZN4juce11Synthesiser9stopVoiceEPNS_16SynthesiserVoiceEfb(ptr noundef nonnull align 8 dereferenceable(224) %0, ptr noundef nonnull %24, float noundef 1.000000e+00, i1 noundef zeroext true)
          to label %37 unwind label %.split

37:                                               ; preds = %36, %30, %29
  %38 = add nsw i32 %23, -1
  %39 = icmp sgt i32 %23, 0
  br i1 %39, label %.lr.ph.split, label %._crit_edge, !llvm.loop !19
}

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 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !15, i64 42}
!9 = !{!"_ZTSN4juce16SynthesiserVoiceE", !10, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !13, i64 32, !15, i64 40, !15, i64 41, !15, i64 42, !16, i64 48}
!10 = !{!"double", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"int", !11, i64 0}
!13 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_16SynthesiserSoundEEE", !14, i64 0}
!14 = !{!"any pointer", !11, i64 0}
!15 = !{!"bool", !11, i64 0}
!16 = !{!"_ZTSN4juce11AudioBufferIfEE", !12, i64 0, !12, i64 4, !17, i64 8, !14, i64 16, !18, i64 24, !11, i64 32, !15, i64 288}
!17 = !{!"long", !11, i64 0}
!18 = !{!"_ZTSN4juce9HeapBlockIcLb1EEE", !14, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{i8 0, i8 2}
!22 = !{}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass