; 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::MidiKeyboardState" = type { %"class.juce::CriticalSection", [128 x i16], %"class.juce::MidiBuffer", %"class.juce::Array.40" }
%"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::MidiBuffer" = type { %"class.juce::Array" }
%"class.juce::Array" = type { %"class.juce::ArrayAllocationBase", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase" = type <{ %"class.juce::HeapBlock", i32, [4 x i8] }>
%"class.juce::HeapBlock" = type { ptr }
%"class.juce::Array.40" = type { %"class.juce::ArrayAllocationBase.41", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.41" = type <{ %"class.juce::HeapBlock.42", i32, [4 x i8] }>
%"class.juce::HeapBlock.42" = 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: mustprogress uwtable
declare dso_local void @_ZN4juce17MidiKeyboardState7noteOffEiif(ptr noundef nonnull align 8 dereferenceable(344), i32 noundef, i32 noundef, float noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.juce::GenericScopedLock", align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %11 = getelementptr inbounds %"class.juce::MidiKeyboardState", ptr %10, i32 0, i32 0
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(40) %11) #3
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp sle i32 %12, 0
  br i1 %13, label %14, label %30

14:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %22, %14
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = icmp sle i32 %16, 16
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %29

19:                                               ; preds = %15
  %20 = load i32, ptr %6, align 4, !tbaa !9
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %10, i32 noundef %20)
          to label %21 unwind label %25

21:                                               ; preds = %19
  br label %22

22:                                               ; preds = %21
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %6, align 4, !tbaa !9
  br label %15, !llvm.loop !11

25:                                               ; preds = %19
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %7, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %48

29:                                               ; preds = %18
  br label %47

30:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %39, %30
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 128
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %46

35:                                               ; preds = %31
  %36 = load i32, ptr %4, align 4, !tbaa !9
  %37 = load i32, ptr %9, align 4, !tbaa !9
  invoke void @_ZN4juce17MidiKeyboardState7noteOffEiif(ptr noundef nonnull align 8 dereferenceable(344) %10, i32 noundef %36, i32 noundef %37, float noundef 0.000000e+00)
          to label %38 unwind label %42

38:                                               ; preds = %35
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %9, align 4, !tbaa !9
  br label %31, !llvm.loop !13

42:                                               ; preds = %35
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %7, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %48

46:                                               ; preds = %34
  br label %47

47:                                               ; preds = %46, %29
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void

48:                                               ; preds = %42, %25
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %49

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

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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: mustprogress uwtable
declare dso_local void @_ZN4juce17MidiKeyboardState7noteOffEiif(ptr noundef nonnull align 8 dereferenceable(344), i32 noundef, i32 noundef, float noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef %1) local_unnamed_addr #2 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) #3
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  %4 = icmp slt i32 %1, 1
  br i1 %4, label %.preheader.preheader, label %.preheader15

.preheader.preheader:                             ; preds = %2
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 1)
          to label %.preheader.1 unwind label %5

.preheader.1:                                     ; preds = %.preheader.preheader
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 2)
          to label %.preheader.2 unwind label %5

.preheader.2:                                     ; preds = %.preheader.1
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 3)
          to label %.preheader.3 unwind label %5

.preheader.3:                                     ; preds = %.preheader.2
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 4)
          to label %.preheader.4 unwind label %5

.preheader.4:                                     ; preds = %.preheader.3
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 5)
          to label %.preheader.5 unwind label %5

.preheader.5:                                     ; preds = %.preheader.4
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 6)
          to label %.preheader.6 unwind label %5

.preheader.6:                                     ; preds = %.preheader.5
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 7)
          to label %.preheader.7 unwind label %5

.preheader.7:                                     ; preds = %.preheader.6
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 8)
          to label %.preheader.8 unwind label %5

.preheader.8:                                     ; preds = %.preheader.7
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 9)
          to label %.preheader.9 unwind label %5

.preheader.9:                                     ; preds = %.preheader.8
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 10)
          to label %.preheader.10 unwind label %5

.preheader.10:                                    ; preds = %.preheader.9
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 11)
          to label %.preheader.11 unwind label %5

.preheader.11:                                    ; preds = %.preheader.10
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 12)
          to label %.preheader.12 unwind label %5

.preheader.12:                                    ; preds = %.preheader.11
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 13)
          to label %.preheader.13 unwind label %5

.preheader.13:                                    ; preds = %.preheader.12
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 14)
          to label %.preheader.14 unwind label %5

.preheader.14:                                    ; preds = %.preheader.13
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 15)
          to label %.preheader.15 unwind label %5

.preheader.15:                                    ; preds = %.preheader.14
  invoke void @_ZN4juce17MidiKeyboardState11allNotesOffEi(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef 16)
          to label %.loopexit unwind label %5

5:                                                ; preds = %.preheader.15, %.preheader.14, %.preheader.13, %.preheader.12, %.preheader.11, %.preheader.10, %.preheader.9, %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %6 = landingpad { ptr, i32 }
          cleanup
  br label %11

.preheader15:                                     ; preds = %2, %7
  %.017 = phi i32 [ %8, %7 ], [ 0, %2 ]
  invoke void @_ZN4juce17MidiKeyboardState7noteOffEiif(ptr noundef nonnull align 8 dereferenceable(344) %0, i32 noundef %1, i32 noundef %.017, float noundef 0.000000e+00)
          to label %7 unwind label %9

7:                                                ; preds = %.preheader15
  %8 = add nuw nsw i32 %.017, 1
  %exitcond.not = icmp eq i32 %8, 128
  br i1 %exitcond.not, label %.loopexit, label %.preheader15, !llvm.loop !5

9:                                                ; preds = %.preheader15
  %10 = landingpad { ptr, i32 }
          cleanup
  br label %11

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

11:                                               ; preds = %9, %5
  %.pn = phi { ptr, i32 } [ %6, %5 ], [ %10, %9 ]
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  resume { ptr, i32 } %.pn
}

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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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