; 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::MidiBuffer::Iterator" = type { ptr, ptr }
%"class.juce::MidiMessage" = type <{ %"union.juce::MidiMessage::PackedData", double, i32, [4 x i8] }>
%"union.juce::MidiMessage::PackedData" = type { ptr }
%"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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4juce10MidiBuffer8Iterator12getNextEventERNS_11MidiMessageERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 4 dereferenceable(4)) #2 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 nounwind uwtable
declare dso_local noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce10MidiBuffer8addEventERKNS_11MidiMessageEi(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(20), i32 noundef) #3 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce17MidiKeyboardState20processNextMidiEventERKNS_11MidiMessageE(ptr noundef nonnull align 8 dereferenceable(344), ptr noundef nonnull align 8 dereferenceable(20)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce17MidiKeyboardState21processNextMidiBufferERNS_10MidiBufferEiib(ptr noundef nonnull align 8 dereferenceable(344) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca %"class.juce::MidiBuffer::Iterator", align 8
  %12 = alloca %"class.juce::MidiMessage", align 8
  %13 = alloca i32, align 4
  %14 = alloca %"class.juce::GenericScopedLock", align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca %"class.juce::MidiBuffer::Iterator", align 8
  %18 = alloca i32, align 4
  %19 = alloca double, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  %21 = zext i1 %4 to i8
  store i8 %21, ptr %10, align 1, !tbaa !11
  %22 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN4juce10MidiBuffer8IteratorC1ERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(24) %23) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #4
  call void @_ZN4juce11MidiMessageC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %24 = getelementptr inbounds %"class.juce::MidiKeyboardState", ptr %22, i32 0, i32 0
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(40) %24) #4
  br label %25

25:                                               ; preds = %28, %5
  %26 = call noundef zeroext i1 @_ZN4juce10MidiBuffer8Iterator12getNextEventERNS_11MidiMessageERi(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(20) %12, ptr noundef nonnull align 4 dereferenceable(4) %13) #4
  br i1 %26, label %27, label %33

27:                                               ; preds = %25
  invoke void @_ZN4juce17MidiKeyboardState20processNextMidiEventERKNS_11MidiMessageE(ptr noundef nonnull align 8 dereferenceable(344) %22, ptr noundef nonnull align 8 dereferenceable(20) %12)
          to label %28 unwind label %29

28:                                               ; preds = %27
  br label %25, !llvm.loop !13

29:                                               ; preds = %27
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %15, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %16, align 4
  br label %74

33:                                               ; preds = %25
  %34 = load i8, ptr %10, align 1, !tbaa !11, !range !15, !noundef !16
  %35 = trunc i8 %34 to i1
  br i1 %35, label %36, label %72

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  %37 = getelementptr inbounds %"class.juce::MidiKeyboardState", ptr %22, i32 0, i32 2
  call void @_ZN4juce10MidiBuffer8IteratorC1ERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(24) %37) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %38 = getelementptr inbounds %"class.juce::MidiKeyboardState", ptr %22, i32 0, i32 2
  %39 = call noundef i32 @_ZNK4juce10MidiBuffer17getFirstEventTimeEv(ptr noundef nonnull align 8 dereferenceable(24) %38) #4
  store i32 %39, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = sitofp i32 %40 to double
  %42 = getelementptr inbounds %"class.juce::MidiKeyboardState", ptr %22, i32 0, i32 2
  %43 = call noundef i32 @_ZNK4juce10MidiBuffer16getLastEventTimeEv(ptr noundef nonnull align 8 dereferenceable(24) %42) #4
  %44 = add nsw i32 %43, 1
  %45 = load i32, ptr %18, align 4, !tbaa !9
  %46 = sub nsw i32 %44, %45
  %47 = sitofp i32 %46 to double
  %48 = fdiv double %41, %47
  store double %48, ptr %19, align 8, !tbaa !17
  br label %49

49:                                               ; preds = %66, %36
  %50 = call noundef zeroext i1 @_ZN4juce10MidiBuffer8Iterator12getNextEventERNS_11MidiMessageERi(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(20) %12, ptr noundef nonnull align 4 dereferenceable(4) %13) #4
  br i1 %50, label %51, label %71

51:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = sub nsw i32 %52, 1
  %54 = load i32, ptr %13, align 4, !tbaa !9
  %55 = load i32, ptr %18, align 4, !tbaa !9
  %56 = sub nsw i32 %54, %55
  %57 = sitofp i32 %56 to double
  %58 = load double, ptr %19, align 8, !tbaa !17
  %59 = fmul double %57, %58
  %60 = call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %59) #4
  %61 = call noundef i32 @_ZN4juce6jlimitIiEET_S1_S1_S1_(i32 noundef 0, i32 noundef %53, i32 noundef %60) #4
  store i32 %61, ptr %20, align 4, !tbaa !9
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = load i32, ptr %20, align 4, !tbaa !9
  %65 = add nsw i32 %63, %64
  invoke void @_ZN4juce10MidiBuffer8addEventERKNS_11MidiMessageEi(ptr noundef nonnull align 8 dereferenceable(24) %62, ptr noundef nonnull align 8 dereferenceable(20) %12, i32 noundef %65)
          to label %66 unwind label %67

66:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  br label %49, !llvm.loop !19

67:                                               ; preds = %51
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %15, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  br label %74

71:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  br label %72

72:                                               ; preds = %71, %33
  %73 = getelementptr inbounds %"class.juce::MidiKeyboardState", ptr %22, i32 0, i32 2
  call void @_ZN4juce10MidiBuffer5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %73) #4
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @_ZN4juce11MidiMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %12) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #4
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  ret void

74:                                               ; preds = %67, %29
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @_ZN4juce11MidiMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %12) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #4
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  br label %75

