; LLVM IR from modlfo/AudioEngine :: AudioEngine/JuceLibraryCode/juce_audio_utils.ll (ZN4juce14AudioThumbnail14createChannelsEi)

; 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::AudioThumbnail" = type { %"class.juce::AudioThumbnailBase", ptr, ptr, %"class.juce::ScopedPointer.115", %"class.juce::ScopedPointer.116", %"class.juce::OwnedArray.117", i32, i64, i64, i32, double, %"class.juce::CriticalSection" }
%"class.juce::AudioThumbnailBase" = type { %"class.juce::ChangeBroadcaster", %"class.juce::AudioFormatWriter::ThreadedWriter::IncomingDataReceiver" }
%"class.juce::ChangeBroadcaster" = type { ptr, %"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback", %"class.juce::ListenerList.20" }
%"class.juce::ChangeBroadcaster::ChangeBroadcasterCallback" = type { %"class.juce::AsyncUpdater", ptr }
%"class.juce::AsyncUpdater" = type { ptr, %"class.juce::ReferenceCountedObjectPtr.19" }
%"class.juce::ReferenceCountedObjectPtr.19" = type { ptr }
%"class.juce::ListenerList.20" = type { %"class.juce::Array.21" }
%"class.juce::Array.21" = type { %"class.juce::ArrayAllocationBase.22", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.22" = type <{ %"class.juce::HeapBlock.23", i32, [4 x i8] }>
%"class.juce::HeapBlock.23" = type { ptr }
%"class.juce::AudioFormatWriter::ThreadedWriter::IncomingDataReceiver" = type { ptr }
%"class.juce::ScopedPointer.115" = type { ptr }
%"class.juce::ScopedPointer.116" = type { ptr }
%"class.juce::OwnedArray.117" = type { %"class.juce::ArrayAllocationBase.118", i32, [4 x i8] }
%"class.juce::ArrayAllocationBase.118" = type <{ %"class.juce::HeapBlock.119", i32, [4 x i8] }>
%"class.juce::HeapBlock.119" = 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 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce14AudioThumbnail14createChannelsEi(ptr noundef nonnull align 8 dereferenceable(200) %0, i32 noundef %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  br label %8

8:                                                ; preds = %18, %2
  %9 = getelementptr inbounds %"class.juce::AudioThumbnail", ptr %7, i32 0, i32 5
  %10 = call noundef i32 @_ZNK4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %9) #5
  %11 = getelementptr inbounds %"class.juce::AudioThumbnail", ptr %7, i32 0, i32 9
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp slt i32 %10, %12
  br i1 %13, label %14, label %24

14:                                               ; preds = %8
  %15 = getelementptr inbounds %"class.juce::AudioThumbnail", ptr %7, i32 0, i32 5
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 32) #6
  %17 = load i32, ptr %4, align 4, !tbaa !9
  invoke void @_ZN4juce14AudioThumbnail9ThumbDataC2Ei(ptr noundef nonnull align 8 dereferenceable(28) %16, i32 noundef %17)
          to label %18 unwind label %20

18:                                               ; preds = %14
  %19 = call noundef ptr @_ZN4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEE3addEPS2_(ptr noundef nonnull align 8 dereferenceable(20) %15, ptr noundef %16) #5
  br label %8, !llvm.loop !31

20:                                               ; preds = %14
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %5, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %16, i64 noundef 32) #7
  br label %25

24:                                               ; preds = %8
  ret void

25:                                               ; preds = %20
  %26 = load ptr, ptr %5, align 8
  %27 = load i32, ptr %6, align 4
  %28 = insertvalue { ptr, i32 } poison, ptr %26, 0
  %29 = insertvalue { ptr, i32 } %28, i32 %27, 1
  resume { ptr, i32 } %29
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEE3addEPS2_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef) #4 align 2

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

