; LLVM IR from glaretechnologies/substrata :: resonance-audio/resonance_audio/base (audio_buffer)

; 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.vraudio::ChannelView" = type <{ ptr, i64, i8, [7 x i8] }>
%"class.vraudio::AudioBuffer" = type <{ i64, %"class.std::vector", i64, %"class.std::vector.0", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl" }
%"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl" = type { %"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl_data" }
%"struct.std::_Vector_base<float, vraudio::AlignedAllocator<float, 64>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl" }
%"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl" = type { %"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vraudio::ChannelView, std::allocator<vraudio::ChannelView>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7vraudio11AudioBuffer16InitChannelViewsEm(ptr noundef nonnull align 8 dereferenceable(68) %0, i64 noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca %"class.vraudio::ChannelView", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %10 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 0
  %11 = load i64, ptr %10, align 8, !tbaa !11
  %12 = call noundef i64 @_ZN7vraudio25FindNextAlignedArrayIndexEmmm(i64 noundef %11, i64 noundef 4, i64 noundef 64)
  store i64 %12, ptr %5, align 8, !tbaa !9
  %13 = load i64, ptr %4, align 8, !tbaa !9
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = mul i64 %13, %14
  %16 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 2
  store i64 %15, ptr %16, align 8, !tbaa !22
  %17 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 1
  %18 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 2
  %19 = load i64, ptr %18, align 8, !tbaa !22
  call void @_ZNSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %19)
  %20 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 3
  call void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %20) #4
  %21 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 3
  %22 = load i64, ptr %4, align 8, !tbaa !9
  call void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %22)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %23 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 1
  %24 = call noundef ptr @_ZNSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #4
  store ptr %24, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %38, %2
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = load i64, ptr %4, align 8, !tbaa !9
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %41

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #4
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 0
  %33 = load i64, ptr %32, align 8, !tbaa !11
  call void @_ZN7vraudio11ChannelViewC2EPfm(ptr noundef nonnull align 8 dereferenceable(17) %8, ptr noundef %31, i64 noundef %33)
  %34 = getelementptr inbounds %"class.vraudio::AudioBuffer", ptr %9, i32 0, i32 3
  call void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %34, ptr noundef nonnull align 8 dereferenceable(17) %8)
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds float, ptr %36, i64 %35
  store ptr %37, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #4
  br label %38

38:                                               ; preds = %30
  %39 = load i64, ptr %7, align 8, !tbaa !9
  %40 = add i64 %39, 1
  store i64 %40, ptr %7, align 8, !tbaa !9
  br label %25, !llvm.loop !23

41:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare noundef i64 @_ZN7vraudio25FindNextAlignedArrayIndexEmmm(i64 noundef, i64 noundef, i64 noundef) #2

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7vraudio11ChannelViewC2EPfm(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef, i64 noundef) unnamed_addr #3 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN7vraudio11AudioBufferE", !10, i64 0, !13, i64 8, !10, i64 32, !17, i64 40, !21, i64 64}
!13 = !{!"_ZTSSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!"_ZTSSt6vectorIN7vraudio11ChannelViewESaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"int", !7, i64 0}
!22 = !{!12, !10, i64 32}
!23 = distinct !{!23, !24}
!24 = !{!"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.vraudio::ChannelView" = type <{ ptr, i64, i8, [7 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7vraudio11AudioBuffer16InitChannelViewsEm(ptr noundef nonnull align 8 dereferenceable(68) %0, i64 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %"class.vraudio::ChannelView", align 8
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = tail call noundef i64 @_ZN7vraudio25FindNextAlignedArrayIndexEmmm(i64 noundef %4, i64 noundef 4, i64 noundef 64)
  %6 = mul i64 %5, %1
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %6, ptr %7, align 8, !tbaa !20
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZNSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %6)
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #4
  tail call void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %1)
  %10 = tail call noundef ptr @_ZNSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #4
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.011 = phi i64 [ %13, %.lr.ph ], [ 0, %2 ]
  %.0910 = phi ptr [ %12, %.lr.ph ], [ %10, %2 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  %11 = load i64, ptr %0, align 8, !tbaa !5
  call void @_ZN7vraudio11ChannelViewC2EPfm(ptr noundef nonnull align 8 dereferenceable(17) %3, ptr noundef %.0910, i64 noundef %11)
  call void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(17) %3)
  %12 = getelementptr inbounds float, ptr %.0910, i64 %5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  %13 = add nuw i64 %.011, 1
  %exitcond.not = icmp eq i64 %13, %1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !21
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare noundef i64 @_ZN7vraudio25FindNextAlignedArrayIndexEmmm(i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7vraudio11ChannelViewC2EPfm(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef, i64 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN7vraudio11ChannelViewESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !7, i64 0}
!6 = !{!"_ZTSN7vraudio11AudioBufferE", !7, i64 0, !10, i64 8, !7, i64 32, !15, i64 40, !19, i64 64}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTSSt6vectorIN7vraudio11ChannelViewESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!19 = !{!"int", !8, i64 0}
!20 = !{!6, !7, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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