75:                                               ; preds = %74
  %76 = load ptr, ptr %15, align 8
  %77 = load i32, ptr %16, align 4
  %78 = insertvalue { ptr, i32 } poison, ptr %76, 0
  %79 = insertvalue { ptr, i32 } %78, i32 %77, 1
  resume { ptr, i32 } %79
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4juce6jlimitIiEET_S1_S1_S1_(i32 noundef, i32 noundef, i32 noundef) #2

declare void @_ZN4juce10MidiBuffer8IteratorC1ERKS0_(ptr, ptr)

declare void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr)

declare void @_ZN4juce11MidiMessageC1Ev(ptr)

declare void @_ZN4juce11MidiMessageD1Ev(ptr)

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 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 = !{!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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = distinct !{!19, !14}


; 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::MidiBuffer::Iterator" = type { ptr, ptr }
%"class.juce::MidiMessage" = type <{ %"union.juce::MidiMessage::PackedData", double, i32, [4 x i8] }>
%"union.juce::MidiMessage::PackedData" = type { ptr }
%"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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4juce10MidiBuffer8Iterator12getNextEventERNS_11MidiMessageERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(20), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 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 i32 @_ZN4juce10roundToIntIdEEiT_(double noundef) local_unnamed_addr #2

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce17MidiKeyboardState21processNextMidiBufferERNS_10MidiBufferEiib(ptr noundef nonnull align 8 dereferenceable(344) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.juce::MidiBuffer::Iterator", align 8
  %7 = alloca %"class.juce::MidiMessage", align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.juce::GenericScopedLock", align 8
  %10 = alloca %"class.juce::MidiBuffer::Iterator", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @_ZN4juce10MidiBuffer8IteratorC1ERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #4
  call void @_ZN4juce11MidiMessageC1Ev(ptr noundef nonnull align 8 dereferenceable(20) %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(40) %0) #4
  br label %11

11:                                               ; preds = %13, %5
  %12 = call noundef zeroext i1 @_ZN4juce10MidiBuffer8Iterator12getNextEventERNS_11MidiMessageERi(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(20) %7, ptr noundef nonnull align 4 dereferenceable(4) %8) #4
  br i1 %12, label %13, label %16

13:                                               ; preds = %11
  invoke void @_ZN4juce17MidiKeyboardState20processNextMidiEventERKNS_11MidiMessageE(ptr noundef nonnull align 8 dereferenceable(344) %0, ptr noundef nonnull align 8 dereferenceable(20) %7)
          to label %11 unwind label %14, !llvm.loop !5

14:                                               ; preds = %13
  %15 = landingpad { ptr, i32 }
          cleanup
  br label %41

16:                                               ; preds = %11
  br i1 %4, label %17, label %39

17:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %10) #4
  %18 = getelementptr inbounds i8, ptr %0, i64 296
  call void @_ZN4juce10MidiBuffer8IteratorC1ERKS0_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(24) %18) #4
  %19 = call noundef i32 @_ZNK4juce10MidiBuffer17getFirstEventTimeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #4
  %20 = sitofp i32 %3 to double
  %21 = call noundef i32 @_ZNK4juce10MidiBuffer16getLastEventTimeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #4
  %reass.sub = sub i32 %21, %19
  %22 = add i32 %reass.sub, 1
  %23 = sitofp i32 %22 to double
  %24 = fdiv double %20, %23
  %25 = add nsw i32 %3, -1
  br label %26

26:                                               ; preds = %28, %17
  %27 = call noundef zeroext i1 @_ZN4juce10MidiBuffer8Iterator12getNextEventERNS_11MidiMessageERi(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(20) %7, ptr noundef nonnull align 4 dereferenceable(4) %8) #4
  br i1 %27, label %28, label %38

28:                                               ; preds = %26
  %29 = load i32, ptr %8, align 4, !tbaa !7
  %30 = sub nsw i32 %29, %19
  %31 = sitofp i32 %30 to double
  %32 = fmul double %24, %31
  %33 = call noundef i32 @_ZN4juce10roundToIntIdEEiT_(double noundef %32) #4
  %34 = call noundef i32 @_ZN4juce6jlimitIiEET_S1_S1_S1_(i32 noundef 0, i32 noundef %25, i32 noundef %33) #4
  %35 = add nsw i32 %34, %2
  invoke void @_ZN4juce10MidiBuffer8addEventERKNS_11MidiMessageEi(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(20) %7, i32 noundef %35)
          to label %26 unwind label %36, !llvm.loop !11

36:                                               ; preds = %28
  %37 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #4
  br label %41

38:                                               ; preds = %26
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %10) #4
  br label %39

39:                                               ; preds = %38, %16
  %40 = getelementptr inbounds i8, ptr %0, i64 296
  call void @_ZN4juce10MidiBuffer5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %40) #4
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @_ZN4juce11MidiMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #4
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  ret void

41:                                               ; preds = %36, %14
  %.pn = phi { ptr, i32 } [ %15, %14 ], [ %37, %36 ]
  call void @_ZN4juce17GenericScopedLockINS_15CriticalSectionEED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @_ZN4juce11MidiMessageD1Ev(ptr noundef nonnull align 8 dereferenceable(20) %7) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #4
  call void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4juce6jlimitIiEET_S1_S1_S1_(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @_ZN4juce10MidiBuffer8IteratorC1ERKS0_(ptr, ptr) local_unnamed_addr

declare void @_ZN4juce10MidiBuffer8IteratorD1Ev(ptr) local_unnamed_addr

declare void @_ZN4juce11MidiMessageC1Ev(ptr) local_unnamed_addr

declare void @_ZN4juce11MidiMessageD1Ev(ptr) local_unnamed_addr

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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,ReassociatePass,SROAPass,SimplifyCFGPass