; LLVM IR from glaretechnologies/substrata :: resonance-audio/resonance_audio/dsp (mixer)

; 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.NullLogger = type { i8 }
%"class.vraudio::Mixer" = type { %"class.vraudio::AudioBuffer", 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 @_ZN7vraudio5Mixer8AddInputERKNS_11AudioBufferE(ptr noundef nonnull align 8 dereferenceable(73) %0, ptr noundef nonnull align 8 dereferenceable(68) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %class.NullLogger, align 1
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #5
  %11 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %5)
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = call noundef i64 @_ZNK7vraudio11AudioBuffer12num_channelsEv(ptr noundef nonnull align 8 dereferenceable(68) %12)
  store i64 %13, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %14 = getelementptr inbounds %"class.vraudio::Mixer", ptr %10, i32 0, i32 0
  %15 = call noundef i64 @_ZNK7vraudio11AudioBuffer12num_channelsEv(ptr noundef nonnull align 8 dereferenceable(68) %14)
  store i64 %15, ptr %8, align 8, !tbaa !9
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %17 = load i64, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  store i64 %17, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %37, %2
  %19 = load i64, ptr %9, align 8, !tbaa !9
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %40

23:                                               ; preds = %18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %9, align 8, !tbaa !9
  %26 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %24, i64 noundef %25)
  %27 = call noundef zeroext i1 @_ZNK7vraudio11ChannelView9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(17) %26)
  br i1 %27, label %28, label %36

28:                                               ; preds = %23
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %29, i64 noundef %30)
  %32 = getelementptr inbounds %"class.vraudio::Mixer", ptr %10, i32 0, i32 0
  %33 = load i64, ptr %9, align 8, !tbaa !9
  %34 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %32, i64 noundef %33)
  %35 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewpLERKS0_(ptr noundef nonnull align 8 dereferenceable(17) %34, ptr noundef nonnull align 8 dereferenceable(17) %31)
  br label %36

36:                                               ; preds = %28, %23
  br label %37

37:                                               ; preds = %36
  %38 = load i64, ptr %9, align 8, !tbaa !9
  %39 = add i64 %38, 1
  store i64 %39, ptr %9, align 8, !tbaa !9
  br label %18, !llvm.loop !11

40:                                               ; preds = %22
  %41 = getelementptr inbounds %"class.vraudio::Mixer", ptr %10, i32 0, i32 1
  store i8 0, ptr %41, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  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: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1)) #0 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZNK7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7vraudio11ChannelView9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(17)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68), i64 noundef) #0 align 2

declare noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewpLERKS0_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) #4

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 = { 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 #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 = { "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 }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !25, i64 72}
!14 = !{!"_ZTSN7vraudio5MixerE", !15, i64 0, !25, i64 72}
!15 = !{!"_ZTSN7vraudio11AudioBufferE", !10, i64 0, !16, i64 8, !10, i64 32, !20, i64 40, !24, i64 64}
!16 = !{!"_ZTSSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTSSt6vectorIN7vraudio11ChannelViewESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIN7vraudio11ChannelViewESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!24 = !{!"int", !7, i64 0}
!25 = !{!"bool", !7, i64 0}


; 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.NullLogger = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7vraudio5Mixer8AddInputERKNS_11AudioBufferE(ptr noundef nonnull align 8 dereferenceable(73) %0, ptr noundef nonnull align 8 dereferenceable(68) %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %class.NullLogger, align 1
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #5
  %6 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %3)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %7 = call noundef i64 @_ZNK7vraudio11AudioBuffer12num_channelsEv(ptr noundef nonnull align 8 dereferenceable(68) %1)
  store i64 %7, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %8 = call noundef i64 @_ZNK7vraudio11AudioBuffer12num_channelsEv(ptr noundef nonnull align 8 dereferenceable(68) %0)
  store i64 %8, ptr %5, align 8, !tbaa !5
  %9 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %10 = load i64, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %.not = icmp eq i64 %10, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %18, %2
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  store i8 0, ptr %11, align 8, !tbaa !9
  ret void

.lr.ph:                                           ; preds = %2, %18
  %.09 = phi i64 [ %19, %18 ], [ 0, %2 ]
  %12 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %1, i64 noundef %.09)
  %13 = call noundef zeroext i1 @_ZNK7vraudio11ChannelView9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(17) %12)
  br i1 %13, label %14, label %18

14:                                               ; preds = %.lr.ph
  %15 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZNK7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %1, i64 noundef %.09)
  %16 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68) %0, i64 noundef %.09)
  %17 = call noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewpLERKS0_(ptr noundef nonnull align 8 dereferenceable(17) %16, ptr noundef nonnull align 8 dereferenceable(17) %15)
  br label %18

18:                                               ; preds = %.lr.ph, %14
  %19 = add nuw i64 %.09, 1
  %exitcond.not = icmp eq i64 %19, %10
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !23
}

; 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 uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #0 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZNK7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7vraudio11ChannelView9IsEnabledEv(ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11AudioBufferixEm(ptr noundef nonnull align 8 dereferenceable(68), i64 noundef) local_unnamed_addr #0 align 2

declare noundef nonnull align 8 dereferenceable(17) ptr @_ZN7vraudio11ChannelViewpLERKS0_(ptr noundef nonnull align 8 dereferenceable(17), ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #4

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 = { 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 #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 = { "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 }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !22, i64 72}
!10 = !{!"_ZTSN7vraudio5MixerE", !11, i64 0, !22, i64 72}
!11 = !{!"_ZTSN7vraudio11AudioBufferE", !6, i64 0, !12, i64 8, !6, i64 32, !17, i64 40, !21, i64 64}
!12 = !{!"_ZTSSt6vectorIfN7vraudio16AlignedAllocatorIfLm64EEEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIfN7vraudio16AlignedAllocatorIfLm64EEEE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !7, i64 0}
!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", !16, i64 0, !16, i64 8, !16, i64 16}
!21 = !{!"int", !7, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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