attributes #0 = { nobuiltin allocsize(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 #1 = { nobuiltin nounwind "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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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, !10, i64 144}
!12 = !{!"_ZTSN4juce14AudioThumbnailE", !13, i64 0, !6, i64 64, !6, i64 72, !23, i64 80, !24, i64 88, !25, i64 96, !10, i64 120, !28, i64 128, !28, i64 136, !10, i64 144, !29, i64 152, !30, i64 160}
!13 = !{!"_ZTSN4juce18AudioThumbnailBaseE", !14, i64 0, !22, i64 56}
!14 = !{!"_ZTSN4juce17ChangeBroadcasterE", !15, i64 8, !18, i64 32}
!15 = !{!"_ZTSN4juce17ChangeBroadcaster25ChangeBroadcasterCallbackE", !16, i64 0, !6, i64 16}
!16 = !{!"_ZTSN4juce12AsyncUpdaterE", !17, i64 8}
!17 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_12AsyncUpdater19AsyncUpdaterMessageEEE", !6, i64 0}
!18 = !{!"_ZTSN4juce12ListenerListINS_14ChangeListenerENS_5ArrayIPS1_NS_20DummyCriticalSectionELi0EEEEE", !19, i64 0}
!19 = !{!"_ZTSN4juce5ArrayIPNS_14ChangeListenerENS_20DummyCriticalSectionELi0EEE", !20, i64 0, !10, i64 16}
!20 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_14ChangeListenerENS_20DummyCriticalSectionEEE", !21, i64 0, !10, i64 8}
!21 = !{!"_ZTSN4juce9HeapBlockIPNS_14ChangeListenerELb0EEE", !6, i64 0}
!22 = !{!"_ZTSN4juce17AudioFormatWriter14ThreadedWriter20IncomingDataReceiverE"}
!23 = !{!"_ZTSN4juce13ScopedPointerINS_14AudioThumbnail15LevelDataSourceEEE", !6, i64 0}
!24 = !{!"_ZTSN4juce13ScopedPointerINS_14AudioThumbnail12CachedWindowEEE", !6, i64 0}
!25 = !{!"_ZTSN4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEEE", !26, i64 0, !10, i64 16}
!26 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEEE", !27, i64 0, !10, i64 8}
!27 = !{!"_ZTSN4juce9HeapBlockIPNS_14AudioThumbnail9ThumbDataELb0EEE", !6, i64 0}
!28 = !{!"long long", !7, i64 0}
!29 = !{!"double", !7, i64 0}
!30 = !{!"_ZTSN4juce15CriticalSectionE", !7, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"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"

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #0

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4juce14AudioThumbnail14createChannelsEi(ptr noundef nonnull align 8 dereferenceable(200) %0, i32 noundef %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  %4 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 144
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = icmp slt i32 %4, %6
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %9
  %8 = tail call noalias noundef nonnull dereferenceable(32) ptr @_Znwm(i64 noundef 32) #6
  invoke void @_ZN4juce14AudioThumbnail9ThumbDataC2Ei(ptr noundef nonnull align 8 dereferenceable(28) %8, i32 noundef %1)
          to label %9 unwind label %14

9:                                                ; preds = %.lr.ph
  %10 = tail call noundef ptr @_ZN4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEE3addEPS2_(ptr noundef nonnull align 8 dereferenceable(20) %3, ptr noundef nonnull %8) #5
  %11 = tail call noundef i32 @_ZNK4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(20) %3) #5
  %12 = load i32, ptr %5, align 8, !tbaa !5
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !29

14:                                               ; preds = %.lr.ph
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %8, i64 noundef 32) #7
  resume { ptr, i32 } %15

._crit_edge:                                      ; preds = %9, %2
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEE3addEPS2_(ptr noundef nonnull align 8 dereferenceable(20), ptr noundef) local_unnamed_addr #4 align 2

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

attributes #0 = { nobuiltin allocsize(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 #1 = { nobuiltin nounwind "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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin 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, !19, i64 144}
!6 = !{!"_ZTSN4juce14AudioThumbnailE", !7, i64 0, !12, i64 64, !12, i64 72, !21, i64 80, !22, i64 88, !23, i64 96, !19, i64 120, !26, i64 128, !26, i64 136, !19, i64 144, !27, i64 152, !28, i64 160}
!7 = !{!"_ZTSN4juce18AudioThumbnailBaseE", !8, i64 0, !20, i64 56}
!8 = !{!"_ZTSN4juce17ChangeBroadcasterE", !9, i64 8, !15, i64 32}
!9 = !{!"_ZTSN4juce17ChangeBroadcaster25ChangeBroadcasterCallbackE", !10, i64 0, !12, i64 16}
!10 = !{!"_ZTSN4juce12AsyncUpdaterE", !11, i64 8}
!11 = !{!"_ZTSN4juce25ReferenceCountedObjectPtrINS_12AsyncUpdater19AsyncUpdaterMessageEEE", !12, i64 0}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"_ZTSN4juce12ListenerListINS_14ChangeListenerENS_5ArrayIPS1_NS_20DummyCriticalSectionELi0EEEEE", !16, i64 0}
!16 = !{!"_ZTSN4juce5ArrayIPNS_14ChangeListenerENS_20DummyCriticalSectionELi0EEE", !17, i64 0, !19, i64 16}
!17 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_14ChangeListenerENS_20DummyCriticalSectionEEE", !18, i64 0, !19, i64 8}
!18 = !{!"_ZTSN4juce9HeapBlockIPNS_14ChangeListenerELb0EEE", !12, i64 0}
!19 = !{!"int", !13, i64 0}
!20 = !{!"_ZTSN4juce17AudioFormatWriter14ThreadedWriter20IncomingDataReceiverE"}
!21 = !{!"_ZTSN4juce13ScopedPointerINS_14AudioThumbnail15LevelDataSourceEEE", !12, i64 0}
!22 = !{!"_ZTSN4juce13ScopedPointerINS_14AudioThumbnail12CachedWindowEEE", !12, i64 0}
!23 = !{!"_ZTSN4juce10OwnedArrayINS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEEE", !24, i64 0, !19, i64 16}
!24 = !{!"_ZTSN4juce19ArrayAllocationBaseIPNS_14AudioThumbnail9ThumbDataENS_20DummyCriticalSectionEEE", !25, i64 0, !19, i64 8}
!25 = !{!"_ZTSN4juce9HeapBlockIPNS_14AudioThumbnail9ThumbDataELb0EEE", !12, i64 0}
!26 = !{!"long long", !13, i64 0}
!27 = !{!"double", !13, i64 0}
!28 = !{!"_ZTSN4juce15CriticalSectionE", !13, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass