; 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" = 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 }
%"struct.juce::MPEZone" = type { i32, i32, i32, i32 }

; 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: 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) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4juce13MPEZoneLayout14getZoneByIndexEi(ptr noundef nonnull align 8 dereferenceable(128), i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce11MPEMessages7addZoneENS_7MPEZoneE(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiBuffer") align 8, i64, i64) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce11MPEMessages13clearAllZonesEv(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiBuffer") align 8) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce11MPEMessages13setZoneLayoutERKNS_13MPEZoneLayoutE(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiBuffer") align 8 %0, ptr noundef nonnull align 8 dereferenceable(128) %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i1, align 1
  %6 = alloca %"class.juce::MidiBuffer", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.juce::MidiBuffer", align 8
  %11 = alloca %"struct.juce::MPEZone", align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i1 false, ptr %5, align 1
  call void @_ZN4juce10MidiBufferC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #4
  invoke void @_ZN4juce11MPEMessages13clearAllZonesEv(ptr dead_on_unwind writable sret(%"class.juce::MidiBuffer") align 8 %6)
          to label %12 unwind label %20

12:                                               ; preds = %2
  invoke void @_ZN4juce10MidiBuffer9addEventsERKS0_iii(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %6, i32 noundef 0, i32 noundef -1, i32 noundef 0)
          to label %13 unwind label %24

13:                                               ; preds = %12
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %39, %13
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef i32 @_ZNK4juce13MPEZoneLayout11getNumZonesEv(ptr noundef nonnull align 8 dereferenceable(128) %16) #4
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %29, label %19

19:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %51

20:                                               ; preds = %2
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %7, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %8, align 4
  br label %28

24:                                               ; preds = %12
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %7, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %8, align 4
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  br label %28

28:                                               ; preds = %24, %20
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #4
  br label %55

29:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #4
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = call noundef ptr @_ZNK4juce13MPEZoneLayout14getZoneByIndexEi(ptr noundef nonnull align 8 dereferenceable(128) %30, i32 noundef %31) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %32, i64 16, i1 false), !tbaa.struct !11
  %33 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 0
  %34 = load i64, ptr %33, align 4
  %35 = getelementptr inbounds { i64, i64 }, ptr %11, i32 0, i32 1
  %36 = load i64, ptr %35, align 4
  invoke void @_ZN4juce11MPEMessages7addZoneENS_7MPEZoneE(ptr dead_on_unwind writable sret(%"class.juce::MidiBuffer") align 8 %10, i64 %34, i64 %36)
          to label %37 unwind label %42

37:                                               ; preds = %29
  invoke void @_ZN4juce10MidiBuffer9addEventsERKS0_iii(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef 0, i32 noundef -1, i32 noundef 0)
          to label %38 unwind label %46

38:                                               ; preds = %37
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  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 %14, !llvm.loop !12

42:                                               ; preds = %29
  %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
  br label %50

46:                                               ; preds = %37
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %7, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %8, align 4
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  br label %50

50:                                               ; preds = %46, %42
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %55

51:                                               ; preds = %19
  store i1 true, ptr %5, align 1
  %52 = load i1, ptr %5, align 1
  br i1 %52, label %54, label %53

53:                                               ; preds = %51
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %54

54:                                               ; preds = %53, %51
  ret void

55:                                               ; preds = %50, %28
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %56

56:                                               ; preds = %55
  %57 = load ptr, ptr %7, align 8
  %58 = load i32, ptr %8, align 4
  %59 = insertvalue { ptr, i32 } poison, ptr %57, 0
  %60 = insertvalue { ptr, i32 } %59, i32 %58, 1
  resume { ptr, i32 } %60
}

declare void @_ZN4juce10MidiBufferC1Ev(ptr)

declare void @_ZN4juce10MidiBufferD1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9}
!12 = distinct !{!12, !13}
!13 = !{!"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::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 }

; Function Attrs: mustprogress 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce11MPEMessages7addZoneENS_7MPEZoneE(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiBuffer") align 8, i64, i64) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4juce11MPEMessages13clearAllZonesEv(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiBuffer") align 8) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce11MPEMessages13setZoneLayoutERKNS_13MPEZoneLayoutE(ptr dead_on_unwind noalias writable sret(%"class.juce::MidiBuffer") align 8 %0, ptr noundef nonnull align 8 dereferenceable(128) %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.juce::MidiBuffer", align 8
  %4 = alloca %"class.juce::MidiBuffer", align 8
  tail call void @_ZN4juce10MidiBufferC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #3
  invoke void @_ZN4juce11MPEMessages13clearAllZonesEv(ptr dead_on_unwind nonnull writable sret(%"class.juce::MidiBuffer") align 8 %3)
          to label %5 unwind label %9

5:                                                ; preds = %2
  invoke void @_ZN4juce10MidiBuffer9addEventsERKS0_iii(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %3, i32 noundef 0, i32 noundef -1, i32 noundef 0)
          to label %6 unwind label %11

6:                                                ; preds = %5
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  %7 = call noundef i32 @_ZNK4juce13MPEZoneLayout11getNumZonesEv(ptr noundef nonnull align 8 dereferenceable(128) %1) #3
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

9:                                                ; preds = %2
  %10 = landingpad { ptr, i32 }
          cleanup
  br label %13

11:                                               ; preds = %5
  %12 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %3) #3
  br label %13

13:                                               ; preds = %11, %9
  %.pn = phi { ptr, i32 } [ %12, %11 ], [ %10, %9 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  br label %25

.lr.ph:                                           ; preds = %6, %16
  %.0715 = phi i32 [ %17, %16 ], [ 0, %6 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  %14 = call noundef ptr @_ZNK4juce13MPEZoneLayout14getZoneByIndexEi(ptr noundef nonnull align 8 dereferenceable(128) %1, i32 noundef %.0715) #3
  %.sroa.0.0.copyload = load i64, ptr %14, align 4
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %14, i64 8
  %.sroa.2.0.copyload = load i64, ptr %.sroa.2.0..sroa_idx, align 4
  invoke void @_ZN4juce11MPEMessages7addZoneENS_7MPEZoneE(ptr dead_on_unwind nonnull writable sret(%"class.juce::MidiBuffer") align 8 %4, i64 %.sroa.0.0.copyload, i64 %.sroa.2.0.copyload)
          to label %15 unwind label %20

15:                                               ; preds = %.lr.ph
  invoke void @_ZN4juce10MidiBuffer9addEventsERKS0_iii(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef 0, i32 noundef -1, i32 noundef 0)
          to label %16 unwind label %22

16:                                               ; preds = %15
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  %17 = add nuw nsw i32 %.0715, 1
  %18 = call noundef i32 @_ZNK4juce13MPEZoneLayout11getNumZonesEv(ptr noundef nonnull align 8 dereferenceable(128) %1) #3
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !5

20:                                               ; preds = %.lr.ph
  %21 = landingpad { ptr, i32 }
          cleanup
  br label %24

22:                                               ; preds = %15
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  br label %24

24:                                               ; preds = %22, %20
  %.pn12 = phi { ptr, i32 } [ %23, %22 ], [ %21, %20 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  br label %25

._crit_edge:                                      ; preds = %16, %6
  ret void

25:                                               ; preds = %24, %13
  %.pn12.pn = phi { ptr, i32 } [ %.pn12, %24 ], [ %.pn, %13 ]
  call void @_ZN4juce10MidiBufferD1Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  resume { ptr, i32 } %.pn12.pn
}

declare void @_ZN4juce10MidiBufferC1Ev(ptr) local_unnamed_addr

declare void @_ZN4juce10MidiBufferD1Ev(ptr) local_unnamed_addr

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